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