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,762 +1,768 @@
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);
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"