summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-15 10:22:38 (UTC)
committer zautrix <zautrix>2005-06-15 10:22:38 (UTC)
commit13c00953a9d521873b03f861e54e83e33b30bc96 (patch) (unidiff)
tree05bc1f7b6d95b68e0d579e70a487c8a48f250a6f
parent37175a31a8fa8772403e9588ff3f8bd7de3979cc (diff)
downloadkdepimpi-13c00953a9d521873b03f861e54e83e33b30bc96.zip
kdepimpi-13c00953a9d521873b03f861e54e83e33b30bc96.tar.gz
kdepimpi-13c00953a9d521873b03f861e54e83e33b30bc96.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp11
-rw-r--r--korganizer/kofilterview.cpp10
-rw-r--r--korganizer/komonthview.cpp12
-rw-r--r--korganizer/koprefs.cpp1
-rw-r--r--korganizer/koprefsdialog.cpp1
5 files changed, 22 insertions, 13 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index e660c32..a8e0678 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,824 +1,829 @@
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 <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#include <qapplication.h> 38#include <qapplication.h>
39#define AGENDA_ICON_SIZE 7 39#define AGENDA_ICON_SIZE 7
40#endif 40#endif
41#include <libkcal/icaldrag.h> 41#include <libkcal/icaldrag.h>
42#include <libkcal/vcaldrag.h> 42#include <libkcal/vcaldrag.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
45extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
46extern int globalFlagBlockAgendaItemUpdate; 46extern int globalFlagBlockAgendaItemUpdate;
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49 49
50#include "koagendaitem.h" 50#include "koagendaitem.h"
51//#include "koagendaitem.moc" 51//#include "koagendaitem.moc"
52 52
53 53
54//-------------------------------------------------------------------------- 54//--------------------------------------------------------------------------
55 55
56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
57 57
58//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
59 59
60class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
67 { 67 {
68 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
69 } 69 }
70private: 70private:
71 KOAgendaItem * _view; 71 KOAgendaItem * _view;
72}; 72};
73 73
74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
75 const char *name,WFlags) : 75 const char *name,WFlags) :
76 QWidget(parent, name), mIncidence(incidence), mDate(qd) 76 QWidget(parent, name), mIncidence(incidence), mDate(qd)
77{ 77{
78#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
80#endif 80#endif
81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
83 setWFlags ( wflags); 83 setWFlags ( wflags);
84 mAllDay = allday; 84 mAllDay = allday;
85 init ( incidence, qd ); 85 init ( incidence, qd );
86 //setMouseTracking(true); 86 //setMouseTracking(true);
87 //setAcceptDrops(true); 87 //setAcceptDrops(true);
88 xPaintCoord = -1; 88 xPaintCoord = -1;
89 yPaintCoord = -1; 89 yPaintCoord = -1;
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100void KOAgendaItem::init ( Incidence *incidence, QDate qd )
101{ 101{
102 mIncidence = incidence; 102 mIncidence = incidence;
103 mDate = qd; 103 mDate = qd;
104 mFirstMultiItem = 0; 104 mFirstMultiItem = 0;
105 mNextMultiItem = 0; 105 mNextMultiItem = 0;
106 mLastMultiItem = 0; 106 mLastMultiItem = 0;
107 computeText(); 107 computeText();
108 108
109 if ( (incidence->typeID() == todoID ) && 109 if ( (incidence->typeID() == todoID ) &&
110 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
114 else 114 else
115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
116 } 116 }
117 else { 117 else {
118 QStringList categories = mIncidence->categories(); 118 QStringList categories = mIncidence->categories();
119 QString cat = categories.first(); 119 QString cat = categories.first();
120 if (cat.isEmpty()) { 120 if (cat.isEmpty()) {
121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) 121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 123 else
124 mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() ); 124 mBackgroundColor =KOPrefs::instance()->defaultColor( incidence->calID() );
125 } else { 125 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
129 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor; 129 mBackgroundColor = KOPrefs::instance()->mTodoDoneColor;
130 } 130 }
131 } 131 }
132 132
133 } 133 }
134 mColorGroup = QColorGroup( mBackgroundColor.light(), 134
135 mBackgroundColor.dark(),mBackgroundColor.light(), 135 QColor BackgroundColor ( mBackgroundColor );
136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 136 if ( mIncidence->calID() > 1 ) {
137 BackgroundColor = KOPrefs::instance()->defaultColor( mIncidence->calID() );
138 }
139 mColorGroup = QColorGroup( BackgroundColor.light(),
140 BackgroundColor.dark(),BackgroundColor.light(),
141 BackgroundColor.dark(),BackgroundColor, black, BackgroundColor) ;
137 setBackgroundColor( mBackgroundColor ); 142 setBackgroundColor( mBackgroundColor );
138 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250); 143 mWhiteText = (mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue() < 250);
139 mConflictItems.clear(); 144 mConflictItems.clear();
140 setCellXY(0,0,1); 145 setCellXY(0,0,1);
141 setCellXWidth(0); 146 setCellXWidth(0);
142 setSubCell(0); 147 setSubCell(0);
143 setSubCells(1); 148 setSubCells(1);
144 setMultiItem(0,0,0); 149 setMultiItem(0,0,0);
145 startMove(); 150 startMove();
146 mSelected = true; 151 mSelected = true;
147 select(false); 152 select(false);
148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 153 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
149 mFontPixelSize = fontinf.height();; 154 mFontPixelSize = fontinf.height();;
150 hide(); 155 hide();
151 xPaintCoord = -1; 156 xPaintCoord = -1;
152 yPaintCoord = -1; 157 yPaintCoord = -1;
153} 158}
154 159
155 160
156KOAgendaItem::~KOAgendaItem() 161KOAgendaItem::~KOAgendaItem()
157{ 162{
158#if QT_VERSION >= 0x030000 163#if QT_VERSION >= 0x030000
159 164
160#else 165#else
161 delete mKOAgendaItemWhatsThis; 166 delete mKOAgendaItemWhatsThis;
162#endif 167#endif
163 168
164} 169}
165 170
166void KOAgendaItem::recreateIncidence() 171void KOAgendaItem::recreateIncidence()
167{ 172{
168#if 0 173#if 0
169 Incidence* newInc = mIncidence->clone(); 174 Incidence* newInc = mIncidence->clone();
170 newInc->recreate(); 175 newInc->recreate();
171 if ( mIncidence->doesRecur() ) { 176 if ( mIncidence->doesRecur() ) {
172 mIncidence->addExDate( mDate ); 177 mIncidence->addExDate( mDate );
173 newInc->recurrence()->unsetRecurs(); 178 newInc->recurrence()->unsetRecurs();
174 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 179 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
175 QTime tim = mIncidence->dtStart().time(); 180 QTime tim = mIncidence->dtStart().time();
176 newInc->setDtStart( QDateTime(mDate, tim) ); 181 newInc->setDtStart( QDateTime(mDate, tim) );
177 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 182 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
178 } 183 }
179#endif 184#endif
180 mIncidence = mIncidence->recreateCloneException( mDate ); 185 mIncidence = mIncidence->recreateCloneException( mDate );
181} 186}
182bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 187bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
183{ 188{
184 int size = AGENDA_ICON_SIZE; 189 int size = AGENDA_ICON_SIZE;
185 190
186 int yOff = 0; 191 int yOff = 0;
187 int xOff = 0; 192 int xOff = 0;
188 int x = pos().x() +3; 193 int x = pos().x() +3;
189 int y; 194 int y;
190 if ( mAllDay ) 195 if ( mAllDay )
191 y = pos().y()+3; 196 y = pos().y()+3;
192 else 197 else
193 y = mCellYTop * ( height() / cellHeight() ) +3; 198 y = mCellYTop * ( height() / cellHeight() ) +3;
194 if (mIncidence->cancelled()) { 199 if (mIncidence->cancelled()) {
195 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 200 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
196 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 201 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
197 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 202 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
198 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 203 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
199 if ( horLayout ) 204 if ( horLayout )
200 ++xOff; 205 ++xOff;
201 else 206 else
202 ++yOff; 207 ++yOff;
203 } 208 }
204 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 209 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
205 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 210 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
206 if ( horLayout ) 211 if ( horLayout )
207 ++xOff; 212 ++xOff;
208 else 213 else
209 ++yOff; 214 ++yOff;
210 } 215 }
211 if (mIncidence->recurrence()->doesRecur()) { 216 if (mIncidence->recurrence()->doesRecur()) {
212 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 217 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
213 if ( horLayout ) 218 if ( horLayout )
214 ++xOff; 219 ++xOff;
215 else 220 else
216 ++yOff; 221 ++yOff;
217 } 222 }
218 if (mIncidence->description().length() > 0) { 223 if (mIncidence->description().length() > 0) {
219 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 224 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
220 if ( horLayout ) 225 if ( horLayout )
221 ++xOff; 226 ++xOff;
222 else 227 else
223 ++yOff; 228 ++yOff;
224 } 229 }
225 if (mIncidence->isReadOnly()) { 230 if (mIncidence->isReadOnly()) {
226 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
227 if ( horLayout ) 232 if ( horLayout )
228 ++xOff; 233 ++xOff;
229 else 234 else
230 ++yOff; 235 ++yOff;
231 } 236 }
232 237
233 if (mIncidence->attendeeCount()>0) { 238 if (mIncidence->attendeeCount()>0) {
234 239
235 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 240 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
236 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 241 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
237 if ( horLayout ) 242 if ( horLayout )
238 ++xOff; 243 ++xOff;
239 else 244 else
240 ++yOff; 245 ++yOff;
241 } else { 246 } else {
242 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 247 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
243 if (me!=0) { 248 if (me!=0) {
244 249
245 250
246 } else { 251 } else {
247 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
248 if ( horLayout ) 253 if ( horLayout )
249 ++xOff; 254 ++xOff;
250 else 255 else
251 ++yOff; 256 ++yOff;
252 257
253 } 258 }
254 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 259 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
255 if ( horLayout ) 260 if ( horLayout )
256 ++xOff; 261 ++xOff;
257 else 262 else
258 ++yOff; 263 ++yOff;
259 264
260 } 265 }
261 266
262 } 267 }
263 return ( yOff || xOff ); 268 return ( yOff || xOff );
264} 269}
265 270
266 271
267void KOAgendaItem::select(bool selected) 272void KOAgendaItem::select(bool selected)
268{ 273{
269 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 274 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
270 if (mSelected == selected) return; 275 if (mSelected == selected) return;
271 mSelected = selected; 276 mSelected = selected;
272 if ( ! isVisible() ) 277 if ( ! isVisible() )
273 return; 278 return;
274 if ( firstMultiItem() ) 279 if ( firstMultiItem() )
275 firstMultiItem()->select( selected ); 280 firstMultiItem()->select( selected );
276 if ( !firstMultiItem() && nextMultiItem() ) { 281 if ( !firstMultiItem() && nextMultiItem() ) {
277 KOAgendaItem * placeItem = nextMultiItem(); 282 KOAgendaItem * placeItem = nextMultiItem();
278 while ( placeItem ) { 283 while ( placeItem ) {
279 placeItem->select( selected ); 284 placeItem->select( selected );
280 placeItem = placeItem->nextMultiItem(); 285 placeItem = placeItem->nextMultiItem();
281 } 286 }
282 } 287 }
283 globalFlagBlockAgendaItemUpdate = 0; 288 globalFlagBlockAgendaItemUpdate = 0;
284 paintMe( selected ); 289 paintMe( selected );
285 globalFlagBlockAgendaItemUpdate = 1; 290 globalFlagBlockAgendaItemUpdate = 1;
286 repaint( false ); 291 repaint( false );
287} 292}
288 293
289 294
290/* 295/*
291 The eventFilter has to filter the mouse events of the agenda item childs. The 296 The eventFilter has to filter the mouse events of the agenda item childs. The
292 events are fed into the event handling method of KOAgendaItem. This allows the 297 events are fed into the event handling method of KOAgendaItem. This allows the
293 KOAgenda to handle the KOAgendaItems by using an eventFilter. 298 KOAgenda to handle the KOAgendaItems by using an eventFilter.
294*/ 299*/
295bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 300bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
296{ 301{
297 if (e->type() == QEvent::MouseButtonPress || 302 if (e->type() == QEvent::MouseButtonPress ||
298 e->type() == QEvent::MouseButtonDblClick || 303 e->type() == QEvent::MouseButtonDblClick ||
299 e->type() == QEvent::MouseButtonRelease || 304 e->type() == QEvent::MouseButtonRelease ||
300 e->type() == QEvent::MouseMove) { 305 e->type() == QEvent::MouseMove) {
301 QMouseEvent *me = (QMouseEvent *)e; 306 QMouseEvent *me = (QMouseEvent *)e;
302 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 307 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
303 mapToGlobal(me->pos())); 308 mapToGlobal(me->pos()));
304 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 309 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
305 return event(&returnEvent); 310 return event(&returnEvent);
306 } else { 311 } else {
307 return false; 312 return false;
308 } 313 }
309} 314}
310void KOAgendaItem::repaintMe( ) 315void KOAgendaItem::repaintMe( )
311{ 316{
312 paintMe ( mSelected ); 317 paintMe ( mSelected );
313} 318}
314void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 319void KOAgendaItem::paintMe( bool selected, QPainter* paint )
315{ 320{
316 if ( globalFlagBlockAgendaItemUpdate && ! selected) 321 if ( globalFlagBlockAgendaItemUpdate && ! selected)
317 return; 322 return;
318 QPainter pa; 323 QPainter pa;
319 324
320 if ( mSelected ) { 325 if ( mSelected ) {
321 pa.begin( paintPixSel() ); 326 pa.begin( paintPixSel() );
322 } else { 327 } else {
323 if ( mAllDay ) 328 if ( mAllDay )
324 pa.begin( paintPixAllday() ); 329 pa.begin( paintPixAllday() );
325 else 330 else
326 pa.begin( paintPix() ); 331 pa.begin( paintPix() );
327 } 332 }
328 int x, yy, w, h; 333 int x, yy, w, h;
329 float nfh = 7.0; 334 float nfh = 7.0;
330 x = pos().x(); w = width(); h = height (); 335 x = pos().x(); w = width(); h = height ();
331 if ( mAllDay ) 336 if ( mAllDay )
332 yy = y(); 337 yy = y();
333 else 338 else
334 yy = mCellYTop * ( height() / cellHeight() ); 339 yy = mCellYTop * ( height() / cellHeight() );
335 xPaintCoord= x; 340 xPaintCoord= x;
336 yPaintCoord = yy; 341 yPaintCoord = yy;
337 wPaintCoord = width(); 342 wPaintCoord = width();
338 hPaintCoord = height(); 343 hPaintCoord = height();
339 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 344 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
340 if ( paint == 0 ) 345 if ( paint == 0 )
341 paint = &pa; 346 paint = &pa;
342 bool horLayout = ( w < h ); 347 bool horLayout = ( w < h );
343 int maxhei = mFontPixelSize+4; 348 int maxhei = mFontPixelSize+4;
344 if ( horLayout ) 349 if ( horLayout )
345 maxhei += AGENDA_ICON_SIZE -4; 350 maxhei += AGENDA_ICON_SIZE -4;
346 bool small = ( h < maxhei ); 351 bool small = ( h < maxhei );
347 if ( ! small ) 352 if ( ! small )
348 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 353 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
349 else { 354 else {
350 QFont f = KOPrefs::instance()->mAgendaViewFont; 355 QFont f = KOPrefs::instance()->mAgendaViewFont;
351 f.setBold( false ); 356 f.setBold( false );
352 int fh = f.pointSize(); 357 int fh = f.pointSize();
353 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 358 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
354 if ( nfh < 6 ) 359 if ( nfh < 6 )
355 nfh = 6; 360 nfh = 6;
356 f.setPointSize( nfh ); 361 f.setPointSize( nfh );
357 paint->setFont(f); 362 paint->setFont(f);
358 } 363 }
359 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 364 paint->fillRect ( x, yy, w, h, mBackgroundColor );
360 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 365 static const QPixmap completedPxmp = SmallIcon("greenhook16");
361 static const QPixmap overduePxmp = SmallIcon("redcross16"); 366 static const QPixmap overduePxmp = SmallIcon("redcross16");
362 if ( mIncidence->typeID() == todoID ) { 367 if ( mIncidence->typeID() == todoID ) {
363 Todo* tempTodo = static_cast<Todo*>(mIncidence); 368 Todo* tempTodo = static_cast<Todo*>(mIncidence);
364 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 369 int xx = pos().x()+(width()-completedPxmp.width()-3 );
365 int yyy = yy+3; 370 int yyy = yy+3;
366 if ( tempTodo->isCompleted() ) 371 if ( tempTodo->isCompleted() )
367 paint->drawPixmap ( xx, yyy, completedPxmp ); 372 paint->drawPixmap ( xx, yyy, completedPxmp );
368 else { 373 else {
369 paint->drawPixmap ( xx, yyy, overduePxmp ); 374 paint->drawPixmap ( xx, yyy, overduePxmp );
370 375
371 } 376 }
372 } 377 }
373 bool addIcon = false; 378 bool addIcon = false;
374 if ( ! small || w > 3 * h || h > 3* w ) 379 if ( ! small || w > 3 * h || h > 3* w )
375 addIcon = updateIcons( paint, horLayout ); 380 addIcon = updateIcons( paint, horLayout );
376 381
377 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 382 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
378 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 383 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
379 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 384 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
380 if ( ! small ) { 385 if ( ! small ) {
381 x += 3; yy += 3;w -= 6; h-= 5; 386 x += 3; yy += 3;w -= 6; h-= 5;
382 } else { 387 } else {
383 x += 2; yy += 1;w -= 4; h-= 4; 388 x += 2; yy += 1;w -= 4; h-= 4;
384 if ( nfh < 6.01 ) { 389 if ( nfh < 6.01 ) {
385 yy -= 2; 390 yy -= 2;
386 h += 4; 391 h += 4;
387 } 392 }
388 else 393 else
389 if ( nfh < h -2 ) 394 if ( nfh < h -2 )
390 ++yy; 395 ++yy;
391 } 396 }
392 int align; 397 int align;
393#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
394 align = ( AlignLeft|WordBreak|AlignTop); 399 align = ( AlignLeft|WordBreak|AlignTop);
395#else 400#else
396 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 401 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
397#endif 402#endif
398 if ( addIcon ) { 403 if ( addIcon ) {
399 if ( ! horLayout ) { 404 if ( ! horLayout ) {
400 x += AGENDA_ICON_SIZE+3; 405 x += AGENDA_ICON_SIZE+3;
401 w -= (AGENDA_ICON_SIZE+3); 406 w -= (AGENDA_ICON_SIZE+3);
402 } 407 }
403 else { 408 else {
404 yy+= AGENDA_ICON_SIZE+2; 409 yy+= AGENDA_ICON_SIZE+2;
405 h -=(AGENDA_ICON_SIZE+3); 410 h -=(AGENDA_ICON_SIZE+3);
406 } 411 }
407 } 412 }
408 if ( mWhiteText ) 413 if ( mWhiteText )
409 paint->setPen ( white); 414 paint->setPen ( white);
410 if ( x < 0 ) { 415 if ( x < 0 ) {
411 w = w+x-3; 416 w = w+x-3;
412 x = 3; 417 x = 3;
413 if ( w > parentWidget()->width() ){ 418 if ( w > parentWidget()->width() ){
414 w = parentWidget()->width() - 6; 419 w = parentWidget()->width() - 6;
415#ifndef DESKTOP_VERSION 420#ifndef DESKTOP_VERSION
416 align = ( AlignHCenter|WordBreak|AlignTop); 421 align = ( AlignHCenter|WordBreak|AlignTop);
417#else 422#else
418 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 423 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
419#endif 424#endif
420 425
421 } 426 }
422 } 427 }
423 QRect dr; 428 QRect dr;
424 if ( w + x > parentWidget()->width() ) 429 if ( w + x > parentWidget()->width() )
425 w = parentWidget()->width()-x; 430 w = parentWidget()->width()-x;
426 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 431 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
427 //qDebug("%d %d %d %d ", x, yy, w, h ); 432 //qDebug("%d %d %d %d ", x, yy, w, h );
428 if ( mIncidence->cancelled() ){ 433 if ( mIncidence->cancelled() ){
429 434
430 435
431 small = ( height() < 20 ); 436 small = ( height() < 20 );
432 437
433 if ( ! small ) { 438 if ( ! small ) {
434 QFontMetrics fm ( paint->font() ); 439 QFontMetrics fm ( paint->font() );
435 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 440 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
436 } 441 }
437 442
438 } 443 }
439 pa.end(); 444 pa.end();
440 445
441} 446}
442void KOAgendaItem::resizePixmap( int w , int h ) 447void KOAgendaItem::resizePixmap( int w , int h )
443{ 448{
444 paintPix()->resize( w, h ); 449 paintPix()->resize( w, h );
445 paintPixSel()->resize( w, h ); 450 paintPixSel()->resize( w, h );
446 451
447} 452}
448QPixmap * KOAgendaItem::paintPix() 453QPixmap * KOAgendaItem::paintPix()
449{ 454{
450 static QPixmap* mPaintPix = 0; 455 static QPixmap* mPaintPix = 0;
451 if ( ! mPaintPix ) { 456 if ( ! mPaintPix ) {
452 int w = QApplication::desktop()->width(); 457 int w = QApplication::desktop()->width();
453 int h = QApplication::desktop()->height(); 458 int h = QApplication::desktop()->height();
454 mPaintPix = new QPixmap(w,h); 459 mPaintPix = new QPixmap(w,h);
455 } 460 }
456 return mPaintPix ; 461 return mPaintPix ;
457} 462}
458QPixmap * KOAgendaItem::paintPixAllday() 463QPixmap * KOAgendaItem::paintPixAllday()
459{ 464{
460 static QPixmap* mPaintPixA = 0; 465 static QPixmap* mPaintPixA = 0;
461 if ( ! mPaintPixA ) { 466 if ( ! mPaintPixA ) {
462 int w = QApplication::desktop()->width(); 467 int w = QApplication::desktop()->width();
463 int h = QApplication::desktop()->height()/3; 468 int h = QApplication::desktop()->height()/3;
464 mPaintPixA = new QPixmap(w,h); 469 mPaintPixA = new QPixmap(w,h);
465 } 470 }
466 return mPaintPixA ; 471 return mPaintPixA ;
467} 472}
468QPixmap * KOAgendaItem::paintPixSel() 473QPixmap * KOAgendaItem::paintPixSel()
469{ 474{
470 static QPixmap* mPaintPixSel = 0; 475 static QPixmap* mPaintPixSel = 0;
471 if ( ! mPaintPixSel ) { 476 if ( ! mPaintPixSel ) {
472 int w = QApplication::desktop()->width(); 477 int w = QApplication::desktop()->width();
473 int h = QApplication::desktop()->height(); 478 int h = QApplication::desktop()->height();
474 mPaintPixSel = new QPixmap(w,h); 479 mPaintPixSel = new QPixmap(w,h);
475 } 480 }
476 return mPaintPixSel ; 481 return mPaintPixSel ;
477} 482}
478void KOAgendaItem::paintEvent ( QPaintEvent *e ) 483void KOAgendaItem::paintEvent ( QPaintEvent *e )
479{ 484{
480 485
481 if ( globalFlagBlockAgendaItemPaint ) 486 if ( globalFlagBlockAgendaItemPaint )
482 return; 487 return;
483 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 488 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
484 return; 489 return;
485 int yy; 490 int yy;
486 if ( mAllDay ) 491 if ( mAllDay )
487 yy = y(); 492 yy = y();
488 else 493 else
489 yy = mCellYTop * ( height() / cellHeight() ); 494 yy = mCellYTop * ( height() / cellHeight() );
490 int xx = x(); 495 int xx = x();
491 496
492 if ( xPaintCoord != xx || yPaintCoord != yy || 497 if ( xPaintCoord != xx || yPaintCoord != yy ||
493 wPaintCoord != width() || hPaintCoord != height()) { 498 wPaintCoord != width() || hPaintCoord != height()) {
494 xPaintCoord= xx; 499 xPaintCoord= xx;
495 yPaintCoord = yy; 500 yPaintCoord = yy;
496 wPaintCoord = width(); 501 wPaintCoord = width();
497 hPaintCoord = height(); 502 hPaintCoord = height();
498 globalFlagBlockAgendaItemUpdate = 0; 503 globalFlagBlockAgendaItemUpdate = 0;
499 paintMe( mSelected ); 504 paintMe( mSelected );
500 //qDebug("calling paintMe "); 505 //qDebug("calling paintMe ");
501 globalFlagBlockAgendaItemUpdate = 1; 506 globalFlagBlockAgendaItemUpdate = 1;
502 } 507 }
503 int rx, ry, rw, rh; 508 int rx, ry, rw, rh;
504 rx = e->rect().x(); 509 rx = e->rect().x();
505 ry = e->rect().y(); 510 ry = e->rect().y();
506 rw = e->rect().width(); 511 rw = e->rect().width();
507 rh = e->rect().height(); 512 rh = e->rect().height();
508 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 513 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
509 514
510 QPixmap* paintFrom ; 515 QPixmap* paintFrom ;
511 if ( mSelected ) { 516 if ( mSelected ) {
512 paintFrom = paintPixSel(); 517 paintFrom = paintPixSel();
513 } else { 518 } else {
514 if ( mAllDay ) 519 if ( mAllDay )
515 paintFrom = paintPixAllday(); 520 paintFrom = paintPixAllday();
516 else 521 else
517 paintFrom = paintPix(); 522 paintFrom = paintPix();
518 } 523 }
519 xx += rx; 524 xx += rx;
520 525
521 if ( xx < 0 ) { 526 if ( xx < 0 ) {
522 rw = rw + xx; 527 rw = rw + xx;
523 rx -= xx; 528 rx -= xx;
524 xx = 0; 529 xx = 0;
525 if ( rw <= 1 ) { 530 if ( rw <= 1 ) {
526 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 531 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
527 return; 532 return;
528 } 533 }
529 } 534 }
530 if ( paintFrom->width() < xx+rw ) { 535 if ( paintFrom->width() < xx+rw ) {
531 rw = paintFrom->width() - xx; 536 rw = paintFrom->width() - xx;
532 if ( rw <= 1 ) { 537 if ( rw <= 1 ) {
533 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 538 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
534 return; 539 return;
535 } 540 }
536 } 541 }
537 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 542 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
538 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 543 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
539} 544}
540void KOAgendaItem::computeText() 545void KOAgendaItem::computeText()
541{ 546{
542 mDisplayedText = mIncidence->summary(); 547 mDisplayedText = mIncidence->summary();
543 if ( (mIncidence->typeID() == todoID ) ) { 548 if ( (mIncidence->typeID() == todoID ) ) {
544 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 549 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
545 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 550 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
546 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 551 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
547 else if ( !(mIncidence->doesFloat())) 552 else if ( !(mIncidence->doesFloat()))
548 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 553 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
549 } 554 }
550 } else { 555 } else {
551 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 556 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
552 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 557 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
553 558
554 if ( mAllDay ) { 559 if ( mAllDay ) {
555 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 560 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
556 if ( mIncidence->doesRecur() ) { 561 if ( mIncidence->doesRecur() ) {
557 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 562 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
558 } else { 563 } else {
559 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 564 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
560 } 565 }
561 } 566 }
562 } 567 }
563 } 568 }
564 569
565 if ( !mIncidence->location().isEmpty() ) { 570 if ( !mIncidence->location().isEmpty() ) {
566 if ( mAllDay ) 571 if ( mAllDay )
567 mDisplayedText += " ("; 572 mDisplayedText += " (";
568 else 573 else
569 mDisplayedText += "\n("; 574 mDisplayedText += "\n(";
570 mDisplayedText += mIncidence->location() +")"; 575 mDisplayedText += mIncidence->location() +")";
571 } 576 }
572#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
573 QString tipText = mIncidence->summary(); 578 QString tipText = mIncidence->summary();
574 if ( !mIncidence->doesFloat() ) { 579 if ( !mIncidence->doesFloat() ) {
575 if ( mIncidence->typeID() == eventID ) { 580 if ( mIncidence->typeID() == eventID ) {
576 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 581 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
577 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 582 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
578 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 583 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
579 } 584 }
580 else { 585 else {
581 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 586 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
582 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 587 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
583 } 588 }
584 } 589 }
585 else if ( mIncidence->typeID() == todoID ) { 590 else if ( mIncidence->typeID() == todoID ) {
586 if (mIncidence->hasStartDate()) 591 if (mIncidence->hasStartDate())
587 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 592 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
588 if (((Todo*)mIncidence)->hasDueDate()) 593 if (((Todo*)mIncidence)->hasDueDate())
589 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 594 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
590 } 595 }
591 } else if ( mIncidence->typeID() == todoID ) { 596 } else if ( mIncidence->typeID() == todoID ) {
592 if (mIncidence->hasStartDate()) 597 if (mIncidence->hasStartDate())
593 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 598 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
594 if (((Todo*)mIncidence)->hasDueDate()) 599 if (((Todo*)mIncidence)->hasDueDate())
595 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 600 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
596 } 601 }
597 602
598 if (!mIncidence->location().isEmpty()) { 603 if (!mIncidence->location().isEmpty()) {
599 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 604 tipText += "\n"+i18n("Location: ")+mIncidence->location();
600 } 605 }
601 QToolTip::add(this,tipText,toolTipGroup(),""); 606 QToolTip::add(this,tipText,toolTipGroup(),"");
602#endif 607#endif
603} 608}
604void KOAgendaItem::updateItem() 609void KOAgendaItem::updateItem()
605{ 610{
606 computeText(); 611 computeText();
607 612
608 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 613 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
609 paintMe( mSelected ); 614 paintMe( mSelected );
610 repaint( false); 615 repaint( false);
611} 616}
612 617
613void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 618void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
614{ 619{
615 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 620 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
616 paintMe( mSelected ); 621 paintMe( mSelected );
617 repaint( false ); 622 repaint( false );
618} 623}
619 624
620/* 625/*
621 Return height of item in units of agenda cells 626 Return height of item in units of agenda cells
622*/ 627*/
623int KOAgendaItem::cellHeight() 628int KOAgendaItem::cellHeight()
624{ 629{
625 int ret = mCellYBottom - mCellYTop + 1; 630 int ret = mCellYBottom - mCellYTop + 1;
626 if ( ret <= 0 ) { 631 if ( ret <= 0 ) {
627 ret = 1; 632 ret = 1;
628 mCellYBottom = 0; 633 mCellYBottom = 0;
629 mCellYTop = 0; 634 mCellYTop = 0;
630 } 635 }
631 return ret; 636 return ret;
632} 637}
633 638
634/* 639/*
635 Return height of item in units of agenda cells 640 Return height of item in units of agenda cells
636*/ 641*/
637int KOAgendaItem::cellWidth() 642int KOAgendaItem::cellWidth()
638{ 643{
639 return mCellXWidth - mCellX + 1; 644 return mCellXWidth - mCellX + 1;
640} 645}
641 646
642void KOAgendaItem::setItemDate(QDate qd) 647void KOAgendaItem::setItemDate(QDate qd)
643{ 648{
644 mDate = qd; 649 mDate = qd;
645} 650}
646 651
647void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 652void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
648{ 653{
649 mCellX = X; 654 mCellX = X;
650 mCellYTop = YTop; 655 mCellYTop = YTop;
651 mCellYBottom = YBottom; 656 mCellYBottom = YBottom;
652} 657}
653 658
654void KOAgendaItem::setCellXWidth(int xwidth) 659void KOAgendaItem::setCellXWidth(int xwidth)
655{ 660{
656 mCellXWidth = xwidth; 661 mCellXWidth = xwidth;
657} 662}
658 663
659void KOAgendaItem::setCellX(int XLeft, int XRight) 664void KOAgendaItem::setCellX(int XLeft, int XRight)
660{ 665{
661 mCellX = XLeft; 666 mCellX = XLeft;
662 mCellXWidth = XRight; 667 mCellXWidth = XRight;
663} 668}
664 669
665void KOAgendaItem::setCellY(int YTop, int YBottom) 670void KOAgendaItem::setCellY(int YTop, int YBottom)
666{ 671{
667 mCellYTop = YTop; 672 mCellYTop = YTop;
668 mCellYBottom = YBottom; 673 mCellYBottom = YBottom;
669} 674}
670 675
671void KOAgendaItem::setSubCell(int subCell) 676void KOAgendaItem::setSubCell(int subCell)
672{ 677{
673 mSubCell = subCell; 678 mSubCell = subCell;
674} 679}
675 680
676void KOAgendaItem::setSubCells(int subCells) 681void KOAgendaItem::setSubCells(int subCells)
677{ 682{
678 mSubCells = subCells; 683 mSubCells = subCells;
679} 684}
680 685
681void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 686void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
682 KOAgendaItem *last) 687 KOAgendaItem *last)
683{ 688{
684 mFirstMultiItem = first; 689 mFirstMultiItem = first;
685 mNextMultiItem = next; 690 mNextMultiItem = next;
686 mLastMultiItem = last; 691 mLastMultiItem = last;
687} 692}
688 693
689void KOAgendaItem::startMove() 694void KOAgendaItem::startMove()
690{ 695{
691 mStartCellX = mCellX; 696 mStartCellX = mCellX;
692 mStartCellXWidth = mCellXWidth; 697 mStartCellXWidth = mCellXWidth;
693 mStartCellYTop = mCellYTop; 698 mStartCellYTop = mCellYTop;
694 mStartCellYBottom = mCellYBottom; 699 mStartCellYBottom = mCellYBottom;
695} 700}
696 701
697void KOAgendaItem::resetMove() 702void KOAgendaItem::resetMove()
698{ 703{
699 mCellX = mStartCellX; 704 mCellX = mStartCellX;
700 mCellXWidth = mStartCellXWidth; 705 mCellXWidth = mStartCellXWidth;
701 mCellYTop = mStartCellYTop; 706 mCellYTop = mStartCellYTop;
702 mCellYBottom = mStartCellYBottom; 707 mCellYBottom = mStartCellYBottom;
703} 708}
704 709
705void KOAgendaItem::moveRelative(int dx, int dy) 710void KOAgendaItem::moveRelative(int dx, int dy)
706{ 711{
707 int newX = cellX() + dx; 712 int newX = cellX() + dx;
708 int newXWidth = cellXWidth() + dx; 713 int newXWidth = cellXWidth() + dx;
709 int newYTop = cellYTop() + dy; 714 int newYTop = cellYTop() + dy;
710 int newYBottom = cellYBottom() + dy; 715 int newYBottom = cellYBottom() + dy;
711 setCellXY(newX,newYTop,newYBottom); 716 setCellXY(newX,newYTop,newYBottom);
712 setCellXWidth(newXWidth); 717 setCellXWidth(newXWidth);
713} 718}
714 719
715void KOAgendaItem::expandTop(int dy) 720void KOAgendaItem::expandTop(int dy)
716{ 721{
717 int newYTop = cellYTop() + dy; 722 int newYTop = cellYTop() + dy;
718 int newYBottom = cellYBottom(); 723 int newYBottom = cellYBottom();
719 if (newYTop > newYBottom) newYTop = newYBottom; 724 if (newYTop > newYBottom) newYTop = newYBottom;
720 setCellY(newYTop, newYBottom); 725 setCellY(newYTop, newYBottom);
721} 726}
722 727
723void KOAgendaItem::expandBottom(int dy) 728void KOAgendaItem::expandBottom(int dy)
724{ 729{
725 int newYTop = cellYTop(); 730 int newYTop = cellYTop();
726 int newYBottom = cellYBottom() + dy; 731 int newYBottom = cellYBottom() + dy;
727 if (newYBottom < newYTop) newYBottom = newYTop; 732 if (newYBottom < newYTop) newYBottom = newYTop;
728 setCellY(newYTop, newYBottom); 733 setCellY(newYTop, newYBottom);
729} 734}
730 735
731void KOAgendaItem::expandLeft(int dx) 736void KOAgendaItem::expandLeft(int dx)
732{ 737{
733 int newX = cellX() + dx; 738 int newX = cellX() + dx;
734 int newXWidth = cellXWidth(); 739 int newXWidth = cellXWidth();
735 if (newX > newXWidth) newX = newXWidth; 740 if (newX > newXWidth) newX = newXWidth;
736 setCellX(newX,newXWidth); 741 setCellX(newX,newXWidth);
737} 742}
738 743
739void KOAgendaItem::expandRight(int dx) 744void KOAgendaItem::expandRight(int dx)
740{ 745{
741 int newX = cellX(); 746 int newX = cellX();
742 int newXWidth = cellXWidth() + dx; 747 int newXWidth = cellXWidth() + dx;
743 if (newXWidth < newX) newXWidth = newX; 748 if (newXWidth < newX) newXWidth = newX;
744 setCellX(newX,newXWidth); 749 setCellX(newX,newXWidth);
745} 750}
746 751
747QToolTipGroup *KOAgendaItem::toolTipGroup() 752QToolTipGroup *KOAgendaItem::toolTipGroup()
748{ 753{
749 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 754 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
750 return mToolTipGroup; 755 return mToolTipGroup;
751} 756}
752 757
753void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 758void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
754{ 759{
755#ifndef KORG_NODND 760#ifndef KORG_NODND
756 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 761 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
757 !QTextDrag::canDecode( e ) ) { 762 !QTextDrag::canDecode( e ) ) {
758 e->ignore(); 763 e->ignore();
759 return; 764 return;
760 } 765 }
761 e->accept(); 766 e->accept();
762#endif 767#endif
763} 768}
764 769
765void KOAgendaItem::dropEvent( QDropEvent *e ) 770void KOAgendaItem::dropEvent( QDropEvent *e )
766{ 771{
767#ifndef KORG_NODND 772#ifndef KORG_NODND
768 QString text; 773 QString text;
769 if(QTextDrag::decode(e,text)) 774 if(QTextDrag::decode(e,text))
770 { 775 {
771 kdDebug() << "Dropped : " << text << endl; 776 kdDebug() << "Dropped : " << text << endl;
772 QStringList emails = QStringList::split(",",text); 777 QStringList emails = QStringList::split(",",text);
773 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 778 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
774 kdDebug() << " Email: " << (*it) << endl; 779 kdDebug() << " Email: " << (*it) << endl;
775 int pos = (*it).find("<"); 780 int pos = (*it).find("<");
776 QString name = (*it).left(pos); 781 QString name = (*it).left(pos);
777 QString email = (*it).mid(pos); 782 QString email = (*it).mid(pos);
778 if (!email.isEmpty()) { 783 if (!email.isEmpty()) {
779 mIncidence->addAttendee(new Attendee(name,email)); 784 mIncidence->addAttendee(new Attendee(name,email));
780 } 785 }
781 } 786 }
782 } 787 }
783#endif 788#endif
784} 789}
785 790
786 791
787QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 792QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
788{ 793{
789 return mConflictItems; 794 return mConflictItems;
790} 795}
791 796
792void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 797void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
793{ 798{
794 mConflictItems = ci; 799 mConflictItems = ci;
795 KOAgendaItem *item; 800 KOAgendaItem *item;
796 for ( item=mConflictItems.first(); item != 0; 801 for ( item=mConflictItems.first(); item != 0;
797 item=mConflictItems.next() ) { 802 item=mConflictItems.next() ) {
798 item->addConflictItem(this); 803 item->addConflictItem(this);
799 } 804 }
800} 805}
801 806
802void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 807void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
803{ 808{
804 if (mConflictItems.find(ci)<0) 809 if (mConflictItems.find(ci)<0)
805 mConflictItems.append(ci); 810 mConflictItems.append(ci);
806} 811}
807 812
808bool KOAgendaItem::checkLayout() 813bool KOAgendaItem::checkLayout()
809{ 814{
810 if ( !mConflictItems.count() ) 815 if ( !mConflictItems.count() )
811 return true; 816 return true;
812 int max = 0; 817 int max = 0;
813 KOAgendaItem *item; 818 KOAgendaItem *item;
814 for ( item=mConflictItems.first(); item != 0; 819 for ( item=mConflictItems.first(); item != 0;
815 item=mConflictItems.next() ) { 820 item=mConflictItems.next() ) {
816 if ( item->subCells() > max ) 821 if ( item->subCells() > max )
817 max = item->subCells(); 822 max = item->subCells();
818 } 823 }
819 if ( max > subCells() ) { 824 if ( max > subCells() ) {
820 setSubCells( max ); 825 setSubCells( max );
821 return false; 826 return false;
822 } 827 }
823 return true; 828 return true;
824} 829}
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 52bc463..a653c18 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,420 +1,420 @@
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 <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30 30
31 31
32#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
33 33
34#include "kofilterview.h" 34#include "kofilterview.h"
35#include "koprefs.h" 35#include "koprefs.h"
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kcolorbutton.h> 38#include <kcolorbutton.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40 40
41 41
42#include <kurlrequester.h> 42#include <kurlrequester.h>
43#include <klineedit.h> 43#include <klineedit.h>
44 44
45class KONewCalPrefs : public QDialog 45class KONewCalPrefs : public QDialog
46{ 46{
47 public: 47 public:
48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
49 QDialog( parent, name, true ) 49 QDialog( parent, name, true )
50 { 50 {
51 setCaption( i18n("Add new Calendar") ); 51 setCaption( i18n("Add new Calendar") );
52 QVBoxLayout* lay = new QVBoxLayout( this ); 52 QVBoxLayout* lay = new QVBoxLayout( this );
53 lay->setSpacing( 3 ); 53 lay->setSpacing( 3 );
54 lay->setMargin( 3 ); 54 lay->setMargin( 3 );
55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
56 lay->addWidget( lab ); 56 lay->addWidget( lab );
57 nameE = new KLineEdit( this ); 57 nameE = new KLineEdit( this );
58 lay->addWidget( nameE ); 58 lay->addWidget( nameE );
59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); 59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this );
60 lay->addWidget( lab ); 60 lay->addWidget( lab );
61 url = new KURLRequester ( this ); 61 url = new KURLRequester ( this );
62 lay->addWidget( url ); 62 lay->addWidget( url );
63 QPushButton * ok = new QPushButton( i18n("OK"), this ); 63 QPushButton * ok = new QPushButton( i18n("OK"), this );
64 lay->addWidget( ok ); 64 lay->addWidget( ok );
65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
66 lay->addWidget( cancel ); 66 lay->addWidget( cancel );
67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
69 //resize( 200, 200 ); 69 //resize( 200, 200 );
70 } 70 }
71 71
72 QString calName() { return nameE->text(); } 72 QString calName() { return nameE->text(); }
73 QString calFileName() { return url->url(); } 73 QString calFileName() { return url->url(); }
74private: 74private:
75 KLineEdit* nameE; 75 KLineEdit* nameE;
76 KURLRequester *url; 76 KURLRequester *url;
77}; 77};
78 78
79 79
80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
81 const char* name,WFlags fl ) 81 const char* name,WFlags fl )
82 : KOFilterView_base(parent,name,fl) 82 : KOFilterView_base(parent,name,fl)
83{ 83{
84 mFilters = filterList; 84 mFilters = filterList;
85 85
86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
89} 89}
90 90
91KOFilterView::~KOFilterView() 91KOFilterView::~KOFilterView()
92{ 92{
93 // no need to delete child widgets, Qt does it all for us 93 // no need to delete child widgets, Qt does it all for us
94} 94}
95 95
96bool KOFilterView::filtersEnabled() 96bool KOFilterView::filtersEnabled()
97{ 97{
98 return mEnabledCheck->isChecked(); 98 return mEnabledCheck->isChecked();
99} 99}
100 100
101void KOFilterView::setFiltersEnabled(bool set) 101void KOFilterView::setFiltersEnabled(bool set)
102{ 102{
103 mEnabledCheck->setChecked(set); 103 mEnabledCheck->setChecked(set);
104 emit filterChanged(); 104 emit filterChanged();
105} 105}
106 106
107 107
108void KOFilterView::updateFilters() 108void KOFilterView::updateFilters()
109{ 109{
110 mSelectionCombo->clear(); 110 mSelectionCombo->clear();
111 111
112 CalFilter *filter = mFilters->first(); 112 CalFilter *filter = mFilters->first();
113 while(filter) { 113 while(filter) {
114 mSelectionCombo->insertItem(filter->name()); 114 mSelectionCombo->insertItem(filter->name());
115 filter = mFilters->next(); 115 filter = mFilters->next();
116 } 116 }
117} 117}
118 118
119CalFilter *KOFilterView::selectedFilter() 119CalFilter *KOFilterView::selectedFilter()
120{ 120{
121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
122 return f; 122 return f;
123} 123}
124 124
125void KOFilterView::setSelectedFilter(QString filterName) 125void KOFilterView::setSelectedFilter(QString filterName)
126{ 126{
127 int filter_num = mSelectionCombo->count(); 127 int filter_num = mSelectionCombo->count();
128 int i; 128 int i;
129 for (i=0;i<filter_num;i++) { 129 for (i=0;i<filter_num;i++) {
130 if (mSelectionCombo->text(i)==filterName) 130 if (mSelectionCombo->text(i)==filterName)
131 mSelectionCombo->setCurrentItem(i); 131 mSelectionCombo->setCurrentItem(i);
132 } 132 }
133 emit filterChanged(); 133 emit filterChanged();
134} 134}
135void KOFilterView::setSelectedFilter( int fil ) 135void KOFilterView::setSelectedFilter( int fil )
136{ 136{
137 if ( fil >= mSelectionCombo->count() ) 137 if ( fil >= mSelectionCombo->count() )
138 return; 138 return;
139 mSelectionCombo->setCurrentItem( fil ); 139 mSelectionCombo->setCurrentItem( fil );
140 emit filterChanged(); 140 emit filterChanged();
141} 141}
142 142
143 143
144 144
145KOCalEditView::KOCalEditView(QWidget* parent, 145KOCalEditView::KOCalEditView(QWidget* parent,
146 const char* name ) 146 const char* name )
147 : QScrollView(parent,name) 147 : QScrollView(parent,name)
148{ 148{
149 mw = 0; 149 mw = 0;
150 setResizePolicy( AutoOneFit ); 150 setResizePolicy( AutoOneFit );
151 setFrameStyle ( QFrame::Panel | QFrame::Plain ); 151 setFrameStyle ( QFrame::Panel | QFrame::Plain );
152 setLineWidth ( 1 ); 152 setLineWidth ( 1 );
153 setMidLineWidth ( 1 ); 153 setMidLineWidth ( 1 );
154} 154}
155 155
156KOCalEditView::~KOCalEditView() 156KOCalEditView::~KOCalEditView()
157{ 157{
158 // no need to delete child widgets, Qt does it all for us 158 // no need to delete child widgets, Qt does it all for us
159} 159}
160void KOCalEditView::selectCal(int id ,bool b) 160void KOCalEditView::selectCal(int id ,bool b)
161{ 161{
162 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 162 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
163 emit calendarEnabled ( id, b ); 163 emit calendarEnabled ( id, b );
164 emit needsUpdate(); 164 emit needsUpdate();
165 165
166} 166}
167void KOCalEditView::selectStdCal( int id, bool b ) 167void KOCalEditView::selectStdCal( int id, bool b )
168{ 168{
169 169
170 if ( !b ) { 170 if ( !b ) {
171 KOCalCheckButton* it = (KOCalCheckButton*) sender(); 171 KOCalCheckButton* it = (KOCalCheckButton*) sender();
172 if ( it ) { 172 if ( it ) {
173 it->blockSignals( true ); 173 it->blockSignals( true );
174 it->setChecked( true ); 174 it->setChecked( true );
175 it->blockSignals( false ); 175 it->blockSignals( false );
176 return; 176 return;
177 } 177 }
178 return; 178 return;
179 } 179 }
180 KOCalCheckButton* sen = (KOCalCheckButton*) sender(); 180 KOCalCheckButton* sen = (KOCalCheckButton*) sender();
181 KOCalCheckButton* it = mStdandardB.first(); 181 KOCalCheckButton* it = mStdandardB.first();
182 while ( it ) { 182 while ( it ) {
183 if ( it->isChecked() ) { 183 if ( it->isChecked() ) {
184 if ( it != sen ) { 184 if ( it != sen ) {
185 it->blockSignals( true ); 185 it->blockSignals( true );
186 it->setChecked( false ); 186 it->setChecked( false );
187 it->blockSignals( false ); 187 it->blockSignals( false );
188 break; 188 break;
189 } 189 }
190 } 190 }
191 it = mStdandardB.next(); 191 it = mStdandardB.next();
192 } 192 }
193 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 193 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
194 while ( kkf ) { 194 while ( kkf ) {
195 kkf->isStandard = false; 195 kkf->isStandard = false;
196 kkf = KOPrefs::instance()->mCalendars.next(); 196 kkf = KOPrefs::instance()->mCalendars.next();
197 } 197 }
198 KOPrefs::instance()->getCalendar( id )->isStandard = true; 198 KOPrefs::instance()->getCalendar( id )->isStandard = true;
199 emit setCalendarDefault ( id ); 199 emit setCalendarDefault ( id );
200} 200}
201 201
202void KOCalEditView::selectCalAlarm(int id ,bool b ) 202void KOCalEditView::selectCalAlarm(int id ,bool b )
203{ 203{
204 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 204 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
205 emit alarmEnabled ( id , b ); 205 emit alarmEnabled ( id , b );
206 emit needsUpdate(); 206 emit needsUpdate();
207} 207}
208void KOCalEditView::selectReadOnly(int id ,bool b ) 208void KOCalEditView::selectReadOnly(int id ,bool b )
209{ 209{
210 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 210 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
211 emit calendarReadonly ( id , b ); 211 emit calendarReadonly ( id , b );
212 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) { 212 if ( KOPrefs::instance()->getCalendar( id )->isStandard && b && id > 1 ) {
213 KOPrefs::instance()->getCalendar( id )->isStandard = false; 213 KOPrefs::instance()->getCalendar( id )->isStandard = false;
214 KOPrefs::instance()->getCalendar( 1 )->isStandard = true; 214 KOPrefs::instance()->getCalendar( 1 )->isStandard = true;
215 emit setCalendarDefault ( 1 ); 215 emit setCalendarDefault ( 1 );
216 } 216 }
217 emit needsUpdate(); 217 emit needsUpdate();
218 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 218 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
219 219
220} 220}
221void KOCalEditView::setColor( const QColor& c, int id ) 221void KOCalEditView::setColor( const QColor& c, int id )
222{ 222{
223 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 223 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
224 emit needsUpdate(); 224 emit needsUpdate();
225} 225}
226void KOCalEditView::deleteCal( int id ) 226void KOCalEditView::deleteCal( int id )
227{ 227{
228 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 228 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
229 QString name = kkf->mName; 229 QString name = kkf->mName;
230 QString file = kkf->mFileName; 230 QString file = kkf->mFileName;
231 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 231 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
232 if ( kkf->isStandard ) 232 if ( kkf->isStandard )
233 selectStdCal( 1, true ); 233 selectStdCal( 1, true );
234 emit removeCalendar ( id ); 234 emit removeCalendar ( id );
235 KOPrefs::instance()->mCalendars.remove ( kkf ); 235 KOPrefs::instance()->mCalendars.remove ( kkf );
236 emit needsUpdate(); 236 emit needsUpdate();
237 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 237 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
238} 238}
239void KOCalEditView::infoCal( int id ) 239void KOCalEditView::infoCal( int id )
240{ 240{
241 QString name = KOPrefs::instance()->getCalendar( id )->mName; 241 QString name = KOPrefs::instance()->getCalendar( id )->mName;
242 QString file = KOPrefs::instance()->getCalendar( id )->mFileName; 242 QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
243 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) { 243 if ( KOPrefs::instance()->getCalendar( id )->mErrorOnLoad ) {
244 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) { 244 if ( KMessageBox::Yes == KMessageBox::questionYesNo( this, i18n("The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>").arg(name).arg(file) ) ) {
245 emit calendarAdded( id ); 245 emit calendarAdded( id );
246 emit needsUpdate(); 246 emit needsUpdate();
247 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 247 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
248 } 248 }
249 } 249 }
250 else 250 else
251 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 251 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
252} 252}
253void KOCalEditView::readConfig() 253void KOCalEditView::readConfig()
254{ 254{
255 255
256 mStdandardB.clear(); 256 mStdandardB.clear();
257 mEnabledB.clear(); 257 mEnabledB.clear();
258 mAlarmB.clear(); 258 mAlarmB.clear();
259 mROB.clear(); 259 mROB.clear();
260 260
261 if ( mw ) delete mw; 261 if ( mw ) delete mw;
262 mw = new QWidget ( viewport() ); 262 mw = new QWidget ( viewport() );
263 addChild(mw); 263 addChild(mw);
264 264
265 mainLayout = new QGridLayout ( mw , 2, 8 ); 265 mainLayout = new QGridLayout ( mw , 2, 8 );
266 mainLayout->setMargin( 3); 266 mainLayout->setMargin( 3);
267 mainLayout->setSpacing( 2); 267 mainLayout->setSpacing( 2);
268 QPushButton * addBut = new QPushButton ( mw ); 268 QPushButton * addBut = new QPushButton ( mw );
269 mainLayout->addWidget( addBut,0,0 ); 269 mainLayout->addWidget( addBut,0,0 );
270 addBut->setPixmap ( SmallIcon("plus")); 270 addBut->setPixmap ( SmallIcon("plus"));
271 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 271 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
272 addBut->setMaximumWidth( addBut->sizeHint().height() ); 272 addBut->setMaximumWidth( addBut->sizeHint().height() );
273 273
274 addBut = new QPushButton ( mw ); 274 addBut = new QPushButton ( mw );
275 mainLayout->addWidget( addBut,0,1 ); 275 mainLayout->addWidget( addBut,0,1 );
276 addBut->setPixmap ( SmallIcon("eye")); 276 addBut->setPixmap ( SmallIcon("eye"));
277 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 277 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
278 addBut->setMaximumWidth( addBut->sizeHint().height() ); 278 addBut->setMaximumWidth( addBut->sizeHint().height() );
279 279
280 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw ); 280 QLabel* lab = new QLabel (i18n(" Calendar \n Resource "), mw );
281 mainLayout->addWidget( lab,0,2 ); 281 mainLayout->addWidget( lab,0,2 );
282 lab = new QLabel ( i18n(" "), mw ); 282 lab = new QLabel ( i18n(" "), mw );
283 mainLayout->addWidget( lab,0,3 ); 283 mainLayout->addWidget( lab,0,3 );
284 lab->setFixedWidth( 6 ); 284 lab->setFixedWidth( 6 );
285 addBut = new QPushButton ( mw ); 285 addBut = new QPushButton ( mw );
286 mainLayout->addWidget( addBut,0,4 ); 286 mainLayout->addWidget( addBut,0,4 );
287 addBut->setPixmap ( SmallIcon("bell")); 287 addBut->setPixmap ( SmallIcon("bell"));
288 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 288 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
289 addBut->setMaximumWidth( addBut->sizeHint().height() ); 289 addBut->setMaximumWidth( addBut->sizeHint().height() );
290 290
291 addBut = new QPushButton ( mw ); 291 addBut = new QPushButton ( mw );
292 mainLayout->addWidget( addBut,0,5 ); 292 mainLayout->addWidget( addBut,0,5 );
293 addBut->setPixmap ( SmallIcon("pencil")); 293 addBut->setPixmap ( SmallIcon("pencil"));
294 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 294 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
295 addBut->setMaximumWidth( addBut->sizeHint().height() ); 295 addBut->setMaximumWidth( addBut->sizeHint().height() );
296 296
297 lab = new QLabel ( i18n(" Color "), mw ); 297 lab = new QLabel ( i18n(" Color "), mw );
298 mainLayout->addWidget( lab,0,6 ); 298 mainLayout->addWidget( lab,0,6 );
299#if 0 299#if 0
300 addBut = new QPushButton ( mw ); 300 addBut = new QPushButton ( mw );
301 mainLayout->addWidget( addBut,0,6 ); 301 mainLayout->addWidget( addBut,0,6 );
302 addBut->setPixmap ( SmallIcon("minus")); 302 addBut->setPixmap ( SmallIcon("minus"));
303 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); 303 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
304 addBut->setMaximumWidth( addBut->sizeHint().height() ); 304 addBut->setMaximumWidth( addBut->sizeHint().height() );
305#endif 305#endif
306 306
307 307
308 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 308 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
309 int row = 1; 309 int row = 1;
310 while ( kkf ) { 310 while ( kkf ) {
311 int iii = 0; 311 int iii = 0;
312 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 312 KOCalCheckButton* cb = new KOCalCheckButton( mw );
313 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); 313 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
314 cb->setChecked( kkf->isStandard ); 314 cb->setChecked( kkf->isStandard );
315 cb->setNum( kkf->mCalNumber ); 315 cb->setNum( kkf->mCalNumber );
316 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); 316 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
317 if ( kkf->mErrorOnLoad || kkf->isReadOnly ) 317 if ( kkf->mErrorOnLoad || kkf->isReadOnly )
318 cb->setEnabled( false ); 318 cb->setEnabled( false );
319 cb = new KOCalCheckButton( mw ); 319 cb = new KOCalCheckButton( mw );
320 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb ); 320 mainLayout->addWidget( cb,row,++iii );mEnabledB.append( cb );
321 cb->setChecked( kkf->isEnabled ); 321 cb->setChecked( kkf->isEnabled );
322 cb->setNum( kkf->mCalNumber ); 322 cb->setNum( kkf->mCalNumber );
323 if ( kkf->mErrorOnLoad ) 323 if ( kkf->mErrorOnLoad )
324 cb->setEnabled( false ); 324 cb->setEnabled( false );
325 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 325 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
326 KOCalButton* name = new KOCalButton( mw ); 326 KOCalButton* name = new KOCalButton( mw );
327 name->setNum( kkf->mCalNumber ); 327 name->setNum( kkf->mCalNumber );
328 name->setText( kkf->mName ); 328 name->setText( kkf->mName );
329 mainLayout->addWidget( name,row,++iii ); 329 mainLayout->addWidget( name,row,++iii );
330 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 330 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
331 lab = new QLabel ( i18n(" "), mw ); 331 lab = new QLabel ( i18n(" "), mw );
332 mainLayout->addWidget( lab,row,++iii ); 332 mainLayout->addWidget( lab,row,++iii );
333 cb = new KOCalCheckButton( mw ); 333 cb = new KOCalCheckButton( mw );
334 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb ); 334 mainLayout->addWidget( cb,row,++iii );mAlarmB.append( cb );
335 cb->setChecked( kkf->isAlarmEnabled ); 335 cb->setChecked( kkf->isAlarmEnabled );
336 cb->setNum( kkf->mCalNumber ); 336 cb->setNum( kkf->mCalNumber );
337 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 337 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
338 if ( kkf->mErrorOnLoad ) 338 if ( kkf->mErrorOnLoad )
339 cb->setEnabled( false ); 339 cb->setEnabled( false );
340 cb = new KOCalCheckButton( mw ); 340 cb = new KOCalCheckButton( mw );
341 mainLayout->addWidget( cb,row,++iii );mROB.append( cb ); 341 mainLayout->addWidget( cb,row,++iii );mROB.append( cb );
342 cb->setChecked( kkf->isReadOnly ); 342 cb->setChecked( kkf->isReadOnly );
343 cb->setNum( kkf->mCalNumber ); 343 cb->setNum( kkf->mCalNumber );
344 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 344 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
345 if ( kkf->mErrorOnLoad ) 345 if ( kkf->mErrorOnLoad )
346 cb->setEnabled( false ); 346 cb->setEnabled( false );
347 KColorButton *colb = new KColorButton( mw );
348 mainLayout->addWidget( colb,row,++iii );
349 colb->setID( kkf->mCalNumber );
350 colb->setColor( kkf->mDefaultColor );
351 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
352 if ( row > 1) { 347 if ( row > 1) {
348 KColorButton *colb = new KColorButton( mw );
349 mainLayout->addWidget( colb,row,++iii );
350 colb->setID( kkf->mCalNumber );
351 colb->setColor( kkf->mDefaultColor );
352 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
353 KOCalButton* calb = new KOCalButton( mw ); 353 KOCalButton* calb = new KOCalButton( mw );
354 mainLayout->addWidget( calb,row,++iii ); 354 mainLayout->addWidget( calb,row,++iii );
355 calb->setNum( kkf->mCalNumber ); 355 calb->setNum( kkf->mCalNumber );
356 calb->setPixmap ( SmallIcon("minus")); 356 calb->setPixmap ( SmallIcon("minus"));
357 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 357 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
358 int hei = calb->sizeHint().height(); 358 int hei = calb->sizeHint().height();
359 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 359 //calb->setMaximumSize( hei*9/10, hei*9/10 );
360 } 360 }
361 ++row; 361 ++row;
362 kkf = KOPrefs::instance()->mCalendars.next(); 362 kkf = KOPrefs::instance()->mCalendars.next();
363 } 363 }
364 lab = new QLabel ( "", mw ); 364 lab = new QLabel ( "", mw );
365 mainLayout->addWidget( lab,row,0 ); 365 mainLayout->addWidget( lab,row,0 );
366 mw->show(); 366 mw->show();
367 367
368} 368}
369void KOCalEditView::addCal() 369void KOCalEditView::addCal()
370{ 370{
371 KONewCalPrefs prefs ( this ); 371 KONewCalPrefs prefs ( this );
372 if ( ! prefs.exec() ) 372 if ( ! prefs.exec() )
373 return; 373 return;
374 QString name = prefs.calName(); 374 QString name = prefs.calName();
375 QString file = prefs.calFileName(); 375 QString file = prefs.calFileName();
376 QFileInfo fi ( file ); 376 QFileInfo fi ( file );
377 if (!fi.exists() ) { 377 if (!fi.exists() ) {
378 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); 378 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!"));
379 return; 379 return;
380 } 380 }
381 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 381 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
382 kkf->mName = name; 382 kkf->mName = name;
383 kkf->mFileName = file; 383 kkf->mFileName = file;
384 emit calendarAdded( kkf->mCalNumber ); 384 emit calendarAdded( kkf->mCalNumber );
385 emit needsUpdate(); 385 emit needsUpdate();
386 QTimer::singleShot( 0, this, SLOT ( readConfig() ) ); 386 QTimer::singleShot( 0, this, SLOT ( readConfig() ) );
387} 387}
388void KOCalEditView::enableAll() 388void KOCalEditView::enableAll()
389{ 389{
390 toggleList( mEnabledB ); 390 toggleList( mEnabledB );
391} 391}
392void KOCalEditView::enableAlarm() 392void KOCalEditView::enableAlarm()
393{ 393{
394 toggleList( mAlarmB ); 394 toggleList( mAlarmB );
395} 395}
396void KOCalEditView::disableRO() 396void KOCalEditView::disableRO()
397{ 397{
398 toggleList( mROB ); 398 toggleList( mROB );
399} 399}
400void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) 400void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
401{ 401{
402 bool dis = false; 402 bool dis = false;
403 KOCalCheckButton* it = list.first(); 403 KOCalCheckButton* it = list.first();
404 while ( it ) { 404 while ( it ) {
405 if ( !it->isChecked() ) { 405 if ( !it->isChecked() ) {
406 dis = true; 406 dis = true;
407 break; 407 break;
408 } 408 }
409 it = list.next(); 409 it = list.next();
410 } 410 }
411 it = list.first(); 411 it = list.first();
412 while ( it ) { 412 while ( it ) {
413 it->setChecked(dis); 413 it->setChecked(dis);
414 it = list.next(); 414 it = list.next();
415 } 415 }
416} 416}
417void KOCalEditView::deleteAll() 417void KOCalEditView::deleteAll()
418{ 418{
419 qDebug("delteAll"); 419 qDebug("delteAll");
420} 420}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 96f2502..2150654 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,2096 +1,2100 @@
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 <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92#if QT_VERSION >= 0x030000 92#if QT_VERSION >= 0x030000
93 93
94#else 94#else
95 delete mWT; 95 delete mWT;
96#endif 96#endif
97} 97}
98 98
99 99
100void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 100void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
101{ 101{
102 QListBox::focusInEvent ( e ); 102 QListBox::focusInEvent ( e );
103 if ( count() ){ 103 if ( count() ){
104 int ci = currentItem(); 104 int ci = currentItem();
105 if ( ci < 0 ) ci = 0; 105 if ( ci < 0 ) ci = 0;
106 106
107 setCurrentItem( ci ); 107 setCurrentItem( ci );
108 setSelected ( ci, true ); 108 setSelected ( ci, true );
109 emit highlighted( item ( ci ) ); 109 emit highlighted( item ( ci ) );
110 110
111 resetOnFocusIn = true; 111 resetOnFocusIn = true;
112 112
113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
114 QListBoxItem *fi = firstItem (); 114 QListBoxItem *fi = firstItem ();
115 if (fi ) { 115 if (fi ) {
116 int ihei = fi->height( this ); 116 int ihei = fi->height( this );
117 int hei = numRows () * ihei; 117 int hei = numRows () * ihei;
118 if ( hei < height() - horizontalScrollBar()->height () ) { 118 if ( hei < height() - horizontalScrollBar()->height () ) {
119 setVScrollBarMode(QScrollView::AlwaysOff); 119 setVScrollBarMode(QScrollView::AlwaysOff);
120 } 120 }
121 else 121 else
122 setVScrollBarMode(QScrollView::Auto); 122 setVScrollBarMode(QScrollView::Auto);
123 if ( ihei *3 > height() ) { 123 if ( ihei *3 > height() ) {
124 setHScrollBarMode(QScrollView::AlwaysOff); 124 setHScrollBarMode(QScrollView::AlwaysOff);
125 } 125 }
126 else { 126 else {
127 setHScrollBarMode(QScrollView::Auto); 127 setHScrollBarMode(QScrollView::Auto);
128 } 128 }
129 } else { 129 } else {
130 setVScrollBarMode(QScrollView::Auto); 130 setVScrollBarMode(QScrollView::Auto);
131 setHScrollBarMode(QScrollView::Auto); 131 setHScrollBarMode(QScrollView::Auto);
132 } 132 }
133 } 133 }
134 } 134 }
135} 135}
136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
137{ 137{
138 int i = currentItem (); 138 int i = currentItem ();
139 if ( i >= 0 ) { 139 if ( i >= 0 ) {
140 setSelected ( i, false ); 140 setSelected ( i, false );
141 } 141 }
142 QListBox::focusOutEvent ( e ); 142 QListBox::focusOutEvent ( e );
143 setVScrollBarMode(QScrollView::AlwaysOff); 143 setVScrollBarMode(QScrollView::AlwaysOff);
144 setHScrollBarMode(QScrollView::AlwaysOff); 144 setHScrollBarMode(QScrollView::AlwaysOff);
145} 145}
146 146
147QString KNoScrollListBox::getWhatsThisText(QPoint p) 147QString KNoScrollListBox::getWhatsThisText(QPoint p)
148{ 148{
149 QListBoxItem* item = itemAt ( p ); 149 QListBoxItem* item = itemAt ( p );
150 if ( ! item ) { 150 if ( ! item ) {
151 return i18n("Click in the cell\nto add an event!"); 151 return i18n("Click in the cell\nto add an event!");
152 } 152 }
153 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 153 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
154 KOPrefs::instance()->mWTshowDetails, 154 KOPrefs::instance()->mWTshowDetails,
155 KOPrefs::instance()->mWTshowCreated, 155 KOPrefs::instance()->mWTshowCreated,
156 KOPrefs::instance()->mWTshowChanged); 156 KOPrefs::instance()->mWTshowChanged);
157} 157}
158void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 158void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
159{ 159{
160 //qDebug("KNoScrollListBox::keyPressEvent "); 160 //qDebug("KNoScrollListBox::keyPressEvent ");
161 switch(e->key()) { 161 switch(e->key()) {
162 case Key_Right: 162 case Key_Right:
163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
164 { 164 {
165 e->ignore(); 165 e->ignore();
166 return; 166 return;
167 } 167 }
168 scrollBy(10,0); 168 scrollBy(10,0);
169 break; 169 break;
170 case Key_Left: 170 case Key_Left:
171 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 171 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
172 { 172 {
173 e->ignore(); 173 e->ignore();
174 return; 174 return;
175 } 175 }
176 scrollBy(-10,0); 176 scrollBy(-10,0);
177 break; 177 break;
178 case Key_Up: 178 case Key_Up:
179 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 179 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
180 e->ignore(); 180 e->ignore();
181 break; 181 break;
182 } 182 }
183 if ( count() ) { 183 if ( count() ) {
184 if ( currentItem() == 0 ) { 184 if ( currentItem() == 0 ) {
185 emit prevCell(); 185 emit prevCell();
186 } else { 186 } else {
187 setCurrentItem((currentItem()+count()-1)%count()); 187 setCurrentItem((currentItem()+count()-1)%count());
188 if(!itemVisible(currentItem())) { 188 if(!itemVisible(currentItem())) {
189 if((unsigned int) currentItem() == (count()-1)) { 189 if((unsigned int) currentItem() == (count()-1)) {
190 setTopItem(currentItem()-numItemsVisible()+1); 190 setTopItem(currentItem()-numItemsVisible()+1);
191 } else { 191 } else {
192 setTopItem(topItem()-1); 192 setTopItem(topItem()-1);
193 } 193 }
194 } 194 }
195 } 195 }
196 } 196 }
197 break; 197 break;
198 case Key_Down: 198 case Key_Down:
199 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 199 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
200 e->ignore(); 200 e->ignore();
201 break; 201 break;
202 } 202 }
203 if ( count () ) { 203 if ( count () ) {
204 if ( currentItem()+1 == count () ) { 204 if ( currentItem()+1 == count () ) {
205 emit nextCell(); 205 emit nextCell();
206 } else { 206 } else {
207 setCurrentItem((currentItem()+1)%count()); 207 setCurrentItem((currentItem()+1)%count());
208 if(!itemVisible(currentItem())) { 208 if(!itemVisible(currentItem())) {
209 if(currentItem() == 0) { 209 if(currentItem() == 0) {
210 setTopItem(0); 210 setTopItem(0);
211 } else { 211 } else {
212 setTopItem(topItem()+1); 212 setTopItem(topItem()+1);
213 } 213 }
214 } 214 }
215 } 215 }
216 } 216 }
217 break; 217 break;
218 case Key_I: 218 case Key_I:
219 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 219 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
220 e->ignore(); 220 e->ignore();
221 break; 221 break;
222 case Key_Return: 222 case Key_Return:
223 case Key_Enter: 223 case Key_Enter:
224 { 224 {
225 if ( currentItem() >= 0 ) { 225 if ( currentItem() >= 0 ) {
226 emit doubleClicked( item( currentItem() ) ); 226 emit doubleClicked( item( currentItem() ) );
227 e->accept(); 227 e->accept();
228 } else { 228 } else {
229 e->ignore(); 229 e->ignore();
230 } 230 }
231 } 231 }
232 break; 232 break;
233 case Key_Shift: 233 case Key_Shift:
234 emit shiftDown(); 234 emit shiftDown();
235 break; 235 break;
236 default: 236 default:
237 e->ignore(); 237 e->ignore();
238 break; 238 break;
239 } 239 }
240} 240}
241 241
242void KNoScrollListBox::oneDown() 242void KNoScrollListBox::oneDown()
243{ 243{
244 if ( count () ) { 244 if ( count () ) {
245 if ( currentItem()+1 == count () ) { 245 if ( currentItem()+1 == count () ) {
246 emit nextCell(); 246 emit nextCell();
247 } else { 247 } else {
248 resetOnFocusIn = false; 248 resetOnFocusIn = false;
249 setCurrentItem((currentItem()+1)%count()); 249 setCurrentItem((currentItem()+1)%count());
250 if(!itemVisible(currentItem())) { 250 if(!itemVisible(currentItem())) {
251 if(currentItem() == 0) { 251 if(currentItem() == 0) {
252 setTopItem(0); 252 setTopItem(0);
253 } else { 253 } else {
254 setTopItem(topItem()+1); 254 setTopItem(topItem()+1);
255 } 255 }
256 } 256 }
257 } 257 }
258 } 258 }
259} 259}
260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
261{ 261{
262 switch(e->key()) { 262 switch(e->key()) {
263 case Key_Shift: 263 case Key_Shift:
264 emit shiftUp(); 264 emit shiftUp();
265 break; 265 break;
266 default: 266 default:
267 break; 267 break;
268 } 268 }
269} 269}
270 270
271void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 271void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
272{ 272{
273 QListBox::mousePressEvent(e); 273 QListBox::mousePressEvent(e);
274 274
275 if(e->button() == RightButton) { 275 if(e->button() == RightButton) {
276 emit rightClick(); 276 emit rightClick();
277 } 277 }
278} 278}
279 279
280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
281 : QListBoxItem() 281 : QListBoxItem()
282{ 282{
283 mblockRepaint = true; 283 mblockRepaint = true;
284 setText( s ); 284 setText( s );
285 mMultiday = 0; 285 mMultiday = 0;
286 mIncidence = incidence; 286 mIncidence = incidence;
287 mDate = qd; 287 mDate = qd;
288 mRecur = false; 288 mRecur = false;
289 mAlarm = false; 289 mAlarm = false;
290 mReply = false; 290 mReply = false;
291 mInfo = false; 291 mInfo = false;
292 mdayPos = 0; 292 mdayPos = 0;
293 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 293 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
294} 294}
295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
296{ 296{
297 setText( s ); 297 setText( s );
298 mMultiday = 0; 298 mMultiday = 0;
299 mIncidence = incidence; 299 mIncidence = incidence;
300 mDate = qd; 300 mDate = qd;
301 mRecur = false; 301 mRecur = false;
302 mAlarm = false; 302 mAlarm = false;
303 mReply = false; 303 mReply = false;
304 mInfo = false; 304 mInfo = false;
305 mdayPos = 0; 305 mdayPos = 0;
306} 306}
307 307
308void MonthViewItem::paint(QPainter *p) 308void MonthViewItem::paint(QPainter *p)
309{ 309{
310 if ( mblockRepaint ) { 310 if ( mblockRepaint ) {
311 return; 311 return;
312 } 312 }
313#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 314 bool sel = isSelected();
315#else 315#else
316 bool sel = selected(); 316 bool sel = selected();
317#endif 317#endif
318 318
319 319
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 321 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 322 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 323 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
325 } 325 }
326 int x = 1; 326 int x = 1;
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 327 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 328 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 329 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 330 size = 3;
331 int heihei = height( listBox () ); 331 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 332 int y = (heihei - size -1 ) /2;
333 333
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 334 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 335 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 336 p->fillRect ( x, y,size,size, Qt::darkGreen );
337 x += size + 1; 337 x += size + 1;
338 } 338 }
339 if ( mRecur ) { 339 if ( mRecur ) {
340 p->fillRect ( x, y,size,size, Qt::blue ); 340 p->fillRect ( x, y,size,size, Qt::blue );
341 x += size + 1; 341 x += size + 1;
342 } 342 }
343 if ( mAlarm ) { 343 if ( mAlarm ) {
344 p->fillRect ( x, y,size,size, Qt::red ); 344 p->fillRect ( x, y,size,size, Qt::red );
345 x += size + 1; 345 x += size + 1;
346 } 346 }
347 if ( mReply ) { 347 if ( mReply ) {
348 p->fillRect ( x, y,size,size, Qt::yellow ); 348 p->fillRect ( x, y,size,size, Qt::yellow );
349 x += size + 1; 349 x += size + 1;
350 } 350 }
351 } 351 }
352 if ( mMultiday ) { 352 if ( mMultiday ) {
353 int yyy = y+(size/2); 353 int yyy = y+(size/2);
354 int sizeM = size+2; 354 int sizeM = size+2;
355 p->setBrush( QBrush::SolidPattern ); 355 p->setBrush( QBrush::SolidPattern );
356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
357 if ( mMultiday == 2 || mMultiday == 3 ) { 357 if ( mMultiday == 2 || mMultiday == 3 ) {
358 QPointArray pa ( 3 ); 358 QPointArray pa ( 3 );
359 pa.setPoint (0, x, yyy ); 359 pa.setPoint (0, x, yyy );
360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
362 p->drawPolygon( pa ); 362 p->drawPolygon( pa );
363 } 363 }
364 if ( mMultiday == 2 || mMultiday == 1 ) { 364 if ( mMultiday == 2 || mMultiday == 1 ) {
365 QPointArray pa ( 3 ); 365 QPointArray pa ( 3 );
366 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 366 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
369 p->drawPolygon( pa ); 369 p->drawPolygon( pa );
370 } 370 }
371 if ( mMultiday == 1 ) { 371 if ( mMultiday == 1 ) {
372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
373 373
374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
375 } 375 }
376 if ( mMultiday == 3 ) { 376 if ( mMultiday == 3 ) {
377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
379 379
380 } 380 }
381 x += sizeM/2 + 1; 381 x += sizeM/2 + 1;
382 x += sizeM + 1; 382 x += sizeM + 1;
383 } 383 }
384 384
385 if ( mIncidence->typeID() == todoID ){ 385 if ( mIncidence->typeID() == todoID ){
386 Todo* td = ( Todo* ) mIncidence; 386 Todo* td = ( Todo* ) mIncidence;
387 if ( td->isCompleted() ) { 387 if ( td->isCompleted() ) {
388 int half = size/2; 388 int half = size/2;
389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
391 x += half+half + 4; 391 x += half+half + 4;
392 392
393 } else { 393 } else {
394 int val = td->percentComplete()/20; 394 int val = td->percentComplete()/20;
395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
396 p->drawRect ( x, y-2,7,size+4); 396 p->drawRect ( x, y-2,7,size+4);
397 x += size + 3; 397 x += size + 3;
398 } 398 }
399 } 399 }
400 QFontMetrics fm = p->fontMetrics(); 400 QFontMetrics fm = p->fontMetrics();
401 int yPos; 401 int yPos;
402 int pmheight = size; 402 int pmheight = size;
403 if( pmheight < fm.height() ) 403 if( pmheight < fm.height() )
404 yPos = fm.ascent() + fm.leading()/2; 404 yPos = fm.ascent() + fm.leading()/2;
405 else 405 else
406 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 406 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
407 p->setPen( palette().color( QPalette::Normal, sel ? \ 407 p->setPen( palette().color( QPalette::Normal, sel ? \
408 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 408 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
409 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 409 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
410 p->drawText( x, yPos, text() ); 410 p->drawText( x, yPos, text() );
411 if ( mIncidence->cancelled() ) { 411 if ( mIncidence->cancelled() ) {
412 int wid = fm.width( text() ); 412 int wid = fm.width( text() );
413 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 413 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
414 } 414 }
415 } else { 415 } else {
416 QString pText = text(); 416 QString pText = text();
417 if( pText.mid(2,1) == ":" ) 417 if( pText.mid(2,1) == ":" )
418 pText = pText.mid( 6 ); 418 pText = pText.mid( 6 );
419 p->drawText( x, yPos, pText ); 419 p->drawText( x, yPos, pText );
420 if ( mIncidence->cancelled() ) { 420 if ( mIncidence->cancelled() ) {
421 int wid = fm.width( pText ); 421 int wid = fm.width( pText );
422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
423 } 423 }
424 } 424 }
425} 425}
426 426
427int MonthViewItem::height(const QListBox *lb) const 427int MonthViewItem::height(const QListBox *lb) const
428{ 428{
429 int ret = 10; 429 int ret = 10;
430 if ( lb ) 430 if ( lb )
431 ret = lb->fontMetrics().lineSpacing()+1; 431 ret = lb->fontMetrics().lineSpacing()+1;
432 return ret; 432 return ret;
433} 433}
434 434
435int MonthViewItem::width(const QListBox *lb) const 435int MonthViewItem::width(const QListBox *lb) const
436{ 436{
437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
438 int size = PIXMAP_SIZE; 438 int size = PIXMAP_SIZE;
439 if ( QApplication::desktop()->width() < 300 ) 439 if ( QApplication::desktop()->width() < 300 )
440 size = 3; 440 size = 3;
441 int x = 1; 441 int x = 1;
442 if ( KOPrefs::instance()->mMonthShowIcons ) { 442 if ( KOPrefs::instance()->mMonthShowIcons ) {
443 if ( mInfo ) { 443 if ( mInfo ) {
444 x += size + 1; 444 x += size + 1;
445 } 445 }
446 if( mRecur ) { 446 if( mRecur ) {
447 x += size+1; 447 x += size+1;
448 } 448 }
449 if( mAlarm ) { 449 if( mAlarm ) {
450 x += size+1; 450 x += size+1;
451 } 451 }
452 if( mReply ) { 452 if( mReply ) {
453 x += size+1; 453 x += size+1;
454 } 454 }
455 } 455 }
456 if( mMultiday ) { 456 if( mMultiday ) {
457 x += size+1+2+size/2; 457 x += size+1+2+size/2;
458 } 458 }
459 return( x + lb->fontMetrics().width( text() ) + 1 ); 459 return( x + lb->fontMetrics().width( text() ) + 1 );
460 } 460 }
461 if ( ! lb ) 461 if ( ! lb )
462 return 10; 462 return 10;
463 return lb->width(); 463 return lb->width();
464} 464}
465 465
466 466
467MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 467MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
468 : KNoScrollListBox( par ), 468 : KNoScrollListBox( par ),
469 mMonthView( parent ) 469 mMonthView( parent )
470{ 470{
471 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 471 //QVBoxLayout *topLayout = new QVBoxLayout( this );
472 currentPalette = 0; 472 currentPalette = 0;
473 // mLabel = new QLabel( this );QPushButton 473 // mLabel = new QLabel( this );QPushButton
474 mLabel = new QPushButton( this ); 474 mLabel = new QPushButton( this );
475 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 475 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
476 //mLabel->setLineWidth( 1 ); 476 //mLabel->setLineWidth( 1 );
477 //mLabel->setAlignment( AlignCenter ); 477 //mLabel->setAlignment( AlignCenter );
478 mLabel->setFlat( true ); 478 mLabel->setFlat( true );
479 mLabel->setFocusPolicy(NoFocus); 479 mLabel->setFocusPolicy(NoFocus);
480 //mItemList = new KNoScrollListBox( this ); 480 //mItemList = new KNoScrollListBox( this );
481 setMinimumSize( 10, 10 ); 481 setMinimumSize( 10, 10 );
482 setFrameStyle( QFrame::Panel | QFrame::Plain ); 482 setFrameStyle( QFrame::Panel | QFrame::Plain );
483 setLineWidth( 1 ); 483 setLineWidth( 1 );
484 //topLayout->addWidget( mItemList ); 484 //topLayout->addWidget( mItemList );
485 mLabel->raise(); 485 mLabel->raise();
486 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 486 // QColor( 0,0,255 ) QColor( 160,1600,255 )
487 mStandardPalette = palette(); 487 mStandardPalette = palette();
488 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 488 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
489 489
490 enableScrollBars( false ); 490 enableScrollBars( false );
491 updateConfig(); 491 updateConfig();
492 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 492 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
493 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 493 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
494 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 494 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
495 SLOT( defaultAction( QListBoxItem * ) ) ); 495 SLOT( defaultAction( QListBoxItem * ) ) );
496 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 496 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
497 const QPoint &) ), 497 const QPoint &) ),
498 SLOT( contextMenu( QListBoxItem * ) ) ); 498 SLOT( contextMenu( QListBoxItem * ) ) );
499 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 499 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
500 SLOT( selection( QListBoxItem * ) ) ); 500 SLOT( selection( QListBoxItem * ) ) );
501 501
502 /* 502 /*
503 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 503 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
504 SLOT( selection( QListBoxItem * ) ) ); 504 SLOT( selection( QListBoxItem * ) ) );
505 */ 505 */
506} 506}
507#ifdef DESKTOP_VERSION 507#ifdef DESKTOP_VERSION
508QToolTipGroup *MonthViewCell::toolTipGroup() 508QToolTipGroup *MonthViewCell::toolTipGroup()
509{ 509{
510 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 510 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
511 return mToolTipGroup; 511 return mToolTipGroup;
512} 512}
513#endif 513#endif
514 514
515void MonthViewCell::setDate( const QDate &date ) 515void MonthViewCell::setDate( const QDate &date )
516{ 516{
517 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 517 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
518 mDate = date; 518 mDate = date;
519 519
520 520
521 521
522 //resizeEvent( 0 ); 522 //resizeEvent( 0 );
523} 523}
524 524
525QDate MonthViewCell::date() const 525QDate MonthViewCell::date() const
526{ 526{
527 return mDate; 527 return mDate;
528} 528}
529 529
530void MonthViewCell::setPrimary( bool primary ) 530void MonthViewCell::setPrimary( bool primary )
531{ 531{
532 mPrimary = primary; 532 mPrimary = primary;
533 //setMyPalette(); 533 //setMyPalette();
534} 534}
535void MonthViewCell::setMyPalette() 535void MonthViewCell::setMyPalette()
536{ 536{
537 537
538 if ( mHoliday) { 538 if ( mHoliday) {
539 if ( currentPalette == 1 ) return; 539 if ( currentPalette == 1 ) return;
540 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 540 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
541 setPalette( mHolidayPalette ); 541 setPalette( mHolidayPalette );
542 //mLabel->setPalette( mHolidayPalette ); 542 //mLabel->setPalette( mHolidayPalette );
543 currentPalette = 1; 543 currentPalette = 1;
544 544
545 } else { 545 } else {
546 if ( mPrimary ) { 546 if ( mPrimary ) {
547 if ( currentPalette == 2 ) return; 547 if ( currentPalette == 2 ) return;
548 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 548 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
549 //mLabel->setPalette( mPrimaryPalette ); 549 //mLabel->setPalette( mPrimaryPalette );
550 setPalette( mPrimaryPalette ); 550 setPalette( mPrimaryPalette );
551 currentPalette = 2; 551 currentPalette = 2;
552 552
553 } else { 553 } else {
554 if ( currentPalette == 3 ) return; 554 if ( currentPalette == 3 ) return;
555 setPalette( mNonPrimaryPalette ); 555 setPalette( mNonPrimaryPalette );
556 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 556 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
557 //mLabel->setPalette( mNonPrimaryPalette );; 557 //mLabel->setPalette( mNonPrimaryPalette );;
558 currentPalette = 3; 558 currentPalette = 3;
559 } 559 }
560 } 560 }
561 //QPalette pal = palette(); 561 //QPalette pal = palette();
562 562
563 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 563 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
564} 564}
565QPalette MonthViewCell::getPalette () 565QPalette MonthViewCell::getPalette ()
566{ 566{
567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
568 return mStandardPalette; 568 return mStandardPalette;
569 if ( mHoliday) { 569 if ( mHoliday) {
570 return mHolidayPalette ; 570 return mHolidayPalette ;
571 } else { 571 } else {
572 if ( mPrimary ) { 572 if ( mPrimary ) {
573 return mPrimaryPalette ; 573 return mPrimaryPalette ;
574 } 574 }
575 } 575 }
576 return mNonPrimaryPalette; 576 return mNonPrimaryPalette;
577} 577}
578bool MonthViewCell::isPrimary() const 578bool MonthViewCell::isPrimary() const
579{ 579{
580 return mPrimary; 580 return mPrimary;
581} 581}
582 582
583void MonthViewCell::setHoliday( bool holiday ) 583void MonthViewCell::setHoliday( bool holiday )
584{ 584{
585 mHoliday = holiday; 585 mHoliday = holiday;
586 //setMyPalette(); 586 //setMyPalette();
587} 587}
588 588
589void MonthViewCell::setHoliday( const QString &holiday ) 589void MonthViewCell::setHoliday( const QString &holiday )
590{ 590{
591 mHolidayString = holiday; 591 mHolidayString = holiday;
592 592
593 if ( !holiday.isEmpty() ) { 593 if ( !holiday.isEmpty() ) {
594 setHoliday( true ); 594 setHoliday( true );
595 } 595 }
596} 596}
597 597
598void MonthViewCell::startUpdateCell() 598void MonthViewCell::startUpdateCell()
599{ 599{
600 mdayCount = 0; 600 mdayCount = 0;
601 setFocusPolicy(NoFocus); 601 setFocusPolicy(NoFocus);
602 if ( !mMonthView->isUpdatePossible() ) 602 if ( !mMonthView->isUpdatePossible() )
603 return; 603 return;
604 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 604 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
605 while ( mitem ) { 605 while ( mitem ) {
606 mitem->setBlockRepaint( true ); 606 mitem->setBlockRepaint( true );
607 mitem = (MonthViewItem *)mitem->next(); 607 mitem = (MonthViewItem *)mitem->next();
608 } 608 }
609 if ( mAvailItemList.count() > 20 ) { 609 if ( mAvailItemList.count() > 20 ) {
610 mAvailItemList.setAutoDelete( true ); 610 mAvailItemList.setAutoDelete( true );
611 mAvailItemList.clear(); 611 mAvailItemList.clear();
612 mAvailItemList.setAutoDelete( false ); 612 mAvailItemList.setAutoDelete( false );
613 } 613 }
614 614
615 setPrimary( mDate.month()%2 ); 615 setPrimary( mDate.month()%2 );
616 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 616 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
617 if ( mDate == QDate::currentDate() ) { 617 if ( mDate == QDate::currentDate() ) {
618 setLineWidth( 3 ); 618 setLineWidth( 3 );
619 } else { 619 } else {
620 setLineWidth( 1 ); 620 setLineWidth( 1 );
621 } 621 }
622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
623 //clear(); 623 //clear();
624 while ( CurrentAvailItem ) { 624 while ( CurrentAvailItem ) {
625 MonthViewItem *item = CurrentAvailItem; 625 MonthViewItem *item = CurrentAvailItem;
626 CurrentAvailItem = (MonthViewItem *)item->next(); 626 CurrentAvailItem = (MonthViewItem *)item->next();
627 mAvailItemList.append( item ); 627 mAvailItemList.append( item );
628 takeItem ( item ); 628 takeItem ( item );
629 } 629 }
630 630
631#ifdef DESKTOP_VERSION 631#ifdef DESKTOP_VERSION
632 QToolTip::remove(this); 632 QToolTip::remove(this);
633#endif 633#endif
634 mToolTip.clear(); 634 mToolTip.clear();
635 //qApp->processEvents(); 635 //qApp->processEvents();
636#if 0 636#if 0
637 if ( !mHolidayString.isEmpty() ) { 637 if ( !mHolidayString.isEmpty() ) {
638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
639 item->setPalette( mHolidayPalette ); 639 item->setPalette( mHolidayPalette );
640 insertItem( item ); 640 insertItem( item );
641 mToolTip.append ( mHolidayString ); 641 mToolTip.append ( mHolidayString );
642 } 642 }
643#endif 643#endif
644} 644}
645 645
646int MonthViewCell::insertEvent(Event *event) 646int MonthViewCell::insertEvent(Event *event)
647{ 647{
648 bool useToolTips = true; 648 bool useToolTips = true;
649#ifndef DESKTOP_VERSION 649#ifndef DESKTOP_VERSION
650 useToolTips = false; 650 useToolTips = false;
651#endif 651#endif
652 QString mToolTipText; 652 QString mToolTipText;
653 setFocusPolicy(WheelFocus); 653 setFocusPolicy(WheelFocus);
654 if ( !(event->doesRecur() == Recurrence::rNone) ) { 654 if ( !(event->doesRecur() == Recurrence::rNone) ) {
655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
656 return mdayCount; 656 return mdayCount;
657 else 657 else
658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
659 return mdayCount; 659 return mdayCount;
660 } 660 }
661 661
662 if ( event->isHoliday()) { 662 if ( event->isHoliday()) {
663 setHoliday( true ); 663 setHoliday( true );
664 if ( mDate.dayOfWeek() == 7 ) 664 if ( mDate.dayOfWeek() == 7 )
665 setLineWidth( 3 ); 665 setLineWidth( 3 );
666 } 666 }
667 QString text; 667 QString text;
668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
669 if (event->isMultiDay()) { 669 if (event->isMultiDay()) {
670 QString prefix = "<->";multiday = 2; 670 QString prefix = "<->";multiday = 2;
671 QString time; 671 QString time;
672 if ( event->doesRecur() ) { 672 if ( event->doesRecur() ) {
673 if ( event->recursOn( mDate) ) { 673 if ( event->recursOn( mDate) ) {
674 prefix ="->" ;multiday = 1; 674 prefix ="->" ;multiday = 1;
675 } 675 }
676 else { 676 else {
677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
678 if ( event->recursOn( mDate.addDays( -days)) ) { 678 if ( event->recursOn( mDate.addDays( -days)) ) {
679 prefix ="<-" ;multiday = 3; 679 prefix ="<-" ;multiday = 3;
680 } 680 }
681 } 681 }
682 682
683 } else { 683 } else {
684 if (mDate == event->dtStart().date()) { 684 if (mDate == event->dtStart().date()) {
685 prefix ="->" ;multiday = 1; 685 prefix ="->" ;multiday = 1;
686 } else if (mDate == event->dtEnd().date()) { 686 } else if (mDate == event->dtEnd().date()) {
687 prefix ="<-" ;multiday = 3; 687 prefix ="<-" ;multiday = 3;
688 } 688 }
689 } 689 }
690 if ( !event->doesFloat() ) { 690 if ( !event->doesFloat() ) {
691 if ( mDate == event->dtStart().date () ) 691 if ( mDate == event->dtStart().date () )
692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
693 else if ( mDate == event->dtEnd().date () ) 693 else if ( mDate == event->dtEnd().date () )
694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
695 695
696 } 696 }
697 text = time + event->summary(); 697 text = time + event->summary();
698 if ( useToolTips ) 698 if ( useToolTips )
699 mToolTipText += prefix + text; 699 mToolTipText += prefix + text;
700 } else { 700 } else {
701 if (event->doesFloat()) { 701 if (event->doesFloat()) {
702 text = event->summary(); 702 text = event->summary();
703 if ( useToolTips ) 703 if ( useToolTips )
704 mToolTipText += text; 704 mToolTipText += text;
705 } 705 }
706 else { 706 else {
707 text = KGlobal::locale()->formatTime(event->dtStart().time()); 707 text = KGlobal::locale()->formatTime(event->dtStart().time());
708 text += " " + event->summary(); 708 text += " " + event->summary();
709 if ( useToolTips ) 709 if ( useToolTips )
710 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 710 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
711 } 711 }
712 } 712 }
713 if ( useToolTips && ! event->location().isEmpty() ) { 713 if ( useToolTips && ! event->location().isEmpty() ) {
714 mToolTipText += " (" + event->location() +")"; 714 mToolTipText += " (" + event->location() +")";
715 } 715 }
716 MonthViewItem *item ; 716 MonthViewItem *item ;
717 717
718 if ( mAvailItemList.count() ) { 718 if ( mAvailItemList.count() ) {
719 item = mAvailItemList.first(); 719 item = mAvailItemList.first();
720 mAvailItemList.remove( item ); 720 mAvailItemList.remove( item );
721 item->recycle( event, mDate, text ); 721 item->recycle( event, mDate, text );
722 } else { 722 } else {
723 item = new MonthViewItem( event, mDate, text ); 723 item = new MonthViewItem( event, mDate, text );
724 } 724 }
725 725
726 QPalette pal; 726 QPalette pal;
727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
728 QStringList categories = event->categories(); 728 QStringList categories = event->categories();
729 QString cat = categories.first(); 729 QString cat = categories.first();
730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
731 pal = getPalette(); 731 pal = getPalette();
732 if (cat.isEmpty()) { 732 if (cat.isEmpty()) {
733 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 733 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
734 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
734 } else { 735 } else {
735 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 736 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
736 } 737 }
737 738
738 } else { 739 } else {
739 if (cat.isEmpty()) { 740 if (cat.isEmpty()) {
740 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 741 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
742 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
741 } else { 743 } else {
742 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 744 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
743 } 745 }
744 } 746 }
745 747
746 } else { 748 } else {
747 pal = mStandardPalette ; 749 pal = mStandardPalette ;
748 } 750 }
749 item->setPalette( pal ); 751 item->setPalette( pal );
750 item->setRecur( event->recurrence()->doesRecur() ); 752 item->setRecur( event->recurrence()->doesRecur() );
751 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); 753 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
752 item->setMoreInfo( event->description().length() > 0 ); 754 item->setMoreInfo( event->description().length() > 0 );
753#ifdef DESKTOP_VERSION 755#ifdef DESKTOP_VERSION
754 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 756 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
755 KOPrefs::instance()->email()); 757 KOPrefs::instance()->email());
756 if ( me != 0 ) { 758 if ( me != 0 ) {
757 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 759 if ( me->status() == Attendee::NeedsAction && me->RSVP())
758 item->setReply(true && multiday < 2); 760 item->setReply(true && multiday < 2);
759 else 761 else
760 item->setReply(false); 762 item->setReply(false);
761 } else 763 } else
762 item->setReply(false); 764 item->setReply(false);
763#endif 765#endif
764 item->setMultiDay( multiday ); 766 item->setMultiDay( multiday );
765 if ( multiday ) { 767 if ( multiday ) {
766 insertItem( item ,mdayCount); 768 insertItem( item ,mdayCount);
767 ++mdayCount; 769 ++mdayCount;
768 } else { 770 } else {
769 uint i; 771 uint i;
770 int pos = mdayCount; 772 int pos = mdayCount;
771 for ( i = mdayCount; i < count();++i ) { 773 for ( i = mdayCount; i < count();++i ) {
772 QListBoxItem* it = this->item ( i ); 774 QListBoxItem* it = this->item ( i );
773 if ( it && text < it->text() ) { 775 if ( it && text < it->text() ) {
774 pos = i; 776 pos = i;
775 break; 777 break;
776 } 778 }
777 ++pos; 779 ++pos;
778 } 780 }
779 insertItem( item ,pos); 781 insertItem( item ,pos);
780 } 782 }
781 if ( useToolTips ) { 783 if ( useToolTips ) {
782 mToolTip.append( mToolTipText ); 784 mToolTip.append( mToolTipText );
783 } 785 }
784 return mdayCount; 786 return mdayCount;
785} 787}
786void MonthViewCell::insertTodo(Todo *todo) 788void MonthViewCell::insertTodo(Todo *todo)
787{ 789{
788 setFocusPolicy(WheelFocus); 790 setFocusPolicy(WheelFocus);
789 QString text; 791 QString text;
790 if (todo->hasDueDate()) { 792 if (todo->hasDueDate()) {
791 if (!todo->doesFloat()) { 793 if (!todo->doesFloat()) {
792 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 794 text += KGlobal::locale()->formatTime(todo->dtDue().time());
793 text += " "; 795 text += " ";
794 } 796 }
795 } 797 }
796 text += todo->summary(); 798 text += todo->summary();
797 MonthViewItem *item ; 799 MonthViewItem *item ;
798 if ( mAvailItemList.count() ) { 800 if ( mAvailItemList.count() ) {
799 item = mAvailItemList.first(); 801 item = mAvailItemList.first();
800 mAvailItemList.remove( item ); 802 mAvailItemList.remove( item );
801 item->recycle( todo, mDate, text ); 803 item->recycle( todo, mDate, text );
802 } else { 804 } else {
803 item = new MonthViewItem( todo, mDate, text ); 805 item = new MonthViewItem( todo, mDate, text );
804 } 806 }
805 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 807 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
806 //item->setPalette( mStandardPalette ); 808 //item->setPalette( mStandardPalette );
807 QPalette pal; 809 QPalette pal;
808 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 810 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
809 QStringList categories = todo->categories(); 811 QStringList categories = todo->categories();
810 QString cat = categories.first(); 812 QString cat = categories.first();
811 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 813 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
812 pal = getPalette(); 814 pal = getPalette();
813 if (cat.isEmpty()) { 815 if (cat.isEmpty()) {
814 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 816 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
817 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
815 } else { 818 } else {
816 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 819 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
817 } 820 }
818 821
819 } else { 822 } else {
820 if (cat.isEmpty()) { 823 if (cat.isEmpty()) {
821 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 824 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
825 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
822 } else { 826 } else {
823 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 827 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
824 } 828 }
825 } 829 }
826 830
827 } else { 831 } else {
828 pal = mStandardPalette ; 832 pal = mStandardPalette ;
829 } 833 }
830 item->setPalette( pal ); 834 item->setPalette( pal );
831 item->setRecur( todo->recurrence()->doesRecur() ); 835 item->setRecur( todo->recurrence()->doesRecur() );
832 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 836 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
833 item->setMoreInfo( todo->description().length() > 0 ); 837 item->setMoreInfo( todo->description().length() > 0 );
834 insertItem( item , count()); 838 insertItem( item , count());
835#ifdef DESKTOP_VERSION 839#ifdef DESKTOP_VERSION
836 mToolTip.append( text ); 840 mToolTip.append( text );
837#endif 841#endif
838} 842}
839void MonthViewCell::repaintfinishUpdateCell() 843void MonthViewCell::repaintfinishUpdateCell()
840{ 844{
841 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 845 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
842 while ( mitem ) { 846 while ( mitem ) {
843 mitem->setBlockRepaint( false ); 847 mitem->setBlockRepaint( false );
844 updateItem ( mitem ); 848 updateItem ( mitem );
845 mitem = (MonthViewItem *)mitem->next(); 849 mitem = (MonthViewItem *)mitem->next();
846 } 850 }
847} 851}
848void MonthViewCell::finishUpdateCell() 852void MonthViewCell::finishUpdateCell()
849{ 853{
850 854
851 855
852 856
853#ifdef DESKTOP_VERSION 857#ifdef DESKTOP_VERSION
854 if (mToolTip.count() > 0 ) { 858 if (mToolTip.count() > 0 ) {
855 mToolTip.sort(); 859 mToolTip.sort();
856 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 860 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
857 } 861 }
858#endif 862#endif
859 //sort(); 863 //sort();
860 //setMyPalette(); 864 //setMyPalette();
861 setMyPalette(); 865 setMyPalette();
862 866
863 resizeEvent( 0 ); 867 resizeEvent( 0 );
864 868
865} 869}
866void MonthViewCell::updateCell() 870void MonthViewCell::updateCell()
867{ 871{
868 if ( !mMonthView->isUpdatePossible() ) 872 if ( !mMonthView->isUpdatePossible() )
869 return; 873 return;
870 startUpdateCell(); 874 startUpdateCell();
871 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 875 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
872 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 876 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
873 Event *event; 877 Event *event;
874 for( event = events.first(); event; event = events.next() ) { // for event 878 for( event = events.first(); event; event = events.next() ) { // for event
875 insertEvent(event); 879 insertEvent(event);
876 } 880 }
877 // insert due todos 881 // insert due todos
878 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 882 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
879 Todo *todo; 883 Todo *todo;
880 for(todo = todos.first(); todo; todo = todos.next()) { 884 for(todo = todos.first(); todo; todo = todos.next()) {
881 insertTodo( todo ); 885 insertTodo( todo );
882 } 886 }
883 finishUpdateCell(); 887 finishUpdateCell();
884 // if ( isVisible()) 888 // if ( isVisible())
885 //qApp->processEvents(); 889 //qApp->processEvents();
886} 890}
887 891
888void MonthViewCell::updateConfig( bool bigFont ) // = false 892void MonthViewCell::updateConfig( bool bigFont ) // = false
889{ 893{
890 894
891 if ( bigFont ) { 895 if ( bigFont ) {
892 QFont fo = KOPrefs::instance()->mMonthViewFont; 896 QFont fo = KOPrefs::instance()->mMonthViewFont;
893 int ps = fo.pointSize() + 2; 897 int ps = fo.pointSize() + 2;
894 if ( ps < 18 ) 898 if ( ps < 18 )
895 ps += 2; 899 ps += 2;
896 fo.setPointSize( ps ); 900 fo.setPointSize( ps );
897 setFont( fo ); 901 setFont( fo );
898 } else 902 } else
899 setFont( KOPrefs::instance()->mMonthViewFont ); 903 setFont( KOPrefs::instance()->mMonthViewFont );
900 904
901 QFontMetrics fm( font() ); 905 QFontMetrics fm( font() );
902 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 906 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
903 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 907 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
904 mHolidayPalette = mStandardPalette; 908 mHolidayPalette = mStandardPalette;
905 mPrimaryPalette = mStandardPalette; 909 mPrimaryPalette = mStandardPalette;
906 mNonPrimaryPalette = mStandardPalette; 910 mNonPrimaryPalette = mStandardPalette;
907 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 911 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
908 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 912 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
909 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 913 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
910 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 914 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
911 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 915 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
912 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 916 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
913 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 917 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
914 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 918 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
915 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 919 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
916 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 920 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
917 } 921 }
918 //updateCell(); 922 //updateCell();
919} 923}
920 924
921void MonthViewCell::enableScrollBars( bool enabled ) 925void MonthViewCell::enableScrollBars( bool enabled )
922{ 926{
923 927
924 return; 928 return;
925 if ( enabled ) { 929 if ( enabled ) {
926 QListBoxItem *fi = firstItem (); 930 QListBoxItem *fi = firstItem ();
927 if (fi ) { 931 if (fi ) {
928 int ihei = fi->height( this ); 932 int ihei = fi->height( this );
929 int hei = numRows () * ihei; 933 int hei = numRows () * ihei;
930 if ( hei < height() - horizontalScrollBar()->height () ) { 934 if ( hei < height() - horizontalScrollBar()->height () ) {
931 setVScrollBarMode(QScrollView::AlwaysOff); 935 setVScrollBarMode(QScrollView::AlwaysOff);
932 } 936 }
933 else 937 else
934 setVScrollBarMode(QScrollView::Auto); 938 setVScrollBarMode(QScrollView::Auto);
935 if ( ihei *3 > height() ) { 939 if ( ihei *3 > height() ) {
936 setHScrollBarMode(QScrollView::AlwaysOff); 940 setHScrollBarMode(QScrollView::AlwaysOff);
937 } 941 }
938 else { 942 else {
939 setHScrollBarMode(QScrollView::Auto); 943 setHScrollBarMode(QScrollView::Auto);
940 } 944 }
941 } else { 945 } else {
942 setVScrollBarMode(QScrollView::Auto); 946 setVScrollBarMode(QScrollView::Auto);
943 setHScrollBarMode(QScrollView::Auto); 947 setHScrollBarMode(QScrollView::Auto);
944 } 948 }
945 } else { 949 } else {
946 setVScrollBarMode(QScrollView::AlwaysOff); 950 setVScrollBarMode(QScrollView::AlwaysOff);
947 setHScrollBarMode(QScrollView::AlwaysOff); 951 setHScrollBarMode(QScrollView::AlwaysOff);
948 } 952 }
949} 953}
950 954
951Incidence *MonthViewCell::selectedIncidence() 955Incidence *MonthViewCell::selectedIncidence()
952{ 956{
953 int index = currentItem(); 957 int index = currentItem();
954 if ( index < 0 ) return 0; 958 if ( index < 0 ) return 0;
955 959
956 MonthViewItem *mitem = 960 MonthViewItem *mitem =
957 static_cast<MonthViewItem *>( item( index ) ); 961 static_cast<MonthViewItem *>( item( index ) );
958 962
959 if ( !mitem ) return 0; 963 if ( !mitem ) return 0;
960 964
961 return mitem->incidence(); 965 return mitem->incidence();
962} 966}
963 967
964QDate MonthViewCell::selectedIncidenceDate() 968QDate MonthViewCell::selectedIncidenceDate()
965{ 969{
966 QDate qd; 970 QDate qd;
967 int index = currentItem(); 971 int index = currentItem();
968 if ( index < 0 ) return qd; 972 if ( index < 0 ) return qd;
969 973
970 MonthViewItem *mitem = 974 MonthViewItem *mitem =
971 static_cast<MonthViewItem *>( item( index ) ); 975 static_cast<MonthViewItem *>( item( index ) );
972 976
973 if ( !mitem ) return qd; 977 if ( !mitem ) return qd;
974 978
975 return mitem->incidenceDate(); 979 return mitem->incidenceDate();
976} 980}
977 981
978void MonthViewCell::deselect() 982void MonthViewCell::deselect()
979{ 983{
980 clearSelection(); 984 clearSelection();
981 enableScrollBars( false ); 985 enableScrollBars( false );
982 // updateCell(); 986 // updateCell();
983} 987}
984void MonthViewCell::select() 988void MonthViewCell::select()
985{ 989{
986 ;// updateCell(); 990 ;// updateCell();
987} 991}
988 992
989void MonthViewCell::resizeEvent ( QResizeEvent * e ) 993void MonthViewCell::resizeEvent ( QResizeEvent * e )
990{ 994{
991 if ( !mMonthView->isUpdatePossible() ) 995 if ( !mMonthView->isUpdatePossible() )
992 return; 996 return;
993 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 997 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
994 deselect(); 998 deselect();
995 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 999 mLabel->setMaximumHeight( height() - lineWidth()*2 );
996 1000
997 QString text; 1001 QString text;
998 mLabel->setText( text ); 1002 mLabel->setText( text );
999 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1003 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1000 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1004 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1001 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1005 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1002 mLabel->resize( mLabelBigSize ); 1006 mLabel->resize( mLabelBigSize );
1003 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1007 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1004 } else { 1008 } else {
1005 mLabel->resize( mLabelSize ); 1009 mLabel->resize( mLabelSize );
1006 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1010 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1007 } 1011 }
1008 mLabel->setText( text ); 1012 mLabel->setText( text );
1009 1013
1010 int size = height() - mLabel->height() - lineWidth()-1; 1014 int size = height() - mLabel->height() - lineWidth()-1;
1011 //qDebug("LW %d ", lineWidth()); 1015 //qDebug("LW %d ", lineWidth());
1012 if ( size > 0 ) 1016 if ( size > 0 )
1013 verticalScrollBar()->setMaximumHeight( size ); 1017 verticalScrollBar()->setMaximumHeight( size );
1014 size = width() - mLabel->width() -lineWidth()-1; 1018 size = width() - mLabel->width() -lineWidth()-1;
1015 if ( size > 0 ) 1019 if ( size > 0 )
1016 horizontalScrollBar()->setMaximumWidth( size ); 1020 horizontalScrollBar()->setMaximumWidth( size );
1017 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1021 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1018 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1022 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1019 // mItemList->resize ( width(), height () ); 1023 // mItemList->resize ( width(), height () );
1020 if ( e ) 1024 if ( e )
1021 KNoScrollListBox::resizeEvent ( e ); 1025 KNoScrollListBox::resizeEvent ( e );
1022} 1026}
1023 1027
1024void MonthViewCell::defaultAction( QListBoxItem *item ) 1028void MonthViewCell::defaultAction( QListBoxItem *item )
1025{ 1029{
1026 1030
1027 if ( !item ) { 1031 if ( !item ) {
1028 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1032 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1029 emit newEventSignal( dt ); 1033 emit newEventSignal( dt );
1030 return; 1034 return;
1031 } 1035 }
1032 1036
1033 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1037 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1034 Incidence *incidence = eventItem->incidence(); 1038 Incidence *incidence = eventItem->incidence();
1035 if ( incidence ) mMonthView->defaultAction( incidence ); 1039 if ( incidence ) mMonthView->defaultAction( incidence );
1036} 1040}
1037void MonthViewCell::showDay() 1041void MonthViewCell::showDay()
1038{ 1042{
1039 emit showDaySignal( date() ); 1043 emit showDaySignal( date() );
1040} 1044}
1041void MonthViewCell::newEvent() 1045void MonthViewCell::newEvent()
1042{ 1046{
1043 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1047 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1044 emit newEventSignal( dt ); 1048 emit newEventSignal( dt );
1045} 1049}
1046void MonthViewCell::cellClicked( QListBoxItem *item ) 1050void MonthViewCell::cellClicked( QListBoxItem *item )
1047{ 1051{
1048 mMonthView->setSelectedCell( this ); 1052 mMonthView->setSelectedCell( this );
1049 if ( item == 0 ) { 1053 if ( item == 0 ) {
1050 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1054 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1051 emit newEventSignal( dt ); 1055 emit newEventSignal( dt );
1052 return; 1056 return;
1053 } 1057 }
1054 1058
1055} 1059}
1056 1060
1057void MonthViewCell::contextMenu( QListBoxItem *item ) 1061void MonthViewCell::contextMenu( QListBoxItem *item )
1058{ 1062{
1059 mMonthView->setPopupCell( this ); 1063 mMonthView->setPopupCell( this );
1060 if ( !item ) { 1064 if ( !item ) {
1061 mMonthView->showContextMenu( 0 ); 1065 mMonthView->showContextMenu( 0 );
1062 return; 1066 return;
1063 } 1067 }
1064 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1068 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1065 Incidence *incidence = eventItem->incidence(); 1069 Incidence *incidence = eventItem->incidence();
1066 if ( incidence ) mMonthView->showContextMenu( incidence ); 1070 if ( incidence ) mMonthView->showContextMenu( incidence );
1067} 1071}
1068 1072
1069void MonthViewCell::selection( QListBoxItem *item ) 1073void MonthViewCell::selection( QListBoxItem *item )
1070{ 1074{
1071 if ( !item ) return; 1075 if ( !item ) return;
1072 1076
1073 mMonthView->setSelectedCell( this ); 1077 mMonthView->setSelectedCell( this );
1074} 1078}
1075 1079
1076 1080
1077// ******************************************************************************* 1081// *******************************************************************************
1078// ******************************************************************************* 1082// *******************************************************************************
1079// ******************************************************************************* 1083// *******************************************************************************
1080 1084
1081 1085
1082KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1086KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1083 : KOEventView( calendar, parent, name ), 1087 : KOEventView( calendar, parent, name ),
1084 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1088 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1085 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1089 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1086{ 1090{
1087 mFlagKeyPressed = false; 1091 mFlagKeyPressed = false;
1088 mShortDayLabelsM = false; 1092 mShortDayLabelsM = false;
1089 mShortDayLabelsW = false; 1093 mShortDayLabelsW = false;
1090 skipResize = false; 1094 skipResize = false;
1091 clPending = true; 1095 clPending = true;
1092 mPopupCell = 0; 1096 mPopupCell = 0;
1093 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1097 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1094 mWidStack = new QWidgetStack( this ); 1098 mWidStack = new QWidgetStack( this );
1095 QVBoxLayout* hb = new QVBoxLayout( this ); 1099 QVBoxLayout* hb = new QVBoxLayout( this );
1096 mMonthView = new QWidget( mWidStack ); 1100 mMonthView = new QWidget( mWidStack );
1097 mWeekView = new QWidget( mWidStack ); 1101 mWeekView = new QWidget( mWidStack );
1098#if QT_VERSION >= 0x030000 1102#if QT_VERSION >= 0x030000
1099 mWidStack->addWidget(mMonthView ); 1103 mWidStack->addWidget(mMonthView );
1100 mWidStack->addWidget(mWeekView ); 1104 mWidStack->addWidget(mWeekView );
1101#else 1105#else
1102 mWidStack->addWidget( mMonthView, 1 ); 1106 mWidStack->addWidget( mMonthView, 1 );
1103 mWidStack->addWidget( mWeekView , 1 ); 1107 mWidStack->addWidget( mWeekView , 1 );
1104#endif 1108#endif
1105 hb->addWidget( mNavigatorBar ); 1109 hb->addWidget( mNavigatorBar );
1106 hb->addWidget( mWidStack ); 1110 hb->addWidget( mWidStack );
1107 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1111 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1108 updatePossible = false; 1112 updatePossible = false;
1109 //updatePossible = true; 1113 //updatePossible = true;
1110 mCells.setAutoDelete( true ); 1114 mCells.setAutoDelete( true );
1111 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1115 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1112 mDayLabels.resize( mDaysPerWeek ); 1116 mDayLabels.resize( mDaysPerWeek );
1113 mDayLabelsW.resize( mDaysPerWeek ); 1117 mDayLabelsW.resize( mDaysPerWeek );
1114 QFont bfont = font(); 1118 QFont bfont = font();
1115 if ( QApplication::desktop()->width() < 650 ) { 1119 if ( QApplication::desktop()->width() < 650 ) {
1116 bfont.setPointSize( bfont.pointSize() - 2 ); 1120 bfont.setPointSize( bfont.pointSize() - 2 );
1117 } 1121 }
1118 bfont.setBold( true ); 1122 bfont.setBold( true );
1119 int i; 1123 int i;
1120 1124
1121 for( i = 0; i < mDaysPerWeek; i++ ) { 1125 for( i = 0; i < mDaysPerWeek; i++ ) {
1122 QLabel *label = new QLabel( mMonthView ); 1126 QLabel *label = new QLabel( mMonthView );
1123 label->setFont(bfont); 1127 label->setFont(bfont);
1124 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1128 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1125 label->setLineWidth(1); 1129 label->setLineWidth(1);
1126 label->setAlignment(AlignCenter); 1130 label->setAlignment(AlignCenter);
1127 mDayLabels.insert( i, label ); 1131 mDayLabels.insert( i, label );
1128 label = new QLabel( mWeekView ); 1132 label = new QLabel( mWeekView );
1129 label->setFont(bfont); 1133 label->setFont(bfont);
1130 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1134 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1131 label->setLineWidth(1); 1135 label->setLineWidth(1);
1132 label->setAlignment(AlignCenter); 1136 label->setAlignment(AlignCenter);
1133 mDayLabelsW.insert( i, label ); 1137 mDayLabelsW.insert( i, label );
1134 } 1138 }
1135 1139
1136 bfont.setBold( false ); 1140 bfont.setBold( false );
1137 mWeekLabels.resize( mNumWeeks+1 ); 1141 mWeekLabels.resize( mNumWeeks+1 );
1138 mWeekLabelsW.resize( 2 ); 1142 mWeekLabelsW.resize( 2 );
1139 for( i = 0; i < mNumWeeks+1; i++ ) { 1143 for( i = 0; i < mNumWeeks+1; i++ ) {
1140 KOWeekButton *label = new KOWeekButton( mMonthView ); 1144 KOWeekButton *label = new KOWeekButton( mMonthView );
1141 label->setFocusPolicy(NoFocus); 1145 label->setFocusPolicy(NoFocus);
1142 label->setFont(bfont); 1146 label->setFont(bfont);
1143 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1147 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1144 label->setFlat(true); 1148 label->setFlat(true);
1145 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1149 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1146 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1150 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1147 //label->setLineWidth(1); 1151 //label->setLineWidth(1);
1148 //label->setAlignment(AlignCenter); 1152 //label->setAlignment(AlignCenter);
1149 mWeekLabels.insert( i, label ); 1153 mWeekLabels.insert( i, label );
1150 } 1154 }
1151 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1155 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1152 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1156 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1153 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1157 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1154 1158
1155 for( i = 0; i < 1+1; i++ ) { 1159 for( i = 0; i < 1+1; i++ ) {
1156 KOWeekButton *label = new KOWeekButton( mWeekView ); 1160 KOWeekButton *label = new KOWeekButton( mWeekView );
1157 label->setFocusPolicy(NoFocus); 1161 label->setFocusPolicy(NoFocus);
1158 label->setFont(bfont); 1162 label->setFont(bfont);
1159 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1163 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1160 label->setFlat(true); 1164 label->setFlat(true);
1161 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1165 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1162 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1166 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1163 //label->setLineWidth(1); 1167 //label->setLineWidth(1);
1164 //label->setAlignment(AlignCenter); 1168 //label->setAlignment(AlignCenter);
1165 mWeekLabelsW.insert( i, label ); 1169 mWeekLabelsW.insert( i, label );
1166 } 1170 }
1167 mWeekLabelsW[1]->setText( i18n("W")); 1171 mWeekLabelsW[1]->setText( i18n("W"));
1168 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1172 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1169 1173
1170 1174
1171 int row, col; 1175 int row, col;
1172 mCells.resize( mNumCells ); 1176 mCells.resize( mNumCells );
1173 for( row = 0; row < mNumWeeks; ++row ) { 1177 for( row = 0; row < mNumWeeks; ++row ) {
1174 for( col = 0; col < mDaysPerWeek; ++col ) { 1178 for( col = 0; col < mDaysPerWeek; ++col ) {
1175 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1179 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1176 mCells.insert( row * mDaysPerWeek + col, cell ); 1180 mCells.insert( row * mDaysPerWeek + col, cell );
1177 1181
1178 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1182 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1179 SLOT( defaultAction( Incidence * ) ) ); 1183 SLOT( defaultAction( Incidence * ) ) );
1180 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1184 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1181 SIGNAL( newEventSignal( QDateTime ) ) ); 1185 SIGNAL( newEventSignal( QDateTime ) ) );
1182 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1186 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1183 SIGNAL( showDaySignal( QDate ) ) ); 1187 SIGNAL( showDaySignal( QDate ) ) );
1184 connect( cell, SIGNAL( nextCell() ), 1188 connect( cell, SIGNAL( nextCell() ),
1185 SLOT( nextCell() ) ); 1189 SLOT( nextCell() ) );
1186 connect( cell, SIGNAL( prevCell() ), 1190 connect( cell, SIGNAL( prevCell() ),
1187 SLOT( prevCell() ) ); 1191 SLOT( prevCell() ) );
1188 } 1192 }
1189 } 1193 }
1190 mCellsW.resize( mDaysPerWeek ); 1194 mCellsW.resize( mDaysPerWeek );
1191 for( col = 0; col < mDaysPerWeek; ++col ) { 1195 for( col = 0; col < mDaysPerWeek; ++col ) {
1192 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1196 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1193 mCellsW.insert( col, cell ); 1197 mCellsW.insert( col, cell );
1194 1198
1195 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1199 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1196 SLOT( defaultAction( Incidence * ) ) ); 1200 SLOT( defaultAction( Incidence * ) ) );
1197 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1201 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1198 SIGNAL( newEventSignal( QDateTime ) ) ); 1202 SIGNAL( newEventSignal( QDateTime ) ) );
1199 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1203 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1200 SIGNAL( showDaySignal( QDate ) ) ); 1204 SIGNAL( showDaySignal( QDate ) ) );
1201 connect( cell, SIGNAL( nextCell() ), 1205 connect( cell, SIGNAL( nextCell() ),
1202 SLOT( nextCell() ) ); 1206 SLOT( nextCell() ) );
1203 connect( cell, SIGNAL( prevCell() ), 1207 connect( cell, SIGNAL( prevCell() ),
1204 SLOT( prevCell() ) ); 1208 SLOT( prevCell() ) );
1205 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1209 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1206 } 1210 }
1207 1211
1208 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1212 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1209 mContextMenu = eventPopup(); 1213 mContextMenu = eventPopup();
1210 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1214 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1211 i18n("New Event..."),this, 1215 i18n("New Event..."),this,
1212 SLOT(slotNewEvent()),false); 1216 SLOT(slotNewEvent()),false);
1213 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1217 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1214 i18n("New Todo..."),this, 1218 i18n("New Todo..."),this,
1215 SLOT(slotNewTodo()),false); 1219 SLOT(slotNewTodo()),false);
1216 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1220 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1217 i18n("Journal"),this, 1221 i18n("Journal"),this,
1218 SLOT(slotEditJournal()),false); 1222 SLOT(slotEditJournal()),false);
1219 1223
1220 1224
1221 1225
1222 QString pathString = ""; 1226 QString pathString = "";
1223 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1227 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1224 if ( QApplication::desktop()->width() < 480 ) 1228 if ( QApplication::desktop()->width() < 480 )
1225 pathString += "icons16/"; 1229 pathString += "icons16/";
1226 } else 1230 } else
1227 pathString += "iconsmini/"; 1231 pathString += "iconsmini/";
1228 mNewItemMenu = new QPopupMenu( this ); 1232 mNewItemMenu = new QPopupMenu( this );
1229 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1233 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1230 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1234 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1231 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1235 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1232 1236
1233 // updateConfig(); //useless here... 1237 // updateConfig(); //useless here...
1234 // ... but we need mWidthLongDayLabel computed 1238 // ... but we need mWidthLongDayLabel computed
1235 QFontMetrics fontmetric(mDayLabels[0]->font()); 1239 QFontMetrics fontmetric(mDayLabels[0]->font());
1236 mWidthLongDayLabel = 0; 1240 mWidthLongDayLabel = 0;
1237 for (int i = 0; i < 7; i++) { 1241 for (int i = 0; i < 7; i++) {
1238 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1242 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1239 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1243 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1240 } 1244 }
1241 1245
1242 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1246 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1243 1247
1244#if 0 1248#if 0
1245 if ( mShowWeekView ) 1249 if ( mShowWeekView )
1246 mWidStack->raiseWidget( mWeekView ); 1250 mWidStack->raiseWidget( mWeekView );
1247 else 1251 else
1248 mWidStack->raiseWidget( mMonthView ); 1252 mWidStack->raiseWidget( mMonthView );
1249#endif 1253#endif
1250 1254
1251 emit incidenceSelected( 0 ); 1255 emit incidenceSelected( 0 );
1252 1256
1253 mComputeLayoutTimer = new QTimer( this ); 1257 mComputeLayoutTimer = new QTimer( this );
1254 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1258 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1255 1259
1256 1260
1257#ifndef DESKTOP_VERSION 1261#ifndef DESKTOP_VERSION
1258 resize( QApplication::desktop()->size() ); 1262 resize( QApplication::desktop()->size() );
1259#else 1263#else
1260 resize(640, 480 ); 1264 resize(640, 480 );
1261 updatePossible = true; 1265 updatePossible = true;
1262#endif 1266#endif
1263 computeLayout(); 1267 computeLayout();
1264 1268
1265 if ( mShowWeekView ) 1269 if ( mShowWeekView )
1266 mWidStack->raiseWidget( mWeekView ); 1270 mWidStack->raiseWidget( mWeekView );
1267 else 1271 else
1268 mWidStack->raiseWidget( mMonthView ); 1272 mWidStack->raiseWidget( mMonthView );
1269} 1273}
1270 1274
1271KOMonthView::~KOMonthView() 1275KOMonthView::~KOMonthView()
1272{ 1276{
1273 delete mContextMenu; 1277 delete mContextMenu;
1274} 1278}
1275 1279
1276void KOMonthView::selectInternalWeekNum ( int n ) 1280void KOMonthView::selectInternalWeekNum ( int n )
1277{ 1281{
1278 switchView(); 1282 switchView();
1279 if ( !KOPrefs::instance()->mMonthViewWeek ) 1283 if ( !KOPrefs::instance()->mMonthViewWeek )
1280 emit selectMonth (); 1284 emit selectMonth ();
1281 else 1285 else
1282 emit selectWeekNum ( n ); 1286 emit selectWeekNum ( n );
1283} 1287}
1284 1288
1285int KOMonthView::currentWeek() 1289int KOMonthView::currentWeek()
1286{ 1290{
1287 if ( mShowWeekView ) 1291 if ( mShowWeekView )
1288 return mWeekLabelsW[0]->getWeekNum(); 1292 return mWeekLabelsW[0]->getWeekNum();
1289 return mWeekLabels[0]->getWeekNum(); 1293 return mWeekLabels[0]->getWeekNum();
1290} 1294}
1291void KOMonthView::switchView() 1295void KOMonthView::switchView()
1292{ 1296{
1293 if ( selectedCell( ) ) 1297 if ( selectedCell( ) )
1294 selectedCell()->deselect(); 1298 selectedCell()->deselect();
1295 mShowWeekView = !mShowWeekView; 1299 mShowWeekView = !mShowWeekView;
1296 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1300 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1297 if ( clPending ) { 1301 if ( clPending ) {
1298 computeLayout(); 1302 computeLayout();
1299 updateConfig(); 1303 updateConfig();
1300 } 1304 }
1301 if ( mShowWeekView ) 1305 if ( mShowWeekView )
1302 mWidStack->raiseWidget( mWeekView ); 1306 mWidStack->raiseWidget( mWeekView );
1303 else 1307 else
1304 mWidStack->raiseWidget( mMonthView ); 1308 mWidStack->raiseWidget( mMonthView );
1305 clPending = false; 1309 clPending = false;
1306} 1310}
1307 1311
1308int KOMonthView::maxDatesHint() 1312int KOMonthView::maxDatesHint()
1309{ 1313{
1310 return mNumCells; 1314 return mNumCells;
1311} 1315}
1312 1316
1313int KOMonthView::currentDateCount() 1317int KOMonthView::currentDateCount()
1314{ 1318{
1315 return mNumCells; 1319 return mNumCells;
1316} 1320}
1317 1321
1318QPtrList<Incidence> KOMonthView::selectedIncidences() 1322QPtrList<Incidence> KOMonthView::selectedIncidences()
1319{ 1323{
1320 QPtrList<Incidence> selected; 1324 QPtrList<Incidence> selected;
1321 1325
1322 if ( mSelectedCell ) { 1326 if ( mSelectedCell ) {
1323 Incidence *incidence = mSelectedCell->selectedIncidence(); 1327 Incidence *incidence = mSelectedCell->selectedIncidence();
1324 if ( incidence ) selected.append( incidence ); 1328 if ( incidence ) selected.append( incidence );
1325 } 1329 }
1326 1330
1327 return selected; 1331 return selected;
1328} 1332}
1329 1333
1330DateList KOMonthView::selectedDates() 1334DateList KOMonthView::selectedDates()
1331{ 1335{
1332 DateList selected; 1336 DateList selected;
1333 1337
1334 if ( mSelectedCell ) { 1338 if ( mSelectedCell ) {
1335 QDate qd = mSelectedCell->selectedIncidenceDate(); 1339 QDate qd = mSelectedCell->selectedIncidenceDate();
1336 if ( qd.isValid() ) selected.append( qd ); 1340 if ( qd.isValid() ) selected.append( qd );
1337 } 1341 }
1338 1342
1339 return selected; 1343 return selected;
1340} 1344}
1341 1345
1342void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1346void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1343 const QDate &td) 1347 const QDate &td)
1344{ 1348{
1345#ifndef KORG_NOPRINTER 1349#ifndef KORG_NOPRINTER
1346 calPrinter->preview(CalPrinter::Month, fd, td); 1350 calPrinter->preview(CalPrinter::Month, fd, td);
1347#endif 1351#endif
1348} 1352}
1349 1353
1350void KOMonthView::updateConfig() 1354void KOMonthView::updateConfig()
1351{ 1355{
1352 1356
1353 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1357 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1354 1358
1355 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1359 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1356 mWeekStartsMonday = true; 1360 mWeekStartsMonday = true;
1357 } 1361 }
1358 QFontMetrics fontmetric(mDayLabels[0]->font()); 1362 QFontMetrics fontmetric(mDayLabels[0]->font());
1359 mWidthLongDayLabel = 0; 1363 mWidthLongDayLabel = 0;
1360 1364
1361 for (int i = 0; i < 7; i++) { 1365 for (int i = 0; i < 7; i++) {
1362 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1366 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1363 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1367 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1364 } 1368 }
1365 bool temp = mShowSatSunComp ; 1369 bool temp = mShowSatSunComp ;
1366 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1370 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1367 if ( ! mShowWeekView ) { 1371 if ( ! mShowWeekView ) {
1368 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1372 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1369 computeLayout(); 1373 computeLayout();
1370 } 1374 }
1371 updateDayLabels(); 1375 updateDayLabels();
1372 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1376 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1373 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1377 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1374 //resizeEvent( 0 ); 1378 //resizeEvent( 0 );
1375 for (uint i = 0; i < mCells.count(); ++i) { 1379 for (uint i = 0; i < mCells.count(); ++i) {
1376 mCells[i]->updateConfig(); 1380 mCells[i]->updateConfig();
1377 } 1381 }
1378 1382
1379 for (uint i = 0; i < mCellsW.count(); ++i) { 1383 for (uint i = 0; i < mCellsW.count(); ++i) {
1380 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1384 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1381 } 1385 }
1382#ifdef DESKTOP_VERSION 1386#ifdef DESKTOP_VERSION
1383 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1387 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1384#endif 1388#endif
1385 updateView(); 1389 updateView();
1386} 1390}
1387 1391
1388void KOMonthView::updateDayLabels() 1392void KOMonthView::updateDayLabels()
1389{ 1393{
1390 1394
1391 QPtrVector<QLabel> *mDayLabelsT; 1395 QPtrVector<QLabel> *mDayLabelsT;
1392 1396
1393 mDayLabelsT = &mDayLabelsW; 1397 mDayLabelsT = &mDayLabelsW;
1394 for (int i = 0; i < 7; i++) { 1398 for (int i = 0; i < 7; i++) {
1395 { 1399 {
1396 bool show = mShortDayLabelsW; 1400 bool show = mShortDayLabelsW;
1397 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1401 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1398 show = true; 1402 show = true;
1399 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1403 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1400 } 1404 }
1401 } 1405 }
1402 mDayLabelsT = &mDayLabels; 1406 mDayLabelsT = &mDayLabels;
1403 for (int i = 0; i < 7; i++) { 1407 for (int i = 0; i < 7; i++) {
1404 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1408 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1405 bool show = mShortDayLabelsM; 1409 bool show = mShortDayLabelsM;
1406 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1410 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1407 show = true; 1411 show = true;
1408 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1412 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1409 } else { 1413 } else {
1410 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1414 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1411 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1415 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1412 1416
1413 } 1417 }
1414 } 1418 }
1415 1419
1416} 1420}
1417 1421
1418void KOMonthView::clearList() 1422void KOMonthView::clearList()
1419{ 1423{
1420 unsigned int i; 1424 unsigned int i;
1421 for( i = 0; i < mCells.size(); ++i ) { 1425 for( i = 0; i < mCells.size(); ++i ) {
1422 mCells[i]->clear(); 1426 mCells[i]->clear();
1423 } 1427 }
1424 for( i = 0; i < mCellsW.size(); ++i ) { 1428 for( i = 0; i < mCellsW.size(); ++i ) {
1425 mCellsW[i]->clear(); 1429 mCellsW[i]->clear();
1426 } 1430 }
1427} 1431}
1428void KOMonthView::showDates(const QDate &start, const QDate &) 1432void KOMonthView::showDates(const QDate &start, const QDate &)
1429{ 1433{
1430 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1434 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1431 1435
1432 QPtrVector<MonthViewCell> *cells; 1436 QPtrVector<MonthViewCell> *cells;
1433 QPtrVector<QLabel> *dayLabels; 1437 QPtrVector<QLabel> *dayLabels;
1434 QPtrVector<KOWeekButton> *weekLabels; 1438 QPtrVector<KOWeekButton> *weekLabels;
1435 int weekNum = 6; 1439 int weekNum = 6;
1436 mStartDate = start; 1440 mStartDate = start;
1437 if ( mShowWeekView ) { 1441 if ( mShowWeekView ) {
1438 weekNum = 1; 1442 weekNum = 1;
1439 cells = &mCellsW; 1443 cells = &mCellsW;
1440 dayLabels = &mDayLabelsW; 1444 dayLabels = &mDayLabelsW;
1441 weekLabels = &mWeekLabelsW; 1445 weekLabels = &mWeekLabelsW;
1442 if ( !KGlobal::locale()->weekStartsMonday() ) { 1446 if ( !KGlobal::locale()->weekStartsMonday() ) {
1443 mStartDate = mStartDate.addDays( 1 ); 1447 mStartDate = mStartDate.addDays( 1 );
1444 } 1448 }
1445 } else { 1449 } else {
1446 cells = &mCells; 1450 cells = &mCells;
1447 dayLabels = &mDayLabels; 1451 dayLabels = &mDayLabels;
1448 weekLabels = &mWeekLabels; 1452 weekLabels = &mWeekLabels;
1449 } 1453 }
1450 1454
1451 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1455 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1452 1456
1453 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1457 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1454 mWeekStartsMonday = true; 1458 mWeekStartsMonday = true;
1455 } 1459 }
1456 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1460 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1457 1461
1458 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1462 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1459 mStartDate = mStartDate.addDays( -1 ); 1463 mStartDate = mStartDate.addDays( -1 );
1460 } 1464 }
1461 bool primary = false; 1465 bool primary = false;
1462 uint i; 1466 uint i;
1463 for( i = 0; i < (*cells).size(); ++i ) { 1467 for( i = 0; i < (*cells).size(); ++i ) {
1464 QDate date = mStartDate.addDays( i ); 1468 QDate date = mStartDate.addDays( i );
1465 (*cells)[i]->setDate( date ); 1469 (*cells)[i]->setDate( date );
1466 1470
1467#ifndef KORG_NOPLUGINS 1471#ifndef KORG_NOPLUGINS
1468 // add holiday, if present 1472 // add holiday, if present
1469 QString hstring(KOCore::self()->holiday(date)); 1473 QString hstring(KOCore::self()->holiday(date));
1470 (*cells)[i]->setHoliday( hstring ); 1474 (*cells)[i]->setHoliday( hstring );
1471#endif 1475#endif
1472 1476
1473 } 1477 }
1474 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1478 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1475 for( i = 0; i < weekNum; ++i ) { 1479 for( i = 0; i < weekNum; ++i ) {
1476 int wno; 1480 int wno;
1477 // remember, according to ISO 8601, the first week of the year is the 1481 // remember, according to ISO 8601, the first week of the year is the
1478 // first week that contains a thursday. Thus we must subtract off 4, 1482 // first week that contains a thursday. Thus we must subtract off 4,
1479 // not just 1. 1483 // not just 1.
1480 int dayOfYear = date.dayOfYear(); 1484 int dayOfYear = date.dayOfYear();
1481 if (dayOfYear % 7 != 0) 1485 if (dayOfYear % 7 != 0)
1482 wno = dayOfYear / 7 + 1; 1486 wno = dayOfYear / 7 + 1;
1483 else 1487 else
1484 wno =dayOfYear / 7; 1488 wno =dayOfYear / 7;
1485 (*weekLabels)[i]->setWeekNum( wno ); 1489 (*weekLabels)[i]->setWeekNum( wno );
1486 date = date.addDays( 7 ); 1490 date = date.addDays( 7 );
1487 } 1491 }
1488 updateView(); 1492 updateView();
1489} 1493}
1490 1494
1491void KOMonthView::showEvents(QPtrList<Event>) 1495void KOMonthView::showEvents(QPtrList<Event>)
1492{ 1496{
1493 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1497 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1494} 1498}
1495 1499
1496void KOMonthView::changeEventDisplay(Event *, int) 1500void KOMonthView::changeEventDisplay(Event *, int)
1497{ 1501{
1498 // this should be re-written to be much more efficient, but this 1502 // this should be re-written to be much more efficient, but this
1499 // quick-and-dirty-hack gets the job done for right now. 1503 // quick-and-dirty-hack gets the job done for right now.
1500 //qDebug("KOMonthView::changeEventDisplay "); 1504 //qDebug("KOMonthView::changeEventDisplay ");
1501 updateView(); 1505 updateView();
1502} 1506}
1503 1507
1504void KOMonthView::updateView() 1508void KOMonthView::updateView()
1505{ 1509{
1506 1510
1507 if ( !updatePossible ) 1511 if ( !updatePossible )
1508 return; 1512 return;
1509 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1513 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1510 //QTime ti; 1514 //QTime ti;
1511 //ti.start(); 1515 //ti.start();
1512 clearSelection(); 1516 clearSelection();
1513 QPtrVector<MonthViewCell> *cells; 1517 QPtrVector<MonthViewCell> *cells;
1514 if ( mShowWeekView ) { 1518 if ( mShowWeekView ) {
1515 cells = &mCellsW; 1519 cells = &mCellsW;
1516 } else { 1520 } else {
1517 cells = &mCells; 1521 cells = &mCells;
1518 } 1522 }
1519#if 1 1523#if 1
1520 int i; 1524 int i;
1521 int timeSpan = (*cells).size()-1; 1525 int timeSpan = (*cells).size()-1;
1522 if ( KOPrefs::instance()->mMonthViewWeek ) 1526 if ( KOPrefs::instance()->mMonthViewWeek )
1523 timeSpan = 6; 1527 timeSpan = 6;
1524 for( i = 0; i < timeSpan + 1; ++i ) { 1528 for( i = 0; i < timeSpan + 1; ++i ) {
1525 (*cells)[i]->startUpdateCell(); 1529 (*cells)[i]->startUpdateCell();
1526 } 1530 }
1527 1531
1528 QPtrList<Event> events = calendar()->events(); 1532 QPtrList<Event> events = calendar()->events();
1529 Event *event; 1533 Event *event;
1530 QDateTime dt; 1534 QDateTime dt;
1531 bool ok; 1535 bool ok;
1532 QDate endDate = mStartDate.addDays( timeSpan ); 1536 QDate endDate = mStartDate.addDays( timeSpan );
1533 for( event = events.first(); event; event = events.next() ) { // for event 1537 for( event = events.first(); event; event = events.next() ) { // for event
1534 if ( event->doesRecur() ) { 1538 if ( event->doesRecur() ) {
1535 bool last; 1539 bool last;
1536 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1540 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1537 QDateTime incidenceEnd; 1541 QDateTime incidenceEnd;
1538 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1542 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1539 bool invalid = false; 1543 bool invalid = false;
1540 while( true ) { 1544 while( true ) {
1541 if ( incidenceStart.isValid() ) { 1545 if ( incidenceStart.isValid() ) {
1542 incidenceEnd = incidenceStart.addDays( eventlen ); 1546 incidenceEnd = incidenceStart.addDays( eventlen );
1543 int st = incidenceStart.date().daysTo( endDate ); 1547 int st = incidenceStart.date().daysTo( endDate );
1544 if ( st >= 0 ) { // start before timeend 1548 if ( st >= 0 ) { // start before timeend
1545 int end = mStartDate.daysTo( incidenceEnd.date() ); 1549 int end = mStartDate.daysTo( incidenceEnd.date() );
1546 if ( end >= 0 ) { // end after timestart --- got one! 1550 if ( end >= 0 ) { // end after timestart --- got one!
1547 //normalize 1551 //normalize
1548 st = timeSpan - st; 1552 st = timeSpan - st;
1549 if ( st < 0 ) st = 0; 1553 if ( st < 0 ) st = 0;
1550 if ( end > timeSpan ) end = timeSpan; 1554 if ( end > timeSpan ) end = timeSpan;
1551 int iii; 1555 int iii;
1552 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1556 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1553 for ( iii = st;iii<= end;++iii) 1557 for ( iii = st;iii<= end;++iii)
1554 (*cells)[iii]->insertEvent( event ); 1558 (*cells)[iii]->insertEvent( event );
1555 } 1559 }
1556 } 1560 }
1557 } else { 1561 } else {
1558 if ( invalid ) 1562 if ( invalid )
1559 break; 1563 break;
1560 invalid = true; 1564 invalid = true;
1561 //qDebug("invalid %s", event->summary().latin1()); 1565 //qDebug("invalid %s", event->summary().latin1());
1562 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1566 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1563 } 1567 }
1564 if ( last ) 1568 if ( last )
1565 break; 1569 break;
1566 bool ok; 1570 bool ok;
1567 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1571 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1568 if ( ! ok ) 1572 if ( ! ok )
1569 break; 1573 break;
1570 if ( incidenceStart.date() > endDate ) 1574 if ( incidenceStart.date() > endDate )
1571 break; 1575 break;
1572 } 1576 }
1573 } else { // no recur 1577 } else { // no recur
1574 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1578 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1575 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1579 if ( event->uid().left(15) == QString("last-syncEvent-") )
1576 continue; 1580 continue;
1577 int st = event->dtStart().date().daysTo( endDate ); 1581 int st = event->dtStart().date().daysTo( endDate );
1578 if ( st >= 0 ) { // start before timeend 1582 if ( st >= 0 ) { // start before timeend
1579 int end = mStartDate.daysTo( event->dtEnd().date() ); 1583 int end = mStartDate.daysTo( event->dtEnd().date() );
1580 if ( end >= 0 ) { // end after timestart --- got one! 1584 if ( end >= 0 ) { // end after timestart --- got one!
1581 //normalize 1585 //normalize
1582 st = timeSpan - st; 1586 st = timeSpan - st;
1583 if ( st < 0 ) st = 0; 1587 if ( st < 0 ) st = 0;
1584 if ( end > timeSpan ) end = timeSpan; 1588 if ( end > timeSpan ) end = timeSpan;
1585 int iii; 1589 int iii;
1586 for ( iii = st;iii<= end;++iii) 1590 for ( iii = st;iii<= end;++iii)
1587 (*cells)[iii]->insertEvent( event ); 1591 (*cells)[iii]->insertEvent( event );
1588 } 1592 }
1589 } 1593 }
1590 } 1594 }
1591 } 1595 }
1592 // insert due todos 1596 // insert due todos
1593 QPtrList<Todo> todos = calendar()->todos( ); 1597 QPtrList<Todo> todos = calendar()->todos( );
1594 Todo *todo; 1598 Todo *todo;
1595 for(todo = todos.first(); todo; todo = todos.next()) { 1599 for(todo = todos.first(); todo; todo = todos.next()) {
1596 //insertTodo( todo ); 1600 //insertTodo( todo );
1597 if ( todo->hasDueDate() ) { 1601 if ( todo->hasDueDate() ) {
1598 int day = mStartDate.daysTo( todo->dtDue().date() ); 1602 int day = mStartDate.daysTo( todo->dtDue().date() );
1599 if ( day >= 0 && day < timeSpan + 1) { 1603 if ( day >= 0 && day < timeSpan + 1) {
1600 (*cells)[day]->insertTodo( todo ); 1604 (*cells)[day]->insertTodo( todo );
1601 } 1605 }
1602 } 1606 }
1603 } 1607 }
1604 1608
1605 for( i = 0; i < timeSpan+1; ++i ) { 1609 for( i = 0; i < timeSpan+1; ++i ) {
1606 (*cells)[i]->finishUpdateCell(); 1610 (*cells)[i]->finishUpdateCell();
1607 } 1611 }
1608 processSelectionChange(); 1612 processSelectionChange();
1609 //qApp->processEvents(); 1613 //qApp->processEvents();
1610 for( i = 0; i < timeSpan+1; ++i ) { 1614 for( i = 0; i < timeSpan+1; ++i ) {
1611 (*cells)[i]->repaintfinishUpdateCell(); 1615 (*cells)[i]->repaintfinishUpdateCell();
1612 } 1616 }
1613 setKeyBFocus(); 1617 setKeyBFocus();
1614#else 1618#else
1615 // old code 1619 // old code
1616 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1620 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1617 int i; 1621 int i;
1618 for( i = 0; i < (*cells).count(); ++i ) { 1622 for( i = 0; i < (*cells).count(); ++i ) {
1619 (*cells)[i]->updateCell(); 1623 (*cells)[i]->updateCell();
1620 } 1624 }
1621 1625
1622 //qDebug("KOMonthView::updateView() "); 1626 //qDebug("KOMonthView::updateView() ");
1623 processSelectionChange(); 1627 processSelectionChange();
1624 // qDebug("---------------------------------------------------------------------+ "); 1628 // qDebug("---------------------------------------------------------------------+ ");
1625 (*cells)[0]->setFocus(); 1629 (*cells)[0]->setFocus();
1626#endif 1630#endif
1627 1631
1628 //qDebug("update time %d ", ti.elapsed()); 1632 //qDebug("update time %d ", ti.elapsed());
1629} 1633}
1630 1634
1631void KOMonthView::setKeyBoardFocus() 1635void KOMonthView::setKeyBoardFocus()
1632{ 1636{
1633 //qDebug("KOMonthView::setKeyBoardFocus() "); 1637 //qDebug("KOMonthView::setKeyBoardFocus() ");
1634 bool shootAgain = false; 1638 bool shootAgain = false;
1635 if ( mShowWeekView ) { 1639 if ( mShowWeekView ) {
1636 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1640 shootAgain = !mWeekLabelsW[1]->hasFocus();
1637 mWeekLabelsW[1]->setFocus(); 1641 mWeekLabelsW[1]->setFocus();
1638 } 1642 }
1639 else { 1643 else {
1640 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1644 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1641 mWeekLabels[mNumWeeks]->setFocus(); 1645 mWeekLabels[mNumWeeks]->setFocus();
1642 } 1646 }
1643 if ( shootAgain ) { 1647 if ( shootAgain ) {
1644 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1648 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1645 } 1649 }
1646} 1650}
1647void KOMonthView::setKeyBFocus() 1651void KOMonthView::setKeyBFocus()
1648{ 1652{
1649 //qDebug("KOMonthView::setKeyBFocus() "); 1653 //qDebug("KOMonthView::setKeyBFocus() ");
1650 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1654 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1651} 1655}
1652void KOMonthView::resizeEvent(QResizeEvent * e) 1656void KOMonthView::resizeEvent(QResizeEvent * e)
1653{ 1657{
1654 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1658 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1655 if ( isVisible() ) { 1659 if ( isVisible() ) {
1656 //qDebug("KOMonthView::isVisible "); 1660 //qDebug("KOMonthView::isVisible ");
1657 slotComputeLayout(); 1661 slotComputeLayout();
1658 } else 1662 } else
1659 mComputeLayoutTimer->start( 100 ); 1663 mComputeLayoutTimer->start( 100 );
1660} 1664}
1661 1665
1662void KOMonthView::slotComputeLayout() 1666void KOMonthView::slotComputeLayout()
1663{ 1667{
1664 mComputeLayoutTimer->stop(); 1668 mComputeLayoutTimer->stop();
1665 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1669 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1666 computeLayout(); 1670 computeLayout();
1667 clPending = true; 1671 clPending = true;
1668 setKeyBFocus(); 1672 setKeyBFocus();
1669} 1673}
1670void KOMonthView::computeLayoutWeek() 1674void KOMonthView::computeLayoutWeek()
1671{ 1675{
1672 static int lastWid = 0; 1676 static int lastWid = 0;
1673 static int lastHei = 0; 1677 static int lastHei = 0;
1674 int daysToShow; 1678 int daysToShow;
1675 bool combinedSatSun = false; 1679 bool combinedSatSun = false;
1676 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1680 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1677 daysToShow = 6; 1681 daysToShow = 6;
1678 combinedSatSun = true; 1682 combinedSatSun = true;
1679 } 1683 }
1680 int tWid = topLevelWidget()->size().width(); 1684 int tWid = topLevelWidget()->size().width();
1681 int tHei = topLevelWidget()->size().height(); 1685 int tHei = topLevelWidget()->size().height();
1682 1686
1683 int wid = width();//e 1687 int wid = width();//e
1684 int hei = height()-1-mNavigatorBar->height(); 1688 int hei = height()-1-mNavigatorBar->height();
1685 1689
1686 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1690 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1687 return; 1691 return;
1688 1692
1689 if ( lastWid == width() && lastHei == height() ) { 1693 if ( lastWid == width() && lastHei == height() ) {
1690 //qDebug("KOListWeekView::No compute layout needed "); 1694 //qDebug("KOListWeekView::No compute layout needed ");
1691 return; 1695 return;
1692 } 1696 }
1693 lastWid = width(); 1697 lastWid = width();
1694 lastHei = height(); 1698 lastHei = height();
1695 1699
1696 1700
1697 if ( wid < hei ) 1701 if ( wid < hei )
1698 daysToShow = 2; 1702 daysToShow = 2;
1699 else 1703 else
1700 daysToShow = 3; 1704 daysToShow = 3;
1701 mShowSatSunComp = true; 1705 mShowSatSunComp = true;
1702 combinedSatSun = true; 1706 combinedSatSun = true;
1703 1707
1704 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1708 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1705 QFontMetrics fm ( mWeekLabels[0]->font() ); 1709 QFontMetrics fm ( mWeekLabels[0]->font() );
1706 int weeklabelwid = fm.width( "888" ); 1710 int weeklabelwid = fm.width( "888" );
1707 wid -= weeklabelwid; 1711 wid -= weeklabelwid;
1708 1712
1709 int colWid = wid / daysToShow; 1713 int colWid = wid / daysToShow;
1710 int lastCol = wid - ( colWid*6 ); 1714 int lastCol = wid - ( colWid*6 );
1711 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1715 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1712 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1716 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1713 int colModulo = wid % daysToShow; 1717 int colModulo = wid % daysToShow;
1714 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1718 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1715 //qDebug("rowmod %d ", rowModulo); 1719 //qDebug("rowmod %d ", rowModulo);
1716 int i; 1720 int i;
1717 int x,y,w,h; 1721 int x,y,w,h;
1718 x= 0; 1722 x= 0;
1719 y= 0; 1723 y= 0;
1720 w = colWid; 1724 w = colWid;
1721 h = dayLabelHei ; 1725 h = dayLabelHei ;
1722 for ( i = 0; i < 7; i++) { 1726 for ( i = 0; i < 7; i++) {
1723 if ( i && !( i % daysToShow) && i < 6) { 1727 if ( i && !( i % daysToShow) && i < 6) {
1724 y += hei/(5-daysToShow); 1728 y += hei/(5-daysToShow);
1725 x = 0; 1729 x = 0;
1726 w = colWid; 1730 w = colWid;
1727 } 1731 }
1728 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1732 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1729 ++w; 1733 ++w;
1730 } 1734 }
1731 if ( i >= 5 ) { 1735 if ( i >= 5 ) {
1732 int wi = width() - x - weeklabelwid; 1736 int wi = width() - x - weeklabelwid;
1733 if ( i == 5 ) { 1737 if ( i == 5 ) {
1734 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1738 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1735 } else { 1739 } else {
1736 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1740 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1737 } 1741 }
1738 x = x - w + wi - (wi/2 ); 1742 x = x - w + wi - (wi/2 );
1739 } 1743 }
1740 else { 1744 else {
1741 int wi = w; 1745 int wi = w;
1742 if ( !(( i+1) % daysToShow)) { 1746 if ( !(( i+1) % daysToShow)) {
1743 wi = width() - x - weeklabelwid; 1747 wi = width() - x - weeklabelwid;
1744 } 1748 }
1745 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1749 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1746 } 1750 }
1747 x += w; 1751 x += w;
1748 } 1752 }
1749 x= 0; 1753 x= 0;
1750 y= dayLabelHei; 1754 y= dayLabelHei;
1751 w = colWid; 1755 w = colWid;
1752 h = cellHei; 1756 h = cellHei;
1753 int max = 0; 1757 int max = 0;
1754 for ( i = 0; i < mCellsW.count(); ++i) { 1758 for ( i = 0; i < mCellsW.count(); ++i) {
1755 if ( i > 6 ) { 1759 if ( i > 6 ) {
1756 mCellsW[i]->hide(); 1760 mCellsW[i]->hide();
1757 continue; 1761 continue;
1758 } 1762 }
1759 1763
1760 w = colWid; 1764 w = colWid;
1761 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1765 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1762 ++w; 1766 ++w;
1763 } 1767 }
1764 if ( i == (daysToShow-1-rowModulo)*7) 1768 if ( i == (daysToShow-1-rowModulo)*7)
1765 ++h; 1769 ++h;
1766 1770
1767 if ( i >= 5 ) { 1771 if ( i >= 5 ) {
1768 if ( i ==5 ) { 1772 if ( i ==5 ) {
1769 max = h/2; 1773 max = h/2;
1770 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1774 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1771 x -= w ;y += h/2; 1775 x -= w ;y += h/2;
1772 } else { 1776 } else {
1773 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1777 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1774 ++w; 1778 ++w;
1775 } 1779 }
1776 max = h-h/2; 1780 max = h-h/2;
1777 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1781 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1778 y -= h/2; 1782 y -= h/2;
1779 } 1783 }
1780 } else { 1784 } else {
1781 max = h; 1785 max = h;
1782 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1786 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1783 } 1787 }
1784 1788
1785 1789
1786 x += w; 1790 x += w;
1787 if ( x + w/2 > wid ) { 1791 if ( x + w/2 > wid ) {
1788 x = 0; 1792 x = 0;
1789 y += h+dayLabelHei ; 1793 y += h+dayLabelHei ;
1790 } 1794 }
1791 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1795 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1792 } 1796 }
1793 y= dayLabelHei; 1797 y= dayLabelHei;
1794 h = cellHei ; 1798 h = cellHei ;
1795 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1799 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1796 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1800 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1797 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1801 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1798 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1802 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1799 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1803 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1800 updateDayLabels(); 1804 updateDayLabels();
1801 //bool forceUpdate = !updatePossible; 1805 //bool forceUpdate = !updatePossible;
1802 updatePossible = true; 1806 updatePossible = true;
1803 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1807 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1804 //if ( forceUpdate ) 1808 //if ( forceUpdate )
1805 // updateView(); 1809 // updateView();
1806} 1810}
1807void KOMonthView::computeLayout() 1811void KOMonthView::computeLayout()
1808{ 1812{
1809 1813
1810 1814
1811 static int lastWid = 0; 1815 static int lastWid = 0;
1812 static int lastHei = 0; 1816 static int lastHei = 0;
1813 1817
1814 if ( mShowWeekView ){ 1818 if ( mShowWeekView ){
1815 computeLayoutWeek(); 1819 computeLayoutWeek();
1816 return; 1820 return;
1817 } 1821 }
1818 int daysToShow = 7; 1822 int daysToShow = 7;
1819 bool combinedSatSun = false; 1823 bool combinedSatSun = false;
1820 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1824 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1821 daysToShow = 6; 1825 daysToShow = 6;
1822 combinedSatSun = true; 1826 combinedSatSun = true;
1823 } 1827 }
1824 int tWid = topLevelWidget()->size().width(); 1828 int tWid = topLevelWidget()->size().width();
1825 int tHei = topLevelWidget()->size().height(); 1829 int tHei = topLevelWidget()->size().height();
1826 1830
1827 int wid = width();//e 1831 int wid = width();//e
1828 int hei = height()-1-mNavigatorBar->height(); 1832 int hei = height()-1-mNavigatorBar->height();
1829 1833
1830 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1834 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1831 return; 1835 return;
1832 } 1836 }
1833 if ( lastWid == width() && lastHei == height() ){ 1837 if ( lastWid == width() && lastHei == height() ){
1834 //qDebug("KOMonthview::No compute layout needed "); 1838 //qDebug("KOMonthview::No compute layout needed ");
1835 return; 1839 return;
1836 } 1840 }
1837 1841
1838 lastWid = width(); 1842 lastWid = width();
1839 lastHei = height(); 1843 lastHei = height();
1840 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1844 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1841 QFontMetrics fm ( mWeekLabels[0]->font() ); 1845 QFontMetrics fm ( mWeekLabels[0]->font() );
1842 int weeklabelwid = fm.width( "888" ); 1846 int weeklabelwid = fm.width( "888" );
1843 wid -= weeklabelwid; 1847 wid -= weeklabelwid;
1844 1848
1845 int colWid = wid / daysToShow; 1849 int colWid = wid / daysToShow;
1846 int lastCol = wid - ( colWid*6 ); 1850 int lastCol = wid - ( colWid*6 );
1847 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1851 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1848 int cellHei = (hei - dayLabelHei) /6; 1852 int cellHei = (hei - dayLabelHei) /6;
1849 int colModulo = wid % daysToShow; 1853 int colModulo = wid % daysToShow;
1850 int rowModulo = (hei- dayLabelHei) % 6; 1854 int rowModulo = (hei- dayLabelHei) % 6;
1851 //qDebug("rowmod %d ", rowModulo); 1855 //qDebug("rowmod %d ", rowModulo);
1852 int i; 1856 int i;
1853 int x,y,w,h; 1857 int x,y,w,h;
1854 x= 0; 1858 x= 0;
1855 y= 0; 1859 y= 0;
1856 w = colWid; 1860 w = colWid;
1857 h = dayLabelHei ; 1861 h = dayLabelHei ;
1858 for ( i = 0; i < 7; i++) { 1862 for ( i = 0; i < 7; i++) {
1859 if ( i == daysToShow-colModulo ) 1863 if ( i == daysToShow-colModulo )
1860 ++w; 1864 ++w;
1861 if ( combinedSatSun ) { 1865 if ( combinedSatSun ) {
1862 if ( i >= daysToShow-1 ) { 1866 if ( i >= daysToShow-1 ) {
1863 1867
1864 if ( i == 6 ) 1868 if ( i == 6 )
1865 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 1869 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
1866 else 1870 else
1867 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1871 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1868 x -= w/2 ; 1872 x -= w/2 ;
1869 } 1873 }
1870 else 1874 else
1871 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1875 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1872 } else 1876 } else
1873 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1877 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1874 x += w; 1878 x += w;
1875 } 1879 }
1876 x= 0; 1880 x= 0;
1877 y= dayLabelHei; 1881 y= dayLabelHei;
1878 w = colWid; 1882 w = colWid;
1879 h = cellHei ; 1883 h = cellHei ;
1880 int max = 0; 1884 int max = 0;
1881 for ( i = 0; i < mCells.count(); ++i) { 1885 for ( i = 0; i < mCells.count(); ++i) {
1882 //qDebug("iii %d ", i); 1886 //qDebug("iii %d ", i);
1883 w = colWid; 1887 w = colWid;
1884 if ( ((i) % 7) >= 7-colModulo ) { 1888 if ( ((i) % 7) >= 7-colModulo ) {
1885 ++w; 1889 ++w;
1886 } 1890 }
1887 if ( i == (6-rowModulo)*7) 1891 if ( i == (6-rowModulo)*7)
1888 ++h; 1892 ++h;
1889 if ( combinedSatSun ) { 1893 if ( combinedSatSun ) {
1890 if ( (i)%7 >= daysToShow-1 ) { 1894 if ( (i)%7 >= daysToShow-1 ) {
1891 if ( (i)%7 == daysToShow-1 ) { 1895 if ( (i)%7 == daysToShow-1 ) {
1892 w = width()-x-weeklabelwid; 1896 w = width()-x-weeklabelwid;
1893 max = h/2; 1897 max = h/2;
1894 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1898 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1895 x -= w ;y += h/2; 1899 x -= w ;y += h/2;
1896 } else { 1900 } else {
1897 w = width()-x-weeklabelwid; 1901 w = width()-x-weeklabelwid;
1898 max = h-h/2; 1902 max = h-h/2;
1899 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1903 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1900 y -= h/2; 1904 y -= h/2;
1901 } 1905 }
1902 } else { 1906 } else {
1903 max = h; 1907 max = h;
1904 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1908 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1905 } 1909 }
1906 1910
1907 } 1911 }
1908 else { 1912 else {
1909 max = h; 1913 max = h;
1910 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1914 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1911 } 1915 }
1912 x += w; 1916 x += w;
1913 if ( x + w/2 > wid ) { 1917 if ( x + w/2 > wid ) {
1914 x = 0; 1918 x = 0;
1915 y += h; 1919 y += h;
1916 } 1920 }
1917 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1921 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1918 } 1922 }
1919 y= dayLabelHei; 1923 y= dayLabelHei;
1920 h = cellHei ; 1924 h = cellHei ;
1921 for ( i = 0; i < 6; i++) { 1925 for ( i = 0; i < 6; i++) {
1922 if ( i == (6-rowModulo)) 1926 if ( i == (6-rowModulo))
1923 ++h; 1927 ++h;
1924 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1928 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1925 y += h; 1929 y += h;
1926 } 1930 }
1927 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1931 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1928 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1932 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1929 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1933 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1930 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1934 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1931 updateDayLabels(); 1935 updateDayLabels();
1932 //bool forceUpdate = !updatePossible; 1936 //bool forceUpdate = !updatePossible;
1933 updatePossible = true; 1937 updatePossible = true;
1934 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1938 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1935} 1939}
1936 1940
1937void KOMonthView::showContextMenu( Incidence *incidence ) 1941void KOMonthView::showContextMenu( Incidence *incidence )
1938{ 1942{
1939 if( incidence ) 1943 if( incidence )
1940 mContextMenu->showIncidencePopup(incidence); 1944 mContextMenu->showIncidencePopup(incidence);
1941 else { 1945 else {
1942 //qDebug("KOMonthView::showContextMenu "); 1946 //qDebug("KOMonthView::showContextMenu ");
1943 mNewItemMenu->popup(QCursor::pos()); 1947 mNewItemMenu->popup(QCursor::pos());
1944 } 1948 }
1945 /* 1949 /*
1946 if( incidence && incidence->typeID() == eventID ) { 1950 if( incidence && incidence->typeID() == eventID ) {
1947 Event *event = static_cast<Event *>(incidence); 1951 Event *event = static_cast<Event *>(incidence);
1948 mContextMenu->showEventPopup(event); 1952 mContextMenu->showEventPopup(event);
1949 } else { 1953 } else {
1950 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1954 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1951 } 1955 }
1952 */ 1956 */
1953} 1957}
1954MonthViewCell * KOMonthView::selectedCell( ) 1958MonthViewCell * KOMonthView::selectedCell( )
1955{ 1959{
1956 return mSelectedCell; 1960 return mSelectedCell;
1957} 1961}
1958void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1962void KOMonthView::setSelectedCell( MonthViewCell *cell )
1959{ 1963{
1960 //qDebug("KOMonthView::setSelectedCell %d", cell); 1964 //qDebug("KOMonthView::setSelectedCell %d", cell);
1961 if ( mSelectedCell && mSelectedCell != cell ) { 1965 if ( mSelectedCell && mSelectedCell != cell ) {
1962 MonthViewCell * mvc = mSelectedCell; 1966 MonthViewCell * mvc = mSelectedCell;
1963 mSelectedCell = cell; 1967 mSelectedCell = cell;
1964 mvc->deselect(); 1968 mvc->deselect();
1965 } else 1969 } else
1966 mSelectedCell = cell; 1970 mSelectedCell = cell;
1967 // if ( mSelectedCell ) 1971 // if ( mSelectedCell )
1968 // mSelectedCell->select(); 1972 // mSelectedCell->select();
1969 if ( !mSelectedCell ) 1973 if ( !mSelectedCell )
1970 emit incidenceSelected( 0 ); 1974 emit incidenceSelected( 0 );
1971 else 1975 else
1972 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1976 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1973} 1977}
1974 1978
1975void KOMonthView::processSelectionChange() 1979void KOMonthView::processSelectionChange()
1976{ 1980{
1977 QPtrList<Incidence> incidences = selectedIncidences(); 1981 QPtrList<Incidence> incidences = selectedIncidences();
1978 if (incidences.count() > 0) { 1982 if (incidences.count() > 0) {
1979 emit incidenceSelected( incidences.first() ); 1983 emit incidenceSelected( incidences.first() );
1980 } else { 1984 } else {
1981 emit incidenceSelected( 0 ); 1985 emit incidenceSelected( 0 );
1982 clearSelection(); 1986 clearSelection();
1983 } 1987 }
1984} 1988}
1985 1989
1986void KOMonthView::clearSelection() 1990void KOMonthView::clearSelection()
1987{ 1991{
1988 if ( mSelectedCell ) { 1992 if ( mSelectedCell ) {
1989 mSelectedCell->deselect(); 1993 mSelectedCell->deselect();
1990 mSelectedCell = 0; 1994 mSelectedCell = 0;
1991 } 1995 }
1992} 1996}
1993 1997
1994void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 1998void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1995{ 1999{
1996 if ( !e->isAutoRepeat() ) { 2000 if ( !e->isAutoRepeat() ) {
1997 mFlagKeyPressed = false; 2001 mFlagKeyPressed = false;
1998 } 2002 }
1999} 2003}
2000 2004
2001void KOMonthView::keyPressEvent ( QKeyEvent * e ) 2005void KOMonthView::keyPressEvent ( QKeyEvent * e )
2002{ 2006{
2003 2007
2004 qApp->processEvents(); 2008 qApp->processEvents();
2005 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2009 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2006 //e->ignore(); 2010 //e->ignore();
2007 e->accept(); 2011 e->accept();
2008 return; 2012 return;
2009 } 2013 }
2010 if (! e->isAutoRepeat() ) 2014 if (! e->isAutoRepeat() )
2011 mFlagKeyPressed = true; 2015 mFlagKeyPressed = true;
2012 switch(e->key()) { 2016 switch(e->key()) {
2013 case Key_Up: 2017 case Key_Up:
2014 { 2018 {
2015 if ( mShowWeekView ) { 2019 if ( mShowWeekView ) {
2016 emit selectWeekNum ( currentWeek() - 1 ); 2020 emit selectWeekNum ( currentWeek() - 1 );
2017 } 2021 }
2018 else { 2022 else {
2019 emit prevMonth(); 2023 emit prevMonth();
2020 } 2024 }
2021 } 2025 }
2022 e->accept(); 2026 e->accept();
2023 break; 2027 break;
2024 case Key_Down: 2028 case Key_Down:
2025 { 2029 {
2026 if ( mShowWeekView ) { 2030 if ( mShowWeekView ) {
2027 emit selectWeekNum ( currentWeek() +1); 2031 emit selectWeekNum ( currentWeek() +1);
2028 } 2032 }
2029 else { 2033 else {
2030 emit nextMonth(); 2034 emit nextMonth();
2031 } 2035 }
2032 2036
2033 } 2037 }
2034 e->accept(); 2038 e->accept();
2035 break; 2039 break;
2036 case Key_Return: 2040 case Key_Return:
2037 case Key_Enter: 2041 case Key_Enter:
2038 { 2042 {
2039 selectInternalWeekNum ( currentWeek() ); 2043 selectInternalWeekNum ( currentWeek() );
2040 } 2044 }
2041 e->accept(); 2045 e->accept();
2042 break; 2046 break;
2043 case Key_D: 2047 case Key_D:
2044 if ( mSelectedCell ) { 2048 if ( mSelectedCell ) {
2045 mSelectedCell->showDay(); 2049 mSelectedCell->showDay();
2046 e->accept(); 2050 e->accept();
2047 } else { 2051 } else {
2048 e->ignore(); 2052 e->ignore();
2049 } 2053 }
2050 break; 2054 break;
2051 default: 2055 default:
2052 e->ignore(); 2056 e->ignore();
2053 break; 2057 break;
2054 } 2058 }
2055} 2059}
2056 2060
2057void KOMonthView::nextCell() 2061void KOMonthView::nextCell()
2058{ 2062{
2059 bool res = focusNextPrevChild ( true ); 2063 bool res = focusNextPrevChild ( true );
2060} 2064}
2061void KOMonthView::prevCell() 2065void KOMonthView::prevCell()
2062{ 2066{
2063 focusNextPrevChild ( false ); 2067 focusNextPrevChild ( false );
2064} 2068}
2065 2069
2066void KOMonthView::slotNewTodo() 2070void KOMonthView::slotNewTodo()
2067{ 2071{
2068 //qDebug("KOMonthView::slotNewTodo() "); 2072 //qDebug("KOMonthView::slotNewTodo() ");
2069 if ( mPopupCell ){ 2073 if ( mPopupCell ){
2070 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2074 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2071 emit newTodoSignal(dt,true); 2075 emit newTodoSignal(dt,true);
2072 } 2076 }
2073 mPopupCell = 0; 2077 mPopupCell = 0;
2074} 2078}
2075void KOMonthView::slotNewEvent() 2079void KOMonthView::slotNewEvent()
2076{ 2080{
2077 if ( mPopupCell ) { 2081 if ( mPopupCell ) {
2078 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2082 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2079 emit newEventSignal( dt ); 2083 emit newEventSignal( dt );
2080 } 2084 }
2081 //qDebug("KOMonthView::slotNewEvent() "); 2085 //qDebug("KOMonthView::slotNewEvent() ");
2082 mPopupCell = 0; 2086 mPopupCell = 0;
2083} 2087}
2084 2088
2085void KOMonthView::slotEditJournal() 2089void KOMonthView::slotEditJournal()
2086{ 2090{
2087 if ( mPopupCell ) 2091 if ( mPopupCell )
2088 emit showJournalSignal( 7, mPopupCell->date() ); 2092 emit showJournalSignal( 7, mPopupCell->date() );
2089 //qDebug("KOMonthView::slotEditJournal() "); 2093 //qDebug("KOMonthView::slotEditJournal() ");
2090 mPopupCell = 0; 2094 mPopupCell = 0;
2091} 2095}
2092 2096
2093void KOMonthView::setPopupCell( MonthViewCell * c) 2097void KOMonthView::setPopupCell( MonthViewCell * c)
2094{ 2098{
2095 mPopupCell = c; 2099 mPopupCell = c;
2096} 2100}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index e679bd3..65f0342 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,594 +1,595 @@
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 <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kemailsettings.h> 43#include <kemailsettings.h>
44#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "mainwindow.h" 48#include "mainwindow.h"
49 49
50KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
51static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
52 52
53KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
54 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
55{ 55{
56 mCategoryColors.setAutoDelete(true); 56 mCategoryColors.setAutoDelete(true);
57 fillMailDefaults(); 57 fillMailDefaults();
58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
59 QColor defaultHolidayColor = QColor(255,0,0); 59 QColor defaultHolidayColor = QColor(255,0,0);
60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
63 QColor defaultTodoDueTodayColor = QColor(255,220,100); 63 QColor defaultTodoDueTodayColor = QColor(255,220,100);
64 QColor defaultTodoOverdueColor = QColor(255,153,125); 64 QColor defaultTodoOverdueColor = QColor(255,153,125);
65 QColor defaultTodoRunColor = QColor(99,194,30); 65 QColor defaultTodoRunColor = QColor(99,194,30);
66 KPrefs::setCurrentGroup("General"); 66 KPrefs::setCurrentGroup("General");
67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
70 addItemBool("ShowIconSearch",&mShowIconSearch,true); 70 addItemBool("ShowIconSearch",&mShowIconSearch,true);
71 addItemBool("ShowIconList",&mShowIconList,true); 71 addItemBool("ShowIconList",&mShowIconList,true);
72 addItemBool("ShowIconDay1",&mShowIconDay1,true); 72 addItemBool("ShowIconDay1",&mShowIconDay1,true);
73 addItemBool("ShowIconDay5",&mShowIconDay5,true); 73 addItemBool("ShowIconDay5",&mShowIconDay5,true);
74 addItemBool("ShowIconDay6",&mShowIconDay6,true); 74 addItemBool("ShowIconDay6",&mShowIconDay6,true);
75 addItemBool("ShowIconDay7",&mShowIconDay7,true); 75 addItemBool("ShowIconDay7",&mShowIconDay7,true);
76 addItemBool("ShowIconMonth",&mShowIconMonth,true); 76 addItemBool("ShowIconMonth",&mShowIconMonth,true);
77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
79 addItemBool("ShowIconBack",&mShowIconBack,true); 79 addItemBool("ShowIconBack",&mShowIconBack,true);
80 addItemBool("ShowIconToday",&mShowIconToday,true); 80 addItemBool("ShowIconToday",&mShowIconToday,true);
81 addItemBool("ShowIconForward",&mShowIconForward,true); 81 addItemBool("ShowIconForward",&mShowIconForward,true);
82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); 84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
86 addItemBool("ShowIconNext",&mShowIconNext,true); 86 addItemBool("ShowIconNext",&mShowIconNext,true);
87 addItemBool("ShowIconJournal",&mShowIconJournal,true); 87 addItemBool("ShowIconJournal",&mShowIconJournal,true);
88 addItemBool("ShowIconStretch",&mShowIconStretch,true); 88 addItemBool("ShowIconStretch",&mShowIconStretch,true);
89 addItemBool("ShowIconFilter",&mShowIconFilter,false); 89 addItemBool("ShowIconFilter",&mShowIconFilter,false);
90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); 90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
91 91
92 bool addIcons = false; 92 bool addIcons = false;
93#ifdef DESKTOP_VERSION 93#ifdef DESKTOP_VERSION
94 addIcons = true; 94 addIcons = true;
95#endif 95#endif
96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); 96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons);
97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); 97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons);
98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); 98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons);
99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); 99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons);
100 100
101 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 101 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarHorV",&mToolBarHorV, true ); 112 addItemBool("ToolBarHorV",&mToolBarHorV, true );
113 addItemBool("ToolBarUpV",&mToolBarUpV, false ); 113 addItemBool("ToolBarUpV",&mToolBarUpV, false );
114 addItemBool("ToolBarHorN",&mToolBarHorN, true ); 114 addItemBool("ToolBarHorN",&mToolBarHorN, true );
115 addItemBool("ToolBarUpN",&mToolBarUpN, false ); 115 addItemBool("ToolBarUpN",&mToolBarUpN, false );
116 addItemBool("ToolBarHorF",&mToolBarHorF, true ); 116 addItemBool("ToolBarHorF",&mToolBarHorF, true );
117 addItemBool("ToolBarUpF",&mToolBarUpF, false ); 117 addItemBool("ToolBarUpF",&mToolBarUpF, false );
118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
119 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
121 121
122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); 123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true);
124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
127 addItemInt("AllDay Size",&mAllDaySize,28); 127 addItemInt("AllDay Size",&mAllDaySize,28);
128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
130 130
131 addItemStringList("LocationDefaults",&mLocationDefaults ); 131 addItemStringList("LocationDefaults",&mLocationDefaults );
132 addItemStringList("EventSummary User",&mEventSummaryUser); 132 addItemStringList("EventSummary User",&mEventSummaryUser);
133 addItemStringList("TodoSummary User",&mTodoSummaryUser); 133 addItemStringList("TodoSummary User",&mTodoSummaryUser);
134 134
135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
136 addItemBool("Enable Project View",&mEnableProjectView,false); 136 addItemBool("Enable Project View",&mEnableProjectView,false);
137 addItemBool("Auto Save",&mAutoSave,false); 137 addItemBool("Auto Save",&mAutoSave,false);
138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
139 addItemBool("Confirm Deletes",&mConfirm,true); 139 addItemBool("Confirm Deletes",&mConfirm,true);
140 addItemString("Archive File",&mArchiveFile); 140 addItemString("Archive File",&mArchiveFile);
141 addItemString("Html Export File",&mHtmlExportFile, 141 addItemString("Html Export File",&mHtmlExportFile,
142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
143 addItemBool("Html With Save",&mHtmlWithSave,false); 143 addItemBool("Html With Save",&mHtmlWithSave,false);
144 144
145 KPrefs::setCurrentGroup("Personal Settings"); 145 KPrefs::setCurrentGroup("Personal Settings");
146 146
147 addItemInt("Mail Client",&mMailClient,MailClientKMail); 147 addItemInt("Mail Client",&mMailClient,MailClientKMail);
148 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 148 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
149 addItemBool("Bcc",&mBcc,false); 149 addItemBool("Bcc",&mBcc,false);
150 150
151 KPrefs::setCurrentGroup("Time & Date"); 151 KPrefs::setCurrentGroup("Time & Date");
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 KPrefs::setCurrentGroup("AlarmSettings"); 157 KPrefs::setCurrentGroup("AlarmSettings");
158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
162 162
163 163
164 KPrefs::setCurrentGroup("Calendar"); 164 KPrefs::setCurrentGroup("Calendar");
165 165
166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
167 167
168 KPrefs::setCurrentGroup("Fonts"); 168 KPrefs::setCurrentGroup("Fonts");
169 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 169 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
170 QFont fon = KGlobalSettings::generalFont(); 170 QFont fon = KGlobalSettings::generalFont();
171 addItemFont("TimeBar Font",&mTimeBarFont,fon ); 171 addItemFont("TimeBar Font",&mTimeBarFont,fon );
172 addItemFont("MonthView Font",&mMonthViewFont,fon); 172 addItemFont("MonthView Font",&mMonthViewFont,fon);
173 addItemFont("AgendaView Font",&mAgendaViewFont,fon); 173 addItemFont("AgendaView Font",&mAgendaViewFont,fon);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon);
176 addItemFont("TodoView Font",&mTodoViewFont,fon); 176 addItemFont("TodoView Font",&mTodoViewFont,fon);
177 addItemFont("ListView Font",&mListViewFont,fon); 177 addItemFont("ListView Font",&mListViewFont,fon);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon);
179 addItemFont("EditBox Font",&mEditBoxFont,fon); 179 addItemFont("EditBox Font",&mEditBoxFont,fon);
180 addItemFont("JournalView Font",&mJornalViewFont,fon); 180 addItemFont("JournalView Font",&mJornalViewFont,fon);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon);
182 addItemFont("EventView Font",&mEventViewFont,fon); 182 addItemFont("EventView Font",&mEventViewFont,fon);
183 183
184 KPrefs::setCurrentGroup("RemoteSyncing"); 184 KPrefs::setCurrentGroup("RemoteSyncing");
185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
188 addItemInt("LastSyncTime",&mLastSyncTime,0); 188 addItemInt("LastSyncTime",&mLastSyncTime,0);
189 189
190#ifdef _WIN32_ 190#ifdef _WIN32_
191 QString hdp= locateLocal("data","korganizer")+"\\\\"; 191 QString hdp= locateLocal("data","korganizer")+"\\\\";
192#else 192#else
193 QString hdp= locateLocal("data","korganizer")+"/"; 193 QString hdp= locateLocal("data","korganizer")+"/";
194#endif 194#endif
195 195
196 KPrefs::setCurrentGroup("LoadSaveFileNames"); 196 KPrefs::setCurrentGroup("LoadSaveFileNames");
197 197
198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
202 202
203 203
204 KPrefs::setCurrentGroup("Locale"); 204 KPrefs::setCurrentGroup("Locale");
205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
206 206
207 207
208 KPrefs::setCurrentGroup("Colors"); 208 KPrefs::setCurrentGroup("Colors");
209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); 217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
223 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 223 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
227 addItemBool("UseAppColors",&mUseAppColors,false); 227 addItemBool("UseAppColors",&mUseAppColors,false);
228 228
229 229
230 230
231 KPrefs::setCurrentGroup("Views"); 231 KPrefs::setCurrentGroup("Views");
232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true); 232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true);
233 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 233 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
234 addItemInt("Hour Size",&mHourSize,8); 234 addItemInt("Hour Size",&mHourSize,8);
235 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 235 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
239 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 239 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); 241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true);
242#ifdef DESKTOP_VERION 242#ifdef DESKTOP_VERION
243 addItemBool("Enable ToolTips",&mEnableToolTips,true); 243 addItemBool("Enable ToolTips",&mEnableToolTips,true);
244#else 244#else
245 addItemBool("Enable ToolTips",&mEnableToolTips,false); 245 addItemBool("Enable ToolTips",&mEnableToolTips,false);
246#endif 246#endif
247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
267#ifdef DESKTOP_VERSION 267#ifdef DESKTOP_VERSION
268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
269#else 269#else
270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
271#endif 271#endif
272 addItemInt("Day Begins",&mDayBegins,7); 272 addItemInt("Day Begins",&mDayBegins,7);
273 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 273 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
274 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 274 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
275 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 275 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
277 277
278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
279 addItemBool("Full View Month",&mFullViewMonth,true); 279 addItemBool("Full View Month",&mFullViewMonth,true);
280 addItemBool("Full View Todo",&mFullViewTodo,true); 280 addItemBool("Full View Todo",&mFullViewTodo,true);
281 addItemBool("Quick Todo",&mEnableQuickTodo,false); 281 addItemBool("Quick Todo",&mEnableQuickTodo,false);
282 282
283 addItemInt("Next X Days",&mNextXDays,3); 283 addItemInt("Next X Days",&mNextXDays,3);
284 284
285 KPrefs::setCurrentGroup("Printer"); 285 KPrefs::setCurrentGroup("Printer");
286 286
287 KPrefs::setCurrentGroup("Layout"); 287 KPrefs::setCurrentGroup("Layout");
288 288
289 addItemBool("CompactDialogs",&mCompactDialogs,false); 289 addItemBool("CompactDialogs",&mCompactDialogs,false);
290 addItemBool("VerticalScreen",&mVerticalScreen,true); 290 addItemBool("VerticalScreen",&mVerticalScreen,true);
291 291
292 KPrefs::setCurrentGroup("KOrganizer Plugins"); 292 KPrefs::setCurrentGroup("KOrganizer Plugins");
293 293
294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
295 295
296 KPrefs::setCurrentGroup("Group Scheduling"); 296 KPrefs::setCurrentGroup("Group Scheduling");
297 297
298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
300 addItemStringList("AdditionalMails",&mAdditionalMails,""); 300 addItemStringList("AdditionalMails",&mAdditionalMails,"");
301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
306 306
307 KPrefs::setCurrentGroup( "Editors" ); 307 KPrefs::setCurrentGroup( "Editors" );
308 308
309 addItemStringList( "EventTemplates", &mEventTemplates ); 309 addItemStringList( "EventTemplates", &mEventTemplates );
310 addItemStringList( "TodoTemplates", &mTodoTemplates ); 310 addItemStringList( "TodoTemplates", &mTodoTemplates );
311 311
312 addItemInt("DestinationPolicy",&mDestination,standardDestination); 312 addItemInt("DestinationPolicy",&mDestination,standardDestination);
313 313
314 KPrefs::setCurrentGroup( "ViewOptions" ); 314 KPrefs::setCurrentGroup( "ViewOptions" );
315 addItemBool("EVshowDetails",&mEVshowDetails,true); 315 addItemBool("EVshowDetails",&mEVshowDetails,true);
316 addItemBool("EVshowCreated",&mEVshowCreated,true); 316 addItemBool("EVshowCreated",&mEVshowCreated,true);
317 addItemBool("EVshowChanged",&mEVshowChanged,true); 317 addItemBool("EVshowChanged",&mEVshowChanged,true);
318 addItemBool("WTshowDetails",&mWTshowDetails,false); 318 addItemBool("WTshowDetails",&mWTshowDetails,false);
319 addItemBool("WTshowCreated",&mWTshowCreated,false); 319 addItemBool("WTshowCreated",&mWTshowCreated,false);
320 addItemBool("WTshowChanged",&mWTshowChanged,false); 320 addItemBool("WTshowChanged",&mWTshowChanged,false);
321 mCalendars.setAutoDelete( true ); 321 mCalendars.setAutoDelete( true );
322} 322}
323 323
324 324
325KOPrefs::~KOPrefs() 325KOPrefs::~KOPrefs()
326{ 326{
327 if (mInstance == this) 327 if (mInstance == this)
328 mInstance = insd.setObject(0); 328 mInstance = insd.setObject(0);
329 mCalendars.setAutoDelete( true ); 329 mCalendars.setAutoDelete( true );
330 mCalendars.clear(); 330 mCalendars.clear();
331 //qDebug("KOPrefs::~KOPrefs() "); 331 //qDebug("KOPrefs::~KOPrefs() ");
332} 332}
333 333
334 334
335KOPrefs *KOPrefs::instance() 335KOPrefs *KOPrefs::instance()
336{ 336{
337 if (!mInstance) { 337 if (!mInstance) {
338 mInstance = insd.setObject(new KOPrefs()); 338 mInstance = insd.setObject(new KOPrefs());
339 mInstance->readConfig(); 339 mInstance->readConfig();
340 } 340 }
341 341
342 return mInstance; 342 return mInstance;
343} 343}
344 344
345void KOPrefs::usrSetDefaults() 345void KOPrefs::usrSetDefaults()
346{ 346{
347 347
348} 348}
349 349
350void KOPrefs::fillMailDefaults() 350void KOPrefs::fillMailDefaults()
351{ 351{
352 if (mName.isEmpty()) mName = i18n("Anonymous"); 352 if (mName.isEmpty()) mName = i18n("Anonymous");
353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
354} 354}
355 355
356void KOPrefs::setTimeZoneIdDefault() 356void KOPrefs::setTimeZoneIdDefault()
357{ 357{
358 ; 358 ;
359} 359}
360 360
361void KOPrefs::setAllDefaults() 361void KOPrefs::setAllDefaults()
362{ 362{
363 setCategoryDefaults(); 363 setCategoryDefaults();
364 mEventSummaryUser = getDefaultList() ; 364 mEventSummaryUser = getDefaultList() ;
365 mTodoSummaryUser = getDefaultList() ; 365 mTodoSummaryUser = getDefaultList() ;
366 mLocationDefaults = getLocationDefaultList(); 366 mLocationDefaults = getLocationDefaultList();
367} 367}
368 368
369void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
370{ 370{
371 mCustomCategories.clear(); 371 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
373 373
374 QStringList::Iterator it; 374 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
377 } 377 }
378} 378}
379QStringList KOPrefs::getLocationDefaultList() 379QStringList KOPrefs::getLocationDefaultList()
380{ 380{
381 QStringList retval ; 381 QStringList retval ;
382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
387 387
388 retval.sort(); 388 retval.sort();
389 return retval; 389 return retval;
390} 390}
391QStringList KOPrefs::getDefaultList() 391QStringList KOPrefs::getDefaultList()
392{ 392{
393 QStringList retval ; 393 QStringList retval ;
394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
402 retval.sort(); 402 retval.sort();
403 //qDebug("cat %s ", retval.join("-").latin1()); 403 //qDebug("cat %s ", retval.join("-").latin1());
404 return retval; 404 return retval;
405} 405}
406 406
407void KOPrefs::usrReadConfig() 407void KOPrefs::usrReadConfig()
408{ 408{
409 config()->setGroup("General"); 409 config()->setGroup("General");
410 410
411 //qDebug("KOPrefs::usrReadConfig() "); 411 //qDebug("KOPrefs::usrReadConfig() ");
412 mCustomCategories = config()->readListEntry("Custom Categories"); 412 mCustomCategories = config()->readListEntry("Custom Categories");
413 mOldLoadedLanguage = mOldLanguage ; 413 mOldLoadedLanguage = mOldLanguage ;
414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
415 if (mLocationDefaults.isEmpty()) { 415 if (mLocationDefaults.isEmpty()) {
416 mLocationDefaults = getLocationDefaultList(); 416 mLocationDefaults = getLocationDefaultList();
417 } 417 }
418 418
419 if (mEventSummaryUser.isEmpty()) { 419 if (mEventSummaryUser.isEmpty()) {
420 mEventSummaryUser = getDefaultList() ; 420 mEventSummaryUser = getDefaultList() ;
421 } 421 }
422 if (mTodoSummaryUser.isEmpty()) { 422 if (mTodoSummaryUser.isEmpty()) {
423 mTodoSummaryUser = getDefaultList() ; 423 mTodoSummaryUser = getDefaultList() ;
424 } 424 }
425 425
426 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 426 if (mCustomCategories.isEmpty()) setCategoryDefaults();
427 427
428 config()->setGroup("Personal Settings"); 428 config()->setGroup("Personal Settings");
429 mName = config()->readEntry("user_name",""); 429 mName = config()->readEntry("user_name","");
430 mEmail = config()->readEntry("user_email",""); 430 mEmail = config()->readEntry("user_email","");
431 fillMailDefaults(); 431 fillMailDefaults();
432 432
433 config()->setGroup("Category Colors"); 433 config()->setGroup("Category Colors");
434 QStringList::Iterator it; 434 QStringList::Iterator it;
435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
437 437
438 } 438 }
439 KConfig fc (locateLocal("config","kopicalendarrc")); 439 KConfig fc (locateLocal("config","kopicalendarrc"));
440 fc.setGroup("CC"); 440 fc.setGroup("CC");
441 int numCals = fc.readNumEntry("NumberCalendars",0 ); 441 int numCals = fc.readNumEntry("NumberCalendars",0 );
442 mNextAvailableCalendar = 1; 442 mNextAvailableCalendar = 1;
443 if ( numCals == 0 ) { 443 if ( numCals == 0 ) {
444 KopiCalendarFile *kkf = getNewCalendar(); 444 KopiCalendarFile *kkf = getNewCalendar();
445 kkf->isStandard = true; 445 kkf->isStandard = true;
446 kkf->mName = i18n("Standard"); 446 kkf->mName = i18n("Standard");
447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
448 } 448 }
449 while ( mNextAvailableCalendar <= numCals ) { 449 while ( mNextAvailableCalendar <= numCals ) {
450 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 450 //qDebug("Read cal #%d ", mNextAvailableCalendar );
451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
452 KopiCalendarFile *kkf = getNewCalendar(); 452 KopiCalendarFile *kkf = getNewCalendar();
453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); 458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName);
459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
460 if ( kkf->mCalNumber == 1 ) { 460 if ( kkf->mCalNumber == 1 ) {
461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
462 } 462 }
463 } 463 }
464 464
465 KPimPrefs::usrReadConfig(); 465 KPimPrefs::usrReadConfig();
466} 466}
467 467
468KopiCalendarFile * KOPrefs::getCalendar( int num ) 468KopiCalendarFile * KOPrefs::getCalendar( int num )
469{ 469{
470 return mDefCalColors[num-1]; 470 return mDefCalColors[num-1];
471} 471}
472 472
473KopiCalendarFile * KOPrefs::getNewCalendar() 473KopiCalendarFile * KOPrefs::getNewCalendar()
474{ 474{
475 KopiCalendarFile * kkf = new KopiCalendarFile(); 475 KopiCalendarFile * kkf = new KopiCalendarFile();
476 kkf->mCalNumber = mNextAvailableCalendar; 476 kkf->mCalNumber = mNextAvailableCalendar;
477 mDefCalColors.resize( mNextAvailableCalendar ); 477 mDefCalColors.resize( mNextAvailableCalendar );
478 mDefCalColors[mNextAvailableCalendar-1] = kkf; 478 mDefCalColors[mNextAvailableCalendar-1] = kkf;
479 ++mNextAvailableCalendar; 479 ++mNextAvailableCalendar;
480 kkf->mDefaultColor = mEventColor; 480 kkf->mDefaultColor = mEventColor;
481 kkf->mName = i18n("New Calendar"); 481 kkf->mName = i18n("New Calendar");
482 mCalendars.append( kkf ); 482 mCalendars.append( kkf );
483 return kkf; 483 return kkf;
484} 484}
485void KOPrefs::deleteCalendar( int num ) 485void KOPrefs::deleteCalendar( int num )
486{ 486{
487 KopiCalendarFile * kkf = mCalendars.first(); 487 KopiCalendarFile * kkf = mCalendars.first();
488 while ( kkf ) { 488 while ( kkf ) {
489 if ( kkf->mCalNumber == num ) { 489 if ( kkf->mCalNumber == num ) {
490 qDebug("KOPrefs::deleteCalendar %d ", num ); 490 qDebug("KOPrefs::deleteCalendar %d ", num );
491 mCalendars.remove( kkf ); 491 mCalendars.remove( kkf );
492 delete kkf; 492 delete kkf;
493 return; 493 return;
494 } 494 }
495 kkf = mCalendars.next(); 495 kkf = mCalendars.next();
496 } 496 }
497} 497}
498QColor KOPrefs::defaultColor( int calNum ) const 498QColor KOPrefs::defaultColor( int calNum ) const
499{ 499{
500 if ( calNum == 1 ) return mEventColor;
500 return (mDefCalColors[calNum-1])->mDefaultColor; 501 return (mDefCalColors[calNum-1])->mDefaultColor;
501} 502}
502void KOPrefs::usrWriteConfig() 503void KOPrefs::usrWriteConfig()
503{ 504{
504 config()->setGroup("General"); 505 config()->setGroup("General");
505 config()->writeEntry("Custom Categories",mCustomCategories); 506 config()->writeEntry("Custom Categories",mCustomCategories);
506 507
507 config()->setGroup("Personal Settings"); 508 config()->setGroup("Personal Settings");
508 config()->writeEntry("user_name",mName); 509 config()->writeEntry("user_name",mName);
509 config()->writeEntry("user_email",mEmail); 510 config()->writeEntry("user_email",mEmail);
510 511
511 config()->setGroup("Category Colors"); 512 config()->setGroup("Category Colors");
512 QDictIterator<QColor> it(mCategoryColors); 513 QDictIterator<QColor> it(mCategoryColors);
513 while (it.current()) { 514 while (it.current()) {
514 config()->writeEntry(it.currentKey(),*(it.current())); 515 config()->writeEntry(it.currentKey(),*(it.current()));
515 ++it; 516 ++it;
516 } 517 }
517 KConfig fc (locateLocal("config","kopicalendarrc")); 518 KConfig fc (locateLocal("config","kopicalendarrc"));
518 fc.setGroup("CC"); 519 fc.setGroup("CC");
519 fc.writeEntry("NumberCalendars",mCalendars.count()); 520 fc.writeEntry("NumberCalendars",mCalendars.count());
520 int numCal = 1; 521 int numCal = 1;
521 int writeCal = 0; 522 int writeCal = 0;
522 while ( numCal < mNextAvailableCalendar ) { 523 while ( numCal < mNextAvailableCalendar ) {
523 KopiCalendarFile * kkf = mCalendars.first(); 524 KopiCalendarFile * kkf = mCalendars.first();
524 while ( kkf ) { 525 while ( kkf ) {
525 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 526 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
526 if ( kkf->mCalNumber == numCal ) { 527 if ( kkf->mCalNumber == numCal ) {
527 ++writeCal; 528 ++writeCal;
528 //qDebug("Write calendar %d %d ", numCal , writeCal); 529 //qDebug("Write calendar %d %d ", numCal , writeCal);
529 QString prefix = "Cal_" + QString::number( writeCal ); 530 QString prefix = "Cal_" + QString::number( writeCal );
530 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 531 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
531 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 532 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
532 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 533 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
533 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 534 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
534 fc.writeEntry( prefix+"_Name", kkf->mName); 535 fc.writeEntry( prefix+"_Name", kkf->mName);
535 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 536 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
536 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 537 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
537 } 538 }
538 kkf = mCalendars.next(); 539 kkf = mCalendars.next();
539 } 540 }
540 ++numCal; 541 ++numCal;
541 } 542 }
542 fc.sync(); 543 fc.sync();
543 KPimPrefs::usrWriteConfig(); 544 KPimPrefs::usrWriteConfig();
544} 545}
545 546
546void KOPrefs::setCategoryColor(QString cat,const QColor & color) 547void KOPrefs::setCategoryColor(QString cat,const QColor & color)
547{ 548{
548 mCategoryColors.replace(cat,new QColor(color)); 549 mCategoryColors.replace(cat,new QColor(color));
549} 550}
550 551
551QColor *KOPrefs::categoryColor(QString cat) 552QColor *KOPrefs::categoryColor(QString cat)
552{ 553{
553 QColor *color = 0; 554 QColor *color = 0;
554 555
555 if (!cat.isEmpty()) color = mCategoryColors[cat]; 556 if (!cat.isEmpty()) color = mCategoryColors[cat];
556 557
557 if (color) return color; 558 if (color) return color;
558 else return &mDefaultCategoryColor; 559 else return &mDefaultCategoryColor;
559} 560}
560 561
561void KOPrefs::setFullName(const QString &name) 562void KOPrefs::setFullName(const QString &name)
562{ 563{
563 mName = name; 564 mName = name;
564} 565}
565 566
566void KOPrefs::setEmail(const QString &email) 567void KOPrefs::setEmail(const QString &email)
567{ 568{
568 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 569 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
569 mEmail = email; 570 mEmail = email;
570} 571}
571 572
572QString KOPrefs::fullName() 573QString KOPrefs::fullName()
573{ 574{
574 if (mEmailControlCenter) { 575 if (mEmailControlCenter) {
575 KEMailSettings settings; 576 KEMailSettings settings;
576 return settings.getSetting(KEMailSettings::RealName); 577 return settings.getSetting(KEMailSettings::RealName);
577 } else { 578 } else {
578 return mName; 579 return mName;
579 } 580 }
580} 581}
581 582
582QString KOPrefs::email() 583QString KOPrefs::email()
583{ 584{
584 if (mEmailControlCenter) { 585 if (mEmailControlCenter) {
585 KEMailSettings settings; 586 KEMailSettings settings;
586 return settings.getSetting(KEMailSettings::EmailAddress); 587 return settings.getSetting(KEMailSettings::EmailAddress);
587 } else { 588 } else {
588 return mEmail; 589 return mEmail;
589 } 590 }
590} 591}
591KConfig* KOPrefs::getConfig() 592KConfig* KOPrefs::getConfig()
592{ 593{
593 return config(); 594 return config();
594} 595}
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp
index 3ee9a22..35a56ca 100644
--- a/korganizer/koprefsdialog.cpp
+++ b/korganizer/koprefsdialog.cpp
@@ -1,1539 +1,1538 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qvbox.h> 34#include <qvbox.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44 44
45#include <kcolorbutton.h> 45#include <kcolorbutton.h>
46#include <kdebug.h> 46#include <kdebug.h>
47#include <klocale.h> 47#include <klocale.h>
48#include <kglobal.h> 48#include <kglobal.h>
49#include <kfontdialog.h> 49#include <kfontdialog.h>
50#include <kfiledialog.h> 50#include <kfiledialog.h>
51#include <kmessagebox.h> 51#include <kmessagebox.h>
52#include <kcolordialog.h> 52#include <kcolordialog.h>
53#include <kiconloader.h> 53#include <kiconloader.h>
54#include <kemailsettings.h> 54#include <kemailsettings.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kglobalsettings.h> 56#include <kglobalsettings.h>
57 57
58#include <kurlrequester.h> 58#include <kurlrequester.h>
59#include <klineedit.h> 59#include <klineedit.h>
60 60
61#if defined(USE_SOLARIS) 61#if defined(USE_SOLARIS)
62#include <sys/param.h> 62#include <sys/param.h>
63 63
64#define ZONEINFODIR "/usr/share/lib/zoneinfo" 64#define ZONEINFODIR "/usr/share/lib/zoneinfo"
65#define INITFILE "/etc/default/init" 65#define INITFILE "/etc/default/init"
66#endif 66#endif
67 67
68#include "koprefs.h" 68#include "koprefs.h"
69 69
70#include "koprefsdialog.h" 70#include "koprefsdialog.h"
71#include "kpimglobalprefs.h" 71#include "kpimglobalprefs.h"
72 72
73 73
74KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : 74KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) :
75 KPrefsDialog(KOPrefs::instance(),parent,name,true) 75 KPrefsDialog(KOPrefs::instance(),parent,name,true)
76{ 76{
77 77
78 setFont( KGlobalSettings::generalMaxFont() ); 78 setFont( KGlobalSettings::generalMaxFont() );
79 setCaption( i18n("Preferences - some settings need a restart (nr)")); 79 setCaption( i18n("Preferences - some settings need a restart (nr)"));
80 mCategoryDict.setAutoDelete(true); 80 mCategoryDict.setAutoDelete(true);
81 81
82 KGlobal::locale()->insertCatalogue("timezones"); 82 KGlobal::locale()->insertCatalogue("timezones");
83 mSpacingHint = spacingHintSmall(); 83 mSpacingHint = spacingHintSmall();
84 mMarginHint = marginHintSmall(); 84 mMarginHint = marginHintSmall();
85#ifndef DESKTOP_VERSION 85#ifndef DESKTOP_VERSION
86 if ( QApplication::desktop()->height() == 480 ) 86 if ( QApplication::desktop()->height() == 480 )
87 hideButtons(); 87 hideButtons();
88#endif 88#endif
89 89
90 setupMainTab(); 90 setupMainTab();
91 // setupLocaleTab(); 91 // setupLocaleTab();
92 //setupTimeZoneTab(); 92 //setupTimeZoneTab();
93 setupTimeTab(); 93 setupTimeTab();
94 //setupLocaleDateTab(); 94 //setupLocaleDateTab();
95 setupFontsTab(); 95 setupFontsTab();
96 setupColorsTab(); 96 setupColorsTab();
97 setupViewsTab(); 97 setupViewsTab();
98 //setupSyncTab(); 98 //setupSyncTab();
99 //setupSyncAlgTab(); 99 //setupSyncAlgTab();
100 //setupPrinterTab(); 100 //setupPrinterTab();
101 //setupGroupSchedulingTab(); 101 //setupGroupSchedulingTab();
102 //setupGroupAutomationTab(); 102 //setupGroupAutomationTab();
103 103
104 104
105} 105}
106 106
107 107
108KOPrefsDialog::~KOPrefsDialog() 108KOPrefsDialog::~KOPrefsDialog()
109{ 109{
110} 110}
111void KOPrefsDialog::setupGlobalTab() 111void KOPrefsDialog::setupGlobalTab()
112{ 112{
113 113
114 114
115} 115}
116void KOPrefsDialog::setupLocaleDateTab() 116void KOPrefsDialog::setupLocaleDateTab()
117{ 117{
118#if 0 118#if 0
119QFrame *topFrame = addPage(i18n("Date Format"),0,0); 119QFrame *topFrame = addPage(i18n("Date Format"),0,0);
120 QGridLayout *topLayout = new QGridLayout(topFrame,3,2); 120 QGridLayout *topLayout = new QGridLayout(topFrame,3,2);
121 topLayout->setSpacing(mSpacingHint); 121 topLayout->setSpacing(mSpacingHint);
122 topLayout->setMargin(mMarginHint); 122 topLayout->setMargin(mMarginHint);
123 int iii = 0; 123 int iii = 0;
124 124
125 125
126 KPrefsDialogWidRadios *syncPrefsGroup = 126 KPrefsDialogWidRadios *syncPrefsGroup =
127 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); 127 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame);
128 QString format; 128 QString format;
129 if ( QApplication::desktop()->width() < 480 ) 129 if ( QApplication::desktop()->width() < 480 )
130 format = "(%d.%m.%Y)"; 130 format = "(%d.%m.%Y)";
131 else 131 else
132 format = "(%d.%m.%Y|%A %d %B %Y)"; 132 format = "(%d.%m.%Y|%A %d %B %Y)";
133 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 133 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
134 if ( QApplication::desktop()->width() < 480 ) 134 if ( QApplication::desktop()->width() < 480 )
135 format = "(%m.%d.%Y)"; 135 format = "(%m.%d.%Y)";
136 else 136 else
137 format = "(%m.%d.%Y|%A %B %d %Y)"; 137 format = "(%m.%d.%Y|%A %B %d %Y)";
138 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 138 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
139 if ( QApplication::desktop()->width() < 480 ) 139 if ( QApplication::desktop()->width() < 480 )
140 format = "(%Y-%m-%d)"; 140 format = "(%Y-%m-%d)";
141 else 141 else
142 format = "(%Y-%m-%d|%A %Y %B %d)"; 142 format = "(%Y-%m-%d|%A %Y %B %d)";
143 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 143 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
144 syncPrefsGroup->addRadio(i18n("User defined")); 144 syncPrefsGroup->addRadio(i18n("User defined"));
145 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 145 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
146 ++iii; 146 ++iii;
147 ++iii; 147 ++iii;
148 QLabel * lab; 148 QLabel * lab;
149 mUserDateFormatLong = new QLineEdit(topFrame); 149 mUserDateFormatLong = new QLineEdit(topFrame);
150 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 150 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
151 topLayout->addWidget(lab ,iii,0); 151 topLayout->addWidget(lab ,iii,0);
152 topLayout->addWidget(mUserDateFormatLong,iii,1); 152 topLayout->addWidget(mUserDateFormatLong,iii,1);
153 ++iii; 153 ++iii;
154 mUserDateFormatShort = new QLineEdit(topFrame); 154 mUserDateFormatShort = new QLineEdit(topFrame);
155 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 155 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
156 topLayout->addWidget(lab ,iii,0); 156 topLayout->addWidget(lab ,iii,0);
157 topLayout->addWidget(mUserDateFormatShort,iii,1); 157 topLayout->addWidget(mUserDateFormatShort,iii,1);
158 ++iii; 158 ++iii;
159 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 159 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
160 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 160 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
161 ++iii; 161 ++iii;
162 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 162 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
163 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 163 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
164 ++iii; 164 ++iii;
165 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 165 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
166 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 166 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
167 ++iii; 167 ++iii;
168#endif 168#endif
169 169
170} 170}
171 171
172void KOPrefsDialog::setupLocaleTab() 172void KOPrefsDialog::setupLocaleTab()
173{ 173{
174#if 0 174#if 0
175 QFrame *topFrame = addPage(i18n("Locale"),0,0); 175 QFrame *topFrame = addPage(i18n("Locale"),0,0);
176 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 176 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
177 topLayout->setSpacing(mSpacingHint); 177 topLayout->setSpacing(mSpacingHint);
178 topLayout->setMargin(mMarginHint); 178 topLayout->setMargin(mMarginHint);
179 int iii = 0; 179 int iii = 0;
180 KPrefsDialogWidRadios *syncPrefsGroup = 180 KPrefsDialogWidRadios *syncPrefsGroup =
181 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); 181 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame);
182 syncPrefsGroup->addRadio(i18n("English")); 182 syncPrefsGroup->addRadio(i18n("English"));
183 syncPrefsGroup->addRadio(i18n("German")); 183 syncPrefsGroup->addRadio(i18n("German"));
184 syncPrefsGroup->addRadio(i18n("French")); 184 syncPrefsGroup->addRadio(i18n("French"));
185 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 185 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
186 if ( QApplication::desktop()->width() < 300 ) 186 if ( QApplication::desktop()->width() < 300 )
187 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 187 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
188 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 188 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
189 ++iii; 189 ++iii;
190 190
191 syncPrefsGroup = 191 syncPrefsGroup =
192 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); 192 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame);
193 if ( QApplication::desktop()->width() > 300 ) 193 if ( QApplication::desktop()->width() > 300 )
194 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 194 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
195 syncPrefsGroup->addRadio(i18n("24:00")); 195 syncPrefsGroup->addRadio(i18n("24:00"));
196 syncPrefsGroup->addRadio(i18n("12:00am")); 196 syncPrefsGroup->addRadio(i18n("12:00am"));
197 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 197 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
198 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 198 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
199 ++iii; 199 ++iii;
200 KPrefsDialogWidBool *sb; 200 KPrefsDialogWidBool *sb;
201 if ( QApplication::desktop()->width() < 300 ) { 201 if ( QApplication::desktop()->width() < 300 ) {
202 sb = 202 sb =
203 addWidBool(i18n("Week starts on Sunday"), 203 addWidBool(i18n("Week starts on Sunday"),
204 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); 204 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame);
205 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 205 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
206 ++iii; 206 ++iii;
207 sb = 207 sb =
208 addWidBool(i18n("Use short date in (WN/E) view"), 208 addWidBool(i18n("Use short date in (WN/E) view"),
209 &(KOPrefs::instance()->mShortDateInViewer),topFrame); 209 &(KOPrefs::instance()->mShortDateInViewer),topFrame);
210 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 210 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
211 } 211 }
212 else { 212 else {
213 QWidget * hb = new QWidget( topFrame ); 213 QWidget * hb = new QWidget( topFrame );
214 QHBoxLayout *hbLayout = new QHBoxLayout(hb); 214 QHBoxLayout *hbLayout = new QHBoxLayout(hb);
215 sb = 215 sb =
216 addWidBool(i18n("Week starts on Sunday"), 216 addWidBool(i18n("Week starts on Sunday"),
217 &(KOPrefs::instance()->mWeekStartsOnSunday),hb); 217 &(KOPrefs::instance()->mWeekStartsOnSunday),hb);
218 hbLayout->addWidget(sb->checkBox() ); 218 hbLayout->addWidget(sb->checkBox() );
219 sb = 219 sb =
220 addWidBool(i18n("Use short date in (WN/E) view"), 220 addWidBool(i18n("Use short date in (WN/E) view"),
221 &(KOPrefs::instance()->mShortDateInViewer),hb); 221 &(KOPrefs::instance()->mShortDateInViewer),hb);
222 hbLayout->addWidget(sb->checkBox() ); 222 hbLayout->addWidget(sb->checkBox() );
223 topLayout->addMultiCellWidget(hb, iii,iii,0,1); 223 topLayout->addMultiCellWidget(hb, iii,iii,0,1);
224 224
225 } 225 }
226 // KPrefsDialogWidBool *sb; //#ifndef DESKTOP_VERSION 226 // KPrefsDialogWidBool *sb; //#ifndef DESKTOP_VERSION
227#if 0 227#if 0
228 ++iii; 228 ++iii;
229 sb = 229 sb =
230 addWidBool(i18n("Quick load/save (w/o Unicode)"), 230 addWidBool(i18n("Quick load/save (w/o Unicode)"),
231 &(KOPrefs::instance()->mUseQuicksave),topFrame); 231 &(KOPrefs::instance()->mUseQuicksave),topFrame);
232 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 232 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
233#endif 233#endif
234#endif 234#endif
235} 235}
236 236
237void KOPrefsDialog::setupMainTab() 237void KOPrefsDialog::setupMainTab()
238{ 238{
239 QFrame *topFrame = addPage(i18n("General"),0,0); 239 QFrame *topFrame = addPage(i18n("General"),0,0);
240 // DesktopIcon("identity",KIcon::SizeMedium)); 240 // DesktopIcon("identity",KIcon::SizeMedium));
241 241
242 QGridLayout *topLayout = new QGridLayout(topFrame,5,2); 242 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
243 topLayout->setSpacing(mSpacingHint); 243 topLayout->setSpacing(mSpacingHint);
244 topLayout->setMargin(mMarginHint); 244 topLayout->setMargin(mMarginHint);
245 245
246 // KPrefsDialogWidBool *emailControlCenter = 246 // KPrefsDialogWidBool *emailControlCenter =
247// addWidBool(i18n("&Use email settings from Control Center"), 247// addWidBool(i18n("&Use email settings from Control Center"),
248// &(KOPrefs::instance()->mEmailControlCenter),topFrame); 248// &(KOPrefs::instance()->mEmailControlCenter),topFrame);
249// topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); 249// topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1);
250 // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), 250 // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)),
251 // SLOT(toggleEmailSettings(bool))); 251 // SLOT(toggleEmailSettings(bool)));
252 252
253 mNameEdit = new QLineEdit(topFrame); 253 mNameEdit = new QLineEdit(topFrame);
254 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); 254 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
255 topLayout->addWidget(mNameLabel,0,0); 255 topLayout->addWidget(mNameLabel,0,0);
256 topLayout->addWidget(mNameEdit,0,1); 256 topLayout->addWidget(mNameEdit,0,1);
257 257
258 mEmailEdit = new QLineEdit(topFrame); 258 mEmailEdit = new QLineEdit(topFrame);
259 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); 259 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
260 topLayout->addWidget(mEmailLabel,1,0); 260 topLayout->addWidget(mEmailLabel,1,0);
261 topLayout->addWidget(mEmailEdit,1,1); 261 topLayout->addWidget(mEmailEdit,1,1);
262 KPrefsDialogWidBool *wb; 262 KPrefsDialogWidBool *wb;
263 263
264 264
265 265
266 KPrefsDialogWidBool *widbool = addWidBool(i18n("Full menu bar(nr)"), 266 KPrefsDialogWidBool *widbool = addWidBool(i18n("Full menu bar(nr)"),
267 &(KOPrefs::instance()->mShowFullMenu),topFrame); 267 &(KOPrefs::instance()->mShowFullMenu),topFrame);
268 topLayout->addMultiCellWidget( widbool->checkBox(), 2,2,0,1); 268 topLayout->addMultiCellWidget( widbool->checkBox(), 2,2,0,1);
269 269
270 270
271 widbool = addWidBool(i18n("Mini icons in toolbar(nr)"), 271 widbool = addWidBool(i18n("Mini icons in toolbar(nr)"),
272 &(KOPrefs::instance()->mToolBarMiniIcons),topFrame); 272 &(KOPrefs::instance()->mToolBarMiniIcons),topFrame);
273 topLayout->addMultiCellWidget( widbool->checkBox(), 3,3,0,1); 273 topLayout->addMultiCellWidget( widbool->checkBox(), 3,3,0,1);
274 274
275 275
276 KPrefsDialogWidBool *verticalScreen = 276 KPrefsDialogWidBool *verticalScreen =
277 addWidBool(i18n("Show vertical screen (Needs restart)"), 277 addWidBool(i18n("Show vertical screen (Needs restart)"),
278 &(KOPrefs::instance()->mVerticalScreen),topFrame); 278 &(KOPrefs::instance()->mVerticalScreen),topFrame);
279 //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); 279 //topLayout->addWidget(verticalScreen->checkBox(),ii++,0);
280 topLayout->addMultiCellWidget(verticalScreen->checkBox(),4,4,0,1); 280 topLayout->addMultiCellWidget(verticalScreen->checkBox(),4,4,0,1);
281 281
282 282
283 int iii = 5; 283 int iii = 5;
284 widbool = addWidBool(i18n("Block popup until mouse button release"), 284 widbool = addWidBool(i18n("Block popup until mouse button release"),
285 &(KOPrefs::instance()->mBlockPopupMenu),topFrame); 285 &(KOPrefs::instance()->mBlockPopupMenu),topFrame);
286 topLayout->addMultiCellWidget( widbool->checkBox(), iii,iii,0,1); 286 topLayout->addMultiCellWidget( widbool->checkBox(), iii,iii,0,1);
287 ++iii; 287 ++iii;
288 if ( QApplication::desktop()->height() <= 240 ) { 288 if ( QApplication::desktop()->height() <= 240 ) {
289 topFrame = addPage(i18n("General") +" 2",0,0); 289 topFrame = addPage(i18n("General") +" 2",0,0);
290 topLayout = new QGridLayout(topFrame,4,2); 290 topLayout = new QGridLayout(topFrame,4,2);
291 topLayout->setSpacing(2); 291 topLayout->setSpacing(2);
292 topLayout->setMargin(3); 292 topLayout->setMargin(3);
293 iii = 0; 293 iii = 0;
294 } 294 }
295 QHBox *dummy = new QHBox(topFrame); 295 QHBox *dummy = new QHBox(topFrame);
296 new QLabel(i18n("Days in Next-X-Days:"),dummy); 296 new QLabel(i18n("Days in Next-X-Days:"),dummy);
297 mNextXDaysSpin = new QSpinBox(2,14,1,dummy); 297 mNextXDaysSpin = new QSpinBox(2,14,1,dummy);
298 298
299 topLayout->addMultiCellWidget(dummy,iii,iii,0,1); 299 topLayout->addMultiCellWidget(dummy,iii,iii,0,1);
300 300
301 ++iii; 301 ++iii;
302 302
303 303
304 // KPrefsDialogWidBool *bcc = 304 // KPrefsDialogWidBool *bcc =
305// addWidBool(i18n("Send copy to owner when mailing events"), 305// addWidBool(i18n("Send copy to owner when mailing events"),
306// &(KOPrefs::instance()->mBcc),topFrame); 306// &(KOPrefs::instance()->mBcc),topFrame);
307// topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); 307// topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1);
308 308
309 309
310 // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); 310 // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame);
311 //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); 311 //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1);
312 312
313 // addWidBool(i18n("Enable automatic saving of calendar"), 313 // addWidBool(i18n("Enable automatic saving of calendar"),
314 // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); 314 // &(KOPrefs::instance()->mAutoSave),autoSaveGroup);
315 315
316 QHBox *intervalBox = new QHBox(topFrame); 316 QHBox *intervalBox = new QHBox(topFrame);
317 // intervalBox->setSpacing(mSpacingHint); 317 // intervalBox->setSpacing(mSpacingHint);
318 topLayout->addMultiCellWidget(intervalBox,iii,iii,0,1); 318 topLayout->addMultiCellWidget(intervalBox,iii,iii,0,1);
319 ++iii; 319 ++iii;
320 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); 320 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox);
321 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); 321 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox);
322 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); 322 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin);
323 /* 323 /*
324 QHBox * agendasize = new QHBox ( topFrame ); 324 QHBox * agendasize = new QHBox ( topFrame );
325 325
326 new QLabel (i18n("AllDayAgenda Height:"), agendasize ); 326 new QLabel (i18n("AllDayAgenda Height:"), agendasize );
327 327
328 328
329 mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); 329 mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize);
330 topLayout->addMultiCellWidget(agendasize,7,7,0,1); 330 topLayout->addMultiCellWidget(agendasize,7,7,0,1);
331 */ 331 */
332 332
333 333
334 KPrefsDialogWidBool *ask = 334 KPrefsDialogWidBool *ask =
335 addWidBool(i18n("Ask for quit when closing KO/Pi"), 335 addWidBool(i18n("Ask for quit when closing KO/Pi"),
336 &(KOPrefs::instance()->mAskForQuit),topFrame); 336 &(KOPrefs::instance()->mAskForQuit),topFrame);
337 topLayout->addMultiCellWidget(ask->checkBox(),iii,iii,0,1); 337 topLayout->addMultiCellWidget(ask->checkBox(),iii,iii,0,1);
338 ++iii; 338 ++iii;
339 339
340 340
341 /* 341 /*
342 KPrefsDialogWidBool *confirmCheck = 342 KPrefsDialogWidBool *confirmCheck =
343 addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), 343 addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm),
344 topFrame); 344 topFrame);
345 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); 345 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1);
346 346
347 347
348 mEnableGroupScheduling = 348 mEnableGroupScheduling =
349 addWidBool(i18n("Enable group scheduling"), 349 addWidBool(i18n("Enable group scheduling"),
350 &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); 350 &(KOPrefs::instance()->mEnableGroupScheduling),topFrame);
351 topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); 351 topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0);
352 connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), 352 connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()),
353 SLOT(warningGroupScheduling())); 353 SLOT(warningGroupScheduling()));
354 354
355 mEnableProjectView = 355 mEnableProjectView =
356 addWidBool(i18n("Enable project view"), 356 addWidBool(i18n("Enable project view"),
357 &(KOPrefs::instance()->mEnableProjectView),topFrame); 357 &(KOPrefs::instance()->mEnableProjectView),topFrame);
358 topLayout->addWidget(mEnableProjectView->checkBox(),9,0); 358 topLayout->addWidget(mEnableProjectView->checkBox(),9,0);
359 connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), 359 connect(mEnableProjectView->checkBox(),SIGNAL(clicked()),
360 SLOT(warningProjectView())); 360 SLOT(warningProjectView()));
361 361
362 // Can't be disabled anymore 362 // Can't be disabled anymore
363 mEnableGroupScheduling->checkBox()->hide(); 363 mEnableGroupScheduling->checkBox()->hide();
364 364
365 // Disable setting, because this feature now becomes stable 365 // Disable setting, because this feature now becomes stable
366 mEnableProjectView->checkBox()->hide(); 366 mEnableProjectView->checkBox()->hide();
367 367
368 KPrefsDialogWidRadios *defaultFormatGroup = 368 KPrefsDialogWidRadios *defaultFormatGroup =
369 addWidRadios(i18n("Default Calendar Format"), 369 addWidRadios(i18n("Default Calendar Format"),
370 &(KOPrefs::instance()->mDefaultFormat),topFrame); 370 &(KOPrefs::instance()->mDefaultFormat),topFrame);
371 defaultFormatGroup->addRadio(i18n("vCalendar")); 371 defaultFormatGroup->addRadio(i18n("vCalendar"));
372 defaultFormatGroup->addRadio(i18n("iCalendar")); 372 defaultFormatGroup->addRadio(i18n("iCalendar"));
373 373
374 topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); 374 topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1);
375 375
376 // Default format unconditionally is iCalendar 376 // Default format unconditionally is iCalendar
377 defaultFormatGroup->groupBox()->hide(); 377 defaultFormatGroup->groupBox()->hide();
378 378
379 KPrefsDialogWidRadios *mailClientGroup = 379 KPrefsDialogWidRadios *mailClientGroup =
380 addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), 380 addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient),
381 topFrame); 381 topFrame);
382 mailClientGroup->addRadio(i18n("KMail")); 382 mailClientGroup->addRadio(i18n("KMail"));
383 mailClientGroup->addRadio(i18n("Sendmail")); 383 mailClientGroup->addRadio(i18n("Sendmail"));
384 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); 384 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1);
385 385
386 KPrefsDialogWidBool *htmlsave = 386 KPrefsDialogWidBool *htmlsave =
387 addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), 387 addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave),
388 topFrame); 388 topFrame);
389 topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); 389 topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1);
390 390
391 KPrefsDialogWidRadios *destinationGroup = 391 KPrefsDialogWidRadios *destinationGroup =
392 addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), 392 addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination),
393 topFrame); 393 topFrame);
394 destinationGroup->addRadio(i18n("be added to the standard resource")); 394 destinationGroup->addRadio(i18n("be added to the standard resource"));
395 destinationGroup->addRadio(i18n("be asked which resource to use")); 395 destinationGroup->addRadio(i18n("be asked which resource to use"));
396 topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); 396 topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1);
397 397
398 topLayout->setRowStretch(14,1); 398 topLayout->setRowStretch(14,1);
399 */ 399 */
400} 400}
401 401
402 402
403void KOPrefsDialog::setupTimeTab() 403void KOPrefsDialog::setupTimeTab()
404{ 404{
405 QFrame *topFrame = addPage(i18n("Time"),0,0); 405 QFrame *topFrame = addPage(i18n("Time"),0,0);
406 // DesktopIcon("clock",KIcon::SizeMedium)); 406 // DesktopIcon("clock",KIcon::SizeMedium));
407 407
408 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 408 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
409 topLayout->setSpacing(mSpacingHint); 409 topLayout->setSpacing(mSpacingHint);
410 topLayout->setMargin(mMarginHint); 410 topLayout->setMargin(mMarginHint);
411 411
412 QHBox *dummy = new QHBox(topFrame); 412 QHBox *dummy = new QHBox(topFrame);
413 KPrefsDialogWidTime *dayBegins = 413 KPrefsDialogWidTime *dayBegins =
414 addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), 414 addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
415 dummy); 415 dummy);
416 //topLayout->addWidget(dayBegins->label(),2,0); 416 //topLayout->addWidget(dayBegins->label(),2,0);
417 417
418 //topLayout->addWidget(dayBegins->spinBox(),2,1); 418 //topLayout->addWidget(dayBegins->spinBox(),2,1);
419 topLayout->addMultiCellWidget(dummy,0,0,0,1); 419 topLayout->addMultiCellWidget(dummy,0,0,0,1);
420 420
421 topLayout->addWidget(new QLabel(i18n("Default appointment time:"), 421 topLayout->addWidget(new QLabel(i18n("Default appointment time:"),
422 topFrame),1,0); 422 topFrame),1,0);
423 mStartTimeSpin = new QSpinBox(0,23,1,topFrame); 423 mStartTimeSpin = new QSpinBox(0,23,1,topFrame);
424 mStartTimeSpin->setSuffix(":00"); 424 mStartTimeSpin->setSuffix(":00");
425 topLayout->addWidget(mStartTimeSpin,1,1); 425 topLayout->addWidget(mStartTimeSpin,1,1);
426 426
427 topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), 427 topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"),
428 topFrame),2,0); 428 topFrame),2,0);
429 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); 429 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame);
430 mDefaultDurationSpin->setSuffix(":00"); 430 mDefaultDurationSpin->setSuffix(":00");
431 topLayout->addWidget(mDefaultDurationSpin,2,1); 431 topLayout->addWidget(mDefaultDurationSpin,2,1);
432 432
433 QStringList alarmList; 433 QStringList alarmList;
434 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") 434 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes")
435 << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; 435 << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ;
436 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), 436 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame),
437 3,0); 437 3,0);
438 mAlarmTimeCombo = new QComboBox(topFrame); 438 mAlarmTimeCombo = new QComboBox(topFrame);
439 mAlarmTimeCombo->insertStringList(alarmList); 439 mAlarmTimeCombo->insertStringList(alarmList);
440 topLayout->addWidget(mAlarmTimeCombo,3,1); 440 topLayout->addWidget(mAlarmTimeCombo,3,1);
441 int iii = 4; 441 int iii = 4;
442 if ( QApplication::desktop()->height() <= 240 ) { 442 if ( QApplication::desktop()->height() <= 240 ) {
443 topFrame = addPage(i18n("Time") +" 2",0,0); 443 topFrame = addPage(i18n("Time") +" 2",0,0);
444 topLayout = new QGridLayout(topFrame,1,2); 444 topLayout = new QGridLayout(topFrame,1,2);
445 topLayout->setSpacing(2); 445 topLayout->setSpacing(2);
446 topLayout->setMargin(3); 446 topLayout->setMargin(3);
447 iii = 0; 447 iii = 0;
448 } 448 }
449 449
450 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, 450 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal,
451 i18n("Working Hours"), 451 i18n("Working Hours"),
452 topFrame); 452 topFrame);
453 topLayout->addMultiCellWidget(workingHoursGroup,iii,iii,0,1); 453 topLayout->addMultiCellWidget(workingHoursGroup,iii,iii,0,1);
454 workingHoursGroup->layout()->setSpacing( 0 ); 454 workingHoursGroup->layout()->setSpacing( 0 );
455 workingHoursGroup->layout()->setMargin( 4 ); 455 workingHoursGroup->layout()->setMargin( 4 );
456 QHBox *workStartBox = new QHBox(workingHoursGroup); 456 QHBox *workStartBox = new QHBox(workingHoursGroup);
457 // workStartBox->setMargin( 0 ); 457 // workStartBox->setMargin( 0 );
458 addWidTime(i18n("Daily starting hour:"), 458 addWidTime(i18n("Daily starting hour:"),
459 &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); 459 &(KOPrefs::instance()->mWorkingHoursStart),workStartBox);
460 460
461 QHBox *workEndBox = new QHBox(workingHoursGroup); 461 QHBox *workEndBox = new QHBox(workingHoursGroup);
462 //workEndBox->setMargin( 0 ); 462 //workEndBox->setMargin( 0 );
463 addWidTime(i18n("Daily ending hour:"), 463 addWidTime(i18n("Daily ending hour:"),
464 &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); 464 &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox);
465 QVBox *excludeBox = new QVBox(workingHoursGroup); 465 QVBox *excludeBox = new QVBox(workingHoursGroup);
466 //excludeBox->setMargin( 0 ); 466 //excludeBox->setMargin( 0 );
467 addWidBool(i18n("Exclude holidays"), 467 addWidBool(i18n("Exclude holidays"),
468 &(KOPrefs::instance()->mExcludeHolidays),excludeBox); 468 &(KOPrefs::instance()->mExcludeHolidays),excludeBox);
469 469
470 addWidBool(i18n("Exclude Saturdays"), 470 addWidBool(i18n("Exclude Saturdays"),
471 &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); 471 &(KOPrefs::instance()->mExcludeSaturdays),excludeBox);
472 472
473// KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), 473// KPrefsDialogWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"),
474 // &(KOPrefs::instance()->mMarcusBainsShowSeconds), 474 // &(KOPrefs::instance()->mMarcusBainsShowSeconds),
475 // topFrame); 475 // topFrame);
476// topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); 476// topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0);
477 477
478 // topLayout->setRowStretch(6,1); 478 // topLayout->setRowStretch(6,1);
479} 479}
480 480
481 481
482void KOPrefsDialog::setupViewsTab() 482void KOPrefsDialog::setupViewsTab()
483{ 483{
484 484
485 QFrame *topFrame = addPage(i18n("Views"),0,0); 485 QFrame *topFrame = addPage(i18n("Views"),0,0);
486 // DesktopIcon("viewmag",KIcon::SizeMedium)); 486 // DesktopIcon("viewmag",KIcon::SizeMedium));
487 487
488 QGridLayout *topLayout = new QGridLayout(topFrame,6,1); 488 QGridLayout *topLayout = new QGridLayout(topFrame,6,1);
489 topLayout->setSpacing(mSpacingHint); 489 topLayout->setSpacing(mSpacingHint);
490 topLayout->setMargin(mMarginHint); 490 topLayout->setMargin(mMarginHint);
491 491
492// QBoxLayout *dayBeginsLayout = new QHBoxLayout; 492// QBoxLayout *dayBeginsLayout = new QHBoxLayout;
493// topLayout->addLayout(dayBeginsLayout,0,0); 493// topLayout->addLayout(dayBeginsLayout,0,0);
494 494
495// KPrefsDialogWidTime *dayBegins = 495// KPrefsDialogWidTime *dayBegins =
496// addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), 496// addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
497// topFrame); 497// topFrame);
498// dayBeginsLayout->addWidget(dayBegins->label()); 498// dayBeginsLayout->addWidget(dayBegins->label());
499// dayBeginsLayout->addStretch(1); 499// dayBeginsLayout->addStretch(1);
500// dayBeginsLayout->addWidget(dayBegins->spinBox()); 500// dayBeginsLayout->addWidget(dayBegins->spinBox());
501 501
502// QBoxLayout *nextDaysLayout = new QHBoxLayout; 502// QBoxLayout *nextDaysLayout = new QHBoxLayout;
503// topLayout->addLayout(nextDaysLayout,1,0); 503// topLayout->addLayout(nextDaysLayout,1,0);
504// nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); 504// nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame));
505// mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); 505// mNextXDaysSpin = new QSpinBox(2,14,1,topFrame);
506// nextDaysLayout->addStretch(1); 506// nextDaysLayout->addStretch(1);
507// nextDaysLayout->addWidget(mNextXDaysSpin); 507// nextDaysLayout->addWidget(mNextXDaysSpin);
508 508
509 509
510 int ii = 0; 510 int ii = 0;
511 KPrefsDialogWidBool *dummy = 511 KPrefsDialogWidBool *dummy =
512 addWidBool(i18n("Edit item on doubleclick (if not, show)"), 512 addWidBool(i18n("Edit item on doubleclick (if not, show)"),
513 &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); 513 &(KOPrefs::instance()->mEditOnDoubleClick),topFrame);
514 topLayout->addWidget(dummy->checkBox(),ii++,0); 514 topLayout->addWidget(dummy->checkBox(),ii++,0);
515 515
516 516
517 517
518 518
519 519
520 520
521 // topLayout->addWidget(hourSizeGroup,ii++,0); 521 // topLayout->addWidget(hourSizeGroup,ii++,0);
522 // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); 522 // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0);
523 //topLayout->setRowStretch(11,1); 523 //topLayout->setRowStretch(11,1);
524 524
525 525
526 526
527 527
528#if 0 528#if 0
529 529
530 topFrame = addPage(i18n("ViewChange"),0,0); 530 topFrame = addPage(i18n("ViewChange"),0,0);
531 // DesktopIcon("viewmag",KIcon::SizeMedium)); 531 // DesktopIcon("viewmag",KIcon::SizeMedium));
532 532
533 topLayout = new QGridLayout(topFrame,6,1); 533 topLayout = new QGridLayout(topFrame,6,1);
534 topLayout->setSpacing(mSpacingHint); 534 topLayout->setSpacing(mSpacingHint);
535 topLayout->setMargin(mMarginHint); 535 topLayout->setMargin(mMarginHint);
536 ii = 0; 536 ii = 0;
537 537
538#endif 538#endif
539 539
540 dummy = 540 dummy =
541 addWidBool(i18n("Hold fullscreen on view change"), 541 addWidBool(i18n("Hold fullscreen on view change"),
542 &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); 542 &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame);
543 topLayout->addWidget(dummy->checkBox(),ii++,0); 543 topLayout->addWidget(dummy->checkBox(),ii++,0);
544 544
545 dummy = 545 dummy =
546 addWidBool(i18n("Hold non-fullscreen on view change"), 546 addWidBool(i18n("Hold non-fullscreen on view change"),
547 &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); 547 &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame);
548 topLayout->addWidget(dummy->checkBox(),ii++,0); 548 topLayout->addWidget(dummy->checkBox(),ii++,0);
549 549
550 550
551 551
552 KPrefsDialogWidBool *fullViewMonth = 552 KPrefsDialogWidBool *fullViewMonth =
553 addWidBool(i18n("Next days view uses full window"), 553 addWidBool(i18n("Next days view uses full window"),
554 &(KOPrefs::instance()->mFullViewMonth),topFrame); 554 &(KOPrefs::instance()->mFullViewMonth),topFrame);
555 topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); 555 topLayout->addWidget(fullViewMonth->checkBox(),ii++,0);
556 556
557 557
558 KPrefsDialogWidBool *fullViewTodo = 558 KPrefsDialogWidBool *fullViewTodo =
559 addWidBool(i18n("Event list view uses full window"), 559 addWidBool(i18n("Event list view uses full window"),
560 &(KOPrefs::instance()->mFullViewTodo),topFrame); 560 &(KOPrefs::instance()->mFullViewTodo),topFrame);
561 topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); 561 topLayout->addWidget(fullViewTodo->checkBox(),ii++,0);
562 dummy = 562 dummy =
563 addWidBool(i18n("Listview uses monthly timespan"), 563 addWidBool(i18n("Listview uses monthly timespan"),
564 &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); 564 &(KOPrefs::instance()->mListViewMonthTimespan),topFrame);
565 topLayout->addWidget(dummy->checkBox(),ii++,0); 565 topLayout->addWidget(dummy->checkBox(),ii++,0);
566 dummy = 566 dummy =
567 addWidBool(i18n("Highlight selection in Time Edit"), 567 addWidBool(i18n("Highlight selection in Time Edit"),
568 &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); 568 &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame);
569 topLayout->addWidget( dummy->checkBox(), ii++,0); 569 topLayout->addWidget( dummy->checkBox(), ii++,0);
570 570
571 KPrefsDialogWidBool *dailyRecur = 571 KPrefsDialogWidBool *dailyRecur =
572 addWidBool(i18n("Show events that recur daily in date nav."), 572 addWidBool(i18n("Show events that recur daily in date nav."),
573 &(KOPrefs::instance()->mDailyRecur),topFrame); 573 &(KOPrefs::instance()->mDailyRecur),topFrame);
574 topLayout->addWidget(dailyRecur->checkBox(),ii++,0); 574 topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
575 575
576 KPrefsDialogWidBool *weeklyRecur = 576 KPrefsDialogWidBool *weeklyRecur =
577 addWidBool(i18n("Show ev. that recur weekly in date nav."), 577 addWidBool(i18n("Show ev. that recur weekly in date nav."),
578 &(KOPrefs::instance()->mWeeklyRecur),topFrame); 578 &(KOPrefs::instance()->mWeeklyRecur),topFrame);
579 topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); 579 topLayout->addWidget(weeklyRecur->checkBox(),ii++,0);
580 580
581#ifdef DESKTOP_VERSION 581#ifdef DESKTOP_VERSION
582 KPrefsDialogWidBool *enableToolTips = 582 KPrefsDialogWidBool *enableToolTips =
583 addWidBool(i18n("Enable tooltips displaying summary of ev."), 583 addWidBool(i18n("Enable tooltips displaying summary of ev."),
584 &(KOPrefs::instance()->mEnableToolTips),topFrame); 584 &(KOPrefs::instance()->mEnableToolTips),topFrame);
585 topLayout->addWidget(enableToolTips->checkBox(),ii++,0); 585 topLayout->addWidget(enableToolTips->checkBox(),ii++,0);
586#endif 586#endif
587 // ********************************************************* 587 // *********************************************************
588 588
589 topFrame = addPage(i18n("Agenda View"),0,0); 589 topFrame = addPage(i18n("Agenda View"),0,0);
590 // DesktopIcon("viewmag",KIcon::SizeMedium)); 590 // DesktopIcon("viewmag",KIcon::SizeMedium));
591 591
592 topLayout = new QGridLayout(topFrame,5,1); 592 topLayout = new QGridLayout(topFrame,5,1);
593 topLayout->setSpacing(mSpacingHint); 593 topLayout->setSpacing(mSpacingHint);
594 topLayout->setMargin(mMarginHint); 594 topLayout->setMargin(mMarginHint);
595 ii = 0; 595 ii = 0;
596 596
597 597
598 dummy = 598 dummy =
599 addWidBool(i18n("Show time in agenda items"), 599 addWidBool(i18n("Show time in agenda items"),
600 &(KOPrefs::instance()->mShowTimeInAgenda),topFrame); 600 &(KOPrefs::instance()->mShowTimeInAgenda),topFrame);
601 topLayout->addWidget(dummy->checkBox(),ii++,0); 601 topLayout->addWidget(dummy->checkBox(),ii++,0);
602 602
603 dummy = 603 dummy =
604 addWidBool(i18n("Highlight current day in agenda"), 604 addWidBool(i18n("Highlight current day in agenda"),
605 &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); 605 &(KOPrefs::instance()->mHighlightCurrentDay),topFrame);
606 topLayout->addWidget(dummy->checkBox(),ii++,0); 606 topLayout->addWidget(dummy->checkBox(),ii++,0);
607 607
608 dummy = 608 dummy =
609 addWidBool(i18n("Use light color for highlight current day"), 609 addWidBool(i18n("Use light color for highlight current day"),
610 &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); 610 &(KOPrefs::instance()->mUseHighlightLightColor),topFrame);
611 topLayout->addWidget(dummy->checkBox(),ii++,0); 611 topLayout->addWidget(dummy->checkBox(),ii++,0);
612 612
613 613
614 KPrefsDialogWidBool *marcusBainsEnabled = 614 KPrefsDialogWidBool *marcusBainsEnabled =
615 addWidBool(i18n("Show current time"), 615 addWidBool(i18n("Show current time"),
616 &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); 616 &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame);
617 topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); 617 topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0);
618 618
619 619
620 dummy = 620 dummy =
621 addWidBool(i18n("Set agenda to DayBeginsAt on change"), 621 addWidBool(i18n("Set agenda to DayBeginsAt on change"),
622 &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); 622 &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame);
623 topLayout->addWidget(dummy->checkBox(),ii++,0); 623 topLayout->addWidget(dummy->checkBox(),ii++,0);
624 624
625 dummy = 625 dummy =
626 addWidBool(i18n("Set agenda to current time on change"), 626 addWidBool(i18n("Set agenda to current time on change"),
627 &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); 627 &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame);
628 topLayout->addWidget(dummy->checkBox(),ii++,0); 628 topLayout->addWidget(dummy->checkBox(),ii++,0);
629 629
630 630
631 dummy = 631 dummy =
632 addWidBool(i18n("Allday Agenda view shows todos"), 632 addWidBool(i18n("Allday Agenda view shows todos"),
633 &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); 633 &(KOPrefs::instance()->mShowTodoInAgenda),topFrame);
634 topLayout->addWidget(dummy->checkBox(),ii++,0); 634 topLayout->addWidget(dummy->checkBox(),ii++,0);
635 635
636 636
637 637
638 dummy = 638 dummy =
639 addWidBool(i18n("Agenda view shows completed todos"), 639 addWidBool(i18n("Agenda view shows completed todos"),
640 &(KOPrefs::instance()->mShowCompletedTodoInAgenda),topFrame); 640 &(KOPrefs::instance()->mShowCompletedTodoInAgenda),topFrame);
641 topLayout->addWidget(dummy->checkBox(),ii++,0); 641 topLayout->addWidget(dummy->checkBox(),ii++,0);
642 642
643 643
644 644
645 645
646 646
647 topFrame = addPage(i18n("Month View"),0,0); 647 topFrame = addPage(i18n("Month View"),0,0);
648 // DesktopIcon("viewmag",KIcon::SizeMedium)); 648 // DesktopIcon("viewmag",KIcon::SizeMedium));
649 649
650 topLayout = new QGridLayout(topFrame,5,1); 650 topLayout = new QGridLayout(topFrame,5,1);
651 topLayout->setSpacing(mSpacingHint); 651 topLayout->setSpacing(mSpacingHint);
652 topLayout->setMargin(mMarginHint); 652 topLayout->setMargin(mMarginHint);
653 ii = 0; 653 ii = 0;
654 QLabel *lab; 654 QLabel *lab;
655 QHBox *habo = new QHBox( topFrame ); 655 QHBox *habo = new QHBox( topFrame );
656 if ( QApplication::desktop()->width() <= 480 ) { 656 if ( QApplication::desktop()->width() <= 480 ) {
657 lab = new QLabel ( i18n("Show events that recur "), topFrame ); 657 lab = new QLabel ( i18n("Show events that recur "), topFrame );
658 topLayout->addMultiCellWidget(lab,ii, ii,0,1); 658 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
659 ii++; 659 ii++;
660 } else { 660 } else {
661 new QLabel ( i18n("Show events that recur "), habo ); 661 new QLabel ( i18n("Show events that recur "), habo );
662 } 662 }
663 dailyRecur = 663 dailyRecur =
664 addWidBool(i18n("daily"), 664 addWidBool(i18n("daily"),
665 &(KOPrefs::instance()->mMonthDailyRecur),habo); 665 &(KOPrefs::instance()->mMonthDailyRecur),habo);
666 // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); 666 // topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
667 667
668 weeklyRecur = 668 weeklyRecur =
669 addWidBool(i18n("weekly"), 669 addWidBool(i18n("weekly"),
670 &(KOPrefs::instance()->mMonthWeeklyRecur),habo); 670 &(KOPrefs::instance()->mMonthWeeklyRecur),habo);
671 topLayout->addMultiCellWidget(habo,ii, ii,0,1); 671 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
672 ii++; 672 ii++;
673 673
674 674
675 habo = new QHBox( topFrame ); 675 habo = new QHBox( topFrame );
676 if ( QApplication::desktop()->width() <= 480 ) { 676 if ( QApplication::desktop()->width() <= 480 ) {
677 lab = new QLabel (i18n("Show in every cell ") , topFrame ); 677 lab = new QLabel (i18n("Show in every cell ") , topFrame );
678 topLayout->addMultiCellWidget(lab,ii, ii,0,1); 678 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
679 ii++; 679 ii++;
680 680
681 } else { 681 } else {
682 new QLabel ( i18n("Show in every cell "), habo ); 682 new QLabel ( i18n("Show in every cell "), habo );
683 } 683 }
684 weeklyRecur = 684 weeklyRecur =
685 addWidBool(i18n("short month"), 685 addWidBool(i18n("short month"),
686 &(KOPrefs::instance()->mMonthShowShort),habo); 686 &(KOPrefs::instance()->mMonthShowShort),habo);
687 weeklyRecur = 687 weeklyRecur =
688 addWidBool(i18n("icons"), 688 addWidBool(i18n("icons"),
689 &(KOPrefs::instance()->mMonthShowIcons),habo); 689 &(KOPrefs::instance()->mMonthShowIcons),habo);
690 weeklyRecur = 690 weeklyRecur =
691 addWidBool(i18n("times"), 691 addWidBool(i18n("times"),
692 &(KOPrefs::instance()->mMonthShowTimes),habo); 692 &(KOPrefs::instance()->mMonthShowTimes),habo);
693 topLayout->addMultiCellWidget(habo,ii, ii,0,1); 693 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
694 ii++; 694 ii++;
695#ifdef DESKTOP_VERSION 695#ifdef DESKTOP_VERSION
696 KPrefsDialogWidBool *enableMonthScroll = 696 KPrefsDialogWidBool *enableMonthScroll =
697 addWidBool(i18n("Enable scrollbars in month view cells"), 697 addWidBool(i18n("Enable scrollbars in month view cells"),
698 &(KOPrefs::instance()->mEnableMonthScroll),topFrame); 698 &(KOPrefs::instance()->mEnableMonthScroll),topFrame);
699 topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); 699 topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0);
700#endif 700#endif
701 dummy = 701 dummy =
702 addWidBool(i18n("Week view mode uses bigger font"), 702 addWidBool(i18n("Week view mode uses bigger font"),
703 &(KOPrefs::instance()->mMonthViewUsesBigFont),topFrame); 703 &(KOPrefs::instance()->mMonthViewUsesBigFont),topFrame);
704 topLayout->addWidget(dummy->checkBox(),ii++,0); 704 topLayout->addWidget(dummy->checkBox(),ii++,0);
705 dummy = 705 dummy =
706 addWidBool(i18n("Show Sat/Sun together"), 706 addWidBool(i18n("Show Sat/Sun together"),
707 &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); 707 &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame);
708 topLayout->addWidget(dummy->checkBox(),ii++,0); 708 topLayout->addWidget(dummy->checkBox(),ii++,0);
709 709
710 KPrefsDialogWidBool *coloredCategoriesInMonthView = 710 KPrefsDialogWidBool *coloredCategoriesInMonthView =
711 addWidBool(i18n("Month view uses category colors"), 711 addWidBool(i18n("Month view uses category colors"),
712 &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); 712 &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame);
713 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); 713 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
714 714
715 dummy = 715 dummy =
716 addWidBool(i18n("Category colors are applied to text"), 716 addWidBool(i18n("Category colors are applied to text"),
717 &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); 717 &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame);
718 topLayout->addWidget(dummy->checkBox(),ii++,0); 718 topLayout->addWidget(dummy->checkBox(),ii++,0);
719 719
720 720
721 721
722 if ( QApplication::desktop()->height() <= 240 ) { 722 if ( QApplication::desktop()->height() <= 240 ) {
723 topFrame = addPage(i18n("Month View") +" 2",0,0); 723 topFrame = addPage(i18n("Month View") +" 2",0,0);
724 topLayout = new QGridLayout(topFrame,4,1); 724 topLayout = new QGridLayout(topFrame,4,1);
725 topLayout->setSpacing(2); 725 topLayout->setSpacing(2);
726 topLayout->setMargin(1); 726 topLayout->setMargin(1);
727 ii = 0; 727 ii = 0;
728 } 728 }
729 729
730 730
731 coloredCategoriesInMonthView = 731 coloredCategoriesInMonthView =
732 addWidBool(i18n("Month view uses day colors"), 732 addWidBool(i18n("Month view uses day colors"),
733 &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); 733 &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame);
734 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); 734 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
735 735
736 KPrefsDialogWidColor *holidayColor = 736 KPrefsDialogWidColor *holidayColor =
737 addWidColor(i18n("Day color odd months"), 737 addWidColor(i18n("Day color odd months"),
738 &(KOPrefs::instance()->mMonthViewOddColor),topFrame); 738 &(KOPrefs::instance()->mMonthViewOddColor),topFrame);
739 topLayout->addWidget(holidayColor->label(),ii,0); 739 topLayout->addWidget(holidayColor->label(),ii,0);
740 topLayout->addWidget(holidayColor->button(),ii++,1); 740 topLayout->addWidget(holidayColor->button(),ii++,1);
741 741
742 holidayColor = 742 holidayColor =
743 addWidColor(i18n("Day color even months"), 743 addWidColor(i18n("Day color even months"),
744 &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); 744 &(KOPrefs::instance()->mMonthViewEvenColor),topFrame);
745 topLayout->addWidget(holidayColor->label(),ii,0); 745 topLayout->addWidget(holidayColor->label(),ii,0);
746 topLayout->addWidget(holidayColor->button(),ii++,1); 746 topLayout->addWidget(holidayColor->button(),ii++,1);
747 747
748 748
749 holidayColor = 749 holidayColor =
750 addWidColor(i18n("Color for Sundays + category \"Holiday\""), 750 addWidColor(i18n("Color for Sundays + category \"Holiday\""),
751 &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); 751 &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame);
752 topLayout->addWidget(holidayColor->label(),ii,0); 752 topLayout->addWidget(holidayColor->label(),ii,0);
753 topLayout->addWidget(holidayColor->button(),ii++,1); 753 topLayout->addWidget(holidayColor->button(),ii++,1);
754 // *********************** What'sNext View 754 // *********************** What'sNext View
755 topFrame = addPage(i18n("What's Next View"),0,0); 755 topFrame = addPage(i18n("What's Next View"),0,0);
756 // DesktopIcon("viewmag",KIcon::SizeMedium)); 756 // DesktopIcon("viewmag",KIcon::SizeMedium));
757 757
758 topLayout = new QGridLayout(topFrame,4,1); 758 topLayout = new QGridLayout(topFrame,4,1);
759 topLayout->setSpacing(mSpacingHint); 759 topLayout->setSpacing(mSpacingHint);
760 topLayout->setMargin(mMarginHint); 760 topLayout->setMargin(mMarginHint);
761 ii = 0; 761 ii = 0;
762 762
763 763
764 QHBox* hdummy = new QHBox(topFrame); 764 QHBox* hdummy = new QHBox(topFrame);
765 new QLabel(i18n("Days in What's Next:"),hdummy); 765 new QLabel(i18n("Days in What's Next:"),hdummy);
766 mWhatsNextSpin = new QSpinBox(1,14,1,hdummy); 766 mWhatsNextSpin = new QSpinBox(1,14,1,hdummy);
767 767
768 topLayout->addWidget(hdummy,ii++,0); 768 topLayout->addWidget(hdummy,ii++,0);
769 769
770 QHBox *prioBox = new QHBox(topFrame); 770 QHBox *prioBox = new QHBox(topFrame);
771 // intervalBox->setSpacing(mSpacingHint); 771 // intervalBox->setSpacing(mSpacingHint);
772 topLayout->addWidget(prioBox,ii++,0); 772 topLayout->addWidget(prioBox,ii++,0);
773 773
774 QLabel *prioLabel = new QLabel(i18n("Number of max.displayed todo prios:"), prioBox); 774 QLabel *prioLabel = new QLabel(i18n("Number of max.displayed todo prios:"), prioBox);
775 mPrioSpin = new QSpinBox(0,5,1,prioBox); 775 mPrioSpin = new QSpinBox(0,5,1,prioBox);
776 if ( QApplication::desktop()->width() < 300 ) 776 if ( QApplication::desktop()->width() < 300 )
777 mPrioSpin->setFixedWidth( 40 ); 777 mPrioSpin->setFixedWidth( 40 );
778 778
779 KPrefsDialogWidBool *passwdk = 779 KPrefsDialogWidBool *passwdk =
780 780
781 addWidBool(i18n("Show events that are done"), 781 addWidBool(i18n("Show events that are done"),
782 &(KOPrefs::instance()->mWNViewShowsPast),topFrame); 782 &(KOPrefs::instance()->mWNViewShowsPast),topFrame);
783 topLayout->addWidget(passwdk->checkBox(), ii++,0); 783 topLayout->addWidget(passwdk->checkBox(), ii++,0);
784 passwdk = 784 passwdk =
785 addWidBool(i18n("Show parent To-Do's"), 785 addWidBool(i18n("Show parent To-Do's"),
786 &(KOPrefs::instance()->mWNViewShowsParents),topFrame); 786 &(KOPrefs::instance()->mWNViewShowsParents),topFrame);
787 topLayout->addWidget(passwdk->checkBox(), ii++,0); 787 topLayout->addWidget(passwdk->checkBox(), ii++,0);
788 788
789 passwdk = 789 passwdk =
790 addWidBool(i18n("Show location"), 790 addWidBool(i18n("Show location"),
791 &(KOPrefs::instance()->mWNViewShowLocation),topFrame); 791 &(KOPrefs::instance()->mWNViewShowLocation),topFrame);
792 topLayout->addWidget(passwdk->checkBox(), ii++,0); 792 topLayout->addWidget(passwdk->checkBox(), ii++,0);
793 793
794 794
795 passwdk = 795 passwdk =
796 addWidBool(i18n("Use short date in WN+Event view"), 796 addWidBool(i18n("Use short date in WN+Event view"),
797 &(KOPrefs::instance()->mShortDateInViewer),topFrame); 797 &(KOPrefs::instance()->mShortDateInViewer),topFrame);
798 topLayout->addWidget(passwdk->checkBox(), ii++,0); 798 topLayout->addWidget(passwdk->checkBox(), ii++,0);
799 799
800 800
801 801
802 802
803 // *********************** Todo View 803 // *********************** Todo View
804 804
805 topFrame = addPage(i18n("Todo View"),0,0); 805 topFrame = addPage(i18n("Todo View"),0,0);
806 // DesktopIcon("viewmag",KIcon::SizeMedium)); 806 // DesktopIcon("viewmag",KIcon::SizeMedium));
807 807
808 topLayout = new QGridLayout(topFrame,4,1); 808 topLayout = new QGridLayout(topFrame,4,1);
809 topLayout->setSpacing(mSpacingHint); 809 topLayout->setSpacing(mSpacingHint);
810 topLayout->setMargin(mMarginHint); 810 topLayout->setMargin(mMarginHint);
811 ii = 0; 811 ii = 0;
812dummy = 812dummy =
813 addWidBool(i18n("Hide not running Todos in To-do view"), 813 addWidBool(i18n("Hide not running Todos in To-do view"),
814 &(KOPrefs::instance()->mHideNonStartedTodos),topFrame); 814 &(KOPrefs::instance()->mHideNonStartedTodos),topFrame);
815 topLayout->addWidget(dummy->checkBox(),ii++,0); 815 topLayout->addWidget(dummy->checkBox(),ii++,0);
816 816
817 817
818 KPrefsDialogWidBool *showCompletedTodo = 818 KPrefsDialogWidBool *showCompletedTodo =
819 addWidBool(i18n("To-do view shows completed Todos"), 819 addWidBool(i18n("To-do view shows completed Todos"),
820 &(KOPrefs::instance()->mShowCompletedTodo),topFrame); 820 &(KOPrefs::instance()->mShowCompletedTodo),topFrame);
821 topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); 821 topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0);
822 dummy = 822 dummy =
823 addWidBool(i18n("To-do view shows complete as 'xx %'"), 823 addWidBool(i18n("To-do view shows complete as 'xx %'"),
824 &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); 824 &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame);
825 topLayout->addWidget(dummy->checkBox(),ii++,0); 825 topLayout->addWidget(dummy->checkBox(),ii++,0);
826 826
827 dummy = 827 dummy =
828 addWidBool(i18n("Small To-do view uses smaller font"), 828 addWidBool(i18n("Small To-do view uses smaller font"),
829 &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); 829 &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame);
830 topLayout->addWidget(dummy->checkBox(),ii++,0); 830 topLayout->addWidget(dummy->checkBox(),ii++,0);
831 831
832 832
833 833
834 dummy = 834 dummy =
835 addWidBool(i18n("Todo view uses category colors"), 835 addWidBool(i18n("Todo view uses category colors"),
836 &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); 836 &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame);
837 topLayout->addWidget(dummy->checkBox(),ii++,0); 837 topLayout->addWidget(dummy->checkBox(),ii++,0);
838 838
839 839
840 QWidget* wid = new QWidget( topFrame ); 840 QWidget* wid = new QWidget( topFrame );
841 // Todo run today color 841 // Todo run today color
842 KPrefsDialogWidColor *todoRunColor = 842 KPrefsDialogWidColor *todoRunColor =
843 addWidColor(i18n("Color for running todos:"), 843 addWidColor(i18n("Color for running todos:"),
844 &(KOPrefs::instance()->mTodoRunColor),wid); 844 &(KOPrefs::instance()->mTodoRunColor),wid);
845 QHBoxLayout *widLayout = new QHBoxLayout(wid); 845 QHBoxLayout *widLayout = new QHBoxLayout(wid);
846 widLayout->addWidget( todoRunColor->label() ); 846 widLayout->addWidget( todoRunColor->label() );
847 widLayout->addWidget( todoRunColor->button() ); 847 widLayout->addWidget( todoRunColor->button() );
848 topLayout->addWidget(wid,ii++,0); 848 topLayout->addWidget(wid,ii++,0);
849 849
850 wid = new QWidget( topFrame ); 850 wid = new QWidget( topFrame );
851 // Todo due today color 851 // Todo due today color
852 KPrefsDialogWidColor *todoDueTodayColor = 852 KPrefsDialogWidColor *todoDueTodayColor =
853 addWidColor(i18n("Todo due today color:"), 853 addWidColor(i18n("Todo due today color:"),
854 &(KOPrefs::instance()->mTodoDueTodayColor),wid); 854 &(KOPrefs::instance()->mTodoDueTodayColor),wid);
855 widLayout = new QHBoxLayout(wid); 855 widLayout = new QHBoxLayout(wid);
856 widLayout->addWidget( todoDueTodayColor->label() ); 856 widLayout->addWidget( todoDueTodayColor->label() );
857 widLayout->addWidget( todoDueTodayColor->button() ); 857 widLayout->addWidget( todoDueTodayColor->button() );
858 topLayout->addWidget(wid,ii++,0); 858 topLayout->addWidget(wid,ii++,0);
859 //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); 859 //topLayout->addWidget(todoDueTodayColor->button(),ii++,1);
860 860
861 // Todo overdue color 861 // Todo overdue color
862 wid = new QWidget( topFrame ); 862 wid = new QWidget( topFrame );
863 widLayout = new QHBoxLayout(wid); 863 widLayout = new QHBoxLayout(wid);
864 KPrefsDialogWidColor *todoOverdueColor = 864 KPrefsDialogWidColor *todoOverdueColor =
865 addWidColor(i18n("Todo overdue color:"), 865 addWidColor(i18n("Todo overdue color:"),
866 &(KOPrefs::instance()->mTodoOverdueColor),wid); 866 &(KOPrefs::instance()->mTodoOverdueColor),wid);
867 widLayout->addWidget(todoOverdueColor->label()); 867 widLayout->addWidget(todoOverdueColor->label());
868 widLayout->addWidget(todoOverdueColor->button()); 868 widLayout->addWidget(todoOverdueColor->button());
869 topLayout->addWidget(wid,ii++,0); 869 topLayout->addWidget(wid,ii++,0);
870 870
871 dummy = 871 dummy =
872 addWidBool(i18n("Colors are applied to text"), 872 addWidBool(i18n("Colors are applied to text"),
873 &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); 873 &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame);
874 topLayout->addWidget(dummy->checkBox(),ii++,0); 874 topLayout->addWidget(dummy->checkBox(),ii++,0);
875 875
876 876
877 877
878 topFrame = addPage(i18n("View Options"),0,0); 878 topFrame = addPage(i18n("View Options"),0,0);
879 879
880 topLayout = new QGridLayout(topFrame,4,1); 880 topLayout = new QGridLayout(topFrame,4,1);
881 topLayout->setSpacing(mSpacingHint); 881 topLayout->setSpacing(mSpacingHint);
882 topLayout->setMargin(mMarginHint); 882 topLayout->setMargin(mMarginHint);
883 ii = 0; 883 ii = 0;
884 884
885 dummy = 885 dummy =
886 addWidBool(i18n("Show Sync Events"), 886 addWidBool(i18n("Show Sync Events"),
887 &(KOPrefs::instance()->mShowSyncEvents),topFrame); 887 &(KOPrefs::instance()->mShowSyncEvents),topFrame);
888 topLayout->addWidget(dummy->checkBox(), ii++,0); 888 topLayout->addWidget(dummy->checkBox(), ii++,0);
889 889
890 lab = new QLabel( i18n("Show in todo/event viewer:"), topFrame); 890 lab = new QLabel( i18n("Show in todo/event viewer:"), topFrame);
891 topLayout->addWidget(lab ,ii++,0); 891 topLayout->addWidget(lab ,ii++,0);
892 892
893 dummy = addWidBool(i18n("Details"), 893 dummy = addWidBool(i18n("Details"),
894 &(KOPrefs::instance()->mEVshowDetails),topFrame); 894 &(KOPrefs::instance()->mEVshowDetails),topFrame);
895 topLayout->addWidget(dummy->checkBox(),ii++,0); 895 topLayout->addWidget(dummy->checkBox(),ii++,0);
896 dummy = addWidBool(i18n("Created time"), 896 dummy = addWidBool(i18n("Created time"),
897 &(KOPrefs::instance()->mEVshowCreated),topFrame); 897 &(KOPrefs::instance()->mEVshowCreated),topFrame);
898 topLayout->addWidget(dummy->checkBox(),ii++,0); 898 topLayout->addWidget(dummy->checkBox(),ii++,0);
899 dummy = addWidBool(i18n("Last modified time"), 899 dummy = addWidBool(i18n("Last modified time"),
900 &(KOPrefs::instance()->mEVshowChanged),topFrame); 900 &(KOPrefs::instance()->mEVshowChanged),topFrame);
901 topLayout->addWidget(dummy->checkBox(),ii++,0); 901 topLayout->addWidget(dummy->checkBox(),ii++,0);
902 902
903 903
904 lab = new QLabel( i18n("Show in What'sThis quick overview:"), topFrame); 904 lab = new QLabel( i18n("Show in What'sThis quick overview:"), topFrame);
905 topLayout->addWidget(lab ,ii++,0); 905 topLayout->addWidget(lab ,ii++,0);
906 906
907 dummy = addWidBool(i18n("Details"), 907 dummy = addWidBool(i18n("Details"),
908 &(KOPrefs::instance()->mWTshowDetails),topFrame); 908 &(KOPrefs::instance()->mWTshowDetails),topFrame);
909 topLayout->addWidget(dummy->checkBox(),ii++,0); 909 topLayout->addWidget(dummy->checkBox(),ii++,0);
910 dummy = addWidBool(i18n("Created time"), 910 dummy = addWidBool(i18n("Created time"),
911 &(KOPrefs::instance()->mWTshowCreated),topFrame); 911 &(KOPrefs::instance()->mWTshowCreated),topFrame);
912 topLayout->addWidget(dummy->checkBox(),ii++,0); 912 topLayout->addWidget(dummy->checkBox(),ii++,0);
913 dummy = addWidBool(i18n("Last modified time"), 913 dummy = addWidBool(i18n("Last modified time"),
914 &(KOPrefs::instance()->mWTshowChanged),topFrame); 914 &(KOPrefs::instance()->mWTshowChanged),topFrame);
915 topLayout->addWidget(dummy->checkBox(),ii++,0); 915 topLayout->addWidget(dummy->checkBox(),ii++,0);
916 916
917 917
918 topFrame = addPage(i18n("Alarm"),0,0); 918 topFrame = addPage(i18n("Alarm"),0,0);
919 // DesktopIcon("viewmag",KIcon::SizeMedium)); 919 // DesktopIcon("viewmag",KIcon::SizeMedium));
920 920
921 topLayout = new QGridLayout(topFrame,2,1); 921 topLayout = new QGridLayout(topFrame,2,1);
922 topLayout->setSpacing(mSpacingHint); 922 topLayout->setSpacing(mSpacingHint);
923 topLayout->setMargin(mMarginHint); 923 topLayout->setMargin(mMarginHint);
924 int iii = 0; 924 int iii = 0;
925 925
926 dummy = 926 dummy =
927 addWidBool(i18n("Use internal alarm notification"), 927 addWidBool(i18n("Use internal alarm notification"),
928 &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); 928 &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame);
929 topLayout->addWidget(dummy->checkBox(),iii++,0); 929 topLayout->addWidget(dummy->checkBox(),iii++,0);
930 930
931 if ( QApplication::desktop()->height() > 240 ) { 931 if ( QApplication::desktop()->height() > 240 ) {
932 932
933 lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); 933 lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame);
934 934
935 topLayout->addWidget(lab ,iii++,0); 935 topLayout->addWidget(lab ,iii++,0);
936 } 936 }
937#ifndef DESKTOP_VERSION 937#ifndef DESKTOP_VERSION
938 lab->setAlignment( AlignLeft|WordBreak|AlignTop); 938 lab->setAlignment( AlignLeft|WordBreak|AlignTop);
939#else 939#else
940 lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 940 lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
941 lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); 941 lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
942#endif 942#endif
943 943
944 QHBox* dummyBox = new QHBox(topFrame); 944 QHBox* dummyBox = new QHBox(topFrame);
945 new QLabel(i18n("Play beeps count:"),dummyBox); 945 new QLabel(i18n("Play beeps count:"),dummyBox);
946 mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); 946 mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox);
947 topLayout->addWidget(dummyBox,iii++,0); 947 topLayout->addWidget(dummyBox,iii++,0);
948 948
949 dummyBox = new QHBox(topFrame); 949 dummyBox = new QHBox(topFrame);
950 new QLabel(i18n("Beeps interval in sec:"),dummyBox); 950 new QLabel(i18n("Beeps interval in sec:"),dummyBox);
951 mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); 951 mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox);
952 topLayout->addWidget(dummyBox,iii++,0); 952 topLayout->addWidget(dummyBox,iii++,0);
953 953
954 dummyBox = new QHBox(topFrame); 954 dummyBox = new QHBox(topFrame);
955 new QLabel(i18n("Default suspend time in min:"),dummyBox); 955 new QLabel(i18n("Default suspend time in min:"),dummyBox);
956 mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); 956 mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox);
957 topLayout->addWidget(dummyBox,iii++,0); 957 topLayout->addWidget(dummyBox,iii++,0);
958 958
959 dummyBox = new QHBox(topFrame); 959 dummyBox = new QHBox(topFrame);
960 new QLabel(i18n("Auto suspend count:"),dummyBox); 960 new QLabel(i18n("Auto suspend count:"),dummyBox);
961 mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); 961 mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox);
962 topLayout->addWidget(dummyBox,iii++,0); 962 topLayout->addWidget(dummyBox,iii++,0);
963 963
964 964
965 965
966 QHBox* hbo = new QHBox ( topFrame ); 966 QHBox* hbo = new QHBox ( topFrame );
967 mDefaultAlarmFile = new QLineEdit(hbo); 967 mDefaultAlarmFile = new QLineEdit(hbo);
968 QPushButton * loadTemplate = new QPushButton(hbo); 968 QPushButton * loadTemplate = new QPushButton(hbo);
969 QPixmap icon; 969 QPixmap icon;
970 if ( QApplication::desktop()->width() < 321 ) 970 if ( QApplication::desktop()->width() < 321 )
971 icon = SmallIcon("fileimport16"); 971 icon = SmallIcon("fileimport16");
972 else 972 else
973 icon = SmallIcon("fileimport"); 973 icon = SmallIcon("fileimport");
974 loadTemplate->setIconSet (icon ) ; 974 loadTemplate->setIconSet (icon ) ;
975 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); 975 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) );
976 int size = loadTemplate->sizeHint().height(); 976 int size = loadTemplate->sizeHint().height();
977 loadTemplate->setFixedSize( size, size ); 977 loadTemplate->setFixedSize( size, size );
978 //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); 978 //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame);
979 // topLayout->addWidget(lab ,iii++,0); 979 // topLayout->addWidget(lab ,iii++,0);
980 lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); 980 lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame);
981 topLayout->addWidget(lab ,iii++,0); 981 topLayout->addWidget(lab ,iii++,0);
982 topLayout->addWidget(hbo,iii++,0); 982 topLayout->addWidget(hbo,iii++,0);
983 // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); 983 // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame);
984 984
985// topLayout->addWidget(lab ,iii++,0); 985// topLayout->addWidget(lab ,iii++,0);
986// #ifndef DESKTOP_VERSION 986// #ifndef DESKTOP_VERSION
987// lab->setAlignment( AlignLeft|WordBreak|AlignTop); 987// lab->setAlignment( AlignLeft|WordBreak|AlignTop);
988// #else 988// #else
989// lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 989// lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
990// lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); 990// lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
991// #endif 991// #endif
992 992
993 993
994} 994}
995 995
996void KOPrefsDialog::selectSoundFile() 996void KOPrefsDialog::selectSoundFile()
997{ 997{
998 QString fileName = mDefaultAlarmFile->text(); 998 QString fileName = mDefaultAlarmFile->text();
999 fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); 999 fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this );
1000 if ( fileName.length() > 0 ) 1000 if ( fileName.length() > 0 )
1001 mDefaultAlarmFile->setText( fileName ); 1001 mDefaultAlarmFile->setText( fileName );
1002} 1002}
1003void KOPrefsDialog::setupFontsTab() 1003void KOPrefsDialog::setupFontsTab()
1004{ 1004{
1005 1005
1006 QFrame *topFrame = addPage(i18n("Fonts"),0,0); 1006 QFrame *topFrame = addPage(i18n("Fonts"),0,0);
1007 // DesktopIcon("fonts",KIcon::SizeMedium)); 1007 // DesktopIcon("fonts",KIcon::SizeMedium));
1008 1008
1009 QGridLayout *topLayout = new QGridLayout(topFrame,7,3); 1009 QGridLayout *topLayout = new QGridLayout(topFrame,7,3);
1010 topLayout->setSpacing(1); 1010 topLayout->setSpacing(1);
1011 topLayout->setMargin(3); 1011 topLayout->setMargin(3);
1012 KPrefsDialogWidFont * tVFont; 1012 KPrefsDialogWidFont * tVFont;
1013 int i = 0; 1013 int i = 0;
1014 KPrefsDialogWidFont *timeLabelsFont = 1014 KPrefsDialogWidFont *timeLabelsFont =
1015 addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), 1015 addWidFont(i18n("23"),i18n("DateNavigator:(nr)"),
1016 &(KOPrefs::instance()->mDateNavigatorFont),topFrame); 1016 &(KOPrefs::instance()->mDateNavigatorFont),topFrame);
1017 topLayout->addWidget(timeLabelsFont->label(),i,0); 1017 topLayout->addWidget(timeLabelsFont->label(),i,0);
1018 topLayout->addWidget(timeLabelsFont->preview(),i,1); 1018 topLayout->addWidget(timeLabelsFont->preview(),i,1);
1019 topLayout->addWidget(timeLabelsFont->button(),i,2); 1019 topLayout->addWidget(timeLabelsFont->button(),i,2);
1020 ++i; 1020 ++i;
1021 1021
1022 1022
1023 timeLabelsFont = 1023 timeLabelsFont =
1024 addWidFont(i18n("Mon 15"),i18n("Date Labels:"), 1024 addWidFont(i18n("Mon 15"),i18n("Date Labels:"),
1025 &(KOPrefs::instance()->mTimeLabelsFont),topFrame); 1025 &(KOPrefs::instance()->mTimeLabelsFont),topFrame);
1026 topLayout->addWidget(timeLabelsFont->label(),i,0); 1026 topLayout->addWidget(timeLabelsFont->label(),i,0);
1027 topLayout->addWidget(timeLabelsFont->preview(),i,1); 1027 topLayout->addWidget(timeLabelsFont->preview(),i,1);
1028 topLayout->addWidget(timeLabelsFont->button(),i,2); 1028 topLayout->addWidget(timeLabelsFont->button(),i,2);
1029 ++i; 1029 ++i;
1030 1030
1031 KPrefsDialogWidFont *timeBarFont = 1031 KPrefsDialogWidFont *timeBarFont =
1032 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), 1032 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"),
1033 &(KOPrefs::instance()->mTimeBarFont),topFrame); 1033 &(KOPrefs::instance()->mTimeBarFont),topFrame);
1034 topLayout->addWidget(timeBarFont->label(),i,0); 1034 topLayout->addWidget(timeBarFont->label(),i,0);
1035 topLayout->addWidget(timeBarFont->preview(),i,1); 1035 topLayout->addWidget(timeBarFont->preview(),i,1);
1036 topLayout->addWidget(timeBarFont->button(),i,2); 1036 topLayout->addWidget(timeBarFont->button(),i,2);
1037 ++i; 1037 ++i;
1038 1038
1039 1039
1040 KPrefsDialogWidFont *marcusBainsFont = 1040 KPrefsDialogWidFont *marcusBainsFont =
1041 addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), 1041 addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"),
1042 &(KOPrefs::instance()->mMarcusBainsFont),topFrame); 1042 &(KOPrefs::instance()->mMarcusBainsFont),topFrame);
1043 topLayout->addWidget(marcusBainsFont->label(),i,0); 1043 topLayout->addWidget(marcusBainsFont->label(),i,0);
1044 topLayout->addWidget(marcusBainsFont->preview(),i,1); 1044 topLayout->addWidget(marcusBainsFont->preview(),i,1);
1045 topLayout->addWidget(marcusBainsFont->button(),i,2); 1045 topLayout->addWidget(marcusBainsFont->button(),i,2);
1046 ++i; 1046 ++i;
1047 1047
1048 tVFont = 1048 tVFont =
1049 addWidFont(i18n("Summary"),i18n("Event Viewer:"), 1049 addWidFont(i18n("Summary"),i18n("Event Viewer:"),
1050 &(KOPrefs::instance()->mEventViewFont),topFrame); 1050 &(KOPrefs::instance()->mEventViewFont),topFrame);
1051 topLayout->addWidget(tVFont->label(),i,0); 1051 topLayout->addWidget(tVFont->label(),i,0);
1052 topLayout->addWidget(tVFont->preview(),i,1); 1052 topLayout->addWidget(tVFont->preview(),i,1);
1053 topLayout->addWidget(tVFont->button(),i,2); 1053 topLayout->addWidget(tVFont->button(),i,2);
1054 ++i; 1054 ++i;
1055 1055
1056 1056
1057 1057
1058 tVFont = 1058 tVFont =
1059 addWidFont(i18n("Details"),i18n("EditorBox:"), 1059 addWidFont(i18n("Details"),i18n("EditorBox:"),
1060 &(KOPrefs::instance()->mEditBoxFont),topFrame); 1060 &(KOPrefs::instance()->mEditBoxFont),topFrame);
1061 topLayout->addWidget(tVFont->label(),i,0); 1061 topLayout->addWidget(tVFont->label(),i,0);
1062 topLayout->addWidget(tVFont->preview(),i,1); 1062 topLayout->addWidget(tVFont->preview(),i,1);
1063 topLayout->addWidget(tVFont->button(),i,2); 1063 topLayout->addWidget(tVFont->button(),i,2);
1064 ++i; 1064 ++i;
1065 1065
1066 1066
1067 1067
1068 topLayout->setColStretch(1,1); 1068 topLayout->setColStretch(1,1);
1069 topLayout->setRowStretch(4,1); 1069 topLayout->setRowStretch(4,1);
1070 1070
1071 1071
1072 i = 0; 1072 i = 0;
1073 topFrame = addPage(i18n("View Fonts"),0, 1073 topFrame = addPage(i18n("View Fonts"),0,
1074 DesktopIcon("fonts",KIcon::SizeMedium)); 1074 DesktopIcon("fonts",KIcon::SizeMedium));
1075 1075
1076 topLayout = new QGridLayout(topFrame,7,3); 1076 topLayout = new QGridLayout(topFrame,7,3);
1077 topLayout->setSpacing(1); 1077 topLayout->setSpacing(1);
1078 topLayout->setMargin(3); 1078 topLayout->setMargin(3);
1079 1079
1080 tVFont = 1080 tVFont =
1081 addWidFont(i18n("Configure KO"),i18n("What's Next View:"), 1081 addWidFont(i18n("Configure KO"),i18n("What's Next View:"),
1082 &(KOPrefs::instance()->mWhatsNextFont),topFrame); 1082 &(KOPrefs::instance()->mWhatsNextFont),topFrame);
1083 topLayout->addWidget(tVFont->label(),i,0); 1083 topLayout->addWidget(tVFont->label(),i,0);
1084 topLayout->addWidget(tVFont->preview(),i,1); 1084 topLayout->addWidget(tVFont->preview(),i,1);
1085 topLayout->addWidget(tVFont->button(),i,2); 1085 topLayout->addWidget(tVFont->button(),i,2);
1086 ++i; 1086 ++i;
1087 KPrefsDialogWidFont *agendaViewFont = 1087 KPrefsDialogWidFont *agendaViewFont =
1088 addWidFont(i18n("Event text"),i18n("Agenda view:"), 1088 addWidFont(i18n("Event text"),i18n("Agenda view:"),
1089 &(KOPrefs::instance()->mAgendaViewFont),topFrame); 1089 &(KOPrefs::instance()->mAgendaViewFont),topFrame);
1090 topLayout->addWidget(agendaViewFont->label(),i,0); 1090 topLayout->addWidget(agendaViewFont->label(),i,0);
1091 topLayout->addWidget(agendaViewFont->preview(),i,1); 1091 topLayout->addWidget(agendaViewFont->preview(),i,1);
1092 topLayout->addWidget(agendaViewFont->button(),i,2); 1092 topLayout->addWidget(agendaViewFont->button(),i,2);
1093 ++i; 1093 ++i;
1094 1094
1095 1095
1096 KPrefsDialogWidFont *monthViewFont = 1096 KPrefsDialogWidFont *monthViewFont =
1097 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), 1097 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"),
1098 i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); 1098 i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame);
1099 topLayout->addWidget(monthViewFont->label(),i,0); 1099 topLayout->addWidget(monthViewFont->label(),i,0);
1100 topLayout->addWidget(monthViewFont->preview(),i,1); 1100 topLayout->addWidget(monthViewFont->preview(),i,1);
1101 topLayout->addWidget(monthViewFont->button(),i,2); 1101 topLayout->addWidget(monthViewFont->button(),i,2);
1102 ++i; 1102 ++i;
1103 1103
1104 1104
1105 KPrefsDialogWidFont *lVFont = 1105 KPrefsDialogWidFont *lVFont =
1106 addWidFont(i18n("Event"),i18n("List View:"), 1106 addWidFont(i18n("Event"),i18n("List View:"),
1107 &(KOPrefs::instance()->mListViewFont),topFrame); 1107 &(KOPrefs::instance()->mListViewFont),topFrame);
1108 topLayout->addWidget(lVFont->label(),i,0); 1108 topLayout->addWidget(lVFont->label(),i,0);
1109 topLayout->addWidget(lVFont->preview(),i,1); 1109 topLayout->addWidget(lVFont->preview(),i,1);
1110 topLayout->addWidget(lVFont->button(),i,2); 1110 topLayout->addWidget(lVFont->button(),i,2);
1111 ++i; 1111 ++i;
1112 1112
1113 1113
1114 tVFont = 1114 tVFont =
1115 addWidFont(i18n("ToDo"),i18n("ToDoView:"), 1115 addWidFont(i18n("ToDo"),i18n("ToDoView:"),
1116 &(KOPrefs::instance()->mTodoViewFont),topFrame); 1116 &(KOPrefs::instance()->mTodoViewFont),topFrame);
1117 topLayout->addWidget(tVFont->label(),i,0); 1117 topLayout->addWidget(tVFont->label(),i,0);
1118 topLayout->addWidget(tVFont->preview(),i,1); 1118 topLayout->addWidget(tVFont->preview(),i,1);
1119 topLayout->addWidget(tVFont->button(),i,2); 1119 topLayout->addWidget(tVFont->button(),i,2);
1120 ++i; 1120 ++i;
1121 1121
1122 1122
1123 tVFont = 1123 tVFont =
1124 addWidFont(i18n("Today"),i18n("JournalView:"), 1124 addWidFont(i18n("Today"),i18n("JournalView:"),
1125 &(KOPrefs::instance()->mJornalViewFont),topFrame); 1125 &(KOPrefs::instance()->mJornalViewFont),topFrame);
1126 topLayout->addWidget(tVFont->label(),i,0); 1126 topLayout->addWidget(tVFont->label(),i,0);
1127 topLayout->addWidget(tVFont->preview(),i,1); 1127 topLayout->addWidget(tVFont->preview(),i,1);
1128 topLayout->addWidget(tVFont->button(),i,2); 1128 topLayout->addWidget(tVFont->button(),i,2);
1129 ++i; 1129 ++i;
1130 1130
1131 1131
1132 1132
1133 1133
1134 topLayout->setColStretch(1,1); 1134 topLayout->setColStretch(1,1);
1135 topLayout->setRowStretch(4,1); 1135 topLayout->setRowStretch(4,1);
1136 1136
1137 1137
1138 1138
1139 1139
1140} 1140}
1141 1141
1142void KOPrefsDialog::setupColorsTab() 1142void KOPrefsDialog::setupColorsTab()
1143{ 1143{
1144 QFrame *topFrame = addPage(i18n("Colors"),0,0); 1144 QFrame *topFrame = addPage(i18n("Colors"),0,0);
1145 // DesktopIcon("colorize",KIcon::SizeMedium)); 1145 // DesktopIcon("colorize",KIcon::SizeMedium));
1146 1146
1147 QGridLayout *topLayout = new QGridLayout(topFrame,5,2); 1147 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
1148 // topLayout->setSpacing(mSpacingHint); 1148 // topLayout->setSpacing(mSpacingHint);
1149 // topLayout->setMargin(mMarginHint); 1149 // topLayout->setMargin(mMarginHint);
1150 1150
1151 topLayout->setSpacing(2); 1151 topLayout->setSpacing(2);
1152 topLayout->setMargin(3); 1152 topLayout->setMargin(3);
1153 1153
1154 int ii = 1; 1154 int ii = 1;
1155 QGroupBox *categoryGroup ; 1155 QGroupBox *categoryGroup ;
1156 1156
1157 categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), 1157 categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"),
1158 topFrame); 1158 topFrame);
1159 topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); 1159 topLayout->addMultiCellWidget(categoryGroup,0,0,0,1);
1160 1160
1161 mCategoryCombo = new QComboBox(categoryGroup); 1161 mCategoryCombo = new QComboBox(categoryGroup);
1162 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 1162 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1163 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); 1163 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor()));
1164 1164
1165 mCategoryButton = new KColorButton(categoryGroup); 1165 mCategoryButton = new KColorButton(categoryGroup);
1166 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); 1166 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor()));
1167 updateCategoryColor(); 1167 updateCategoryColor();
1168 1168
1169 1169
1170 // Holiday Color 1170 // Holiday Color
1171 1171
1172 KPrefsDialogWidColor *holidayColor = 1172 KPrefsDialogWidColor *holidayColor =
1173 addWidColor(i18n("Holiday color:"), 1173 addWidColor(i18n("Holiday color:"),
1174 &(KOPrefs::instance()->mHolidayColor),topFrame); 1174 &(KOPrefs::instance()->mHolidayColor),topFrame);
1175 topLayout->addWidget(holidayColor->label(),ii,0); 1175 topLayout->addWidget(holidayColor->label(),ii,0);
1176 topLayout->addWidget(holidayColor->button(),ii++,1); 1176 topLayout->addWidget(holidayColor->button(),ii++,1);
1177 1177
1178 // Highlight Color 1178 // Highlight Color
1179 KPrefsDialogWidColor *highlightColor = 1179 KPrefsDialogWidColor *highlightColor =
1180 addWidColor(i18n("Highlight color:"), 1180 addWidColor(i18n("Highlight color:"),
1181 &(KOPrefs::instance()->mHighlightColor),topFrame); 1181 &(KOPrefs::instance()->mHighlightColor),topFrame);
1182 topLayout->addWidget(highlightColor->label(),ii,0); 1182 topLayout->addWidget(highlightColor->label(),ii,0);
1183 topLayout->addWidget(highlightColor->button(),ii++,1); 1183 topLayout->addWidget(highlightColor->button(),ii++,1);
1184 1184
1185 // Event color 1185 // Event color
1186 KPrefsDialogWidColor *eventColor = 1186 KPrefsDialogWidColor *eventColor =
1187 addWidColor(i18n("Default event color:"), 1187 addWidColor(i18n("Default event color:"),
1188 &(KOPrefs::instance()->mEventColor),topFrame); 1188 &(KOPrefs::instance()->mEventColor),topFrame);
1189 topLayout->addWidget(eventColor->label(),ii,0); 1189 topLayout->addWidget(eventColor->label(),ii,0);
1190 topLayout->addWidget(eventColor->button(),ii++,1); 1190 topLayout->addWidget(eventColor->button(),ii++,1);
1191 eventColor = 1191 eventColor =
1192 addWidColor(i18n("Default todo done color:"), 1192 addWidColor(i18n("Default todo done color:"),
1193 &(KOPrefs::instance()->mTodoDoneColor),topFrame); 1193 &(KOPrefs::instance()->mTodoDoneColor),topFrame);
1194 topLayout->addWidget(eventColor->label(),ii,0); 1194 topLayout->addWidget(eventColor->label(),ii,0);
1195 topLayout->addWidget(eventColor->button(),ii++,1); 1195 topLayout->addWidget(eventColor->button(),ii++,1);
1196 1196
1197 if ( QApplication::desktop()->height() <= 240 ) { 1197 if ( QApplication::desktop()->height() <= 240 ) {
1198 topFrame = addPage(i18n("Colors") +" 2",0,0); 1198 topFrame = addPage(i18n("Colors") +" 2",0,0);
1199 // DesktopIcon("colorize",KIcon::SizeMedium)); 1199 // DesktopIcon("colorize",KIcon::SizeMedium));
1200 1200
1201 topLayout = new QGridLayout(topFrame,5,2); 1201 topLayout = new QGridLayout(topFrame,5,2);
1202 // topLayout->setSpacing(mSpacingHint); 1202 // topLayout->setSpacing(mSpacingHint);
1203 // topLayout->setMargin(mMarginHint); 1203 // topLayout->setMargin(mMarginHint);
1204 1204
1205 topLayout->setSpacing(2); 1205 topLayout->setSpacing(2);
1206 topLayout->setMargin(3); 1206 topLayout->setMargin(3);
1207 } 1207 }
1208 1208
1209 1209
1210 // agenda view background color 1210 // agenda view background color
1211 KPrefsDialogWidColor *agendaBgColor = 1211 KPrefsDialogWidColor *agendaBgColor =
1212 addWidColor(i18n("Agenda view background color:"), 1212 addWidColor(i18n("Agenda view background color:"),
1213 &(KOPrefs::instance()->mAgendaBgColor),topFrame); 1213 &(KOPrefs::instance()->mAgendaBgColor),topFrame);
1214 topLayout->addWidget(agendaBgColor->label(),ii,0); 1214 topLayout->addWidget(agendaBgColor->label(),ii,0);
1215 topLayout->addWidget(agendaBgColor->button(),ii++,1); 1215 topLayout->addWidget(agendaBgColor->button(),ii++,1);
1216 1216
1217 // working hours color 1217 // working hours color
1218 KPrefsDialogWidColor *workingHoursColor = 1218 KPrefsDialogWidColor *workingHoursColor =
1219 addWidColor(i18n("Working hours color:"), 1219 addWidColor(i18n("Working hours color:"),
1220 &(KOPrefs::instance()->mWorkingHoursColor),topFrame); 1220 &(KOPrefs::instance()->mWorkingHoursColor),topFrame);
1221 topLayout->addWidget(workingHoursColor->label(),ii,0); 1221 topLayout->addWidget(workingHoursColor->label(),ii,0);
1222 topLayout->addWidget(workingHoursColor->button(),ii++,1); 1222 topLayout->addWidget(workingHoursColor->button(),ii++,1);
1223 1223
1224 KPrefsDialogWidBool *sb = 1224 KPrefsDialogWidBool *sb =
1225 addWidBool(i18n("Use colors for application:"), 1225 addWidBool(i18n("Use colors for application:"),
1226 &(KOPrefs::instance()->mUseAppColors),topFrame); 1226 &(KOPrefs::instance()->mUseAppColors),topFrame);
1227 topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); 1227 topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 );
1228 1228
1229 ii++; 1229 ii++;
1230 KPrefsDialogWidColor * workingHoursColor1 = 1230 KPrefsDialogWidColor * workingHoursColor1 =
1231 addWidColor(i18n("Buttons, menus, etc.:"), 1231 addWidColor(i18n("Buttons, menus, etc.:"),
1232 &(KOPrefs::instance()->mAppColor1),topFrame); 1232 &(KOPrefs::instance()->mAppColor1),topFrame);
1233 topLayout->addWidget(workingHoursColor1->label(),ii,0); 1233 topLayout->addWidget(workingHoursColor1->label(),ii,0);
1234 topLayout->addWidget(workingHoursColor1->button(),ii++,1); 1234 topLayout->addWidget(workingHoursColor1->button(),ii++,1);
1235 1235
1236 KPrefsDialogWidColor * workingHoursColor2 = 1236 KPrefsDialogWidColor * workingHoursColor2 =
1237 addWidColor(i18n("Frames, labels, etc.:"), 1237 addWidColor(i18n("Frames, labels, etc.:"),
1238 &(KOPrefs::instance()->mAppColor2),topFrame); 1238 &(KOPrefs::instance()->mAppColor2),topFrame);
1239 topLayout->addWidget(workingHoursColor2->label(),ii,0); 1239 topLayout->addWidget(workingHoursColor2->label(),ii,0);
1240 topLayout->addWidget(workingHoursColor2->button(),ii++,1); 1240 topLayout->addWidget(workingHoursColor2->button(),ii++,1);
1241 1241
1242 1242
1243 1243
1244} 1244}
1245 1245
1246void KOPrefsDialog::setCategoryColor() 1246void KOPrefsDialog::setCategoryColor()
1247{ 1247{
1248 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); 1248 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color()));
1249} 1249}
1250 1250
1251void KOPrefsDialog::updateCategoryColor() 1251void KOPrefsDialog::updateCategoryColor()
1252{ 1252{
1253 QString cat = mCategoryCombo->currentText(); 1253 QString cat = mCategoryCombo->currentText();
1254 QColor *color = mCategoryDict.find(cat); 1254 QColor *color = mCategoryDict.find(cat);
1255 if (!color) { 1255 if (!color) {
1256 color = KOPrefs::instance()->categoryColor(cat); 1256 color = KOPrefs::instance()->categoryColor(cat);
1257 } 1257 }
1258 if (color) { 1258 if (color) {
1259 mCategoryButton->setColor(*color); 1259 mCategoryButton->setColor(*color);
1260 } 1260 }
1261} 1261}
1262 1262
1263void KOPrefsDialog::setupPrinterTab() 1263void KOPrefsDialog::setupPrinterTab()
1264{ 1264{
1265 mPrinterTab = addPage(i18n("Printing"),0, 1265 mPrinterTab = addPage(i18n("Printing"),0,
1266 DesktopIcon("fileprint",KIcon::SizeMedium)); 1266 DesktopIcon("fileprint",KIcon::SizeMedium));
1267 1267
1268 QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); 1268 QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2);
1269 topLayout->setSpacing(mSpacingHint); 1269 topLayout->setSpacing(mSpacingHint);
1270 topLayout->setMargin(mMarginHint); 1270 topLayout->setMargin(mMarginHint);
1271 1271
1272 topLayout->setRowStretch(4,1); 1272 topLayout->setRowStretch(4,1);
1273} 1273}
1274 1274
1275void KOPrefsDialog::setupGroupSchedulingTab() 1275void KOPrefsDialog::setupGroupSchedulingTab()
1276{ 1276{
1277#if 0 1277#if 0
1278 QFrame *topFrame = addPage(i18n("Group Scheduling"),0, 1278 QFrame *topFrame = addPage(i18n("Group Scheduling"),0,
1279 DesktopIcon("personal",KIcon::SizeMedium)); 1279 DesktopIcon("personal",KIcon::SizeMedium));
1280 1280
1281 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 1281 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
1282 topLayout->setSpacing(mSpacingHint); 1282 topLayout->setSpacing(mSpacingHint);
1283 topLayout->setMargin(mMarginHint); 1283 topLayout->setMargin(mMarginHint);
1284 1284
1285#if 0 1285#if 0
1286 KPrefsDialogWidRadios *schedulerGroup = 1286 KPrefsDialogWidRadios *schedulerGroup =
1287 addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), 1287 addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler),
1288 topFrame); 1288 topFrame);
1289 schedulerGroup->addRadio("Dummy"); // Only for debugging 1289 schedulerGroup->addRadio("Dummy"); // Only for debugging
1290 schedulerGroup->addRadio(i18n("Mail client")); 1290 schedulerGroup->addRadio(i18n("Mail client"));
1291 1291
1292 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); 1292 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
1293#endif 1293#endif
1294 1294
1295 KPrefsDialogWidRadios *sendGroup = 1295 KPrefsDialogWidRadios *sendGroup =
1296 addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), 1296 addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend),
1297 topFrame); 1297 topFrame);
1298 sendGroup->addRadio(i18n("Send to outbox")); 1298 sendGroup->addRadio(i18n("Send to outbox"));
1299 sendGroup->addRadio(i18n("Send directly")); 1299 sendGroup->addRadio(i18n("Send directly"));
1300 1300
1301 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); 1301 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1);
1302 1302
1303 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); 1303 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1);
1304 mAMails = new QListView(topFrame); 1304 mAMails = new QListView(topFrame);
1305 mAMails->addColumn(i18n("Email"),300); 1305 mAMails->addColumn(i18n("Email"),300);
1306 topLayout->addMultiCellWidget(mAMails,3,3,0,1); 1306 topLayout->addMultiCellWidget(mAMails,3,3,0,1);
1307 1307
1308 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); 1308 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0);
1309 aEmailsEdit = new QLineEdit(topFrame); 1309 aEmailsEdit = new QLineEdit(topFrame);
1310 aEmailsEdit->setEnabled(false); 1310 aEmailsEdit->setEnabled(false);
1311 topLayout->addWidget(aEmailsEdit,4,1); 1311 topLayout->addWidget(aEmailsEdit,4,1);
1312 1312
1313 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); 1313 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new");
1314 topLayout->addWidget(add,5,0); 1314 topLayout->addWidget(add,5,0);
1315 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); 1315 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove");
1316 topLayout->addWidget(del,5,1); 1316 topLayout->addWidget(del,5,1);
1317 1317
1318 //topLayout->setRowStretch(2,1); 1318 //topLayout->setRowStretch(2,1);
1319 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); 1319 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) );
1320 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); 1320 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) );
1321 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); 1321 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem()));
1322 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); 1322 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput()));
1323#endif 1323#endif
1324} 1324}
1325 1325
1326void KOPrefsDialog::setupGroupAutomationTab() 1326void KOPrefsDialog::setupGroupAutomationTab()
1327{ 1327{
1328 return; 1328 return;
1329 QFrame *topFrame = addPage(i18n("Group Automation"),0, 1329 QFrame *topFrame = addPage(i18n("Group Automation"),0,
1330 DesktopIcon("personal",KIcon::SizeMedium)); 1330 DesktopIcon("personal",KIcon::SizeMedium));
1331 1331
1332 QGridLayout *topLayout = new QGridLayout(topFrame,5,1); 1332 QGridLayout *topLayout = new QGridLayout(topFrame,5,1);
1333 topLayout->setSpacing(mSpacingHint); 1333 topLayout->setSpacing(mSpacingHint);
1334 topLayout->setMargin(mMarginHint); 1334 topLayout->setMargin(mMarginHint);
1335 1335
1336 KPrefsDialogWidRadios *autoRefreshGroup = 1336 KPrefsDialogWidRadios *autoRefreshGroup =
1337 addWidRadios(i18n("Auto Send Refresh"), 1337 addWidRadios(i18n("Auto Send Refresh"),
1338 &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); 1338 &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame);
1339 autoRefreshGroup->addRadio(i18n("Never")); 1339 autoRefreshGroup->addRadio(i18n("Never"));
1340 autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); 1340 autoRefreshGroup->addRadio(i18n("If attendee is in addressbook"));
1341 //autoRefreshGroup->addRadio(i18n("selected emails")); 1341 //autoRefreshGroup->addRadio(i18n("selected emails"));
1342 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); 1342 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0);
1343 1343
1344 KPrefsDialogWidRadios *autoInsertGroup = 1344 KPrefsDialogWidRadios *autoInsertGroup =
1345 addWidRadios(i18n("Auto Insert IMIP Replies"), 1345 addWidRadios(i18n("Auto Insert IMIP Replies"),
1346 &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); 1346 &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame);
1347 autoInsertGroup->addRadio(i18n("Never")); 1347 autoInsertGroup->addRadio(i18n("Never"));
1348 autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); 1348 autoInsertGroup->addRadio(i18n("If attendee is in addressbook"));
1349 //autoInsertGroup->addRadio(i18n("selected emails")); 1349 //autoInsertGroup->addRadio(i18n("selected emails"));
1350 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); 1350 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0);
1351 1351
1352 KPrefsDialogWidRadios *autoRequestGroup = 1352 KPrefsDialogWidRadios *autoRequestGroup =
1353 addWidRadios(i18n("Auto Insert IMIP Requests"), 1353 addWidRadios(i18n("Auto Insert IMIP Requests"),
1354 &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); 1354 &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame);
1355 autoRequestGroup->addRadio(i18n("Never")); 1355 autoRequestGroup->addRadio(i18n("Never"));
1356 autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); 1356 autoRequestGroup->addRadio(i18n("If organizer is in addressbook"));
1357 //autoInsertGroup->addRadio(i18n("selected emails")); 1357 //autoInsertGroup->addRadio(i18n("selected emails"));
1358 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); 1358 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0);
1359 1359
1360 KPrefsDialogWidRadios *autoFreeBusyGroup = 1360 KPrefsDialogWidRadios *autoFreeBusyGroup =
1361 addWidRadios(i18n("Auto Send FreeBusy Information"), 1361 addWidRadios(i18n("Auto Send FreeBusy Information"),
1362 &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); 1362 &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame);
1363 autoFreeBusyGroup->addRadio(i18n("Never")); 1363 autoFreeBusyGroup->addRadio(i18n("Never"));
1364 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); 1364 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook"));
1365 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 1365 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1366 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); 1366 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0);
1367 1367
1368 KPrefsDialogWidRadios *autoFreeBusyReplyGroup = 1368 KPrefsDialogWidRadios *autoFreeBusyReplyGroup =
1369 addWidRadios(i18n("Auto Save FreeBusy Replies"), 1369 addWidRadios(i18n("Auto Save FreeBusy Replies"),
1370 &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); 1370 &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame);
1371 autoFreeBusyReplyGroup->addRadio(i18n("Never")); 1371 autoFreeBusyReplyGroup->addRadio(i18n("Never"));
1372 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); 1372 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook"));
1373 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 1373 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1374 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); 1374 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0);
1375} 1375}
1376 1376
1377void KOPrefsDialog::showPrinterTab() 1377void KOPrefsDialog::showPrinterTab()
1378{ 1378{
1379 showPage(pageIndex(mPrinterTab)); 1379 showPage(pageIndex(mPrinterTab));
1380} 1380}
1381 1381
1382 1382
1383void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, 1383void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text,
1384 const QStringList *tags) 1384 const QStringList *tags)
1385{ 1385{
1386 if (tags) { 1386 if (tags) {
1387 int i = tags->findIndex(text); 1387 int i = tags->findIndex(text);
1388 if (i > 0) combo->setCurrentItem(i); 1388 if (i > 0) combo->setCurrentItem(i);
1389 } else { 1389 } else {
1390 for(int i=0;i<combo->count();++i) { 1390 for(int i=0;i<combo->count();++i) {
1391 if (combo->text(i) == text) { 1391 if (combo->text(i) == text) {
1392 combo->setCurrentItem(i); 1392 combo->setCurrentItem(i);
1393 break; 1393 break;
1394 } 1394 }
1395 } 1395 }
1396 } 1396 }
1397} 1397}
1398 1398
1399void KOPrefsDialog::usrReadConfig() 1399void KOPrefsDialog::usrReadConfig()
1400{ 1400{
1401 1401
1402 mNameEdit->setText(KOPrefs::instance()->fullName()); 1402 mNameEdit->setText(KOPrefs::instance()->fullName());
1403 mEmailEdit->setText(KOPrefs::instance()->email()); 1403 mEmailEdit->setText(KOPrefs::instance()->email());
1404 1404
1405 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); 1405 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval);
1406 1406
1407 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); 1407 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime);
1408 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); 1408 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration);
1409 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); 1409 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime);
1410 1410
1411 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); 1411 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays);
1412 mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); 1412 mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays);
1413 mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); 1413 mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios);
1414 // mAMails->clear(); 1414 // mAMails->clear();
1415 // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); 1415 // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
1416// it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { 1416// it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
1417// QListViewItem *item = new QListViewItem(mAMails); 1417// QListViewItem *item = new QListViewItem(mAMails);
1418// item->setText(0,*it); 1418// item->setText(0,*it);
1419// mAMails->insertItem(item); 1419// mAMails->insertItem(item);
1420// } 1420// }
1421 1421
1422 //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); 1422 //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile);
1423 mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); 1423 mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile);
1424 updateCategories(); 1424 updateCategories();
1425 mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); 1425 mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps );
1426 mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); 1426 mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime );
1427 mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); 1427 mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount );
1428 mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); 1428 mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval );
1429 1429
1430} 1430}
1431 1431
1432 1432
1433void KOPrefsDialog::usrWriteConfig() 1433void KOPrefsDialog::usrWriteConfig()
1434{ 1434{
1435 1435
1436 1436
1437 KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); 1437 KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text();
1438 KOPrefs::instance()->setFullName(mNameEdit->text()); 1438 KOPrefs::instance()->setFullName(mNameEdit->text());
1439 KOPrefs::instance()->setEmail(mEmailEdit->text()); 1439 KOPrefs::instance()->setEmail(mEmailEdit->text());
1440 1440
1441 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); 1441 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value();
1442 KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); 1442 KOPrefs::instance()->mStartTime = mStartTimeSpin->value();
1443 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); 1443 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value();
1444 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); 1444 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem();
1445 1445
1446 QDictIterator<QColor> it(mCategoryDict); 1446 QDictIterator<QColor> it(mCategoryDict);
1447 while (it.current()) { 1447 while (it.current()) {
1448 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); 1448 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current());
1449 ++it; 1449 ++it;
1450 } 1450 }
1451 1451
1452 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); 1452 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value();
1453 KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); 1453 KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value();
1454 KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); 1454 KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value();
1455 1455
1456 KOPrefs::instance()->mAdditionalMails.clear(); 1456 KOPrefs::instance()->mAdditionalMails.clear();
1457 // QListViewItem *item; 1457 // QListViewItem *item;
1458 // item = mAMails->firstChild(); 1458 // item = mAMails->firstChild();
1459 // while (item) 1459 // while (item)
1460 // { 1460 // {
1461 // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); 1461 // KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
1462 // item = item->nextSibling(); 1462 // item = item->nextSibling();
1463 // } 1463 // }
1464 KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); 1464 KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value();
1465 KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; 1465 KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ;
1466 KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; 1466 KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ;
1467 KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; 1467 KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ;
1468
1469} 1468}
1470 1469
1471void KOPrefsDialog::updateCategories() 1470void KOPrefsDialog::updateCategories()
1472{ 1471{
1473 mCategoryCombo->clear(); 1472 mCategoryCombo->clear();
1474 mCategoryDict.clear(); 1473 mCategoryDict.clear();
1475 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 1474 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1476 updateCategoryColor(); 1475 updateCategoryColor();
1477} 1476}
1478 1477
1479void KOPrefsDialog::toggleEmailSettings(bool on) 1478void KOPrefsDialog::toggleEmailSettings(bool on)
1480{ 1479{
1481 if (on) { 1480 if (on) {
1482 mEmailEdit->setEnabled(false); 1481 mEmailEdit->setEnabled(false);
1483 mNameEdit->setEnabled(false); 1482 mNameEdit->setEnabled(false);
1484 mEmailLabel->setEnabled(false); 1483 mEmailLabel->setEnabled(false);
1485 mNameLabel->setEnabled(false); 1484 mNameLabel->setEnabled(false);
1486 1485
1487 KEMailSettings settings; 1486 KEMailSettings settings;
1488 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); 1487 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName));
1489 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); 1488 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress));
1490 } else { 1489 } else {
1491 mEmailEdit->setEnabled(true); 1490 mEmailEdit->setEnabled(true);
1492 mNameEdit->setEnabled(true); 1491 mNameEdit->setEnabled(true);
1493 mEmailLabel->setEnabled(true); 1492 mEmailLabel->setEnabled(true);
1494 mNameLabel->setEnabled(true); 1493 mNameLabel->setEnabled(true);
1495 } 1494 }
1496} 1495}
1497 1496
1498void KOPrefsDialog::addItem() 1497void KOPrefsDialog::addItem()
1499{ 1498{
1500 // aEmailsEdit->setEnabled(true); 1499 // aEmailsEdit->setEnabled(true);
1501// QListViewItem *item = new QListViewItem(mAMails); 1500// QListViewItem *item = new QListViewItem(mAMails);
1502// mAMails->insertItem(item); 1501// mAMails->insertItem(item);
1503// mAMails->setSelected(item,true); 1502// mAMails->setSelected(item,true);
1504// aEmailsEdit->setText(i18n("(EmptyEmail)")); 1503// aEmailsEdit->setText(i18n("(EmptyEmail)"));
1505} 1504}
1506 1505
1507void KOPrefsDialog::removeItem() 1506void KOPrefsDialog::removeItem()
1508{ 1507{
1509// QListViewItem *item; 1508// QListViewItem *item;
1510// item = mAMails->selectedItem(); 1509// item = mAMails->selectedItem();
1511// if (!item) return; 1510// if (!item) return;
1512// mAMails->takeItem(item); 1511// mAMails->takeItem(item);
1513// item = mAMails->selectedItem(); 1512// item = mAMails->selectedItem();
1514// if (!item) { 1513// if (!item) {
1515// aEmailsEdit->setText(""); 1514// aEmailsEdit->setText("");
1516// aEmailsEdit->setEnabled(false); 1515// aEmailsEdit->setEnabled(false);
1517// } 1516// }
1518// if (mAMails->childCount() == 0) { 1517// if (mAMails->childCount() == 0) {
1519// aEmailsEdit->setEnabled(false); 1518// aEmailsEdit->setEnabled(false);
1520// } 1519// }
1521} 1520}
1522 1521
1523void KOPrefsDialog::updateItem() 1522void KOPrefsDialog::updateItem()
1524{ 1523{
1525 // QListViewItem *item; 1524 // QListViewItem *item;
1526// item = mAMails->selectedItem(); 1525// item = mAMails->selectedItem();
1527// if (!item) return; 1526// if (!item) return;
1528// item->setText(0,aEmailsEdit->text()); 1527// item->setText(0,aEmailsEdit->text());
1529} 1528}
1530 1529
1531void KOPrefsDialog::updateInput() 1530void KOPrefsDialog::updateInput()
1532{ 1531{
1533// QListViewItem *item; 1532// QListViewItem *item;
1534// item = mAMails->selectedItem(); 1533// item = mAMails->selectedItem();
1535// if (!item) return; 1534// if (!item) return;
1536// aEmailsEdit->setEnabled(true); 1535// aEmailsEdit->setEnabled(true);
1537// aEmailsEdit->setText(item->text(0)); 1536// aEmailsEdit->setText(item->text(0));
1538} 1537}
1539 1538