summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp23
-rw-r--r--korganizer/koagendaview.cpp15
-rw-r--r--korganizer/kofilterview.cpp23
-rw-r--r--korganizer/kofilterview.h1
-rw-r--r--korganizer/koprefs.cpp6
-rw-r--r--korganizer/koprefs.h4
-rw-r--r--microkde/kglobalsettings.cpp9
-rw-r--r--microkde/kglobalsettings.h1
8 files changed, 59 insertions, 23 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 662576f..92c1cd6 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,829 +1,830 @@
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
64//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
66 : QFrame(_agenda->viewport(),name), agenda(_agenda) 66 : QFrame(_agenda->viewport(),name), agenda(_agenda)
67{ 67{
68 setLineWidth(0); 68 setLineWidth(0);
69 setMargin(0); 69 setMargin(0);
70 setBackgroundColor(Qt::red); 70 setBackgroundColor(Qt::red);
71 minutes = new QTimer(this); 71 minutes = new QTimer(this);
72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
73 minutes->start(0, true); 73 minutes->start(0, true);
74 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
80 80
81 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
82 82
83 oldToday = -1; 83 oldToday = -1;
84} 84}
85 85
86MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
87{ 87{
88 delete minutes; 88 //delete minutes;
89} 89}
90 90
91int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
92{ 92{
93 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
94 94
95 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 96 DateList::ConstIterator it;
97 int col = 0; 97 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 99 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
102 ++col; 102 ++col;
103 } 103 }
104 104
105 return -1; 105 return -1;
106} 106}
107void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
108{ 108{
109 updateLocation(); 109 updateLocation();
110} 110}
111void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
112{ 112{
113 113
114 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 117 recalculate = true;
118 118
119 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154
155 mTimeBox->raise(); 154 mTimeBox->raise();
156 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
157 minutes->start(5000,true); 156 int secs = QTime::currentTime().second();
157 qDebug("second %d ", secs );
158 minutes->start( (60 - secs +1)*1000 ,true);
158} 159}
159 160
160 161
161//////////////////////////////////////////////////////////////////////////// 162////////////////////////////////////////////////////////////////////////////
162 163
163 164
164/* 165/*
165 Create an agenda widget with rows rows and columns columns. 166 Create an agenda widget with rows rows and columns columns.
166*/ 167*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 168KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 169 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 170 QScrollView(parent,name,f)
170{ 171{
171 172
172 mAllAgendaPopup = 0; 173 mAllAgendaPopup = 0;
173 mColumns = columns; 174 mColumns = columns;
174 mRows = rows; 175 mRows = rows;
175 mGridSpacingY = rowSize; 176 mGridSpacingY = rowSize;
176 mAllDayMode = false; 177 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 178#ifndef DESKTOP_VERSION
178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 179 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 180#endif
180 mHolidayMask = 0; 181 mHolidayMask = 0;
181 init(); 182 init();
182 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); 183 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) );
183} 184}
184 185
185/* 186/*
186 Create an agenda widget with columns columns and one row. This is used for 187 Create an agenda widget with columns columns and one row. This is used for
187 all-day events. 188 all-day events.
188*/ 189*/
189KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 190KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
190 QScrollView(parent,name,f) 191 QScrollView(parent,name,f)
191{ 192{
192 mAllAgendaPopup = 0; 193 mAllAgendaPopup = 0;
193 blockResize = false; 194 blockResize = false;
194 mColumns = columns; 195 mColumns = columns;
195 mRows = 1; 196 mRows = 1;
196 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 197 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
197 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 198 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
198 mAllDayMode = true; 199 mAllDayMode = true;
199#ifndef DESKTOP_VERSION 200#ifndef DESKTOP_VERSION
200 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 201 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
201#endif 202#endif
202 mHolidayMask = 0; 203 mHolidayMask = 0;
203 init(); 204 init();
204} 205}
205 206
206 207
207KOAgenda::~KOAgenda() 208KOAgenda::~KOAgenda()
208{ 209{
209 if(mMarcusBains) delete mMarcusBains; 210 if(mMarcusBains) delete mMarcusBains;
210 211
211} 212}
212 213
213Incidence *KOAgenda::selectedIncidence() const 214Incidence *KOAgenda::selectedIncidence() const
214{ 215{
215 return (mSelectedItem ? mSelectedItem->incidence() : 0); 216 return (mSelectedItem ? mSelectedItem->incidence() : 0);
216} 217}
217 218
218 219
219QDate KOAgenda::selectedIncidenceDate() const 220QDate KOAgenda::selectedIncidenceDate() const
220{ 221{
221 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 222 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
222} 223}
223 224
224 225
225void KOAgenda::init() 226void KOAgenda::init()
226{ 227{
227 mPopupTimer = new QTimer(this); 228 mPopupTimer = new QTimer(this);
228 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 229 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
229 230
230 mNewItemPopup = new QPopupMenu( this ); 231 mNewItemPopup = new QPopupMenu( this );
231 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 232 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
232 QString pathString = ""; 233 QString pathString = "";
233 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 234 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
234 if ( QApplication::desktop()->width() < 480 ) 235 if ( QApplication::desktop()->width() < 480 )
235 pathString += "icons16/"; 236 pathString += "icons16/";
236 } else 237 } else
237 pathString += "iconsmini/"; 238 pathString += "iconsmini/";
238 239
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
241 mNewItemPopup->insertSeparator ( ); 242 mNewItemPopup->insertSeparator ( );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 246 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 247 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 248 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
248#ifndef _WIN32_ 249#ifndef _WIN32_
249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 250 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
250 viewport()->setWFlags ( wflags); 251 viewport()->setWFlags ( wflags);
251#endif 252#endif
252 mGridSpacingX = 80; 253 mGridSpacingX = 80;
253 mResizeBorderWidth = 8; 254 mResizeBorderWidth = 8;
254 mScrollBorderWidth = 8; 255 mScrollBorderWidth = 8;
255 mScrollDelay = 30; 256 mScrollDelay = 30;
256 mScrollOffset = 10; 257 mScrollOffset = 10;
257 mPaintPixmap.resize( 20,20); 258 mPaintPixmap.resize( 20,20);
258 //enableClipper(true); 259 //enableClipper(true);
259 260
260 // Grab key strokes for keyboard navigation of agenda. Seems to have no 261 // Grab key strokes for keyboard navigation of agenda. Seems to have no
261 // effect. Has to be fixed. 262 // effect. Has to be fixed.
262 setFocusPolicy(WheelFocus); 263 setFocusPolicy(WheelFocus);
263 264
264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 265 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 266 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 267 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
267 268
268 mStartCellX = 0; 269 mStartCellX = 0;
269 mStartCellY = 0; 270 mStartCellY = 0;
270 mCurrentCellX = 0; 271 mCurrentCellX = 0;
271 mCurrentCellY = 0; 272 mCurrentCellY = 0;
272 273
273 mSelectionCellX = 0; 274 mSelectionCellX = 0;
274 mSelectionYTop = 0; 275 mSelectionYTop = 0;
275 mSelectionHeight = 0; 276 mSelectionHeight = 0;
276 277
277 mOldLowerScrollValue = -1; 278 mOldLowerScrollValue = -1;
278 mOldUpperScrollValue = -1; 279 mOldUpperScrollValue = -1;
279 280
280 mClickedItem = 0; 281 mClickedItem = 0;
281 282
282 mActionItem = 0; 283 mActionItem = 0;
283 mActionType = NOP; 284 mActionType = NOP;
284 mItemMoved = false; 285 mItemMoved = false;
285 286
286 mSelectedItem = 0; 287 mSelectedItem = 0;
287 288
288 // mItems.setAutoDelete(true); 289 // mItems.setAutoDelete(true);
289 290
290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 291 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
291 292
292 viewport()->update(); 293 viewport()->update();
293 294
294 setMinimumSize(30, 1); 295 setMinimumSize(30, 1);
295// setMaximumHeight(mGridSpacingY * mRows + 5); 296// setMaximumHeight(mGridSpacingY * mRows + 5);
296 297
297 // Disable horizontal scrollbar. This is a hack. The geometry should be 298 // Disable horizontal scrollbar. This is a hack. The geometry should be
298 // controlled in a way that the contents horizontally always fits. Then it is 299 // controlled in a way that the contents horizontally always fits. Then it is
299 // not necessary to turn off the scrollbar. 300 // not necessary to turn off the scrollbar.
300 setHScrollBarMode(AlwaysOff); 301 setHScrollBarMode(AlwaysOff);
301 if ( ! mAllDayMode ) 302 if ( ! mAllDayMode )
302 setVScrollBarMode(AlwaysOn); 303 setVScrollBarMode(AlwaysOn);
303 else 304 else
304 setVScrollBarMode(AlwaysOff); 305 setVScrollBarMode(AlwaysOff);
305 306
306 setStartHour(KOPrefs::instance()->mDayBegins); 307 setStartHour(KOPrefs::instance()->mDayBegins);
307 308
308 calculateWorkingHours(); 309 calculateWorkingHours();
309 310
310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 311 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
311 SLOT(checkScrollBoundaries(int))); 312 SLOT(checkScrollBoundaries(int)));
312 313
313 // Create the Marcus Bains line. 314 // Create the Marcus Bains line.
314 if(mAllDayMode) 315 if(mAllDayMode)
315 mMarcusBains = 0; 316 mMarcusBains = 0;
316 else { 317 else {
317 mMarcusBains = new MarcusBains(this); 318 mMarcusBains = new MarcusBains(this);
318 addChild(mMarcusBains); 319 addChild(mMarcusBains);
319 } 320 }
320 mPopupKind = 0; 321 mPopupKind = 0;
321 mPopupItem = 0; 322 mPopupItem = 0;
322 mInvalidPixmap = false; 323 mInvalidPixmap = false;
323 324
324} 325}
325 326
326void KOAgenda::shrinkPixmap() 327void KOAgenda::shrinkPixmap()
327{ 328{
328 mPaintPixmap.resize( 20,20); 329 mPaintPixmap.resize( 20,20);
329 mInvalidPixmap = true; 330 mInvalidPixmap = true;
330} 331}
331void KOAgenda::slotContentMove(int,int) 332void KOAgenda::slotContentMove(int,int)
332{ 333{
333 emit sendPing(); 334 emit sendPing();
334 if ( mActionType == NOP ) 335 if ( mActionType == NOP )
335 slotClearSelection(); 336 slotClearSelection();
336 if ( mSelectedItem && !mActionItem ) { 337 if ( mSelectedItem && !mActionItem ) {
337 deselectItem(); 338 deselectItem();
338 emit incidenceSelected( 0 ); 339 emit incidenceSelected( 0 );
339 } 340 }
340} 341}
341void KOAgenda::clear() 342void KOAgenda::clear()
342{ 343{
343 KOAgendaItem *item; 344 KOAgendaItem *item;
344 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 345 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
345 mUnusedItems.append( item ); 346 mUnusedItems.append( item );
346 //item->hide(); 347 //item->hide();
347 } 348 }
348 mItems.clear(); 349 mItems.clear();
349 mSelectedItem = 0; 350 mSelectedItem = 0;
350 clearSelection(); 351 clearSelection();
351} 352}
352 353
353void KOAgenda::clearSelection() 354void KOAgenda::clearSelection()
354{ 355{
355 mSelectionCellX = 0; 356 mSelectionCellX = 0;
356 mSelectionYTop = 0; 357 mSelectionYTop = 0;
357 mSelectionHeight = 0; 358 mSelectionHeight = 0;
358} 359}
359 360
360void KOAgenda::marcus_bains() 361void KOAgenda::marcus_bains()
361{ 362{
362 if(mMarcusBains) mMarcusBains->updateLocation(true); 363 if(mMarcusBains) mMarcusBains->updateLocation(true);
363} 364}
364 365
365 366
366void KOAgenda::changeColumns(int columns) 367void KOAgenda::changeColumns(int columns)
367{ 368{
368 if (columns == 0) { 369 if (columns == 0) {
369 qDebug("KOAgenda::changeColumns() called with argument 0 "); 370 qDebug("KOAgenda::changeColumns() called with argument 0 ");
370 return; 371 return;
371 } 372 }
372 clear(); 373 clear();
373 mColumns = columns; 374 mColumns = columns;
374 computeSizes(); 375 computeSizes();
375} 376}
376 377
377/* 378/*
378 This is the eventFilter function, which gets all events from the KOAgendaItems 379 This is the eventFilter function, which gets all events from the KOAgendaItems
379 contained in the agenda. It has to handle moving and resizing for all items. 380 contained in the agenda. It has to handle moving and resizing for all items.
380*/ 381*/
381bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 382bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
382{ 383{
383 // kdDebug() << "KOAgenda::eventFilter" << endl; 384 // kdDebug() << "KOAgenda::eventFilter" << endl;
384 switch(event->type()) { 385 switch(event->type()) {
385 case QEvent::MouseButtonPress: 386 case QEvent::MouseButtonPress:
386 case QEvent::MouseButtonDblClick: 387 case QEvent::MouseButtonDblClick:
387 case QEvent::MouseButtonRelease: 388 case QEvent::MouseButtonRelease:
388 case QEvent::MouseMove: 389 case QEvent::MouseMove:
389 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 390 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
390 391
391 case (QEvent::Leave): 392 case (QEvent::Leave):
392 if (!mActionItem) 393 if (!mActionItem)
393 setCursor(arrowCursor); 394 setCursor(arrowCursor);
394 return true; 395 return true;
395 396
396 default: 397 default:
397 return QScrollView::eventFilter(object,event); 398 return QScrollView::eventFilter(object,event);
398 } 399 }
399} 400}
400void KOAgenda::popupMenu() 401void KOAgenda::popupMenu()
401{ 402{
402 mPopupTimer->stop(); 403 mPopupTimer->stop();
403 if ( mPopupKind == 1 || mPopupKind == 3 ) { 404 if ( mPopupKind == 1 || mPopupKind == 3 ) {
404 if (mActionItem ) { 405 if (mActionItem ) {
405 endItemAction(); 406 endItemAction();
406 } 407 }
407 mLeftMouseDown = false; // no more leftMouse computation 408 mLeftMouseDown = false; // no more leftMouse computation
408 if (mPopupItem) { 409 if (mPopupItem) {
409 //mClickedItem = mPopupItem; 410 //mClickedItem = mPopupItem;
410 selectItem(mPopupItem); 411 selectItem(mPopupItem);
411 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 412 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
412 mAllAgendaPopup->installEventFilter( this ); 413 mAllAgendaPopup->installEventFilter( this );
413 emit showIncidencePopupSignal(mPopupItem->incidence()); 414 emit showIncidencePopupSignal(mPopupItem->incidence());
414 415
415 } 416 }
416 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 417 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
417 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 418 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
418 endSelectAction( false ); // do not emit new event signal 419 endSelectAction( false ); // do not emit new event signal
419 mLeftMouseDown = false; // no more leftMouse computation 420 mLeftMouseDown = false; // no more leftMouse computation
420 } 421 }
421 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 422 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
422 mNewItemPopup->installEventFilter( this ); 423 mNewItemPopup->installEventFilter( this );
423 mNewItemPopup->popup( mPopupPos); 424 mNewItemPopup->popup( mPopupPos);
424 425
425 } 426 }
426 mLeftMouseDown = false; 427 mLeftMouseDown = false;
427 mPopupItem = 0; 428 mPopupItem = 0;
428 mPopupKind = 0; 429 mPopupKind = 0;
429} 430}
430void KOAgenda::categoryChanged(Incidence * inc) 431void KOAgenda::categoryChanged(Incidence * inc)
431{ 432{
432 KOAgendaItem *item; 433 KOAgendaItem *item;
433 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 434 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
434 if ( item->incidence() == inc ) { 435 if ( item->incidence() == inc ) {
435 item->initColor (); 436 item->initColor ();
436 item->updateItem(); 437 item->updateItem();
437 } 438 }
438 } 439 }
439} 440}
440bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 441bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
441{ 442{
442 443
443 if ( mInvalidPixmap ) { 444 if ( mInvalidPixmap ) {
444 mInvalidPixmap = false; 445 mInvalidPixmap = false;
445 qDebug("InvalidPixmap "); 446 qDebug("KO: Upsizing Pixmaps ");
446 computeSizes(); 447 computeSizes();
447 emit updateViewSignal(); 448 emit updateViewSignal();
448 return true; 449 return true;
449 } 450 }
450 emit sendPing(); 451 emit sendPing();
451 static int startX = 0; 452 static int startX = 0;
452 static int startY = 0; 453 static int startY = 0;
453 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 454 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
454 static bool blockMoving = true; 455 static bool blockMoving = true;
455 456
456 //qDebug("KOAgenda::eventFilter_mous "); 457 //qDebug("KOAgenda::eventFilter_mous ");
457 if ( object == mNewItemPopup ) { 458 if ( object == mNewItemPopup ) {
458 //qDebug("mNewItemPopup "); 459 //qDebug("mNewItemPopup ");
459 if ( me->type() == QEvent::MouseButtonRelease ) { 460 if ( me->type() == QEvent::MouseButtonRelease ) {
460 mNewItemPopup->removeEventFilter( this ); 461 mNewItemPopup->removeEventFilter( this );
461 int dX = me->globalPos().x() - mPopupPos.x();; 462 int dX = me->globalPos().x() - mPopupPos.x();;
462 if ( dX < 0 ) 463 if ( dX < 0 )
463 dX = -dX; 464 dX = -dX;
464 int dY = me->globalPos().y() - mPopupPos.y(); 465 int dY = me->globalPos().y() - mPopupPos.y();
465 if ( dY < 0 ) 466 if ( dY < 0 )
466 dY = -dY; 467 dY = -dY;
467 if ( dX > blockmoveDist || dY > blockmoveDist ) { 468 if ( dX > blockmoveDist || dY > blockmoveDist ) {
468 mNewItemPopup->hide(); 469 mNewItemPopup->hide();
469 } 470 }
470 } 471 }
471 return true; 472 return true;
472 } 473 }
473 if ( object == mAllAgendaPopup ) { 474 if ( object == mAllAgendaPopup ) {
474 //qDebug(" mAllAgendaPopup "); 475 //qDebug(" mAllAgendaPopup ");
475 if ( me->type() == QEvent::MouseButtonRelease ) { 476 if ( me->type() == QEvent::MouseButtonRelease ) {
476 mAllAgendaPopup->removeEventFilter( this ); 477 mAllAgendaPopup->removeEventFilter( this );
477 int dX = me->globalPos().x() - mPopupPos.x();; 478 int dX = me->globalPos().x() - mPopupPos.x();;
478 if ( dX < 0 ) 479 if ( dX < 0 )
479 dX = -dX; 480 dX = -dX;
480 int dY = me->globalPos().y() - mPopupPos.y(); 481 int dY = me->globalPos().y() - mPopupPos.y();
481 if ( dY < 0 ) 482 if ( dY < 0 )
482 dY = -dY; 483 dY = -dY;
483 if ( dX > blockmoveDist || dY > blockmoveDist ) { 484 if ( dX > blockmoveDist || dY > blockmoveDist ) {
484 mAllAgendaPopup->hide(); 485 mAllAgendaPopup->hide();
485 } 486 }
486 } 487 }
487 return true; 488 return true;
488 } 489 }
489 QPoint viewportPos; 490 QPoint viewportPos;
490 if (object != viewport()) { 491 if (object != viewport()) {
491 blockmoveDist = blockmoveDist*2; 492 blockmoveDist = blockmoveDist*2;
492 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 493 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
493 } else { 494 } else {
494 viewportPos = me->pos(); 495 viewportPos = me->pos();
495 } 496 }
496 bool objIsNotViewport = (object != viewport()); 497 bool objIsNotViewport = (object != viewport());
497 bool leftButt = false; 498 bool leftButt = false;
498#ifdef DESKTOP_VERSION 499#ifdef DESKTOP_VERSION
499 leftButt = (me->button() == LeftButton); 500 leftButt = (me->button() == LeftButton);
500#endif 501#endif
501 switch (me->type()) { 502 switch (me->type()) {
502 case QEvent::MouseButtonPress: 503 case QEvent::MouseButtonPress:
503 if (me->button() == LeftButton) { 504 if (me->button() == LeftButton) {
504 mPopupTimer->start( 600 ); 505 mPopupTimer->start( 600 );
505 mLeftMouseDown = true; 506 mLeftMouseDown = true;
506 } 507 }
507 blockMoving = true; 508 blockMoving = true;
508 startX = viewportPos.x(); 509 startX = viewportPos.x();
509 startY = viewportPos.y(); 510 startY = viewportPos.y();
510 mPopupPos = me->globalPos(); 511 mPopupPos = me->globalPos();
511 if ( objIsNotViewport && !leftButt ) { 512 if ( objIsNotViewport && !leftButt ) {
512 KOAgendaItem * tempItem = (KOAgendaItem *)object; 513 KOAgendaItem * tempItem = (KOAgendaItem *)object;
513 if (mAllDayMode) { 514 if (mAllDayMode) {
514 if ( tempItem->height() > 10 ) { 515 if ( tempItem->height() > 10 ) {
515 int minV = tempItem->height()/4; 516 int minV = tempItem->height()/4;
516 if ( minV > (blockmoveDist/2)-2 ) { 517 if ( minV > (blockmoveDist/2)-2 ) {
517 if ( minV > blockmoveDist ) 518 if ( minV > blockmoveDist )
518 minV = blockmoveDist; 519 minV = blockmoveDist;
519 else 520 else
520 minV = (blockmoveDist/2); 521 minV = (blockmoveDist/2);
521 } 522 }
522 bool border = false; 523 bool border = false;
523 int diff = tempItem->y() - viewportPos.y(); 524 int diff = tempItem->y() - viewportPos.y();
524 if ( diff < 0 ) 525 if ( diff < 0 )
525 diff *= -1; 526 diff *= -1;
526 if ( diff < minV ) { 527 if ( diff < minV ) {
527 border = true; 528 border = true;
528 objIsNotViewport = false; 529 objIsNotViewport = false;
529 } 530 }
530 if ( ! border ) { 531 if ( ! border ) {
531 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 532 diff = tempItem->y() + tempItem->height()- viewportPos.y();
532 if ( diff < 0 ) 533 if ( diff < 0 )
533 diff *= -1; 534 diff *= -1;
534 if ( diff < minV ) { 535 if ( diff < minV ) {
535 border = true; 536 border = true;
536 objIsNotViewport = false; 537 objIsNotViewport = false;
537 } 538 }
538 } 539 }
539 } 540 }
540 } else { // not allday 541 } else { // not allday
541 if ( tempItem->width() > 10 ) { 542 if ( tempItem->width() > 10 ) {
542 int minH = tempItem->width()/4; 543 int minH = tempItem->width()/4;
543 if ( minH > (blockmoveDist/2)-2 ) { 544 if ( minH > (blockmoveDist/2)-2 ) {
544 if ( minH > blockmoveDist ) 545 if ( minH > blockmoveDist )
545 minH = blockmoveDist; 546 minH = blockmoveDist;
546 else 547 else
547 minH = (blockmoveDist/2); 548 minH = (blockmoveDist/2);
548 } 549 }
549 bool border = false; 550 bool border = false;
550 int diff = tempItem->x() - viewportPos.x(); 551 int diff = tempItem->x() - viewportPos.x();
551 if ( diff < 0 ) 552 if ( diff < 0 )
552 diff *= -1; 553 diff *= -1;
553 if ( diff < minH ) { 554 if ( diff < minH ) {
554 border = true; 555 border = true;
555 objIsNotViewport = false; 556 objIsNotViewport = false;
556 } 557 }
557 if ( ! border ) { 558 if ( ! border ) {
558 diff = tempItem->x() + tempItem->width() - viewportPos.x(); 559 diff = tempItem->x() + tempItem->width() - viewportPos.x();
559 if ( diff < 0 ) 560 if ( diff < 0 )
560 diff *= -1; 561 diff *= -1;
561 if ( diff < minH ) { 562 if ( diff < minH ) {
562 border = true; 563 border = true;
563 objIsNotViewport = false; 564 objIsNotViewport = false;
564 } 565 }
565 } 566 }
566 } 567 }
567 } 568 }
568 } 569 }
569 if ( objIsNotViewport ) { 570 if ( objIsNotViewport ) {
570 mPopupItem = (KOAgendaItem *)object; 571 mPopupItem = (KOAgendaItem *)object;
571 mPopupKind = 1; 572 mPopupKind = 1;
572 if (me->button() == RightButton) { 573 if (me->button() == RightButton) {
573 mPopupKind = 3; 574 mPopupKind = 3;
574 popupMenu(); 575 popupMenu();
575 } else if (me->button() == LeftButton) { 576 } else if (me->button() == LeftButton) {
576 mActionItem = (KOAgendaItem *)object; 577 mActionItem = (KOAgendaItem *)object;
577 if (mActionItem) { 578 if (mActionItem) {
578 emit signalClearSelection(); 579 emit signalClearSelection();
579 slotClearSelection(); 580 slotClearSelection();
580 selectItem(mActionItem); 581 selectItem(mActionItem);
581 Incidence *incidence = mActionItem->incidence(); 582 Incidence *incidence = mActionItem->incidence();
582 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 583 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
583 mActionItem = 0; 584 mActionItem = 0;
584 } else { 585 } else {
585 startItemAction(viewportPos); 586 startItemAction(viewportPos);
586 } 587 }
587 } 588 }
588 } 589 }
589 } else { // ---------- viewport() 590 } else { // ---------- viewport()
590 mPopupItem = 0; 591 mPopupItem = 0;
591 mPopupKind = 2; 592 mPopupKind = 2;
592 selectItem(0); 593 selectItem(0);
593 mActionItem = 0; 594 mActionItem = 0;
594 if (me->button() == RightButton) { 595 if (me->button() == RightButton) {
595 int x,y; 596 int x,y;
596 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 597 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
597 int gx,gy; 598 int gx,gy;
598 contentsToGrid(x,y,gx,gy); 599 contentsToGrid(x,y,gx,gy);
599 mCurrentCellX = gx; 600 mCurrentCellX = gx;
600 mCurrentCellY = gy; 601 mCurrentCellY = gy;
601 mStartCellX = gx; 602 mStartCellX = gx;
602 mStartCellY = gy; 603 mStartCellY = gy;
603 mPopupKind = 4; 604 mPopupKind = 4;
604 popupMenu(); 605 popupMenu();
605 } else if (me->button() == LeftButton) { 606 } else if (me->button() == LeftButton) {
606 setCursor(arrowCursor); 607 setCursor(arrowCursor);
607 startSelectAction(viewportPos); 608 startSelectAction(viewportPos);
608 } 609 }
609 } 610 }
610 break; 611 break;
611 612
612 case QEvent::MouseButtonRelease: 613 case QEvent::MouseButtonRelease:
613 if (me->button() == LeftButton ) { 614 if (me->button() == LeftButton ) {
614 mPopupTimer->stop(); 615 mPopupTimer->stop();
615 } 616 }
616 if (object != viewport()) { 617 if (object != viewport()) {
617 if (me->button() == LeftButton && mLeftMouseDown) { 618 if (me->button() == LeftButton && mLeftMouseDown) {
618 if (mActionItem) { 619 if (mActionItem) {
619 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 620 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
620 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 621 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
621 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 622 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
622 mScrollUpTimer.stop(); 623 mScrollUpTimer.stop();
623 mScrollDownTimer.stop(); 624 mScrollDownTimer.stop();
624 mActionItem->resetMove(); 625 mActionItem->resetMove();
625 placeSubCells( mActionItem ); 626 placeSubCells( mActionItem );
626 // emit startDragSignal( mActionItem->incidence() ); 627 // emit startDragSignal( mActionItem->incidence() );
627 setCursor( arrowCursor ); 628 setCursor( arrowCursor );
628 mActionItem = 0; 629 mActionItem = 0;
629 mActionType = NOP; 630 mActionType = NOP;
630 mItemMoved = 0; 631 mItemMoved = 0;
631 mLeftMouseDown = false; 632 mLeftMouseDown = false;
632 return true; 633 return true;
633 } 634 }
634 endItemAction(); 635 endItemAction();
635 } 636 }
636 } 637 }
637 638
638 } else { // ---------- viewport() 639 } else { // ---------- viewport()
639 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 640 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
640 endSelectAction( true ); // emit new event signal 641 endSelectAction( true ); // emit new event signal
641 } 642 }
642 } 643 }
643 if (me->button() == LeftButton) 644 if (me->button() == LeftButton)
644 mLeftMouseDown = false; 645 mLeftMouseDown = false;
645 646
646 break; 647 break;
647 648
648 case QEvent::MouseMove: 649 case QEvent::MouseMove:
649 //qDebug("mm "); 650 //qDebug("mm ");
650 if ( !mLeftMouseDown ) 651 if ( !mLeftMouseDown )
651 return false; 652 return false;
652 if ( blockMoving ) { 653 if ( blockMoving ) {
653 int dX, dY; 654 int dX, dY;
654 dX = startX - viewportPos.x(); 655 dX = startX - viewportPos.x();
655 if ( dX < 0 ) 656 if ( dX < 0 )
656 dX = -dX; 657 dX = -dX;
657 dY = viewportPos.y() - startY; 658 dY = viewportPos.y() - startY;
658 if ( dY < 0 ) 659 if ( dY < 0 )
659 dY = -dY; 660 dY = -dY;
660 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 661 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
661 if ( dX > blockmoveDist || dY > blockmoveDist ) { 662 if ( dX > blockmoveDist || dY > blockmoveDist ) {
662 blockMoving = false; 663 blockMoving = false;
663 } 664 }
664 } 665 }
665 if ( ! blockMoving ) 666 if ( ! blockMoving )
666 mPopupTimer->stop(); 667 mPopupTimer->stop();
667 if (object != viewport()) { 668 if (object != viewport()) {
668 KOAgendaItem *moveItem = (KOAgendaItem *)object; 669 KOAgendaItem *moveItem = (KOAgendaItem *)object;
669 if (!moveItem->incidence()->isReadOnly() ) { 670 if (!moveItem->incidence()->isReadOnly() ) {
670 if (!mActionItem) 671 if (!mActionItem)
671 setNoActionCursor(moveItem,viewportPos); 672 setNoActionCursor(moveItem,viewportPos);
672 else { 673 else {
673 if ( !blockMoving ) 674 if ( !blockMoving )
674 performItemAction(viewportPos); 675 performItemAction(viewportPos);
675 } 676 }
676 } 677 }
677 } else { // ---------- viewport() 678 } else { // ---------- viewport()
678 mPopupPos = viewport()->mapToGlobal( me->pos() ); 679 mPopupPos = viewport()->mapToGlobal( me->pos() );
679 if ( mActionType == SELECT ) { 680 if ( mActionType == SELECT ) {
680 performSelectAction( viewportPos ); 681 performSelectAction( viewportPos );
681 } 682 }
682 } 683 }
683 break; 684 break;
684 685
685 case QEvent::MouseButtonDblClick: 686 case QEvent::MouseButtonDblClick:
686 mPopupTimer->stop(); 687 mPopupTimer->stop();
687 if (object == viewport()) { 688 if (object == viewport()) {
688 selectItem(0); 689 selectItem(0);
689 int x,y; 690 int x,y;
690 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 691 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
691 int gx,gy; 692 int gx,gy;
692 contentsToGrid(x,y,gx,gy); 693 contentsToGrid(x,y,gx,gy);
693 emit newEventSignal(gx,gy); 694 emit newEventSignal(gx,gy);
694 } else { 695 } else {
695 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 696 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
696 selectItem(doubleClickedItem); 697 selectItem(doubleClickedItem);
697 if ( KOPrefs::instance()->mEditOnDoubleClick ) 698 if ( KOPrefs::instance()->mEditOnDoubleClick )
698 emit editIncidenceSignal(doubleClickedItem->incidence()); 699 emit editIncidenceSignal(doubleClickedItem->incidence());
699 else 700 else
700 emit showIncidenceSignal(doubleClickedItem->incidence()); 701 emit showIncidenceSignal(doubleClickedItem->incidence());
701 } 702 }
702 break; 703 break;
703 704
704 default: 705 default:
705 break; 706 break;
706 } 707 }
707 return true; 708 return true;
708 709
709} 710}
710 711
711void KOAgenda::newItem( int item ) 712void KOAgenda::newItem( int item )
712{ 713{
713 if ( item == 1 ) { //new event 714 if ( item == 1 ) { //new event
714 newEventSignal(mStartCellX ,mStartCellY ); 715 newEventSignal(mStartCellX ,mStartCellY );
715 } else 716 } else
716 if ( item == 2 ) { //new event 717 if ( item == 2 ) { //new event
717 newTodoSignal(mStartCellX ,mStartCellY ); 718 newTodoSignal(mStartCellX ,mStartCellY );
718 } else 719 } else
719 { 720 {
720 emit showDateView( item, mStartCellX ); 721 emit showDateView( item, mStartCellX );
721 // 3Day view 722 // 3Day view
722 // 4Week view 723 // 4Week view
723 // 5Month view 724 // 5Month view
724 // 6Journal view 725 // 6Journal view
725 } 726 }
726} 727}
727void KOAgenda::slotClearSelection() 728void KOAgenda::slotClearSelection()
728{ 729{
729 if (mSelectionHeight) { 730 if (mSelectionHeight) {
730 int selectionX = mSelectionCellX * mGridSpacingX; 731 int selectionX = mSelectionCellX * mGridSpacingX;
731 int top = mSelectionYTop - 2 *mGridSpacingY; 732 int top = mSelectionYTop - 2 *mGridSpacingY;
732 int hei = mSelectionHeight + 4 *mGridSpacingY; 733 int hei = mSelectionHeight + 4 *mGridSpacingY;
733 clearSelection(); 734 clearSelection();
734 repaintContents( selectionX, top, 735 repaintContents( selectionX, top,
735 mGridSpacingX, hei ,false ); 736 mGridSpacingX, hei ,false );
736 } 737 }
737 738
738} 739}
739void KOAgenda::startSelectAction(QPoint viewportPos) 740void KOAgenda::startSelectAction(QPoint viewportPos)
740{ 741{
741 742
742 emit signalClearSelection(); 743 emit signalClearSelection();
743 slotClearSelection(); 744 slotClearSelection();
744 745
745 mActionType = SELECT; 746 mActionType = SELECT;
746 747
747 int x,y; 748 int x,y;
748 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 749 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
749 int gx,gy; 750 int gx,gy;
750 contentsToGrid(x,y,gx,gy); 751 contentsToGrid(x,y,gx,gy);
751 752
752 mStartCellX = gx; 753 mStartCellX = gx;
753 mStartCellY = gy; 754 mStartCellY = gy;
754 mCurrentCellX = gx; 755 mCurrentCellX = gx;
755 mCurrentCellY = gy; 756 mCurrentCellY = gy;
756 757
757 // Store new selection 758 // Store new selection
758 mSelectionCellX = gx; 759 mSelectionCellX = gx;
759 mSelectionYTop = gy * mGridSpacingY; 760 mSelectionYTop = gy * mGridSpacingY;
760 mSelectionHeight = mGridSpacingY; 761 mSelectionHeight = mGridSpacingY;
761 762
762 // Paint new selection 763 // Paint new selection
763 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 764 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
764 mGridSpacingX-1, mSelectionHeight ); 765 mGridSpacingX-1, mSelectionHeight );
765} 766}
766 767
767void KOAgenda::performSelectAction(QPoint viewportPos) 768void KOAgenda::performSelectAction(QPoint viewportPos)
768{ 769{
769 int x,y; 770 int x,y;
770 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 771 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
771 int gx,gy; 772 int gx,gy;
772 contentsToGrid(x,y,gx,gy); 773 contentsToGrid(x,y,gx,gy);
773 774
774 QPoint clipperPos = clipper()-> 775 QPoint clipperPos = clipper()->
775 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 776 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
776 777
777 // Scroll if cursor was moved to upper or lower end of agenda. 778 // Scroll if cursor was moved to upper or lower end of agenda.
778 if (clipperPos.y() < mScrollBorderWidth) { 779 if (clipperPos.y() < mScrollBorderWidth) {
779 mScrollUpTimer.start(mScrollDelay); 780 mScrollUpTimer.start(mScrollDelay);
780 } else if (visibleHeight() - clipperPos.y() < 781 } else if (visibleHeight() - clipperPos.y() <
781 mScrollBorderWidth) { 782 mScrollBorderWidth) {
782 mScrollDownTimer.start(mScrollDelay); 783 mScrollDownTimer.start(mScrollDelay);
783 } else { 784 } else {
784 mScrollUpTimer.stop(); 785 mScrollUpTimer.stop();
785 mScrollDownTimer.stop(); 786 mScrollDownTimer.stop();
786 } 787 }
787 788
788 if ( gy > mCurrentCellY ) { 789 if ( gy > mCurrentCellY ) {
789 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 790 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
790 791
791 792
792 repaintContents( (KOGlobals::self()->reverseLayout() ? 793 repaintContents( (KOGlobals::self()->reverseLayout() ?
793 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 794 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
794 mGridSpacingX, mSelectionYTop, 795 mGridSpacingX, mSelectionYTop,
795 mGridSpacingX, mSelectionHeight , false); 796 mGridSpacingX, mSelectionHeight , false);
796 797
797 mCurrentCellY = gy; 798 mCurrentCellY = gy;
798 } else if ( gy < mCurrentCellY ) { 799 } else if ( gy < mCurrentCellY ) {
799 if ( gy >= mStartCellY ) { 800 if ( gy >= mStartCellY ) {
800 int selectionHeight = mSelectionHeight; 801 int selectionHeight = mSelectionHeight;
801 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 802 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
802 803
803 repaintContents( (KOGlobals::self()->reverseLayout() ? 804 repaintContents( (KOGlobals::self()->reverseLayout() ?
804 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 805 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
805 mGridSpacingX, mSelectionYTop, 806 mGridSpacingX, mSelectionYTop,
806 mGridSpacingX, selectionHeight,false ); 807 mGridSpacingX, selectionHeight,false );
807 808
808 mCurrentCellY = gy; 809 mCurrentCellY = gy;
809 } else { 810 } else {
810 } 811 }
811 } 812 }
812} 813}
813 814
814void KOAgenda::endSelectAction( bool emitNewEvent ) 815void KOAgenda::endSelectAction( bool emitNewEvent )
815{ 816{
816 mActionType = NOP; 817 mActionType = NOP;
817 mScrollUpTimer.stop(); 818 mScrollUpTimer.stop();
818 mScrollDownTimer.stop(); 819 mScrollDownTimer.stop();
819 820
820 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 821 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
821 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 822 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
822 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 823 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
823 } 824 }
824} 825}
825 826
826void KOAgenda::startItemAction(QPoint viewportPos) 827void KOAgenda::startItemAction(QPoint viewportPos)
827{ 828{
828 int x,y; 829 int x,y;
829 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 830 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
@@ -895,1372 +896,1366 @@ void KOAgenda::performItemAction(QPoint viewportPos)
895 mScrollUpTimer.stop(); 896 mScrollUpTimer.stop();
896 mScrollDownTimer.stop(); 897 mScrollDownTimer.stop();
897 mActionItem->resetMove(); 898 mActionItem->resetMove();
898 placeSubCells( mActionItem ); 899 placeSubCells( mActionItem );
899 // emit startDragSignal( mActionItem->incidence() ); 900 // emit startDragSignal( mActionItem->incidence() );
900 setCursor( arrowCursor ); 901 setCursor( arrowCursor );
901 mActionItem = 0; 902 mActionItem = 0;
902 mActionType = NOP; 903 mActionType = NOP;
903 mItemMoved = 0; 904 mItemMoved = 0;
904 return; 905 return;
905 } 906 }
906 } else { 907 } else {
907 switch ( mActionType ) { 908 switch ( mActionType ) {
908 case MOVE: 909 case MOVE:
909 setCursor( sizeAllCursor ); 910 setCursor( sizeAllCursor );
910 break; 911 break;
911 case RESIZETOP: 912 case RESIZETOP:
912 case RESIZEBOTTOM: 913 case RESIZEBOTTOM:
913 setCursor( sizeVerCursor ); 914 setCursor( sizeVerCursor );
914 break; 915 break;
915 case RESIZELEFT: 916 case RESIZELEFT:
916 case RESIZERIGHT: 917 case RESIZERIGHT:
917 setCursor( sizeHorCursor ); 918 setCursor( sizeHorCursor );
918 break; 919 break;
919 default: 920 default:
920 setCursor( arrowCursor ); 921 setCursor( arrowCursor );
921 } 922 }
922 } 923 }
923 924
924 // Scroll if item was moved to upper or lower end of agenda. 925 // Scroll if item was moved to upper or lower end of agenda.
925 if (clipperPos.y() < mScrollBorderWidth) { 926 if (clipperPos.y() < mScrollBorderWidth) {
926 mScrollUpTimer.start(mScrollDelay); 927 mScrollUpTimer.start(mScrollDelay);
927 } else if (visibleHeight() - clipperPos.y() < 928 } else if (visibleHeight() - clipperPos.y() <
928 mScrollBorderWidth) { 929 mScrollBorderWidth) {
929 mScrollDownTimer.start(mScrollDelay); 930 mScrollDownTimer.start(mScrollDelay);
930 } else { 931 } else {
931 mScrollUpTimer.stop(); 932 mScrollUpTimer.stop();
932 mScrollDownTimer.stop(); 933 mScrollDownTimer.stop();
933 } 934 }
934 935
935 // Move or resize item if necessary 936 // Move or resize item if necessary
936 if (mCurrentCellX != gx || mCurrentCellY != gy) { 937 if (mCurrentCellX != gx || mCurrentCellY != gy) {
937 mItemMoved = true; 938 mItemMoved = true;
938 mActionItem->raise(); 939 mActionItem->raise();
939 if (mActionType == MOVE) { 940 if (mActionType == MOVE) {
940 // Move all items belonging to a multi item 941 // Move all items belonging to a multi item
941 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 942 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
942 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 943 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
943 if (!moveItem) moveItem = mActionItem; 944 if (!moveItem) moveItem = mActionItem;
944 while (moveItem) { 945 while (moveItem) {
945 int dy; 946 int dy;
946 if (isMultiItem) dy = 0; 947 if (isMultiItem) dy = 0;
947 else dy = gy - mCurrentCellY; 948 else dy = gy - mCurrentCellY;
948 moveItem->moveRelative(gx - mCurrentCellX,dy); 949 moveItem->moveRelative(gx - mCurrentCellX,dy);
949 int x,y; 950 int x,y;
950 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 951 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
951 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 952 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
952 mGridSpacingY * moveItem->cellHeight()); 953 mGridSpacingY * moveItem->cellHeight());
953 moveItem->raise(); 954 moveItem->raise();
954 moveChild(moveItem,x,y); 955 moveChild(moveItem,x,y);
955 moveItem = moveItem->nextMultiItem(); 956 moveItem = moveItem->nextMultiItem();
956 } 957 }
957 } else if (mActionType == RESIZETOP) { 958 } else if (mActionType == RESIZETOP) {
958 if (mCurrentCellY <= mActionItem->cellYBottom()) { 959 if (mCurrentCellY <= mActionItem->cellYBottom()) {
959 mActionItem->expandTop(gy - mCurrentCellY); 960 mActionItem->expandTop(gy - mCurrentCellY);
960 mActionItem->resize(mActionItem->width(), 961 mActionItem->resize(mActionItem->width(),
961 mGridSpacingY * mActionItem->cellHeight()); 962 mGridSpacingY * mActionItem->cellHeight());
962 int x,y; 963 int x,y;
963 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 964 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
964 //moveChild(mActionItem,childX(mActionItem),y); 965 //moveChild(mActionItem,childX(mActionItem),y);
965 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 966 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
966 } 967 }
967 } else if (mActionType == RESIZEBOTTOM) { 968 } else if (mActionType == RESIZEBOTTOM) {
968 if (mCurrentCellY >= mActionItem->cellYTop()) { 969 if (mCurrentCellY >= mActionItem->cellYTop()) {
969 mActionItem->expandBottom(gy - mCurrentCellY); 970 mActionItem->expandBottom(gy - mCurrentCellY);
970 mActionItem->resize(mActionItem->width(), 971 mActionItem->resize(mActionItem->width(),
971 mGridSpacingY * mActionItem->cellHeight()); 972 mGridSpacingY * mActionItem->cellHeight());
972 } 973 }
973 } else if (mActionType == RESIZELEFT) { 974 } else if (mActionType == RESIZELEFT) {
974 if (mCurrentCellX <= mActionItem->cellXWidth()) { 975 if (mCurrentCellX <= mActionItem->cellXWidth()) {
975 mActionItem->expandLeft(gx - mCurrentCellX); 976 mActionItem->expandLeft(gx - mCurrentCellX);
976 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 977 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
977 mActionItem->height()); 978 mActionItem->height());
978 int x,y; 979 int x,y;
979 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 980 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
980 moveChild(mActionItem,x,childY(mActionItem)); 981 moveChild(mActionItem,x,childY(mActionItem));
981 } 982 }
982 } else if (mActionType == RESIZERIGHT) { 983 } else if (mActionType == RESIZERIGHT) {
983 if (mCurrentCellX >= mActionItem->cellX()) { 984 if (mCurrentCellX >= mActionItem->cellX()) {
984 mActionItem->expandRight(gx - mCurrentCellX); 985 mActionItem->expandRight(gx - mCurrentCellX);
985 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 986 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
986 mActionItem->height()); 987 mActionItem->height());
987 } 988 }
988 } 989 }
989 mCurrentCellX = gx; 990 mCurrentCellX = gx;
990 mCurrentCellY = gy; 991 mCurrentCellY = gy;
991 } 992 }
992} 993}
993 994
994void KOAgenda::endItemAction() 995void KOAgenda::endItemAction()
995{ 996{
996 997
997 if ( mItemMoved ) { 998 if ( mItemMoved ) {
998 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 999 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
999 if ( !placeItem ) { 1000 if ( !placeItem ) {
1000 placeItem = mActionItem; 1001 placeItem = mActionItem;
1001 } 1002 }
1002 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 1003 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
1003 Incidence* oldInc = placeItem->incidence(); 1004 Incidence* oldInc = placeItem->incidence();
1004 placeItem->recreateIncidence(); 1005 placeItem->recreateIncidence();
1005 emit addToCalSignal(placeItem->incidence(), oldInc ); 1006 emit addToCalSignal(placeItem->incidence(), oldInc );
1006 } 1007 }
1007 int type = mActionType; 1008 int type = mActionType;
1008 if ( mAllDayMode ) 1009 if ( mAllDayMode )
1009 type = -1; 1010 type = -1;
1010 KOAgendaItem *modifiedItem = placeItem; 1011 KOAgendaItem *modifiedItem = placeItem;
1011 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1012 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1012 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1013 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1013 KOAgendaItem *item; 1014 KOAgendaItem *item;
1014 1015
1015 if ( placeItem->incidence()->typeID() == todoID ) { 1016 if ( placeItem->incidence()->typeID() == todoID ) {
1016 mSelectedItem = 0; 1017 mSelectedItem = 0;
1017 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1018 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1018 modifiedItem->mLastMoveXPos = mCurrentCellX; 1019 modifiedItem->mLastMoveXPos = mCurrentCellX;
1019 emit itemModified( modifiedItem, mActionType ); 1020 emit itemModified( modifiedItem, mActionType );
1020 } 1021 }
1021 else { 1022 else {
1022 1023
1023 1024
1024 globalFlagBlockAgendaItemPaint = 1; 1025 globalFlagBlockAgendaItemPaint = 1;
1025 for ( item=oldconflictItems.first(); item != 0; 1026 for ( item=oldconflictItems.first(); item != 0;
1026 item=oldconflictItems.next() ) { 1027 item=oldconflictItems.next() ) {
1027 placeSubCells(item); 1028 placeSubCells(item);
1028 } 1029 }
1029 while ( placeItem ) { 1030 while ( placeItem ) {
1030 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1031 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1031 oldconflictItems = placeItem->conflictItems(); 1032 oldconflictItems = placeItem->conflictItems();
1032 for ( item=oldconflictItems.first(); item != 0; 1033 for ( item=oldconflictItems.first(); item != 0;
1033 item=oldconflictItems.next() ) { 1034 item=oldconflictItems.next() ) {
1034 placeSubCells(item); 1035 placeSubCells(item);
1035 } 1036 }
1036 placeSubCells( placeItem ); 1037 placeSubCells( placeItem );
1037 placeItem = placeItem->nextMultiItem(); 1038 placeItem = placeItem->nextMultiItem();
1038 } 1039 }
1039 globalFlagBlockAgendaItemPaint = 0; 1040 globalFlagBlockAgendaItemPaint = 0;
1040 for ( item=oldconflictItems.first(); item != 0; 1041 for ( item=oldconflictItems.first(); item != 0;
1041 item=oldconflictItems.next() ) { 1042 item=oldconflictItems.next() ) {
1042 globalFlagBlockAgendaItemUpdate = 0; 1043 globalFlagBlockAgendaItemUpdate = 0;
1043 item->repaintMe(); 1044 item->repaintMe();
1044 globalFlagBlockAgendaItemUpdate = 1; 1045 globalFlagBlockAgendaItemUpdate = 1;
1045 item->repaint( false ); 1046 item->repaint( false );
1046 } 1047 }
1047 placeItem = modifiedItem; 1048 placeItem = modifiedItem;
1048 1049
1049 while ( placeItem ) { 1050 while ( placeItem ) {
1050 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1051 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1051 globalFlagBlockAgendaItemUpdate = 0; 1052 globalFlagBlockAgendaItemUpdate = 0;
1052 placeItem->repaintMe(); 1053 placeItem->repaintMe();
1053 globalFlagBlockAgendaItemUpdate = 1; 1054 globalFlagBlockAgendaItemUpdate = 1;
1054 placeItem->repaint(false); 1055 placeItem->repaint(false);
1055 placeItem = placeItem->nextMultiItem(); 1056 placeItem = placeItem->nextMultiItem();
1056 } 1057 }
1057 emit itemModified( modifiedItem, mActionType ); 1058 emit itemModified( modifiedItem, mActionType );
1058 1059
1059 1060
1060 placeItem = modifiedItem; 1061 placeItem = modifiedItem;
1061 while ( placeItem ) { 1062 while ( placeItem ) {
1062 oldconflictItems = placeItem->conflictItems(); 1063 oldconflictItems = placeItem->conflictItems();
1063 for ( item=oldconflictItems.first(); item != 0; 1064 for ( item=oldconflictItems.first(); item != 0;
1064 item=oldconflictItems.next() ) { 1065 item=oldconflictItems.next() ) {
1065 placeSubCells(item); 1066 placeSubCells(item);
1066 } 1067 }
1067 placeSubCells( placeItem ); 1068 placeSubCells( placeItem );
1068 placeItem = placeItem->nextMultiItem(); 1069 placeItem = placeItem->nextMultiItem();
1069 1070
1070 } 1071 }
1071 placeItem = modifiedItem; 1072 placeItem = modifiedItem;
1072 while ( placeItem ) { 1073 while ( placeItem ) {
1073 oldconflictItems = placeItem->conflictItems(); 1074 oldconflictItems = placeItem->conflictItems();
1074 for ( item=oldconflictItems.first(); item != 0; 1075 for ( item=oldconflictItems.first(); item != 0;
1075 item=oldconflictItems.next() ) { 1076 item=oldconflictItems.next() ) {
1076 globalFlagBlockAgendaItemUpdate = 0; 1077 globalFlagBlockAgendaItemUpdate = 0;
1077 item->repaintMe(); 1078 item->repaintMe();
1078 globalFlagBlockAgendaItemUpdate = 1; 1079 globalFlagBlockAgendaItemUpdate = 1;
1079 item->repaint(false); 1080 item->repaint(false);
1080 } 1081 }
1081 placeItem = placeItem->nextMultiItem(); 1082 placeItem = placeItem->nextMultiItem();
1082 } 1083 }
1083 /* 1084 /*
1084 1085
1085 oldconflictItems = modifiedItem->conflictItems(); 1086 oldconflictItems = modifiedItem->conflictItems();
1086 for ( item=oldconflictItems.first(); item != 0; 1087 for ( item=oldconflictItems.first(); item != 0;
1087 item=oldconflictItems.next() ) { 1088 item=oldconflictItems.next() ) {
1088 globalFlagBlockAgendaItemUpdate = 0; 1089 globalFlagBlockAgendaItemUpdate = 0;
1089 item->paintMe(false); 1090 item->paintMe(false);
1090 globalFlagBlockAgendaItemUpdate = 1; 1091 globalFlagBlockAgendaItemUpdate = 1;
1091 item->repaint(false); 1092 item->repaint(false);
1092 } 1093 }
1093 */ 1094 */
1094 1095
1095 1096
1096 } 1097 }
1097 1098
1098 } 1099 }
1099 1100
1100 mScrollUpTimer.stop(); 1101 mScrollUpTimer.stop();
1101 mScrollDownTimer.stop(); 1102 mScrollDownTimer.stop();
1102 setCursor( arrowCursor ); 1103 setCursor( arrowCursor );
1103 mActionItem = 0; 1104 mActionItem = 0;
1104 mActionType = NOP; 1105 mActionType = NOP;
1105 mItemMoved = 0; 1106 mItemMoved = 0;
1106 1107
1107} 1108}
1108 1109
1109void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1110void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1110{ 1111{
1111// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1112// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1112// QPoint point = viewport()->mapToGlobal(viewportPos); 1113// QPoint point = viewport()->mapToGlobal(viewportPos);
1113// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1114// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1114// point = clipper()->mapFromGlobal(point); 1115// point = clipper()->mapFromGlobal(point);
1115// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1116// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1116 1117
1117 int x,y; 1118 int x,y;
1118 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1119 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1119// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1120// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1120 int gx,gy; 1121 int gx,gy;
1121 contentsToGrid(x,y,gx,gy); 1122 contentsToGrid(x,y,gx,gy);
1122 1123
1123 // Change cursor to resize cursor if appropriate 1124 // Change cursor to resize cursor if appropriate
1124 if (mAllDayMode) { 1125 if (mAllDayMode) {
1125 int gridDistanceX = (x - gx * mGridSpacingX); 1126 int gridDistanceX = (x - gx * mGridSpacingX);
1126 if (gridDistanceX < mResizeBorderWidth && 1127 if (gridDistanceX < mResizeBorderWidth &&
1127 moveItem->cellX() == gx) { 1128 moveItem->cellX() == gx) {
1128 setCursor(sizeHorCursor); 1129 setCursor(sizeHorCursor);
1129 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1130 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1130 moveItem->cellXWidth() == gx) { 1131 moveItem->cellXWidth() == gx) {
1131 setCursor(sizeHorCursor); 1132 setCursor(sizeHorCursor);
1132 } else { 1133 } else {
1133 setCursor(arrowCursor); 1134 setCursor(arrowCursor);
1134 } 1135 }
1135 } else { 1136 } else {
1136 int gridDistanceY = (y - gy * mGridSpacingY); 1137 int gridDistanceY = (y - gy * mGridSpacingY);
1137 if (gridDistanceY < mResizeBorderWidth && 1138 if (gridDistanceY < mResizeBorderWidth &&
1138 moveItem->cellYTop() == gy && 1139 moveItem->cellYTop() == gy &&
1139 !moveItem->firstMultiItem()) { 1140 !moveItem->firstMultiItem()) {
1140 setCursor(sizeVerCursor); 1141 setCursor(sizeVerCursor);
1141 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1142 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1142 moveItem->cellYBottom() == gy && 1143 moveItem->cellYBottom() == gy &&
1143 !moveItem->lastMultiItem()) { 1144 !moveItem->lastMultiItem()) {
1144 setCursor(sizeVerCursor); 1145 setCursor(sizeVerCursor);
1145 } else { 1146 } else {
1146 setCursor(arrowCursor); 1147 setCursor(arrowCursor);
1147 } 1148 }
1148 } 1149 }
1149} 1150}
1150 1151
1151 1152
1152/* 1153/*
1153 Place item in cell and take care that multiple items using the same cell do 1154 Place item in cell and take care that multiple items using the same cell do
1154 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1155 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1155 it can get in all cases. 1156 it can get in all cases.
1156 At the moment the method has a bug: When an item is placed only the sub cell 1157 At the moment the method has a bug: When an item is placed only the sub cell
1157 widths of the items are changed, which are within the Y region the item to 1158 widths of the items are changed, which are within the Y region the item to
1158 place spans. When the sub cell width change of one of this items affects a 1159 place spans. When the sub cell width change of one of this items affects a
1159 cell, where other items are, which do not overlap in Y with the item to place, 1160 cell, where other items are, which do not overlap in Y with the item to place,
1160 the display gets corrupted, although the corruption looks quite nice. 1161 the display gets corrupted, although the corruption looks quite nice.
1161*/ 1162*/
1162void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1163void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1163{ 1164{
1164 1165
1165 QPtrList<KOAgendaItem> conflictItems; 1166 QPtrList<KOAgendaItem> conflictItems;
1166 int maxSubCells = 0; 1167 int maxSubCells = 0;
1167 QIntDict<KOAgendaItem> subCellDict(7); 1168 QIntDict<KOAgendaItem> subCellDict(7);
1168 1169
1169 KOAgendaItem *item; 1170 KOAgendaItem *item;
1170 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1171 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1171 if (item != placeItem) { 1172 if (item != placeItem) {
1172 if (placeItem->cellX() <= item->cellXWidth() && 1173 if (placeItem->cellX() <= item->cellXWidth() &&
1173 placeItem->cellXWidth() >= item->cellX()) { 1174 placeItem->cellXWidth() >= item->cellX()) {
1174 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1175 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1175 (placeItem->cellYBottom() >= item->cellYTop())) { 1176 (placeItem->cellYBottom() >= item->cellYTop())) {
1176 conflictItems.append(item); 1177 conflictItems.append(item);
1177 if (item->subCells() > maxSubCells) 1178 if (item->subCells() > maxSubCells)
1178 maxSubCells = item->subCells(); 1179 maxSubCells = item->subCells();
1179 subCellDict.insert(item->subCell(),item); 1180 subCellDict.insert(item->subCell(),item);
1180 } 1181 }
1181 } 1182 }
1182 } 1183 }
1183 } 1184 }
1184 1185
1185 if (conflictItems.count() > 0) { 1186 if (conflictItems.count() > 0) {
1186 // Look for unused sub cell and insert item 1187 // Look for unused sub cell and insert item
1187 int i; 1188 int i;
1188 for(i=0;i<maxSubCells;++i) { 1189 for(i=0;i<maxSubCells;++i) {
1189 if (!subCellDict.find(i)) { 1190 if (!subCellDict.find(i)) {
1190 placeItem->setSubCell(i); 1191 placeItem->setSubCell(i);
1191 break; 1192 break;
1192 } 1193 }
1193 } 1194 }
1194 if (i == maxSubCells) { 1195 if (i == maxSubCells) {
1195 placeItem->setSubCell(maxSubCells); 1196 placeItem->setSubCell(maxSubCells);
1196 maxSubCells++; // add new item to number of sub cells 1197 maxSubCells++; // add new item to number of sub cells
1197 } 1198 }
1198 1199
1199 // Prepare for sub cell geometry adjustment 1200 // Prepare for sub cell geometry adjustment
1200 int newSubCellWidth; 1201 int newSubCellWidth;
1201 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1202 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1202 else newSubCellWidth = mGridSpacingX / maxSubCells; 1203 else newSubCellWidth = mGridSpacingX / maxSubCells;
1203 conflictItems.append(placeItem); 1204 conflictItems.append(placeItem);
1204 1205
1205 1206
1206 // Adjust sub cell geometry of all direct conflict items 1207 // Adjust sub cell geometry of all direct conflict items
1207 for ( item=conflictItems.first(); item != 0; 1208 for ( item=conflictItems.first(); item != 0;
1208 item=conflictItems.next() ) { 1209 item=conflictItems.next() ) {
1209 item->setSubCells(maxSubCells); 1210 item->setSubCells(maxSubCells);
1210 if (mAllDayMode) { 1211 if (mAllDayMode) {
1211 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1212 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1212 } else { 1213 } else {
1213 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1214 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1214 } 1215 }
1215 int x,y; 1216 int x,y;
1216 gridToContents(item->cellX(),item->cellYTop(),x,y); 1217 gridToContents(item->cellX(),item->cellYTop(),x,y);
1217 if (mAllDayMode) { 1218 if (mAllDayMode) {
1218 y += item->subCell() * newSubCellWidth; 1219 y += item->subCell() * newSubCellWidth;
1219 } else { 1220 } else {
1220 x += item->subCell() * newSubCellWidth; 1221 x += item->subCell() * newSubCellWidth;
1221 } 1222 }
1222 moveChild(item,x,y); 1223 moveChild(item,x,y);
1223 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1224 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1224 //item->updateItem(); 1225 //item->updateItem();
1225 } 1226 }
1226 // Adjust sub cell geometry of all conflict items of all conflict items 1227 // Adjust sub cell geometry of all conflict items of all conflict items
1227 for ( item=conflictItems.first(); item != 0; 1228 for ( item=conflictItems.first(); item != 0;
1228 item=conflictItems.next() ) { 1229 item=conflictItems.next() ) {
1229 if ( placeItem != item ) { 1230 if ( placeItem != item ) {
1230 KOAgendaItem *item2; 1231 KOAgendaItem *item2;
1231 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1232 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1232 for ( item2=conflictItems2.first(); item2 != 0; 1233 for ( item2=conflictItems2.first(); item2 != 0;
1233 item2=conflictItems2.next() ) { 1234 item2=conflictItems2.next() ) {
1234 if ( item2->subCells() != maxSubCells) { 1235 if ( item2->subCells() != maxSubCells) {
1235 item2->setSubCells(maxSubCells); 1236 item2->setSubCells(maxSubCells);
1236 if (mAllDayMode) { 1237 if (mAllDayMode) {
1237 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1238 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1238 } else { 1239 } else {
1239 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1240 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1240 } 1241 }
1241 int x,y; 1242 int x,y;
1242 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1243 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1243 if (mAllDayMode) { 1244 if (mAllDayMode) {
1244 y += item2->subCell() * newSubCellWidth; 1245 y += item2->subCell() * newSubCellWidth;
1245 } else { 1246 } else {
1246 x += item2->subCell() * newSubCellWidth; 1247 x += item2->subCell() * newSubCellWidth;
1247 } 1248 }
1248 moveChild(item2,x,y); 1249 moveChild(item2,x,y);
1249 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1250 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1250 } 1251 }
1251 } 1252 }
1252 } 1253 }
1253 } 1254 }
1254 } else { 1255 } else {
1255 placeItem->setSubCell(0); 1256 placeItem->setSubCell(0);
1256 placeItem->setSubCells(1); 1257 placeItem->setSubCells(1);
1257 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1258 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1258 else placeItem->resize(mGridSpacingX,placeItem->height()); 1259 else placeItem->resize(mGridSpacingX,placeItem->height());
1259 int x,y; 1260 int x,y;
1260 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1261 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1261 moveChild(placeItem,x,y); 1262 moveChild(placeItem,x,y);
1262 } 1263 }
1263 placeItem->setConflictItems(conflictItems); 1264 placeItem->setConflictItems(conflictItems);
1264 // for ( item=conflictItems.first(); item != 0; 1265 // for ( item=conflictItems.first(); item != 0;
1265// item=conflictItems.next() ) { 1266// item=conflictItems.next() ) {
1266// //item->updateItem(); 1267// //item->updateItem();
1267// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1268// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1268// } 1269// }
1269// placeItem->updateItem(); 1270// placeItem->updateItem();
1270} 1271}
1271 1272
1272void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1273void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1273{ 1274{
1274 if ( globalFlagBlockAgenda ) 1275 if ( globalFlagBlockAgenda )
1275 return; 1276 return;
1276 1277
1277 if ( mInvalidPixmap ) { 1278 if ( mInvalidPixmap ) {
1278 mInvalidPixmap = false; 1279 mInvalidPixmap = false;
1279 qDebug("InvalidPixmap "); 1280 qDebug("KO: Upsizing Pixmaps ");
1280 computeSizes(); 1281 computeSizes();
1281 emit updateViewSignal(); 1282 emit updateViewSignal();
1282 return; 1283 return;
1283 } 1284 }
1284 if ( ! mAllDayMode ) { 1285 if ( ! mAllDayMode ) {
1285 // currently not working for 1286 // currently not working for
1286 1287
1287 //qDebug("KOAgenda::drawContents "); 1288 //qDebug("KOAgenda::drawContents ");
1288#if 0 1289#if 0
1289 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1290 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1290 qDebug("WAU "); 1291 qDebug("WAU ");
1291 drawContentsToPainter(); 1292 drawContentsToPainter();
1292 } 1293 }
1293#endif 1294#endif
1294 QPaintDevice* pd = p->device(); 1295 QPaintDevice* pd = p->device();
1295 p->end(); 1296 p->end();
1296 int vx, vy; 1297 int vx, vy;
1297 int selectionX = KOGlobals::self()->reverseLayout() ? 1298 int selectionX = KOGlobals::self()->reverseLayout() ?
1298 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1299 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1299 mSelectionCellX * mGridSpacingX; 1300 mSelectionCellX * mGridSpacingX;
1300 contentsToViewport ( cx, cy, vx,vy); 1301 contentsToViewport ( cx, cy, vx,vy);
1301 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1302 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1302 1303
1303 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1304 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1304 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1305 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1305 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1306 1307
1307 int vxSel, vySel; 1308 int vxSel, vySel;
1308 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1309 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1309 int off = mSelectionHeight; 1310 int off = mSelectionHeight;
1310 if ( vySel < 0 ) 1311 if ( vySel < 0 )
1311 off += vySel; 1312 off += vySel;
1312 //qDebug("OFF %d %d %d", off,vySel, vy ); 1313 //qDebug("OFF %d %d %d", off,vySel, vy );
1313 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1314 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1314 } else { 1315 } else {
1315 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1316 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1316 } 1317 }
1317 } 1318 }
1318 if ( mSelectionHeight > 0 ) { 1319 if ( mSelectionHeight > 0 ) {
1319 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1320 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1320 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1321 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1321 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1322 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1322 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1323 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1323 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1324 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1324 int hei = mSelectionHeight; 1325 int hei = mSelectionHeight;
1325 int offset = 0; 1326 int offset = 0;
1326 while ( hei > 0 ) { 1327 while ( hei > 0 ) {
1327 int p_hei = 5; 1328 int p_hei = 5;
1328 if ( hei < 5 ) p_hei = hei; 1329 if ( hei < 5 ) p_hei = hei;
1329 hei -= 5; 1330 hei -= 5;
1330 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1331 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1331 offset += 5; 1332 offset += 5;
1332 } 1333 }
1333 } 1334 }
1334 } 1335 }
1335 p->begin( pd ); 1336 p->begin( pd );
1336 } else { 1337 } else {
1337#if 0 1338#if 0
1338 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); 1339 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() );
1339 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1340 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1340 qDebug("WAUWAU "); 1341 qDebug("WAUWAU ");
1341 drawContentsToPainter(); 1342 drawContentsToPainter();
1342 } 1343 }
1343#endif 1344#endif
1344 QPaintDevice* pd = p->device(); 1345 QPaintDevice* pd = p->device();
1345 p->end(); 1346 p->end();
1346 int vx, vy; 1347 int vx, vy;
1347 int selectionX = KOGlobals::self()->reverseLayout() ? 1348 int selectionX = KOGlobals::self()->reverseLayout() ?
1348 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1349 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1349 mSelectionCellX * mGridSpacingX; 1350 mSelectionCellX * mGridSpacingX;
1350 contentsToViewport ( cx, cy, vx,vy); 1351 contentsToViewport ( cx, cy, vx,vy);
1351 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1352 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1352 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1353 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1353 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1354 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1354 1355
1355 if ( mSelectionHeight > 0 ) { 1356 if ( mSelectionHeight > 0 ) {
1356 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1357 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1357 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1358 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1358 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1359 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1359 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1360 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1360 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1361 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1361 int hei = mSelectionHeight; 1362 int hei = mSelectionHeight;
1362 int offset = 0; 1363 int offset = 0;
1363 while ( hei > 0 ) { 1364 while ( hei > 0 ) {
1364 int p_hei = 5; 1365 int p_hei = 5;
1365 if ( hei < 5 ) p_hei = hei; 1366 if ( hei < 5 ) p_hei = hei;
1366 hei -= 5; 1367 hei -= 5;
1367 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1368 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1368 offset += 5; 1369 offset += 5;
1369 } 1370 }
1370 } 1371 }
1371 } 1372 }
1372 p->begin( pd ); 1373 p->begin( pd );
1373 } 1374 }
1374 1375
1375} 1376}
1376 1377
1377void KOAgenda::finishUpdate() 1378void KOAgenda::finishUpdate()
1378{ 1379{
1379 1380
1380 KOAgendaItem *item; 1381 KOAgendaItem *item;
1381 globalFlagBlockAgendaItemPaint = 1; 1382 globalFlagBlockAgendaItemPaint = 1;
1382 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1383 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1383 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1384 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1384 if ( !item->checkLayout() ) { 1385 if ( !item->checkLayout() ) {
1385 //qDebug(" conflictitem found "); 1386 //qDebug(" conflictitem found ");
1386 int newSubCellWidth; 1387 int newSubCellWidth;
1387 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1388 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1388 else newSubCellWidth = mGridSpacingX / item->subCells(); 1389 else newSubCellWidth = mGridSpacingX / item->subCells();
1389 1390
1390 if (mAllDayMode) { 1391 if (mAllDayMode) {
1391 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1392 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1392 } else { 1393 } else {
1393 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1394 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1394 } 1395 }
1395 int x,y; 1396 int x,y;
1396 gridToContents(item->cellX(),item->cellYTop(),x,y); 1397 gridToContents(item->cellX(),item->cellYTop(),x,y);
1397 if (mAllDayMode) { 1398 if (mAllDayMode) {
1398 y += item->subCell() * newSubCellWidth; 1399 y += item->subCell() * newSubCellWidth;
1399 } else { 1400 } else {
1400 x += item->subCell() * newSubCellWidth; 1401 x += item->subCell() * newSubCellWidth;
1401 } 1402 }
1402 moveChild(item,x,y); 1403 moveChild(item,x,y);
1403 } 1404 }
1404 } 1405 }
1405 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1406 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1406 if ( !item->isVisible() ) 1407 if ( !item->isVisible() )
1407 item->show(); 1408 item->show();
1408 1409
1409 } 1410 }
1410 globalFlagBlockAgendaItemUpdate = 0; 1411 globalFlagBlockAgendaItemUpdate = 0;
1411 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1412 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1412 item->repaintMe( ); 1413 item->repaintMe( );
1413 } 1414 }
1414 globalFlagBlockAgendaItemUpdate = 1; 1415 globalFlagBlockAgendaItemUpdate = 1;
1415 qApp->processEvents(); 1416 qApp->processEvents();
1416 globalFlagBlockAgendaItemPaint = 0; 1417 globalFlagBlockAgendaItemPaint = 0;
1417 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1418 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1418 item->repaint( false ); 1419 item->repaint( false );
1419 } 1420 }
1420 1421 marcus_bains();
1421} 1422}
1422 1423
1423/* 1424/*
1424 Draw grid in the background of the agenda. 1425 Draw grid in the background of the agenda.
1425*/ 1426*/
1426void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1427void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1427{ 1428{
1428 1429
1429 1430
1430 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1431 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1431 return; 1432 return;
1432 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1433 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1433 return; 1434 return;
1434 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1435 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1435 if ( ch < 1 ) 1436 if ( ch < 1 )
1436 ch = 1; 1437 ch = 1;
1437 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1438 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1438 mPaintPixmap.resize( contentsWidth()+42, ch ); 1439 mPaintPixmap.resize( contentsWidth()+42, ch );
1439 } 1440 }
1440 mCurPixWid = contentsWidth(); 1441 mCurPixWid = contentsWidth();
1441 mCurPixHei = ch; 1442 mCurPixHei = ch;
1442 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1443 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1443 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1444 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1444 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1445 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1445 } 1446 }
1446 mPixPainter.begin( &mPaintPixmap) ; 1447 mPixPainter.begin( &mPaintPixmap) ;
1447 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1448 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1448 QPainter * p ; 1449 QPainter * p ;
1449 if (paint == 0) { 1450 if (paint == 0) {
1450 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1451 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1451 p = &mPixPainter; 1452 p = &mPixPainter;
1452 } 1453 }
1453 else 1454 else
1454 p = paint ; 1455 p = paint ;
1455 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1456 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1456 1457
1457 //--cx;++cw; 1458 //--cx;++cw;
1458 int lGridSpacingY = mGridSpacingY*2; 1459 int lGridSpacingY = mGridSpacingY*2;
1459 int selDay; 1460 int selDay;
1460 QDate curDate = QDate::currentDate(); 1461 QDate curDate = QDate::currentDate();
1461 if ( !backgroundOnly ) { 1462 if ( !backgroundOnly ) {
1462 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1463 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1463 { 1464 {
1464 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1465 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1465 int x1 = cx; 1466 int x1 = cx;
1466 int y1 = 0; 1467 int y1 = 0;
1467 if (y1 < cy) y1 = cy; 1468 if (y1 < cy) y1 = cy;
1468 int x2 = cx+cw-1; 1469 int x2 = cx+cw-1;
1469 int y2 = contentsHeight(); 1470 int y2 = contentsHeight();
1470 if (y2 > cy+ch-1) y2=cy+ch-1; 1471 if (y2 > cy+ch-1) y2=cy+ch-1;
1471 if (x2 >= x1 && y2 >= y1) { 1472 if (x2 >= x1 && y2 >= y1) {
1472 int gxStart = selDay; 1473 int gxStart = selDay;
1473 int gxEnd = gxStart ; 1474 int gxEnd = gxStart ;
1474 int xStart = KOGlobals::self()->reverseLayout() ? 1475 int xStart = KOGlobals::self()->reverseLayout() ?
1475 (mColumns - 1 - gxStart)*mGridSpacingX : 1476 (mColumns - 1 - gxStart)*mGridSpacingX :
1476 gxStart*mGridSpacingX; 1477 gxStart*mGridSpacingX;
1477 if (xStart < x1) xStart = x1; 1478 if (xStart < x1) xStart = x1;
1478 int xEnd = KOGlobals::self()->reverseLayout() ? 1479 int xEnd = KOGlobals::self()->reverseLayout() ?
1479 (mColumns - gxStart)*mGridSpacingX-1 : 1480 (mColumns - gxStart)*mGridSpacingX-1 :
1480 (gxStart+1)*mGridSpacingX-1; 1481 (gxStart+1)*mGridSpacingX-1;
1481 if (xEnd > x2) xEnd = x2; 1482 if (xEnd > x2) xEnd = x2;
1482 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1483 if ( KOPrefs::instance()->mUseHighlightLightColor )
1483 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1484 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1484 KOPrefs::instance()->mAgendaBgColor.light()); 1485 KOPrefs::instance()->mAgendaBgColor.light());
1485 else 1486 else
1486 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1487 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1487 KOPrefs::instance()->mAgendaBgColor.dark()); 1488 KOPrefs::instance()->mAgendaBgColor.dark());
1488 1489
1489 } 1490 }
1490 } 1491 }
1491 } 1492 }
1492 } 1493 }
1493 // Highlight working hours 1494 // Highlight working hours
1494 1495
1495 if ( !backgroundOnly ) 1496 if ( !backgroundOnly )
1496 if (mWorkingHoursEnable) { 1497 if (mWorkingHoursEnable) {
1497 int x1 = cx; 1498 int x1 = cx;
1498 int y1 = mWorkingHoursYTop; 1499 int y1 = mWorkingHoursYTop;
1499 if (y1 < cy) y1 = cy; 1500 if (y1 < cy) y1 = cy;
1500 int x2 = cx+cw-1; 1501 int x2 = cx+cw-1;
1501 // int x2 = mGridSpacingX * 5 - 1; 1502 // int x2 = mGridSpacingX * 5 - 1;
1502 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1503 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1503 int y2 = mWorkingHoursYBottom; 1504 int y2 = mWorkingHoursYBottom;
1504 if (y2 > cy+ch-1) y2=cy+ch-1; 1505 if (y2 > cy+ch-1) y2=cy+ch-1;
1505 1506
1506 if (x2 >= x1 && y2 >= y1) { 1507 if (x2 >= x1 && y2 >= y1) {
1507 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1508 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1508 int gxStart = x1/mGridSpacingX; 1509 int gxStart = x1/mGridSpacingX;
1509 int gxEnd = x2/mGridSpacingX; 1510 int gxEnd = x2/mGridSpacingX;
1510 while(gxStart <= gxEnd) { 1511 while(gxStart <= gxEnd) {
1511 if (gxStart < int(mHolidayMask->count()) && 1512 if (gxStart < int(mHolidayMask->count()) &&
1512 !mHolidayMask->at(gxStart)) { 1513 !mHolidayMask->at(gxStart)) {
1513 int xStart = KOGlobals::self()->reverseLayout() ? 1514 int xStart = KOGlobals::self()->reverseLayout() ?
1514 (mColumns - 1 - gxStart)*mGridSpacingX : 1515 (mColumns - 1 - gxStart)*mGridSpacingX :
1515 gxStart*mGridSpacingX; 1516 gxStart*mGridSpacingX;
1516 if (xStart < x1) xStart = x1; 1517 if (xStart < x1) xStart = x1;
1517 int xEnd = KOGlobals::self()->reverseLayout() ? 1518 int xEnd = KOGlobals::self()->reverseLayout() ?
1518 (mColumns - gxStart)*mGridSpacingX-1 : 1519 (mColumns - gxStart)*mGridSpacingX-1 :
1519 (gxStart+1)*mGridSpacingX-1; 1520 (gxStart+1)*mGridSpacingX-1;
1520 if (xEnd > x2) xEnd = x2; 1521 if (xEnd > x2) xEnd = x2;
1521 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { 1522 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) {
1522 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1523 if ( KOPrefs::instance()->mUseHighlightLightColor )
1523 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1524 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1524 KOPrefs::instance()->mWorkingHoursColor.light()); 1525 KOPrefs::instance()->mWorkingHoursColor.light());
1525 else 1526 else
1526 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1527 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1527 KOPrefs::instance()->mWorkingHoursColor.dark()); 1528 KOPrefs::instance()->mWorkingHoursColor.dark());
1528 } else { 1529 } else {
1529 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1530 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1530 KOPrefs::instance()->mWorkingHoursColor); 1531 KOPrefs::instance()->mWorkingHoursColor);
1531 } 1532 }
1532 } 1533 }
1533 ++gxStart; 1534 ++gxStart;
1534 } 1535 }
1535 } 1536 }
1536 } 1537 }
1537 /* 1538 /*
1538 int selectionX = KOGlobals::self()->reverseLayout() ? 1539 int selectionX = KOGlobals::self()->reverseLayout() ?
1539 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1540 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1540 mSelectionCellX * mGridSpacingX; 1541 mSelectionCellX * mGridSpacingX;
1541 1542
1542 // Draw selection 1543 // Draw selection
1543 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1544 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1544 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1545 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1545 // TODO: paint only part within cx,cy,cw,ch 1546 // TODO: paint only part within cx,cy,cw,ch
1546 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1547 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1547 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1548 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1548 } 1549 }
1549 */ 1550 */
1550 // Draw vertical lines of grid 1551 // Draw vertical lines of grid
1551 1552
1552 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1553 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1553 if ( mGridSpacingX > 0 ) { 1554 if ( mGridSpacingX > 0 ) {
1554 while (x < cx + cw) { 1555 while (x < cx + cw) {
1555 p->drawLine(x,cy,x,cy+ch); 1556 p->drawLine(x,cy,x,cy+ch);
1556 x+=mGridSpacingX; 1557 x+=mGridSpacingX;
1557 } 1558 }
1558 } 1559 }
1559 // Draw horizontal lines of grid 1560 // Draw horizontal lines of grid
1560 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1561 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1561 if ( lGridSpacingY > 0 ) { 1562 if ( lGridSpacingY > 0 ) {
1562 while (y < cy + ch) { 1563 while (y < cy + ch) {
1563 p->setPen( SolidLine ); 1564 p->setPen( SolidLine );
1564 p->drawLine(cx,y,cx+cw,y); 1565 p->drawLine(cx,y,cx+cw,y);
1565 y+=lGridSpacingY; 1566 y+=lGridSpacingY;
1566 p->setPen( DotLine ); 1567 p->setPen( DotLine );
1567 p->drawLine(cx,y,cx+cw,y); 1568 p->drawLine(cx,y,cx+cw,y);
1568 y+=lGridSpacingY; 1569 y+=lGridSpacingY;
1569 } 1570 }
1570 p->setPen( SolidLine ); 1571 p->setPen( SolidLine );
1571 } 1572 }
1572 mPixPainter.end() ; 1573 mPixPainter.end() ;
1573} 1574}
1574 1575
1575/* 1576/*
1576 Convert srcollview contents coordinates to agenda grid coordinates. 1577 Convert srcollview contents coordinates to agenda grid coordinates.
1577*/ 1578*/
1578void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1579void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1579{ 1580{
1580 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1581 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1581 x/mGridSpacingX; 1582 x/mGridSpacingX;
1582 gy = y/mGridSpacingY; 1583 gy = y/mGridSpacingY;
1583} 1584}
1584 1585
1585/* 1586/*
1586 Convert agenda grid coordinates to scrollview contents coordinates. 1587 Convert agenda grid coordinates to scrollview contents coordinates.
1587*/ 1588*/
1588void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1589void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1589{ 1590{
1590 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1591 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1591 gx*mGridSpacingX; 1592 gx*mGridSpacingX;
1592 y = gy*mGridSpacingY; 1593 y = gy*mGridSpacingY;
1593} 1594}
1594 1595
1595 1596
1596/* 1597/*
1597 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1598 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1598 the grid. 1599 the grid.
1599*/ 1600*/
1600int KOAgenda::timeToY(const QTime &time) 1601int KOAgenda::timeToY(const QTime &time)
1601{ 1602{
1602 int minutesPerCell = 24 * 60 / mRows; 1603 int minutesPerCell = 24 * 60 / mRows;
1603 int timeMinutes = time.hour() * 60 + time.minute(); 1604 int timeMinutes = time.hour() * 60 + time.minute();
1604 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1605 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1605 return Y; 1606 return Y;
1606} 1607}
1607 1608
1608 1609
1609/* 1610/*
1610 Return time corresponding to cell y coordinate. Coordinates are rounded to 1611 Return time corresponding to cell y coordinate. Coordinates are rounded to
1611 fit into the grid. 1612 fit into the grid.
1612*/ 1613*/
1613QTime KOAgenda::gyToTime(int gy) 1614QTime KOAgenda::gyToTime(int gy)
1614{ 1615{
1615 1616
1616 int secondsPerCell = 24 * 60 * 60/ mRows; 1617 int secondsPerCell = 24 * 60 * 60/ mRows;
1617 1618
1618 int timeSeconds = secondsPerCell * gy; 1619 int timeSeconds = secondsPerCell * gy;
1619 1620
1620 QTime time( 0, 0, 0 ); 1621 QTime time( 0, 0, 0 );
1621 if ( timeSeconds < 24 * 60 * 60 ) { 1622 if ( timeSeconds < 24 * 60 * 60 ) {
1622 time = time.addSecs(timeSeconds); 1623 time = time.addSecs(timeSeconds);
1623 } else { 1624 } else {
1624 time.setHMS( 23, 59, 59 ); 1625 time.setHMS( 23, 59, 59 );
1625 } 1626 }
1626 1627
1627 return time; 1628 return time;
1628} 1629}
1629 1630
1630void KOAgenda::setStartHour(int startHour) 1631void KOAgenda::setStartHour(int startHour)
1631{ 1632{
1632 int startCell = startHour * mRows / 24; 1633 int startCell = startHour * mRows / 24;
1633 setContentsPos(0,startCell * gridSpacingY()); 1634 setContentsPos(0,startCell * gridSpacingY());
1634} 1635}
1635void KOAgenda::hideUnused() 1636void KOAgenda::hideUnused()
1636{ 1637{
1637 // experimental only 1638 // experimental only
1638 // return; 1639 // return;
1639 KOAgendaItem *item; 1640 KOAgendaItem *item;
1640 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1641 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1641 item->hide(); 1642 item->hide();
1642 } 1643 }
1643} 1644}
1644 1645
1645 1646
1646KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1647KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1647{ 1648{
1648 1649
1649 KOAgendaItem *fi; 1650 KOAgendaItem *fi;
1650 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1651 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1651 if ( fi->incidence() == event ) { 1652 if ( fi->incidence() == event ) {
1652 mUnusedItems.remove(); 1653 mUnusedItems.remove();
1653 fi->init( event, qd ); 1654 fi->init( event, qd );
1654 return fi; 1655 return fi;
1655 } 1656 }
1656 } 1657 }
1657 fi=mUnusedItems.first(); 1658 fi=mUnusedItems.first();
1658 if ( fi ) { 1659 if ( fi ) {
1659 mUnusedItems.remove(); 1660 mUnusedItems.remove();
1660 fi->init( event, qd ); 1661 fi->init( event, qd );
1661 return fi; 1662 return fi;
1662 } 1663 }
1663 // qDebug("new KOAgendaItem "); 1664 // qDebug("new KOAgendaItem ");
1664 1665
1665 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1666 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1666 agendaItem->installEventFilter(this); 1667 agendaItem->installEventFilter(this);
1667 addChild(agendaItem,0,0); 1668 addChild(agendaItem,0,0);
1668 return agendaItem; 1669 return agendaItem;
1669} 1670}
1670KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1671KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1671{ 1672{
1672 KOAgendaItem *item; 1673 KOAgendaItem *item;
1673 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1674 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1674 if ( item->incidence() == todo ) { 1675 if ( item->incidence() == todo ) {
1675 mItems.remove(); 1676 mItems.remove();
1676 return item; 1677 return item;
1677 } 1678 }
1678 } 1679 }
1679 return 0; 1680 return 0;
1680} 1681}
1681 1682
1682 1683
1683void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1684void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1684{ 1685{
1685 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1686 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1686 KOAgendaItem *item; 1687 KOAgendaItem *item;
1687 item = getItemForTodo ( todo ); 1688 item = getItemForTodo ( todo );
1688 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1689 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1689 if ( item ) { 1690 if ( item ) {
1690 blockSignals( true ); 1691 blockSignals( true );
1691 //qDebug("item found "); 1692 //qDebug("item found ");
1692 item->hide(); 1693 item->hide();
1693 item->setCellX(-2, -1 ); 1694 item->setCellX(-2, -1 );
1694 item->select(false); 1695 item->select(false);
1695 mUnusedItems.append( item ); 1696 mUnusedItems.append( item );
1696 mItems.remove( item ); 1697 mItems.remove( item );
1697 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1698 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1698 KOAgendaItem *itemit; 1699 KOAgendaItem *itemit;
1699 //globalFlagBlockAgendaItemPaint = 1; 1700 //globalFlagBlockAgendaItemPaint = 1;
1700 for ( itemit=oldconflictItems.first(); itemit != 0; 1701 for ( itemit=oldconflictItems.first(); itemit != 0;
1701 itemit=oldconflictItems.next() ) { 1702 itemit=oldconflictItems.next() ) {
1702 if ( itemit != item ) 1703 if ( itemit != item )
1703 placeSubCells(itemit); 1704 placeSubCells(itemit);
1704 } 1705 }
1705 qApp->processEvents(); 1706 qApp->processEvents();
1706 //globalFlagBlockAgendaItemPaint = 0; 1707 //globalFlagBlockAgendaItemPaint = 0;
1707 for ( itemit=oldconflictItems.first(); itemit != 0; 1708 for ( itemit=oldconflictItems.first(); itemit != 0;
1708 itemit=oldconflictItems.next() ) { 1709 itemit=oldconflictItems.next() ) {
1709 globalFlagBlockAgendaItemUpdate = 0; 1710 globalFlagBlockAgendaItemUpdate = 0;
1710 if ( itemit != item ) 1711 if ( itemit != item )
1711 itemit->repaintMe(); 1712 itemit->repaintMe();
1712 globalFlagBlockAgendaItemUpdate = 1; 1713 globalFlagBlockAgendaItemUpdate = 1;
1713 //qDebug("sigleshot "); 1714 //qDebug("sigleshot ");
1714 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); 1715 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1715 //itemit->repaint( false ); repaintItem() 1716 //itemit->repaint( false ); repaintItem()
1716 } 1717 }
1717 blockSignals( false ); 1718 blockSignals( false );
1718 } 1719 }
1719 if ( remove ) { 1720 if ( remove ) {
1720 //qDebug("remove****************************************** "); 1721 //qDebug("remove****************************************** ");
1721 return; 1722 return;
1722 } 1723 }
1723 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1724 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1724 return; 1725 return;
1725 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1726 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1726 QDate currentDate = QDate::currentDate(); 1727 QDate currentDate = QDate::currentDate();
1727 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1728 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
1728 QDateTime dt; 1729 QDateTime dt;
1729 if ( todo->hasCompletedDate() ) 1730 if ( todo->hasCompletedDate() )
1730 dt = todo->completed(); 1731 dt = todo->completed();
1731 else 1732 else
1732 dt = todo->dtDue(); 1733 dt = todo->dtDue();
1733 if ( overdue ) { 1734 if ( overdue ) {
1734 days += todo->dtDue().date().daysTo( currentDate ); 1735 days += todo->dtDue().date().daysTo( currentDate );
1735 } 1736 }
1736 else 1737 else
1737 currentDate = dt.date(); 1738 currentDate = dt.date();
1738 1739
1739 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1740 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1740 if ( ! mAllDayMode ) return; 1741 if ( ! mAllDayMode ) return;
1741 // aldayagenda 1742 // aldayagenda
1742 globalFlagBlockAgendaItemPaint = 1; 1743 globalFlagBlockAgendaItemPaint = 1;
1743 item = insertAllDayItem(todo, currentDate,days, days); 1744 item = insertAllDayItem(todo, currentDate,days, days);
1744 item->show(); 1745 item->show();
1745 1746
1746 } 1747 }
1747 else { 1748 else {
1748 if ( mAllDayMode ) return; 1749 if ( mAllDayMode ) return;
1749 // mAgenda 1750 // mAgenda
1750 globalFlagBlockAgendaItemPaint = 1; 1751 globalFlagBlockAgendaItemPaint = 1;
1751 int endY = timeToY(dt.time()) - 1; 1752 int endY = timeToY(dt.time()) - 1;
1752 int hi = 12/KOPrefs::instance()->mHourSize; 1753 int hi = 12/KOPrefs::instance()->mHourSize;
1753 int startY = endY - 1-hi; 1754 int startY = endY - 1-hi;
1754 item = insertItem(todo,currentDate,days,startY,endY); 1755 item = insertItem(todo,currentDate,days,startY,endY);
1755 item->show(); 1756 item->show();
1756 } 1757 }
1757 qApp->processEvents(); 1758 qApp->processEvents();
1758 globalFlagBlockAgendaItemPaint = 0; 1759 globalFlagBlockAgendaItemPaint = 0;
1759 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1760 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1760 KOAgendaItem *itemit; 1761 KOAgendaItem *itemit;
1761 for ( itemit=oldconflictItems.first(); itemit != 0; 1762 for ( itemit=oldconflictItems.first(); itemit != 0;
1762 itemit=oldconflictItems.next() ) { 1763 itemit=oldconflictItems.next() ) {
1763 globalFlagBlockAgendaItemUpdate = 0; 1764 globalFlagBlockAgendaItemUpdate = 0;
1764 itemit->repaintMe(); 1765 itemit->repaintMe();
1765 globalFlagBlockAgendaItemUpdate = 1; 1766 globalFlagBlockAgendaItemUpdate = 1;
1766 itemit->repaint(); 1767 itemit->repaint();
1767 } 1768 }
1768 globalFlagBlockAgendaItemUpdate = 0; 1769 globalFlagBlockAgendaItemUpdate = 0;
1769 item->repaintMe(); 1770 item->repaintMe();
1770 globalFlagBlockAgendaItemUpdate = 1; 1771 globalFlagBlockAgendaItemUpdate = 1;
1771 item->repaint(); 1772 item->repaint();
1772} 1773}
1773/* 1774/*
1774 Insert KOAgendaItem into agenda. 1775 Insert KOAgendaItem into agenda.
1775*/ 1776*/
1776KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1777KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1777{ 1778{
1778 if (mAllDayMode) { 1779 if (mAllDayMode) {
1779 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1780 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1780 return 0; 1781 return 0;
1781 } 1782 }
1782 1783
1783 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1784 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1784 //agendaItem->setFrameStyle(WinPanel|Raised); 1785 //agendaItem->setFrameStyle(WinPanel|Raised);
1785 1786
1786 int YSize = YBottom - YTop + 1; 1787 int YSize = YBottom - YTop + 1;
1787 if (YSize < 0) { 1788 if (YSize < 0) {
1788 YSize = 1; 1789 YSize = 1;
1789 } 1790 }
1790 int iheight = mGridSpacingY * YSize; 1791 int iheight = mGridSpacingY * YSize;
1791 1792
1792 agendaItem->resize(mGridSpacingX,iheight ); 1793 agendaItem->resize(mGridSpacingX,iheight );
1793 agendaItem->setCellXY(X,YTop,YBottom); 1794 agendaItem->setCellXY(X,YTop,YBottom);
1794 agendaItem->setCellXWidth(X); 1795 agendaItem->setCellXWidth(X);
1795 1796
1796 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1797 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1797 mItems.append(agendaItem); 1798 mItems.append(agendaItem);
1798 1799
1799 placeSubCells(agendaItem); 1800 placeSubCells(agendaItem);
1800 1801
1801 //agendaItem->show(); 1802 //agendaItem->show();
1802 1803
1803 marcus_bains();
1804 1804
1805 return agendaItem; 1805 return agendaItem;
1806} 1806}
1807 1807
1808 1808
1809/* 1809/*
1810 Insert all-day KOAgendaItem into agenda. 1810 Insert all-day KOAgendaItem into agenda.
1811*/ 1811*/
1812KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1812KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1813{ 1813{
1814 if (!mAllDayMode) { 1814 if (!mAllDayMode) {
1815 return 0; 1815 return 0;
1816 } 1816 }
1817 1817
1818 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1818 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1819 1819
1820 agendaItem->setCellXY(XBegin,0,0); 1820 agendaItem->setCellXY(XBegin,0,0);
1821 agendaItem->setCellXWidth(XEnd); 1821 agendaItem->setCellXWidth(XEnd);
1822 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1822 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1823 1823
1824 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1824 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1825 mItems.append(agendaItem); 1825 mItems.append(agendaItem);
1826 1826
1827 placeSubCells(agendaItem); 1827 placeSubCells(agendaItem);
1828 1828
1829 //agendaItem->show(); 1829 //agendaItem->show();
1830 1830
1831 return agendaItem; 1831 return agendaItem;
1832} 1832}
1833 1833
1834 1834
1835void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1835void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1836 int YTop,int YBottom) 1836 int YTop,int YBottom)
1837{ 1837{
1838 if (mAllDayMode) { 1838 if (mAllDayMode) {
1839 ; 1839 ;
1840 return; 1840 return;
1841 } 1841 }
1842 1842
1843 int cellX,cellYTop,cellYBottom; 1843 int cellX,cellYTop,cellYBottom;
1844 QString newtext; 1844 QString newtext;
1845 int width = XEnd - XBegin + 1; 1845 int width = XEnd - XBegin + 1;
1846 int count = 0; 1846 int count = 0;
1847 KOAgendaItem *current = 0; 1847 KOAgendaItem *current = 0;
1848 QPtrList<KOAgendaItem> multiItems; 1848 QPtrList<KOAgendaItem> multiItems;
1849 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1849 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1850 if (cellX == XBegin) cellYTop = YTop; 1850 if (cellX == XBegin) cellYTop = YTop;
1851 else cellYTop = 0; 1851 else cellYTop = 0;
1852 if (cellX == XEnd) cellYBottom = YBottom; 1852 if (cellX == XEnd) cellYBottom = YBottom;
1853 else cellYBottom = rows() - 1; 1853 else cellYBottom = rows() - 1;
1854 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1854 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1855 newtext.append(event->summary()); 1855 newtext.append(event->summary());
1856 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1856 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1857 current->setText(newtext); 1857 current->setText(newtext);
1858 multiItems.append(current); 1858 multiItems.append(current);
1859 } 1859 }
1860 1860
1861 KOAgendaItem *next = 0; 1861 KOAgendaItem *next = 0;
1862 KOAgendaItem *last = multiItems.last(); 1862 KOAgendaItem *last = multiItems.last();
1863 KOAgendaItem *first = multiItems.first(); 1863 KOAgendaItem *first = multiItems.first();
1864 KOAgendaItem *setFirst,*setLast; 1864 KOAgendaItem *setFirst,*setLast;
1865 current = first; 1865 current = first;
1866 while (current) { 1866 while (current) {
1867 next = multiItems.next(); 1867 next = multiItems.next();
1868 if (current == first) setFirst = 0; 1868 if (current == first) setFirst = 0;
1869 else setFirst = first; 1869 else setFirst = first;
1870 if (current == last) setLast = 0; 1870 if (current == last) setLast = 0;
1871 else setLast = last; 1871 else setLast = last;
1872 1872
1873 current->setMultiItem(setFirst,next,setLast); 1873 current->setMultiItem(setFirst,next,setLast);
1874 current = next; 1874 current = next;
1875 } 1875 }
1876
1877 marcus_bains();
1878} 1876}
1879 1877
1880 1878
1881//QSizePolicy KOAgenda::sizePolicy() const 1879//QSizePolicy KOAgenda::sizePolicy() const
1882//{ 1880//{
1883 // Thought this would make the all-day event agenda minimum size and the 1881 // Thought this would make the all-day event agenda minimum size and the
1884 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1882 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1885 // don´t seem to think that an Expanding widget needs more space than a 1883 // don´t seem to think that an Expanding widget needs more space than a
1886 // Preferred one. 1884 // Preferred one.
1887 // But it doesn´t hurt, so it stays. 1885 // But it doesn´t hurt, so it stays.
1888// if (mAllDayMode) { 1886// if (mAllDayMode) {
1889// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1887// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1890// } else { 1888// } else {
1891// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1889// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1892// } 1890// }
1893//} 1891//}
1894void KOAgenda::finishResize ( ) 1892void KOAgenda::finishResize ( )
1895{ 1893{
1896 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1894 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1897 if ( globalFlagBlockAgenda == 0 ) { 1895 if ( globalFlagBlockAgenda == 0 ) {
1898 finishUpdate(); 1896 finishUpdate();
1899 //qDebug("finishUpdate() called "); 1897 //qDebug("finishUpdate() called ");
1900 } 1898 }
1901} 1899}
1902/* 1900/*
1903 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1901 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1904*/ 1902*/
1905void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1903void KOAgenda::resizeEvent ( QResizeEvent *ev )
1906{ 1904{
1907 mSelectionHeight = 0; 1905 mSelectionHeight = 0;
1908 mResizeTimer.start( 150 , true ); 1906 mResizeTimer.start( 150 , true );
1909 computeSizes(); 1907 computeSizes();
1910 return; 1908 return;
1911 1909
1912} 1910}
1913void KOAgenda::computeSizes() 1911void KOAgenda::computeSizes()
1914{ 1912{
1915 if ( globalFlagBlockStartup ) 1913 if ( globalFlagBlockStartup )
1916 return; 1914 return;
1917 int frameOffset = frameWidth() * 2 +1; 1915 int frameOffset = frameWidth() * 2 +1;
1918 if (mAllDayMode) { 1916 if (mAllDayMode) {
1919 mGridSpacingX = (width()-frameOffset) / mColumns; 1917 mGridSpacingX = (width()-frameOffset) / mColumns;
1920 mGridSpacingY = height() - 2 * frameWidth() - 1; 1918 mGridSpacingY = height() - 2 * frameWidth() - 1;
1921 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1919 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1922 // mGridSpacingY = height(); 1920 // mGridSpacingY = height();
1923 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1921 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1924 1922
1925 KOAgendaItem *item; 1923 KOAgendaItem *item;
1926 int subCellWidth; 1924 int subCellWidth;
1927 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1925 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1928 subCellWidth = mGridSpacingY / item->subCells(); 1926 subCellWidth = mGridSpacingY / item->subCells();
1929 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1927 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1930 moveChild(item,KOGlobals::self()->reverseLayout() ? 1928 moveChild(item,KOGlobals::self()->reverseLayout() ?
1931 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1929 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1932 item->cellX() * mGridSpacingX, 1930 item->cellX() * mGridSpacingX,
1933 item->subCell() * subCellWidth); 1931 item->subCell() * subCellWidth);
1934 } 1932 }
1935 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1933 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1936 } else { 1934 } else {
1937 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1935 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1938 if (height() > mGridSpacingY * mRows + 1 ) { 1936 if (height() > mGridSpacingY * mRows + 1 ) {
1939 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1937 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1940 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1938 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1941 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1939 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1942 emit resizedSignal(); 1940 emit resizedSignal();
1943 } else 1941 } else
1944 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1942 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1945 KOAgendaItem *item; 1943 KOAgendaItem *item;
1946 int subCellWidth; 1944 int subCellWidth;
1947 1945
1948 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1946 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1949 subCellWidth = mGridSpacingX / item->subCells(); 1947 subCellWidth = mGridSpacingX / item->subCells();
1950 item->resize(subCellWidth,item->height()); 1948 item->resize(subCellWidth,item->height());
1951 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1949 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1952 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1950 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1953 item->cellX() * mGridSpacingX) + 1951 item->cellX() * mGridSpacingX) +
1954 item->subCell() * subCellWidth,childY(item)); 1952 item->subCell() * subCellWidth,childY(item));
1955 } 1953 }
1956 } 1954 }
1957 int cw = contentsWidth(); 1955 int cw = contentsWidth();
1958 int ch = contentsHeight(); 1956 int ch = contentsHeight();
1959 if ( mAllDayMode ) { 1957 if ( mAllDayMode ) {
1960 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1958 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1961 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1959 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1962 qDebug("paintPixAll->resize "); 1960 //qDebug("paintPixAll->resize ");
1963 paintPixAll->resize( cw, ch ); 1961 paintPixAll->resize( cw, ch );
1964 } 1962 }
1965 } else { 1963 } else {
1966 QPixmap* paintPix = KOAgendaItem::paintPix(); 1964 QPixmap* paintPix = KOAgendaItem::paintPix();
1967 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1965 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1968 qDebug("paintPix->resize "); 1966 //qDebug("paintPix->resize ");
1969 paintPix->resize( cw , ch ); 1967 paintPix->resize( cw , ch );
1970 } 1968 }
1971 } 1969 }
1972 1970
1973 checkScrollBoundaries(); 1971 checkScrollBoundaries();
1974 marcus_bains();
1975 drawContentsToPainter(); 1972 drawContentsToPainter();
1976 viewport()->repaint(false); 1973 viewport()->repaint(false);
1977} 1974}
1978 1975
1979void KOAgenda::scrollUp() 1976void KOAgenda::scrollUp()
1980{ 1977{
1981 scrollBy(0,-mScrollOffset); 1978 scrollBy(0,-mScrollOffset);
1982} 1979}
1983 1980
1984 1981
1985void KOAgenda::scrollDown() 1982void KOAgenda::scrollDown()
1986{ 1983{
1987 scrollBy(0,mScrollOffset); 1984 scrollBy(0,mScrollOffset);
1988} 1985}
1989 1986
1990void KOAgenda::popupAlarm() 1987void KOAgenda::popupAlarm()
1991{ 1988{
1992 if (!mClickedItem) { 1989 if (!mClickedItem) {
1993 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1990 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1994 return; 1991 return;
1995 } 1992 }
1996 // TODO: deal correctly with multiple alarms 1993 // TODO: deal correctly with multiple alarms
1997 Alarm* alarm; 1994 Alarm* alarm;
1998 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1995 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1999 for(alarm=list.first();alarm;alarm=list.next()) { 1996 for(alarm=list.first();alarm;alarm=list.next()) {
2000 alarm->toggleAlarm(); 1997 alarm->toggleAlarm();
2001 } 1998 }
2002 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1999 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
2003 mClickedItem->paintMe( true ); 2000 mClickedItem->paintMe( true );
2004 mClickedItem->repaint( false ); 2001 mClickedItem->repaint( false );
2005} 2002}
2006 2003
2007/* 2004/*
2008 Calculates the minimum width 2005 Calculates the minimum width
2009*/ 2006*/
2010int KOAgenda::minimumWidth() const 2007int KOAgenda::minimumWidth() const
2011{ 2008{
2012 // TODO:: develop a way to dynamically determine the minimum width 2009 // TODO:: develop a way to dynamically determine the minimum width
2013 int min = 100; 2010 int min = 100;
2014 2011
2015 return min; 2012 return min;
2016} 2013}
2017 2014
2018void KOAgenda::updateConfig() 2015void KOAgenda::updateConfig()
2019{ 2016{
2020 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 2017 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
2021 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 2018 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
2022 if ( mAllDayMode ) { 2019 if ( mAllDayMode ) {
2023 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 2020 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
2024 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 2021 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
2025 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 2022 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
2026 // setMaximumHeight( mGridSpacingY+1 ); 2023 // setMaximumHeight( mGridSpacingY+1 );
2027 viewport()->repaint( false ); 2024 viewport()->repaint( false );
2028 //setFixedHeight( mGridSpacingY+1 ); 2025 //setFixedHeight( mGridSpacingY+1 );
2029 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 2026 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
2030 } 2027 }
2031 else { 2028 else {
2032 mGridSpacingY = KOPrefs::instance()->mHourSize; 2029 mGridSpacingY = KOPrefs::instance()->mHourSize;
2033 calculateWorkingHours(); 2030 calculateWorkingHours();
2034 marcus_bains();
2035 } 2031 }
2036} 2032}
2037 2033
2038void KOAgenda::checkScrollBoundaries() 2034void KOAgenda::checkScrollBoundaries()
2039{ 2035{
2040 // Invalidate old values to force update 2036 // Invalidate old values to force update
2041 mOldLowerScrollValue = -1; 2037 mOldLowerScrollValue = -1;
2042 mOldUpperScrollValue = -1; 2038 mOldUpperScrollValue = -1;
2043 2039
2044 checkScrollBoundaries(verticalScrollBar()->value()); 2040 checkScrollBoundaries(verticalScrollBar()->value());
2045} 2041}
2046 2042
2047void KOAgenda::checkScrollBoundaries(int v) 2043void KOAgenda::checkScrollBoundaries(int v)
2048{ 2044{
2049 if ( mGridSpacingY == 0 ) 2045 if ( mGridSpacingY == 0 )
2050 return; 2046 return;
2051 int yMin = v/mGridSpacingY; 2047 int yMin = v/mGridSpacingY;
2052 int yMax = (v+visibleHeight())/mGridSpacingY; 2048 int yMax = (v+visibleHeight())/mGridSpacingY;
2053 2049
2054// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 2050// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
2055 2051
2056 if (yMin != mOldLowerScrollValue) { 2052 if (yMin != mOldLowerScrollValue) {
2057 mOldLowerScrollValue = yMin; 2053 mOldLowerScrollValue = yMin;
2058 emit lowerYChanged(yMin); 2054 emit lowerYChanged(yMin);
2059 } 2055 }
2060 if (yMax != mOldUpperScrollValue) { 2056 if (yMax != mOldUpperScrollValue) {
2061 mOldUpperScrollValue = yMax; 2057 mOldUpperScrollValue = yMax;
2062 emit upperYChanged(yMax); 2058 emit upperYChanged(yMax);
2063 } 2059 }
2064} 2060}
2065 2061
2066void KOAgenda::deselectItem() 2062void KOAgenda::deselectItem()
2067{ 2063{
2068 if (mSelectedItem.isNull()) return; 2064 if (mSelectedItem.isNull()) return;
2069 mSelectedItem->select(false); 2065 mSelectedItem->select(false);
2070 mSelectedItem = 0; 2066 mSelectedItem = 0;
2071} 2067}
2072 2068
2073void KOAgenda::selectItem(KOAgendaItem *item) 2069void KOAgenda::selectItem(KOAgendaItem *item)
2074{ 2070{
2075 if ((KOAgendaItem *)mSelectedItem == item) return; 2071 if ((KOAgendaItem *)mSelectedItem == item) return;
2076 deselectItem(); 2072 deselectItem();
2077 if (item == 0) { 2073 if (item == 0) {
2078 emit incidenceSelected( 0 ); 2074 emit incidenceSelected( 0 );
2079 return; 2075 return;
2080 } 2076 }
2081 mSelectedItem = item; 2077 mSelectedItem = item;
2082 mSelectedItem->select(); 2078 mSelectedItem->select();
2083 emit incidenceSelected( mSelectedItem->incidence() ); 2079 emit incidenceSelected( mSelectedItem->incidence() );
2084} 2080}
2085 2081
2086// This function seems never be called. 2082// This function seems never be called.
2087void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2083void KOAgenda::keyPressEvent( QKeyEvent *kev )
2088{ 2084{
2089 switch(kev->key()) { 2085 switch(kev->key()) {
2090 case Key_PageDown: 2086 case Key_PageDown:
2091 verticalScrollBar()->addPage(); 2087 verticalScrollBar()->addPage();
2092 break; 2088 break;
2093 case Key_PageUp: 2089 case Key_PageUp:
2094 verticalScrollBar()->subtractPage(); 2090 verticalScrollBar()->subtractPage();
2095 break; 2091 break;
2096 case Key_Down: 2092 case Key_Down:
2097 verticalScrollBar()->addLine(); 2093 verticalScrollBar()->addLine();
2098 break; 2094 break;
2099 case Key_Up: 2095 case Key_Up:
2100 verticalScrollBar()->subtractLine(); 2096 verticalScrollBar()->subtractLine();
2101 break; 2097 break;
2102 default: 2098 default:
2103 ; 2099 ;
2104 } 2100 }
2105} 2101}
2106 2102
2107void KOAgenda::calculateWorkingHours() 2103void KOAgenda::calculateWorkingHours()
2108{ 2104{
2109// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 2105// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
2110 mWorkingHoursEnable = !mAllDayMode; 2106 mWorkingHoursEnable = !mAllDayMode;
2111 2107
2112 mWorkingHoursYTop = mGridSpacingY * 2108 mWorkingHoursYTop = mGridSpacingY *
2113 KOPrefs::instance()->mWorkingHoursStart * 4; 2109 KOPrefs::instance()->mWorkingHoursStart * 4;
2114 mWorkingHoursYBottom = mGridSpacingY * 2110 mWorkingHoursYBottom = mGridSpacingY *
2115 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 2111 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
2116} 2112}
2117 2113
2118 2114
2119DateList KOAgenda::dateList() const 2115DateList KOAgenda::dateList() const
2120{ 2116{
2121 return mSelectedDates; 2117 return mSelectedDates;
2122} 2118}
2123 2119
2124void KOAgenda::setDateList(const DateList &selectedDates) 2120void KOAgenda::setDateList(const DateList &selectedDates)
2125{ 2121{
2126 mSelectedDates = selectedDates; 2122 mSelectedDates = selectedDates;
2127 marcus_bains();
2128} 2123}
2129 2124
2130void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 2125void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
2131{ 2126{
2132 mHolidayMask = mask; 2127 mHolidayMask = mask;
2133 2128
2134/* 2129/*
2135 kdDebug() << "HolidayMask: "; 2130 kdDebug() << "HolidayMask: ";
2136 for(uint i=0;i<mask->count();++i) { 2131 for(uint i=0;i<mask->count();++i) {
2137 kdDebug() << (mask->at(i) ? "*" : "o"); 2132 kdDebug() << (mask->at(i) ? "*" : "o");
2138 } 2133 }
2139 kdDebug() << endl; 2134 kdDebug() << endl;
2140*/ 2135*/
2141} 2136}
2142 2137
2143void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 2138void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2144{ 2139{
2145 2140
2146 QScrollView::contentsMousePressEvent(event); 2141 QScrollView::contentsMousePressEvent(event);
2147} 2142}
2148 2143
2149void KOAgenda::storePosition() 2144void KOAgenda::storePosition()
2150{ 2145{
2151 //mContentPosition 2146 //mContentPosition
2152 int max = mGridSpacingY*4*24; 2147 int max = mGridSpacingY*4*24;
2153 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2148 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2154 mContentPosition = 0; 2149 mContentPosition = 0;
2155 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2150 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2156 mContentPosition = -1.0; 2151 mContentPosition = -1.0;
2157 else 2152 else
2158 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2153 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2159 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2154 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2160 2155
2161} 2156}
2162void KOAgenda::restorePosition() 2157void KOAgenda::restorePosition()
2163{ 2158{
2164 int posY; 2159 int posY;
2165 int max = mGridSpacingY*4*24; 2160 int max = mGridSpacingY*4*24;
2166 if ( mContentPosition < 0 ) 2161 if ( mContentPosition < 0 )
2167 posY = max-viewport()->height(); 2162 posY = max-viewport()->height();
2168 else 2163 else
2169 if ( mContentPosition == 0 ) 2164 if ( mContentPosition == 0 )
2170 posY = 0; 2165 posY = 0;
2171 else 2166 else
2172 posY = (max/mContentPosition)-(viewport()->height()/2); 2167 posY = (max/mContentPosition)-(viewport()->height()/2);
2173 setContentsPos (0, posY ); 2168 setContentsPos (0, posY );
2174 //qDebug("posY %d hei %d", posY, max); 2169 //qDebug("posY %d hei %d", posY, max);
2175 2170
2176} 2171}
2177void KOAgenda::moveChild( QWidget *w, int x , int y ) 2172void KOAgenda::moveChild( QWidget *w, int x , int y )
2178{ 2173{
2179 ++x; 2174 ++x;
2180 QScrollView::moveChild( w, x , y ); 2175 QScrollView::moveChild( w, x , y );
2181} 2176}
2182#include <qmessagebox.h> 2177#include <qmessagebox.h>
2183#ifdef DESKTOP_VERSION 2178#ifdef DESKTOP_VERSION
2184#include <qprinter.h> 2179#include <qprinter.h>
2185#include <qpainter.h> 2180#include <qpainter.h>
2186#include <qpaintdevicemetrics.h> 2181#include <qpaintdevicemetrics.h>
2187 2182
2188#endif 2183#endif
2189void KOAgenda::printSelection() 2184void KOAgenda::printSelection()
2190{ 2185{
2191#ifdef DESKTOP_VERSION 2186#ifdef DESKTOP_VERSION
2192 if ( mStartCellY == mCurrentCellY ) { 2187 if ( mStartCellY == mCurrentCellY ) {
2193 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2188 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2194 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 2189 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
2195 i18n("OK"), 0, 0, 2190 i18n("OK"), 0, 0,
2196 0, 1 ); 2191 0, 1 );
2197 return; 2192 return;
2198 } 2193 }
2199 2194
2200 float dx, dy; 2195 float dx, dy;
2201 int x,y,w,h; 2196 int x,y,w,h;
2202 x= 0; 2197 x= 0;
2203 w= contentsWidth()+2; 2198 w= contentsWidth()+2;
2204 // h= contentsHeight(); 2199 // h= contentsHeight();
2205 y = mGridSpacingY*mStartCellY; 2200 y = mGridSpacingY*mStartCellY;
2206 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 2201 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
2207 2202
2208 //return; 2203 //return;
2209 QPrinter* printer = new QPrinter(); 2204 QPrinter* printer = new QPrinter();
2210 if ( !printer->setup()) { 2205 if ( !printer->setup()) {
2211 delete printer; 2206 delete printer;
2212 return; 2207 return;
2213 } 2208 }
2214 QPainter p( printer ); 2209 QPainter p( printer );
2215 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 2210 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
2216 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 2211 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
2217 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 2212 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
2218 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 2213 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
2219 // p.drawText( 0, 0, date ); 2214 // p.drawText( 0, 0, date );
2220 int offset = m.width()/8; 2215 int offset = m.width()/8;
2221 // compute the scale 2216 // compute the scale
2222 dx = ((float) m.width()-offset) / (float)w; 2217 dx = ((float) m.width()-offset) / (float)w;
2223 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 2218 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
2224 float scale; 2219 float scale;
2225 // scale to fit the width or height of the paper 2220 // scale to fit the width or height of the paper
2226 if ( dx < dy ) 2221 if ( dx < dy )
2227 scale = dx; 2222 scale = dx;
2228 else 2223 else
2229 scale = dy; 2224 scale = dy;
2230 // set the scale 2225 // set the scale
2231 p.drawText( offset* scale, offset* scale*3/4, date ); 2226 p.drawText( offset* scale, offset* scale*3/4, date );
2232 2227
2233 int selDay; 2228 int selDay;
2234 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 2229 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
2235 float startX = 1; 2230 float startX = 1;
2236 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 2231 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
2237 { 2232 {
2238 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 2233 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
2239 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); 2234 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) );
2240 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 2235 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
2241 startX += widOffset; 2236 startX += widOffset;
2242 2237
2243 } 2238 }
2244 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 2239 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
2245 p.scale( scale, scale ); 2240 p.scale( scale, scale );
2246 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); 2241 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale );
2247 // now printing with y offset: 2 hei 2242 // now printing with y offset: 2 hei
2248 // p.translate( 0, -y*scale); 2243 // p.translate( 0, -y*scale);
2249 2244
2250 drawContentsToPainter(&p, true ); 2245 drawContentsToPainter(&p, true );
2251 globalFlagBlockAgendaItemUpdate = false; 2246 globalFlagBlockAgendaItemUpdate = false;
2252 KOAgendaItem *item; 2247 KOAgendaItem *item;
2253 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2248 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
2254 item->select(false); 2249 item->select(false);
2255 item->paintMe( false, &p ); 2250 item->paintMe( false, &p );
2256 } 2251 }
2257 globalFlagBlockAgendaItemUpdate = true; 2252 globalFlagBlockAgendaItemUpdate = true;
2258 p.end(); 2253 p.end();
2259 delete printer; 2254 delete printer;
2260#else 2255#else
2261 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2256 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2262 i18n("Not supported \non PDA!\n"), 2257 i18n("Not supported \non PDA!\n"),
2263 i18n("OK"), 0, 0, 2258 i18n("OK"), 0, 0,
2264 0, 1 ); 2259 0, 1 );
2265#endif 2260#endif
2266} 2261}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1b21a71..ef5c4dd 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,992 +1,995 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79#define IDLETIMEOUT 15 79#define IDLETIMEOUT 45
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
215 215
216 // update HourSize 216 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(mMiniWidth,mRows * mCellHeight+1); 218 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 219}
220 220
221/** update time label positions */ 221/** update time label positions */
222void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
223{ 223{
224 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
226} 226}
227 227
228/** */ 228/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 230{
231 mAgenda = agenda; 231 mAgenda = agenda;
232} 232}
233 233
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 235{
236 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
238} 238}
239 239
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 241{
242 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
244 return; 244 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 246 if ( tSize < 4 )
247 tSize = 4; 247 tSize = 4;
248 if ( tSize > 22 ) 248 if ( tSize > 22 )
249 tSize = 22; 249 tSize = 22;
250 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 252
253} 253}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 255{
256 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
259 return; 259 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 261 if ( tSize < 4 )
262 tSize = 4; 262 tSize = 4;
263 if ( tSize > 22 ) 263 if ( tSize > 22 )
264 tSize = 22; 264 tSize = 22;
265 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 267 return;
268 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 269 emit scaleChanged();
270} 270}
271 271
272/** This is called in response to repaint() */ 272/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 273void TimeLabels::paintEvent(QPaintEvent*)
274{ 274{
275 275
276 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 277 // this is another hack!
278 // QPainter painter(this); 278 // QPainter painter(this);
279 //QString c 279 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 281}
282 282
283//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
284 284
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 286 : QFrame(parent,name)
287{ 287{
288 mColumns = 1; 288 mColumns = 1;
289 mTopBox = 0; 289 mTopBox = 0;
290 mLocation = loc; 290 mLocation = loc;
291 mTopLayout = 0; 291 mTopLayout = 0;
292 mPaintWidget = 0; 292 mPaintWidget = 0;
293 mXOffset = 0; 293 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 297 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
299} 299}
300 300
301EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
302{ 302{
303} 303}
304 304
305void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
306{ 306{
307 307
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 310 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 312 if ( ! han ) {
313 int i; 313 int i;
314 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 315 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 321 }
322 } 322 }
323 } else { 323 } else {
324 han->repaint(); 324 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
326 326
327 QPainter pa( han ); 327 QPainter pa( han );
328 int i; 328 int i;
329 bool setColor = false; 329 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 331 if (mEnabled[i]) {
332 setColor = true; 332 setColor = true;
333 333
334 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
340 340
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *))); 479 this,SLOT(categoryChanged(Incidence *)));
480 480
481 481
482 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 484 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
486 486
487 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
488 // updateConfig(); 488 // updateConfig();
489 489
490 // createDayLabels(); 490 // createDayLabels();
491 491
492 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 496
497 // Scrolling 497 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
502 502
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 505
506 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 525
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 538
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
543 543
544 // event indicator update 544 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 549 // drag signals
550 /* 550 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
555 */ 555 */
556 // synchronize selections 556 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 573
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576#ifndef DESKTOP_VERSION
576 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); 577 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) );
577 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); 578 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) );
578
579 connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); 579 connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) );
580 connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); 580 connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) );
581
582
583 mIdleTimer = new QTimer ( this );; 581 mIdleTimer = new QTimer ( this );;
584 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); 582 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout()));
583#endif
585} 584}
586void KOAgendaView::startIdleTimeout() 585void KOAgendaView::startIdleTimeout()
587{ 586{
587#ifndef DESKTOP_VERSION
588 mIdleStart = QDateTime::currentDateTime(); 588 mIdleStart = QDateTime::currentDateTime();
589 mIdleTimer->start( IDLETIMEOUT * 1000 ); 589 mIdleTimer->start( IDLETIMEOUT * 1000 );
590#endif
590} 591}
591void KOAgendaView::slotIdleTimeout() 592void KOAgendaView::slotIdleTimeout()
592{ 593{
593 qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); 594#ifndef DESKTOP_VERSION
595 //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) );
594 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); 596 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() );
595 mIdleTimer->stop(); 597 mIdleTimer->stop();
596 bool isActice = topLevelWidget()->isActiveWindow(); 598 bool isActice = topLevelWidget()->isActiveWindow();
597 qDebug("KO: Active Window %d %d", isActice, isVisible()); 599 //qDebug("KO: Active Window %d %d", isActice, isVisible());
598 // we do nothing if we wake up from a suspend 600 // we do nothing if we wake up from a suspend
599 if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { 601 if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) {
600 qDebug("KO: Wakeup from suspend "); 602 qDebug("KO: Wakeup from suspend ");
601 startIdleTimeout(); 603 startIdleTimeout();
602 return; 604 return;
603 } 605 }
604 qDebug("KO: Downsizing Pixmaps "); 606 qDebug("KO: Downsizing Pixmaps ");
605 mAgenda->shrinkPixmap(); 607 mAgenda->shrinkPixmap();
606 mAllDayAgenda->shrinkPixmap(); 608 mAllDayAgenda->shrinkPixmap();
607 KOAgendaItem::paintPix()->resize( 20,20); 609 KOAgendaItem::paintPix()->resize( 20,20);
608 KOAgendaItem::paintPixAllday()->resize( 20,20); 610 KOAgendaItem::paintPixAllday()->resize( 20,20);
611#endif
609 612
610} 613}
611void KOAgendaView::toggleAllDay() 614void KOAgendaView::toggleAllDay()
612{ 615{
613 if ( mSplitterAgenda->firstHandle() ) 616 if ( mSplitterAgenda->firstHandle() )
614 mSplitterAgenda->firstHandle()->toggle(); 617 mSplitterAgenda->firstHandle()->toggle();
615} 618}
616void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 619void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
617{ 620{
618 calendar()->addIncidence( inc ); 621 calendar()->addIncidence( inc );
619 622
620 if ( incOld ) { 623 if ( incOld ) {
621 if ( incOld->typeID() == todoID ) 624 if ( incOld->typeID() == todoID )
622 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 625 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
623 else 626 else
624 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 627 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
625 } 628 }
626 629
627} 630}
628void KOAgendaView::categoryChanged(Incidence * inc) 631void KOAgendaView::categoryChanged(Incidence * inc)
629{ 632{
630 mAgenda->categoryChanged( inc ); 633 mAgenda->categoryChanged( inc );
631 mAllDayAgenda->categoryChanged( inc ); 634 mAllDayAgenda->categoryChanged( inc );
632} 635}
633KOAgendaView::~KOAgendaView() 636KOAgendaView::~KOAgendaView()
634{ 637{
635 delete mAllAgendaPopup; 638 delete mAllAgendaPopup;
636 //delete mAllDayAgendaPopup; 639 //delete mAllDayAgendaPopup;
637 delete KOAgendaItem::paintPix(); 640 delete KOAgendaItem::paintPix();
638 delete KOAgendaItem::paintPixAllday(); 641 delete KOAgendaItem::paintPixAllday();
639} 642}
640void KOAgendaView::resizeEvent( QResizeEvent* e ) 643void KOAgendaView::resizeEvent( QResizeEvent* e )
641{ 644{
642 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 645 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
643 bool uc = false; 646 bool uc = false;
644 int ow = e->oldSize().width(); 647 int ow = e->oldSize().width();
645 int oh = e->oldSize().height(); 648 int oh = e->oldSize().height();
646 int w = e->size().width(); 649 int w = e->size().width();
647 int h = e->size().height(); 650 int h = e->size().height();
648 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 651 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
649 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 652 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
650 uc = true; 653 uc = true;
651 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 654 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
652 } 655 }
653 mUpcomingWidth = e->size().width() ; 656 mUpcomingWidth = e->size().width() ;
654 if ( mBlockUpdating || uc ) { 657 if ( mBlockUpdating || uc ) {
655 mBlockUpdating = false; 658 mBlockUpdating = false;
656 //mAgenda->setMinimumSize(800 , 600 ); 659 //mAgenda->setMinimumSize(800 , 600 );
657 //qDebug("mAgenda->resize+++++++++++++++ "); 660 //qDebug("mAgenda->resize+++++++++++++++ ");
658 updateConfig(); 661 updateConfig();
659 //qDebug("KOAgendaView::Updating now possible "); 662 //qDebug("KOAgendaView::Updating now possible ");
660 } else 663 } else
661 createDayLabels(); 664 createDayLabels();
662 //qDebug("resizeEvent end "); 665 //qDebug("resizeEvent end ");
663 666
664} 667}
665void KOAgendaView::slotDaylabelClicked( int num ) 668void KOAgendaView::slotDaylabelClicked( int num )
666{ 669{
667 670
668 QDate firstDate = mSelectedDates.first(); 671 QDate firstDate = mSelectedDates.first();
669 if ( num == -1 ) 672 if ( num == -1 )
670 emit showDateView( 6, firstDate ); 673 emit showDateView( 6, firstDate );
671 else if (num >= 0 ) { 674 else if (num >= 0 ) {
672 if ( mSelectedDates.count() == 1) 675 if ( mSelectedDates.count() == 1)
673 emit showDateView( 9, firstDate.addDays( num ) ); 676 emit showDateView( 9, firstDate.addDays( num ) );
674 else 677 else
675 emit showDateView( 3, firstDate.addDays( num ) ); 678 emit showDateView( 3, firstDate.addDays( num ) );
676 } 679 }
677 else 680 else
678 showDateView( 10, firstDate.addDays(1) ); 681 showDateView( 10, firstDate.addDays(1) );
679} 682}
680 683
681KOAgendaButton* KOAgendaView::getNewDaylabel() 684KOAgendaButton* KOAgendaView::getNewDaylabel()
682{ 685{
683 686
684 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 687 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
685 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 688 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
686 mDayLabelsList.append( dayLabel ); 689 mDayLabelsList.append( dayLabel );
687 mLayoutDayLabels->addWidget(dayLabel); 690 mLayoutDayLabels->addWidget(dayLabel);
688 return dayLabel ; 691 return dayLabel ;
689} 692}
690 693
691void KOAgendaView::createDayLabels() 694void KOAgendaView::createDayLabels()
692{ 695{
693 696
694 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 697 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
695 // qDebug(" KOAgendaView::createDayLabels() blocked "); 698 // qDebug(" KOAgendaView::createDayLabels() blocked ");
696 return; 699 return;
697 700
698 } 701 }
699 int newHight; 702 int newHight;
700 if ( !mSelectedDates.count()) 703 if ( !mSelectedDates.count())
701 return; 704 return;
702 705
703 // ### Before deleting and recreating we could check if mSelectedDates changed... 706 // ### Before deleting and recreating we could check if mSelectedDates changed...
704 // It would remove some flickering and gain speed (since this is called by 707 // It would remove some flickering and gain speed (since this is called by
705 // each updateView() call) 708 // each updateView() call)
706 709
707 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 710 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
708 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 711 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
709 if ( maxWid < 20 ) 712 if ( maxWid < 20 )
710 maxWid = 20; 713 maxWid = 20;
711 714
712 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 715 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
713 QFontMetrics fm ( dlf ); 716 QFontMetrics fm ( dlf );
714 dlf.setBold( true ); 717 dlf.setBold( true );
715 int selCount = mSelectedDates.count(); 718 int selCount = mSelectedDates.count();
716 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 719 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
717 QString dayTest = "Mon 20"; 720 QString dayTest = "Mon 20";
718 //QString dayTest = "Mon 20"; 721 //QString dayTest = "Mon 20";
719 int wid = fm.width( dayTest ); 722 int wid = fm.width( dayTest );
720 //maxWid -= ( selCount * 3 ); //working for QLabels 723 //maxWid -= ( selCount * 3 ); //working for QLabels
721 if ( QApplication::desktop()->width() <= 320 ) 724 if ( QApplication::desktop()->width() <= 320 )
722 maxWid -= ( selCount * 3 ); //working for QPushButton 725 maxWid -= ( selCount * 3 ); //working for QPushButton
723 else 726 else
724 maxWid -= ( selCount * 4 ); //working for QPushButton 727 maxWid -= ( selCount * 4 ); //working for QPushButton
725 if ( maxWid < 0 ) 728 if ( maxWid < 0 )
726 maxWid = 20; 729 maxWid = 20;
727 int needWid = wid * selCount; 730 int needWid = wid * selCount;
728 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 731 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
729 //if ( needWid > maxWid ) 732 //if ( needWid > maxWid )
730 // qDebug("DAYLABELS TOOOOOOO BIG "); 733 // qDebug("DAYLABELS TOOOOOOO BIG ");
731 while ( needWid > maxWid ) { 734 while ( needWid > maxWid ) {
732 dayTest = dayTest.left( dayTest.length() - 1 ); 735 dayTest = dayTest.left( dayTest.length() - 1 );
733 wid = fm.width( dayTest ); 736 wid = fm.width( dayTest );
734 needWid = wid * selCount; 737 needWid = wid * selCount;
735 } 738 }
736 int maxLen = dayTest.length(); 739 int maxLen = dayTest.length();
737 int fontPoint = dlf.pointSize(); 740 int fontPoint = dlf.pointSize();
738 if ( maxLen < 2 ) { 741 if ( maxLen < 2 ) {
739 int fontPoint = dlf.pointSize(); 742 int fontPoint = dlf.pointSize();
740 while ( fontPoint > 4 ) { 743 while ( fontPoint > 4 ) {
741 --fontPoint; 744 --fontPoint;
742 dlf.setPointSize( fontPoint ); 745 dlf.setPointSize( fontPoint );
743 QFontMetrics f( dlf ); 746 QFontMetrics f( dlf );
744 wid = f.width( "30" ); 747 wid = f.width( "30" );
745 needWid = wid * selCount; 748 needWid = wid * selCount;
746 if ( needWid < maxWid ) 749 if ( needWid < maxWid )
747 break; 750 break;
748 } 751 }
749 maxLen = 2; 752 maxLen = 2;
750 } 753 }
751 //qDebug("Max len %d ", dayTest.length() ); 754 //qDebug("Max len %d ", dayTest.length() );
752 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 755 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
753 dlf.setBold( false ); 756 dlf.setBold( false );
754 QFontMetrics tempF( dlf ); 757 QFontMetrics tempF( dlf );
755 newHight = tempF.height(); 758 newHight = tempF.height();
756 mDayLabels->setFont( dlf ); 759 mDayLabels->setFont( dlf );
757 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 760 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
758 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 761 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
759 //mLayoutDayLabels->addSpacing( 2 ); 762 //mLayoutDayLabels->addSpacing( 2 );
760 // QFont lFont = dlf; 763 // QFont lFont = dlf;
761 bool appendLabels = false; 764 bool appendLabels = false;
762 KOAgendaButton *dayLabel; 765 KOAgendaButton *dayLabel;
763 dayLabel = mDayLabelsList.first(); 766 dayLabel = mDayLabelsList.first();
764 if ( !dayLabel ) { 767 if ( !dayLabel ) {
765 appendLabels = true; 768 appendLabels = true;
766 dayLabel = getNewDaylabel(); 769 dayLabel = getNewDaylabel();
767 } 770 }
768 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 771 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
769 dayLabel->setFont( dlf ); 772 dayLabel->setFont( dlf );
770 dayLabel->setNum( -1 ); 773 dayLabel->setNum( -1 );
771 //dayLabel->setAlignment(QLabel::AlignHCenter); 774 //dayLabel->setAlignment(QLabel::AlignHCenter);
772 775
773 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 776 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
774 dayLabel->show(); 777 dayLabel->show();
775 DateList::ConstIterator dit; 778 DateList::ConstIterator dit;
776 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 779 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
777 int counter = -1; 780 int counter = -1;
778 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 781 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
779 ++counter; 782 ++counter;
780 QDate date = *dit; 783 QDate date = *dit;
781 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 784 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
782 if ( ! appendLabels ) { 785 if ( ! appendLabels ) {
783 dayLabel = mDayLabelsList.next(); 786 dayLabel = mDayLabelsList.next();
784 if ( !dayLabel ) 787 if ( !dayLabel )
785 appendLabels = true; 788 appendLabels = true;
786 } 789 }
787 if ( appendLabels ) { 790 if ( appendLabels ) {
788 dayLabel = getNewDaylabel(); 791 dayLabel = getNewDaylabel();
789 } 792 }
790 dayLabel->setMinimumWidth( 1 ); 793 dayLabel->setMinimumWidth( 1 );
791 dayLabel->setMaximumWidth( 10240 ); 794 dayLabel->setMaximumWidth( 10240 );
792 dayLabel->setFont( dlf ); 795 dayLabel->setFont( dlf );
793 dayLabel->show(); 796 dayLabel->show();
794 dayLabel->setAutoRepeat( false ); 797 dayLabel->setAutoRepeat( false );
795 dayLabel->setNum( counter ); 798 dayLabel->setNum( counter );
796 QString str; 799 QString str;
797 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 800 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
798 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 801 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
799 switch ( maxLen ) { 802 switch ( maxLen ) {
800 case 2: 803 case 2:
801 str = QString::number( date.day() ); 804 str = QString::number( date.day() );
802 break; 805 break;
803 806
804 case 3: 807 case 3:
805 str = dayName.left( 1 ) +QString::number( date.day()); 808 str = dayName.left( 1 ) +QString::number( date.day());
806 809
807 break; 810 break;
808 case 4: 811 case 4:
809 str = dayName.left( 1 ) + " " +QString::number( date.day()); 812 str = dayName.left( 1 ) + " " +QString::number( date.day());
810 813
811 break; 814 break;
812 case 5: 815 case 5:
813 str = dayName.left( 2 ) + " " +QString::number( date.day()); 816 str = dayName.left( 2 ) + " " +QString::number( date.day());
814 817
815 break; 818 break;
816 case 6: 819 case 6:
817 str = dayName.left( 3 ) + " " +QString::number( date.day()); 820 str = dayName.left( 3 ) + " " +QString::number( date.day());
818 break; 821 break;
819 822
820 default: 823 default:
821 break; 824 break;
822 } 825 }
823 if ( oneday ) { 826 if ( oneday ) {
824 QString addString; 827 QString addString;
825 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 828 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
826 addString = i18n("Today"); 829 addString = i18n("Today");
827 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 830 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
828 addString = i18n("Tomorrow"); 831 addString = i18n("Tomorrow");
829 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 832 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
830 addString = i18n("Yesterday"); 833 addString = i18n("Yesterday");
831 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 834 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
832 addString = i18n("Day before yesterday"); 835 addString = i18n("Day before yesterday");
833 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 836 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
834 addString = i18n("Day after tomorrow"); 837 addString = i18n("Day after tomorrow");
835 if ( !addString.isEmpty() ) { 838 if ( !addString.isEmpty() ) {
836 str = addString+", " + str; 839 str = addString+", " + str;
837 } else { 840 } else {
838 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 841 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
839 } 842 }
840 } 843 }
841 dayLabel->setText(str); 844 dayLabel->setText(str);
842 //dayLabel->setAlignment(QLabel::AlignHCenter); 845 //dayLabel->setAlignment(QLabel::AlignHCenter);
843 if (date == QDate::currentDate()) { 846 if (date == QDate::currentDate()) {
844 QFont bFont = dlf; 847 QFont bFont = dlf;
845 bFont.setBold( true ); 848 bFont.setBold( true );
846 dayLabel->setFont(bFont); 849 dayLabel->setFont(bFont);
847 } 850 }
848 //dayLayout->addWidget(dayLabel); 851 //dayLayout->addWidget(dayLabel);
849 852
850#ifndef KORG_NOPLUGINS 853#ifndef KORG_NOPLUGINS
851 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 854 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
852 CalendarDecoration *it; 855 CalendarDecoration *it;
853 for(it = cds.first(); it; it = cds.next()) { 856 for(it = cds.first(); it; it = cds.next()) {
854 QString text = it->shortText( date ); 857 QString text = it->shortText( date );
855 if ( !text.isEmpty() ) { 858 if ( !text.isEmpty() ) {
856 QLabel *label = new QLabel(text,mDayLabels); 859 QLabel *label = new QLabel(text,mDayLabels);
857 label->setAlignment(AlignCenter); 860 label->setAlignment(AlignCenter);
858 dayLayout->addWidget(label); 861 dayLayout->addWidget(label);
859 } 862 }
860 } 863 }
861 864
862 for(it = cds.first(); it; it = cds.next()) { 865 for(it = cds.first(); it; it = cds.next()) {
863 QWidget *wid = it->smallWidget(mDayLabels,date); 866 QWidget *wid = it->smallWidget(mDayLabels,date);
864 if ( wid ) { 867 if ( wid ) {
865 // wid->setHeight(20); 868 // wid->setHeight(20);
866 dayLayout->addWidget(wid); 869 dayLayout->addWidget(wid);
867 } 870 }
868 } 871 }
869#endif 872#endif
870 } 873 }
871 if ( ! appendLabels ) { 874 if ( ! appendLabels ) {
872 dayLabel = mDayLabelsList.next(); 875 dayLabel = mDayLabelsList.next();
873 if ( !dayLabel ) 876 if ( !dayLabel )
874 appendLabels = true; 877 appendLabels = true;
875 } 878 }
876 if ( appendLabels ) { 879 if ( appendLabels ) {
877 dayLabel = getNewDaylabel(); 880 dayLabel = getNewDaylabel();
878 } 881 }
879 //dayLabel->hide();//test only 882 //dayLabel->hide();//test only
880 883
881 dayLabel->setText(">"); 884 dayLabel->setText(">");
882 dayLabel->setFont( dlf ); 885 dayLabel->setFont( dlf );
883 dayLabel->setAutoRepeat( true ); 886 dayLabel->setAutoRepeat( true );
884 dayLabel->show(); 887 dayLabel->show();
885 dayLabel->setNum( -2 ); 888 dayLabel->setNum( -2 );
886 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 889 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
887 890
888 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 891 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
889 if ( !appendLabels ) { 892 if ( !appendLabels ) {
890 dayLabel = mDayLabelsList.next(); 893 dayLabel = mDayLabelsList.next();
891 while ( dayLabel ) { 894 while ( dayLabel ) {
892 //qDebug("!dayLabel %d",dayLabel ); 895 //qDebug("!dayLabel %d",dayLabel );
893 dayLabel->hide(); 896 dayLabel->hide();
894 dayLabel = mDayLabelsList.next(); 897 dayLabel = mDayLabelsList.next();
895 } 898 }
896 } 899 }
897 900
898 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 901 mDayLabelsFrame->setFixedHeight( newHight + 4 );
899} 902}
900 903
901int KOAgendaView::maxDatesHint() 904int KOAgendaView::maxDatesHint()
902{ 905{
903 // Not sure about the max number of events, so return 0 for now. 906 // Not sure about the max number of events, so return 0 for now.
904 return 0; 907 return 0;
905} 908}
906 909
907int KOAgendaView::currentDateCount() 910int KOAgendaView::currentDateCount()
908{ 911{
909 return mSelectedDates.count(); 912 return mSelectedDates.count();
910} 913}
911 914
912QPtrList<Incidence> KOAgendaView::selectedIncidences() 915QPtrList<Incidence> KOAgendaView::selectedIncidences()
913{ 916{
914 QPtrList<Incidence> selected; 917 QPtrList<Incidence> selected;
915 Incidence *incidence; 918 Incidence *incidence;
916 919
917 incidence = mAgenda->selectedIncidence(); 920 incidence = mAgenda->selectedIncidence();
918 if (incidence) selected.append(incidence); 921 if (incidence) selected.append(incidence);
919 922
920 incidence = mAllDayAgenda->selectedIncidence(); 923 incidence = mAllDayAgenda->selectedIncidence();
921 if (incidence) selected.append(incidence); 924 if (incidence) selected.append(incidence);
922 925
923 return selected; 926 return selected;
924} 927}
925 928
926DateList KOAgendaView::selectedDates() 929DateList KOAgendaView::selectedDates()
927{ 930{
928 DateList selected; 931 DateList selected;
929 QDate qd; 932 QDate qd;
930 933
931 qd = mAgenda->selectedIncidenceDate(); 934 qd = mAgenda->selectedIncidenceDate();
932 if (qd.isValid()) selected.append(qd); 935 if (qd.isValid()) selected.append(qd);
933 936
934 qd = mAllDayAgenda->selectedIncidenceDate(); 937 qd = mAllDayAgenda->selectedIncidenceDate();
935 if (qd.isValid()) selected.append(qd); 938 if (qd.isValid()) selected.append(qd);
936 939
937 return selected; 940 return selected;
938} 941}
939 942
940 943
941void KOAgendaView::updateView() 944void KOAgendaView::updateView()
942{ 945{
943 if ( mBlockUpdating ) 946 if ( mBlockUpdating )
944 return; 947 return;
945 // kdDebug() << "KOAgendaView::updateView()" << endl; 948 // kdDebug() << "KOAgendaView::updateView()" << endl;
946 fillAgenda(); 949 fillAgenda();
947 950
948} 951}
949 952
950 953
951/* 954/*
952 Update configuration settings for the agenda view. This method is not 955 Update configuration settings for the agenda view. This method is not
953 complete. 956 complete.
954*/ 957*/
955void KOAgendaView::updateConfig() 958void KOAgendaView::updateConfig()
956{ 959{
957 if ( mBlockUpdating ) 960 if ( mBlockUpdating )
958 return; 961 return;
959 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 962 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
960 int old = KOPrefs::instance()->mHourSize; 963 int old = KOPrefs::instance()->mHourSize;
961 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 964 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
962 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 965 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
963 } 966 }
964 967
965 968
966 // update config for children 969 // update config for children
967 mTimeLabels->updateConfig(); 970 mTimeLabels->updateConfig();
968 mAgenda->storePosition(); 971 mAgenda->storePosition();
969 mAgenda->updateConfig(); 972 mAgenda->updateConfig();
970 mAllDayAgenda->updateConfig(); 973 mAllDayAgenda->updateConfig();
971 // widget synchronization 974 // widget synchronization
972 //TODO: find a better way, maybe signal/slot 975 //TODO: find a better way, maybe signal/slot
973 mTimeLabels->positionChanged(); 976 mTimeLabels->positionChanged();
974 977
975 // for some reason, this needs to be called explicitly 978 // for some reason, this needs to be called explicitly
976 mTimeLabels->repaint(); 979 mTimeLabels->repaint();
977 980
978 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 981 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
979 982
980 // ToolTips displaying summary of events 983 // ToolTips displaying summary of events
981 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 984 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
982 ->mEnableToolTips); 985 ->mEnableToolTips);
983 986
984 //setHolidayMasks(); 987 //setHolidayMasks();
985 988
986 //createDayLabels(); called by via updateView(); 989 //createDayLabels(); called by via updateView();
987 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 990 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
988 updateView(); 991 updateView();
989 mAgenda->restorePosition(); 992 mAgenda->restorePosition();
990} 993}
991 994
992 995
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index ff80afc..7ce3f1f 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,469 +1,486 @@
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 <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32 32
33 33
34#include <libkcal/calfilter.h> 34#include <libkcal/calfilter.h>
35 35
36#include "kofilterview.h" 36#include "kofilterview.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#include <kiconloader.h> 38#include <kiconloader.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <kglobalsettings.h>
40#include <kcolorbutton.h> 41#include <kcolorbutton.h>
41#include <kmessagebox.h> 42#include <kmessagebox.h>
42 43
43 44
44 45
45 46
46 47
47KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 48KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
48 const char* name,WFlags fl ) 49 const char* name,WFlags fl )
49 : KOFilterView_base(parent,name,fl) 50 : KOFilterView_base(parent,name,fl)
50{ 51{
51 mFilters = filterList; 52 mFilters = filterList;
52 53
53 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 54 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
54 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 55 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
55 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 56 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
56} 57}
57 58
58KOFilterView::~KOFilterView() 59KOFilterView::~KOFilterView()
59{ 60{
60 // no need to delete child widgets, Qt does it all for us 61 // no need to delete child widgets, Qt does it all for us
61} 62}
62 63
63bool KOFilterView::filtersEnabled() 64bool KOFilterView::filtersEnabled()
64{ 65{
65 return mEnabledCheck->isChecked(); 66 return mEnabledCheck->isChecked();
66} 67}
67 68
68void KOFilterView::setFiltersEnabled(bool set) 69void KOFilterView::setFiltersEnabled(bool set)
69{ 70{
70 mEnabledCheck->setChecked(set); 71 mEnabledCheck->setChecked(set);
71 emit filterChanged(); 72 emit filterChanged();
72} 73}
73 74
74 75
75void KOFilterView::updateFilters() 76void KOFilterView::updateFilters()
76{ 77{
77 mSelectionCombo->clear(); 78 mSelectionCombo->clear();
78 79
79 CalFilter *filter = mFilters->first(); 80 CalFilter *filter = mFilters->first();
80 while(filter) { 81 while(filter) {
81 mSelectionCombo->insertItem(filter->name()); 82 mSelectionCombo->insertItem(filter->name());
82 filter = mFilters->next(); 83 filter = mFilters->next();
83 } 84 }
84} 85}
85 86
86CalFilter *KOFilterView::selectedFilter() 87CalFilter *KOFilterView::selectedFilter()
87{ 88{
88 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 89 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
89 return f; 90 return f;
90} 91}
91 92
92void KOFilterView::setSelectedFilter(QString filterName) 93void KOFilterView::setSelectedFilter(QString filterName)
93{ 94{
94 int filter_num = mSelectionCombo->count(); 95 int filter_num = mSelectionCombo->count();
95 int i; 96 int i;
96 for (i=0;i<filter_num;i++) { 97 for (i=0;i<filter_num;i++) {
97 if (mSelectionCombo->text(i)==filterName) 98 if (mSelectionCombo->text(i)==filterName)
98 mSelectionCombo->setCurrentItem(i); 99 mSelectionCombo->setCurrentItem(i);
99 } 100 }
100 emit filterChanged(); 101 emit filterChanged();
101} 102}
102void KOFilterView::setSelectedFilter( int fil ) 103void KOFilterView::setSelectedFilter( int fil )
103{ 104{
104 if ( fil >= mSelectionCombo->count() ) 105 if ( fil >= mSelectionCombo->count() )
105 return; 106 return;
106 mSelectionCombo->setCurrentItem( fil ); 107 mSelectionCombo->setCurrentItem( fil );
107 emit filterChanged(); 108 emit filterChanged();
108} 109}
109 110
110 111
111 112
112KOCalEditView::KOCalEditView(QWidget* parent, 113KOCalEditView::KOCalEditView(QWidget* parent,
113 const char* name ) 114 const char* name )
114 : QScrollView(parent,name) 115 : QScrollView(parent,name)
115{ 116{
116 mw = 0; 117 mw = 0;
117 setResizePolicy( AutoOneFit ); 118 setResizePolicy( AutoOneFit );
118 setFrameStyle ( QFrame::Panel | QFrame::Plain ); 119 setFrameStyle ( QFrame::Panel | QFrame::Plain );
119 setLineWidth ( 1 ); 120 setLineWidth ( 1 );
120 setMidLineWidth ( 1 ); 121 setMidLineWidth ( 1 );
121 setFocusPolicy(NoFocus); 122 setFocusPolicy(NoFocus);
122} 123}
123 124
124KOCalEditView::~KOCalEditView() 125KOCalEditView::~KOCalEditView()
125{ 126{
126 // no need to delete child widgets, Qt does it all for us 127 // no need to delete child widgets, Qt does it all for us
127} 128}
128void KOCalEditView::selectCal(int id ,bool b) 129void KOCalEditView::selectCal(int id ,bool b)
129{ 130{
130 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 131 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
131 emit calendarEnabled ( id, b ); 132 emit calendarEnabled ( id, b );
132 emit needsUpdate(); 133 emit needsUpdate();
133 134
134} 135}
135void KOCalEditView::selectStdCal( int id ) 136void KOCalEditView::selectStdCal( int id )
136{ 137{
137 KOCalRadioButton* it = mStdandardB.first(); 138 KOCalRadioButton* it = mStdandardB.first();
138 while ( it ) { 139 while ( it ) {
139 it->blockSignals( true ); 140 it->blockSignals( true );
140 it->setChecked( it->num() == id ); 141 it->setChecked( it->num() == id );
141 it->blockSignals( false ); 142 it->blockSignals( false );
142 it = mStdandardB.next(); 143 it = mStdandardB.next();
143 } 144 }
144 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 145 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
145 while ( kkf ) { 146 while ( kkf ) {
146 kkf->isStandard = (kkf->mCalNumber == id ); 147 kkf->isStandard = (kkf->mCalNumber == id );
147 kkf = KOPrefs::instance()->mCalendars.next(); 148 kkf = KOPrefs::instance()->mCalendars.next();
148 } 149 }
149 emit setCalendarDefault ( id ); 150 emit setCalendarDefault ( id );
150} 151}
151 152
152void KOCalEditView::selectCalAlarm(int id ,bool b ) 153void KOCalEditView::selectCalAlarm(int id ,bool b )
153{ 154{
154 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 155 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
155 emit alarmEnabled ( id , b ); 156 emit alarmEnabled ( id , b );
156 emit needsUpdate(); 157 emit needsUpdate();
157} 158}
158void KOCalEditView::selectReadOnly(int id ,bool b ) 159void KOCalEditView::selectReadOnly(int id ,bool b )
159{ 160{
160 161
161 emit calendarReadonly ( id , b ); 162 emit calendarReadonly ( id , b );
162 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 163 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
163 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) { 164 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b ) {
164 findNewStandard(); 165 findNewStandard();
165 } 166 }
166 if ( !b ){ 167 if ( !b ){
167 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 168 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
168 while ( kkf ) { 169 while ( kkf ) {
169 if (kkf->isReadOnly && kkf->isStandard ) { 170 if (kkf->isReadOnly && kkf->isStandard ) {
170 selectStdCal( id ); 171 selectStdCal( id );
171 break; 172 break;
172 } 173 }
173 kkf = KOPrefs::instance()->mCalendars.next(); 174 kkf = KOPrefs::instance()->mCalendars.next();
174 } 175 }
175 } 176 }
176 177
177 mStdandardB.at(id-1)->setEnabled( !b ); 178 mStdandardB.at(id-1)->setEnabled( !b );
178 emit needsUpdate(); 179 emit needsUpdate();
179 180
180} 181}
181void KOCalEditView::findNewStandard() 182void KOCalEditView::findNewStandard()
182{ 183{
183 bool found = false; 184 bool found = false;
184 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 185 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
185 while ( kkf ) { 186 while ( kkf ) {
186 if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) { 187 if (!kkf->isReadOnly && !kkf->mErrorOnLoad ) {
187 found = true; 188 found = true;
188 selectStdCal( kkf->mCalNumber ); 189 selectStdCal( kkf->mCalNumber );
189 break; 190 break;
190 } 191 }
191 kkf = KOPrefs::instance()->mCalendars.next(); 192 kkf = KOPrefs::instance()->mCalendars.next();
192 } 193 }
193 if ( !found ) { 194 if ( !found ) {
194 KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"), 195 KMessageBox::error( this,i18n("\nNO\n WRITEABLE\n CALENDAR\n FOUND!\n\nPlease fix your calendar settings!\n"),
195 i18n("Houston, we have a problem!") ); 196 i18n("Houston, we have a problem!") );
196 197
197 } 198 }
198} 199}
199 200
200void KOCalEditView::setColor( const QColor& c, int id ) 201void KOCalEditView::setColor( const QColor& c, int id )
201{ 202{
202 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 203 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
203 emit needsUpdate(); 204 emit needsUpdate();
204} 205}
205void KOCalEditView::deleteCal( int id ) 206void KOCalEditView::deleteCal( int id )
206{ 207{
207 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 208 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
208 QString name = kkf->mName; 209 QString name = kkf->mName;
209 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 210 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
210 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 211 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>. Do you want to remove this calendar from KO/Pi? (The file is not removed!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
211 bool findnewstd = kkf->isStandard; 212 bool findnewstd = kkf->isStandard;
212 emit removeCalendar ( id ); 213 emit removeCalendar ( id );
213 KOPrefs::instance()->mCalendars.remove ( kkf ); 214 KOPrefs::instance()->mCalendars.remove ( kkf );
214 if ( findnewstd ) findNewStandard(); 215 if ( findnewstd ) findNewStandard();
215 emit needsUpdate(); 216 emit needsUpdate();
216 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 217 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
217} 218}
218void KOCalEditView::infoCal( int id ) 219void KOCalEditView::infoCal( int id )
219{ 220{
220 QString name = KOPrefs::instance()->getCalendar( id )->mName; 221 QString name = KOPrefs::instance()->getCalendar( id )->mName;
221 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 ); 222 QString file = KGlobal::formatMessage ( KOPrefs::instance()->getCalendar( id )->mFileName, 0 );
222 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { 223 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
223 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { 224 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) {
224 emit calendarAdded( id ); 225 emit calendarAdded( id );
225 emit needsUpdate(); 226 emit needsUpdate();
226 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 227 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
227 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 228 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
228 } 229 }
229 } 230 }
230 else 231 else
231 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 232 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
232} 233}
233void KOCalEditView::readConfig() 234void KOCalEditView::readConfig()
234{ 235{
235 236
236 mStdandardB.clear(); 237 mStdandardB.clear();
237 mEnabledB.clear(); 238 mEnabledB.clear();
238 mAlarmB.clear(); 239 mAlarmB.clear();
239 mROB.clear(); 240 mROB.clear();
240 241
241 if ( mw ) delete mw; 242 if ( mw ) delete mw;
242 mw = new QWidget ( viewport() ); 243 mw = new QWidget ( viewport() );
243 addChild(mw); 244 addChild(mw);
244 int ii = 0; 245 int ii = 0;
245 mainLayout = new QGridLayout ( mw , 2, 8 ); 246 mainLayout = new QGridLayout ( mw , 2, 8 );
246 mainLayout->setMargin( 2 ); 247 mainLayout->setMargin( 2 );
247 mainLayout->setSpacing( 2 ); 248 mainLayout->setSpacing( 2 );
248 QPushButton * addButT = new QPushButton ( mw ); 249 QPushButton * addButT = new QPushButton ( mw );
249 addButT->setFocusPolicy(NoFocus); 250 addButT->setFocusPolicy(NoFocus);
250 mainLayout->addWidget( addButT,0,0 ); 251 mainLayout->addWidget( addButT,0,0 );
251 addButT->setText( "D"); 252 addButT->setText( "D");
252 connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo())); 253 connect(addButT,SIGNAL(clicked()),SLOT(defaultInfo()));
253 //addBut->setPixmap ( SmallIcon("greenhook16")); 254 //addBut->setPixmap ( SmallIcon("greenhook16"));
254 QPushButton *addBut = new QPushButton ( mw ); 255 QPushButton *addBut = new QPushButton ( mw );
255 addBut->setFocusPolicy(NoFocus); 256 addBut->setFocusPolicy(NoFocus);
256 mainLayout->addWidget( addBut,0,++ii ); 257 mainLayout->addWidget( addBut,0,++ii );
257 addBut->setPixmap ( SmallIcon("eye")); 258 addBut->setPixmap ( SmallIcon("eye"));
258 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 259 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
259 int max = addBut->sizeHint().height(); 260 int max = addBut->sizeHint().height();
260 addBut->setMaximumWidth( max ); 261 addBut->setMaximumWidth( max );
261 addButT->setFixedSize( QSize( max, max ) ); 262 addButT->setFixedSize( QSize( max, max ) );
262 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); 263 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw );
263 mainLayout->addWidget( lab,0,++ii ); 264 mainLayout->addWidget( lab,0,++ii );
264 //lab = new QLabel ( i18n(" "), mw ); 265 //lab = new QLabel ( i18n(" "), mw );
265 //mainLayout->addWidget( lab,0,++ii ); 266 //mainLayout->addWidget( lab,0,++ii );
266 //lab->setFixedWidth( 1 ); 267 //lab->setFixedWidth( 1 );
267 addBut = new QPushButton ( mw ); 268 addBut = new QPushButton ( mw );
268 addBut->setFocusPolicy(NoFocus); 269 addBut->setFocusPolicy(NoFocus);
269 mainLayout->addWidget( addBut,0,++ii ); 270 mainLayout->addWidget( addBut,0,++ii );
270 addBut->setPixmap ( SmallIcon("bell")); 271 addBut->setPixmap ( SmallIcon("bell"));
271 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 272 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
272 addBut->setMaximumWidth( addBut->sizeHint().height() ); 273 addBut->setMaximumWidth( addBut->sizeHint().height() );
273 274
274 addBut = new QPushButton ( mw ); 275 addBut = new QPushButton ( mw );
275 addBut->setFocusPolicy(NoFocus); 276 addBut->setFocusPolicy(NoFocus);
276 mainLayout->addWidget( addBut,0,++ii ); 277 mainLayout->addWidget( addBut,0,++ii );
277 addBut->setPixmap ( SmallIcon("pencil")); 278 addBut->setPixmap ( SmallIcon("pencil"));
278 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 279 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
279 addBut->setMaximumWidth( addBut->sizeHint().height() ); 280 addBut->setMaximumWidth( addBut->sizeHint().height() );
280 lab = new QLabel ( "", mw ); 281 lab = new QLabel ( "", mw );
281 mainLayout->addWidget( lab,0,++ii ); 282 mainLayout->addWidget( lab,0,++ii );
282 283
283 addBut = new QPushButton ( mw ); 284 addBut = new QPushButton ( mw );
284 addBut->setFocusPolicy(NoFocus); 285 addBut->setFocusPolicy(NoFocus);
285 mainLayout->addWidget( addBut,0,++ii ); 286 mainLayout->addWidget( addBut,0,++ii );
286 addBut->setPixmap ( SmallIcon("plus")); 287 addBut->setPixmap ( SmallIcon("plus"));
287 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 288 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
288 289
289 lab = new QLabel ( " ", mw ); 290 lab = new QLabel ( " ", mw );
290 mainLayout->addWidget( lab,0,++ii ); 291 mainLayout->addWidget( lab,0,++ii );
291 292
292 293
293 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 294 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
294 int row = 1; 295 int row = 1;
295 bool errorLoadStandard = false; 296 bool errorLoadStandard = false;
296 while ( kkf ) { 297 while ( kkf ) {
297 int iii = 0; 298 int iii = 0;
298 KOCalRadioButton* rb = new KOCalRadioButton( mw ); 299 KOCalRadioButton* rb = new KOCalRadioButton( mw );
299 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb ); 300 mainLayout->addWidget( rb,row,0 );mStdandardB.append( rb );
300 rb->setChecked( kkf->isStandard ); 301 rb->setChecked( kkf->isStandard );
301 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) ) 302 if ( kkf->isStandard && ( kkf->mErrorOnLoad || kkf->isReadOnly ) )
302 errorLoadStandard = true; 303 errorLoadStandard = true;
303 rb->setNum( kkf->mCalNumber ); 304 rb->setNum( kkf->mCalNumber );
304 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) ); 305 connect (rb, SIGNAL (selectNum(int)), SLOT ( selectStdCal(int) ) );
305 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 306 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
306 rb->setEnabled( false ); 307 rb->setEnabled( false );
307 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 308 KOCalCheckButton* cb = new KOCalCheckButton( mw );
308 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); 309 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
309 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad ); 310 cb->setChecked( kkf->isEnabled && !kkf->mErrorOnLoad );
310 cb->setNum( kkf->mCalNumber ); 311 cb->setNum( kkf->mCalNumber );
311 if ( kkf->mErrorOnLoad ) 312 if ( kkf->mErrorOnLoad )
312 cb->setEnabled( false ); 313 cb->setEnabled( false );
313 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 314 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
314 KOCalButton* name = new KOCalButton( mw ); 315 KOCalButton* name = new KOCalButton( mw );
315 name->setNum( kkf->mCalNumber ); 316 name->setNum( kkf->mCalNumber );
316 name->setText( kkf->mName ); 317 name->setText( kkf->mName );
317 mainLayout->addWidget( name,row,++iii ); 318 mainLayout->addWidget( name,row,++iii );
318 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 319 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
319 //lab = new QLabel (" ", mw ); 320 //lab = new QLabel (" ", mw );
320 //mainLayout->addWidget( lab,row,++iii ); 321 //mainLayout->addWidget( lab,row,++iii );
321 cb = new KOCalCheckButton( mw ); 322 cb = new KOCalCheckButton( mw );
322 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); 323 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
323 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad); 324 cb->setChecked( kkf->isAlarmEnabled && !kkf->mErrorOnLoad);
324 cb->setNum( kkf->mCalNumber ); 325 cb->setNum( kkf->mCalNumber );
325 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 326 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
326 if ( kkf->mErrorOnLoad ) 327 if ( kkf->mErrorOnLoad )
327 cb->setEnabled( false ); 328 cb->setEnabled( false );
328 cb = new KOCalCheckButton( mw ); 329 cb = new KOCalCheckButton( mw );
329 mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); 330 mainLayout->addWidget( cb,row,++iii );mROB.append( cb );
330 cb->setChecked( kkf->isReadOnly ); 331 cb->setChecked( kkf->isReadOnly );
331 cb->setNum( kkf->mCalNumber ); 332 cb->setNum( kkf->mCalNumber );
332 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 333 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
333 if ( kkf->mErrorOnLoad ) 334 if ( kkf->mErrorOnLoad )
334 cb->setEnabled( false ); 335 cb->setEnabled( false );
335 if ( row > 1) { 336 if ( row > 1) {
336 KColorButton *colb = new KColorButton( mw ); 337 KColorButton *colb = new KColorButton( mw );
337 mainLayout->addWidget( colb,row,++iii ); 338 mainLayout->addWidget( colb,row,++iii );
338 colb->setID( kkf->mCalNumber ); 339 colb->setID( kkf->mCalNumber );
339 colb->setColor( kkf->mDefaultColor ); 340 colb->setColor( kkf->mDefaultColor );
340 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 341 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
341 KOCalButton* calb = new KOCalButton( mw ); 342 KOCalButton* calb = new KOCalButton( mw );
342 mainLayout->addWidget( calb,row,++iii ); 343 mainLayout->addWidget( calb,row,++iii );
343 calb->setNum( kkf->mCalNumber ); 344 calb->setNum( kkf->mCalNumber );
344 calb->setPixmap ( SmallIcon("minus")); 345 calb->setPixmap ( SmallIcon("minus"));
345 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 346 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
346 int hei = calb->sizeHint().height(); 347 int hei = calb->sizeHint().height();
347 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 348 //calb->setMaximumSize( hei*9/10, hei*9/10 );
348 } 349 }
349 ++row; 350 ++row;
350 kkf = KOPrefs::instance()->mCalendars.next(); 351 kkf = KOPrefs::instance()->mCalendars.next();
351 } 352 }
352 if ( errorLoadStandard ) 353 if ( errorLoadStandard )
353 findNewStandard(); 354 findNewStandard();
354 lab = new QLabel ( "", mw ); 355 lab = new QLabel ( "", mw );
355 mainLayout->addWidget( lab,row,0 ); 356 mainLayout->addWidget( lab,row,0 );
356 mw->show(); 357 mw->show();
357 358
358} 359}
359 360
360void KOCalEditView::defaultInfo() 361void KOCalEditView::defaultInfo()
361{ 362{
362 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") ); 363 KMessageBox::information( this, i18n("Please choose the <b>default calendar</b> in this column. Newly created or imported items are added to the default calendar.") );
363} 364}
364void KOCalEditView::addCal() 365void KOCalEditView::addCal()
365{ 366{
366 bool tryagain = true; 367 bool tryagain = true;
367 QString name, file; 368 QString name, file;
368 while ( tryagain ) { 369 while ( tryagain ) {
369 KONewCalPrefs prefs ( this ); 370 KONewCalPrefs prefs ( this );
370 prefs.nameE->setText( name ); 371 prefs.nameE->setText( name );
371 prefs.url->setURL( file ); 372 prefs.url->setURL( file );
372 if ( ! prefs.exec() ) 373 if ( ! prefs.exec() )
373 return; 374 return;
374 name = prefs.calName(); 375 name = prefs.calName();
375 file = prefs.calFileName(); 376 file = prefs.calFileName();
376 tryagain = false; 377 tryagain = false;
377 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 378 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
378 while ( kkf ) { 379 while ( kkf ) {
379 if ( kkf->mName == name ) { 380 if ( kkf->mName == name ) {
380 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) ); 381 KMessageBox::information( this, i18n("Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!").arg( name ) );
381 name = ""; 382 name = "";
382 tryagain = true; 383 tryagain = true;
383 break; 384 break;
384 } 385 }
385 if ( kkf->mFileName == file ) { 386 if ( kkf->mFileName == file ) {
386 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) ); 387 KMessageBox::information( this, i18n("Sorry, the file \n%1\nis already loaded!\nPlease choose another file!").arg( KGlobal::formatMessage (file, 0 )) );
387 tryagain = true; 388 tryagain = true;
388 file = ""; 389 file = "";
389 break; 390 break;
390 } 391 }
391 kkf = KOPrefs::instance()->mCalendars.next(); 392 kkf = KOPrefs::instance()->mCalendars.next();
392 } 393 }
393 } 394 }
394 addCalendar ( name, file ); 395 addCalendar ( name, file );
395 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) ); 396 QTimer::singleShot( 100, this, SIGNAL ( checkCalendar() ) );
396} 397}
397int KOCalEditView::addCalendar( QString name, QString file, bool ask ) 398int KOCalEditView::addCalendar( QString name, QString file, bool ask )
398{ 399{
399 400
400 QFileInfo fi ( file ); 401 QFileInfo fi ( file );
402 QString absFile = file;
403 bool isRelative = false;
404 if ( fi.isRelative() ) {
405 isRelative = true;
406 absFile = KGlobalSettings::calendarDir()+file;
407 fi.setFile( absFile );
408 } else {
409 QString cd = KGlobalSettings::calendarDir();
410 if ( file.left( cd.length() ) == cd ) {
411 isRelative = true;
412 file = fi.fileName ();
413 fi.setFile( absFile );
414 }
415 }
401 if (!fi.exists() ) { 416 if (!fi.exists() ) {
402 if ( ask ) 417 if ( ask )
403 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( file ) )== KMessageBox::No ) 418 if ( KMessageBox::questionYesNo(this, i18n("The file\n%1\ndoes not exist!\nShall I create it for you?").arg( KGlobal::formatMessage (absFile,0) ) )== KMessageBox::No )
404 return 0; 419 return 0;
405 QFile fileIn( file ); 420 QFile fileIn( absFile );
406 if (!fileIn.open( IO_WriteOnly ) ) { 421 if (!fileIn.open( IO_WriteOnly ) ) {
407 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) ); 422 KMessageBox::sorry( this, i18n("Sorry, cannot create the file\n%1!\nNo calendar added!").arg( file ) );
408 return 0; 423 return 0;
409 } 424 }
410 QTextStream tsIn( &fileIn ); 425 QTextStream tsIn( &fileIn );
411 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 426 tsIn.setCodec( QTextCodec::codecForName("utf8") );
412 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n"; 427 tsIn << "BEGIN:VCALENDAR\nPRODID:-//KDE-Pim//Platform-independent 2.1.0\nVERSION:2.0\nEND:VCALENDAR\n";
413 fileIn.close(); 428 fileIn.close();
414 } 429 }
415 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 430 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
416 kkf->mName = name; 431 kkf->mName = name;
417 kkf->mFileName = file; 432 kkf->mFileName = absFile;
433 kkf->mSavedFileName = file;
434 kkf->isRelative = isRelative;
418 emit calendarAdded( kkf->mCalNumber ); 435 emit calendarAdded( kkf->mCalNumber );
419 if ( ask ) 436 if ( ask )
420 emit needsUpdate(); 437 emit needsUpdate();
421 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 438 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
422 return kkf->mCalNumber; 439 return kkf->mCalNumber;
423} 440}
424int KOCalEditView::getBirtdayID() 441int KOCalEditView::getBirtdayID()
425{ 442{
426 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 443 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
427 while ( kkf ) { 444 while ( kkf ) {
428 if ( kkf->mName == i18n("Birthdays") ) 445 if ( kkf->mName == i18n("Birthdays") )
429 return kkf->mCalNumber; 446 return kkf->mCalNumber;
430 kkf = KOPrefs::instance()->mCalendars.next(); 447 kkf = KOPrefs::instance()->mCalendars.next();
431 } 448 }
432 QString file = locateLocal( "data", "korganizer/birthdays.ics" ); 449 QString file = locateLocal( "data", "korganizer/birthdays.ics" );
433 return addCalendar( i18n("Birthdays"), file, false ); 450 return addCalendar( i18n("Birthdays"), file, false );
434} 451}
435 452
436void KOCalEditView::enableAll() 453void KOCalEditView::enableAll()
437{ 454{
438 toggleList( mEnabledB ); 455 toggleList( mEnabledB );
439} 456}
440void KOCalEditView::enableAlarm() 457void KOCalEditView::enableAlarm()
441{ 458{
442 toggleList( mAlarmB ); 459 toggleList( mAlarmB );
443} 460}
444void KOCalEditView::disableRO() 461void KOCalEditView::disableRO()
445{ 462{
446 toggleList( mROB, false ); 463 toggleList( mROB, false );
447} 464}
448void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable ) 465void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list , bool enable )
449{ 466{
450 bool dis = !enable; 467 bool dis = !enable;
451 KOCalCheckButton* it = list.first(); 468 KOCalCheckButton* it = list.first();
452 while ( it ) { 469 while ( it ) {
453 if ( !it->isChecked() == enable && it->isEnabled() ) { 470 if ( !it->isChecked() == enable && it->isEnabled() ) {
454 dis = !dis; 471 dis = !dis;
455 break; 472 break;
456 } 473 }
457 it = list.next(); 474 it = list.next();
458 } 475 }
459 it = list.first(); 476 it = list.first();
460 while ( it ) { 477 while ( it ) {
461 if ( it->isEnabled() ) 478 if ( it->isEnabled() )
462 it->setChecked(dis); 479 it->setChecked(dis);
463 it = list.next(); 480 it = list.next();
464 } 481 }
465} 482}
466void KOCalEditView::deleteAll() 483void KOCalEditView::deleteAll()
467{ 484{
468 qDebug("delteAll"); 485 qDebug("delteAll");
469} 486}
diff --git a/korganizer/kofilterview.h b/korganizer/kofilterview.h
index 4322299..be7b5b6 100644
--- a/korganizer/kofilterview.h
+++ b/korganizer/kofilterview.h
@@ -1,255 +1,256 @@
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 KOFILTERVIEW_H 23#ifndef KOFILTERVIEW_H
24#define KOFILTERVIEW_H 24#define KOFILTERVIEW_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qapplication.h> 28#include <qapplication.h>
29#include <qradiobutton.h> 29#include <qradiobutton.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qlabel.h> 31#include <qlabel.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qscrollview.h> 33#include <qscrollview.h>
34#include <qpushbutton.h> 34#include <qpushbutton.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include "kofilterview_base.h" 36#include "kofilterview_base.h"
37 37
38#include <libkcal/calfilter.h> 38#include <libkcal/calfilter.h>
39 39
40#include <kurlrequester.h> 40#include <kurlrequester.h>
41#include <klineedit.h> 41#include <klineedit.h>
42#include <kglobal.h> 42#include <kglobal.h>
43#include <kmessagebox.h> 43#include <kmessagebox.h>
44 44
45class QGridLayout; 45class QGridLayout;
46 46
47using namespace KCal; 47using namespace KCal;
48 48
49class KONewCalPrefs : public QDialog 49class KONewCalPrefs : public QDialog
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 53 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
54 QDialog( parent, name, true ) 54 QDialog( parent, name, true )
55 { 55 {
56 setCaption( i18n("Add new Calendar") ); 56 setCaption( i18n("Add new Calendar") );
57 QVBoxLayout* lay = new QVBoxLayout( this ); 57 QVBoxLayout* lay = new QVBoxLayout( this );
58 lay->setSpacing( 3 ); 58 lay->setSpacing( 3 );
59 lay->setMargin( 3 ); 59 lay->setMargin( 3 );
60 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 60 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
61 lay->addWidget( lab ); 61 lay->addWidget( lab );
62 nameE = new KLineEdit( this ); 62 nameE = new KLineEdit( this );
63 lay->addWidget( nameE ); 63 lay->addWidget( nameE );
64 lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this ); 64 lab = new QLabel( i18n("<b>Local ical (*.ics) file:</b>"), this );
65 lay->addWidget( lab ); 65 lay->addWidget( lab );
66 url = new KURLRequester ( this ); 66 url = new KURLRequester ( this );
67 lay->addWidget( url ); 67 lay->addWidget( url );
68 QPushButton * ok = new QPushButton( i18n("OK"), this ); 68 QPushButton * ok = new QPushButton( i18n("OK"), this );
69 lay->addWidget( ok ); 69 lay->addWidget( ok );
70 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 70 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
71 lay->addWidget( cancel ); 71 lay->addWidget( cancel );
72 connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) ); 72 connect ( ok,SIGNAL(clicked() ),this , SLOT ( checkValid() ) );
73 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 73 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
74 int minwid = 220; 74 int minwid = 220;
75 if ( QApplication::desktop()->width() >= 320 ) minwid = 300; 75 if ( QApplication::desktop()->width() >= 320 ) minwid = 300;
76 setMinimumWidth( minwid ); 76 setMinimumWidth( minwid );
77 resize(sizeHint() ); 77 resize(sizeHint() );
78 } 78 }
79 79
80 QString calName() { return nameE->text(); } 80 QString calName() { return nameE->text(); }
81 QString calFileName() { return url->url(); } 81 QString calFileName() { return url->url(); }
82 82
83public slots: 83public slots:
84void checkValid() { 84void checkValid() {
85 if ( nameE->text().isEmpty() ) { 85 if ( nameE->text().isEmpty() ) {
86 KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") ); 86 KMessageBox::information( this, i18n("Sorry, the calendar name is empty!") );
87 nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () )); 87 nameE->setText( "LPQJ_"+ QString::number( QTime::currentTime().msec () ));
88 return; 88 return;
89 } 89 }
90 if ( url->url().isEmpty() ) { 90 if ( url->url().isEmpty() ) {
91 KMessageBox::information( this, i18n("Sorry, the file name is empty!") ); 91 KMessageBox::information( this, i18n("Sorry, the file name is empty!") );
92 url->setURL( nameE->text() + ".ics" );
92 return; 93 return;
93 } 94 }
94 accept(); 95 accept();
95} 96}
96 97
97public: 98public:
98 KLineEdit* nameE; 99 KLineEdit* nameE;
99 KURLRequester *url; 100 KURLRequester *url;
100}; 101};
101 102
102class KOCalButton : public QPushButton 103class KOCalButton : public QPushButton
103{ 104{
104 Q_OBJECT 105 Q_OBJECT
105 public: 106 public:
106 KOCalButton( QWidget *parent=0, const char *name=0 ) : 107 KOCalButton( QWidget *parent=0, const char *name=0 ) :
107 QPushButton( parent, name) 108 QPushButton( parent, name)
108 { 109 {
109 connect( this, SIGNAL( clicked() ), 110 connect( this, SIGNAL( clicked() ),
110 SLOT( bottonClicked() )); 111 SLOT( bottonClicked() ));
111 mNumber = -1; 112 mNumber = -1;
112 setFocusPolicy(NoFocus); 113 setFocusPolicy(NoFocus);
113 } 114 }
114 void setNum ( int num ) {mNumber = num; } 115 void setNum ( int num ) {mNumber = num; }
115 signals: 116 signals:
116 void selectNum ( int ); 117 void selectNum ( int );
117private: 118private:
118 int mNumber; 119 int mNumber;
119 void keyPressEvent ( QKeyEvent * e ) 120 void keyPressEvent ( QKeyEvent * e )
120 { 121 {
121 e->ignore(); 122 e->ignore();
122 } 123 }
123 124
124private slots : 125private slots :
125 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); } 126 void bottonClicked() { if ( mNumber > 0 ) emit selectNum ( mNumber ); }
126}; 127};
127class KOCalCheckButton : public QCheckBox 128class KOCalCheckButton : public QCheckBox
128{ 129{
129 Q_OBJECT 130 Q_OBJECT
130 public: 131 public:
131 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) : 132 KOCalCheckButton( QWidget *parent=0, const char *name=0 ) :
132 QCheckBox( parent, name) 133 QCheckBox( parent, name)
133 { 134 {
134 connect( this, SIGNAL( toggled ( bool ) ), 135 connect( this, SIGNAL( toggled ( bool ) ),
135 SLOT( bottonClicked( bool ) )); 136 SLOT( bottonClicked( bool ) ));
136 mNumber = -1; 137 mNumber = -1;
137 setFocusPolicy(NoFocus); 138 setFocusPolicy(NoFocus);
138 //setMaximumWidth( 10 ); 139 //setMaximumWidth( 10 );
139 140
140 } 141 }
141 void setNum ( int num ) {mNumber = num; } 142 void setNum ( int num ) {mNumber = num; }
142 signals: 143 signals:
143 void selectNum ( int, bool ); 144 void selectNum ( int, bool );
144private: 145private:
145 int mNumber; 146 int mNumber;
146 void keyPressEvent ( QKeyEvent * e ) 147 void keyPressEvent ( QKeyEvent * e )
147 { 148 {
148 e->ignore(); 149 e->ignore();
149 } 150 }
150 151
151private slots : 152private slots :
152 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); } 153 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber , b); }
153}; 154};
154 155
155class KOCalRadioButton : public QRadioButton 156class KOCalRadioButton : public QRadioButton
156{ 157{
157 Q_OBJECT 158 Q_OBJECT
158 public: 159 public:
159 KOCalRadioButton( QWidget *parent=0, const char *name=0 ) : 160 KOCalRadioButton( QWidget *parent=0, const char *name=0 ) :
160 QRadioButton( parent, name) 161 QRadioButton( parent, name)
161 { 162 {
162 connect( this, SIGNAL( toggled ( bool ) ), 163 connect( this, SIGNAL( toggled ( bool ) ),
163 SLOT( bottonClicked( bool ) )); 164 SLOT( bottonClicked( bool ) ));
164 mNumber = -1; 165 mNumber = -1;
165 setFocusPolicy(NoFocus); 166 setFocusPolicy(NoFocus);
166 //setMaximumWidth( 10 ); 167 //setMaximumWidth( 10 );
167 168
168 } 169 }
169 int num() { return mNumber;} 170 int num() { return mNumber;}
170 void setNum ( int num ) {mNumber = num; } 171 void setNum ( int num ) {mNumber = num; }
171 signals: 172 signals:
172 void selectNum ( int ); 173 void selectNum ( int );
173private: 174private:
174 int mNumber; 175 int mNumber;
175 void keyPressEvent ( QKeyEvent * e ) 176 void keyPressEvent ( QKeyEvent * e )
176 { 177 {
177 e->ignore(); 178 e->ignore();
178 } 179 }
179 180
180private slots : 181private slots :
181 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber); } 182 void bottonClicked( bool b) { if ( mNumber > 0 ) emit selectNum ( mNumber); }
182}; 183};
183 184
184 185
185 186
186class KOFilterView : public KOFilterView_base 187class KOFilterView : public KOFilterView_base
187{ 188{
188 Q_OBJECT 189 Q_OBJECT
189 public: 190 public:
190 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0); 191 KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent=0,const char* name=0, WFlags fl=0);
191 ~KOFilterView(); 192 ~KOFilterView();
192 193
193 void updateFilters(); 194 void updateFilters();
194 195
195 bool filtersEnabled(); 196 bool filtersEnabled();
196 void setFiltersEnabled(bool); 197 void setFiltersEnabled(bool);
197 CalFilter *selectedFilter(); 198 CalFilter *selectedFilter();
198 void setSelectedFilter(QString); 199 void setSelectedFilter(QString);
199 void setSelectedFilter( int ); 200 void setSelectedFilter( int );
200 201
201 signals: 202 signals:
202 void filterChanged(); 203 void filterChanged();
203 void editFilters(); 204 void editFilters();
204 205
205 private: 206 private:
206 QPtrList<CalFilter> *mFilters; 207 QPtrList<CalFilter> *mFilters;
207}; 208};
208 209
209class KOCalEditView : public QScrollView 210class KOCalEditView : public QScrollView
210{ 211{
211 Q_OBJECT 212 Q_OBJECT
212 public: 213 public:
213 KOCalEditView( QWidget* parent=0,const char* name=0); 214 KOCalEditView( QWidget* parent=0,const char* name=0);
214 ~KOCalEditView(); 215 ~KOCalEditView();
215 int addCalendar( QString calName, QString fileName, bool ask = true ); 216 int addCalendar( QString calName, QString fileName, bool ask = true );
216 int getBirtdayID(); 217 int getBirtdayID();
217 public slots: 218 public slots:
218 void addCal(); 219 void addCal();
219 void enableAll(); 220 void enableAll();
220 void enableAlarm(); 221 void enableAlarm();
221 void disableRO(); 222 void disableRO();
222 void deleteAll(); 223 void deleteAll();
223 void selectStdCal(int); 224 void selectStdCal(int);
224 void selectCal(int,bool ); 225 void selectCal(int,bool );
225 void selectCalAlarm(int,bool ); 226 void selectCalAlarm(int,bool );
226 void selectReadOnly(int,bool ); 227 void selectReadOnly(int,bool );
227 void setColor(const QColor &,int) ; 228 void setColor(const QColor &,int) ;
228 void deleteCal(int) ; 229 void deleteCal(int) ;
229 void infoCal(int) ; 230 void infoCal(int) ;
230 void readConfig(); 231 void readConfig();
231 void defaultInfo(); 232 void defaultInfo();
232 void findNewStandard(); 233 void findNewStandard();
233 signals: 234 signals:
234 void alarmEnabled ( int cal, bool enable ); 235 void alarmEnabled ( int cal, bool enable );
235 void calendarEnabled ( int cal, bool enable ); 236 void calendarEnabled ( int cal, bool enable );
236 void calendarReadonly ( int cal, bool readonly ); 237 void calendarReadonly ( int cal, bool readonly );
237 void setCalendarDefault ( int cal ); 238 void setCalendarDefault ( int cal );
238 void removeCalendar ( int cal ); 239 void removeCalendar ( int cal );
239 void calendarAdded( int ); 240 void calendarAdded( int );
240 void needsUpdate(); 241 void needsUpdate();
241 void checkCalendar(); 242 void checkCalendar();
242 243
243 private: 244 private:
244 QWidget *mw; 245 QWidget *mw;
245 void toggleList ( QPtrList<KOCalCheckButton> , bool b = true ); 246 void toggleList ( QPtrList<KOCalCheckButton> , bool b = true );
246 QPtrList<KOCalRadioButton> mStdandardB; 247 QPtrList<KOCalRadioButton> mStdandardB;
247 QPtrList<KOCalCheckButton> mEnabledB; 248 QPtrList<KOCalCheckButton> mEnabledB;
248 QPtrList<KOCalCheckButton> mAlarmB; 249 QPtrList<KOCalCheckButton> mAlarmB;
249 QPtrList<KOCalCheckButton> mROB; 250 QPtrList<KOCalCheckButton> mROB;
250 QGridLayout* mainLayout; 251 QGridLayout* mainLayout;
251}; 252};
252 253
253 254
254 255
255#endif // KOFILTERVIEW_H 256#endif // KOFILTERVIEW_H
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index a886735..f1f1442 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -73,543 +73,549 @@ KOPrefs::KOPrefs() :
73 addItemBool("ShowIconDay5",&mShowIconDay5,true); 73 addItemBool("ShowIconDay5",&mShowIconDay5,true);
74 addItemBool("ShowIconDay6",&mShowIconDay6,true); 74 addItemBool("ShowIconDay6",&mShowIconDay6,true);
75 addItemBool("ShowIconDay7",&mShowIconDay7,true); 75 addItemBool("ShowIconDay7",&mShowIconDay7,true);
76 addItemBool("ShowIconMonth",&mShowIconMonth,true); 76 addItemBool("ShowIconMonth",&mShowIconMonth,true);
77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
79 addItemBool("ShowIconBack",&mShowIconBack,true); 79 addItemBool("ShowIconBack",&mShowIconBack,true);
80 addItemBool("ShowIconToday",&mShowIconToday,true); 80 addItemBool("ShowIconToday",&mShowIconToday,true);
81 addItemBool("ShowIconForward",&mShowIconForward,true); 81 addItemBool("ShowIconForward",&mShowIconForward,true);
82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); 84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
86 addItemBool("ShowIconNext",&mShowIconNext,true); 86 addItemBool("ShowIconNext",&mShowIconNext,true);
87 addItemBool("ShowIconJournal",&mShowIconJournal,true); 87 addItemBool("ShowIconJournal",&mShowIconJournal,true);
88 addItemBool("ShowIconStretch",&mShowIconStretch,true); 88 addItemBool("ShowIconStretch",&mShowIconStretch,true);
89 addItemBool("ShowIconFilter",&mShowIconFilter,false); 89 addItemBool("ShowIconFilter",&mShowIconFilter,false);
90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); 90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
91 91
92 bool addIcons = false; 92 bool addIcons = false;
93#ifdef DESKTOP_VERSION 93#ifdef DESKTOP_VERSION
94 addIcons = true; 94 addIcons = true;
95#endif 95#endif
96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); 96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons);
97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); 97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons);
98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); 98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons);
99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); 99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons);
100 100
101 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 101 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarHorV",&mToolBarHorV, true ); 112 addItemBool("ToolBarHorV",&mToolBarHorV, true );
113 addItemBool("ToolBarUpV",&mToolBarUpV, false ); 113 addItemBool("ToolBarUpV",&mToolBarUpV, false );
114 addItemBool("ToolBarHorN",&mToolBarHorN, true ); 114 addItemBool("ToolBarHorN",&mToolBarHorN, true );
115 addItemBool("ToolBarUpN",&mToolBarUpN, false ); 115 addItemBool("ToolBarUpN",&mToolBarUpN, false );
116 addItemBool("ToolBarHorF",&mToolBarHorF, true ); 116 addItemBool("ToolBarHorF",&mToolBarHorF, true );
117 addItemBool("ToolBarUpF",&mToolBarUpF, false ); 117 addItemBool("ToolBarUpF",&mToolBarUpF, false );
118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
119 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
121 121
122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); 123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true);
124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
127 addItemInt("AllDay Size",&mAllDaySize,28); 127 addItemInt("AllDay Size",&mAllDaySize,28);
128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
130 130
131 addItemStringList("LocationDefaults",&mLocationDefaults ); 131 addItemStringList("LocationDefaults",&mLocationDefaults );
132 addItemStringList("EventSummary User",&mEventSummaryUser); 132 addItemStringList("EventSummary User",&mEventSummaryUser);
133 addItemStringList("TodoSummary User",&mTodoSummaryUser); 133 addItemStringList("TodoSummary User",&mTodoSummaryUser);
134 addItemStringList("JournalSummary User",&mJournalSummaryUser); 134 addItemStringList("JournalSummary User",&mJournalSummaryUser);
135 135
136 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 136 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
137 addItemBool("Enable Project View",&mEnableProjectView,false); 137 addItemBool("Enable Project View",&mEnableProjectView,false);
138 addItemBool("Auto Save",&mAutoSave,false); 138 addItemBool("Auto Save",&mAutoSave,false);
139 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 139 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
140 addItemBool("Confirm Deletes",&mConfirm,true); 140 addItemBool("Confirm Deletes",&mConfirm,true);
141 addItemString("Archive File",&mArchiveFile); 141 addItemString("Archive File",&mArchiveFile);
142 addItemString("Html Export File",&mHtmlExportFile, 142 addItemString("Html Export File",&mHtmlExportFile,
143 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 143 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
144 addItemBool("Html With Save",&mHtmlWithSave,false); 144 addItemBool("Html With Save",&mHtmlWithSave,false);
145 145
146 KPrefs::setCurrentGroup("Personal Settings"); 146 KPrefs::setCurrentGroup("Personal Settings");
147 147
148 addItemInt("Mail Client",&mMailClient,MailClientKMail); 148 addItemInt("Mail Client",&mMailClient,MailClientKMail);
149 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 149 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
150 addItemBool("Bcc",&mBcc,false); 150 addItemBool("Bcc",&mBcc,false);
151 151
152 KPrefs::setCurrentGroup("Time & Date"); 152 KPrefs::setCurrentGroup("Time & Date");
153 153
154 154
155 addItemInt("Default Start Time",&mStartTime,10); 155 addItemInt("Default Start Time",&mStartTime,10);
156 addItemInt("Default Duration",&mDefaultDuration,2); 156 addItemInt("Default Duration",&mDefaultDuration,2);
157 addItemInt("Default Alarm Time",&mAlarmTime,3); 157 addItemInt("Default Alarm Time",&mAlarmTime,3);
158 KPrefs::setCurrentGroup("AlarmSettings"); 158 KPrefs::setCurrentGroup("AlarmSettings");
159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
163 163
164 164
165 KPrefs::setCurrentGroup("Calendar"); 165 KPrefs::setCurrentGroup("Calendar");
166 166
167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
168 168
169 KPrefs::setCurrentGroup("Fonts"); 169 KPrefs::setCurrentGroup("Fonts");
170 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 170 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
171 QFont fon = KGlobalSettings::generalFont(); 171 QFont fon = KGlobalSettings::generalFont();
172 addItemFont("TimeBar Font",&mTimeBarFont,fon ); 172 addItemFont("TimeBar Font",&mTimeBarFont,fon );
173 addItemFont("MonthView Font",&mMonthViewFont,fon); 173 addItemFont("MonthView Font",&mMonthViewFont,fon);
174 addItemFont("AgendaView Font",&mAgendaViewFont,fon); 174 addItemFont("AgendaView Font",&mAgendaViewFont,fon);
175 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); 175 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon);
176 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); 176 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon);
177 addItemFont("TodoView Font",&mTodoViewFont,fon); 177 addItemFont("TodoView Font",&mTodoViewFont,fon);
178 addItemFont("ListView Font",&mListViewFont,fon); 178 addItemFont("ListView Font",&mListViewFont,fon);
179 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); 179 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon);
180 addItemFont("EditBox Font",&mEditBoxFont,fon); 180 addItemFont("EditBox Font",&mEditBoxFont,fon);
181 addItemFont("JournalView Font",&mJornalViewFont,fon); 181 addItemFont("JournalView Font",&mJornalViewFont,fon);
182 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); 182 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon);
183 addItemFont("EventView Font",&mEventViewFont,fon); 183 addItemFont("EventView Font",&mEventViewFont,fon);
184 184
185 KPrefs::setCurrentGroup("RemoteSyncing"); 185 KPrefs::setCurrentGroup("RemoteSyncing");
186 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 186 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
187 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 187 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
188 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 188 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
189 addItemInt("LastSyncTime",&mLastSyncTime,0); 189 addItemInt("LastSyncTime",&mLastSyncTime,0);
190 190
191#ifdef _WIN32_ 191#ifdef _WIN32_
192 QString hdp= locateLocal("data","korganizer")+"\\\\"; 192 QString hdp= locateLocal("data","korganizer")+"\\\\";
193#else 193#else
194 QString hdp= locateLocal("data","korganizer")+"/"; 194 QString hdp= locateLocal("data","korganizer")+"/";
195#endif 195#endif
196 196
197 KPrefs::setCurrentGroup("LoadSaveFileNames"); 197 KPrefs::setCurrentGroup("LoadSaveFileNames");
198 198
199 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 199 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
200 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 200 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
201 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 201 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
202 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 202 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
203 203
204 204
205 KPrefs::setCurrentGroup("Locale"); 205 KPrefs::setCurrentGroup("Locale");
206 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 206 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
207 207
208 208
209 KPrefs::setCurrentGroup("Colors"); 209 KPrefs::setCurrentGroup("Colors");
210 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 210 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
211 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 211 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
212 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 212 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
213 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 213 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
214 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 214 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
215 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 215 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
216 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 216 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
217 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 217 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
218 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); 218 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
219 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 219 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
220 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 220 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
221 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 221 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
222 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 222 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
223 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 223 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
224 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 224 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
225 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 225 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
226 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 226 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
227 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 227 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
228 addItemBool("UseAppColors",&mUseAppColors,false); 228 addItemBool("UseAppColors",&mUseAppColors,false);
229 229
230 230
231 231
232 KPrefs::setCurrentGroup("Views"); 232 KPrefs::setCurrentGroup("Views");
233 addItemBool("Block Popup Menu",&mBlockPopupMenu,false); 233 addItemBool("Block Popup Menu",&mBlockPopupMenu,false);
234 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 234 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
235 addItemInt("Hour Size",&mHourSize,8); 235 addItemInt("Hour Size",&mHourSize,8);
236 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 236 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
237 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 237 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
238 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 238 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
239 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 239 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
240 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 240 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
241 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 241 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
242 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); 242 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true);
243#ifdef DESKTOP_VERION 243#ifdef DESKTOP_VERION
244 addItemBool("Enable ToolTips",&mEnableToolTips,true); 244 addItemBool("Enable ToolTips",&mEnableToolTips,true);
245#else 245#else
246 addItemBool("Enable ToolTips",&mEnableToolTips,false); 246 addItemBool("Enable ToolTips",&mEnableToolTips,false);
247#endif 247#endif
248 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 248 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
249 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 249 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
250 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 250 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
251 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 251 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
252 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 252 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
253 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 253 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
254 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 254 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
255 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 255 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
256 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 256 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
257 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 257 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
258 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 258 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
259 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 259 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
260 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 260 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
261 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 261 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
262 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 262 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
263 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 263 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
264 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 264 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
265 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 265 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
266 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 266 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
267 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 267 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
268#ifdef DESKTOP_VERSION 268#ifdef DESKTOP_VERSION
269 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 269 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
270#else 270#else
271 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 271 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
272#endif 272#endif
273 addItemInt("Day Begins",&mDayBegins,7); 273 addItemInt("Day Begins",&mDayBegins,7);
274 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 274 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
275 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 275 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
276 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 276 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
277 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 277 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
278 278
279 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 279 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
280 addItemBool("Full View Month",&mFullViewMonth,true); 280 addItemBool("Full View Month",&mFullViewMonth,true);
281 addItemBool("Full View Todo",&mFullViewTodo,true); 281 addItemBool("Full View Todo",&mFullViewTodo,true);
282 addItemBool("Quick Todo",&mEnableQuickTodo,false); 282 addItemBool("Quick Todo",&mEnableQuickTodo,false);
283 283
284 addItemInt("Next X Days",&mNextXDays,3); 284 addItemInt("Next X Days",&mNextXDays,3);
285 285
286 KPrefs::setCurrentGroup("Printer"); 286 KPrefs::setCurrentGroup("Printer");
287 287
288 KPrefs::setCurrentGroup("Layout"); 288 KPrefs::setCurrentGroup("Layout");
289 289
290 addItemBool("CompactDialogs",&mCompactDialogs,false); 290 addItemBool("CompactDialogs",&mCompactDialogs,false);
291 addItemBool("VerticalScreen",&mVerticalScreen,true); 291 addItemBool("VerticalScreen",&mVerticalScreen,true);
292 292
293 KPrefs::setCurrentGroup("KOrganizer Plugins"); 293 KPrefs::setCurrentGroup("KOrganizer Plugins");
294 294
295 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 295 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
296 296
297 KPrefs::setCurrentGroup("Group Scheduling"); 297 KPrefs::setCurrentGroup("Group Scheduling");
298 298
299 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 299 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
300 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 300 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
301 addItemStringList("AdditionalMails",&mAdditionalMails,""); 301 addItemStringList("AdditionalMails",&mAdditionalMails,"");
302 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 302 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
303 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 303 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
304 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 304 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
305 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 305 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
306 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 306 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
307 307
308 KPrefs::setCurrentGroup( "Editors" ); 308 KPrefs::setCurrentGroup( "Editors" );
309 309
310 addItemStringList( "EventTemplates", &mEventTemplates ); 310 addItemStringList( "EventTemplates", &mEventTemplates );
311 addItemStringList( "TodoTemplates", &mTodoTemplates ); 311 addItemStringList( "TodoTemplates", &mTodoTemplates );
312 312
313 addItemInt("DestinationPolicy",&mDestination,standardDestination); 313 addItemInt("DestinationPolicy",&mDestination,standardDestination);
314 314
315 KPrefs::setCurrentGroup( "ViewOptions" ); 315 KPrefs::setCurrentGroup( "ViewOptions" );
316 addItemBool("EVshowDetails",&mEVshowDetails,true); 316 addItemBool("EVshowDetails",&mEVshowDetails,true);
317 addItemBool("EVshowCreated",&mEVshowCreated,true); 317 addItemBool("EVshowCreated",&mEVshowCreated,true);
318 addItemBool("EVshowChanged",&mEVshowChanged,true); 318 addItemBool("EVshowChanged",&mEVshowChanged,true);
319 addItemBool("WTshowDetails",&mWTshowDetails,false); 319 addItemBool("WTshowDetails",&mWTshowDetails,false);
320 addItemBool("WTshowCreated",&mWTshowCreated,false); 320 addItemBool("WTshowCreated",&mWTshowCreated,false);
321 addItemBool("WTshowChanged",&mWTshowChanged,false); 321 addItemBool("WTshowChanged",&mWTshowChanged,false);
322 mCalendars.setAutoDelete( true ); 322 mCalendars.setAutoDelete( true );
323} 323}
324 324
325 325
326KOPrefs::~KOPrefs() 326KOPrefs::~KOPrefs()
327{ 327{
328 if (mInstance == this) 328 if (mInstance == this)
329 mInstance = insd.setObject(0); 329 mInstance = insd.setObject(0);
330 mCalendars.setAutoDelete( true ); 330 mCalendars.setAutoDelete( true );
331 mCalendars.clear(); 331 mCalendars.clear();
332 //qDebug("KOPrefs::~KOPrefs() "); 332 //qDebug("KOPrefs::~KOPrefs() ");
333} 333}
334 334
335 335
336KOPrefs *KOPrefs::instance() 336KOPrefs *KOPrefs::instance()
337{ 337{
338 if (!mInstance) { 338 if (!mInstance) {
339 mInstance = insd.setObject(new KOPrefs()); 339 mInstance = insd.setObject(new KOPrefs());
340 mInstance->readConfig(); 340 mInstance->readConfig();
341 } 341 }
342 342
343 return mInstance; 343 return mInstance;
344} 344}
345 345
346void KOPrefs::usrSetDefaults() 346void KOPrefs::usrSetDefaults()
347{ 347{
348 348
349} 349}
350 350
351void KOPrefs::fillMailDefaults() 351void KOPrefs::fillMailDefaults()
352{ 352{
353 if (mName.isEmpty()) mName = i18n("Anonymous"); 353 if (mName.isEmpty()) mName = i18n("Anonymous");
354 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 354 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
355} 355}
356 356
357void KOPrefs::setTimeZoneIdDefault() 357void KOPrefs::setTimeZoneIdDefault()
358{ 358{
359 ; 359 ;
360} 360}
361 361
362void KOPrefs::setAllDefaults() 362void KOPrefs::setAllDefaults()
363{ 363{
364 setCategoryDefaults(); 364 setCategoryDefaults();
365 mEventSummaryUser = getDefaultList() ; 365 mEventSummaryUser = getDefaultList() ;
366 mTodoSummaryUser = getDefaultList() ; 366 mTodoSummaryUser = getDefaultList() ;
367 mJournalSummaryUser = getDefaultList() ; 367 mJournalSummaryUser = getDefaultList() ;
368 mLocationDefaults = getLocationDefaultList(); 368 mLocationDefaults = getLocationDefaultList();
369} 369}
370 370
371void KOPrefs::setCategoryDefaults() 371void KOPrefs::setCategoryDefaults()
372{ 372{
373 mCustomCategories.clear(); 373 mCustomCategories.clear();
374 mCustomCategories = getDefaultList(); 374 mCustomCategories = getDefaultList();
375 375
376 QStringList::Iterator it; 376 QStringList::Iterator it;
377 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 377 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
378 setCategoryColor(*it,mDefaultCategoryColor); 378 setCategoryColor(*it,mDefaultCategoryColor);
379 } 379 }
380} 380}
381QStringList KOPrefs::getLocationDefaultList() 381QStringList KOPrefs::getLocationDefaultList()
382{ 382{
383 QStringList retval ; 383 QStringList retval ;
384 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 384 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
385 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 385 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
386 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 386 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
387 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 387 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
388 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 388 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
389 389
390 retval.sort(); 390 retval.sort();
391 return retval; 391 return retval;
392} 392}
393QStringList KOPrefs::getDefaultList() 393QStringList KOPrefs::getDefaultList()
394{ 394{
395 QStringList retval ; 395 QStringList retval ;
396 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") 396 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer")
397 << i18n("Break") 397 << i18n("Break")
398 << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") 398 << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts")
399 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") 399 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts")
400 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") 400 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal")
401 << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") 401 << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping")
402 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") 402 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")
403 << i18n("Vacation") ; 403 << i18n("Vacation") ;
404 retval.sort(); 404 retval.sort();
405 //qDebug("cat %s ", retval.join("-").latin1()); 405 //qDebug("cat %s ", retval.join("-").latin1());
406 return retval; 406 return retval;
407} 407}
408// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") 408// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema")
409void KOPrefs::usrReadConfig() 409void KOPrefs::usrReadConfig()
410{ 410{
411 config()->setGroup("General"); 411 config()->setGroup("General");
412 412
413 //qDebug("KOPrefs::usrReadConfig() "); 413 //qDebug("KOPrefs::usrReadConfig() ");
414 mCustomCategories = config()->readListEntry("Custom Categories"); 414 mCustomCategories = config()->readListEntry("Custom Categories");
415 mOldLoadedLanguage = mOldLanguage ; 415 mOldLoadedLanguage = mOldLanguage ;
416 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 416 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
417 if (mLocationDefaults.isEmpty()) { 417 if (mLocationDefaults.isEmpty()) {
418 mLocationDefaults = getLocationDefaultList(); 418 mLocationDefaults = getLocationDefaultList();
419 } 419 }
420 420
421 if (mEventSummaryUser.isEmpty()) { 421 if (mEventSummaryUser.isEmpty()) {
422 mEventSummaryUser = getDefaultList() ; 422 mEventSummaryUser = getDefaultList() ;
423 } 423 }
424 if (mTodoSummaryUser.isEmpty()) { 424 if (mTodoSummaryUser.isEmpty()) {
425 mTodoSummaryUser = getDefaultList() ; 425 mTodoSummaryUser = getDefaultList() ;
426 } 426 }
427 427
428 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 428 if (mCustomCategories.isEmpty()) setCategoryDefaults();
429 429
430 config()->setGroup("Personal Settings"); 430 config()->setGroup("Personal Settings");
431 mName = config()->readEntry("user_name",""); 431 mName = config()->readEntry("user_name","");
432 mEmail = config()->readEntry("user_email",""); 432 mEmail = config()->readEntry("user_email","");
433 fillMailDefaults(); 433 fillMailDefaults();
434 434
435 config()->setGroup("Category Colors"); 435 config()->setGroup("Category Colors");
436 QStringList::Iterator it; 436 QStringList::Iterator it;
437 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 437 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
438 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 438 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
439 439
440 } 440 }
441 KConfig fc (locateLocal("config","kopicalendarrc")); 441 KConfig fc (locateLocal("config","kopicalendarrc"));
442 fc.setGroup("CC"); 442 fc.setGroup("CC");
443 int numCals = fc.readNumEntry("NumberCalendars",0 ); 443 int numCals = fc.readNumEntry("NumberCalendars",0 );
444 mNextAvailableCalendar = 1; 444 mNextAvailableCalendar = 1;
445 if ( numCals == 0 ) { 445 if ( numCals == 0 ) {
446 KopiCalendarFile *kkf = getNewCalendar(); 446 KopiCalendarFile *kkf = getNewCalendar();
447 kkf->isStandard = true; 447 kkf->isStandard = true;
448 kkf->mName = i18n("Standard"); 448 kkf->mName = i18n("Standard");
449 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 449 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
450 } 450 }
451 while ( mNextAvailableCalendar <= numCals ) { 451 while ( mNextAvailableCalendar <= numCals ) {
452 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 452 //qDebug("Read cal #%d ", mNextAvailableCalendar );
453 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 453 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
454 KopiCalendarFile *kkf = getNewCalendar(); 454 KopiCalendarFile *kkf = getNewCalendar();
455 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 455 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
456 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 456 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
457 kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false );
457 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 458 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
458 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 459 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
459 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 460 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
460 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); 461 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName);
462 kkf->mSavedFileName = fc.readEntry( prefix+"_SavedFileName", kkf->mFileName);
461 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 463 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
462 if ( kkf->mCalNumber == 1 ) { 464 if ( kkf->mCalNumber == 1 ) {
463 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 465 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
464 } 466 }
465 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); 467 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() );
466 if ( kkf->mName == i18n("Birthdays") ) { 468 if ( kkf->mName == i18n("Birthdays") ) {
467 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); 469 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" );
468 } 470 }
471 if ( kkf->isRelative )
472 kkf->mFileName = KGlobalSettings::calendarDir() + kkf->mSavedFileName;
469 } 473 }
470 474
471 KPimPrefs::usrReadConfig(); 475 KPimPrefs::usrReadConfig();
472} 476}
473 477
474KopiCalendarFile * KOPrefs::getCalendar( int num ) 478KopiCalendarFile * KOPrefs::getCalendar( int num )
475{ 479{
476 return mDefCalColors[num-1]; 480 return mDefCalColors[num-1];
477} 481}
478 482
479KopiCalendarFile * KOPrefs::getNewCalendar() 483KopiCalendarFile * KOPrefs::getNewCalendar()
480{ 484{
481 KopiCalendarFile * kkf = new KopiCalendarFile(); 485 KopiCalendarFile * kkf = new KopiCalendarFile();
482 kkf->mCalNumber = mNextAvailableCalendar; 486 kkf->mCalNumber = mNextAvailableCalendar;
483 mDefCalColors.resize( mNextAvailableCalendar ); 487 mDefCalColors.resize( mNextAvailableCalendar );
484 mDefCalColors[mNextAvailableCalendar-1] = kkf; 488 mDefCalColors[mNextAvailableCalendar-1] = kkf;
485 ++mNextAvailableCalendar; 489 ++mNextAvailableCalendar;
486 kkf->mDefaultColor = mEventColor; 490 kkf->mDefaultColor = mEventColor;
487 kkf->mName = i18n("New Calendar"); 491 kkf->mName = i18n("New Calendar");
488 mCalendars.append( kkf ); 492 mCalendars.append( kkf );
489 return kkf; 493 return kkf;
490} 494}
491void KOPrefs::deleteCalendar( int num ) 495void KOPrefs::deleteCalendar( int num )
492{ 496{
493 KopiCalendarFile * kkf = mCalendars.first(); 497 KopiCalendarFile * kkf = mCalendars.first();
494 while ( kkf ) { 498 while ( kkf ) {
495 if ( kkf->mCalNumber == num ) { 499 if ( kkf->mCalNumber == num ) {
496 qDebug("KOPrefs::deleteCalendar %d ", num ); 500 qDebug("KOPrefs::deleteCalendar %d ", num );
497 mCalendars.remove( kkf ); 501 mCalendars.remove( kkf );
498 delete kkf; 502 delete kkf;
499 return; 503 return;
500 } 504 }
501 kkf = mCalendars.next(); 505 kkf = mCalendars.next();
502 } 506 }
503} 507}
504int KOPrefs::getCalendarID( const QString & name ) 508int KOPrefs::getCalendarID( const QString & name )
505{ 509{
506 KopiCalendarFile * kkf = mCalendars.first(); 510 KopiCalendarFile * kkf = mCalendars.first();
507 while ( kkf ) { 511 while ( kkf ) {
508 if ( name == kkf->mName) 512 if ( name == kkf->mName)
509 return kkf->mCalNumber; 513 return kkf->mCalNumber;
510 kkf = mCalendars.next(); 514 kkf = mCalendars.next();
511 } 515 }
512 return 1; 516 return 1;
513} 517}
514QString KOPrefs::calName( int calNum) const 518QString KOPrefs::calName( int calNum) const
515{ 519{
516 return (mDefCalColors[calNum-1])->mName; 520 return (mDefCalColors[calNum-1])->mName;
517} 521}
518QColor KOPrefs::defaultColor( int calNum ) const 522QColor KOPrefs::defaultColor( int calNum ) const
519{ 523{
520 if ( calNum == 1 ) return mEventColor; 524 if ( calNum == 1 ) return mEventColor;
521 return (mDefCalColors[calNum-1])->mDefaultColor; 525 return (mDefCalColors[calNum-1])->mDefaultColor;
522} 526}
523void KOPrefs::usrWriteConfig() 527void KOPrefs::usrWriteConfig()
524{ 528{
525 config()->setGroup("General"); 529 config()->setGroup("General");
526 config()->writeEntry("Custom Categories",mCustomCategories); 530 config()->writeEntry("Custom Categories",mCustomCategories);
527 531
528 config()->setGroup("Personal Settings"); 532 config()->setGroup("Personal Settings");
529 config()->writeEntry("user_name",mName); 533 config()->writeEntry("user_name",mName);
530 config()->writeEntry("user_email",mEmail); 534 config()->writeEntry("user_email",mEmail);
531 535
532 config()->setGroup("Category Colors"); 536 config()->setGroup("Category Colors");
533 QDictIterator<QColor> it(mCategoryColors); 537 QDictIterator<QColor> it(mCategoryColors);
534 while (it.current()) { 538 while (it.current()) {
535 config()->writeEntry(it.currentKey(),*(it.current())); 539 config()->writeEntry(it.currentKey(),*(it.current()));
536 ++it; 540 ++it;
537 } 541 }
538 KConfig fc (locateLocal("config","kopicalendarrc")); 542 KConfig fc (locateLocal("config","kopicalendarrc"));
539 fc.setGroup("CC"); 543 fc.setGroup("CC");
540 fc.writeEntry("NumberCalendars",mCalendars.count()); 544 fc.writeEntry("NumberCalendars",mCalendars.count());
541 int numCal = 1; 545 int numCal = 1;
542 int writeCal = 0; 546 int writeCal = 0;
543 while ( numCal < mNextAvailableCalendar ) { 547 while ( numCal < mNextAvailableCalendar ) {
544 KopiCalendarFile * kkf = mCalendars.first(); 548 KopiCalendarFile * kkf = mCalendars.first();
545 while ( kkf ) { 549 while ( kkf ) {
546 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 550 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
547 if ( kkf->mCalNumber == numCal ) { 551 if ( kkf->mCalNumber == numCal ) {
548 ++writeCal; 552 ++writeCal;
549 //qDebug("Write calendar %d %d ", numCal , writeCal); 553 //qDebug("Write calendar %d %d ", numCal , writeCal);
550 QString prefix = "Cal_" + QString::number( writeCal ); 554 QString prefix = "Cal_" + QString::number( writeCal );
551 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 555 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
552 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 556 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
553 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 557 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
554 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 558 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
559 fc.writeEntry( prefix+"_isRelative", kkf->isRelative );
555 fc.writeEntry( prefix+"_Name", kkf->mName); 560 fc.writeEntry( prefix+"_Name", kkf->mName);
556 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 561 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
562 fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName);
557 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 563 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
558 } 564 }
559 kkf = mCalendars.next(); 565 kkf = mCalendars.next();
560 } 566 }
561 ++numCal; 567 ++numCal;
562 } 568 }
563 fc.sync(); 569 fc.sync();
564 KPimPrefs::usrWriteConfig(); 570 KPimPrefs::usrWriteConfig();
565} 571}
566 572
567void KOPrefs::setCategoryColor(QString cat,const QColor & color) 573void KOPrefs::setCategoryColor(QString cat,const QColor & color)
568{ 574{
569 mCategoryColors.replace(cat,new QColor(color)); 575 mCategoryColors.replace(cat,new QColor(color));
570} 576}
571 577
572QColor *KOPrefs::categoryColor(QString cat) 578QColor *KOPrefs::categoryColor(QString cat)
573{ 579{
574 QColor *color = 0; 580 QColor *color = 0;
575 581
576 if (!cat.isEmpty()) color = mCategoryColors[cat]; 582 if (!cat.isEmpty()) color = mCategoryColors[cat];
577 583
578 if (color) return color; 584 if (color) return color;
579 else return &mDefaultCategoryColor; 585 else return &mDefaultCategoryColor;
580} 586}
581 587
582void KOPrefs::setFullName(const QString &name) 588void KOPrefs::setFullName(const QString &name)
583{ 589{
584 mName = name; 590 mName = name;
585} 591}
586 592
587void KOPrefs::setEmail(const QString &email) 593void KOPrefs::setEmail(const QString &email)
588{ 594{
589 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 595 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
590 mEmail = email; 596 mEmail = email;
591} 597}
592 598
593QString KOPrefs::fullName() 599QString KOPrefs::fullName()
594{ 600{
595 if (mEmailControlCenter) { 601 if (mEmailControlCenter) {
596 KEMailSettings settings; 602 KEMailSettings settings;
597 return settings.getSetting(KEMailSettings::RealName); 603 return settings.getSetting(KEMailSettings::RealName);
598 } else { 604 } else {
599 return mName; 605 return mName;
600 } 606 }
601} 607}
602 608
603QString KOPrefs::email() 609QString KOPrefs::email()
604{ 610{
605 if (mEmailControlCenter) { 611 if (mEmailControlCenter) {
606 KEMailSettings settings; 612 KEMailSettings settings;
607 return settings.getSetting(KEMailSettings::EmailAddress); 613 return settings.getSetting(KEMailSettings::EmailAddress);
608 } else { 614 } else {
609 return mEmail; 615 return mEmail;
610 } 616 }
611} 617}
612KConfig* KOPrefs::getConfig() 618KConfig* KOPrefs::getConfig()
613{ 619{
614 return config(); 620 return config();
615} 621}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 7ec5327..0779e27 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,358 +1,362 @@
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 KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qobject.h> 30#include <qobject.h>
31 31
32class KConfig; 32class KConfig;
33class QFont; 33class QFont;
34class QColor; 34class QColor;
35class QStringList; 35class QStringList;
36 36
37#define VIEW_WN_VIEW 1 37#define VIEW_WN_VIEW 1
38#define VIEW_NX_VIEW 2 38#define VIEW_NX_VIEW 2
39#define VIEW_J_VIEW 3 39#define VIEW_J_VIEW 3
40#define VIEW_A_VIEW 4 40#define VIEW_A_VIEW 4
41#define VIEW_ML_VIEW 5 41#define VIEW_ML_VIEW 5
42#define VIEW_M_VIEW 6 42#define VIEW_M_VIEW 6
43#define VIEW_L_VIEW 7 43#define VIEW_L_VIEW 7
44#define VIEW_T_VIEW 8 44#define VIEW_T_VIEW 8
45 45
46class KopiCalendarFile : public QObject 46class KopiCalendarFile : public QObject
47{ 47{
48 public: 48 public:
49 KopiCalendarFile( ) : QObject( ) 49 KopiCalendarFile( ) : QObject( )
50 { 50 {
51 isStandard = false; 51 isStandard = false;
52 isEnabled = true; 52 isEnabled = true;
53 isAlarmEnabled = true; 53 isAlarmEnabled = true;
54 isReadOnly = false; 54 isReadOnly = false;
55 mName = "Calendar"; 55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics"; 56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mSavedFileName = "icalfile.ics";
57 mCalNumber = 0; 58 mCalNumber = 0;
58 mDefaultColor = Qt::red; 59 mDefaultColor = Qt::red;
59 mErrorOnLoad = false; 60 mErrorOnLoad = false;
61 isRelative = false;
60 } 62 }
61 bool isStandard; 63 bool isStandard;
62 bool isEnabled; 64 bool isEnabled;
63 bool isAlarmEnabled; 65 bool isAlarmEnabled;
64 bool isReadOnly; 66 bool isReadOnly;
65 bool mErrorOnLoad; 67 bool mErrorOnLoad;
66 QString mName; 68 QString mName;
67 QString mFileName; 69 QString mFileName;
70 QString mSavedFileName;
71 bool isRelative;
68 int mCalNumber; 72 int mCalNumber;
69 QColor mDefaultColor; 73 QColor mDefaultColor;
70 QDateTime mLoadDt; 74 QDateTime mLoadDt;
71}; 75};
72class KOPrefs : public KPimPrefs 76class KOPrefs : public KPimPrefs
73{ 77{
74 public: 78 public:
75 enum { FormatVCalendar, FormatICalendar }; 79 enum { FormatVCalendar, FormatICalendar };
76 enum { MailClientKMail, MailClientSendmail }; 80 enum { MailClientKMail, MailClientSendmail };
77 enum { IMIPDummy, IMIPKMail }; 81 enum { IMIPDummy, IMIPKMail };
78 enum { IMIPOutbox, IMIPdirectsend }; 82 enum { IMIPOutbox, IMIPdirectsend };
79 enum { neverAuto, addressbookAuto, selectedAuto }; 83 enum { neverAuto, addressbookAuto, selectedAuto };
80 enum { standardDestination, askDestination }; 84 enum { standardDestination, askDestination };
81 85
82 virtual ~KOPrefs(); 86 virtual ~KOPrefs();
83 87
84 /** Get instance of KOPrefs. It is made sure that there is only one 88 /** Get instance of KOPrefs. It is made sure that there is only one
85 instance. */ 89 instance. */
86 static KOPrefs *instance(); 90 static KOPrefs *instance();
87 91
88 /** Set preferences to default values */ 92 /** Set preferences to default values */
89 void usrSetDefaults(); 93 void usrSetDefaults();
90 94
91 /** Read preferences from config file */ 95 /** Read preferences from config file */
92 void usrReadConfig(); 96 void usrReadConfig();
93 97
94 /** Write preferences to config file */ 98 /** Write preferences to config file */
95 void usrWriteConfig(); 99 void usrWriteConfig();
96 void setCategoryDefaults(); 100 void setCategoryDefaults();
97 void setAllDefaults(); 101 void setAllDefaults();
98 KopiCalendarFile * getNewCalendar(); 102 KopiCalendarFile * getNewCalendar();
99 KopiCalendarFile * getCalendar( int ); 103 KopiCalendarFile * getCalendar( int );
100 void deleteCalendar( int ); 104 void deleteCalendar( int );
101 QColor defaultColor( int ) const; 105 QColor defaultColor( int ) const;
102 QString calName( int ) const; 106 QString calName( int ) const;
103 int getCalendarID( const QString & name ); 107 int getCalendarID( const QString & name );
104 protected: 108 protected:
105 void setTimeZoneIdDefault(); 109 void setTimeZoneIdDefault();
106 110
107 /** Fill empty mail fields with default values. */ 111 /** Fill empty mail fields with default values. */
108 void fillMailDefaults(); 112 void fillMailDefaults();
109 113
110 private: 114 private:
111 /** Constructor disabled for public. Use instance() to create a KOPrefs 115 /** Constructor disabled for public. Use instance() to create a KOPrefs
112 object. */ 116 object. */
113 KOPrefs(); 117 KOPrefs();
114 118
115 static KOPrefs *mInstance; 119 static KOPrefs *mInstance;
116 QStringList getDefaultList(); 120 QStringList getDefaultList();
117 QStringList getLocationDefaultList(); 121 QStringList getLocationDefaultList();
118 public: 122 public:
119 // preferences data 123 // preferences data
120 KConfig* getConfig(); 124 KConfig* getConfig();
121 void setFullName(const QString &); 125 void setFullName(const QString &);
122 QString fullName(); 126 QString fullName();
123 void setEmail(const QString &); 127 void setEmail(const QString &);
124 QString email(); 128 QString email();
125 129
126 QString mAdditional; 130 QString mAdditional;
127 131
128 bool mEmailControlCenter; 132 bool mEmailControlCenter;
129 133
130 bool mBcc; 134 bool mBcc;
131 bool mAutoSave; 135 bool mAutoSave;
132 int mAutoSaveInterval; 136 int mAutoSaveInterval;
133 bool mConfirm; 137 bool mConfirm;
134 138
135 bool mEnableGroupScheduling; 139 bool mEnableGroupScheduling;
136 bool mEnableProjectView; 140 bool mEnableProjectView;
137 141
138 int mDefaultFormat; 142 int mDefaultFormat;
139 int mMailClient; 143 int mMailClient;
140 144
141 int mStartTime; 145 int mStartTime;
142 int mDefaultDuration; 146 int mDefaultDuration;
143 int mAlarmTime; 147 int mAlarmTime;
144 148
145 int mWorkingHoursStart; 149 int mWorkingHoursStart;
146 int mWorkingHoursEnd; 150 int mWorkingHoursEnd;
147 bool mExcludeHolidays; 151 bool mExcludeHolidays;
148 bool mExcludeSaturdays; 152 bool mExcludeSaturdays;
149 bool mMarcusBainsShowSeconds; 153 bool mMarcusBainsShowSeconds;
150 154
151 QFont mTimeBarFont; 155 QFont mTimeBarFont;
152 QFont mMonthViewFont; 156 QFont mMonthViewFont;
153 QFont mAgendaViewFont; 157 QFont mAgendaViewFont;
154 QFont mMarcusBainsFont; 158 QFont mMarcusBainsFont;
155 QFont mTimeLabelsFont; 159 QFont mTimeLabelsFont;
156 QFont mTodoViewFont; 160 QFont mTodoViewFont;
157 QFont mListViewFont; 161 QFont mListViewFont;
158 QFont mDateNavigatorFont; 162 QFont mDateNavigatorFont;
159 QFont mEditBoxFont; 163 QFont mEditBoxFont;
160 QFont mJornalViewFont; 164 QFont mJornalViewFont;
161 QFont mWhatsNextFont; 165 QFont mWhatsNextFont;
162 QFont mEventViewFont; 166 QFont mEventViewFont;
163 167
164 168
165 169
166 170
167 QColor mHolidayColor; 171 QColor mHolidayColor;
168 QColor mHighlightColor; 172 QColor mHighlightColor;
169 QColor mEventColor; 173 QColor mEventColor;
170 QColor mTodoDoneColor; 174 QColor mTodoDoneColor;
171 QColor mAgendaBgColor; 175 QColor mAgendaBgColor;
172 QColor mWorkingHoursColor; 176 QColor mWorkingHoursColor;
173 QColor mTodoDueTodayColor; 177 QColor mTodoDueTodayColor;
174 QColor mTodoOverdueColor; 178 QColor mTodoOverdueColor;
175 QColor mTodoRunColor; 179 QColor mTodoRunColor;
176 QColor mMonthViewEvenColor; 180 QColor mMonthViewEvenColor;
177 QColor mMonthViewOddColor; 181 QColor mMonthViewOddColor;
178 QColor mMonthViewHolidayColor; 182 QColor mMonthViewHolidayColor;
179 bool mMonthViewUsesDayColors; 183 bool mMonthViewUsesDayColors;
180 bool mMonthViewSatSunTog; 184 bool mMonthViewSatSunTog;
181 bool mMonthViewWeek; 185 bool mMonthViewWeek;
182 QColor mAppColor1; 186 QColor mAppColor1;
183 QColor mAppColor2; 187 QColor mAppColor2;
184 bool mUseAppColors; 188 bool mUseAppColors;
185 189
186 int mDayBegins; 190 int mDayBegins;
187 int mHourSize; 191 int mHourSize;
188 int mAllDaySize; 192 int mAllDaySize;
189 bool mShowFullMenu; 193 bool mShowFullMenu;
190 bool mDailyRecur; 194 bool mDailyRecur;
191 bool mWeeklyRecur; 195 bool mWeeklyRecur;
192 bool mMonthDailyRecur; 196 bool mMonthDailyRecur;
193 bool mMonthWeeklyRecur; 197 bool mMonthWeeklyRecur;
194 bool mMonthShowIcons; 198 bool mMonthShowIcons;
195 bool mMonthShowTimes; 199 bool mMonthShowTimes;
196 bool mMonthShowShort; 200 bool mMonthShowShort;
197 bool mEnableToolTips; 201 bool mEnableToolTips;
198 bool mEnableMonthScroll; 202 bool mEnableMonthScroll;
199 bool mFullViewMonth; 203 bool mFullViewMonth;
200 bool mMonthViewUsesCategoryColor; 204 bool mMonthViewUsesCategoryColor;
201 bool mFullViewTodo; 205 bool mFullViewTodo;
202 bool mShowCompletedTodo; 206 bool mShowCompletedTodo;
203 bool mMarcusBainsEnabled; 207 bool mMarcusBainsEnabled;
204 int mNextXDays; 208 int mNextXDays;
205 int mWhatsNextDays; 209 int mWhatsNextDays;
206 int mWhatsNextPrios; 210 int mWhatsNextPrios;
207 bool mEnableQuickTodo; 211 bool mEnableQuickTodo;
208 212
209 bool mCompactDialogs; 213 bool mCompactDialogs;
210 bool mVerticalScreen; 214 bool mVerticalScreen;
211 215
212 bool mShowIconNewTodo; 216 bool mShowIconNewTodo;
213 bool mShowIconNewEvent; 217 bool mShowIconNewEvent;
214 bool mShowIconSearch; 218 bool mShowIconSearch;
215 bool mShowIconList; 219 bool mShowIconList;
216 bool mShowIconDay1; 220 bool mShowIconDay1;
217 bool mShowIconDay5; 221 bool mShowIconDay5;
218 bool mShowIconDay6; 222 bool mShowIconDay6;
219 bool mShowIconDay7; 223 bool mShowIconDay7;
220 bool mShowIconMonth; 224 bool mShowIconMonth;
221 bool mShowIconTodoview; 225 bool mShowIconTodoview;
222 bool mShowIconBackFast; 226 bool mShowIconBackFast;
223 bool mShowIconBack; 227 bool mShowIconBack;
224 bool mShowIconToday; 228 bool mShowIconToday;
225 bool mShowIconForward; 229 bool mShowIconForward;
226 bool mShowIconForwardFast; 230 bool mShowIconForwardFast;
227 bool mShowIconWhatsThis; 231 bool mShowIconWhatsThis;
228 bool mShowIconWeekNum; 232 bool mShowIconWeekNum;
229 bool mShowIconNextDays; 233 bool mShowIconNextDays;
230 bool mShowIconNext; 234 bool mShowIconNext;
231 bool mShowIconJournal; 235 bool mShowIconJournal;
232 bool mShowIconFilter; 236 bool mShowIconFilter;
233 bool mShowIconOnetoolbar; 237 bool mShowIconOnetoolbar;
234 bool mShowIconNavigator; 238 bool mShowIconNavigator;
235 bool mShowIconAllday; 239 bool mShowIconAllday;
236 bool mShowIconFilterview; 240 bool mShowIconFilterview;
237 bool mShowIconToggleFull; 241 bool mShowIconToggleFull;
238 242
239 bool mShowIconStretch; 243 bool mShowIconStretch;
240 244
241 bool mToolBarHor; 245 bool mToolBarHor;
242 bool mToolBarUp; 246 bool mToolBarUp;
243 bool mToolBarHorV; 247 bool mToolBarHorV;
244 bool mToolBarUpV; 248 bool mToolBarUpV;
245 bool mToolBarHorN; 249 bool mToolBarHorN;
246 bool mToolBarUpN; 250 bool mToolBarUpN;
247 bool mToolBarHorF; 251 bool mToolBarHorF;
248 bool mToolBarUpF; 252 bool mToolBarUpF;
249 bool mToolBarMiniIcons; 253 bool mToolBarMiniIcons;
250 254
251 bool mAskForQuit; 255 bool mAskForQuit;
252 bool mUsePassWd; 256 bool mUsePassWd;
253 bool mShowSyncEvents; 257 bool mShowSyncEvents;
254 bool mShowTodoInAgenda; 258 bool mShowTodoInAgenda;
255 bool mShowCompletedTodoInAgenda; 259 bool mShowCompletedTodoInAgenda;
256 bool mShowTimeInAgenda; 260 bool mShowTimeInAgenda;
257 bool mHideNonStartedTodos; 261 bool mHideNonStartedTodos;
258 262
259 bool mBlockPopupMenu; 263 bool mBlockPopupMenu;
260 264
261 int mLastSyncTime; 265 int mLastSyncTime;
262 void setCategoryColor(QString cat,const QColor & color); 266 void setCategoryColor(QString cat,const QColor & color);
263 QColor *categoryColor(QString cat); 267 QColor *categoryColor(QString cat);
264 268
265 QString mArchiveFile; 269 QString mArchiveFile;
266 QString mHtmlExportFile; 270 QString mHtmlExportFile;
267 bool mHtmlWithSave; 271 bool mHtmlWithSave;
268 272
269 QStringList mSelectedPlugins; 273 QStringList mSelectedPlugins;
270 274
271 QString mLastImportFile; 275 QString mLastImportFile;
272 QString mLastVcalFile; 276 QString mLastVcalFile;
273 QString mLastSaveFile; 277 QString mLastSaveFile;
274 QString mLastLoadFile; 278 QString mLastLoadFile;
275 279
276 280
277 QString mDefaultAlarmFile; 281 QString mDefaultAlarmFile;
278 int mIMIPScheduler; 282 int mIMIPScheduler;
279 int mIMIPSend; 283 int mIMIPSend;
280 QStringList mAdditionalMails; 284 QStringList mAdditionalMails;
281 int mIMIPAutoRefresh; 285 int mIMIPAutoRefresh;
282 int mIMIPAutoInsertReply; 286 int mIMIPAutoInsertReply;
283 int mIMIPAutoInsertRequest; 287 int mIMIPAutoInsertRequest;
284 int mIMIPAutoFreeBusy; 288 int mIMIPAutoFreeBusy;
285 int mIMIPAutoFreeBusyReply; 289 int mIMIPAutoFreeBusyReply;
286 290
287 QStringList mTodoTemplates; 291 QStringList mTodoTemplates;
288 QStringList mEventTemplates; 292 QStringList mEventTemplates;
289 293
290 int mDestination; 294 int mDestination;
291 295
292 296
293 bool mEditOnDoubleClick; 297 bool mEditOnDoubleClick;
294 bool mViewChangeHoldFullscreen; 298 bool mViewChangeHoldFullscreen;
295 bool mViewChangeHoldNonFullscreen; 299 bool mViewChangeHoldNonFullscreen;
296 bool mCenterOnCurrentTime; 300 bool mCenterOnCurrentTime;
297 bool mSetTimeToDayStartAt; 301 bool mSetTimeToDayStartAt;
298 bool mHighlightCurrentDay; 302 bool mHighlightCurrentDay;
299 bool mUseHighlightLightColor; 303 bool mUseHighlightLightColor;
300 bool mListViewMonthTimespan; 304 bool mListViewMonthTimespan;
301 bool mWNViewShowsParents; 305 bool mWNViewShowsParents;
302 bool mWNViewShowsPast; 306 bool mWNViewShowsPast;
303 bool mWNViewShowLocation; 307 bool mWNViewShowLocation;
304 bool mTodoViewShowsPercentage; 308 bool mTodoViewShowsPercentage;
305 bool mTodoViewUsesCatColors; 309 bool mTodoViewUsesCatColors;
306 bool mMonthViewUsesBigFont; 310 bool mMonthViewUsesBigFont;
307 bool mTodoViewUsesSmallFont; 311 bool mTodoViewUsesSmallFont;
308 bool mTodoViewUsesForegroundColor; 312 bool mTodoViewUsesForegroundColor;
309 bool mMonthViewUsesForegroundColor; 313 bool mMonthViewUsesForegroundColor;
310 314
311 bool mHightlightDateTimeEdit; 315 bool mHightlightDateTimeEdit;
312 bool mShortDateInViewer; 316 bool mShortDateInViewer;
313 317
314 bool mShowDateNavigator; 318 bool mShowDateNavigator;
315 319
316 QStringList mLocationDefaults; 320 QStringList mLocationDefaults;
317 QStringList mEventSummaryUser; 321 QStringList mEventSummaryUser;
318 QStringList mTodoSummaryUser; 322 QStringList mTodoSummaryUser;
319 QStringList mJournalSummaryUser; 323 QStringList mJournalSummaryUser;
320 324
321 bool mUseInternalAlarmNotification; 325 bool mUseInternalAlarmNotification;
322 int mAlarmPlayBeeps; 326 int mAlarmPlayBeeps;
323 int mAlarmSuspendTime; 327 int mAlarmSuspendTime;
324 int mAlarmSuspendCount; 328 int mAlarmSuspendCount;
325 int mAlarmBeepInterval; 329 int mAlarmBeepInterval;
326 int mOldLanguage; 330 int mOldLanguage;
327 int mOldLoadedLanguage; 331 int mOldLoadedLanguage;
328 332
329 333
330 QString mActiveSyncPort; 334 QString mActiveSyncPort;
331 QString mActiveSyncIP; 335 QString mActiveSyncIP;
332 336
333 // settings for eventviewer 337 // settings for eventviewer
334 bool mEVshowDetails; 338 bool mEVshowDetails;
335 bool mEVshowCreated; 339 bool mEVshowCreated;
336 bool mEVshowChanged; 340 bool mEVshowChanged;
337 bool mWTshowDetails; 341 bool mWTshowDetails;
338 bool mWTshowCreated; 342 bool mWTshowCreated;
339 bool mWTshowChanged; 343 bool mWTshowChanged;
340 344
341 int mCurrentDisplayedView; 345 int mCurrentDisplayedView;
342 QPtrList<KopiCalendarFile> mCalendars; 346 QPtrList<KopiCalendarFile> mCalendars;
343 int mNextAvailableCalendar; 347 int mNextAvailableCalendar;
344 348
345 private: 349 private:
346 QDict<QColor> mCategoryColors; 350 QDict<QColor> mCategoryColors;
347 QArray<KopiCalendarFile*> mDefCalColors; 351 QArray<KopiCalendarFile*> mDefCalColors;
348 QColor mDefaultCategoryColor; 352 QColor mDefaultCategoryColor;
349 353
350 QFont mDefaultTimeBarFont; 354 QFont mDefaultTimeBarFont;
351 QFont mDefaultViewFont; 355 QFont mDefaultViewFont;
352 QFont mDefaultMonthViewFont; 356 QFont mDefaultMonthViewFont;
353 357
354 QString mName; 358 QString mName;
355 QString mEmail; 359 QString mEmail;
356}; 360};
357 361
358#endif 362#endif
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp
index 3f8a630..2e483e9 100644
--- a/microkde/kglobalsettings.cpp
+++ b/microkde/kglobalsettings.cpp
@@ -1,104 +1,113 @@
1#include "kglobalsettings.h" 1#include "kglobalsettings.h"
2#include "kconfig.h" 2#include "kconfig.h"
3#include "kglobal.h" 3#include "kglobal.h"
4#include "kconfigbase.h" 4#include "kconfigbase.h"
5 5
6#include <qapplication.h> 6#include <qapplication.h>
7 7
8#ifdef DESKTOP_VERSION 8#ifdef DESKTOP_VERSION
9 QColor KGlobalSettings::mAlternate = QColor( 235, 235, 235 ); 9 QColor KGlobalSettings::mAlternate = QColor( 235, 235, 235 );
10#else 10#else
11 QColor KGlobalSettings::mAlternate = QColor( 210, 210, 210 ); 11 QColor KGlobalSettings::mAlternate = QColor( 210, 210, 210 );
12#endif 12#endif
13 13
14 14
15QFont KGlobalSettings::generalFont() 15QFont KGlobalSettings::generalFont()
16{ 16{
17 int size = 12; 17 int size = 12;
18 if (QApplication::desktop()->width() < 480 ) { 18 if (QApplication::desktop()->width() < 480 ) {
19 size = 10; 19 size = 10;
20 } 20 }
21#ifndef DESKTOP_VERSION 21#ifndef DESKTOP_VERSION
22 else 22 else
23 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 23 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
24 size = 18; 24 size = 18;
25#endif 25#endif
26 QFont f = QApplication::font(); 26 QFont f = QApplication::font();
27 //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1()); 27 //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1());
28 f.setPointSize( size ); 28 f.setPointSize( size );
29 return f; 29 return f;
30} 30}
31QFont KGlobalSettings::generalMaxFont() 31QFont KGlobalSettings::generalMaxFont()
32{ 32{
33 int size = 12; 33 int size = 12;
34 if (QApplication::desktop()->width() < 480 ) { 34 if (QApplication::desktop()->width() < 480 ) {
35 size = 10; 35 size = 10;
36 } 36 }
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38 else 38 else
39 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 39 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
40 size = 18; 40 size = 18;
41#endif 41#endif
42 QFont f = QApplication::font(); 42 QFont f = QApplication::font();
43 if ( f.pointSize() > size ) 43 if ( f.pointSize() > size )
44 f.setPointSize( size ); 44 f.setPointSize( size );
45 return f; 45 return f;
46} 46}
47 47
48QString KGlobalSettings::timeTrackerDir() 48QString KGlobalSettings::timeTrackerDir()
49{ 49{
50 static QString dir; 50 static QString dir;
51 if ( dir.isEmpty() ) { 51 if ( dir.isEmpty() ) {
52 dir = locateLocal( "data", "timetrackerdir/d.ttl" ); 52 dir = locateLocal( "data", "timetrackerdir/d.ttl" );
53 dir = dir.left ( dir.length() - 5); 53 dir = dir.left ( dir.length() - 5);
54 } 54 }
55 return dir; 55 return dir;
56} 56}
57QString KGlobalSettings::backupDataDir() 57QString KGlobalSettings::backupDataDir()
58{ 58{
59 static QString dir; 59 static QString dir;
60 if ( dir.isEmpty() ) { 60 if ( dir.isEmpty() ) {
61 dir = locateLocal( "data", "backupdir/d.ttl" ); 61 dir = locateLocal( "data", "backupdir/d.ttl" );
62 dir = dir.left ( dir.length() - 5); 62 dir = dir.left ( dir.length() - 5);
63 } 63 }
64 return dir; 64 return dir;
65} 65}
66QString KGlobalSettings::calendarDir()
67{
68 static QString dir;
69 if ( dir.isEmpty() ) {
70 dir = locateLocal( "data", "korganizer/d.ttl" );
71 dir = dir.left ( dir.length() - 5);
72 }
73 return dir;
74}
66 75
67QFont KGlobalSettings::toolBarFont() 76QFont KGlobalSettings::toolBarFont()
68{ 77{
69 return QApplication::font(); 78 return QApplication::font();
70} 79}
71 80
72QColor KGlobalSettings::toolBarHighlightColor() 81QColor KGlobalSettings::toolBarHighlightColor()
73{ 82{
74 return QColor( "black" ); 83 return QColor( "black" );
75} 84}
76 85
77QColor KGlobalSettings::alternateBackgroundColor() 86QColor KGlobalSettings::alternateBackgroundColor()
78{ 87{
79 return mAlternate; 88 return mAlternate;
80 89
81} 90}
82void KGlobalSettings::setAlternateBackgroundColor(QColor c) 91void KGlobalSettings::setAlternateBackgroundColor(QColor c)
83{ 92{
84 mAlternate = c; 93 mAlternate = c;
85 94
86} 95}
87 96
88QRect KGlobalSettings::desktopGeometry( QWidget * ) 97QRect KGlobalSettings::desktopGeometry( QWidget * )
89{ 98{
90 return QApplication::desktop()->rect(); 99 return QApplication::desktop()->rect();
91} 100}
92 101
93 /** 102 /**
94 * Returns whether KDE runs in single (default) or double click 103 * Returns whether KDE runs in single (default) or double click
95 * mode. 104 * mode.
96 * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html 105 * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html
97 * @return true if single click mode, or false if double click mode. 106 * @return true if single click mode, or false if double click mode.
98 **/ 107 **/
99bool KGlobalSettings::singleClick() 108bool KGlobalSettings::singleClick()
100{ 109{
101 KConfig *c = KGlobal::config(); 110 KConfig *c = KGlobal::config();
102 KConfigGroupSaver cgs( c, "KDE" ); 111 KConfigGroupSaver cgs( c, "KDE" );
103 return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); 112 return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
104} 113}
diff --git a/microkde/kglobalsettings.h b/microkde/kglobalsettings.h
index 4e4d87c..977e5b6 100644
--- a/microkde/kglobalsettings.h
+++ b/microkde/kglobalsettings.h
@@ -1,36 +1,37 @@
1#ifndef MICROKDE_KGLOBALSETTINGS_H 1#ifndef MICROKDE_KGLOBALSETTINGS_H
2#define MICROKDE_KGLOBALSETTINGS_H 2#define MICROKDE_KGLOBALSETTINGS_H
3 3
4#include <qfont.h> 4#include <qfont.h>
5#include <qrect.h> 5#include <qrect.h>
6 6
7 7
8#define KDE_DEFAULT_SINGLECLICK true 8#define KDE_DEFAULT_SINGLECLICK true
9 9
10 10
11class KGlobalSettings 11class KGlobalSettings
12{ 12{
13 public: 13 public:
14 static QFont generalFont(); 14 static QFont generalFont();
15 static QFont generalMaxFont(); 15 static QFont generalMaxFont();
16 static QFont toolBarFont(); 16 static QFont toolBarFont();
17 17
18 static QColor mAlternate; 18 static QColor mAlternate;
19 static QColor toolBarHighlightColor(); 19 static QColor toolBarHighlightColor();
20 static QColor alternateBackgroundColor(); 20 static QColor alternateBackgroundColor();
21 static void setAlternateBackgroundColor(QColor); 21 static void setAlternateBackgroundColor(QColor);
22 static QRect desktopGeometry( QWidget * ); 22 static QRect desktopGeometry( QWidget * );
23 static QString timeTrackerDir(); 23 static QString timeTrackerDir();
24 static QString backupDataDir(); 24 static QString backupDataDir();
25 static QString calendarDir();
25 26
26 /** 27 /**
27 * Returns whether KDE runs in single (default) or double click 28 * Returns whether KDE runs in single (default) or double click
28 * mode. 29 * mode.
29 * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html 30 * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html
30 * @return true if single click mode, or false if double click mode. 31 * @return true if single click mode, or false if double click mode.
31 **/ 32 **/
32 static bool singleClick(); 33 static bool singleClick();
33 34
34}; 35};
35 36
36#endif 37#endif