summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-26 23:12:59 (UTC)
committer zautrix <zautrix>2005-01-26 23:12:59 (UTC)
commitf20b5e71f9ae61b18f0ced792508b40432ad50b6 (patch) (unidiff)
tree3dde48c6dcecf2e5c19d3e7a62aba57c385e92df /korganizer
parent15351333eff09beadb6e691e9f0aab2aaf0a95a0 (diff)
downloadkdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.zip
kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.tar.gz
kdepimpi-f20b5e71f9ae61b18f0ced792508b40432ad50b6.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/koagendaview.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b5596d9..05216a7 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1509 +1,1511 @@
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
79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
80 QScrollView(parent,name,f) 80 QScrollView(parent,name,f)
81{ 81{
82 mRows = rows; 82 mRows = rows;
83 83
84 setMinimumHeight( 20 ); 84 setMinimumHeight( 20 );
85 mCellHeight = KOPrefs::instance()->mHourSize*4; 85 mCellHeight = KOPrefs::instance()->mHourSize*4;
86 86
87 enableClipper(true); 87 enableClipper(true);
88 88
89 setHScrollBarMode(AlwaysOff); 89 setHScrollBarMode(AlwaysOff);
90 setVScrollBarMode(AlwaysOff); 90 setVScrollBarMode(AlwaysOff);
91 91
92 resizeContents(50,mRows * mCellHeight); 92 resizeContents(50,mRows * mCellHeight);
93 93
94 viewport()->setBackgroundMode( PaletteBackground ); 94 viewport()->setBackgroundMode( PaletteBackground );
95} 95}
96 96
97void TimeLabels::setCellHeight(int height) 97void TimeLabels::setCellHeight(int height)
98{ 98{
99 mCellHeight = height; 99 mCellHeight = height;
100} 100}
101 101
102/* 102/*
103 Optimization so that only the "dirty" portion of the scroll view 103 Optimization so that only the "dirty" portion of the scroll view
104 is redrawn. Unfortunately, this is not called by default paintEvent() method. 104 is redrawn. Unfortunately, this is not called by default paintEvent() method.
105*/ 105*/
106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
107{ 107{
108 108
109 // if ( globalFlagBlockAgenda ) 109 // if ( globalFlagBlockAgenda )
110 // return; 110 // return;
111 // bug: the parameters cx, cy, cw, ch are the areas that need to be 111 // bug: the parameters cx, cy, cw, ch are the areas that need to be
112 // redrawn, not the area of the widget. unfortunately, this 112 // redrawn, not the area of the widget. unfortunately, this
113 // code assumes the latter... 113 // code assumes the latter...
114 114
115 // now, for a workaround... 115 // now, for a workaround...
116 // these two assignments fix the weird redraw bug 116 // these two assignments fix the weird redraw bug
117 cx = contentsX() + 2; 117 cx = contentsX() + 2;
118 cw = contentsWidth() - 2; 118 cw = contentsWidth() - 2;
119 // end of workaround 119 // end of workaround
120 120
121 int cell = ((int)(cy/mCellHeight)); 121 int cell = ((int)(cy/mCellHeight));
122 int y = cell * mCellHeight; 122 int y = cell * mCellHeight;
123 QFontMetrics fm = fontMetrics(); 123 QFontMetrics fm = fontMetrics();
124 QString hour; 124 QString hour;
125 QString suffix; 125 QString suffix;
126 QString fullTime; 126 QString fullTime;
127 int tW = fm.width("24:00i"); 127 int tW = fm.width("24:00i");
128 128
129 while (y < cy + ch) { 129 while (y < cy + ch) {
130 p->drawLine(cx,y,cx+tW,y); 130 p->drawLine(cx,y,cx+tW,y);
131 hour.setNum(cell); 131 hour.setNum(cell);
132 suffix = "am"; 132 suffix = "am";
133 133
134 // handle 24h and am/pm time formats 134 // handle 24h and am/pm time formats
135 if (KGlobal::locale()->use12Clock()) { 135 if (KGlobal::locale()->use12Clock()) {
136 if (cell > 11) suffix = "pm"; 136 if (cell > 11) suffix = "pm";
137 if (cell == 0) hour.setNum(12); 137 if (cell == 0) hour.setNum(12);
138 if (cell > 12) hour.setNum(cell - 12); 138 if (cell > 12) hour.setNum(cell - 12);
139 } else { 139 } else {
140 suffix = ":00"; 140 suffix = ":00";
141 } 141 }
142 142
143 // create string in format of "XX:XX" or "XXpm/am" 143 // create string in format of "XX:XX" or "XXpm/am"
144 fullTime = hour + suffix; 144 fullTime = hour + suffix;
145 145
146 // center and draw the time label 146 // center and draw the time label
147 int timeWidth = fm.width(fullTime+"i"); 147 int timeWidth = fm.width(fullTime+"i");
148 int offset = this->width() - timeWidth; 148 int offset = this->width() - timeWidth;
149 int borderWidth = 5; 149 int borderWidth = 5;
150 int timeHeight = fm.height(); 150 int timeHeight = fm.height();
151 timeHeight = timeHeight + 2 - ( timeHeight / 4 ); 151 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); 152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
153 153
154 // increment indices 154 // increment indices
155 y += mCellHeight; 155 y += mCellHeight;
156 cell++; 156 cell++;
157 } 157 }
158} 158}
159 159
160/** 160/**
161 Calculates the minimum width. 161 Calculates the minimum width.
162*/ 162*/
163int TimeLabels::minimumWidth() const 163int TimeLabels::minimumWidth() const
164{ 164{
165 QFontMetrics fm = fontMetrics(); 165 QFontMetrics fm = fontMetrics();
166 166
167 //TODO: calculate this value 167 //TODO: calculate this value
168 int borderWidth = 4; 168 int borderWidth = 4;
169 169
170 // the maximum width possible 170 // the maximum width possible
171 int width = fm.width("88:88x") + borderWidth; 171 int width = fm.width("88:88x") + borderWidth;
172 172
173 return width; 173 return width;
174} 174}
175 175
176/** updates widget's internal state */ 176/** updates widget's internal state */
177void TimeLabels::updateConfig() 177void TimeLabels::updateConfig()
178{ 178{
179 // set the font 179 // set the font
180 // config->setGroup("Fonts"); 180 // config->setGroup("Fonts");
181 // QFont font = config->readFontEntry("TimeBar Font"); 181 // QFont font = config->readFontEntry("TimeBar Font");
182 setFont(KOPrefs::instance()->mTimeBarFont); 182 setFont(KOPrefs::instance()->mTimeBarFont);
183 183
184 // update geometry restrictions based on new settings 184 // update geometry restrictions based on new settings
185 setFixedWidth(minimumWidth()); 185 setFixedWidth(minimumWidth());
186 186
187 // update HourSize 187 // update HourSize
188 mCellHeight = KOPrefs::instance()->mHourSize*4; 188 mCellHeight = KOPrefs::instance()->mHourSize*4;
189 resizeContents(50,mRows * mCellHeight); 189 resizeContents(50,mRows * mCellHeight);
190} 190}
191 191
192/** update time label positions */ 192/** update time label positions */
193void TimeLabels::positionChanged() 193void TimeLabels::positionChanged()
194{ 194{
195 int adjustment = mAgenda->contentsY(); 195 int adjustment = mAgenda->contentsY();
196 setContentsPos(0, adjustment); 196 setContentsPos(0, adjustment);
197} 197}
198 198
199/** */ 199/** */
200void TimeLabels::setAgenda(KOAgenda* agenda) 200void TimeLabels::setAgenda(KOAgenda* agenda)
201{ 201{
202 mAgenda = agenda; 202 mAgenda = agenda;
203} 203}
204 204
205void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 205void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
206{ 206{
207 mMouseDownY = e->pos().y(); 207 mMouseDownY = e->pos().y();
208 mOrgCap = topLevelWidget()->caption();
208} 209}
209 210
210void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 211void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
211{ 212{
212 int diff = mMouseDownY - e->pos().y(); 213 int diff = mMouseDownY - e->pos().y();
213 if ( diff < 10 && diff > -10 ) 214 if ( diff < 10 && diff > -10 )
214 return; 215 return;
215 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 216 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
216 if ( tSize < 4 ) 217 if ( tSize < 4 )
217 tSize = 4; 218 tSize = 4;
218 if ( tSize > 18 ) 219 if ( tSize > 18 )
219 tSize = 18; 220 tSize = 18;
220 tSize = (tSize-2)/2; 221 tSize = (tSize-2)/2;
221 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 222 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
222 223
223} 224}
224void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 225void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
225{ 226{
227 topLevelWidget()->setCaption( mOrgCap );
226 int diff = mMouseDownY - e->pos().y(); 228 int diff = mMouseDownY - e->pos().y();
227 if ( diff < 10 && diff > -10 ) 229 if ( diff < 10 && diff > -10 )
228 return; 230 return;
229 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 231 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
230 if ( tSize < 4 ) 232 if ( tSize < 4 )
231 tSize = 4; 233 tSize = 4;
232 if ( tSize > 18 ) 234 if ( tSize > 18 )
233 tSize = 18; 235 tSize = 18;
234 tSize = (tSize/2)*2; 236 tSize = (tSize/2)*2;
235 if ( tSize == KOPrefs::instance()->mHourSize ) 237 if ( tSize == KOPrefs::instance()->mHourSize )
236 return; 238 return;
237 KOPrefs::instance()->mHourSize = tSize; 239 KOPrefs::instance()->mHourSize = tSize;
238 emit scaleChanged(); 240 emit scaleChanged();
239} 241}
240 242
241/** This is called in response to repaint() */ 243/** This is called in response to repaint() */
242void TimeLabels::paintEvent(QPaintEvent*) 244void TimeLabels::paintEvent(QPaintEvent*)
243{ 245{
244 246
245 // kdDebug() << "paintevent..." << endl; 247 // kdDebug() << "paintevent..." << endl;
246 // this is another hack! 248 // this is another hack!
247 // QPainter painter(this); 249 // QPainter painter(this);
248 //QString c 250 //QString c
249 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 251 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
250} 252}
251 253
252//////////////////////////////////////////////////////////////////////////// 254////////////////////////////////////////////////////////////////////////////
253 255
254EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 256EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
255 : QFrame(parent,name) 257 : QFrame(parent,name)
256{ 258{
257 mColumns = 1; 259 mColumns = 1;
258 mTopBox = 0; 260 mTopBox = 0;
259 mLocation = loc; 261 mLocation = loc;
260 mTopLayout = 0; 262 mTopLayout = 0;
261 mPaintWidget = 0; 263 mPaintWidget = 0;
262 mXOffset = 0; 264 mXOffset = 0;
263 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 265 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
264 else mPixmap = SmallIcon("1downarrow"); 266 else mPixmap = SmallIcon("1downarrow");
265 mEnabled.resize(mColumns); 267 mEnabled.resize(mColumns);
266 if (mLocation == Top) 268 if (mLocation == Top)
267 setMaximumHeight(0); 269 setMaximumHeight(0);
268 else 270 else
269 setMinimumHeight(mPixmap.height()); 271 setMinimumHeight(mPixmap.height());
270} 272}
271 273
272EventIndicator::~EventIndicator() 274EventIndicator::~EventIndicator()
273{ 275{
274} 276}
275 277
276void EventIndicator::drawContents(QPainter *p) 278void EventIndicator::drawContents(QPainter *p)
277{ 279{
278 280
279 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 281 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
280 KDGanttSplitterHandle* han = 0; 282 KDGanttSplitterHandle* han = 0;
281 if ( mPaintWidget ) 283 if ( mPaintWidget )
282 han = mPaintWidget->firstHandle(); 284 han = mPaintWidget->firstHandle();
283 if ( ! han ) { 285 if ( ! han ) {
284 int i; 286 int i;
285 for(i=0;i<mColumns;++i) { 287 for(i=0;i<mColumns;++i) {
286 if (mEnabled[i]) { 288 if (mEnabled[i]) {
287 int cellWidth = contentsRect().right()/mColumns; 289 int cellWidth = contentsRect().right()/mColumns;
288 int xOffset = KOGlobals::self()->reverseLayout() ? 290 int xOffset = KOGlobals::self()->reverseLayout() ?
289 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 291 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
290 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 292 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
291 p->drawPixmap(QPoint(xOffset,0),mPixmap); 293 p->drawPixmap(QPoint(xOffset,0),mPixmap);
292 } 294 }
293 } 295 }
294 } else { 296 } else {
295 han->repaint(); 297 han->repaint();
296 //mPaintWidget->setBackgroundColor( red ); 298 //mPaintWidget->setBackgroundColor( red );
297 299
298 QPainter pa( han ); 300 QPainter pa( han );
299 int i; 301 int i;
300 bool setColor = false; 302 bool setColor = false;
301 for(i=0;i<mColumns;++i) { 303 for(i=0;i<mColumns;++i) {
302 if (mEnabled[i]) { 304 if (mEnabled[i]) {
303 setColor = true; 305 setColor = true;
304 306
305 int cellWidth = contentsRect().right()/mColumns; 307 int cellWidth = contentsRect().right()/mColumns;
306 int xOffset = KOGlobals::self()->reverseLayout() ? 308 int xOffset = KOGlobals::self()->reverseLayout() ?
307 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
308 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 310 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
309 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
310 //qDebug("222draw pix %d ",xOffset ); 312 //qDebug("222draw pix %d ",xOffset );
311 313
312 } 314 }
313 315
314 } 316 }
315 pa.end(); 317 pa.end();
316 318
317 } 319 }
318} 320}
319 321
320void EventIndicator::setXOffset( int x ) 322void EventIndicator::setXOffset( int x )
321{ 323{
322 mXOffset = x; 324 mXOffset = x;
323} 325}
324void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
325{ 327{
326 mPaintWidget = w; 328 mPaintWidget = w;
327} 329}
328void EventIndicator::changeColumns(int columns) 330void EventIndicator::changeColumns(int columns)
329{ 331{
330 mColumns = columns; 332 mColumns = columns;
331 mEnabled.resize(mColumns); 333 mEnabled.resize(mColumns);
332 334
333 update(); 335 update();
334} 336}
335 337
336void EventIndicator::enableColumn(int column, bool enable) 338void EventIndicator::enableColumn(int column, bool enable)
337{ 339{
338 mEnabled[column] = enable; 340 mEnabled[column] = enable;
339} 341}
340 342
341 343
342//////////////////////////////////////////////////////////////////////////// 344////////////////////////////////////////////////////////////////////////////
343//////////////////////////////////////////////////////////////////////////// 345////////////////////////////////////////////////////////////////////////////
344//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
345 347
346KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 348KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
347 KOEventView (cal,parent,name) 349 KOEventView (cal,parent,name)
348{ 350{
349 mBlockUpdating = true; 351 mBlockUpdating = true;
350 mStartHour = 8; 352 mStartHour = 8;
351 mSelectedDates.append(QDate::currentDate()); 353 mSelectedDates.append(QDate::currentDate());
352 354
353 mLayoutDayLabels = 0; 355 mLayoutDayLabels = 0;
354 mDayLabelsFrame = 0; 356 mDayLabelsFrame = 0;
355 mDayLabels = 0; 357 mDayLabels = 0;
356 bool isRTL = KOGlobals::self()->reverseLayout(); 358 bool isRTL = KOGlobals::self()->reverseLayout();
357 359
358 if ( KOPrefs::instance()->mVerticalScreen ) { 360 if ( KOPrefs::instance()->mVerticalScreen ) {
359 mExpandedPixmap = SmallIcon( "1downarrow" ); 361 mExpandedPixmap = SmallIcon( "1downarrow" );
360 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 362 mNotExpandedPixmap = SmallIcon( "1uparrow" );
361 } else { 363 } else {
362 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 364 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
363 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 365 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
364 } 366 }
365 367
366 QBoxLayout *topLayout = new QVBoxLayout(this); 368 QBoxLayout *topLayout = new QVBoxLayout(this);
367 369
368 // Create day name labels for agenda columns 370 // Create day name labels for agenda columns
369 mDayLabelsFrame = new QHBox(this); 371 mDayLabelsFrame = new QHBox(this);
370 topLayout->addWidget(mDayLabelsFrame); 372 topLayout->addWidget(mDayLabelsFrame);
371 mDayLabels = new QFrame (mDayLabelsFrame); 373 mDayLabels = new QFrame (mDayLabelsFrame);
372 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 374 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
373 // Create agenda splitter 375 // Create agenda splitter
374#ifndef KORG_NOSPLITTER 376#ifndef KORG_NOSPLITTER
375 mSplitterAgenda = new QSplitter(Vertical,this); 377 mSplitterAgenda = new QSplitter(Vertical,this);
376 topLayout->addWidget(mSplitterAgenda); 378 topLayout->addWidget(mSplitterAgenda);
377 mSplitterAgenda->setOpaqueResize(); 379 mSplitterAgenda->setOpaqueResize();
378 380
379 mAllDayFrame = new QHBox(mSplitterAgenda); 381 mAllDayFrame = new QHBox(mSplitterAgenda);
380 382
381 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 383 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
382#else 384#else
383#if 0 385#if 0
384 QWidget *mainBox = new QWidget( this ); 386 QWidget *mainBox = new QWidget( this );
385 topLayout->addWidget( mainBox ); 387 topLayout->addWidget( mainBox );
386 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 388 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
387 mAllDayFrame = new QHBox(mainBox); 389 mAllDayFrame = new QHBox(mainBox);
388 mainLayout->addWidget(mAllDayFrame); 390 mainLayout->addWidget(mAllDayFrame);
389 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 391 mainLayout->setStretchFactor( mAllDayFrame, 0 );
390 mAllDayFrame->setFocusPolicy(NoFocus); 392 mAllDayFrame->setFocusPolicy(NoFocus);
391 QWidget *agendaFrame = new QWidget(mainBox); 393 QWidget *agendaFrame = new QWidget(mainBox);
392 mainLayout->addWidget(agendaFrame); 394 mainLayout->addWidget(agendaFrame);
393 mainLayout->setStretchFactor( agendaFrame, 10 ); 395 mainLayout->setStretchFactor( agendaFrame, 10 );
394 396
395 agendaFrame->setFocusPolicy(NoFocus); 397 agendaFrame->setFocusPolicy(NoFocus);
396#endif 398#endif
397 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 399 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
398 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 400 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
399 topLayout->addWidget( mSplitterAgenda ); 401 topLayout->addWidget( mSplitterAgenda );
400 mAllDayFrame = new QHBox(mSplitterAgenda); 402 mAllDayFrame = new QHBox(mSplitterAgenda);
401 mAllDayFrame->setFocusPolicy(NoFocus); 403 mAllDayFrame->setFocusPolicy(NoFocus);
402 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 404 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
403 agendaFrame->setFocusPolicy(NoFocus); 405 agendaFrame->setFocusPolicy(NoFocus);
404 406
405#endif 407#endif
406 408
407 // Create all-day agenda widget 409 // Create all-day agenda widget
408 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 410 mDummyAllDayLeft = new QVBox( mAllDayFrame );
409 411
410 mExpandButton = new QPushButton(mDummyAllDayLeft); 412 mExpandButton = new QPushButton(mDummyAllDayLeft);
411 mExpandButton->setPixmap( mNotExpandedPixmap ); 413 mExpandButton->setPixmap( mNotExpandedPixmap );
412 int widebut = mExpandButton->sizeHint().width(); 414 int widebut = mExpandButton->sizeHint().width();
413 if ( QApplication::desktop()->width() < 480 ) 415 if ( QApplication::desktop()->width() < 480 )
414 widebut = widebut*2; 416 widebut = widebut*2;
415 else 417 else
416 widebut = (widebut*3) / 2; 418 widebut = (widebut*3) / 2;
417 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
418 // QSizePolicy::Fixed ) ); 420 // QSizePolicy::Fixed ) );
419 mExpandButton->setFixedSize( widebut, widebut); 421 mExpandButton->setFixedSize( widebut, widebut);
420 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
421 mExpandButton->setFocusPolicy(NoFocus); 423 mExpandButton->setFocusPolicy(NoFocus);
422 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
423 mAllDayAgenda->setFocusPolicy(NoFocus); 425 mAllDayAgenda->setFocusPolicy(NoFocus);
424 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 426 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
425 427
426 // Create event context menu for all day agenda 428 // Create event context menu for all day agenda
427 mAllDayAgendaPopup = eventPopup(); 429 mAllDayAgendaPopup = eventPopup();
428 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 430 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
429 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 431 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
430 432
431 // Create agenda frame 433 // Create agenda frame
432 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 434 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
433 // QHBox *agendaFrame = new QHBox(splitterAgenda); 435 // QHBox *agendaFrame = new QHBox(splitterAgenda);
434 436
435 // create event indicator bars 437 // create event indicator bars
436 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 438 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
437 agendaLayout->addWidget(mEventIndicatorTop,0,1); 439 agendaLayout->addWidget(mEventIndicatorTop,0,1);
438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 440 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
439 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 441 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
440 agendaFrame); 442 agendaFrame);
441 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 443 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
442 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 444 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
443 agendaLayout->addWidget(dummyAgendaRight,0,2); 445 agendaLayout->addWidget(dummyAgendaRight,0,2);
444 446
445 // Create time labels 447 // Create time labels
446 mTimeLabels = new TimeLabels(24,agendaFrame); 448 mTimeLabels = new TimeLabels(24,agendaFrame);
447 agendaLayout->addWidget(mTimeLabels,1,0); 449 agendaLayout->addWidget(mTimeLabels,1,0);
448 connect(mTimeLabels,SIGNAL( scaleChanged()), 450 connect(mTimeLabels,SIGNAL( scaleChanged()),
449 this,SLOT(updateConfig())); 451 this,SLOT(updateConfig()));
450 452
451 // Create agenda 453 // Create agenda
452 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
453 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
454 agendaLayout->setColStretch(1,1); 456 agendaLayout->setColStretch(1,1);
455 mAgenda->setFocusPolicy(NoFocus); 457 mAgenda->setFocusPolicy(NoFocus);
456 // Create event context menu for agenda 458 // Create event context menu for agenda
457 mAgendaPopup = eventPopup(); 459 mAgendaPopup = eventPopup();
458 460
459 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
460 i18n("Toggle Alarm"),mAgenda, 462 i18n("Toggle Alarm"),mAgenda,
461 SLOT(popupAlarm()),true); 463 SLOT(popupAlarm()),true);
462 464
463 465
464 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
465 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
466 468
467 // make connections between dependent widgets 469 // make connections between dependent widgets
468 mTimeLabels->setAgenda(mAgenda); 470 mTimeLabels->setAgenda(mAgenda);
469 471
470 // Update widgets to reflect user preferences 472 // Update widgets to reflect user preferences
471 // updateConfig(); 473 // updateConfig();
472 474
473 // createDayLabels(); 475 // createDayLabels();
474 476
475 // these blank widgets make the All Day Event box line up with the agenda 477 // these blank widgets make the All Day Event box line up with the agenda
476 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
477 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
478 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
479 481
480 // Scrolling 482 // Scrolling
481 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
482 mTimeLabels, SLOT(positionChanged())); 484 mTimeLabels, SLOT(positionChanged()));
483 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
484 SLOT(setContentsPos(int))); 486 SLOT(setContentsPos(int)));
485 487
486 // Create/Show/Edit/Delete Event 488 // Create/Show/Edit/Delete Event
487 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 489 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
488 SLOT(newEvent(int,int))); 490 SLOT(newEvent(int,int)));
489 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 491 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
490 SLOT(newEvent(int,int,int,int))); 492 SLOT(newEvent(int,int,int,int)));
491 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
492 SLOT(newEventAllDay(int,int))); 494 SLOT(newEventAllDay(int,int)));
493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 495 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
494 SLOT(newEventAllDay(int,int))); 496 SLOT(newEventAllDay(int,int)));
495 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 497 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
496 SLOT(newTimeSpanSelected(int,int,int,int))); 498 SLOT(newTimeSpanSelected(int,int,int,int)));
497 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 499 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
498 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 500 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
499 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 501 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
500 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 502 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
501 503
502 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 504 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
503 SIGNAL(editIncidenceSignal(Incidence *))); 505 SIGNAL(editIncidenceSignal(Incidence *)));
504 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 506 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
505 SIGNAL(editIncidenceSignal(Incidence *))); 507 SIGNAL(editIncidenceSignal(Incidence *)));
506 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 508 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
507 SIGNAL(showIncidenceSignal(Incidence *))); 509 SIGNAL(showIncidenceSignal(Incidence *)));
508 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 510 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
509 SIGNAL(showIncidenceSignal(Incidence *))); 511 SIGNAL(showIncidenceSignal(Incidence *)));
510 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 512 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
511 SIGNAL(deleteIncidenceSignal(Incidence *))); 513 SIGNAL(deleteIncidenceSignal(Incidence *)));
512 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 514 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
513 SIGNAL(deleteIncidenceSignal(Incidence *))); 515 SIGNAL(deleteIncidenceSignal(Incidence *)));
514 516
515 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 517 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
516 SLOT(updateEventDates(KOAgendaItem *, int ))); 518 SLOT(updateEventDates(KOAgendaItem *, int )));
517 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 519 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
518 SLOT(updateEventDates(KOAgendaItem *, int))); 520 SLOT(updateEventDates(KOAgendaItem *, int)));
519 521
520 // event indicator update 522 // event indicator update
521 connect(mAgenda,SIGNAL(lowerYChanged(int)), 523 connect(mAgenda,SIGNAL(lowerYChanged(int)),
522 SLOT(updateEventIndicatorTop(int))); 524 SLOT(updateEventIndicatorTop(int)));
523 connect(mAgenda,SIGNAL(upperYChanged(int)), 525 connect(mAgenda,SIGNAL(upperYChanged(int)),
524 SLOT(updateEventIndicatorBottom(int))); 526 SLOT(updateEventIndicatorBottom(int)));
525 // drag signals 527 // drag signals
526 /* 528 /*
527 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 529 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
528 SLOT(startDrag(Event *))); 530 SLOT(startDrag(Event *)));
529 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 531 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
530 SLOT(startDrag(Event *))); 532 SLOT(startDrag(Event *)));
531 */ 533 */
532 // synchronize selections 534 // synchronize selections
533 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 535 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
534 mAllDayAgenda, SLOT( deselectItem() ) ); 536 mAllDayAgenda, SLOT( deselectItem() ) );
535 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 537 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
536 mAgenda, SLOT( deselectItem() ) ); 538 mAgenda, SLOT( deselectItem() ) );
537 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 539 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
538 SIGNAL( incidenceSelected( Incidence * ) ) ); 540 SIGNAL( incidenceSelected( Incidence * ) ) );
539 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 541 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
540 SIGNAL( incidenceSelected( Incidence * ) ) ); 542 SIGNAL( incidenceSelected( Incidence * ) ) );
541 connect( mAgenda, SIGNAL( resizedSignal() ), 543 connect( mAgenda, SIGNAL( resizedSignal() ),
542 SLOT( updateConfig( ) ) ); 544 SLOT( updateConfig( ) ) );
543 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 545 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
544 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 546 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
545 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 547 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
546 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 548 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
547 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 549 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
548 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 550 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
549 551
550 552
551} 553}
552 554
553void KOAgendaView::toggleAllDay() 555void KOAgendaView::toggleAllDay()
554{ 556{
555 if ( mSplitterAgenda->firstHandle() ) 557 if ( mSplitterAgenda->firstHandle() )
556 mSplitterAgenda->firstHandle()->toggle(); 558 mSplitterAgenda->firstHandle()->toggle();
557} 559}
558void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 560void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
559{ 561{
560 calendar()->addIncidence( inc ); 562 calendar()->addIncidence( inc );
561 563
562 if ( incOld ) { 564 if ( incOld ) {
563 if ( incOld->type() == "Todo" ) 565 if ( incOld->type() == "Todo" )
564 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 566 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
565 else 567 else
566 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 568 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
567 } 569 }
568 570
569} 571}
570 572
571KOAgendaView::~KOAgendaView() 573KOAgendaView::~KOAgendaView()
572{ 574{
573 delete mAgendaPopup; 575 delete mAgendaPopup;
574 delete mAllDayAgendaPopup; 576 delete mAllDayAgendaPopup;
575 delete KOAgendaItem::paintPix(); 577 delete KOAgendaItem::paintPix();
576 delete KOAgendaItem::paintPixSel(); 578 delete KOAgendaItem::paintPixSel();
577} 579}
578void KOAgendaView::resizeEvent( QResizeEvent* e ) 580void KOAgendaView::resizeEvent( QResizeEvent* e )
579{ 581{
580 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 582 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
581 bool uc = false; 583 bool uc = false;
582 int ow = e->oldSize().width(); 584 int ow = e->oldSize().width();
583 int oh = e->oldSize().height(); 585 int oh = e->oldSize().height();
584 int w = e->size().width(); 586 int w = e->size().width();
585 int h = e->size().height(); 587 int h = e->size().height();
586 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 588 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
587 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 589 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
588 uc = true; 590 uc = true;
589 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 591 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
590 } 592 }
591 mUpcomingWidth = e->size().width() ; 593 mUpcomingWidth = e->size().width() ;
592 if ( mBlockUpdating || uc ) { 594 if ( mBlockUpdating || uc ) {
593 mBlockUpdating = false; 595 mBlockUpdating = false;
594 //mAgenda->setMinimumSize(800 , 600 ); 596 //mAgenda->setMinimumSize(800 , 600 );
595 //qDebug("mAgenda->resize+++++++++++++++ "); 597 //qDebug("mAgenda->resize+++++++++++++++ ");
596 updateConfig(); 598 updateConfig();
597 //qDebug("KOAgendaView::Updating now possible "); 599 //qDebug("KOAgendaView::Updating now possible ");
598 } else 600 } else
599 createDayLabels(); 601 createDayLabels();
600 //qDebug("resizeEvent end "); 602 //qDebug("resizeEvent end ");
601 603
602} 604}
603void KOAgendaView::createDayLabels() 605void KOAgendaView::createDayLabels()
604{ 606{
605 607
606 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 608 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
607 // qDebug(" KOAgendaView::createDayLabels() blocked "); 609 // qDebug(" KOAgendaView::createDayLabels() blocked ");
608 return; 610 return;
609 611
610 } 612 }
611 int newHight; 613 int newHight;
612 614
613 // ### Before deleting and recreating we could check if mSelectedDates changed... 615 // ### Before deleting and recreating we could check if mSelectedDates changed...
614 // It would remove some flickering and gain speed (since this is called by 616 // It would remove some flickering and gain speed (since this is called by
615 // each updateView() call) 617 // each updateView() call)
616 618
617 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 619 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
618 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 620 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
619 if ( maxWid < 0 ) 621 if ( maxWid < 0 )
620 maxWid = 20; 622 maxWid = 20;
621 623
622 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 624 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
623 QFontMetrics fm ( dlf ); 625 QFontMetrics fm ( dlf );
624 int selCount = mSelectedDates.count(); 626 int selCount = mSelectedDates.count();
625 QString dayTest = "Mon 20"; 627 QString dayTest = "Mon 20";
626 int wid = fm.width( dayTest ); 628 int wid = fm.width( dayTest );
627 maxWid -= ( selCount * 3 ); 629 maxWid -= ( selCount * 3 );
628 if ( maxWid < 0 ) 630 if ( maxWid < 0 )
629 maxWid = 20; 631 maxWid = 20;
630 int needWid = wid * selCount; 632 int needWid = wid * selCount;
631 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 633 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
632 //if ( needWid > maxWid ) 634 //if ( needWid > maxWid )
633 // qDebug("DAYLABELS TOOOOOOO BIG "); 635 // qDebug("DAYLABELS TOOOOOOO BIG ");
634 while ( needWid > maxWid ) { 636 while ( needWid > maxWid ) {
635 dayTest = dayTest.left( dayTest.length() - 1 ); 637 dayTest = dayTest.left( dayTest.length() - 1 );
636 wid = fm.width( dayTest ); 638 wid = fm.width( dayTest );
637 needWid = wid * selCount; 639 needWid = wid * selCount;
638 } 640 }
639 int maxLen = dayTest.length(); 641 int maxLen = dayTest.length();
640 int fontPoint = dlf.pointSize(); 642 int fontPoint = dlf.pointSize();
641 if ( maxLen < 2 ) { 643 if ( maxLen < 2 ) {
642 int fontPoint = dlf.pointSize(); 644 int fontPoint = dlf.pointSize();
643 while ( fontPoint > 4 ) { 645 while ( fontPoint > 4 ) {
644 --fontPoint; 646 --fontPoint;
645 dlf.setPointSize( fontPoint ); 647 dlf.setPointSize( fontPoint );
646 QFontMetrics f( dlf ); 648 QFontMetrics f( dlf );
647 wid = f.width( "20" ); 649 wid = f.width( "20" );
648 needWid = wid * selCount; 650 needWid = wid * selCount;
649 if ( needWid < maxWid ) 651 if ( needWid < maxWid )
650 break; 652 break;
651 } 653 }
652 maxLen = 2; 654 maxLen = 2;
653 } 655 }
654 //qDebug("Max len %d ", dayTest.length() ); 656 //qDebug("Max len %d ", dayTest.length() );
655 657
656 QFontMetrics tempF( dlf ); 658 QFontMetrics tempF( dlf );
657 newHight = tempF.height(); 659 newHight = tempF.height();
658 mDayLabels->setFont( dlf ); 660 mDayLabels->setFont( dlf );
659 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 661 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
660 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 662 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
661 //mLayoutDayLabels->addSpacing( 2 ); 663 //mLayoutDayLabels->addSpacing( 2 );
662 // QFont lFont = dlf; 664 // QFont lFont = dlf;
663 bool appendLabels = false; 665 bool appendLabels = false;
664 QLabel *dayLabel; 666 QLabel *dayLabel;
665 dayLabel = mDayLabelsList.first(); 667 dayLabel = mDayLabelsList.first();
666 if ( !dayLabel ) { 668 if ( !dayLabel ) {
667 appendLabels = true; 669 appendLabels = true;
668 dayLabel = new QLabel(mDayLabels); 670 dayLabel = new QLabel(mDayLabels);
669 mDayLabelsList.append( dayLabel ); 671 mDayLabelsList.append( dayLabel );
670 mLayoutDayLabels->addWidget(dayLabel); 672 mLayoutDayLabels->addWidget(dayLabel);
671 } 673 }
672 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 674 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
673 dayLabel->setFont( dlf ); 675 dayLabel->setFont( dlf );
674 dayLabel->setAlignment(QLabel::AlignHCenter); 676 dayLabel->setAlignment(QLabel::AlignHCenter);
675 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 677 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
676 dayLabel->show(); 678 dayLabel->show();
677 DateList::ConstIterator dit; 679 DateList::ConstIterator dit;
678 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 680 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
679 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 681 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
680 QDate date = *dit; 682 QDate date = *dit;
681 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 683 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
682 if ( ! appendLabels ) { 684 if ( ! appendLabels ) {
683 dayLabel = mDayLabelsList.next(); 685 dayLabel = mDayLabelsList.next();
684 if ( !dayLabel ) 686 if ( !dayLabel )
685 appendLabels = true; 687 appendLabels = true;
686 } 688 }
687 if ( appendLabels ) { 689 if ( appendLabels ) {
688 dayLabel = new QLabel(mDayLabels); 690 dayLabel = new QLabel(mDayLabels);
689 mDayLabelsList.append( dayLabel ); 691 mDayLabelsList.append( dayLabel );
690 mLayoutDayLabels->addWidget(dayLabel); 692 mLayoutDayLabels->addWidget(dayLabel);
691 } 693 }
692 dayLabel->setMinimumWidth( 1 ); 694 dayLabel->setMinimumWidth( 1 );
693 dayLabel->setMaximumWidth( 2048 ); 695 dayLabel->setMaximumWidth( 2048 );
694 dayLabel->setFont( dlf ); 696 dayLabel->setFont( dlf );
695 dayLabel->show(); 697 dayLabel->show();
696 QString str; 698 QString str;
697 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 699 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
698 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 700 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
699 switch ( maxLen ) { 701 switch ( maxLen ) {
700 case 2: 702 case 2:
701 str = QString::number( date.day() ); 703 str = QString::number( date.day() );
702 break; 704 break;
703 705
704 case 3: 706 case 3:
705 str = dayName.left( 1 ) +QString::number( date.day()); 707 str = dayName.left( 1 ) +QString::number( date.day());
706 708
707 break; 709 break;
708 case 4: 710 case 4:
709 str = dayName.left( 1 ) + " " +QString::number( date.day()); 711 str = dayName.left( 1 ) + " " +QString::number( date.day());
710 712
711 break; 713 break;
712 case 5: 714 case 5:
713 str = dayName.left( 2 ) + " " +QString::number( date.day()); 715 str = dayName.left( 2 ) + " " +QString::number( date.day());
714 716
715 break; 717 break;
716 case 6: 718 case 6:
717 str = dayName.left( 3 ) + " " +QString::number( date.day()); 719 str = dayName.left( 3 ) + " " +QString::number( date.day());
718 break; 720 break;
719 721
720 default: 722 default:
721 break; 723 break;
722 } 724 }
723 if ( oneday ) { 725 if ( oneday ) {
724 QString addString; 726 QString addString;
725 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 727 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
726 addString = i18n("Today"); 728 addString = i18n("Today");
727 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 729 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
728 addString = i18n("Tomorrow"); 730 addString = i18n("Tomorrow");
729 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 731 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
730 addString = i18n("Yesterday"); 732 addString = i18n("Yesterday");
731 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 733 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
732 addString = i18n("Day before yesterday"); 734 addString = i18n("Day before yesterday");
733 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 735 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
734 addString = i18n("Day after tomorrow"); 736 addString = i18n("Day after tomorrow");
735 if ( !addString.isEmpty() ) { 737 if ( !addString.isEmpty() ) {
736 str = addString+", " + str; 738 str = addString+", " + str;
737 } 739 }
738 } 740 }
739 dayLabel->setText(str); 741 dayLabel->setText(str);
740 dayLabel->setAlignment(QLabel::AlignHCenter); 742 dayLabel->setAlignment(QLabel::AlignHCenter);
741 if (date == QDate::currentDate()) { 743 if (date == QDate::currentDate()) {
742 QFont bFont = dlf; 744 QFont bFont = dlf;
743 bFont.setBold( true ); 745 bFont.setBold( true );
744 dayLabel->setFont(bFont); 746 dayLabel->setFont(bFont);
745 } 747 }
746 //dayLayout->addWidget(dayLabel); 748 //dayLayout->addWidget(dayLabel);
747 749
748#ifndef KORG_NOPLUGINS 750#ifndef KORG_NOPLUGINS
749 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 751 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
750 CalendarDecoration *it; 752 CalendarDecoration *it;
751 for(it = cds.first(); it; it = cds.next()) { 753 for(it = cds.first(); it; it = cds.next()) {
752 QString text = it->shortText( date ); 754 QString text = it->shortText( date );
753 if ( !text.isEmpty() ) { 755 if ( !text.isEmpty() ) {
754 QLabel *label = new QLabel(text,mDayLabels); 756 QLabel *label = new QLabel(text,mDayLabels);
755 label->setAlignment(AlignCenter); 757 label->setAlignment(AlignCenter);
756 dayLayout->addWidget(label); 758 dayLayout->addWidget(label);
757 } 759 }
758 } 760 }
759 761
760 for(it = cds.first(); it; it = cds.next()) { 762 for(it = cds.first(); it; it = cds.next()) {
761 QWidget *wid = it->smallWidget(mDayLabels,date); 763 QWidget *wid = it->smallWidget(mDayLabels,date);
762 if ( wid ) { 764 if ( wid ) {
763 // wid->setHeight(20); 765 // wid->setHeight(20);
764 dayLayout->addWidget(wid); 766 dayLayout->addWidget(wid);
765 } 767 }
766 } 768 }
767#endif 769#endif
768 } 770 }
769 if ( ! appendLabels ) { 771 if ( ! appendLabels ) {
770 dayLabel = mDayLabelsList.next(); 772 dayLabel = mDayLabelsList.next();
771 if ( !dayLabel ) 773 if ( !dayLabel )
772 appendLabels = true; 774 appendLabels = true;
773 } 775 }
774 if ( appendLabels ) { 776 if ( appendLabels ) {
775 dayLabel = new QLabel(mDayLabels); 777 dayLabel = new QLabel(mDayLabels);
776 mDayLabelsList.append( dayLabel ); 778 mDayLabelsList.append( dayLabel );
777 mLayoutDayLabels->addWidget(dayLabel); 779 mLayoutDayLabels->addWidget(dayLabel);
778 } 780 }
779 //dayLabel->hide();//test only 781 //dayLabel->hide();//test only
780 782
781 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 783 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
782 if ( offset < 0 ) offset = 0; 784 if ( offset < 0 ) offset = 0;
783 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 785 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
784 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); 786 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) );
785 dayLabel->show(); 787 dayLabel->show();
786 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 788 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
787 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 789 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
788 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 790 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
789 if ( !appendLabels ) { 791 if ( !appendLabels ) {
790 dayLabel = mDayLabelsList.next(); 792 dayLabel = mDayLabelsList.next();
791 while ( dayLabel ) { 793 while ( dayLabel ) {
792 //qDebug("!dayLabel %d",dayLabel ); 794 //qDebug("!dayLabel %d",dayLabel );
793 dayLabel->hide(); 795 dayLabel->hide();
794 dayLabel = mDayLabelsList.next(); 796 dayLabel = mDayLabelsList.next();
795 } 797 }
796 } 798 }
797 //mDayLabelsFrame->show(); 799 //mDayLabelsFrame->show();
798 //mDayLabels->show(); 800 //mDayLabels->show();
799 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 801 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
800 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 802 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
801 mDayLabelsFrame->setFixedHeight( newHight ); 803 mDayLabelsFrame->setFixedHeight( newHight );
802} 804}
803 805
804int KOAgendaView::maxDatesHint() 806int KOAgendaView::maxDatesHint()
805{ 807{
806 // Not sure about the max number of events, so return 0 for now. 808 // Not sure about the max number of events, so return 0 for now.
807 return 0; 809 return 0;
808} 810}
809 811
810int KOAgendaView::currentDateCount() 812int KOAgendaView::currentDateCount()
811{ 813{
812 return mSelectedDates.count(); 814 return mSelectedDates.count();
813} 815}
814 816
815QPtrList<Incidence> KOAgendaView::selectedIncidences() 817QPtrList<Incidence> KOAgendaView::selectedIncidences()
816{ 818{
817 QPtrList<Incidence> selected; 819 QPtrList<Incidence> selected;
818 Incidence *incidence; 820 Incidence *incidence;
819 821
820 incidence = mAgenda->selectedIncidence(); 822 incidence = mAgenda->selectedIncidence();
821 if (incidence) selected.append(incidence); 823 if (incidence) selected.append(incidence);
822 824
823 incidence = mAllDayAgenda->selectedIncidence(); 825 incidence = mAllDayAgenda->selectedIncidence();
824 if (incidence) selected.append(incidence); 826 if (incidence) selected.append(incidence);
825 827
826 return selected; 828 return selected;
827} 829}
828 830
829DateList KOAgendaView::selectedDates() 831DateList KOAgendaView::selectedDates()
830{ 832{
831 DateList selected; 833 DateList selected;
832 QDate qd; 834 QDate qd;
833 835
834 qd = mAgenda->selectedIncidenceDate(); 836 qd = mAgenda->selectedIncidenceDate();
835 if (qd.isValid()) selected.append(qd); 837 if (qd.isValid()) selected.append(qd);
836 838
837 qd = mAllDayAgenda->selectedIncidenceDate(); 839 qd = mAllDayAgenda->selectedIncidenceDate();
838 if (qd.isValid()) selected.append(qd); 840 if (qd.isValid()) selected.append(qd);
839 841
840 return selected; 842 return selected;
841} 843}
842 844
843 845
844void KOAgendaView::updateView() 846void KOAgendaView::updateView()
845{ 847{
846 if ( mBlockUpdating ) 848 if ( mBlockUpdating )
847 return; 849 return;
848 // kdDebug() << "KOAgendaView::updateView()" << endl; 850 // kdDebug() << "KOAgendaView::updateView()" << endl;
849 fillAgenda(); 851 fillAgenda();
850 852
851} 853}
852 854
853 855
854/* 856/*
855 Update configuration settings for the agenda view. This method is not 857 Update configuration settings for the agenda view. This method is not
856 complete. 858 complete.
857*/ 859*/
858void KOAgendaView::updateConfig() 860void KOAgendaView::updateConfig()
859{ 861{
860 if ( mBlockUpdating ) 862 if ( mBlockUpdating )
861 return; 863 return;
862 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 864 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
863 865
864 // update config for children 866 // update config for children
865 mTimeLabels->updateConfig(); 867 mTimeLabels->updateConfig();
866 mAgenda->storePosition(); 868 mAgenda->storePosition();
867 mAgenda->updateConfig(); 869 mAgenda->updateConfig();
868 mAllDayAgenda->updateConfig(); 870 mAllDayAgenda->updateConfig();
869 // widget synchronization 871 // widget synchronization
870 //TODO: find a better way, maybe signal/slot 872 //TODO: find a better way, maybe signal/slot
871 mTimeLabels->positionChanged(); 873 mTimeLabels->positionChanged();
872 874
873 // for some reason, this needs to be called explicitly 875 // for some reason, this needs to be called explicitly
874 mTimeLabels->repaint(); 876 mTimeLabels->repaint();
875 877
876 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 878 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
877 879
878 // ToolTips displaying summary of events 880 // ToolTips displaying summary of events
879 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 881 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
880 ->mEnableToolTips); 882 ->mEnableToolTips);
881 883
882 //setHolidayMasks(); 884 //setHolidayMasks();
883 885
884 //createDayLabels(); called by via updateView(); 886 //createDayLabels(); called by via updateView();
885 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 887 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
886 updateView(); 888 updateView();
887 mAgenda->restorePosition(); 889 mAgenda->restorePosition();
888} 890}
889 891
890 892
891void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 893void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
892{ 894{
893 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 895 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
894 //qDebug("KOAgendaView::updateEventDates "); 896 //qDebug("KOAgendaView::updateEventDates ");
895 QDateTime startDt,endDt; 897 QDateTime startDt,endDt;
896 QDate startDate; 898 QDate startDate;
897 int lenInSecs; 899 int lenInSecs;
898 // if ( type == KOAgenda::RESIZETOP ) 900 // if ( type == KOAgenda::RESIZETOP )
899 // qDebug("RESIZETOP "); 901 // qDebug("RESIZETOP ");
900 // if ( type == KOAgenda::RESIZEBOTTOM ) 902 // if ( type == KOAgenda::RESIZEBOTTOM )
901 // qDebug("RESIZEBOTTOM "); 903 // qDebug("RESIZEBOTTOM ");
902 // if ( type == KOAgenda::MOVE ) 904 // if ( type == KOAgenda::MOVE )
903 // qDebug("MOVE "); 905 // qDebug("MOVE ");
904 if ( item->incidence()->type() == "Event" ) { 906 if ( item->incidence()->type() == "Event" ) {
905 startDt =item->incidence()->dtStart(); 907 startDt =item->incidence()->dtStart();
906 endDt = item->incidence()->dtEnd(); 908 endDt = item->incidence()->dtEnd();
907 lenInSecs = startDt.secsTo( endDt ); 909 lenInSecs = startDt.secsTo( endDt );
908 } 910 }
909 911
910 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 912 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
911 913
912 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 914 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
913 startDate = mSelectedDates[item->mLastMoveXPos]; 915 startDate = mSelectedDates[item->mLastMoveXPos];
914 } else { 916 } else {
915 if (item->cellX() < 0) { 917 if (item->cellX() < 0) {
916 startDate = (mSelectedDates.first()).addDays(item->cellX()); 918 startDate = (mSelectedDates.first()).addDays(item->cellX());
917 } else { 919 } else {
918 startDate = mSelectedDates[item->cellX()]; 920 startDate = mSelectedDates[item->cellX()];
919 } 921 }
920 } 922 }
921 startDt.setDate(startDate); 923 startDt.setDate(startDate);
922 924
923 if (item->incidence()->doesFloat()) { 925 if (item->incidence()->doesFloat()) {
924 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 926 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
925 } else { 927 } else {
926 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 928 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
927 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 929 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
928 if ( item->incidence()->type() == "Event" ) { 930 if ( item->incidence()->type() == "Event" ) {
929 if ( type == KOAgenda::MOVE ) { 931 if ( type == KOAgenda::MOVE ) {
930 endDt = startDt.addSecs(lenInSecs); 932 endDt = startDt.addSecs(lenInSecs);
931 933
932 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 934 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
933 if (item->lastMultiItem()) { 935 if (item->lastMultiItem()) {
934 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 936 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
935 endDt.setDate(startDate. 937 endDt.setDate(startDate.
936 addDays(item->lastMultiItem()->cellX() - item->cellX())); 938 addDays(item->lastMultiItem()->cellX() - item->cellX()));
937 } else { 939 } else {
938 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 940 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
939 endDt.setDate(startDate); 941 endDt.setDate(startDate);
940 } 942 }
941 } 943 }
942 } else { 944 } else {
943 // todo 945 // todo
944 if (item->lastMultiItem()) { 946 if (item->lastMultiItem()) {
945 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 947 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
946 endDt.setDate(startDate. 948 endDt.setDate(startDate.
947 addDays(item->lastMultiItem()->cellX() - item->cellX())); 949 addDays(item->lastMultiItem()->cellX() - item->cellX()));
948 } else { 950 } else {
949 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 951 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
950 if ( item->cellYBottom() > 0 ) 952 if ( item->cellYBottom() > 0 )
951 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 953 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
952 else 954 else
953 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 955 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
954 endDt.setDate(startDate); 956 endDt.setDate(startDate);
955 } 957 }
956 } 958 }
957 } 959 }
958 960
959 961
960 if ( item->incidence()->type() == "Event" ) { 962 if ( item->incidence()->type() == "Event" ) {
961 item->incidence()->setDtStart(startDt); 963 item->incidence()->setDtStart(startDt);
962 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 964 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
963 } else if ( item->incidence()->type() == "Todo" ) { 965 } else if ( item->incidence()->type() == "Todo" ) {
964 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 966 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
965 } 967 }
966 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 968 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
967 item->incidence()->setRevision(item->incidence()->revision()+1); 969 item->incidence()->setRevision(item->incidence()->revision()+1);
968 item->setItemDate(startDt.date()); 970 item->setItemDate(startDt.date());
969 //item->updateItem(); 971 //item->updateItem();
970 if ( item->incidence()->type() == "Todo" ) { 972 if ( item->incidence()->type() == "Todo" ) {
971 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 973 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
972 974
973 } 975 }
974 else 976 else
975 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 977 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
976 item->updateItem(); 978 item->updateItem();
977} 979}
978 980
979void KOAgendaView::showDates( const QDate &start, const QDate &end ) 981void KOAgendaView::showDates( const QDate &start, const QDate &end )
980{ 982{
981 // kdDebug() << "KOAgendaView::selectDates" << endl; 983 // kdDebug() << "KOAgendaView::selectDates" << endl;
982 984
983 mSelectedDates.clear(); 985 mSelectedDates.clear();
984 // qDebug("KOAgendaView::showDates "); 986 // qDebug("KOAgendaView::showDates ");
985 QDate d = start; 987 QDate d = start;
986 while (d <= end) { 988 while (d <= end) {
987 mSelectedDates.append(d); 989 mSelectedDates.append(d);
988 d = d.addDays( 1 ); 990 d = d.addDays( 1 );
989 } 991 }
990 992
991 // and update the view 993 // and update the view
992 fillAgenda(); 994 fillAgenda();
993} 995}
994 996
995 997
996void KOAgendaView::showEvents(QPtrList<Event>) 998void KOAgendaView::showEvents(QPtrList<Event>)
997{ 999{
998 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1000 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
999} 1001}
1000 1002
1001void KOAgendaView::changeEventDisplay(Event *, int) 1003void KOAgendaView::changeEventDisplay(Event *, int)
1002{ 1004{
1003 // qDebug("KOAgendaView::changeEventDisplay "); 1005 // qDebug("KOAgendaView::changeEventDisplay ");
1004 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1006 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1005 // this should be re-written to be MUCH smarter. Right now we 1007 // this should be re-written to be MUCH smarter. Right now we
1006 // are just playing dumb. 1008 // are just playing dumb.
1007 fillAgenda(); 1009 fillAgenda();
1008} 1010}
1009 1011
1010void KOAgendaView::fillAgenda(const QDate &) 1012void KOAgendaView::fillAgenda(const QDate &)
1011{ 1013{
1012 // qDebug("KOAgendaView::fillAgenda "); 1014 // qDebug("KOAgendaView::fillAgenda ");
1013 fillAgenda(); 1015 fillAgenda();
1014} 1016}
1015 1017
1016void KOAgendaView::fillAgenda() 1018void KOAgendaView::fillAgenda()
1017{ 1019{
1018 if ( globalFlagBlockStartup ) 1020 if ( globalFlagBlockStartup )
1019 return; 1021 return;
1020 if ( globalFlagBlockAgenda == 1 ) 1022 if ( globalFlagBlockAgenda == 1 )
1021 return; 1023 return;
1022 //if ( globalFlagBlockAgenda == 2 ) 1024 //if ( globalFlagBlockAgenda == 2 )
1023 //globalFlagBlockAgenda = 0; 1025 //globalFlagBlockAgenda = 0;
1024 // globalFlagBlockPainting = false; 1026 // globalFlagBlockPainting = false;
1025 if ( globalFlagBlockAgenda == 0 ) 1027 if ( globalFlagBlockAgenda == 0 )
1026 globalFlagBlockAgenda = 1; 1028 globalFlagBlockAgenda = 1;
1027 // clearView(); 1029 // clearView();
1028 //qDebug("fillAgenda()++++ "); 1030 //qDebug("fillAgenda()++++ ");
1029 globalFlagBlockAgendaItemPaint = 1; 1031 globalFlagBlockAgendaItemPaint = 1;
1030 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1032 mAllDayAgenda->changeColumns(mSelectedDates.count());
1031 mAgenda->changeColumns(mSelectedDates.count()); 1033 mAgenda->changeColumns(mSelectedDates.count());
1032 qApp->processEvents(); 1034 qApp->processEvents();
1033 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1035 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1034 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1036 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1035 setHolidayMasks(); 1037 setHolidayMasks();
1036 1038
1037 //mAgenda->hideUnused(); 1039 //mAgenda->hideUnused();
1038 //mAllDayAgenda->hideUnused(); 1040 //mAllDayAgenda->hideUnused();
1039 1041
1040 // mAgenda->blockNextRepaint( false ); 1042 // mAgenda->blockNextRepaint( false );
1041 // mAgenda->viewport()->repaint(); 1043 // mAgenda->viewport()->repaint();
1042 // mAgenda->blockNextRepaint( true ); 1044 // mAgenda->blockNextRepaint( true );
1043 mMinY.resize(mSelectedDates.count()); 1045 mMinY.resize(mSelectedDates.count());
1044 mMaxY.resize(mSelectedDates.count()); 1046 mMaxY.resize(mSelectedDates.count());
1045 1047
1046 QPtrList<Event> dayEvents; 1048 QPtrList<Event> dayEvents;
1047 1049
1048 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1050 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1049 // Therefore, get all of them. 1051 // Therefore, get all of them.
1050 QPtrList<Todo> todos = calendar()->todos(); 1052 QPtrList<Todo> todos = calendar()->todos();
1051 1053
1052 mAgenda->setDateList(mSelectedDates); 1054 mAgenda->setDateList(mSelectedDates);
1053 1055
1054 QDate today = QDate::currentDate(); 1056 QDate today = QDate::currentDate();
1055 1057
1056 DateList::ConstIterator dit; 1058 DateList::ConstIterator dit;
1057 int curCol = 0; 1059 int curCol = 0;
1058 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1060 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1059 QDate currentDate = *dit; 1061 QDate currentDate = *dit;
1060 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1062 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1061 // << endl; 1063 // << endl;
1062 1064
1063 dayEvents = calendar()->events(currentDate,true); 1065 dayEvents = calendar()->events(currentDate,true);
1064 1066
1065 // Default values, which can never be reached 1067 // Default values, which can never be reached
1066 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1068 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1067 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1069 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1068 1070
1069 unsigned int numEvent; 1071 unsigned int numEvent;
1070 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1072 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1071 Event *event = dayEvents.at(numEvent); 1073 Event *event = dayEvents.at(numEvent);
1072 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1074 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1073 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1075 if ( event->uid().left(15) == QString("last-syncEvent-") )
1074 continue; 1076 continue;
1075 // kdDebug() << " Event: " << event->summary() << endl; 1077 // kdDebug() << " Event: " << event->summary() << endl;
1076 1078
1077 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1079 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1078 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1080 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1079 1081
1080 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1082 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1081 1083
1082 if (event->doesFloat()) { 1084 if (event->doesFloat()) {
1083 if (event->recurrence()->doesRecur()) { 1085 if (event->recurrence()->doesRecur()) {
1084 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1086 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1085 } else { 1087 } else {
1086 if (beginX <= 0 && curCol == 0) { 1088 if (beginX <= 0 && curCol == 0) {
1087 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1089 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1088 } else if (beginX == curCol) { 1090 } else if (beginX == curCol) {
1089 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1091 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1090 } 1092 }
1091 } 1093 }
1092 } else if (event->isMultiDay()) { 1094 } else if (event->isMultiDay()) {
1093 if ( event->doesRecur () ) { 1095 if ( event->doesRecur () ) {
1094 QDate dateit = currentDate; 1096 QDate dateit = currentDate;
1095 int count = 0; 1097 int count = 0;
1096 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1098 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1097 while (! event->recursOn( dateit ) && count <= max ) { 1099 while (! event->recursOn( dateit ) && count <= max ) {
1098 ++count; 1100 ++count;
1099 dateit = dateit.addDays( -1 ); 1101 dateit = dateit.addDays( -1 );
1100 } 1102 }
1101 bool ok; 1103 bool ok;
1102 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1104 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1103 if ( ok ) 1105 if ( ok )
1104 { 1106 {
1105 int secs = event->dtStart().secsTo( event->dtEnd() ); 1107 int secs = event->dtStart().secsTo( event->dtEnd() );
1106 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1108 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1107 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1109 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1108 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1110 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1109 1111
1110 } 1112 }
1111 } 1113 }
1112 int startY = mAgenda->timeToY(event->dtStart().time()); 1114 int startY = mAgenda->timeToY(event->dtStart().time());
1113 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1115 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1114 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1116 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1115 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1117 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1116 //qDebug("insert!!! "); 1118 //qDebug("insert!!! ");
1117 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1119 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1118 } 1120 }
1119 if (beginX == curCol) { 1121 if (beginX == curCol) {
1120 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1122 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1121 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1123 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1122 } else if (endX == curCol) { 1124 } else if (endX == curCol) {
1123 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1125 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1124 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1126 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1125 } else { 1127 } else {
1126 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1128 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1127 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1129 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1128 } 1130 }
1129 } else { 1131 } else {
1130 int startY = mAgenda->timeToY(event->dtStart().time()); 1132 int startY = mAgenda->timeToY(event->dtStart().time());
1131 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1133 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1132 if (endY < startY) endY = startY; 1134 if (endY < startY) endY = startY;
1133 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1135 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1134 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1136 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1135 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1137 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1136 } 1138 }
1137 } 1139 }
1138 // ---------- [display Todos -------------- 1140 // ---------- [display Todos --------------
1139 unsigned int numTodo; 1141 unsigned int numTodo;
1140 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1142 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1141 Todo *todo = todos.at(numTodo); 1143 Todo *todo = todos.at(numTodo);
1142 1144
1143 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1145 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1144 1146
1145 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1147 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1146 // Already completed items can be displayed on their original due date 1148 // Already completed items can be displayed on their original due date
1147 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1149 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1148 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1150 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1149 1151
1150 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1152 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1151 ((currentDate == today) && overdue) ) { 1153 ((currentDate == today) && overdue) ) {
1152 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1154 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1153 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1155 if ( KOPrefs::instance()->mShowTodoInAgenda )
1154 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1156 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1155 } 1157 }
1156 else { 1158 else {
1157 1159
1158 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1160 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1159 int hi = (18/KOPrefs::instance()->mHourSize); 1161 int hi = (18/KOPrefs::instance()->mHourSize);
1160 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1162 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1161 int startY = endY -hi; 1163 int startY = endY -hi;
1162 1164
1163 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1165 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1164 1166
1165 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1167 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1166 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1168 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1167 } 1169 }
1168 } 1170 }
1169 } 1171 }
1170 // ---------- display Todos] -------------- 1172 // ---------- display Todos] --------------
1171 1173
1172 ++curCol; 1174 ++curCol;
1173 } 1175 }
1174 mAgenda->hideUnused(); 1176 mAgenda->hideUnused();
1175 mAllDayAgenda->hideUnused(); 1177 mAllDayAgenda->hideUnused();
1176 mAgenda->checkScrollBoundaries(); 1178 mAgenda->checkScrollBoundaries();
1177 1179
1178 deleteSelectedDateTime(); 1180 deleteSelectedDateTime();
1179 1181
1180 createDayLabels(); 1182 createDayLabels();
1181 emit incidenceSelected( 0 ); 1183 emit incidenceSelected( 0 );
1182 1184
1183 if ( globalFlagBlockAgenda == 2 ) { 1185 if ( globalFlagBlockAgenda == 2 ) {
1184 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1186 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1185 setStartHour( KOPrefs::instance()->mDayBegins ); 1187 setStartHour( KOPrefs::instance()->mDayBegins );
1186 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1188 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1187 setStartHour( QTime::currentTime ().hour() ); 1189 setStartHour( QTime::currentTime ().hour() );
1188 // qApp->processEvents(); 1190 // qApp->processEvents();
1189 } 1191 }
1190 qApp->processEvents(); 1192 qApp->processEvents();
1191 //qDebug("qApp->processEvents(); END "); 1193 //qDebug("qApp->processEvents(); END ");
1192 globalFlagBlockAgenda = 0; 1194 globalFlagBlockAgenda = 0;
1193 1195
1194 // mAgenda->hideUnused(); 1196 // mAgenda->hideUnused();
1195 //mAllDayAgenda->hideUnused(); 1197 //mAllDayAgenda->hideUnused();
1196 mAllDayAgenda->drawContentsToPainter(); 1198 mAllDayAgenda->drawContentsToPainter();
1197 mAgenda->drawContentsToPainter(); 1199 mAgenda->drawContentsToPainter();
1198 repaintAgenda(); 1200 repaintAgenda();
1199 // mAgenda->finishUpdate(); 1201 // mAgenda->finishUpdate();
1200 //mAllDayAgenda->finishUpdate(); 1202 //mAllDayAgenda->finishUpdate();
1201 1203
1202 // repaintAgenda(); 1204 // repaintAgenda();
1203 //qApp->processEvents(); 1205 //qApp->processEvents();
1204 // globalFlagBlockAgenda = 0; 1206 // globalFlagBlockAgenda = 0;
1205} 1207}
1206void KOAgendaView::repaintAgenda() 1208void KOAgendaView::repaintAgenda()
1207{ 1209{
1208 // mAllDayAgenda->drawContentsToPainter(); 1210 // mAllDayAgenda->drawContentsToPainter();
1209// mAllDayAgenda->viewport()->repaint( false ); 1211// mAllDayAgenda->viewport()->repaint( false );
1210// mAgenda->drawContentsToPainter(); 1212// mAgenda->drawContentsToPainter();
1211// mAgenda->viewport()->repaint( false ); 1213// mAgenda->viewport()->repaint( false );
1212// qApp->processEvents(); 1214// qApp->processEvents();
1213 1215
1214 //qDebug("KOAgendaView::repaintAgenda() "); 1216 //qDebug("KOAgendaView::repaintAgenda() ");
1215 //qApp->processEvents(); 1217 //qApp->processEvents();
1216 mAgenda->viewport()->repaint( false ); 1218 mAgenda->viewport()->repaint( false );
1217 mAllDayAgenda->viewport()->repaint( false ); 1219 mAllDayAgenda->viewport()->repaint( false );
1218 mAgenda->finishUpdate(); 1220 mAgenda->finishUpdate();
1219 mAllDayAgenda->finishUpdate(); 1221 mAllDayAgenda->finishUpdate();
1220} 1222}
1221 1223
1222 1224
1223void KOAgendaView::clearView() 1225void KOAgendaView::clearView()
1224{ 1226{
1225 // kdDebug() << "ClearView" << endl; 1227 // kdDebug() << "ClearView" << endl;
1226 mAllDayAgenda->clear(); 1228 mAllDayAgenda->clear();
1227 mAgenda->clear(); 1229 mAgenda->clear();
1228} 1230}
1229 1231
1230void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1232void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1231 const QDate &td) 1233 const QDate &td)
1232{ 1234{
1233#ifndef KORG_NOPRINTER 1235#ifndef KORG_NOPRINTER
1234 if (fd == td) 1236 if (fd == td)
1235 calPrinter->preview(CalPrinter::Day, fd, td); 1237 calPrinter->preview(CalPrinter::Day, fd, td);
1236 else 1238 else
1237 calPrinter->preview(CalPrinter::Week, fd, td); 1239 calPrinter->preview(CalPrinter::Week, fd, td);
1238#endif 1240#endif
1239} 1241}
1240 1242
1241// void KOAgendaView::updateMovedTodo() 1243// void KOAgendaView::updateMovedTodo()
1242// { 1244// {
1243// // updateConfig(); 1245// // updateConfig();
1244// // emit updateTodoViews(); 1246// // emit updateTodoViews();
1245// } 1247// }
1246 1248
1247void KOAgendaView::newEvent(int gx, int gy) 1249void KOAgendaView::newEvent(int gx, int gy)
1248{ 1250{
1249 if (!mSelectedDates.count()) return; 1251 if (!mSelectedDates.count()) return;
1250 1252
1251 QDate day = mSelectedDates[gx]; 1253 QDate day = mSelectedDates[gx];
1252 1254
1253 QTime time = mAgenda->gyToTime(gy); 1255 QTime time = mAgenda->gyToTime(gy);
1254 QDateTime dt(day,time); 1256 QDateTime dt(day,time);
1255 // if ( dt < QDateTime::currentDateTime () ) 1257 // if ( dt < QDateTime::currentDateTime () )
1256 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1258 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1257 emit newEventSignal(dt); 1259 emit newEventSignal(dt);
1258} 1260}
1259 1261
1260void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1262void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1261{ 1263{
1262 if (!mSelectedDates.count()) return; 1264 if (!mSelectedDates.count()) return;
1263 1265
1264 QDate dayStart = mSelectedDates[gxStart]; 1266 QDate dayStart = mSelectedDates[gxStart];
1265 QDate dayEnd = mSelectedDates[gxEnd]; 1267 QDate dayEnd = mSelectedDates[gxEnd];
1266 1268
1267 QTime timeStart = mAgenda->gyToTime(gyStart); 1269 QTime timeStart = mAgenda->gyToTime(gyStart);
1268 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1270 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1269 1271
1270 QDateTime dtStart(dayStart,timeStart); 1272 QDateTime dtStart(dayStart,timeStart);
1271 QDateTime dtEnd(dayEnd,timeEnd); 1273 QDateTime dtEnd(dayEnd,timeEnd);
1272 1274
1273 emit newEventSignal(dtStart,dtEnd); 1275 emit newEventSignal(dtStart,dtEnd);
1274} 1276}
1275 1277
1276void KOAgendaView::newEventAllDay(int gx, int ) 1278void KOAgendaView::newEventAllDay(int gx, int )
1277{ 1279{
1278 if (!mSelectedDates.count()) return; 1280 if (!mSelectedDates.count()) return;
1279 1281
1280 QDate day = mSelectedDates[gx]; 1282 QDate day = mSelectedDates[gx];
1281 1283
1282 emit newEventSignal(day); 1284 emit newEventSignal(day);
1283} 1285}
1284 1286
1285void KOAgendaView::updateEventIndicatorTop(int newY) 1287void KOAgendaView::updateEventIndicatorTop(int newY)
1286{ 1288{
1287 uint i; 1289 uint i;
1288 for(i=0;i<mMinY.size();++i) { 1290 for(i=0;i<mMinY.size();++i) {
1289 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1291 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1290 else mEventIndicatorTop->enableColumn(i,false); 1292 else mEventIndicatorTop->enableColumn(i,false);
1291 } 1293 }
1292 1294
1293 mEventIndicatorTop->update(); 1295 mEventIndicatorTop->update();
1294} 1296}
1295 1297
1296void KOAgendaView::updateEventIndicatorBottom(int newY) 1298void KOAgendaView::updateEventIndicatorBottom(int newY)
1297{ 1299{
1298 uint i; 1300 uint i;
1299 for(i=0;i<mMaxY.size();++i) { 1301 for(i=0;i<mMaxY.size();++i) {
1300 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1302 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1301 else mEventIndicatorBottom->enableColumn(i,false); 1303 else mEventIndicatorBottom->enableColumn(i,false);
1302 } 1304 }
1303 1305
1304 mEventIndicatorBottom->update(); 1306 mEventIndicatorBottom->update();
1305} 1307}
1306 1308
1307void KOAgendaView::startDrag(Event *event) 1309void KOAgendaView::startDrag(Event *event)
1308{ 1310{
1309#ifndef KORG_NODND 1311#ifndef KORG_NODND
1310 DndFactory factory( calendar() ); 1312 DndFactory factory( calendar() );
1311 ICalDrag *vd = factory.createDrag(event,this); 1313 ICalDrag *vd = factory.createDrag(event,this);
1312 if (vd->drag()) { 1314 if (vd->drag()) {
1313 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1315 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1314 } 1316 }
1315#endif 1317#endif
1316} 1318}
1317 1319
1318void KOAgendaView::readSettings() 1320void KOAgendaView::readSettings()
1319{ 1321{
1320 readSettings(KOGlobals::config()); 1322 readSettings(KOGlobals::config());
1321} 1323}
1322 1324
1323void KOAgendaView::readSettings(KConfig *config) 1325void KOAgendaView::readSettings(KConfig *config)
1324{ 1326{
1325 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1327 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1326 1328
1327 config->setGroup("Views"); 1329 config->setGroup("Views");
1328 1330
1329 //#ifndef KORG_NOSPLITTER 1331 //#ifndef KORG_NOSPLITTER
1330 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1332 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1331 if (sizes.count() == 2) { 1333 if (sizes.count() == 2) {
1332 if ( sizes[0] < 20 ) { 1334 if ( sizes[0] < 20 ) {
1333 sizes[1] = sizes[1] +20 - sizes[0]; 1335 sizes[1] = sizes[1] +20 - sizes[0];
1334 sizes[0] = 20; 1336 sizes[0] = 20;
1335 } 1337 }
1336 mSplitterAgenda->setSizes(sizes); 1338 mSplitterAgenda->setSizes(sizes);
1337 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1339 // qDebug("read %d %d ",sizes[0],sizes[1] );
1338 } 1340 }
1339 //#endif 1341 //#endif
1340 1342
1341 // updateConfig(); 1343 // updateConfig();
1342} 1344}
1343 1345
1344void KOAgendaView::writeSettings(KConfig *config) 1346void KOAgendaView::writeSettings(KConfig *config)
1345{ 1347{
1346 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1348 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1347 1349
1348 config->setGroup("Views"); 1350 config->setGroup("Views");
1349 1351
1350 //#ifndef KORG_NOSPLITTER 1352 //#ifndef KORG_NOSPLITTER
1351 QValueList<int> list = mSplitterAgenda->sizes(); 1353 QValueList<int> list = mSplitterAgenda->sizes();
1352 config->writeEntry("Separator AgendaView",list); 1354 config->writeEntry("Separator AgendaView",list);
1353 //qDebug("write %d %d ", list[0],list[1] ); 1355 //qDebug("write %d %d ", list[0],list[1] );
1354 //#endif 1356 //#endif
1355} 1357}
1356 1358
1357void KOAgendaView::setHolidayMasks() 1359void KOAgendaView::setHolidayMasks()
1358{ 1360{
1359 mHolidayMask.resize(mSelectedDates.count()); 1361 mHolidayMask.resize(mSelectedDates.count());
1360 1362
1361 uint i; 1363 uint i;
1362 for(i=0;i<mSelectedDates.count();++i) { 1364 for(i=0;i<mSelectedDates.count();++i) {
1363 QDate date = mSelectedDates[i]; 1365 QDate date = mSelectedDates[i];
1364 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1366 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1365 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1367 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1366 bool showHoliday = false; 1368 bool showHoliday = false;
1367 if ( KOPrefs::instance()->mExcludeHolidays ) { 1369 if ( KOPrefs::instance()->mExcludeHolidays ) {
1368 QPtrList<Event> events = calendar()->events( date, true ); 1370 QPtrList<Event> events = calendar()->events( date, true );
1369 Event *event; 1371 Event *event;
1370 for( event = events.first(); event; event = events.next() ) { 1372 for( event = events.first(); event; event = events.next() ) {
1371 if ( event->categories().contains("Holiday") || 1373 if ( event->categories().contains("Holiday") ||
1372 event->categories().contains(i18n("Holiday"))) { 1374 event->categories().contains(i18n("Holiday"))) {
1373 showHoliday = true; 1375 showHoliday = true;
1374 break; 1376 break;
1375 } 1377 }
1376 } 1378 }
1377 1379
1378 } 1380 }
1379 1381
1380#ifndef KORG_NOPLUGINS 1382#ifndef KORG_NOPLUGINS
1381 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1383 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1382 !KOCore::self()->holiday(date).isEmpty(); 1384 !KOCore::self()->holiday(date).isEmpty();
1383#endif 1385#endif
1384 bool showDay = showSaturday || showSunday || showHoliday; 1386 bool showDay = showSaturday || showSunday || showHoliday;
1385 1387
1386 if (showDay) { 1388 if (showDay) {
1387 mHolidayMask.at(i) = true; 1389 mHolidayMask.at(i) = true;
1388 } else { 1390 } else {
1389 mHolidayMask.at(i) = false; 1391 mHolidayMask.at(i) = false;
1390 } 1392 }
1391 } 1393 }
1392 1394
1393 mAgenda->setHolidayMask(&mHolidayMask); 1395 mAgenda->setHolidayMask(&mHolidayMask);
1394 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1396 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1395} 1397}
1396 1398
1397void KOAgendaView::setContentsPos(int y) 1399void KOAgendaView::setContentsPos(int y)
1398{ 1400{
1399 mAgenda->setContentsPos(0,y); 1401 mAgenda->setContentsPos(0,y);
1400} 1402}
1401 1403
1402void KOAgendaView::setExpandedButton( bool expanded ) 1404void KOAgendaView::setExpandedButton( bool expanded )
1403{ 1405{
1404 if ( expanded ) { 1406 if ( expanded ) {
1405 mExpandButton->setPixmap( mExpandedPixmap ); 1407 mExpandButton->setPixmap( mExpandedPixmap );
1406 } else { 1408 } else {
1407 mExpandButton->setPixmap( mNotExpandedPixmap ); 1409 mExpandButton->setPixmap( mNotExpandedPixmap );
1408 } 1410 }
1409} 1411}
1410 1412
1411void KOAgendaView::clearSelection() 1413void KOAgendaView::clearSelection()
1412{ 1414{
1413 mAgenda->deselectItem(); 1415 mAgenda->deselectItem();
1414 mAllDayAgenda->deselectItem(); 1416 mAllDayAgenda->deselectItem();
1415} 1417}
1416 1418
1417void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1419void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1418 int gxEnd, int gyEnd) 1420 int gxEnd, int gyEnd)
1419{ 1421{
1420 mTimeSpanInAllDay = true; 1422 mTimeSpanInAllDay = true;
1421 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1423 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1422} 1424}
1423 1425
1424 1426
1425 1427
1426 1428
1427void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1429void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1428 int gxEnd, int gyEnd) 1430 int gxEnd, int gyEnd)
1429{ 1431{
1430 if (!mSelectedDates.count()) return; 1432 if (!mSelectedDates.count()) return;
1431 1433
1432 QDate dayStart = mSelectedDates[gxStart]; 1434 QDate dayStart = mSelectedDates[gxStart];
1433 QDate dayEnd = mSelectedDates[gxEnd]; 1435 QDate dayEnd = mSelectedDates[gxEnd];
1434 1436
1435 QTime timeStart = mAgenda->gyToTime(gyStart); 1437 QTime timeStart = mAgenda->gyToTime(gyStart);
1436 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1438 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1437 1439
1438 QDateTime dtStart(dayStart,timeStart); 1440 QDateTime dtStart(dayStart,timeStart);
1439 QDateTime dtEnd(dayEnd,timeEnd); 1441 QDateTime dtEnd(dayEnd,timeEnd);
1440 1442
1441 mTimeSpanBegin = dtStart; 1443 mTimeSpanBegin = dtStart;
1442 mTimeSpanEnd = dtEnd; 1444 mTimeSpanEnd = dtEnd;
1443 1445
1444} 1446}
1445 1447
1446void KOAgendaView::deleteSelectedDateTime() 1448void KOAgendaView::deleteSelectedDateTime()
1447{ 1449{
1448 mTimeSpanBegin.setDate(QDate()); 1450 mTimeSpanBegin.setDate(QDate());
1449 mTimeSpanEnd.setDate(QDate()); 1451 mTimeSpanEnd.setDate(QDate());
1450 mTimeSpanInAllDay = false; 1452 mTimeSpanInAllDay = false;
1451} 1453}
1452 1454
1453void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1455void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1454{ 1456{
1455 e->ignore(); 1457 e->ignore();
1456} 1458}
1457 1459
1458void KOAgendaView::scrollOneHourUp() 1460void KOAgendaView::scrollOneHourUp()
1459{ 1461{
1460 1462
1461 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1463 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1462} 1464}
1463void KOAgendaView::scrollOneHourDown() 1465void KOAgendaView::scrollOneHourDown()
1464{ 1466{
1465 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1467 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1466} 1468}
1467 1469
1468void KOAgendaView::setStartHour( int h ) 1470void KOAgendaView::setStartHour( int h )
1469{ 1471{
1470 mAgenda->setStartHour( h ); 1472 mAgenda->setStartHour( h );
1471 1473
1472} 1474}
1473 1475
1474void KOAgendaView::updateTodo( Todo * t, int ) 1476void KOAgendaView::updateTodo( Todo * t, int )
1475{ 1477{
1476 1478
1477 bool remove = false; 1479 bool remove = false;
1478 bool removeAD = false; 1480 bool removeAD = false;
1479 if ( ! t->hasDueDate() ) { 1481 if ( ! t->hasDueDate() ) {
1480 remove = true; 1482 remove = true;
1481 removeAD = true; 1483 removeAD = true;
1482 } 1484 }
1483 else { 1485 else {
1484 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1486 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1485 if ( overdue && 1487 if ( overdue &&
1486 QDate::currentDate() >= mSelectedDates.first() && 1488 QDate::currentDate() >= mSelectedDates.first() &&
1487 QDate::currentDate() <= mSelectedDates.last()) { 1489 QDate::currentDate() <= mSelectedDates.last()) {
1488 removeAD = false; 1490 removeAD = false;
1489 remove = true; 1491 remove = true;
1490 } 1492 }
1491 else { 1493 else {
1492 if ( t->dtDue().date() < mSelectedDates.first() || 1494 if ( t->dtDue().date() < mSelectedDates.first() ||
1493 t->dtDue().date() > mSelectedDates.last() ) { 1495 t->dtDue().date() > mSelectedDates.last() ) {
1494 remove = true; 1496 remove = true;
1495 removeAD = true; 1497 removeAD = true;
1496 } else { 1498 } else {
1497 remove = t->doesFloat(); 1499 remove = t->doesFloat();
1498 removeAD = !remove; 1500 removeAD = !remove;
1499 } 1501 }
1500 } 1502 }
1501 } 1503 }
1502 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1504 int days = mSelectedDates.first().daysTo( t->dtDue().date() );
1503 // qDebug("daysto %d ", days ); 1505 // qDebug("daysto %d ", days );
1504 mAgenda->updateTodo( t , days, remove); 1506 mAgenda->updateTodo( t , days, remove);
1505 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1507 if ( KOPrefs::instance()->mShowTodoInAgenda )
1506 mAllDayAgenda->updateTodo( t , days, removeAD); 1508 mAllDayAgenda->updateTodo( t , days, removeAD);
1507 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1509 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1508 1510
1509} 1511}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 221b0ea..3cf938f 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,257 +1,258 @@
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 <qlayout.h> 28#include <qlayout.h>
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30#include <qksplitter.h> 30#include <qksplitter.h>
31#else 31#else
32#include <qsplitter.h> 32#include <qsplitter.h>
33#endif 33#endif
34#include <qmemarray.h> 34#include <qmemarray.h>
35 35
36#include "koeventview.h" 36#include "koeventview.h"
37 37
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;
48class TimeLabels : public QScrollView { 48class TimeLabels : public QScrollView {
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
52 52
53 void setCellHeight(int height); 53 void setCellHeight(int height);
54 54
55 /** Calculates the minimum width */ 55 /** Calculates the minimum width */
56 virtual int minimumWidth() const; 56 virtual int minimumWidth() const;
57 57
58 /** updates widget's internal state */ 58 /** updates widget's internal state */
59 void updateConfig(); 59 void updateConfig();
60 60
61 /** */ 61 /** */
62 void setAgenda(KOAgenda* agenda); 62 void setAgenda(KOAgenda* agenda);
63 63
64 /** */ 64 /** */
65 virtual void paintEvent(QPaintEvent* e); 65 virtual void paintEvent(QPaintEvent* e);
66 void contentsMousePressEvent ( QMouseEvent * ) ; 66 void contentsMousePressEvent ( QMouseEvent * ) ;
67 void contentsMouseReleaseEvent ( QMouseEvent * ); 67 void contentsMouseReleaseEvent ( QMouseEvent * );
68 void contentsMouseMoveEvent ( QMouseEvent * ); 68 void contentsMouseMoveEvent ( QMouseEvent * );
69 69
70 public slots: 70 public slots:
71 /** update time label positions */ 71 /** update time label positions */
72 void positionChanged(); 72 void positionChanged();
73 signals: 73 signals:
74 void scaleChanged(); 74 void scaleChanged();
75 protected: 75 protected:
76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
77 77
78 private: 78 private:
79 int mMouseDownY; 79 int mMouseDownY;
80 QString mOrgCap;
80 int mRows; 81 int mRows;
81 int mCellHeight; 82 int mCellHeight;
82 83
83 /** */ 84 /** */
84 KOAgenda* mAgenda; 85 KOAgenda* mAgenda;
85}; 86};
86 87
87class EventIndicator : public QFrame { 88class EventIndicator : public QFrame {
88 Q_OBJECT 89 Q_OBJECT
89 public: 90 public:
90 enum Location { Top, Bottom }; 91 enum Location { Top, Bottom };
91 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 92 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
92 virtual ~EventIndicator(); 93 virtual ~EventIndicator();
93 94
94 void changeColumns(int columns); 95 void changeColumns(int columns);
95 void setPaintWidget( KDGanttMinimizeSplitter* ); 96 void setPaintWidget( KDGanttMinimizeSplitter* );
96 void setXOffset( int ); 97 void setXOffset( int );
97 void enableColumn(int column, bool enable); 98 void enableColumn(int column, bool enable);
98 99
99 protected: 100 protected:
100 void drawContents(QPainter *); 101 void drawContents(QPainter *);
101 102
102 private: 103 private:
103 int mXOffset; 104 int mXOffset;
104 KDGanttMinimizeSplitter* mPaintWidget; 105 KDGanttMinimizeSplitter* mPaintWidget;
105 int mColumns; 106 int mColumns;
106 QHBox *mTopBox; 107 QHBox *mTopBox;
107 QBoxLayout *mTopLayout; 108 QBoxLayout *mTopLayout;
108 Location mLocation; 109 Location mLocation;
109 QPixmap mPixmap; 110 QPixmap mPixmap;
110 QMemArray<bool> mEnabled; 111 QMemArray<bool> mEnabled;
111}; 112};
112 113
113/** 114/**
114 KOAgendaView is the agenda-like view used to display events in an one or 115 KOAgendaView is the agenda-like view used to display events in an one or
115 multi-day view. 116 multi-day view.
116*/ 117*/
117class KOAgendaView : public KOEventView { 118class KOAgendaView : public KOEventView {
118 Q_OBJECT 119 Q_OBJECT
119 public: 120 public:
120 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
121 virtual ~KOAgendaView(); 122 virtual ~KOAgendaView();
122 void setStartHour( int ); 123 void setStartHour( int );
123 void toggleAllDay(); 124 void toggleAllDay();
124 125
125 126
126 /** Returns maximum number of days supported by the koagendaview */ 127 /** Returns maximum number of days supported by the koagendaview */
127 virtual int maxDatesHint(); 128 virtual int maxDatesHint();
128 129
129 /** Returns number of currently shown dates. */ 130 /** Returns number of currently shown dates. */
130 virtual int currentDateCount(); 131 virtual int currentDateCount();
131 132
132 /** returns the currently selected events */ 133 /** returns the currently selected events */
133 virtual QPtrList<Incidence> selectedIncidences(); 134 virtual QPtrList<Incidence> selectedIncidences();
134 135
135 /** returns the currently selected events */ 136 /** returns the currently selected events */
136 virtual DateList selectedDates(); 137 virtual DateList selectedDates();
137 138
138 /** Remove all events from view */ 139 /** Remove all events from view */
139 void clearView(); 140 void clearView();
140 KOAgenda *agenda() { return mAgenda;} 141 KOAgenda *agenda() { return mAgenda;}
141 virtual void printPreview(CalPrinter *calPrinter, 142 virtual void printPreview(CalPrinter *calPrinter,
142 const QDate &, const QDate &); 143 const QDate &, const QDate &);
143 144
144 /** start-datetime of selection */ 145 /** start-datetime of selection */
145 QDateTime selectionStart() {return mTimeSpanBegin;} 146 QDateTime selectionStart() {return mTimeSpanBegin;}
146 /** end-datetime of selection */ 147 /** end-datetime of selection */
147 QDateTime selectionEnd() {return mTimeSpanEnd;} 148 QDateTime selectionEnd() {return mTimeSpanEnd;}
148 /** returns true if selection is for whole day */ 149 /** returns true if selection is for whole day */
149 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 150 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
150 /** make selected start/end invalid */ 151 /** make selected start/end invalid */
151 void deleteSelectedDateTime(); 152 void deleteSelectedDateTime();
152 void repaintAgenda(); 153 void repaintAgenda();
153 public slots: 154 public slots:
154 virtual void updateView(); 155 virtual void updateView();
155 virtual void updateConfig(); 156 virtual void updateConfig();
156 virtual void showDates(const QDate &start, const QDate &end); 157 virtual void showDates(const QDate &start, const QDate &end);
157 virtual void showEvents(QPtrList<Event> eventList); 158 virtual void showEvents(QPtrList<Event> eventList);
158 159
159 void updateTodo( Todo *, int ); 160 void updateTodo( Todo *, int );
160 void changeEventDisplay(Event *, int); 161 void changeEventDisplay(Event *, int);
161 162
162 void clearSelection(); 163 void clearSelection();
163 164
164 void newEvent(int gx,int gy); 165 void newEvent(int gx,int gy);
165 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 166 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
166 void newEventAllDay(int gx, int gy); 167 void newEventAllDay(int gx, int gy);
167 168
168 void startDrag(Event *); 169 void startDrag(Event *);
169 170
170 void readSettings(); 171 void readSettings();
171 void readSettings(KConfig *); 172 void readSettings(KConfig *);
172 void writeSettings(KConfig *); 173 void writeSettings(KConfig *);
173 174
174 void setContentsPos(int y); 175 void setContentsPos(int y);
175 176
176 void setExpandedButton( bool expanded ); 177 void setExpandedButton( bool expanded );
177 void scrollOneHourUp(); 178 void scrollOneHourUp();
178 void scrollOneHourDown(); 179 void scrollOneHourDown();
179 void addToCalSlot(Incidence *, Incidence *); 180 void addToCalSlot(Incidence *, Incidence *);
180 181
181 signals: 182 signals:
182 void toggleExpand(); 183 void toggleExpand();
183 void todoMoved( Todo *, int ); 184 void todoMoved( Todo *, int );
184 void incidenceChanged(Incidence * , int ); 185 void incidenceChanged(Incidence * , int );
185 // void cloneIncidenceSignal(Incidence *); 186 // void cloneIncidenceSignal(Incidence *);
186 187
187 protected: 188 protected:
188 bool mBlockUpdating; 189 bool mBlockUpdating;
189 int mUpcomingWidth; 190 int mUpcomingWidth;
190 /** Fill agenda beginning with date startDate */ 191 /** Fill agenda beginning with date startDate */
191 void fillAgenda(const QDate &startDate); 192 void fillAgenda(const QDate &startDate);
192 void resizeEvent( QResizeEvent* e ); 193 void resizeEvent( QResizeEvent* e );
193 /** Fill agenda using the current set value for the start date */ 194 /** Fill agenda using the current set value for the start date */
194 void fillAgenda(); 195 void fillAgenda();
195 196
196 /** Create labels for the selected dates. */ 197 /** Create labels for the selected dates. */
197 void createDayLabels(); 198 void createDayLabels();
198 199
199 /** 200 /**
200 Set the masks on the agenda widgets indicating, which days are holidays. 201 Set the masks on the agenda widgets indicating, which days are holidays.
201 */ 202 */
202 void setHolidayMasks(); 203 void setHolidayMasks();
203 204
204 protected slots: 205 protected slots:
205 /** Update event belonging to agenda item */ 206 /** Update event belonging to agenda item */
206 void updateEventDates(KOAgendaItem *item, int mode = -1); 207 void updateEventDates(KOAgendaItem *item, int mode = -1);
207 //void updateMovedTodo(); 208 //void updateMovedTodo();
208 209
209 void updateEventIndicatorTop(int newY); 210 void updateEventIndicatorTop(int newY);
210 void updateEventIndicatorBottom(int newY); 211 void updateEventIndicatorBottom(int newY);
211 212
212 /** Updates data for selected timespan */ 213 /** Updates data for selected timespan */
213 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 214 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
214 /** Updates data for selected timespan for all day event*/ 215 /** Updates data for selected timespan for all day event*/
215 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 216 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
216 217
217 private: 218 private:
218 // view widgets 219 // view widgets
219 QFrame *mDayLabels; 220 QFrame *mDayLabels;
220 QHBox *mDayLabelsFrame; 221 QHBox *mDayLabelsFrame;
221 QBoxLayout *mLayoutDayLabels; 222 QBoxLayout *mLayoutDayLabels;
222 QFrame *mAllDayFrame; 223 QFrame *mAllDayFrame;
223 KOAgenda *mAllDayAgenda; 224 KOAgenda *mAllDayAgenda;
224 KOAgenda *mAgenda; 225 KOAgenda *mAgenda;
225 TimeLabels *mTimeLabels; 226 TimeLabels *mTimeLabels;
226 QWidget *mDummyAllDayLeft; 227 QWidget *mDummyAllDayLeft;
227 228
228 KDGanttMinimizeSplitter* mSplitterAgenda; 229 KDGanttMinimizeSplitter* mSplitterAgenda;
229 QPushButton *mExpandButton; 230 QPushButton *mExpandButton;
230 231
231 DateList mSelectedDates; // List of dates to be displayed 232 DateList mSelectedDates; // List of dates to be displayed
232 int mViewType; 233 int mViewType;
233 234
234 bool mWeekStartsMonday; 235 bool mWeekStartsMonday;
235 int mStartHour; 236 int mStartHour;
236 237
237 KOEventPopupMenu *mAgendaPopup; 238 KOEventPopupMenu *mAgendaPopup;
238 KOEventPopupMenu *mAllDayAgendaPopup; 239 KOEventPopupMenu *mAllDayAgendaPopup;
239 240
240 EventIndicator *mEventIndicatorTop; 241 EventIndicator *mEventIndicatorTop;
241 EventIndicator *mEventIndicatorBottom; 242 EventIndicator *mEventIndicatorBottom;
242 243
243 QMemArray<int> mMinY; 244 QMemArray<int> mMinY;
244 QMemArray<int> mMaxY; 245 QMemArray<int> mMaxY;
245 246
246 QMemArray<bool> mHolidayMask; 247 QMemArray<bool> mHolidayMask;
247 248
248 QPixmap mExpandedPixmap; 249 QPixmap mExpandedPixmap;
249 QPixmap mNotExpandedPixmap; 250 QPixmap mNotExpandedPixmap;
250 QPtrList<QLabel> mDayLabelsList; 251 QPtrList<QLabel> mDayLabelsList;
251 QDateTime mTimeSpanBegin; 252 QDateTime mTimeSpanBegin;
252 QDateTime mTimeSpanEnd; 253 QDateTime mTimeSpanEnd;
253 bool mTimeSpanInAllDay; 254 bool mTimeSpanInAllDay;
254 void keyPressEvent ( QKeyEvent * e ); 255 void keyPressEvent ( QKeyEvent * e );
255}; 256};
256 257
257#endif // KOAGENDAVIEW_H 258#endif // KOAGENDAVIEW_H