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