summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp10
-rw-r--r--korganizer/kowhatsnextview.cpp19
-rw-r--r--libkdepim/categoryeditdialog.cpp2
-rw-r--r--libkdepim/categoryselectdialog.cpp8
4 files changed, 28 insertions, 11 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 3aae076..749204b 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1437 +1,1443 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
80 QScrollView(parent,name,f) 80 QScrollView(parent,name,f)
81{ 81{
82 mRows = rows; 82 mRows = rows;
83 83
84 setMinimumHeight( 20 ); 84 setMinimumHeight( 20 );
85 mCellHeight = KOPrefs::instance()->mHourSize*4; 85 mCellHeight = KOPrefs::instance()->mHourSize*4;
86 86
87 enableClipper(true); 87 enableClipper(true);
88 88
89 setHScrollBarMode(AlwaysOff); 89 setHScrollBarMode(AlwaysOff);
90 setVScrollBarMode(AlwaysOff); 90 setVScrollBarMode(AlwaysOff);
91 91
92 resizeContents(50,mRows * mCellHeight); 92 resizeContents(50,mRows * mCellHeight);
93 93
94 viewport()->setBackgroundMode( PaletteBackground ); 94 viewport()->setBackgroundMode( PaletteBackground );
95} 95}
96 96
97void TimeLabels::setCellHeight(int height) 97void TimeLabels::setCellHeight(int height)
98{ 98{
99 mCellHeight = height; 99 mCellHeight = height;
100} 100}
101 101
102/* 102/*
103 Optimization so that only the "dirty" portion of the scroll view 103 Optimization so that only the "dirty" portion of the scroll view
104 is redrawn. Unfortunately, this is not called by default paintEvent() method. 104 is redrawn. Unfortunately, this is not called by default paintEvent() method.
105*/ 105*/
106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
107{ 107{
108 108
109 // if ( globalFlagBlockAgenda ) 109 // if ( globalFlagBlockAgenda )
110 // return; 110 // return;
111 // bug: the parameters cx, cy, cw, ch are the areas that need to be 111 // bug: the parameters cx, cy, cw, ch are the areas that need to be
112 // redrawn, not the area of the widget. unfortunately, this 112 // redrawn, not the area of the widget. unfortunately, this
113 // code assumes the latter... 113 // code assumes the latter...
114 114
115 // now, for a workaround... 115 // now, for a workaround...
116 // these two assignments fix the weird redraw bug 116 // these two assignments fix the weird redraw bug
117 cx = contentsX() + 2; 117 cx = contentsX() + 2;
118 cw = contentsWidth() - 2; 118 cw = contentsWidth() - 2;
119 // end of workaround 119 // end of workaround
120 120
121 int cell = ((int)(cy/mCellHeight)); 121 int cell = ((int)(cy/mCellHeight));
122 int y = cell * mCellHeight; 122 int y = cell * mCellHeight;
123 QFontMetrics fm = fontMetrics(); 123 QFontMetrics fm = fontMetrics();
124 QString hour; 124 QString hour;
125 QString suffix; 125 QString suffix;
126 QString fullTime; 126 QString fullTime;
127 int tW = fm.width("24:00i"); 127 int tW = fm.width("24:00i");
128 128
129 while (y < cy + ch) { 129 while (y < cy + ch) {
130 p->drawLine(cx,y,cx+tW,y); 130 p->drawLine(cx,y,cx+tW,y);
131 hour.setNum(cell); 131 hour.setNum(cell);
132 suffix = "am"; 132 suffix = "am";
133 133
134 // handle 24h and am/pm time formats 134 // handle 24h and am/pm time formats
135 if (KGlobal::locale()->use12Clock()) { 135 if (KGlobal::locale()->use12Clock()) {
136 if (cell > 11) suffix = "pm"; 136 if (cell > 11) suffix = "pm";
137 if (cell == 0) hour.setNum(12); 137 if (cell == 0) hour.setNum(12);
138 if (cell > 12) hour.setNum(cell - 12); 138 if (cell > 12) hour.setNum(cell - 12);
139 } else { 139 } else {
140 suffix = ":00"; 140 suffix = ":00";
141 } 141 }
142 142
143 // create string in format of "XX:XX" or "XXpm/am" 143 // create string in format of "XX:XX" or "XXpm/am"
144 fullTime = hour + suffix; 144 fullTime = hour + suffix;
145 145
146 // center and draw the time label 146 // center and draw the time label
147 int timeWidth = fm.width(fullTime+"i"); 147 int timeWidth = fm.width(fullTime+"i");
148 int offset = this->width() - timeWidth; 148 int offset = this->width() - timeWidth;
149 int borderWidth = 5; 149 int borderWidth = 5;
150 int timeHeight = fm.height(); 150 int timeHeight = fm.height();
151 timeHeight = timeHeight + 2 - ( timeHeight / 4 ); 151 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); 152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
153 153
154 // increment indices 154 // increment indices
155 y += mCellHeight; 155 y += mCellHeight;
156 cell++; 156 cell++;
157 } 157 }
158} 158}
159 159
160/** 160/**
161 Calculates the minimum width. 161 Calculates the minimum width.
162*/ 162*/
163int TimeLabels::minimumWidth() const 163int TimeLabels::minimumWidth() const
164{ 164{
165 QFontMetrics fm = fontMetrics(); 165 QFontMetrics fm = fontMetrics();
166 166
167 //TODO: calculate this value 167 //TODO: calculate this value
168 int borderWidth = 4; 168 int borderWidth = 4;
169 169
170 // the maximum width possible 170 // the maximum width possible
171 int width = fm.width("88:88x") + borderWidth; 171 int width = fm.width("88:88x") + borderWidth;
172 172
173 return width; 173 return width;
174} 174}
175 175
176/** updates widget's internal state */ 176/** updates widget's internal state */
177void TimeLabels::updateConfig() 177void TimeLabels::updateConfig()
178{ 178{
179 // set the font 179 // set the font
180 // config->setGroup("Fonts"); 180 // config->setGroup("Fonts");
181 // QFont font = config->readFontEntry("TimeBar Font"); 181 // QFont font = config->readFontEntry("TimeBar Font");
182 setFont(KOPrefs::instance()->mTimeBarFont); 182 setFont(KOPrefs::instance()->mTimeBarFont);
183 183
184 // update geometry restrictions based on new settings 184 // update geometry restrictions based on new settings
185 setFixedWidth(minimumWidth()); 185 setFixedWidth(minimumWidth());
186 186
187 // update HourSize 187 // update HourSize
188 mCellHeight = KOPrefs::instance()->mHourSize*4; 188 mCellHeight = KOPrefs::instance()->mHourSize*4;
189 resizeContents(50,mRows * mCellHeight); 189 resizeContents(50,mRows * mCellHeight);
190} 190}
191 191
192/** update time label positions */ 192/** update time label positions */
193void TimeLabels::positionChanged() 193void TimeLabels::positionChanged()
194{ 194{
195 int adjustment = mAgenda->contentsY(); 195 int adjustment = mAgenda->contentsY();
196 setContentsPos(0, adjustment); 196 setContentsPos(0, adjustment);
197} 197}
198 198
199/** */ 199/** */
200void TimeLabels::setAgenda(KOAgenda* agenda) 200void TimeLabels::setAgenda(KOAgenda* agenda)
201{ 201{
202 mAgenda = agenda; 202 mAgenda = agenda;
203} 203}
204 204
205 205
206/** This is called in response to repaint() */ 206/** This is called in response to repaint() */
207void TimeLabels::paintEvent(QPaintEvent*) 207void TimeLabels::paintEvent(QPaintEvent*)
208{ 208{
209 209
210 // kdDebug() << "paintevent..." << endl; 210 // kdDebug() << "paintevent..." << endl;
211 // this is another hack! 211 // this is another hack!
212 // QPainter painter(this); 212 // QPainter painter(this);
213 //QString c 213 //QString c
214 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 214 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
215} 215}
216 216
217//////////////////////////////////////////////////////////////////////////// 217////////////////////////////////////////////////////////////////////////////
218 218
219EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 219EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
220 : QFrame(parent,name) 220 : QFrame(parent,name)
221{ 221{
222 mColumns = 1; 222 mColumns = 1;
223 mTopBox = 0; 223 mTopBox = 0;
224 mLocation = loc; 224 mLocation = loc;
225 mTopLayout = 0; 225 mTopLayout = 0;
226 mPaintWidget = 0; 226 mPaintWidget = 0;
227 mXOffset = 0; 227 mXOffset = 0;
228 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 228 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
229 else mPixmap = SmallIcon("1downarrow"); 229 else mPixmap = SmallIcon("1downarrow");
230 mEnabled.resize(mColumns); 230 mEnabled.resize(mColumns);
231 if (mLocation == Top) 231 if (mLocation == Top)
232 setMaximumHeight(0); 232 setMaximumHeight(0);
233 else 233 else
234 setMinimumHeight(mPixmap.height()); 234 setMinimumHeight(mPixmap.height());
235} 235}
236 236
237EventIndicator::~EventIndicator() 237EventIndicator::~EventIndicator()
238{ 238{
239} 239}
240 240
241void EventIndicator::drawContents(QPainter *p) 241void EventIndicator::drawContents(QPainter *p)
242{ 242{
243 243
244 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 244 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
245 KDGanttSplitterHandle* han = 0; 245 KDGanttSplitterHandle* han = 0;
246 if ( mPaintWidget ) 246 if ( mPaintWidget )
247 han = mPaintWidget->firstHandle(); 247 han = mPaintWidget->firstHandle();
248 if ( ! han ) { 248 if ( ! han ) {
249 int i; 249 int i;
250 for(i=0;i<mColumns;++i) { 250 for(i=0;i<mColumns;++i) {
251 if (mEnabled[i]) { 251 if (mEnabled[i]) {
252 int cellWidth = contentsRect().right()/mColumns; 252 int cellWidth = contentsRect().right()/mColumns;
253 int xOffset = KOGlobals::self()->reverseLayout() ? 253 int xOffset = KOGlobals::self()->reverseLayout() ?
254 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 254 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
255 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 255 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
256 p->drawPixmap(QPoint(xOffset,0),mPixmap); 256 p->drawPixmap(QPoint(xOffset,0),mPixmap);
257 } 257 }
258 } 258 }
259 } else { 259 } else {
260 han->repaint(); 260 han->repaint();
261 //mPaintWidget->setBackgroundColor( red ); 261 //mPaintWidget->setBackgroundColor( red );
262 262
263 QPainter pa( han ); 263 QPainter pa( han );
264 int i; 264 int i;
265 bool setColor = false; 265 bool setColor = false;
266 for(i=0;i<mColumns;++i) { 266 for(i=0;i<mColumns;++i) {
267 if (mEnabled[i]) { 267 if (mEnabled[i]) {
268 setColor = true; 268 setColor = true;
269 269
270 int cellWidth = contentsRect().right()/mColumns; 270 int cellWidth = contentsRect().right()/mColumns;
271 int xOffset = KOGlobals::self()->reverseLayout() ? 271 int xOffset = KOGlobals::self()->reverseLayout() ?
272 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 272 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
273 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 273 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
274 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 274 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
275 //qDebug("222draw pix %d ",xOffset ); 275 //qDebug("222draw pix %d ",xOffset );
276 276
277 } 277 }
278 278
279 } 279 }
280 pa.end(); 280 pa.end();
281 281
282 } 282 }
283} 283}
284 284
285void EventIndicator::setXOffset( int x ) 285void EventIndicator::setXOffset( int x )
286{ 286{
287 mXOffset = x; 287 mXOffset = x;
288} 288}
289void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 289void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
290{ 290{
291 mPaintWidget = w; 291 mPaintWidget = w;
292} 292}
293void EventIndicator::changeColumns(int columns) 293void EventIndicator::changeColumns(int columns)
294{ 294{
295 mColumns = columns; 295 mColumns = columns;
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 297
298 update(); 298 update();
299} 299}
300 300
301void EventIndicator::enableColumn(int column, bool enable) 301void EventIndicator::enableColumn(int column, bool enable)
302{ 302{
303 mEnabled[column] = enable; 303 mEnabled[column] = enable;
304} 304}
305 305
306 306
307//////////////////////////////////////////////////////////////////////////// 307////////////////////////////////////////////////////////////////////////////
308//////////////////////////////////////////////////////////////////////////// 308////////////////////////////////////////////////////////////////////////////
309//////////////////////////////////////////////////////////////////////////// 309////////////////////////////////////////////////////////////////////////////
310 310
311KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 311KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
312 KOEventView (cal,parent,name) 312 KOEventView (cal,parent,name)
313{ 313{
314 mBlockUpdating = true; 314 mBlockUpdating = true;
315 mStartHour = 8; 315 mStartHour = 8;
316 mSelectedDates.append(QDate::currentDate()); 316 mSelectedDates.append(QDate::currentDate());
317 317
318 mLayoutDayLabels = 0; 318 mLayoutDayLabels = 0;
319 mDayLabelsFrame = 0; 319 mDayLabelsFrame = 0;
320 mDayLabels = 0; 320 mDayLabels = 0;
321 bool isRTL = KOGlobals::self()->reverseLayout(); 321 bool isRTL = KOGlobals::self()->reverseLayout();
322 322
323 if ( KOPrefs::instance()->mVerticalScreen ) { 323 if ( KOPrefs::instance()->mVerticalScreen ) {
324 mExpandedPixmap = SmallIcon( "1downarrow" ); 324 mExpandedPixmap = SmallIcon( "1downarrow" );
325 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 325 mNotExpandedPixmap = SmallIcon( "1uparrow" );
326 } else { 326 } else {
327 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 327 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
328 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 328 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
329 } 329 }
330 330
331 QBoxLayout *topLayout = new QVBoxLayout(this); 331 QBoxLayout *topLayout = new QVBoxLayout(this);
332 332
333 // Create day name labels for agenda columns 333 // Create day name labels for agenda columns
334 mDayLabelsFrame = new QHBox(this); 334 mDayLabelsFrame = new QHBox(this);
335 topLayout->addWidget(mDayLabelsFrame); 335 topLayout->addWidget(mDayLabelsFrame);
336 mDayLabels = new QFrame (mDayLabelsFrame); 336 mDayLabels = new QFrame (mDayLabelsFrame);
337 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 337 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
338 // Create agenda splitter 338 // Create agenda splitter
339#ifndef KORG_NOSPLITTER 339#ifndef KORG_NOSPLITTER
340 mSplitterAgenda = new QSplitter(Vertical,this); 340 mSplitterAgenda = new QSplitter(Vertical,this);
341 topLayout->addWidget(mSplitterAgenda); 341 topLayout->addWidget(mSplitterAgenda);
342 mSplitterAgenda->setOpaqueResize(); 342 mSplitterAgenda->setOpaqueResize();
343 343
344 mAllDayFrame = new QHBox(mSplitterAgenda); 344 mAllDayFrame = new QHBox(mSplitterAgenda);
345 345
346 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 346 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
347#else 347#else
348#if 0 348#if 0
349 QWidget *mainBox = new QWidget( this ); 349 QWidget *mainBox = new QWidget( this );
350 topLayout->addWidget( mainBox ); 350 topLayout->addWidget( mainBox );
351 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 351 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
352 mAllDayFrame = new QHBox(mainBox); 352 mAllDayFrame = new QHBox(mainBox);
353 mainLayout->addWidget(mAllDayFrame); 353 mainLayout->addWidget(mAllDayFrame);
354 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 354 mainLayout->setStretchFactor( mAllDayFrame, 0 );
355 mAllDayFrame->setFocusPolicy(NoFocus); 355 mAllDayFrame->setFocusPolicy(NoFocus);
356 QWidget *agendaFrame = new QWidget(mainBox); 356 QWidget *agendaFrame = new QWidget(mainBox);
357 mainLayout->addWidget(agendaFrame); 357 mainLayout->addWidget(agendaFrame);
358 mainLayout->setStretchFactor( agendaFrame, 10 ); 358 mainLayout->setStretchFactor( agendaFrame, 10 );
359 359
360 agendaFrame->setFocusPolicy(NoFocus); 360 agendaFrame->setFocusPolicy(NoFocus);
361#endif 361#endif
362 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 362 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
363 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 363 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
364 topLayout->addWidget( mSplitterAgenda ); 364 topLayout->addWidget( mSplitterAgenda );
365 mAllDayFrame = new QHBox(mSplitterAgenda); 365 mAllDayFrame = new QHBox(mSplitterAgenda);
366 mAllDayFrame->setFocusPolicy(NoFocus); 366 mAllDayFrame->setFocusPolicy(NoFocus);
367 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 367 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
368 agendaFrame->setFocusPolicy(NoFocus); 368 agendaFrame->setFocusPolicy(NoFocus);
369 369
370#endif 370#endif
371 371
372 // Create all-day agenda widget 372 // Create all-day agenda widget
373 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 373 mDummyAllDayLeft = new QVBox( mAllDayFrame );
374 374
375 mExpandButton = new QPushButton(mDummyAllDayLeft); 375 mExpandButton = new QPushButton(mDummyAllDayLeft);
376 mExpandButton->setPixmap( mNotExpandedPixmap ); 376 mExpandButton->setPixmap( mNotExpandedPixmap );
377 mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 377 int widebut = mExpandButton->sizeHint().width();
378 QSizePolicy::Fixed ) ); 378 if ( QApplication::desktop()->width() < 480 )
379 widebut = widebut*2;
380 else
381 widebut = (widebut*3) / 2;
382 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
383 // QSizePolicy::Fixed ) );
384 mExpandButton->setFixedSize( widebut, widebut);
379 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 385 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
380 mExpandButton->setFocusPolicy(NoFocus); 386 mExpandButton->setFocusPolicy(NoFocus);
381 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 387 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
382 mAllDayAgenda->setFocusPolicy(NoFocus); 388 mAllDayAgenda->setFocusPolicy(NoFocus);
383 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 389 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
384 390
385 // Create event context menu for all day agenda 391 // Create event context menu for all day agenda
386 mAllDayAgendaPopup = eventPopup(); 392 mAllDayAgendaPopup = eventPopup();
387 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 393 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
388 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 394 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
389 395
390 // Create agenda frame 396 // Create agenda frame
391 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 397 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
392 // QHBox *agendaFrame = new QHBox(splitterAgenda); 398 // QHBox *agendaFrame = new QHBox(splitterAgenda);
393 399
394 // create event indicator bars 400 // create event indicator bars
395 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 401 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
396 agendaLayout->addWidget(mEventIndicatorTop,0,1); 402 agendaLayout->addWidget(mEventIndicatorTop,0,1);
397 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 403 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
398 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 404 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
399 agendaFrame); 405 agendaFrame);
400 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 406 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
401 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 407 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
402 agendaLayout->addWidget(dummyAgendaRight,0,2); 408 agendaLayout->addWidget(dummyAgendaRight,0,2);
403 409
404 // Create time labels 410 // Create time labels
405 mTimeLabels = new TimeLabels(24,agendaFrame); 411 mTimeLabels = new TimeLabels(24,agendaFrame);
406 agendaLayout->addWidget(mTimeLabels,1,0); 412 agendaLayout->addWidget(mTimeLabels,1,0);
407 413
408 // Create agenda 414 // Create agenda
409 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 415 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
410 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 416 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
411 agendaLayout->setColStretch(1,1); 417 agendaLayout->setColStretch(1,1);
412 mAgenda->setFocusPolicy(NoFocus); 418 mAgenda->setFocusPolicy(NoFocus);
413 // Create event context menu for agenda 419 // Create event context menu for agenda
414 mAgendaPopup = eventPopup(); 420 mAgendaPopup = eventPopup();
415 421
416 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 422 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
417 i18n("Toggle Alarm"),mAgenda, 423 i18n("Toggle Alarm"),mAgenda,
418 SLOT(popupAlarm()),true); 424 SLOT(popupAlarm()),true);
419 425
420 426
421 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 427 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
422 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 428 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
423 429
424 // make connections between dependent widgets 430 // make connections between dependent widgets
425 mTimeLabels->setAgenda(mAgenda); 431 mTimeLabels->setAgenda(mAgenda);
426 432
427 // Update widgets to reflect user preferences 433 // Update widgets to reflect user preferences
428 // updateConfig(); 434 // updateConfig();
429 435
430 // createDayLabels(); 436 // createDayLabels();
431 437
432 // these blank widgets make the All Day Event box line up with the agenda 438 // these blank widgets make the All Day Event box line up with the agenda
433 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 439 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
434 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 440 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
435 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 441 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
436 442
437 // Scrolling 443 // Scrolling
438 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 444 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
439 mTimeLabels, SLOT(positionChanged())); 445 mTimeLabels, SLOT(positionChanged()));
440 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 446 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
441 SLOT(setContentsPos(int))); 447 SLOT(setContentsPos(int)));
442 448
443 // Create/Show/Edit/Delete Event 449 // Create/Show/Edit/Delete Event
444 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 450 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
445 SLOT(newEvent(int,int))); 451 SLOT(newEvent(int,int)));
446 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 452 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
447 SLOT(newEvent(int,int,int,int))); 453 SLOT(newEvent(int,int,int,int)));
448 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 454 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
449 SLOT(newEventAllDay(int,int))); 455 SLOT(newEventAllDay(int,int)));
450 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 456 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
451 SLOT(newEventAllDay(int,int))); 457 SLOT(newEventAllDay(int,int)));
452 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 458 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
453 SLOT(newTimeSpanSelected(int,int,int,int))); 459 SLOT(newTimeSpanSelected(int,int,int,int)));
454 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 460 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
455 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 461 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
456 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 462 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
457 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 463 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
458 464
459 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 465 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
460 SIGNAL(editIncidenceSignal(Incidence *))); 466 SIGNAL(editIncidenceSignal(Incidence *)));
461 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 467 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
462 SIGNAL(editIncidenceSignal(Incidence *))); 468 SIGNAL(editIncidenceSignal(Incidence *)));
463 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 469 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
464 SIGNAL(showIncidenceSignal(Incidence *))); 470 SIGNAL(showIncidenceSignal(Incidence *)));
465 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 471 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
466 SIGNAL(showIncidenceSignal(Incidence *))); 472 SIGNAL(showIncidenceSignal(Incidence *)));
467 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 473 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
468 SIGNAL(deleteIncidenceSignal(Incidence *))); 474 SIGNAL(deleteIncidenceSignal(Incidence *)));
469 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
470 SIGNAL(deleteIncidenceSignal(Incidence *))); 476 SIGNAL(deleteIncidenceSignal(Incidence *)));
471 477
472 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 478 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
473 SLOT(updateEventDates(KOAgendaItem *, int ))); 479 SLOT(updateEventDates(KOAgendaItem *, int )));
474 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 480 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
475 SLOT(updateEventDates(KOAgendaItem *, int))); 481 SLOT(updateEventDates(KOAgendaItem *, int)));
476 482
477 // event indicator update 483 // event indicator update
478 connect(mAgenda,SIGNAL(lowerYChanged(int)), 484 connect(mAgenda,SIGNAL(lowerYChanged(int)),
479 SLOT(updateEventIndicatorTop(int))); 485 SLOT(updateEventIndicatorTop(int)));
480 connect(mAgenda,SIGNAL(upperYChanged(int)), 486 connect(mAgenda,SIGNAL(upperYChanged(int)),
481 SLOT(updateEventIndicatorBottom(int))); 487 SLOT(updateEventIndicatorBottom(int)));
482 // drag signals 488 // drag signals
483 /* 489 /*
484 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 490 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
485 SLOT(startDrag(Event *))); 491 SLOT(startDrag(Event *)));
486 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 492 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
487 SLOT(startDrag(Event *))); 493 SLOT(startDrag(Event *)));
488 */ 494 */
489 // synchronize selections 495 // synchronize selections
490 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 496 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
491 mAllDayAgenda, SLOT( deselectItem() ) ); 497 mAllDayAgenda, SLOT( deselectItem() ) );
492 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 498 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
493 mAgenda, SLOT( deselectItem() ) ); 499 mAgenda, SLOT( deselectItem() ) );
494 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 500 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
495 SIGNAL( incidenceSelected( Incidence * ) ) ); 501 SIGNAL( incidenceSelected( Incidence * ) ) );
496 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 502 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
497 SIGNAL( incidenceSelected( Incidence * ) ) ); 503 SIGNAL( incidenceSelected( Incidence * ) ) );
498 connect( mAgenda, SIGNAL( resizedSignal() ), 504 connect( mAgenda, SIGNAL( resizedSignal() ),
499 SLOT( updateConfig( ) ) ); 505 SLOT( updateConfig( ) ) );
500 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 506 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
501 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 507 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
502 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 508 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
503 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 509 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
504 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 510 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
505 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 511 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
506 512
507 513
508} 514}
509 515
510void KOAgendaView::toggleAllDay() 516void KOAgendaView::toggleAllDay()
511{ 517{
512 if ( mSplitterAgenda->firstHandle() ) 518 if ( mSplitterAgenda->firstHandle() )
513 mSplitterAgenda->firstHandle()->toggle(); 519 mSplitterAgenda->firstHandle()->toggle();
514} 520}
515void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 521void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
516{ 522{
517 calendar()->addIncidence( inc ); 523 calendar()->addIncidence( inc );
518 524
519 if ( incOld ) { 525 if ( incOld ) {
520 if ( incOld->type() == "Todo" ) 526 if ( incOld->type() == "Todo" )
521 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 527 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
522 else 528 else
523 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 529 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
524 } 530 }
525 531
526} 532}
527 533
528KOAgendaView::~KOAgendaView() 534KOAgendaView::~KOAgendaView()
529{ 535{
530 delete mAgendaPopup; 536 delete mAgendaPopup;
531 delete mAllDayAgendaPopup; 537 delete mAllDayAgendaPopup;
532 delete KOAgendaItem::paintPix(); 538 delete KOAgendaItem::paintPix();
533 delete KOAgendaItem::paintPixSel(); 539 delete KOAgendaItem::paintPixSel();
534} 540}
535void KOAgendaView::resizeEvent( QResizeEvent* e ) 541void KOAgendaView::resizeEvent( QResizeEvent* e )
536{ 542{
537 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 543 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
538 bool uc = false; 544 bool uc = false;
539 int ow = e->oldSize().width(); 545 int ow = e->oldSize().width();
540 int oh = e->oldSize().height(); 546 int oh = e->oldSize().height();
541 int w = e->size().width(); 547 int w = e->size().width();
542 int h = e->size().height(); 548 int h = e->size().height();
543 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 549 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
544 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 550 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
545 uc = true; 551 uc = true;
546 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 552 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
547 } 553 }
548 mUpcomingWidth = e->size().width() ; 554 mUpcomingWidth = e->size().width() ;
549 if ( mBlockUpdating || uc ) { 555 if ( mBlockUpdating || uc ) {
550 mBlockUpdating = false; 556 mBlockUpdating = false;
551 //mAgenda->setMinimumSize(800 , 600 ); 557 //mAgenda->setMinimumSize(800 , 600 );
552 //qDebug("mAgenda->resize+++++++++++++++ "); 558 //qDebug("mAgenda->resize+++++++++++++++ ");
553 updateConfig(); 559 updateConfig();
554 //qDebug("KOAgendaView::Updating now possible "); 560 //qDebug("KOAgendaView::Updating now possible ");
555 } else 561 } else
556 createDayLabels(); 562 createDayLabels();
557 //qDebug("resizeEvent end "); 563 //qDebug("resizeEvent end ");
558 564
559} 565}
560void KOAgendaView::createDayLabels() 566void KOAgendaView::createDayLabels()
561{ 567{
562 568
563 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 569 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
564 // qDebug(" KOAgendaView::createDayLabels() blocked "); 570 // qDebug(" KOAgendaView::createDayLabels() blocked ");
565 return; 571 return;
566 572
567 } 573 }
568 int newHight; 574 int newHight;
569 575
570 // ### Before deleting and recreating we could check if mSelectedDates changed... 576 // ### Before deleting and recreating we could check if mSelectedDates changed...
571 // It would remove some flickering and gain speed (since this is called by 577 // It would remove some flickering and gain speed (since this is called by
572 // each updateView() call) 578 // each updateView() call)
573 579
574 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 580 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
575 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 581 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
576 if ( maxWid < 0 ) 582 if ( maxWid < 0 )
577 maxWid = 20; 583 maxWid = 20;
578 584
579 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 585 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
580 QFontMetrics fm ( dlf ); 586 QFontMetrics fm ( dlf );
581 int selCount = mSelectedDates.count(); 587 int selCount = mSelectedDates.count();
582 QString dayTest = "Mon 20"; 588 QString dayTest = "Mon 20";
583 int wid = fm.width( dayTest ); 589 int wid = fm.width( dayTest );
584 maxWid -= ( selCount * 3 ); 590 maxWid -= ( selCount * 3 );
585 if ( maxWid < 0 ) 591 if ( maxWid < 0 )
586 maxWid = 20; 592 maxWid = 20;
587 int needWid = wid * selCount; 593 int needWid = wid * selCount;
588 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 594 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
589 //if ( needWid > maxWid ) 595 //if ( needWid > maxWid )
590 // qDebug("DAYLABELS TOOOOOOO BIG "); 596 // qDebug("DAYLABELS TOOOOOOO BIG ");
591 while ( needWid > maxWid ) { 597 while ( needWid > maxWid ) {
592 dayTest = dayTest.left( dayTest.length() - 1 ); 598 dayTest = dayTest.left( dayTest.length() - 1 );
593 wid = fm.width( dayTest ); 599 wid = fm.width( dayTest );
594 needWid = wid * selCount; 600 needWid = wid * selCount;
595 } 601 }
596 int maxLen = dayTest.length(); 602 int maxLen = dayTest.length();
597 int fontPoint = dlf.pointSize(); 603 int fontPoint = dlf.pointSize();
598 if ( maxLen < 2 ) { 604 if ( maxLen < 2 ) {
599 int fontPoint = dlf.pointSize(); 605 int fontPoint = dlf.pointSize();
600 while ( fontPoint > 4 ) { 606 while ( fontPoint > 4 ) {
601 --fontPoint; 607 --fontPoint;
602 dlf.setPointSize( fontPoint ); 608 dlf.setPointSize( fontPoint );
603 QFontMetrics f( dlf ); 609 QFontMetrics f( dlf );
604 wid = f.width( "20" ); 610 wid = f.width( "20" );
605 needWid = wid * selCount; 611 needWid = wid * selCount;
606 if ( needWid < maxWid ) 612 if ( needWid < maxWid )
607 break; 613 break;
608 } 614 }
609 maxLen = 2; 615 maxLen = 2;
610 } 616 }
611 //qDebug("Max len %d ", dayTest.length() ); 617 //qDebug("Max len %d ", dayTest.length() );
612 618
613 QFontMetrics tempF( dlf ); 619 QFontMetrics tempF( dlf );
614 newHight = tempF.height(); 620 newHight = tempF.height();
615 mDayLabels->setFont( dlf ); 621 mDayLabels->setFont( dlf );
616 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 622 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
617 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 623 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
618 //mLayoutDayLabels->addSpacing( 2 ); 624 //mLayoutDayLabels->addSpacing( 2 );
619 // QFont lFont = dlf; 625 // QFont lFont = dlf;
620 bool appendLabels = false; 626 bool appendLabels = false;
621 QLabel *dayLabel; 627 QLabel *dayLabel;
622 dayLabel = mDayLabelsList.first(); 628 dayLabel = mDayLabelsList.first();
623 if ( !dayLabel ) { 629 if ( !dayLabel ) {
624 appendLabels = true; 630 appendLabels = true;
625 dayLabel = new QLabel(mDayLabels); 631 dayLabel = new QLabel(mDayLabels);
626 mDayLabelsList.append( dayLabel ); 632 mDayLabelsList.append( dayLabel );
627 mLayoutDayLabels->addWidget(dayLabel); 633 mLayoutDayLabels->addWidget(dayLabel);
628 } 634 }
629 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 635 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
630 dayLabel->setFont( dlf ); 636 dayLabel->setFont( dlf );
631 dayLabel->setAlignment(QLabel::AlignHCenter); 637 dayLabel->setAlignment(QLabel::AlignHCenter);
632 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 638 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
633 dayLabel->show(); 639 dayLabel->show();
634 DateList::ConstIterator dit; 640 DateList::ConstIterator dit;
635 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 641 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
636 QDate date = *dit; 642 QDate date = *dit;
637 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 643 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
638 if ( ! appendLabels ) { 644 if ( ! appendLabels ) {
639 dayLabel = mDayLabelsList.next(); 645 dayLabel = mDayLabelsList.next();
640 if ( !dayLabel ) 646 if ( !dayLabel )
641 appendLabels = true; 647 appendLabels = true;
642 } 648 }
643 if ( appendLabels ) { 649 if ( appendLabels ) {
644 dayLabel = new QLabel(mDayLabels); 650 dayLabel = new QLabel(mDayLabels);
645 mDayLabelsList.append( dayLabel ); 651 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 652 mLayoutDayLabels->addWidget(dayLabel);
647 } 653 }
648 dayLabel->setMinimumWidth( 1 ); 654 dayLabel->setMinimumWidth( 1 );
649 dayLabel->setMaximumWidth( 2048 ); 655 dayLabel->setMaximumWidth( 2048 );
650 dayLabel->setFont( dlf ); 656 dayLabel->setFont( dlf );
651 dayLabel->show(); 657 dayLabel->show();
652 QString str; 658 QString str;
653 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 659 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
654 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 660 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
655 switch ( maxLen ) { 661 switch ( maxLen ) {
656 case 2: 662 case 2:
657 str = QString::number( date.day() ); 663 str = QString::number( date.day() );
658 break; 664 break;
659 665
660 case 3: 666 case 3:
661 str = dayName.left( 1 ) +QString::number( date.day()); 667 str = dayName.left( 1 ) +QString::number( date.day());
662 668
663 break; 669 break;
664 case 4: 670 case 4:
665 str = dayName.left( 1 ) + " " +QString::number( date.day()); 671 str = dayName.left( 1 ) + " " +QString::number( date.day());
666 672
667 break; 673 break;
668 case 5: 674 case 5:
669 str = dayName.left( 2 ) + " " +QString::number( date.day()); 675 str = dayName.left( 2 ) + " " +QString::number( date.day());
670 676
671 break; 677 break;
672 case 6: 678 case 6:
673 str = dayName.left( 3 ) + " " +QString::number( date.day()); 679 str = dayName.left( 3 ) + " " +QString::number( date.day());
674 break; 680 break;
675 681
676 default: 682 default:
677 break; 683 break;
678 } 684 }
679 685
680 dayLabel->setText(str); 686 dayLabel->setText(str);
681 dayLabel->setAlignment(QLabel::AlignHCenter); 687 dayLabel->setAlignment(QLabel::AlignHCenter);
682 if (date == QDate::currentDate()) { 688 if (date == QDate::currentDate()) {
683 QFont bFont = dlf; 689 QFont bFont = dlf;
684 bFont.setBold( true ); 690 bFont.setBold( true );
685 dayLabel->setFont(bFont); 691 dayLabel->setFont(bFont);
686 } 692 }
687 //dayLayout->addWidget(dayLabel); 693 //dayLayout->addWidget(dayLabel);
688 694
689#ifndef KORG_NOPLUGINS 695#ifndef KORG_NOPLUGINS
690 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 696 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
691 CalendarDecoration *it; 697 CalendarDecoration *it;
692 for(it = cds.first(); it; it = cds.next()) { 698 for(it = cds.first(); it; it = cds.next()) {
693 QString text = it->shortText( date ); 699 QString text = it->shortText( date );
694 if ( !text.isEmpty() ) { 700 if ( !text.isEmpty() ) {
695 QLabel *label = new QLabel(text,mDayLabels); 701 QLabel *label = new QLabel(text,mDayLabels);
696 label->setAlignment(AlignCenter); 702 label->setAlignment(AlignCenter);
697 dayLayout->addWidget(label); 703 dayLayout->addWidget(label);
698 } 704 }
699 } 705 }
700 706
701 for(it = cds.first(); it; it = cds.next()) { 707 for(it = cds.first(); it; it = cds.next()) {
702 QWidget *wid = it->smallWidget(mDayLabels,date); 708 QWidget *wid = it->smallWidget(mDayLabels,date);
703 if ( wid ) { 709 if ( wid ) {
704 // wid->setHeight(20); 710 // wid->setHeight(20);
705 dayLayout->addWidget(wid); 711 dayLayout->addWidget(wid);
706 } 712 }
707 } 713 }
708#endif 714#endif
709 } 715 }
710 if ( ! appendLabels ) { 716 if ( ! appendLabels ) {
711 dayLabel = mDayLabelsList.next(); 717 dayLabel = mDayLabelsList.next();
712 if ( !dayLabel ) 718 if ( !dayLabel )
713 appendLabels = true; 719 appendLabels = true;
714 } 720 }
715 if ( appendLabels ) { 721 if ( appendLabels ) {
716 dayLabel = new QLabel(mDayLabels); 722 dayLabel = new QLabel(mDayLabels);
717 mDayLabelsList.append( dayLabel ); 723 mDayLabelsList.append( dayLabel );
718 mLayoutDayLabels->addWidget(dayLabel); 724 mLayoutDayLabels->addWidget(dayLabel);
719 } 725 }
720 //dayLabel->hide();//test only 726 //dayLabel->hide();//test only
721 727
722 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 728 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
723 if ( offset < 0 ) offset = 0; 729 if ( offset < 0 ) offset = 0;
724 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 730 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
725 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); 731 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) );
726 dayLabel->show(); 732 dayLabel->show();
727 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 733 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
728 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 734 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
729 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 735 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
730 if ( !appendLabels ) { 736 if ( !appendLabels ) {
731 dayLabel = mDayLabelsList.next(); 737 dayLabel = mDayLabelsList.next();
732 while ( dayLabel ) { 738 while ( dayLabel ) {
733 //qDebug("!dayLabel %d",dayLabel ); 739 //qDebug("!dayLabel %d",dayLabel );
734 dayLabel->hide(); 740 dayLabel->hide();
735 dayLabel = mDayLabelsList.next(); 741 dayLabel = mDayLabelsList.next();
736 } 742 }
737 } 743 }
738 //mDayLabelsFrame->show(); 744 //mDayLabelsFrame->show();
739 //mDayLabels->show(); 745 //mDayLabels->show();
740 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 746 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
741 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 747 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
742 mDayLabelsFrame->setFixedHeight( newHight ); 748 mDayLabelsFrame->setFixedHeight( newHight );
743} 749}
744 750
745int KOAgendaView::maxDatesHint() 751int KOAgendaView::maxDatesHint()
746{ 752{
747 // Not sure about the max number of events, so return 0 for now. 753 // Not sure about the max number of events, so return 0 for now.
748 return 0; 754 return 0;
749} 755}
750 756
751int KOAgendaView::currentDateCount() 757int KOAgendaView::currentDateCount()
752{ 758{
753 return mSelectedDates.count(); 759 return mSelectedDates.count();
754} 760}
755 761
756QPtrList<Incidence> KOAgendaView::selectedIncidences() 762QPtrList<Incidence> KOAgendaView::selectedIncidences()
757{ 763{
758 QPtrList<Incidence> selected; 764 QPtrList<Incidence> selected;
759 Incidence *incidence; 765 Incidence *incidence;
760 766
761 incidence = mAgenda->selectedIncidence(); 767 incidence = mAgenda->selectedIncidence();
762 if (incidence) selected.append(incidence); 768 if (incidence) selected.append(incidence);
763 769
764 incidence = mAllDayAgenda->selectedIncidence(); 770 incidence = mAllDayAgenda->selectedIncidence();
765 if (incidence) selected.append(incidence); 771 if (incidence) selected.append(incidence);
766 772
767 return selected; 773 return selected;
768} 774}
769 775
770DateList KOAgendaView::selectedDates() 776DateList KOAgendaView::selectedDates()
771{ 777{
772 DateList selected; 778 DateList selected;
773 QDate qd; 779 QDate qd;
774 780
775 qd = mAgenda->selectedIncidenceDate(); 781 qd = mAgenda->selectedIncidenceDate();
776 if (qd.isValid()) selected.append(qd); 782 if (qd.isValid()) selected.append(qd);
777 783
778 qd = mAllDayAgenda->selectedIncidenceDate(); 784 qd = mAllDayAgenda->selectedIncidenceDate();
779 if (qd.isValid()) selected.append(qd); 785 if (qd.isValid()) selected.append(qd);
780 786
781 return selected; 787 return selected;
782} 788}
783 789
784 790
785void KOAgendaView::updateView() 791void KOAgendaView::updateView()
786{ 792{
787 if ( mBlockUpdating ) 793 if ( mBlockUpdating )
788 return; 794 return;
789 // kdDebug() << "KOAgendaView::updateView()" << endl; 795 // kdDebug() << "KOAgendaView::updateView()" << endl;
790 fillAgenda(); 796 fillAgenda();
791 797
792} 798}
793 799
794 800
795/* 801/*
796 Update configuration settings for the agenda view. This method is not 802 Update configuration settings for the agenda view. This method is not
797 complete. 803 complete.
798*/ 804*/
799void KOAgendaView::updateConfig() 805void KOAgendaView::updateConfig()
800{ 806{
801 if ( mBlockUpdating ) 807 if ( mBlockUpdating )
802 return; 808 return;
803 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 809 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
804 810
805 // update config for children 811 // update config for children
806 mTimeLabels->updateConfig(); 812 mTimeLabels->updateConfig();
807 mAgenda->storePosition(); 813 mAgenda->storePosition();
808 mAgenda->updateConfig(); 814 mAgenda->updateConfig();
809 mAllDayAgenda->updateConfig(); 815 mAllDayAgenda->updateConfig();
810 // widget synchronization 816 // widget synchronization
811 //TODO: find a better way, maybe signal/slot 817 //TODO: find a better way, maybe signal/slot
812 mTimeLabels->positionChanged(); 818 mTimeLabels->positionChanged();
813 819
814 // for some reason, this needs to be called explicitly 820 // for some reason, this needs to be called explicitly
815 mTimeLabels->repaint(); 821 mTimeLabels->repaint();
816 822
817 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 823 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
818 824
819 // ToolTips displaying summary of events 825 // ToolTips displaying summary of events
820 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 826 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
821 ->mEnableToolTips); 827 ->mEnableToolTips);
822 828
823 //setHolidayMasks(); 829 //setHolidayMasks();
824 830
825 //createDayLabels(); called by via updateView(); 831 //createDayLabels(); called by via updateView();
826 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 832 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
827 updateView(); 833 updateView();
828 mAgenda->restorePosition(); 834 mAgenda->restorePosition();
829} 835}
830 836
831 837
832void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 838void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
833{ 839{
834 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 840 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
835 //qDebug("KOAgendaView::updateEventDates "); 841 //qDebug("KOAgendaView::updateEventDates ");
836 QDateTime startDt,endDt; 842 QDateTime startDt,endDt;
837 QDate startDate; 843 QDate startDate;
838 int lenInSecs; 844 int lenInSecs;
839 // if ( type == KOAgenda::RESIZETOP ) 845 // if ( type == KOAgenda::RESIZETOP )
840 // qDebug("RESIZETOP "); 846 // qDebug("RESIZETOP ");
841 // if ( type == KOAgenda::RESIZEBOTTOM ) 847 // if ( type == KOAgenda::RESIZEBOTTOM )
842 // qDebug("RESIZEBOTTOM "); 848 // qDebug("RESIZEBOTTOM ");
843 // if ( type == KOAgenda::MOVE ) 849 // if ( type == KOAgenda::MOVE )
844 // qDebug("MOVE "); 850 // qDebug("MOVE ");
845 if ( item->incidence()->type() == "Event" ) { 851 if ( item->incidence()->type() == "Event" ) {
846 startDt =item->incidence()->dtStart(); 852 startDt =item->incidence()->dtStart();
847 endDt = item->incidence()->dtEnd(); 853 endDt = item->incidence()->dtEnd();
848 lenInSecs = startDt.secsTo( endDt ); 854 lenInSecs = startDt.secsTo( endDt );
849 } 855 }
850 856
851 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 857 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
852 858
853 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 859 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
854 startDate = mSelectedDates[item->mLastMoveXPos]; 860 startDate = mSelectedDates[item->mLastMoveXPos];
855 } else { 861 } else {
856 if (item->cellX() < 0) { 862 if (item->cellX() < 0) {
857 startDate = (mSelectedDates.first()).addDays(item->cellX()); 863 startDate = (mSelectedDates.first()).addDays(item->cellX());
858 } else { 864 } else {
859 startDate = mSelectedDates[item->cellX()]; 865 startDate = mSelectedDates[item->cellX()];
860 } 866 }
861 } 867 }
862 startDt.setDate(startDate); 868 startDt.setDate(startDate);
863 869
864 if (item->incidence()->doesFloat()) { 870 if (item->incidence()->doesFloat()) {
865 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 871 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
866 } else { 872 } else {
867 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 873 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
868 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 874 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
869 if ( item->incidence()->type() == "Event" ) { 875 if ( item->incidence()->type() == "Event" ) {
870 if ( type == KOAgenda::MOVE ) { 876 if ( type == KOAgenda::MOVE ) {
871 endDt = startDt.addSecs(lenInSecs); 877 endDt = startDt.addSecs(lenInSecs);
872 878
873 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 879 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
874 if (item->lastMultiItem()) { 880 if (item->lastMultiItem()) {
875 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 881 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
876 endDt.setDate(startDate. 882 endDt.setDate(startDate.
877 addDays(item->lastMultiItem()->cellX() - item->cellX())); 883 addDays(item->lastMultiItem()->cellX() - item->cellX()));
878 } else { 884 } else {
879 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 885 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
880 endDt.setDate(startDate); 886 endDt.setDate(startDate);
881 } 887 }
882 } 888 }
883 } else { 889 } else {
884 // todo 890 // todo
885 if (item->lastMultiItem()) { 891 if (item->lastMultiItem()) {
886 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 892 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
887 endDt.setDate(startDate. 893 endDt.setDate(startDate.
888 addDays(item->lastMultiItem()->cellX() - item->cellX())); 894 addDays(item->lastMultiItem()->cellX() - item->cellX()));
889 } else { 895 } else {
890 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 896 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
891 if ( item->cellYBottom() > 0 ) 897 if ( item->cellYBottom() > 0 )
892 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 898 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
893 else 899 else
894 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 900 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
895 endDt.setDate(startDate); 901 endDt.setDate(startDate);
896 } 902 }
897 } 903 }
898 } 904 }
899 905
900 906
901 if ( item->incidence()->type() == "Event" ) { 907 if ( item->incidence()->type() == "Event" ) {
902 item->incidence()->setDtStart(startDt); 908 item->incidence()->setDtStart(startDt);
903 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 909 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
904 } else if ( item->incidence()->type() == "Todo" ) { 910 } else if ( item->incidence()->type() == "Todo" ) {
905 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 911 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
906 } 912 }
907 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 913 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
908 item->incidence()->setRevision(item->incidence()->revision()+1); 914 item->incidence()->setRevision(item->incidence()->revision()+1);
909 item->setItemDate(startDt.date()); 915 item->setItemDate(startDt.date());
910 //item->updateItem(); 916 //item->updateItem();
911 if ( item->incidence()->type() == "Todo" ) { 917 if ( item->incidence()->type() == "Todo" ) {
912 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 918 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
913 919
914 } 920 }
915 else 921 else
916 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 922 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
917 item->updateItem(); 923 item->updateItem();
918} 924}
919 925
920void KOAgendaView::showDates( const QDate &start, const QDate &end ) 926void KOAgendaView::showDates( const QDate &start, const QDate &end )
921{ 927{
922 // kdDebug() << "KOAgendaView::selectDates" << endl; 928 // kdDebug() << "KOAgendaView::selectDates" << endl;
923 929
924 mSelectedDates.clear(); 930 mSelectedDates.clear();
925 // qDebug("KOAgendaView::showDates "); 931 // qDebug("KOAgendaView::showDates ");
926 QDate d = start; 932 QDate d = start;
927 while (d <= end) { 933 while (d <= end) {
928 mSelectedDates.append(d); 934 mSelectedDates.append(d);
929 d = d.addDays( 1 ); 935 d = d.addDays( 1 );
930 } 936 }
931 937
932 // and update the view 938 // and update the view
933 fillAgenda(); 939 fillAgenda();
934} 940}
935 941
936 942
937void KOAgendaView::showEvents(QPtrList<Event>) 943void KOAgendaView::showEvents(QPtrList<Event>)
938{ 944{
939 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 945 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
940} 946}
941 947
942void KOAgendaView::changeEventDisplay(Event *, int) 948void KOAgendaView::changeEventDisplay(Event *, int)
943{ 949{
944 // qDebug("KOAgendaView::changeEventDisplay "); 950 // qDebug("KOAgendaView::changeEventDisplay ");
945 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 951 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
946 // this should be re-written to be MUCH smarter. Right now we 952 // this should be re-written to be MUCH smarter. Right now we
947 // are just playing dumb. 953 // are just playing dumb.
948 fillAgenda(); 954 fillAgenda();
949} 955}
950 956
951void KOAgendaView::fillAgenda(const QDate &) 957void KOAgendaView::fillAgenda(const QDate &)
952{ 958{
953 // qDebug("KOAgendaView::fillAgenda "); 959 // qDebug("KOAgendaView::fillAgenda ");
954 fillAgenda(); 960 fillAgenda();
955} 961}
956 962
957void KOAgendaView::fillAgenda() 963void KOAgendaView::fillAgenda()
958{ 964{
959 if ( globalFlagBlockStartup ) 965 if ( globalFlagBlockStartup )
960 return; 966 return;
961 if ( globalFlagBlockAgenda == 1 ) 967 if ( globalFlagBlockAgenda == 1 )
962 return; 968 return;
963 //if ( globalFlagBlockAgenda == 2 ) 969 //if ( globalFlagBlockAgenda == 2 )
964 //globalFlagBlockAgenda = 0; 970 //globalFlagBlockAgenda = 0;
965 // globalFlagBlockPainting = false; 971 // globalFlagBlockPainting = false;
966 if ( globalFlagBlockAgenda == 0 ) 972 if ( globalFlagBlockAgenda == 0 )
967 globalFlagBlockAgenda = 1; 973 globalFlagBlockAgenda = 1;
968 // clearView(); 974 // clearView();
969 //qDebug("fillAgenda()++++ "); 975 //qDebug("fillAgenda()++++ ");
970 globalFlagBlockAgendaItemPaint = 1; 976 globalFlagBlockAgendaItemPaint = 1;
971 mAllDayAgenda->changeColumns(mSelectedDates.count()); 977 mAllDayAgenda->changeColumns(mSelectedDates.count());
972 mAgenda->changeColumns(mSelectedDates.count()); 978 mAgenda->changeColumns(mSelectedDates.count());
973 qApp->processEvents(); 979 qApp->processEvents();
974 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 980 mEventIndicatorTop->changeColumns(mSelectedDates.count());
975 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 981 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
976 setHolidayMasks(); 982 setHolidayMasks();
977 983
978 //mAgenda->hideUnused(); 984 //mAgenda->hideUnused();
979 //mAllDayAgenda->hideUnused(); 985 //mAllDayAgenda->hideUnused();
980 986
981 // mAgenda->blockNextRepaint( false ); 987 // mAgenda->blockNextRepaint( false );
982 // mAgenda->viewport()->repaint(); 988 // mAgenda->viewport()->repaint();
983 // mAgenda->blockNextRepaint( true ); 989 // mAgenda->blockNextRepaint( true );
984 mMinY.resize(mSelectedDates.count()); 990 mMinY.resize(mSelectedDates.count());
985 mMaxY.resize(mSelectedDates.count()); 991 mMaxY.resize(mSelectedDates.count());
986 992
987 QPtrList<Event> dayEvents; 993 QPtrList<Event> dayEvents;
988 994
989 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 995 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
990 // Therefore, get all of them. 996 // Therefore, get all of them.
991 QPtrList<Todo> todos = calendar()->todos(); 997 QPtrList<Todo> todos = calendar()->todos();
992 998
993 mAgenda->setDateList(mSelectedDates); 999 mAgenda->setDateList(mSelectedDates);
994 1000
995 QDate today = QDate::currentDate(); 1001 QDate today = QDate::currentDate();
996 1002
997 DateList::ConstIterator dit; 1003 DateList::ConstIterator dit;
998 int curCol = 0; 1004 int curCol = 0;
999 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1005 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1000 QDate currentDate = *dit; 1006 QDate currentDate = *dit;
1001 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1007 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1002 // << endl; 1008 // << endl;
1003 1009
1004 dayEvents = calendar()->events(currentDate,true); 1010 dayEvents = calendar()->events(currentDate,true);
1005 1011
1006 // Default values, which can never be reached 1012 // Default values, which can never be reached
1007 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1013 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1008 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1014 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1009 1015
1010 unsigned int numEvent; 1016 unsigned int numEvent;
1011 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1017 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1012 Event *event = dayEvents.at(numEvent); 1018 Event *event = dayEvents.at(numEvent);
1013 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1019 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1014 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1020 if ( event->uid().left(15) == QString("last-syncEvent-") )
1015 continue; 1021 continue;
1016 // kdDebug() << " Event: " << event->summary() << endl; 1022 // kdDebug() << " Event: " << event->summary() << endl;
1017 1023
1018 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1024 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1019 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1025 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1020 1026
1021 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1027 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1022 1028
1023 if (event->doesFloat()) { 1029 if (event->doesFloat()) {
1024 if (event->recurrence()->doesRecur()) { 1030 if (event->recurrence()->doesRecur()) {
1025 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1031 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1026 } else { 1032 } else {
1027 if (beginX <= 0 && curCol == 0) { 1033 if (beginX <= 0 && curCol == 0) {
1028 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1034 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1029 } else if (beginX == curCol) { 1035 } else if (beginX == curCol) {
1030 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1036 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1031 } 1037 }
1032 } 1038 }
1033 } else if (event->isMultiDay()) { 1039 } else if (event->isMultiDay()) {
1034 if ( event->doesRecur () ) { 1040 if ( event->doesRecur () ) {
1035 QDate dateit = currentDate; 1041 QDate dateit = currentDate;
1036 int count = 0; 1042 int count = 0;
1037 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1043 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1038 while (! event->recursOn( dateit ) && count <= max ) { 1044 while (! event->recursOn( dateit ) && count <= max ) {
1039 ++count; 1045 ++count;
1040 dateit = dateit.addDays( -1 ); 1046 dateit = dateit.addDays( -1 );
1041 } 1047 }
1042 bool ok; 1048 bool ok;
1043 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1049 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1044 if ( ok ) 1050 if ( ok )
1045 { 1051 {
1046 int secs = event->dtStart().secsTo( event->dtEnd() ); 1052 int secs = event->dtStart().secsTo( event->dtEnd() );
1047 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1053 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1048 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1054 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1049 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1055 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1050 1056
1051 } 1057 }
1052 } 1058 }
1053 int startY = mAgenda->timeToY(event->dtStart().time()); 1059 int startY = mAgenda->timeToY(event->dtStart().time());
1054 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1060 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1055 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1061 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1056 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1062 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1057 //qDebug("insert!!! "); 1063 //qDebug("insert!!! ");
1058 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1064 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1059 } 1065 }
1060 if (beginX == curCol) { 1066 if (beginX == curCol) {
1061 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1062 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1068 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1063 } else if (endX == curCol) { 1069 } else if (endX == curCol) {
1064 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1070 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1065 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1071 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1066 } else { 1072 } else {
1067 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1073 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1068 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1074 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1069 } 1075 }
1070 } else { 1076 } else {
1071 int startY = mAgenda->timeToY(event->dtStart().time()); 1077 int startY = mAgenda->timeToY(event->dtStart().time());
1072 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1078 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1073 if (endY < startY) endY = startY; 1079 if (endY < startY) endY = startY;
1074 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1080 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1075 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1081 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1076 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1082 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1077 } 1083 }
1078 } 1084 }
1079 // ---------- [display Todos -------------- 1085 // ---------- [display Todos --------------
1080 unsigned int numTodo; 1086 unsigned int numTodo;
1081 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1087 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1082 Todo *todo = todos.at(numTodo); 1088 Todo *todo = todos.at(numTodo);
1083 1089
1084 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1090 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1085 1091
1086 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1092 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1087 // Already completed items can be displayed on their original due date 1093 // Already completed items can be displayed on their original due date
1088 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1094 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1089 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1095 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1090 1096
1091 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1097 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1092 ((currentDate == today) && overdue) ) { 1098 ((currentDate == today) && overdue) ) {
1093 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1099 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1094 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1100 if ( KOPrefs::instance()->mShowTodoInAgenda )
1095 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1101 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1096 } 1102 }
1097 else { 1103 else {
1098 1104
1099 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1105 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1100 int hi = (18/KOPrefs::instance()->mHourSize); 1106 int hi = (18/KOPrefs::instance()->mHourSize);
1101 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1107 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1102 int startY = endY -hi; 1108 int startY = endY -hi;
1103 1109
1104 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1110 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1105 1111
1106 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1112 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1107 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1113 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1108 } 1114 }
1109 } 1115 }
1110 } 1116 }
1111 // ---------- display Todos] -------------- 1117 // ---------- display Todos] --------------
1112 1118
1113 ++curCol; 1119 ++curCol;
1114 } 1120 }
1115 mAgenda->hideUnused(); 1121 mAgenda->hideUnused();
1116 mAllDayAgenda->hideUnused(); 1122 mAllDayAgenda->hideUnused();
1117 mAgenda->checkScrollBoundaries(); 1123 mAgenda->checkScrollBoundaries();
1118 1124
1119 deleteSelectedDateTime(); 1125 deleteSelectedDateTime();
1120 1126
1121 createDayLabels(); 1127 createDayLabels();
1122 emit incidenceSelected( 0 ); 1128 emit incidenceSelected( 0 );
1123 1129
1124 if ( globalFlagBlockAgenda == 2 ) { 1130 if ( globalFlagBlockAgenda == 2 ) {
1125 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1131 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1126 setStartHour( KOPrefs::instance()->mDayBegins ); 1132 setStartHour( KOPrefs::instance()->mDayBegins );
1127 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1133 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1128 setStartHour( QTime::currentTime ().hour() ); 1134 setStartHour( QTime::currentTime ().hour() );
1129 // qApp->processEvents(); 1135 // qApp->processEvents();
1130 } 1136 }
1131 qApp->processEvents(); 1137 qApp->processEvents();
1132 //qDebug("qApp->processEvents(); END "); 1138 //qDebug("qApp->processEvents(); END ");
1133 globalFlagBlockAgenda = 0; 1139 globalFlagBlockAgenda = 0;
1134 1140
1135 // mAgenda->hideUnused(); 1141 // mAgenda->hideUnused();
1136 //mAllDayAgenda->hideUnused(); 1142 //mAllDayAgenda->hideUnused();
1137 mAllDayAgenda->drawContentsToPainter(); 1143 mAllDayAgenda->drawContentsToPainter();
1138 mAgenda->drawContentsToPainter(); 1144 mAgenda->drawContentsToPainter();
1139 repaintAgenda(); 1145 repaintAgenda();
1140 // mAgenda->finishUpdate(); 1146 // mAgenda->finishUpdate();
1141 //mAllDayAgenda->finishUpdate(); 1147 //mAllDayAgenda->finishUpdate();
1142 1148
1143 // repaintAgenda(); 1149 // repaintAgenda();
1144 //qApp->processEvents(); 1150 //qApp->processEvents();
1145 // globalFlagBlockAgenda = 0; 1151 // globalFlagBlockAgenda = 0;
1146} 1152}
1147void KOAgendaView::repaintAgenda() 1153void KOAgendaView::repaintAgenda()
1148{ 1154{
1149 // mAllDayAgenda->drawContentsToPainter(); 1155 // mAllDayAgenda->drawContentsToPainter();
1150// mAllDayAgenda->viewport()->repaint( false ); 1156// mAllDayAgenda->viewport()->repaint( false );
1151// mAgenda->drawContentsToPainter(); 1157// mAgenda->drawContentsToPainter();
1152// mAgenda->viewport()->repaint( false ); 1158// mAgenda->viewport()->repaint( false );
1153// qApp->processEvents(); 1159// qApp->processEvents();
1154 1160
1155 //qDebug("KOAgendaView::repaintAgenda() "); 1161 //qDebug("KOAgendaView::repaintAgenda() ");
1156 //qApp->processEvents(); 1162 //qApp->processEvents();
1157 mAgenda->viewport()->repaint( false ); 1163 mAgenda->viewport()->repaint( false );
1158 mAllDayAgenda->viewport()->repaint( false ); 1164 mAllDayAgenda->viewport()->repaint( false );
1159 mAgenda->finishUpdate(); 1165 mAgenda->finishUpdate();
1160 mAllDayAgenda->finishUpdate(); 1166 mAllDayAgenda->finishUpdate();
1161} 1167}
1162 1168
1163 1169
1164void KOAgendaView::clearView() 1170void KOAgendaView::clearView()
1165{ 1171{
1166 // kdDebug() << "ClearView" << endl; 1172 // kdDebug() << "ClearView" << endl;
1167 mAllDayAgenda->clear(); 1173 mAllDayAgenda->clear();
1168 mAgenda->clear(); 1174 mAgenda->clear();
1169} 1175}
1170 1176
1171void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1177void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1172 const QDate &td) 1178 const QDate &td)
1173{ 1179{
1174#ifndef KORG_NOPRINTER 1180#ifndef KORG_NOPRINTER
1175 if (fd == td) 1181 if (fd == td)
1176 calPrinter->preview(CalPrinter::Day, fd, td); 1182 calPrinter->preview(CalPrinter::Day, fd, td);
1177 else 1183 else
1178 calPrinter->preview(CalPrinter::Week, fd, td); 1184 calPrinter->preview(CalPrinter::Week, fd, td);
1179#endif 1185#endif
1180} 1186}
1181 1187
1182// void KOAgendaView::updateMovedTodo() 1188// void KOAgendaView::updateMovedTodo()
1183// { 1189// {
1184// // updateConfig(); 1190// // updateConfig();
1185// // emit updateTodoViews(); 1191// // emit updateTodoViews();
1186// } 1192// }
1187 1193
1188void KOAgendaView::newEvent(int gx, int gy) 1194void KOAgendaView::newEvent(int gx, int gy)
1189{ 1195{
1190 if (!mSelectedDates.count()) return; 1196 if (!mSelectedDates.count()) return;
1191 1197
1192 QDate day = mSelectedDates[gx]; 1198 QDate day = mSelectedDates[gx];
1193 1199
1194 QTime time = mAgenda->gyToTime(gy); 1200 QTime time = mAgenda->gyToTime(gy);
1195 QDateTime dt(day,time); 1201 QDateTime dt(day,time);
1196 // if ( dt < QDateTime::currentDateTime () ) 1202 // if ( dt < QDateTime::currentDateTime () )
1197 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1203 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1198 emit newEventSignal(dt); 1204 emit newEventSignal(dt);
1199} 1205}
1200 1206
1201void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1207void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1202{ 1208{
1203 if (!mSelectedDates.count()) return; 1209 if (!mSelectedDates.count()) return;
1204 1210
1205 QDate dayStart = mSelectedDates[gxStart]; 1211 QDate dayStart = mSelectedDates[gxStart];
1206 QDate dayEnd = mSelectedDates[gxEnd]; 1212 QDate dayEnd = mSelectedDates[gxEnd];
1207 1213
1208 QTime timeStart = mAgenda->gyToTime(gyStart); 1214 QTime timeStart = mAgenda->gyToTime(gyStart);
1209 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1215 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1210 1216
1211 QDateTime dtStart(dayStart,timeStart); 1217 QDateTime dtStart(dayStart,timeStart);
1212 QDateTime dtEnd(dayEnd,timeEnd); 1218 QDateTime dtEnd(dayEnd,timeEnd);
1213 1219
1214 emit newEventSignal(dtStart,dtEnd); 1220 emit newEventSignal(dtStart,dtEnd);
1215} 1221}
1216 1222
1217void KOAgendaView::newEventAllDay(int gx, int ) 1223void KOAgendaView::newEventAllDay(int gx, int )
1218{ 1224{
1219 if (!mSelectedDates.count()) return; 1225 if (!mSelectedDates.count()) return;
1220 1226
1221 QDate day = mSelectedDates[gx]; 1227 QDate day = mSelectedDates[gx];
1222 1228
1223 emit newEventSignal(day); 1229 emit newEventSignal(day);
1224} 1230}
1225 1231
1226void KOAgendaView::updateEventIndicatorTop(int newY) 1232void KOAgendaView::updateEventIndicatorTop(int newY)
1227{ 1233{
1228 uint i; 1234 uint i;
1229 for(i=0;i<mMinY.size();++i) { 1235 for(i=0;i<mMinY.size();++i) {
1230 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1236 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1231 else mEventIndicatorTop->enableColumn(i,false); 1237 else mEventIndicatorTop->enableColumn(i,false);
1232 } 1238 }
1233 1239
1234 mEventIndicatorTop->update(); 1240 mEventIndicatorTop->update();
1235} 1241}
1236 1242
1237void KOAgendaView::updateEventIndicatorBottom(int newY) 1243void KOAgendaView::updateEventIndicatorBottom(int newY)
1238{ 1244{
1239 uint i; 1245 uint i;
1240 for(i=0;i<mMaxY.size();++i) { 1246 for(i=0;i<mMaxY.size();++i) {
1241 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1247 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1242 else mEventIndicatorBottom->enableColumn(i,false); 1248 else mEventIndicatorBottom->enableColumn(i,false);
1243 } 1249 }
1244 1250
1245 mEventIndicatorBottom->update(); 1251 mEventIndicatorBottom->update();
1246} 1252}
1247 1253
1248void KOAgendaView::startDrag(Event *event) 1254void KOAgendaView::startDrag(Event *event)
1249{ 1255{
1250#ifndef KORG_NODND 1256#ifndef KORG_NODND
1251 DndFactory factory( calendar() ); 1257 DndFactory factory( calendar() );
1252 ICalDrag *vd = factory.createDrag(event,this); 1258 ICalDrag *vd = factory.createDrag(event,this);
1253 if (vd->drag()) { 1259 if (vd->drag()) {
1254 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1260 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1255 } 1261 }
1256#endif 1262#endif
1257} 1263}
1258 1264
1259void KOAgendaView::readSettings() 1265void KOAgendaView::readSettings()
1260{ 1266{
1261 readSettings(KOGlobals::config()); 1267 readSettings(KOGlobals::config());
1262} 1268}
1263 1269
1264void KOAgendaView::readSettings(KConfig *config) 1270void KOAgendaView::readSettings(KConfig *config)
1265{ 1271{
1266 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1272 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1267 1273
1268 config->setGroup("Views"); 1274 config->setGroup("Views");
1269 1275
1270 //#ifndef KORG_NOSPLITTER 1276 //#ifndef KORG_NOSPLITTER
1271 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1277 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1272 if (sizes.count() == 2) { 1278 if (sizes.count() == 2) {
1273 if ( sizes[0] < 20 ) { 1279 if ( sizes[0] < 20 ) {
1274 sizes[1] = sizes[1] +20 - sizes[0]; 1280 sizes[1] = sizes[1] +20 - sizes[0];
1275 sizes[0] = 20; 1281 sizes[0] = 20;
1276 } 1282 }
1277 mSplitterAgenda->setSizes(sizes); 1283 mSplitterAgenda->setSizes(sizes);
1278 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1284 // qDebug("read %d %d ",sizes[0],sizes[1] );
1279 } 1285 }
1280 //#endif 1286 //#endif
1281 1287
1282 // updateConfig(); 1288 // updateConfig();
1283} 1289}
1284 1290
1285void KOAgendaView::writeSettings(KConfig *config) 1291void KOAgendaView::writeSettings(KConfig *config)
1286{ 1292{
1287 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1293 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1288 1294
1289 config->setGroup("Views"); 1295 config->setGroup("Views");
1290 1296
1291 //#ifndef KORG_NOSPLITTER 1297 //#ifndef KORG_NOSPLITTER
1292 QValueList<int> list = mSplitterAgenda->sizes(); 1298 QValueList<int> list = mSplitterAgenda->sizes();
1293 config->writeEntry("Separator AgendaView",list); 1299 config->writeEntry("Separator AgendaView",list);
1294 //qDebug("write %d %d ", list[0],list[1] ); 1300 //qDebug("write %d %d ", list[0],list[1] );
1295 //#endif 1301 //#endif
1296} 1302}
1297 1303
1298void KOAgendaView::setHolidayMasks() 1304void KOAgendaView::setHolidayMasks()
1299{ 1305{
1300 mHolidayMask.resize(mSelectedDates.count()); 1306 mHolidayMask.resize(mSelectedDates.count());
1301 1307
1302 uint i; 1308 uint i;
1303 for(i=0;i<mSelectedDates.count();++i) { 1309 for(i=0;i<mSelectedDates.count();++i) {
1304 QDate date = mSelectedDates[i]; 1310 QDate date = mSelectedDates[i];
1305 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1311 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1306 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1312 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1307#ifndef KORG_NOPLUGINS 1313#ifndef KORG_NOPLUGINS
1308 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1314 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1309 !KOCore::self()->holiday(date).isEmpty(); 1315 !KOCore::self()->holiday(date).isEmpty();
1310 bool showDay = showSaturday || showSunday || showHoliday; 1316 bool showDay = showSaturday || showSunday || showHoliday;
1311#else 1317#else
1312 bool showDay = showSaturday || showSunday; 1318 bool showDay = showSaturday || showSunday;
1313#endif 1319#endif
1314 if (showDay) { 1320 if (showDay) {
1315 mHolidayMask.at(i) = true; 1321 mHolidayMask.at(i) = true;
1316 } else { 1322 } else {
1317 mHolidayMask.at(i) = false; 1323 mHolidayMask.at(i) = false;
1318 } 1324 }
1319 } 1325 }
1320 1326
1321 mAgenda->setHolidayMask(&mHolidayMask); 1327 mAgenda->setHolidayMask(&mHolidayMask);
1322 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1328 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1323} 1329}
1324 1330
1325void KOAgendaView::setContentsPos(int y) 1331void KOAgendaView::setContentsPos(int y)
1326{ 1332{
1327 mAgenda->setContentsPos(0,y); 1333 mAgenda->setContentsPos(0,y);
1328} 1334}
1329 1335
1330void KOAgendaView::setExpandedButton( bool expanded ) 1336void KOAgendaView::setExpandedButton( bool expanded )
1331{ 1337{
1332 if ( expanded ) { 1338 if ( expanded ) {
1333 mExpandButton->setPixmap( mExpandedPixmap ); 1339 mExpandButton->setPixmap( mExpandedPixmap );
1334 } else { 1340 } else {
1335 mExpandButton->setPixmap( mNotExpandedPixmap ); 1341 mExpandButton->setPixmap( mNotExpandedPixmap );
1336 } 1342 }
1337} 1343}
1338 1344
1339void KOAgendaView::clearSelection() 1345void KOAgendaView::clearSelection()
1340{ 1346{
1341 mAgenda->deselectItem(); 1347 mAgenda->deselectItem();
1342 mAllDayAgenda->deselectItem(); 1348 mAllDayAgenda->deselectItem();
1343} 1349}
1344 1350
1345void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1351void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1346 int gxEnd, int gyEnd) 1352 int gxEnd, int gyEnd)
1347{ 1353{
1348 mTimeSpanInAllDay = true; 1354 mTimeSpanInAllDay = true;
1349 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1355 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1350} 1356}
1351 1357
1352 1358
1353 1359
1354 1360
1355void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1361void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1356 int gxEnd, int gyEnd) 1362 int gxEnd, int gyEnd)
1357{ 1363{
1358 if (!mSelectedDates.count()) return; 1364 if (!mSelectedDates.count()) return;
1359 1365
1360 QDate dayStart = mSelectedDates[gxStart]; 1366 QDate dayStart = mSelectedDates[gxStart];
1361 QDate dayEnd = mSelectedDates[gxEnd]; 1367 QDate dayEnd = mSelectedDates[gxEnd];
1362 1368
1363 QTime timeStart = mAgenda->gyToTime(gyStart); 1369 QTime timeStart = mAgenda->gyToTime(gyStart);
1364 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1370 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1365 1371
1366 QDateTime dtStart(dayStart,timeStart); 1372 QDateTime dtStart(dayStart,timeStart);
1367 QDateTime dtEnd(dayEnd,timeEnd); 1373 QDateTime dtEnd(dayEnd,timeEnd);
1368 1374
1369 mTimeSpanBegin = dtStart; 1375 mTimeSpanBegin = dtStart;
1370 mTimeSpanEnd = dtEnd; 1376 mTimeSpanEnd = dtEnd;
1371 1377
1372} 1378}
1373 1379
1374void KOAgendaView::deleteSelectedDateTime() 1380void KOAgendaView::deleteSelectedDateTime()
1375{ 1381{
1376 mTimeSpanBegin.setDate(QDate()); 1382 mTimeSpanBegin.setDate(QDate());
1377 mTimeSpanEnd.setDate(QDate()); 1383 mTimeSpanEnd.setDate(QDate());
1378 mTimeSpanInAllDay = false; 1384 mTimeSpanInAllDay = false;
1379} 1385}
1380 1386
1381void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1387void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1382{ 1388{
1383 e->ignore(); 1389 e->ignore();
1384} 1390}
1385 1391
1386void KOAgendaView::scrollOneHourUp() 1392void KOAgendaView::scrollOneHourUp()
1387{ 1393{
1388 1394
1389 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1395 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1390} 1396}
1391void KOAgendaView::scrollOneHourDown() 1397void KOAgendaView::scrollOneHourDown()
1392{ 1398{
1393 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1399 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1394} 1400}
1395 1401
1396void KOAgendaView::setStartHour( int h ) 1402void KOAgendaView::setStartHour( int h )
1397{ 1403{
1398 mAgenda->setStartHour( h ); 1404 mAgenda->setStartHour( h );
1399 1405
1400} 1406}
1401 1407
1402void KOAgendaView::updateTodo( Todo * t, int ) 1408void KOAgendaView::updateTodo( Todo * t, int )
1403{ 1409{
1404 1410
1405 bool remove = false; 1411 bool remove = false;
1406 bool removeAD = false; 1412 bool removeAD = false;
1407 if ( ! t->hasDueDate() ) { 1413 if ( ! t->hasDueDate() ) {
1408 remove = true; 1414 remove = true;
1409 removeAD = true; 1415 removeAD = true;
1410 } 1416 }
1411 else { 1417 else {
1412 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1418 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1413 if ( overdue && 1419 if ( overdue &&
1414 QDate::currentDate() >= mSelectedDates.first() && 1420 QDate::currentDate() >= mSelectedDates.first() &&
1415 QDate::currentDate() <= mSelectedDates.last()) { 1421 QDate::currentDate() <= mSelectedDates.last()) {
1416 removeAD = false; 1422 removeAD = false;
1417 remove = true; 1423 remove = true;
1418 } 1424 }
1419 else { 1425 else {
1420 if ( t->dtDue().date() < mSelectedDates.first() || 1426 if ( t->dtDue().date() < mSelectedDates.first() ||
1421 t->dtDue().date() > mSelectedDates.last() ) { 1427 t->dtDue().date() > mSelectedDates.last() ) {
1422 remove = true; 1428 remove = true;
1423 removeAD = true; 1429 removeAD = true;
1424 } else { 1430 } else {
1425 remove = t->doesFloat(); 1431 remove = t->doesFloat();
1426 removeAD = !remove; 1432 removeAD = !remove;
1427 } 1433 }
1428 } 1434 }
1429 } 1435 }
1430 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1436 int days = mSelectedDates.first().daysTo( t->dtDue().date() );
1431 // qDebug("daysto %d ", days ); 1437 // qDebug("daysto %d ", days );
1432 mAgenda->updateTodo( t , days, remove); 1438 mAgenda->updateTodo( t , days, remove);
1433 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1439 if ( KOPrefs::instance()->mShowTodoInAgenda )
1434 mAllDayAgenda->updateTodo( t , days, removeAD); 1440 mAllDayAgenda->updateTodo( t , days, removeAD);
1435 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1441 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1436 1442
1437} 1443}
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 0fea9be..59b864c 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,683 +1,694 @@
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 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27 27
28#include <kglobal.h> 28#include <kglobal.h>
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kiconloader.h> 31#include <kiconloader.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35 35
36#ifndef KORG_NOPRINTER 36#ifndef KORG_NOPRINTER
37#include "calprinter.h" 37#include "calprinter.h"
38#endif 38#endif
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "koeventviewerdialog.h" 41#include "koeventviewerdialog.h"
42 42#include <qstylesheet.h>
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44using namespace KOrg; 44using namespace KOrg;
45 45
46void WhatsNextTextBrowser::setSource(const QString& n) 46void WhatsNextTextBrowser::setSource(const QString& n)
47{ 47{
48 48
49 if (n.startsWith("event:")) { 49 if (n.startsWith("event:")) {
50 emit showIncidence(n); 50 emit showIncidence(n);
51 return; 51 return;
52 } else if (n.startsWith("todo:")) { 52 } else if (n.startsWith("todo:")) {
53 emit showIncidence(n); 53 emit showIncidence(n);
54 return; 54 return;
55 } else { 55 } else {
56 QTextBrowser::setSource(n); 56 QTextBrowser::setSource(n);
57 } 57 }
58} 58}
59 59
60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
61 const char *name) 61 const char *name)
62 : KOrg::BaseView(calendar, parent, name) 62 : KOrg::BaseView(calendar, parent, name)
63{ 63{
64 // mDateLabel = 64 // mDateLabel =
65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
66 // mDateLabel->setMargin(2); 66 // mDateLabel->setMargin(2);
67 // mDateLabel->setAlignment(AlignCenter); 67 // mDateLabel->setAlignment(AlignCenter);
68 setFont( KOPrefs::instance()->mWhatsNextFont ); 68 setFont( KOPrefs::instance()->mWhatsNextFont );
69 mView = new WhatsNextTextBrowser(this); 69 mView = new WhatsNextTextBrowser(this);
70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
71 71 QStyleSheet* stsh = mView->styleSheet();
72 QStyleSheetItem * style ;
73
74 style = stsh->item ("h2" );
75 if ( style ) {
76 style->setMargin(QStyleSheetItem::MarginAll,0);
77 }
78 style = stsh->item ("table" );
79 if ( style ) {
80 style->setMargin(QStyleSheetItem::MarginAll,0);
81 }
72 mEventViewer = 0; 82 mEventViewer = 0;
73 83
74 QBoxLayout *topLayout = new QVBoxLayout(this); 84 QBoxLayout *topLayout = new QVBoxLayout(this);
75 // topLayout->addWidget(mDateLabel); 85 // topLayout->addWidget(mDateLabel);
76 topLayout->addWidget(mView); 86 topLayout->addWidget(mView);
77 mTimer = new QTimer( this ); 87 mTimer = new QTimer( this );
78 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 88 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
79 89
80 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 90 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
81 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 91 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
82} 92}
83 93
84KOWhatsNextView::~KOWhatsNextView() 94KOWhatsNextView::~KOWhatsNextView()
85{ 95{
86} 96}
87 97
88int KOWhatsNextView::maxDatesHint() 98int KOWhatsNextView::maxDatesHint()
89{ 99{
90 return 0; 100 return 0;
91} 101}
92 102
93int KOWhatsNextView::currentDateCount() 103int KOWhatsNextView::currentDateCount()
94{ 104{
95 return 0; 105 return 0;
96} 106}
97 107
98QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 108QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
99{ 109{
100 QPtrList<Incidence> eventList; 110 QPtrList<Incidence> eventList;
101 111
102 return eventList; 112 return eventList;
103} 113}
104 114
105 115
106void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 116void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
107 const QDate &td) 117 const QDate &td)
108{ 118{
109#ifndef KORG_NOPRINTER 119#ifndef KORG_NOPRINTER
110 calPrinter->preview(CalPrinter::Day, fd, td); 120 calPrinter->preview(CalPrinter::Day, fd, td);
111#endif 121#endif
112} 122}
113void KOWhatsNextView::updateConfig() 123void KOWhatsNextView::updateConfig()
114{ 124{
115 setFont( KOPrefs::instance()->mWhatsNextFont ); 125 setFont( KOPrefs::instance()->mWhatsNextFont );
116 updateView(); 126 updateView();
117 127
118} 128}
119void KOWhatsNextView::showEvent ( QShowEvent * e ) 129void KOWhatsNextView::showEvent ( QShowEvent * e )
120{ 130{
121 //qDebug("KOWhatsNextView::showEvent "); 131 //qDebug("KOWhatsNextView::showEvent ");
122 restartTimer(); 132 restartTimer();
123 QWidget::showEvent ( e ); 133 QWidget::showEvent ( e );
124} 134}
125void KOWhatsNextView::hideEvent ( QHideEvent * e) 135void KOWhatsNextView::hideEvent ( QHideEvent * e)
126{ 136{
127 //qDebug(" KOWhatsNextView::hideEvent"); 137 //qDebug(" KOWhatsNextView::hideEvent");
128 mTimer->stop(); 138 mTimer->stop();
129 QWidget::hideEvent ( e ); 139 QWidget::hideEvent ( e );
130} 140}
131void KOWhatsNextView::restartTimer() 141void KOWhatsNextView::restartTimer()
132{ 142{
133 //qDebug("KOWhatsNextView::restartTimer() "); 143 //qDebug("KOWhatsNextView::restartTimer() ");
134 mTimer->start( 300000 ); 144 mTimer->start( 300000 );
135 //mTimer->start( 5000 ); 145 //mTimer->start( 5000 );
136} 146}
137void KOWhatsNextView::updateView() 147void KOWhatsNextView::updateView()
138{ 148{
139 if ( mTimer->isActive() ) 149 if ( mTimer->isActive() )
140 restartTimer(); 150 restartTimer();
141 //qDebug("KOWhatsNextView::updateView() "); 151 //qDebug("KOWhatsNextView::updateView() ");
142 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 152 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
143 KIconLoader kil("korganizer"); 153 KIconLoader kil("korganizer");
144 QString ipath;// = new QString(); 154 QString ipath;// = new QString();
145 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 155 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
146 //<big><big><strong>" + date + "</strong></big></big>\n"; 156 //<big><big><strong>" + date + "</strong></big></big>\n";
147 mText = "<table width=\"100%\">\n"; 157 mText = "<qt><table width=\"100%\">\n";
148 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 158 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
149#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
150 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 160 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
151#else 161#else
152 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 162 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
153#endif 163#endif
154 // mText += "<img src=\""; 164 // mText += "<img src=\"";
155 // mText += ipath; 165 // mText += ipath;
156 // mText += "\">"; 166 // mText += "\">";
157 mEventDate = QDate::currentDate(); 167 mEventDate = QDate::currentDate();
158#ifdef DESKTOP_VERSION 168#ifdef DESKTOP_VERSION
159 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 169 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
160#else 170#else
161 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 171 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
162#endif 172#endif
163 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 173 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
164 int iii; 174 int iii;
165 mTodos.clear(); 175 mTodos.clear();
166 QPtrList<Event> events; 176 QPtrList<Event> events;
167 QPtrList<Todo> todos = calendar()->todos(); 177 QPtrList<Todo> todos = calendar()->todos();
168 Todo * todo; 178 Todo * todo;
169 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 179 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
170 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 180 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
171 bool itemAdded = false; 181 bool itemAdded = false;
172 for ( iii = 0; iii < daysToShow; ++iii ) { 182 for ( iii = 0; iii < daysToShow; ++iii ) {
173 QString date; 183 QString date;
174 itemAdded = false; 184 itemAdded = false;
175 events = calendar()->events( mEventDate, true ); 185 events = calendar()->events( mEventDate, true );
176 186
177 if ( iii == 0 ) { // today !!! 187 if ( iii == 0 ) { // today !!!
178 todo = todos.first(); 188 todo = todos.first();
179 while(todo) { 189 while(todo) {
180 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 190 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
181 if ( ! itemAdded ) { 191 if ( ! itemAdded ) {
182 appendDay ( iii, mEventDate ); 192 appendDay ( iii, mEventDate );
183 itemAdded = true; 193 itemAdded = true;
184 194
185 } 195 }
186 appendEvent(todo); 196 appendEvent(todo);
187 } 197 }
188 todo = todos.next(); 198 todo = todos.next();
189 } 199 }
190 } 200 }
191 201
192 202
193 if (events.count() > 0) { 203 if (events.count() > 0) {
194 // mText += "<p></p>"; 204 // mText += "<p></p>";
195 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 205 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
196 // mText += "<h2>"; 206 // mText += "<h2>";
197 //mText += " <img src=\""; 207 //mText += " <img src=\"";
198 //mText += ipath; 208 //mText += ipath;
199 //mText += "\">"; 209 //mText += "\">";
200 if ( ! itemAdded ) { 210 if ( ! itemAdded ) {
201 appendDay ( iii, mEventDate ); 211 appendDay ( iii, mEventDate );
202 itemAdded = true; 212 itemAdded = true;
203 213
204 } 214 }
205 Event *ev = events.first(); 215 Event *ev = events.first();
206 while(ev) { 216 while(ev) {
207 //qDebug("+++++event append %s", ev->summary().latin1()); 217 //qDebug("+++++event append %s", ev->summary().latin1());
208 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 218 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
209 appendEvent(ev, false , iii!= 0 ); 219 appendEvent(ev, false , iii!= 0 );
210 } 220 }
211 ev = events.next(); 221 ev = events.next();
212 } 222 }
213 223
214 //mText += "</table>\n"; 224 //mText += "</table>\n";
215 } 225 }
216 226
217 todo = todos.first(); 227 todo = todos.first();
218 while(todo) { 228 while(todo) {
219 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 229 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
220 if ( ! itemAdded ) { 230 if ( ! itemAdded ) {
221 appendDay ( iii, mEventDate ); 231 appendDay ( iii, mEventDate );
222 itemAdded = true; 232 itemAdded = true;
223 } 233 }
224 appendEvent(todo); 234 appendEvent(todo);
225 } 235 }
226 todo = todos.next(); 236 todo = todos.next();
227 } 237 }
228 if ( !itemAdded && iii == 0 ) { 238 if ( !itemAdded && iii == 0 ) {
229 // appendDay ( iii, mEventDate ); 239 // appendDay ( iii, mEventDate );
230 //mText += "<table>"; 240 //mText += "<table>";
231 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 241 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
232 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; 242 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n";
233 //mText +="</table>"; 243 //mText +="</table>";
234 } 244 }
235 if ( itemAdded ) 245 if ( itemAdded )
236 mText += "</table>\n"; 246 mText += "</table>\n";
237 mEventDate = mEventDate.addDays( 1 ); 247 mEventDate = mEventDate.addDays( 1 );
238 } 248 }
239 249
240 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 250 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
241 if (todos.count() > 0 && topmostPrios > 0 ) { 251 if (todos.count() > 0 && topmostPrios > 0 ) {
242 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 252 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
243 // mText += "<h2>"; 253 // mText += "<h2>";
244 //<img src=\""; 254 //<img src=\"";
245 // mText += ipath; 255 // mText += ipath;
246 // mText += "\">"; 256 // mText += "\">";
247 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 257 // mText += i18n("Overdue To-Do:") + "</h2>\n";
248 258
249 //mText += "<ul>\n"; 259 //mText += "<ul>\n";
250 bool gotone = false; 260 bool gotone = false;
251 int priority = 1; 261 int priority = 1;
252 int priosFound = 0; 262 int priosFound = 0;
253#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
254 mText +="<p></p>"; 264 mText +="<p></p>";
255#endif 265#endif
256 266
257 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n"; 267 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n";
258 mText += "<ul>\n"; 268 mText += "<ul>\n";
259 while (!gotone && priority<6) { 269 while (!gotone && priority<6) {
260 todo = todos.first(); 270 todo = todos.first();
261 while(todo) { 271 while(todo) {
262 if (!todo->isCompleted() && (todo->priority() == priority) ) { 272 if (!todo->isCompleted() && (todo->priority() == priority) ) {
263 if ( appendTodo(todo) ) 273 if ( appendTodo(todo) )
264 gotone = true; 274 gotone = true;
265 } 275 }
266 todo = todos.next(); 276 todo = todos.next();
267 } 277 }
268 if ( gotone ) { 278 if ( gotone ) {
269 gotone = false; 279 gotone = false;
270 ++priosFound; 280 ++priosFound;
271 if ( priosFound == topmostPrios ) 281 if ( priosFound == topmostPrios )
272 break; 282 break;
273 } 283 }
274 priority++; 284 priority++;
275 // kdDebug() << "adding the todos..." << endl; 285 // kdDebug() << "adding the todos..." << endl;
276 } 286 }
277 mText += "</ul>\n"; 287 mText += "</ul>\n";
278 } 288 }
279 289
280 int replys = 0; 290 int replys = 0;
281 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 291 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
282 if (events.count() > 0) { 292 if (events.count() > 0) {
283 Event *ev = events.first(); 293 Event *ev = events.first();
284 while(ev) { 294 while(ev) {
285 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 295 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
286 if (me!=0) { 296 if (me!=0) {
287 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 297 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
288 if (replys == 0) { 298 if (replys == 0) {
289 mText += "<p></p>"; 299 mText += "<p></p>";
290 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 300 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
291 //mText += "<h2>"; 301 //mText += "<h2>";
292 //<img src=\""; 302 //<img src=\"";
293 // mText += ipath; 303 // mText += ipath;
294 // mText += "\">"; 304 // mText += "\">";
295 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 305 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
296 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></strong></big></big>\n"; 306 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></strong></big></big>\n";
297 mText += "<table>\n"; 307 mText += "<table>\n";
298 } 308 }
299 replys++; 309 replys++;
300 appendEvent(ev,true); 310 appendEvent(ev,true);
301 } 311 }
302 } 312 }
303 ev = events.next(); 313 ev = events.next();
304 } 314 }
305 } 315 }
306 todos = calendar()->todos(); 316 todos = calendar()->todos();
307 if (todos.count() > 0) { 317 if (todos.count() > 0) {
308 Todo *to = todos.first(); 318 Todo *to = todos.first();
309 while(to) { 319 while(to) {
310 if ( !to->isCompleted() ){ 320 if ( !to->isCompleted() ){
311 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 321 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
312 if (me!=0) { 322 if (me!=0) {
313 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 323 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
314 if (replys == 0) { 324 if (replys == 0) {
315 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></strong></big></big>\n"; 325 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></strong></big></big>\n";
316 mText += "<table>\n"; 326 mText += "<table>\n";
317 } 327 }
318 replys++; 328 replys++;
319 appendEvent(to, true); 329 appendEvent(to, true);
320 } 330 }
321 } 331 }
322 } 332 }
323 to = todos.next(); 333 to = todos.next();
324 } 334 }
325 } 335 }
326 if (replys > 0 ) mText += "</table>\n"; 336 if (replys > 0 ) mText += "</table>\n";
327 337
328 338
329 mText += "</td></tr>\n</table>\n"; 339 mText += "</td></tr>\n</table></qt>\n";
330 340
331 mView->setText(mText); 341 mView->setText(mText);
332 mView->setFocus(); 342 mView->setFocus();
333 343
334 // QPixmap bPix = SmallIcon( "back" ); 344 // QPixmap bPix = SmallIcon( "back" );
335 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 345 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
336 // QWidget* test = new QWidget(); 346 // QWidget* test = new QWidget();
337 // test->setBackgroundMode(FixedPixmap ); 347 // test->setBackgroundMode(FixedPixmap );
338 // test->setBackgroundPixmap ( bPix ); 348 // test->setBackgroundPixmap ( bPix );
339 // test->resize( 300, 400 ); 349 // test->resize( 300, 400 );
340 // test->show(); 350 // test->show();
341 // mView->setBackgroundMode(FixedPixmap ); 351 // mView->setBackgroundMode(FixedPixmap );
342 // mView->setBackgroundPixmap ( bPix ); 352 // mView->setBackgroundPixmap ( bPix );
353 qDebug("%s ",mText.latin1());
343} 354}
344 355
345void KOWhatsNextView::appendDay( int i, QDate eventDate ) 356void KOWhatsNextView::appendDay( int i, QDate eventDate )
346{ 357{
347 QString date; 358 QString date;
348 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 359 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
349 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 360 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
350 if ( i == 0 ) { 361 if ( i == 0 ) {
351 mText += "<table>\n"; 362 mText += "<table>\n";
352 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 363 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
353 } 364 }
354 else if ( i == 1 ) 365 else if ( i == 1 )
355 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 366 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
356 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 367 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
357 //mText += "<h2>" + date + "</h2>\n"; 368 //mText += "<h2>" + date + "</h2>\n";
358 mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 369 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
359 mText += "<table>\n"; 370 mText += "<table>\n";
360 371
361 372
362 373
363 } else { 374 } else {
364 if ( i == 0 ) { 375 if ( i == 0 ) {
365 mText += "<table>\n"; 376 mText += "<table>\n";
366 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 377 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
367 } 378 }
368 379
369#ifdef DESKTOP_VERSION 380#ifdef DESKTOP_VERSION
370 else if ( i == 1 ) { 381 else if ( i == 1 ) {
371 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 382 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
372 } 383 }
373 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 384 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
374#else 385#else
375 else if ( i == 1 ) { 386 else if ( i == 1 ) {
376 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 387 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
377 } 388 }
378 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 389 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
379 390
380#endif 391#endif
381 //mText += "<h2>" + date + "</h2>\n"; 392 //mText += "<h2>" + date + "</h2>\n";
382 mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 393 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
383 mText += "<table>\n"; 394 mText += "<table>\n";
384 } 395 }
385} 396}
386 397
387 398
388void KOWhatsNextView::showDates(const QDate &, const QDate &) 399void KOWhatsNextView::showDates(const QDate &, const QDate &)
389{ 400{
390 updateView(); 401 updateView();
391} 402}
392 403
393void KOWhatsNextView::showEvents(QPtrList<Event>) 404void KOWhatsNextView::showEvents(QPtrList<Event>)
394{ 405{
395} 406}
396 407
397void KOWhatsNextView::changeEventDisplay(Event *, int action) 408void KOWhatsNextView::changeEventDisplay(Event *, int action)
398{ 409{
399 switch(action) { 410 switch(action) {
400 case KOGlobals::EVENTADDED: 411 case KOGlobals::EVENTADDED:
401 updateView(); 412 updateView();
402 break; 413 break;
403 case KOGlobals::EVENTEDITED: 414 case KOGlobals::EVENTEDITED:
404 updateView(); 415 updateView();
405 break; 416 break;
406 case KOGlobals::EVENTDELETED: 417 case KOGlobals::EVENTDELETED:
407 updateView(); 418 updateView();
408 break; 419 break;
409 default: 420 default:
410 updateView(); 421 updateView();
411 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 422 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
412 } 423 }
413} 424}
414 425
415void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) 426void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed )
416{ 427{
417 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 428 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
418 return; 429 return;
419 QDateTime cdt = QDateTime::currentDateTime(); 430 QDateTime cdt = QDateTime::currentDateTime();
420 QDateTime noc; 431 QDateTime noc;
421 bool ok = true; 432 bool ok = true;
422 if ( reply ) { 433 if ( reply ) {
423 noc = ev->getNextOccurence( cdt, &ok ); 434 noc = ev->getNextOccurence( cdt, &ok );
424 if (! ok && ev->type() == "Event") 435 if (! ok && ev->type() == "Event")
425 return; 436 return;
426 } 437 }
427 mText += "<tr><td><b>"; 438 mText += "<tr><td><b>";
428 if (ev->type()=="Event") { 439 if (ev->type()=="Event") {
429 if (reply) { 440 if (reply) {
430 if (!ev->doesFloat()) 441 if (!ev->doesFloat())
431 mText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 442 mText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
432 else 443 else
433 mText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 444 mText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
434 445
435 } else { 446 } else {
436 if (!ev->doesFloat()) { 447 if (!ev->doesFloat()) {
437 Event *event = static_cast<Event *>(ev); 448 Event *event = static_cast<Event *>(ev);
438 QDateTime st,end; 449 QDateTime st,end;
439 if ( event->recurrence()->doesRecur() ) { 450 if ( event->recurrence()->doesRecur() ) {
440 QDate recDate= mEventDate; 451 QDate recDate= mEventDate;
441 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 452 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
442 while ( ! event->recursOn( recDate ) ) { 453 while ( ! event->recursOn( recDate ) ) {
443 recDate = recDate.addDays( -1 ); 454 recDate = recDate.addDays( -1 );
444 455
445 } 456 }
446 st = QDateTime ( recDate, event->dtStart().time() ); 457 st = QDateTime ( recDate, event->dtStart().time() );
447 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 458 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
448 } 459 }
449 else { 460 else {
450 st = event->dtStart(); 461 st = event->dtStart();
451 end = event->dtEnd(); 462 end = event->dtEnd();
452 } 463 }
453 464
454 465
455 QString dateText; 466 QString dateText;
456 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 467 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
457 if ( st.date() < mEventDate ) 468 if ( st.date() < mEventDate )
458 dateText = "++:++-"; 469 dateText = "++:++-";
459 else 470 else
460 dateText = event->dtStartTimeStr() + "-"; 471 dateText = event->dtStartTimeStr() + "-";
461 if ( end.date() > mEventDate ) 472 if ( end.date() > mEventDate )
462 dateText += "++:++"; 473 dateText += "++:++";
463 else 474 else
464 dateText += event->dtEndTimeStr(); 475 dateText += event->dtEndTimeStr();
465 if ( notRed ) 476 if ( notRed )
466 mText += dateText; 477 mText += dateText;
467 else { 478 else {
468 if ( end < cdt ) 479 if ( end < cdt )
469 mText += "<font color=\"#F00000\">" + dateText + "</font>"; 480 mText += "<font color=\"#F00000\">" + dateText + "</font>";
470 else if ( st < cdt ) 481 else if ( st < cdt )
471 mText += "<font color=\"#008000\">" + dateText + "</font>"; 482 mText += "<font color=\"#008000\">" + dateText + "</font>";
472 else 483 else
473 mText += dateText; 484 mText += dateText;
474 485
475 } 486 }
476 487
477 } else { 488 } else {
478 mText += i18n("Allday:"); 489 mText += i18n("Allday:");
479 490
480 } 491 }
481 } 492 }
482 } else { 493 } else {
483 mTodos.append( ev ); 494 mTodos.append( ev );
484 mText += i18n("ToDo:"); 495 mText += i18n("ToDo:");
485 if (reply) { 496 if (reply) {
486 mText += " "; 497 mText += " ";
487 if ( noc != cdt ) { 498 if ( noc != cdt ) {
488 mText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 499 mText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
489 } 500 }
490 } else { 501 } else {
491 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 502 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
492 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 503 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
493 QString dfs = KGlobal::locale()->dateFormatShort(); 504 QString dfs = KGlobal::locale()->dateFormatShort();
494 KGlobal::locale()->setDateFormatShort("%d.%b"); 505 KGlobal::locale()->setDateFormatShort("%d.%b");
495 mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 506 mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
496 KGlobal::locale()->setDateFormatShort(dfs); 507 KGlobal::locale()->setDateFormatShort(dfs);
497 } else { 508 } else {
498 if (!ev->doesFloat() ) 509 if (!ev->doesFloat() )
499 if( ( (Todo*)ev)->dtDue() < cdt ) { 510 if( ( (Todo*)ev)->dtDue() < cdt ) {
500 mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 511 mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
501 512
502 513
503 } else 514 } else
504 mText +=((Todo*)ev)->dtDueTimeStr(); 515 mText +=((Todo*)ev)->dtDueTimeStr();
505 mTodos.append( ev ); 516 mTodos.append( ev );
506 } 517 }
507 } 518 }
508 } 519 }
509 mText += "</b></td><td>"; 520 mText += "</b></td><td>";
510 bool needClose = false; 521 bool needClose = false;
511 if ( ev->cancelled() ) { 522 if ( ev->cancelled() ) {
512 mText += "<font color=\"#F00000\">[c"; 523 mText += "<font color=\"#F00000\">[c";
513 needClose =true; 524 needClose =true;
514 525
515 } 526 }
516 if ( ev->isAlarmEnabled() ) { 527 if ( ev->isAlarmEnabled() ) {
517 if ( !needClose) 528 if ( !needClose)
518 mText +="["; 529 mText +="[";
519 mText += "a"; 530 mText += "a";
520 needClose =true; 531 needClose =true;
521 532
522 } 533 }
523 if ( ev->description().length() > 0 ) { 534 if ( ev->description().length() > 0 ) {
524 if ( !needClose) 535 if ( !needClose)
525 mText +="["; 536 mText +="[";
526 mText += "i"; 537 mText += "i";
527 needClose =true; 538 needClose =true;
528 } 539 }
529 if ( ev->recurrence()->doesRecur() ) { 540 if ( ev->recurrence()->doesRecur() ) {
530 if ( !needClose) 541 if ( !needClose)
531 mText +="["; 542 mText +="[";
532 mText += "r"; 543 mText += "r";
533 needClose =true; 544 needClose =true;
534 } 545 }
535 if ( needClose ) { 546 if ( needClose ) {
536 mText += "] "; 547 mText += "] ";
537 } 548 }
538 if ( ev->cancelled() ) 549 if ( ev->cancelled() )
539 mText += "</font>"; 550 mText += "</font>";
540 mText += "<a "; 551 mText += "<a ";
541 if (ev->type()=="Event") mText += "href=\"event:"; 552 if (ev->type()=="Event") mText += "href=\"event:";
542 if (ev->type()=="Todo") mText += "href=\"todo:"; 553 if (ev->type()=="Todo") mText += "href=\"todo:";
543 mText += ev->uid() + "\">"; 554 mText += ev->uid() + "\">";
544 if ( ev->summary().length() > 0 ) 555 if ( ev->summary().length() > 0 )
545 mText += ev->summary(); 556 mText += ev->summary();
546 else 557 else
547 mText += i18n("-no summary-"); 558 mText += i18n("-no summary-");
548 mText += "</a>"; 559 mText += "</a>";
549 if ( KOPrefs::instance()->mWNViewShowLocation ) 560 if ( KOPrefs::instance()->mWNViewShowLocation )
550 if ( !ev->location().isEmpty() ) 561 if ( !ev->location().isEmpty() )
551 mText += " ("+ev->location() +")"; 562 mText += " ("+ev->location() +")";
552 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 563 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
553 mText += " ["+ev->relatedTo()->summary() +"]"; 564 mText += " ["+ev->relatedTo()->summary() +"]";
554 mText += "</td></tr>\n"; 565 mText += "</td></tr>\n";
555} 566}
556 567
557bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 568bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
558{ 569{
559 if ( mTodos.find( ev ) != mTodos.end() ) return false; 570 if ( mTodos.find( ev ) != mTodos.end() ) return false;
560 571
561 mTodos.append( ev ); 572 mTodos.append( ev );
562 if ( !isSub ) 573 if ( !isSub )
563 mText += "<p>"; 574 mText += "<p>";
564 else 575 else
565 mText += "<li>"; 576 mText += "<li>";
566 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 577 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
567 578
568 579
569 mText += ind; 580 mText += ind;
570 bool needClose = false; 581 bool needClose = false;
571 if ( ev->cancelled() ) { 582 if ( ev->cancelled() ) {
572 mText += "<font color=\"#F00000\">[c"; 583 mText += "<font color=\"#F00000\">[c";
573 needClose =true; 584 needClose =true;
574 585
575 } 586 }
576 if ( ev->isAlarmEnabled() ) { 587 if ( ev->isAlarmEnabled() ) {
577 if ( !needClose) 588 if ( !needClose)
578 mText +="["; 589 mText +="[";
579 mText += "a"; 590 mText += "a";
580 needClose =true; 591 needClose =true;
581 592
582 } 593 }
583 594
584 if ( ev->description().length() > 0 ) { 595 if ( ev->description().length() > 0 ) {
585 if ( !needClose) 596 if ( !needClose)
586 mText +="["; 597 mText +="[";
587 mText += "i"; 598 mText += "i";
588 needClose =true; 599 needClose =true;
589 } 600 }
590 // if ( ev->recurrence()->doesRecur() ) { 601 // if ( ev->recurrence()->doesRecur() ) {
591 // if ( !needClose) 602 // if ( !needClose)
592 // mText +="("; 603 // mText +="(";
593 // mText += "r"; 604 // mText += "r";
594 // needClose =true; 605 // needClose =true;
595 // } 606 // }
596 if ( needClose ) 607 if ( needClose )
597 mText += "] "; 608 mText += "] ";
598 if ( ev->cancelled() ) 609 if ( ev->cancelled() )
599 mText += "</font>"; 610 mText += "</font>";
600 mText += "<a href=\"todo:" + ev->uid() + "\">"; 611 mText += "<a href=\"todo:" + ev->uid() + "\">";
601 mText += ev->summary(); 612 mText += ev->summary();
602 mText += "</a>"; 613 mText += "</a>";
603 if ( ((Todo*)ev)->hasDueDate () ) { 614 if ( ((Todo*)ev)->hasDueDate () ) {
604 QString year = ""; 615 QString year = "";
605 int ye = ((Todo*)ev)->dtDue().date().year(); 616 int ye = ((Todo*)ev)->dtDue().date().year();
606 if ( QDateTime::currentDateTime().date().year() != ye ) 617 if ( QDateTime::currentDateTime().date().year() != ye )
607 year = QString::number( ye ); 618 year = QString::number( ye );
608 QString dfs = KGlobal::locale()->dateFormatShort(); 619 QString dfs = KGlobal::locale()->dateFormatShort();
609 KGlobal::locale()->setDateFormatShort("%d.%b"); 620 KGlobal::locale()->setDateFormatShort("%d.%b");
610 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 621 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
611 KGlobal::locale()->setDateFormatShort(dfs); 622 KGlobal::locale()->setDateFormatShort(dfs);
612 } 623 }
613 if ( KOPrefs::instance()->mWNViewShowLocation ) 624 if ( KOPrefs::instance()->mWNViewShowLocation )
614 if ( !ev->location().isEmpty() ) 625 if ( !ev->location().isEmpty() )
615 mText += " ("+ev->location() +")"; 626 mText += " ("+ev->location() +")";
616 if ( !isSub ) { 627 if ( !isSub ) {
617 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 628 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
618 mText += " ["+ev->relatedTo()->summary() +"]"; 629 mText += " ["+ev->relatedTo()->summary() +"]";
619 mText += "</p>\n"; 630 mText += "</p>\n";
620 } 631 }
621 else { 632 else {
622 ind += "-"; 633 ind += "-";
623 mText += "</li>\n"; 634 mText += "</li>\n";
624 } 635 }
625 QPtrList<Incidence> Relations = ev->relations(); 636 QPtrList<Incidence> Relations = ev->relations();
626 Incidence *to; 637 Incidence *to;
627 for (to=Relations.first();to;to=Relations.next()) { 638 for (to=Relations.first();to;to=Relations.next()) {
628 if (!((Todo*)to)->isCompleted()) 639 if (!((Todo*)to)->isCompleted())
629 appendTodo( to, ind , true ); 640 appendTodo( to, ind , true );
630 } 641 }
631 642
632 return true; 643 return true;
633} 644}
634 645
635/* 646/*
636 void KOWhatsNextView::createEventViewer() 647 void KOWhatsNextView::createEventViewer()
637 { 648 {
638 if (!mEventViewer) { 649 if (!mEventViewer) {
639 650
640 mEventViewer = new KOEventViewerDialog(this); 651 mEventViewer = new KOEventViewerDialog(this);
641 } 652 }
642 } 653 }
643*/ 654*/
644void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 655void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
645{ 656{
646 mEventViewer = v; 657 mEventViewer = v;
647} 658}
648 659
649// TODO: Create this function in CalendarView and remove it from here 660// TODO: Create this function in CalendarView and remove it from here
650void KOWhatsNextView::showIncidence(const QString &uid) 661void KOWhatsNextView::showIncidence(const QString &uid)
651{ 662{
652 if ( !mEventViewer ) { 663 if ( !mEventViewer ) {
653 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 664 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
654 return; 665 return;
655 } 666 }
656 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 667 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
657 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 668 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
658 if (uid.startsWith("event:")) { 669 if (uid.startsWith("event:")) {
659#ifdef DESKTOP_VERSION 670#ifdef DESKTOP_VERSION
660 Event *event = calendar()->event(uid.mid(8)); 671 Event *event = calendar()->event(uid.mid(8));
661#else 672#else
662 Event *event = calendar()->event(uid.mid(6)); 673 Event *event = calendar()->event(uid.mid(6));
663#endif 674#endif
664 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 675 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
665 if (!event) return; 676 if (!event) return;
666 //createEventViewer(); 677 //createEventViewer();
667 mEventViewer->setEvent(event); 678 mEventViewer->setEvent(event);
668 } else if (uid.startsWith("todo:")) { 679 } else if (uid.startsWith("todo:")) {
669#ifdef DESKTOP_VERSION 680#ifdef DESKTOP_VERSION
670 Todo *todo = calendar()->todo(uid.mid(7)); 681 Todo *todo = calendar()->todo(uid.mid(7));
671#else 682#else
672 Todo *todo = calendar()->todo(uid.mid(5)); 683 Todo *todo = calendar()->todo(uid.mid(5));
673#endif 684#endif
674 if (!todo) return; 685 if (!todo) return;
675 //createEventViewer(); 686 //createEventViewer();
676 mEventViewer->setTodo(todo); 687 mEventViewer->setTodo(todo);
677 } else { 688 } else {
678 return; 689 return;
679 690
680 } 691 }
681 mEventViewer->showMe(); 692 mEventViewer->showMe();
682 mEventViewer->raise(); 693 mEventViewer->raise();
683} 694}
diff --git a/libkdepim/categoryeditdialog.cpp b/libkdepim/categoryeditdialog.cpp
index f719c31..a19900f 100644
--- a/libkdepim/categoryeditdialog.cpp
+++ b/libkdepim/categoryeditdialog.cpp
@@ -1,135 +1,137 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 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 <qstringlist.h> 24#include <qstringlist.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qlistview.h> 26#include <qlistview.h>
27#include <qheader.h> 27#include <qheader.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include "kpimprefs.h" 31#include "kpimprefs.h"
32 32
33#include "categoryeditdialog.h" 33#include "categoryeditdialog.h"
34 34
35using namespace KPIM; 35using namespace KPIM;
36 36
37CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent, 37CategoryEditDialog::CategoryEditDialog( KPimPrefs *prefs, QWidget* parent,
38 const char* name, bool modal, 38 const char* name, bool modal,
39 WFlags fl ) 39 WFlags fl )
40 : CategoryEditDialog_base( parent, name, modal, fl ), 40 : CategoryEditDialog_base( parent, name, modal, fl ),
41 mPrefs( prefs ) 41 mPrefs( prefs )
42{ 42{
43 mCategories->header()->hide(); 43 mCategories->header()->hide();
44 44
45 QStringList::Iterator it; 45 QStringList::Iterator it;
46 bool categoriesExist=false; 46 bool categoriesExist=false;
47 for (it = mPrefs->mCustomCategories.begin(); 47 for (it = mPrefs->mCustomCategories.begin();
48 it != mPrefs->mCustomCategories.end(); ++it ) { 48 it != mPrefs->mCustomCategories.end(); ++it ) {
49 new QListViewItem(mCategories,*it); 49 new QListViewItem(mCategories,*it);
50 categoriesExist=true; 50 categoriesExist=true;
51 } 51 }
52 52
53 connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)), 53 connect(mCategories,SIGNAL(selectionChanged(QListViewItem *)),
54 SLOT(editItem(QListViewItem *))); 54 SLOT(editItem(QListViewItem *)));
55 connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &))); 55 connect(mEdit,SIGNAL(textChanged ( const QString & )),this,SLOT(slotTextChanged(const QString &)));
56 mButtonRemove->setEnabled(categoriesExist); 56 mButtonRemove->setEnabled(categoriesExist);
57 mButtonModify->setEnabled(categoriesExist); 57 mButtonModify->setEnabled(categoriesExist);
58 mButtonAdd->setEnabled(!mEdit->text().isEmpty()); 58 mButtonAdd->setEnabled(!mEdit->text().isEmpty());
59 if ( QApplication::desktop()->width() > 460 ) 59 if ( QApplication::desktop()->width() > 460 )
60 resize( 300, 360 ); 60 resize( 300, 360 );
61 else
62 showMaximized();
61} 63}
62 64
63/* 65/*
64 * Destroys the object and frees any allocated resources 66 * Destroys the object and frees any allocated resources
65 */ 67 */
66CategoryEditDialog::~CategoryEditDialog() 68CategoryEditDialog::~CategoryEditDialog()
67{ 69{
68 // no need to delete child widgets, Qt does it all for us 70 // no need to delete child widgets, Qt does it all for us
69} 71}
70 72
71void CategoryEditDialog::slotTextChanged(const QString &text) 73void CategoryEditDialog::slotTextChanged(const QString &text)
72{ 74{
73 mButtonAdd->setEnabled(!text.isEmpty()); 75 mButtonAdd->setEnabled(!text.isEmpty());
74} 76}
75 77
76void CategoryEditDialog::add() 78void CategoryEditDialog::add()
77{ 79{
78 if (!mEdit->text().isEmpty()) { 80 if (!mEdit->text().isEmpty()) {
79 new QListViewItem(mCategories,mEdit->text()); 81 new QListViewItem(mCategories,mEdit->text());
80 mEdit->setText(""); 82 mEdit->setText("");
81 mButtonRemove->setEnabled(mCategories->childCount()>0); 83 mButtonRemove->setEnabled(mCategories->childCount()>0);
82 mButtonModify->setEnabled(mCategories->childCount()>0); 84 mButtonModify->setEnabled(mCategories->childCount()>0);
83 } 85 }
84} 86}
85 87
86void CategoryEditDialog::remove() 88void CategoryEditDialog::remove()
87{ 89{
88 if (mCategories->currentItem()) { 90 if (mCategories->currentItem()) {
89 delete mCategories->currentItem(); 91 delete mCategories->currentItem();
90 mButtonRemove->setEnabled(mCategories->childCount()>0); 92 mButtonRemove->setEnabled(mCategories->childCount()>0);
91 mButtonModify->setEnabled(mCategories->childCount()>0); 93 mButtonModify->setEnabled(mCategories->childCount()>0);
92 } 94 }
93} 95}
94 96
95void CategoryEditDialog::modify() 97void CategoryEditDialog::modify()
96{ 98{
97 if (!mEdit->text().isEmpty()) { 99 if (!mEdit->text().isEmpty()) {
98 if (mCategories->currentItem()) { 100 if (mCategories->currentItem()) {
99 mCategories->currentItem()->setText(0,mEdit->text()); 101 mCategories->currentItem()->setText(0,mEdit->text());
100 } 102 }
101 } 103 }
102} 104}
103void CategoryEditDialog::accept() 105void CategoryEditDialog::accept()
104{ 106{
105 slotOk(); 107 slotOk();
106} 108}
107 109
108void CategoryEditDialog::slotOk() 110void CategoryEditDialog::slotOk()
109{ 111{
110 slotApply(); 112 slotApply();
111 QDialog::accept(); 113 QDialog::accept();
112} 114}
113 115
114void CategoryEditDialog::slotApply() 116void CategoryEditDialog::slotApply()
115{ 117{
116 mPrefs->mCustomCategories.clear(); 118 mPrefs->mCustomCategories.clear();
117 119
118 QListViewItem *item = mCategories->firstChild(); 120 QListViewItem *item = mCategories->firstChild();
119 while(item) { 121 while(item) {
120 mPrefs->mCustomCategories.append(item->text(0)); 122 mPrefs->mCustomCategories.append(item->text(0));
121 item = item->nextSibling(); 123 item = item->nextSibling();
122 } 124 }
123 mPrefs->writeConfig(); 125 mPrefs->writeConfig();
124 126
125 emit categoryConfigChanged(); 127 emit categoryConfigChanged();
126} 128}
127 129
128void CategoryEditDialog::editItem(QListViewItem *item) 130void CategoryEditDialog::editItem(QListViewItem *item)
129{ 131{
130 mEdit->setText(item->text(0)); 132 mEdit->setText(item->text(0));
131 mButtonRemove->setEnabled(true); 133 mButtonRemove->setEnabled(true);
132 mButtonModify->setEnabled(true); 134 mButtonModify->setEnabled(true);
133} 135}
134 136
135//US #include "categoryeditdialog.moc" 137//US #include "categoryeditdialog.moc"
diff --git a/libkdepim/categoryselectdialog.cpp b/libkdepim/categoryselectdialog.cpp
index 40b46cf..7df9154 100644
--- a/libkdepim/categoryselectdialog.cpp
+++ b/libkdepim/categoryselectdialog.cpp
@@ -1,173 +1,171 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2000, 2001, 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001, 2002 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 <qlistview.h> 24#include <qlistview.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qheader.h> 26#include <qheader.h>
27#include <qapp.h> 27#include <qapp.h>
28#include <qmessagebox.h> 28#include <qmessagebox.h>
29 29
30 30
31#include "categoryeditdialog.h" 31#include "categoryeditdialog.h"
32#include "categoryselectdialog.h" 32#include "categoryselectdialog.h"
33 33
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35 35
36using namespace KPIM; 36using namespace KPIM;
37 37
38CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent, 38CategorySelectDialog::CategorySelectDialog( KPimPrefs *prefs, QWidget* parent,
39 const char* name, 39 const char* name,
40 bool modal, WFlags fl ) 40 bool modal, WFlags fl )
41 : CategorySelectDialog_base( parent, name, true, fl ), 41 : CategorySelectDialog_base( parent, name, true, fl ),
42 mPrefs( prefs ) 42 mPrefs( prefs )
43{ 43{
44 mCategories->header()->hide(); 44 mCategories->header()->hide();
45 45
46 setCategories(); 46 setCategories();
47 47
48 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog())); 48 connect(mButtonEdit,SIGNAL(clicked()),this, SLOT(editCategoriesDialog()));
49 if ( qApp->desktop()->height() < 321 )
50 setMaximumHeight( QApplication::desktop()->height() - 50 );
51 else
52 setMaximumHeight( QApplication::desktop()->height() - 80 );
53 if ( QApplication::desktop()->width() > 460 ) 49 if ( QApplication::desktop()->width() > 460 )
54 resize( 260, 360 ); 50 resize( 300, 360 );
51 else
52 showMaximized();
55} 53}
56void CategorySelectDialog::editCategoriesDialog() 54void CategorySelectDialog::editCategoriesDialog()
57{ 55{
58 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this ); 56 KPIM::CategoryEditDialog* ced = new KPIM::CategoryEditDialog(mPrefs,this );
59 57
60 ced->exec(); 58 ced->exec();
61 delete ced; 59 delete ced;
62 setCategories(); 60 setCategories();
63} 61}
64void CategorySelectDialog::setCategories() 62void CategorySelectDialog::setCategories()
65{ 63{
66 mCategories->clear(); 64 mCategories->clear();
67 mCategoryList.clear(); 65 mCategoryList.clear();
68 66
69 QStringList::Iterator it; 67 QStringList::Iterator it;
70 68
71 for (it = mPrefs->mCustomCategories.begin(); 69 for (it = mPrefs->mCustomCategories.begin();
72 it != mPrefs->mCustomCategories.end(); ++it ) { 70 it != mPrefs->mCustomCategories.end(); ++it ) {
73 new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox); 71 new QCheckListItem(mCategories,*it,QCheckListItem::CheckBox);
74 } 72 }
75} 73}
76 74
77CategorySelectDialog::~CategorySelectDialog() 75CategorySelectDialog::~CategorySelectDialog()
78{ 76{
79} 77}
80 78
81void CategorySelectDialog::setSelected(const QStringList &selList) 79void CategorySelectDialog::setSelected(const QStringList &selList)
82{ 80{
83 clear(); 81 clear();
84 82
85 QStringList::ConstIterator it; 83 QStringList::ConstIterator it;
86 QStringList notFound; 84 QStringList notFound;
87 bool found = false; 85 bool found = false;
88 for (it=selList.begin();it!=selList.end();++it) { 86 for (it=selList.begin();it!=selList.end();++it) {
89 //qDebug(" CategorySelectDialog::setSelected("); 87 //qDebug(" CategorySelectDialog::setSelected(");
90 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 88 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
91 while (item) { 89 while (item) {
92 if (item->text() == *it) { 90 if (item->text() == *it) {
93 item->setOn(true); 91 item->setOn(true);
94 found = true; 92 found = true;
95 break; 93 break;
96 } 94 }
97 item = (QCheckListItem *)item->nextSibling(); 95 item = (QCheckListItem *)item->nextSibling();
98 } 96 }
99// if ( ! found ) { 97// if ( ! found ) {
100 98
101//emit updateCategoriesGlobal(); 99//emit updateCategoriesGlobal();
102// QMessageBox::information( this, "KO/E: Information!", 100// QMessageBox::information( this, "KO/E: Information!",
103// "Categories found, which were not\n" 101// "Categories found, which were not\n"
104// "in list of categories!\n" 102// "in list of categories!\n"
105// "message", 103// "message",
106// "OK", "", 0, 104// "OK", "", 0,
107// 0, 1 ); 105// 0, 1 );
108// setSelected(selList); 106// setSelected(selList);
109// return; 107// return;
110// } 108// }
111 } 109 }
112} 110}
113 111
114QStringList CategorySelectDialog::selectedCategories() const 112QStringList CategorySelectDialog::selectedCategories() const
115{ 113{
116 return mCategoryList; 114 return mCategoryList;
117} 115}
118 116
119void CategorySelectDialog::slotApply() 117void CategorySelectDialog::slotApply()
120{ 118{
121 QStringList categories; 119 QStringList categories;
122 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 120 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
123 while (item) { 121 while (item) {
124 if (item->isOn()) { 122 if (item->isOn()) {
125 categories.append(item->text()); 123 categories.append(item->text());
126 } 124 }
127 item = (QCheckListItem *)item->nextSibling(); 125 item = (QCheckListItem *)item->nextSibling();
128 } 126 }
129 127
130 QString categoriesStr = categories.join(","); 128 QString categoriesStr = categories.join(",");
131 129
132 mCategoryList = categories; 130 mCategoryList = categories;
133 131
134 emit categoriesSelected(categories); 132 emit categoriesSelected(categories);
135 emit categoriesSelected(categoriesStr); 133 emit categoriesSelected(categoriesStr);
136} 134}
137void CategorySelectDialog::accept() 135void CategorySelectDialog::accept()
138{ 136{
139 slotOk(); 137 slotOk();
140} 138}
141 139
142void CategorySelectDialog::slotOk() 140void CategorySelectDialog::slotOk()
143{ 141{
144 slotApply(); 142 slotApply();
145 QDialog::accept(); 143 QDialog::accept();
146} 144}
147 145
148void CategorySelectDialog::clear() 146void CategorySelectDialog::clear()
149{ 147{
150 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 148 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
151 while (item) { 149 while (item) {
152 item->setOn(false); 150 item->setOn(false);
153 item = (QCheckListItem *)item->nextSibling(); 151 item = (QCheckListItem *)item->nextSibling();
154 } 152 }
155} 153}
156 154
157void CategorySelectDialog::updateCategoryConfig() 155void CategorySelectDialog::updateCategoryConfig()
158{ 156{
159 QStringList selected; 157 QStringList selected;
160 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild(); 158 QCheckListItem *item = (QCheckListItem *)mCategories->firstChild();
161 while (item) { 159 while (item) {
162 if (item->isOn()) { 160 if (item->isOn()) {
163 selected.append(item->text()); 161 selected.append(item->text());
164 } 162 }
165 item = (QCheckListItem *)item->nextSibling(); 163 item = (QCheckListItem *)item->nextSibling();
166 } 164 }
167 165
168 setCategories(); 166 setCategories();
169 167
170 setSelected(selected); 168 setSelected(selected);
171} 169}
172 170
173//#include "categoryselectdialog.moc" 171//#include "categoryselectdialog.moc"