summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-26 04:09:44 (UTC)
committer zautrix <zautrix>2005-01-26 04:09:44 (UTC)
commitc3e40c9baa61009469022a87e9cd068734899bcc (patch) (unidiff)
tree11f0f33d939fd17f613381fec4cf8c454b9847b4
parent76b0e73d8752448058e2fa3ad065f0219b9ffad8 (diff)
downloadkdepimpi-c3e40c9baa61009469022a87e9cd068734899bcc.zip
kdepimpi-c3e40c9baa61009469022a87e9cd068734899bcc.tar.gz
kdepimpi-c3e40c9baa61009469022a87e9cd068734899bcc.tar.bz2
monthview fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp8
-rw-r--r--korganizer/koprefs.cpp2
2 files changed, 7 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index b819eec..437debe 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1125 +1,1129 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtooltip.h> 27#include <qtooltip.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35 35
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45#include "calprinter.h" 45#include "calprinter.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
49#include "kocore.h" 49#include "kocore.h"
50#endif 50#endif
51#include "koglobals.h" 51#include "koglobals.h"
52#include <libkcal/kincidenceformatter.h> 52#include <libkcal/kincidenceformatter.h>
53 53
54#include "komonthview.h" 54#include "komonthview.h"
55 55
56#define PIXMAP_SIZE 5 56#define PIXMAP_SIZE 5
57#ifdef DESKTOP_VERSION 57#ifdef DESKTOP_VERSION
58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
59#endif 59#endif
60class KNOWhatsThis :public QWhatsThis 60class KNOWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
64 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
64 65
65protected: 66protected:
66 virtual QString text( const QPoint& p) 67 virtual QString text( const QPoint& p)
67 { 68 {
68 return _wid->getWhatsThisText(p) ; 69 return _wid->getWhatsThisText(p) ;
69 }; 70 };
70private: 71private:
71 KNoScrollListBox* _wid; 72 KNoScrollListBox* _wid;
72 73
73}; 74};
74 75
75 76
76KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 77KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
77 : QListBox(parent, name, WRepaintNoErase) 78 : QListBox(parent, name, WRepaintNoErase)
78{ 79{
79#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
80 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
81#endif 82#endif
82 mWT = new KNOWhatsThis(this); 83 mWT = new KNOWhatsThis(this);
83} 84}
84KNoScrollListBox::~KNoScrollListBox() 85KNoScrollListBox::~KNoScrollListBox()
85{ 86{
86 delete mWT; 87
87} 88}
88QString KNoScrollListBox::getWhatsThisText(QPoint p) 89QString KNoScrollListBox::getWhatsThisText(QPoint p)
89{ 90{
90 QListBoxItem* item = itemAt ( p ); 91 QListBoxItem* item = itemAt ( p );
91 if ( ! item ) { 92 if ( ! item ) {
92 return i18n("Click in the cell\nto add an event!"); 93 return i18n("Click in the cell\nto add an event!");
93 } 94 }
94 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 95 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
95} 96}
96void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 97void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
97{ 98{
98 99
99 switch(e->key()) { 100 switch(e->key()) {
100 case Key_Right: 101 case Key_Right:
101 // if ( e->state() == Qt::ControlButton ) 102 // if ( e->state() == Qt::ControlButton )
102 { 103 {
103 e->ignore(); 104 e->ignore();
104 return; 105 return;
105 } 106 }
106 scrollBy(4,0); 107 scrollBy(4,0);
107 break; 108 break;
108 case Key_Left: 109 case Key_Left:
109 // if ( e->state() == Qt::ControlButton ) 110 // if ( e->state() == Qt::ControlButton )
110 { 111 {
111 e->ignore(); 112 e->ignore();
112 return; 113 return;
113 } 114 }
114 scrollBy(-4,0); 115 scrollBy(-4,0);
115 break; 116 break;
116 case Key_Up: 117 case Key_Up:
117 if(!count()) break; 118 if(!count()) break;
118 setCurrentItem((currentItem()+count()-1)%count()); 119 setCurrentItem((currentItem()+count()-1)%count());
119 if(!itemVisible(currentItem())) { 120 if(!itemVisible(currentItem())) {
120 if((unsigned int) currentItem() == (count()-1)) { 121 if((unsigned int) currentItem() == (count()-1)) {
121 setTopItem(currentItem()-numItemsVisible()+1); 122 setTopItem(currentItem()-numItemsVisible()+1);
122 } else { 123 } else {
123 setTopItem(topItem()-1); 124 setTopItem(topItem()-1);
124 } 125 }
125 } 126 }
126 break; 127 break;
127 case Key_Down: 128 case Key_Down:
128 if(!count()) break; 129 if(!count()) break;
129 setCurrentItem((currentItem()+1)%count()); 130 setCurrentItem((currentItem()+1)%count());
130 if(!itemVisible(currentItem())) { 131 if(!itemVisible(currentItem())) {
131 if(currentItem() == 0) { 132 if(currentItem() == 0) {
132 setTopItem(0); 133 setTopItem(0);
133 } else { 134 } else {
134 setTopItem(topItem()+1); 135 setTopItem(topItem()+1);
135 } 136 }
136 } 137 }
137 break; 138 break;
138 case Key_Shift: 139 case Key_Shift:
139 emit shiftDown(); 140 emit shiftDown();
140 break; 141 break;
141 default: 142 default:
142 e->ignore(); 143 e->ignore();
143 break; 144 break;
144 } 145 }
145} 146}
146 147
147void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 148void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
148{ 149{
149 switch(e->key()) { 150 switch(e->key()) {
150 case Key_Shift: 151 case Key_Shift:
151 emit shiftUp(); 152 emit shiftUp();
152 break; 153 break;
153 default: 154 default:
154 break; 155 break;
155 } 156 }
156} 157}
157 158
158void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 159void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
159{ 160{
160 QListBox::mousePressEvent(e); 161 QListBox::mousePressEvent(e);
161 162
162 if(e->button() == RightButton) { 163 if(e->button() == RightButton) {
163 emit rightClick(); 164 emit rightClick();
164 } 165 }
165} 166}
166 167
167MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 168MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
168 : QListBoxItem() 169 : QListBoxItem()
169{ 170{
170 setText( s ); 171 setText( s );
171 172
172 mIncidence = incidence; 173 mIncidence = incidence;
173 mDate = qd; 174 mDate = qd;
174 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 175 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
175 mRecur = false; 176 mRecur = false;
176 mAlarm = false; 177 mAlarm = false;
177 mReply = false; 178 mReply = false;
178 mInfo = false; 179 mInfo = false;
179} 180}
180 181
181void MonthViewItem::paint(QPainter *p) 182void MonthViewItem::paint(QPainter *p)
182{ 183{
183#if QT_VERSION >= 0x030000 184#if QT_VERSION >= 0x030000
184 bool sel = isSelected(); 185 bool sel = isSelected();
185#else 186#else
186 bool sel = selected(); 187 bool sel = selected();
187#endif 188#endif
188 189
189 190
190 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 191 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
191 { 192 {
192 p->setBackgroundColor( palette().color( QPalette::Normal, \ 193 p->setBackgroundColor( palette().color( QPalette::Normal, \
193 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 194 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
194 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 195 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
195 } 196 }
196 int x = 1; 197 int x = 1;
197 int y = 3;//(height() - mRecurPixmap.height()) /2; 198 int y = 3;//(height() - mRecurPixmap.height()) /2;
198 int size = PIXMAP_SIZE; 199 int size = PIXMAP_SIZE;
199 if ( QApplication::desktop()->width() < 300 ) 200 if ( QApplication::desktop()->width() < 300 )
200 size = 3; 201 size = 3;
201 if ( KOPrefs::instance()->mMonthShowIcons ) { 202 if ( KOPrefs::instance()->mMonthShowIcons ) {
202 if ( mInfo ) { 203 if ( mInfo ) {
203 p->fillRect ( x, y,size,size, Qt::darkGreen ); 204 p->fillRect ( x, y,size,size, Qt::darkGreen );
204 x += size + 1; 205 x += size + 1;
205 } 206 }
206 if ( mRecur ) { 207 if ( mRecur ) {
207 p->fillRect ( x, y,size,size, Qt::blue ); 208 p->fillRect ( x, y,size,size, Qt::blue );
208 x += size + 1; 209 x += size + 1;
209 } 210 }
210 if ( mAlarm ) { 211 if ( mAlarm ) {
211 p->fillRect ( x, y,size,size, Qt::red ); 212 p->fillRect ( x, y,size,size, Qt::red );
212 x += size + 1; 213 x += size + 1;
213 } 214 }
214 if ( mReply ) { 215 if ( mReply ) {
215 p->fillRect ( x, y,size,size, Qt::yellow ); 216 p->fillRect ( x, y,size,size, Qt::yellow );
216 x += size + 1; 217 x += size + 1;
217 } 218 }
218 } 219 }
219 QFontMetrics fm = p->fontMetrics(); 220 QFontMetrics fm = p->fontMetrics();
220 int yPos; 221 int yPos;
221 int pmheight = size; 222 int pmheight = size;
222 if( pmheight < fm.height() ) 223 if( pmheight < fm.height() )
223 yPos = fm.ascent() + fm.leading()/2; 224 yPos = fm.ascent() + fm.leading()/2;
224 else 225 else
225 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 226 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
226 p->setPen( palette().color( QPalette::Normal, sel ? \ 227 p->setPen( palette().color( QPalette::Normal, sel ? \
227 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 228 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
228 p->drawText( x, yPos, text() ); 229 p->drawText( x, yPos, text() );
229 if ( mIncidence->cancelled() ) { 230 if ( mIncidence->cancelled() ) {
230 int wid = fm.width( text() ); 231 int wid = fm.width( text() );
231 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 232 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
232 } 233 }
233 234
234} 235}
235 236
236int MonthViewItem::height(const QListBox *lb) const 237int MonthViewItem::height(const QListBox *lb) const
237{ 238{
238 return lb->fontMetrics().lineSpacing()+1; 239 return lb->fontMetrics().lineSpacing()+1;
239} 240}
240 241
241int MonthViewItem::width(const QListBox *lb) const 242int MonthViewItem::width(const QListBox *lb) const
242{ 243{
243 int size = PIXMAP_SIZE; 244 int size = PIXMAP_SIZE;
244 if ( QApplication::desktop()->width() < 300 ) 245 if ( QApplication::desktop()->width() < 300 )
245 size = 3; 246 size = 3;
246 int x = 1; 247 int x = 1;
247 if ( mInfo ) { 248 if ( mInfo ) {
248 x += size + 1; 249 x += size + 1;
249 } 250 }
250 if( mRecur ) { 251 if( mRecur ) {
251 x += size+1; 252 x += size+1;
252 } 253 }
253 if( mAlarm ) { 254 if( mAlarm ) {
254 x += size+1; 255 x += size+1;
255 } 256 }
256 if( mReply ) { 257 if( mReply ) {
257 x += size+1; 258 x += size+1;
258 } 259 }
259 260
260 return( x + lb->fontMetrics().width( text() ) + 1 ); 261 return( x + lb->fontMetrics().width( text() ) + 1 );
261} 262}
262 263
263 264
264MonthViewCell::MonthViewCell( KOMonthView *parent) 265MonthViewCell::MonthViewCell( KOMonthView *parent)
265 : QWidget( parent ), 266 : QWidget( parent ),
266 mMonthView( parent ) 267 mMonthView( parent )
267{ 268{
268 269
269 QVBoxLayout *topLayout = new QVBoxLayout( this ); 270 QVBoxLayout *topLayout = new QVBoxLayout( this );
270 271
271 // mLabel = new QLabel( this );QPushButton 272 // mLabel = new QLabel( this );QPushButton
272 mLabel = new QPushButton( this ); 273 mLabel = new QPushButton( this );
273 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 274 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
274 //mLabel->setLineWidth( 1 ); 275 //mLabel->setLineWidth( 1 );
275 //mLabel->setAlignment( AlignCenter ); 276 //mLabel->setAlignment( AlignCenter );
276 mLabel->setFlat( true ); 277 mLabel->setFlat( true );
277 mItemList = new KNoScrollListBox( this ); 278 mItemList = new KNoScrollListBox( this );
278 mItemList->setMinimumSize( 10, 10 ); 279 mItemList->setMinimumSize( 10, 10 );
279 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 280 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
280 mItemList->setLineWidth( 1 ); 281 mItemList->setLineWidth( 1 );
281 topLayout->addWidget( mItemList ); 282 topLayout->addWidget( mItemList );
282 mLabel->raise(); 283 mLabel->raise();
283 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 284 // QColor( 0,0,255 ) QColor( 160,1600,255 )
284 mStandardPalette = palette(); 285 mStandardPalette = palette();
285 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 286 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
286 287
287 enableScrollBars( false ); 288 enableScrollBars( false );
288 updateConfig(); 289 updateConfig();
289 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 290 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
290 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 291 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
291 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 292 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
292 SLOT( defaultAction( QListBoxItem * ) ) ); 293 SLOT( defaultAction( QListBoxItem * ) ) );
293 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 294 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
294 const QPoint &) ), 295 const QPoint &) ),
295 SLOT( contextMenu( QListBoxItem * ) ) ); 296 SLOT( contextMenu( QListBoxItem * ) ) );
296 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 297 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
297 SLOT( selection( QListBoxItem * ) ) ); 298 SLOT( selection( QListBoxItem * ) ) );
298 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 299 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
299 SLOT( cellClicked( QListBoxItem * ) ) ); 300 SLOT( cellClicked( QListBoxItem * ) ) );
300 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 301 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
301 SLOT( selection( QListBoxItem * ) ) ); 302 SLOT( selection( QListBoxItem * ) ) );
302} 303}
303#ifdef DESKTOP_VERSION 304#ifdef DESKTOP_VERSION
304QToolTipGroup *MonthViewCell::toolTipGroup() 305QToolTipGroup *MonthViewCell::toolTipGroup()
305{ 306{
306 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 307 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
307 return mToolTipGroup; 308 return mToolTipGroup;
308} 309}
309#endif 310#endif
310 311
311void MonthViewCell::setDate( const QDate &date ) 312void MonthViewCell::setDate( const QDate &date )
312{ 313{
313// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 314// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
314 mDate = date; 315 mDate = date;
315 316
316 317
317 318
318 //resizeEvent( 0 ); 319 //resizeEvent( 0 );
319} 320}
320 321
321QDate MonthViewCell::date() const 322QDate MonthViewCell::date() const
322{ 323{
323 return mDate; 324 return mDate;
324} 325}
325 326
326void MonthViewCell::setPrimary( bool primary ) 327void MonthViewCell::setPrimary( bool primary )
327{ 328{
328 mPrimary = primary; 329 mPrimary = primary;
329 //setMyPalette(); 330 //setMyPalette();
330} 331}
331void MonthViewCell::setMyPalette() 332void MonthViewCell::setMyPalette()
332{ 333{
333 334
334 if ( mHoliday) { 335 if ( mHoliday) {
335 setPalette( mHolidayPalette ); 336 setPalette( mHolidayPalette );
336 } else { 337 } else {
337 if ( mPrimary ) { 338 if ( mPrimary ) {
338 setPalette( mPrimaryPalette ); 339 setPalette( mPrimaryPalette );
339 } else { 340 } else {
340 setPalette( mNonPrimaryPalette ); 341 setPalette( mNonPrimaryPalette );
341 } 342 }
342 } 343 }
343 QPalette pal = palette(); 344 QPalette pal = palette();
344 345
345 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 346 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
346} 347}
347QPalette MonthViewCell::getPalette () 348QPalette MonthViewCell::getPalette ()
348{ 349{
349 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 350 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
350 return mStandardPalette; 351 return mStandardPalette;
351 if ( mHoliday) { 352 if ( mHoliday) {
352 return mHolidayPalette ; 353 return mHolidayPalette ;
353 } else { 354 } else {
354 if ( mPrimary ) { 355 if ( mPrimary ) {
355 return mPrimaryPalette ; 356 return mPrimaryPalette ;
356 } 357 }
357 } 358 }
358 return mNonPrimaryPalette; 359 return mNonPrimaryPalette;
359} 360}
360bool MonthViewCell::isPrimary() const 361bool MonthViewCell::isPrimary() const
361{ 362{
362 return mPrimary; 363 return mPrimary;
363} 364}
364 365
365void MonthViewCell::setHoliday( bool holiday ) 366void MonthViewCell::setHoliday( bool holiday )
366{ 367{
367 mHoliday = holiday; 368 mHoliday = holiday;
368 //setMyPalette(); 369 //setMyPalette();
369} 370}
370 371
371void MonthViewCell::setHoliday( const QString &holiday ) 372void MonthViewCell::setHoliday( const QString &holiday )
372{ 373{
373 mHolidayString = holiday; 374 mHolidayString = holiday;
374 375
375 if ( !holiday.isEmpty() ) { 376 if ( !holiday.isEmpty() ) {
376 setHoliday( true ); 377 setHoliday( true );
377 } 378 }
378} 379}
379void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 380void MonthViewCell::keyPressEvent ( QKeyEvent * e )
380{ 381{
381 382
382 e->ignore(); 383 e->ignore();
383 384
384} 385}
385void MonthViewCell::clear() 386void MonthViewCell::clear()
386{ 387{
387 mItemList->clear(); 388 mItemList->clear();
388 QApplication::removePostedEvents ( mItemList ); 389 QApplication::removePostedEvents ( mItemList );
389 QApplication::removePostedEvents ( mLabel ); 390 QApplication::removePostedEvents ( mLabel );
390 QApplication::removePostedEvents ( this ); 391 QApplication::removePostedEvents ( this );
391} 392}
392void MonthViewCell::updateCell() 393void MonthViewCell::updateCell()
393{ 394{
394 if ( !mMonthView->isUpdatePossible() ) 395 if ( !mMonthView->isUpdatePossible() )
395 return; 396 return;
396 /* 397 /*
397 if ( !isVisible() ){ 398 if ( !isVisible() ){
398 return; 399 return;
399 } 400 }
400 */ 401 */
401 // qDebug("MonthViewCell::updateCell() "); 402 // qDebug("MonthViewCell::updateCell() ");
402 setPrimary( mDate.month()%2 ); 403 setPrimary( mDate.month()%2 );
403 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 404 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
404 if ( mDate == QDate::currentDate() ) { 405 if ( mDate == QDate::currentDate() ) {
405 mItemList->setLineWidth( 3 ); 406 mItemList->setLineWidth( 3 );
406 } else { 407 } else {
407 mItemList->setLineWidth( 1 ); 408 mItemList->setLineWidth( 1 );
408 } 409 }
409 mItemList->clear(); 410 mItemList->clear();
410 411
411#ifdef DESKTOP_VERSION 412#ifdef DESKTOP_VERSION
412 QToolTip::remove(this); 413 QToolTip::remove(this);
413#endif 414#endif
414 QString tipText(""); 415 QString tipText("");
415 //qApp->processEvents(); 416 //qApp->processEvents();
416 if ( !mHolidayString.isEmpty() ) { 417 if ( !mHolidayString.isEmpty() ) {
417 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 418 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
418 item->setPalette( mHolidayPalette ); 419 item->setPalette( mHolidayPalette );
419 mItemList->insertItem( item ); 420 mItemList->insertItem( item );
420 tipText += mHolidayString+"\n"; 421 tipText += mHolidayString+"\n";
421 } 422 }
422 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 423 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
423 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 424 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
424 Event *event; 425 Event *event;
425 for( event = events.first(); event; event = events.next() ) { // for event 426 for( event = events.first(); event; event = events.next() ) { // for event
426 427
427 if ( !(event->doesRecur() == Recurrence::rNone) ) { 428 if ( !(event->doesRecur() == Recurrence::rNone) ) {
428 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 429 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
429 continue; 430 continue;
430 else 431 else
431 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 432 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
432 continue; 433 continue;
433 } 434 }
434 435
435 if ( event->categories().contains("Holiday") || 436 if ( event->categories().contains("Holiday") ||
436 event->categories().contains(i18n("Holiday"))) { 437 event->categories().contains(i18n("Holiday"))) {
437 setHoliday( true ); 438 setHoliday( true );
438 if ( mDate.dayOfWeek() == 7 ) 439 if ( mDate.dayOfWeek() == 7 )
439 mItemList->setLineWidth( 3 ); 440 mItemList->setLineWidth( 3 );
440 } 441 }
441 QString text; 442 QString text;
442 if (event->isMultiDay()) { 443 if (event->isMultiDay()) {
443 QString prefix = "<->"; 444 QString prefix = "<->";
444 if ( event->doesRecur() ) { 445 if ( event->doesRecur() ) {
445 if ( event->recursOn( mDate) ) 446 if ( event->recursOn( mDate) )
446 prefix ="->" ; 447 prefix ="->" ;
447 else { 448 else {
448 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 449 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
449 if ( event->recursOn( mDate.addDays( -days)) ) 450 if ( event->recursOn( mDate.addDays( -days)) )
450 prefix ="<-" ; 451 prefix ="<-" ;
451 } 452 }
452 453
453 } else { 454 } else {
454 if (mDate == event->dtStart().date()) { 455 if (mDate == event->dtStart().date()) {
455 prefix ="->" ; 456 prefix ="->" ;
456 } else if (mDate == event->dtEnd().date()) { 457 } else if (mDate == event->dtEnd().date()) {
457 prefix ="<-" ; 458 prefix ="<-" ;
458 } 459 }
459 } 460 }
460 text = prefix + event->summary(); 461 text = prefix + event->summary();
461 tipText += text; 462 tipText += text;
462 } else { 463 } else {
463 if (event->doesFloat()) { 464 if (event->doesFloat()) {
464 text = event->summary(); 465 text = event->summary();
465 tipText += text; 466 tipText += text;
466 } 467 }
467 else { 468 else {
468 text = KGlobal::locale()->formatTime(event->dtStart().time()); 469 text = KGlobal::locale()->formatTime(event->dtStart().time());
469 text += " " + event->summary(); 470 text += " " + event->summary();
470 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 471 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
471 } 472 }
472 } 473 }
473 474
474 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 475 MonthViewItem *item = new MonthViewItem( event, mDate, text );
475 QPalette pal; 476 QPalette pal;
476 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 477 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
477 QStringList categories = event->categories(); 478 QStringList categories = event->categories();
478 QString cat = categories.first(); 479 QString cat = categories.first();
479 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 480 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
480 pal = getPalette(); 481 pal = getPalette();
481 if (cat.isEmpty()) { 482 if (cat.isEmpty()) {
482 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 483 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
483 } else { 484 } else {
484 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 485 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
485 } 486 }
486 487
487 } else { 488 } else {
488 if (cat.isEmpty()) { 489 if (cat.isEmpty()) {
489 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 490 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
490 } else { 491 } else {
491 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 492 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
492 } 493 }
493 } 494 }
494 495
495 } else { 496 } else {
496 pal = mStandardPalette ; 497 pal = mStandardPalette ;
497 } 498 }
498 item->setPalette( pal ); 499 item->setPalette( pal );
499 item->setRecur( event->recurrence()->doesRecur() ); 500 item->setRecur( event->recurrence()->doesRecur() );
500 item->setAlarm( event->isAlarmEnabled() ); 501 item->setAlarm( event->isAlarmEnabled() );
501 item->setMoreInfo( event->description().length() > 0 ); 502 item->setMoreInfo( event->description().length() > 0 );
502#ifdef DESKTOP_VERSION 503#ifdef DESKTOP_VERSION
503 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 504 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
504 KOPrefs::instance()->email()); 505 KOPrefs::instance()->email());
505 if ( me != 0 ) { 506 if ( me != 0 ) {
506 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 507 if ( me->status() == Attendee::NeedsAction && me->RSVP())
507 item->setReply(true); 508 item->setReply(true);
508 else 509 else
509 item->setReply(false); 510 item->setReply(false);
510 } else 511 } else
511 item->setReply(false); 512 item->setReply(false);
512#endif 513#endif
513 mItemList->insertItem( item ); 514 mItemList->insertItem( item );
514 tipText += "\n"; 515 tipText += "\n";
515 516
516 } 517 }
517 518
518 // insert due todos 519 // insert due todos
519 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 520 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
520 Todo *todo; 521 Todo *todo;
521 for(todo = todos.first(); todo; todo = todos.next()) { 522 for(todo = todos.first(); todo; todo = todos.next()) {
522 QString text; 523 QString text;
523 if (todo->hasDueDate()) { 524 if (todo->hasDueDate()) {
524 if (!todo->doesFloat()) { 525 if (!todo->doesFloat()) {
525 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 526 text += KGlobal::locale()->formatTime(todo->dtDue().time());
526 text += " "; 527 text += " ";
527 } 528 }
528 } 529 }
529 text += i18n("To-Do: %1").arg(todo->summary()); 530 text += i18n("To-Do: %1").arg(todo->summary());
530 531
531 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 532 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
532 //item->setPalette( mStandardPalette ); 533 //item->setPalette( mStandardPalette );
533 QPalette pal; 534 QPalette pal;
534 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 535 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
535 QStringList categories = todo->categories(); 536 QStringList categories = todo->categories();
536 QString cat = categories.first(); 537 QString cat = categories.first();
537 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 538 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
538 pal = getPalette(); 539 pal = getPalette();
539 if (cat.isEmpty()) { 540 if (cat.isEmpty()) {
540 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 541 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
541 } else { 542 } else {
542 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 543 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
543 } 544 }
544 545
545 } else { 546 } else {
546 if (cat.isEmpty()) { 547 if (cat.isEmpty()) {
547 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 548 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
548 } else { 549 } else {
549 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 550 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
550 } 551 }
551 } 552 }
552 553
553 } else { 554 } else {
554 pal = mStandardPalette ; 555 pal = mStandardPalette ;
555 } 556 }
556 item->setPalette( pal ); 557 item->setPalette( pal );
557 mItemList->insertItem( item ); 558 mItemList->insertItem( item );
558 tipText += text+"\n"; 559 tipText += text+"\n";
559 } 560 }
560#ifdef DESKTOP_VERSION 561#ifdef DESKTOP_VERSION
561 if (tipText != "") 562 if (tipText != "")
562 QToolTip::add(this,tipText,toolTipGroup(),""); 563 QToolTip::add(this,tipText,toolTipGroup(),"");
563#endif 564#endif
564 565
565 //setMyPalette(); 566 //setMyPalette();
566 setMyPalette(); 567 setMyPalette();
567 QString text; 568 QString text;
568 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 569 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
569 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 570 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
570 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 571 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
571 mLabel->resize( mLabelBigSize ); 572 mLabel->resize( mLabelBigSize );
572 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 573 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
573 } else { 574 } else {
574 mLabel->resize( mLabelSize ); 575 mLabel->resize( mLabelSize );
575 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 576 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
576 } 577 }
577 578
578 mLabel->setText( text ); 579 mLabel->setText( text );
579 resizeEvent( 0 ); 580 resizeEvent( 0 );
580 // if ( isVisible()) 581 // if ( isVisible())
581 //qApp->processEvents(); 582 //qApp->processEvents();
582} 583}
583 584
584void MonthViewCell::updateConfig() 585void MonthViewCell::updateConfig()
585{ 586{
586 587
587 setFont( KOPrefs::instance()->mMonthViewFont ); 588 setFont( KOPrefs::instance()->mMonthViewFont );
588 589
589 QFontMetrics fm( font() ); 590 QFontMetrics fm( font() );
590 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 591 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
591 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 592 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
592 mHolidayPalette = mStandardPalette; 593 mHolidayPalette = mStandardPalette;
593 mPrimaryPalette = mStandardPalette; 594 mPrimaryPalette = mStandardPalette;
594 mNonPrimaryPalette = mStandardPalette; 595 mNonPrimaryPalette = mStandardPalette;
595 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 596 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
596 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 597 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
597 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 598 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
598 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 599 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
599 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 600 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
600 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 601 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
601 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 602 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
602 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 603 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
603 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 604 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
604 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 605 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
605 } 606 }
606 updateCell(); 607 updateCell();
607} 608}
608 609
609void MonthViewCell::enableScrollBars( bool enabled ) 610void MonthViewCell::enableScrollBars( bool enabled )
610{ 611{
611 if ( enabled ) { 612 if ( enabled ) {
612 mItemList->setVScrollBarMode(QScrollView::Auto); 613 mItemList->setVScrollBarMode(QScrollView::Auto);
613 mItemList->setHScrollBarMode(QScrollView::Auto); 614 mItemList->setHScrollBarMode(QScrollView::Auto);
614 } else { 615 } else {
615 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 616 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
616 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 617 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
617 } 618 }
618} 619}
619 620
620Incidence *MonthViewCell::selectedIncidence() 621Incidence *MonthViewCell::selectedIncidence()
621{ 622{
622 int index = mItemList->currentItem(); 623 int index = mItemList->currentItem();
623 if ( index < 0 ) return 0; 624 if ( index < 0 ) return 0;
624 625
625 MonthViewItem *item = 626 MonthViewItem *item =
626 static_cast<MonthViewItem *>( mItemList->item( index ) ); 627 static_cast<MonthViewItem *>( mItemList->item( index ) );
627 628
628 if ( !item ) return 0; 629 if ( !item ) return 0;
629 630
630 return item->incidence(); 631 return item->incidence();
631} 632}
632 633
633QDate MonthViewCell::selectedIncidenceDate() 634QDate MonthViewCell::selectedIncidenceDate()
634{ 635{
635 QDate qd; 636 QDate qd;
636 int index = mItemList->currentItem(); 637 int index = mItemList->currentItem();
637 if ( index < 0 ) return qd; 638 if ( index < 0 ) return qd;
638 639
639 MonthViewItem *item = 640 MonthViewItem *item =
640 static_cast<MonthViewItem *>( mItemList->item( index ) ); 641 static_cast<MonthViewItem *>( mItemList->item( index ) );
641 642
642 if ( !item ) return qd; 643 if ( !item ) return qd;
643 644
644 return item->incidenceDate(); 645 return item->incidenceDate();
645} 646}
646 647
647void MonthViewCell::deselect() 648void MonthViewCell::deselect()
648{ 649{
649 mItemList->clearSelection(); 650 mItemList->clearSelection();
650 enableScrollBars( false ); 651 enableScrollBars( false );
651 // updateCell(); 652 // updateCell();
652} 653}
653void MonthViewCell::select() 654void MonthViewCell::select()
654{ 655{
655 ;// updateCell(); 656 ;// updateCell();
656} 657}
657 658
658void MonthViewCell::resizeEvent ( QResizeEvent * ) 659void MonthViewCell::resizeEvent ( QResizeEvent * )
659{ 660{
660 if ( !mMonthView->isUpdatePossible() ) 661 if ( !mMonthView->isUpdatePossible() )
661 return; 662 return;
663#ifndef DESKTOP_VERSION
662 if ( !isVisible() ){ 664 if ( !isVisible() ){
663 return; 665 return;
664 } 666 }
667#endif
665 int size = height() - mLabel->height(); 668 int size = height() - mLabel->height();
666 if ( size > 0 ) 669 if ( size > 0 )
667 mItemList->verticalScrollBar()->setMaximumHeight( size ); 670 mItemList->verticalScrollBar()->setMaximumHeight( size );
668 size = width() - mLabel->width(); 671 size = width() - mLabel->width();
669 if ( size > 0 ) 672 if ( size > 0 )
670 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 673 mItemList->horizontalScrollBar()->setMaximumWidth( size );
671 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 674 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
672 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 675 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
673} 676}
674 677
675void MonthViewCell::defaultAction( QListBoxItem *item ) 678void MonthViewCell::defaultAction( QListBoxItem *item )
676{ 679{
677 if ( !item ) return; 680 if ( !item ) return;
678 681
679 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 682 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
680 Incidence *incidence = eventItem->incidence(); 683 Incidence *incidence = eventItem->incidence();
681 if ( incidence ) mMonthView->defaultAction( incidence ); 684 if ( incidence ) mMonthView->defaultAction( incidence );
682} 685}
683void MonthViewCell::showDay() 686void MonthViewCell::showDay()
684{ 687{
685 emit showDaySignal( date() ); 688 emit showDaySignal( date() );
686} 689}
687void MonthViewCell::newEvent() 690void MonthViewCell::newEvent()
688{ 691{
689 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 692 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
690 emit newEventSignal( dt ); 693 emit newEventSignal( dt );
691} 694}
692void MonthViewCell::cellClicked( QListBoxItem *item ) 695void MonthViewCell::cellClicked( QListBoxItem *item )
693{ 696{
694 static QListBoxItem * lastClicked = 0; 697 static QListBoxItem * lastClicked = 0;
695 if ( item == 0 ) { 698 if ( item == 0 ) {
696 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 699 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
697 emit newEventSignal( dt ); 700 emit newEventSignal( dt );
698 return; 701 return;
699 } 702 }
700 /* 703 /*
701 if ( lastClicked ) 704 if ( lastClicked )
702 if ( ! item ) { 705 if ( ! item ) {
703 if ( lastClicked->listBox() != item->listBox() ) 706 if ( lastClicked->listBox() != item->listBox() )
704 lastClicked->listBox()->clearSelection(); 707 lastClicked->listBox()->clearSelection();
705 } 708 }
706 */ 709 */
707 710
708 mMonthView->setSelectedCell( this ); 711 mMonthView->setSelectedCell( this );
709 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 712 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
710 select(); 713 select();
711} 714}
712 715
713void MonthViewCell::contextMenu( QListBoxItem *item ) 716void MonthViewCell::contextMenu( QListBoxItem *item )
714{ 717{
715 if ( !item ) return; 718 if ( !item ) return;
716 719
717 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 720 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
718 Incidence *incidence = eventItem->incidence(); 721 Incidence *incidence = eventItem->incidence();
719 if ( incidence ) mMonthView->showContextMenu( incidence ); 722 if ( incidence ) mMonthView->showContextMenu( incidence );
720} 723}
721 724
722void MonthViewCell::selection( QListBoxItem *item ) 725void MonthViewCell::selection( QListBoxItem *item )
723{ 726{
724 if ( !item ) return; 727 if ( !item ) return;
725 728
726 mMonthView->setSelectedCell( this ); 729 mMonthView->setSelectedCell( this );
727} 730}
728 731
729 732
730// ******************************************************************************* 733// *******************************************************************************
731// ******************************************************************************* 734// *******************************************************************************
732// ******************************************************************************* 735// *******************************************************************************
733 736
734 737
735KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 738KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
736 : KOEventView( calendar, parent, name ), 739 : KOEventView( calendar, parent, name ),
737 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 740 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
738 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 741 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
739{ 742{
740 updatePossible = false; 743
744 updatePossible = false;
741 mCells.setAutoDelete( true ); 745 mCells.setAutoDelete( true );
742 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 746 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
743 // mDayLayout = new QGridLayout( this ); 747 // mDayLayout = new QGridLayout( this );
744 // create the day of the week labels (Sun, Mon, etc) and add them to 748 // create the day of the week labels (Sun, Mon, etc) and add them to
745 // the layout. 749 // the layout.
746 mDayLabels.resize( mDaysPerWeek ); 750 mDayLabels.resize( mDaysPerWeek );
747 QFont bfont = font(); 751 QFont bfont = font();
748 if ( QApplication::desktop()->width() < 650 ) { 752 if ( QApplication::desktop()->width() < 650 ) {
749 bfont.setPointSize( bfont.pointSize() - 2 ); 753 bfont.setPointSize( bfont.pointSize() - 2 );
750 } 754 }
751 bfont.setBold( true ); 755 bfont.setBold( true );
752 int i; 756 int i;
753 757
754 for( i = 0; i < mDaysPerWeek; i++ ) { 758 for( i = 0; i < mDaysPerWeek; i++ ) {
755 QLabel *label = new QLabel( this ); 759 QLabel *label = new QLabel( this );
756 label->setFont(bfont); 760 label->setFont(bfont);
757 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 761 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
758 label->setLineWidth(1); 762 label->setLineWidth(1);
759 label->setAlignment(AlignCenter); 763 label->setAlignment(AlignCenter);
760 mDayLabels.insert( i, label ); 764 mDayLabels.insert( i, label );
761 } 765 }
762 766
763 bfont.setBold( false ); 767 bfont.setBold( false );
764 mWeekLabels.resize( mNumWeeks+1 ); 768 mWeekLabels.resize( mNumWeeks+1 );
765 for( i = 0; i < mNumWeeks+1; i++ ) { 769 for( i = 0; i < mNumWeeks+1; i++ ) {
766 KOWeekButton *label = new KOWeekButton( this ); 770 KOWeekButton *label = new KOWeekButton( this );
767 label->setFont(bfont); 771 label->setFont(bfont);
768 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); 772 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
769 label->setFlat(true); 773 label->setFlat(true);
770 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); 774 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
771 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 775 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
772 //label->setLineWidth(1); 776 //label->setLineWidth(1);
773 //label->setAlignment(AlignCenter); 777 //label->setAlignment(AlignCenter);
774 mWeekLabels.insert( i, label ); 778 mWeekLabels.insert( i, label );
775 } 779 }
776 mWeekLabels[mNumWeeks]->setText( i18n("W")); 780 mWeekLabels[mNumWeeks]->setText( i18n("W"));
777 int row, col; 781 int row, col;
778 mCells.resize( mNumCells ); 782 mCells.resize( mNumCells );
779 for( row = 0; row < mNumWeeks; ++row ) { 783 for( row = 0; row < mNumWeeks; ++row ) {
780 for( col = 0; col < mDaysPerWeek; ++col ) { 784 for( col = 0; col < mDaysPerWeek; ++col ) {
781 MonthViewCell *cell = new MonthViewCell( this ); 785 MonthViewCell *cell = new MonthViewCell( this );
782 mCells.insert( row * mDaysPerWeek + col, cell ); 786 mCells.insert( row * mDaysPerWeek + col, cell );
783 787
784 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 788 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
785 SLOT( defaultAction( Incidence * ) ) ); 789 SLOT( defaultAction( Incidence * ) ) );
786 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 790 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
787 SIGNAL( newEventSignal( QDateTime ) ) ); 791 SIGNAL( newEventSignal( QDateTime ) ) );
788 connect( cell, SIGNAL( showDaySignal( QDate ) ), 792 connect( cell, SIGNAL( showDaySignal( QDate ) ),
789 SIGNAL( showDaySignal( QDate ) ) ); 793 SIGNAL( showDaySignal( QDate ) ) );
790 } 794 }
791 } 795 }
792 796
793 mContextMenu = eventPopup(); 797 mContextMenu = eventPopup();
794 // updateConfig(); //useless here 798 // updateConfig(); //useless here
795 799
796 emit incidenceSelected( 0 ); 800 emit incidenceSelected( 0 );
797} 801}
798 802
799KOMonthView::~KOMonthView() 803KOMonthView::~KOMonthView()
800{ 804{
801 delete mContextMenu; 805 delete mContextMenu;
802} 806}
803 807
804int KOMonthView::maxDatesHint() 808int KOMonthView::maxDatesHint()
805{ 809{
806 return mNumCells; 810 return mNumCells;
807} 811}
808 812
809int KOMonthView::currentDateCount() 813int KOMonthView::currentDateCount()
810{ 814{
811 return mNumCells; 815 return mNumCells;
812} 816}
813 817
814QPtrList<Incidence> KOMonthView::selectedIncidences() 818QPtrList<Incidence> KOMonthView::selectedIncidences()
815{ 819{
816 QPtrList<Incidence> selected; 820 QPtrList<Incidence> selected;
817 821
818 if ( mSelectedCell ) { 822 if ( mSelectedCell ) {
819 Incidence *incidence = mSelectedCell->selectedIncidence(); 823 Incidence *incidence = mSelectedCell->selectedIncidence();
820 if ( incidence ) selected.append( incidence ); 824 if ( incidence ) selected.append( incidence );
821 } 825 }
822 826
823 return selected; 827 return selected;
824} 828}
825 829
826DateList KOMonthView::selectedDates() 830DateList KOMonthView::selectedDates()
827{ 831{
828 DateList selected; 832 DateList selected;
829 833
830 if ( mSelectedCell ) { 834 if ( mSelectedCell ) {
831 QDate qd = mSelectedCell->selectedIncidenceDate(); 835 QDate qd = mSelectedCell->selectedIncidenceDate();
832 if ( qd.isValid() ) selected.append( qd ); 836 if ( qd.isValid() ) selected.append( qd );
833 } 837 }
834 838
835 return selected; 839 return selected;
836} 840}
837 841
838void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 842void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
839 const QDate &td) 843 const QDate &td)
840{ 844{
841#ifndef KORG_NOPRINTER 845#ifndef KORG_NOPRINTER
842 calPrinter->preview(CalPrinter::Month, fd, td); 846 calPrinter->preview(CalPrinter::Month, fd, td);
843#endif 847#endif
844} 848}
845 849
846void KOMonthView::updateConfig() 850void KOMonthView::updateConfig()
847{ 851{
848 852
849 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 853 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
850 854
851 QFontMetrics fontmetric(mDayLabels[0]->font()); 855 QFontMetrics fontmetric(mDayLabels[0]->font());
852 mWidthLongDayLabel = 0; 856 mWidthLongDayLabel = 0;
853 857
854 for (int i = 0; i < 7; i++) { 858 for (int i = 0; i < 7; i++) {
855 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 859 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
856 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 860 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
857 } 861 }
858 bool temp = mShowSatSunComp ; 862 bool temp = mShowSatSunComp ;
859 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 863 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
860 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 864 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
861 computeLayout(); 865 computeLayout();
862 updateDayLabels(); 866 updateDayLabels();
863 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 867 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
864 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 868 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
865 //resizeEvent( 0 ); 869 //resizeEvent( 0 );
866 for (uint i = 0; i < mCells.count(); ++i) { 870 for (uint i = 0; i < mCells.count(); ++i) {
867 mCells[i]->updateConfig(); 871 mCells[i]->updateConfig();
868 } 872 }
869#ifdef DESKTOP_VERSION 873#ifdef DESKTOP_VERSION
870 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 874 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
871#endif 875#endif
872} 876}
873 877
874void KOMonthView::updateDayLabels() 878void KOMonthView::updateDayLabels()
875{ 879{
876 880
877 for (int i = 0; i < 7; i++) { 881 for (int i = 0; i < 7; i++) {
878 if (mWeekStartsMonday) { 882 if (mWeekStartsMonday) {
879 bool show = mShortDayLabels; 883 bool show = mShortDayLabels;
880 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 884 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
881 show = true; 885 show = true;
882 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 886 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
883 } else { 887 } else {
884 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 888 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
885 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 889 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
886 890
887 } 891 }
888 } 892 }
889} 893}
890 894
891void KOMonthView::showDates(const QDate &start, const QDate &) 895void KOMonthView::showDates(const QDate &start, const QDate &)
892{ 896{
893// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 897// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
894 898
895 899
896 mStartDate = start; 900 mStartDate = start;
897 901
898 int startWeekDay = mWeekStartsMonday ? 1 : 7; 902 int startWeekDay = mWeekStartsMonday ? 1 : 7;
899 903
900 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 904 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
901 mStartDate = mStartDate.addDays( -1 ); 905 mStartDate = mStartDate.addDays( -1 );
902 } 906 }
903 907
904 bool primary = false; 908 bool primary = false;
905 uint i; 909 uint i;
906 for( i = 0; i < mCells.size(); ++i ) { 910 for( i = 0; i < mCells.size(); ++i ) {
907 QDate date = mStartDate.addDays( i ); 911 QDate date = mStartDate.addDays( i );
908 mCells[i]->setDate( date ); 912 mCells[i]->setDate( date );
909 913
910#ifndef KORG_NOPLUGINS 914#ifndef KORG_NOPLUGINS
911 // add holiday, if present 915 // add holiday, if present
912 QString hstring(KOCore::self()->holiday(date)); 916 QString hstring(KOCore::self()->holiday(date));
913 mCells[i]->setHoliday( hstring ); 917 mCells[i]->setHoliday( hstring );
914#endif 918#endif
915 919
916 } 920 }
917 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 921 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
918 for( i = 0; i < 6; ++i ) { 922 for( i = 0; i < 6; ++i ) {
919 int wno; 923 int wno;
920 // remember, according to ISO 8601, the first week of the year is the 924 // remember, according to ISO 8601, the first week of the year is the
921 // first week that contains a thursday. Thus we must subtract off 4, 925 // first week that contains a thursday. Thus we must subtract off 4,
922 // not just 1. 926 // not just 1.
923 int dayOfYear = date.dayOfYear(); 927 int dayOfYear = date.dayOfYear();
924 if (dayOfYear % 7 != 0) 928 if (dayOfYear % 7 != 0)
925 wno = dayOfYear / 7 + 1; 929 wno = dayOfYear / 7 + 1;
926 else 930 else
927 wno =dayOfYear / 7; 931 wno =dayOfYear / 7;
928 mWeekLabels[i]->setWeekNum( wno ); 932 mWeekLabels[i]->setWeekNum( wno );
929 date = date.addDays( 7 ); 933 date = date.addDays( 7 );
930 } 934 }
931 updateView(); 935 updateView();
932} 936}
933 937
934void KOMonthView::showEvents(QPtrList<Event>) 938void KOMonthView::showEvents(QPtrList<Event>)
935{ 939{
936 qDebug("KOMonthView::selectEvents is not implemented yet. "); 940 qDebug("KOMonthView::selectEvents is not implemented yet. ");
937} 941}
938 942
939void KOMonthView::changeEventDisplay(Event *, int) 943void KOMonthView::changeEventDisplay(Event *, int)
940{ 944{
941 // this should be re-written to be much more efficient, but this 945 // this should be re-written to be much more efficient, but this
942 // quick-and-dirty-hack gets the job done for right now. 946 // quick-and-dirty-hack gets the job done for right now.
943 updateView(); 947 updateView();
944} 948}
945 949
946void KOMonthView::updateView() 950void KOMonthView::updateView()
947{ 951{
948 if ( !updatePossible ) 952 if ( !updatePossible )
949 return; 953 return;
950 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 954 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
951 int i; 955 int i;
952 for( i = 0; i < mCells.count(); ++i ) { 956 for( i = 0; i < mCells.count(); ++i ) {
953 mCells[i]->updateCell(); 957 mCells[i]->updateCell();
954 } 958 }
955 959
956 //qDebug("KOMonthView::updateView() "); 960 //qDebug("KOMonthView::updateView() ");
957 processSelectionChange(); 961 processSelectionChange();
958 // qDebug("---------------------------------------------------------------------+ "); 962 // qDebug("---------------------------------------------------------------------+ ");
959} 963}
960 964
961void KOMonthView::resizeEvent(QResizeEvent * e) 965void KOMonthView::resizeEvent(QResizeEvent * e)
962{ 966{
963 computeLayout(); 967 computeLayout();
964} 968}
965void KOMonthView::computeLayout() 969void KOMonthView::computeLayout()
966{ 970{
967 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 971 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
968 // note this only changes the text if the requested size crosses the 972 // note this only changes the text if the requested size crosses the
969 // threshold between big enough to support the full name and not big 973 // threshold between big enough to support the full name and not big
970 // enough. 974 // enough.
971 975
972 int daysToShow = 7; 976 int daysToShow = 7;
973 bool combinedSatSun = false; 977 bool combinedSatSun = false;
974 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 978 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
975 daysToShow = 6; 979 daysToShow = 6;
976 combinedSatSun = true; 980 combinedSatSun = true;
977 } 981 }
978 int tWid = topLevelWidget()->size().width(); 982 int tWid = topLevelWidget()->size().width();
979 int tHei = topLevelWidget()->size().height(); 983 int tHei = topLevelWidget()->size().height();
980 984
981 int wid = size().width();//e 985 int wid = size().width();//e
982 int hei = size().height()-1; 986 int hei = size().height()-1;
983 987
984 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 988 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
985 return; 989 return;
986 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 990 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
987 QFontMetrics fm ( mWeekLabels[0]->font() ); 991 QFontMetrics fm ( mWeekLabels[0]->font() );
988 int weeklabelwid = fm.width( "888" ); 992 int weeklabelwid = fm.width( "888" );
989 wid -= weeklabelwid; 993 wid -= weeklabelwid;
990 994
991 int colWid = wid / daysToShow; 995 int colWid = wid / daysToShow;
992 int lastCol = wid - ( colWid*6 ); 996 int lastCol = wid - ( colWid*6 );
993 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 997 int dayLabelHei = mDayLabels[0]->sizeHint().height();
994 int cellHei = (hei - dayLabelHei) /6; 998 int cellHei = (hei - dayLabelHei) /6;
995 int colModulo = wid % daysToShow; 999 int colModulo = wid % daysToShow;
996 int rowModulo = (hei- dayLabelHei) % 6; 1000 int rowModulo = (hei- dayLabelHei) % 6;
997 //qDebug("rowmod %d ", rowModulo); 1001 //qDebug("rowmod %d ", rowModulo);
998 int i; 1002 int i;
999 int x,y,w,h; 1003 int x,y,w,h;
1000 x= 0; 1004 x= 0;
1001 y= 0; 1005 y= 0;
1002 w = colWid; 1006 w = colWid;
1003 h = dayLabelHei ; 1007 h = dayLabelHei ;
1004 for ( i = 0; i < 7; i++) { 1008 for ( i = 0; i < 7; i++) {
1005 if ( i == daysToShow-colModulo ) 1009 if ( i == daysToShow-colModulo )
1006 ++w; 1010 ++w;
1007 if ( combinedSatSun ) { 1011 if ( combinedSatSun ) {
1008 if ( i >= daysToShow-1 ) { 1012 if ( i >= daysToShow-1 ) {
1009 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1013 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1010 x -= w/2 ; 1014 x -= w/2 ;
1011 } 1015 }
1012 else 1016 else
1013 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1017 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1014 } else 1018 } else
1015 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1019 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1016 x += w; 1020 x += w;
1017 } 1021 }
1018 x= 0; 1022 x= 0;
1019 y= dayLabelHei; 1023 y= dayLabelHei;
1020 w = colWid; 1024 w = colWid;
1021 h = cellHei ; 1025 h = cellHei ;
1022 for ( i = 0; i < mCells.count(); ++i) { 1026 for ( i = 0; i < mCells.count(); ++i) {
1023 1027
1024 w = colWid; 1028 w = colWid;
1025 if ( ((i) % 7) >= 7-colModulo ) { 1029 if ( ((i) % 7) >= 7-colModulo ) {
1026 ++w; 1030 ++w;
1027 } 1031 }
1028 if ( i == (6-rowModulo)*7) 1032 if ( i == (6-rowModulo)*7)
1029 ++h; 1033 ++h;
1030 if ( combinedSatSun ) { 1034 if ( combinedSatSun ) {
1031 if ( (i)%7 >= daysToShow-1 ) { 1035 if ( (i)%7 >= daysToShow-1 ) {
1032 if ( (i)%7 == daysToShow-1 ) { 1036 if ( (i)%7 == daysToShow-1 ) {
1033 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1037 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1034 x -= w ;y += h/2; 1038 x -= w ;y += h/2;
1035 } else { 1039 } else {
1036 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1040 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1037 y -= h/2; 1041 y -= h/2;
1038 } 1042 }
1039 } else 1043 } else
1040 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1044 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1041 1045
1042 } 1046 }
1043 else 1047 else
1044 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1048 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1045 x += w; 1049 x += w;
1046 if ( x + w/2 > wid ) { 1050 if ( x + w/2 > wid ) {
1047 x = 0; 1051 x = 0;
1048 y += h; 1052 y += h;
1049 } 1053 }
1050 } 1054 }
1051 y= dayLabelHei; 1055 y= dayLabelHei;
1052 h = cellHei ; 1056 h = cellHei ;
1053 for ( i = 0; i < 6; i++) { 1057 for ( i = 0; i < 6; i++) {
1054 if ( i == (6-rowModulo)) 1058 if ( i == (6-rowModulo))
1055 ++h; 1059 ++h;
1056 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1060 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1057 y += h; 1061 y += h;
1058 } 1062 }
1059 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1063 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1060 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1064 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1061 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1065 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1062 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1066 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1063 updateDayLabels(); 1067 updateDayLabels();
1064 bool forceUpdate = !updatePossible; 1068 bool forceUpdate = !updatePossible;
1065 updatePossible = true; 1069 updatePossible = true;
1066 if ( forceUpdate ) 1070 if ( forceUpdate )
1067 updateView(); 1071 updateView();
1068} 1072}
1069 1073
1070void KOMonthView::showContextMenu( Incidence *incidence ) 1074void KOMonthView::showContextMenu( Incidence *incidence )
1071{ 1075{
1072 mContextMenu->showIncidencePopup(incidence); 1076 mContextMenu->showIncidencePopup(incidence);
1073 /* 1077 /*
1074 if( incidence && incidence->type() == "Event" ) { 1078 if( incidence && incidence->type() == "Event" ) {
1075 Event *event = static_cast<Event *>(incidence); 1079 Event *event = static_cast<Event *>(incidence);
1076 mContextMenu->showEventPopup(event); 1080 mContextMenu->showEventPopup(event);
1077 } else { 1081 } else {
1078 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1082 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1079 } 1083 }
1080 */ 1084 */
1081} 1085}
1082MonthViewCell * KOMonthView::selectedCell( ) 1086MonthViewCell * KOMonthView::selectedCell( )
1083{ 1087{
1084 return mSelectedCell; 1088 return mSelectedCell;
1085} 1089}
1086void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1090void KOMonthView::setSelectedCell( MonthViewCell *cell )
1087{ 1091{
1088 // qDebug("KOMonthView::setSelectedCell "); 1092 // qDebug("KOMonthView::setSelectedCell ");
1089 if ( mSelectedCell && mSelectedCell != cell ) { 1093 if ( mSelectedCell && mSelectedCell != cell ) {
1090 MonthViewCell * mvc = mSelectedCell; 1094 MonthViewCell * mvc = mSelectedCell;
1091 mSelectedCell = cell; 1095 mSelectedCell = cell;
1092 mvc->deselect(); 1096 mvc->deselect();
1093 } else 1097 } else
1094 mSelectedCell = cell; 1098 mSelectedCell = cell;
1095 // if ( mSelectedCell ) 1099 // if ( mSelectedCell )
1096// mSelectedCell->select(); 1100// mSelectedCell->select();
1097 if ( !mSelectedCell ) 1101 if ( !mSelectedCell )
1098 emit incidenceSelected( 0 ); 1102 emit incidenceSelected( 0 );
1099 else 1103 else
1100 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1104 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1101} 1105}
1102 1106
1103void KOMonthView::processSelectionChange() 1107void KOMonthView::processSelectionChange()
1104{ 1108{
1105 QPtrList<Incidence> incidences = selectedIncidences(); 1109 QPtrList<Incidence> incidences = selectedIncidences();
1106 if (incidences.count() > 0) { 1110 if (incidences.count() > 0) {
1107 emit incidenceSelected( incidences.first() ); 1111 emit incidenceSelected( incidences.first() );
1108 } else { 1112 } else {
1109 emit incidenceSelected( 0 ); 1113 emit incidenceSelected( 0 );
1110 } 1114 }
1111} 1115}
1112 1116
1113void KOMonthView::clearSelection() 1117void KOMonthView::clearSelection()
1114{ 1118{
1115 if ( mSelectedCell ) { 1119 if ( mSelectedCell ) {
1116 mSelectedCell->deselect(); 1120 mSelectedCell->deselect();
1117 mSelectedCell = 0; 1121 mSelectedCell = 0;
1118 } 1122 }
1119} 1123}
1120void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1124void KOMonthView::keyPressEvent ( QKeyEvent * e )
1121{ 1125{
1122 1126
1123 e->ignore(); 1127 e->ignore();
1124 1128
1125} 1129}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index dbbe832..ddd9cf8 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,471 +1,471 @@
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 <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49KOPrefs *KOPrefs::mInstance = 0; 49KOPrefs *KOPrefs::mInstance = 0;
50static KStaticDeleter<KOPrefs> insd; 50static KStaticDeleter<KOPrefs> insd;
51 51
52KOPrefs::KOPrefs() : 52KOPrefs::KOPrefs() :
53 KPimPrefs("korganizerrc") 53 KPimPrefs("korganizerrc")
54{ 54{
55 mCategoryColors.setAutoDelete(true); 55 mCategoryColors.setAutoDelete(true);
56 fillMailDefaults(); 56 fillMailDefaults();
57 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 57 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
58 QColor defaultHolidayColor = QColor(255,0,0); 58 QColor defaultHolidayColor = QColor(255,0,0);
59 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 59 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
60 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 60 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
61 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 61 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
62 QColor defaultTodoDueTodayColor = QColor(255,220,100); 62 QColor defaultTodoDueTodayColor = QColor(255,220,100);
63 QColor defaultTodoOverdueColor = QColor(255,153,125); 63 QColor defaultTodoOverdueColor = QColor(255,153,125);
64 64
65 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 65 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
66 mDefaultViewFont = QFont("helvetica",10); 66 mDefaultViewFont = QFont("helvetica",10);
67 mDefaultMonthViewFont = QFont("helvetica",8); 67 mDefaultMonthViewFont = QFont("helvetica",8);
68 mMarcusBainsFont= QFont("helvetica",10); 68 mMarcusBainsFont= QFont("helvetica",10);
69 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 69 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
70 mEditBoxFont = QFont("helvetica",12); 70 mEditBoxFont = QFont("helvetica",12);
71 mJornalViewFont = QFont("helvetica",12); 71 mJornalViewFont = QFont("helvetica",12);
72 72
73 KPrefs::setCurrentGroup("General"); 73 KPrefs::setCurrentGroup("General");
74 74
75 75
76 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 76 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
77 77
78 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 78 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
79 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 79 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
80 addItemBool("ShowIconSearch",&mShowIconSearch,true); 80 addItemBool("ShowIconSearch",&mShowIconSearch,true);
81 addItemBool("ShowIconList",&mShowIconList,true); 81 addItemBool("ShowIconList",&mShowIconList,true);
82 addItemBool("ShowIconDay1",&mShowIconDay1,true); 82 addItemBool("ShowIconDay1",&mShowIconDay1,true);
83 addItemBool("ShowIconDay5",&mShowIconDay5,true); 83 addItemBool("ShowIconDay5",&mShowIconDay5,true);
84 addItemBool("ShowIconDay7",&mShowIconDay7,true); 84 addItemBool("ShowIconDay7",&mShowIconDay7,true);
85 addItemBool("ShowIconMonth",&mShowIconMonth,true); 85 addItemBool("ShowIconMonth",&mShowIconMonth,true);
86 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 86 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
87 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 87 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
88 addItemBool("ShowIconBack",&mShowIconBack,true); 88 addItemBool("ShowIconBack",&mShowIconBack,true);
89 addItemBool("ShowIconToday",&mShowIconToday,true); 89 addItemBool("ShowIconToday",&mShowIconToday,true);
90 addItemBool("ShowIconForward",&mShowIconForward,true); 90 addItemBool("ShowIconForward",&mShowIconForward,true);
91 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 91 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
92 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 92 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
93 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 93 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
94 addItemBool("ShowIconNext",&mShowIconNext,true); 94 addItemBool("ShowIconNext",&mShowIconNext,true);
95 addItemBool("ShowIconJournal",&mShowIconJournal,true); 95 addItemBool("ShowIconJournal",&mShowIconJournal,true);
96 addItemBool("ShowIconStretch",&mShowIconStretch,true); 96 addItemBool("ShowIconStretch",&mShowIconStretch,true);
97 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 97 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
98 98
99 addItemBool("AskForQuit",&mAskForQuit,false); 99 addItemBool("AskForQuit",&mAskForQuit,false);
100 100
101#ifndef DESKTOP_VERSION 101#ifndef DESKTOP_VERSION
102 addItemBool("ShowFullMenu",&mShowFullMenu,false); 102 addItemBool("ShowFullMenu",&mShowFullMenu,false);
103#else 103#else
104 addItemBool("ShowFullMenu",&mShowFullMenu,true); 104 addItemBool("ShowFullMenu",&mShowFullMenu,true);
105#endif 105#endif
106 addItemBool("ToolBarHor",&mToolBarHor, true ); 106 addItemBool("ToolBarHor",&mToolBarHor, true );
107 addItemBool("ToolBarUp",&mToolBarUp, false ); 107 addItemBool("ToolBarUp",&mToolBarUp, false );
108 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 108 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
109 addItemInt("Whats Next Days",&mWhatsNextDays,3); 109 addItemInt("Whats Next Days",&mWhatsNextDays,3);
110 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 110 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
111 111
112 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 112 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
113 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 113 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
114 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 114 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
115 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 115 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
116 addItemInt("AllDay Size",&mAllDaySize,28); 116 addItemInt("AllDay Size",&mAllDaySize,28);
117 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 117 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
118 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 118 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
119 119
120 addItemStringList("LocationDefaults",&mLocationDefaults ); 120 addItemStringList("LocationDefaults",&mLocationDefaults );
121 addItemStringList("EventSummary User",&mEventSummaryUser); 121 addItemStringList("EventSummary User",&mEventSummaryUser);
122 addItemStringList("TodoSummary User",&mTodoSummaryUser); 122 addItemStringList("TodoSummary User",&mTodoSummaryUser);
123 123
124 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 124 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
125 addItemBool("Enable Project View",&mEnableProjectView,false); 125 addItemBool("Enable Project View",&mEnableProjectView,false);
126 addItemBool("Auto Save",&mAutoSave,false); 126 addItemBool("Auto Save",&mAutoSave,false);
127 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 127 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
128 addItemBool("Confirm Deletes",&mConfirm,true); 128 addItemBool("Confirm Deletes",&mConfirm,true);
129 addItemString("Archive File",&mArchiveFile); 129 addItemString("Archive File",&mArchiveFile);
130 addItemString("Html Export File",&mHtmlExportFile, 130 addItemString("Html Export File",&mHtmlExportFile,
131 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 131 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
132 addItemBool("Html With Save",&mHtmlWithSave,false); 132 addItemBool("Html With Save",&mHtmlWithSave,false);
133 133
134 KPrefs::setCurrentGroup("Personal Settings"); 134 KPrefs::setCurrentGroup("Personal Settings");
135 135
136 addItemInt("Mail Client",&mMailClient,MailClientKMail); 136 addItemInt("Mail Client",&mMailClient,MailClientKMail);
137 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 137 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
138 addItemBool("Bcc",&mBcc,false); 138 addItemBool("Bcc",&mBcc,false);
139 139
140 KPrefs::setCurrentGroup("Time & Date"); 140 KPrefs::setCurrentGroup("Time & Date");
141 141
142 142
143 addItemInt("Default Start Time",&mStartTime,10); 143 addItemInt("Default Start Time",&mStartTime,10);
144 addItemInt("Default Duration",&mDefaultDuration,2); 144 addItemInt("Default Duration",&mDefaultDuration,2);
145 addItemInt("Default Alarm Time",&mAlarmTime,3); 145 addItemInt("Default Alarm Time",&mAlarmTime,3);
146 KPrefs::setCurrentGroup("AlarmSettings"); 146 KPrefs::setCurrentGroup("AlarmSettings");
147 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 147 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
148 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 148 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
149 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 149 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
150 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 150 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
151 151
152 152
153 KPrefs::setCurrentGroup("Calendar"); 153 KPrefs::setCurrentGroup("Calendar");
154 154
155 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 155 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
156 156
157 KPrefs::setCurrentGroup("Fonts"); 157 KPrefs::setCurrentGroup("Fonts");
158 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 158 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
159 addItemFont("TimeBar Font",&mTimeBarFont); 159 addItemFont("TimeBar Font",&mTimeBarFont);
160 addItemFont("MonthView Font",&mMonthViewFont); 160 addItemFont("MonthView Font",&mMonthViewFont);
161 addItemFont("AgendaView Font",&mAgendaViewFont); 161 addItemFont("AgendaView Font",&mAgendaViewFont);
162 addItemFont("MarcusBains Font",&mMarcusBainsFont); 162 addItemFont("MarcusBains Font",&mMarcusBainsFont);
163 addItemFont("TimeLabels Font",&mTimeLabelsFont); 163 addItemFont("TimeLabels Font",&mTimeLabelsFont);
164 addItemFont("TodoView Font",&mTodoViewFont); 164 addItemFont("TodoView Font",&mTodoViewFont);
165 addItemFont("ListView Font",&mListViewFont); 165 addItemFont("ListView Font",&mListViewFont);
166 addItemFont("DateNavigator Font",&mDateNavigatorFont); 166 addItemFont("DateNavigator Font",&mDateNavigatorFont);
167 addItemFont("EditBox Font",&mEditBoxFont); 167 addItemFont("EditBox Font",&mEditBoxFont);
168 addItemFont("JournalView Font",&mJornalViewFont); 168 addItemFont("JournalView Font",&mJornalViewFont);
169 addItemFont("WhatsNextView Font",&mWhatsNextFont); 169 addItemFont("WhatsNextView Font",&mWhatsNextFont);
170 addItemFont("EventView Font",&mEventViewFont); 170 addItemFont("EventView Font",&mEventViewFont);
171 171
172 KPrefs::setCurrentGroup("RemoteSyncing"); 172 KPrefs::setCurrentGroup("RemoteSyncing");
173 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 173 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
174 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 174 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
175 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 175 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
176 addItemInt("LastSyncTime",&mLastSyncTime,0); 176 addItemInt("LastSyncTime",&mLastSyncTime,0);
177 177
178#ifdef _WIN32_ 178#ifdef _WIN32_
179 QString hdp= locateLocal("data","korganizer")+"\\\\"; 179 QString hdp= locateLocal("data","korganizer")+"\\\\";
180#else 180#else
181 QString hdp= locateLocal("data","korganizer")+"/"; 181 QString hdp= locateLocal("data","korganizer")+"/";
182#endif 182#endif
183 183
184 KPrefs::setCurrentGroup("LoadSaveFileNames"); 184 KPrefs::setCurrentGroup("LoadSaveFileNames");
185 185
186 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 186 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
187 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 187 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
188 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 188 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
189 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 189 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
190 190
191 191
192 KPrefs::setCurrentGroup("Locale"); 192 KPrefs::setCurrentGroup("Locale");
193 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 193 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
194 194
195 195
196 KPrefs::setCurrentGroup("Colors"); 196 KPrefs::setCurrentGroup("Colors");
197 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 197 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
198 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 198 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
199 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 199 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
200 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 200 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
201 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 201 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
202 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 202 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
203 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 203 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
204 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 204 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
205 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 205 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
206 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 206 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
207 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 207 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
208 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 208 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
209 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 209 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
210 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 210 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
211 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 211 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
212 addItemBool("UseAppColors",&mUseAppColors,false); 212 addItemBool("UseAppColors",&mUseAppColors,false);
213 213
214 214
215 215
216 KPrefs::setCurrentGroup("Views"); 216 KPrefs::setCurrentGroup("Views");
217 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 217 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
218 addItemInt("Hour Size",&mHourSize,8); 218 addItemInt("Hour Size",&mHourSize,8);
219 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 219 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
220 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 220 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
221 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 221 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
222 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 222 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
223 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 223 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
224 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 224 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
225 addItemBool("Enable ToolTips",&mEnableToolTips,false); 225 addItemBool("Enable ToolTips",&mEnableToolTips,false);
226 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 226 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
227 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 227 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
228 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 228 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
229 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 229 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
230 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 230 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
231 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,true); 231 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
232 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 232 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
233 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 233 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
234 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 234 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
235 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 235 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
236 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 236 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
237 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 237 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
238 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 238 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
239 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 239 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
240 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 240 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
241 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 241 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
242 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 242 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
243 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 243 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
244 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 244 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
245#ifdef DESKTOP_VERSION 245#ifdef DESKTOP_VERSION
246 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 246 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
247#else 247#else
248 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 248 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
249#endif 249#endif
250 addItemInt("Day Begins",&mDayBegins,7); 250 addItemInt("Day Begins",&mDayBegins,7);
251 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 251 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
252 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 252 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
253 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 253 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
254 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 254 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
255 255
256 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 256 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
257 addItemBool("Full View Month",&mFullViewMonth,true); 257 addItemBool("Full View Month",&mFullViewMonth,true);
258 addItemBool("Full View Todo",&mFullViewTodo,true); 258 addItemBool("Full View Todo",&mFullViewTodo,true);
259 addItemBool("Quick Todo",&mEnableQuickTodo,false); 259 addItemBool("Quick Todo",&mEnableQuickTodo,false);
260 260
261 addItemInt("Next X Days",&mNextXDays,3); 261 addItemInt("Next X Days",&mNextXDays,3);
262 262
263 KPrefs::setCurrentGroup("Printer"); 263 KPrefs::setCurrentGroup("Printer");
264 264
265 KPrefs::setCurrentGroup("Layout"); 265 KPrefs::setCurrentGroup("Layout");
266 266
267 addItemBool("CompactDialogs",&mCompactDialogs,false); 267 addItemBool("CompactDialogs",&mCompactDialogs,false);
268 addItemBool("VerticalScreen",&mVerticalScreen,true); 268 addItemBool("VerticalScreen",&mVerticalScreen,true);
269 269
270 KPrefs::setCurrentGroup("KOrganizer Plugins"); 270 KPrefs::setCurrentGroup("KOrganizer Plugins");
271 271
272 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 272 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
273 273
274 KPrefs::setCurrentGroup("Group Scheduling"); 274 KPrefs::setCurrentGroup("Group Scheduling");
275 275
276 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 276 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
277 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 277 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
278 addItemStringList("AdditionalMails",&mAdditionalMails,""); 278 addItemStringList("AdditionalMails",&mAdditionalMails,"");
279 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 279 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
280 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 280 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
281 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 281 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
282 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 282 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
283 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 283 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
284 284
285 KPrefs::setCurrentGroup( "Editors" ); 285 KPrefs::setCurrentGroup( "Editors" );
286 286
287 addItemStringList( "EventTemplates", &mEventTemplates ); 287 addItemStringList( "EventTemplates", &mEventTemplates );
288 addItemStringList( "TodoTemplates", &mTodoTemplates ); 288 addItemStringList( "TodoTemplates", &mTodoTemplates );
289 289
290 addItemInt("DestinationPolicy",&mDestination,standardDestination); 290 addItemInt("DestinationPolicy",&mDestination,standardDestination);
291 291
292 292
293 293
294} 294}
295 295
296 296
297KOPrefs::~KOPrefs() 297KOPrefs::~KOPrefs()
298{ 298{
299 if (mInstance == this) 299 if (mInstance == this)
300 mInstance = insd.setObject(0); 300 mInstance = insd.setObject(0);
301 301
302 //qDebug("KOPrefs::~KOPrefs() "); 302 //qDebug("KOPrefs::~KOPrefs() ");
303} 303}
304 304
305 305
306KOPrefs *KOPrefs::instance() 306KOPrefs *KOPrefs::instance()
307{ 307{
308 if (!mInstance) { 308 if (!mInstance) {
309 mInstance = insd.setObject(new KOPrefs()); 309 mInstance = insd.setObject(new KOPrefs());
310 mInstance->readConfig(); 310 mInstance->readConfig();
311 } 311 }
312 312
313 return mInstance; 313 return mInstance;
314} 314}
315 315
316void KOPrefs::usrSetDefaults() 316void KOPrefs::usrSetDefaults()
317{ 317{
318 318
319} 319}
320 320
321void KOPrefs::fillMailDefaults() 321void KOPrefs::fillMailDefaults()
322{ 322{
323 if (mName.isEmpty()) mName = i18n("Anonymous"); 323 if (mName.isEmpty()) mName = i18n("Anonymous");
324 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 324 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
325} 325}
326 326
327void KOPrefs::setTimeZoneIdDefault() 327void KOPrefs::setTimeZoneIdDefault()
328{ 328{
329 ; 329 ;
330} 330}
331 331
332void KOPrefs::setCategoryDefaults() 332void KOPrefs::setCategoryDefaults()
333{ 333{
334 mCustomCategories.clear(); 334 mCustomCategories.clear();
335 mCustomCategories = getDefaultList(); 335 mCustomCategories = getDefaultList();
336 336
337 QStringList::Iterator it; 337 QStringList::Iterator it;
338 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 338 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
339 setCategoryColor(*it,mDefaultCategoryColor); 339 setCategoryColor(*it,mDefaultCategoryColor);
340 } 340 }
341} 341}
342 342
343QStringList KOPrefs::getDefaultList() 343QStringList KOPrefs::getDefaultList()
344{ 344{
345 QStringList retval ; 345 QStringList retval ;
346 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 346 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
347 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 347 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
348 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 348 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
349 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 349 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
350 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 350 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
351 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 351 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
352 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 352 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
353 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 353 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
354 retval.sort(); 354 retval.sort();
355 return retval; 355 return retval;
356} 356}
357 357
358void KOPrefs::usrReadConfig() 358void KOPrefs::usrReadConfig()
359{ 359{
360 config()->setGroup("General"); 360 config()->setGroup("General");
361 361
362 mCustomCategories = config()->readListEntry("Custom Categories"); 362 mCustomCategories = config()->readListEntry("Custom Categories");
363 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) { 363 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) {
364 mLocationDefaults.clear(); 364 mLocationDefaults.clear();
365 mEventSummaryUser.clear(); 365 mEventSummaryUser.clear();
366 mTodoSummaryUser.clear(); 366 mTodoSummaryUser.clear();
367 } 367 }
368 mOldLoadedLanguage = mOldLanguage ; 368 mOldLoadedLanguage = mOldLanguage ;
369 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 369 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
370 if (mLocationDefaults.isEmpty()) { 370 if (mLocationDefaults.isEmpty()) {
371 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 371 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
372 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 372 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
373 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 373 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
374 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 374 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
375 mLocationDefaults.sort(); 375 mLocationDefaults.sort();
376 } 376 }
377 377
378 if (mEventSummaryUser.isEmpty()) { 378 if (mEventSummaryUser.isEmpty()) {
379 mEventSummaryUser = getDefaultList() ; 379 mEventSummaryUser = getDefaultList() ;
380 } 380 }
381 if (mTodoSummaryUser.isEmpty()) { 381 if (mTodoSummaryUser.isEmpty()) {
382 mTodoSummaryUser = getDefaultList() ; 382 mTodoSummaryUser = getDefaultList() ;
383 } 383 }
384 384
385 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 385 if (mCustomCategories.isEmpty()) setCategoryDefaults();
386 386
387 config()->setGroup("Personal Settings"); 387 config()->setGroup("Personal Settings");
388 mName = config()->readEntry("user_name",""); 388 mName = config()->readEntry("user_name","");
389 mEmail = config()->readEntry("user_email",""); 389 mEmail = config()->readEntry("user_email","");
390 fillMailDefaults(); 390 fillMailDefaults();
391 391
392 config()->setGroup("Category Colors"); 392 config()->setGroup("Category Colors");
393 QStringList::Iterator it; 393 QStringList::Iterator it;
394 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 394 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
395 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 395 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
396 396
397 } 397 }
398 398
399 KPimPrefs::usrReadConfig(); 399 KPimPrefs::usrReadConfig();
400} 400}
401 401
402 402
403void KOPrefs::usrWriteConfig() 403void KOPrefs::usrWriteConfig()
404{ 404{
405 config()->setGroup("General"); 405 config()->setGroup("General");
406 config()->writeEntry("Custom Categories",mCustomCategories); 406 config()->writeEntry("Custom Categories",mCustomCategories);
407 407
408 config()->setGroup("Personal Settings"); 408 config()->setGroup("Personal Settings");
409 config()->writeEntry("user_name",mName); 409 config()->writeEntry("user_name",mName);
410 config()->writeEntry("user_email",mEmail); 410 config()->writeEntry("user_email",mEmail);
411 411
412 config()->setGroup("Category Colors"); 412 config()->setGroup("Category Colors");
413 QDictIterator<QColor> it(mCategoryColors); 413 QDictIterator<QColor> it(mCategoryColors);
414 while (it.current()) { 414 while (it.current()) {
415 config()->writeEntry(it.currentKey(),*(it.current())); 415 config()->writeEntry(it.currentKey(),*(it.current()));
416 ++it; 416 ++it;
417 } 417 }
418 418
419 419
420 KPimPrefs::usrWriteConfig(); 420 KPimPrefs::usrWriteConfig();
421} 421}
422 422
423void KOPrefs::setCategoryColor(QString cat,const QColor & color) 423void KOPrefs::setCategoryColor(QString cat,const QColor & color)
424{ 424{
425 mCategoryColors.replace(cat,new QColor(color)); 425 mCategoryColors.replace(cat,new QColor(color));
426} 426}
427 427
428QColor *KOPrefs::categoryColor(QString cat) 428QColor *KOPrefs::categoryColor(QString cat)
429{ 429{
430 QColor *color = 0; 430 QColor *color = 0;
431 431
432 if (!cat.isEmpty()) color = mCategoryColors[cat]; 432 if (!cat.isEmpty()) color = mCategoryColors[cat];
433 433
434 if (color) return color; 434 if (color) return color;
435 else return &mDefaultCategoryColor; 435 else return &mDefaultCategoryColor;
436} 436}
437 437
438void KOPrefs::setFullName(const QString &name) 438void KOPrefs::setFullName(const QString &name)
439{ 439{
440 mName = name; 440 mName = name;
441} 441}
442 442
443void KOPrefs::setEmail(const QString &email) 443void KOPrefs::setEmail(const QString &email)
444{ 444{
445 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 445 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
446 mEmail = email; 446 mEmail = email;
447} 447}
448 448
449QString KOPrefs::fullName() 449QString KOPrefs::fullName()
450{ 450{
451 if (mEmailControlCenter) { 451 if (mEmailControlCenter) {
452 KEMailSettings settings; 452 KEMailSettings settings;
453 return settings.getSetting(KEMailSettings::RealName); 453 return settings.getSetting(KEMailSettings::RealName);
454 } else { 454 } else {
455 return mName; 455 return mName;
456 } 456 }
457} 457}
458 458
459QString KOPrefs::email() 459QString KOPrefs::email()
460{ 460{
461 if (mEmailControlCenter) { 461 if (mEmailControlCenter) {
462 KEMailSettings settings; 462 KEMailSettings settings;
463 return settings.getSetting(KEMailSettings::EmailAddress); 463 return settings.getSetting(KEMailSettings::EmailAddress);
464 } else { 464 } else {
465 return mEmail; 465 return mEmail;
466 } 466 }
467} 467}
468KConfig* KOPrefs::getConfig() 468KConfig* KOPrefs::getConfig()
469{ 469{
470 return config(); 470 return config();
471} 471}