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,543 +1,547 @@
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()))
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c32a2a4..53ebdb2 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,450 +1,450 @@
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 )
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index fd86095..b94916a 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,724 +1,729 @@
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;
@@ -800,468 +805,469 @@ QPtrList<Incidence> KOListView::selectedIncidences()
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,476 +1,480 @@
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 );
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index f26d16d..e95039d 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -207,769 +207,775 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
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 }
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 87cef20..68e5e5a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -209,768 +209,774 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
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_
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