summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp8
-rw-r--r--korganizer/kodaymatrix.cpp2
-rw-r--r--korganizer/kolistview.cpp8
-rw-r--r--korganizer/kolistview.h3
-rw-r--r--korganizer/komonthview.cpp6
-rw-r--r--korganizer/kotodoview.cpp8
-rw-r--r--korganizer/mainwindow.cpp6
-rw-r--r--korganizer/mainwindow.h1
8 files changed, 35 insertions, 7 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 1801d7e..df2e478 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,820 +1,824 @@
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->type() == "Todo") && 109 if ( (incidence->type() == "Todo") &&
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->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 121 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 123 else
124 mBackgroundColor =KOPrefs::instance()->mEventColor; 124 mBackgroundColor =KOPrefs::instance()->mEventColor;
125 } else { 125 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 127 if ( (incidence->type() == "Todo") &&((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 mColorGroup = QColorGroup( mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor.light(), 135 mBackgroundColor.dark(),mBackgroundColor.light(),
136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
137 setBackgroundColor( mBackgroundColor ); 137 setBackgroundColor( mBackgroundColor );
138 138
139 mConflictItems.clear(); 139 mConflictItems.clear();
140 setCellXY(0,0,1); 140 setCellXY(0,0,1);
141 setCellXWidth(0); 141 setCellXWidth(0);
142 setSubCell(0); 142 setSubCell(0);
143 setSubCells(1); 143 setSubCells(1);
144 setMultiItem(0,0,0); 144 setMultiItem(0,0,0);
145 startMove(); 145 startMove();
146 mSelected = true; 146 mSelected = true;
147 select(false); 147 select(false);
148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
149 mFontPixelSize = fontinf.height();; 149 mFontPixelSize = fontinf.height();;
150 hide(); 150 hide();
151 xPaintCoord = -1; 151 xPaintCoord = -1;
152 yPaintCoord = -1; 152 yPaintCoord = -1;
153} 153}
154 154
155 155
156KOAgendaItem::~KOAgendaItem() 156KOAgendaItem::~KOAgendaItem()
157{ 157{
158 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 158#if QT_VERSION >= 0x030000
159 // delete mKOAgendaItemWhatsThis; 159
160#else
161 delete mKOAgendaItemWhatsThis;
162#endif
163
160} 164}
161 165
162void KOAgendaItem::recreateIncidence() 166void KOAgendaItem::recreateIncidence()
163{ 167{
164#if 0 168#if 0
165 Incidence* newInc = mIncidence->clone(); 169 Incidence* newInc = mIncidence->clone();
166 newInc->recreate(); 170 newInc->recreate();
167 if ( mIncidence->doesRecur() ) { 171 if ( mIncidence->doesRecur() ) {
168 mIncidence->addExDate( mDate ); 172 mIncidence->addExDate( mDate );
169 newInc->recurrence()->unsetRecurs(); 173 newInc->recurrence()->unsetRecurs();
170 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 174 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
171 QTime tim = mIncidence->dtStart().time(); 175 QTime tim = mIncidence->dtStart().time();
172 newInc->setDtStart( QDateTime(mDate, tim) ); 176 newInc->setDtStart( QDateTime(mDate, tim) );
173 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 177 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
174 } 178 }
175#endif 179#endif
176 mIncidence = mIncidence->recreateCloneException( mDate ); 180 mIncidence = mIncidence->recreateCloneException( mDate );
177} 181}
178bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 182bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
179{ 183{
180 int size = AGENDA_ICON_SIZE; 184 int size = AGENDA_ICON_SIZE;
181 185
182 int yOff = 0; 186 int yOff = 0;
183 int xOff = 0; 187 int xOff = 0;
184 int x = pos().x() +3; 188 int x = pos().x() +3;
185 int y; 189 int y;
186 if ( mAllDay ) 190 if ( mAllDay )
187 y = pos().y()+3; 191 y = pos().y()+3;
188 else 192 else
189 y = mCellYTop * ( height() / cellHeight() ) +3; 193 y = mCellYTop * ( height() / cellHeight() ) +3;
190 if (mIncidence->cancelled()) { 194 if (mIncidence->cancelled()) {
191 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 195 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
192 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 196 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
193 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 197 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
194 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 198 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
195 if ( horLayout ) 199 if ( horLayout )
196 ++xOff; 200 ++xOff;
197 else 201 else
198 ++yOff; 202 ++yOff;
199 } 203 }
200 if (mIncidence->isAlarmEnabled()) { 204 if (mIncidence->isAlarmEnabled()) {
201 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 205 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
202 if ( horLayout ) 206 if ( horLayout )
203 ++xOff; 207 ++xOff;
204 else 208 else
205 ++yOff; 209 ++yOff;
206 } 210 }
207 if (mIncidence->recurrence()->doesRecur()) { 211 if (mIncidence->recurrence()->doesRecur()) {
208 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 212 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
209 if ( horLayout ) 213 if ( horLayout )
210 ++xOff; 214 ++xOff;
211 else 215 else
212 ++yOff; 216 ++yOff;
213 } 217 }
214 if (mIncidence->description().length() > 0) { 218 if (mIncidence->description().length() > 0) {
215 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 219 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
216 if ( horLayout ) 220 if ( horLayout )
217 ++xOff; 221 ++xOff;
218 else 222 else
219 ++yOff; 223 ++yOff;
220 } 224 }
221 if (mIncidence->isReadOnly()) { 225 if (mIncidence->isReadOnly()) {
222 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 226 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
223 if ( horLayout ) 227 if ( horLayout )
224 ++xOff; 228 ++xOff;
225 else 229 else
226 ++yOff; 230 ++yOff;
227 } 231 }
228 232
229 if (mIncidence->attendeeCount()>0) { 233 if (mIncidence->attendeeCount()>0) {
230 234
231 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 235 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
232 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 236 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
233 if ( horLayout ) 237 if ( horLayout )
234 ++xOff; 238 ++xOff;
235 else 239 else
236 ++yOff; 240 ++yOff;
237 } else { 241 } else {
238 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 242 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
239 if (me!=0) { 243 if (me!=0) {
240 244
241 245
242 } else { 246 } else {
243 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 247 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
244 if ( horLayout ) 248 if ( horLayout )
245 ++xOff; 249 ++xOff;
246 else 250 else
247 ++yOff; 251 ++yOff;
248 252
249 } 253 }
250 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 254 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
251 if ( horLayout ) 255 if ( horLayout )
252 ++xOff; 256 ++xOff;
253 else 257 else
254 ++yOff; 258 ++yOff;
255 259
256 } 260 }
257 261
258 } 262 }
259 return ( yOff || xOff ); 263 return ( yOff || xOff );
260} 264}
261 265
262 266
263void KOAgendaItem::select(bool selected) 267void KOAgendaItem::select(bool selected)
264{ 268{
265 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 269 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
266 if (mSelected == selected) return; 270 if (mSelected == selected) return;
267 mSelected = selected; 271 mSelected = selected;
268 if ( ! isVisible() ) 272 if ( ! isVisible() )
269 return; 273 return;
270 if ( firstMultiItem() ) 274 if ( firstMultiItem() )
271 firstMultiItem()->select( selected ); 275 firstMultiItem()->select( selected );
272 if ( !firstMultiItem() && nextMultiItem() ) { 276 if ( !firstMultiItem() && nextMultiItem() ) {
273 KOAgendaItem * placeItem = nextMultiItem(); 277 KOAgendaItem * placeItem = nextMultiItem();
274 while ( placeItem ) { 278 while ( placeItem ) {
275 placeItem->select( selected ); 279 placeItem->select( selected );
276 placeItem = placeItem->nextMultiItem(); 280 placeItem = placeItem->nextMultiItem();
277 } 281 }
278 } 282 }
279 globalFlagBlockAgendaItemUpdate = 0; 283 globalFlagBlockAgendaItemUpdate = 0;
280 paintMe( selected ); 284 paintMe( selected );
281 globalFlagBlockAgendaItemUpdate = 1; 285 globalFlagBlockAgendaItemUpdate = 1;
282 repaint( false ); 286 repaint( false );
283} 287}
284 288
285 289
286/* 290/*
287 The eventFilter has to filter the mouse events of the agenda item childs. The 291 The eventFilter has to filter the mouse events of the agenda item childs. The
288 events are fed into the event handling method of KOAgendaItem. This allows the 292 events are fed into the event handling method of KOAgendaItem. This allows the
289 KOAgenda to handle the KOAgendaItems by using an eventFilter. 293 KOAgenda to handle the KOAgendaItems by using an eventFilter.
290*/ 294*/
291bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 295bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
292{ 296{
293 if (e->type() == QEvent::MouseButtonPress || 297 if (e->type() == QEvent::MouseButtonPress ||
294 e->type() == QEvent::MouseButtonDblClick || 298 e->type() == QEvent::MouseButtonDblClick ||
295 e->type() == QEvent::MouseButtonRelease || 299 e->type() == QEvent::MouseButtonRelease ||
296 e->type() == QEvent::MouseMove) { 300 e->type() == QEvent::MouseMove) {
297 QMouseEvent *me = (QMouseEvent *)e; 301 QMouseEvent *me = (QMouseEvent *)e;
298 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 302 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
299 mapToGlobal(me->pos())); 303 mapToGlobal(me->pos()));
300 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 304 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
301 return event(&returnEvent); 305 return event(&returnEvent);
302 } else { 306 } else {
303 return false; 307 return false;
304 } 308 }
305} 309}
306void KOAgendaItem::repaintMe( ) 310void KOAgendaItem::repaintMe( )
307{ 311{
308 paintMe ( mSelected ); 312 paintMe ( mSelected );
309} 313}
310void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 314void KOAgendaItem::paintMe( bool selected, QPainter* paint )
311{ 315{
312 if ( globalFlagBlockAgendaItemUpdate && ! selected) 316 if ( globalFlagBlockAgendaItemUpdate && ! selected)
313 return; 317 return;
314 QPainter pa; 318 QPainter pa;
315 319
316 if ( mSelected ) { 320 if ( mSelected ) {
317 pa.begin( paintPixSel() ); 321 pa.begin( paintPixSel() );
318 } else { 322 } else {
319 if ( mAllDay ) 323 if ( mAllDay )
320 pa.begin( paintPixAllday() ); 324 pa.begin( paintPixAllday() );
321 else 325 else
322 pa.begin( paintPix() ); 326 pa.begin( paintPix() );
323 } 327 }
324 int x, yy, w, h; 328 int x, yy, w, h;
325 float nfh = 7.0; 329 float nfh = 7.0;
326 x = pos().x(); w = width(); h = height (); 330 x = pos().x(); w = width(); h = height ();
327 if ( mAllDay ) 331 if ( mAllDay )
328 yy = y(); 332 yy = y();
329 else 333 else
330 yy = mCellYTop * ( height() / cellHeight() ); 334 yy = mCellYTop * ( height() / cellHeight() );
331 xPaintCoord= x; 335 xPaintCoord= x;
332 yPaintCoord = yy; 336 yPaintCoord = yy;
333 wPaintCoord = width(); 337 wPaintCoord = width();
334 hPaintCoord = height(); 338 hPaintCoord = height();
335 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 339 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
336 if ( paint == 0 ) 340 if ( paint == 0 )
337 paint = &pa; 341 paint = &pa;
338 bool horLayout = ( w < h ); 342 bool horLayout = ( w < h );
339 int maxhei = mFontPixelSize+4; 343 int maxhei = mFontPixelSize+4;
340 if ( horLayout ) 344 if ( horLayout )
341 maxhei += AGENDA_ICON_SIZE -4; 345 maxhei += AGENDA_ICON_SIZE -4;
342 bool small = ( h < maxhei ); 346 bool small = ( h < maxhei );
343 if ( ! small ) 347 if ( ! small )
344 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 348 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
345 else { 349 else {
346 QFont f = KOPrefs::instance()->mAgendaViewFont; 350 QFont f = KOPrefs::instance()->mAgendaViewFont;
347 f.setBold( false ); 351 f.setBold( false );
348 int fh = f.pointSize(); 352 int fh = f.pointSize();
349 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 353 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
350 if ( nfh < 6 ) 354 if ( nfh < 6 )
351 nfh = 6; 355 nfh = 6;
352 f.setPointSize( nfh ); 356 f.setPointSize( nfh );
353 paint->setFont(f); 357 paint->setFont(f);
354 } 358 }
355 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 359 paint->fillRect ( x, yy, w, h, mBackgroundColor );
356 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 360 static const QPixmap completedPxmp = SmallIcon("greenhook16");
357 static const QPixmap overduePxmp = SmallIcon("redcross16"); 361 static const QPixmap overduePxmp = SmallIcon("redcross16");
358 if ( mIncidence->type() == "Todo" ) { 362 if ( mIncidence->type() == "Todo" ) {
359 Todo* tempTodo = static_cast<Todo*>(mIncidence); 363 Todo* tempTodo = static_cast<Todo*>(mIncidence);
360 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 364 int xx = pos().x()+(width()-completedPxmp.width()-3 );
361 int yyy = yy+3; 365 int yyy = yy+3;
362 if ( tempTodo->isCompleted() ) 366 if ( tempTodo->isCompleted() )
363 paint->drawPixmap ( xx, yyy, completedPxmp ); 367 paint->drawPixmap ( xx, yyy, completedPxmp );
364 else { 368 else {
365 paint->drawPixmap ( xx, yyy, overduePxmp ); 369 paint->drawPixmap ( xx, yyy, overduePxmp );
366 370
367 } 371 }
368 } 372 }
369 bool addIcon = false; 373 bool addIcon = false;
370 if ( ! small || w > 3 * h || h > 3* w ) 374 if ( ! small || w > 3 * h || h > 3* w )
371 addIcon = updateIcons( paint, horLayout ); 375 addIcon = updateIcons( paint, horLayout );
372 376
373 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 377 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
374 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 378 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
375 if ( ! small ) { 379 if ( ! small ) {
376 x += 3; yy += 3;w -= 6; h-= 5; 380 x += 3; yy += 3;w -= 6; h-= 5;
377 } else { 381 } else {
378 x += 2; yy += 1;w -= 4; h-= 4; 382 x += 2; yy += 1;w -= 4; h-= 4;
379 if ( nfh < 6.01 ) { 383 if ( nfh < 6.01 ) {
380 yy -= 2; 384 yy -= 2;
381 h += 4; 385 h += 4;
382 } 386 }
383 else 387 else
384 if ( nfh < h -2 ) 388 if ( nfh < h -2 )
385 ++yy; 389 ++yy;
386 } 390 }
387 int align; 391 int align;
388#ifndef DESKTOP_VERSION 392#ifndef DESKTOP_VERSION
389 align = ( AlignLeft|WordBreak|AlignTop); 393 align = ( AlignLeft|WordBreak|AlignTop);
390#else 394#else
391 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 395 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
392#endif 396#endif
393 if ( addIcon ) { 397 if ( addIcon ) {
394 if ( ! horLayout ) { 398 if ( ! horLayout ) {
395 x += AGENDA_ICON_SIZE+3; 399 x += AGENDA_ICON_SIZE+3;
396 w -= (AGENDA_ICON_SIZE+3); 400 w -= (AGENDA_ICON_SIZE+3);
397 } 401 }
398 else { 402 else {
399 yy+= AGENDA_ICON_SIZE+2; 403 yy+= AGENDA_ICON_SIZE+2;
400 h -=(AGENDA_ICON_SIZE+3); 404 h -=(AGENDA_ICON_SIZE+3);
401 } 405 }
402 } 406 }
403 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 407 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
404 if ( colsum < 250 ) 408 if ( colsum < 250 )
405 paint->setPen ( white); 409 paint->setPen ( white);
406 if ( x < 0 ) { 410 if ( x < 0 ) {
407 w = w+x-3; 411 w = w+x-3;
408 x = 3; 412 x = 3;
409 if ( w > parentWidget()->width() ){ 413 if ( w > parentWidget()->width() ){
410 w = parentWidget()->width() - 6; 414 w = parentWidget()->width() - 6;
411#ifndef DESKTOP_VERSION 415#ifndef DESKTOP_VERSION
412 align = ( AlignHCenter|WordBreak|AlignTop); 416 align = ( AlignHCenter|WordBreak|AlignTop);
413#else 417#else
414 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 418 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
415#endif 419#endif
416 420
417 } 421 }
418 } 422 }
419 QRect dr; 423 QRect dr;
420 if ( w + x > parentWidget()->width() ) 424 if ( w + x > parentWidget()->width() )
421 w = parentWidget()->width()-x; 425 w = parentWidget()->width()-x;
422 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 426 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
423 //qDebug("%d %d %d %d ", x, yy, w, h ); 427 //qDebug("%d %d %d %d ", x, yy, w, h );
424 if ( mIncidence->cancelled() ){ 428 if ( mIncidence->cancelled() ){
425 429
426 430
427 small = ( height() < 20 ); 431 small = ( height() < 20 );
428 432
429 if ( ! small ) { 433 if ( ! small ) {
430 QFontMetrics fm ( paint->font() ); 434 QFontMetrics fm ( paint->font() );
431 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 435 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
432 } 436 }
433 437
434 } 438 }
435 pa.end(); 439 pa.end();
436 440
437} 441}
438void KOAgendaItem::resizePixmap( int w , int h ) 442void KOAgendaItem::resizePixmap( int w , int h )
439{ 443{
440 paintPix()->resize( w, h ); 444 paintPix()->resize( w, h );
441 paintPixSel()->resize( w, h ); 445 paintPixSel()->resize( w, h );
442 446
443} 447}
444QPixmap * KOAgendaItem::paintPix() 448QPixmap * KOAgendaItem::paintPix()
445{ 449{
446 static QPixmap* mPaintPix = 0; 450 static QPixmap* mPaintPix = 0;
447 if ( ! mPaintPix ) { 451 if ( ! mPaintPix ) {
448 int w = QApplication::desktop()->width(); 452 int w = QApplication::desktop()->width();
449 int h = QApplication::desktop()->height(); 453 int h = QApplication::desktop()->height();
450 mPaintPix = new QPixmap(w,h); 454 mPaintPix = new QPixmap(w,h);
451 } 455 }
452 return mPaintPix ; 456 return mPaintPix ;
453} 457}
454QPixmap * KOAgendaItem::paintPixAllday() 458QPixmap * KOAgendaItem::paintPixAllday()
455{ 459{
456 static QPixmap* mPaintPixA = 0; 460 static QPixmap* mPaintPixA = 0;
457 if ( ! mPaintPixA ) { 461 if ( ! mPaintPixA ) {
458 int w = QApplication::desktop()->width(); 462 int w = QApplication::desktop()->width();
459 int h = QApplication::desktop()->height()/3; 463 int h = QApplication::desktop()->height()/3;
460 mPaintPixA = new QPixmap(w,h); 464 mPaintPixA = new QPixmap(w,h);
461 } 465 }
462 return mPaintPixA ; 466 return mPaintPixA ;
463} 467}
464QPixmap * KOAgendaItem::paintPixSel() 468QPixmap * KOAgendaItem::paintPixSel()
465{ 469{
466 static QPixmap* mPaintPixSel = 0; 470 static QPixmap* mPaintPixSel = 0;
467 if ( ! mPaintPixSel ) { 471 if ( ! mPaintPixSel ) {
468 int w = QApplication::desktop()->width(); 472 int w = QApplication::desktop()->width();
469 int h = QApplication::desktop()->height(); 473 int h = QApplication::desktop()->height();
470 mPaintPixSel = new QPixmap(w,h); 474 mPaintPixSel = new QPixmap(w,h);
471 } 475 }
472 return mPaintPixSel ; 476 return mPaintPixSel ;
473} 477}
474void KOAgendaItem::paintEvent ( QPaintEvent *e ) 478void KOAgendaItem::paintEvent ( QPaintEvent *e )
475{ 479{
476 480
477 if ( globalFlagBlockAgendaItemPaint ) 481 if ( globalFlagBlockAgendaItemPaint )
478 return; 482 return;
479 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 483 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
480 return; 484 return;
481 int yy; 485 int yy;
482 if ( mAllDay ) 486 if ( mAllDay )
483 yy = y(); 487 yy = y();
484 else 488 else
485 yy = mCellYTop * ( height() / cellHeight() ); 489 yy = mCellYTop * ( height() / cellHeight() );
486 int xx = x(); 490 int xx = x();
487 491
488 if ( xPaintCoord != xx || yPaintCoord != yy || 492 if ( xPaintCoord != xx || yPaintCoord != yy ||
489 wPaintCoord != width() || hPaintCoord != height()) { 493 wPaintCoord != width() || hPaintCoord != height()) {
490 xPaintCoord= xx; 494 xPaintCoord= xx;
491 yPaintCoord = yy; 495 yPaintCoord = yy;
492 wPaintCoord = width(); 496 wPaintCoord = width();
493 hPaintCoord = height(); 497 hPaintCoord = height();
494 globalFlagBlockAgendaItemUpdate = 0; 498 globalFlagBlockAgendaItemUpdate = 0;
495 paintMe( mSelected ); 499 paintMe( mSelected );
496 //qDebug("calling paintMe "); 500 //qDebug("calling paintMe ");
497 globalFlagBlockAgendaItemUpdate = 1; 501 globalFlagBlockAgendaItemUpdate = 1;
498 } 502 }
499 int rx, ry, rw, rh; 503 int rx, ry, rw, rh;
500 rx = e->rect().x(); 504 rx = e->rect().x();
501 ry = e->rect().y(); 505 ry = e->rect().y();
502 rw = e->rect().width(); 506 rw = e->rect().width();
503 rh = e->rect().height(); 507 rh = e->rect().height();
504 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 508 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
505 509
506 QPixmap* paintFrom ; 510 QPixmap* paintFrom ;
507 if ( mSelected ) { 511 if ( mSelected ) {
508 paintFrom = paintPixSel(); 512 paintFrom = paintPixSel();
509 } else { 513 } else {
510 if ( mAllDay ) 514 if ( mAllDay )
511 paintFrom = paintPixAllday(); 515 paintFrom = paintPixAllday();
512 else 516 else
513 paintFrom = paintPix(); 517 paintFrom = paintPix();
514 } 518 }
515 xx += rx; 519 xx += rx;
516 520
517 if ( xx < 0 ) { 521 if ( xx < 0 ) {
518 rw = rw + xx; 522 rw = rw + xx;
519 rx -= xx; 523 rx -= xx;
520 xx = 0; 524 xx = 0;
521 if ( rw <= 1 ) { 525 if ( rw <= 1 ) {
522 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 526 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
523 return; 527 return;
524 } 528 }
525 } 529 }
526 if ( paintFrom->width() < xx+rw ) { 530 if ( paintFrom->width() < xx+rw ) {
527 rw = paintFrom->width() - xx; 531 rw = paintFrom->width() - xx;
528 if ( rw <= 1 ) { 532 if ( rw <= 1 ) {
529 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 533 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
530 return; 534 return;
531 } 535 }
532 } 536 }
533 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 537 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
534 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 538 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
535} 539}
536void KOAgendaItem::computeText() 540void KOAgendaItem::computeText()
537{ 541{
538 mDisplayedText = mIncidence->summary(); 542 mDisplayedText = mIncidence->summary();
539 if ( (mIncidence->type() == "Todo") ) { 543 if ( (mIncidence->type() == "Todo") ) {
540 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 544 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
541 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 545 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
542 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 546 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
543 else if ( !(mIncidence->doesFloat())) 547 else if ( !(mIncidence->doesFloat()))
544 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 548 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
545 } 549 }
546 } else { 550 } else {
547 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 551 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
548 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 552 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
549 553
550 if ( mAllDay ) { 554 if ( mAllDay ) {
551 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 555 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
552 if ( mIncidence->doesRecur() ) { 556 if ( mIncidence->doesRecur() ) {
553 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 557 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
554 } else { 558 } else {
555 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 559 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
556 } 560 }
557 } 561 }
558 } 562 }
559 } 563 }
560 564
561 if ( !mIncidence->location().isEmpty() ) { 565 if ( !mIncidence->location().isEmpty() ) {
562 if ( mAllDay ) 566 if ( mAllDay )
563 mDisplayedText += " ("; 567 mDisplayedText += " (";
564 else 568 else
565 mDisplayedText += "\n("; 569 mDisplayedText += "\n(";
566 mDisplayedText += mIncidence->location() +")"; 570 mDisplayedText += mIncidence->location() +")";
567 } 571 }
568#ifdef DESKTOP_VERSION 572#ifdef DESKTOP_VERSION
569 QString tipText = mIncidence->summary(); 573 QString tipText = mIncidence->summary();
570 if ( !mIncidence->doesFloat() ) { 574 if ( !mIncidence->doesFloat() ) {
571 if ( mIncidence->type() == "Event" ) { 575 if ( mIncidence->type() == "Event" ) {
572 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 576 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
573 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 577 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
574 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 578 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
575 } 579 }
576 else { 580 else {
577 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 581 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
578 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 582 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
579 } 583 }
580 } 584 }
581 else if ( mIncidence->type() == "Todo" ) { 585 else if ( mIncidence->type() == "Todo" ) {
582 if (mIncidence->hasStartDate()) 586 if (mIncidence->hasStartDate())
583 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 587 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
584 if (((Todo*)mIncidence)->hasDueDate()) 588 if (((Todo*)mIncidence)->hasDueDate())
585 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 589 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
586 } 590 }
587 } else if ( mIncidence->type() == "Todo" ) { 591 } else if ( mIncidence->type() == "Todo" ) {
588 if (mIncidence->hasStartDate()) 592 if (mIncidence->hasStartDate())
589 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 593 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
590 if (((Todo*)mIncidence)->hasDueDate()) 594 if (((Todo*)mIncidence)->hasDueDate())
591 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 595 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
592 } 596 }
593 597
594 if (!mIncidence->location().isEmpty()) { 598 if (!mIncidence->location().isEmpty()) {
595 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 599 tipText += "\n"+i18n("Location: ")+mIncidence->location();
596 } 600 }
597 QToolTip::add(this,tipText,toolTipGroup(),""); 601 QToolTip::add(this,tipText,toolTipGroup(),"");
598#endif 602#endif
599} 603}
600void KOAgendaItem::updateItem() 604void KOAgendaItem::updateItem()
601{ 605{
602 computeText(); 606 computeText();
603 607
604 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 608 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
605 paintMe( mSelected ); 609 paintMe( mSelected );
606 repaint( false); 610 repaint( false);
607} 611}
608 612
609void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 613void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
610{ 614{
611 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 615 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
612 paintMe( mSelected ); 616 paintMe( mSelected );
613 repaint( false ); 617 repaint( false );
614} 618}
615 619
616/* 620/*
617 Return height of item in units of agenda cells 621 Return height of item in units of agenda cells
618*/ 622*/
619int KOAgendaItem::cellHeight() 623int KOAgendaItem::cellHeight()
620{ 624{
621 int ret = mCellYBottom - mCellYTop + 1; 625 int ret = mCellYBottom - mCellYTop + 1;
622 if ( ret <= 0 ) { 626 if ( ret <= 0 ) {
623 ret = 1; 627 ret = 1;
624 mCellYBottom = 0; 628 mCellYBottom = 0;
625 mCellYTop = 0; 629 mCellYTop = 0;
626 } 630 }
627 return ret; 631 return ret;
628} 632}
629 633
630/* 634/*
631 Return height of item in units of agenda cells 635 Return height of item in units of agenda cells
632*/ 636*/
633int KOAgendaItem::cellWidth() 637int KOAgendaItem::cellWidth()
634{ 638{
635 return mCellXWidth - mCellX + 1; 639 return mCellXWidth - mCellX + 1;
636} 640}
637 641
638void KOAgendaItem::setItemDate(QDate qd) 642void KOAgendaItem::setItemDate(QDate qd)
639{ 643{
640 mDate = qd; 644 mDate = qd;
641} 645}
642 646
643void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 647void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
644{ 648{
645 mCellX = X; 649 mCellX = X;
646 mCellYTop = YTop; 650 mCellYTop = YTop;
647 mCellYBottom = YBottom; 651 mCellYBottom = YBottom;
648} 652}
649 653
650void KOAgendaItem::setCellXWidth(int xwidth) 654void KOAgendaItem::setCellXWidth(int xwidth)
651{ 655{
652 mCellXWidth = xwidth; 656 mCellXWidth = xwidth;
653} 657}
654 658
655void KOAgendaItem::setCellX(int XLeft, int XRight) 659void KOAgendaItem::setCellX(int XLeft, int XRight)
656{ 660{
657 mCellX = XLeft; 661 mCellX = XLeft;
658 mCellXWidth = XRight; 662 mCellXWidth = XRight;
659} 663}
660 664
661void KOAgendaItem::setCellY(int YTop, int YBottom) 665void KOAgendaItem::setCellY(int YTop, int YBottom)
662{ 666{
663 mCellYTop = YTop; 667 mCellYTop = YTop;
664 mCellYBottom = YBottom; 668 mCellYBottom = YBottom;
665} 669}
666 670
667void KOAgendaItem::setSubCell(int subCell) 671void KOAgendaItem::setSubCell(int subCell)
668{ 672{
669 mSubCell = subCell; 673 mSubCell = subCell;
670} 674}
671 675
672void KOAgendaItem::setSubCells(int subCells) 676void KOAgendaItem::setSubCells(int subCells)
673{ 677{
674 mSubCells = subCells; 678 mSubCells = subCells;
675} 679}
676 680
677void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 681void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
678 KOAgendaItem *last) 682 KOAgendaItem *last)
679{ 683{
680 mFirstMultiItem = first; 684 mFirstMultiItem = first;
681 mNextMultiItem = next; 685 mNextMultiItem = next;
682 mLastMultiItem = last; 686 mLastMultiItem = last;
683} 687}
684 688
685void KOAgendaItem::startMove() 689void KOAgendaItem::startMove()
686{ 690{
687 mStartCellX = mCellX; 691 mStartCellX = mCellX;
688 mStartCellXWidth = mCellXWidth; 692 mStartCellXWidth = mCellXWidth;
689 mStartCellYTop = mCellYTop; 693 mStartCellYTop = mCellYTop;
690 mStartCellYBottom = mCellYBottom; 694 mStartCellYBottom = mCellYBottom;
691} 695}
692 696
693void KOAgendaItem::resetMove() 697void KOAgendaItem::resetMove()
694{ 698{
695 mCellX = mStartCellX; 699 mCellX = mStartCellX;
696 mCellXWidth = mStartCellXWidth; 700 mCellXWidth = mStartCellXWidth;
697 mCellYTop = mStartCellYTop; 701 mCellYTop = mStartCellYTop;
698 mCellYBottom = mStartCellYBottom; 702 mCellYBottom = mStartCellYBottom;
699} 703}
700 704
701void KOAgendaItem::moveRelative(int dx, int dy) 705void KOAgendaItem::moveRelative(int dx, int dy)
702{ 706{
703 int newX = cellX() + dx; 707 int newX = cellX() + dx;
704 int newXWidth = cellXWidth() + dx; 708 int newXWidth = cellXWidth() + dx;
705 int newYTop = cellYTop() + dy; 709 int newYTop = cellYTop() + dy;
706 int newYBottom = cellYBottom() + dy; 710 int newYBottom = cellYBottom() + dy;
707 setCellXY(newX,newYTop,newYBottom); 711 setCellXY(newX,newYTop,newYBottom);
708 setCellXWidth(newXWidth); 712 setCellXWidth(newXWidth);
709} 713}
710 714
711void KOAgendaItem::expandTop(int dy) 715void KOAgendaItem::expandTop(int dy)
712{ 716{
713 int newYTop = cellYTop() + dy; 717 int newYTop = cellYTop() + dy;
714 int newYBottom = cellYBottom(); 718 int newYBottom = cellYBottom();
715 if (newYTop > newYBottom) newYTop = newYBottom; 719 if (newYTop > newYBottom) newYTop = newYBottom;
716 setCellY(newYTop, newYBottom); 720 setCellY(newYTop, newYBottom);
717} 721}
718 722
719void KOAgendaItem::expandBottom(int dy) 723void KOAgendaItem::expandBottom(int dy)
720{ 724{
721 int newYTop = cellYTop(); 725 int newYTop = cellYTop();
722 int newYBottom = cellYBottom() + dy; 726 int newYBottom = cellYBottom() + dy;
723 if (newYBottom < newYTop) newYBottom = newYTop; 727 if (newYBottom < newYTop) newYBottom = newYTop;
724 setCellY(newYTop, newYBottom); 728 setCellY(newYTop, newYBottom);
725} 729}
726 730
727void KOAgendaItem::expandLeft(int dx) 731void KOAgendaItem::expandLeft(int dx)
728{ 732{
729 int newX = cellX() + dx; 733 int newX = cellX() + dx;
730 int newXWidth = cellXWidth(); 734 int newXWidth = cellXWidth();
731 if (newX > newXWidth) newX = newXWidth; 735 if (newX > newXWidth) newX = newXWidth;
732 setCellX(newX,newXWidth); 736 setCellX(newX,newXWidth);
733} 737}
734 738
735void KOAgendaItem::expandRight(int dx) 739void KOAgendaItem::expandRight(int dx)
736{ 740{
737 int newX = cellX(); 741 int newX = cellX();
738 int newXWidth = cellXWidth() + dx; 742 int newXWidth = cellXWidth() + dx;
739 if (newXWidth < newX) newXWidth = newX; 743 if (newXWidth < newX) newXWidth = newX;
740 setCellX(newX,newXWidth); 744 setCellX(newX,newXWidth);
741} 745}
742 746
743QToolTipGroup *KOAgendaItem::toolTipGroup() 747QToolTipGroup *KOAgendaItem::toolTipGroup()
744{ 748{
745 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 749 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
746 return mToolTipGroup; 750 return mToolTipGroup;
747} 751}
748 752
749void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 753void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
750{ 754{
751#ifndef KORG_NODND 755#ifndef KORG_NODND
752 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 756 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
753 !QTextDrag::canDecode( e ) ) { 757 !QTextDrag::canDecode( e ) ) {
754 e->ignore(); 758 e->ignore();
755 return; 759 return;
756 } 760 }
757 e->accept(); 761 e->accept();
758#endif 762#endif
759} 763}
760 764
761void KOAgendaItem::dropEvent( QDropEvent *e ) 765void KOAgendaItem::dropEvent( QDropEvent *e )
762{ 766{
763#ifndef KORG_NODND 767#ifndef KORG_NODND
764 QString text; 768 QString text;
765 if(QTextDrag::decode(e,text)) 769 if(QTextDrag::decode(e,text))
766 { 770 {
767 kdDebug() << "Dropped : " << text << endl; 771 kdDebug() << "Dropped : " << text << endl;
768 QStringList emails = QStringList::split(",",text); 772 QStringList emails = QStringList::split(",",text);
769 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 773 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
770 kdDebug() << " Email: " << (*it) << endl; 774 kdDebug() << " Email: " << (*it) << endl;
771 int pos = (*it).find("<"); 775 int pos = (*it).find("<");
772 QString name = (*it).left(pos); 776 QString name = (*it).left(pos);
773 QString email = (*it).mid(pos); 777 QString email = (*it).mid(pos);
774 if (!email.isEmpty()) { 778 if (!email.isEmpty()) {
775 mIncidence->addAttendee(new Attendee(name,email)); 779 mIncidence->addAttendee(new Attendee(name,email));
776 } 780 }
777 } 781 }
778 } 782 }
779#endif 783#endif
780} 784}
781 785
782 786
783QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 787QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
784{ 788{
785 return mConflictItems; 789 return mConflictItems;
786} 790}
787 791
788void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 792void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
789{ 793{
790 mConflictItems = ci; 794 mConflictItems = ci;
791 KOAgendaItem *item; 795 KOAgendaItem *item;
792 for ( item=mConflictItems.first(); item != 0; 796 for ( item=mConflictItems.first(); item != 0;
793 item=mConflictItems.next() ) { 797 item=mConflictItems.next() ) {
794 item->addConflictItem(this); 798 item->addConflictItem(this);
795 } 799 }
796} 800}
797 801
798void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 802void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
799{ 803{
800 if (mConflictItems.find(ci)<0) 804 if (mConflictItems.find(ci)<0)
801 mConflictItems.append(ci); 805 mConflictItems.append(ci);
802} 806}
803 807
804bool KOAgendaItem::checkLayout() 808bool KOAgendaItem::checkLayout()
805{ 809{
806 if ( !mConflictItems.count() ) 810 if ( !mConflictItems.count() )
807 return true; 811 return true;
808 int max = 0; 812 int max = 0;
809 KOAgendaItem *item; 813 KOAgendaItem *item;
810 for ( item=mConflictItems.first(); item != 0; 814 for ( item=mConflictItems.first(); item != 0;
811 item=mConflictItems.next() ) { 815 item=mConflictItems.next() ) {
812 if ( item->subCells() > max ) 816 if ( item->subCells() > max )
813 max = item->subCells(); 817 max = item->subCells();
814 } 818 }
815 if ( max > subCells() ) { 819 if ( max > subCells() ) {
816 setSubCells( max ); 820 setSubCells( max );
817 return false; 821 return false;
818 } 822 }
819 return true; 823 return true;
820} 824}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c32a2a4..53ebdb2 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,1170 +1,1170 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source ode for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include <libkcal/vcaldrag.h> 35#include <libkcal/vcaldrag.h>
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/dndfactory.h> 37#include <libkcal/dndfactory.h>
38#include <libkcal/calendarresources.h> 38#include <libkcal/calendarresources.h>
39#include <libkcal/resourcecalendar.h> 39#include <libkcal/resourcecalendar.h>
40#include <kresources/resourceselectdialog.h> 40#include <kresources/resourceselectdialog.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#include "koglobals.h" 48#include "koglobals.h"
49 49
50#include "kodaymatrix.h" 50#include "kodaymatrix.h"
51 51
52// ============================================================================ 52// ============================================================================
53// D Y N A M I C T I P 53// D Y N A M I C T I P
54// ============================================================================ 54// ============================================================================
55 55
56DynamicTip::DynamicTip( QWidget * parent ) 56DynamicTip::DynamicTip( QWidget * parent )
57 : QToolTip( parent ) 57 : QToolTip( parent )
58{ 58{
59 matrix = (KODayMatrix*)parent; 59 matrix = (KODayMatrix*)parent;
60} 60}
61 61
62class KODaymatrixWhatsThis :public QWhatsThis 62class KODaymatrixWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;}; 65 KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { ;};
66 ~KODaymatrixWhatsThis() { qDebug("DELETE KODaymatrixWhatsThis "); }; 66 ~KODaymatrixWhatsThis() { ; };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p ) 69 virtual QString text( const QPoint& p )
70 { 70 {
71 return _view->getWhatsThisText( p ) ; 71 return _view->getWhatsThisText( p ) ;
72 } 72 }
73private: 73private:
74 KODayMatrix * _view; 74 KODayMatrix * _view;
75}; 75};
76 76
77void DynamicTip::maybeTip( const QPoint &pos ) 77void DynamicTip::maybeTip( const QPoint &pos )
78{ 78{
79 //calculate which cell of the matrix the mouse is in 79 //calculate which cell of the matrix the mouse is in
80 QRect sz = matrix->frameRect(); 80 QRect sz = matrix->frameRect();
81 int dheight = sz.height()*7 / 42; 81 int dheight = sz.height()*7 / 42;
82 int dwidth = sz.width() / 7; 82 int dwidth = sz.width() / 7;
83 int row = pos.y()/dheight; 83 int row = pos.y()/dheight;
84 int col = pos.x()/dwidth; 84 int col = pos.x()/dwidth;
85 85
86 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 86 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
87 87
88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 88// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
89// col << "][" << row << "] => " <<(col+row*7) << endl; 89// col << "][" << row << "] => " <<(col+row*7) << endl;
90 90
91 //show holiday names only 91 //show holiday names only
92 QString str = matrix->getHolidayLabel(col+row*7); 92 QString str = matrix->getHolidayLabel(col+row*7);
93 if (str.isEmpty()) return; 93 if (str.isEmpty()) return;
94 tip(rct, str); 94 tip(rct, str);
95} 95}
96 96
97 97
98// ============================================================================ 98// ============================================================================
99// K O D A Y M A T R I X 99// K O D A Y M A T R I X
100// ============================================================================ 100// ============================================================================
101 101
102const int KODayMatrix::NOSELECTION = -1000; 102const int KODayMatrix::NOSELECTION = -1000;
103const int KODayMatrix::NUMDAYS = 42; 103const int KODayMatrix::NUMDAYS = 42;
104 104
105KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) 105KODayMatrix::KODayMatrix( QWidget *parent, const char *name )
106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 ) 106 : QFrame( parent, name , Qt::WRepaintNoErase ), mCalendar( 0 )
107 107
108 108
109{ 109{
110 mLastView = -1; 110 mLastView = -1;
111 oldW = 0; 111 oldW = 0;
112 oldH = 0; 112 oldH = 0;
113 myPix.resize( 150, 120 ); 113 myPix.resize( 150, 120 );
114 mRedrawNeeded = true; 114 mRedrawNeeded = true;
115 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this); 115 mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
116 mPendingUpdateBeforeRepaint = false; 116 mPendingUpdateBeforeRepaint = false;
117 mouseDown = false; 117 mouseDown = false;
118 // initialize dynamic arrays 118 // initialize dynamic arrays
119 bDays.resize ( NUMDAYS ); 119 bDays.resize ( NUMDAYS );
120 pDays.resize ( NUMDAYS ); 120 pDays.resize ( NUMDAYS );
121 hDays.resize ( NUMDAYS ); 121 hDays.resize ( NUMDAYS );
122 eDays.resize ( NUMDAYS ); 122 eDays.resize ( NUMDAYS );
123 days = new QDate[NUMDAYS]; 123 days = new QDate[NUMDAYS];
124 daylbls = new QString[NUMDAYS]; 124 daylbls = new QString[NUMDAYS];
125 //events = new int[NUMDAYS]; 125 //events = new int[NUMDAYS];
126 mToolTip = new DynamicTip(this); 126 mToolTip = new DynamicTip(this);
127 127
128 // set default values used for drawing the matrix 128 // set default values used for drawing the matrix
129 mDefaultBackColor = palette().active().base(); 129 mDefaultBackColor = palette().active().base();
130 mDefaultTextColor = palette().active().foreground(); 130 mDefaultTextColor = palette().active().foreground();
131 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 131 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
132 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 132 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
133 mSelectedDaysColor = QColor("white"); 133 mSelectedDaysColor = QColor("white");
134 mTodayMarginWidth = 2; 134 mTodayMarginWidth = 2;
135 mSelEnd = mSelStart = NOSELECTION; 135 mSelEnd = mSelStart = NOSELECTION;
136 136
137 setAcceptDrops(true); 137 setAcceptDrops(true);
138 //setFont( QFont("Arial", 10) ); 138 //setFont( QFont("Arial", 10) );
139 139
140 mUpdateTimer = new QTimer( this ); 140 mUpdateTimer = new QTimer( this );
141 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 141 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
142 mRepaintTimer = new QTimer( this ); 142 mRepaintTimer = new QTimer( this );
143 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 143 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
144 mDayChanged = false; 144 mDayChanged = false;
145 updateView(); 145 updateView();
146} 146}
147QString KODayMatrix::getWhatsThisText( QPoint p ) 147QString KODayMatrix::getWhatsThisText( QPoint p )
148{ 148{
149 149
150 int tmp = getDayIndexFrom(p.x(), p.y()); 150 int tmp = getDayIndexFrom(p.x(), p.y());
151 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) 151 if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar )
152 return QString(); 152 return QString();
153 QDate mDate = days[tmp]; 153 QDate mDate = days[tmp];
154 QPtrList<Event> eventlist = mCalendar->events(mDate); 154 QPtrList<Event> eventlist = mCalendar->events(mDate);
155 Event *event; 155 Event *event;
156 QStringList mToolTip; 156 QStringList mToolTip;
157 for(event=eventlist.first();event != 0;event=eventlist.next()) { 157 for(event=eventlist.first();event != 0;event=eventlist.next()) {
158 QString mToolTipText; 158 QString mToolTipText;
159 QString text; 159 QString text;
160 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 160 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
161 if (event->isMultiDay()) { 161 if (event->isMultiDay()) {
162 QString prefix = "<->";multiday = 2; 162 QString prefix = "<->";multiday = 2;
163 QString time; 163 QString time;
164 if ( event->doesRecur() ) { 164 if ( event->doesRecur() ) {
165 if ( event->recursOn( mDate) ) { 165 if ( event->recursOn( mDate) ) {
166 prefix ="->" ;multiday = 1; 166 prefix ="->" ;multiday = 1;
167 } 167 }
168 else { 168 else {
169 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 169 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
170 if ( event->recursOn( mDate.addDays( -days)) ) { 170 if ( event->recursOn( mDate.addDays( -days)) ) {
171 prefix ="<-" ;multiday = 3; 171 prefix ="<-" ;multiday = 3;
172 } 172 }
173 } 173 }
174 } else { 174 } else {
175 if (mDate == event->dtStart().date()) { 175 if (mDate == event->dtStart().date()) {
176 prefix ="->" ;multiday = 1; 176 prefix ="->" ;multiday = 1;
177 } else if (mDate == event->dtEnd().date()) { 177 } else if (mDate == event->dtEnd().date()) {
178 prefix ="<-" ;multiday = 3; 178 prefix ="<-" ;multiday = 3;
179 } 179 }
180 } 180 }
181 if ( !event->doesFloat() ) { 181 if ( !event->doesFloat() ) {
182 if ( mDate == event->dtStart().date () ) 182 if ( mDate == event->dtStart().date () )
183 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 183 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
184 else if ( mDate == event->dtEnd().date () ) 184 else if ( mDate == event->dtEnd().date () )
185 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 185 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
186 186
187 } 187 }
188 text = time + event->summary(); 188 text = time + event->summary();
189 mToolTipText += prefix + text; 189 mToolTipText += prefix + text;
190 } else { 190 } else {
191 if (event->doesFloat()) { 191 if (event->doesFloat()) {
192 text = event->summary(); 192 text = event->summary();
193 mToolTipText += text; 193 mToolTipText += text;
194 } 194 }
195 else { 195 else {
196 text = KGlobal::locale()->formatTime(event->dtStart().time()); 196 text = KGlobal::locale()->formatTime(event->dtStart().time());
197 text += " " + event->summary(); 197 text += " " + event->summary();
198 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 198 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
199 } 199 }
200 } 200 }
201 if ( !event->location().isEmpty() ) 201 if ( !event->location().isEmpty() )
202 mToolTipText += " (" + event->location() + ")"; 202 mToolTipText += " (" + event->location() + ")";
203#if QT_VERSION >= 0x030000 203#if QT_VERSION >= 0x030000
204 mToolTipText.replace( '<' , "&lt;" ); 204 mToolTipText.replace( '<' , "&lt;" );
205 mToolTipText.replace( '>' , "&gt;" ); 205 mToolTipText.replace( '>' , "&gt;" );
206#else 206#else
207 if ( mToolTipText.find ('<') >= 0 ) { 207 if ( mToolTipText.find ('<') >= 0 ) {
208 mToolTipText.replace( QRegExp("<") , "&lt;" ); 208 mToolTipText.replace( QRegExp("<") , "&lt;" );
209 } 209 }
210 if ( mToolTipText.find ('>') >= 0 ) { 210 if ( mToolTipText.find ('>') >= 0 ) {
211 mToolTipText.replace( QRegExp(">") , "&gt;" ); 211 mToolTipText.replace( QRegExp(">") , "&gt;" );
212 } 212 }
213#endif 213#endif
214 //qDebug("TTT: %s ", mToolTipText.latin1()); 214 //qDebug("TTT: %s ", mToolTipText.latin1());
215 mToolTip.append( mToolTipText ); 215 mToolTip.append( mToolTipText );
216 } 216 }
217 mToolTip.sort(); 217 mToolTip.sort();
218 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); 218 return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>");
219} 219}
220void KODayMatrix::setCalendar( Calendar *cal ) 220void KODayMatrix::setCalendar( Calendar *cal )
221{ 221{
222 mCalendar = cal; 222 mCalendar = cal;
223 223
224 setAcceptDrops( mCalendar ); 224 setAcceptDrops( mCalendar );
225 225
226 updateEvents(); 226 updateEvents();
227} 227}
228 228
229QColor KODayMatrix::getShadedColor(QColor color) 229QColor KODayMatrix::getShadedColor(QColor color)
230{ 230{
231 QColor shaded; 231 QColor shaded;
232 int h=0; 232 int h=0;
233 int s=0; 233 int s=0;
234 int v=0; 234 int v=0;
235 color.hsv(&h,&s,&v); 235 color.hsv(&h,&s,&v);
236 s = s/4; 236 s = s/4;
237 v = 192+v/4; 237 v = 192+v/4;
238 shaded.setHsv(h,s,v); 238 shaded.setHsv(h,s,v);
239 239
240 return shaded; 240 return shaded;
241} 241}
242 242
243KODayMatrix::~KODayMatrix() 243KODayMatrix::~KODayMatrix()
244{ 244{
245#if QT_VERSION >= 0x030000 245#if QT_VERSION >= 0x030000
246 246
247#else 247#else
248 delete mKODaymatrixWhatsThis; 248 delete mKODaymatrixWhatsThis;
249#endif 249#endif
250 250
251 // delete mKODaymatrixWhatsThis; 251 // delete mKODaymatrixWhatsThis;
252 delete [] days; 252 delete [] days;
253 delete [] daylbls; 253 delete [] daylbls;
254 //delete [] events; 254 //delete [] events;
255 delete mToolTip; 255 delete mToolTip;
256} 256}
257 257
258/* 258/*
259void KODayMatrix::setStartDate(QDate start) 259void KODayMatrix::setStartDate(QDate start)
260{ 260{
261 updateView(start); 261 updateView(start);
262} 262}
263*/ 263*/
264 264
265void KODayMatrix::addSelectedDaysTo(DateList& selDays) 265void KODayMatrix::addSelectedDaysTo(DateList& selDays)
266{ 266{
267 267
268 if (mSelStart == NOSELECTION) { 268 if (mSelStart == NOSELECTION) {
269 return; 269 return;
270 } 270 }
271 271
272 //cope with selection being out of matrix limits at top (< 0) 272 //cope with selection being out of matrix limits at top (< 0)
273 int i0 = mSelStart; 273 int i0 = mSelStart;
274 if (i0 < 0) { 274 if (i0 < 0) {
275 for (int i = i0; i < 0; i++) { 275 for (int i = i0; i < 0; i++) {
276 selDays.append(days[0].addDays(i)); 276 selDays.append(days[0].addDays(i));
277 } 277 }
278 i0 = 0; 278 i0 = 0;
279 } 279 }
280 280
281 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 281 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
282 if (mSelEnd > NUMDAYS-1) { 282 if (mSelEnd > NUMDAYS-1) {
283 for (int i = i0; i <= NUMDAYS-1; i++) { 283 for (int i = i0; i <= NUMDAYS-1; i++) {
284 selDays.append(days[i]); 284 selDays.append(days[i]);
285 } 285 }
286 for (int i = NUMDAYS; i < mSelEnd; i++) { 286 for (int i = NUMDAYS; i < mSelEnd; i++) {
287 selDays.append(days[0].addDays(i)); 287 selDays.append(days[0].addDays(i));
288 } 288 }
289 289
290 // apply normal routine to selection being entirely within matrix limits 290 // apply normal routine to selection being entirely within matrix limits
291 } else { 291 } else {
292 for (int i = i0; i <= mSelEnd; i++) { 292 for (int i = i0; i <= mSelEnd; i++) {
293 selDays.append(days[i]); 293 selDays.append(days[i]);
294 } 294 }
295 } 295 }
296} 296}
297 297
298bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 298bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
299{ 299{
300 mRedrawNeeded = true; 300 mRedrawNeeded = true;
301 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION ); 301 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
302 mSelStart = startdate.daysTo(start); 302 mSelStart = startdate.daysTo(start);
303 if ( mSelStart < 0 ) 303 if ( mSelStart < 0 )
304 mSelStart = 0; 304 mSelStart = 0;
305 mSelEnd = startdate.daysTo(end); 305 mSelEnd = startdate.daysTo(end);
306 if ( mSelEnd > NUMDAYS-1 ) 306 if ( mSelEnd > NUMDAYS-1 )
307 mSelEnd = NUMDAYS-1; 307 mSelEnd = NUMDAYS-1;
308 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) { 308 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
309 clearSelection(); 309 clearSelection();
310 if ( noSel ) 310 if ( noSel )
311 return false; 311 return false;
312 } 312 }
313 313
314 return true; 314 return true;
315} 315}
316void KODayMatrix::clearSelection() 316void KODayMatrix::clearSelection()
317{ 317{
318 mSelEnd = mSelStart = NOSELECTION; 318 mSelEnd = mSelStart = NOSELECTION;
319} 319}
320 320
321 321
322void KODayMatrix::recalculateToday() 322void KODayMatrix::recalculateToday()
323{ 323{
324 today = -1; 324 today = -1;
325 for (int i=0; i<NUMDAYS; i++) { 325 for (int i=0; i<NUMDAYS; i++) {
326 //events[i] = 0; 326 //events[i] = 0;
327 days[i] = startdate.addDays(i); 327 days[i] = startdate.addDays(i);
328 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 328 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
329 329
330 // if today is in the currently displayed month, hilight today 330 // if today is in the currently displayed month, hilight today
331 if (days[i].year() == QDate::currentDate().year() && 331 if (days[i].year() == QDate::currentDate().year() &&
332 days[i].month() == QDate::currentDate().month() && 332 days[i].month() == QDate::currentDate().month() &&
333 days[i].day() == QDate::currentDate().day()) { 333 days[i].day() == QDate::currentDate().day()) {
334 today = i; 334 today = i;
335 } 335 }
336 } 336 }
337 // qDebug(QString("Today is visible at %1.").arg(today)); 337 // qDebug(QString("Today is visible at %1.").arg(today));
338} 338}
339 339
340void KODayMatrix::updateView() 340void KODayMatrix::updateView()
341{ 341{
342 updateView(startdate); 342 updateView(startdate);
343} 343}
344void KODayMatrix::repaintViewTimed() 344void KODayMatrix::repaintViewTimed()
345{ 345{
346 mRedrawNeeded = true; 346 mRedrawNeeded = true;
347 // bDays.fill( false); 347 // bDays.fill( false);
348 //pDays.fill( false); 348 //pDays.fill( false);
349 //hDays.fill( false); 349 //hDays.fill( false);
350 //eDays.fill( false); 350 //eDays.fill( false);
351 mRepaintTimer->stop(); 351 mRepaintTimer->stop();
352 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 352 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
353 int i; 353 int i;
354 for(i = 0; i < NUMDAYS; i++) { 354 for(i = 0; i < NUMDAYS; i++) {
355 if ( ( (i+startDay) % 7 == 0 ) ) { 355 if ( ( (i+startDay) % 7 == 0 ) ) {
356 pDays.setBit(i); 356 pDays.setBit(i);
357 } 357 }
358 } 358 }
359 repaint(false); 359 repaint(false);
360} 360}
361void KODayMatrix::computeEvent(Event *event, int i ) 361void KODayMatrix::computeEvent(Event *event, int i )
362{ 362{
363 QString holiStr = mHolidays[i]; 363 QString holiStr = mHolidays[i];
364 if ( event->isHoliday()) { 364 if ( event->isHoliday()) {
365 pDays.setBit(i); 365 pDays.setBit(i);
366 hDays.setBit(i); 366 hDays.setBit(i);
367 if ( !holiStr.isEmpty() ) 367 if ( !holiStr.isEmpty() )
368 holiStr += "\n"; 368 holiStr += "\n";
369 holiStr += event->summary(); 369 holiStr += event->summary();
370 if ( !event->location().isEmpty() ) 370 if ( !event->location().isEmpty() )
371 holiStr += " (" + event->location() + ")"; 371 holiStr += " (" + event->location() + ")";
372 mHolidays[i] =holiStr ; 372 mHolidays[i] =holiStr ;
373 eDays.setBit(i); 373 eDays.setBit(i);
374 } 374 }
375 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) { 375 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_T_VIEW && KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) {
376 if ( event->isBirthday()) { 376 if ( event->isBirthday()) {
377 pDays.setBit(i); 377 pDays.setBit(i);
378 if ( !holiStr.isEmpty() ) 378 if ( !holiStr.isEmpty() )
379 holiStr += "\n"; 379 holiStr += "\n";
380 holiStr += i18n("Birthday") + ": "+event->summary(); 380 holiStr += i18n("Birthday") + ": "+event->summary();
381 if ( !event->location().isEmpty() ) 381 if ( !event->location().isEmpty() )
382 holiStr += " (" + event->location() + ")"; 382 holiStr += " (" + event->location() + ")";
383 bDays.setBit(i); 383 bDays.setBit(i);
384 mHolidays[i] =holiStr ; 384 mHolidays[i] =holiStr ;
385 } 385 }
386 } 386 }
387 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW ) 387 if ( KOPrefs::instance()->mCurrentDisplayedView != VIEW_J_VIEW )
388 eDays.setBit(i); 388 eDays.setBit(i);
389} 389}
390void KODayMatrix::updateViewTimed() 390void KODayMatrix::updateViewTimed()
391{ 391{
392 mUpdateTimer->stop(); 392 mUpdateTimer->stop();
393 if ( !mCalendar ) { 393 if ( !mCalendar ) {
394 qDebug("NOT CAL "); 394 qDebug("NOT CAL ");
395 return; 395 return;
396 } 396 }
397#if 1 397#if 1
398 398
399 399
400 int i; 400 int i;
401 int timeSpan = NUMDAYS-1; 401 int timeSpan = NUMDAYS-1;
402 QPtrList<Event> events = mCalendar->events(); 402 QPtrList<Event> events = mCalendar->events();
403 Event *event; 403 Event *event;
404 QDateTime dt; 404 QDateTime dt;
405 bool ok; 405 bool ok;
406 bDays.fill( false); 406 bDays.fill( false);
407 pDays.fill( false); 407 pDays.fill( false);
408 hDays.fill( false); 408 hDays.fill( false);
409 eDays.fill( false); 409 eDays.fill( false);
410 mHolidays.clear(); 410 mHolidays.clear();
411 QDate mStartDate = days[0]; 411 QDate mStartDate = days[0];
412 QDate endDate = mStartDate.addDays( timeSpan ); 412 QDate endDate = mStartDate.addDays( timeSpan );
413 for( event = events.first(); event; event = events.next() ) { // for event 413 for( event = events.first(); event; event = events.next() ) { // for event
414 ushort recurType = event->recurrence()->doesRecur(); 414 ushort recurType = event->recurrence()->doesRecur();
415 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 415 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
416 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 416 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
417 continue; 417 continue;
418 } 418 }
419 if ( event->doesRecur() ) { 419 if ( event->doesRecur() ) {
420 bool last; 420 bool last;
421 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 421 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
422 QDateTime incidenceEnd; 422 QDateTime incidenceEnd;
423 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 423 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
424 bool invalid = false; 424 bool invalid = false;
425 while( true ) { 425 while( true ) {
426 if ( incidenceStart.isValid() ) { 426 if ( incidenceStart.isValid() ) {
427 incidenceEnd = incidenceStart.addDays( eventlen ); 427 incidenceEnd = incidenceStart.addDays( eventlen );
428 int st = incidenceStart.date().daysTo( endDate ); 428 int st = incidenceStart.date().daysTo( endDate );
429 if ( st >= 0 ) { // start before timeend 429 if ( st >= 0 ) { // start before timeend
430 int end = mStartDate.daysTo( incidenceEnd.date() ); 430 int end = mStartDate.daysTo( incidenceEnd.date() );
431 if ( end >= 0 ) { // end after timestart --- got one! 431 if ( end >= 0 ) { // end after timestart --- got one!
432 //normalize 432 //normalize
433 st = timeSpan - st; 433 st = timeSpan - st;
434 if ( st < 0 ) st = 0; 434 if ( st < 0 ) st = 0;
435 if ( end > timeSpan ) end = timeSpan; 435 if ( end > timeSpan ) end = timeSpan;
436 int iii; 436 int iii;
437 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 437 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
438 for ( iii = st;iii<= end;++iii) { 438 for ( iii = st;iii<= end;++iii) {
439 computeEvent( event, iii ); 439 computeEvent( event, iii );
440 } 440 }
441 } 441 }
442 } 442 }
443 } else { 443 } else {
444 if ( invalid ) 444 if ( invalid )
445 break; 445 break;
446 invalid = true; 446 invalid = true;
447 //qDebug("invalid %s", event->summary().latin1()); 447 //qDebug("invalid %s", event->summary().latin1());
448 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 448 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
449 } 449 }
450 if ( last ) 450 if ( last )
451 break; 451 break;
452 bool ok; 452 bool ok;
453 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 453 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
454 if ( ! ok ) 454 if ( ! ok )
455 break; 455 break;
456 if ( incidenceStart.date() > endDate ) 456 if ( incidenceStart.date() > endDate )
457 break; 457 break;
458 } 458 }
459 } else { // no recur 459 } else { // no recur
460 int st = event->dtStart().date().daysTo( endDate ); 460 int st = event->dtStart().date().daysTo( endDate );
461 if ( st >= 0 ) { // start before timeend 461 if ( st >= 0 ) { // start before timeend
462 int end = mStartDate.daysTo( event->dtEnd().date() ); 462 int end = mStartDate.daysTo( event->dtEnd().date() );
463 if ( end >= 0 ) { // end after timestart --- got one! 463 if ( end >= 0 ) { // end after timestart --- got one!
464 //normalize 464 //normalize
465 st = timeSpan - st; 465 st = timeSpan - st;
466 if ( st < 0 ) st = 0; 466 if ( st < 0 ) st = 0;
467 if ( end > timeSpan ) end = timeSpan; 467 if ( end > timeSpan ) end = timeSpan;
468 int iii; 468 int iii;
469 for ( iii = st;iii<= end;++iii) 469 for ( iii = st;iii<= end;++iii)
470 computeEvent( event, iii ); 470 computeEvent( event, iii );
471 } 471 }
472 } 472 }
473 } 473 }
474 } 474 }
475 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday 475 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
476 for(i = 0; i < NUMDAYS; i++) { 476 for(i = 0; i < NUMDAYS; i++) {
477 if ( ( (i+startDay) % 7 == 0 ) ) { 477 if ( ( (i+startDay) % 7 == 0 ) ) {
478 pDays.setBit(i); 478 pDays.setBit(i);
479 } 479 }
480 } 480 }
481 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 481 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
482 bDays.fill( false); 482 bDays.fill( false);
483 // insert due todos 483 // insert due todos
484 QPtrList<Todo> todos = mCalendar->todos( ); 484 QPtrList<Todo> todos = mCalendar->todos( );
485 Todo *todo; 485 Todo *todo;
486 for(todo = todos.first(); todo; todo = todos.next()) { 486 for(todo = todos.first(); todo; todo = todos.next()) {
487 //insertTodo( todo ); 487 //insertTodo( todo );
488 if ( todo->hasDueDate() ) { 488 if ( todo->hasDueDate() ) {
489 int day = mStartDate.daysTo( todo->dtDue().date() ); 489 int day = mStartDate.daysTo( todo->dtDue().date() );
490 if ( day >= 0 && day < timeSpan + 1) { 490 if ( day >= 0 && day < timeSpan + 1) {
491 int i = day; 491 int i = day;
492 QString holiStr = mHolidays[i]; 492 QString holiStr = mHolidays[i];
493 pDays.setBit(i); 493 pDays.setBit(i);
494 if ( !holiStr.isEmpty() ) 494 if ( !holiStr.isEmpty() )
495 holiStr += "\n"; 495 holiStr += "\n";
496 holiStr += i18n("Todo") + ": "+todo->summary(); 496 holiStr += i18n("Todo") + ": "+todo->summary();
497 if ( !todo->location().isEmpty() ) 497 if ( !todo->location().isEmpty() )
498 holiStr += " (" + todo->location() + ")"; 498 holiStr += " (" + todo->location() + ")";
499 bDays.setBit(i); 499 bDays.setBit(i);
500 mHolidays[i] =holiStr ; 500 mHolidays[i] =holiStr ;
501 eDays.setBit(i); 501 eDays.setBit(i);
502 } 502 }
503 } 503 }
504 } 504 }
505 } 505 }
506 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 506 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
507 bDays.fill( false); 507 bDays.fill( false);
508 // insert due todos 508 // insert due todos
509 QPtrList<Journal> todos = mCalendar->journals( ); 509 QPtrList<Journal> todos = mCalendar->journals( );
510 Journal *todo; 510 Journal *todo;
511 for(todo = todos.first(); todo; todo = todos.next()) { 511 for(todo = todos.first(); todo; todo = todos.next()) {
512 int day = mStartDate.daysTo( todo->dtStart().date() ); 512 int day = mStartDate.daysTo( todo->dtStart().date() );
513 if ( day >= 0 && day < timeSpan + 1) { 513 if ( day >= 0 && day < timeSpan + 1) {
514 int i = day; 514 int i = day;
515 QString holiStr = mHolidays[i]; 515 QString holiStr = mHolidays[i];
516 pDays.setBit(i); 516 pDays.setBit(i);
517 if ( !holiStr.isEmpty() ) 517 if ( !holiStr.isEmpty() )
518 holiStr += "\n"; 518 holiStr += "\n";
519 holiStr += i18n("Journal"); 519 holiStr += i18n("Journal");
520 bDays.setBit(i); 520 bDays.setBit(i);
521 mHolidays[i] =holiStr ; 521 mHolidays[i] =holiStr ;
522 eDays.setBit(i); 522 eDays.setBit(i);
523 523
524 } 524 }
525 } 525 }
526 } 526 }
527#else 527#else
528 //qDebug("KODayMatrix::updateViewTimed "); 528 //qDebug("KODayMatrix::updateViewTimed ");
529 for(int i = 0; i < NUMDAYS; i++) { 529 for(int i = 0; i < NUMDAYS; i++) {
530 // if events are set for the day then remember to draw it bold 530 // if events are set for the day then remember to draw it bold
531 QPtrList<Event> eventlist = mCalendar->events(days[i]); 531 QPtrList<Event> eventlist = mCalendar->events(days[i]);
532 Event *event; 532 Event *event;
533 int numEvents = eventlist.count(); 533 int numEvents = eventlist.count();
534 QString holiStr = ""; 534 QString holiStr = "";
535 bDays.clearBit(i); 535 bDays.clearBit(i);
536 hDays.clearBit(i); 536 hDays.clearBit(i);
537 eDays.clearBit(i); 537 eDays.clearBit(i);
538 for(event=eventlist.first();event != 0;event=eventlist.next()) { 538 for(event=eventlist.first();event != 0;event=eventlist.next()) {
539 ushort recurType = event->recurrence()->doesRecur(); 539 ushort recurType = event->recurrence()->doesRecur();
540 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 540 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
541 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 541 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
542 numEvents--; 542 numEvents--;
543 } 543 }
544 if ( event->isHoliday()) { 544 if ( event->isHoliday()) {
545 hDays.setBit(i); 545 hDays.setBit(i);
546 if ( !holiStr.isEmpty() ) 546 if ( !holiStr.isEmpty() )
547 holiStr += "\n"; 547 holiStr += "\n";
548 holiStr += event->summary(); 548 holiStr += event->summary();
549 if ( !event->location().isEmpty() ) 549 if ( !event->location().isEmpty() )
550 holiStr += " (" + event->location() + ")"; 550 holiStr += " (" + event->location() + ")";
551 } 551 }
552 if ( event->isBirthday()) { 552 if ( event->isBirthday()) {
553 if ( !holiStr.isEmpty() ) 553 if ( !holiStr.isEmpty() )
554 holiStr += "\n"; 554 holiStr += "\n";
555 holiStr += i18n("Birthday") + ": "+event->summary(); 555 holiStr += i18n("Birthday") + ": "+event->summary();
556 if ( !event->location().isEmpty() ) 556 if ( !event->location().isEmpty() )
557 holiStr += " (" + event->location() + ")"; 557 holiStr += " (" + event->location() + ")";
558 bDays.setBit(i); 558 bDays.setBit(i);
559 } 559 }
560 } 560 }
561 if ( numEvents ) 561 if ( numEvents )
562 eDays.setBit(i); 562 eDays.setBit(i);
563 //if it is a holy day then draw it red. Sundays are consider holidays, too 563 //if it is a holy day then draw it red. Sundays are consider holidays, too
564 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 564 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
565 !holiStr.isEmpty()) { 565 !holiStr.isEmpty()) {
566 mHolidays[i] = holiStr; 566 mHolidays[i] = holiStr;
567 } else { 567 } else {
568 mHolidays[i] = QString::null; 568 mHolidays[i] = QString::null;
569 } 569 }
570 } 570 }
571#endif 571#endif
572 mRedrawNeeded = true; 572 mRedrawNeeded = true;
573 if ( ! mPendingUpdateBeforeRepaint ) 573 if ( ! mPendingUpdateBeforeRepaint )
574 repaint(false); 574 repaint(false);
575} 575}
576void KODayMatrix::updateView(QDate actdate) 576void KODayMatrix::updateView(QDate actdate)
577{ 577{
578 if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView ) 578 if ( mLastView != KOPrefs::instance()->mCurrentDisplayedView )
579 mRedrawNeeded = true; 579 mRedrawNeeded = true;
580 mLastView = KOPrefs::instance()->mCurrentDisplayedView; 580 mLastView = KOPrefs::instance()->mCurrentDisplayedView;
581 if ( ! actdate.isValid() ) { 581 if ( ! actdate.isValid() ) {
582 //qDebug("date not valid "); 582 //qDebug("date not valid ");
583 return; 583 return;
584 } 584 }
585 mDayChanged = false; 585 mDayChanged = false;
586 //flag to indicate if the starting day of the matrix has changed by this call 586 //flag to indicate if the starting day of the matrix has changed by this call
587 //mDayChanged = false; 587 //mDayChanged = false;
588 // if a new startdate is to be set then apply Cornelius's calculation 588 // if a new startdate is to be set then apply Cornelius's calculation
589 // of the first day to be shown 589 // of the first day to be shown
590 if (actdate != startdate) { 590 if (actdate != startdate) {
591 // reset index of selection according to shift of starting date from startdate to actdate 591 // reset index of selection according to shift of starting date from startdate to actdate
592 if (mSelStart != NOSELECTION) { 592 if (mSelStart != NOSELECTION) {
593 int tmp = actdate.daysTo(startdate); 593 int tmp = actdate.daysTo(startdate);
594 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 594 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
595 // shift selection if new one would be visible at least partly ! 595 // shift selection if new one would be visible at least partly !
596 596
597 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 597 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
598 // nested if is required for next X display pushed from a different month - correction required 598 // nested if is required for next X display pushed from a different month - correction required
599 // otherwise, for month forward and backward, it must be avoided 599 // otherwise, for month forward and backward, it must be avoided
600 if( mSelStart > NUMDAYS || mSelStart < 0 ) 600 if( mSelStart > NUMDAYS || mSelStart < 0 )
601 mSelStart = mSelStart + tmp; 601 mSelStart = mSelStart + tmp;
602 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 602 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
603 mSelEnd = mSelEnd + tmp; 603 mSelEnd = mSelEnd + tmp;
604 } 604 }
605 } 605 }
606 startdate = actdate; 606 startdate = actdate;
607 mDayChanged = true; 607 mDayChanged = true;
608 recalculateToday(); 608 recalculateToday();
609 mRedrawNeeded = true; 609 mRedrawNeeded = true;
610 } 610 }
611 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 611 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
612 if ( !isVisible() ) { 612 if ( !isVisible() ) {
613 mPendingUpdateBeforeRepaint = true; 613 mPendingUpdateBeforeRepaint = true;
614 } else { 614 } else {
615#ifdef DESKTOP_VERSION 615#ifdef DESKTOP_VERSION
616 //mRepaintTimer->start( 100 ); 616 //mRepaintTimer->start( 100 );
617 //updateViewTimed(); 617 //updateViewTimed();
618 mUpdateTimer->start( 50 ); 618 mUpdateTimer->start( 50 );
619#else 619#else
620 mRepaintTimer->start( 350 ); 620 mRepaintTimer->start( 350 );
621 mUpdateTimer->start( 800 ); 621 mUpdateTimer->start( 800 );
622#endif 622#endif
623 } 623 }
624} 624}
625void KODayMatrix::updateEvents() 625void KODayMatrix::updateEvents()
626{ 626{
627 if ( !mCalendar ) return; 627 if ( !mCalendar ) return;
628 628
629 for( int i = 0; i < NUMDAYS; i++ ) { 629 for( int i = 0; i < NUMDAYS; i++ ) {
630 // if events are set for the day then remember to draw it bold 630 // if events are set for the day then remember to draw it bold
631 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 631 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
632 int numEvents = eventlist.count(); 632 int numEvents = eventlist.count();
633 Event *event; 633 Event *event;
634 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 634 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
635 ushort recurType = event->doesRecur(); 635 ushort recurType = event->doesRecur();
636 636
637 if ( ( recurType == Recurrence::rDaily && 637 if ( ( recurType == Recurrence::rDaily &&
638 !KOPrefs::instance()->mDailyRecur ) || 638 !KOPrefs::instance()->mDailyRecur ) ||
639 ( recurType == Recurrence::rWeekly && 639 ( recurType == Recurrence::rWeekly &&
640 !KOPrefs::instance()->mWeeklyRecur ) ) { 640 !KOPrefs::instance()->mWeeklyRecur ) ) {
641 numEvents--; 641 numEvents--;
642 } 642 }
643 } 643 }
644 if ( numEvents ) 644 if ( numEvents )
645 eDays.setBit(i); 645 eDays.setBit(i);
646 else 646 else
647 eDays.clearBit(i); 647 eDays.clearBit(i);
648 } 648 }
649} 649}
650 650
651const QDate& KODayMatrix::getDate(int offset) 651const QDate& KODayMatrix::getDate(int offset)
652{ 652{
653 if (offset < 0 || offset > NUMDAYS-1) { 653 if (offset < 0 || offset > NUMDAYS-1) {
654 qDebug("Wrong offset2 %d", offset); 654 qDebug("Wrong offset2 %d", offset);
655 return days[0]; 655 return days[0];
656 } 656 }
657 return days[offset]; 657 return days[offset];
658} 658}
659 659
660QString KODayMatrix::getHolidayLabel(int offset) 660QString KODayMatrix::getHolidayLabel(int offset)
661{ 661{
662 if (offset < 0 || offset > NUMDAYS-1) { 662 if (offset < 0 || offset > NUMDAYS-1) {
663 qDebug("Wrong offset1 %d", offset); 663 qDebug("Wrong offset1 %d", offset);
664 return QString(); 664 return QString();
665 } 665 }
666 return mHolidays[offset]; 666 return mHolidays[offset];
667} 667}
668 668
669int KODayMatrix::getDayIndexFrom(int x, int y) 669int KODayMatrix::getDayIndexFrom(int x, int y)
670{ 670{
671 int colModulo = (width()-2) % 7; 671 int colModulo = (width()-2) % 7;
672 int rowModulo = (height()-2) % 6; 672 int rowModulo = (height()-2) % 6;
673#if 0 673#if 0
674 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 674 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
675 6 - x/daysize.width() : x/daysize.width()); 675 6 - x/daysize.width() : x/daysize.width());
676#endif 676#endif
677 int xVal = (x-colModulo/2-2)/daysize.width(); 677 int xVal = (x-colModulo/2-2)/daysize.width();
678 int yVal = (y-rowModulo/2-2)/daysize.height(); 678 int yVal = (y-rowModulo/2-2)/daysize.height();
679 679
680 680
681 return 7*(yVal) + xVal; 681 return 7*(yVal) + xVal;
682 682
683} 683}
684 684
685// ---------------------------------------------------------------------------- 685// ----------------------------------------------------------------------------
686// M O U S E E V E N T H A N D L I N G 686// M O U S E E V E N T H A N D L I N G
687// ---------------------------------------------------------------------------- 687// ----------------------------------------------------------------------------
688 688
689void KODayMatrix::mousePressEvent (QMouseEvent* e) 689void KODayMatrix::mousePressEvent (QMouseEvent* e)
690{ 690{
691 691
692 if ( e->button() == LeftButton ) 692 if ( e->button() == LeftButton )
693 mouseDown = true; 693 mouseDown = true;
694 mSelStart = getDayIndexFrom(e->x(), e->y()); 694 mSelStart = getDayIndexFrom(e->x(), e->y());
695 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 695 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
696 mSelInit = mSelStart; 696 mSelInit = mSelStart;
697 mSelEnd = mSelStart; 697 mSelEnd = mSelStart;
698 mRedrawNeeded = true; 698 mRedrawNeeded = true;
699 repaint(false); 699 repaint(false);
700} 700}
701 701
702void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 702void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
703{ 703{
704 mRedrawNeeded = true; 704 mRedrawNeeded = true;
705 if ( e->button() == LeftButton ) 705 if ( e->button() == LeftButton )
706 if ( ! mouseDown ) { 706 if ( ! mouseDown ) {
707 return; 707 return;
708 } 708 }
709 else 709 else
710 mouseDown = false; 710 mouseDown = false;
711 int tmp = getDayIndexFrom(e->x(), e->y()); 711 int tmp = getDayIndexFrom(e->x(), e->y());
712 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 712 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
713 713
714 if (mSelInit > tmp) { 714 if (mSelInit > tmp) {
715 mSelEnd = mSelInit; 715 mSelEnd = mSelInit;
716 if (tmp != mSelStart) { 716 if (tmp != mSelStart) {
717 mSelStart = tmp; 717 mSelStart = tmp;
718 repaint(false); 718 repaint(false);
719 } 719 }
720 } else { 720 } else {
721 mSelStart = mSelInit; 721 mSelStart = mSelInit;
722 722
723 //repaint only if selection has changed 723 //repaint only if selection has changed
724 if (tmp != mSelEnd) { 724 if (tmp != mSelEnd) {
725 mSelEnd = tmp; 725 mSelEnd = tmp;
726 repaint(false); 726 repaint(false);
727 } 727 }
728 } 728 }
729 729
730 DateList daylist; 730 DateList daylist;
731 if ( mSelStart < 0 ) 731 if ( mSelStart < 0 )
732 mSelStart = 0; 732 mSelStart = 0;
733 for (int i = mSelStart; i <= mSelEnd; i++) { 733 for (int i = mSelStart; i <= mSelEnd; i++) {
734 daylist.append(days[i]); 734 daylist.append(days[i]);
735 } 735 }
736 emit selected((const DateList)daylist); 736 emit selected((const DateList)daylist);
737 737
738} 738}
739 739
740void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 740void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
741{ 741{
742 if ( ! mouseDown ) { 742 if ( ! mouseDown ) {
743 return; 743 return;
744 } 744 }
745 mRedrawNeeded = true; 745 mRedrawNeeded = true;
746 int tmp = getDayIndexFrom(e->x(), e->y()); 746 int tmp = getDayIndexFrom(e->x(), e->y());
747 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 747 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
748 748
749 if (mSelInit > tmp) { 749 if (mSelInit > tmp) {
750 mSelEnd = mSelInit; 750 mSelEnd = mSelInit;
751 if (tmp != mSelStart) { 751 if (tmp != mSelStart) {
752 mSelStart = tmp; 752 mSelStart = tmp;
753 repaint(false); 753 repaint(false);
754 } 754 }
755 } else { 755 } else {
756 mSelStart = mSelInit; 756 mSelStart = mSelInit;
757 757
758 //repaint only if selection has changed 758 //repaint only if selection has changed
759 if (tmp != mSelEnd) { 759 if (tmp != mSelEnd) {
760 mSelEnd = tmp; 760 mSelEnd = tmp;
761 repaint(false); 761 repaint(false);
762 } 762 }
763 } 763 }
764} 764}
765 765
766// ---------------------------------------------------------------------------- 766// ----------------------------------------------------------------------------
767// D R A G ' N D R O P H A N D L I N G 767// D R A G ' N D R O P H A N D L I N G
768// ---------------------------------------------------------------------------- 768// ----------------------------------------------------------------------------
769 769
770void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 770void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
771{ 771{
772#ifndef KORG_NODND 772#ifndef KORG_NODND
773 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 773 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
774 e->ignore(); 774 e->ignore();
775 return; 775 return;
776 } 776 }
777 777
778 // some visual feedback 778 // some visual feedback
779// oldPalette = palette(); 779// oldPalette = palette();
780// setPalette(my_HilitePalette); 780// setPalette(my_HilitePalette);
781// update(); 781// update();
782#endif 782#endif
783} 783}
784 784
785void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 785void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
786{ 786{
787#ifndef KORG_NODND 787#ifndef KORG_NODND
788 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 788 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
789 e->ignore(); 789 e->ignore();
790 return; 790 return;
791 } 791 }
792 792
793 e->accept(); 793 e->accept();
794#endif 794#endif
795} 795}
796 796
797void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 797void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
798{ 798{
799#ifndef KORG_NODND 799#ifndef KORG_NODND
800// setPalette(oldPalette); 800// setPalette(oldPalette);
801// update(); 801// update();
802#endif 802#endif
803} 803}
804 804
805void KODayMatrix::dropEvent(QDropEvent *e) 805void KODayMatrix::dropEvent(QDropEvent *e)
806{ 806{
807#ifndef KORG_NODND 807#ifndef KORG_NODND
808// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 808// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
809 809
810 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 810 if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
811 e->ignore(); 811 e->ignore();
812 return; 812 return;
813 } 813 }
814 814
815 DndFactory factory( mCalendar ); 815 DndFactory factory( mCalendar );
816 Event *event = factory.createDrop(e); 816 Event *event = factory.createDrop(e);
817 817
818 if (event) { 818 if (event) {
819 e->acceptAction(); 819 e->acceptAction();
820 820
821 Event *existingEvent = mCalendar->event(event->uid()); 821 Event *existingEvent = mCalendar->event(event->uid());
822 822
823 if(existingEvent) { 823 if(existingEvent) {
824 // uniquify event 824 // uniquify event
825 event->recreate(); 825 event->recreate();
826/* 826/*
827 KMessageBox::sorry(this, 827 KMessageBox::sorry(this,
828 i18n("Event already exists in this calendar."), 828 i18n("Event already exists in this calendar."),
829 i18n("Drop Event")); 829 i18n("Drop Event"));
830 delete event; 830 delete event;
831 return; 831 return;
832*/ 832*/
833 } 833 }
834// kdDebug() << "Drop new Event" << endl; 834// kdDebug() << "Drop new Event" << endl;
835 // Adjust date 835 // Adjust date
836 QDateTime start = event->dtStart(); 836 QDateTime start = event->dtStart();
837 QDateTime end = event->dtEnd(); 837 QDateTime end = event->dtEnd();
838 int duration = start.daysTo(end); 838 int duration = start.daysTo(end);
839 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 839 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
840 840
841 start.setDate(days[idx]); 841 start.setDate(days[idx]);
842 end.setDate(days[idx].addDays(duration)); 842 end.setDate(days[idx].addDays(duration));
843 843
844 event->setDtStart(start); 844 event->setDtStart(start);
845 event->setDtEnd(end); 845 event->setDtEnd(end);
846 mCalendar->addEvent(event); 846 mCalendar->addEvent(event);
847 847
848 emit eventDropped(event); 848 emit eventDropped(event);
849 } else { 849 } else {
850// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 850// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
851 e->ignore(); 851 e->ignore();
852 } 852 }
853#endif 853#endif
854} 854}
855 855
856// ---------------------------------------------------------------------------- 856// ----------------------------------------------------------------------------
857// P A I N T E V E N T H A N D L I N G 857// P A I N T E V E N T H A N D L I N G
858// ---------------------------------------------------------------------------- 858// ----------------------------------------------------------------------------
859 859
860void KODayMatrix::paintEvent(QPaintEvent * pevent) 860void KODayMatrix::paintEvent(QPaintEvent * pevent)
861{ 861{
862 862
863 if ( width() <= 0 || height() <= 0 ) 863 if ( width() <= 0 || height() <= 0 )
864 return; 864 return;
865 if ( mPendingUpdateBeforeRepaint ) { 865 if ( mPendingUpdateBeforeRepaint ) {
866 updateViewTimed(); 866 updateViewTimed();
867 mPendingUpdateBeforeRepaint = false; 867 mPendingUpdateBeforeRepaint = false;
868 } 868 }
869#if 0 869#if 0
870 if ( myPix.width() != width() || myPix.height()!=height() ) { 870 if ( myPix.width() != width() || myPix.height()!=height() ) {
871 myPix.resize(size() ); 871 myPix.resize(size() );
872 mRedrawNeeded = true; 872 mRedrawNeeded = true;
873 } 873 }
874#endif 874#endif
875 if ( oldW != width() || oldH !=height() ) 875 if ( oldW != width() || oldH !=height() )
876 mRedrawNeeded = true; 876 mRedrawNeeded = true;
877 877
878 oldH = height() ; 878 oldH = height() ;
879 oldW = width(); 879 oldW = width();
880 if ( myPix.width() < width() || myPix.height() < height() ) { 880 if ( myPix.width() < width() || myPix.height() < height() ) {
881 myPix.resize(size() ); 881 myPix.resize(size() );
882 mRedrawNeeded = true; 882 mRedrawNeeded = true;
883 883
884 } 884 }
885 885
886 if ( mRedrawNeeded ) { 886 if ( mRedrawNeeded ) {
887 //qDebug("REDRAW "); 887 //qDebug("REDRAW ");
888 QPainter p(&myPix); 888 QPainter p(&myPix);
889 p.setFont(font()); 889 p.setFont(font());
890 890
891 891
892 int dheight = daysize.height(); 892 int dheight = daysize.height();
893 int dwidth = daysize.width(); 893 int dwidth = daysize.width();
894 int row,col; 894 int row,col;
895 int selw, selh; 895 int selw, selh;
896 int xyOff = frameWidth(); 896 int xyOff = frameWidth();
897 int colModulo = (width()-2) % 7; 897 int colModulo = (width()-2) % 7;
898 int rowModulo = (height()-2) % 6; 898 int rowModulo = (height()-2) % 6;
899 //qDebug("col %d row %d ",colModulo,rowModulo ); 899 //qDebug("col %d row %d ",colModulo,rowModulo );
900 900
901 bool isRTL = KOGlobals::self()->reverseLayout(); 901 bool isRTL = KOGlobals::self()->reverseLayout();
902 902
903 // draw background and topleft frame 903 // draw background and topleft frame
904 p.fillRect(0,0,width(),height(), mDefaultBackColor); 904 p.fillRect(0,0,width(),height(), mDefaultBackColor);
905 p.setPen(mDefaultTextColor); 905 p.setPen(mDefaultTextColor);
906 p.drawRect(0, 0, width(), height()); 906 p.drawRect(0, 0, width(), height());
907 int mSelStartT = mSelStart; 907 int mSelStartT = mSelStart;
908 int mSelEndT = mSelEnd; 908 int mSelEndT = mSelEnd;
909 if ( mSelEndT >= NUMDAYS ) 909 if ( mSelEndT >= NUMDAYS )
910 mSelEndT = NUMDAYS-1; 910 mSelEndT = NUMDAYS-1;
911 // draw selected days with highlighted background color 911 // draw selected days with highlighted background color
912 if (mSelStart != NOSELECTION) { 912 if (mSelStart != NOSELECTION) {
913 bool skip = false; 913 bool skip = false;
914 if ( ! mouseDown ) { 914 if ( ! mouseDown ) {
915 int mo = days[20].month(); 915 int mo = days[20].month();
916 //qDebug("-- %d %d ", mSelStartT, mSelEndT); 916 //qDebug("-- %d %d ", mSelStartT, mSelEndT);
917 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); 917 //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
918 int startMo = days[mSelStartT].month(); 918 int startMo = days[mSelStartT].month();
919 int endMo = days[mSelEndT].month(); 919 int endMo = days[mSelEndT].month();
920 if ( startMo == 12 && mo == 1 && endMo <= 2 ) 920 if ( startMo == 12 && mo == 1 && endMo <= 2 )
921 startMo = 1; 921 startMo = 1;
922 if ( endMo == 1 && mo == 12 ) 922 if ( endMo == 1 && mo == 12 )
923 endMo = 12; 923 endMo = 12;
924 if ( mo == 12 && startMo == 1 ) 924 if ( mo == 12 && startMo == 1 )
925 startMo = 13; 925 startMo = 13;
926 if ( (startMo > mo || endMo < mo) ) { 926 if ( (startMo > mo || endMo < mo) ) {
927 skip = true; 927 skip = true;
928 } else { 928 } else {
929 if ( days[mSelStartT].month() != mo ) { 929 if ( days[mSelStartT].month() != mo ) {
930 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); 930 int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
931 mSelStartT += add +1; 931 mSelStartT += add +1;
932 } 932 }
933 if ( days[mSelEndT].month() != mo ) { 933 if ( days[mSelEndT].month() != mo ) {
934 int sub = days[mSelEndT].day(); 934 int sub = days[mSelEndT].day();
935 mSelEndT -= sub ; 935 mSelEndT -= sub ;
936 } 936 }
937 } 937 }
938 } 938 }
939 //qDebug("SKIP %d ", skip); 939 //qDebug("SKIP %d ", skip);
940 if ( ! skip ) { 940 if ( ! skip ) {
941 row = mSelStartT/7; 941 row = mSelStartT/7;
942 col = mSelStartT -row*7; 942 col = mSelStartT -row*7;
943 QColor selcol = KOPrefs::instance()->mHighlightColor; 943 QColor selcol = KOPrefs::instance()->mHighlightColor;
944 int addCol = 0; 944 int addCol = 0;
945 int addRow = 0; 945 int addRow = 0;
946 int addRow2 = 0; 946 int addRow2 = 0;
947 int addCol2 = 0; 947 int addCol2 = 0;
948 if (row == mSelEndT/7) { 948 if (row == mSelEndT/7) {
949 if ( rowModulo ) { 949 if ( rowModulo ) {
950 if ( row >= 6 - rowModulo ) 950 if ( row >= 6 - rowModulo )
951 addRow = row - 5 + rowModulo; 951 addRow = row - 5 + rowModulo;
952 } 952 }
953 if ( colModulo ) { 953 if ( colModulo ) {
954 int colt1 = mSelEndT%7; 954 int colt1 = mSelEndT%7;
955 //qDebug("colt1 %d ", colt1 ); 955 //qDebug("colt1 %d ", colt1 );
956 if ( colt1 >= 7 - colModulo ) 956 if ( colt1 >= 7 - colModulo )
957 addCol = colt1 - 7 + colModulo+1; 957 addCol = colt1 - 7 + colModulo+1;
958 int colt = mSelStartT%7; 958 int colt = mSelStartT%7;
959 if ( colt >= 7 - colModulo ) 959 if ( colt >= 7 - colModulo )
960 addCol2 = colt - 7 + colModulo; 960 addCol2 = colt - 7 + colModulo;
961 addCol -= addCol2; 961 addCol -= addCol2;
962 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 ); 962 //qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
963 } 963 }
964 // Single row selection 964 // Single row selection
965 //if ( row == 0) 965 //if ( row == 0)
966 // addRow = 1; 966 // addRow = 1;
967 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2, 967 p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
968 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol); 968 row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
969 } else { 969 } else {
970 // draw first row to the right 970 // draw first row to the right
971 if ( colModulo ) { 971 if ( colModulo ) {
972 if ( col >= 7 - colModulo ) 972 if ( col >= 7 - colModulo )
973 addCol2 = col - 7 + colModulo; 973 addCol2 = col - 7 + colModulo;
974 } 974 }
975 if ( rowModulo ) { 975 if ( rowModulo ) {
976 if ( row >= 6 - rowModulo ) 976 if ( row >= 6 - rowModulo )
977 addRow = row - 5 + rowModulo; 977 addRow = row - 5 + rowModulo;
978 } 978 }
979 //if ( row == 0) 979 //if ( row == 0)
980 // addRow = 1; 980 // addRow = 1;
981 int drawWid = width()-(col*dwidth+1+addCol2)-1; 981 int drawWid = width()-(col*dwidth+1+addCol2)-1;
982 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid, 982 p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, drawWid,
983 dheight+1, selcol); 983 dheight+1, selcol);
984 // draw full block till last line 984 // draw full block till last line
985 selh = mSelEndT/7-row; 985 selh = mSelEndT/7-row;
986 addRow = 0; 986 addRow = 0;
987 if ( rowModulo ) { 987 if ( rowModulo ) {
988 if ( mSelEndT/7 >= 6 - rowModulo ) 988 if ( mSelEndT/7 >= 6 - rowModulo )
989 addRow = mSelEndT/7 - 5 + rowModulo; 989 addRow = mSelEndT/7 - 5 + rowModulo;
990 } 990 }
991 //qDebug("%d %d %d ",selh, row, addRow ); 991 //qDebug("%d %d %d ",selh, row, addRow );
992 int addrow2 = addRow-selh+1; 992 int addrow2 = addRow-selh+1;
993 if ( addrow2 < 0 ) 993 if ( addrow2 < 0 )
994 addrow2 = 0; 994 addrow2 = 0;
995 if (selh > 1) { 995 if (selh > 1) {
996 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol); 996 p.fillRect(1, (row+1)*dheight+addrow2, 7*dwidth+colModulo, (selh-1)*dheight+addRow,selcol);
997 } 997 }
998 // draw last block from left to mSelEndT 998 // draw last block from left to mSelEndT
999 selw = mSelEndT-7*(mSelEndT/7)+1; 999 selw = mSelEndT-7*(mSelEndT/7)+1;
1000 //qDebug("esl %d ",selw ); 1000 //qDebug("esl %d ",selw );
1001 int add = 0; 1001 int add = 0;
1002 if ( colModulo ) { 1002 if ( colModulo ) {
1003 add = 7 - colModulo; 1003 add = 7 - colModulo;
1004 if ( selw > add ) 1004 if ( selw > add )
1005 add = selw - add; 1005 add = selw - add;
1006 else 1006 else
1007 add = 0; 1007 add = 0;
1008 } 1008 }
1009 //qDebug("add %d ", add); 1009 //qDebug("add %d ", add);
1010 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow, 1010 p.fillRect(isRTL ? (7-selw)*dwidth : 1, (row+selh)*dheight+addRow,
1011 selw*dwidth+add, dheight+1, selcol); 1011 selw*dwidth+add, dheight+1, selcol);
1012 } 1012 }
1013 } 1013 }
1014 } 1014 }
1015 1015
1016 // iterate over all days in the matrix and draw the day label in appropriate colors 1016 // iterate over all days in the matrix and draw the day label in appropriate colors
1017 QColor actcol = mDefaultTextColorShaded; 1017 QColor actcol = mDefaultTextColorShaded;
1018 p.setPen(actcol); 1018 p.setPen(actcol);
1019 QPen tmppen; 1019 QPen tmppen;
1020 for(int i = 0; i < NUMDAYS; i++) { 1020 for(int i = 0; i < NUMDAYS; i++) {
1021 row = i/7; 1021 row = i/7;
1022 col = isRTL ? 6-(i-row*7) : i-row*7; 1022 col = isRTL ? 6-(i-row*7) : i-row*7;
1023 1023
1024 // if it is the first day of a month switch color from normal to shaded and vice versa 1024 // if it is the first day of a month switch color from normal to shaded and vice versa
1025 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 1025 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
1026 if (actcol == mDefaultTextColorShaded) { 1026 if (actcol == mDefaultTextColorShaded) {
1027 actcol = mDefaultTextColor; 1027 actcol = mDefaultTextColor;
1028 } else { 1028 } else {
1029 actcol = mDefaultTextColorShaded; 1029 actcol = mDefaultTextColorShaded;
1030 } 1030 }
1031 p.setPen(actcol); 1031 p.setPen(actcol);
1032 } 1032 }
1033 if (actcol == mDefaultTextColorShaded) { 1033 if (actcol == mDefaultTextColorShaded) {
1034 if ( ! mouseDown ) { 1034 if ( ! mouseDown ) {
1035 continue; 1035 continue;
1036 } 1036 }
1037 } 1037 }
1038 //Reset pen color after selected days block 1038 //Reset pen color after selected days block
1039 if (i == mSelEndT+1) { 1039 if (i == mSelEndT+1) {
1040 p.setPen(actcol); 1040 p.setPen(actcol);
1041 } 1041 }
1042 1042
1043 // if today then draw rectangle around day 1043 // if today then draw rectangle around day
1044 if (today == i) { 1044 if (today == i) {
1045 tmppen = p.pen(); 1045 tmppen = p.pen();
1046 QPen mTodayPen(p.pen()); 1046 QPen mTodayPen(p.pen());
1047 if ( daysize.width() < 20 ) 1047 if ( daysize.width() < 20 )
1048 mTodayPen.setWidth(1); 1048 mTodayPen.setWidth(1);
1049 else 1049 else
1050 mTodayPen.setWidth(mTodayMarginWidth); 1050 mTodayPen.setWidth(mTodayMarginWidth);
1051 //draw red rectangle for holidays 1051 //draw red rectangle for holidays
1052 if (pDays.testBit(i)) { 1052 if (pDays.testBit(i)) {
1053 if (actcol == mDefaultTextColor) { 1053 if (actcol == mDefaultTextColor) {
1054 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 1054 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
1055 } else { 1055 } else {
1056 mTodayPen.setColor(mHolidayColorShaded); 1056 mTodayPen.setColor(mHolidayColorShaded);
1057 } 1057 }
1058 } 1058 }
1059 //draw gray rectangle for today if in selection 1059 //draw gray rectangle for today if in selection
1060 if (i >= mSelStartT && i <= mSelEndT) { 1060 if (i >= mSelStartT && i <= mSelEndT) {
1061 QColor grey("grey"); 1061 QColor grey("grey");
1062 mTodayPen.setColor(grey); 1062 mTodayPen.setColor(grey);
1063 } 1063 }
1064 p.setPen(mTodayPen); 1064 p.setPen(mTodayPen);
1065 1065
1066 1066
1067 int addCol = 0; 1067 int addCol = 0;
1068 int addRow = 0; 1068 int addRow = 0;
1069 if (rowModulo) { 1069 if (rowModulo) {
1070 if ( row >= 6 - rowModulo ) 1070 if ( row >= 6 - rowModulo )
1071 addRow = row - 5 + rowModulo; 1071 addRow = row - 5 + rowModulo;
1072 } 1072 }
1073 if ( colModulo ) { 1073 if ( colModulo ) {
1074 if ( col >= 7 - colModulo ) 1074 if ( col >= 7 - colModulo )
1075 addCol = col - 6 + colModulo-1; 1075 addCol = col - 6 + colModulo-1;
1076 } 1076 }
1077 1077
1078 addCol += 1; 1078 addCol += 1;
1079 if ( row == 0 ) 1079 if ( row == 0 )
1080 addRow = 1; 1080 addRow = 1;
1081 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1); 1081 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth+1, dheight+1);
1082 p.setPen(tmppen); 1082 p.setPen(tmppen);
1083 } 1083 }
1084 1084
1085 // if any events are on that day then draw it using a bold font 1085 // if any events are on that day then draw it using a bold font
1086 if ( eDays.testBit(i) ) { 1086 if ( eDays.testBit(i) ) {
1087 QFont myFont = font(); 1087 QFont myFont = font();
1088 myFont.setBold(true); 1088 myFont.setBold(true);
1089 p.setFont(myFont); 1089 p.setFont(myFont);
1090 } 1090 }
1091 1091
1092 // if it is a holiday then use the default holiday color 1092 // if it is a holiday then use the default holiday color
1093 if ( pDays.testBit(i)) { 1093 if ( pDays.testBit(i)) {
1094 if ( bDays.testBit(i) ) { 1094 if ( bDays.testBit(i) ) {
1095 if ( hDays.testBit(i) ) 1095 if ( hDays.testBit(i) )
1096 p.setPen(QColor(0,200,0)); 1096 p.setPen(QColor(0,200,0));
1097 else 1097 else
1098 p.setPen(QColor(Qt::blue)); 1098 p.setPen(QColor(Qt::blue));
1099 } else { 1099 } else {
1100 if (actcol == mDefaultTextColor ) { 1100 if (actcol == mDefaultTextColor ) {
1101 p.setPen(KOPrefs::instance()->mHolidayColor); 1101 p.setPen(KOPrefs::instance()->mHolidayColor);
1102 } else { 1102 } else {
1103 p.setPen(mHolidayColorShaded); 1103 p.setPen(mHolidayColorShaded);
1104 } 1104 }
1105 } 1105 }
1106 } 1106 }
1107 1107
1108 // draw selected days with special color 1108 // draw selected days with special color
1109 // DO NOT specially highlight holidays in selection ! 1109 // DO NOT specially highlight holidays in selection !
1110 if (i >= mSelStartT && i <= mSelEndT) { 1110 if (i >= mSelStartT && i <= mSelEndT) {
1111 ;//p.setPen(mSelectedDaysColor); 1111 ;//p.setPen(mSelectedDaysColor);
1112 } 1112 }
1113 1113
1114 int addCol = 0; 1114 int addCol = 0;
1115 int addRow = 0; 1115 int addRow = 0;
1116 if ( colModulo ) { 1116 if ( colModulo ) {
1117 if ( col >= 7 - colModulo ) 1117 if ( col >= 7 - colModulo )
1118 addCol = col - 7 + colModulo; 1118 addCol = col - 7 + colModulo;
1119 } 1119 }
1120 if ( rowModulo ) { 1120 if ( rowModulo ) {
1121 if ( row >= 6 - rowModulo ) 1121 if ( row >= 6 - rowModulo )
1122 addRow = row - 5 + rowModulo; 1122 addRow = row - 5 + rowModulo;
1123 } 1123 }
1124 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 1124 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
1125 ++addCol;//++addCol; 1125 ++addCol;//++addCol;
1126 if ( row == 0) 1126 if ( row == 0)
1127 addRow = 1; 1127 addRow = 1;
1128 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 1128 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
1129 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 1129 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
1130 1130
1131 // reset color to actual color 1131 // reset color to actual color
1132 if (pDays.testBit(i)) { 1132 if (pDays.testBit(i)) {
1133 p.setPen(actcol); 1133 p.setPen(actcol);
1134 } 1134 }
1135 // reset bold font to plain font 1135 // reset bold font to plain font
1136 if ( eDays.testBit(i)) { 1136 if ( eDays.testBit(i)) {
1137 QFont myFont = font(); 1137 QFont myFont = font();
1138 myFont.setBold(false); 1138 myFont.setBold(false);
1139 p.setFont(myFont); 1139 p.setFont(myFont);
1140 } 1140 }
1141 } 1141 }
1142 } else { 1142 } else {
1143 //qDebug("NO redraw "); 1143 //qDebug("NO redraw ");
1144 } 1144 }
1145 1145
1146 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP); 1146 bitBlt (this, pevent->rect().topLeft(), &myPix , pevent->rect() ,CopyROP);
1147 mRedrawNeeded = false; 1147 mRedrawNeeded = false;
1148} 1148}
1149 1149
1150// ---------------------------------------------------------------------------- 1150// ----------------------------------------------------------------------------
1151// R E SI Z E E V E N T H A N D L I N G 1151// R E SI Z E E V E N T H A N D L I N G
1152// ---------------------------------------------------------------------------- 1152// ----------------------------------------------------------------------------
1153 1153
1154void KODayMatrix::resizeEvent(QResizeEvent *) 1154void KODayMatrix::resizeEvent(QResizeEvent *)
1155{ 1155{
1156 QRect sz = frameRect(); 1156 QRect sz = frameRect();
1157 daysize.setHeight(sz.height()*7 / NUMDAYS); 1157 daysize.setHeight(sz.height()*7 / NUMDAYS);
1158 daysize.setWidth(sz.width() / 7); 1158 daysize.setWidth(sz.width() / 7);
1159} 1159}
1160 1160
1161QSize KODayMatrix::sizeHint() const 1161QSize KODayMatrix::sizeHint() const
1162{ 1162{
1163 1163
1164 QFontMetrics fm ( font() ); 1164 QFontMetrics fm ( font() );
1165 int wid = fm.width( "30") *7+3; 1165 int wid = fm.width( "30") *7+3;
1166 int hei = fm.height() * 6+3; 1166 int hei = fm.height() * 6+3;
1167 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); 1167 //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei);
1168 return QSize ( wid, hei ); 1168 return QSize ( wid, hei );
1169 1169
1170} 1170}
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index fd86095..b94916a 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1267 +1,1273 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98 bool ok = false; 98 bool ok = false;
99 QString start, end; 99 QString start, end;
100 QDate ds, de; 100 QDate ds, de;
101 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
103 if ( ok ) { 103 if ( ok ) {
104 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
105 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
106 de = ds.addDays( days); 106 de = ds.addDays( days);
107 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
108 } 108 }
109 109
110 } 110 }
111 if ( ! ok ) { 111 if ( ! ok ) {
112 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
113 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
114 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
115 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
116 } 116 }
117 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
118 mItem->setText(1,start); 118 mItem->setText(1,start);
119 if ( e->doesFloat() ) 119 if ( e->doesFloat() )
120 mItem->setText(2,"---"); 120 mItem->setText(2,"---");
121 else 121 else
122 mItem->setText(2,e->dtStartTimeStr()); 122 mItem->setText(2,e->dtStartTimeStr());
123 mItem->setText(3,end); 123 mItem->setText(3,end);
124 if ( e->doesFloat() ) 124 if ( e->doesFloat() )
125 mItem->setText(4,"---"); 125 mItem->setText(4,"---");
126 else 126 else
127 mItem->setText(4,e->dtEndTimeStr()); 127 mItem->setText(4,e->dtEndTimeStr());
128 if ( e->isAlarmEnabled() ) { 128 if ( e->isAlarmEnabled() ) {
129 mItem->setText(5,e->alarms().first()->offsetText() ); 129 mItem->setText(5,e->alarms().first()->offsetText() );
130 } else { 130 } else {
131 mItem->setText(5, i18n("No")); 131 mItem->setText(5, i18n("No"));
132 } 132 }
133 mItem->setText(6, e->recurrence()->recurrenceText()); 133 mItem->setText(6, e->recurrence()->recurrenceText());
134 if( ! e->doesRecur() ) 134 if( ! e->doesRecur() )
135 mItem->setSortKey( 6, "-" ); 135 mItem->setSortKey( 6, "-" );
136 mItem->setText(7,"---"); 136 mItem->setText(7,"---");
137 mItem->setText(8,"---"); 137 mItem->setText(8,"---");
138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
139 mItem->setText(10,e->categoriesStr()); 139 mItem->setText(10,e->categoriesStr());
140 140
141 QString key; 141 QString key;
142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
144 mItem->setSortKey(1,key); 144 mItem->setSortKey(1,key);
145 145
146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
148 mItem->setSortKey(3,key); 148 mItem->setSortKey(3,key);
149 return true; 149 return true;
150} 150}
151 151
152bool ListItemVisitor::visit(Todo *t) 152bool ListItemVisitor::visit(Todo *t)
153{ 153{
154 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 154 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
155 if (t->hasStartDate()) { 155 if (t->hasStartDate()) {
156 mItem->setText(1,t->dtStartDateStr()); 156 mItem->setText(1,t->dtStartDateStr());
157 if (t->doesFloat()) { 157 if (t->doesFloat()) {
158 mItem->setText(2,"---"); 158 mItem->setText(2,"---");
159 } else { 159 } else {
160 mItem->setText(2,t->dtStartTimeStr()); 160 mItem->setText(2,t->dtStartTimeStr());
161 } 161 }
162 } else { 162 } else {
163 mItem->setText(1,"---"); 163 mItem->setText(1,"---");
164 mItem->setText(2,"---"); 164 mItem->setText(2,"---");
165 } 165 }
166 mItem->setText(3,"---"); 166 mItem->setText(3,"---");
167 mItem->setText(4,"---"); 167 mItem->setText(4,"---");
168 if ( t->isAlarmEnabled() ) { 168 if ( t->isAlarmEnabled() ) {
169 mItem->setText(5,t->alarms().first()->offsetText() ); 169 mItem->setText(5,t->alarms().first()->offsetText() );
170 } else { 170 } else {
171 mItem->setText(5, i18n("No")); 171 mItem->setText(5, i18n("No"));
172 } 172 }
173 mItem->setText(6, t->recurrence()->recurrenceText()); 173 mItem->setText(6, t->recurrence()->recurrenceText());
174 if( ! t->doesRecur() ) 174 if( ! t->doesRecur() )
175 mItem->setSortKey( 6, "-" ); 175 mItem->setSortKey( 6, "-" );
176 if (t->hasDueDate()) { 176 if (t->hasDueDate()) {
177 mItem->setText(7,t->dtDueDateStr()); 177 mItem->setText(7,t->dtDueDateStr());
178 if (t->doesFloat()) { 178 if (t->doesFloat()) {
179 mItem->setText(8,"---"); 179 mItem->setText(8,"---");
180 } else { 180 } else {
181 mItem->setText(8,t->dtDueTimeStr()); 181 mItem->setText(8,t->dtDueTimeStr());
182 } 182 }
183 } else { 183 } else {
184 mItem->setText(7,"---"); 184 mItem->setText(7,"---");
185 mItem->setText(8,"---"); 185 mItem->setText(8,"---");
186 } 186 }
187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
188 mItem->setText(10,t->categoriesStr()); 188 mItem->setText(10,t->categoriesStr());
189 189
190 QString key; 190 QString key;
191 QDate d; 191 QDate d;
192 if (t->hasDueDate()) { 192 if (t->hasDueDate()) {
193 d = t->dtDue().date(); 193 d = t->dtDue().date();
194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
196 mItem->setSortKey(7,key); 196 mItem->setSortKey(7,key);
197 } 197 }
198 if ( t->hasStartDate() ) { 198 if ( t->hasStartDate() ) {
199 d = t->dtStart().date(); 199 d = t->dtStart().date();
200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
202 mItem->setSortKey(1,key); 202 mItem->setSortKey(1,key);
203 } 203 }
204 return true; 204 return true;
205} 205}
206 206
207bool ListItemVisitor::visit(Journal * j) 207bool ListItemVisitor::visit(Journal * j)
208{ 208{
209 QString des = j->description().left(30); 209 QString des = j->description().left(30);
210 des = des.simplifyWhiteSpace (); 210 des = des.simplifyWhiteSpace ();
211 des.replace (QRegExp ("\\n"),"" ); 211 des.replace (QRegExp ("\\n"),"" );
212 des.replace (QRegExp ("\\r"),"" ); 212 des.replace (QRegExp ("\\r"),"" );
213 mItem->setText(0,i18n("Journal: ")+des.left(25)); 213 mItem->setText(0,i18n("Journal: ")+des.left(25));
214 mItem->setText(1,j->dtStartDateStr()); 214 mItem->setText(1,j->dtStartDateStr());
215 mItem->setText(2,"---"); 215 mItem->setText(2,"---");
216 mItem->setText(3,"---"); 216 mItem->setText(3,"---");
217 mItem->setText(4,"---"); 217 mItem->setText(4,"---");
218 mItem->setText(5,"---"); 218 mItem->setText(5,"---");
219 mItem->setText(6,"---"); 219 mItem->setText(6,"---");
220 mItem->setText(7,j->dtStartDateStr()); 220 mItem->setText(7,j->dtStartDateStr());
221 mItem->setText(8,"---"); 221 mItem->setText(8,"---");
222 mItem->setText(9,"---"); 222 mItem->setText(9,"---");
223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
224 224
225 QString key; 225 QString key;
226 QDate d = j->dtStart().date(); 226 QDate d = j->dtStart().date();
227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
228 mItem->setSortKey(1,key); 228 mItem->setSortKey(1,key);
229 mItem->setSortKey(7,key); 229 mItem->setSortKey(7,key);
230 230
231 return true; 231 return true;
232} 232}
233 233
234KOListView::KOListView(Calendar *calendar, QWidget *parent, 234KOListView::KOListView(Calendar *calendar, QWidget *parent,
235 const char *name) 235 const char *name)
236 : KOEventView(calendar, parent, name) 236 : KOEventView(calendar, parent, name)
237{ 237{
238 mActiveItem = 0; 238 mActiveItem = 0;
239 mListView = new KOListViewListView(this); 239 mListView = new KOListViewListView(this);
240 mListView->addColumn(i18n("Summary")); 240 mListView->addColumn(i18n("Summary"));
241 mListView->addColumn(i18n("Start Date")); 241 mListView->addColumn(i18n("Start Date"));
242 mListView->addColumn(i18n("Start Time")); 242 mListView->addColumn(i18n("Start Time"));
243 mListView->addColumn(i18n("End Date")); 243 mListView->addColumn(i18n("End Date"));
244 mListView->addColumn(i18n("End Time")); 244 mListView->addColumn(i18n("End Time"));
245 mListView->addColumn(i18n("Alarm")); // alarm set? 245 mListView->addColumn(i18n("Alarm")); // alarm set?
246 mListView->addColumn(i18n("Recurs")); // recurs? 246 mListView->addColumn(i18n("Recurs")); // recurs?
247 mListView->addColumn(i18n("Due Date")); 247 mListView->addColumn(i18n("Due Date"));
248 mListView->addColumn(i18n("Due Time")); 248 mListView->addColumn(i18n("Due Time"));
249 mListView->addColumn(i18n("Cancelled")); 249 mListView->addColumn(i18n("Cancelled"));
250 mListView->addColumn(i18n("Categories")); 250 mListView->addColumn(i18n("Categories"));
251 251
252 mListView->setColumnAlignment(0,AlignLeft); 252 mListView->setColumnAlignment(0,AlignLeft);
253 mListView->setColumnAlignment(1,AlignLeft); 253 mListView->setColumnAlignment(1,AlignLeft);
254 mListView->setColumnAlignment(2,AlignHCenter); 254 mListView->setColumnAlignment(2,AlignHCenter);
255 mListView->setColumnAlignment(3,AlignLeft); 255 mListView->setColumnAlignment(3,AlignLeft);
256 mListView->setColumnAlignment(4,AlignHCenter); 256 mListView->setColumnAlignment(4,AlignHCenter);
257 mListView->setColumnAlignment(5,AlignLeft); 257 mListView->setColumnAlignment(5,AlignLeft);
258 mListView->setColumnAlignment(6,AlignLeft); 258 mListView->setColumnAlignment(6,AlignLeft);
259 mListView->setColumnAlignment(7,AlignLeft); 259 mListView->setColumnAlignment(7,AlignLeft);
260 mListView->setColumnAlignment(8,AlignLeft); 260 mListView->setColumnAlignment(8,AlignLeft);
261 mListView->setColumnAlignment(9,AlignLeft); 261 mListView->setColumnAlignment(9,AlignLeft);
262 mListView->setColumnAlignment(10,AlignLeft); 262 mListView->setColumnAlignment(10,AlignLeft);
263 mListView->setColumnWidthMode(10, QListView::Manual); 263 mListView->setColumnWidthMode(10, QListView::Manual);
264 new KOListViewWhatsThis(mListView->viewport(),this); 264 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
265 265
266 int iii = 0; 266 int iii = 0;
267 for ( iii = 0; iii< 10 ; ++iii ) 267 for ( iii = 0; iii< 10 ; ++iii )
268 mListView->setColumnWidthMode( iii, QListView::Manual ); 268 mListView->setColumnWidthMode( iii, QListView::Manual );
269 269
270 QBoxLayout *layoutTop = new QVBoxLayout(this); 270 QBoxLayout *layoutTop = new QVBoxLayout(this);
271 layoutTop->addWidget(mListView); 271 layoutTop->addWidget(mListView);
272 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 272 mListView->setFont ( KOPrefs::instance()->mListViewFont );
273 mPopupMenu = eventPopup(); 273 mPopupMenu = eventPopup();
274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
275 i18n("Select all"),this, 275 i18n("Select all"),this,
276 SLOT(allSelection()),true); 276 SLOT(allSelection()),true);
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Deselect all"),this, 278 i18n("Deselect all"),this,
279 SLOT(clearSelection()),true); 279 SLOT(clearSelection()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Delete all selected"),this, 281 i18n("Delete all selected"),this,
282 SLOT(deleteAll()),true); 282 SLOT(deleteAll()),true);
283 mPopupMenu->insertSeparator(); 283 mPopupMenu->insertSeparator();
284 QPopupMenu * exportPO = new QPopupMenu ( this ); 284 QPopupMenu * exportPO = new QPopupMenu ( this );
285 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 285 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
286 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 286 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
287 SLOT(saveToFile())); 287 SLOT(saveToFile()));
288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
289 SLOT(saveToFileVCS())); 289 SLOT(saveToFileVCS()));
290 exportPO->insertItem( i18n("Journal/Details..."),this, 290 exportPO->insertItem( i18n("Journal/Details..."),this,
291 SLOT(saveDescriptionToFile())); 291 SLOT(saveDescriptionToFile()));
292 // mPopupMenu->insertSeparator(); 292 // mPopupMenu->insertSeparator();
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Add Categ. to selected..."),this, 294 i18n("Add Categ. to selected..."),this,
295 SLOT(addCat()),true); 295 SLOT(addCat()),true);
296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
297 i18n("Set Categ. for selected..."),this, 297 i18n("Set Categ. for selected..."),this,
298 SLOT(setCat()),true); 298 SLOT(setCat()),true);
299 //mPopupMenu->insertSeparator(); 299 //mPopupMenu->insertSeparator();
300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
301 i18n("Set alarm for selected..."),this, 301 i18n("Set alarm for selected..."),this,
302 SLOT(setAlarm()),true); 302 SLOT(setAlarm()),true);
303 303
304 304
305#ifndef DESKTOP_VERSION 305#ifndef DESKTOP_VERSION
306 mPopupMenu->insertSeparator(); 306 mPopupMenu->insertSeparator();
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Beam selected via IR"),this, 308 i18n("Beam selected via IR"),this,
309 SLOT(beamSelected()),true); 309 SLOT(beamSelected()),true);
310#endif 310#endif
311 /* 311 /*
312 mPopupMenu = new QPopupMenu; 312 mPopupMenu = new QPopupMenu;
313 mPopupMenu->insertItem(i18n("Edit Event"), this, 313 mPopupMenu->insertItem(i18n("Edit Event"), this,
314 SLOT (editEvent())); 314 SLOT (editEvent()));
315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
316 SLOT (deleteEvent())); 316 SLOT (deleteEvent()));
317 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
318 mPopupMenu->insertItem(i18n("Show Dates"), this, 318 mPopupMenu->insertItem(i18n("Show Dates"), this,
319 SLOT(showDates())); 319 SLOT(showDates()));
320 mPopupMenu->insertItem(i18n("Hide Dates"), this, 320 mPopupMenu->insertItem(i18n("Hide Dates"), this,
321 SLOT(hideDates())); 321 SLOT(hideDates()));
322 */ 322 */
323 QObject::connect(mListView,SIGNAL( newEvent()), 323 QObject::connect(mListView,SIGNAL( newEvent()),
324 this,SIGNAL(signalNewEvent())); 324 this,SIGNAL(signalNewEvent()));
325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
326 this,SLOT(defaultItemAction(QListViewItem *))); 326 this,SLOT(defaultItemAction(QListViewItem *)));
327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
328 const QPoint &, int )), 328 const QPoint &, int )),
329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
331 SLOT(processSelectionChange(QListViewItem *))); 331 SLOT(processSelectionChange(QListViewItem *)));
332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
333 SIGNAL(showIncidenceSignal(Incidence *)) ); 333 SIGNAL(showIncidenceSignal(Incidence *)) );
334 334
335 readSettings(KOGlobals::config(),"KOListView Layout"); 335 readSettings(KOGlobals::config(),"KOListView Layout");
336} 336}
337 337
338KOListView::~KOListView() 338KOListView::~KOListView()
339{ 339{
340 delete mPopupMenu; 340 delete mPopupMenu;
341#if QT_VERSION >= 0x030000
342
343#else
344 delete mKOListViewWhatsThis;
345#endif
341} 346}
342 347
343QString KOListView::getWhatsThisText(QPoint p) 348QString KOListView::getWhatsThisText(QPoint p)
344{ 349{
345 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 350 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
346 if ( item ) 351 if ( item )
347 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 352 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
348 KOPrefs::instance()->mWTshowDetails, 353 KOPrefs::instance()->mWTshowDetails,
349 KOPrefs::instance()->mWTshowCreated, 354 KOPrefs::instance()->mWTshowCreated,
350 KOPrefs::instance()->mWTshowChanged); 355 KOPrefs::instance()->mWTshowChanged);
351 return i18n("That is the list view" ); 356 return i18n("That is the list view" );
352 357
353} 358}
354 359
355void KOListView::updateList() 360void KOListView::updateList()
356{ 361{
357 // qDebug(" KOListView::updateList() "); 362 // qDebug(" KOListView::updateList() ");
358 363
359} 364}
360 365
361void KOListView::addCat( ) 366void KOListView::addCat( )
362{ 367{
363 setCategories( false ); 368 setCategories( false );
364} 369}
365void KOListView::setCat() 370void KOListView::setCat()
366{ 371{
367 setCategories( true ); 372 setCategories( true );
368} 373}
369void KOListView::setAlarm() 374void KOListView::setAlarm()
370{ 375{
371 KOAlarmPrefs kap( this); 376 KOAlarmPrefs kap( this);
372 if ( !kap.exec() ) 377 if ( !kap.exec() )
373 return; 378 return;
374 QStringList itemList; 379 QStringList itemList;
375 QPtrList<KOListViewItem> sel ; 380 QPtrList<KOListViewItem> sel ;
376 QListViewItem *qitem = mListView->firstChild (); 381 QListViewItem *qitem = mListView->firstChild ();
377 while ( qitem ) { 382 while ( qitem ) {
378 if ( qitem->isSelected() ) { 383 if ( qitem->isSelected() ) {
379 Incidence* inc = ((KOListViewItem *) qitem)->data(); 384 Incidence* inc = ((KOListViewItem *) qitem)->data();
380 if ( inc->type() != "Journal" ) { 385 if ( inc->type() != "Journal" ) {
381 if ( inc->type() == "Todo" ) { 386 if ( inc->type() == "Todo" ) {
382 if ( ((Todo*)inc)->hasDueDate() ) 387 if ( ((Todo*)inc)->hasDueDate() )
383 sel.append(((KOListViewItem *)qitem)); 388 sel.append(((KOListViewItem *)qitem));
384 } else 389 } else
385 sel.append(((KOListViewItem *)qitem)); 390 sel.append(((KOListViewItem *)qitem));
386 } 391 }
387 } 392 }
388 qitem = qitem->nextSibling(); 393 qitem = qitem->nextSibling();
389 } 394 }
390 int count = 0; 395 int count = 0;
391 KOListViewItem * item, *temp; 396 KOListViewItem * item, *temp;
392 item = sel.first(); 397 item = sel.first();
393 Incidence* inc; 398 Incidence* inc;
394 while ( item ) { 399 while ( item ) {
395 inc = item->data(); 400 inc = item->data();
396 ++count; 401 ++count;
397 if (kap.mAlarmButton->isChecked()) { 402 if (kap.mAlarmButton->isChecked()) {
398 if (inc->alarms().count() == 0) 403 if (inc->alarms().count() == 0)
399 inc->newAlarm(); 404 inc->newAlarm();
400 QPtrList<Alarm> alarms = inc->alarms(); 405 QPtrList<Alarm> alarms = inc->alarms();
401 Alarm *alarm; 406 Alarm *alarm;
402 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 407 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
403 alarm->setEnabled(true); 408 alarm->setEnabled(true);
404 int j = kap.mAlarmTimeEdit->value()* -60; 409 int j = kap.mAlarmTimeEdit->value()* -60;
405 if (kap.mAlarmIncrCombo->currentItem() == 1) 410 if (kap.mAlarmIncrCombo->currentItem() == 1)
406 j = j * 60; 411 j = j * 60;
407 else if (kap.mAlarmIncrCombo->currentItem() == 2) 412 else if (kap.mAlarmIncrCombo->currentItem() == 2)
408 j = j * (60 * 24); 413 j = j * (60 * 24);
409 alarm->setStartOffset( j ); 414 alarm->setStartOffset( j );
410 415
411 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 416 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
412 alarm->setProcedureAlarm(kap.mAlarmProgram); 417 alarm->setProcedureAlarm(kap.mAlarmProgram);
413 } 418 }
414 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 419 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
415 alarm->setAudioAlarm(kap.mAlarmSound); 420 alarm->setAudioAlarm(kap.mAlarmSound);
416 else 421 else
417 alarm->setType(Alarm::Invalid); 422 alarm->setType(Alarm::Invalid);
418 //alarm->setAudioAlarm("default"); 423 //alarm->setAudioAlarm("default");
419 // TODO: Deal with multiple alarms 424 // TODO: Deal with multiple alarms
420 break; // For now, stop after the first alarm 425 break; // For now, stop after the first alarm
421 } 426 }
422 } else { 427 } else {
423 Alarm* alarm = inc->alarms().first(); 428 Alarm* alarm = inc->alarms().first();
424 if ( alarm ) { 429 if ( alarm ) {
425 alarm->setEnabled(false); 430 alarm->setEnabled(false);
426 alarm->setType(Alarm::Invalid); 431 alarm->setType(Alarm::Invalid);
427 } 432 }
428 } 433 }
429 ListItemVisitor v(item, mStartDate ); 434 ListItemVisitor v(item, mStartDate );
430 inc->accept(v); 435 inc->accept(v);
431 item = sel.next(); 436 item = sel.next();
432 } 437 }
433 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); 438 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
434 qDebug("KO: Set alarm for %d items", count); 439 qDebug("KO: Set alarm for %d items", count);
435 calendar()->reInitAlarmSettings(); 440 calendar()->reInitAlarmSettings();
436 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 441 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
437} 442}
438void KOListView::setCategories( bool removeOld ) 443void KOListView::setCategories( bool removeOld )
439{ 444{
440 445
441 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 446 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
442 csd->setColorEnabled(); 447 csd->setColorEnabled();
443 if (! csd->exec()) { 448 if (! csd->exec()) {
444 delete csd; 449 delete csd;
445 return; 450 return;
446 } 451 }
447 QStringList catList = csd->selectedCategories(); 452 QStringList catList = csd->selectedCategories();
448 delete csd; 453 delete csd;
449 // if ( catList.count() == 0 ) 454 // if ( catList.count() == 0 )
450 // return; 455 // return;
451 //catList.sort(); 456 //catList.sort();
452 QString categoriesStr = catList.join(","); 457 QString categoriesStr = catList.join(",");
453 int i; 458 int i;
454 QStringList itemList; 459 QStringList itemList;
455 QPtrList<KOListViewItem> sel ; 460 QPtrList<KOListViewItem> sel ;
456 QListViewItem *qitem = mListView->firstChild (); 461 QListViewItem *qitem = mListView->firstChild ();
457 while ( qitem ) { 462 while ( qitem ) {
458 if ( qitem->isSelected() ) { 463 if ( qitem->isSelected() ) {
459 sel.append(((KOListViewItem *)qitem)); 464 sel.append(((KOListViewItem *)qitem));
460 } 465 }
461 qitem = qitem->nextSibling(); 466 qitem = qitem->nextSibling();
462 } 467 }
463 KOListViewItem * item, *temp; 468 KOListViewItem * item, *temp;
464 item = sel.first(); 469 item = sel.first();
465 if( item ) { 470 if( item ) {
466 Incidence* inc = item->data() ; 471 Incidence* inc = item->data() ;
467 bool setSub = false; 472 bool setSub = false;
468 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { 473 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) {
469 int result = KMessageBox::warningYesNoCancel(this, 474 int result = KMessageBox::warningYesNoCancel(this,
470 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 475 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
471 i18n("Todo has subtodos"), 476 i18n("Todo has subtodos"),
472 i18n("Yes"), 477 i18n("Yes"),
473 i18n("No")); 478 i18n("No"));
474 if (result == KMessageBox::Cancel) item = 0; 479 if (result == KMessageBox::Cancel) item = 0;
475 if (result == KMessageBox::Yes) setSub = true; 480 if (result == KMessageBox::Yes) setSub = true;
476 } 481 }
477 while ( item ) { 482 while ( item ) {
478 inc = item->data(); 483 inc = item->data();
479 if ( removeOld ) { 484 if ( removeOld ) {
480 inc->setCategories( catList, setSub ); 485 inc->setCategories( catList, setSub );
481 } else { 486 } else {
482 inc->addCategories( catList, setSub ); 487 inc->addCategories( catList, setSub );
483 } 488 }
484 ListItemVisitor v(item, mStartDate ); 489 ListItemVisitor v(item, mStartDate );
485 inc->accept(v); 490 inc->accept(v);
486 item = sel.next(); 491 item = sel.next();
487 } 492 }
488 } 493 }
489 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 494 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
490} 495}
491 496
492void KOListView::beamSelected() 497void KOListView::beamSelected()
493{ 498{
494 int icount = 0; 499 int icount = 0;
495 QPtrList<Incidence> delSel ; 500 QPtrList<Incidence> delSel ;
496 QListViewItem *item = mListView->firstChild (); 501 QListViewItem *item = mListView->firstChild ();
497 while ( item ) { 502 while ( item ) {
498 if ( item->isSelected() ) { 503 if ( item->isSelected() ) {
499 delSel.append(((KOListViewItem *)item)->data()); 504 delSel.append(((KOListViewItem *)item)->data());
500 ++icount; 505 ++icount;
501 } 506 }
502 507
503 item = item->nextSibling(); 508 item = item->nextSibling();
504 } 509 }
505 if ( icount ) { 510 if ( icount ) {
506 emit beamIncidenceList( delSel ); 511 emit beamIncidenceList( delSel );
507 return; 512 return;
508 QString fn ; 513 QString fn ;
509 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 514 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
510 QString mes; 515 QString mes;
511 bool createbup = true; 516 bool createbup = true;
512 if ( createbup ) { 517 if ( createbup ) {
513 QString description = "\n"; 518 QString description = "\n";
514 CalendarLocal* cal = new CalendarLocal(); 519 CalendarLocal* cal = new CalendarLocal();
515 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 520 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
516 Incidence *incidence = delSel.first(); 521 Incidence *incidence = delSel.first();
517 while ( incidence ) { 522 while ( incidence ) {
518 Incidence *in = incidence->clone(); 523 Incidence *in = incidence->clone();
519 description += in->summary() + "\n"; 524 description += in->summary() + "\n";
520 cal->addIncidence( in ); 525 cal->addIncidence( in );
521 incidence = delSel.next(); 526 incidence = delSel.next();
522 } 527 }
523 FileStorage storage( cal, fn, new VCalFormat ); 528 FileStorage storage( cal, fn, new VCalFormat );
524 storage.save(); 529 storage.save();
525 delete cal; 530 delete cal;
526 mes = i18n("KO/Pi: Ready for beaming"); 531 mes = i18n("KO/Pi: Ready for beaming");
527 topLevelWidget()->setCaption(mes); 532 topLevelWidget()->setCaption(mes);
528 533
529#ifndef DESKTOP_VERSION 534#ifndef DESKTOP_VERSION
530 Ir *ir = new Ir( this ); 535 Ir *ir = new Ir( this );
531 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 536 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
532 ir->send( fn, description, "text/x-vCalendar" ); 537 ir->send( fn, description, "text/x-vCalendar" );
533#endif 538#endif
534 } 539 }
535 } 540 }
536} 541}
537void KOListView::beamDone( Ir *ir ) 542void KOListView::beamDone( Ir *ir )
538{ 543{
539#ifndef DESKTOP_VERSION 544#ifndef DESKTOP_VERSION
540 delete ir; 545 delete ir;
541#endif 546#endif
542 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 547 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
543} 548}
544 549
545void KOListView::saveDescriptionToFile() 550void KOListView::saveDescriptionToFile()
546{ 551{
547 552
548 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 553 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
549 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 554 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
550 i18n("Continue"), i18n("Cancel"), 0, 555 i18n("Continue"), i18n("Cancel"), 0,
551 0, 1 ); 556 0, 1 );
552 if ( result != 0 ) { 557 if ( result != 0 ) {
553 return; 558 return;
554 } 559 }
555 int icount = 0; 560 int icount = 0;
556 QPtrList<Incidence> delSel ; 561 QPtrList<Incidence> delSel ;
557 QListViewItem *item = mListView->firstChild (); 562 QListViewItem *item = mListView->firstChild ();
558 while ( item ) { 563 while ( item ) {
559 if ( item->isSelected() ) { 564 if ( item->isSelected() ) {
560 delSel.append(((KOListViewItem *)item)->data()); 565 delSel.append(((KOListViewItem *)item)->data());
561 ++icount; 566 ++icount;
562 } 567 }
563 568
564 item = item->nextSibling(); 569 item = item->nextSibling();
565 } 570 }
566 if ( icount ) { 571 if ( icount ) {
567 QString fn = KOPrefs::instance()->mLastSaveFile; 572 QString fn = KOPrefs::instance()->mLastSaveFile;
568 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 573 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
569 574
570 if ( fn == "" ) 575 if ( fn == "" )
571 return; 576 return;
572 QFileInfo info; 577 QFileInfo info;
573 info.setFile( fn ); 578 info.setFile( fn );
574 QString mes; 579 QString mes;
575 bool createbup = true; 580 bool createbup = true;
576 if ( info. exists() ) { 581 if ( info. exists() ) {
577 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 582 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
578 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 583 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
579 i18n("Overwrite!"), i18n("Cancel"), 0, 584 i18n("Overwrite!"), i18n("Cancel"), 0,
580 0, 1 ); 585 0, 1 );
581 if ( result != 0 ) { 586 if ( result != 0 ) {
582 createbup = false; 587 createbup = false;
583 } 588 }
584 } 589 }
585 if ( createbup ) { 590 if ( createbup ) {
586 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 591 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
587 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 592 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
588 Incidence *incidence = delSel.first(); 593 Incidence *incidence = delSel.first();
589 icount = 0; 594 icount = 0;
590 while ( incidence ) { 595 while ( incidence ) {
591 if ( incidence->type() == "Journal" ) { 596 if ( incidence->type() == "Journal" ) {
592 text += "\n************************************\n"; 597 text += "\n************************************\n";
593 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 598 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
594 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 599 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
595 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 600 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
596 ++icount; 601 ++icount;
597 602
598 } else { 603 } else {
599 if ( !incidence->description().isEmpty() ) { 604 if ( !incidence->description().isEmpty() ) {
600 text += "\n************************************\n"; 605 text += "\n************************************\n";
601 if ( incidence->type() == "Todo" ) 606 if ( incidence->type() == "Todo" )
602 text += i18n("To-Do: "); 607 text += i18n("To-Do: ");
603 text += incidence->summary(); 608 text += incidence->summary();
604 if ( incidence->hasStartDate() ) 609 if ( incidence->hasStartDate() )
605 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 610 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
606 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 611 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
607 if ( !incidence->location().isEmpty() ) 612 if ( !incidence->location().isEmpty() )
608 text += "\n" +i18n("Location: ") + incidence->location(); 613 text += "\n" +i18n("Location: ") + incidence->location();
609 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 614 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
610 ++icount; 615 ++icount;
611 616
612 } 617 }
613 } 618 }
614 incidence = delSel.next(); 619 incidence = delSel.next();
615 } 620 }
616 QFile file( fn ); 621 QFile file( fn );
617 if (!file.open( IO_WriteOnly ) ) { 622 if (!file.open( IO_WriteOnly ) ) {
618 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 623 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
619 return; 624 return;
620 } 625 }
621 QTextStream ts( &file ); 626 QTextStream ts( &file );
622 ts << text; 627 ts << text;
623 file.close(); 628 file.close();
624 //qDebug("%s ", text.latin1()); 629 //qDebug("%s ", text.latin1());
625 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 630 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
626 KOPrefs::instance()->mLastSaveFile = fn; 631 KOPrefs::instance()->mLastSaveFile = fn;
627 topLevelWidget()->setCaption(mes); 632 topLevelWidget()->setCaption(mes);
628 } 633 }
629 } 634 }
630} 635}
631void KOListView::saveToFileVCS() 636void KOListView::saveToFileVCS()
632{ 637{
633 writeToFile( false ); 638 writeToFile( false );
634} 639}
635void KOListView::saveToFile() 640void KOListView::saveToFile()
636{ 641{
637 writeToFile( true ); 642 writeToFile( true );
638} 643}
639void KOListView::writeToFile( bool iCal ) 644void KOListView::writeToFile( bool iCal )
640{ 645{
641 646
642 int icount = 0; 647 int icount = 0;
643 QPtrList<Incidence> delSel ; 648 QPtrList<Incidence> delSel ;
644 QListViewItem *item = mListView->firstChild (); 649 QListViewItem *item = mListView->firstChild ();
645 bool journal = iCal; // warn only for vCal 650 bool journal = iCal; // warn only for vCal
646 while ( item ) { 651 while ( item ) {
647 if ( item->isSelected() ) { 652 if ( item->isSelected() ) {
648 if ( !journal ) 653 if ( !journal )
649 if ( ((KOListViewItem *)item)->data()->type() == "Journal") 654 if ( ((KOListViewItem *)item)->data()->type() == "Journal")
650 journal = true; 655 journal = true;
651 delSel.append(((KOListViewItem *)item)->data()); 656 delSel.append(((KOListViewItem *)item)->data());
652 ++icount; 657 ++icount;
653 } 658 }
654 659
655 item = item->nextSibling(); 660 item = item->nextSibling();
656 } 661 }
657 if ( !iCal && journal ) { 662 if ( !iCal && journal ) {
658 int result = KMessageBox::warningContinueCancel(this, 663 int result = KMessageBox::warningContinueCancel(this,
659 i18n("The journal entries can not be\nexported to a vCalendar file."), 664 i18n("The journal entries can not be\nexported to a vCalendar file."),
660 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 665 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
661 true); 666 true);
662 if (result != KMessageBox::Continue) return; 667 if (result != KMessageBox::Continue) return;
663 } 668 }
664 if ( icount ) { 669 if ( icount ) {
665 QString fn = KOPrefs::instance()->mLastSaveFile; 670 QString fn = KOPrefs::instance()->mLastSaveFile;
666 QString extension; 671 QString extension;
667 if ( iCal ) { 672 if ( iCal ) {
668 if ( fn.right( 4 ).lower() == ".vcs" ) { 673 if ( fn.right( 4 ).lower() == ".vcs" ) {
669 fn = fn.left( fn.length() -3) + "ics"; 674 fn = fn.left( fn.length() -3) + "ics";
670 } 675 }
671 } else { 676 } else {
672 if ( fn.right( 4 ).lower() == ".ics" ) { 677 if ( fn.right( 4 ).lower() == ".ics" ) {
673 fn = fn.left( fn.length() -3) + "vcs"; 678 fn = fn.left( fn.length() -3) + "vcs";
674 } 679 }
675 } 680 }
676 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 681 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
677 682
678 if ( fn == "" ) 683 if ( fn == "" )
679 return; 684 return;
680 QFileInfo info; 685 QFileInfo info;
681 info.setFile( fn ); 686 info.setFile( fn );
682 QString mes; 687 QString mes;
683 bool createbup = true; 688 bool createbup = true;
684 if ( info. exists() ) { 689 if ( info. exists() ) {
685 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 690 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
686 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 691 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
687 i18n("Overwrite!"), i18n("Cancel"), 0, 692 i18n("Overwrite!"), i18n("Cancel"), 0,
688 0, 1 ); 693 0, 1 );
689 if ( result != 0 ) { 694 if ( result != 0 ) {
690 createbup = false; 695 createbup = false;
691 } 696 }
692 } 697 }
693 if ( createbup ) { 698 if ( createbup ) {
694 CalendarLocal cal; 699 CalendarLocal cal;
695 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 700 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
696 Incidence *incidence = delSel.first(); 701 Incidence *incidence = delSel.first();
697 while ( incidence ) { 702 while ( incidence ) {
698 cal.addIncidence( incidence->clone() ); 703 cal.addIncidence( incidence->clone() );
699 incidence = delSel.next(); 704 incidence = delSel.next();
700 } 705 }
701 if ( iCal ) { 706 if ( iCal ) {
702 ICalFormat format; 707 ICalFormat format;
703 format.save( &cal, fn ); 708 format.save( &cal, fn );
704 } else { 709 } else {
705 710
706 VCalFormat format; 711 VCalFormat format;
707 format.save( &cal, fn ); 712 format.save( &cal, fn );
708 } 713 }
709 mes = i18n("KO/Pi:Saved %1").arg(fn ); 714 mes = i18n("KO/Pi:Saved %1").arg(fn );
710 KOPrefs::instance()->mLastSaveFile = fn; 715 KOPrefs::instance()->mLastSaveFile = fn;
711 topLevelWidget()->setCaption(mes); 716 topLevelWidget()->setCaption(mes);
712 } 717 }
713 } 718 }
714 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 719 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
715} 720}
716void KOListView::deleteAll() 721void KOListView::deleteAll()
717{ 722{
718 int icount = 0; 723 int icount = 0;
719 QPtrList<Incidence> delSel ; 724 QPtrList<Incidence> delSel ;
720 QListViewItem *item = mListView->firstChild (); 725 QListViewItem *item = mListView->firstChild ();
721 while ( item ) { 726 while ( item ) {
722 if ( item->isSelected() ) { 727 if ( item->isSelected() ) {
723 delSel.append(((KOListViewItem *)item)->data()); 728 delSel.append(((KOListViewItem *)item)->data());
724 ++icount; 729 ++icount;
725 } 730 }
726 731
727 item = item->nextSibling(); 732 item = item->nextSibling();
728 } 733 }
729 if ( icount ) { 734 if ( icount ) {
730 Incidence *incidence = delSel.first(); 735 Incidence *incidence = delSel.first();
731 Incidence *toDelete; 736 Incidence *toDelete;
732 KOPrefs *p = KOPrefs::instance(); 737 KOPrefs *p = KOPrefs::instance();
733 bool confirm = p->mConfirm; 738 bool confirm = p->mConfirm;
734 QString mess; 739 QString mess;
735 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 740 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
736 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 741 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
737 p->mConfirm = false; 742 p->mConfirm = false;
738 int delCounter = 0; 743 int delCounter = 0;
739 QDialog dia ( this, "p-dialog", true ); 744 QDialog dia ( this, "p-dialog", true );
740 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 745 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
741 QVBoxLayout lay( &dia ); 746 QVBoxLayout lay( &dia );
742 lay.setMargin(7); 747 lay.setMargin(7);
743 lay.setSpacing(7); 748 lay.setSpacing(7);
744 lay.addWidget( &lab); 749 lay.addWidget( &lab);
745 QProgressBar bar( icount, &dia ); 750 QProgressBar bar( icount, &dia );
746 lay.addWidget( &bar); 751 lay.addWidget( &bar);
747 int w = 220; 752 int w = 220;
748 int h = 50; 753 int h = 50;
749 int dw = QApplication::desktop()->width(); 754 int dw = QApplication::desktop()->width();
750 int dh = QApplication::desktop()->height(); 755 int dh = QApplication::desktop()->height();
751 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 756 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
752 //dia.resize( 240,50 ); 757 //dia.resize( 240,50 );
753 dia.show(); 758 dia.show();
754 759
755 while ( incidence ) { 760 while ( incidence ) {
756 bar.setProgress( delCounter ); 761 bar.setProgress( delCounter );
757 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 762 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
758 dia.setCaption( mess ); 763 dia.setCaption( mess );
759 qApp->processEvents(); 764 qApp->processEvents();
760 toDelete = (incidence); 765 toDelete = (incidence);
761 incidence = delSel.next(); 766 incidence = delSel.next();
762 emit deleteIncidenceSignal(toDelete ); 767 emit deleteIncidenceSignal(toDelete );
763 if ( dia.result() != 0 ) 768 if ( dia.result() != 0 )
764 break; 769 break;
765 770
766 } 771 }
767 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 772 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
768 topLevelWidget ()->setCaption( mess ); 773 topLevelWidget ()->setCaption( mess );
769 p->mConfirm = confirm; 774 p->mConfirm = confirm;
770 } 775 }
771 } 776 }
772 777
773 778
774} 779}
775int KOListView::maxDatesHint() 780int KOListView::maxDatesHint()
776{ 781{
777 return 0; 782 return 0;
778} 783}
779 784
780int KOListView::currentDateCount() 785int KOListView::currentDateCount()
781{ 786{
782 return 0; 787 return 0;
783} 788}
784 789
785QPtrList<Incidence> KOListView::selectedIncidences() 790QPtrList<Incidence> KOListView::selectedIncidences()
786{ 791{
787 QPtrList<Incidence> eventList; 792 QPtrList<Incidence> eventList;
788 QListViewItem *item = mListView->firstChild (); 793 QListViewItem *item = mListView->firstChild ();
789 while ( item ) { 794 while ( item ) {
790 if ( item->isSelected() ) { 795 if ( item->isSelected() ) {
791 eventList.append(((KOListViewItem *)item)->data()); 796 eventList.append(((KOListViewItem *)item)->data());
792 } 797 }
793 798
794 item = item->nextSibling(); 799 item = item->nextSibling();
795 } 800 }
796 801
797 // // QListViewItem *item = mListView->selectedItem(); 802 // // QListViewItem *item = mListView->selectedItem();
798 //if (item) eventList.append(((KOListViewItem *)item)->data()); 803 //if (item) eventList.append(((KOListViewItem *)item)->data());
799 804
800 return eventList; 805 return eventList;
801} 806}
802 807
803DateList KOListView::selectedDates() 808DateList KOListView::selectedDates()
804{ 809{
805 DateList eventList; 810 DateList eventList;
806 return eventList; 811 return eventList;
807} 812}
808 813
809void KOListView::showDates(bool show) 814void KOListView::showDates(bool show)
810{ 815{
811 // Shouldn't we set it to a value greater 0? When showDates is called with 816 // Shouldn't we set it to a value greater 0? When showDates is called with
812 // show == true at first, then the columnwidths are set to zero. 817 // show == true at first, then the columnwidths are set to zero.
813 static int oldColWidth1 = 0; 818 static int oldColWidth1 = 0;
814 static int oldColWidth3 = 0; 819 static int oldColWidth3 = 0;
815 820
816 if (!show) { 821 if (!show) {
817 oldColWidth1 = mListView->columnWidth(1); 822 oldColWidth1 = mListView->columnWidth(1);
818 oldColWidth3 = mListView->columnWidth(3); 823 oldColWidth3 = mListView->columnWidth(3);
819 mListView->setColumnWidth(1, 0); 824 mListView->setColumnWidth(1, 0);
820 mListView->setColumnWidth(3, 0); 825 mListView->setColumnWidth(3, 0);
821 } else { 826 } else {
822 mListView->setColumnWidth(1, oldColWidth1); 827 mListView->setColumnWidth(1, oldColWidth1);
823 mListView->setColumnWidth(3, oldColWidth3); 828 mListView->setColumnWidth(3, oldColWidth3);
824 } 829 }
825 mListView->repaint(); 830 mListView->repaint();
826} 831}
827 832
828void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 833void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
829 const QDate &td) 834 const QDate &td)
830{ 835{
831#ifndef KORG_NOPRINTER 836#ifndef KORG_NOPRINTER
832 calPrinter->preview(CalPrinter::Day, fd, td); 837 calPrinter->preview(CalPrinter::Day, fd, td);
833#endif 838#endif
834} 839}
835 840
836void KOListView::showDates() 841void KOListView::showDates()
837{ 842{
838 showDates(true); 843 showDates(true);
839} 844}
840 845
841void KOListView::hideDates() 846void KOListView::hideDates()
842{ 847{
843 showDates(false); 848 showDates(false);
844} 849}
845 850
846void KOListView::resetFocus() 851void KOListView::resetFocus()
847{ 852{
848 topLevelWidget()->setActiveWindow(); 853 topLevelWidget()->setActiveWindow();
849 topLevelWidget()->raise(); 854 topLevelWidget()->raise();
850 mListView->setFocus(); 855 mListView->setFocus();
851} 856}
852void KOListView::updateView() 857void KOListView::updateView()
853{ 858{
854 mListView->setFocus(); 859 mListView->setFocus();
855 if ( mListView->firstChild () ) 860 if ( mListView->firstChild () )
856 mListView->setCurrentItem( mListView->firstChild () ); 861 mListView->setCurrentItem( mListView->firstChild () );
857} 862}
858void KOListView::updateConfig() 863void KOListView::updateConfig()
859{ 864{
860 865
861 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 866 mListView->setFont ( KOPrefs::instance()->mListViewFont );
862 updateView(); 867 updateView();
863 868
864} 869}
865void KOListView::setStartDate(const QDate &start) 870void KOListView::setStartDate(const QDate &start)
866{ 871{
867 mStartDate = start; 872 mStartDate = start;
868} 873}
869 874
870void KOListView::showDates(const QDate &start, const QDate &end) 875void KOListView::showDates(const QDate &start, const QDate &end)
871{ 876{
872 clear(); 877 clear();
873 mStartDate = start; 878 mStartDate = start;
874 QDate date = start; 879 QDate date = start;
875 QPtrList<Journal> j_list; 880 QPtrList<Journal> j_list;
876 while( date <= end ) { 881 while( date <= end ) {
877 addEvents(calendar()->events(date)); 882 addEvents(calendar()->events(date));
878 addTodos(calendar()->todos(date)); 883 addTodos(calendar()->todos(date));
879 Journal* jo = calendar()->journal(date); 884 Journal* jo = calendar()->journal(date);
880 if ( jo ) 885 if ( jo )
881 j_list.append( jo ); 886 j_list.append( jo );
882 date = date.addDays( 1 ); 887 date = date.addDays( 1 );
883 } 888 }
884 addJournals(j_list); 889 addJournals(j_list);
885 emit incidenceSelected( 0 ); 890 emit incidenceSelected( 0 );
886 updateView(); 891 updateView();
887 892
888} 893}
889 894
890void KOListView::addEvents(QPtrList<Event> eventList) 895void KOListView::addEvents(QPtrList<Event> eventList)
891{ 896{
892 897
893 Event *ev; 898 Event *ev;
894 for(ev = eventList.first(); ev; ev = eventList.next()) { 899 for(ev = eventList.first(); ev; ev = eventList.next()) {
895 addIncidence(ev); 900 addIncidence(ev);
896 } 901 }
897 if ( !mListView->currentItem() ){ 902 if ( !mListView->currentItem() ){
898 updateView(); 903 updateView();
899 } 904 }
900} 905}
901 906
902void KOListView::addTodos(QPtrList<Todo> eventList) 907void KOListView::addTodos(QPtrList<Todo> eventList)
903{ 908{
904 Todo *ev; 909 Todo *ev;
905 for(ev = eventList.first(); ev; ev = eventList.next()) { 910 for(ev = eventList.first(); ev; ev = eventList.next()) {
906 addIncidence(ev); 911 addIncidence(ev);
907 } 912 }
908 if ( !mListView->currentItem() ){ 913 if ( !mListView->currentItem() ){
909 updateView(); 914 updateView();
910 } 915 }
911} 916}
912void KOListView::addJournals(QPtrList<Journal> eventList) 917void KOListView::addJournals(QPtrList<Journal> eventList)
913{ 918{
914 Journal *ev; 919 Journal *ev;
915 for(ev = eventList.first(); ev; ev = eventList.next()) { 920 for(ev = eventList.first(); ev; ev = eventList.next()) {
916 addIncidence(ev); 921 addIncidence(ev);
917 } 922 }
918 if ( !mListView->currentItem() ){ 923 if ( !mListView->currentItem() ){
919 updateView(); 924 updateView();
920 } 925 }
921} 926}
922 927
923void KOListView::addIncidence(Incidence *incidence) 928void KOListView::addIncidence(Incidence *incidence)
924{ 929{
925 if ( mUidDict.find( incidence->uid() ) ) return; 930 if ( mUidDict.find( incidence->uid() ) ) return;
926 931
927 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 932 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
928 mUidDict.insert( incidence->uid(), incidence ); 933 mUidDict.insert( incidence->uid(), incidence );
929 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 934 KOListViewItem *item = new KOListViewItem( incidence, mListView );
930 ListItemVisitor v(item, mStartDate ); 935 ListItemVisitor v(item, mStartDate );
931 if (incidence->accept(v)) { 936 if (incidence->accept(v)) {
932 return; 937 return;
933 } 938 }
934 else delete item; 939 else delete item;
935} 940}
936 941
937void KOListView::showEvents(QPtrList<Event> eventList) 942void KOListView::showEvents(QPtrList<Event> eventList)
938{ 943{
939 clear(); 944 clear();
940 945
941 addEvents(eventList); 946 addEvents(eventList);
942 947
943 // After new creation of list view no events are selected. 948 // After new creation of list view no events are selected.
944 emit incidenceSelected( 0 ); 949 emit incidenceSelected( 0 );
945} 950}
946int KOListView::count() 951int KOListView::count()
947{ 952{
948 return mListView->childCount(); 953 return mListView->childCount();
949} 954}
950 955
951void KOListView::changeEventDisplay(Event *event, int action) 956void KOListView::changeEventDisplay(Event *event, int action)
952{ 957{
953 KOListViewItem *item; 958 KOListViewItem *item;
954 959
955 switch(action) { 960 switch(action) {
956 case KOGlobals::EVENTADDED: 961 case KOGlobals::EVENTADDED:
957 addIncidence( event ); 962 addIncidence( event );
958 break; 963 break;
959 case KOGlobals::EVENTEDITED: 964 case KOGlobals::EVENTEDITED:
960 item = getItemForEvent(event); 965 item = getItemForEvent(event);
961 if (item) { 966 if (item) {
962 mUidDict.remove( event->uid() ); 967 mUidDict.remove( event->uid() );
963 delete item; 968 delete item;
964 addIncidence( event ); 969 addIncidence( event );
965 } 970 }
966 break; 971 break;
967 case KOGlobals::EVENTDELETED: 972 case KOGlobals::EVENTDELETED:
968 item = getItemForEvent(event); 973 item = getItemForEvent(event);
969 if (item) { 974 if (item) {
970 mUidDict.remove( event->uid() ); 975 mUidDict.remove( event->uid() );
971 delete item; 976 delete item;
972 } 977 }
973 break; 978 break;
974 default: 979 default:
975 ; 980 ;
976 } 981 }
977} 982}
978 983
979KOListViewItem *KOListView::getItemForEvent(Event *event) 984KOListViewItem *KOListView::getItemForEvent(Event *event)
980{ 985{
981 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 986 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
982 while (item) { 987 while (item) {
983 if (item->data() == event) return item; 988 if (item->data() == event) return item;
984 item = (KOListViewItem *)item->nextSibling(); 989 item = (KOListViewItem *)item->nextSibling();
985 } 990 }
986 return 0; 991 return 0;
987} 992}
988 993
989void KOListView::defaultItemAction(QListViewItem *i) 994void KOListView::defaultItemAction(QListViewItem *i)
990{ 995{
991 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 996 KOListViewItem *item = static_cast<KOListViewItem *>( i );
992 if ( item ) defaultAction( item->data() ); 997 if ( item ) defaultAction( item->data() );
993 998
994} 999}
995 1000
996void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1001void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
997{ 1002{
998 mActiveItem = (KOListViewItem *)item; 1003 mActiveItem = (KOListViewItem *)item;
999 if (mActiveItem) { 1004 if (mActiveItem) {
1000 Incidence *incidence = mActiveItem->data(); 1005 Incidence *incidence = mActiveItem->data();
1001 mPopupMenu->showIncidencePopup(incidence); 1006 mPopupMenu->showIncidencePopup(incidence);
1002 1007
1003 /* 1008 /*
1004 if ( incidence && incidence->type() == "Event" ) { 1009 if ( incidence && incidence->type() == "Event" ) {
1005 Event *event = static_cast<Event *>( incidence ); 1010 Event *event = static_cast<Event *>( incidence );
1006 mPopupMenu->showEventPopup(event); 1011 mPopupMenu->showEventPopup(event);
1007 } 1012 }
1008 */ 1013 */
1009 } 1014 }
1010} 1015}
1011 1016
1012void KOListView::readSettings(KConfig *config, QString setting) 1017void KOListView::readSettings(KConfig *config, QString setting)
1013{ 1018{
1014 // qDebug("KOListView::readSettings "); 1019 // qDebug("KOListView::readSettings ");
1015 mListView->restoreLayout(config,setting); 1020 mListView->restoreLayout(config,setting);
1016} 1021}
1017 1022
1018void KOListView::writeSettings(KConfig *config, QString setting) 1023void KOListView::writeSettings(KConfig *config, QString setting)
1019{ 1024{
1020 // qDebug("KOListView::writeSettings "); 1025 // qDebug("KOListView::writeSettings ");
1021 mListView->saveLayout(config, setting); 1026 mListView->saveLayout(config, setting);
1022} 1027}
1023 1028
1024void KOListView::processSelectionChange(QListViewItem *) 1029void KOListView::processSelectionChange(QListViewItem *)
1025{ 1030{
1026 1031
1027 KOListViewItem *item = 1032 KOListViewItem *item =
1028 static_cast<KOListViewItem *>( mListView->currentItem() ); 1033 static_cast<KOListViewItem *>( mListView->currentItem() );
1029 1034
1030 if ( !item ) { 1035 if ( !item ) {
1031 emit incidenceSelected( 0 ); 1036 emit incidenceSelected( 0 );
1032 } else { 1037 } else {
1033 emit incidenceSelected( item->data() ); 1038 emit incidenceSelected( item->data() );
1034 } 1039 }
1035} 1040}
1036 1041
1037void KOListView::clearSelection() 1042void KOListView::clearSelection()
1038{ 1043{
1039 mListView->selectAll( false ); 1044 mListView->selectAll( false );
1040} 1045}
1041void KOListView::allSelection() 1046void KOListView::allSelection()
1042{ 1047{
1043 mListView->selectAll( true ); 1048 mListView->selectAll( true );
1044} 1049}
1045 1050
1046void KOListView::clear() 1051void KOListView::clear()
1047{ 1052{
1048 mListView->clear(); 1053 mListView->clear();
1049 mUidDict.clear(); 1054 mUidDict.clear();
1050} 1055}
1051 1056
1052Incidence* KOListView::currentItem() 1057Incidence* KOListView::currentItem()
1053{ 1058{
1054 if ( mListView->currentItem() ) 1059 if ( mListView->currentItem() )
1055 return ((KOListViewItem*) mListView->currentItem())->data(); 1060 return ((KOListViewItem*) mListView->currentItem())->data();
1056 return 0; 1061 return 0;
1057} 1062}
1058void KOListView::keyPressEvent ( QKeyEvent *e) 1063void KOListView::keyPressEvent ( QKeyEvent *e)
1059{ 1064{
1060 1065
1061 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1066 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1062 deleteAll(); 1067 deleteAll();
1063 return; 1068 return;
1064 } 1069 }
1065 1070
1066 e->ignore(); 1071 e->ignore();
1067} 1072}
1068void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1073void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1069{ 1074{
1070 1075
1071 switch ( e->key() ) { 1076 switch ( e->key() ) {
1072 case Qt::Key_Down: 1077 case Qt::Key_Down:
1073 if ( e->state() == ShiftButton ) { 1078 if ( e->state() == ShiftButton ) {
1074 QListViewItem* cn = currentItem(); 1079 QListViewItem* cn = currentItem();
1075 if ( !cn ) 1080 if ( !cn )
1076 cn = firstChild(); 1081 cn = firstChild();
1077 if ( !cn ) 1082 if ( !cn )
1078 return; 1083 return;
1079 while ( cn->nextSibling() ) 1084 while ( cn->nextSibling() )
1080 cn = cn->nextSibling(); 1085 cn = cn->nextSibling();
1081 setCurrentItem ( cn ); 1086 setCurrentItem ( cn );
1082 ensureItemVisible ( cn ); 1087 ensureItemVisible ( cn );
1083 1088
1084 e->accept(); 1089 e->accept();
1085 return; 1090 return;
1086 } 1091 }
1087 if ( e->state() == ControlButton ) { 1092 if ( e->state() == ControlButton ) {
1088 int count = childCount (); 1093 int count = childCount ();
1089 int jump = count / 5; 1094 int jump = count / 5;
1090 QListViewItem* cn; 1095 QListViewItem* cn;
1091 cn = currentItem(); 1096 cn = currentItem();
1092 if ( ! cn ) 1097 if ( ! cn )
1093 return; 1098 return;
1094 if ( jump == 0 ) 1099 if ( jump == 0 )
1095 jump = 1; 1100 jump = 1;
1096 while ( jump && cn->nextSibling() ) { 1101 while ( jump && cn->nextSibling() ) {
1097 cn = cn->nextSibling(); 1102 cn = cn->nextSibling();
1098 --jump; 1103 --jump;
1099 } 1104 }
1100 setCurrentItem ( cn ); 1105 setCurrentItem ( cn );
1101 ensureItemVisible ( cn ); 1106 ensureItemVisible ( cn );
1102 1107
1103 } else 1108 } else
1104 QListView::keyPressEvent ( e ) ; 1109 QListView::keyPressEvent ( e ) ;
1105 e->accept(); 1110 e->accept();
1106 break; 1111 break;
1107 1112
1108 case Qt::Key_Up: 1113 case Qt::Key_Up:
1109 if ( e->state() == ShiftButton ) { 1114 if ( e->state() == ShiftButton ) {
1110 QListViewItem* cn = firstChild(); 1115 QListViewItem* cn = firstChild();
1111 if ( cn ) { 1116 if ( cn ) {
1112 setCurrentItem ( cn ); 1117 setCurrentItem ( cn );
1113 ensureItemVisible ( cn ); 1118 ensureItemVisible ( cn );
1114 } 1119 }
1115 e->accept(); 1120 e->accept();
1116 return; 1121 return;
1117 } 1122 }
1118 if ( e->state() == ControlButton ) { 1123 if ( e->state() == ControlButton ) {
1119 int count = childCount (); 1124 int count = childCount ();
1120 int jump = count / 5; 1125 int jump = count / 5;
1121 QListViewItem* cn; 1126 QListViewItem* cn;
1122 cn = currentItem(); 1127 cn = currentItem();
1123 if ( ! cn ) 1128 if ( ! cn )
1124 return; 1129 return;
1125 if ( jump == 0 ) 1130 if ( jump == 0 )
1126 jump = 1; 1131 jump = 1;
1127 while ( jump && cn->itemAbove ()) { 1132 while ( jump && cn->itemAbove ()) {
1128 cn = cn->itemAbove (); 1133 cn = cn->itemAbove ();
1129 --jump; 1134 --jump;
1130 } 1135 }
1131 setCurrentItem ( cn ); 1136 setCurrentItem ( cn );
1132 ensureItemVisible ( cn ); 1137 ensureItemVisible ( cn );
1133 } else 1138 } else
1134 QListView::keyPressEvent ( e ) ; 1139 QListView::keyPressEvent ( e ) ;
1135 e->accept(); 1140 e->accept();
1136 break; 1141 break;
1137 case Qt::Key_I: { 1142 case Qt::Key_I: {
1138 QListViewItem* cn; 1143 QListViewItem* cn;
1139 cn = currentItem(); 1144 cn = currentItem();
1140 if ( cn ) { 1145 if ( cn ) {
1141 KOListViewItem* ci = (KOListViewItem*)( cn ); 1146 KOListViewItem* ci = (KOListViewItem*)( cn );
1142 if ( ci ){ 1147 if ( ci ){
1143 //emit showIncidence( ci->data()); 1148 //emit showIncidence( ci->data());
1144 cn = cn->nextSibling(); 1149 cn = cn->nextSibling();
1145 if ( cn ) { 1150 if ( cn ) {
1146 setCurrentItem ( cn ); 1151 setCurrentItem ( cn );
1147 ensureItemVisible ( cn ); 1152 ensureItemVisible ( cn );
1148 } 1153 }
1149 emit showIncidence( ci->data()); 1154 emit showIncidence( ci->data());
1150 } 1155 }
1151 } 1156 }
1152 e->accept(); 1157 e->accept();
1153 } 1158 }
1154 break; 1159 break;
1155 case Qt::Key_Return: 1160 case Qt::Key_Return:
1156 case Qt::Key_Enter: 1161 case Qt::Key_Enter:
1157 { 1162 {
1158 QListViewItem* cn; 1163 QListViewItem* cn;
1159 cn = currentItem(); 1164 cn = currentItem();
1160 if ( cn ) { 1165 if ( cn ) {
1161 KOListViewItem* ci = (KOListViewItem*)( cn ); 1166 KOListViewItem* ci = (KOListViewItem*)( cn );
1162 if ( ci ){ 1167 if ( ci ){
1163 if ( e->state() == ShiftButton ) 1168 if ( e->state() == ShiftButton )
1164 ci->setSelected( false ); 1169 ci->setSelected( false );
1165 else 1170 else
1166 ci->setSelected( true ); 1171 ci->setSelected( true );
1167 cn = cn->nextSibling(); 1172 cn = cn->nextSibling();
1168 if ( cn ) { 1173 if ( cn ) {
1169 setCurrentItem ( cn ); 1174 setCurrentItem ( cn );
1170 ensureItemVisible ( cn ); 1175 ensureItemVisible ( cn );
1171 } 1176 }
1172 } 1177 }
1173 } 1178 }
1174 e->accept(); 1179 e->accept();
1175 } 1180 }
1176 break; 1181 break;
1177 default: 1182 default:
1178 e->ignore(); 1183 e->ignore();
1179 } 1184 }
1180} 1185}
1181KOListViewListView::KOListViewListView(KOListView * lv ) 1186KOListViewListView::KOListViewListView(KOListView * lv )
1182 : KListView( lv, "kolistlistview", false ) 1187 : KListView( lv, "kolistlistview", false )
1183{ 1188{
1189 mYMousePos = 0;
1184 mPopupTimer = new QTimer(this); 1190 mPopupTimer = new QTimer(this);
1185 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1191 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1186#ifndef DESKTOP_VERSION 1192#ifndef DESKTOP_VERSION
1187 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1193 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1188#endif 1194#endif
1189 setSelectionMode( QListView::Multi ); 1195 setSelectionMode( QListView::Multi );
1190 setMultiSelection( true); 1196 setMultiSelection( true);
1191} 1197}
1192void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1198void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1193{ 1199{
1194 if (!e) return; 1200 if (!e) return;
1195 QPoint vp = contentsToViewport(e->pos()); 1201 QPoint vp = contentsToViewport(e->pos());
1196 QListViewItem *item = itemAt(vp); 1202 QListViewItem *item = itemAt(vp);
1197 if (!item) { 1203 if (!item) {
1198 emit newEvent(); 1204 emit newEvent();
1199 return; 1205 return;
1200 } 1206 }
1201 KListView::contentsMouseDoubleClickEvent(e); 1207 KListView::contentsMouseDoubleClickEvent(e);
1202} 1208}
1203#if 0 1209#if 0
1204void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1210void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1205{ 1211{
1206 //qDebug("contentsMousePressEvent++++ "); 1212 //qDebug("contentsMousePressEvent++++ ");
1207 KListView::contentsMousePressEvent( e ); 1213 KListView::contentsMousePressEvent( e );
1208 if ( e->button() == RightButton ) { 1214 if ( e->button() == RightButton ) {
1209 QListViewItem* ci = currentItem(); 1215 QListViewItem* ci = currentItem();
1210 clearSelection () ; 1216 clearSelection () ;
1211 if ( ci ) 1217 if ( ci )
1212 ci->setSelected( true ); 1218 ci->setSelected( true );
1213 } 1219 }
1214} 1220}
1215void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1221void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1216{ 1222{
1217 KListView::contentsMouseReleaseEvent(e); 1223 KListView::contentsMouseReleaseEvent(e);
1218} 1224}
1219void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1225void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1220{ 1226{
1221 KListView::contentsMouseMoveEvent(e); 1227 KListView::contentsMouseMoveEvent(e);
1222} 1228}
1223#endif 1229#endif
1224void KOListViewListView::popupMenu() 1230void KOListViewListView::popupMenu()
1225{ 1231{
1226 mPopupTimer->stop(); 1232 mPopupTimer->stop();
1227 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1233 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1228 QApplication::postEvent( this->viewport(), e ); 1234 QApplication::postEvent( this->viewport(), e );
1229 1235
1230} 1236}
1231void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1237void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1232{ 1238{
1233 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1239 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1234 mYMousePos = mapToGlobal( (e->pos())).y(); 1240 mYMousePos = mapToGlobal( (e->pos())).y();
1235 if ( e->button() == LeftButton ) { 1241 if ( e->button() == LeftButton ) {
1236 mPopupTimer->start( 600 ); 1242 mPopupTimer->start( 600 );
1237 mEventPos = contentsToViewport(e->pos()); 1243 mEventPos = contentsToViewport(e->pos());
1238 mEventGlobalPos = e->globalPos(); 1244 mEventGlobalPos = e->globalPos();
1239 } 1245 }
1240 KListView::contentsMousePressEvent( e ); 1246 KListView::contentsMousePressEvent( e );
1241 if ( e->button() == RightButton ) { 1247 if ( e->button() == RightButton ) {
1242 QListViewItem* ci = currentItem(); 1248 QListViewItem* ci = currentItem();
1243 //clearSelection(); 1249 //clearSelection();
1244 if ( ci ) 1250 if ( ci )
1245 ci->setSelected( true ); 1251 ci->setSelected( true );
1246 } 1252 }
1247} 1253}
1248void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1254void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1249{ 1255{
1250 mPopupTimer->stop(); 1256 mPopupTimer->stop();
1251 KListView::contentsMouseReleaseEvent(e); 1257 KListView::contentsMouseReleaseEvent(e);
1252} 1258}
1253void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1259void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1254{ 1260{
1255 // qDebug("contentsMouseMoveEv....... "); 1261 // qDebug("contentsMouseMoveEv....... ");
1256 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1262 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1257 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1263 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1258 if ( diff < 0 ) diff = -diff; 1264 if ( diff < 0 ) diff = -diff;
1259 if ( diff > 15 ) 1265 if ( diff > 15 )
1260 mPopupTimer->stop(); 1266 mPopupTimer->stop();
1261 else { 1267 else {
1262 mEventPos = contentsToViewport(e->pos()); 1268 mEventPos = contentsToViewport(e->pos());
1263 mEventGlobalPos = e->globalPos(); 1269 mEventGlobalPos = e->globalPos();
1264 } 1270 }
1265 KListView::contentsMouseMoveEvent(e); 1271 KListView::contentsMouseMoveEvent(e);
1266} 1272}
1267 1273
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index eb5bb6e..2051d60 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,311 +1,312 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef _KOLISTVIEW_H 24#ifndef _KOLISTVIEW_H
25#define _KOLISTVIEW_H 25#define _KOLISTVIEW_H
26 26
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qmap.h> 28#include <qmap.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include <klistview.h> 31#include <klistview.h>
32 32
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/incidence.h> 38#include <libkcal/incidence.h>
39 39
40#include "koeventview.h" 40#include "koeventview.h"
41#include "customlistviewitem.h" 41#include "customlistviewitem.h"
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45 45class KOListViewWhatsThis;
46 46
47#include <qpushbutton.h> 47#include <qpushbutton.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qdialog.h> 49#include <qdialog.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qcombobox.h> 51#include <qcombobox.h>
52#include <qspinbox.h> 52#include <qspinbox.h>
53#include <qtooltip.h> 53#include <qtooltip.h>
54#include <qcheckbox.h> 54#include <qcheckbox.h>
55#include <qhbox.h> 55#include <qhbox.h>
56#include <qlabel.h> 56#include <qlabel.h>
57#include <kiconloader.h> 57#include <kiconloader.h>
58#include "kfiledialog.h" 58#include "kfiledialog.h"
59#include "koprefs.h" 59#include "koprefs.h"
60class KOAlarmPrefs : public QDialog 60class KOAlarmPrefs : public QDialog
61{ 61{
62 Q_OBJECT 62 Q_OBJECT
63 public: 63 public:
64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : 64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) :
65 QDialog( par, name, true ) 65 QDialog( par, name, true )
66 { 66 {
67 setCaption( i18n("Alarm Options") ); 67 setCaption( i18n("Alarm Options") );
68 QVBoxLayout* alarmLayout = new QVBoxLayout( this ); 68 QVBoxLayout* alarmLayout = new QVBoxLayout( this );
69 alarmLayout->setSpacing( 3 ); 69 alarmLayout->setSpacing( 3 );
70 alarmLayout->setMargin( 3 ); 70 alarmLayout->setMargin( 3 );
71 QWidget *parent = this; 71 QWidget *parent = this;
72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); 72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent);
73 alarmLayout->addWidget(mAlarmButton); 73 alarmLayout->addWidget(mAlarmButton);
74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
75 mAlarmTimeEdit->setValue( 15 ); 75 mAlarmTimeEdit->setValue( 15 );
76 alarmLayout->addWidget(mAlarmTimeEdit); 76 alarmLayout->addWidget(mAlarmTimeEdit);
77 mAlarmIncrCombo = new QComboBox(false, parent); 77 mAlarmIncrCombo = new QComboBox(false, parent);
78 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 78 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
79 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 79 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
80 mAlarmIncrCombo->insertItem(i18n("day(s)")); 80 mAlarmIncrCombo->insertItem(i18n("day(s)"));
81 alarmLayout->addWidget(mAlarmIncrCombo); 81 alarmLayout->addWidget(mAlarmIncrCombo);
82 QHBox * hb = new QHBox ( parent ); 82 QHBox * hb = new QHBox ( parent );
83 alarmLayout->addWidget(hb); 83 alarmLayout->addWidget(hb);
84 mAlarmSoundButton = new QPushButton(hb); 84 mAlarmSoundButton = new QPushButton(hb);
85 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 85 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
86 mAlarmSoundButton->setToggleButton(true); 86 mAlarmSoundButton->setToggleButton(true);
87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
88 mAlarmProgramButton = new QPushButton(hb); 88 mAlarmProgramButton = new QPushButton(hb);
89 mAlarmProgramButton->setPixmap(SmallIcon("run")); 89 mAlarmProgramButton->setPixmap(SmallIcon("run"));
90 mAlarmProgramButton->setToggleButton(true); 90 mAlarmProgramButton->setToggleButton(true);
91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
94 mAlarmLabel = new QLabel( this ); 94 mAlarmLabel = new QLabel( this );
95 alarmLayout->addWidget( mAlarmLabel ); 95 alarmLayout->addWidget( mAlarmLabel );
96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); 96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) );
97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
98 mAlarmSoundButton->setOn( true ); 98 mAlarmSoundButton->setOn( true );
99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); 99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this );
100 alarmLayout->addWidget( ok ); 100 alarmLayout->addWidget( ok );
101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
102 alarmLayout->addWidget( cancel ); 102 alarmLayout->addWidget( cancel );
103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
105 resize( 200, 200 ); 105 resize( 200, 200 );
106 106
107 } 107 }
108 108
109 109
110 110
111 QString mAlarmSound, mAlarmProgram ; 111 QString mAlarmSound, mAlarmProgram ;
112 QCheckBox* mAlarmButton; 112 QCheckBox* mAlarmButton;
113 QSpinBox* mAlarmTimeEdit; 113 QSpinBox* mAlarmTimeEdit;
114 QLabel* mAlarmLabel; 114 QLabel* mAlarmLabel;
115 QComboBox* mAlarmIncrCombo ; 115 QComboBox* mAlarmIncrCombo ;
116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
117private slots: 117private slots:
118 118
119void pickAlarmSound() 119void pickAlarmSound()
120{ 120{
121 //QString prefix = mAlarmSound; 121 //QString prefix = mAlarmSound;
122 if (!mAlarmSoundButton->isOn()) { 122 if (!mAlarmSoundButton->isOn()) {
123 //mAlarmSound = ""; 123 //mAlarmSound = "";
124 QToolTip::remove(mAlarmSoundButton); 124 QToolTip::remove(mAlarmSoundButton);
125 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 125 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
126 mAlarmProgramButton->setOn(true); 126 mAlarmProgramButton->setOn(true);
127 mAlarmSoundButton->setOn(false); 127 mAlarmSoundButton->setOn(false);
128 } else { 128 } else {
129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
130 i18n("*.wav|Wav Files"), 0)); 130 i18n("*.wav|Wav Files"), 0));
131 if (!fileName.isEmpty()) { 131 if (!fileName.isEmpty()) {
132 mAlarmSound = fileName; 132 mAlarmSound = fileName;
133 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 133 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
134 QToolTip::remove(mAlarmSoundButton); 134 QToolTip::remove(mAlarmSoundButton);
135 QString dispStr = i18n("Playing '%1'").arg(fileName); 135 QString dispStr = i18n("Playing '%1'").arg(fileName);
136 QToolTip::add(mAlarmSoundButton, dispStr); 136 QToolTip::add(mAlarmSoundButton, dispStr);
137 mAlarmProgramButton->setOn(false); 137 mAlarmProgramButton->setOn(false);
138 mAlarmSoundButton->setOn(true); 138 mAlarmSoundButton->setOn(true);
139 } else { 139 } else {
140 mAlarmProgramButton->setOn(true); 140 mAlarmProgramButton->setOn(true);
141 mAlarmSoundButton->setOn(false); 141 mAlarmSoundButton->setOn(false);
142 142
143 } 143 }
144 } 144 }
145}; 145};
146 146
147void pickAlarmProgram() 147void pickAlarmProgram()
148{ 148{
149 if (!mAlarmProgramButton->isOn()) { 149 if (!mAlarmProgramButton->isOn()) {
150 //mAlarmProgram = ""; 150 //mAlarmProgram = "";
151 QToolTip::remove(mAlarmProgramButton); 151 QToolTip::remove(mAlarmProgramButton);
152 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 152 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
153 mAlarmProgramButton->setOn(false); 153 mAlarmProgramButton->setOn(false);
154 mAlarmSoundButton->setOn(true); 154 mAlarmSoundButton->setOn(true);
155 } else { 155 } else {
156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
157 if (!fileName.isEmpty()) { 157 if (!fileName.isEmpty()) {
158 mAlarmProgram = fileName; 158 mAlarmProgram = fileName;
159 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 159 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
160 QToolTip::remove(mAlarmProgramButton); 160 QToolTip::remove(mAlarmProgramButton);
161 QString dispStr = i18n("Running '%1'").arg(fileName); 161 QString dispStr = i18n("Running '%1'").arg(fileName);
162 QToolTip::add(mAlarmProgramButton, dispStr); 162 QToolTip::add(mAlarmProgramButton, dispStr);
163 mAlarmSoundButton->setOn(false); 163 mAlarmSoundButton->setOn(false);
164 mAlarmProgramButton->setOn(true); 164 mAlarmProgramButton->setOn(true);
165 } else { 165 } else {
166 mAlarmProgramButton->setOn(false); 166 mAlarmProgramButton->setOn(false);
167 mAlarmSoundButton->setOn(true); 167 mAlarmSoundButton->setOn(true);
168 } 168 }
169 } 169 }
170}; 170};
171 171
172}; 172};
173 173
174 174
175 175
176 176
177 177
178 178
179 179
180typedef CustomListViewItem<Incidence *> KOListViewItem; 180typedef CustomListViewItem<Incidence *> KOListViewItem;
181 181
182/** 182/**
183 This class provides the initialisation of a KOListViewItem for calendar 183 This class provides the initialisation of a KOListViewItem for calendar
184 components using the Incidence::Visitor. 184 components using the Incidence::Visitor.
185*/ 185*/
186class ListItemVisitor : public Incidence::Visitor 186class ListItemVisitor : public Incidence::Visitor
187{ 187{
188 public: 188 public:
189 ListItemVisitor(KOListViewItem *, QDate d); 189 ListItemVisitor(KOListViewItem *, QDate d);
190 ~ListItemVisitor(); 190 ~ListItemVisitor();
191 191
192 bool visit(Event *); 192 bool visit(Event *);
193 bool visit(Todo *); 193 bool visit(Todo *);
194 bool visit(Journal *); 194 bool visit(Journal *);
195 195
196 private: 196 private:
197 KOListViewItem *mItem; 197 KOListViewItem *mItem;
198 QDate mDate; 198 QDate mDate;
199}; 199};
200 200
201/** 201/**
202 This class provides a multi-column list view of events. It can 202 This class provides a multi-column list view of events. It can
203 display events from one particular day or several days, it doesn't 203 display events from one particular day or several days, it doesn't
204 matter. To use a view that only handles one day at a time, use 204 matter. To use a view that only handles one day at a time, use
205 KODayListView. 205 KODayListView.
206 206
207 @short multi-column list view of various events. 207 @short multi-column list view of various events.
208 @author Preston Brown <pbrown@kde.org> 208 @author Preston Brown <pbrown@kde.org>
209 @see KOBaseView, KODayListView 209 @see KOBaseView, KODayListView
210*/ 210*/
211class KOListView; 211class KOListView;
212 212
213class KOListViewListView : public KListView 213class KOListViewListView : public KListView
214{ 214{
215 Q_OBJECT 215 Q_OBJECT
216 public: 216 public:
217 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
218 signals: 218 signals:
219 void newEvent(); 219 void newEvent();
220 void showIncidence( Incidence* ); 220 void showIncidence( Incidence* );
221 public slots: 221 public slots:
222 void popupMenu(); 222 void popupMenu();
223 private: 223 private:
224 QPoint mEventPos; 224 QPoint mEventPos;
225 QPoint mEventGlobalPos; 225 QPoint mEventGlobalPos;
226 QTimer* mPopupTimer; 226 QTimer* mPopupTimer;
227 int mYMousePos; 227 int mYMousePos;
228 void keyPressEvent ( QKeyEvent * ) ; 228 void keyPressEvent ( QKeyEvent * ) ;
229 void contentsMouseDoubleClickEvent(QMouseEvent *e); 229 void contentsMouseDoubleClickEvent(QMouseEvent *e);
230 void contentsMousePressEvent(QMouseEvent *e); 230 void contentsMousePressEvent(QMouseEvent *e);
231 void contentsMouseReleaseEvent(QMouseEvent *e); 231 void contentsMouseReleaseEvent(QMouseEvent *e);
232 void contentsMouseMoveEvent(QMouseEvent *e); 232 void contentsMouseMoveEvent(QMouseEvent *e);
233 bool mMouseDown; 233 bool mMouseDown;
234}; 234};
235 235
236class KOListView : public KOEventView 236class KOListView : public KOEventView
237{ 237{
238 Q_OBJECT 238 Q_OBJECT
239 public: 239 public:
240 KOListView(Calendar *calendar, QWidget *parent = 0, 240 KOListView(Calendar *calendar, QWidget *parent = 0,
241 const char *name = 0); 241 const char *name = 0);
242 ~KOListView(); 242 ~KOListView();
243 243
244 virtual int maxDatesHint(); 244 virtual int maxDatesHint();
245 virtual int currentDateCount(); 245 virtual int currentDateCount();
246 virtual QPtrList<Incidence> selectedIncidences(); 246 virtual QPtrList<Incidence> selectedIncidences();
247 virtual DateList selectedDates(); 247 virtual DateList selectedDates();
248 248
249 void showDates(bool show); 249 void showDates(bool show);
250 Incidence* currentItem(); 250 Incidence* currentItem();
251 void addTodos(QPtrList<Todo> eventList); 251 void addTodos(QPtrList<Todo> eventList);
252 void addJournals(QPtrList<Journal> eventList); 252 void addJournals(QPtrList<Journal> eventList);
253 virtual void printPreview(CalPrinter *calPrinter, 253 virtual void printPreview(CalPrinter *calPrinter,
254 const QDate &, const QDate &); 254 const QDate &, const QDate &);
255 255
256 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 256 void readSettings(KConfig *config, QString setting = "KOListView Layout");
257 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 257 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
258 void updateList(); 258 void updateList();
259 void setStartDate(const QDate &start); 259 void setStartDate(const QDate &start);
260 int count(); 260 int count();
261 QString getWhatsThisText(QPoint p); 261 QString getWhatsThisText(QPoint p);
262 signals: 262 signals:
263 void signalNewEvent(); 263 void signalNewEvent();
264 void beamIncidenceList(QPtrList<Incidence>); 264 void beamIncidenceList(QPtrList<Incidence>);
265 265
266 public slots: 266 public slots:
267 void resetFocus(); 267 void resetFocus();
268 virtual void updateView(); 268 virtual void updateView();
269 virtual void showDates(const QDate &start, const QDate &end); 269 virtual void showDates(const QDate &start, const QDate &end);
270 virtual void showEvents(QPtrList<Event> eventList); 270 virtual void showEvents(QPtrList<Event> eventList);
271 void clearSelection(); 271 void clearSelection();
272 void allSelection(); 272 void allSelection();
273 273
274 void clear(); 274 void clear();
275 void beamDone( Ir *ir ); 275 void beamDone( Ir *ir );
276 void showDates(); 276 void showDates();
277 void hideDates(); 277 void hideDates();
278 void deleteAll(); 278 void deleteAll();
279 void saveToFile(); 279 void saveToFile();
280 void saveToFileVCS(); 280 void saveToFileVCS();
281 void saveDescriptionToFile(); 281 void saveDescriptionToFile();
282 void beamSelected(); 282 void beamSelected();
283 void updateConfig(); 283 void updateConfig();
284 void addCat(); 284 void addCat();
285 void setCat(); 285 void setCat();
286 void setAlarm(); 286 void setAlarm();
287 void setCategories( bool removeOld ); 287 void setCategories( bool removeOld );
288 void changeEventDisplay(Event *, int); 288 void changeEventDisplay(Event *, int);
289 289
290 void defaultItemAction(QListViewItem *item); 290 void defaultItemAction(QListViewItem *item);
291 void popupMenu(QListViewItem *item,const QPoint &,int); 291 void popupMenu(QListViewItem *item,const QPoint &,int);
292 292
293 protected slots: 293 protected slots:
294 void processSelectionChange(QListViewItem *); 294 void processSelectionChange(QListViewItem *);
295 295
296 protected: 296 protected:
297 void writeToFile( bool iCal ); 297 void writeToFile( bool iCal );
298 void addEvents(QPtrList<Event> eventList); 298 void addEvents(QPtrList<Event> eventList);
299 void addIncidence(Incidence *); 299 void addIncidence(Incidence *);
300 KOListViewItem *getItemForEvent(Event *event); 300 KOListViewItem *getItemForEvent(Event *event);
301 301
302 private: 302 private:
303 KOListViewWhatsThis *mKOListViewWhatsThis;
303 KOListViewListView *mListView; 304 KOListViewListView *mListView;
304 KOEventPopupMenu *mPopupMenu; 305 KOEventPopupMenu *mPopupMenu;
305 KOListViewItem *mActiveItem; 306 KOListViewItem *mActiveItem;
306 QDict<Incidence> mUidDict; 307 QDict<Incidence> mUidDict;
307 QDate mStartDate; 308 QDate mStartDate;
308 void keyPressEvent ( QKeyEvent * ) ; 309 void keyPressEvent ( QKeyEvent * ) ;
309}; 310};
310 311
311#endif 312#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index ae61db6..7927307 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,2082 +1,2086 @@
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 92#if QT_VERSION >= 0x030000
93
94#else
95 delete mWT;
96#endif
93} 97}
94 98
95 99
96void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 100void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
97{ 101{
98 QListBox::focusInEvent ( e ); 102 QListBox::focusInEvent ( e );
99 if ( count() ){ 103 if ( count() ){
100 int ci = currentItem(); 104 int ci = currentItem();
101 if ( ci < 0 ) ci = 0; 105 if ( ci < 0 ) ci = 0;
102 106
103 setCurrentItem( ci ); 107 setCurrentItem( ci );
104 setSelected ( ci, true ); 108 setSelected ( ci, true );
105 emit highlighted( item ( ci ) ); 109 emit highlighted( item ( ci ) );
106 110
107 resetOnFocusIn = true; 111 resetOnFocusIn = true;
108 112
109 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
110 QListBoxItem *fi = firstItem (); 114 QListBoxItem *fi = firstItem ();
111 if (fi ) { 115 if (fi ) {
112 int ihei = fi->height( this ); 116 int ihei = fi->height( this );
113 int hei = numRows () * ihei; 117 int hei = numRows () * ihei;
114 if ( hei < height() - horizontalScrollBar()->height () ) { 118 if ( hei < height() - horizontalScrollBar()->height () ) {
115 setVScrollBarMode(QScrollView::AlwaysOff); 119 setVScrollBarMode(QScrollView::AlwaysOff);
116 } 120 }
117 else 121 else
118 setVScrollBarMode(QScrollView::Auto); 122 setVScrollBarMode(QScrollView::Auto);
119 if ( ihei *3 > height() ) { 123 if ( ihei *3 > height() ) {
120 setHScrollBarMode(QScrollView::AlwaysOff); 124 setHScrollBarMode(QScrollView::AlwaysOff);
121 } 125 }
122 else { 126 else {
123 setHScrollBarMode(QScrollView::Auto); 127 setHScrollBarMode(QScrollView::Auto);
124 } 128 }
125 } else { 129 } else {
126 setVScrollBarMode(QScrollView::Auto); 130 setVScrollBarMode(QScrollView::Auto);
127 setHScrollBarMode(QScrollView::Auto); 131 setHScrollBarMode(QScrollView::Auto);
128 } 132 }
129 } 133 }
130 } 134 }
131} 135}
132void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
133{ 137{
134 int i = currentItem (); 138 int i = currentItem ();
135 if ( i >= 0 ) { 139 if ( i >= 0 ) {
136 setSelected ( i, false ); 140 setSelected ( i, false );
137 } 141 }
138 QListBox::focusOutEvent ( e ); 142 QListBox::focusOutEvent ( e );
139 setVScrollBarMode(QScrollView::AlwaysOff); 143 setVScrollBarMode(QScrollView::AlwaysOff);
140 setHScrollBarMode(QScrollView::AlwaysOff); 144 setHScrollBarMode(QScrollView::AlwaysOff);
141} 145}
142 146
143QString KNoScrollListBox::getWhatsThisText(QPoint p) 147QString KNoScrollListBox::getWhatsThisText(QPoint p)
144{ 148{
145 QListBoxItem* item = itemAt ( p ); 149 QListBoxItem* item = itemAt ( p );
146 if ( ! item ) { 150 if ( ! item ) {
147 return i18n("Click in the cell\nto add an event!"); 151 return i18n("Click in the cell\nto add an event!");
148 } 152 }
149 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 153 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
150 KOPrefs::instance()->mWTshowDetails, 154 KOPrefs::instance()->mWTshowDetails,
151 KOPrefs::instance()->mWTshowCreated, 155 KOPrefs::instance()->mWTshowCreated,
152 KOPrefs::instance()->mWTshowChanged); 156 KOPrefs::instance()->mWTshowChanged);
153} 157}
154void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 158void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
155{ 159{
156 //qDebug("KNoScrollListBox::keyPressEvent "); 160 //qDebug("KNoScrollListBox::keyPressEvent ");
157 switch(e->key()) { 161 switch(e->key()) {
158 case Key_Right: 162 case Key_Right:
159 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
160 { 164 {
161 e->ignore(); 165 e->ignore();
162 return; 166 return;
163 } 167 }
164 scrollBy(10,0); 168 scrollBy(10,0);
165 break; 169 break;
166 case Key_Left: 170 case Key_Left:
167 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 171 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
168 { 172 {
169 e->ignore(); 173 e->ignore();
170 return; 174 return;
171 } 175 }
172 scrollBy(-10,0); 176 scrollBy(-10,0);
173 break; 177 break;
174 case Key_Up: 178 case Key_Up:
175 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 179 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
176 e->ignore(); 180 e->ignore();
177 break; 181 break;
178 } 182 }
179 if ( count() ) { 183 if ( count() ) {
180 if ( currentItem() == 0 ) { 184 if ( currentItem() == 0 ) {
181 emit prevCell(); 185 emit prevCell();
182 } else { 186 } else {
183 setCurrentItem((currentItem()+count()-1)%count()); 187 setCurrentItem((currentItem()+count()-1)%count());
184 if(!itemVisible(currentItem())) { 188 if(!itemVisible(currentItem())) {
185 if((unsigned int) currentItem() == (count()-1)) { 189 if((unsigned int) currentItem() == (count()-1)) {
186 setTopItem(currentItem()-numItemsVisible()+1); 190 setTopItem(currentItem()-numItemsVisible()+1);
187 } else { 191 } else {
188 setTopItem(topItem()-1); 192 setTopItem(topItem()-1);
189 } 193 }
190 } 194 }
191 } 195 }
192 } 196 }
193 break; 197 break;
194 case Key_Down: 198 case Key_Down:
195 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 199 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
196 e->ignore(); 200 e->ignore();
197 break; 201 break;
198 } 202 }
199 if ( count () ) { 203 if ( count () ) {
200 if ( currentItem()+1 == count () ) { 204 if ( currentItem()+1 == count () ) {
201 emit nextCell(); 205 emit nextCell();
202 } else { 206 } else {
203 setCurrentItem((currentItem()+1)%count()); 207 setCurrentItem((currentItem()+1)%count());
204 if(!itemVisible(currentItem())) { 208 if(!itemVisible(currentItem())) {
205 if(currentItem() == 0) { 209 if(currentItem() == 0) {
206 setTopItem(0); 210 setTopItem(0);
207 } else { 211 } else {
208 setTopItem(topItem()+1); 212 setTopItem(topItem()+1);
209 } 213 }
210 } 214 }
211 } 215 }
212 } 216 }
213 break; 217 break;
214 case Key_I: 218 case Key_I:
215 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 219 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
216 e->ignore(); 220 e->ignore();
217 break; 221 break;
218 case Key_Return: 222 case Key_Return:
219 case Key_Enter: 223 case Key_Enter:
220 { 224 {
221 if ( currentItem() >= 0 ) { 225 if ( currentItem() >= 0 ) {
222 emit doubleClicked( item( currentItem() ) ); 226 emit doubleClicked( item( currentItem() ) );
223 e->accept(); 227 e->accept();
224 } else { 228 } else {
225 e->ignore(); 229 e->ignore();
226 } 230 }
227 } 231 }
228 break; 232 break;
229 case Key_Shift: 233 case Key_Shift:
230 emit shiftDown(); 234 emit shiftDown();
231 break; 235 break;
232 default: 236 default:
233 e->ignore(); 237 e->ignore();
234 break; 238 break;
235 } 239 }
236} 240}
237 241
238void KNoScrollListBox::oneDown() 242void KNoScrollListBox::oneDown()
239{ 243{
240 if ( count () ) { 244 if ( count () ) {
241 if ( currentItem()+1 == count () ) { 245 if ( currentItem()+1 == count () ) {
242 emit nextCell(); 246 emit nextCell();
243 } else { 247 } else {
244 resetOnFocusIn = false; 248 resetOnFocusIn = false;
245 setCurrentItem((currentItem()+1)%count()); 249 setCurrentItem((currentItem()+1)%count());
246 if(!itemVisible(currentItem())) { 250 if(!itemVisible(currentItem())) {
247 if(currentItem() == 0) { 251 if(currentItem() == 0) {
248 setTopItem(0); 252 setTopItem(0);
249 } else { 253 } else {
250 setTopItem(topItem()+1); 254 setTopItem(topItem()+1);
251 } 255 }
252 } 256 }
253 } 257 }
254 } 258 }
255} 259}
256void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
257{ 261{
258 switch(e->key()) { 262 switch(e->key()) {
259 case Key_Shift: 263 case Key_Shift:
260 emit shiftUp(); 264 emit shiftUp();
261 break; 265 break;
262 default: 266 default:
263 break; 267 break;
264 } 268 }
265} 269}
266 270
267void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 271void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
268{ 272{
269 QListBox::mousePressEvent(e); 273 QListBox::mousePressEvent(e);
270 274
271 if(e->button() == RightButton) { 275 if(e->button() == RightButton) {
272 emit rightClick(); 276 emit rightClick();
273 } 277 }
274} 278}
275 279
276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
277 : QListBoxItem() 281 : QListBoxItem()
278{ 282{
279 mblockRepaint = true; 283 mblockRepaint = true;
280 setText( s ); 284 setText( s );
281 mMultiday = 0; 285 mMultiday = 0;
282 mIncidence = incidence; 286 mIncidence = incidence;
283 mDate = qd; 287 mDate = qd;
284 mRecur = false; 288 mRecur = false;
285 mAlarm = false; 289 mAlarm = false;
286 mReply = false; 290 mReply = false;
287 mInfo = false; 291 mInfo = false;
288 mdayPos = 0; 292 mdayPos = 0;
289 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 293 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
290} 294}
291void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
292{ 296{
293 setText( s ); 297 setText( s );
294 mMultiday = 0; 298 mMultiday = 0;
295 mIncidence = incidence; 299 mIncidence = incidence;
296 mDate = qd; 300 mDate = qd;
297 mRecur = false; 301 mRecur = false;
298 mAlarm = false; 302 mAlarm = false;
299 mReply = false; 303 mReply = false;
300 mInfo = false; 304 mInfo = false;
301 mdayPos = 0; 305 mdayPos = 0;
302} 306}
303 307
304void MonthViewItem::paint(QPainter *p) 308void MonthViewItem::paint(QPainter *p)
305{ 309{
306 if ( mblockRepaint ) { 310 if ( mblockRepaint ) {
307 return; 311 return;
308 } 312 }
309#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
310 bool sel = isSelected(); 314 bool sel = isSelected();
311#else 315#else
312 bool sel = selected(); 316 bool sel = selected();
313#endif 317#endif
314 318
315 319
316 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
317 { 321 {
318 p->setBackgroundColor( palette().color( QPalette::Normal, \ 322 p->setBackgroundColor( palette().color( QPalette::Normal, \
319 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 323 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
320 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
321 } 325 }
322 int x = 1; 326 int x = 1;
323 //int y = 3;//(height() - mRecurPixmap.height()) /2; 327 //int y = 3;//(height() - mRecurPixmap.height()) /2;
324 int size = PIXMAP_SIZE; 328 int size = PIXMAP_SIZE;
325 if ( QApplication::desktop()->width() < 300 ) 329 if ( QApplication::desktop()->width() < 300 )
326 size = 3; 330 size = 3;
327 int heihei = height( listBox () ); 331 int heihei = height( listBox () );
328 int y = (heihei - size -1 ) /2; 332 int y = (heihei - size -1 ) /2;
329 333
330 if ( KOPrefs::instance()->mMonthShowIcons ) { 334 if ( KOPrefs::instance()->mMonthShowIcons ) {
331 if ( mInfo ) { 335 if ( mInfo ) {
332 p->fillRect ( x, y,size,size, Qt::darkGreen ); 336 p->fillRect ( x, y,size,size, Qt::darkGreen );
333 x += size + 1; 337 x += size + 1;
334 } 338 }
335 if ( mRecur ) { 339 if ( mRecur ) {
336 p->fillRect ( x, y,size,size, Qt::blue ); 340 p->fillRect ( x, y,size,size, Qt::blue );
337 x += size + 1; 341 x += size + 1;
338 } 342 }
339 if ( mAlarm ) { 343 if ( mAlarm ) {
340 p->fillRect ( x, y,size,size, Qt::red ); 344 p->fillRect ( x, y,size,size, Qt::red );
341 x += size + 1; 345 x += size + 1;
342 } 346 }
343 if ( mReply ) { 347 if ( mReply ) {
344 p->fillRect ( x, y,size,size, Qt::yellow ); 348 p->fillRect ( x, y,size,size, Qt::yellow );
345 x += size + 1; 349 x += size + 1;
346 } 350 }
347 } 351 }
348 if ( mMultiday ) { 352 if ( mMultiday ) {
349 int yyy = y+(size/2); 353 int yyy = y+(size/2);
350 int sizeM = size+2; 354 int sizeM = size+2;
351 p->setBrush( QBrush::SolidPattern ); 355 p->setBrush( QBrush::SolidPattern );
352 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
353 if ( mMultiday == 2 || mMultiday == 3 ) { 357 if ( mMultiday == 2 || mMultiday == 3 ) {
354 QPointArray pa ( 3 ); 358 QPointArray pa ( 3 );
355 pa.setPoint (0, x, yyy ); 359 pa.setPoint (0, x, yyy );
356 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
357 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
358 p->drawPolygon( pa ); 362 p->drawPolygon( pa );
359 } 363 }
360 if ( mMultiday == 2 || mMultiday == 1 ) { 364 if ( mMultiday == 2 || mMultiday == 1 ) {
361 QPointArray pa ( 3 ); 365 QPointArray pa ( 3 );
362 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 366 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
363 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
364 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
365 p->drawPolygon( pa ); 369 p->drawPolygon( pa );
366 } 370 }
367 if ( mMultiday == 1 ) { 371 if ( mMultiday == 1 ) {
368 // 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 ) );
369 373
370 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 );
371 } 375 }
372 if ( mMultiday == 3 ) { 376 if ( mMultiday == 3 ) {
373 // 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 ) );
374 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 );
375 379
376 } 380 }
377 x += sizeM/2 + 1; 381 x += sizeM/2 + 1;
378 x += sizeM + 1; 382 x += sizeM + 1;
379 } 383 }
380 384
381 if ( mIncidence->type() == "Todo" ){ 385 if ( mIncidence->type() == "Todo" ){
382 Todo* td = ( Todo* ) mIncidence; 386 Todo* td = ( Todo* ) mIncidence;
383 if ( td->isCompleted() ) { 387 if ( td->isCompleted() ) {
384 int half = size/2; 388 int half = size/2;
385 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
386 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 ) ;
387 x += half+half + 4; 391 x += half+half + 4;
388 392
389 } else { 393 } else {
390 int val = td->percentComplete()/20; 394 int val = td->percentComplete()/20;
391 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
392 p->drawRect ( x, y-2,7,size+4); 396 p->drawRect ( x, y-2,7,size+4);
393 x += size + 3; 397 x += size + 3;
394 } 398 }
395 } 399 }
396 QFontMetrics fm = p->fontMetrics(); 400 QFontMetrics fm = p->fontMetrics();
397 int yPos; 401 int yPos;
398 int pmheight = size; 402 int pmheight = size;
399 if( pmheight < fm.height() ) 403 if( pmheight < fm.height() )
400 yPos = fm.ascent() + fm.leading()/2; 404 yPos = fm.ascent() + fm.leading()/2;
401 else 405 else
402 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 406 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
403 p->setPen( palette().color( QPalette::Normal, sel ? \ 407 p->setPen( palette().color( QPalette::Normal, sel ? \
404 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 408 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
405 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 409 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
406 p->drawText( x, yPos, text() ); 410 p->drawText( x, yPos, text() );
407 if ( mIncidence->cancelled() ) { 411 if ( mIncidence->cancelled() ) {
408 int wid = fm.width( text() ); 412 int wid = fm.width( text() );
409 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 413 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
410 } 414 }
411 } else { 415 } else {
412 QString pText = text(); 416 QString pText = text();
413 if( pText.mid(2,1) == ":" ) 417 if( pText.mid(2,1) == ":" )
414 pText = pText.mid( 6 ); 418 pText = pText.mid( 6 );
415 p->drawText( x, yPos, pText ); 419 p->drawText( x, yPos, pText );
416 if ( mIncidence->cancelled() ) { 420 if ( mIncidence->cancelled() ) {
417 int wid = fm.width( pText ); 421 int wid = fm.width( pText );
418 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
419 } 423 }
420 } 424 }
421} 425}
422 426
423int MonthViewItem::height(const QListBox *lb) const 427int MonthViewItem::height(const QListBox *lb) const
424{ 428{
425 int ret = 10; 429 int ret = 10;
426 if ( lb ) 430 if ( lb )
427 ret = lb->fontMetrics().lineSpacing()+1; 431 ret = lb->fontMetrics().lineSpacing()+1;
428 return ret; 432 return ret;
429} 433}
430 434
431int MonthViewItem::width(const QListBox *lb) const 435int MonthViewItem::width(const QListBox *lb) const
432{ 436{
433 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
434 int size = PIXMAP_SIZE; 438 int size = PIXMAP_SIZE;
435 if ( QApplication::desktop()->width() < 300 ) 439 if ( QApplication::desktop()->width() < 300 )
436 size = 3; 440 size = 3;
437 int x = 1; 441 int x = 1;
438 if ( KOPrefs::instance()->mMonthShowIcons ) { 442 if ( KOPrefs::instance()->mMonthShowIcons ) {
439 if ( mInfo ) { 443 if ( mInfo ) {
440 x += size + 1; 444 x += size + 1;
441 } 445 }
442 if( mRecur ) { 446 if( mRecur ) {
443 x += size+1; 447 x += size+1;
444 } 448 }
445 if( mAlarm ) { 449 if( mAlarm ) {
446 x += size+1; 450 x += size+1;
447 } 451 }
448 if( mReply ) { 452 if( mReply ) {
449 x += size+1; 453 x += size+1;
450 } 454 }
451 } 455 }
452 if( mMultiday ) { 456 if( mMultiday ) {
453 x += size+1+2+size/2; 457 x += size+1+2+size/2;
454 } 458 }
455 return( x + lb->fontMetrics().width( text() ) + 1 ); 459 return( x + lb->fontMetrics().width( text() ) + 1 );
456 } 460 }
457 if ( ! lb ) 461 if ( ! lb )
458 return 10; 462 return 10;
459 return lb->width(); 463 return lb->width();
460} 464}
461 465
462 466
463MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 467MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
464 : KNoScrollListBox( par ), 468 : KNoScrollListBox( par ),
465 mMonthView( parent ) 469 mMonthView( parent )
466{ 470{
467 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 471 //QVBoxLayout *topLayout = new QVBoxLayout( this );
468 currentPalette = 0; 472 currentPalette = 0;
469 // mLabel = new QLabel( this );QPushButton 473 // mLabel = new QLabel( this );QPushButton
470 mLabel = new QPushButton( this ); 474 mLabel = new QPushButton( this );
471 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 475 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
472 //mLabel->setLineWidth( 1 ); 476 //mLabel->setLineWidth( 1 );
473 //mLabel->setAlignment( AlignCenter ); 477 //mLabel->setAlignment( AlignCenter );
474 mLabel->setFlat( true ); 478 mLabel->setFlat( true );
475 mLabel->setFocusPolicy(NoFocus); 479 mLabel->setFocusPolicy(NoFocus);
476 //mItemList = new KNoScrollListBox( this ); 480 //mItemList = new KNoScrollListBox( this );
477 setMinimumSize( 10, 10 ); 481 setMinimumSize( 10, 10 );
478 setFrameStyle( QFrame::Panel | QFrame::Plain ); 482 setFrameStyle( QFrame::Panel | QFrame::Plain );
479 setLineWidth( 1 ); 483 setLineWidth( 1 );
480 //topLayout->addWidget( mItemList ); 484 //topLayout->addWidget( mItemList );
481 mLabel->raise(); 485 mLabel->raise();
482 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 486 // QColor( 0,0,255 ) QColor( 160,1600,255 )
483 mStandardPalette = palette(); 487 mStandardPalette = palette();
484 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 488 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
485 489
486 enableScrollBars( false ); 490 enableScrollBars( false );
487 updateConfig(); 491 updateConfig();
488 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 492 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
489 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 493 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
490 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 494 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
491 SLOT( defaultAction( QListBoxItem * ) ) ); 495 SLOT( defaultAction( QListBoxItem * ) ) );
492 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 496 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
493 const QPoint &) ), 497 const QPoint &) ),
494 SLOT( contextMenu( QListBoxItem * ) ) ); 498 SLOT( contextMenu( QListBoxItem * ) ) );
495 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 499 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
496 SLOT( selection( QListBoxItem * ) ) ); 500 SLOT( selection( QListBoxItem * ) ) );
497 501
498 /* 502 /*
499 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 503 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
500 SLOT( selection( QListBoxItem * ) ) ); 504 SLOT( selection( QListBoxItem * ) ) );
501 */ 505 */
502} 506}
503#ifdef DESKTOP_VERSION 507#ifdef DESKTOP_VERSION
504QToolTipGroup *MonthViewCell::toolTipGroup() 508QToolTipGroup *MonthViewCell::toolTipGroup()
505{ 509{
506 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 510 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
507 return mToolTipGroup; 511 return mToolTipGroup;
508} 512}
509#endif 513#endif
510 514
511void MonthViewCell::setDate( const QDate &date ) 515void MonthViewCell::setDate( const QDate &date )
512{ 516{
513 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 517 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
514 mDate = date; 518 mDate = date;
515 519
516 520
517 521
518 //resizeEvent( 0 ); 522 //resizeEvent( 0 );
519} 523}
520 524
521QDate MonthViewCell::date() const 525QDate MonthViewCell::date() const
522{ 526{
523 return mDate; 527 return mDate;
524} 528}
525 529
526void MonthViewCell::setPrimary( bool primary ) 530void MonthViewCell::setPrimary( bool primary )
527{ 531{
528 mPrimary = primary; 532 mPrimary = primary;
529 //setMyPalette(); 533 //setMyPalette();
530} 534}
531void MonthViewCell::setMyPalette() 535void MonthViewCell::setMyPalette()
532{ 536{
533 537
534 if ( mHoliday) { 538 if ( mHoliday) {
535 if ( currentPalette == 1 ) return; 539 if ( currentPalette == 1 ) return;
536 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 ) ));
537 setPalette( mHolidayPalette ); 541 setPalette( mHolidayPalette );
538 //mLabel->setPalette( mHolidayPalette ); 542 //mLabel->setPalette( mHolidayPalette );
539 currentPalette = 1; 543 currentPalette = 1;
540 544
541 } else { 545 } else {
542 if ( mPrimary ) { 546 if ( mPrimary ) {
543 if ( currentPalette == 2 ) return; 547 if ( currentPalette == 2 ) return;
544 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 ) ));
545 //mLabel->setPalette( mPrimaryPalette ); 549 //mLabel->setPalette( mPrimaryPalette );
546 setPalette( mPrimaryPalette ); 550 setPalette( mPrimaryPalette );
547 currentPalette = 2; 551 currentPalette = 2;
548 552
549 } else { 553 } else {
550 if ( currentPalette == 3 ) return; 554 if ( currentPalette == 3 ) return;
551 setPalette( mNonPrimaryPalette ); 555 setPalette( mNonPrimaryPalette );
552 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 ) ));
553 //mLabel->setPalette( mNonPrimaryPalette );; 557 //mLabel->setPalette( mNonPrimaryPalette );;
554 currentPalette = 3; 558 currentPalette = 3;
555 } 559 }
556 } 560 }
557 //QPalette pal = palette(); 561 //QPalette pal = palette();
558 562
559 //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 ) ));
560} 564}
561QPalette MonthViewCell::getPalette () 565QPalette MonthViewCell::getPalette ()
562{ 566{
563 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
564 return mStandardPalette; 568 return mStandardPalette;
565 if ( mHoliday) { 569 if ( mHoliday) {
566 return mHolidayPalette ; 570 return mHolidayPalette ;
567 } else { 571 } else {
568 if ( mPrimary ) { 572 if ( mPrimary ) {
569 return mPrimaryPalette ; 573 return mPrimaryPalette ;
570 } 574 }
571 } 575 }
572 return mNonPrimaryPalette; 576 return mNonPrimaryPalette;
573} 577}
574bool MonthViewCell::isPrimary() const 578bool MonthViewCell::isPrimary() const
575{ 579{
576 return mPrimary; 580 return mPrimary;
577} 581}
578 582
579void MonthViewCell::setHoliday( bool holiday ) 583void MonthViewCell::setHoliday( bool holiday )
580{ 584{
581 mHoliday = holiday; 585 mHoliday = holiday;
582 //setMyPalette(); 586 //setMyPalette();
583} 587}
584 588
585void MonthViewCell::setHoliday( const QString &holiday ) 589void MonthViewCell::setHoliday( const QString &holiday )
586{ 590{
587 mHolidayString = holiday; 591 mHolidayString = holiday;
588 592
589 if ( !holiday.isEmpty() ) { 593 if ( !holiday.isEmpty() ) {
590 setHoliday( true ); 594 setHoliday( true );
591 } 595 }
592} 596}
593 597
594void MonthViewCell::startUpdateCell() 598void MonthViewCell::startUpdateCell()
595{ 599{
596 mdayCount = 0; 600 mdayCount = 0;
597 setFocusPolicy(NoFocus); 601 setFocusPolicy(NoFocus);
598 if ( !mMonthView->isUpdatePossible() ) 602 if ( !mMonthView->isUpdatePossible() )
599 return; 603 return;
600 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 604 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
601 while ( mitem ) { 605 while ( mitem ) {
602 mitem->setBlockRepaint( true ); 606 mitem->setBlockRepaint( true );
603 mitem = (MonthViewItem *)mitem->next(); 607 mitem = (MonthViewItem *)mitem->next();
604 } 608 }
605 if ( mAvailItemList.count() > 20 ) { 609 if ( mAvailItemList.count() > 20 ) {
606 mAvailItemList.setAutoDelete( true ); 610 mAvailItemList.setAutoDelete( true );
607 mAvailItemList.clear(); 611 mAvailItemList.clear();
608 mAvailItemList.setAutoDelete( false ); 612 mAvailItemList.setAutoDelete( false );
609 } 613 }
610 614
611 setPrimary( mDate.month()%2 ); 615 setPrimary( mDate.month()%2 );
612 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);
613 if ( mDate == QDate::currentDate() ) { 617 if ( mDate == QDate::currentDate() ) {
614 setLineWidth( 3 ); 618 setLineWidth( 3 );
615 } else { 619 } else {
616 setLineWidth( 1 ); 620 setLineWidth( 1 );
617 } 621 }
618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
619 //clear(); 623 //clear();
620 while ( CurrentAvailItem ) { 624 while ( CurrentAvailItem ) {
621 MonthViewItem *item = CurrentAvailItem; 625 MonthViewItem *item = CurrentAvailItem;
622 CurrentAvailItem = (MonthViewItem *)item->next(); 626 CurrentAvailItem = (MonthViewItem *)item->next();
623 mAvailItemList.append( item ); 627 mAvailItemList.append( item );
624 takeItem ( item ); 628 takeItem ( item );
625 } 629 }
626 630
627#ifdef DESKTOP_VERSION 631#ifdef DESKTOP_VERSION
628 QToolTip::remove(this); 632 QToolTip::remove(this);
629#endif 633#endif
630 mToolTip.clear(); 634 mToolTip.clear();
631 //qApp->processEvents(); 635 //qApp->processEvents();
632#if 0 636#if 0
633 if ( !mHolidayString.isEmpty() ) { 637 if ( !mHolidayString.isEmpty() ) {
634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
635 item->setPalette( mHolidayPalette ); 639 item->setPalette( mHolidayPalette );
636 insertItem( item ); 640 insertItem( item );
637 mToolTip.append ( mHolidayString ); 641 mToolTip.append ( mHolidayString );
638 } 642 }
639#endif 643#endif
640} 644}
641 645
642int MonthViewCell::insertEvent(Event *event) 646int MonthViewCell::insertEvent(Event *event)
643{ 647{
644 bool useToolTips = true; 648 bool useToolTips = true;
645#ifndef DESKTOP_VERSION 649#ifndef DESKTOP_VERSION
646 useToolTips = false; 650 useToolTips = false;
647#endif 651#endif
648 QString mToolTipText; 652 QString mToolTipText;
649 setFocusPolicy(WheelFocus); 653 setFocusPolicy(WheelFocus);
650 if ( !(event->doesRecur() == Recurrence::rNone) ) { 654 if ( !(event->doesRecur() == Recurrence::rNone) ) {
651 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
652 return mdayCount; 656 return mdayCount;
653 else 657 else
654 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
655 return mdayCount; 659 return mdayCount;
656 } 660 }
657 661
658 if ( event->isHoliday()) { 662 if ( event->isHoliday()) {
659 setHoliday( true ); 663 setHoliday( true );
660 if ( mDate.dayOfWeek() == 7 ) 664 if ( mDate.dayOfWeek() == 7 )
661 setLineWidth( 3 ); 665 setLineWidth( 3 );
662 } 666 }
663 QString text; 667 QString text;
664 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
665 if (event->isMultiDay()) { 669 if (event->isMultiDay()) {
666 QString prefix = "<->";multiday = 2; 670 QString prefix = "<->";multiday = 2;
667 QString time; 671 QString time;
668 if ( event->doesRecur() ) { 672 if ( event->doesRecur() ) {
669 if ( event->recursOn( mDate) ) { 673 if ( event->recursOn( mDate) ) {
670 prefix ="->" ;multiday = 1; 674 prefix ="->" ;multiday = 1;
671 } 675 }
672 else { 676 else {
673 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
674 if ( event->recursOn( mDate.addDays( -days)) ) { 678 if ( event->recursOn( mDate.addDays( -days)) ) {
675 prefix ="<-" ;multiday = 3; 679 prefix ="<-" ;multiday = 3;
676 } 680 }
677 } 681 }
678 682
679 } else { 683 } else {
680 if (mDate == event->dtStart().date()) { 684 if (mDate == event->dtStart().date()) {
681 prefix ="->" ;multiday = 1; 685 prefix ="->" ;multiday = 1;
682 } else if (mDate == event->dtEnd().date()) { 686 } else if (mDate == event->dtEnd().date()) {
683 prefix ="<-" ;multiday = 3; 687 prefix ="<-" ;multiday = 3;
684 } 688 }
685 } 689 }
686 if ( !event->doesFloat() ) { 690 if ( !event->doesFloat() ) {
687 if ( mDate == event->dtStart().date () ) 691 if ( mDate == event->dtStart().date () )
688 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
689 else if ( mDate == event->dtEnd().date () ) 693 else if ( mDate == event->dtEnd().date () )
690 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
691 695
692 } 696 }
693 text = time + event->summary(); 697 text = time + event->summary();
694 if ( useToolTips ) 698 if ( useToolTips )
695 mToolTipText += prefix + text; 699 mToolTipText += prefix + text;
696 } else { 700 } else {
697 if (event->doesFloat()) { 701 if (event->doesFloat()) {
698 text = event->summary(); 702 text = event->summary();
699 if ( useToolTips ) 703 if ( useToolTips )
700 mToolTipText += text; 704 mToolTipText += text;
701 } 705 }
702 else { 706 else {
703 text = KGlobal::locale()->formatTime(event->dtStart().time()); 707 text = KGlobal::locale()->formatTime(event->dtStart().time());
704 text += " " + event->summary(); 708 text += " " + event->summary();
705 if ( useToolTips ) 709 if ( useToolTips )
706 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();
707 } 711 }
708 } 712 }
709 if ( useToolTips && ! event->location().isEmpty() ) { 713 if ( useToolTips && ! event->location().isEmpty() ) {
710 mToolTipText += " (" + event->location() +")"; 714 mToolTipText += " (" + event->location() +")";
711 } 715 }
712 MonthViewItem *item ; 716 MonthViewItem *item ;
713 717
714 if ( mAvailItemList.count() ) { 718 if ( mAvailItemList.count() ) {
715 item = mAvailItemList.first(); 719 item = mAvailItemList.first();
716 mAvailItemList.remove( item ); 720 mAvailItemList.remove( item );
717 item->recycle( event, mDate, text ); 721 item->recycle( event, mDate, text );
718 } else { 722 } else {
719 item = new MonthViewItem( event, mDate, text ); 723 item = new MonthViewItem( event, mDate, text );
720 } 724 }
721 725
722 QPalette pal; 726 QPalette pal;
723 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
724 QStringList categories = event->categories(); 728 QStringList categories = event->categories();
725 QString cat = categories.first(); 729 QString cat = categories.first();
726 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
727 pal = getPalette(); 731 pal = getPalette();
728 if (cat.isEmpty()) { 732 if (cat.isEmpty()) {
729 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 733 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
730 } else { 734 } else {
731 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 735 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
732 } 736 }
733 737
734 } else { 738 } else {
735 if (cat.isEmpty()) { 739 if (cat.isEmpty()) {
736 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 740 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
737 } else { 741 } else {
738 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 742 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
739 } 743 }
740 } 744 }
741 745
742 } else { 746 } else {
743 pal = mStandardPalette ; 747 pal = mStandardPalette ;
744 } 748 }
745 item->setPalette( pal ); 749 item->setPalette( pal );
746 item->setRecur( event->recurrence()->doesRecur() ); 750 item->setRecur( event->recurrence()->doesRecur() );
747 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 751 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
748 item->setMoreInfo( event->description().length() > 0 ); 752 item->setMoreInfo( event->description().length() > 0 );
749#ifdef DESKTOP_VERSION 753#ifdef DESKTOP_VERSION
750 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 754 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
751 KOPrefs::instance()->email()); 755 KOPrefs::instance()->email());
752 if ( me != 0 ) { 756 if ( me != 0 ) {
753 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 757 if ( me->status() == Attendee::NeedsAction && me->RSVP())
754 item->setReply(true && multiday < 2); 758 item->setReply(true && multiday < 2);
755 else 759 else
756 item->setReply(false); 760 item->setReply(false);
757 } else 761 } else
758 item->setReply(false); 762 item->setReply(false);
759#endif 763#endif
760 item->setMultiDay( multiday ); 764 item->setMultiDay( multiday );
761 if ( multiday ) { 765 if ( multiday ) {
762 insertItem( item ,mdayCount); 766 insertItem( item ,mdayCount);
763 ++mdayCount; 767 ++mdayCount;
764 } else { 768 } else {
765 uint i; 769 uint i;
766 int pos = mdayCount; 770 int pos = mdayCount;
767 for ( i = mdayCount; i < count();++i ) { 771 for ( i = mdayCount; i < count();++i ) {
768 QListBoxItem* it = this->item ( i ); 772 QListBoxItem* it = this->item ( i );
769 if ( text < it->text() ) { 773 if ( text < it->text() ) {
770 pos = i; 774 pos = i;
771 break; 775 break;
772 } 776 }
773 ++pos; 777 ++pos;
774 } 778 }
775 insertItem( item ,pos); 779 insertItem( item ,pos);
776 } 780 }
777 if ( useToolTips ) { 781 if ( useToolTips ) {
778 mToolTip.append( mToolTipText ); 782 mToolTip.append( mToolTipText );
779 } 783 }
780 return mdayCount; 784 return mdayCount;
781} 785}
782void MonthViewCell::insertTodo(Todo *todo) 786void MonthViewCell::insertTodo(Todo *todo)
783{ 787{
784 setFocusPolicy(WheelFocus); 788 setFocusPolicy(WheelFocus);
785 QString text; 789 QString text;
786 if (todo->hasDueDate()) { 790 if (todo->hasDueDate()) {
787 if (!todo->doesFloat()) { 791 if (!todo->doesFloat()) {
788 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 792 text += KGlobal::locale()->formatTime(todo->dtDue().time());
789 text += " "; 793 text += " ";
790 } 794 }
791 } 795 }
792 text += todo->summary(); 796 text += todo->summary();
793 MonthViewItem *item ; 797 MonthViewItem *item ;
794 if ( mAvailItemList.count() ) { 798 if ( mAvailItemList.count() ) {
795 item = mAvailItemList.first(); 799 item = mAvailItemList.first();
796 mAvailItemList.remove( item ); 800 mAvailItemList.remove( item );
797 item->recycle( todo, mDate, text ); 801 item->recycle( todo, mDate, text );
798 } else { 802 } else {
799 item = new MonthViewItem( todo, mDate, text ); 803 item = new MonthViewItem( todo, mDate, text );
800 } 804 }
801 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 805 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
802 //item->setPalette( mStandardPalette ); 806 //item->setPalette( mStandardPalette );
803 QPalette pal; 807 QPalette pal;
804 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 808 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
805 QStringList categories = todo->categories(); 809 QStringList categories = todo->categories();
806 QString cat = categories.first(); 810 QString cat = categories.first();
807 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 811 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
808 pal = getPalette(); 812 pal = getPalette();
809 if (cat.isEmpty()) { 813 if (cat.isEmpty()) {
810 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 814 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
811 } else { 815 } else {
812 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 816 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
813 } 817 }
814 818
815 } else { 819 } else {
816 if (cat.isEmpty()) { 820 if (cat.isEmpty()) {
817 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 821 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
818 } else { 822 } else {
819 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 823 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
820 } 824 }
821 } 825 }
822 826
823 } else { 827 } else {
824 pal = mStandardPalette ; 828 pal = mStandardPalette ;
825 } 829 }
826 item->setPalette( pal ); 830 item->setPalette( pal );
827 item->setRecur( todo->recurrence()->doesRecur() ); 831 item->setRecur( todo->recurrence()->doesRecur() );
828 item->setAlarm( todo->isAlarmEnabled() ); 832 item->setAlarm( todo->isAlarmEnabled() );
829 item->setMoreInfo( todo->description().length() > 0 ); 833 item->setMoreInfo( todo->description().length() > 0 );
830 insertItem( item , count()); 834 insertItem( item , count());
831#ifdef DESKTOP_VERSION 835#ifdef DESKTOP_VERSION
832 mToolTip.append( text ); 836 mToolTip.append( text );
833#endif 837#endif
834} 838}
835void MonthViewCell::repaintfinishUpdateCell() 839void MonthViewCell::repaintfinishUpdateCell()
836{ 840{
837 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 841 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
838 while ( mitem ) { 842 while ( mitem ) {
839 mitem->setBlockRepaint( false ); 843 mitem->setBlockRepaint( false );
840 updateItem ( mitem ); 844 updateItem ( mitem );
841 mitem = (MonthViewItem *)mitem->next(); 845 mitem = (MonthViewItem *)mitem->next();
842 } 846 }
843} 847}
844void MonthViewCell::finishUpdateCell() 848void MonthViewCell::finishUpdateCell()
845{ 849{
846 850
847 851
848 852
849#ifdef DESKTOP_VERSION 853#ifdef DESKTOP_VERSION
850 if (mToolTip.count() > 0 ) { 854 if (mToolTip.count() > 0 ) {
851 mToolTip.sort(); 855 mToolTip.sort();
852 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 856 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
853 } 857 }
854#endif 858#endif
855 //sort(); 859 //sort();
856 //setMyPalette(); 860 //setMyPalette();
857 setMyPalette(); 861 setMyPalette();
858 862
859 resizeEvent( 0 ); 863 resizeEvent( 0 );
860 864
861} 865}
862void MonthViewCell::updateCell() 866void MonthViewCell::updateCell()
863{ 867{
864 if ( !mMonthView->isUpdatePossible() ) 868 if ( !mMonthView->isUpdatePossible() )
865 return; 869 return;
866 startUpdateCell(); 870 startUpdateCell();
867 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 871 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
868 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 872 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
869 Event *event; 873 Event *event;
870 for( event = events.first(); event; event = events.next() ) { // for event 874 for( event = events.first(); event; event = events.next() ) { // for event
871 insertEvent(event); 875 insertEvent(event);
872 } 876 }
873 // insert due todos 877 // insert due todos
874 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 878 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
875 Todo *todo; 879 Todo *todo;
876 for(todo = todos.first(); todo; todo = todos.next()) { 880 for(todo = todos.first(); todo; todo = todos.next()) {
877 insertTodo( todo ); 881 insertTodo( todo );
878 } 882 }
879 finishUpdateCell(); 883 finishUpdateCell();
880 // if ( isVisible()) 884 // if ( isVisible())
881 //qApp->processEvents(); 885 //qApp->processEvents();
882} 886}
883 887
884void MonthViewCell::updateConfig( bool bigFont ) // = false 888void MonthViewCell::updateConfig( bool bigFont ) // = false
885{ 889{
886 890
887 if ( bigFont ) { 891 if ( bigFont ) {
888 QFont fo = KOPrefs::instance()->mMonthViewFont; 892 QFont fo = KOPrefs::instance()->mMonthViewFont;
889 int ps = fo.pointSize() + 2; 893 int ps = fo.pointSize() + 2;
890 if ( ps < 18 ) 894 if ( ps < 18 )
891 ps += 2; 895 ps += 2;
892 fo.setPointSize( ps ); 896 fo.setPointSize( ps );
893 setFont( fo ); 897 setFont( fo );
894 } else 898 } else
895 setFont( KOPrefs::instance()->mMonthViewFont ); 899 setFont( KOPrefs::instance()->mMonthViewFont );
896 900
897 QFontMetrics fm( font() ); 901 QFontMetrics fm( font() );
898 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 902 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
899 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 903 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
900 mHolidayPalette = mStandardPalette; 904 mHolidayPalette = mStandardPalette;
901 mPrimaryPalette = mStandardPalette; 905 mPrimaryPalette = mStandardPalette;
902 mNonPrimaryPalette = mStandardPalette; 906 mNonPrimaryPalette = mStandardPalette;
903 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 907 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
904 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 908 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
905 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 909 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
906 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 910 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
907 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 911 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
908 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 912 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
909 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 913 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
910 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 914 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
911 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 915 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
912 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 916 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
913 } 917 }
914 //updateCell(); 918 //updateCell();
915} 919}
916 920
917void MonthViewCell::enableScrollBars( bool enabled ) 921void MonthViewCell::enableScrollBars( bool enabled )
918{ 922{
919 923
920 return; 924 return;
921 if ( enabled ) { 925 if ( enabled ) {
922 QListBoxItem *fi = firstItem (); 926 QListBoxItem *fi = firstItem ();
923 if (fi ) { 927 if (fi ) {
924 int ihei = fi->height( this ); 928 int ihei = fi->height( this );
925 int hei = numRows () * ihei; 929 int hei = numRows () * ihei;
926 if ( hei < height() - horizontalScrollBar()->height () ) { 930 if ( hei < height() - horizontalScrollBar()->height () ) {
927 setVScrollBarMode(QScrollView::AlwaysOff); 931 setVScrollBarMode(QScrollView::AlwaysOff);
928 } 932 }
929 else 933 else
930 setVScrollBarMode(QScrollView::Auto); 934 setVScrollBarMode(QScrollView::Auto);
931 if ( ihei *3 > height() ) { 935 if ( ihei *3 > height() ) {
932 setHScrollBarMode(QScrollView::AlwaysOff); 936 setHScrollBarMode(QScrollView::AlwaysOff);
933 } 937 }
934 else { 938 else {
935 setHScrollBarMode(QScrollView::Auto); 939 setHScrollBarMode(QScrollView::Auto);
936 } 940 }
937 } else { 941 } else {
938 setVScrollBarMode(QScrollView::Auto); 942 setVScrollBarMode(QScrollView::Auto);
939 setHScrollBarMode(QScrollView::Auto); 943 setHScrollBarMode(QScrollView::Auto);
940 } 944 }
941 } else { 945 } else {
942 setVScrollBarMode(QScrollView::AlwaysOff); 946 setVScrollBarMode(QScrollView::AlwaysOff);
943 setHScrollBarMode(QScrollView::AlwaysOff); 947 setHScrollBarMode(QScrollView::AlwaysOff);
944 } 948 }
945} 949}
946 950
947Incidence *MonthViewCell::selectedIncidence() 951Incidence *MonthViewCell::selectedIncidence()
948{ 952{
949 int index = currentItem(); 953 int index = currentItem();
950 if ( index < 0 ) return 0; 954 if ( index < 0 ) return 0;
951 955
952 MonthViewItem *mitem = 956 MonthViewItem *mitem =
953 static_cast<MonthViewItem *>( item( index ) ); 957 static_cast<MonthViewItem *>( item( index ) );
954 958
955 if ( !mitem ) return 0; 959 if ( !mitem ) return 0;
956 960
957 return mitem->incidence(); 961 return mitem->incidence();
958} 962}
959 963
960QDate MonthViewCell::selectedIncidenceDate() 964QDate MonthViewCell::selectedIncidenceDate()
961{ 965{
962 QDate qd; 966 QDate qd;
963 int index = currentItem(); 967 int index = currentItem();
964 if ( index < 0 ) return qd; 968 if ( index < 0 ) return qd;
965 969
966 MonthViewItem *mitem = 970 MonthViewItem *mitem =
967 static_cast<MonthViewItem *>( item( index ) ); 971 static_cast<MonthViewItem *>( item( index ) );
968 972
969 if ( !mitem ) return qd; 973 if ( !mitem ) return qd;
970 974
971 return mitem->incidenceDate(); 975 return mitem->incidenceDate();
972} 976}
973 977
974void MonthViewCell::deselect() 978void MonthViewCell::deselect()
975{ 979{
976 clearSelection(); 980 clearSelection();
977 enableScrollBars( false ); 981 enableScrollBars( false );
978 // updateCell(); 982 // updateCell();
979} 983}
980void MonthViewCell::select() 984void MonthViewCell::select()
981{ 985{
982 ;// updateCell(); 986 ;// updateCell();
983} 987}
984 988
985void MonthViewCell::resizeEvent ( QResizeEvent * e ) 989void MonthViewCell::resizeEvent ( QResizeEvent * e )
986{ 990{
987 if ( !mMonthView->isUpdatePossible() ) 991 if ( !mMonthView->isUpdatePossible() )
988 return; 992 return;
989 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 993 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
990 deselect(); 994 deselect();
991 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 995 mLabel->setMaximumHeight( height() - lineWidth()*2 );
992 996
993 QString text; 997 QString text;
994 mLabel->setText( text ); 998 mLabel->setText( text );
995 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 999 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
996 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1000 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
997 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1001 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
998 mLabel->resize( mLabelBigSize ); 1002 mLabel->resize( mLabelBigSize );
999 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1003 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1000 } else { 1004 } else {
1001 mLabel->resize( mLabelSize ); 1005 mLabel->resize( mLabelSize );
1002 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1006 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1003 } 1007 }
1004 mLabel->setText( text ); 1008 mLabel->setText( text );
1005 1009
1006 int size = height() - mLabel->height() - lineWidth()-1; 1010 int size = height() - mLabel->height() - lineWidth()-1;
1007 //qDebug("LW %d ", lineWidth()); 1011 //qDebug("LW %d ", lineWidth());
1008 if ( size > 0 ) 1012 if ( size > 0 )
1009 verticalScrollBar()->setMaximumHeight( size ); 1013 verticalScrollBar()->setMaximumHeight( size );
1010 size = width() - mLabel->width() -lineWidth()-1; 1014 size = width() - mLabel->width() -lineWidth()-1;
1011 if ( size > 0 ) 1015 if ( size > 0 )
1012 horizontalScrollBar()->setMaximumWidth( size ); 1016 horizontalScrollBar()->setMaximumWidth( size );
1013 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1017 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1014 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1018 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1015 // mItemList->resize ( width(), height () ); 1019 // mItemList->resize ( width(), height () );
1016 if ( e ) 1020 if ( e )
1017 KNoScrollListBox::resizeEvent ( e ); 1021 KNoScrollListBox::resizeEvent ( e );
1018} 1022}
1019 1023
1020void MonthViewCell::defaultAction( QListBoxItem *item ) 1024void MonthViewCell::defaultAction( QListBoxItem *item )
1021{ 1025{
1022 1026
1023 if ( !item ) { 1027 if ( !item ) {
1024 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1028 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1025 emit newEventSignal( dt ); 1029 emit newEventSignal( dt );
1026 return; 1030 return;
1027 } 1031 }
1028 1032
1029 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1033 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1030 Incidence *incidence = eventItem->incidence(); 1034 Incidence *incidence = eventItem->incidence();
1031 if ( incidence ) mMonthView->defaultAction( incidence ); 1035 if ( incidence ) mMonthView->defaultAction( incidence );
1032} 1036}
1033void MonthViewCell::showDay() 1037void MonthViewCell::showDay()
1034{ 1038{
1035 emit showDaySignal( date() ); 1039 emit showDaySignal( date() );
1036} 1040}
1037void MonthViewCell::newEvent() 1041void MonthViewCell::newEvent()
1038{ 1042{
1039 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1043 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1040 emit newEventSignal( dt ); 1044 emit newEventSignal( dt );
1041} 1045}
1042void MonthViewCell::cellClicked( QListBoxItem *item ) 1046void MonthViewCell::cellClicked( QListBoxItem *item )
1043{ 1047{
1044 mMonthView->setSelectedCell( this ); 1048 mMonthView->setSelectedCell( this );
1045 if ( item == 0 ) { 1049 if ( item == 0 ) {
1046 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1050 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1047 emit newEventSignal( dt ); 1051 emit newEventSignal( dt );
1048 return; 1052 return;
1049 } 1053 }
1050 1054
1051} 1055}
1052 1056
1053void MonthViewCell::contextMenu( QListBoxItem *item ) 1057void MonthViewCell::contextMenu( QListBoxItem *item )
1054{ 1058{
1055 mMonthView->setPopupCell( this ); 1059 mMonthView->setPopupCell( this );
1056 if ( !item ) { 1060 if ( !item ) {
1057 mMonthView->showContextMenu( 0 ); 1061 mMonthView->showContextMenu( 0 );
1058 return; 1062 return;
1059 } 1063 }
1060 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1064 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1061 Incidence *incidence = eventItem->incidence(); 1065 Incidence *incidence = eventItem->incidence();
1062 if ( incidence ) mMonthView->showContextMenu( incidence ); 1066 if ( incidence ) mMonthView->showContextMenu( incidence );
1063} 1067}
1064 1068
1065void MonthViewCell::selection( QListBoxItem *item ) 1069void MonthViewCell::selection( QListBoxItem *item )
1066{ 1070{
1067 if ( !item ) return; 1071 if ( !item ) return;
1068 1072
1069 mMonthView->setSelectedCell( this ); 1073 mMonthView->setSelectedCell( this );
1070} 1074}
1071 1075
1072 1076
1073// ******************************************************************************* 1077// *******************************************************************************
1074// ******************************************************************************* 1078// *******************************************************************************
1075// ******************************************************************************* 1079// *******************************************************************************
1076 1080
1077 1081
1078KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1082KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1079 : KOEventView( calendar, parent, name ), 1083 : KOEventView( calendar, parent, name ),
1080 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1084 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1081 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1085 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1082{ 1086{
1083 mFlagKeyPressed = false; 1087 mFlagKeyPressed = false;
1084 mShortDayLabelsM = false; 1088 mShortDayLabelsM = false;
1085 mShortDayLabelsW = false; 1089 mShortDayLabelsW = false;
1086 skipResize = false; 1090 skipResize = false;
1087 clPending = true; 1091 clPending = true;
1088 mPopupCell = 0; 1092 mPopupCell = 0;
1089 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1093 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1090 mWidStack = new QWidgetStack( this ); 1094 mWidStack = new QWidgetStack( this );
1091 QVBoxLayout* hb = new QVBoxLayout( this ); 1095 QVBoxLayout* hb = new QVBoxLayout( this );
1092 mMonthView = new QWidget( mWidStack ); 1096 mMonthView = new QWidget( mWidStack );
1093 mWeekView = new QWidget( mWidStack ); 1097 mWeekView = new QWidget( mWidStack );
1094#if QT_VERSION >= 0x030000 1098#if QT_VERSION >= 0x030000
1095 mWidStack->addWidget(mMonthView ); 1099 mWidStack->addWidget(mMonthView );
1096 mWidStack->addWidget(mWeekView ); 1100 mWidStack->addWidget(mWeekView );
1097#else 1101#else
1098 mWidStack->addWidget( mMonthView, 1 ); 1102 mWidStack->addWidget( mMonthView, 1 );
1099 mWidStack->addWidget( mWeekView , 1 ); 1103 mWidStack->addWidget( mWeekView , 1 );
1100#endif 1104#endif
1101 hb->addWidget( mNavigatorBar ); 1105 hb->addWidget( mNavigatorBar );
1102 hb->addWidget( mWidStack ); 1106 hb->addWidget( mWidStack );
1103 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1107 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1104 updatePossible = false; 1108 updatePossible = false;
1105 //updatePossible = true; 1109 //updatePossible = true;
1106 mCells.setAutoDelete( true ); 1110 mCells.setAutoDelete( true );
1107 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1111 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1108 mDayLabels.resize( mDaysPerWeek ); 1112 mDayLabels.resize( mDaysPerWeek );
1109 mDayLabelsW.resize( mDaysPerWeek ); 1113 mDayLabelsW.resize( mDaysPerWeek );
1110 QFont bfont = font(); 1114 QFont bfont = font();
1111 if ( QApplication::desktop()->width() < 650 ) { 1115 if ( QApplication::desktop()->width() < 650 ) {
1112 bfont.setPointSize( bfont.pointSize() - 2 ); 1116 bfont.setPointSize( bfont.pointSize() - 2 );
1113 } 1117 }
1114 bfont.setBold( true ); 1118 bfont.setBold( true );
1115 int i; 1119 int i;
1116 1120
1117 for( i = 0; i < mDaysPerWeek; i++ ) { 1121 for( i = 0; i < mDaysPerWeek; i++ ) {
1118 QLabel *label = new QLabel( mMonthView ); 1122 QLabel *label = new QLabel( mMonthView );
1119 label->setFont(bfont); 1123 label->setFont(bfont);
1120 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1124 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1121 label->setLineWidth(1); 1125 label->setLineWidth(1);
1122 label->setAlignment(AlignCenter); 1126 label->setAlignment(AlignCenter);
1123 mDayLabels.insert( i, label ); 1127 mDayLabels.insert( i, label );
1124 label = new QLabel( mWeekView ); 1128 label = new QLabel( mWeekView );
1125 label->setFont(bfont); 1129 label->setFont(bfont);
1126 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1130 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1127 label->setLineWidth(1); 1131 label->setLineWidth(1);
1128 label->setAlignment(AlignCenter); 1132 label->setAlignment(AlignCenter);
1129 mDayLabelsW.insert( i, label ); 1133 mDayLabelsW.insert( i, label );
1130 } 1134 }
1131 1135
1132 bfont.setBold( false ); 1136 bfont.setBold( false );
1133 mWeekLabels.resize( mNumWeeks+1 ); 1137 mWeekLabels.resize( mNumWeeks+1 );
1134 mWeekLabelsW.resize( 2 ); 1138 mWeekLabelsW.resize( 2 );
1135 for( i = 0; i < mNumWeeks+1; i++ ) { 1139 for( i = 0; i < mNumWeeks+1; i++ ) {
1136 KOWeekButton *label = new KOWeekButton( mMonthView ); 1140 KOWeekButton *label = new KOWeekButton( mMonthView );
1137 label->setFocusPolicy(NoFocus); 1141 label->setFocusPolicy(NoFocus);
1138 label->setFont(bfont); 1142 label->setFont(bfont);
1139 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1143 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1140 label->setFlat(true); 1144 label->setFlat(true);
1141 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1145 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1142 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1146 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1143 //label->setLineWidth(1); 1147 //label->setLineWidth(1);
1144 //label->setAlignment(AlignCenter); 1148 //label->setAlignment(AlignCenter);
1145 mWeekLabels.insert( i, label ); 1149 mWeekLabels.insert( i, label );
1146 } 1150 }
1147 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1151 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1148 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1152 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1149 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1153 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1150 1154
1151 for( i = 0; i < 1+1; i++ ) { 1155 for( i = 0; i < 1+1; i++ ) {
1152 KOWeekButton *label = new KOWeekButton( mWeekView ); 1156 KOWeekButton *label = new KOWeekButton( mWeekView );
1153 label->setFocusPolicy(NoFocus); 1157 label->setFocusPolicy(NoFocus);
1154 label->setFont(bfont); 1158 label->setFont(bfont);
1155 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1159 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1156 label->setFlat(true); 1160 label->setFlat(true);
1157 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1161 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1158 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1162 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1159 //label->setLineWidth(1); 1163 //label->setLineWidth(1);
1160 //label->setAlignment(AlignCenter); 1164 //label->setAlignment(AlignCenter);
1161 mWeekLabelsW.insert( i, label ); 1165 mWeekLabelsW.insert( i, label );
1162 } 1166 }
1163 mWeekLabelsW[1]->setText( i18n("W")); 1167 mWeekLabelsW[1]->setText( i18n("W"));
1164 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1168 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1165 1169
1166 1170
1167 int row, col; 1171 int row, col;
1168 mCells.resize( mNumCells ); 1172 mCells.resize( mNumCells );
1169 for( row = 0; row < mNumWeeks; ++row ) { 1173 for( row = 0; row < mNumWeeks; ++row ) {
1170 for( col = 0; col < mDaysPerWeek; ++col ) { 1174 for( col = 0; col < mDaysPerWeek; ++col ) {
1171 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1175 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1172 mCells.insert( row * mDaysPerWeek + col, cell ); 1176 mCells.insert( row * mDaysPerWeek + col, cell );
1173 1177
1174 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1178 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1175 SLOT( defaultAction( Incidence * ) ) ); 1179 SLOT( defaultAction( Incidence * ) ) );
1176 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1180 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1177 SIGNAL( newEventSignal( QDateTime ) ) ); 1181 SIGNAL( newEventSignal( QDateTime ) ) );
1178 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1182 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1179 SIGNAL( showDaySignal( QDate ) ) ); 1183 SIGNAL( showDaySignal( QDate ) ) );
1180 connect( cell, SIGNAL( nextCell() ), 1184 connect( cell, SIGNAL( nextCell() ),
1181 SLOT( nextCell() ) ); 1185 SLOT( nextCell() ) );
1182 connect( cell, SIGNAL( prevCell() ), 1186 connect( cell, SIGNAL( prevCell() ),
1183 SLOT( prevCell() ) ); 1187 SLOT( prevCell() ) );
1184 } 1188 }
1185 } 1189 }
1186 mCellsW.resize( mDaysPerWeek ); 1190 mCellsW.resize( mDaysPerWeek );
1187 for( col = 0; col < mDaysPerWeek; ++col ) { 1191 for( col = 0; col < mDaysPerWeek; ++col ) {
1188 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1192 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1189 mCellsW.insert( col, cell ); 1193 mCellsW.insert( col, cell );
1190 1194
1191 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1195 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1192 SLOT( defaultAction( Incidence * ) ) ); 1196 SLOT( defaultAction( Incidence * ) ) );
1193 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1197 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1194 SIGNAL( newEventSignal( QDateTime ) ) ); 1198 SIGNAL( newEventSignal( QDateTime ) ) );
1195 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1199 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1196 SIGNAL( showDaySignal( QDate ) ) ); 1200 SIGNAL( showDaySignal( QDate ) ) );
1197 connect( cell, SIGNAL( nextCell() ), 1201 connect( cell, SIGNAL( nextCell() ),
1198 SLOT( nextCell() ) ); 1202 SLOT( nextCell() ) );
1199 connect( cell, SIGNAL( prevCell() ), 1203 connect( cell, SIGNAL( prevCell() ),
1200 SLOT( prevCell() ) ); 1204 SLOT( prevCell() ) );
1201 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1205 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1202 } 1206 }
1203 1207
1204 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1208 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1205 mContextMenu = eventPopup(); 1209 mContextMenu = eventPopup();
1206 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1210 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1207 i18n("New Event..."),this, 1211 i18n("New Event..."),this,
1208 SLOT(slotNewEvent()),false); 1212 SLOT(slotNewEvent()),false);
1209 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1213 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1210 i18n("New Todo..."),this, 1214 i18n("New Todo..."),this,
1211 SLOT(slotNewTodo()),false); 1215 SLOT(slotNewTodo()),false);
1212 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1216 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1213 i18n("Journal"),this, 1217 i18n("Journal"),this,
1214 SLOT(slotEditJournal()),false); 1218 SLOT(slotEditJournal()),false);
1215 1219
1216 1220
1217 1221
1218 QString pathString = ""; 1222 QString pathString = "";
1219 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1223 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1220 if ( QApplication::desktop()->width() < 480 ) 1224 if ( QApplication::desktop()->width() < 480 )
1221 pathString += "icons16/"; 1225 pathString += "icons16/";
1222 } else 1226 } else
1223 pathString += "iconsmini/"; 1227 pathString += "iconsmini/";
1224 mNewItemMenu = new QPopupMenu( this ); 1228 mNewItemMenu = new QPopupMenu( this );
1225 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1229 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1226 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1230 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1227 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1231 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1228 1232
1229 // updateConfig(); //useless here... 1233 // updateConfig(); //useless here...
1230 // ... but we need mWidthLongDayLabel computed 1234 // ... but we need mWidthLongDayLabel computed
1231 QFontMetrics fontmetric(mDayLabels[0]->font()); 1235 QFontMetrics fontmetric(mDayLabels[0]->font());
1232 mWidthLongDayLabel = 0; 1236 mWidthLongDayLabel = 0;
1233 for (int i = 0; i < 7; i++) { 1237 for (int i = 0; i < 7; i++) {
1234 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1238 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1235 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1239 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1236 } 1240 }
1237 1241
1238 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1242 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1239 1243
1240#if 0 1244#if 0
1241 if ( mShowWeekView ) 1245 if ( mShowWeekView )
1242 mWidStack->raiseWidget( mWeekView ); 1246 mWidStack->raiseWidget( mWeekView );
1243 else 1247 else
1244 mWidStack->raiseWidget( mMonthView ); 1248 mWidStack->raiseWidget( mMonthView );
1245#endif 1249#endif
1246 1250
1247 emit incidenceSelected( 0 ); 1251 emit incidenceSelected( 0 );
1248 1252
1249 mComputeLayoutTimer = new QTimer( this ); 1253 mComputeLayoutTimer = new QTimer( this );
1250 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1254 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1251 1255
1252 1256
1253#ifndef DESKTOP_VERSION 1257#ifndef DESKTOP_VERSION
1254 resize( QApplication::desktop()->size() ); 1258 resize( QApplication::desktop()->size() );
1255#else 1259#else
1256 resize(640, 480 ); 1260 resize(640, 480 );
1257 updatePossible = true; 1261 updatePossible = true;
1258#endif 1262#endif
1259 computeLayout(); 1263 computeLayout();
1260 1264
1261 if ( mShowWeekView ) 1265 if ( mShowWeekView )
1262 mWidStack->raiseWidget( mWeekView ); 1266 mWidStack->raiseWidget( mWeekView );
1263 else 1267 else
1264 mWidStack->raiseWidget( mMonthView ); 1268 mWidStack->raiseWidget( mMonthView );
1265} 1269}
1266 1270
1267KOMonthView::~KOMonthView() 1271KOMonthView::~KOMonthView()
1268{ 1272{
1269 delete mContextMenu; 1273 delete mContextMenu;
1270} 1274}
1271 1275
1272void KOMonthView::selectInternalWeekNum ( int n ) 1276void KOMonthView::selectInternalWeekNum ( int n )
1273{ 1277{
1274 switchView(); 1278 switchView();
1275 if ( !KOPrefs::instance()->mMonthViewWeek ) 1279 if ( !KOPrefs::instance()->mMonthViewWeek )
1276 emit selectMonth (); 1280 emit selectMonth ();
1277 else 1281 else
1278 emit selectWeekNum ( n ); 1282 emit selectWeekNum ( n );
1279} 1283}
1280 1284
1281int KOMonthView::currentWeek() 1285int KOMonthView::currentWeek()
1282{ 1286{
1283 if ( mShowWeekView ) 1287 if ( mShowWeekView )
1284 return mWeekLabelsW[0]->getWeekNum(); 1288 return mWeekLabelsW[0]->getWeekNum();
1285 return mWeekLabels[0]->getWeekNum(); 1289 return mWeekLabels[0]->getWeekNum();
1286} 1290}
1287void KOMonthView::switchView() 1291void KOMonthView::switchView()
1288{ 1292{
1289 if ( selectedCell( ) ) 1293 if ( selectedCell( ) )
1290 selectedCell()->deselect(); 1294 selectedCell()->deselect();
1291 mShowWeekView = !mShowWeekView; 1295 mShowWeekView = !mShowWeekView;
1292 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1296 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1293 if ( clPending ) { 1297 if ( clPending ) {
1294 computeLayout(); 1298 computeLayout();
1295 updateConfig(); 1299 updateConfig();
1296 } 1300 }
1297 if ( mShowWeekView ) 1301 if ( mShowWeekView )
1298 mWidStack->raiseWidget( mWeekView ); 1302 mWidStack->raiseWidget( mWeekView );
1299 else 1303 else
1300 mWidStack->raiseWidget( mMonthView ); 1304 mWidStack->raiseWidget( mMonthView );
1301 clPending = false; 1305 clPending = false;
1302} 1306}
1303 1307
1304int KOMonthView::maxDatesHint() 1308int KOMonthView::maxDatesHint()
1305{ 1309{
1306 return mNumCells; 1310 return mNumCells;
1307} 1311}
1308 1312
1309int KOMonthView::currentDateCount() 1313int KOMonthView::currentDateCount()
1310{ 1314{
1311 return mNumCells; 1315 return mNumCells;
1312} 1316}
1313 1317
1314QPtrList<Incidence> KOMonthView::selectedIncidences() 1318QPtrList<Incidence> KOMonthView::selectedIncidences()
1315{ 1319{
1316 QPtrList<Incidence> selected; 1320 QPtrList<Incidence> selected;
1317 1321
1318 if ( mSelectedCell ) { 1322 if ( mSelectedCell ) {
1319 Incidence *incidence = mSelectedCell->selectedIncidence(); 1323 Incidence *incidence = mSelectedCell->selectedIncidence();
1320 if ( incidence ) selected.append( incidence ); 1324 if ( incidence ) selected.append( incidence );
1321 } 1325 }
1322 1326
1323 return selected; 1327 return selected;
1324} 1328}
1325 1329
1326DateList KOMonthView::selectedDates() 1330DateList KOMonthView::selectedDates()
1327{ 1331{
1328 DateList selected; 1332 DateList selected;
1329 1333
1330 if ( mSelectedCell ) { 1334 if ( mSelectedCell ) {
1331 QDate qd = mSelectedCell->selectedIncidenceDate(); 1335 QDate qd = mSelectedCell->selectedIncidenceDate();
1332 if ( qd.isValid() ) selected.append( qd ); 1336 if ( qd.isValid() ) selected.append( qd );
1333 } 1337 }
1334 1338
1335 return selected; 1339 return selected;
1336} 1340}
1337 1341
1338void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1342void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1339 const QDate &td) 1343 const QDate &td)
1340{ 1344{
1341#ifndef KORG_NOPRINTER 1345#ifndef KORG_NOPRINTER
1342 calPrinter->preview(CalPrinter::Month, fd, td); 1346 calPrinter->preview(CalPrinter::Month, fd, td);
1343#endif 1347#endif
1344} 1348}
1345 1349
1346void KOMonthView::updateConfig() 1350void KOMonthView::updateConfig()
1347{ 1351{
1348 1352
1349 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1353 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1350 1354
1351 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1355 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1352 mWeekStartsMonday = true; 1356 mWeekStartsMonday = true;
1353 } 1357 }
1354 QFontMetrics fontmetric(mDayLabels[0]->font()); 1358 QFontMetrics fontmetric(mDayLabels[0]->font());
1355 mWidthLongDayLabel = 0; 1359 mWidthLongDayLabel = 0;
1356 1360
1357 for (int i = 0; i < 7; i++) { 1361 for (int i = 0; i < 7; i++) {
1358 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1362 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1359 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1363 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1360 } 1364 }
1361 bool temp = mShowSatSunComp ; 1365 bool temp = mShowSatSunComp ;
1362 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1366 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1363 if ( ! mShowWeekView ) { 1367 if ( ! mShowWeekView ) {
1364 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1368 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1365 computeLayout(); 1369 computeLayout();
1366 } 1370 }
1367 updateDayLabels(); 1371 updateDayLabels();
1368 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1372 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1369 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1373 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1370 //resizeEvent( 0 ); 1374 //resizeEvent( 0 );
1371 for (uint i = 0; i < mCells.count(); ++i) { 1375 for (uint i = 0; i < mCells.count(); ++i) {
1372 mCells[i]->updateConfig(); 1376 mCells[i]->updateConfig();
1373 } 1377 }
1374 1378
1375 for (uint i = 0; i < mCellsW.count(); ++i) { 1379 for (uint i = 0; i < mCellsW.count(); ++i) {
1376 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1380 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1377 } 1381 }
1378#ifdef DESKTOP_VERSION 1382#ifdef DESKTOP_VERSION
1379 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1383 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1380#endif 1384#endif
1381 updateView(); 1385 updateView();
1382} 1386}
1383 1387
1384void KOMonthView::updateDayLabels() 1388void KOMonthView::updateDayLabels()
1385{ 1389{
1386 1390
1387 QPtrVector<QLabel> *mDayLabelsT; 1391 QPtrVector<QLabel> *mDayLabelsT;
1388 1392
1389 mDayLabelsT = &mDayLabelsW; 1393 mDayLabelsT = &mDayLabelsW;
1390 for (int i = 0; i < 7; i++) { 1394 for (int i = 0; i < 7; i++) {
1391 { 1395 {
1392 bool show = mShortDayLabelsW; 1396 bool show = mShortDayLabelsW;
1393 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1397 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1394 show = true; 1398 show = true;
1395 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1399 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1396 } 1400 }
1397 } 1401 }
1398 mDayLabelsT = &mDayLabels; 1402 mDayLabelsT = &mDayLabels;
1399 for (int i = 0; i < 7; i++) { 1403 for (int i = 0; i < 7; i++) {
1400 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1404 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1401 bool show = mShortDayLabelsM; 1405 bool show = mShortDayLabelsM;
1402 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1406 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1403 show = true; 1407 show = true;
1404 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1408 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1405 } else { 1409 } else {
1406 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1410 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1407 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1411 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1408 1412
1409 } 1413 }
1410 } 1414 }
1411 1415
1412} 1416}
1413 1417
1414void KOMonthView::showDates(const QDate &start, const QDate &) 1418void KOMonthView::showDates(const QDate &start, const QDate &)
1415{ 1419{
1416 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1420 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1417 1421
1418 QPtrVector<MonthViewCell> *cells; 1422 QPtrVector<MonthViewCell> *cells;
1419 QPtrVector<QLabel> *dayLabels; 1423 QPtrVector<QLabel> *dayLabels;
1420 QPtrVector<KOWeekButton> *weekLabels; 1424 QPtrVector<KOWeekButton> *weekLabels;
1421 int weekNum = 6; 1425 int weekNum = 6;
1422 mStartDate = start; 1426 mStartDate = start;
1423 if ( mShowWeekView ) { 1427 if ( mShowWeekView ) {
1424 weekNum = 1; 1428 weekNum = 1;
1425 cells = &mCellsW; 1429 cells = &mCellsW;
1426 dayLabels = &mDayLabelsW; 1430 dayLabels = &mDayLabelsW;
1427 weekLabels = &mWeekLabelsW; 1431 weekLabels = &mWeekLabelsW;
1428 if ( !KGlobal::locale()->weekStartsMonday() ) { 1432 if ( !KGlobal::locale()->weekStartsMonday() ) {
1429 mStartDate = mStartDate.addDays( 1 ); 1433 mStartDate = mStartDate.addDays( 1 );
1430 } 1434 }
1431 } else { 1435 } else {
1432 cells = &mCells; 1436 cells = &mCells;
1433 dayLabels = &mDayLabels; 1437 dayLabels = &mDayLabels;
1434 weekLabels = &mWeekLabels; 1438 weekLabels = &mWeekLabels;
1435 } 1439 }
1436 1440
1437 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1441 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1438 1442
1439 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1443 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1440 mWeekStartsMonday = true; 1444 mWeekStartsMonday = true;
1441 } 1445 }
1442 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1446 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1443 1447
1444 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1448 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1445 mStartDate = mStartDate.addDays( -1 ); 1449 mStartDate = mStartDate.addDays( -1 );
1446 } 1450 }
1447 bool primary = false; 1451 bool primary = false;
1448 uint i; 1452 uint i;
1449 for( i = 0; i < (*cells).size(); ++i ) { 1453 for( i = 0; i < (*cells).size(); ++i ) {
1450 QDate date = mStartDate.addDays( i ); 1454 QDate date = mStartDate.addDays( i );
1451 (*cells)[i]->setDate( date ); 1455 (*cells)[i]->setDate( date );
1452 1456
1453#ifndef KORG_NOPLUGINS 1457#ifndef KORG_NOPLUGINS
1454 // add holiday, if present 1458 // add holiday, if present
1455 QString hstring(KOCore::self()->holiday(date)); 1459 QString hstring(KOCore::self()->holiday(date));
1456 (*cells)[i]->setHoliday( hstring ); 1460 (*cells)[i]->setHoliday( hstring );
1457#endif 1461#endif
1458 1462
1459 } 1463 }
1460 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1464 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1461 for( i = 0; i < weekNum; ++i ) { 1465 for( i = 0; i < weekNum; ++i ) {
1462 int wno; 1466 int wno;
1463 // remember, according to ISO 8601, the first week of the year is the 1467 // remember, according to ISO 8601, the first week of the year is the
1464 // first week that contains a thursday. Thus we must subtract off 4, 1468 // first week that contains a thursday. Thus we must subtract off 4,
1465 // not just 1. 1469 // not just 1.
1466 int dayOfYear = date.dayOfYear(); 1470 int dayOfYear = date.dayOfYear();
1467 if (dayOfYear % 7 != 0) 1471 if (dayOfYear % 7 != 0)
1468 wno = dayOfYear / 7 + 1; 1472 wno = dayOfYear / 7 + 1;
1469 else 1473 else
1470 wno =dayOfYear / 7; 1474 wno =dayOfYear / 7;
1471 (*weekLabels)[i]->setWeekNum( wno ); 1475 (*weekLabels)[i]->setWeekNum( wno );
1472 date = date.addDays( 7 ); 1476 date = date.addDays( 7 );
1473 } 1477 }
1474 updateView(); 1478 updateView();
1475} 1479}
1476 1480
1477void KOMonthView::showEvents(QPtrList<Event>) 1481void KOMonthView::showEvents(QPtrList<Event>)
1478{ 1482{
1479 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1483 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1480} 1484}
1481 1485
1482void KOMonthView::changeEventDisplay(Event *, int) 1486void KOMonthView::changeEventDisplay(Event *, int)
1483{ 1487{
1484 // this should be re-written to be much more efficient, but this 1488 // this should be re-written to be much more efficient, but this
1485 // quick-and-dirty-hack gets the job done for right now. 1489 // quick-and-dirty-hack gets the job done for right now.
1486 //qDebug("KOMonthView::changeEventDisplay "); 1490 //qDebug("KOMonthView::changeEventDisplay ");
1487 updateView(); 1491 updateView();
1488} 1492}
1489 1493
1490void KOMonthView::updateView() 1494void KOMonthView::updateView()
1491{ 1495{
1492 1496
1493 if ( !updatePossible ) 1497 if ( !updatePossible )
1494 return; 1498 return;
1495 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1499 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1496 //QTime ti; 1500 //QTime ti;
1497 //ti.start(); 1501 //ti.start();
1498 clearSelection(); 1502 clearSelection();
1499 QPtrVector<MonthViewCell> *cells; 1503 QPtrVector<MonthViewCell> *cells;
1500 if ( mShowWeekView ) { 1504 if ( mShowWeekView ) {
1501 cells = &mCellsW; 1505 cells = &mCellsW;
1502 } else { 1506 } else {
1503 cells = &mCells; 1507 cells = &mCells;
1504 } 1508 }
1505#if 1 1509#if 1
1506 int i; 1510 int i;
1507 int timeSpan = (*cells).size()-1; 1511 int timeSpan = (*cells).size()-1;
1508 if ( KOPrefs::instance()->mMonthViewWeek ) 1512 if ( KOPrefs::instance()->mMonthViewWeek )
1509 timeSpan = 6; 1513 timeSpan = 6;
1510 for( i = 0; i < timeSpan + 1; ++i ) { 1514 for( i = 0; i < timeSpan + 1; ++i ) {
1511 (*cells)[i]->startUpdateCell(); 1515 (*cells)[i]->startUpdateCell();
1512 } 1516 }
1513 1517
1514 QPtrList<Event> events = calendar()->events(); 1518 QPtrList<Event> events = calendar()->events();
1515 Event *event; 1519 Event *event;
1516 QDateTime dt; 1520 QDateTime dt;
1517 bool ok; 1521 bool ok;
1518 QDate endDate = mStartDate.addDays( timeSpan ); 1522 QDate endDate = mStartDate.addDays( timeSpan );
1519 for( event = events.first(); event; event = events.next() ) { // for event 1523 for( event = events.first(); event; event = events.next() ) { // for event
1520 if ( event->doesRecur() ) { 1524 if ( event->doesRecur() ) {
1521 bool last; 1525 bool last;
1522 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1526 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1523 QDateTime incidenceEnd; 1527 QDateTime incidenceEnd;
1524 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1528 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1525 bool invalid = false; 1529 bool invalid = false;
1526 while( true ) { 1530 while( true ) {
1527 if ( incidenceStart.isValid() ) { 1531 if ( incidenceStart.isValid() ) {
1528 incidenceEnd = incidenceStart.addDays( eventlen ); 1532 incidenceEnd = incidenceStart.addDays( eventlen );
1529 int st = incidenceStart.date().daysTo( endDate ); 1533 int st = incidenceStart.date().daysTo( endDate );
1530 if ( st >= 0 ) { // start before timeend 1534 if ( st >= 0 ) { // start before timeend
1531 int end = mStartDate.daysTo( incidenceEnd.date() ); 1535 int end = mStartDate.daysTo( incidenceEnd.date() );
1532 if ( end >= 0 ) { // end after timestart --- got one! 1536 if ( end >= 0 ) { // end after timestart --- got one!
1533 //normalize 1537 //normalize
1534 st = timeSpan - st; 1538 st = timeSpan - st;
1535 if ( st < 0 ) st = 0; 1539 if ( st < 0 ) st = 0;
1536 if ( end > timeSpan ) end = timeSpan; 1540 if ( end > timeSpan ) end = timeSpan;
1537 int iii; 1541 int iii;
1538 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1542 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1539 for ( iii = st;iii<= end;++iii) 1543 for ( iii = st;iii<= end;++iii)
1540 (*cells)[iii]->insertEvent( event ); 1544 (*cells)[iii]->insertEvent( event );
1541 } 1545 }
1542 } 1546 }
1543 } else { 1547 } else {
1544 if ( invalid ) 1548 if ( invalid )
1545 break; 1549 break;
1546 invalid = true; 1550 invalid = true;
1547 //qDebug("invalid %s", event->summary().latin1()); 1551 //qDebug("invalid %s", event->summary().latin1());
1548 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1552 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1549 } 1553 }
1550 if ( last ) 1554 if ( last )
1551 break; 1555 break;
1552 bool ok; 1556 bool ok;
1553 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1557 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1554 if ( ! ok ) 1558 if ( ! ok )
1555 break; 1559 break;
1556 if ( incidenceStart.date() > endDate ) 1560 if ( incidenceStart.date() > endDate )
1557 break; 1561 break;
1558 } 1562 }
1559 } else { // no recur 1563 } else { // no recur
1560 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1564 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1561 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1565 if ( event->uid().left(15) == QString("last-syncEvent-") )
1562 continue; 1566 continue;
1563 int st = event->dtStart().date().daysTo( endDate ); 1567 int st = event->dtStart().date().daysTo( endDate );
1564 if ( st >= 0 ) { // start before timeend 1568 if ( st >= 0 ) { // start before timeend
1565 int end = mStartDate.daysTo( event->dtEnd().date() ); 1569 int end = mStartDate.daysTo( event->dtEnd().date() );
1566 if ( end >= 0 ) { // end after timestart --- got one! 1570 if ( end >= 0 ) { // end after timestart --- got one!
1567 //normalize 1571 //normalize
1568 st = timeSpan - st; 1572 st = timeSpan - st;
1569 if ( st < 0 ) st = 0; 1573 if ( st < 0 ) st = 0;
1570 if ( end > timeSpan ) end = timeSpan; 1574 if ( end > timeSpan ) end = timeSpan;
1571 int iii; 1575 int iii;
1572 for ( iii = st;iii<= end;++iii) 1576 for ( iii = st;iii<= end;++iii)
1573 (*cells)[iii]->insertEvent( event ); 1577 (*cells)[iii]->insertEvent( event );
1574 } 1578 }
1575 } 1579 }
1576 } 1580 }
1577 } 1581 }
1578 // insert due todos 1582 // insert due todos
1579 QPtrList<Todo> todos = calendar()->todos( ); 1583 QPtrList<Todo> todos = calendar()->todos( );
1580 Todo *todo; 1584 Todo *todo;
1581 for(todo = todos.first(); todo; todo = todos.next()) { 1585 for(todo = todos.first(); todo; todo = todos.next()) {
1582 //insertTodo( todo ); 1586 //insertTodo( todo );
1583 if ( todo->hasDueDate() ) { 1587 if ( todo->hasDueDate() ) {
1584 int day = mStartDate.daysTo( todo->dtDue().date() ); 1588 int day = mStartDate.daysTo( todo->dtDue().date() );
1585 if ( day >= 0 && day < timeSpan + 1) { 1589 if ( day >= 0 && day < timeSpan + 1) {
1586 (*cells)[day]->insertTodo( todo ); 1590 (*cells)[day]->insertTodo( todo );
1587 } 1591 }
1588 } 1592 }
1589 } 1593 }
1590 1594
1591 for( i = 0; i < timeSpan+1; ++i ) { 1595 for( i = 0; i < timeSpan+1; ++i ) {
1592 (*cells)[i]->finishUpdateCell(); 1596 (*cells)[i]->finishUpdateCell();
1593 } 1597 }
1594 processSelectionChange(); 1598 processSelectionChange();
1595 //qApp->processEvents(); 1599 //qApp->processEvents();
1596 for( i = 0; i < timeSpan+1; ++i ) { 1600 for( i = 0; i < timeSpan+1; ++i ) {
1597 (*cells)[i]->repaintfinishUpdateCell(); 1601 (*cells)[i]->repaintfinishUpdateCell();
1598 } 1602 }
1599 setKeyBFocus(); 1603 setKeyBFocus();
1600#else 1604#else
1601 // old code 1605 // old code
1602 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1606 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1603 int i; 1607 int i;
1604 for( i = 0; i < (*cells).count(); ++i ) { 1608 for( i = 0; i < (*cells).count(); ++i ) {
1605 (*cells)[i]->updateCell(); 1609 (*cells)[i]->updateCell();
1606 } 1610 }
1607 1611
1608 //qDebug("KOMonthView::updateView() "); 1612 //qDebug("KOMonthView::updateView() ");
1609 processSelectionChange(); 1613 processSelectionChange();
1610 // qDebug("---------------------------------------------------------------------+ "); 1614 // qDebug("---------------------------------------------------------------------+ ");
1611 (*cells)[0]->setFocus(); 1615 (*cells)[0]->setFocus();
1612#endif 1616#endif
1613 1617
1614 //qDebug("update time %d ", ti.elapsed()); 1618 //qDebug("update time %d ", ti.elapsed());
1615} 1619}
1616 1620
1617void KOMonthView::setKeyBoardFocus() 1621void KOMonthView::setKeyBoardFocus()
1618{ 1622{
1619 //qDebug("KOMonthView::setKeyBoardFocus() "); 1623 //qDebug("KOMonthView::setKeyBoardFocus() ");
1620 bool shootAgain = false; 1624 bool shootAgain = false;
1621 if ( mShowWeekView ) { 1625 if ( mShowWeekView ) {
1622 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1626 shootAgain = !mWeekLabelsW[1]->hasFocus();
1623 mWeekLabelsW[1]->setFocus(); 1627 mWeekLabelsW[1]->setFocus();
1624 } 1628 }
1625 else { 1629 else {
1626 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1630 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1627 mWeekLabels[mNumWeeks]->setFocus(); 1631 mWeekLabels[mNumWeeks]->setFocus();
1628 } 1632 }
1629 if ( shootAgain ) { 1633 if ( shootAgain ) {
1630 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1634 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1631 } 1635 }
1632} 1636}
1633void KOMonthView::setKeyBFocus() 1637void KOMonthView::setKeyBFocus()
1634{ 1638{
1635 //qDebug("KOMonthView::setKeyBFocus() "); 1639 //qDebug("KOMonthView::setKeyBFocus() ");
1636 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1640 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1637} 1641}
1638void KOMonthView::resizeEvent(QResizeEvent * e) 1642void KOMonthView::resizeEvent(QResizeEvent * e)
1639{ 1643{
1640 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1644 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1641 if ( isVisible() ) { 1645 if ( isVisible() ) {
1642 //qDebug("KOMonthView::isVisible "); 1646 //qDebug("KOMonthView::isVisible ");
1643 slotComputeLayout(); 1647 slotComputeLayout();
1644 } else 1648 } else
1645 mComputeLayoutTimer->start( 100 ); 1649 mComputeLayoutTimer->start( 100 );
1646} 1650}
1647 1651
1648void KOMonthView::slotComputeLayout() 1652void KOMonthView::slotComputeLayout()
1649{ 1653{
1650 mComputeLayoutTimer->stop(); 1654 mComputeLayoutTimer->stop();
1651 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1655 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1652 computeLayout(); 1656 computeLayout();
1653 clPending = true; 1657 clPending = true;
1654 setKeyBFocus(); 1658 setKeyBFocus();
1655} 1659}
1656void KOMonthView::computeLayoutWeek() 1660void KOMonthView::computeLayoutWeek()
1657{ 1661{
1658 static int lastWid = 0; 1662 static int lastWid = 0;
1659 static int lastHei = 0; 1663 static int lastHei = 0;
1660 int daysToShow; 1664 int daysToShow;
1661 bool combinedSatSun = false; 1665 bool combinedSatSun = false;
1662 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1666 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1663 daysToShow = 6; 1667 daysToShow = 6;
1664 combinedSatSun = true; 1668 combinedSatSun = true;
1665 } 1669 }
1666 int tWid = topLevelWidget()->size().width(); 1670 int tWid = topLevelWidget()->size().width();
1667 int tHei = topLevelWidget()->size().height(); 1671 int tHei = topLevelWidget()->size().height();
1668 1672
1669 int wid = width();//e 1673 int wid = width();//e
1670 int hei = height()-1-mNavigatorBar->height(); 1674 int hei = height()-1-mNavigatorBar->height();
1671 1675
1672 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1676 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1673 return; 1677 return;
1674 1678
1675 if ( lastWid == width() && lastHei == height() ) { 1679 if ( lastWid == width() && lastHei == height() ) {
1676 //qDebug("KOListWeekView::No compute layout needed "); 1680 //qDebug("KOListWeekView::No compute layout needed ");
1677 return; 1681 return;
1678 } 1682 }
1679 lastWid = width(); 1683 lastWid = width();
1680 lastHei = height(); 1684 lastHei = height();
1681 1685
1682 1686
1683 if ( wid < hei ) 1687 if ( wid < hei )
1684 daysToShow = 2; 1688 daysToShow = 2;
1685 else 1689 else
1686 daysToShow = 3; 1690 daysToShow = 3;
1687 mShowSatSunComp = true; 1691 mShowSatSunComp = true;
1688 combinedSatSun = true; 1692 combinedSatSun = true;
1689 1693
1690 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1694 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1691 QFontMetrics fm ( mWeekLabels[0]->font() ); 1695 QFontMetrics fm ( mWeekLabels[0]->font() );
1692 int weeklabelwid = fm.width( "888" ); 1696 int weeklabelwid = fm.width( "888" );
1693 wid -= weeklabelwid; 1697 wid -= weeklabelwid;
1694 1698
1695 int colWid = wid / daysToShow; 1699 int colWid = wid / daysToShow;
1696 int lastCol = wid - ( colWid*6 ); 1700 int lastCol = wid - ( colWid*6 );
1697 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1701 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1698 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1702 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1699 int colModulo = wid % daysToShow; 1703 int colModulo = wid % daysToShow;
1700 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1704 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1701 //qDebug("rowmod %d ", rowModulo); 1705 //qDebug("rowmod %d ", rowModulo);
1702 int i; 1706 int i;
1703 int x,y,w,h; 1707 int x,y,w,h;
1704 x= 0; 1708 x= 0;
1705 y= 0; 1709 y= 0;
1706 w = colWid; 1710 w = colWid;
1707 h = dayLabelHei ; 1711 h = dayLabelHei ;
1708 for ( i = 0; i < 7; i++) { 1712 for ( i = 0; i < 7; i++) {
1709 if ( i && !( i % daysToShow) && i < 6) { 1713 if ( i && !( i % daysToShow) && i < 6) {
1710 y += hei/(5-daysToShow); 1714 y += hei/(5-daysToShow);
1711 x = 0; 1715 x = 0;
1712 w = colWid; 1716 w = colWid;
1713 } 1717 }
1714 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1718 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1715 ++w; 1719 ++w;
1716 } 1720 }
1717 if ( i >= 5 ) { 1721 if ( i >= 5 ) {
1718 int wi = width() - x - weeklabelwid; 1722 int wi = width() - x - weeklabelwid;
1719 if ( i == 5 ) { 1723 if ( i == 5 ) {
1720 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1724 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1721 } else { 1725 } else {
1722 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1726 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1723 } 1727 }
1724 x = x - w + wi - (wi/2 ); 1728 x = x - w + wi - (wi/2 );
1725 } 1729 }
1726 else { 1730 else {
1727 int wi = w; 1731 int wi = w;
1728 if ( !(( i+1) % daysToShow)) { 1732 if ( !(( i+1) % daysToShow)) {
1729 wi = width() - x - weeklabelwid; 1733 wi = width() - x - weeklabelwid;
1730 } 1734 }
1731 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1735 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1732 } 1736 }
1733 x += w; 1737 x += w;
1734 } 1738 }
1735 x= 0; 1739 x= 0;
1736 y= dayLabelHei; 1740 y= dayLabelHei;
1737 w = colWid; 1741 w = colWid;
1738 h = cellHei; 1742 h = cellHei;
1739 int max = 0; 1743 int max = 0;
1740 for ( i = 0; i < mCellsW.count(); ++i) { 1744 for ( i = 0; i < mCellsW.count(); ++i) {
1741 if ( i > 6 ) { 1745 if ( i > 6 ) {
1742 mCellsW[i]->hide(); 1746 mCellsW[i]->hide();
1743 continue; 1747 continue;
1744 } 1748 }
1745 1749
1746 w = colWid; 1750 w = colWid;
1747 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1751 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1748 ++w; 1752 ++w;
1749 } 1753 }
1750 if ( i == (daysToShow-1-rowModulo)*7) 1754 if ( i == (daysToShow-1-rowModulo)*7)
1751 ++h; 1755 ++h;
1752 1756
1753 if ( i >= 5 ) { 1757 if ( i >= 5 ) {
1754 if ( i ==5 ) { 1758 if ( i ==5 ) {
1755 max = h/2; 1759 max = h/2;
1756 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1760 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1757 x -= w ;y += h/2; 1761 x -= w ;y += h/2;
1758 } else { 1762 } else {
1759 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1763 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1760 ++w; 1764 ++w;
1761 } 1765 }
1762 max = h-h/2; 1766 max = h-h/2;
1763 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1767 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1764 y -= h/2; 1768 y -= h/2;
1765 } 1769 }
1766 } else { 1770 } else {
1767 max = h; 1771 max = h;
1768 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1772 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1769 } 1773 }
1770 1774
1771 1775
1772 x += w; 1776 x += w;
1773 if ( x + w/2 > wid ) { 1777 if ( x + w/2 > wid ) {
1774 x = 0; 1778 x = 0;
1775 y += h+dayLabelHei ; 1779 y += h+dayLabelHei ;
1776 } 1780 }
1777 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1781 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1778 } 1782 }
1779 y= dayLabelHei; 1783 y= dayLabelHei;
1780 h = cellHei ; 1784 h = cellHei ;
1781 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1785 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1782 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1786 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1783 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1787 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1784 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1788 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1785 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1789 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1786 updateDayLabels(); 1790 updateDayLabels();
1787 //bool forceUpdate = !updatePossible; 1791 //bool forceUpdate = !updatePossible;
1788 updatePossible = true; 1792 updatePossible = true;
1789 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1793 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1790 //if ( forceUpdate ) 1794 //if ( forceUpdate )
1791 // updateView(); 1795 // updateView();
1792} 1796}
1793void KOMonthView::computeLayout() 1797void KOMonthView::computeLayout()
1794{ 1798{
1795 1799
1796 1800
1797 static int lastWid = 0; 1801 static int lastWid = 0;
1798 static int lastHei = 0; 1802 static int lastHei = 0;
1799 1803
1800 if ( mShowWeekView ){ 1804 if ( mShowWeekView ){
1801 computeLayoutWeek(); 1805 computeLayoutWeek();
1802 return; 1806 return;
1803 } 1807 }
1804 int daysToShow = 7; 1808 int daysToShow = 7;
1805 bool combinedSatSun = false; 1809 bool combinedSatSun = false;
1806 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1810 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1807 daysToShow = 6; 1811 daysToShow = 6;
1808 combinedSatSun = true; 1812 combinedSatSun = true;
1809 } 1813 }
1810 int tWid = topLevelWidget()->size().width(); 1814 int tWid = topLevelWidget()->size().width();
1811 int tHei = topLevelWidget()->size().height(); 1815 int tHei = topLevelWidget()->size().height();
1812 1816
1813 int wid = width();//e 1817 int wid = width();//e
1814 int hei = height()-1-mNavigatorBar->height(); 1818 int hei = height()-1-mNavigatorBar->height();
1815 1819
1816 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1820 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1817 return; 1821 return;
1818 } 1822 }
1819 if ( lastWid == width() && lastHei == height() ){ 1823 if ( lastWid == width() && lastHei == height() ){
1820 //qDebug("KOMonthview::No compute layout needed "); 1824 //qDebug("KOMonthview::No compute layout needed ");
1821 return; 1825 return;
1822 } 1826 }
1823 1827
1824 lastWid = width(); 1828 lastWid = width();
1825 lastHei = height(); 1829 lastHei = height();
1826 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1830 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1827 QFontMetrics fm ( mWeekLabels[0]->font() ); 1831 QFontMetrics fm ( mWeekLabels[0]->font() );
1828 int weeklabelwid = fm.width( "888" ); 1832 int weeklabelwid = fm.width( "888" );
1829 wid -= weeklabelwid; 1833 wid -= weeklabelwid;
1830 1834
1831 int colWid = wid / daysToShow; 1835 int colWid = wid / daysToShow;
1832 int lastCol = wid - ( colWid*6 ); 1836 int lastCol = wid - ( colWid*6 );
1833 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1837 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1834 int cellHei = (hei - dayLabelHei) /6; 1838 int cellHei = (hei - dayLabelHei) /6;
1835 int colModulo = wid % daysToShow; 1839 int colModulo = wid % daysToShow;
1836 int rowModulo = (hei- dayLabelHei) % 6; 1840 int rowModulo = (hei- dayLabelHei) % 6;
1837 //qDebug("rowmod %d ", rowModulo); 1841 //qDebug("rowmod %d ", rowModulo);
1838 int i; 1842 int i;
1839 int x,y,w,h; 1843 int x,y,w,h;
1840 x= 0; 1844 x= 0;
1841 y= 0; 1845 y= 0;
1842 w = colWid; 1846 w = colWid;
1843 h = dayLabelHei ; 1847 h = dayLabelHei ;
1844 for ( i = 0; i < 7; i++) { 1848 for ( i = 0; i < 7; i++) {
1845 if ( i == daysToShow-colModulo ) 1849 if ( i == daysToShow-colModulo )
1846 ++w; 1850 ++w;
1847 if ( combinedSatSun ) { 1851 if ( combinedSatSun ) {
1848 if ( i >= daysToShow-1 ) { 1852 if ( i >= daysToShow-1 ) {
1849 1853
1850 if ( i == 6 ) 1854 if ( i == 6 )
1851 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 1855 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
1852 else 1856 else
1853 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1857 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1854 x -= w/2 ; 1858 x -= w/2 ;
1855 } 1859 }
1856 else 1860 else
1857 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1861 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1858 } else 1862 } else
1859 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1863 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1860 x += w; 1864 x += w;
1861 } 1865 }
1862 x= 0; 1866 x= 0;
1863 y= dayLabelHei; 1867 y= dayLabelHei;
1864 w = colWid; 1868 w = colWid;
1865 h = cellHei ; 1869 h = cellHei ;
1866 int max = 0; 1870 int max = 0;
1867 for ( i = 0; i < mCells.count(); ++i) { 1871 for ( i = 0; i < mCells.count(); ++i) {
1868 //qDebug("iii %d ", i); 1872 //qDebug("iii %d ", i);
1869 w = colWid; 1873 w = colWid;
1870 if ( ((i) % 7) >= 7-colModulo ) { 1874 if ( ((i) % 7) >= 7-colModulo ) {
1871 ++w; 1875 ++w;
1872 } 1876 }
1873 if ( i == (6-rowModulo)*7) 1877 if ( i == (6-rowModulo)*7)
1874 ++h; 1878 ++h;
1875 if ( combinedSatSun ) { 1879 if ( combinedSatSun ) {
1876 if ( (i)%7 >= daysToShow-1 ) { 1880 if ( (i)%7 >= daysToShow-1 ) {
1877 if ( (i)%7 == daysToShow-1 ) { 1881 if ( (i)%7 == daysToShow-1 ) {
1878 w = width()-x-weeklabelwid; 1882 w = width()-x-weeklabelwid;
1879 max = h/2; 1883 max = h/2;
1880 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1884 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1881 x -= w ;y += h/2; 1885 x -= w ;y += h/2;
1882 } else { 1886 } else {
1883 w = width()-x-weeklabelwid; 1887 w = width()-x-weeklabelwid;
1884 max = h-h/2; 1888 max = h-h/2;
1885 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1889 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1886 y -= h/2; 1890 y -= h/2;
1887 } 1891 }
1888 } else { 1892 } else {
1889 max = h; 1893 max = h;
1890 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1894 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1891 } 1895 }
1892 1896
1893 } 1897 }
1894 else { 1898 else {
1895 max = h; 1899 max = h;
1896 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1900 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1897 } 1901 }
1898 x += w; 1902 x += w;
1899 if ( x + w/2 > wid ) { 1903 if ( x + w/2 > wid ) {
1900 x = 0; 1904 x = 0;
1901 y += h; 1905 y += h;
1902 } 1906 }
1903 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1907 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1904 } 1908 }
1905 y= dayLabelHei; 1909 y= dayLabelHei;
1906 h = cellHei ; 1910 h = cellHei ;
1907 for ( i = 0; i < 6; i++) { 1911 for ( i = 0; i < 6; i++) {
1908 if ( i == (6-rowModulo)) 1912 if ( i == (6-rowModulo))
1909 ++h; 1913 ++h;
1910 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1914 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1911 y += h; 1915 y += h;
1912 } 1916 }
1913 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1917 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1914 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1918 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1915 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1919 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1916 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1920 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1917 updateDayLabels(); 1921 updateDayLabels();
1918 //bool forceUpdate = !updatePossible; 1922 //bool forceUpdate = !updatePossible;
1919 updatePossible = true; 1923 updatePossible = true;
1920 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1924 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1921} 1925}
1922 1926
1923void KOMonthView::showContextMenu( Incidence *incidence ) 1927void KOMonthView::showContextMenu( Incidence *incidence )
1924{ 1928{
1925 if( incidence ) 1929 if( incidence )
1926 mContextMenu->showIncidencePopup(incidence); 1930 mContextMenu->showIncidencePopup(incidence);
1927 else { 1931 else {
1928 //qDebug("KOMonthView::showContextMenu "); 1932 //qDebug("KOMonthView::showContextMenu ");
1929 mNewItemMenu->popup(QCursor::pos()); 1933 mNewItemMenu->popup(QCursor::pos());
1930 } 1934 }
1931 /* 1935 /*
1932 if( incidence && incidence->type() == "Event" ) { 1936 if( incidence && incidence->type() == "Event" ) {
1933 Event *event = static_cast<Event *>(incidence); 1937 Event *event = static_cast<Event *>(incidence);
1934 mContextMenu->showEventPopup(event); 1938 mContextMenu->showEventPopup(event);
1935 } else { 1939 } else {
1936 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1940 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1937 } 1941 }
1938 */ 1942 */
1939} 1943}
1940MonthViewCell * KOMonthView::selectedCell( ) 1944MonthViewCell * KOMonthView::selectedCell( )
1941{ 1945{
1942 return mSelectedCell; 1946 return mSelectedCell;
1943} 1947}
1944void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1948void KOMonthView::setSelectedCell( MonthViewCell *cell )
1945{ 1949{
1946 //qDebug("KOMonthView::setSelectedCell %d", cell); 1950 //qDebug("KOMonthView::setSelectedCell %d", cell);
1947 if ( mSelectedCell && mSelectedCell != cell ) { 1951 if ( mSelectedCell && mSelectedCell != cell ) {
1948 MonthViewCell * mvc = mSelectedCell; 1952 MonthViewCell * mvc = mSelectedCell;
1949 mSelectedCell = cell; 1953 mSelectedCell = cell;
1950 mvc->deselect(); 1954 mvc->deselect();
1951 } else 1955 } else
1952 mSelectedCell = cell; 1956 mSelectedCell = cell;
1953 // if ( mSelectedCell ) 1957 // if ( mSelectedCell )
1954 // mSelectedCell->select(); 1958 // mSelectedCell->select();
1955 if ( !mSelectedCell ) 1959 if ( !mSelectedCell )
1956 emit incidenceSelected( 0 ); 1960 emit incidenceSelected( 0 );
1957 else 1961 else
1958 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1962 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1959} 1963}
1960 1964
1961void KOMonthView::processSelectionChange() 1965void KOMonthView::processSelectionChange()
1962{ 1966{
1963 QPtrList<Incidence> incidences = selectedIncidences(); 1967 QPtrList<Incidence> incidences = selectedIncidences();
1964 if (incidences.count() > 0) { 1968 if (incidences.count() > 0) {
1965 emit incidenceSelected( incidences.first() ); 1969 emit incidenceSelected( incidences.first() );
1966 } else { 1970 } else {
1967 emit incidenceSelected( 0 ); 1971 emit incidenceSelected( 0 );
1968 clearSelection(); 1972 clearSelection();
1969 } 1973 }
1970} 1974}
1971 1975
1972void KOMonthView::clearSelection() 1976void KOMonthView::clearSelection()
1973{ 1977{
1974 if ( mSelectedCell ) { 1978 if ( mSelectedCell ) {
1975 mSelectedCell->deselect(); 1979 mSelectedCell->deselect();
1976 mSelectedCell = 0; 1980 mSelectedCell = 0;
1977 } 1981 }
1978} 1982}
1979 1983
1980void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 1984void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1981{ 1985{
1982 if ( !e->isAutoRepeat() ) { 1986 if ( !e->isAutoRepeat() ) {
1983 mFlagKeyPressed = false; 1987 mFlagKeyPressed = false;
1984 } 1988 }
1985} 1989}
1986 1990
1987void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1991void KOMonthView::keyPressEvent ( QKeyEvent * e )
1988{ 1992{
1989 1993
1990 qApp->processEvents(); 1994 qApp->processEvents();
1991 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1995 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1992 //e->ignore(); 1996 //e->ignore();
1993 e->accept(); 1997 e->accept();
1994 return; 1998 return;
1995 } 1999 }
1996 if (! e->isAutoRepeat() ) 2000 if (! e->isAutoRepeat() )
1997 mFlagKeyPressed = true; 2001 mFlagKeyPressed = true;
1998 switch(e->key()) { 2002 switch(e->key()) {
1999 case Key_Up: 2003 case Key_Up:
2000 { 2004 {
2001 if ( mShowWeekView ) { 2005 if ( mShowWeekView ) {
2002 emit selectWeekNum ( currentWeek() - 1 ); 2006 emit selectWeekNum ( currentWeek() - 1 );
2003 } 2007 }
2004 else { 2008 else {
2005 emit prevMonth(); 2009 emit prevMonth();
2006 } 2010 }
2007 } 2011 }
2008 e->accept(); 2012 e->accept();
2009 break; 2013 break;
2010 case Key_Down: 2014 case Key_Down:
2011 { 2015 {
2012 if ( mShowWeekView ) { 2016 if ( mShowWeekView ) {
2013 emit selectWeekNum ( currentWeek() +1); 2017 emit selectWeekNum ( currentWeek() +1);
2014 } 2018 }
2015 else { 2019 else {
2016 emit nextMonth(); 2020 emit nextMonth();
2017 } 2021 }
2018 2022
2019 } 2023 }
2020 e->accept(); 2024 e->accept();
2021 break; 2025 break;
2022 case Key_Return: 2026 case Key_Return:
2023 case Key_Enter: 2027 case Key_Enter:
2024 { 2028 {
2025 selectInternalWeekNum ( currentWeek() ); 2029 selectInternalWeekNum ( currentWeek() );
2026 } 2030 }
2027 e->accept(); 2031 e->accept();
2028 break; 2032 break;
2029 case Key_D: 2033 case Key_D:
2030 if ( mSelectedCell ) { 2034 if ( mSelectedCell ) {
2031 mSelectedCell->showDay(); 2035 mSelectedCell->showDay();
2032 e->accept(); 2036 e->accept();
2033 } else { 2037 } else {
2034 e->ignore(); 2038 e->ignore();
2035 } 2039 }
2036 break; 2040 break;
2037 default: 2041 default:
2038 e->ignore(); 2042 e->ignore();
2039 break; 2043 break;
2040 } 2044 }
2041} 2045}
2042 2046
2043void KOMonthView::nextCell() 2047void KOMonthView::nextCell()
2044{ 2048{
2045 bool res = focusNextPrevChild ( true ); 2049 bool res = focusNextPrevChild ( true );
2046} 2050}
2047void KOMonthView::prevCell() 2051void KOMonthView::prevCell()
2048{ 2052{
2049 focusNextPrevChild ( false ); 2053 focusNextPrevChild ( false );
2050} 2054}
2051 2055
2052void KOMonthView::slotNewTodo() 2056void KOMonthView::slotNewTodo()
2053{ 2057{
2054 //qDebug("KOMonthView::slotNewTodo() "); 2058 //qDebug("KOMonthView::slotNewTodo() ");
2055 if ( mPopupCell ){ 2059 if ( mPopupCell ){
2056 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2060 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2057 emit newTodoSignal(dt,true); 2061 emit newTodoSignal(dt,true);
2058 } 2062 }
2059 mPopupCell = 0; 2063 mPopupCell = 0;
2060} 2064}
2061void KOMonthView::slotNewEvent() 2065void KOMonthView::slotNewEvent()
2062{ 2066{
2063 if ( mPopupCell ) { 2067 if ( mPopupCell ) {
2064 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2068 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2065 emit newEventSignal( dt ); 2069 emit newEventSignal( dt );
2066 } 2070 }
2067 //qDebug("KOMonthView::slotNewEvent() "); 2071 //qDebug("KOMonthView::slotNewEvent() ");
2068 mPopupCell = 0; 2072 mPopupCell = 0;
2069} 2073}
2070 2074
2071void KOMonthView::slotEditJournal() 2075void KOMonthView::slotEditJournal()
2072{ 2076{
2073 if ( mPopupCell ) 2077 if ( mPopupCell )
2074 emit showJournalSignal( 7, mPopupCell->date() ); 2078 emit showJournalSignal( 7, mPopupCell->date() );
2075 //qDebug("KOMonthView::slotEditJournal() "); 2079 //qDebug("KOMonthView::slotEditJournal() ");
2076 mPopupCell = 0; 2080 mPopupCell = 0;
2077} 2081}
2078 2082
2079void KOMonthView::setPopupCell( MonthViewCell * c) 2083void KOMonthView::setPopupCell( MonthViewCell * c)
2080{ 2084{
2081 mPopupCell = c; 2085 mPopupCell = c;
2082} 2086}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index f26d16d..e95039d 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1445 +1,1451 @@
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 <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28 28
29#include <qvbox.h> 29#include <qvbox.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include "koprefs.h" 31#include "koprefs.h"
32#include <klocale.h> 32#include <klocale.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkcal/icaldrag.h> 37#include <libkcal/icaldrag.h>
38#include <libkcal/vcaldrag.h> 38#include <libkcal/vcaldrag.h>
39#include <libkcal/calfilter.h> 39#include <libkcal/calfilter.h>
40#include <libkcal/dndfactory.h> 40#include <libkcal/dndfactory.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <kresources/resourceselectdialog.h> 43#include <kresources/resourceselectdialog.h>
44#include <libkcal/kincidenceformatter.h> 44#include <libkcal/kincidenceformatter.h>
45#ifndef DESKTOP_VERSION 45#ifndef DESKTOP_VERSION
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#else 47#else
48#include <qapplication.h> 48#include <qapplication.h>
49#endif 49#endif
50#ifndef KORG_NOPRINTER 50#ifndef KORG_NOPRINTER
51#include "calprinter.h" 51#include "calprinter.h"
52#endif 52#endif
53#include "docprefs.h" 53#include "docprefs.h"
54 54
55#include "kotodoview.h" 55#include "kotodoview.h"
56using namespace KOrg; 56using namespace KOrg;
57 57
58 58
59class KOTodoViewWhatsThis :public QWhatsThis 59class KOTodoViewWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& p) 65 virtual QString text( const QPoint& p)
66 { 66 {
67 return _view->getWhatsThisText(p) ; 67 return _view->getWhatsThisText(p) ;
68 } 68 }
69private: 69private:
70 QWidget* _wid; 70 QWidget* _wid;
71 KOTodoView * _view; 71 KOTodoView * _view;
72}; 72};
73 73
74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
75 const char *name) : 75 const char *name) :
76 KListView(parent,name) 76 KListView(parent,name)
77{ 77{
78 mName = QString ( name ); 78 mName = QString ( name );
79 mCalendar = calendar; 79 mCalendar = calendar;
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
82#endif 82#endif
83 mOldCurrent = 0; 83 mOldCurrent = 0;
84 mMousePressed = false; 84 mMousePressed = false;
85 85
86 setAcceptDrops(true); 86 setAcceptDrops(true);
87 viewport()->setAcceptDrops(true); 87 viewport()->setAcceptDrops(true);
88 int size = 16; 88 int size = 16;
89 if (qApp->desktop()->width() < 300 ) 89 if (qApp->desktop()->width() < 300 )
90 size = 12; 90 size = 12;
91 setTreeStepSize( size + 6 ); 91 setTreeStepSize( size + 6 );
92 92
93} 93}
94 94
95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
96{ 96{
97#ifndef KORG_NODND 97#ifndef KORG_NODND
98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
100 !QTextDrag::canDecode( e ) ) { 100 !QTextDrag::canDecode( e ) ) {
101 e->ignore(); 101 e->ignore();
102 return; 102 return;
103 } 103 }
104 104
105 mOldCurrent = currentItem(); 105 mOldCurrent = currentItem();
106#endif 106#endif
107} 107}
108 108
109 109
110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
111{ 111{
112#ifndef KORG_NODND 112#ifndef KORG_NODND
113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
114 114
115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
116 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 120
121 e->accept(); 121 e->accept();
122#endif 122#endif
123} 123}
124 124
125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
126{ 126{
127#ifndef KORG_NODND 127#ifndef KORG_NODND
128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
129 129
130 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
131 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
132#endif 132#endif
133} 133}
134 134
135void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
136{ 136{
137#ifndef KORG_NODND 137#ifndef KORG_NODND
138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
139 139
140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
141 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
142 e->ignore(); 142 e->ignore();
143 return; 143 return;
144 } 144 }
145 145
146 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
147 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
148 148
149 if (todo) { 149 if (todo) {
150 e->acceptAction(); 150 e->acceptAction();
151 151
152 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
154 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
155 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
156 156
157 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
158 158
159 if(existingTodo) { 159 if(existingTodo) {
160 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
161 while(to) { 161 while(to) {
162 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
163 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
164 i18n("Cannot move Todo to itself\nor a child of itself"), 164 i18n("Cannot move Todo to itself\nor a child of itself"),
165 i18n("Drop Todo")); 165 i18n("Drop Todo"));
166 delete todo; 166 delete todo;
167 return; 167 return;
168 } 168 }
169 to = to->relatedTo(); 169 to = to->relatedTo();
170 } 170 }
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207void KOTodoListView::wheelEvent (QWheelEvent *e) 207void KOTodoListView::wheelEvent (QWheelEvent *e)
208{ 208{
209 QListView::wheelEvent (e); 209 QListView::wheelEvent (e);
210} 210}
211 211
212void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 212void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
213{ 213{
214 214
215 QPoint p(contentsToViewport(e->pos())); 215 QPoint p(contentsToViewport(e->pos()));
216 QListViewItem *i = itemAt(p); 216 QListViewItem *i = itemAt(p);
217 bool rootClicked = true; 217 bool rootClicked = true;
218 if (i) { 218 if (i) {
219 // if the user clicked into the root decoration of the item, don't 219 // if the user clicked into the root decoration of the item, don't
220 // try to start a drag! 220 // try to start a drag!
221 int X = p.x(); 221 int X = p.x();
222 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 222 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
223 if (X > header()->sectionPos(0) + 223 if (X > header()->sectionPos(0) +
224 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 224 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
225 itemMargin() +i->height()|| 225 itemMargin() +i->height()||
226 X < header()->sectionPos(0)) { 226 X < header()->sectionPos(0)) {
227 rootClicked = false; 227 rootClicked = false;
228 } 228 }
229 } else { 229 } else {
230 rootClicked = false; 230 rootClicked = false;
231 } 231 }
232#ifndef KORG_NODND 232#ifndef KORG_NODND
233 mMousePressed = false; 233 mMousePressed = false;
234 if (! rootClicked && !( e->button() == RightButton) ) { 234 if (! rootClicked && !( e->button() == RightButton) ) {
235 mPressPos = e->pos(); 235 mPressPos = e->pos();
236 mMousePressed = true; 236 mMousePressed = true;
237 } else { 237 } else {
238 mMousePressed = false; 238 mMousePressed = false;
239 } 239 }
240#endif 240#endif
241 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 241 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
242#ifndef DESKTOP_VERSION 242#ifndef DESKTOP_VERSION
243 if (!( e->button() == RightButton && rootClicked) ) 243 if (!( e->button() == RightButton && rootClicked) )
244 QListView::contentsMousePressEvent(e); 244 QListView::contentsMousePressEvent(e);
245#else 245#else
246 QListView::contentsMousePressEvent(e); 246 QListView::contentsMousePressEvent(e);
247#endif 247#endif
248} 248}
249void KOTodoListView::paintEvent(QPaintEvent* e) 249void KOTodoListView::paintEvent(QPaintEvent* e)
250{ 250{
251 emit paintNeeded(); 251 emit paintNeeded();
252 QListView::paintEvent( e); 252 QListView::paintEvent( e);
253} 253}
254void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 254void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
255{ 255{
256 256
257#ifndef KORG_NODND 257#ifndef KORG_NODND
258 //QListView::contentsMouseMoveEvent(e); 258 //QListView::contentsMouseMoveEvent(e);
259 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 259 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
260 QApplication::startDragDistance()*3) { 260 QApplication::startDragDistance()*3) {
261 mMousePressed = false; 261 mMousePressed = false;
262 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 262 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
263 if (item) { 263 if (item) {
264 DndFactory factory( mCalendar ); 264 DndFactory factory( mCalendar );
265 ICalDrag *vd = factory.createDrag( 265 ICalDrag *vd = factory.createDrag(
266 ((KOTodoViewItem *)item)->todo(),viewport()); 266 ((KOTodoViewItem *)item)->todo(),viewport());
267 internalDrop = false; 267 internalDrop = false;
268 // we cannot do any senseful here, because the DnD is still broken in Qt 268 // we cannot do any senseful here, because the DnD is still broken in Qt
269 if (vd->drag()) { 269 if (vd->drag()) {
270 if ( !internalDrop ) { 270 if ( !internalDrop ) {
271 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 271 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
272 qDebug("Dnd: External move: Delete drag source "); 272 qDebug("Dnd: External move: Delete drag source ");
273 } else 273 } else
274 qDebug("Dnd: Internal move "); 274 qDebug("Dnd: Internal move ");
275 275
276 } else { 276 } else {
277 if ( !internalDrop ) { 277 if ( !internalDrop ) {
278 qDebug("Dnd: External Copy"); 278 qDebug("Dnd: External Copy");
279 } else 279 } else
280 qDebug("DnD: Internal copy: Copy pending"); 280 qDebug("DnD: Internal copy: Copy pending");
281 } 281 }
282 } 282 }
283 } 283 }
284#endif 284#endif
285} 285}
286void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 286void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
287{ 287{
288 if ( !e->isAutoRepeat() ) { 288 if ( !e->isAutoRepeat() ) {
289 mFlagKeyPressed = false; 289 mFlagKeyPressed = false;
290 } 290 }
291} 291}
292 292
293 293
294void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 294void KOTodoListView::keyPressEvent ( QKeyEvent * e )
295{ 295{
296 qApp->processEvents(); 296 qApp->processEvents();
297 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 297 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
298 e->ignore(); 298 e->ignore();
299 // qDebug(" ignore %d",e->isAutoRepeat() ); 299 // qDebug(" ignore %d",e->isAutoRepeat() );
300 return; 300 return;
301 } 301 }
302 if (! e->isAutoRepeat() ) 302 if (! e->isAutoRepeat() )
303 mFlagKeyPressed = true; 303 mFlagKeyPressed = true;
304 QListViewItem* cn; 304 QListViewItem* cn;
305 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 305 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
306 cn = currentItem(); 306 cn = currentItem();
307 if ( cn ) { 307 if ( cn ) {
308 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 308 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
309 if ( ci ){ 309 if ( ci ){
310 if ( e->state() == ShiftButton ) 310 if ( e->state() == ShiftButton )
311 ci->setOn( false ); 311 ci->setOn( false );
312 else 312 else
313 ci->setOn( true ); 313 ci->setOn( true );
314 cn = cn->itemBelow(); 314 cn = cn->itemBelow();
315 if ( cn ) { 315 if ( cn ) {
316 setCurrentItem ( cn ); 316 setCurrentItem ( cn );
317 ensureItemVisible ( cn ); 317 ensureItemVisible ( cn );
318 } 318 }
319 319
320 } 320 }
321 } 321 }
322 322
323 return; 323 return;
324 } 324 }
325 325
326 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 326 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
327 switch ( e->key() ) { 327 switch ( e->key() ) {
328 case Qt::Key_Down: 328 case Qt::Key_Down:
329 case Qt::Key_Up: 329 case Qt::Key_Up:
330 QListView::keyPressEvent ( e ); 330 QListView::keyPressEvent ( e );
331 break; 331 break;
332 case Qt::Key_Left: 332 case Qt::Key_Left:
333 case Qt::Key_Right: 333 case Qt::Key_Right:
334 QListView::keyPressEvent ( e ); 334 QListView::keyPressEvent ( e );
335 e->accept(); 335 e->accept();
336 return; 336 return;
337 break; 337 break;
338 default: 338 default:
339 e->ignore(); 339 e->ignore();
340 break; 340 break;
341 } 341 }
342 return; 342 return;
343 } 343 }
344 e->ignore(); 344 e->ignore();
345} 345}
346void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 346void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
347{ 347{
348 QListView::contentsMouseReleaseEvent(e); 348 QListView::contentsMouseReleaseEvent(e);
349 mMousePressed = false; 349 mMousePressed = false;
350} 350}
351 351
352void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 352void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
353{ 353{
354 if (!e) return; 354 if (!e) return;
355 355
356 QPoint vp = contentsToViewport(e->pos()); 356 QPoint vp = contentsToViewport(e->pos());
357 357
358 QListViewItem *item = itemAt(vp); 358 QListViewItem *item = itemAt(vp);
359 359
360 emit double_Clicked(item); 360 emit double_Clicked(item);
361 if (!item) return; 361 if (!item) return;
362 362
363 emit doubleClicked(item,vp,0); 363 emit doubleClicked(item,vp,0);
364} 364}
365 365
366///////////////////////////////////////////////////////////////////////////// 366/////////////////////////////////////////////////////////////////////////////
367 367
368KOQuickTodo::KOQuickTodo(QWidget *parent) : 368KOQuickTodo::KOQuickTodo(QWidget *parent) :
369 QLineEdit(parent) 369 QLineEdit(parent)
370{ 370{
371 setText(i18n("Click to add a new Todo")); 371 setText(i18n("Click to add a new Todo"));
372} 372}
373 373
374void KOQuickTodo::focusInEvent(QFocusEvent *ev) 374void KOQuickTodo::focusInEvent(QFocusEvent *ev)
375{ 375{
376 if ( text()==i18n("Click to add a new Todo") ) 376 if ( text()==i18n("Click to add a new Todo") )
377 setText(""); 377 setText("");
378 QLineEdit::focusInEvent(ev); 378 QLineEdit::focusInEvent(ev);
379} 379}
380 380
381void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 381void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
382{ 382{
383 setText(i18n("Click to add a new Todo")); 383 setText(i18n("Click to add a new Todo"));
384 QLineEdit::focusOutEvent(ev); 384 QLineEdit::focusOutEvent(ev);
385} 385}
386 386
387///////////////////////////////////////////////////////////////////////////// 387/////////////////////////////////////////////////////////////////////////////
388 388
389KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 389KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
390 KOrg::BaseView(calendar,parent,name) 390 KOrg::BaseView(calendar,parent,name)
391{ 391{
392 mPendingUpdateBeforeRepaint = false; 392 mPendingUpdateBeforeRepaint = false;
393 isFlatDisplay = false; 393 isFlatDisplay = false;
394 mNavigator = 0; 394 mNavigator = 0;
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 mName = QString ( name ); 396 mName = QString ( name );
397 mBlockUpdate = false; 397 mBlockUpdate = false;
398 mQuickAdd = new KOQuickTodo(this); 398 mQuickAdd = new KOQuickTodo(this);
399 topLayout->addWidget(mQuickAdd); 399 topLayout->addWidget(mQuickAdd);
400 400
401 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 401 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
402 402
403 mTodoListView = new KOTodoListView(calendar,this, name ); 403 mTodoListView = new KOTodoListView(calendar,this, name );
404 topLayout->addWidget(mTodoListView); 404 topLayout->addWidget(mTodoListView);
405 //mTodoListView->header()->setMaximumHeight(30); 405 //mTodoListView->header()->setMaximumHeight(30);
406 mTodoListView->setRootIsDecorated(true); 406 mTodoListView->setRootIsDecorated(true);
407 mTodoListView->setAllColumnsShowFocus(true); 407 mTodoListView->setAllColumnsShowFocus(true);
408 408
409 mTodoListView->setShowSortIndicator(true); 409 mTodoListView->setShowSortIndicator(true);
410 410
411 mTodoListView->addColumn(i18n("Todo")); 411 mTodoListView->addColumn(i18n("Todo"));
412 mTodoListView->addColumn(i18n("Prio")); 412 mTodoListView->addColumn(i18n("Prio"));
413 mTodoListView->setColumnAlignment(1,AlignHCenter); 413 mTodoListView->setColumnAlignment(1,AlignHCenter);
414 mTodoListView->addColumn(i18n("Complete")); 414 mTodoListView->addColumn(i18n("Complete"));
415 mTodoListView->setColumnAlignment(2,AlignCenter); 415 mTodoListView->setColumnAlignment(2,AlignCenter);
416 416
417 mTodoListView->addColumn(i18n("Due Date")); 417 mTodoListView->addColumn(i18n("Due Date"));
418 mTodoListView->setColumnAlignment(3,AlignLeft); 418 mTodoListView->setColumnAlignment(3,AlignLeft);
419 mTodoListView->addColumn(i18n("Due Time")); 419 mTodoListView->addColumn(i18n("Due Time"));
420 mTodoListView->setColumnAlignment(4,AlignHCenter); 420 mTodoListView->setColumnAlignment(4,AlignHCenter);
421 421
422 mTodoListView->addColumn(i18n("Start Date")); 422 mTodoListView->addColumn(i18n("Start Date"));
423 mTodoListView->setColumnAlignment(5,AlignLeft); 423 mTodoListView->setColumnAlignment(5,AlignLeft);
424 mTodoListView->addColumn(i18n("Start Time")); 424 mTodoListView->addColumn(i18n("Start Time"));
425 mTodoListView->setColumnAlignment(6,AlignHCenter); 425 mTodoListView->setColumnAlignment(6,AlignHCenter);
426 426
427 mTodoListView->addColumn(i18n("Cancelled")); 427 mTodoListView->addColumn(i18n("Cancelled"));
428 mTodoListView->addColumn(i18n("Categories")); 428 mTodoListView->addColumn(i18n("Categories"));
429#if 0 429#if 0
430 mTodoListView->addColumn(i18n("Sort Id")); 430 mTodoListView->addColumn(i18n("Sort Id"));
431 mTodoListView->setColumnAlignment(4,AlignHCenter); 431 mTodoListView->setColumnAlignment(4,AlignHCenter);
432#endif 432#endif
433 433
434 mTodoListView->setMinimumHeight( 60 ); 434 mTodoListView->setMinimumHeight( 60 );
435 mTodoListView->setItemsRenameable( true ); 435 mTodoListView->setItemsRenameable( true );
436 mTodoListView->setRenameable( 0 ); 436 mTodoListView->setRenameable( 0 );
437 mTodoListView->setColumnWidth( 0, 120 ); 437 mTodoListView->setColumnWidth( 0, 120 );
438 mTodoListView->setColumnWidthMode(0, QListView::Manual); 438 mTodoListView->setColumnWidthMode(0, QListView::Manual);
439 mTodoListView->setColumnWidthMode(1, QListView::Manual); 439 mTodoListView->setColumnWidthMode(1, QListView::Manual);
440 mTodoListView->setColumnWidthMode(2, QListView::Manual); 440 mTodoListView->setColumnWidthMode(2, QListView::Manual);
441 mTodoListView->setColumnWidthMode(3, QListView::Manual); 441 mTodoListView->setColumnWidthMode(3, QListView::Manual);
442 mTodoListView->setColumnWidthMode(4, QListView::Manual); 442 mTodoListView->setColumnWidthMode(4, QListView::Manual);
443 mTodoListView->setColumnWidthMode(5, QListView::Manual); 443 mTodoListView->setColumnWidthMode(5, QListView::Manual);
444 mTodoListView->setColumnWidthMode(6, QListView::Manual); 444 mTodoListView->setColumnWidthMode(6, QListView::Manual);
445 mTodoListView->setColumnWidthMode(7, QListView::Manual); 445 mTodoListView->setColumnWidthMode(7, QListView::Manual);
446 mTodoListView->setColumnWidthMode(8, QListView::Manual); 446 mTodoListView->setColumnWidthMode(8, QListView::Manual);
447 447
448 448
449 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 449 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
450 450
451 mPriorityPopupMenu = new QPopupMenu(this); 451 mPriorityPopupMenu = new QPopupMenu(this);
452 for (int i = 1; i <= 5; i++) { 452 for (int i = 1; i <= 5; i++) {
453 QString label = QString ("%1").arg (i); 453 QString label = QString ("%1").arg (i);
454 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 454 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
455 } 455 }
456 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 456 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
457 457
458 mPercentageCompletedPopupMenu = new QPopupMenu(this); 458 mPercentageCompletedPopupMenu = new QPopupMenu(this);
459 for (int i = 0; i <= 100; i+=20) { 459 for (int i = 0; i <= 100; i+=20) {
460 QString label = QString ("%1 %").arg (i); 460 QString label = QString ("%1 %").arg (i);
461 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 461 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
462 } 462 }
463 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 463 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
464 464
465 465
466 466
467 mItemPopupMenu = new QPopupMenu(this); 467 mItemPopupMenu = new QPopupMenu(this);
468 mItemPopupMenu->insertItem(i18n("Show..."), this, 468 mItemPopupMenu->insertItem(i18n("Show..."), this,
469 SLOT (showTodo())); 469 SLOT (showTodo()));
470 mItemPopupMenu->insertItem(i18n("Edit..."), this, 470 mItemPopupMenu->insertItem(i18n("Edit..."), this,
471 SLOT (editTodo())); 471 SLOT (editTodo()));
472 mItemPopupMenu->insertItem( i18n("Delete"), this, 472 mItemPopupMenu->insertItem( i18n("Delete"), this,
473 SLOT (deleteTodo())); 473 SLOT (deleteTodo()));
474 mItemPopupMenu->insertItem( i18n("Clone..."), this, 474 mItemPopupMenu->insertItem( i18n("Clone..."), this,
475 SLOT (cloneTodo())); 475 SLOT (cloneTodo()));
476 mItemPopupMenu->insertItem( i18n("Move..."), this, 476 mItemPopupMenu->insertItem( i18n("Move..."), this,
477 SLOT (moveTodo())); 477 SLOT (moveTodo()));
478 mItemPopupMenu->insertItem( i18n("Beam..."), this, 478 mItemPopupMenu->insertItem( i18n("Beam..."), this,
479 SLOT (beamTodo())); 479 SLOT (beamTodo()));
480 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 480 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
481 SLOT (cancelTodo())); 481 SLOT (cancelTodo()));
482 mItemPopupMenu->insertSeparator(); 482 mItemPopupMenu->insertSeparator();
483 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 483 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
484 SLOT (toggleRunningItem())); 484 SLOT (toggleRunningItem()));
485 mItemPopupMenu->insertSeparator(); 485 mItemPopupMenu->insertSeparator();
486 /* 486 /*
487 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 487 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
488 SLOT (newTodo())); 488 SLOT (newTodo()));
489 */ 489 */
490 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 490 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
491 SLOT (newSubTodo())); 491 SLOT (newSubTodo()));
492 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 492 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
493 SLOT (unparentTodo()),0,21); 493 SLOT (unparentTodo()),0,21);
494 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 494 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
495 SLOT (reparentTodo()),0,22); 495 SLOT (reparentTodo()),0,22);
496 mItemPopupMenu->insertSeparator(); 496 mItemPopupMenu->insertSeparator();
497#if 0 497#if 0
498 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 498 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
499 this, SLOT( purgeCompleted() ) ); 499 this, SLOT( purgeCompleted() ) );
500 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 500 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
501 this, SLOT( toggleCompleted() ),0, 33 ); 501 this, SLOT( toggleCompleted() ),0, 33 );
502 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 502 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
503 this, SLOT( toggleQuickTodo() ),0, 34 ); 503 this, SLOT( toggleQuickTodo() ),0, 34 );
504 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 504 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
505 this, SLOT( toggleRunning() ),0, 35 ); 505 this, SLOT( toggleRunning() ),0, 35 );
506 506
507#endif 507#endif
508 mPopupMenu = new QPopupMenu(this); 508 mPopupMenu = new QPopupMenu(this);
509 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 509 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
510 SLOT (newTodo()),0,1); 510 SLOT (newTodo()),0,1);
511 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 511 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
512 this, SLOT(purgeCompleted()),0,2); 512 this, SLOT(purgeCompleted()),0,2);
513 mPopupMenu->insertItem(i18n("Show Completed"), 513 mPopupMenu->insertItem(i18n("Show Completed"),
514 this, SLOT( toggleCompleted() ),0,3 ); 514 this, SLOT( toggleCompleted() ),0,3 );
515 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 515 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
516 this, SLOT( toggleRunning() ),0,5 ); 516 this, SLOT( toggleRunning() ),0,5 );
517 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 517 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
518 this, SLOT( setAllOpen() ),0,6 ); 518 this, SLOT( setAllOpen() ),0,6 );
519 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 519 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
520 this, SLOT( setAllClose() ),0,7 ); 520 this, SLOT( setAllClose() ),0,7 );
521 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 521 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
522 this, SLOT( setAllFlat() ),0,8 ); 522 this, SLOT( setAllFlat() ),0,8 );
523 mPopupMenu->insertSeparator(); 523 mPopupMenu->insertSeparator();
524 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 524 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
525 this, SLOT( toggleQuickTodo() ),0,4 ); 525 this, SLOT( toggleQuickTodo() ),0,4 );
526 mDocPrefs = new DocPrefs( name ); 526 mDocPrefs = new DocPrefs( name );
527 527
528 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 528 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
529 mPopupMenu->setCheckable( true ); 529 mPopupMenu->setCheckable( true );
530 mItemPopupMenu->setCheckable( true ); 530 mItemPopupMenu->setCheckable( true );
531 531
532 532
533 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 533 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
534 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 534 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
535 535
536 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 536 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
537 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 537 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
538 538
539 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 539 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
540 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 540 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
541 541
542 542
543 // Double clicking conflicts with opening/closing the subtree 543 // Double clicking conflicts with opening/closing the subtree
544 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 544 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
545 SLOT( editItem( QListViewItem *) ) ); 545 SLOT( editItem( QListViewItem *) ) );
546 /* 546 /*
547 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 547 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
548 const QPoint &,int ) ), 548 const QPoint &,int ) ),
549 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 549 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
550 */ 550 */
551 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 551 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
552 const QPoint &,int ) ), 552 const QPoint &,int ) ),
553 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 553 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
554 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 554 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
555 SLOT( itemClicked( QListViewItem * ) ) ); 555 SLOT( itemClicked( QListViewItem * ) ) );
556 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 556 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
557 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 557 SLOT( itemDoubleClicked( QListViewItem * ) ) );
558 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 558 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
559 SLOT( updateView() ) ); 559 SLOT( updateView() ) );
560 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 560 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
561 SLOT( todoModified(Todo *, int) ) ); 561 SLOT( todoModified(Todo *, int) ) );
562 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 562 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
563 SLOT( itemStateChanged( QListViewItem * ) ) ); 563 SLOT( itemStateChanged( QListViewItem * ) ) );
564 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 564 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
565 SLOT( itemStateChanged( QListViewItem * ) ) ); 565 SLOT( itemStateChanged( QListViewItem * ) ) );
566 connect( mTodoListView, SIGNAL( paintNeeded() ), 566 connect( mTodoListView, SIGNAL( paintNeeded() ),
567 SLOT( paintNeeded()) ); 567 SLOT( paintNeeded()) );
568 568
569#if 0 569#if 0
570 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 570 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
571 SLOT(selectionChanged(QListViewItem *))); 571 SLOT(selectionChanged(QListViewItem *)));
572 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 572 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
573 SLOT(selectionChanged(QListViewItem *))); 573 SLOT(selectionChanged(QListViewItem *)));
574 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 574 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
575 SLOT(selectionChanged(QListViewItem *))); 575 SLOT(selectionChanged(QListViewItem *)));
576#endif 576#endif
577 577
578 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 578 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
579 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 579 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
580 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 580 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
581 581
582 connect( mTodoListView, SIGNAL(selectionChanged() ), 582 connect( mTodoListView, SIGNAL(selectionChanged() ),
583 SLOT( processSelectionChange() ) ); 583 SLOT( processSelectionChange() ) );
584 connect( mQuickAdd, SIGNAL( returnPressed () ), 584 connect( mQuickAdd, SIGNAL( returnPressed () ),
585 SLOT( addQuickTodo() ) ); 585 SLOT( addQuickTodo() ) );
586 586
587} 587}
588 588
589KOTodoView::~KOTodoView() 589KOTodoView::~KOTodoView()
590{ 590{
591 // delete mKOTodoViewWhatsThis; 591
592#if QT_VERSION >= 0x030000
593
594#else
595 delete mKOTodoViewWhatsThis;
596#endif
597
592 delete mDocPrefs; 598 delete mDocPrefs;
593} 599}
594QString KOTodoView::getWhatsThisText(QPoint p) 600QString KOTodoView::getWhatsThisText(QPoint p)
595{ 601{
596 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 602 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
597 if ( item ) 603 if ( item )
598 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 604 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
599 KOPrefs::instance()->mWTshowDetails, 605 KOPrefs::instance()->mWTshowDetails,
600 KOPrefs::instance()->mWTshowCreated, 606 KOPrefs::instance()->mWTshowCreated,
601 KOPrefs::instance()->mWTshowChanged); 607 KOPrefs::instance()->mWTshowChanged);
602 return i18n("That is the todo view" ); 608 return i18n("That is the todo view" );
603 609
604} 610}
605 611
606void KOTodoView::jumpToDate () 612void KOTodoView::jumpToDate ()
607{ 613{
608 // if (mActiveItem) { 614 // if (mActiveItem) {
609// mActiveItem->todo()); 615// mActiveItem->todo());
610// if ( mActiveItem->todo()->hasDueDate() ) 616// if ( mActiveItem->todo()->hasDueDate() )
611// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 617// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
612} 618}
613void KOTodoView::paintNeeded() 619void KOTodoView::paintNeeded()
614{ 620{
615 if ( mPendingUpdateBeforeRepaint ) { 621 if ( mPendingUpdateBeforeRepaint ) {
616 updateView(); 622 updateView();
617 mPendingUpdateBeforeRepaint = false; 623 mPendingUpdateBeforeRepaint = false;
618 } 624 }
619} 625}
620void KOTodoView::paintEvent(QPaintEvent * pevent) 626void KOTodoView::paintEvent(QPaintEvent * pevent)
621{ 627{
622 if ( mPendingUpdateBeforeRepaint ) { 628 if ( mPendingUpdateBeforeRepaint ) {
623 updateView(); 629 updateView();
624 mPendingUpdateBeforeRepaint = false; 630 mPendingUpdateBeforeRepaint = false;
625 } 631 }
626 KOrg::BaseView::paintEvent( pevent); 632 KOrg::BaseView::paintEvent( pevent);
627} 633}
628 634
629void KOTodoView::updateView() 635void KOTodoView::updateView()
630{ 636{
631 pendingSubtodo = 0; 637 pendingSubtodo = 0;
632 if ( mBlockUpdate ) { 638 if ( mBlockUpdate ) {
633 return; 639 return;
634 } 640 }
635 if ( !isVisible() ) { 641 if ( !isVisible() ) {
636 mPendingUpdateBeforeRepaint = true; 642 mPendingUpdateBeforeRepaint = true;
637 return; 643 return;
638 } 644 }
639 storeCurrentItem(); 645 storeCurrentItem();
640 //qDebug("KOTodoView::updateView() %x", this); 646 //qDebug("KOTodoView::updateView() %x", this);
641 if ( isFlatDisplay ) { 647 if ( isFlatDisplay ) {
642 displayAllFlat(); 648 displayAllFlat();
643 resetCurrentItem(); 649 resetCurrentItem();
644 return; 650 return;
645 } 651 }
646 //qDebug("update "); 652 //qDebug("update ");
647// kdDebug() << "KOTodoView::updateView()" << endl; 653// kdDebug() << "KOTodoView::updateView()" << endl;
648 QFont fo = KOPrefs::instance()->mTodoViewFont; 654 QFont fo = KOPrefs::instance()->mTodoViewFont;
649 655
650 656
651 mTodoListView->clear(); 657 mTodoListView->clear();
652 if ( mName == "todolistsmall" ) { 658 if ( mName == "todolistsmall" ) {
653 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 659 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
654 int ps = fo.pointSize() -2; 660 int ps = fo.pointSize() -2;
655 if ( ps > 12 ) 661 if ( ps > 12 )
656 ps -= 2; 662 ps -= 2;
657 fo.setPointSize( ps ); 663 fo.setPointSize( ps );
658 } 664 }
659 } 665 }
660 666
661 mTodoListView->setFont( fo ); 667 mTodoListView->setFont( fo );
662 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 668 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
663 //mTodoListView->header()->setMaximumHeight(fm.height()); 669 //mTodoListView->header()->setMaximumHeight(fm.height());
664 QPtrList<Todo> todoList = calendar()->todos(); 670 QPtrList<Todo> todoList = calendar()->todos();
665 671
666/* 672/*
667 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 673 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
668 Event *t; 674 Event *t;
669 for(t = todoList.first(); t; t = todoList.next()) { 675 for(t = todoList.first(); t; t = todoList.next()) {
670 kdDebug() << " " << t->getSummary() << endl; 676 kdDebug() << " " << t->getSummary() << endl;
671 677
672 if (t->getRelatedTo()) { 678 if (t->getRelatedTo()) {
673 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 679 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
674 } 680 }
675 681
676 QPtrList<Event> l = t->getRelations(); 682 QPtrList<Event> l = t->getRelations();
677 Event *c; 683 Event *c;
678 for(c=l.first();c;c=l.next()) { 684 for(c=l.first();c;c=l.next()) {
679 kdDebug() << " - relation: " << c->getSummary() << endl; 685 kdDebug() << " - relation: " << c->getSummary() << endl;
680 } 686 }
681 } 687 }
682*/ 688*/
683 689
684 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 690 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
685 // specific order of events. That means that we have to generate parent items 691 // specific order of events. That means that we have to generate parent items
686 // recursively for proper hierarchical display of Todos. 692 // recursively for proper hierarchical display of Todos.
687 mTodoMap.clear(); 693 mTodoMap.clear();
688 Todo *todo; 694 Todo *todo;
689 todo = todoList.first();// todo; todo = todoList.next()) { 695 todo = todoList.first();// todo; todo = todoList.next()) {
690 while ( todo ) { 696 while ( todo ) {
691 bool next = true; 697 bool next = true;
692 // qDebug("todo %s ", todo->summary().latin1()); 698 // qDebug("todo %s ", todo->summary().latin1());
693 Incidence *incidence = todo->relatedTo(); 699 Incidence *incidence = todo->relatedTo();
694 while ( incidence ) { 700 while ( incidence ) {
695 if ( incidence->type() == "Todo") { 701 if ( incidence->type() == "Todo") {
696 //qDebug("related %s ",incidence->summary().latin1() ); 702 //qDebug("related %s ",incidence->summary().latin1() );
697 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 703 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
698 //qDebug("related not found "); 704 //qDebug("related not found ");
699 todoList.remove( ); 705 todoList.remove( );
700 todo = todoList.current(); 706 todo = todoList.current();
701 next = false; 707 next = false;
702 incidence = 0; 708 incidence = 0;
703 709
704 } else { 710 } else {
705 //qDebug("related found "); 711 //qDebug("related found ");
706 incidence = incidence->relatedTo(); 712 incidence = incidence->relatedTo();
707 } 713 }
708 } else 714 } else
709 incidence = 0; 715 incidence = 0;
710 } 716 }
711 if ( next ) 717 if ( next )
712 todo = todoList.next(); 718 todo = todoList.next();
713 } 719 }
714 720
715 for(todo = todoList.first(); todo; todo = todoList.next()) { 721 for(todo = todoList.first(); todo; todo = todoList.next()) {
716 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 722 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
717 { 723 {
718 insertTodoItem(todo); 724 insertTodoItem(todo);
719 } 725 }
720 } 726 }
721 // Restore opened/closed state 727 // Restore opened/closed state
722 mTodoListView->blockSignals( true ); 728 mTodoListView->blockSignals( true );
723 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 729 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
724 mTodoListView->blockSignals( false ); 730 mTodoListView->blockSignals( false );
725 resetCurrentItem(); 731 resetCurrentItem();
726 processSelectionChange(); 732 processSelectionChange();
727} 733}
728 734
729void KOTodoView::storeCurrentItem() 735void KOTodoView::storeCurrentItem()
730{ 736{
731 mCurItem = 0; 737 mCurItem = 0;
732 mCurItemRootParent = 0; 738 mCurItemRootParent = 0;
733 mCurItemParent = 0; 739 mCurItemParent = 0;
734 mCurItemAbove = 0; 740 mCurItemAbove = 0;
735 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 741 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
736 if (mActiveItem) { 742 if (mActiveItem) {
737 mCurItem = mActiveItem->todo(); 743 mCurItem = mActiveItem->todo();
738 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 744 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
739 if ( activeItemAbove ) 745 if ( activeItemAbove )
740 mCurItemAbove = activeItemAbove->todo(); 746 mCurItemAbove = activeItemAbove->todo();
741 mCurItemRootParent = mCurItem; 747 mCurItemRootParent = mCurItem;
742 mCurItemParent = mCurItemRootParent->relatedTo(); 748 mCurItemParent = mCurItemRootParent->relatedTo();
743 while ( mCurItemRootParent->relatedTo() != 0 ) 749 while ( mCurItemRootParent->relatedTo() != 0 )
744 mCurItemRootParent = mCurItemRootParent->relatedTo(); 750 mCurItemRootParent = mCurItemRootParent->relatedTo();
745 } 751 }
746 mActiveItem = 0; 752 mActiveItem = 0;
747} 753}
748 754
749void KOTodoView::resetCurrentItem() 755void KOTodoView::resetCurrentItem()
750{ 756{
751 mTodoListView->setFocus(); 757 mTodoListView->setFocus();
752 KOTodoViewItem* foundItem = 0; 758 KOTodoViewItem* foundItem = 0;
753 KOTodoViewItem* foundItemRoot = 0; 759 KOTodoViewItem* foundItemRoot = 0;
754 KOTodoViewItem* foundItemParent = 0; 760 KOTodoViewItem* foundItemParent = 0;
755 KOTodoViewItem* foundItemAbove = 0; 761 KOTodoViewItem* foundItemAbove = 0;
756 if ( mTodoListView->firstChild () ) { 762 if ( mTodoListView->firstChild () ) {
757 if ( mCurItem ) { 763 if ( mCurItem ) {
758 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 764 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
759 while ( item ) { 765 while ( item ) {
760 if ( item->todo() == mCurItem ) { 766 if ( item->todo() == mCurItem ) {
761 foundItem = item; 767 foundItem = item;
762 break; 768 break;
763 } else if ( item->todo() == mCurItemAbove ) { 769 } else if ( item->todo() == mCurItemAbove ) {
764 foundItemAbove = item; 770 foundItemAbove = item;
765 771
766 } 772 }
767 if ( item->todo() == mCurItemRootParent ) { 773 if ( item->todo() == mCurItemRootParent ) {
768 foundItemRoot = item; 774 foundItemRoot = item;
769 } 775 }
770 if ( item->todo() == mCurItemParent ) { 776 if ( item->todo() == mCurItemParent ) {
771 foundItemParent = item; 777 foundItemParent = item;
772 } 778 }
773 item = (KOTodoViewItem*)item->itemBelow(); 779 item = (KOTodoViewItem*)item->itemBelow();
774 } 780 }
775 if ( ! foundItem ) { 781 if ( ! foundItem ) {
776 if ( foundItemParent ) { 782 if ( foundItemParent ) {
777 foundItem = foundItemParent; 783 foundItem = foundItemParent;
778 } else { 784 } else {
779 if ( foundItemRoot ) 785 if ( foundItemRoot )
780 foundItem = foundItemRoot; 786 foundItem = foundItemRoot;
781 else 787 else
782 foundItem = foundItemAbove; 788 foundItem = foundItemAbove;
783 } 789 }
784 } 790 }
785 } 791 }
786 if ( foundItem ) { 792 if ( foundItem ) {
787 mTodoListView->setCurrentItem( foundItem ); 793 mTodoListView->setCurrentItem( foundItem );
788 mTodoListView->ensureItemVisible( foundItem ); 794 mTodoListView->ensureItemVisible( foundItem );
789 } else { 795 } else {
790 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 796 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
791 } 797 }
792 } 798 }
793 mTodoListView->setFocus(); 799 mTodoListView->setFocus();
794} 800}
795//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 801//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
796bool KOTodoView::checkTodo( Todo * todo ) 802bool KOTodoView::checkTodo( Todo * todo )
797{ 803{
798 804
799 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 805 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
800 return false; 806 return false;
801 if ( !todo->isCompleted() ) { 807 if ( !todo->isCompleted() ) {
802 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 808 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
803 return true; 809 return true;
804 } 810 }
805 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 811 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
806 if ( todo->hasStartDate() ) 812 if ( todo->hasStartDate() )
807 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 813 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
808 return false; 814 return false;
809 if ( todo->hasDueDate() ) 815 if ( todo->hasDueDate() )
810 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 816 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
811 return false; 817 return false;
812 } 818 }
813 return true; 819 return true;
814} 820}
815 821
816void KOTodoView::restoreItemState( QListViewItem *item ) 822void KOTodoView::restoreItemState( QListViewItem *item )
817{ 823{
818 pendingSubtodo = 0; 824 pendingSubtodo = 0;
819 while( item ) { 825 while( item ) {
820 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 826 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
821 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 827 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
822 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 828 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
823 item = item->nextSibling(); 829 item = item->nextSibling();
824 } 830 }
825} 831}
826 832
827 833
828QMap<Todo *,KOTodoViewItem *>::ConstIterator 834QMap<Todo *,KOTodoViewItem *>::ConstIterator
829 KOTodoView::insertTodoItem(Todo *todo) 835 KOTodoView::insertTodoItem(Todo *todo)
830{ 836{
831 837
832// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 838// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
833 // TODO: Check, if dynmaic cast is necessary 839 // TODO: Check, if dynmaic cast is necessary
834 840
835 pendingSubtodo = 0; 841 pendingSubtodo = 0;
836 Incidence *incidence = todo->relatedTo(); 842 Incidence *incidence = todo->relatedTo();
837 if (incidence && incidence->type() == "Todo") { 843 if (incidence && incidence->type() == "Todo") {
838 Todo *relatedTodo = static_cast<Todo *>(incidence); 844 Todo *relatedTodo = static_cast<Todo *>(incidence);
839 845
840// kdDebug() << " has Related" << endl; 846// kdDebug() << " has Related" << endl;
841 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 847 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
842 itemIterator = mTodoMap.find(relatedTodo); 848 itemIterator = mTodoMap.find(relatedTodo);
843 if (itemIterator == mTodoMap.end()) { 849 if (itemIterator == mTodoMap.end()) {
844// kdDebug() << " related not yet in list" << endl; 850// kdDebug() << " related not yet in list" << endl;
845 itemIterator = insertTodoItem (relatedTodo); 851 itemIterator = insertTodoItem (relatedTodo);
846 } 852 }
847 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 853 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
848 // and one into the map. Sure finding is more easy but why? -zecke 854 // and one into the map. Sure finding is more easy but why? -zecke
849 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 855 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
850 return mTodoMap.insert(todo,todoItem); 856 return mTodoMap.insert(todo,todoItem);
851 } else { 857 } else {
852// kdDebug() << " no Related" << endl; 858// kdDebug() << " no Related" << endl;
853 // see above -zecke 859 // see above -zecke
854 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 860 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
855 return mTodoMap.insert(todo,todoItem); 861 return mTodoMap.insert(todo,todoItem);
856 } 862 }
857} 863}
858 864
859 865
860void KOTodoView::updateConfig() 866void KOTodoView::updateConfig()
861{ 867{
862 updateView(); 868 updateView();
863 mTodoListView->repaintContents(); 869 mTodoListView->repaintContents();
864} 870}
865 871
866QPtrList<Incidence> KOTodoView::selectedIncidences() 872QPtrList<Incidence> KOTodoView::selectedIncidences()
867{ 873{
868 QPtrList<Incidence> selected; 874 QPtrList<Incidence> selected;
869 875
870 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 876 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
871// if (!item) item = mActiveItem; 877// if (!item) item = mActiveItem;
872 if (item) selected.append(item->todo()); 878 if (item) selected.append(item->todo());
873 879
874 return selected; 880 return selected;
875} 881}
876 882
877QPtrList<Todo> KOTodoView::selectedTodos() 883QPtrList<Todo> KOTodoView::selectedTodos()
878{ 884{
879 QPtrList<Todo> selected; 885 QPtrList<Todo> selected;
880 886
881 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 887 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
882// if (!item) item = mActiveItem; 888// if (!item) item = mActiveItem;
883 if (item) selected.append(item->todo()); 889 if (item) selected.append(item->todo());
884 890
885 return selected; 891 return selected;
886} 892}
887 893
888void KOTodoView::changeEventDisplay(Event *, int) 894void KOTodoView::changeEventDisplay(Event *, int)
889{ 895{
890 updateView(); 896 updateView();
891} 897}
892 898
893void KOTodoView::showDates(const QDate &, const QDate &) 899void KOTodoView::showDates(const QDate &, const QDate &)
894{ 900{
895} 901}
896 902
897void KOTodoView::showEvents(QPtrList<Event>) 903void KOTodoView::showEvents(QPtrList<Event>)
898{ 904{
899 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 905 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
900} 906}
901 907
902void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 908void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
903 const QDate &td) 909 const QDate &td)
904{ 910{
905#ifndef KORG_NOPRINTER 911#ifndef KORG_NOPRINTER
906 calPrinter->preview(CalPrinter::Todolist, fd, td); 912 calPrinter->preview(CalPrinter::Todolist, fd, td);
907#endif 913#endif
908} 914}
909 915
910void KOTodoView::editItem(QListViewItem *item ) 916void KOTodoView::editItem(QListViewItem *item )
911{ 917{
912 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 918 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
913} 919}
914 920
915void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 921void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
916{ 922{
917 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 923 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
918} 924}
919 925
920void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 926void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
921{ 927{
922 pendingSubtodo = 0; 928 pendingSubtodo = 0;
923 mActiveItem = (KOTodoViewItem *)item; 929 mActiveItem = (KOTodoViewItem *)item;
924 if (item) { 930 if (item) {
925 switch (column){ 931 switch (column){
926 case 1: 932 case 1:
927 mPriorityPopupMenu->popup(QCursor::pos ()); break; 933 mPriorityPopupMenu->popup(QCursor::pos ()); break;
928 case 2: 934 case 2:
929 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 935 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
930 case 3: 936 case 3:
931 moveTodo(); 937 moveTodo();
932 break; 938 break;
933 case 8: 939 case 8:
934 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 940 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
935 default: 941 default:
936 mItemPopupMenu->popup(QCursor::pos()); 942 mItemPopupMenu->popup(QCursor::pos());
937 } 943 }
938 } else mPopupMenu->popup(QCursor::pos()); 944 } else mPopupMenu->popup(QCursor::pos());
939} 945}
940void KOTodoView::newTodo() 946void KOTodoView::newTodo()
941{ 947{
942 emit newTodoSignal(); 948 emit newTodoSignal();
943} 949}
944 950
945void KOTodoView::newSubTodo() 951void KOTodoView::newSubTodo()
946{ 952{
947 if (mActiveItem) { 953 if (mActiveItem) {
948 emit newSubTodoSignal(mActiveItem->todo()); 954 emit newSubTodoSignal(mActiveItem->todo());
949 } 955 }
950} 956}
951void KOTodoView::unparentTodo() 957void KOTodoView::unparentTodo()
952{ 958{
953 if (mActiveItem) { 959 if (mActiveItem) {
954 emit unparentTodoSignal(mActiveItem->todo()); 960 emit unparentTodoSignal(mActiveItem->todo());
955 } 961 }
956} 962}
957 963
958void KOTodoView::reparentTodo() 964void KOTodoView::reparentTodo()
959{ 965{
960 if (mActiveItem) { 966 if (mActiveItem) {
961 topLevelWidget()->setCaption(i18n("Click on new parent item")); 967 topLevelWidget()->setCaption(i18n("Click on new parent item"));
962 pendingSubtodo = mActiveItem; 968 pendingSubtodo = mActiveItem;
963 } 969 }
964} 970}
965void KOTodoView::editTodo() 971void KOTodoView::editTodo()
966{ 972{
967 if (mActiveItem) { 973 if (mActiveItem) {
968 emit editTodoSignal(mActiveItem->todo()); 974 emit editTodoSignal(mActiveItem->todo());
969 } 975 }
970} 976}
971void KOTodoView::cloneTodo() 977void KOTodoView::cloneTodo()
972{ 978{
973 if (mActiveItem) { 979 if (mActiveItem) {
974 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 980 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
975 } 981 }
976} 982}
977void KOTodoView::cancelTodo() 983void KOTodoView::cancelTodo()
978{ 984{
979 if (mActiveItem) { 985 if (mActiveItem) {
980 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 986 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
981 } 987 }
982} 988}
983void KOTodoView::moveTodo() 989void KOTodoView::moveTodo()
984{ 990{
985 if (mActiveItem) { 991 if (mActiveItem) {
986 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 992 emit moveTodoSignal((Incidence*)mActiveItem->todo());
987 } 993 }
988} 994}
989void KOTodoView::beamTodo() 995void KOTodoView::beamTodo()
990{ 996{
991 if (mActiveItem) { 997 if (mActiveItem) {
992 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 998 emit beamTodoSignal((Incidence*)mActiveItem->todo());
993 } 999 }
994} 1000}
995 1001
996 1002
997void KOTodoView::showTodo() 1003void KOTodoView::showTodo()
998{ 1004{
999 if (mActiveItem) { 1005 if (mActiveItem) {
1000 emit showTodoSignal(mActiveItem->todo()); 1006 emit showTodoSignal(mActiveItem->todo());
1001 } 1007 }
1002} 1008}
1003 1009
1004void KOTodoView::deleteTodo() 1010void KOTodoView::deleteTodo()
1005{ 1011{
1006 if (mActiveItem) { 1012 if (mActiveItem) {
1007 emit deleteTodoSignal(mActiveItem->todo()); 1013 emit deleteTodoSignal(mActiveItem->todo());
1008 } 1014 }
1009} 1015}
1010 1016
1011void KOTodoView::setNewPriority(int index) 1017void KOTodoView::setNewPriority(int index)
1012{ 1018{
1013 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1019 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1014 mActiveItem->todo()->setPriority(mPriority[index]); 1020 mActiveItem->todo()->setPriority(mPriority[index]);
1015 mActiveItem->construct(); 1021 mActiveItem->construct();
1016 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1022 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1017 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1023 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1018 } 1024 }
1019} 1025}
1020 1026
1021void KOTodoView::setNewPercentage(int index) 1027void KOTodoView::setNewPercentage(int index)
1022{ 1028{
1023 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1029 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1024 1030
1025 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1031 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1026 mActiveItem->setOn( true ); 1032 mActiveItem->setOn( true );
1027 return; 1033 return;
1028 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1034 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1029 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1035 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1030 if ( par && par->isOn() ) 1036 if ( par && par->isOn() )
1031 par->setOn( false ); 1037 par->setOn( false );
1032 } 1038 }
1033 if (mPercentage[index] == 100) { 1039 if (mPercentage[index] == 100) {
1034 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1040 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1035 } else { 1041 } else {
1036 mActiveItem->todo()->setCompleted(false); 1042 mActiveItem->todo()->setCompleted(false);
1037 } 1043 }
1038 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1044 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1039 mActiveItem->construct(); 1045 mActiveItem->construct();
1040 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1046 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1041 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1047 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1042 } 1048 }
1043} 1049}
1044 1050
1045 1051
1046QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1052QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1047{ 1053{
1048 QPopupMenu* tempMenu = new QPopupMenu (this); 1054 QPopupMenu* tempMenu = new QPopupMenu (this);
1049 QStringList checkedCategories = todoItem->todo()->categories (); 1055 QStringList checkedCategories = todoItem->todo()->categories ();
1050 1056
1051 tempMenu->setCheckable (true); 1057 tempMenu->setCheckable (true);
1052 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1058 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1053 it != KOPrefs::instance()->mCustomCategories.end (); 1059 it != KOPrefs::instance()->mCustomCategories.end ();
1054 ++it) { 1060 ++it) {
1055 int index = tempMenu->insertItem (*it); 1061 int index = tempMenu->insertItem (*it);
1056 mCategory[index] = *it; 1062 mCategory[index] = *it;
1057 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1063 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1058 } 1064 }
1059 1065
1060 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1066 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1061 return tempMenu; 1067 return tempMenu;
1062 1068
1063 1069
1064} 1070}
1065void KOTodoView::changedCategories(int index) 1071void KOTodoView::changedCategories(int index)
1066{ 1072{
1067 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1073 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1068 QStringList categories = mActiveItem->todo()->categories (); 1074 QStringList categories = mActiveItem->todo()->categories ();
1069 QString colcat = categories.first(); 1075 QString colcat = categories.first();
1070 if (categories.find (mCategory[index]) != categories.end ()) 1076 if (categories.find (mCategory[index]) != categories.end ())
1071 categories.remove (mCategory[index]); 1077 categories.remove (mCategory[index]);
1072 else 1078 else
1073 categories.insert (categories.end(), mCategory[index]); 1079 categories.insert (categories.end(), mCategory[index]);
1074 categories.sort (); 1080 categories.sort ();
1075 if ( !colcat.isEmpty() ) { 1081 if ( !colcat.isEmpty() ) {
1076 if ( categories.find ( colcat ) != categories.end () ) { 1082 if ( categories.find ( colcat ) != categories.end () ) {
1077 categories.remove( colcat ); 1083 categories.remove( colcat );
1078 categories.prepend( colcat ); 1084 categories.prepend( colcat );
1079 } 1085 }
1080 } 1086 }
1081 mActiveItem->todo()->setCategories (categories); 1087 mActiveItem->todo()->setCategories (categories);
1082 mActiveItem->construct(); 1088 mActiveItem->construct();
1083 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1089 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1084 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1090 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1085 } 1091 }
1086} 1092}
1087void KOTodoView::itemDoubleClicked(QListViewItem *item) 1093void KOTodoView::itemDoubleClicked(QListViewItem *item)
1088{ 1094{
1089 if ( pendingSubtodo != 0 ) { 1095 if ( pendingSubtodo != 0 ) {
1090 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1096 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1091 } 1097 }
1092 pendingSubtodo = 0; 1098 pendingSubtodo = 0;
1093 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1099 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1094 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1100 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1095 //qDebug("ROW %d ", row); 1101 //qDebug("ROW %d ", row);
1096 if (!item) { 1102 if (!item) {
1097 newTodo(); 1103 newTodo();
1098 return; 1104 return;
1099 } else { 1105 } else {
1100 if ( row == 2 || row == 1 ) { 1106 if ( row == 2 || row == 1 ) {
1101 mActiveItem = (KOTodoViewItem *) item; 1107 mActiveItem = (KOTodoViewItem *) item;
1102 newSubTodo(); 1108 newSubTodo();
1103 return; 1109 return;
1104 } 1110 }
1105 if ( row == 5 || row == 6 ) { 1111 if ( row == 5 || row == 6 ) {
1106 mActiveItem = (KOTodoViewItem *) item; 1112 mActiveItem = (KOTodoViewItem *) item;
1107 toggleRunningItem(); 1113 toggleRunningItem();
1108 return; 1114 return;
1109 } 1115 }
1110 } 1116 }
1111 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1117 if ( KOPrefs::instance()->mEditOnDoubleClick )
1112 editItem( item ); 1118 editItem( item );
1113 else 1119 else
1114 showItem( item , QPoint(), 0 ); 1120 showItem( item , QPoint(), 0 );
1115} 1121}
1116void KOTodoView::toggleRunningItem() 1122void KOTodoView::toggleRunningItem()
1117{ 1123{
1118 // qDebug("KOTodoView::toggleRunning() "); 1124 // qDebug("KOTodoView::toggleRunning() ");
1119 if ( ! mActiveItem ) 1125 if ( ! mActiveItem )
1120 return; 1126 return;
1121 Todo * t = mActiveItem->todo(); 1127 Todo * t = mActiveItem->todo();
1122 if ( t->isRunning() ) { 1128 if ( t->isRunning() ) {
1123 int result = KMessageBox::warningContinueCancel(this, 1129 int result = KMessageBox::warningContinueCancel(this,
1124 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true); 1130 i18n("The todo\n%1\nis started.\nDo you want to set\nthe state to stopped?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is started"),i18n("Stop todo"),i18n("Cancel"), true);
1125 if (result != KMessageBox::Continue) return; 1131 if (result != KMessageBox::Continue) return;
1126 t->setRunning( false ); 1132 t->setRunning( false );
1127 mActiveItem->construct(); 1133 mActiveItem->construct();
1128 } else { 1134 } else {
1129 int result = KMessageBox::warningContinueCancel(this, 1135 int result = KMessageBox::warningContinueCancel(this,
1130 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true); 1136 i18n("The todo\n%1\nis stopped.\nDo you want to set\nthe state to started?").arg(mActiveItem->text(0).left( 25 ) ),i18n("Todo is stopped"),i18n("Start todo"),i18n("Cancel"), true);
1131 if (result != KMessageBox::Continue) return; 1137 if (result != KMessageBox::Continue) return;
1132 t->setRunning( true ); 1138 t->setRunning( true );
1133 mActiveItem->construct(); 1139 mActiveItem->construct();
1134 } 1140 }
1135} 1141}
1136 1142
1137void KOTodoView::itemClicked(QListViewItem *item) 1143void KOTodoView::itemClicked(QListViewItem *item)
1138{ 1144{
1139 //qDebug("KOTodoView::itemClicked %d", item); 1145 //qDebug("KOTodoView::itemClicked %d", item);
1140 if (!item) { 1146 if (!item) {
1141 if ( pendingSubtodo != 0 ) { 1147 if ( pendingSubtodo != 0 ) {
1142 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1148 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1143 } 1149 }
1144 pendingSubtodo = 0; 1150 pendingSubtodo = 0;
1145 return; 1151 return;
1146 } 1152 }
1147 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1153 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1148 if ( pendingSubtodo != 0 ) { 1154 if ( pendingSubtodo != 0 ) {
1149 bool allowReparent = true; 1155 bool allowReparent = true;
1150 QListViewItem *par = item; 1156 QListViewItem *par = item;
1151 while ( par ) { 1157 while ( par ) {
1152 if ( par == pendingSubtodo ) { 1158 if ( par == pendingSubtodo ) {
1153 allowReparent = false; 1159 allowReparent = false;
1154 break; 1160 break;
1155 } 1161 }
1156 par = par->parent(); 1162 par = par->parent();
1157 } 1163 }
1158 if ( !allowReparent ) { 1164 if ( !allowReparent ) {
1159 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1165 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1160 pendingSubtodo = 0; 1166 pendingSubtodo = 0;
1161 } else { 1167 } else {
1162 Todo* newParent = todoItem->todo(); 1168 Todo* newParent = todoItem->todo();
1163 Todo* newSub = pendingSubtodo->todo(); 1169 Todo* newSub = pendingSubtodo->todo();
1164 pendingSubtodo = 0; 1170 pendingSubtodo = 0;
1165 emit reparentTodoSignal( newParent,newSub ); 1171 emit reparentTodoSignal( newParent,newSub );
1166 return; 1172 return;
1167 } 1173 }
1168 } 1174 }
1169 1175
1170} 1176}
1171 1177
1172void KOTodoView::setDocumentId( const QString &id ) 1178void KOTodoView::setDocumentId( const QString &id )
1173{ 1179{
1174 1180
1175 mDocPrefs->setDoc( id ); 1181 mDocPrefs->setDoc( id );
1176} 1182}
1177 1183
1178void KOTodoView::itemStateChanged( QListViewItem *item ) 1184void KOTodoView::itemStateChanged( QListViewItem *item )
1179{ 1185{
1180 if (!item) return; 1186 if (!item) return;
1181 1187
1182 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1188 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1183 1189
1184// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1190// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1185 1191
1186 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1192 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1187} 1193}
1188 1194
1189void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1195void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1190{ 1196{
1191 mTodoListView->saveLayout(config,group); 1197 mTodoListView->saveLayout(config,group);
1192} 1198}
1193 1199
1194void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1200void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1195{ 1201{
1196 mTodoListView->restoreLayout(config,group); 1202 mTodoListView->restoreLayout(config,group);
1197} 1203}
1198 1204
1199void KOTodoView::processSelectionChange() 1205void KOTodoView::processSelectionChange()
1200{ 1206{
1201// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1207// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1202 1208
1203 KOTodoViewItem *item = 1209 KOTodoViewItem *item =
1204 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1210 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1205 1211
1206 if ( !item ) { 1212 if ( !item ) {
1207 emit incidenceSelected( 0 ); 1213 emit incidenceSelected( 0 );
1208 } else { 1214 } else {
1209 emit incidenceSelected( item->todo() ); 1215 emit incidenceSelected( item->todo() );
1210 } 1216 }
1211} 1217}
1212 1218
1213void KOTodoView::modified(bool b) 1219void KOTodoView::modified(bool b)
1214{ 1220{
1215 emit isModified(b); 1221 emit isModified(b);
1216} 1222}
1217void KOTodoView::setTodoModified( Todo* todo ) 1223void KOTodoView::setTodoModified( Todo* todo )
1218{ 1224{
1219 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1225 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1220} 1226}
1221void KOTodoView::clearSelection() 1227void KOTodoView::clearSelection()
1222{ 1228{
1223 mTodoListView->selectAll( false ); 1229 mTodoListView->selectAll( false );
1224} 1230}
1225void KOTodoView::setAllOpen() 1231void KOTodoView::setAllOpen()
1226{ 1232{
1227 if ( isFlatDisplay ) { 1233 if ( isFlatDisplay ) {
1228 isFlatDisplay = false; 1234 isFlatDisplay = false;
1229 mPopupMenu->setItemChecked( 8,false ); 1235 mPopupMenu->setItemChecked( 8,false );
1230 updateView(); 1236 updateView();
1231 } else { 1237 } else {
1232 storeCurrentItem(); 1238 storeCurrentItem();
1233 } 1239 }
1234 setOpen(mTodoListView->firstChild(), true); 1240 setOpen(mTodoListView->firstChild(), true);
1235 resetCurrentItem(); 1241 resetCurrentItem();
1236} 1242}
1237void KOTodoView::setAllClose() 1243void KOTodoView::setAllClose()
1238{ 1244{
1239 if ( isFlatDisplay ) { 1245 if ( isFlatDisplay ) {
1240 isFlatDisplay = false; 1246 isFlatDisplay = false;
1241 mPopupMenu->setItemChecked( 8,false ); 1247 mPopupMenu->setItemChecked( 8,false );
1242 updateView(); 1248 updateView();
1243 } else { 1249 } else {
1244 storeCurrentItem(); 1250 storeCurrentItem();
1245 } 1251 }
1246 setOpen(mTodoListView->firstChild(), false); 1252 setOpen(mTodoListView->firstChild(), false);
1247 resetCurrentItem(); 1253 resetCurrentItem();
1248} 1254}
1249void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1255void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1250{ 1256{
1251 1257
1252 while ( item ) { 1258 while ( item ) {
1253 setOpen( item->firstChild(), setOpenI ); 1259 setOpen( item->firstChild(), setOpenI );
1254 item->setOpen( setOpenI ); 1260 item->setOpen( setOpenI );
1255 item = item->nextSibling(); 1261 item = item->nextSibling();
1256 } 1262 }
1257} 1263}
1258 1264
1259void KOTodoView::displayAllFlat() 1265void KOTodoView::displayAllFlat()
1260{ 1266{
1261 pendingSubtodo = 0; 1267 pendingSubtodo = 0;
1262 if ( mBlockUpdate ) { 1268 if ( mBlockUpdate ) {
1263 return; 1269 return;
1264 } 1270 }
1265 mPopupMenu->setItemChecked( 8,true ); 1271 mPopupMenu->setItemChecked( 8,true );
1266 isFlatDisplay = true; 1272 isFlatDisplay = true;
1267 QPtrList<Todo> todoList = calendar()->todos(); 1273 QPtrList<Todo> todoList = calendar()->todos();
1268 mTodoMap.clear(); 1274 mTodoMap.clear();
1269 mTodoListView->clear(); 1275 mTodoListView->clear();
1270 Todo *todo; 1276 Todo *todo;
1271 for(todo = todoList.first(); todo; todo = todoList.next()) { 1277 for(todo = todoList.first(); todo; todo = todoList.next()) {
1272 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1278 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1273 mTodoMap.insert(todo,todoItem); 1279 mTodoMap.insert(todo,todoItem);
1274 } 1280 }
1275 mTodoListView->setFocus(); 1281 mTodoListView->setFocus();
1276 processSelectionChange(); 1282 processSelectionChange();
1277} 1283}
1278 1284
1279void KOTodoView::setAllFlat() 1285void KOTodoView::setAllFlat()
1280{ 1286{
1281 if ( isFlatDisplay ) { 1287 if ( isFlatDisplay ) {
1282 isFlatDisplay = false; 1288 isFlatDisplay = false;
1283 mPopupMenu->setItemChecked( 8,false ); 1289 mPopupMenu->setItemChecked( 8,false );
1284 updateView(); 1290 updateView();
1285 return; 1291 return;
1286 } 1292 }
1287 storeCurrentItem(); 1293 storeCurrentItem();
1288 displayAllFlat(); 1294 displayAllFlat();
1289 resetCurrentItem(); 1295 resetCurrentItem();
1290} 1296}
1291 1297
1292void KOTodoView::purgeCompleted() 1298void KOTodoView::purgeCompleted()
1293{ 1299{
1294 emit purgeCompletedSignal(); 1300 emit purgeCompletedSignal();
1295 1301
1296} 1302}
1297void KOTodoView::toggleQuickTodo() 1303void KOTodoView::toggleQuickTodo()
1298{ 1304{
1299 if ( mQuickAdd->isVisible() ) { 1305 if ( mQuickAdd->isVisible() ) {
1300 mQuickAdd->hide(); 1306 mQuickAdd->hide();
1301 KOPrefs::instance()->mEnableQuickTodo = false; 1307 KOPrefs::instance()->mEnableQuickTodo = false;
1302 } 1308 }
1303 else { 1309 else {
1304 mQuickAdd->show(); 1310 mQuickAdd->show();
1305 KOPrefs::instance()->mEnableQuickTodo = true; 1311 KOPrefs::instance()->mEnableQuickTodo = true;
1306 } 1312 }
1307 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1313 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1308 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1314 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1309} 1315}
1310 1316
1311void KOTodoView::toggleRunning() 1317void KOTodoView::toggleRunning()
1312{ 1318{
1313 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1319 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1314 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1320 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1315 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1321 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1316 updateView(); 1322 updateView();
1317} 1323}
1318 1324
1319void KOTodoView::toggleCompleted() 1325void KOTodoView::toggleCompleted()
1320{ 1326{
1321 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1327 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1322 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1328 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1323 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1329 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1324 updateView(); 1330 updateView();
1325} 1331}
1326 1332
1327void KOTodoView::addQuickTodo() 1333void KOTodoView::addQuickTodo()
1328{ 1334{
1329 Todo *todo = new Todo(); 1335 Todo *todo = new Todo();
1330 todo->setSummary(mQuickAdd->text()); 1336 todo->setSummary(mQuickAdd->text());
1331 todo->setOrganizer(KOPrefs::instance()->email()); 1337 todo->setOrganizer(KOPrefs::instance()->email());
1332 CalFilter * cf = mCalendar->filter(); 1338 CalFilter * cf = mCalendar->filter();
1333 if ( cf ) { 1339 if ( cf ) {
1334 if ( cf->isEnabled()&& cf->showCategories()) { 1340 if ( cf->isEnabled()&& cf->showCategories()) {
1335 todo->setCategories(cf->categoryList()); 1341 todo->setCategories(cf->categoryList());
1336 } 1342 }
1337 if ( cf->isEnabled() ) 1343 if ( cf->isEnabled() )
1338 todo->setSecrecy( cf->getSecrecy()); 1344 todo->setSecrecy( cf->getSecrecy());
1339 } 1345 }
1340 mCalendar->addTodo(todo); 1346 mCalendar->addTodo(todo);
1341 mQuickAdd->setText(""); 1347 mQuickAdd->setText("");
1342 todoModified (todo, KOGlobals::EVENTADDED ); 1348 todoModified (todo, KOGlobals::EVENTADDED );
1343 updateView(); 1349 updateView();
1344} 1350}
1345 1351
1346void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1352void KOTodoView::keyPressEvent ( QKeyEvent * e )
1347{ 1353{
1348 // e->ignore(); 1354 // e->ignore();
1349 //return; 1355 //return;
1350 //qDebug("KOTodoView::keyPressEvent "); 1356 //qDebug("KOTodoView::keyPressEvent ");
1351 switch ( e->key() ) { 1357 switch ( e->key() ) {
1352 case Qt::Key_Down: 1358 case Qt::Key_Down:
1353 case Qt::Key_Up: 1359 case Qt::Key_Up:
1354 QWidget::keyPressEvent ( e ); 1360 QWidget::keyPressEvent ( e );
1355 break; 1361 break;
1356 1362
1357 case Qt::Key_Q: 1363 case Qt::Key_Q:
1358 toggleQuickTodo(); 1364 toggleQuickTodo();
1359 break; 1365 break;
1360 case Qt::Key_U: 1366 case Qt::Key_U:
1361 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1367 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1362 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1368 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1363 unparentTodo(); 1369 unparentTodo();
1364 e->accept(); 1370 e->accept();
1365 } else 1371 } else
1366 e->ignore(); 1372 e->ignore();
1367 break; 1373 break;
1368 case Qt::Key_S: 1374 case Qt::Key_S:
1369 if ( e->state() == Qt::ControlButton ) { 1375 if ( e->state() == Qt::ControlButton ) {
1370 e->ignore(); 1376 e->ignore();
1371 break; 1377 break;
1372 } 1378 }
1373 if ( e->state() == Qt::ShiftButton ) { 1379 if ( e->state() == Qt::ShiftButton ) {
1374 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1380 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1375 reparentTodo(); 1381 reparentTodo();
1376 e->accept(); 1382 e->accept();
1377 } else 1383 } else
1378 e->ignore(); 1384 e->ignore();
1379 break; 1385 break;
1380 case Qt::Key_P: 1386 case Qt::Key_P:
1381 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1387 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1382 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1388 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1383 if ( pendingSubtodo ) 1389 if ( pendingSubtodo )
1384 itemClicked(mActiveItem); 1390 itemClicked(mActiveItem);
1385 e->accept(); 1391 e->accept();
1386 } else 1392 } else
1387 e->ignore(); 1393 e->ignore();
1388 break; 1394 break;
1389 case Qt::Key_Escape: 1395 case Qt::Key_Escape:
1390 if ( pendingSubtodo ) { 1396 if ( pendingSubtodo ) {
1391 itemClicked(0); 1397 itemClicked(0);
1392 e->accept(); 1398 e->accept();
1393 } else 1399 } else
1394 e->ignore(); 1400 e->ignore();
1395 break; 1401 break;
1396 default: 1402 default:
1397 e->ignore(); 1403 e->ignore();
1398 } 1404 }
1399 1405
1400 if ( true ) { 1406 if ( true ) {
1401 if ( e->key() == Qt::Key_I ) { 1407 if ( e->key() == Qt::Key_I ) {
1402 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1408 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1403 if ( cn ) { 1409 if ( cn ) {
1404 mActiveItem = cn; 1410 mActiveItem = cn;
1405 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1411 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1406 if ( ci ){ 1412 if ( ci ){
1407 showTodo(); 1413 showTodo();
1408 cn = (KOTodoViewItem*)cn->itemBelow(); 1414 cn = (KOTodoViewItem*)cn->itemBelow();
1409 if ( cn ) { 1415 if ( cn ) {
1410 mTodoListView->setCurrentItem ( cn ); 1416 mTodoListView->setCurrentItem ( cn );
1411 mTodoListView->ensureItemVisible ( cn ); 1417 mTodoListView->ensureItemVisible ( cn );
1412 } 1418 }
1413 1419
1414 } 1420 }
1415 } 1421 }
1416 e->accept(); 1422 e->accept();
1417 1423
1418 } 1424 }
1419 1425
1420 } 1426 }
1421 1427
1422} 1428}
1423void KOTodoView::updateTodo( Todo * t, int type ) 1429void KOTodoView::updateTodo( Todo * t, int type )
1424{ 1430{
1425 if ( mBlockUpdate) 1431 if ( mBlockUpdate)
1426 return; 1432 return;
1427 1433
1428 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1434 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1429 itemIterator = mTodoMap.find(t); 1435 itemIterator = mTodoMap.find(t);
1430 if (itemIterator != mTodoMap.end()) { 1436 if (itemIterator != mTodoMap.end()) {
1431 (*itemIterator)->construct(); 1437 (*itemIterator)->construct();
1432 } else { 1438 } else {
1433 if ( type == KOGlobals::EVENTADDED ) { 1439 if ( type == KOGlobals::EVENTADDED ) {
1434 insertTodoItem( t ); 1440 insertTodoItem( t );
1435 } 1441 }
1436 } 1442 }
1437 1443
1438} 1444}
1439 1445
1440void KOTodoView::todoModified(Todo * t , int p ) 1446void KOTodoView::todoModified(Todo * t , int p )
1441{ 1447{
1442 mBlockUpdate = true; 1448 mBlockUpdate = true;
1443 emit todoModifiedSignal ( t, p ); 1449 emit todoModifiedSignal ( t, p );
1444 mBlockUpdate = false; 1450 mBlockUpdate = false;
1445} 1451}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 87cef20..68e5e5a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2453 +1,2459 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131int globalFlagBlockStartup; 131int globalFlagBlockStartup;
132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
133 QMainWindow( parent, name ) 133 QMainWindow( parent, name )
134{ 134{
135 135
136 mClosed = false; 136 mClosed = false;
137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
138 QString confFile = locateLocal("config","korganizerrc"); 138 QString confFile = locateLocal("config","korganizerrc");
139 QFileInfo finf ( confFile ); 139 QFileInfo finf ( confFile );
140 bool showWarning = !finf.exists(); 140 bool showWarning = !finf.exists();
141 setIcon(SmallIcon( "ko24" ) ); 141 setIcon(SmallIcon( "ko24" ) );
142 mBlockAtStartup = true; 142 mBlockAtStartup = true;
143 mFlagKeyPressed = false; 143 mFlagKeyPressed = false;
144 setCaption("KO/Pi"); 144 setCaption("KO/Pi");
145 KOPrefs *p = KOPrefs::instance(); 145 KOPrefs *p = KOPrefs::instance();
146 KPimGlobalPrefs::instance()->setGlobalConfig(); 146 KPimGlobalPrefs::instance()->setGlobalConfig();
147 p->mCurrentDisplayedView = 0; 147 p->mCurrentDisplayedView = 0;
148 if ( p->mHourSize > 22 ) 148 if ( p->mHourSize > 22 )
149 p->mHourSize = 22; 149 p->mHourSize = 22;
150 QMainWindow::ToolBarDock tbd; 150 QMainWindow::ToolBarDock tbd;
151 if ( p->mToolBarHor ) { 151 if ( p->mToolBarHor ) {
152 if ( p->mToolBarUp ) 152 if ( p->mToolBarUp )
153 tbd = Bottom; 153 tbd = Bottom;
154 else 154 else
155 tbd = Top; 155 tbd = Top;
156 } 156 }
157 else { 157 else {
158 if ( p->mToolBarUp ) 158 if ( p->mToolBarUp )
159 tbd = Right; 159 tbd = Right;
160 else 160 else
161 tbd = Left; 161 tbd = Left;
162 } 162 }
163 if ( KOPrefs::instance()->mUseAppColors ) 163 if ( KOPrefs::instance()->mUseAppColors )
164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
165 globalFlagBlockStartup = 1; 165 globalFlagBlockStartup = 1;
166 iconToolBar = new QPEToolBar( this ); 166 iconToolBar = new QPEToolBar( this );
167 addToolBar (iconToolBar , tbd ); 167 addToolBar (iconToolBar , tbd );
168 168
169#ifdef DESKTOP_VERSION 169#ifdef DESKTOP_VERSION
170 if ( KOPrefs::instance()->mShowIconFilter ) 170 if ( KOPrefs::instance()->mShowIconFilter )
171#else 171#else
172 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 172 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
173#endif 173#endif
174 174
175{ 175{
176 if ( p->mToolBarHorF ) { 176 if ( p->mToolBarHorF ) {
177 if ( p->mToolBarUpF ) 177 if ( p->mToolBarUpF )
178 tbd = Bottom; 178 tbd = Bottom;
179 else 179 else
180 tbd = Top; 180 tbd = Top;
181 } 181 }
182 else { 182 else {
183 if ( p->mToolBarUpF ) 183 if ( p->mToolBarUpF )
184 tbd = Right; 184 tbd = Right;
185 else 185 else
186 tbd = Left; 186 tbd = Left;
187 } 187 }
188 filterToolBar = new QPEToolBar ( this ); 188 filterToolBar = new QPEToolBar ( this );
189 filterMenubar = new QMenuBar( filterToolBar ); 189 filterMenubar = new QMenuBar( filterToolBar );
190 QFontMetrics fm ( filterMenubar->font() ); 190 QFontMetrics fm ( filterMenubar->font() );
191 191
192 filterPopupMenu = new QPopupMenu( this ); 192 filterPopupMenu = new QPopupMenu( this );
193 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 193 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
194 QString addTest = "A"; 194 QString addTest = "A";
195 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 195 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
196#ifdef DESKTOP_VERSION 196#ifdef DESKTOP_VERSION
197 addTest = "AAABBBCCCx"; 197 addTest = "AAABBBCCCx";
198#else 198#else
199 addTest = "AAx"; 199 addTest = "AAx";
200#endif 200#endif
201 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 201 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
202 addToolBar (filterToolBar , tbd ); 202 addToolBar (filterToolBar , tbd );
203 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 203 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
204 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 204 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
205 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 205 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
206 filterToolBar->hide(); 206 filterToolBar->hide();
207 } else { 207 } else {
208 filterToolBar = 0; 208 filterToolBar = 0;
209 filterMenubar = 0; 209 filterMenubar = 0;
210 filterPopupMenu = 0; 210 filterPopupMenu = 0;
211 } 211 }
212 if ( p->mShowIconOnetoolbar ) { 212 if ( p->mShowIconOnetoolbar ) {
213 viewToolBar = iconToolBar ; 213 viewToolBar = iconToolBar ;
214 navigatorToolBar = iconToolBar ; 214 navigatorToolBar = iconToolBar ;
215 } else { 215 } else {
216#ifndef DESKTOP_VERSION 216#ifndef DESKTOP_VERSION
217 setToolBarsMovable( false ); 217 setToolBarsMovable( false );
218#endif 218#endif
219 if ( p->mToolBarHorV ) { 219 if ( p->mToolBarHorV ) {
220 if ( p->mToolBarUpV ) 220 if ( p->mToolBarUpV )
221 tbd = Bottom; 221 tbd = Bottom;
222 else 222 else
223 tbd = Top; 223 tbd = Top;
224 } 224 }
225 else { 225 else {
226 if ( p->mToolBarUpV ) 226 if ( p->mToolBarUpV )
227 tbd = Right; 227 tbd = Right;
228 else 228 else
229 tbd = Left; 229 tbd = Left;
230 } 230 }
231 viewToolBar = new QPEToolBar( this ); 231 viewToolBar = new QPEToolBar( this );
232 addToolBar (viewToolBar , tbd ); 232 addToolBar (viewToolBar , tbd );
233 if ( p->mToolBarHorN ) { 233 if ( p->mToolBarHorN ) {
234 if ( p->mToolBarUpN ) 234 if ( p->mToolBarUpN )
235 tbd = Bottom; 235 tbd = Bottom;
236 else 236 else
237 tbd = Top; 237 tbd = Top;
238 } 238 }
239 else { 239 else {
240 if ( p->mToolBarUpN ) 240 if ( p->mToolBarUpN )
241 tbd = Right; 241 tbd = Right;
242 else 242 else
243 tbd = Left; 243 tbd = Left;
244 } 244 }
245 navigatorToolBar = new QPEToolBar( this ); 245 navigatorToolBar = new QPEToolBar( this );
246 addToolBar (navigatorToolBar , tbd ); 246 addToolBar (navigatorToolBar , tbd );
247 } 247 }
248 248
249 249
250 250
251 mCalendarModifiedFlag = false; 251 mCalendarModifiedFlag = false;
252 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 252 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
253 splash->setAlignment ( AlignCenter ); 253 splash->setAlignment ( AlignCenter );
254 setCentralWidget( splash ); 254 setCentralWidget( splash );
255#ifndef DESKTOP_VERSION 255#ifndef DESKTOP_VERSION
256 showMaximized(); 256 showMaximized();
257#endif 257#endif
258 258
259 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 259 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
260 setDefaultPreferences(); 260 setDefaultPreferences();
261 mCalendar = new CalendarLocal(); 261 mCalendar = new CalendarLocal();
262 mView = new CalendarView( mCalendar, this,"mCalendar " ); 262 mView = new CalendarView( mCalendar, this,"mCalendar " );
263 mView->hide(); 263 mView->hide();
264 //mView->resize(splash->size() ); 264 //mView->resize(splash->size() );
265 initActions(); 265 initActions();
266 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 266 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
267 mSyncManager->setBlockSave(false); 267 mSyncManager->setBlockSave(false);
268 mView->setSyncManager(mSyncManager); 268 mView->setSyncManager(mSyncManager);
269#ifndef DESKTOP_VERSION 269#ifndef DESKTOP_VERSION
270 iconToolBar->show(); 270 iconToolBar->show();
271 qApp->processEvents(); 271 qApp->processEvents();
272#endif 272#endif
273 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 273 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
274 int vh = height() ; 274 int vh = height() ;
275 int vw = width(); 275 int vw = width();
276 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 276 //qDebug("Toolbar hei %d ",iconToolBar->height() );
277 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 277 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
278 vh -= iconToolBar->height(); 278 vh -= iconToolBar->height();
279 } else { 279 } else {
280 vw -= iconToolBar->height(); 280 vw -= iconToolBar->height();
281 } 281 }
282 //mView->setMaximumSize( splash->size() ); 282 //mView->setMaximumSize( splash->size() );
283 //mView->resize( splash->size() ); 283 //mView->resize( splash->size() );
284 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 284 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
285 mView->readSettings(); 285 mView->readSettings();
286 bool newFile = false; 286 bool newFile = false;
287 if( !QFile::exists( defaultFileName() ) ) { 287 if( !QFile::exists( defaultFileName() ) ) {
288 QFileInfo finfo ( defaultFileName() ); 288 QFileInfo finfo ( defaultFileName() );
289 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 289 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
290 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 290 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
291 finfo.setFile( oldFile ); 291 finfo.setFile( oldFile );
292 if (finfo.exists() ) { 292 if (finfo.exists() ) {
293 KMessageBox::information( this, message); 293 KMessageBox::information( this, message);
294 mView->openCalendar( oldFile ); 294 mView->openCalendar( oldFile );
295 qApp->processEvents(); 295 qApp->processEvents();
296 } else { 296 } else {
297 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 297 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
298 finfo.setFile( oldFile ); 298 finfo.setFile( oldFile );
299 if (finfo.exists() ) { 299 if (finfo.exists() ) {
300 KMessageBox::information( this, message); 300 KMessageBox::information( this, message);
301 mView->openCalendar( oldFile ); 301 mView->openCalendar( oldFile );
302 qApp->processEvents(); 302 qApp->processEvents();
303 } 303 }
304 } 304 }
305 mView->saveCalendar( defaultFileName() ); 305 mView->saveCalendar( defaultFileName() );
306 newFile = true; 306 newFile = true;
307 } 307 }
308 308
309 QTime neededSaveTime = QDateTime::currentDateTime().time(); 309 QTime neededSaveTime = QDateTime::currentDateTime().time();
310 mView->openCalendar( defaultFileName() ); 310 mView->openCalendar( defaultFileName() );
311 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 311 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
312 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 312 qDebug("KO: Calendar loading time: %d ms",msNeeded );
313 313
314 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 314 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
315 KOPrefs::instance()->setAllDefaults(); 315 KOPrefs::instance()->setAllDefaults();
316 int count = mView->addCategories(); 316 int count = mView->addCategories();
317 } 317 }
318 processIncidenceSelection( 0 ); 318 processIncidenceSelection( 0 );
319 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 319 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
320 SLOT( processIncidenceSelection( Incidence * ) ) ); 320 SLOT( processIncidenceSelection( Incidence * ) ) );
321 connect( mView, SIGNAL( modifiedChanged( bool ) ), 321 connect( mView, SIGNAL( modifiedChanged( bool ) ),
322 SLOT( slotModifiedChanged( bool ) ) ); 322 SLOT( slotModifiedChanged( bool ) ) );
323 323
324 324
325 connect( mView, SIGNAL( tempDisableBR(bool) ), 325 connect( mView, SIGNAL( tempDisableBR(bool) ),
326 SLOT( disableBR(bool) ) ); 326 SLOT( disableBR(bool) ) );
327 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 327 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
328 mView->setModified( false ); 328 mView->setModified( false );
329 mBlockAtStartup = false; 329 mBlockAtStartup = false;
330 mView->setModified( false ); 330 mView->setModified( false );
331 setCentralWidget( mView ); 331 setCentralWidget( mView );
332 globalFlagBlockStartup = 0; 332 globalFlagBlockStartup = 0;
333 mView->show(); 333 mView->show();
334 delete splash; 334 delete splash;
335 if ( newFile ) 335 if ( newFile )
336 mView->updateConfig(); 336 mView->updateConfig();
337 // qApp->processEvents(); 337 // qApp->processEvents();
338 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 338 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
339 //fillSyncMenu(); 339 //fillSyncMenu();
340 340
341 341
342 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 342 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
343 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 343 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
344 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 344 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
345 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 345 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
346 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 346 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
347 mSyncManager->setDefaultFileName( sentSyncFile()); 347 mSyncManager->setDefaultFileName( sentSyncFile());
348 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 348 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
349 mSyncManager->fillSyncMenu(); 349 mSyncManager->fillSyncMenu();
350 350
351 351
352 352
353 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 353 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
354 if ( showWarning ) { 354 if ( showWarning ) {
355 KMessageBox::information( this, 355 KMessageBox::information( this,
356 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 356 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
357 qApp->processEvents(); 357 qApp->processEvents();
358 mView->dialogManager()->showSyncOptions(); 358 mView->dialogManager()->showSyncOptions();
359 } 359 }
360 360
361 //US listen for result adressed from Ka/Pi 361 //US listen for result adressed from Ka/Pi
362#ifndef DESKTOP_VERSION 362#ifndef DESKTOP_VERSION
363 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 363 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
364#endif 364#endif
365#ifndef DESKTOP_VERSION 365#ifndef DESKTOP_VERSION
366 infrared = 0; 366 infrared = 0;
367#endif 367#endif
368 updateFilterToolbar(); 368 updateFilterToolbar();
369 updateWeek( mView->startDate() ); 369 updateWeek( mView->startDate() );
370 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 370 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
371 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 371 SLOT( updateWeekNum( const KCal::DateList & ) ) );
372 mBRdisabled = false; 372 mBRdisabled = false;
373 //toggleBeamReceive(); 373 //toggleBeamReceive();
374} 374}
375MainWindow::~MainWindow() 375MainWindow::~MainWindow()
376{ 376{
377 //qDebug("MainWindow::~MainWindow() "); 377 //qDebug("MainWindow::~MainWindow() ");
378 //save toolbar location 378 //save toolbar location
379 delete mCalendar; 379 delete mCalendar;
380 delete mSyncManager; 380 delete mSyncManager;
381#ifndef DESKTOP_VERSION 381#ifndef DESKTOP_VERSION
382 if ( infrared ) 382 if ( infrared )
383 delete infrared; 383 delete infrared;
384#endif 384#endif
385 385
386 386
387} 387}
388 388
389void MainWindow::disableBR(bool b) 389void MainWindow::disableBR(bool b)
390{ 390{
391#ifndef DESKTOP_VERSION 391#ifndef DESKTOP_VERSION
392 if ( b ) { 392 if ( b ) {
393 if ( infrared ) { 393 if ( infrared ) {
394 toggleBeamReceive(); 394 toggleBeamReceive();
395 mBRdisabled = true; 395 mBRdisabled = true;
396 } 396 }
397 mBRdisabled = true; 397 mBRdisabled = true;
398 } else { 398 } else {
399 if ( mBRdisabled ) { 399 if ( mBRdisabled ) {
400 mBRdisabled = false; 400 mBRdisabled = false;
401 //makes no sense,because other cal ap is probably running 401 //makes no sense,because other cal ap is probably running
402 // toggleBeamReceive(); 402 // toggleBeamReceive();
403 } 403 }
404 } 404 }
405#endif 405#endif
406 406
407} 407}
408bool MainWindow::beamReceiveEnabled() 408bool MainWindow::beamReceiveEnabled()
409{ 409{
410#ifndef DESKTOP_VERSION 410#ifndef DESKTOP_VERSION
411 return ( infrared != 0 ); 411 return ( infrared != 0 );
412#endif 412#endif
413 return false; 413 return false;
414} 414}
415 415
416void MainWindow::toggleBeamReceive() 416void MainWindow::toggleBeamReceive()
417{ 417{
418 if ( mBRdisabled ) 418 if ( mBRdisabled )
419 return; 419 return;
420#ifndef DESKTOP_VERSION 420#ifndef DESKTOP_VERSION
421 if ( infrared ) { 421 if ( infrared ) {
422 qDebug("KO: Disable BeamReceive "); 422 qDebug("KO: Disable BeamReceive ");
423 delete infrared; 423 delete infrared;
424 infrared = 0; 424 infrared = 0;
425 brAction->setOn(false); 425 brAction->setOn(false);
426 return; 426 return;
427 } 427 }
428 qDebug("KO: Enable BeamReceive "); 428 qDebug("KO: Enable BeamReceive ");
429 brAction->setOn(true); 429 brAction->setOn(true);
430 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 430 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
431 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 431 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
432#endif 432#endif
433} 433}
434void MainWindow::showMaximized () 434void MainWindow::showMaximized ()
435{ 435{
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 if ( ! globalFlagBlockStartup ) 437 if ( ! globalFlagBlockStartup )
438 if ( mClosed ) 438 if ( mClosed )
439 mView->goToday(); 439 mView->goToday();
440#endif 440#endif
441 QWidget::showMaximized () ; 441 QWidget::showMaximized () ;
442 mClosed = false; 442 mClosed = false;
443} 443}
444void MainWindow::closeEvent( QCloseEvent* ce ) 444void MainWindow::closeEvent( QCloseEvent* ce )
445{ 445{
446 446
447 447
448 448
449 if ( ! KOPrefs::instance()->mAskForQuit ) { 449 if ( ! KOPrefs::instance()->mAskForQuit ) {
450 saveOnClose(); 450 saveOnClose();
451 mClosed = true; 451 mClosed = true;
452 ce->accept(); 452 ce->accept();
453 return; 453 return;
454 454
455 } 455 }
456 456
457 switch( QMessageBox::information( this, "KO/Pi", 457 switch( QMessageBox::information( this, "KO/Pi",
458 i18n("Do you really want\nto close KO/Pi?"), 458 i18n("Do you really want\nto close KO/Pi?"),
459 i18n("Close"), i18n("No"), 459 i18n("Close"), i18n("No"),
460 0, 0 ) ) { 460 0, 0 ) ) {
461 case 0: 461 case 0:
462 saveOnClose(); 462 saveOnClose();
463 mClosed = true; 463 mClosed = true;
464 ce->accept(); 464 ce->accept();
465 break; 465 break;
466 case 1: 466 case 1:
467 ce->ignore(); 467 ce->ignore();
468 break; 468 break;
469 case 2: 469 case 2:
470 470
471 default: 471 default:
472 break; 472 break;
473 } 473 }
474 474
475 475
476} 476}
477 477
478void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 478void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
479{ 479{
480 QDataStream stream( data, IO_ReadOnly ); 480 QDataStream stream( data, IO_ReadOnly );
481 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 481 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
482 //QString datamess; 482 //QString datamess;
483 //qDebug("message "); 483 //qDebug("message ");
484 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 484 qDebug("KO: QCOP message received: %s ", cmsg.data() );
485 485
486 if ( cmsg == "setDocument(QString)" ) { 486 if ( cmsg == "setDocument(QString)" ) {
487 QDataStream stream( data, IO_ReadOnly ); 487 QDataStream stream( data, IO_ReadOnly );
488 QString fileName; 488 QString fileName;
489 stream >> fileName; 489 stream >> fileName;
490 //qDebug("filename %s ", fileName.latin1()); 490 //qDebug("filename %s ", fileName.latin1());
491 showMaximized(); 491 showMaximized();
492 raise(); 492 raise();
493 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 493 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
494 mSyncManager->slotSyncMenu( 1002 ); 494 mSyncManager->slotSyncMenu( 1002 );
495 return; 495 return;
496 } 496 }
497 497
498 if ( cmsg == "-writeFile" ) { 498 if ( cmsg == "-writeFile" ) {
499 // I made from the "-writeFile" an "-writeAlarm" 499 // I made from the "-writeFile" an "-writeAlarm"
500 mView->viewManager()->showWhatsNextView(); 500 mView->viewManager()->showWhatsNextView();
501 mCalendar->checkAlarmForIncidence( 0, true); 501 mCalendar->checkAlarmForIncidence( 0, true);
502 showMaximized(); 502 showMaximized();
503 raise(); 503 raise();
504 return; 504 return;
505 505
506 } 506 }
507 if ( cmsg == "-writeFileSilent" ) { 507 if ( cmsg == "-writeFileSilent" ) {
508 // I made from the "-writeFile" an "-writeAlarm" 508 // I made from the "-writeFile" an "-writeAlarm"
509 // mView->viewManager()->showWhatsNextView(); 509 // mView->viewManager()->showWhatsNextView();
510 mCalendar->checkAlarmForIncidence( 0, true); 510 mCalendar->checkAlarmForIncidence( 0, true);
511 //showMaximized(); 511 //showMaximized();
512 //raise(); 512 //raise();
513 hide(); 513 hide();
514 return; 514 return;
515 } 515 }
516 if ( cmsg == "-newCountdown" ) { 516 if ( cmsg == "-newCountdown" ) {
517 qDebug("newCountdown "); 517 qDebug("newCountdown ");
518 518
519 } 519 }
520 QString msg ; 520 QString msg ;
521 QString allmsg = cmsg; 521 QString allmsg = cmsg;
522 while ( allmsg.length() > 0 ) { 522 while ( allmsg.length() > 0 ) {
523 int nextC = allmsg.find( "-", 1 ); 523 int nextC = allmsg.find( "-", 1 );
524 if ( nextC == -1 ) { 524 if ( nextC == -1 ) {
525 msg = allmsg; 525 msg = allmsg;
526 allmsg = ""; 526 allmsg = "";
527 } else{ 527 } else{
528 msg = allmsg.left( nextC ); 528 msg = allmsg.left( nextC );
529 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 529 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
530 } 530 }
531 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 531 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
532 if ( msg == "-newEvent" ) { 532 if ( msg == "-newEvent" ) {
533 mView->newEvent(); 533 mView->newEvent();
534 } 534 }
535 if ( msg == "-newTodo" ) { 535 if ( msg == "-newTodo" ) {
536 mView->newTodo(); 536 mView->newTodo();
537 537
538 } 538 }
539 if ( msg == "-showWN" ) { 539 if ( msg == "-showWN" ) {
540 mView->viewManager()->showWhatsNextView(); 540 mView->viewManager()->showWhatsNextView();
541 } 541 }
542 if ( msg == "-showTodo" ) { 542 if ( msg == "-showTodo" ) {
543 mView->viewManager()->showTodoView(); 543 mView->viewManager()->showTodoView();
544 } 544 }
545 if ( msg == "-showList" ) { 545 if ( msg == "-showList" ) {
546 mView->viewManager()->showListView(); 546 mView->viewManager()->showListView();
547 } 547 }
548 else if ( msg == "-showDay" ) { 548 else if ( msg == "-showDay" ) {
549 mView->viewManager()->showDayView(); 549 mView->viewManager()->showDayView();
550 } 550 }
551 else if ( msg == "-showWWeek" ) { 551 else if ( msg == "-showWWeek" ) {
552 mView->viewManager()->showWorkWeekView(); 552 mView->viewManager()->showWorkWeekView();
553 } 553 }
554 else if ( msg == "-ringSync" ) { 554 else if ( msg == "-ringSync" ) {
555 mSyncManager->multiSync( false ); 555 mSyncManager->multiSync( false );
556 } 556 }
557 else if ( msg == "-showWeek" ) { 557 else if ( msg == "-showWeek" ) {
558 mView->viewManager()->showWeekView(); 558 mView->viewManager()->showWeekView();
559 } 559 }
560 else if ( msg == "-showTodo" ) { 560 else if ( msg == "-showTodo" ) {
561 mView->viewManager()->showTodoView(); 561 mView->viewManager()->showTodoView();
562 } 562 }
563 else if ( msg == "-showJournal" ) { 563 else if ( msg == "-showJournal" ) {
564 mView->dateNavigator()->selectDates( 1 ); 564 mView->dateNavigator()->selectDates( 1 );
565 mView->dateNavigator()->selectToday(); 565 mView->dateNavigator()->selectToday();
566 mView->viewManager()->showJournalView(); 566 mView->viewManager()->showJournalView();
567 } 567 }
568 else if ( msg == "-showKO" ) { 568 else if ( msg == "-showKO" ) {
569 mView->viewManager()->showNextXView(); 569 mView->viewManager()->showNextXView();
570 } 570 }
571 else if ( msg == "-showWNext" ) { 571 else if ( msg == "-showWNext" ) {
572 mView->viewManager()->showWhatsNextView(); 572 mView->viewManager()->showWhatsNextView();
573 } 573 }
574 else if ( msg == "nextView()" ) { 574 else if ( msg == "nextView()" ) {
575 mView->viewManager()->showNextView(); 575 mView->viewManager()->showNextView();
576 } 576 }
577 else if ( msg == "-showNextXView" ) { 577 else if ( msg == "-showNextXView" ) {
578 mView->viewManager()->showNextXView(); 578 mView->viewManager()->showNextXView();
579 } 579 }
580 580
581 581
582 } 582 }
583 583
584 showMaximized(); 584 showMaximized();
585 raise(); 585 raise();
586} 586}
587 587
588QPixmap MainWindow::loadPixmap( QString name ) 588QPixmap MainWindow::loadPixmap( QString name )
589{ 589{
590 return SmallIcon( name ); 590 return SmallIcon( name );
591 591
592} 592}
593void MainWindow::setUsesBigPixmaps ( bool b )
594{
595 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
596 if ( b )
597 qDebug("KO: BigPixmaps are not supported ");
598}
593void MainWindow::initActions() 599void MainWindow::initActions()
594{ 600{
595 //KOPrefs::instance()->mShowFullMenu 601 //KOPrefs::instance()->mShowFullMenu
596 iconToolBar->clear(); 602 iconToolBar->clear();
597 KOPrefs *p = KOPrefs::instance(); 603 KOPrefs *p = KOPrefs::instance();
598 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 604 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
599 605
600 QPopupMenu *viewMenu = new QPopupMenu( this ); 606 QPopupMenu *viewMenu = new QPopupMenu( this );
601 QPopupMenu *actionMenu = new QPopupMenu( this ); 607 QPopupMenu *actionMenu = new QPopupMenu( this );
602 QPopupMenu *importMenu = new QPopupMenu( this ); 608 QPopupMenu *importMenu = new QPopupMenu( this );
603 QPopupMenu *importMenu_X = new QPopupMenu( this ); 609 QPopupMenu *importMenu_X = new QPopupMenu( this );
604 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 610 QPopupMenu *exportMenu_X = new QPopupMenu( this );
605 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 611 QPopupMenu *beamMenu_X = new QPopupMenu( this );
606 selectFilterMenu = new QPopupMenu( this ); 612 selectFilterMenu = new QPopupMenu( this );
607 selectFilterMenu->setCheckable( true ); 613 selectFilterMenu->setCheckable( true );
608 syncMenu = new QPopupMenu( this ); 614 syncMenu = new QPopupMenu( this );
609 configureAgendaMenu = new QPopupMenu( this ); 615 configureAgendaMenu = new QPopupMenu( this );
610 configureToolBarMenu = new QPopupMenu( this ); 616 configureToolBarMenu = new QPopupMenu( this );
611 QPopupMenu *helpMenu = new QPopupMenu( this ); 617 QPopupMenu *helpMenu = new QPopupMenu( this );
612 QIconSet icon; 618 QIconSet icon;
613 int pixWid = 22, pixHei = 22; 619 int pixWid = 22, pixHei = 22;
614 QString pathString = ""; 620 QString pathString = "";
615 if ( !p->mToolBarMiniIcons ) { 621 if ( !p->mToolBarMiniIcons ) {
616 if ( QApplication::desktop()->width() < 480 ) { 622 if ( QApplication::desktop()->width() < 480 ) {
617 pathString += "icons16/"; 623 pathString += "icons16/";
618 pixWid = 18; pixHei = 16; 624 pixWid = 18; pixHei = 16;
619 } 625 }
620 } else { 626 } else {
621 pathString += "iconsmini/"; 627 pathString += "iconsmini/";
622 pixWid = 18; pixHei = 16; 628 pixWid = 18; pixHei = 16;
623 } 629 }
624 if ( KOPrefs::instance()->mShowFullMenu ) { 630 if ( KOPrefs::instance()->mShowFullMenu ) {
625 QMenuBar *menuBar1; 631 QMenuBar *menuBar1;
626 menuBar1 = menuBar(); 632 menuBar1 = menuBar();
627 menuBar1->insertItem( i18n("File"), importMenu ); 633 menuBar1->insertItem( i18n("File"), importMenu );
628 menuBar1->insertItem( i18n("View"), viewMenu ); 634 menuBar1->insertItem( i18n("View"), viewMenu );
629 menuBar1->insertItem( i18n("Actions"), actionMenu ); 635 menuBar1->insertItem( i18n("Actions"), actionMenu );
630#ifdef DESKTOP_VERSION 636#ifdef DESKTOP_VERSION
631 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 637 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
632 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 638 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
633#else 639#else
634 menuBar1->insertItem( i18n("Sync"), syncMenu ); 640 menuBar1->insertItem( i18n("Sync"), syncMenu );
635 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 641 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
636#endif 642#endif
637 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 643 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
638 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 644 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
639 menuBar1->insertItem( i18n("Help"), helpMenu ); 645 menuBar1->insertItem( i18n("Help"), helpMenu );
640 } else { 646 } else {
641 QPEMenuBar *menuBar1; 647 QPEMenuBar *menuBar1;
642 menuBar1 = new QPEMenuBar( iconToolBar ); 648 menuBar1 = new QPEMenuBar( iconToolBar );
643 QPopupMenu *menuBar = new QPopupMenu( this ); 649 QPopupMenu *menuBar = new QPopupMenu( this );
644 icon = loadPixmap( pathString + "z_menu" ); 650 icon = loadPixmap( pathString + "z_menu" );
645 menuBar1->insertItem( icon.pixmap(), menuBar); 651 menuBar1->insertItem( icon.pixmap(), menuBar);
646 //menuBar1->insertItem( i18n("ME"), menuBar); 652 //menuBar1->insertItem( i18n("ME"), menuBar);
647 menuBar->insertItem( i18n("File"), importMenu ); 653 menuBar->insertItem( i18n("File"), importMenu );
648 menuBar->insertItem( i18n("View"), viewMenu ); 654 menuBar->insertItem( i18n("View"), viewMenu );
649 menuBar->insertItem( i18n("Actions"), actionMenu ); 655 menuBar->insertItem( i18n("Actions"), actionMenu );
650 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 656 menuBar->insertItem( i18n("Synchronize"), syncMenu );
651 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 657 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
652 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 658 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
653 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 659 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
654 menuBar->insertItem( i18n("Help"), helpMenu ); 660 menuBar->insertItem( i18n("Help"), helpMenu );
655 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 661 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
656 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 662 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
657 } 663 }
658 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 664 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
659 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 665 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
660 666
661 667
662 mWeekBgColor = iconToolBar->backgroundColor(); 668 mWeekBgColor = iconToolBar->backgroundColor();
663 mWeekPixmap.resize( pixWid , pixHei ); 669 mWeekPixmap.resize( pixWid , pixHei );
664 mWeekPixmap.fill( mWeekBgColor ); 670 mWeekPixmap.fill( mWeekBgColor );
665 icon = mWeekPixmap; 671 icon = mWeekPixmap;
666 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 672 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
667 if ( p-> mShowIconWeekNum ) 673 if ( p-> mShowIconWeekNum )
668 mWeekAction->addTo( iconToolBar ); 674 mWeekAction->addTo( iconToolBar );
669 mWeekFont = font(); 675 mWeekFont = font();
670 676
671 int fontPoint = mWeekFont.pointSize(); 677 int fontPoint = mWeekFont.pointSize();
672 QFontMetrics f( mWeekFont ); 678 QFontMetrics f( mWeekFont );
673 int fontWid = f.width( "30" ); 679 int fontWid = f.width( "30" );
674 while ( fontWid > pixWid ) { 680 while ( fontWid > pixWid ) {
675 --fontPoint; 681 --fontPoint;
676 mWeekFont.setPointSize( fontPoint ); 682 mWeekFont.setPointSize( fontPoint );
677 QFontMetrics f( mWeekFont ); 683 QFontMetrics f( mWeekFont );
678 fontWid = f.width( "30" ); 684 fontWid = f.width( "30" );
679 //qDebug("dec-- "); 685 //qDebug("dec-- ");
680 } 686 }
681 687
682 connect( mWeekAction, SIGNAL( activated() ), 688 connect( mWeekAction, SIGNAL( activated() ),
683 this, SLOT( weekAction() ) ); 689 this, SLOT( weekAction() ) );
684 690
685 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 691 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
686 if ( p->mShowIconFilterview ) { 692 if ( p->mShowIconFilterview ) {
687 icon = loadPixmap( pathString + "filter" ); 693 icon = loadPixmap( pathString + "filter" );
688 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 694 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
689 connect( actionFilterMenuTB, SIGNAL( activated() ), 695 connect( actionFilterMenuTB, SIGNAL( activated() ),
690 this, SLOT( fillFilterMenuTB() ) ); 696 this, SLOT( fillFilterMenuTB() ) );
691 actionFilterMenuTB->addTo( iconToolBar ); 697 actionFilterMenuTB->addTo( iconToolBar );
692 selectFilterMenuTB = new QPopupMenu( this ); 698 selectFilterMenuTB = new QPopupMenu( this );
693 selectFilterMenuTB->setCheckable( true ); 699 selectFilterMenuTB->setCheckable( true );
694 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 700 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
695 } 701 }
696 702
697 //#endif 703 //#endif
698 // ****************** 704 // ******************
699 QAction *action; 705 QAction *action;
700 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 706 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
701 configureToolBarMenu->setCheckable( true ); 707 configureToolBarMenu->setCheckable( true );
702 708
703 709
704 configureAgendaMenu->setCheckable( true ); 710 configureAgendaMenu->setCheckable( true );
705 int iii ; 711 int iii ;
706 for ( iii = 1;iii<= 10 ;++iii ){ 712 for ( iii = 1;iii<= 10 ;++iii ){
707 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 713 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
708 } 714 }
709 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 715 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
710 716
711 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 717 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
712 this, SLOT( showConfigureAgenda( ) ) ); 718 this, SLOT( showConfigureAgenda( ) ) );
713 719
714 icon = loadPixmap( pathString + "configure" ); 720 icon = loadPixmap( pathString + "configure" );
715 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 721 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
716 action->addTo( actionMenu ); 722 action->addTo( actionMenu );
717 connect( action, SIGNAL( activated() ), 723 connect( action, SIGNAL( activated() ),
718 mView, SLOT( edit_options() ) ); 724 mView, SLOT( edit_options() ) );
719 actionMenu->insertSeparator(); 725 actionMenu->insertSeparator();
720 726
721 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 727 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
722 action->addTo( actionMenu ); 728 action->addTo( actionMenu );
723 connect( action, SIGNAL( activated() ), 729 connect( action, SIGNAL( activated() ),
724 mView, SLOT( undo_delete() ) ); 730 mView, SLOT( undo_delete() ) );
725 actionMenu->insertSeparator(); 731 actionMenu->insertSeparator();
726 732
727 icon = loadPixmap( pathString + "newevent" ); 733 icon = loadPixmap( pathString + "newevent" );
728 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 734 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
729 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 735 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
730 configureToolBarMenu->insertSeparator(); 736 configureToolBarMenu->insertSeparator();
731 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 737 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
732 configureToolBarMenu->insertSeparator(); 738 configureToolBarMenu->insertSeparator();
733 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 739 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
734 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 740 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
735 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 741 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
736 ne_action->addTo( actionMenu ); 742 ne_action->addTo( actionMenu );
737 connect( ne_action, SIGNAL( activated() ), 743 connect( ne_action, SIGNAL( activated() ),
738 mView, SLOT( newEvent() ) ); 744 mView, SLOT( newEvent() ) );
739 icon = loadPixmap( pathString + "newtodo" ); 745 icon = loadPixmap( pathString + "newtodo" );
740 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 746 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
741 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 747 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
742 nt_action->addTo( actionMenu ); 748 nt_action->addTo( actionMenu );
743 connect( nt_action, SIGNAL( activated() ), 749 connect( nt_action, SIGNAL( activated() ),
744 mView, SLOT( newTodo() ) ); 750 mView, SLOT( newTodo() ) );
745 751
746 icon = loadPixmap( pathString + "today" ); 752 icon = loadPixmap( pathString + "today" );
747 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 753 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
748 today_action->addTo( viewMenu ); 754 today_action->addTo( viewMenu );
749 connect( today_action, SIGNAL( activated() ), 755 connect( today_action, SIGNAL( activated() ),
750 mView, SLOT( goToday() ) ); 756 mView, SLOT( goToday() ) );
751 viewMenu->insertSeparator(); 757 viewMenu->insertSeparator();
752 758
753 // *********************** 759 // ***********************
754 if ( KOPrefs::instance()->mVerticalScreen ) { 760 if ( KOPrefs::instance()->mVerticalScreen ) {
755 icon = SmallIcon( "1updownarrow" ); 761 icon = SmallIcon( "1updownarrow" );
756 } else { 762 } else {
757 icon = SmallIcon("1leftrightarrow" ); 763 icon = SmallIcon("1leftrightarrow" );
758 } 764 }
759 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 765 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
760 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 766 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
761 FSaction->addTo( viewMenu ); 767 FSaction->addTo( viewMenu );
762 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 768 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
763 769
764 icon = loadPixmap( pathString + "navi" ); 770 icon = loadPixmap( pathString + "navi" );
765 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 771 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
766 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 772 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
767 action->addTo( viewMenu ); 773 action->addTo( viewMenu );
768 connect( action, SIGNAL( activated() ), 774 connect( action, SIGNAL( activated() ),
769 mView, SLOT( toggleDateNavigatorWidget() ) ); 775 mView, SLOT( toggleDateNavigatorWidget() ) );
770 mToggleNav = action ; 776 mToggleNav = action ;
771 icon = loadPixmap( pathString + "filter" ); 777 icon = loadPixmap( pathString + "filter" );
772 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 778 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
773 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 779 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
774 action->addTo( viewMenu ); 780 action->addTo( viewMenu );
775 connect( action, SIGNAL( activated() ), 781 connect( action, SIGNAL( activated() ),
776 mView, SLOT( toggleFilter() ) ); 782 mView, SLOT( toggleFilter() ) );
777 mToggleFilter = action; 783 mToggleFilter = action;
778 icon = loadPixmap( pathString + "allday" ); 784 icon = loadPixmap( pathString + "allday" );
779 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 785 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
780 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 786 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
781 action->addTo( viewMenu ); 787 action->addTo( viewMenu );
782 connect( action, SIGNAL( activated() ), 788 connect( action, SIGNAL( activated() ),
783 mView, SLOT( toggleAllDaySize() ) ); 789 mView, SLOT( toggleAllDaySize() ) );
784 mToggleAllday = action; 790 mToggleAllday = action;
785 791
786 792
787 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 793 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
788 mToggleNav, SLOT( setEnabled ( bool ) ) ); 794 mToggleNav, SLOT( setEnabled ( bool ) ) );
789 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 795 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
790 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 796 mToggleFilter, SLOT( setEnabled ( bool ) ) );
791 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 797 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
792 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 798 mToggleAllday, SLOT( setEnabled ( bool ) ) );
793 799
794 viewMenu->insertSeparator(); 800 viewMenu->insertSeparator();
795 icon = loadPixmap( pathString + "picker" ); 801 icon = loadPixmap( pathString + "picker" );
796 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 802 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
797 action->addTo( viewMenu ); 803 action->addTo( viewMenu );
798 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
799 mView, SLOT( showDatePicker() ) ); 805 mView, SLOT( showDatePicker() ) );
800 action->addTo( iconToolBar ); 806 action->addTo( iconToolBar );
801 viewMenu->insertSeparator(); 807 viewMenu->insertSeparator();
802 808
803 if ( p-> mShowIconToggleFull ) 809 if ( p-> mShowIconToggleFull )
804 FSaction->addTo( iconToolBar ); 810 FSaction->addTo( iconToolBar );
805 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 811 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
806 812
807 //******************** 813 //********************
808 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 814 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
809 815
810 816
811 icon = loadPixmap( pathString + "whatsnext" ); 817 icon = loadPixmap( pathString + "whatsnext" );
812 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 818 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
813 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 819 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
814 whatsnext_action->addTo( viewMenu ); 820 whatsnext_action->addTo( viewMenu );
815 connect( whatsnext_action, SIGNAL( activated() ), 821 connect( whatsnext_action, SIGNAL( activated() ),
816 mView->viewManager(), SLOT( showWhatsNextView() ) ); 822 mView->viewManager(), SLOT( showWhatsNextView() ) );
817 823
818 icon = loadPixmap( pathString + "xdays" ); 824 icon = loadPixmap( pathString + "xdays" );
819 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 825 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
820 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 826 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
821 xdays_action->addTo( viewMenu ); 827 xdays_action->addTo( viewMenu );
822 connect( xdays_action, SIGNAL( activated() ), 828 connect( xdays_action, SIGNAL( activated() ),
823 mView->viewManager(), SLOT( showNextXView() ) ); 829 mView->viewManager(), SLOT( showNextXView() ) );
824 830
825 831
826 icon = loadPixmap( pathString + "journal" ); 832 icon = loadPixmap( pathString + "journal" );
827 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 833 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
828 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 834 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
829 viewjournal_action->addTo( viewMenu ); 835 viewjournal_action->addTo( viewMenu );
830 connect( viewjournal_action, SIGNAL( activated() ), 836 connect( viewjournal_action, SIGNAL( activated() ),
831 mView->viewManager(), SLOT( showJournalView() ) ); 837 mView->viewManager(), SLOT( showJournalView() ) );
832 838
833 839
834 icon = loadPixmap( pathString + "day" ); 840 icon = loadPixmap( pathString + "day" );
835 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 841 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
836 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 842 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
837 day1_action->addTo( viewMenu ); 843 day1_action->addTo( viewMenu );
838 // action->addTo( toolBar ); 844 // action->addTo( toolBar );
839 connect( day1_action, SIGNAL( activated() ), 845 connect( day1_action, SIGNAL( activated() ),
840 mView->viewManager(), SLOT( showDayView() ) ); 846 mView->viewManager(), SLOT( showDayView() ) );
841 847
842 icon = loadPixmap( pathString + "workweek" ); 848 icon = loadPixmap( pathString + "workweek" );
843 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 849 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
844 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 850 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
845 day5_action->addTo( viewMenu ); 851 day5_action->addTo( viewMenu );
846 connect( day5_action, SIGNAL( activated() ), 852 connect( day5_action, SIGNAL( activated() ),
847 mView->viewManager(), SLOT( showWorkWeekView() ) ); 853 mView->viewManager(), SLOT( showWorkWeekView() ) );
848 854
849 icon = loadPixmap( pathString + "week" ); 855 icon = loadPixmap( pathString + "week" );
850 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 856 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
851 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 857 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
852 day7_action->addTo( viewMenu ); 858 day7_action->addTo( viewMenu );
853 connect( day7_action, SIGNAL( activated() ), 859 connect( day7_action, SIGNAL( activated() ),
854 mView->viewManager(), SLOT( showWeekView() ) ); 860 mView->viewManager(), SLOT( showWeekView() ) );
855 861
856 icon = loadPixmap( pathString + "workweek2" ); 862 icon = loadPixmap( pathString + "workweek2" );
857 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 863 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
858 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 864 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
859 day6_action->addTo( viewMenu ); 865 day6_action->addTo( viewMenu );
860 connect( day6_action, SIGNAL( activated() ), 866 connect( day6_action, SIGNAL( activated() ),
861 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 867 mView->viewManager(), SLOT( showMonthViewWeek() ) );
862 868
863 icon = loadPixmap( pathString + "month" ); 869 icon = loadPixmap( pathString + "month" );
864 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 870 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
865 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 871 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
866 month_action->addTo( viewMenu ); 872 month_action->addTo( viewMenu );
867 connect( month_action, SIGNAL( activated() ), 873 connect( month_action, SIGNAL( activated() ),
868 mView->viewManager(), SLOT( showMonthView() ) ); 874 mView->viewManager(), SLOT( showMonthView() ) );
869 875
870 icon = loadPixmap( pathString + "list" ); 876 icon = loadPixmap( pathString + "list" );
871 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 877 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
872 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 878 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
873 showlist_action->addTo( viewMenu ); 879 showlist_action->addTo( viewMenu );
874 connect( showlist_action, SIGNAL( activated() ), 880 connect( showlist_action, SIGNAL( activated() ),
875 mView->viewManager(), SLOT( showListView() ) ); 881 mView->viewManager(), SLOT( showListView() ) );
876 882
877 icon = loadPixmap( pathString + "todo" ); 883 icon = loadPixmap( pathString + "todo" );
878 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 884 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
879 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 885 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
880 todoview_action->addTo( viewMenu ); 886 todoview_action->addTo( viewMenu );
881 connect( todoview_action, SIGNAL( activated() ), 887 connect( todoview_action, SIGNAL( activated() ),
882 mView->viewManager(), SLOT( showTodoView() ) ); 888 mView->viewManager(), SLOT( showTodoView() ) );
883 889
884 890
885 891
886#if 0 892#if 0
887 action = new QAction( "view_timespan", "Time Span", 0, this ); 893 action = new QAction( "view_timespan", "Time Span", 0, this );
888 action->addTo( viewMenu ); 894 action->addTo( viewMenu );
889 connect( action, SIGNAL( activated() ), 895 connect( action, SIGNAL( activated() ),
890 mView->viewManager(), SLOT( showTimeSpanView() ) ); 896 mView->viewManager(), SLOT( showTimeSpanView() ) );
891#endif 897#endif
892 898
893 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 899 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
894 this ); 900 this );
895 mNewSubTodoAction->addTo( actionMenu ); 901 mNewSubTodoAction->addTo( actionMenu );
896 connect( mNewSubTodoAction, SIGNAL( activated() ), 902 connect( mNewSubTodoAction, SIGNAL( activated() ),
897 mView, SLOT( newSubTodo() ) ); 903 mView, SLOT( newSubTodo() ) );
898 904
899 actionMenu->insertSeparator(); 905 actionMenu->insertSeparator();
900 906
901 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 907 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
902 mShowAction->addTo( actionMenu ); 908 mShowAction->addTo( actionMenu );
903 connect( mShowAction, SIGNAL( activated() ), 909 connect( mShowAction, SIGNAL( activated() ),
904 mView, SLOT( showIncidence() ) ); 910 mView, SLOT( showIncidence() ) );
905 911
906 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 912 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
907 mEditAction->addTo( actionMenu ); 913 mEditAction->addTo( actionMenu );
908 connect( mEditAction, SIGNAL( activated() ), 914 connect( mEditAction, SIGNAL( activated() ),
909 mView, SLOT( editIncidence() ) ); 915 mView, SLOT( editIncidence() ) );
910 916
911 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 917 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
912 mDeleteAction->addTo( actionMenu ); 918 mDeleteAction->addTo( actionMenu );
913 connect( mDeleteAction, SIGNAL( activated() ), 919 connect( mDeleteAction, SIGNAL( activated() ),
914 mView, SLOT( deleteIncidence() ) ); 920 mView, SLOT( deleteIncidence() ) );
915 921
916 922
917 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 923 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
918 mCloneAction->addTo( actionMenu ); 924 mCloneAction->addTo( actionMenu );
919 connect( mCloneAction, SIGNAL( activated() ), 925 connect( mCloneAction, SIGNAL( activated() ),
920 mView, SLOT( cloneIncidence() ) ); 926 mView, SLOT( cloneIncidence() ) );
921 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 927 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
922 mMoveAction->addTo( actionMenu ); 928 mMoveAction->addTo( actionMenu );
923 connect( mMoveAction, SIGNAL( activated() ), 929 connect( mMoveAction, SIGNAL( activated() ),
924 mView, SLOT( moveIncidence() ) ); 930 mView, SLOT( moveIncidence() ) );
925 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 931 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
926 mBeamAction->addTo( actionMenu ); 932 mBeamAction->addTo( actionMenu );
927 connect( mBeamAction, SIGNAL( activated() ), 933 connect( mBeamAction, SIGNAL( activated() ),
928 mView, SLOT( beamIncidence() ) ); 934 mView, SLOT( beamIncidence() ) );
929 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 935 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
930 mCancelAction->addTo( actionMenu ); 936 mCancelAction->addTo( actionMenu );
931 connect( mCancelAction, SIGNAL( activated() ), 937 connect( mCancelAction, SIGNAL( activated() ),
932 mView, SLOT( toggleCancelIncidence() ) ); 938 mView, SLOT( toggleCancelIncidence() ) );
933 939
934 actionMenu->insertSeparator(); 940 actionMenu->insertSeparator();
935 941
936 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 942 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
937 this ); 943 this );
938 action->addTo( actionMenu ); 944 action->addTo( actionMenu );
939 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 945 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
940 946
941 icon = loadPixmap( pathString + "search" ); 947 icon = loadPixmap( pathString + "search" );
942 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 948 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
943 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 949 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
944 search_action->addTo( actionMenu ); 950 search_action->addTo( actionMenu );
945 connect( search_action, SIGNAL( activated() ), 951 connect( search_action, SIGNAL( activated() ),
946 mView->dialogManager(), SLOT( showSearchDialog() ) ); 952 mView->dialogManager(), SLOT( showSearchDialog() ) );
947 953
948 954
949 955
950 if ( KOPrefs::instance()->mShowFullMenu ) { 956 if ( KOPrefs::instance()->mShowFullMenu ) {
951 actionMenu->insertSeparator(); 957 actionMenu->insertSeparator();
952 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 958 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
953 959
954 } 960 }
955 // actionMenu->insertSeparator(); 961 // actionMenu->insertSeparator();
956 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 962 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
957 this ); 963 this );
958 action->addTo( importMenu_X ); 964 action->addTo( importMenu_X );
959 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 965 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
960 action = new QAction( "import_quick", i18n("Import last file"), 0, 966 action = new QAction( "import_quick", i18n("Import last file"), 0,
961 this ); 967 this );
962 action->addTo( importMenu_X ); 968 action->addTo( importMenu_X );
963 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 969 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
964 importMenu_X->insertSeparator(); 970 importMenu_X->insertSeparator();
965 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 971 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
966 this ); 972 this );
967 action->addTo( importMenu_X ); 973 action->addTo( importMenu_X );
968 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 974 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
969 //#ifndef DESKTOP_VERSION 975 //#ifndef DESKTOP_VERSION
970 importMenu_X->insertSeparator(); 976 importMenu_X->insertSeparator();
971 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 977 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
972 this ); 978 this );
973 action->addTo( importMenu_X ); 979 action->addTo( importMenu_X );
974 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 980 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
975 //#else 981 //#else
976#ifdef _OL_IMPORT_ 982#ifdef _OL_IMPORT_
977 importMenu_X->insertSeparator(); 983 importMenu_X->insertSeparator();
978 action = new QAction( "import_ol", i18n("Import from OL"), 0, 984 action = new QAction( "import_ol", i18n("Import from OL"), 0,
979 this ); 985 this );
980 action->addTo( importMenu_X ); 986 action->addTo( importMenu_X );
981 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 987 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
982#endif 988#endif
983 //#endif 989 //#endif
984 990
985 //importMenu->insertSeparator(); 991 //importMenu->insertSeparator();
986 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 992 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
987 this ); 993 this );
988 action->addTo( importMenu ); 994 action->addTo( importMenu );
989 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 995 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
990 996
991 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 997 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
992 this ); 998 this );
993 action->addTo( importMenu ); 999 action->addTo( importMenu );
994 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1000 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
995 importMenu->insertSeparator(); 1001 importMenu->insertSeparator();
996 importMenu->insertItem( i18n("Import"), importMenu_X ); 1002 importMenu->insertItem( i18n("Import"), importMenu_X );
997 //importMenu->insertSeparator(); 1003 //importMenu->insertSeparator();
998 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1004 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
999 this ); 1005 this );
1000 action->addTo( exportMenu_X ); 1006 action->addTo( exportMenu_X );
1001 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1007 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1002 1008
1003 1009
1004 //LR 1010 //LR
1005 QPopupMenu *ex2phone = new QPopupMenu( this ); 1011 QPopupMenu *ex2phone = new QPopupMenu( this );
1006 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1012 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1007 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1013 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1008 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1014 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1009 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1015 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1010 1016
1011 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1017 importMenu->insertItem( i18n("Export"), exportMenu_X );
1012#ifndef DESKTOP_VERSION 1018#ifndef DESKTOP_VERSION
1013 //importMenu->insertSeparator(); 1019 //importMenu->insertSeparator();
1014 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1020 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1015 this ); 1021 this );
1016 brAction->addTo( beamMenu_X ); 1022 brAction->addTo( beamMenu_X );
1017 brAction->setToggleAction (true ) ; 1023 brAction->setToggleAction (true ) ;
1018 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1024 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1019 1025
1020 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1026 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1021 this ); 1027 this );
1022 action->addTo( beamMenu_X ); 1028 action->addTo( beamMenu_X );
1023 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1029 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1024 1030
1025 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1031 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1026 this ); 1032 this );
1027 action->addTo( beamMenu_X ); 1033 action->addTo( beamMenu_X );
1028 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1034 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1029 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1035 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1030#else 1036#else
1031 //importMenu->insertSeparator(); 1037 //importMenu->insertSeparator();
1032 icon = loadPixmap( pathString + "print" ); 1038 icon = loadPixmap( pathString + "print" );
1033 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1039 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1034 action->addTo( beamMenu_X ); 1040 action->addTo( beamMenu_X );
1035 connect( action, SIGNAL( activated() ), 1041 connect( action, SIGNAL( activated() ),
1036 this, SLOT( printCal() ) ); 1042 this, SLOT( printCal() ) );
1037 1043
1038 icon = loadPixmap( pathString + "print" ); 1044 icon = loadPixmap( pathString + "print" );
1039 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1045 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1040 action->addTo( beamMenu_X ); 1046 action->addTo( beamMenu_X );
1041 connect( action, SIGNAL( activated() ), 1047 connect( action, SIGNAL( activated() ),
1042 this, SLOT( printSel() ) ); 1048 this, SLOT( printSel() ) );
1043 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1049 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1044 action->addTo( beamMenu_X ); 1050 action->addTo( beamMenu_X );
1045 connect( action, SIGNAL( activated() ), 1051 connect( action, SIGNAL( activated() ),
1046 mView->viewManager(), SLOT( slotprintWNV() ) ); 1052 mView->viewManager(), SLOT( slotprintWNV() ) );
1047 1053
1048 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1054 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1049 action->addTo( beamMenu_X ); 1055 action->addTo( beamMenu_X );
1050 connect( action, SIGNAL( activated() ), 1056 connect( action, SIGNAL( activated() ),
1051 mView, SLOT( slotprintSelInc() ) ); 1057 mView, SLOT( slotprintSelInc() ) );
1052 1058
1053 1059
1054 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1060 importMenu->insertItem( i18n("Print"), beamMenu_X );
1055#endif 1061#endif
1056 importMenu->insertSeparator(); 1062 importMenu->insertSeparator();
1057 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1063 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1058 this ); 1064 this );
1059 action->addTo( importMenu ); 1065 action->addTo( importMenu );
1060 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1066 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1061 importMenu->insertSeparator(); 1067 importMenu->insertSeparator();
1062 action = new QAction( "beam all", i18n("Save"), 0, 1068 action = new QAction( "beam all", i18n("Save"), 0,
1063 this ); 1069 this );
1064 action->addTo( importMenu ); 1070 action->addTo( importMenu );
1065 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1071 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1066 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1072 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1067 this ); 1073 this );
1068 action->addTo( importMenu ); 1074 action->addTo( importMenu );
1069 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1075 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1070 1076
1071 //menuBar->insertItem( "Configure",configureMenu ); 1077 //menuBar->insertItem( "Configure",configureMenu );
1072 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1078 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1073 icon = loadPixmap( "korganizer/korganizer" ); 1079 icon = loadPixmap( "korganizer/korganizer" );
1074 1080
1075 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1081 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1076 action->addTo( helpMenu ); 1082 action->addTo( helpMenu );
1077 connect( action, SIGNAL( activated() ), 1083 connect( action, SIGNAL( activated() ),
1078 SLOT( whatsNew() ) ); 1084 SLOT( whatsNew() ) );
1079 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1085 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1080 action->addTo( helpMenu ); 1086 action->addTo( helpMenu );
1081 connect( action, SIGNAL( activated() ), 1087 connect( action, SIGNAL( activated() ),
1082 SLOT( features() ) ); 1088 SLOT( features() ) );
1083 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1089 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1084 action->addTo( helpMenu ); 1090 action->addTo( helpMenu );
1085 connect( action, SIGNAL( activated() ), 1091 connect( action, SIGNAL( activated() ),
1086 SLOT( keyBindings() ) ); 1092 SLOT( keyBindings() ) );
1087 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1093 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1088 action->addTo( helpMenu ); 1094 action->addTo( helpMenu );
1089 connect( action, SIGNAL( activated() ), 1095 connect( action, SIGNAL( activated() ),
1090 SLOT( storagehowto() ) ); 1096 SLOT( storagehowto() ) );
1091 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1097 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1092 action->addTo( helpMenu ); 1098 action->addTo( helpMenu );
1093 connect( action, SIGNAL( activated() ), 1099 connect( action, SIGNAL( activated() ),
1094 SLOT( timetrackinghowto() ) ); 1100 SLOT( timetrackinghowto() ) );
1095 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1101 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1096 action->addTo( helpMenu ); 1102 action->addTo( helpMenu );
1097 connect( action, SIGNAL( activated() ), 1103 connect( action, SIGNAL( activated() ),
1098 SLOT( synchowto() ) ); 1104 SLOT( synchowto() ) );
1099 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1105 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1100 action->addTo( helpMenu ); 1106 action->addTo( helpMenu );
1101 connect( action, SIGNAL( activated() ), 1107 connect( action, SIGNAL( activated() ),
1102 SLOT( kdesynchowto() ) ); 1108 SLOT( kdesynchowto() ) );
1103 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1109 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1104 action->addTo( helpMenu ); 1110 action->addTo( helpMenu );
1105 connect( action, SIGNAL( activated() ), 1111 connect( action, SIGNAL( activated() ),
1106 SLOT( multisynchowto() ) ); 1112 SLOT( multisynchowto() ) );
1107 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1113 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1108 action->addTo( helpMenu ); 1114 action->addTo( helpMenu );
1109 connect( action, SIGNAL( activated() ), 1115 connect( action, SIGNAL( activated() ),
1110 SLOT( aboutAutoSaving() ) ); 1116 SLOT( aboutAutoSaving() ) );
1111 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1117 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1112 action->addTo( helpMenu ); 1118 action->addTo( helpMenu );
1113 connect( action, SIGNAL( activated() ), 1119 connect( action, SIGNAL( activated() ),
1114 SLOT( aboutKnownBugs() ) ); 1120 SLOT( aboutKnownBugs() ) );
1115 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1121 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1116 action->addTo( helpMenu ); 1122 action->addTo( helpMenu );
1117 connect( action, SIGNAL( activated() ), 1123 connect( action, SIGNAL( activated() ),
1118 SLOT( usertrans() ) ); 1124 SLOT( usertrans() ) );
1119 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1125 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1120 action->addTo( helpMenu ); 1126 action->addTo( helpMenu );
1121 connect( action, SIGNAL( activated() ), 1127 connect( action, SIGNAL( activated() ),
1122 SLOT( faq() ) ); 1128 SLOT( faq() ) );
1123 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1129 action = new QAction( "licence", i18n("Licence..."), 0, this );
1124 action->addTo( helpMenu ); 1130 action->addTo( helpMenu );
1125 connect( action, SIGNAL( activated() ), 1131 connect( action, SIGNAL( activated() ),
1126 SLOT( licence() ) ); 1132 SLOT( licence() ) );
1127 action = new QAction( "about", i18n("About..."), 0, this ); 1133 action = new QAction( "about", i18n("About..."), 0, this );
1128 action->addTo( helpMenu ); 1134 action->addTo( helpMenu );
1129 connect( action, SIGNAL( activated() ), 1135 connect( action, SIGNAL( activated() ),
1130 SLOT( about() ) ); 1136 SLOT( about() ) );
1131 //menuBar->insertSeparator(); 1137 //menuBar->insertSeparator();
1132 1138
1133 // ****************************************************** 1139 // ******************************************************
1134 // menubar icons 1140 // menubar icons
1135 1141
1136 1142
1137 1143
1138 //menuBar->insertItem( iconToolBar ); 1144 //menuBar->insertItem( iconToolBar );
1139 //xdays_action 1145 //xdays_action
1140 if (p-> mShowIconNewEvent) 1146 if (p-> mShowIconNewEvent)
1141 ne_action->addTo( iconToolBar ); 1147 ne_action->addTo( iconToolBar );
1142 if (p->mShowIconNewTodo ) 1148 if (p->mShowIconNewTodo )
1143 nt_action->addTo( iconToolBar ); 1149 nt_action->addTo( iconToolBar );
1144 if (p-> mShowIconSearch) 1150 if (p-> mShowIconSearch)
1145 search_action->addTo( iconToolBar ); 1151 search_action->addTo( iconToolBar );
1146 if (p-> mShowIconWhatsThis) 1152 if (p-> mShowIconWhatsThis)
1147 QWhatsThis::whatsThisButton ( iconToolBar ); 1153 QWhatsThis::whatsThisButton ( iconToolBar );
1148 if (p-> mShowIconNext) 1154 if (p-> mShowIconNext)
1149 whatsnext_action->addTo( viewToolBar ); 1155 whatsnext_action->addTo( viewToolBar );
1150 if (p-> mShowIconNextDays) 1156 if (p-> mShowIconNextDays)
1151 xdays_action->addTo( viewToolBar ); 1157 xdays_action->addTo( viewToolBar );
1152 if (p-> mShowIconJournal) 1158 if (p-> mShowIconJournal)
1153 viewjournal_action->addTo( viewToolBar ); 1159 viewjournal_action->addTo( viewToolBar );
1154 if (p-> mShowIconDay1) 1160 if (p-> mShowIconDay1)
1155 day1_action->addTo( viewToolBar ); 1161 day1_action->addTo( viewToolBar );
1156 if (p-> mShowIconDay5) 1162 if (p-> mShowIconDay5)
1157 day5_action->addTo( viewToolBar ); 1163 day5_action->addTo( viewToolBar );
1158 if (p-> mShowIconDay7) 1164 if (p-> mShowIconDay7)
1159 day7_action->addTo( viewToolBar ); 1165 day7_action->addTo( viewToolBar );
1160 if (p-> mShowIconDay6) 1166 if (p-> mShowIconDay6)
1161 day6_action->addTo( viewToolBar ); 1167 day6_action->addTo( viewToolBar );
1162 if (p-> mShowIconMonth) 1168 if (p-> mShowIconMonth)
1163 month_action->addTo( viewToolBar ); 1169 month_action->addTo( viewToolBar );
1164 if (p-> mShowIconList) 1170 if (p-> mShowIconList)
1165 showlist_action->addTo( viewToolBar ); 1171 showlist_action->addTo( viewToolBar );
1166 if (p-> mShowIconTodoview) 1172 if (p-> mShowIconTodoview)
1167 todoview_action->addTo( viewToolBar ); 1173 todoview_action->addTo( viewToolBar );
1168 1174
1169 icon = loadPixmap( pathString + "2leftarrowB" ); 1175 icon = loadPixmap( pathString + "2leftarrowB" );
1170 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1176 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1171 if (p-> mShowIconBackFast) { 1177 if (p-> mShowIconBackFast) {
1172 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1178 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1173 connect( action, SIGNAL( activated() ), 1179 connect( action, SIGNAL( activated() ),
1174 mView, SLOT( goPreviousMonth() ) ); 1180 mView, SLOT( goPreviousMonth() ) );
1175 action->addTo( navigatorToolBar ); 1181 action->addTo( navigatorToolBar );
1176 } 1182 }
1177 icon = loadPixmap( pathString + "1leftarrowB" ); 1183 icon = loadPixmap( pathString + "1leftarrowB" );
1178 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1184 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1179 if (p-> mShowIconBack) { 1185 if (p-> mShowIconBack) {
1180 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1186 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1181 connect( action, SIGNAL( activated() ), 1187 connect( action, SIGNAL( activated() ),
1182 mView, SLOT( goPrevious() ) ); 1188 mView, SLOT( goPrevious() ) );
1183 action->addTo( navigatorToolBar ); 1189 action->addTo( navigatorToolBar );
1184 } 1190 }
1185 icon = loadPixmap( pathString + "today" ); 1191 icon = loadPixmap( pathString + "today" );
1186 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1192 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1187 if (p-> mShowIconToday) 1193 if (p-> mShowIconToday)
1188 today_action->addTo( navigatorToolBar ); 1194 today_action->addTo( navigatorToolBar );
1189 icon = loadPixmap( pathString + "1rightarrowB" ); 1195 icon = loadPixmap( pathString + "1rightarrowB" );
1190 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1196 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1191 if (p-> mShowIconForward) { 1197 if (p-> mShowIconForward) {
1192 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1198 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1193 connect( action, SIGNAL( activated() ), 1199 connect( action, SIGNAL( activated() ),
1194 mView, SLOT( goNext() ) ); 1200 mView, SLOT( goNext() ) );
1195 action->addTo( navigatorToolBar ); 1201 action->addTo( navigatorToolBar );
1196 } 1202 }
1197 icon = loadPixmap( pathString + "2rightarrowB" ); 1203 icon = loadPixmap( pathString + "2rightarrowB" );
1198 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1204 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1199 if (p-> mShowIconForwardFast) { 1205 if (p-> mShowIconForwardFast) {
1200 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1206 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1201 connect( action, SIGNAL( activated() ), 1207 connect( action, SIGNAL( activated() ),
1202 mView, SLOT( goNextMonth() ) ); 1208 mView, SLOT( goNextMonth() ) );
1203 action->addTo( navigatorToolBar ); 1209 action->addTo( navigatorToolBar );
1204 } 1210 }
1205 1211
1206 1212
1207 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1213 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1208 1214
1209 1215
1210 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1216 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1211 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1217 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1212 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1218 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1213 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1219 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1214 1220
1215 if (p-> mShowIconNewEvent) 1221 if (p-> mShowIconNewEvent)
1216 configureToolBarMenu->setItemChecked( 10, true ); 1222 configureToolBarMenu->setItemChecked( 10, true );
1217 if (p->mShowIconNewTodo ) 1223 if (p->mShowIconNewTodo )
1218 configureToolBarMenu->setItemChecked( 20, true ); 1224 configureToolBarMenu->setItemChecked( 20, true );
1219 if (p-> mShowIconSearch) 1225 if (p-> mShowIconSearch)
1220 configureToolBarMenu->setItemChecked( 120, true ); 1226 configureToolBarMenu->setItemChecked( 120, true );
1221 if (p-> mShowIconList) 1227 if (p-> mShowIconList)
1222 configureToolBarMenu->setItemChecked( 30, true ); 1228 configureToolBarMenu->setItemChecked( 30, true );
1223 if (p-> mShowIconDay1) 1229 if (p-> mShowIconDay1)
1224 configureToolBarMenu->setItemChecked( 40, true ); 1230 configureToolBarMenu->setItemChecked( 40, true );
1225 if (p-> mShowIconDay5) 1231 if (p-> mShowIconDay5)
1226 configureToolBarMenu->setItemChecked( 50, true ); 1232 configureToolBarMenu->setItemChecked( 50, true );
1227 if (p-> mShowIconDay6) 1233 if (p-> mShowIconDay6)
1228 configureToolBarMenu->setItemChecked( 75, true ); 1234 configureToolBarMenu->setItemChecked( 75, true );
1229 if (p-> mShowIconDay7) 1235 if (p-> mShowIconDay7)
1230 configureToolBarMenu->setItemChecked( 60, true ); 1236 configureToolBarMenu->setItemChecked( 60, true );
1231 if (p-> mShowIconMonth) 1237 if (p-> mShowIconMonth)
1232 configureToolBarMenu->setItemChecked( 70, true ); 1238 configureToolBarMenu->setItemChecked( 70, true );
1233 if (p-> mShowIconTodoview) 1239 if (p-> mShowIconTodoview)
1234 configureToolBarMenu->setItemChecked( 80, true ); 1240 configureToolBarMenu->setItemChecked( 80, true );
1235 if (p-> mShowIconBackFast) 1241 if (p-> mShowIconBackFast)
1236 configureToolBarMenu->setItemChecked( 200, true ); 1242 configureToolBarMenu->setItemChecked( 200, true );
1237 if (p-> mShowIconBack) 1243 if (p-> mShowIconBack)
1238 configureToolBarMenu->setItemChecked( 210, true ); 1244 configureToolBarMenu->setItemChecked( 210, true );
1239 if (p-> mShowIconToday) 1245 if (p-> mShowIconToday)
1240 configureToolBarMenu->setItemChecked( 130, true ); 1246 configureToolBarMenu->setItemChecked( 130, true );
1241 if (p-> mShowIconForward) 1247 if (p-> mShowIconForward)
1242 configureToolBarMenu->setItemChecked( 220, true ); 1248 configureToolBarMenu->setItemChecked( 220, true );
1243 if (p-> mShowIconForwardFast) 1249 if (p-> mShowIconForwardFast)
1244 configureToolBarMenu->setItemChecked( 230, true ); 1250 configureToolBarMenu->setItemChecked( 230, true );
1245 if (p-> mShowIconNextDays) 1251 if (p-> mShowIconNextDays)
1246 configureToolBarMenu->setItemChecked( 100, true ); 1252 configureToolBarMenu->setItemChecked( 100, true );
1247 if (p-> mShowIconNext) 1253 if (p-> mShowIconNext)
1248 configureToolBarMenu->setItemChecked( 110, true ); 1254 configureToolBarMenu->setItemChecked( 110, true );
1249 if (p-> mShowIconJournal) 1255 if (p-> mShowIconJournal)
1250 configureToolBarMenu->setItemChecked( 90, true ); 1256 configureToolBarMenu->setItemChecked( 90, true );
1251 if (p-> mShowIconWhatsThis) 1257 if (p-> mShowIconWhatsThis)
1252 configureToolBarMenu->setItemChecked( 300, true ); 1258 configureToolBarMenu->setItemChecked( 300, true );
1253 if (p-> mShowIconWeekNum) 1259 if (p-> mShowIconWeekNum)
1254 configureToolBarMenu->setItemChecked( 400, true ); 1260 configureToolBarMenu->setItemChecked( 400, true );
1255 if (!p-> mShowIconStretch) { 1261 if (!p-> mShowIconStretch) {
1256 QLabel* dummy = new QLabel( iconToolBar ); 1262 QLabel* dummy = new QLabel( iconToolBar );
1257 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1263 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1258 dummy->setMinimumWidth( 0 ); 1264 dummy->setMinimumWidth( 0 );
1259 iconToolBar->setStretchableWidget ( dummy ) ; 1265 iconToolBar->setStretchableWidget ( dummy ) ;
1260 } 1266 }
1261 else { 1267 else {
1262 iconToolBar->setHorizontalStretchable (true ); 1268 iconToolBar->setHorizontalStretchable (true );
1263 viewToolBar->setHorizontalStretchable (true ); 1269 viewToolBar->setHorizontalStretchable (true );
1264 navigatorToolBar->setHorizontalStretchable (true ); 1270 navigatorToolBar->setHorizontalStretchable (true );
1265 iconToolBar->setVerticalStretchable (true ); 1271 iconToolBar->setVerticalStretchable (true );
1266 viewToolBar->setVerticalStretchable (true ); 1272 viewToolBar->setVerticalStretchable (true );
1267 navigatorToolBar->setVerticalStretchable (true ); 1273 navigatorToolBar->setVerticalStretchable (true );
1268 configureToolBarMenu->setItemChecked( 5, true ); 1274 configureToolBarMenu->setItemChecked( 5, true );
1269 } 1275 }
1270 if (p-> mShowIconFilter) 1276 if (p-> mShowIconFilter)
1271 configureToolBarMenu->setItemChecked( 7, true ); 1277 configureToolBarMenu->setItemChecked( 7, true );
1272 if (p-> mShowIconOnetoolbar) 1278 if (p-> mShowIconOnetoolbar)
1273 configureToolBarMenu->setItemChecked( 6, true ); 1279 configureToolBarMenu->setItemChecked( 6, true );
1274 1280
1275 1281
1276 if ( filterMenubar ) 1282 if ( filterMenubar )
1277 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1283 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1278 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1284 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1279 configureAgenda( p->mHourSize ); 1285 configureAgenda( p->mHourSize );
1280 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1286 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1281} 1287}
1282 1288
1283void MainWindow::exportToPhone( int mode ) 1289void MainWindow::exportToPhone( int mode )
1284{ 1290{
1285 1291
1286 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1292 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1287 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1293 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1288 KOex2phonePrefs ex2phone; 1294 KOex2phonePrefs ex2phone;
1289 1295
1290 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1296 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1291 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1297 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1292 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1298 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1293 if ( mode == 1 ) 1299 if ( mode == 1 )
1294 ex2phone.setCaption(i18n("Export complete calendar")); 1300 ex2phone.setCaption(i18n("Export complete calendar"));
1295 if ( mode == 2 ) 1301 if ( mode == 2 )
1296 ex2phone.setCaption(i18n("Export filtered calendar")); 1302 ex2phone.setCaption(i18n("Export filtered calendar"));
1297 1303
1298 if ( !ex2phone.exec() ) { 1304 if ( !ex2phone.exec() ) {
1299 return; 1305 return;
1300 } 1306 }
1301 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1307 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1302 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1308 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1303 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1309 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1304 1310
1305 int inFuture = 0; 1311 int inFuture = 0;
1306 if ( ex2phone.mWriteBackFuture->isChecked() ) 1312 if ( ex2phone.mWriteBackFuture->isChecked() )
1307 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1313 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1308 QPtrList<Incidence> delSel; 1314 QPtrList<Incidence> delSel;
1309 if ( mode == 1 ) 1315 if ( mode == 1 )
1310 delSel = mCalendar->rawIncidences(); 1316 delSel = mCalendar->rawIncidences();
1311 if ( mode == 2 ) 1317 if ( mode == 2 )
1312 delSel = mCalendar->incidences(); 1318 delSel = mCalendar->incidences();
1313 CalendarLocal* cal = new CalendarLocal(); 1319 CalendarLocal* cal = new CalendarLocal();
1314 cal->setLocalTime(); 1320 cal->setLocalTime();
1315 Incidence *incidence = delSel.first(); 1321 Incidence *incidence = delSel.first();
1316 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1322 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1317 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1323 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1318 while ( incidence ) { 1324 while ( incidence ) {
1319 if ( incidence->type() != "Journal" ) { 1325 if ( incidence->type() != "Journal" ) {
1320 bool add = true; 1326 bool add = true;
1321 if ( inFuture ) { 1327 if ( inFuture ) {
1322 QDateTime dt; 1328 QDateTime dt;
1323 if ( incidence->type() == "Todo" ) { 1329 if ( incidence->type() == "Todo" ) {
1324 Todo * t = (Todo*)incidence; 1330 Todo * t = (Todo*)incidence;
1325 if ( t->hasDueDate() ) 1331 if ( t->hasDueDate() )
1326 dt = t->dtDue(); 1332 dt = t->dtDue();
1327 else 1333 else
1328 dt = cur.addSecs( 62 ); 1334 dt = cur.addSecs( 62 );
1329 } 1335 }
1330 else { 1336 else {
1331 bool ok; 1337 bool ok;
1332 dt = incidence->getNextOccurence( cur, &ok ); 1338 dt = incidence->getNextOccurence( cur, &ok );
1333 if ( !ok ) 1339 if ( !ok )
1334 dt = cur.addSecs( -62 ); 1340 dt = cur.addSecs( -62 );
1335 } 1341 }
1336 if ( dt < cur || dt > end ) { 1342 if ( dt < cur || dt > end ) {
1337 add = false; 1343 add = false;
1338 } 1344 }
1339 } 1345 }
1340 if ( add ) { 1346 if ( add ) {
1341 Incidence *in = incidence->clone(); 1347 Incidence *in = incidence->clone();
1342 cal->addIncidence( in ); 1348 cal->addIncidence( in );
1343 } 1349 }
1344 } 1350 }
1345 incidence = delSel.next(); 1351 incidence = delSel.next();
1346 } 1352 }
1347 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1353 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1348 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1354 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1349 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1355 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1350 1356
1351 setCaption( i18n("Writing to phone...")); 1357 setCaption( i18n("Writing to phone..."));
1352 if ( PhoneFormat::writeToPhone( cal ) ) 1358 if ( PhoneFormat::writeToPhone( cal ) )
1353 setCaption( i18n("Export to phone successful!")); 1359 setCaption( i18n("Export to phone successful!"));
1354 else 1360 else
1355 setCaption( i18n("Error exporting to phone!")); 1361 setCaption( i18n("Error exporting to phone!"));
1356 delete cal; 1362 delete cal;
1357} 1363}
1358 1364
1359 1365
1360void MainWindow::setDefaultPreferences() 1366void MainWindow::setDefaultPreferences()
1361{ 1367{
1362 KOPrefs *p = KOPrefs::instance(); 1368 KOPrefs *p = KOPrefs::instance();
1363 1369
1364 p->mCompactDialogs = true; 1370 p->mCompactDialogs = true;
1365 p->mConfirm = true; 1371 p->mConfirm = true;
1366 // p->mEnableQuickTodo = false; 1372 // p->mEnableQuickTodo = false;
1367 1373
1368} 1374}
1369 1375
1370QString MainWindow::resourcePath() 1376QString MainWindow::resourcePath()
1371{ 1377{
1372 return KGlobal::iconLoader()->iconPath(); 1378 return KGlobal::iconLoader()->iconPath();
1373} 1379}
1374 1380
1375void MainWindow::displayText( QString text ,QString cap ) 1381void MainWindow::displayText( QString text ,QString cap )
1376{ 1382{
1377 QDialog dia( this, "name", true ); ; 1383 QDialog dia( this, "name", true ); ;
1378 dia.setCaption( cap ); 1384 dia.setCaption( cap );
1379 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1385 QVBoxLayout* lay = new QVBoxLayout( &dia );
1380 lay->setSpacing( 3 ); 1386 lay->setSpacing( 3 );
1381 lay->setMargin( 3 ); 1387 lay->setMargin( 3 );
1382 QTextBrowser tb ( &dia ); 1388 QTextBrowser tb ( &dia );
1383 lay->addWidget( &tb ); 1389 lay->addWidget( &tb );
1384 tb.setText( text ); 1390 tb.setText( text );
1385#ifdef DESKTOP_VERSION 1391#ifdef DESKTOP_VERSION
1386 dia.resize( 640, 480); 1392 dia.resize( 640, 480);
1387#else 1393#else
1388 dia.showMaximized(); 1394 dia.showMaximized();
1389#endif 1395#endif
1390 dia.exec(); 1396 dia.exec();
1391} 1397}
1392 1398
1393void MainWindow::features() 1399void MainWindow::features()
1394{ 1400{
1395 1401
1396 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1402 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1397} 1403}
1398 1404
1399void MainWindow::usertrans() 1405void MainWindow::usertrans()
1400{ 1406{
1401 1407
1402 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1408 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1403} 1409}
1404 1410
1405void MainWindow::storagehowto() 1411void MainWindow::storagehowto()
1406{ 1412{
1407 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1413 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1408} 1414}
1409void MainWindow::timetrackinghowto() 1415void MainWindow::timetrackinghowto()
1410{ 1416{
1411 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1417 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1412} 1418}
1413void MainWindow::kdesynchowto() 1419void MainWindow::kdesynchowto()
1414{ 1420{
1415 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1421 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1416} 1422}
1417void MainWindow::multisynchowto() 1423void MainWindow::multisynchowto()
1418{ 1424{
1419 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1425 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1420} 1426}
1421void MainWindow::synchowto() 1427void MainWindow::synchowto()
1422{ 1428{
1423 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1429 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1424} 1430}
1425void MainWindow::faq() 1431void MainWindow::faq()
1426{ 1432{
1427 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1433 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1428 1434
1429} 1435}
1430void MainWindow::whatsNew() 1436void MainWindow::whatsNew()
1431{ 1437{
1432 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1438 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1433 1439
1434} 1440}
1435void MainWindow::licence() 1441void MainWindow::licence()
1436{ 1442{
1437 KApplication::showLicence(); 1443 KApplication::showLicence();
1438 1444
1439} 1445}
1440void MainWindow::about() 1446void MainWindow::about()
1441{ 1447{
1442 QString version; 1448 QString version;
1443#include <../version> 1449#include <../version>
1444 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1450 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1445 i18n("KOrganizer/Platform-independent\n") + 1451 i18n("KOrganizer/Platform-independent\n") +
1446 "(KO/Pi) " + version + " - " + 1452 "(KO/Pi) " + version + " - " +
1447 1453
1448#ifdef DESKTOP_VERSION 1454#ifdef DESKTOP_VERSION
1449 i18n("Desktop Edition\n") + 1455 i18n("Desktop Edition\n") +
1450#else 1456#else
1451 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1457 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1452#endif 1458#endif
1453 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1459 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1454} 1460}
1455void MainWindow::keyBindings() 1461void MainWindow::keyBindings()
1456{ 1462{
1457 QString cap = i18n("KO/Pi Keys + Colors"); 1463 QString cap = i18n("KO/Pi Keys + Colors");
1458 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1464 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1459 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1465 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1460 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1466 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1461 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1467 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1462 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1468 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1463 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1469 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1464 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1470 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1465 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1471 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1466 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1472 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1467 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1473 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1468 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1474 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1469 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1475 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1470 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1476 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1471 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1477 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1472 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1478 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1473 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1479 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1474 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1480 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1475 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1481 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1476 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1482 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1477 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1483 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1478 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1484 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1479 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1485 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1480 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1486 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1481 i18n("<p><h3>In agenda view:</h3></p>\n") + 1487 i18n("<p><h3>In agenda view:</h3></p>\n") +
1482 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1488 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1483 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1489 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1484 i18n("<p><h3>In todo view:</h3></p>\n") + 1490 i18n("<p><h3>In todo view:</h3></p>\n") +
1485 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1491 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1486 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1492 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1487 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1493 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1488 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1494 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1489 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1495 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1490 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1496 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1491 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1497 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1492 i18n("<p><h3>In list view:</h3></p>\n") + 1498 i18n("<p><h3>In list view:</h3></p>\n") +
1493 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1499 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1494 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1500 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1495 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1501 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1496 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1502 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1497 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1503 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1498 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1504 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1499 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1505 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1500 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1506 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1501 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1507 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1502 i18n("<p><b>E</b>: Edit item</p>\n") + 1508 i18n("<p><b>E</b>: Edit item</p>\n") +
1503 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1509 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1504 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1510 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1505 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1511 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1506 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1512 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1507 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1513 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1508 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1514 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1509 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1515 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1510 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1516 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1511 i18n("<p><b>White</b>: Item readonly</p>\n"); 1517 i18n("<p><b>White</b>: Item readonly</p>\n");
1512 displayText( text, cap); 1518 displayText( text, cap);
1513} 1519}
1514void MainWindow::aboutAutoSaving() 1520void MainWindow::aboutAutoSaving()
1515{ 1521{
1516 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1522 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1517 1523
1518 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1524 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1519 1525
1520} 1526}
1521void MainWindow::aboutKnownBugs() 1527void MainWindow::aboutKnownBugs()
1522{ 1528{
1523 QMessageBox* msg; 1529 QMessageBox* msg;
1524 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1530 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1525 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1531 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1526 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1532 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1527 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1533 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1528 i18n("\nor report them in the bugtracker on\n") + 1534 i18n("\nor report them in the bugtracker on\n") +
1529 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1535 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1530 QMessageBox::NoIcon, 1536 QMessageBox::NoIcon,
1531 QMessageBox::Ok, 1537 QMessageBox::Ok,
1532 QMessageBox::NoButton, 1538 QMessageBox::NoButton,
1533 QMessageBox::NoButton); 1539 QMessageBox::NoButton);
1534 msg->exec(); 1540 msg->exec();
1535 delete msg; 1541 delete msg;
1536 1542
1537} 1543}
1538 1544
1539QString MainWindow::defaultFileName() 1545QString MainWindow::defaultFileName()
1540{ 1546{
1541 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1547 return locateLocal( "data", "korganizer/mycalendar.ics" );
1542} 1548}
1543QString MainWindow::syncFileName() 1549QString MainWindow::syncFileName()
1544{ 1550{
1545#ifdef DESKTOP_VERSION 1551#ifdef DESKTOP_VERSION
1546 return locateLocal( "tmp", "synccalendar.ics" ); 1552 return locateLocal( "tmp", "synccalendar.ics" );
1547#else 1553#else
1548 return QString( "/tmp/synccalendar.ics" ); 1554 return QString( "/tmp/synccalendar.ics" );
1549#endif 1555#endif
1550} 1556}
1551#include "koglobals.h" 1557#include "koglobals.h"
1552#include <kcalendarsystem.h> 1558#include <kcalendarsystem.h>
1553void MainWindow::updateWeek(QDate seda) 1559void MainWindow::updateWeek(QDate seda)
1554{ 1560{
1555 int weekNum = KGlobal::locale()->weekNum ( seda ); 1561 int weekNum = KGlobal::locale()->weekNum ( seda );
1556 mWeekPixmap.fill( mWeekBgColor ); 1562 mWeekPixmap.fill( mWeekBgColor );
1557 QPainter p ( &mWeekPixmap ); 1563 QPainter p ( &mWeekPixmap );
1558 p.setFont( mWeekFont ); 1564 p.setFont( mWeekFont );
1559 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1565 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1560 p.end(); 1566 p.end();
1561 QIconSet icon3 ( mWeekPixmap ); 1567 QIconSet icon3 ( mWeekPixmap );
1562 mWeekAction->setIconSet ( icon3 ); 1568 mWeekAction->setIconSet ( icon3 );
1563 1569
1564} 1570}
1565void MainWindow::updateWeekNum(const DateList &selectedDates) 1571void MainWindow::updateWeekNum(const DateList &selectedDates)
1566{ 1572{
1567 updateWeek( selectedDates.first() ); 1573 updateWeek( selectedDates.first() );
1568} 1574}
1569void MainWindow::processIncidenceSelection( Incidence *incidence ) 1575void MainWindow::processIncidenceSelection( Incidence *incidence )
1570{ 1576{
1571 1577
1572 if ( !incidence ) { 1578 if ( !incidence ) {
1573 enableIncidenceActions( false ); 1579 enableIncidenceActions( false );
1574 1580
1575 mNewSubTodoAction->setEnabled( false ); 1581 mNewSubTodoAction->setEnabled( false );
1576 setCaptionToDates(); 1582 setCaptionToDates();
1577 return; 1583 return;
1578 1584
1579 } 1585 }
1580 1586
1581 //KGlobal::locale()->formatDateTime(nextA, true); 1587 //KGlobal::locale()->formatDateTime(nextA, true);
1582 QString startString = ""; 1588 QString startString = "";
1583 if ( incidence->type() != "Todo" ) { 1589 if ( incidence->type() != "Todo" ) {
1584 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1590 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1585 if ( incidence->doesFloat() ) { 1591 if ( incidence->doesFloat() ) {
1586 startString += ": "+incidence->dtStartDateStr( true ); 1592 startString += ": "+incidence->dtStartDateStr( true );
1587 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1593 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1588 1594
1589 } else { 1595 } else {
1590 startString = ": "+incidence->dtStartStr(true); 1596 startString = ": "+incidence->dtStartStr(true);
1591 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1597 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1592 1598
1593 } 1599 }
1594 1600
1595 } else { 1601 } else {
1596 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1602 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1597 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1603 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1598 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1604 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1599 1605
1600 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1606 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1601 bool ok; 1607 bool ok;
1602 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1608 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1603 if ( ok ) { 1609 if ( ok ) {
1604 int years = noc.date().year() - incidence->dtStart().date().year(); 1610 int years = noc.date().year() - incidence->dtStart().date().year();
1605 startString += i18n(" (%1 y.)"). arg( years ); 1611 startString += i18n(" (%1 y.)"). arg( years );
1606 } 1612 }
1607 } 1613 }
1608 else 1614 else
1609 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1615 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1610 } 1616 }
1611 1617
1612 } 1618 }
1613 else 1619 else
1614 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1620 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1615 if ( !incidence->location().isEmpty() ) 1621 if ( !incidence->location().isEmpty() )
1616 startString += " (" +incidence->location()+")"; 1622 startString += " (" +incidence->location()+")";
1617 setCaption( incidence->summary()+startString); 1623 setCaption( incidence->summary()+startString);
1618 1624
1619 enableIncidenceActions( true ); 1625 enableIncidenceActions( true );
1620 1626
1621 if ( incidence->type() == "Event" ) { 1627 if ( incidence->type() == "Event" ) {
1622 mShowAction->setText( i18n("Show Event...") ); 1628 mShowAction->setText( i18n("Show Event...") );
1623 mEditAction->setText( i18n("Edit Event...") ); 1629 mEditAction->setText( i18n("Edit Event...") );
1624 mDeleteAction->setText( i18n("Delete Event...") ); 1630 mDeleteAction->setText( i18n("Delete Event...") );
1625 1631
1626 mNewSubTodoAction->setEnabled( false ); 1632 mNewSubTodoAction->setEnabled( false );
1627 } else if ( incidence->type() == "Todo" ) { 1633 } else if ( incidence->type() == "Todo" ) {
1628 mShowAction->setText( i18n("Show Todo...") ); 1634 mShowAction->setText( i18n("Show Todo...") );
1629 mEditAction->setText( i18n("Edit Todo...") ); 1635 mEditAction->setText( i18n("Edit Todo...") );
1630 mDeleteAction->setText( i18n("Delete Todo...") ); 1636 mDeleteAction->setText( i18n("Delete Todo...") );
1631 1637
1632 mNewSubTodoAction->setEnabled( true ); 1638 mNewSubTodoAction->setEnabled( true );
1633 } else { 1639 } else {
1634 mShowAction->setText( i18n("Show...") ); 1640 mShowAction->setText( i18n("Show...") );
1635 mShowAction->setText( i18n("Edit...") ); 1641 mShowAction->setText( i18n("Edit...") );
1636 mShowAction->setText( i18n("Delete...") ); 1642 mShowAction->setText( i18n("Delete...") );
1637 1643
1638 mNewSubTodoAction->setEnabled( false ); 1644 mNewSubTodoAction->setEnabled( false );
1639 } 1645 }
1640} 1646}
1641 1647
1642void MainWindow::enableIncidenceActions( bool enabled ) 1648void MainWindow::enableIncidenceActions( bool enabled )
1643{ 1649{
1644 mShowAction->setEnabled( enabled ); 1650 mShowAction->setEnabled( enabled );
1645 mEditAction->setEnabled( enabled ); 1651 mEditAction->setEnabled( enabled );
1646 mDeleteAction->setEnabled( enabled ); 1652 mDeleteAction->setEnabled( enabled );
1647 1653
1648 mCloneAction->setEnabled( enabled ); 1654 mCloneAction->setEnabled( enabled );
1649 mMoveAction->setEnabled( enabled ); 1655 mMoveAction->setEnabled( enabled );
1650 mBeamAction->setEnabled( enabled ); 1656 mBeamAction->setEnabled( enabled );
1651 mCancelAction->setEnabled( enabled ); 1657 mCancelAction->setEnabled( enabled );
1652} 1658}
1653 1659
1654void MainWindow::importOL() 1660void MainWindow::importOL()
1655{ 1661{
1656#ifdef _OL_IMPORT_ 1662#ifdef _OL_IMPORT_
1657 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1663 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1658 id->exec(); 1664 id->exec();
1659 delete id; 1665 delete id;
1660 mView->updateView(); 1666 mView->updateView();
1661#endif 1667#endif
1662} 1668}
1663void MainWindow::importBday() 1669void MainWindow::importBday()
1664{ 1670{
1665 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1671 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1666 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1672 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1667 i18n("Import!"), i18n("Cancel"), 0, 1673 i18n("Import!"), i18n("Cancel"), 0,
1668 0, 1 ); 1674 0, 1 );
1669 if ( result == 0 ) { 1675 if ( result == 0 ) {
1670 mView->importBday(); 1676 mView->importBday();
1671 1677
1672 } 1678 }
1673 1679
1674 1680
1675} 1681}
1676void MainWindow::importQtopia() 1682void MainWindow::importQtopia()
1677{ 1683{
1678 //#ifndef DESKTOP_VERSION 1684 //#ifndef DESKTOP_VERSION
1679 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1685 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1680#ifdef DESKTOP_VERSION 1686#ifdef DESKTOP_VERSION
1681 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1687 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1682#endif 1688#endif
1683 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1689 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1684 i18n("Import!"), i18n("Cancel"), 0, 1690 i18n("Import!"), i18n("Cancel"), 0,
1685 0, 1 ); 1691 0, 1 );
1686 if ( result == 0 ) { 1692 if ( result == 0 ) {
1687#ifndef DESKTOP_VERSION 1693#ifndef DESKTOP_VERSION
1688 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1694 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1689 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1695 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1690 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1696 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1691#else 1697#else
1692 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1698 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1693 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1699 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1694 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1700 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1695#endif 1701#endif
1696 mView->importQtopia( categories, datebook, todolist ); 1702 mView->importQtopia( categories, datebook, todolist );
1697 } 1703 }
1698#if 0 1704#if 0
1699 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1705 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1700 i18n("Not supported \non desktop!\n"), 1706 i18n("Not supported \non desktop!\n"),
1701 i18n("Ok"), i18n("Cancel"), 0, 1707 i18n("Ok"), i18n("Cancel"), 0,
1702 0, 1 ); 1708 0, 1 );
1703 1709
1704#endif 1710#endif
1705} 1711}
1706 1712
1707void MainWindow::saveOnClose() 1713void MainWindow::saveOnClose()
1708{ 1714{
1709 KOPrefs *p = KOPrefs::instance(); 1715 KOPrefs *p = KOPrefs::instance();
1710 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1716 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1711 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1717 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1712 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1718 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1713 if ( filterToolBar ) { 1719 if ( filterToolBar ) {
1714 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1720 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1715 } 1721 }
1716#ifdef DESKTOP_VERSION 1722#ifdef DESKTOP_VERSION
1717 1723
1718 QPoint myP; 1724 QPoint myP;
1719 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1725 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1720 if ( p->mToolBarHor ) 1726 if ( p->mToolBarHor )
1721 p->mToolBarUp = myP.y() > height()/2; 1727 p->mToolBarUp = myP.y() > height()/2;
1722 else 1728 else
1723 p->mToolBarUp = myP.x() > width()/2; 1729 p->mToolBarUp = myP.x() > width()/2;
1724 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1730 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1725 if ( p->mToolBarHorV ) 1731 if ( p->mToolBarHorV )
1726 p->mToolBarUpV = myP.y() > height()/2; 1732 p->mToolBarUpV = myP.y() > height()/2;
1727 else 1733 else
1728 p->mToolBarUpV = myP.x() > width()/2 ; 1734 p->mToolBarUpV = myP.x() > width()/2 ;
1729 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1735 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1730 if ( p->mToolBarHorN ) 1736 if ( p->mToolBarHorN )
1731 p->mToolBarUpN = myP.y() > height()/2; 1737 p->mToolBarUpN = myP.y() > height()/2;
1732 else 1738 else
1733 p->mToolBarUpN = myP.x() > width()/2 ; 1739 p->mToolBarUpN = myP.x() > width()/2 ;
1734 if ( filterToolBar ) { 1740 if ( filterToolBar ) {
1735 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1741 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1736 if ( p->mToolBarHorF ) 1742 if ( p->mToolBarHorF )
1737 p->mToolBarUpF = myP.y() > height()/2; 1743 p->mToolBarUpF = myP.y() > height()/2;
1738 else 1744 else
1739 p->mToolBarUpF = myP.x() > width()/2 ; 1745 p->mToolBarUpF = myP.x() > width()/2 ;
1740 } 1746 }
1741#else 1747#else
1742 if ( p->mToolBarHor ) 1748 if ( p->mToolBarHor )
1743 p->mToolBarUp = iconToolBar->y() > height()/2; 1749 p->mToolBarUp = iconToolBar->y() > height()/2;
1744 else 1750 else
1745 p->mToolBarUp = iconToolBar->x() > width()/2; 1751 p->mToolBarUp = iconToolBar->x() > width()/2;
1746 if ( p->mToolBarHorV ) 1752 if ( p->mToolBarHorV )
1747 p->mToolBarUpV = viewToolBar->y() > height()/2; 1753 p->mToolBarUpV = viewToolBar->y() > height()/2;
1748 else 1754 else
1749 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1755 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1750 1756
1751 if ( p->mToolBarHorN ) 1757 if ( p->mToolBarHorN )
1752 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1758 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1753 else 1759 else
1754 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1760 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1755 if ( filterToolBar ) { 1761 if ( filterToolBar ) {
1756 if ( p->mToolBarHorF ) 1762 if ( p->mToolBarHorF )
1757 p->mToolBarUpF = filterToolBar->y() > height()/2; 1763 p->mToolBarUpF = filterToolBar->y() > height()/2;
1758 else 1764 else
1759 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1765 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1760 } 1766 }
1761#endif 1767#endif
1762 1768
1763 1769
1764 mView->writeSettings(); 1770 mView->writeSettings();
1765 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1771 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1766 save(); 1772 save();
1767} 1773}
1768void MainWindow::slotModifiedChanged( bool changed ) 1774void MainWindow::slotModifiedChanged( bool changed )
1769{ 1775{
1770 if ( mBlockAtStartup ) 1776 if ( mBlockAtStartup )
1771 return; 1777 return;
1772 1778
1773 int msec; 1779 int msec;
1774 // we store the changes after 1 minute, 1780 // we store the changes after 1 minute,
1775 // and for safety reasons after 10 minutes again 1781 // and for safety reasons after 10 minutes again
1776 if ( !mSyncManager->blockSave() ) 1782 if ( !mSyncManager->blockSave() )
1777 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1783 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1778 else 1784 else
1779 msec = 1000 * 600; 1785 msec = 1000 * 600;
1780 mSaveTimer.start( msec, true ); // 1 minute 1786 mSaveTimer.start( msec, true ); // 1 minute
1781 qDebug("KO: Saving File in %d secs!", msec/1000); 1787 qDebug("KO: Saving File in %d secs!", msec/1000);
1782 mCalendarModifiedFlag = true; 1788 mCalendarModifiedFlag = true;
1783} 1789}
1784void MainWindow::saveStopTimer() 1790void MainWindow::saveStopTimer()
1785{ 1791{
1786 mSaveTimer.stop(); 1792 mSaveTimer.stop();
1787} 1793}
1788void MainWindow::save() 1794void MainWindow::save()
1789{ 1795{
1790 if ( !mCalendarModifiedFlag ) { 1796 if ( !mCalendarModifiedFlag ) {
1791 qDebug("KO: Calendar not modified. Nothing saved."); 1797 qDebug("KO: Calendar not modified. Nothing saved.");
1792 return; 1798 return;
1793 } 1799 }
1794 if ( mSyncManager->blockSave() ) 1800 if ( mSyncManager->blockSave() )
1795 return; 1801 return;
1796 mSyncManager->setBlockSave(true); 1802 mSyncManager->setBlockSave(true);
1797 if ( mView->checkFileVersion( defaultFileName()) ) { 1803 if ( mView->checkFileVersion( defaultFileName()) ) {
1798 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1804 QTime neededSaveTime = QDateTime::currentDateTime().time();
1799 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1805 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1800 qDebug("KO: Start saving data to file!"); 1806 qDebug("KO: Start saving data to file!");
1801 mView->saveCalendar( defaultFileName() ); 1807 mView->saveCalendar( defaultFileName() );
1802 mCalendarModifiedFlag = false; 1808 mCalendarModifiedFlag = false;
1803 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1809 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1804 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1810 qDebug("KO: Needed %d ms for saving.",msNeeded );
1805 QString savemes; 1811 QString savemes;
1806 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1812 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1807 setCaption(savemes); 1813 setCaption(savemes);
1808 } else 1814 } else
1809 setCaption(i18n("Saving cancelled!")); 1815 setCaption(i18n("Saving cancelled!"));
1810 mSyncManager->setBlockSave( false ); 1816 mSyncManager->setBlockSave( false );
1811} 1817}
1812 1818
1813void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1819void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1814{ 1820{
1815 if ( !e->isAutoRepeat() ) { 1821 if ( !e->isAutoRepeat() ) {
1816 mFlagKeyPressed = false; 1822 mFlagKeyPressed = false;
1817 } 1823 }
1818} 1824}
1819void MainWindow::keyPressEvent ( QKeyEvent * e ) 1825void MainWindow::keyPressEvent ( QKeyEvent * e )
1820{ 1826{
1821 qApp->processEvents(); 1827 qApp->processEvents();
1822 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1828 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1823 e->ignore(); 1829 e->ignore();
1824 // qDebug(" ignore %d",e->isAutoRepeat() ); 1830 // qDebug(" ignore %d",e->isAutoRepeat() );
1825 return; 1831 return;
1826 } 1832 }
1827 if (! e->isAutoRepeat() ) 1833 if (! e->isAutoRepeat() )
1828 mFlagKeyPressed = true; 1834 mFlagKeyPressed = true;
1829 KOPrefs *p = KOPrefs::instance(); 1835 KOPrefs *p = KOPrefs::instance();
1830 bool showSelectedDates = false; 1836 bool showSelectedDates = false;
1831 int size; 1837 int size;
1832 int pro = 0; 1838 int pro = 0;
1833 //qDebug("MainWindow::keyPressEvent "); 1839 //qDebug("MainWindow::keyPressEvent ");
1834 switch ( e->key() ) { 1840 switch ( e->key() ) {
1835 case Qt::Key_Right: 1841 case Qt::Key_Right:
1836 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1842 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1837 mView->goNextMonth(); 1843 mView->goNextMonth();
1838 else 1844 else
1839 mView->goNext(); 1845 mView->goNext();
1840 showSelectedDates = true; 1846 showSelectedDates = true;
1841 break; 1847 break;
1842 case Qt::Key_Left: 1848 case Qt::Key_Left:
1843 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1849 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1844 mView->goPreviousMonth(); 1850 mView->goPreviousMonth();
1845 else 1851 else
1846 mView->goPrevious(); 1852 mView->goPrevious();
1847 showSelectedDates = true; 1853 showSelectedDates = true;
1848 break; 1854 break;
1849 case Qt::Key_Down: 1855 case Qt::Key_Down:
1850 mView->viewManager()->agendaView()->scrollOneHourDown(); 1856 mView->viewManager()->agendaView()->scrollOneHourDown();
1851 break; 1857 break;
1852 case Qt::Key_Up: 1858 case Qt::Key_Up:
1853 mView->viewManager()->agendaView()->scrollOneHourUp(); 1859 mView->viewManager()->agendaView()->scrollOneHourUp();
1854 break; 1860 break;
1855 case Qt::Key_K: 1861 case Qt::Key_K:
1856 mView->viewManager()->showMonthViewWeek(); 1862 mView->viewManager()->showMonthViewWeek();
1857 break; 1863 break;
1858 case Qt::Key_I: 1864 case Qt::Key_I:
1859 mView->showIncidence(); 1865 mView->showIncidence();
1860 break; 1866 break;
1861 case Qt::Key_Delete: 1867 case Qt::Key_Delete:
1862 case Qt::Key_Backspace: 1868 case Qt::Key_Backspace:
1863 mView->deleteIncidence(); 1869 mView->deleteIncidence();
1864 break; 1870 break;
1865 case Qt::Key_D: 1871 case Qt::Key_D:
1866 mView->viewManager()->showDayView(); 1872 mView->viewManager()->showDayView();
1867 showSelectedDates = true; 1873 showSelectedDates = true;
1868 break; 1874 break;
1869 case Qt::Key_O: 1875 case Qt::Key_O:
1870 mView->toggleFilerEnabled( ); 1876 mView->toggleFilerEnabled( );
1871 break; 1877 break;
1872 case Qt::Key_0: 1878 case Qt::Key_0:
1873 case Qt::Key_1: 1879 case Qt::Key_1:
1874 case Qt::Key_2: 1880 case Qt::Key_2:
1875 case Qt::Key_3: 1881 case Qt::Key_3:
1876 case Qt::Key_4: 1882 case Qt::Key_4:
1877 case Qt::Key_5: 1883 case Qt::Key_5:
1878 case Qt::Key_6: 1884 case Qt::Key_6:
1879 case Qt::Key_7: 1885 case Qt::Key_7:
1880 case Qt::Key_8: 1886 case Qt::Key_8:
1881 case Qt::Key_9: 1887 case Qt::Key_9:
1882 pro = e->key()-48; 1888 pro = e->key()-48;
1883 if ( pro == 0 ) 1889 if ( pro == 0 )
1884 pro = 10; 1890 pro = 10;
1885 if ( e->state() == Qt::ControlButton) 1891 if ( e->state() == Qt::ControlButton)
1886 pro += 10; 1892 pro += 10;
1887 break; 1893 break;
1888 case Qt::Key_M: 1894 case Qt::Key_M:
1889 mView->viewManager()->showMonthView(); 1895 mView->viewManager()->showMonthView();
1890 showSelectedDates = true; 1896 showSelectedDates = true;
1891 break; 1897 break;
1892 case Qt::Key_Insert: 1898 case Qt::Key_Insert:
1893 mView->newEvent(); 1899 mView->newEvent();
1894 break; 1900 break;
1895 case Qt::Key_S : 1901 case Qt::Key_S :
1896 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1902 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1897 mView->newSubTodo(); 1903 mView->newSubTodo();
1898 else 1904 else
1899 mView->dialogManager()->showSearchDialog(); 1905 mView->dialogManager()->showSearchDialog();
1900 break; 1906 break;
1901 case Qt::Key_Y : 1907 case Qt::Key_Y :
1902 case Qt::Key_Z : 1908 case Qt::Key_Z :
1903 mView->viewManager()->showWorkWeekView(); 1909 mView->viewManager()->showWorkWeekView();
1904 showSelectedDates = true; 1910 showSelectedDates = true;
1905 break; 1911 break;
1906 case Qt::Key_U : 1912 case Qt::Key_U :
1907 mView->viewManager()->showWeekView(); 1913 mView->viewManager()->showWeekView();
1908 showSelectedDates = true; 1914 showSelectedDates = true;
1909 break; 1915 break;
1910 case Qt::Key_H : 1916 case Qt::Key_H :
1911 keyBindings(); 1917 keyBindings();
1912 break; 1918 break;
1913 case Qt::Key_W: 1919 case Qt::Key_W:
1914 mView->viewManager()->showWhatsNextView(); 1920 mView->viewManager()->showWhatsNextView();
1915 break; 1921 break;
1916 case Qt::Key_L: 1922 case Qt::Key_L:
1917 mView->viewManager()->showListView(); 1923 mView->viewManager()->showListView();
1918 break; 1924 break;
1919 case Qt::Key_N: 1925 case Qt::Key_N:
1920 mView->viewManager()->showNextView(); 1926 mView->viewManager()->showNextView();
1921 break; 1927 break;
1922 case Qt::Key_V: 1928 case Qt::Key_V:
1923 mView->viewManager()->showTodoView(); 1929 mView->viewManager()->showTodoView();
1924 break; 1930 break;
1925 case Qt::Key_C: 1931 case Qt::Key_C:
1926 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1932 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1927 break; 1933 break;
1928 case Qt::Key_P: 1934 case Qt::Key_P:
1929 mView->showDatePicker( ); 1935 mView->showDatePicker( );
1930 break; 1936 break;
1931 case Qt::Key_F: 1937 case Qt::Key_F:
1932 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1938 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1933 mView->editFilters(); 1939 mView->editFilters();
1934 else 1940 else
1935 mView->toggleFilter(); 1941 mView->toggleFilter();
1936 break; 1942 break;
1937 case Qt::Key_X: 1943 case Qt::Key_X:
1938 if ( e->state() == Qt::ControlButton ) 1944 if ( e->state() == Qt::ControlButton )
1939 mView->toggleDateNavigatorWidget(); 1945 mView->toggleDateNavigatorWidget();
1940 else { 1946 else {
1941 mView->viewManager()->showNextXView(); 1947 mView->viewManager()->showNextXView();
1942 showSelectedDates = true; 1948 showSelectedDates = true;
1943 } 1949 }
1944 break; 1950 break;
1945 case Qt::Key_Space: 1951 case Qt::Key_Space:
1946 mView->toggleExpand(); 1952 mView->toggleExpand();
1947 break; 1953 break;
1948 case Qt::Key_A: 1954 case Qt::Key_A:
1949 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1955 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1950 mView->showNextAlarms(); 1956 mView->showNextAlarms();
1951 else 1957 else
1952 mView->toggleAllDaySize(); 1958 mView->toggleAllDaySize();
1953 break; 1959 break;
1954 case Qt::Key_T: 1960 case Qt::Key_T:
1955 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1961 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1956 mView->newTodo(); 1962 mView->newTodo();
1957 else { 1963 else {
1958 mView->goToday(); 1964 mView->goToday();
1959 showSelectedDates = true; 1965 showSelectedDates = true;
1960 } 1966 }
1961 break; 1967 break;
1962 case Qt::Key_J: 1968 case Qt::Key_J:
1963 mView->viewManager()->showJournalView(); 1969 mView->viewManager()->showJournalView();
1964 break; 1970 break;
1965 case Qt::Key_B: 1971 case Qt::Key_B:
1966 mView->editIncidenceDescription();; 1972 mView->editIncidenceDescription();;
1967 break; 1973 break;
1968 // case Qt::Key_Return: 1974 // case Qt::Key_Return:
1969 case Qt::Key_E: 1975 case Qt::Key_E:
1970 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1976 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1971 mView->newEvent(); 1977 mView->newEvent();
1972 else 1978 else
1973 mView->editIncidence(); 1979 mView->editIncidence();
1974 break; 1980 break;
1975 case Qt::Key_Plus: 1981 case Qt::Key_Plus:
1976 size = p->mHourSize +2; 1982 size = p->mHourSize +2;
1977 if ( size <= 22 ) 1983 if ( size <= 22 )
1978 configureAgenda( size ); 1984 configureAgenda( size );
1979 break; 1985 break;
1980 case Qt::Key_Minus: 1986 case Qt::Key_Minus:
1981 size = p->mHourSize - 2; 1987 size = p->mHourSize - 2;
1982 if ( size >= 4 ) 1988 if ( size >= 4 )
1983 configureAgenda( size ); 1989 configureAgenda( size );
1984 break; 1990 break;
1985 1991
1986 1992
1987 default: 1993 default:
1988 e->ignore(); 1994 e->ignore();
1989 } 1995 }
1990 if ( pro > 0 ) { 1996 if ( pro > 0 ) {
1991 mView->selectFilter( pro-1 ); 1997 mView->selectFilter( pro-1 );
1992 } 1998 }
1993 if ( showSelectedDates ) { 1999 if ( showSelectedDates ) {
1994 ;// setCaptionToDates(); 2000 ;// setCaptionToDates();
1995 } 2001 }
1996 2002
1997} 2003}
1998void MainWindow::fillFilterMenuTB() 2004void MainWindow::fillFilterMenuTB()
1999{ 2005{
2000 selectFilterMenuTB->clear(); 2006 selectFilterMenuTB->clear();
2001 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2007 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2002 selectFilterMenuTB->insertSeparator(); 2008 selectFilterMenuTB->insertSeparator();
2003 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2009 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2004 2010
2005 selectFilterMenuTB->insertSeparator(); 2011 selectFilterMenuTB->insertSeparator();
2006 QPtrList<CalFilter> fili = mView->filters(); 2012 QPtrList<CalFilter> fili = mView->filters();
2007 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2013 CalFilter *curfilter = mView->filterView()->selectedFilter();
2008 CalFilter *filter = fili.first(); 2014 CalFilter *filter = fili.first();
2009 int iii = 2; 2015 int iii = 2;
2010 bool checkitem = mView->filterView()->filtersEnabled(); 2016 bool checkitem = mView->filterView()->filtersEnabled();
2011 while(filter) { 2017 while(filter) {
2012 selectFilterMenuTB->insertItem( filter->name(), iii ); 2018 selectFilterMenuTB->insertItem( filter->name(), iii );
2013 if ( filter == curfilter) 2019 if ( filter == curfilter)
2014 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2020 selectFilterMenuTB->setItemChecked( iii, checkitem );
2015 filter = fili.next(); 2021 filter = fili.next();
2016 ++iii; 2022 ++iii;
2017 } 2023 }
2018 if ( !checkitem ) 2024 if ( !checkitem )
2019 selectFilterMenuTB->setItemChecked( 1, true ); 2025 selectFilterMenuTB->setItemChecked( 1, true );
2020 2026
2021 int x = 0; 2027 int x = 0;
2022 int y = iconToolBar->height(); 2028 int y = iconToolBar->height();
2023 int dX = 0; 2029 int dX = 0;
2024 int dY = 0; 2030 int dY = 0;
2025 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2031 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2026 if ( iconToolBar->y() > height()/2 ) { 2032 if ( iconToolBar->y() > height()/2 ) {
2027 dY = selectFilterMenuTB->sizeHint().height()+8; 2033 dY = selectFilterMenuTB->sizeHint().height()+8;
2028 y = 0; 2034 y = 0;
2029 } 2035 }
2030 } else { 2036 } else {
2031 if ( iconToolBar->x() > width()/2 ) { // right side 2037 if ( iconToolBar->x() > width()/2 ) { // right side
2032 x=0; 2038 x=0;
2033 dX= selectFilterMenuTB->sizeHint().width()+8; 2039 dX= selectFilterMenuTB->sizeHint().width()+8;
2034 y = 0; 2040 y = 0;
2035 } else { 2041 } else {
2036 x= iconToolBar->width(); 2042 x= iconToolBar->width();
2037 y = 0; 2043 y = 0;
2038 } 2044 }
2039 } 2045 }
2040 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2046 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2041 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2047 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2042} 2048}
2043void MainWindow::fillFilterMenu() 2049void MainWindow::fillFilterMenu()
2044{ 2050{
2045 selectFilterMenu->clear(); 2051 selectFilterMenu->clear();
2046 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2052 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2047 selectFilterMenu->insertSeparator(); 2053 selectFilterMenu->insertSeparator();
2048 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2054 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2049 2055
2050 selectFilterMenu->insertSeparator(); 2056 selectFilterMenu->insertSeparator();
2051 QPtrList<CalFilter> fili = mView->filters(); 2057 QPtrList<CalFilter> fili = mView->filters();
2052 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2058 CalFilter *curfilter = mView->filterView()->selectedFilter();
2053 CalFilter *filter = fili.first(); 2059 CalFilter *filter = fili.first();
2054 int iii = 2; 2060 int iii = 2;
2055 bool checkitem = mView->filterView()->filtersEnabled(); 2061 bool checkitem = mView->filterView()->filtersEnabled();
2056 while(filter) { 2062 while(filter) {
2057 selectFilterMenu->insertItem( filter->name(), iii ); 2063 selectFilterMenu->insertItem( filter->name(), iii );
2058 if ( filter == curfilter) 2064 if ( filter == curfilter)
2059 selectFilterMenu->setItemChecked( iii, checkitem ); 2065 selectFilterMenu->setItemChecked( iii, checkitem );
2060 filter = fili.next(); 2066 filter = fili.next();
2061 ++iii; 2067 ++iii;
2062 } 2068 }
2063 if ( !checkitem ) 2069 if ( !checkitem )
2064 selectFilterMenu->setItemChecked( 1, true ); 2070 selectFilterMenu->setItemChecked( 1, true );
2065} 2071}
2066void MainWindow::fillFilterMenuPopup() 2072void MainWindow::fillFilterMenuPopup()
2067{ 2073{
2068 filterPopupMenu->clear(); 2074 filterPopupMenu->clear();
2069 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2075 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2070 2076
2071 filterPopupMenu->insertSeparator(); 2077 filterPopupMenu->insertSeparator();
2072 QPtrList<CalFilter> fili = mView->filters(); 2078 QPtrList<CalFilter> fili = mView->filters();
2073 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2079 CalFilter *curfilter = mView->filterView()->selectedFilter();
2074 CalFilter *filter = fili.first(); 2080 CalFilter *filter = fili.first();
2075 int iii = 1; 2081 int iii = 1;
2076 bool checkitem = mView->filterView()->filtersEnabled(); 2082 bool checkitem = mView->filterView()->filtersEnabled();
2077 while(filter) { 2083 while(filter) {
2078 filterPopupMenu->insertItem( filter->name(), iii ); 2084 filterPopupMenu->insertItem( filter->name(), iii );
2079 if ( filter == curfilter) 2085 if ( filter == curfilter)
2080 filterPopupMenu->setItemChecked( iii, checkitem ); 2086 filterPopupMenu->setItemChecked( iii, checkitem );
2081 filter = fili.next(); 2087 filter = fili.next();
2082 ++iii; 2088 ++iii;
2083 } 2089 }
2084 if ( !checkitem ) 2090 if ( !checkitem )
2085 filterPopupMenu->setItemChecked( 0, true ); 2091 filterPopupMenu->setItemChecked( 0, true );
2086} 2092}
2087void MainWindow::selectFilter( int fil ) 2093void MainWindow::selectFilter( int fil )
2088{ 2094{
2089 2095
2090 if ( fil == 0 ) { 2096 if ( fil == 0 ) {
2091 mView->editFilters( ); 2097 mView->editFilters( );
2092 } else if ( fil == 1 ){ 2098 } else if ( fil == 1 ){
2093 if ( mView->filterView()->filtersEnabled() ) 2099 if ( mView->filterView()->filtersEnabled() )
2094 mView->toggleFilerEnabled( ); 2100 mView->toggleFilerEnabled( );
2095 } else { 2101 } else {
2096 if ( !mView->filterView()->filtersEnabled() ) { 2102 if ( !mView->filterView()->filtersEnabled() ) {
2097 mView->filterView()->blockSignals( true ); 2103 mView->filterView()->blockSignals( true );
2098 mView->toggleFilerEnabled( ); 2104 mView->toggleFilerEnabled( );
2099 mView->filterView()->blockSignals( false ); 2105 mView->filterView()->blockSignals( false );
2100 } 2106 }
2101 mView->selectFilter( fil-2 ); 2107 mView->selectFilter( fil-2 );
2102 } 2108 }
2103} 2109}
2104void MainWindow::updateFilterToolbar() 2110void MainWindow::updateFilterToolbar()
2105{ 2111{
2106 if ( filterMenubar ) { 2112 if ( filterMenubar ) {
2107 if ( !mView->filterView()->filtersEnabled() ) { 2113 if ( !mView->filterView()->filtersEnabled() ) {
2108 filterMenubar->changeItem( 0, i18n("No Filter") ); 2114 filterMenubar->changeItem( 0, i18n("No Filter") );
2109 } else { 2115 } else {
2110 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2116 CalFilter *curfilter = mView->filterView()->selectedFilter();
2111 if ( curfilter ) { 2117 if ( curfilter ) {
2112 filterMenubar->changeItem( 0, curfilter->name() ); 2118 filterMenubar->changeItem( 0, curfilter->name() );
2113 } 2119 }
2114 } 2120 }
2115 } 2121 }
2116} 2122}
2117void MainWindow::selectFilterPopup( int fil ) 2123void MainWindow::selectFilterPopup( int fil )
2118{ 2124{
2119 selectFilter( fil + 1 ); 2125 selectFilter( fil + 1 );
2120 2126
2121} 2127}
2122void MainWindow::configureToolBar( int item ) 2128void MainWindow::configureToolBar( int item )
2123{ 2129{
2124 2130
2125 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2131 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2126 KOPrefs *p = KOPrefs::instance(); 2132 KOPrefs *p = KOPrefs::instance();
2127 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2133 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2128 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2134 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2129 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2135 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2130 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2136 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2131 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2137 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2132 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2138 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2133 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2139 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2134 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2140 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2135 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2141 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2136 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2142 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2137 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2143 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2138 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2144 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2139 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2145 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2140 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2146 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2141 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2147 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2142 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2148 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2143 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2149 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2144 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2150 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2145 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2151 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2146 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2152 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2147 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2153 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2148 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2154 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2149 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2155 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2150 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2156 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2151 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2157 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2152 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2158 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2153 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2159 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2154 // initActions(); 2160 // initActions();
2155} 2161}
2156void MainWindow::setCaption ( const QString & c ) 2162void MainWindow::setCaption ( const QString & c )
2157{ 2163{
2158 QString cap = c; 2164 QString cap = c;
2159 cap.replace( QRegExp("\n"), " " ); 2165 cap.replace( QRegExp("\n"), " " );
2160 cap = cap.stripWhiteSpace(); 2166 cap = cap.stripWhiteSpace();
2161 if ( cap.isEmpty() ) 2167 if ( cap.isEmpty() )
2162 cap = "KO/Pi"; 2168 cap = "KO/Pi";
2163 QWidget::setCaption( cap ); 2169 QWidget::setCaption( cap );
2164} 2170}
2165void MainWindow::setCaptionToDates() 2171void MainWindow::setCaptionToDates()
2166{ 2172{
2167 QString selDates; 2173 QString selDates;
2168 QDate date = mView->startDate(); 2174 QDate date = mView->startDate();
2169 if ( ! date.isValid() ) { 2175 if ( ! date.isValid() ) {
2170 setCaption(""); 2176 setCaption("");
2171 return; 2177 return;
2172 } 2178 }
2173 selDates = KGlobal::locale()->formatDate( date, true); 2179 selDates = KGlobal::locale()->formatDate( date, true);
2174 if (mView->startDate() < mView->endDate() ) 2180 if (mView->startDate() < mView->endDate() )
2175 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2181 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2176 else { 2182 else {
2177 QString addString; 2183 QString addString;
2178 if ( date == QDateTime::currentDateTime().date() ) 2184 if ( date == QDateTime::currentDateTime().date() )
2179 addString = i18n("Today"); 2185 addString = i18n("Today");
2180 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2186 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2181 addString = i18n("Tomorrow"); 2187 addString = i18n("Tomorrow");
2182 if ( !addString.isEmpty() ) 2188 if ( !addString.isEmpty() )
2183 selDates = addString+", "+selDates ; 2189 selDates = addString+", "+selDates ;
2184 } 2190 }
2185 setCaption( i18n("Dates: ") + selDates ); 2191 setCaption( i18n("Dates: ") + selDates );
2186 2192
2187} 2193}
2188void MainWindow::showConfigureAgenda( ) 2194void MainWindow::showConfigureAgenda( )
2189{ 2195{
2190 int iii; 2196 int iii;
2191 for ( iii = 1;iii<= 10 ;++iii ){ 2197 for ( iii = 1;iii<= 10 ;++iii ){
2192 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2198 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2193 } 2199 }
2194 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2200 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2195} 2201}
2196void MainWindow::configureAgenda( int item ) 2202void MainWindow::configureAgenda( int item )
2197{ 2203{
2198 if ( KOPrefs::instance()->mHourSize == item ) 2204 if ( KOPrefs::instance()->mHourSize == item )
2199 return; 2205 return;
2200 KOPrefs::instance()->mHourSize=item; 2206 KOPrefs::instance()->mHourSize=item;
2201 mView->viewManager()->agendaView()->updateConfig(); 2207 mView->viewManager()->agendaView()->updateConfig();
2202} 2208}
2203 2209
2204void MainWindow::saveCalendar() 2210void MainWindow::saveCalendar()
2205{ 2211{
2206 QString fn = KOPrefs::instance()->mLastSaveFile; 2212 QString fn = KOPrefs::instance()->mLastSaveFile;
2207 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 2213 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
2208 2214
2209 if ( fn == "" ) 2215 if ( fn == "" )
2210 return; 2216 return;
2211 QFileInfo info; 2217 QFileInfo info;
2212 info.setFile( fn ); 2218 info.setFile( fn );
2213 QString mes; 2219 QString mes;
2214 bool createbup = true; 2220 bool createbup = true;
2215 if ( info. exists() ) { 2221 if ( info. exists() ) {
2216 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 2222 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
2217 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2223 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2218 i18n("Overwrite!"), i18n("Cancel"), 0, 2224 i18n("Overwrite!"), i18n("Cancel"), 0,
2219 0, 1 ); 2225 0, 1 );
2220 if ( result != 0 ) { 2226 if ( result != 0 ) {
2221 createbup = false; 2227 createbup = false;
2222 } 2228 }
2223 } 2229 }
2224 if ( createbup ) { 2230 if ( createbup ) {
2225 mView->saveCalendar( fn ); 2231 mView->saveCalendar( fn );
2226 mes = i18n("KO/Pi:Saved %1").arg(fn); 2232 mes = i18n("KO/Pi:Saved %1").arg(fn);
2227 KOPrefs::instance()->mLastSaveFile = fn; 2233 KOPrefs::instance()->mLastSaveFile = fn;
2228 setCaption(mes); 2234 setCaption(mes);
2229 } 2235 }
2230} 2236}
2231void MainWindow::loadCalendar() 2237void MainWindow::loadCalendar()
2232{ 2238{
2233 2239
2234 QString fn = KOPrefs::instance()->mLastLoadFile; 2240 QString fn = KOPrefs::instance()->mLastLoadFile;
2235 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2241 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2236 2242
2237 if ( fn == "" ) 2243 if ( fn == "" )
2238 return; 2244 return;
2239 QFileInfo info; 2245 QFileInfo info;
2240 info.setFile( fn ); 2246 info.setFile( fn );
2241 QString mess; 2247 QString mess;
2242 bool loadbup = true; 2248 bool loadbup = true;
2243 if ( info. exists() ) { 2249 if ( info. exists() ) {
2244 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2250 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2245 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2251 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2246 mess, 2252 mess,
2247 i18n("Load!"), i18n("Cancel"), 0, 2253 i18n("Load!"), i18n("Cancel"), 0,
2248 0, 1 ); 2254 0, 1 );
2249 if ( result != 0 ) { 2255 if ( result != 0 ) {
2250 loadbup = false; 2256 loadbup = false;
2251 } 2257 }
2252 } else { 2258 } else {
2253 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2259 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2254 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2260 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2255 0, 1 ); 2261 0, 1 );
2256 2262
2257 return; 2263 return;
2258 } 2264 }
2259 if ( loadbup ) { 2265 if ( loadbup ) {
2260 mView->openCalendar( fn ); 2266 mView->openCalendar( fn );
2261 KOPrefs::instance()->mLastLoadFile = fn; 2267 KOPrefs::instance()->mLastLoadFile = fn;
2262 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2268 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2263 setCaption(mess); 2269 setCaption(mess);
2264 } 2270 }
2265 2271
2266} 2272}
2267void MainWindow::quickImportIcal() 2273void MainWindow::quickImportIcal()
2268{ 2274{
2269 importFile( KOPrefs::instance()->mLastImportFile, false ); 2275 importFile( KOPrefs::instance()->mLastImportFile, false );
2270} 2276}
2271void MainWindow::importFile( QString fn, bool quick ) 2277void MainWindow::importFile( QString fn, bool quick )
2272{ 2278{
2273 QFileInfo info; 2279 QFileInfo info;
2274 info.setFile( fn ); 2280 info.setFile( fn );
2275 QString mess; 2281 QString mess;
2276 bool loadbup = true; 2282 bool loadbup = true;
2277 if ( !info. exists() ) { 2283 if ( !info. exists() ) {
2278 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2284 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2279 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2285 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2280 mess ); 2286 mess );
2281 return; 2287 return;
2282 } 2288 }
2283 int result = 0; 2289 int result = 0;
2284 if ( !quick ) { 2290 if ( !quick ) {
2285 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2291 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2286 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2292 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2287 mess, 2293 mess,
2288 "Import", "Cancel", 0, 2294 "Import", "Cancel", 0,
2289 0, 1 ); 2295 0, 1 );
2290 } 2296 }
2291 if ( result == 0 ) { 2297 if ( result == 0 ) {
2292 if ( mView->openCalendar( fn, true )) { 2298 if ( mView->openCalendar( fn, true )) {
2293 KOPrefs::instance()->mLastImportFile = fn; 2299 KOPrefs::instance()->mLastImportFile = fn;
2294 setCaption(i18n("Imported file successfully")); 2300 setCaption(i18n("Imported file successfully"));
2295 } else { 2301 } else {
2296 setCaption(i18n("Error importing file")); 2302 setCaption(i18n("Error importing file"));
2297 } 2303 }
2298 } 2304 }
2299} 2305}
2300 2306
2301void MainWindow::importIcal() 2307void MainWindow::importIcal()
2302{ 2308{
2303 2309
2304 QString fn =KOPrefs::instance()->mLastImportFile; 2310 QString fn =KOPrefs::instance()->mLastImportFile;
2305 2311
2306 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2312 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2307 if ( fn == "" ) 2313 if ( fn == "" )
2308 return; 2314 return;
2309 importFile( fn, true ); 2315 importFile( fn, true );
2310 2316
2311} 2317}
2312 2318
2313void MainWindow::exportVCalendar() 2319void MainWindow::exportVCalendar()
2314{ 2320{
2315 QString fn = KOPrefs::instance()->mLastVcalFile; 2321 QString fn = KOPrefs::instance()->mLastVcalFile;
2316 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2322 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2317 if ( fn == "" ) 2323 if ( fn == "" )
2318 return; 2324 return;
2319 QFileInfo info; 2325 QFileInfo info;
2320 info.setFile( fn ); 2326 info.setFile( fn );
2321 QString mes; 2327 QString mes;
2322 bool createbup = true; 2328 bool createbup = true;
2323 if ( info. exists() ) { 2329 if ( info. exists() ) {
2324 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2330 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2325 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2331 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2326 i18n("Overwrite!"), i18n("Cancel"), 0, 2332 i18n("Overwrite!"), i18n("Cancel"), 0,
2327 0, 1 ); 2333 0, 1 );
2328 if ( result != 0 ) { 2334 if ( result != 0 ) {
2329 createbup = false; 2335 createbup = false;
2330 } 2336 }
2331 } 2337 }
2332 if ( createbup ) { 2338 if ( createbup ) {
2333 if ( mView->exportVCalendar( fn ) ) { 2339 if ( mView->exportVCalendar( fn ) ) {
2334 KOPrefs::instance()->mLastVcalFile = fn; 2340 KOPrefs::instance()->mLastVcalFile = fn;
2335 if ( fn.length() > 20 ) 2341 if ( fn.length() > 20 )
2336 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2342 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2337 else 2343 else
2338 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2344 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2339 setCaption(mes); 2345 setCaption(mes);
2340 } 2346 }
2341 } 2347 }
2342 2348
2343} 2349}
2344QString MainWindow::sentSyncFile() 2350QString MainWindow::sentSyncFile()
2345{ 2351{
2346#ifdef DESKTOP_VERSION 2352#ifdef DESKTOP_VERSION
2347 return locateLocal( "tmp", "copysynccal.ics" ); 2353 return locateLocal( "tmp", "copysynccal.ics" );
2348#else 2354#else
2349 return QString( "/tmp/copysynccal.ics" ); 2355 return QString( "/tmp/copysynccal.ics" );
2350#endif 2356#endif
2351} 2357}
2352 2358
2353void MainWindow::syncFileRequest() 2359void MainWindow::syncFileRequest()
2354{ 2360{
2355 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2361 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2356 mSyncManager->slotSyncMenu( 999 ); 2362 mSyncManager->slotSyncMenu( 999 );
2357 } 2363 }
2358 2364
2359 setCaption(i18n("Saving Data to temp file ..." )); 2365 setCaption(i18n("Saving Data to temp file ..." ));
2360 mView->saveCalendar( sentSyncFile() ); 2366 mView->saveCalendar( sentSyncFile() );
2361 setCaption(i18n("Data saved to temp file!" )); 2367 setCaption(i18n("Data saved to temp file!" ));
2362 2368
2363} 2369}
2364void MainWindow::getFile( bool success ) 2370void MainWindow::getFile( bool success )
2365{ 2371{
2366 if ( ! success ) { 2372 if ( ! success ) {
2367 setCaption( i18n("Error receiving file. Nothing changed!") ); 2373 setCaption( i18n("Error receiving file. Nothing changed!") );
2368 return; 2374 return;
2369 } 2375 }
2370 mView->openCalendar( sentSyncFile() ); 2376 mView->openCalendar( sentSyncFile() );
2371 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2377 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2372 mSyncManager->slotSyncMenu( 999 ); 2378 mSyncManager->slotSyncMenu( 999 );
2373 } 2379 }
2374 setCaption( i18n("Pi-Sync successful!") ); 2380 setCaption( i18n("Pi-Sync successful!") );
2375} 2381}
2376 2382
2377void MainWindow::printSel( ) 2383void MainWindow::printSel( )
2378{ 2384{
2379 mView->viewManager()->agendaView()->agenda()->printSelection(); 2385 mView->viewManager()->agendaView()->agenda()->printSelection();
2380} 2386}
2381 2387
2382void MainWindow::printCal() 2388void MainWindow::printCal()
2383{ 2389{
2384 mView->print();//mCp->showDialog(); 2390 mView->print();//mCp->showDialog();
2385} 2391}
2386 2392
2387 2393
2388#include "libkdepim/kdatepicker.h" 2394#include "libkdepim/kdatepicker.h"
2389#include <kdatetbl.h> 2395#include <kdatetbl.h>
2390 2396
2391void MainWindow::weekAction() 2397void MainWindow::weekAction()
2392{ 2398{
2393 int month; 2399 int month;
2394 KPopupFrame* popup = new KPopupFrame(this); 2400 KPopupFrame* popup = new KPopupFrame(this);
2395 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2401 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2396 // ----- 2402 // -----
2397 picker->resize(picker->sizeHint()); 2403 picker->resize(picker->sizeHint());
2398 popup->setMainWidget(picker); 2404 popup->setMainWidget(picker);
2399 picker->setFocus(); 2405 picker->setFocus();
2400 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2406 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2401 int x = 0; 2407 int x = 0;
2402 int y = iconToolBar->height(); 2408 int y = iconToolBar->height();
2403 int dX = 0; 2409 int dX = 0;
2404 int dY = 0; 2410 int dY = 0;
2405 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2411 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2406 if ( iconToolBar->y() > height()/2 ) { 2412 if ( iconToolBar->y() > height()/2 ) {
2407 dY = picker->sizeHint().height()+8; 2413 dY = picker->sizeHint().height()+8;
2408 y = 0; 2414 y = 0;
2409 } 2415 }
2410 } else { 2416 } else {
2411 if ( iconToolBar->x() > width()/2 ) { // right side 2417 if ( iconToolBar->x() > width()/2 ) { // right side
2412 x=0; 2418 x=0;
2413 dX= picker->sizeHint().width()+8; 2419 dX= picker->sizeHint().width()+8;
2414 y = 0; 2420 y = 0;
2415 } else { 2421 } else {
2416 x= iconToolBar->width(); 2422 x= iconToolBar->width();
2417 y = 0; 2423 y = 0;
2418 } 2424 }
2419 } 2425 }
2420 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2426 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2421 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2427 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2422 { 2428 {
2423 month = picker->getResult(); 2429 month = picker->getResult();
2424 emit selectWeek ( month ); 2430 emit selectWeek ( month );
2425 //qDebug("weekSelected %d ", month); 2431 //qDebug("weekSelected %d ", month);
2426 } 2432 }
2427 delete popup; 2433 delete popup;
2428} 2434}
2429 2435
2430void MainWindow::hideEvent ( QHideEvent * ) 2436void MainWindow::hideEvent ( QHideEvent * )
2431{ 2437{
2432 QString message; 2438 QString message;
2433 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2439 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2434 if ( nextA.isValid() ) { 2440 if ( nextA.isValid() ) {
2435 QString sum = mCalendar->nextSummary(); 2441 QString sum = mCalendar->nextSummary();
2436 2442
2437 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2443 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2438 setCaption( message ); 2444 setCaption( message );
2439 } 2445 }
2440} 2446}
2441 2447
2442void MainWindow::resizeEvent( QResizeEvent* e) 2448void MainWindow::resizeEvent( QResizeEvent* e)
2443{ 2449{
2444#ifndef DESKTOP_VERSION 2450#ifndef DESKTOP_VERSION
2445 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2451 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2446 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2452 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2447 filterToolBar->hide(); 2453 filterToolBar->hide();
2448 else 2454 else
2449 filterToolBar->show(); 2455 filterToolBar->show();
2450 } 2456 }
2451#endif 2457#endif
2452 QMainWindow::resizeEvent( e); 2458 QMainWindow::resizeEvent( e);
2453} 2459}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index 8fd3d24..6895e36 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,166 +1,167 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14#ifndef DESKTOP_VERSION 14#ifndef DESKTOP_VERSION
15#include <qcopchannel_qws.h> 15#include <qcopchannel_qws.h>
16#endif 16#endif
17class QAction; 17class QAction;
18class CalendarView; 18class CalendarView;
19class KSyncProfile; 19class KSyncProfile;
20#ifdef DESKTOP_VERSION 20#ifdef DESKTOP_VERSION
21 21
22#define QPEToolBar QToolBar 22#define QPEToolBar QToolBar
23#define QPEMenuBar QMenuBar 23#define QPEMenuBar QMenuBar
24#endif 24#endif
25class QPEToolBar; 25class QPEToolBar;
26class QPEMenuBar; 26class QPEMenuBar;
27 27
28 28
29namespace KCal { 29namespace KCal {
30class CalendarLocal; 30class CalendarLocal;
31} 31}
32 32
33using namespace KCal; 33using namespace KCal;
34 34
35class MainWindow : public QMainWindow 35class MainWindow : public QMainWindow
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38 public: 38 public:
39 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 39 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
40 ~MainWindow(); 40 ~MainWindow();
41 bool beamReceiveEnabled(); 41 bool beamReceiveEnabled();
42 static QString defaultFileName(); 42 static QString defaultFileName();
43 static QString syncFileName(); 43 static QString syncFileName();
44 static QString resourcePath(); 44 static QString resourcePath();
45 public slots: 45 public slots:
46 void setUsesBigPixmaps ( bool );
46 void setCaption ( const QString & ); 47 void setCaption ( const QString & );
47 void updateWeekNum(const KCal::DateList &); 48 void updateWeekNum(const KCal::DateList &);
48 void updateWeek(QDate); 49 void updateWeek(QDate);
49 void updateFilterToolbar(); 50 void updateFilterToolbar();
50 virtual void showMaximized (); 51 virtual void showMaximized ();
51 void configureAgenda( int ); 52 void configureAgenda( int );
52 void recieve( const QCString& msg, const QByteArray& data ); 53 void recieve( const QCString& msg, const QByteArray& data );
53 protected slots: 54 protected slots:
54 void setCaptionToDates(); 55 void setCaptionToDates();
55 void weekAction(); 56 void weekAction();
56 void about(); 57 void about();
57 void licence(); 58 void licence();
58 void faq(); 59 void faq();
59 void usertrans(); 60 void usertrans();
60 void features(); 61 void features();
61 void synchowto(); 62 void synchowto();
62 void storagehowto(); 63 void storagehowto();
63 void timetrackinghowto(); 64 void timetrackinghowto();
64 void kdesynchowto(); 65 void kdesynchowto();
65 void multisynchowto(); 66 void multisynchowto();
66 void whatsNew(); 67 void whatsNew();
67 void keyBindings(); 68 void keyBindings();
68 void aboutAutoSaving();; 69 void aboutAutoSaving();;
69 void aboutKnownBugs(); 70 void aboutKnownBugs();
70 71
71 void processIncidenceSelection( Incidence * ); 72 void processIncidenceSelection( Incidence * );
72 73
73 void importQtopia(); 74 void importQtopia();
74 void importBday(); 75 void importBday();
75 void importOL(); 76 void importOL();
76 void importIcal(); 77 void importIcal();
77 void importFile( QString, bool ); 78 void importFile( QString, bool );
78 void quickImportIcal(); 79 void quickImportIcal();
79 80
80 void slotModifiedChanged( bool ); 81 void slotModifiedChanged( bool );
81 82
82 void save(); 83 void save();
83 void saveStopTimer(); 84 void saveStopTimer();
84 void configureToolBar( int ); 85 void configureToolBar( int );
85 void printSel(); 86 void printSel();
86 void printCal(); 87 void printCal();
87 void saveCalendar(); 88 void saveCalendar();
88 void loadCalendar(); 89 void loadCalendar();
89 void exportVCalendar(); 90 void exportVCalendar();
90 void fillFilterMenu(); 91 void fillFilterMenu();
91 void fillFilterMenuTB(); 92 void fillFilterMenuTB();
92 void selectFilter( int ); 93 void selectFilter( int );
93 void fillFilterMenuPopup(); 94 void fillFilterMenuPopup();
94 void selectFilterPopup( int ); 95 void selectFilterPopup( int );
95 void exportToPhone( int ); 96 void exportToPhone( int );
96 void toggleBeamReceive(); 97 void toggleBeamReceive();
97 void disableBR(bool); 98 void disableBR(bool);
98 signals: 99 signals:
99 void selectWeek ( int ); 100 void selectWeek ( int );
100 private slots: 101 private slots:
101 void showConfigureAgenda(); 102 void showConfigureAgenda();
102 void getFile( bool ); 103 void getFile( bool );
103 void syncFileRequest(); 104 void syncFileRequest();
104 105
105 protected: 106 protected:
106 void hideEvent ( QHideEvent * ); 107 void hideEvent ( QHideEvent * );
107 QString sentSyncFile(); 108 QString sentSyncFile();
108 void displayText( QString, QString); 109 void displayText( QString, QString);
109 void enableIncidenceActions( bool ); 110 void enableIncidenceActions( bool );
110 111
111 private: 112 private:
112 bool mBRdisabled; 113 bool mBRdisabled;
113#ifndef DESKTOP_VERSION 114#ifndef DESKTOP_VERSION
114 QCopChannel* infrared; 115 QCopChannel* infrared;
115#endif 116#endif
116 QAction* brAction; 117 QAction* brAction;
117 KSyncManager* mSyncManager; 118 KSyncManager* mSyncManager;
118 bool mClosed; 119 bool mClosed;
119 void saveOnClose(); 120 void saveOnClose();
120 bool mFlagKeyPressed; 121 bool mFlagKeyPressed;
121 bool mBlockAtStartup; 122 bool mBlockAtStartup;
122 QPEToolBar *iconToolBar; 123 QPEToolBar *iconToolBar;
123 QPEToolBar *viewToolBar; 124 QPEToolBar *viewToolBar;
124 QPEToolBar *navigatorToolBar; 125 QPEToolBar *navigatorToolBar;
125 QPEToolBar *filterToolBar; 126 QPEToolBar *filterToolBar;
126 QMenuBar *filterMenubar; 127 QMenuBar *filterMenubar;
127 QPopupMenu * filterPopupMenu; 128 QPopupMenu * filterPopupMenu;
128 void initActions(); 129 void initActions();
129 void setDefaultPreferences(); 130 void setDefaultPreferences();
130 void resizeEvent( QResizeEvent* e); 131 void resizeEvent( QResizeEvent* e);
131 void keyPressEvent ( QKeyEvent * ) ; 132 void keyPressEvent ( QKeyEvent * ) ;
132 void keyReleaseEvent ( QKeyEvent * ) ; 133 void keyReleaseEvent ( QKeyEvent * ) ;
133 QPopupMenu *configureToolBarMenu; 134 QPopupMenu *configureToolBarMenu;
134 QPopupMenu *selectFilterMenu; 135 QPopupMenu *selectFilterMenu;
135 QPopupMenu *selectFilterMenuTB; 136 QPopupMenu *selectFilterMenuTB;
136 QPopupMenu *configureAgendaMenu, *syncMenu; 137 QPopupMenu *configureAgendaMenu, *syncMenu;
137 CalendarLocal *mCalendar; 138 CalendarLocal *mCalendar;
138 CalendarView *mView; 139 CalendarView *mView;
139 QAction *mNewSubTodoAction; 140 QAction *mNewSubTodoAction;
140 QAction *mWeekAction; 141 QAction *mWeekAction;
141 QFont mWeekFont; 142 QFont mWeekFont;
142 QPixmap mWeekPixmap; 143 QPixmap mWeekPixmap;
143 QColor mWeekBgColor; 144 QColor mWeekBgColor;
144 145
145 QAction *mShowAction; 146 QAction *mShowAction;
146 QAction *mEditAction; 147 QAction *mEditAction;
147 QAction *mDeleteAction; 148 QAction *mDeleteAction;
148 QAction *mCloneAction; 149 QAction *mCloneAction;
149 QAction *mMoveAction; 150 QAction *mMoveAction;
150 QAction *mBeamAction; 151 QAction *mBeamAction;
151 QAction *mCancelAction; 152 QAction *mCancelAction;
152 153
153 QAction *mToggleNav; 154 QAction *mToggleNav;
154 QAction *mToggleFilter; 155 QAction *mToggleFilter;
155 QAction *mToggleAllday; 156 QAction *mToggleAllday;
156 QAction *actionFilterMenuTB; 157 QAction *actionFilterMenuTB;
157 158
158 void closeEvent( QCloseEvent* ce ); 159 void closeEvent( QCloseEvent* ce );
159 QTimer mSaveTimer; 160 QTimer mSaveTimer;
160 //bool mBlockSaveFlag; 161 //bool mBlockSaveFlag;
161 bool mCalendarModifiedFlag; 162 bool mCalendarModifiedFlag;
162 QPixmap loadPixmap( QString ); 163 QPixmap loadPixmap( QString );
163}; 164};
164 165
165 166
166#endif 167#endif