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