summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp130
1 files changed, 26 insertions, 104 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 95388ef..880d399 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,484 +1,405 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = p->font(); 123 QFont nFont = font();
124 p->setFont( font());
124 125
125 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
126 if ( QApplication::desktop()->width() <= 320 )
127 suffix = "00"; 127 suffix = "00";
128 else 128 } else
129 suffix = "00"; 129 if (cell > 11) suffix = "pm";
130 }
131 130
132 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
133 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
134 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
135 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
136 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
137 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
138 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
139 break; 138 break;
140 -- pointS; 139 -- pointS;
141 } 140 }
142 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
143 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
144 } 143 }
145 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
146 QFont sFont = nFont; 145 QFont sFont = nFont;
147 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
148 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
149 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
150 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
151 int startW = this->width() - frameWidth()-2; 150 int startW = mMiniWidth - frameWidth()-2 ;
152 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
153 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline
154 //p->drawLine(0,0,0,contentsHeight());
154 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
155 p->drawLine(startW-tw2+1 ,y,cw,y); 156 p->drawLine(startW-tw2 ,y,cw+2,y);
156 hour.setNum(cell); 157 hour.setNum(cell);
157 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
158 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
159 if (cell > 11) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
160 else
161 suffix = "am";
162 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
163 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
164 } 163 }
165 164
166 // center and draw the time label 165 // center and draw the time label
167 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
168 int offset = startW - timeWidth - tw2 ; 167 int offset = startW - timeWidth - tw2 -1 ;
169 p->setFont( nFont ); 168 p->setFont( nFont );
170 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
171 p->setFont( sFont ); 170 p->setFont( sFont );
172 offset = startW - tw2+1; 171 offset = startW - tw2;
173 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
174 173
175 // increment indices 174 // increment indices
176 y += mCellHeight; 175 y += mCellHeight;
177 cell++; 176 cell++;
178 } 177 }
179 178
180 179
181 180
182 181
183#if 0
184 mRedrawNeeded = true;
185 if ( mRedrawNeeded ) {
186 cx = contentsX() + frameWidth()*2;
187 cw = contentsWidth() ;
188 // end of workaround
189
190 int cell = ((int)(cy/mCellHeight));
191 int y = cell * mCellHeight;
192 QFontMetrics fm = fontMetrics();
193 QString hour;
194 QString suffix;
195 int timeHeight = fm.ascent();
196 QFont nFont = p->font();
197
198 if (!KGlobal::locale()->use12Clock()) {
199 if ( QApplication::desktop()->width() <= 320 )
200 suffix = "";
201 else
202 suffix = "00";
203 }
204
205 if ( timeHeight > mCellHeight ) {
206 timeHeight = mCellHeight-1;
207 int pointS = nFont.pointSize();
208 while ( pointS > 4 ) {
209 nFont.setPointSize( pointS );
210 fm = QFontMetrics( nFont );
211 if ( fm.ascent() < mCellHeight )
212 break;
213 -- pointS;
214 }
215 fm = QFontMetrics( nFont );
216 timeHeight = fm.ascent();
217 }
218 //timeHeight -= (timeHeight/4-2);
219 QFont sFont = nFont;
220 sFont.setPointSize( sFont.pointSize()/2 );
221 QFontMetrics fmS( sFont );
222 int sHei = fmS.ascent() ;
223 //sHei -= (sHei/4-2);
224 int startW = this->width() - frameWidth()-2;
225 int tw2 = fmS.width(suffix);
226 while (y < cy + ch) {
227 p->drawLine(cx,y,cw,y);
228 hour.setNum(cell);
229 // handle 24h and am/pm time formats
230 if (KGlobal::locale()->use12Clock()) {
231 if (cell > 11) suffix = "pm";
232 else
233 suffix = "am";
234 if (cell == 0) hour.setNum(12);
235 if (cell > 12) hour.setNum(cell - 12);
236 tw2 = fmS.width(suffix);
237 }
238
239 // center and draw the time label
240 int timeWidth = fm.width(hour);
241 int offset = startW - timeWidth - tw2 ;
242 p->setFont( nFont );
243 p->drawText( offset, y+ timeHeight, hour);
244 p->setFont( sFont );
245 offset = startW - tw2+1;
246 p->drawText( offset, y+ sHei, suffix);
247
248 // increment indices
249 y += mCellHeight;
250 cell++;
251 }
252 } else {
253 //qDebug("NO redraw ");
254 }
255 // double buffer not yet implemented
256 //bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
257 //mRedrawNeeded = false;
258#endif
259} 182}
260 183
261/** 184/**
262 Calculates the minimum width. 185 Calculates the minimum width.
263*/ 186*/
264int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
265{ 188{
266 return mMiniWidth; 189 return mMiniWidth;
267} 190}
268 191
269/** updates widget's internal state */ 192/** updates widget's internal state */
270void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
271{ 194{
272 mRedrawNeeded = true; 195 mRedrawNeeded = true;
273 // set the font 196 // set the font
274 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
275 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
276 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
277 QString test = "20"; 200 QString test = "20";
278 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
279 test = "12"; 202 test = "12";
280 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
281 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
282 test = "pm"; 205 test = "pm";
283 else { 206 else {
284 if ( QApplication::desktop()->width() <= 320 ) 207 test = "00";
285 test = "00";
286 else
287 test = "00";
288 } 208 }
289 QFont sFont = font(); 209 QFont sFont = font();
290 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
291 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
292 mMiniWidth += fmS.width( test ) + frameWidth()*2 +4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 qDebug("testwid %d %d", mMiniWidth ,fmS.width( test ));
293 // update geometry restrictions based on new settings 214 // update geometry restrictions based on new settings
294 setFixedWidth( mMiniWidth ); 215 setFixedWidth( mMiniWidth );
295 216
296 // update HourSize 217 // update HourSize
297 mCellHeight = KOPrefs::instance()->mHourSize*4; 218 mCellHeight = KOPrefs::instance()->mHourSize*4;
298 resizeContents(50,mRows * mCellHeight); 219 resizeContents(50,mRows * mCellHeight);
299} 220}
300 221
301/** update time label positions */ 222/** update time label positions */
302void TimeLabels::positionChanged() 223void TimeLabels::positionChanged()
303{ 224{
304 int adjustment = mAgenda->contentsY(); 225 int adjustment = mAgenda->contentsY();
305 setContentsPos(0, adjustment); 226 setContentsPos(0, adjustment);
306} 227}
307 228
308/** */ 229/** */
309void TimeLabels::setAgenda(KOAgenda* agenda) 230void TimeLabels::setAgenda(KOAgenda* agenda)
310{ 231{
311 mAgenda = agenda; 232 mAgenda = agenda;
312} 233}
313 234
314void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 235void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
315{ 236{
316 mMouseDownY = e->pos().y(); 237 mMouseDownY = e->pos().y();
317 mOrgCap = topLevelWidget()->caption(); 238 mOrgCap = topLevelWidget()->caption();
318} 239}
319 240
320void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 241void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
321{ 242{
322 int diff = mMouseDownY - e->pos().y(); 243 int diff = mMouseDownY - e->pos().y();
323 if ( diff < 10 && diff > -10 ) 244 if ( diff < 10 && diff > -10 )
324 return; 245 return;
325 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 246 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
326 if ( tSize < 4 ) 247 if ( tSize < 4 )
327 tSize = 4; 248 tSize = 4;
328 if ( tSize > 22 ) 249 if ( tSize > 22 )
329 tSize = 22; 250 tSize = 22;
330 tSize = (tSize-2)/2; 251 tSize = (tSize-2)/2;
331 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 252 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
332 253
333} 254}
334void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 255void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
335{ 256{
336 topLevelWidget()->setCaption( mOrgCap ); 257 topLevelWidget()->setCaption( mOrgCap );
337 int diff = mMouseDownY - e->pos().y(); 258 int diff = mMouseDownY - e->pos().y();
338 if ( diff < 10 && diff > -10 ) 259 if ( diff < 10 && diff > -10 )
339 return; 260 return;
340 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 261 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
341 if ( tSize < 4 ) 262 if ( tSize < 4 )
342 tSize = 4; 263 tSize = 4;
343 if ( tSize > 22 ) 264 if ( tSize > 22 )
344 tSize = 22; 265 tSize = 22;
345 tSize = (tSize/2)*2; 266 tSize = (tSize/2)*2;
346 if ( tSize == KOPrefs::instance()->mHourSize ) 267 if ( tSize == KOPrefs::instance()->mHourSize )
347 return; 268 return;
348 KOPrefs::instance()->mHourSize = tSize; 269 KOPrefs::instance()->mHourSize = tSize;
349 emit scaleChanged(); 270 emit scaleChanged();
350} 271}
351 272
352/** This is called in response to repaint() */ 273/** This is called in response to repaint() */
353void TimeLabels::paintEvent(QPaintEvent*) 274void TimeLabels::paintEvent(QPaintEvent*)
354{ 275{
355 276
356 // kdDebug() << "paintevent..." << endl; 277 // kdDebug() << "paintevent..." << endl;
357 // this is another hack! 278 // this is another hack!
358 // QPainter painter(this); 279 // QPainter painter(this);
359 //QString c 280 //QString c
360 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 281 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
361} 282}
362 283
363//////////////////////////////////////////////////////////////////////////// 284////////////////////////////////////////////////////////////////////////////
364 285
365EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 286EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
366 : QFrame(parent,name) 287 : QFrame(parent,name)
367{ 288{
368 mColumns = 1; 289 mColumns = 1;
369 mTopBox = 0; 290 mTopBox = 0;
370 mLocation = loc; 291 mLocation = loc;
371 mTopLayout = 0; 292 mTopLayout = 0;
372 mPaintWidget = 0; 293 mPaintWidget = 0;
373 mXOffset = 0; 294 mXOffset = 0;
374 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 295 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
375 else mPixmap = SmallIcon("1downarrow"); 296 else mPixmap = SmallIcon("1downarrow");
376 mEnabled.resize(mColumns); 297 mEnabled.resize(mColumns);
377 mEnabled.fill( false ); 298 mEnabled.fill( false );
378 setMinimumHeight(mPixmap.height()); 299 setMinimumHeight(mPixmap.height());
379} 300}
380 301
381EventIndicator::~EventIndicator() 302EventIndicator::~EventIndicator()
382{ 303{
383} 304}
384 305
385void EventIndicator::drawContents(QPainter *p) 306void EventIndicator::drawContents(QPainter *p)
386{ 307{
387 308
388 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 309 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
389 KDGanttSplitterHandle* han = 0; 310 KDGanttSplitterHandle* han = 0;
390 if ( mPaintWidget ) 311 if ( mPaintWidget )
391 han = mPaintWidget->firstHandle(); 312 han = mPaintWidget->firstHandle();
392 if ( ! han ) { 313 if ( ! han ) {
393 int i; 314 int i;
394 for(i=0;i<mColumns;++i) { 315 for(i=0;i<mColumns;++i) {
395 if (mEnabled[i]) { 316 if (mEnabled[i]) {
396 int cellWidth = contentsRect().right()/mColumns; 317 int cellWidth = contentsRect().right()/mColumns;
397 int xOffset = KOGlobals::self()->reverseLayout() ? 318 int xOffset = KOGlobals::self()->reverseLayout() ?
398 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 319 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
399 i*cellWidth + (cellWidth -mPixmap.width()) /2; 320 i*cellWidth + (cellWidth -mPixmap.width()) /2;
400 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 321 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
401 } 322 }
402 } 323 }
403 } else { 324 } else {
404 han->repaint(); 325 han->repaint();
405 //mPaintWidget->setBackgroundColor( red ); 326 //mPaintWidget->setBackgroundColor( red );
406 327
407 QPainter pa( han ); 328 QPainter pa( han );
408 int i; 329 int i;
409 bool setColor = false; 330 bool setColor = false;
410 for(i=0;i<mColumns;++i) { 331 for(i=0;i<mColumns;++i) {
411 if (mEnabled[i]) { 332 if (mEnabled[i]) {
412 setColor = true; 333 setColor = true;
413 334
414 int cellWidth = contentsRect().right()/mColumns; 335 int cellWidth = contentsRect().right()/mColumns;
415 int xOffset = KOGlobals::self()->reverseLayout() ? 336 int xOffset = KOGlobals::self()->reverseLayout() ?
416 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 337 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
417 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 338 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
418 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 339 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
419 //qDebug("222draw pix %d ",xOffset ); 340 //qDebug("222draw pix %d ",xOffset );
420 341
421 } 342 }
422 343
423 } 344 }
424 pa.end(); 345 pa.end();
425 346
426 } 347 }
427} 348}
428 349
429void EventIndicator::setXOffset( int x ) 350void EventIndicator::setXOffset( int x )
430{ 351{
431 mXOffset = x; 352 mXOffset = x;
432} 353}
433void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 354void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
434{ 355{
435 mPaintWidget = w; 356 mPaintWidget = w;
436 setMaximumHeight(0); 357 setMaximumHeight(0);
437 setMinimumHeight(0); 358 setMinimumHeight(0);
438} 359}
439void EventIndicator::changeColumns(int columns) 360void EventIndicator::changeColumns(int columns)
440{ 361{
441 mColumns = columns; 362 mColumns = columns;
442 mEnabled.resize(mColumns); 363 mEnabled.resize(mColumns);
443 364
444 update(); 365 update();
445} 366}
446 367
447void EventIndicator::enableColumn(int column, bool enable) 368void EventIndicator::enableColumn(int column, bool enable)
448{ 369{
449 mEnabled[column] = enable; 370 mEnabled[column] = enable;
450} 371}
451 372
452 373
453//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
454//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
455//////////////////////////////////////////////////////////////////////////// 376////////////////////////////////////////////////////////////////////////////
456 377
457KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 378KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
458 KOEventView (cal,parent,name) 379 KOEventView (cal,parent,name)
459{ 380{
460 mBlockUpdating = true; 381 mBlockUpdating = true;
461 mStartHour = 8; 382 mStartHour = 8;
462 mSelectedDates.append(QDate::currentDate()); 383 mSelectedDates.append(QDate::currentDate());
463 384
464 mLayoutDayLabels = 0; 385 mLayoutDayLabels = 0;
465 mDayLabelsFrame = 0; 386 mDayLabelsFrame = 0;
466 mDayLabels = 0; 387 mDayLabels = 0;
467 bool isRTL = KOGlobals::self()->reverseLayout(); 388 bool isRTL = KOGlobals::self()->reverseLayout();
468 QPixmap expandPix; 389 QPixmap expandPix;
469 if ( KOPrefs::instance()->mVerticalScreen ) { 390 if ( KOPrefs::instance()->mVerticalScreen ) {
470 expandPix = SmallIcon( "1updownarrow" ); 391 expandPix = SmallIcon( "1updownarrow" );
471 } else { 392 } else {
472 expandPix = SmallIcon("1leftrightarrow" ); 393 expandPix = SmallIcon("1leftrightarrow" );
473 } 394 }
474 395
475 QBoxLayout *topLayout = new QVBoxLayout(this); 396 QBoxLayout *topLayout = new QVBoxLayout(this);
476 397
477 // Create day name labels for agenda columns 398 // Create day name labels for agenda columns
478 // Create agenda splitter 399 // Create agenda splitter
479 400
480 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
481 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
482 topLayout->addWidget( mSplitterAgenda ); 403 topLayout->addWidget( mSplitterAgenda );
483 mAllDayFrame = new QHBox(mSplitterAgenda); 404 mAllDayFrame = new QHBox(mSplitterAgenda);
484 mAllDayFrame->setFocusPolicy(NoFocus); 405 mAllDayFrame->setFocusPolicy(NoFocus);
@@ -545,573 +466,574 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
545 mAllAgendaPopup = eventPopup(); 466 mAllAgendaPopup = eventPopup();
546 467
547 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
548 i18n("Toggle Alarm"),mAgenda, 469 i18n("Toggle Alarm"),mAgenda,
549 SLOT(popupAlarm()),true); 470 SLOT(popupAlarm()),true);
550 471
551 472
552 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
553 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
554 475
555 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
556 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
557 mAgenda->setPopup( mAllAgendaPopup ); 478 mAgenda->setPopup( mAllAgendaPopup );
558 mAllDayAgenda->setPopup( mAllAgendaPopup ); 479 mAllDayAgenda->setPopup( mAllAgendaPopup );
559 // make connections between dependent widgets 480 // make connections between dependent widgets
560 mTimeLabels->setAgenda(mAgenda); 481 mTimeLabels->setAgenda(mAgenda);
561 482
562 // Update widgets to reflect user preferences 483 // Update widgets to reflect user preferences
563 // updateConfig(); 484 // updateConfig();
564 485
565 // createDayLabels(); 486 // createDayLabels();
566 487
567 // these blank widgets make the All Day Event box line up with the agenda 488 // these blank widgets make the All Day Event box line up with the agenda
568 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
569 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 490 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
570 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 491 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
571 492
572 // Scrolling 493 // Scrolling
573 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 494 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
574 mTimeLabels, SLOT(positionChanged())); 495 mTimeLabels, SLOT(positionChanged()));
575 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 496 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
576 SLOT(setContentsPos(int))); 497 SLOT(setContentsPos(int)));
577 498
578 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 499 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
579 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 500 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
580 501
581 // Create/Show/Edit/Delete Event 502 // Create/Show/Edit/Delete Event
582 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 503 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
583 SLOT(newEvent(int,int))); 504 SLOT(newEvent(int,int)));
584 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 505 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
585 SLOT(newTodo(int,int))); 506 SLOT(newTodo(int,int)));
586 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
587 SLOT(newEvent(int,int,int,int))); 508 SLOT(newEvent(int,int,int,int)));
588 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 509 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
589 SLOT(newEventAllDay(int,int))); 510 SLOT(newEventAllDay(int,int)));
590 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 511 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
591 SLOT(newTodoAllDay(int,int))); 512 SLOT(newTodoAllDay(int,int)));
592 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
593 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
594 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 515 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
595 SLOT(newTimeSpanSelected(int,int,int,int))); 516 SLOT(newTimeSpanSelected(int,int,int,int)));
596 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
597 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 518 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
598 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
599 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 520 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
600 521
601 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 522 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
602 SIGNAL(editIncidenceSignal(Incidence *))); 523 SIGNAL(editIncidenceSignal(Incidence *)));
603 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 524 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
604 SIGNAL(editIncidenceSignal(Incidence *))); 525 SIGNAL(editIncidenceSignal(Incidence *)));
605 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
606 SIGNAL(showIncidenceSignal(Incidence *))); 527 SIGNAL(showIncidenceSignal(Incidence *)));
607 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
608 SIGNAL(showIncidenceSignal(Incidence *))); 529 SIGNAL(showIncidenceSignal(Incidence *)));
609 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
610 SIGNAL(deleteIncidenceSignal(Incidence *))); 531 SIGNAL(deleteIncidenceSignal(Incidence *)));
611 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
612 SIGNAL(deleteIncidenceSignal(Incidence *))); 533 SIGNAL(deleteIncidenceSignal(Incidence *)));
613 534
614 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 535 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
615 SLOT(updateEventDates(KOAgendaItem *, int ))); 536 SLOT(updateEventDates(KOAgendaItem *, int )));
616 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 537 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
617 SLOT(updateEventDates(KOAgendaItem *, int))); 538 SLOT(updateEventDates(KOAgendaItem *, int)));
618 539
619 // event indicator update 540 // event indicator update
620 connect(mAgenda,SIGNAL(lowerYChanged(int)), 541 connect(mAgenda,SIGNAL(lowerYChanged(int)),
621 SLOT(updateEventIndicatorTop(int))); 542 SLOT(updateEventIndicatorTop(int)));
622 connect(mAgenda,SIGNAL(upperYChanged(int)), 543 connect(mAgenda,SIGNAL(upperYChanged(int)),
623 SLOT(updateEventIndicatorBottom(int))); 544 SLOT(updateEventIndicatorBottom(int)));
624 // drag signals 545 // drag signals
625 /* 546 /*
626 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 547 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
627 SLOT(startDrag(Event *))); 548 SLOT(startDrag(Event *)));
628 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 549 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
629 SLOT(startDrag(Event *))); 550 SLOT(startDrag(Event *)));
630 */ 551 */
631 // synchronize selections 552 // synchronize selections
632 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 553 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
633 mAllDayAgenda, SLOT( deselectItem() ) ); 554 mAllDayAgenda, SLOT( deselectItem() ) );
634 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 555 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
635 mAgenda, SLOT( deselectItem() ) ); 556 mAgenda, SLOT( deselectItem() ) );
636 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
637 SIGNAL( incidenceSelected( Incidence * ) ) ); 558 SIGNAL( incidenceSelected( Incidence * ) ) );
638 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
639 SIGNAL( incidenceSelected( Incidence * ) ) ); 560 SIGNAL( incidenceSelected( Incidence * ) ) );
640 connect( mAgenda, SIGNAL( resizedSignal() ), 561 connect( mAgenda, SIGNAL( resizedSignal() ),
641 SLOT( updateConfig( ) ) ); 562 SLOT( updateConfig( ) ) );
642 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 563 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
643 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 564 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
644 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 565 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
645 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 566 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
646 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
647 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 568 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
648 569
649 570
650} 571}
651 572
652void KOAgendaView::toggleAllDay() 573void KOAgendaView::toggleAllDay()
653{ 574{
654 if ( mSplitterAgenda->firstHandle() ) 575 if ( mSplitterAgenda->firstHandle() )
655 mSplitterAgenda->firstHandle()->toggle(); 576 mSplitterAgenda->firstHandle()->toggle();
656} 577}
657void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 578void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
658{ 579{
659 calendar()->addIncidence( inc ); 580 calendar()->addIncidence( inc );
660 581
661 if ( incOld ) { 582 if ( incOld ) {
662 if ( incOld->type() == "Todo" ) 583 if ( incOld->type() == "Todo" )
663 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 584 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
664 else 585 else
665 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 586 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
666 } 587 }
667 588
668} 589}
669 590
670KOAgendaView::~KOAgendaView() 591KOAgendaView::~KOAgendaView()
671{ 592{
672 delete mAllAgendaPopup; 593 delete mAllAgendaPopup;
673 //delete mAllDayAgendaPopup; 594 //delete mAllDayAgendaPopup;
674 delete KOAgendaItem::paintPix(); 595 delete KOAgendaItem::paintPix();
675 delete KOAgendaItem::paintPixSel(); 596 delete KOAgendaItem::paintPixSel();
676} 597}
677void KOAgendaView::resizeEvent( QResizeEvent* e ) 598void KOAgendaView::resizeEvent( QResizeEvent* e )
678{ 599{
679 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 600 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
680 bool uc = false; 601 bool uc = false;
681 int ow = e->oldSize().width(); 602 int ow = e->oldSize().width();
682 int oh = e->oldSize().height(); 603 int oh = e->oldSize().height();
683 int w = e->size().width(); 604 int w = e->size().width();
684 int h = e->size().height(); 605 int h = e->size().height();
685 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 606 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
686 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 607 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
687 uc = true; 608 uc = true;
688 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 609 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
689 } 610 }
690 mUpcomingWidth = e->size().width() ; 611 mUpcomingWidth = e->size().width() ;
691 if ( mBlockUpdating || uc ) { 612 if ( mBlockUpdating || uc ) {
692 mBlockUpdating = false; 613 mBlockUpdating = false;
693 //mAgenda->setMinimumSize(800 , 600 ); 614 //mAgenda->setMinimumSize(800 , 600 );
694 //qDebug("mAgenda->resize+++++++++++++++ "); 615 //qDebug("mAgenda->resize+++++++++++++++ ");
695 updateConfig(); 616 updateConfig();
696 //qDebug("KOAgendaView::Updating now possible "); 617 //qDebug("KOAgendaView::Updating now possible ");
697 } else 618 } else
698 createDayLabels(); 619 createDayLabels();
699 //qDebug("resizeEvent end "); 620 //qDebug("resizeEvent end ");
700 621
701} 622}
702void KOAgendaView::slotDaylabelClicked( int num ) 623void KOAgendaView::slotDaylabelClicked( int num )
703{ 624{
704 625
705 QDate firstDate = mSelectedDates.first(); 626 QDate firstDate = mSelectedDates.first();
706 if ( num == -1 ) 627 if ( num == -1 )
707 emit showDateView( 6, firstDate ); 628 emit showDateView( 6, firstDate );
708 else if (num >= 0 ) { 629 else if (num >= 0 ) {
709 if ( mSelectedDates.count() == 1) 630 if ( mSelectedDates.count() == 1)
710 emit showDateView( 9, firstDate.addDays( num ) ); 631 emit showDateView( 9, firstDate.addDays( num ) );
711 else 632 else
712 emit showDateView( 3, firstDate.addDays( num ) ); 633 emit showDateView( 3, firstDate.addDays( num ) );
713 } 634 }
714 else 635 else
715 showDateView( 10, firstDate.addDays(1) ); 636 showDateView( 10, firstDate.addDays(1) );
716} 637}
717 638
718KOAgendaButton* KOAgendaView::getNewDaylabel() 639KOAgendaButton* KOAgendaView::getNewDaylabel()
719{ 640{
720 641
721 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 642 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
722 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 643 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
723 mDayLabelsList.append( dayLabel ); 644 mDayLabelsList.append( dayLabel );
724 mLayoutDayLabels->addWidget(dayLabel); 645 mLayoutDayLabels->addWidget(dayLabel);
725 return dayLabel ; 646 return dayLabel ;
726} 647}
727 648
728void KOAgendaView::createDayLabels() 649void KOAgendaView::createDayLabels()
729{ 650{
730 651
731 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 652 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
732 // qDebug(" KOAgendaView::createDayLabels() blocked "); 653 // qDebug(" KOAgendaView::createDayLabels() blocked ");
733 return; 654 return;
734 655
735 } 656 }
736 int newHight; 657 int newHight;
658 if ( !mSelectedDates.count())
659 return;
737 660
738 // ### Before deleting and recreating we could check if mSelectedDates changed... 661 // ### Before deleting and recreating we could check if mSelectedDates changed...
739 // It would remove some flickering and gain speed (since this is called by 662 // It would remove some flickering and gain speed (since this is called by
740 // each updateView() call) 663 // each updateView() call)
741 664
742 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 665 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
743 if ( QApplication::desktop()->width() <= 320 )
744 maxWid -= 10;
745 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 666 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
746 if ( maxWid < 0 ) 667 if ( maxWid < 20 )
747 maxWid = 20; 668 maxWid = 20;
748 669
749 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 670 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
750 QFontMetrics fm ( dlf ); 671 QFontMetrics fm ( dlf );
751 int selCount = mSelectedDates.count(); 672 int selCount = mSelectedDates.count();
673 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
752 QString dayTest = "Mon 20"; 674 QString dayTest = "Mon 20";
753 //QString dayTest = "Mon 20"; 675 //QString dayTest = "Mon 20";
754 int wid = fm.width( dayTest ); 676 int wid = fm.width( dayTest );
755 //maxWid -= ( selCount * 3 ); //working for QLabels 677 //maxWid -= ( selCount * 3 ); //working for QLabels
756 maxWid -= ( selCount * 3 ); //working for QPushButton 678 if ( QApplication::desktop()->width() <= 320 )
679 maxWid -= ( selCount * 3 ); //working for QPushButton
680 else
681 maxWid -= ( selCount * 3 ); //working for QPushButton
757 if ( maxWid < 0 ) 682 if ( maxWid < 0 )
758 maxWid = 20; 683 maxWid = 20;
759 int needWid = wid * selCount; 684 int needWid = wid * selCount;
760 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 685 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
761 //if ( needWid > maxWid ) 686 //if ( needWid > maxWid )
762 // qDebug("DAYLABELS TOOOOOOO BIG "); 687 // qDebug("DAYLABELS TOOOOOOO BIG ");
763 while ( needWid > maxWid ) { 688 while ( needWid > maxWid ) {
764 dayTest = dayTest.left( dayTest.length() - 1 ); 689 dayTest = dayTest.left( dayTest.length() - 1 );
765 wid = fm.width( dayTest ); 690 wid = fm.width( dayTest );
766 needWid = wid * selCount; 691 needWid = wid * selCount;
767 } 692 }
768 int maxLen = dayTest.length(); 693 int maxLen = dayTest.length();
769 int fontPoint = dlf.pointSize(); 694 int fontPoint = dlf.pointSize();
770 if ( maxLen < 2 ) { 695 if ( maxLen < 2 ) {
771 int fontPoint = dlf.pointSize(); 696 int fontPoint = dlf.pointSize();
772 while ( fontPoint > 4 ) { 697 while ( fontPoint > 4 ) {
773 --fontPoint; 698 --fontPoint;
774 dlf.setPointSize( fontPoint ); 699 dlf.setPointSize( fontPoint );
775 QFontMetrics f( dlf ); 700 QFontMetrics f( dlf );
776 wid = f.width( "30" ); 701 wid = f.width( "30" );
777 needWid = wid * selCount; 702 needWid = wid * selCount;
778 if ( needWid < maxWid ) 703 if ( needWid < maxWid )
779 break; 704 break;
780 } 705 }
781 maxLen = 2; 706 maxLen = 2;
782 } 707 }
783 //qDebug("Max len %d ", dayTest.length() ); 708 //qDebug("Max len %d ", dayTest.length() );
784 709
785 QFontMetrics tempF( dlf ); 710 QFontMetrics tempF( dlf );
786 newHight = tempF.height(); 711 newHight = tempF.height();
787 mDayLabels->setFont( dlf ); 712 mDayLabels->setFont( dlf );
788 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 713 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
789 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 714 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
790 //mLayoutDayLabels->addSpacing( 2 ); 715 //mLayoutDayLabels->addSpacing( 2 );
791 // QFont lFont = dlf; 716 // QFont lFont = dlf;
792 bool appendLabels = false; 717 bool appendLabels = false;
793 KOAgendaButton *dayLabel; 718 KOAgendaButton *dayLabel;
794 dayLabel = mDayLabelsList.first(); 719 dayLabel = mDayLabelsList.first();
795 if ( !dayLabel ) { 720 if ( !dayLabel ) {
796 appendLabels = true; 721 appendLabels = true;
797 dayLabel = getNewDaylabel(); 722 dayLabel = getNewDaylabel();
798 } 723 }
799 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 724 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
800 dayLabel->setFont( dlf ); 725 dayLabel->setFont( dlf );
801 dayLabel->setNum( -1 ); 726 dayLabel->setNum( -1 );
802 //dayLabel->setAlignment(QLabel::AlignHCenter); 727 //dayLabel->setAlignment(QLabel::AlignHCenter);
803#if 0 728#if 0
804 if ( QApplication::desktop()->width() <= 320 ) 729 if ( QApplication::desktop()->width() <= 320 )
805 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); 730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
806 else 731 else
807#endif 732#endif
808 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 733 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
809 dayLabel->show(); 734 dayLabel->show();
810 DateList::ConstIterator dit; 735 DateList::ConstIterator dit;
811 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 736 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
812 int counter = -1; 737 int counter = -1;
813 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 738 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
814 ++counter; 739 ++counter;
815 QDate date = *dit; 740 QDate date = *dit;
816 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 741 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
817 if ( ! appendLabels ) { 742 if ( ! appendLabels ) {
818 dayLabel = mDayLabelsList.next(); 743 dayLabel = mDayLabelsList.next();
819 if ( !dayLabel ) 744 if ( !dayLabel )
820 appendLabels = true; 745 appendLabels = true;
821 } 746 }
822 if ( appendLabels ) { 747 if ( appendLabels ) {
823 dayLabel = getNewDaylabel(); 748 dayLabel = getNewDaylabel();
824 } 749 }
825 dayLabel->setMinimumWidth( 1 ); 750 dayLabel->setMinimumWidth( 1 );
826 dayLabel->setMaximumWidth( 10240 ); 751 dayLabel->setMaximumWidth( 10240 );
827 dayLabel->setFont( dlf ); 752 dayLabel->setFont( dlf );
828 dayLabel->show(); 753 dayLabel->show();
829 dayLabel->setAutoRepeat( false ); 754 dayLabel->setAutoRepeat( false );
830 dayLabel->setNum( counter ); 755 dayLabel->setNum( counter );
831 QString str; 756 QString str;
832 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 757 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
833 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 758 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
834 switch ( maxLen ) { 759 switch ( maxLen ) {
835 case 2: 760 case 2:
836 str = QString::number( date.day() ); 761 str = QString::number( date.day() );
837 break; 762 break;
838 763
839 case 3: 764 case 3:
840 str = dayName.left( 1 ) +QString::number( date.day()); 765 str = dayName.left( 1 ) +QString::number( date.day());
841 766
842 break; 767 break;
843 case 4: 768 case 4:
844 str = dayName.left( 1 ) + " " +QString::number( date.day()); 769 str = dayName.left( 1 ) + " " +QString::number( date.day());
845 770
846 break; 771 break;
847 case 5: 772 case 5:
848 str = dayName.left( 2 ) + " " +QString::number( date.day()); 773 str = dayName.left( 2 ) + " " +QString::number( date.day());
849 774
850 break; 775 break;
851 case 6: 776 case 6:
852 str = dayName.left( 3 ) + " " +QString::number( date.day()); 777 str = dayName.left( 3 ) + " " +QString::number( date.day());
853 break; 778 break;
854 779
855 default: 780 default:
856 break; 781 break;
857 } 782 }
858 if ( oneday ) { 783 if ( oneday ) {
859 QString addString; 784 QString addString;
860 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 785 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
861 addString = i18n("Today"); 786 addString = i18n("Today");
862 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 787 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
863 addString = i18n("Tomorrow"); 788 addString = i18n("Tomorrow");
864 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 789 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
865 addString = i18n("Yesterday"); 790 addString = i18n("Yesterday");
866 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 791 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
867 addString = i18n("Day before yesterday"); 792 addString = i18n("Day before yesterday");
868 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 793 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
869 addString = i18n("Day after tomorrow"); 794 addString = i18n("Day after tomorrow");
870 if ( !addString.isEmpty() ) { 795 if ( !addString.isEmpty() ) {
871 str = addString+", " + str; 796 str = addString+", " + str;
872 } else { 797 } else {
873 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 798 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
874 } 799 }
875 } 800 }
876 dayLabel->setText(str); 801 dayLabel->setText(str);
877 //dayLabel->setAlignment(QLabel::AlignHCenter); 802 //dayLabel->setAlignment(QLabel::AlignHCenter);
878 if (date == QDate::currentDate()) { 803 if (date == QDate::currentDate()) {
879 QFont bFont = dlf; 804 QFont bFont = dlf;
880 bFont.setBold( true ); 805 bFont.setBold( true );
881 dayLabel->setFont(bFont); 806 dayLabel->setFont(bFont);
882 } 807 }
883 //dayLayout->addWidget(dayLabel); 808 //dayLayout->addWidget(dayLabel);
884 809
885#ifndef KORG_NOPLUGINS 810#ifndef KORG_NOPLUGINS
886 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 811 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
887 CalendarDecoration *it; 812 CalendarDecoration *it;
888 for(it = cds.first(); it; it = cds.next()) { 813 for(it = cds.first(); it; it = cds.next()) {
889 QString text = it->shortText( date ); 814 QString text = it->shortText( date );
890 if ( !text.isEmpty() ) { 815 if ( !text.isEmpty() ) {
891 QLabel *label = new QLabel(text,mDayLabels); 816 QLabel *label = new QLabel(text,mDayLabels);
892 label->setAlignment(AlignCenter); 817 label->setAlignment(AlignCenter);
893 dayLayout->addWidget(label); 818 dayLayout->addWidget(label);
894 } 819 }
895 } 820 }
896 821
897 for(it = cds.first(); it; it = cds.next()) { 822 for(it = cds.first(); it; it = cds.next()) {
898 QWidget *wid = it->smallWidget(mDayLabels,date); 823 QWidget *wid = it->smallWidget(mDayLabels,date);
899 if ( wid ) { 824 if ( wid ) {
900 // wid->setHeight(20); 825 // wid->setHeight(20);
901 dayLayout->addWidget(wid); 826 dayLayout->addWidget(wid);
902 } 827 }
903 } 828 }
904#endif 829#endif
905 } 830 }
906 if ( ! appendLabels ) { 831 if ( ! appendLabels ) {
907 dayLabel = mDayLabelsList.next(); 832 dayLabel = mDayLabelsList.next();
908 if ( !dayLabel ) 833 if ( !dayLabel )
909 appendLabels = true; 834 appendLabels = true;
910 } 835 }
911 if ( appendLabels ) { 836 if ( appendLabels ) {
912 dayLabel = getNewDaylabel(); 837 dayLabel = getNewDaylabel();
913 } 838 }
914 //dayLabel->hide();//test only 839 //dayLabel->hide();//test only
915 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()- (mAgenda->frameWidth()*2) ) % mSelectedDates.count() ; 840
916 if ( offset < 0 ) offset = 0; 841 dayLabel->setText(">");
917 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
918 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
919 dayLabel->setFont( dlf ); 842 dayLabel->setFont( dlf );
920 dayLabel->setAutoRepeat( true ); 843 dayLabel->setAutoRepeat( true );
921 dayLabel->show(); 844 dayLabel->show();
922 dayLabel->setNum( -2 ); 845 dayLabel->setNum( -2 );
923 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 846 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
924 847
925 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
926 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 848 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
927 if ( !appendLabels ) { 849 if ( !appendLabels ) {
928 dayLabel = mDayLabelsList.next(); 850 dayLabel = mDayLabelsList.next();
929 while ( dayLabel ) { 851 while ( dayLabel ) {
930 //qDebug("!dayLabel %d",dayLabel ); 852 //qDebug("!dayLabel %d",dayLabel );
931 dayLabel->hide(); 853 dayLabel->hide();
932 dayLabel = mDayLabelsList.next(); 854 dayLabel = mDayLabelsList.next();
933 } 855 }
934 } 856 }
935 857
936 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 858 mDayLabelsFrame->setFixedHeight( newHight + 4 );
937} 859}
938 860
939int KOAgendaView::maxDatesHint() 861int KOAgendaView::maxDatesHint()
940{ 862{
941 // Not sure about the max number of events, so return 0 for now. 863 // Not sure about the max number of events, so return 0 for now.
942 return 0; 864 return 0;
943} 865}
944 866
945int KOAgendaView::currentDateCount() 867int KOAgendaView::currentDateCount()
946{ 868{
947 return mSelectedDates.count(); 869 return mSelectedDates.count();
948} 870}
949 871
950QPtrList<Incidence> KOAgendaView::selectedIncidences() 872QPtrList<Incidence> KOAgendaView::selectedIncidences()
951{ 873{
952 QPtrList<Incidence> selected; 874 QPtrList<Incidence> selected;
953 Incidence *incidence; 875 Incidence *incidence;
954 876
955 incidence = mAgenda->selectedIncidence(); 877 incidence = mAgenda->selectedIncidence();
956 if (incidence) selected.append(incidence); 878 if (incidence) selected.append(incidence);
957 879
958 incidence = mAllDayAgenda->selectedIncidence(); 880 incidence = mAllDayAgenda->selectedIncidence();
959 if (incidence) selected.append(incidence); 881 if (incidence) selected.append(incidence);
960 882
961 return selected; 883 return selected;
962} 884}
963 885
964DateList KOAgendaView::selectedDates() 886DateList KOAgendaView::selectedDates()
965{ 887{
966 DateList selected; 888 DateList selected;
967 QDate qd; 889 QDate qd;
968 890
969 qd = mAgenda->selectedIncidenceDate(); 891 qd = mAgenda->selectedIncidenceDate();
970 if (qd.isValid()) selected.append(qd); 892 if (qd.isValid()) selected.append(qd);
971 893
972 qd = mAllDayAgenda->selectedIncidenceDate(); 894 qd = mAllDayAgenda->selectedIncidenceDate();
973 if (qd.isValid()) selected.append(qd); 895 if (qd.isValid()) selected.append(qd);
974 896
975 return selected; 897 return selected;
976} 898}
977 899
978 900
979void KOAgendaView::updateView() 901void KOAgendaView::updateView()
980{ 902{
981 if ( mBlockUpdating ) 903 if ( mBlockUpdating )
982 return; 904 return;
983 // kdDebug() << "KOAgendaView::updateView()" << endl; 905 // kdDebug() << "KOAgendaView::updateView()" << endl;
984 fillAgenda(); 906 fillAgenda();
985 907
986} 908}
987 909
988 910
989/* 911/*
990 Update configuration settings for the agenda view. This method is not 912 Update configuration settings for the agenda view. This method is not
991 complete. 913 complete.
992*/ 914*/
993void KOAgendaView::updateConfig() 915void KOAgendaView::updateConfig()
994{ 916{
995 if ( mBlockUpdating ) 917 if ( mBlockUpdating )
996 return; 918 return;
997 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 919 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
998 int old = KOPrefs::instance()->mHourSize; 920 int old = KOPrefs::instance()->mHourSize;
999 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 921 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
1000 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 922 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
1001 } 923 }
1002 924
1003 925
1004 // update config for children 926 // update config for children
1005 mTimeLabels->updateConfig(); 927 mTimeLabels->updateConfig();
1006 mAgenda->storePosition(); 928 mAgenda->storePosition();
1007 mAgenda->updateConfig(); 929 mAgenda->updateConfig();
1008 mAllDayAgenda->updateConfig(); 930 mAllDayAgenda->updateConfig();
1009 // widget synchronization 931 // widget synchronization
1010 //TODO: find a better way, maybe signal/slot 932 //TODO: find a better way, maybe signal/slot
1011 mTimeLabels->positionChanged(); 933 mTimeLabels->positionChanged();
1012 934
1013 // for some reason, this needs to be called explicitly 935 // for some reason, this needs to be called explicitly
1014 mTimeLabels->repaint(); 936 mTimeLabels->repaint();
1015 937
1016 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 938 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
1017 939
1018 // ToolTips displaying summary of events 940 // ToolTips displaying summary of events
1019 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 941 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
1020 ->mEnableToolTips); 942 ->mEnableToolTips);
1021 943
1022 //setHolidayMasks(); 944 //setHolidayMasks();
1023 945
1024 //createDayLabels(); called by via updateView(); 946 //createDayLabels(); called by via updateView();
1025 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 947 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
1026 updateView(); 948 updateView();
1027 mAgenda->restorePosition(); 949 mAgenda->restorePosition();
1028} 950}
1029 951
1030 952
1031void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 953void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
1032{ 954{
1033 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 955 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
1034 //qDebug("KOAgendaView::updateEventDates "); 956 //qDebug("KOAgendaView::updateEventDates ");
1035 QDateTime startDt,endDt; 957 QDateTime startDt,endDt;
1036 QDate startDate; 958 QDate startDate;
1037 int lenInSecs; 959 int lenInSecs;
1038 // if ( type == KOAgenda::RESIZETOP ) 960 // if ( type == KOAgenda::RESIZETOP )
1039 // qDebug("RESIZETOP "); 961 // qDebug("RESIZETOP ");
1040 // if ( type == KOAgenda::RESIZEBOTTOM ) 962 // if ( type == KOAgenda::RESIZEBOTTOM )
1041 // qDebug("RESIZEBOTTOM "); 963 // qDebug("RESIZEBOTTOM ");
1042 // if ( type == KOAgenda::MOVE ) 964 // if ( type == KOAgenda::MOVE )
1043 // qDebug("MOVE "); 965 // qDebug("MOVE ");
1044 if ( item->incidence()->type() == "Event" ) { 966 if ( item->incidence()->type() == "Event" ) {
1045 startDt =item->incidence()->dtStart(); 967 startDt =item->incidence()->dtStart();
1046 endDt = item->incidence()->dtEnd(); 968 endDt = item->incidence()->dtEnd();
1047 lenInSecs = startDt.secsTo( endDt ); 969 lenInSecs = startDt.secsTo( endDt );
1048 } 970 }
1049 971
1050 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 972 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
1051 973
1052 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 974 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
1053 startDate = mSelectedDates[item->mLastMoveXPos]; 975 startDate = mSelectedDates[item->mLastMoveXPos];
1054 } else { 976 } else {
1055 if (item->cellX() < 0) { 977 if (item->cellX() < 0) {
1056 startDate = (mSelectedDates.first()).addDays(item->cellX()); 978 startDate = (mSelectedDates.first()).addDays(item->cellX());
1057 } else { 979 } else {
1058 startDate = mSelectedDates[item->cellX()]; 980 startDate = mSelectedDates[item->cellX()];
1059 } 981 }
1060 } 982 }
1061 startDt.setDate(startDate); 983 startDt.setDate(startDate);
1062 984
1063 if (item->incidence()->doesFloat()) { 985 if (item->incidence()->doesFloat()) {
1064 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 986 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
1065 } else { 987 } else {
1066 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 988 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
1067 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 989 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
1068 if ( item->incidence()->type() == "Event" ) { 990 if ( item->incidence()->type() == "Event" ) {
1069 if ( type == KOAgenda::MOVE ) { 991 if ( type == KOAgenda::MOVE ) {
1070 endDt = startDt.addSecs(lenInSecs); 992 endDt = startDt.addSecs(lenInSecs);
1071 993
1072 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 994 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1073 if (item->lastMultiItem()) { 995 if (item->lastMultiItem()) {
1074 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 996 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1075 endDt.setDate(startDate. 997 endDt.setDate(startDate.
1076 addDays(item->lastMultiItem()->cellX() - item->cellX())); 998 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1077 } else { 999 } else {
1078 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1000 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1079 endDt.setDate(startDate); 1001 endDt.setDate(startDate);
1080 } 1002 }
1081 } 1003 }
1082 } else { 1004 } else {
1083 // todo 1005 // todo
1084 if (item->lastMultiItem()) { 1006 if (item->lastMultiItem()) {
1085 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1007 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1086 endDt.setDate(startDate. 1008 endDt.setDate(startDate.
1087 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1009 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1088 } else { 1010 } else {
1089 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1011 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1090 if ( item->cellYBottom() > 0 ) 1012 if ( item->cellYBottom() > 0 )
1091 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1013 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1092 else 1014 else
1093 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1015 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1094 endDt.setDate(startDate); 1016 endDt.setDate(startDate);
1095 } 1017 }
1096 } 1018 }
1097 } 1019 }
1098 if ( item->incidence()->type() == "Event" ) { 1020 if ( item->incidence()->type() == "Event" ) {
1099 item->incidence()->setDtStart(startDt); 1021 item->incidence()->setDtStart(startDt);
1100 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1022 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1101 } else if ( item->incidence()->type() == "Todo" ) { 1023 } else if ( item->incidence()->type() == "Todo" ) {
1102 Todo* to = static_cast<Todo*>(item->incidence()); 1024 Todo* to = static_cast<Todo*>(item->incidence());
1103 1025
1104 to->setDtDue(endDt); 1026 to->setDtDue(endDt);
1105 if ( to->hasStartDate() ) { 1027 if ( to->hasStartDate() ) {
1106 if (to->dtStart() >= to->dtDue() ) 1028 if (to->dtStart() >= to->dtDue() )
1107 to->setDtStart(to->dtDue().addDays( -2 )); 1029 to->setDtStart(to->dtDue().addDays( -2 ));
1108 } 1030 }
1109 1031
1110 } 1032 }
1111 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1033 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1112 item->incidence()->setRevision(item->incidence()->revision()+1); 1034 item->incidence()->setRevision(item->incidence()->revision()+1);
1113 item->setItemDate(startDt.date()); 1035 item->setItemDate(startDt.date());
1114 //item->updateItem(); 1036 //item->updateItem();
1115 if ( item->incidence()->type() == "Todo" ) { 1037 if ( item->incidence()->type() == "Todo" ) {
1116 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1038 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1117 1039