summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-02 10:58:10 (UTC)
committer zautrix <zautrix>2005-02-02 10:58:10 (UTC)
commitd2f6c50fb3b236e37aaa46ade819ab163f19868a (patch) (unidiff)
tree02b2c7bbcd6d78140def0650fa4b440199e04ef7 /korganizer
parent5bc675bc7e9d5d6fa2d2bc48675a7cfa985ab2c7 (diff)
downloadkdepimpi-d2f6c50fb3b236e37aaa46ade819ab163f19868a.zip
kdepimpi-d2f6c50fb3b236e37aaa46ade819ab163f19868a.tar.gz
kdepimpi-d2f6c50fb3b236e37aaa46ade819ab163f19868a.tar.bz2
qwt added
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp23
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/kolistview.cpp28
-rw-r--r--korganizer/kolistview.h1
-rw-r--r--korganizer/kotodoview.cpp28
-rw-r--r--korganizer/kotodoview.h1
6 files changed, 80 insertions, 2 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 5f9ed92..df7d612 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,740 +1,759 @@
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#define AGENDA_ICON_SIZE 7 38#define AGENDA_ICON_SIZE 7
39#endif 39#endif
40#include <libkcal/icaldrag.h> 40#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h> 41#include <libkcal/vcaldrag.h>
42#include <libkcal/kincidenceformatter.h> 42#include <libkcal/kincidenceformatter.h>
43extern int globalFlagBlockAgenda; 43extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint; 44extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate; 45extern int globalFlagBlockAgendaItemUpdate;
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koagendaitem.h" 49#include "koagendaitem.h"
50//#include "koagendaitem.moc" 50//#include "koagendaitem.moc"
51 51
52 52
53//-------------------------------------------------------------------------- 53//--------------------------------------------------------------------------
54 54
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 56
57//-------------------------------------------------------------------------- 57//--------------------------------------------------------------------------
58 58
59class KOAgendaItemWhatsThis :public QWhatsThis
60{
61public:
62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
63
64protected:
65 virtual QString text( const QPoint& )
66 {
67 return _view->getWhatsThisText() ;
68 }
69private:
70 KOAgendaItem * _view;
71};
72
59KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
60 const char *name,WFlags) : 74 const char *name,WFlags) :
61 QWidget(parent, name), mIncidence(incidence), mDate(qd) 75 QWidget(parent, name), mIncidence(incidence), mDate(qd)
62{ 76{
63#ifndef DESKTOP_VERSION 77#ifndef DESKTOP_VERSION
64 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 78 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
65#endif 79#endif
80 new KOAgendaItemWhatsThis(this);
66 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
67 setWFlags ( wflags); 82 setWFlags ( wflags);
68 mAllDay = allday; 83 mAllDay = allday;
69 init ( incidence, qd ); 84 init ( incidence, qd );
70 setMouseTracking(true); 85 setMouseTracking(true);
71 //setAcceptDrops(true); 86 //setAcceptDrops(true);
72 xPaintCoord = -1; 87 xPaintCoord = -1;
73 yPaintCoord = -1; 88 yPaintCoord = -1;
74} 89}
75 90QString KOAgendaItem::getWhatsThisText()
91{
92 if ( mIncidence )
93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence );
94 return "KOAgendaItem::getWhatsThisText()::internal error";
95}
76void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 96void KOAgendaItem::init ( Incidence *incidence, QDate qd )
77{ 97{
78 mIncidence = incidence; 98 mIncidence = incidence;
79 mDate = qd; 99 mDate = qd;
80 mFirstMultiItem = 0; 100 mFirstMultiItem = 0;
81 mNextMultiItem = 0; 101 mNextMultiItem = 0;
82 mLastMultiItem = 0; 102 mLastMultiItem = 0;
83 computeText(); 103 computeText();
84 104
85 if ( (incidence->type() == "Todo") && 105 if ( (incidence->type() == "Todo") &&
86 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 106 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
87 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 107 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
88 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 108 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
89 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 109 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
90 else 110 else
91 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 111 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
92 } 112 }
93 else { 113 else {
94 QStringList categories = mIncidence->categories(); 114 QStringList categories = mIncidence->categories();
95 QString cat = categories.first(); 115 QString cat = categories.first();
96 if (cat.isEmpty()) { 116 if (cat.isEmpty()) {
97 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 117 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) )
98 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 118 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
99 else 119 else
100 mBackgroundColor =KOPrefs::instance()->mEventColor; 120 mBackgroundColor =KOPrefs::instance()->mEventColor;
101 } else { 121 } else {
102 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 122 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
103 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 123 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
104 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 124 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
105 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 125 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
106 } 126 }
107 } 127 }
108 128
109 } 129 }
110 mColorGroup = QColorGroup( mBackgroundColor.light(), 130 mColorGroup = QColorGroup( mBackgroundColor.light(),
111 mBackgroundColor.dark(),mBackgroundColor.light(), 131 mBackgroundColor.dark(),mBackgroundColor.light(),
112 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 132 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
113 setBackgroundColor( mBackgroundColor ); 133 setBackgroundColor( mBackgroundColor );
114 134
115 setCellXY(0,0,1); 135 setCellXY(0,0,1);
116 setCellXWidth(0); 136 setCellXWidth(0);
117 setSubCell(0); 137 setSubCell(0);
118 setSubCells(1); 138 setSubCells(1);
119 setMultiItem(0,0,0); 139 setMultiItem(0,0,0);
120 startMove(); 140 startMove();
121 mSelected = true; 141 mSelected = true;
122 select(false); 142 select(false);
123 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 143 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
124 mFontPixelSize = fontinf.height();; 144 mFontPixelSize = fontinf.height();;
125 hide(); 145 hide();
126 xPaintCoord = -1; 146 xPaintCoord = -1;
127 yPaintCoord = -1; 147 yPaintCoord = -1;
128} 148}
129 149
130 150
131KOAgendaItem::~KOAgendaItem() 151KOAgendaItem::~KOAgendaItem()
132{ 152{
133 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 153 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
134 154
135} 155}
136 156
137void KOAgendaItem::recreateIncidence() 157void KOAgendaItem::recreateIncidence()
138{ 158{
139#if 0 159#if 0
140 Incidence* newInc = mIncidence->clone(); 160 Incidence* newInc = mIncidence->clone();
141 newInc->recreate(); 161 newInc->recreate();
142 if ( mIncidence->doesRecur() ) { 162 if ( mIncidence->doesRecur() ) {
143 mIncidence->addExDate( mDate ); 163 mIncidence->addExDate( mDate );
144 newInc->recurrence()->unsetRecurs(); 164 newInc->recurrence()->unsetRecurs();
145 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 165 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
146 QTime tim = mIncidence->dtStart().time(); 166 QTime tim = mIncidence->dtStart().time();
147 newInc->setDtStart( QDateTime(mDate, tim) ); 167 newInc->setDtStart( QDateTime(mDate, tim) );
148 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 168 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
149 } 169 }
150#endif 170#endif
151 mIncidence = mIncidence->recreateCloneException( mDate ); 171 mIncidence = mIncidence->recreateCloneException( mDate );
152} 172}
153bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 173bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
154{ 174{
155 int size = AGENDA_ICON_SIZE; 175 int size = AGENDA_ICON_SIZE;
156 176
157 int yOff = 0; 177 int yOff = 0;
158 int xOff = 0; 178 int xOff = 0;
159 int x = pos().x() +3; 179 int x = pos().x() +3;
160 int y; 180 int y;
161 if ( mAllDay ) 181 if ( mAllDay )
162 y = pos().y()+3; 182 y = pos().y()+3;
163 else 183 else
164 y = mCellYTop * ( height() / cellHeight() ) +3; 184 y = mCellYTop * ( height() / cellHeight() ) +3;
165 if (mIncidence->cancelled()) { 185 if (mIncidence->cancelled()) {
166 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 186 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
167 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 187 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
168 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 188 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
169 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 189 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
170 if ( horLayout ) 190 if ( horLayout )
171 ++xOff; 191 ++xOff;
172 else 192 else
173 ++yOff; 193 ++yOff;
174 } 194 }
175 if (mIncidence->isAlarmEnabled()) { 195 if (mIncidence->isAlarmEnabled()) {
176 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 196 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
177 if ( horLayout ) 197 if ( horLayout )
178 ++xOff; 198 ++xOff;
179 else 199 else
180 ++yOff; 200 ++yOff;
181 } 201 }
182 if (mIncidence->recurrence()->doesRecur()) { 202 if (mIncidence->recurrence()->doesRecur()) {
183 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 203 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
184 if ( horLayout ) 204 if ( horLayout )
185 ++xOff; 205 ++xOff;
186 else 206 else
187 ++yOff; 207 ++yOff;
188 } 208 }
189 if (mIncidence->description().length() > 0) { 209 if (mIncidence->description().length() > 0) {
190 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 210 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
191 if ( horLayout ) 211 if ( horLayout )
192 ++xOff; 212 ++xOff;
193 else 213 else
194 ++yOff; 214 ++yOff;
195 } 215 }
196 if (mIncidence->isReadOnly()) { 216 if (mIncidence->isReadOnly()) {
197 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 217 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
198 if ( horLayout ) 218 if ( horLayout )
199 ++xOff; 219 ++xOff;
200 else 220 else
201 ++yOff; 221 ++yOff;
202 } 222 }
203 223
204 if (mIncidence->attendeeCount()>0) { 224 if (mIncidence->attendeeCount()>0) {
205 225
206 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 226 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 227 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
208 if ( horLayout ) 228 if ( horLayout )
209 ++xOff; 229 ++xOff;
210 else 230 else
211 ++yOff; 231 ++yOff;
212 } else { 232 } else {
213 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 233 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
214 if (me!=0) { 234 if (me!=0) {
215 235
216 236
217 } else { 237 } else {
218 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
219 if ( horLayout ) 239 if ( horLayout )
220 ++xOff; 240 ++xOff;
221 else 241 else
222 ++yOff; 242 ++yOff;
223 243
224 } 244 }
225 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
226 if ( horLayout ) 246 if ( horLayout )
227 ++xOff; 247 ++xOff;
228 else 248 else
229 ++yOff; 249 ++yOff;
230 250
231 } 251 }
232 252
233 } 253 }
234 return ( yOff || xOff ); 254 return ( yOff || xOff );
235} 255}
236 256
237 257
238void KOAgendaItem::select(bool selected) 258void KOAgendaItem::select(bool selected)
239{ 259{
240 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 260 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
241 if (mSelected == selected) return; 261 if (mSelected == selected) return;
242 mSelected = selected; 262 mSelected = selected;
243 if ( ! isVisible() ) 263 if ( ! isVisible() )
244 return; 264 return;
245 if ( firstMultiItem() ) 265 if ( firstMultiItem() )
246 firstMultiItem()->select( selected ); 266 firstMultiItem()->select( selected );
247 if ( !firstMultiItem() && nextMultiItem() ) { 267 if ( !firstMultiItem() && nextMultiItem() ) {
248 KOAgendaItem * placeItem = nextMultiItem(); 268 KOAgendaItem * placeItem = nextMultiItem();
249 while ( placeItem ) { 269 while ( placeItem ) {
250 placeItem->select( selected ); 270 placeItem->select( selected );
251 placeItem = placeItem->nextMultiItem(); 271 placeItem = placeItem->nextMultiItem();
252 } 272 }
253 } 273 }
254 globalFlagBlockAgendaItemUpdate = 0; 274 globalFlagBlockAgendaItemUpdate = 0;
255 paintMe( selected ); 275 paintMe( selected );
256 globalFlagBlockAgendaItemUpdate = 1; 276 globalFlagBlockAgendaItemUpdate = 1;
257 repaint( false ); 277 repaint( false );
258} 278}
259 279
260 280
261/* 281/*
262 The eventFilter has to filter the mouse events of the agenda item childs. The 282 The eventFilter has to filter the mouse events of the agenda item childs. The
263 events are fed into the event handling method of KOAgendaItem. This allows the 283 events are fed into the event handling method of KOAgendaItem. This allows the
264 KOAgenda to handle the KOAgendaItems by using an eventFilter. 284 KOAgenda to handle the KOAgendaItems by using an eventFilter.
265*/ 285*/
266bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 286bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
267{ 287{
268 if (e->type() == QEvent::MouseButtonPress || 288 if (e->type() == QEvent::MouseButtonPress ||
269 e->type() == QEvent::MouseButtonDblClick || 289 e->type() == QEvent::MouseButtonDblClick ||
270 e->type() == QEvent::MouseButtonRelease || 290 e->type() == QEvent::MouseButtonRelease ||
271 e->type() == QEvent::MouseMove) { 291 e->type() == QEvent::MouseMove) {
272 QMouseEvent *me = (QMouseEvent *)e; 292 QMouseEvent *me = (QMouseEvent *)e;
273 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 293 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
274 mapToGlobal(me->pos())); 294 mapToGlobal(me->pos()));
275 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 295 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
276 return event(&returnEvent); 296 return event(&returnEvent);
277 } else { 297 } else {
278 return false; 298 return false;
279 } 299 }
280} 300}
281void KOAgendaItem::repaintMe( ) 301void KOAgendaItem::repaintMe( )
282{ 302{
283 paintMe ( mSelected ); 303 paintMe ( mSelected );
284} 304}
285void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 305void KOAgendaItem::paintMe( bool selected, QPainter* paint )
286{ 306{
287 if ( globalFlagBlockAgendaItemUpdate && ! selected) 307 if ( globalFlagBlockAgendaItemUpdate && ! selected)
288 return; 308 return;
289 QPainter pa; 309 QPainter pa;
290 310
291 if ( mSelected ) { 311 if ( mSelected ) {
292 pa.begin( paintPixSel() ); 312 pa.begin( paintPixSel() );
293 } else { 313 } else {
294 if ( mAllDay ) 314 if ( mAllDay )
295 pa.begin( paintPixAllday() ); 315 pa.begin( paintPixAllday() );
296 else 316 else
297 pa.begin( paintPix() ); 317 pa.begin( paintPix() );
298 } 318 }
299 int x, yy, w, h; 319 int x, yy, w, h;
300 float nfh; 320 float nfh;
301 x = pos().x(); w = width(); h = height (); 321 x = pos().x(); w = width(); h = height ();
302 if ( mAllDay ) 322 if ( mAllDay )
303 yy = y(); 323 yy = y();
304 else 324 else
305 yy = mCellYTop * ( height() / cellHeight() ); 325 yy = mCellYTop * ( height() / cellHeight() );
306 xPaintCoord= x; 326 xPaintCoord= x;
307 yPaintCoord = yy; 327 yPaintCoord = yy;
308 wPaintCoord = width(); 328 wPaintCoord = width();
309 hPaintCoord = height(); 329 hPaintCoord = height();
310 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 330 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
311 if ( paint == 0 ) 331 if ( paint == 0 )
312 paint = &pa; 332 paint = &pa;
313 bool horLayout = ( w < h ); 333 bool horLayout = ( w < h );
314 int maxhei = mFontPixelSize+4; 334 int maxhei = mFontPixelSize+4;
315 if ( horLayout ) 335 if ( horLayout )
316 maxhei += AGENDA_ICON_SIZE -4; 336 maxhei += AGENDA_ICON_SIZE -4;
317 bool small = ( h < maxhei ); 337 bool small = ( h < maxhei );
318 if ( ! small ) 338 if ( ! small )
319 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 339 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
320 else { 340 else {
321 QFont f = KOPrefs::instance()->mAgendaViewFont; 341 QFont f = KOPrefs::instance()->mAgendaViewFont;
322 f.setBold( false ); 342 f.setBold( false );
323 int fh = f.pointSize(); 343 int fh = f.pointSize();
324 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 344 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
325 if ( nfh < 6 ) 345 if ( nfh < 6 )
326 nfh = 6; 346 nfh = 6;
327 f.setPointSize( nfh ); 347 f.setPointSize( nfh );
328 paint->setFont(f); 348 paint->setFont(f);
329 } 349 }
330 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 350 paint->fillRect ( x, yy, w, h, mBackgroundColor );
331 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 351 static const QPixmap completedPxmp = SmallIcon("greenhook16");
332 static const QPixmap overduePxmp = SmallIcon("redcross16"); 352 static const QPixmap overduePxmp = SmallIcon("redcross16");
333 if ( mIncidence->type() == "Todo" ) { 353 if ( mIncidence->type() == "Todo" ) {
334 Todo* tempTodo = static_cast<Todo*>(mIncidence); 354 Todo* tempTodo = static_cast<Todo*>(mIncidence);
335 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 355 int xx = pos().x()+(width()-completedPxmp.width()-3 );
336 int yyy = yy+3; 356 int yyy = yy+3;
337 if ( tempTodo->isCompleted() ) 357 if ( tempTodo->isCompleted() )
338 paint->drawPixmap ( xx, yyy, completedPxmp ); 358 paint->drawPixmap ( xx, yyy, completedPxmp );
339 else { 359 else {
340 paint->drawPixmap ( xx, yyy, overduePxmp ); 360 paint->drawPixmap ( xx, yyy, overduePxmp );
341 361
342 } 362 }
343 } 363 }
344 bool addIcon = false; 364 bool addIcon = false;
345 if ( ! small || w > 3 * h || h > 3* w ) 365 if ( ! small || w > 3 * h || h > 3* w )
346 addIcon = updateIcons( paint, horLayout ); 366 addIcon = updateIcons( paint, horLayout );
347 367
348 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 368 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
349 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 369 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
350 if ( ! small ) { 370 if ( ! small ) {
351 x += 3; yy += 3;w -= 6; h-= 5; 371 x += 3; yy += 3;w -= 6; h-= 5;
352 } else { 372 } else {
353 x += 2; yy += 1;w -= 4; h-= 4; 373 x += 2; yy += 1;w -= 4; h-= 4;
354 if ( nfh < 6.01 ) { 374 if ( nfh < 6.01 ) {
355 yy -= 2; 375 yy -= 2;
356 h += 4; 376 h += 4;
357 } 377 }
358 else 378 else
359 if ( nfh < h -2 ) 379 if ( nfh < h -2 )
360 ++yy; 380 ++yy;
361 } 381 }
362 int align; 382 int align;
363#ifndef DESKTOP_VERSION 383#ifndef DESKTOP_VERSION
364 align = ( AlignLeft|WordBreak|AlignTop); 384 align = ( AlignLeft|WordBreak|AlignTop);
365#else 385#else
366 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 386 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
367#endif 387#endif
368 if ( addIcon ) { 388 if ( addIcon ) {
369 if ( ! horLayout ) { 389 if ( ! horLayout ) {
370 x += AGENDA_ICON_SIZE+3; 390 x += AGENDA_ICON_SIZE+3;
371 w -= (AGENDA_ICON_SIZE+3); 391 w -= (AGENDA_ICON_SIZE+3);
372 } 392 }
373 else { 393 else {
374 yy+= AGENDA_ICON_SIZE+2; 394 yy+= AGENDA_ICON_SIZE+2;
375 h -=(AGENDA_ICON_SIZE+3); 395 h -=(AGENDA_ICON_SIZE+3);
376 } 396 }
377 } 397 }
378 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 398 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
379 if ( colsum < 250 ) 399 if ( colsum < 250 )
380 paint->setPen ( white); 400 paint->setPen ( white);
381 if ( x < 0 ) { 401 if ( x < 0 ) {
382 w = w+x-3; 402 w = w+x-3;
383 x = 3; 403 x = 3;
384 if ( w > parentWidget()->width() ){ 404 if ( w > parentWidget()->width() ){
385 w = parentWidget()->width() - 6; 405 w = parentWidget()->width() - 6;
386#ifndef DESKTOP_VERSION 406#ifndef DESKTOP_VERSION
387 align = ( AlignCenter|WordBreak); 407 align = ( AlignCenter|WordBreak);
388#else 408#else
389 align = ( AlignCenter|BreakAnywhere|WordBreak); 409 align = ( AlignCenter|BreakAnywhere|WordBreak);
390#endif 410#endif
391 411
392 } 412 }
393 } 413 }
394 QRect dr; 414 QRect dr;
395 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 415 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
396 if ( mIncidence->cancelled() ){ 416 if ( mIncidence->cancelled() ){
397 if ( ! small ) { 417 if ( ! small ) {
398 QFontMetrics fm ( paint->font() ); 418 QFontMetrics fm ( paint->font() );
399 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 419 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
400 } 420 }
401 421
402 } 422 }
403 pa.end(); 423 pa.end();
404 424
405} 425}
406void KOAgendaItem::resizePixmap( int w , int h ) 426void KOAgendaItem::resizePixmap( int w , int h )
407{ 427{
408 paintPix()->resize( w, h ); 428 paintPix()->resize( w, h );
409 paintPixSel()->resize( w, h ); 429 paintPixSel()->resize( w, h );
410 430
411} 431}
412QPixmap * KOAgendaItem::paintPix() 432QPixmap * KOAgendaItem::paintPix()
413{ 433{
414 static QPixmap* mPaintPix = 0; 434 static QPixmap* mPaintPix = 0;
415 if ( ! mPaintPix ) 435 if ( ! mPaintPix )
416 mPaintPix = new QPixmap(1,1); 436 mPaintPix = new QPixmap(1,1);
417 return mPaintPix ; 437 return mPaintPix ;
418} 438}
419QPixmap * KOAgendaItem::paintPixAllday() 439QPixmap * KOAgendaItem::paintPixAllday()
420{ 440{
421 static QPixmap* mPaintPixA = 0; 441 static QPixmap* mPaintPixA = 0;
422 if ( ! mPaintPixA ) 442 if ( ! mPaintPixA )
423 mPaintPixA = new QPixmap(1,1); 443 mPaintPixA = new QPixmap(1,1);
424 return mPaintPixA ; 444 return mPaintPixA ;
425} 445}
426QPixmap * KOAgendaItem::paintPixSel() 446QPixmap * KOAgendaItem::paintPixSel()
427{ 447{
428 static QPixmap* mPaintPixSel = 0; 448 static QPixmap* mPaintPixSel = 0;
429 if ( ! mPaintPixSel ) 449 if ( ! mPaintPixSel )
430 mPaintPixSel = new QPixmap(1,1); 450 mPaintPixSel = new QPixmap(1,1);
431 return mPaintPixSel ; 451 return mPaintPixSel ;
432} 452}
433void KOAgendaItem::paintEvent ( QPaintEvent *e ) 453void KOAgendaItem::paintEvent ( QPaintEvent *e )
434{ 454{
435 455
436 if ( globalFlagBlockAgendaItemPaint ) 456 if ( globalFlagBlockAgendaItemPaint )
437 return; 457 return;
438 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 458 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
439 return; 459 return;
440 int yy; 460 int yy;
441 if ( mAllDay ) 461 if ( mAllDay )
442 yy = y(); 462 yy = y();
443 else 463 else
444 yy = mCellYTop * ( height() / cellHeight() ); 464 yy = mCellYTop * ( height() / cellHeight() );
445 int xx = x(); 465 int xx = x();
446 if ( xPaintCoord != xx || yPaintCoord != yy || 466 if ( xPaintCoord != xx || yPaintCoord != yy ||
447 wPaintCoord != width() || hPaintCoord != height()) { 467 wPaintCoord != width() || hPaintCoord != height()) {
448 xPaintCoord= xx; 468 xPaintCoord= xx;
449 yPaintCoord = yy; 469 yPaintCoord = yy;
450 wPaintCoord = width(); 470 wPaintCoord = width();
451 hPaintCoord = height(); 471 hPaintCoord = height();
452 globalFlagBlockAgendaItemUpdate = 0; 472 globalFlagBlockAgendaItemUpdate = 0;
453 paintMe( mSelected ); 473 paintMe( mSelected );
454 //qDebug("calling paintMe "); 474 //qDebug("calling paintMe ");
455 globalFlagBlockAgendaItemUpdate = 1; 475 globalFlagBlockAgendaItemUpdate = 1;
456 } 476 }
457 int rx, ry, rw, rh; 477 int rx, ry, rw, rh;
458 rx = e->rect().x(); 478 rx = e->rect().x();
459 ry = e->rect().y(); 479 ry = e->rect().y();
460 rw = e->rect().width(); 480 rw = e->rect().width();
461 rh = e->rect().height(); 481 rh = e->rect().height();
462 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 482 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
463 483
464 QPixmap* paintFrom ; 484 QPixmap* paintFrom ;
465 if ( mSelected ) { 485 if ( mSelected ) {
466 paintFrom = paintPixSel(); 486 paintFrom = paintPixSel();
467 } else { 487 } else {
468 if ( mAllDay ) 488 if ( mAllDay )
469 paintFrom = paintPixAllday(); 489 paintFrom = paintPixAllday();
470 else 490 else
471 paintFrom = paintPix(); 491 paintFrom = paintPix();
472 } 492 }
473 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); 493 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP);
474} 494}
475void KOAgendaItem::computeText() 495void KOAgendaItem::computeText()
476{ 496{
477 497
478 mDisplayedText = mIncidence->summary(); 498 mDisplayedText = mIncidence->summary();
479 if ( (mIncidence->type() == "Todo") ) { 499 if ( (mIncidence->type() == "Todo") ) {
480 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 500 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
481 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 501 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
482 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 502 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
483 else if ( !(mIncidence->doesFloat())) 503 else if ( !(mIncidence->doesFloat()))
484 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 504 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
485 } 505 }
486 } else { 506 } else {
487 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 507 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
488 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 508 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
489 509
490 if ( mAllDay ) { 510 if ( mAllDay ) {
491 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 511 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
492 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 512 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
493 } 513 }
494 } 514 }
495 515
496 } 516 }
497 517
498 if ( !mIncidence->location().isEmpty() ) { 518 if ( !mIncidence->location().isEmpty() ) {
499 if ( mAllDay ) 519 if ( mAllDay )
500 mDisplayedText += " ("; 520 mDisplayedText += " (";
501 else 521 else
502 mDisplayedText += "\n("; 522 mDisplayedText += "\n(";
503 mDisplayedText += mIncidence->location() +")"; 523 mDisplayedText += mIncidence->location() +")";
504 } 524 }
505 525
506 QString tipText = mIncidence->summary(); 526 QString tipText = mIncidence->summary();
507 QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
508 if ( !mIncidence->doesFloat() ) { 527 if ( !mIncidence->doesFloat() ) {
509 if ( mIncidence->type() == "Event" ) { 528 if ( mIncidence->type() == "Event" ) {
510 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 529 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
511 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 530 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
512 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 531 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
513 } 532 }
514 else { 533 else {
515 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 534 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
516 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 535 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
517 } 536 }
518 } 537 }
519 else if ( mIncidence->type() == "Todo" ) { 538 else if ( mIncidence->type() == "Todo" ) {
520 if (mIncidence->hasStartDate()) 539 if (mIncidence->hasStartDate())
521 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 540 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
522 if (((Todo*)mIncidence)->hasDueDate()) 541 if (((Todo*)mIncidence)->hasDueDate())
523 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 542 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
524 } 543 }
525 } else if ( mIncidence->type() == "Todo" ) { 544 } else if ( mIncidence->type() == "Todo" ) {
526 if (mIncidence->hasStartDate()) 545 if (mIncidence->hasStartDate())
527 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 546 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
528 if (((Todo*)mIncidence)->hasDueDate()) 547 if (((Todo*)mIncidence)->hasDueDate())
529 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 548 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
530 } 549 }
531 550
532 if (!mIncidence->location().isEmpty()) { 551 if (!mIncidence->location().isEmpty()) {
533 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 552 tipText += "\n"+i18n("Location: ")+mIncidence->location();
534 } 553 }
535 QToolTip::add(this,tipText,toolTipGroup(),""); 554 QToolTip::add(this,tipText,toolTipGroup(),"");
536 555
537} 556}
538void KOAgendaItem::updateItem() 557void KOAgendaItem::updateItem()
539{ 558{
540 computeText(); 559 computeText();
541 560
542 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 561 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
543 paintMe( mSelected ); 562 paintMe( mSelected );
544 repaint( false); 563 repaint( false);
545} 564}
546 565
547void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 566void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
548{ 567{
549 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 568 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
550 paintMe( mSelected ); 569 paintMe( mSelected );
551 repaint( false ); 570 repaint( false );
552} 571}
553 572
554/* 573/*
555 Return height of item in units of agenda cells 574 Return height of item in units of agenda cells
556*/ 575*/
557int KOAgendaItem::cellHeight() 576int KOAgendaItem::cellHeight()
558{ 577{
559 int ret = mCellYBottom - mCellYTop + 1; 578 int ret = mCellYBottom - mCellYTop + 1;
560 if ( ret <= 0 ) { 579 if ( ret <= 0 ) {
561 ret = 1; 580 ret = 1;
562 mCellYBottom = 0; 581 mCellYBottom = 0;
563 mCellYTop = 0; 582 mCellYTop = 0;
564 } 583 }
565 return ret; 584 return ret;
566} 585}
567 586
568/* 587/*
569 Return height of item in units of agenda cells 588 Return height of item in units of agenda cells
570*/ 589*/
571int KOAgendaItem::cellWidth() 590int KOAgendaItem::cellWidth()
572{ 591{
573 return mCellXWidth - mCellX + 1; 592 return mCellXWidth - mCellX + 1;
574} 593}
575 594
576void KOAgendaItem::setItemDate(QDate qd) 595void KOAgendaItem::setItemDate(QDate qd)
577{ 596{
578 mDate = qd; 597 mDate = qd;
579} 598}
580 599
581void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 600void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
582{ 601{
583 mCellX = X; 602 mCellX = X;
584 mCellYTop = YTop; 603 mCellYTop = YTop;
585 mCellYBottom = YBottom; 604 mCellYBottom = YBottom;
586} 605}
587 606
588void KOAgendaItem::setCellXWidth(int xwidth) 607void KOAgendaItem::setCellXWidth(int xwidth)
589{ 608{
590 mCellXWidth = xwidth; 609 mCellXWidth = xwidth;
591} 610}
592 611
593void KOAgendaItem::setCellX(int XLeft, int XRight) 612void KOAgendaItem::setCellX(int XLeft, int XRight)
594{ 613{
595 mCellX = XLeft; 614 mCellX = XLeft;
596 mCellXWidth = XRight; 615 mCellXWidth = XRight;
597} 616}
598 617
599void KOAgendaItem::setCellY(int YTop, int YBottom) 618void KOAgendaItem::setCellY(int YTop, int YBottom)
600{ 619{
601 mCellYTop = YTop; 620 mCellYTop = YTop;
602 mCellYBottom = YBottom; 621 mCellYBottom = YBottom;
603} 622}
604 623
605void KOAgendaItem::setSubCell(int subCell) 624void KOAgendaItem::setSubCell(int subCell)
606{ 625{
607 mSubCell = subCell; 626 mSubCell = subCell;
608} 627}
609 628
610void KOAgendaItem::setSubCells(int subCells) 629void KOAgendaItem::setSubCells(int subCells)
611{ 630{
612 mSubCells = subCells; 631 mSubCells = subCells;
613} 632}
614 633
615void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 634void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
616 KOAgendaItem *last) 635 KOAgendaItem *last)
617{ 636{
618 mFirstMultiItem = first; 637 mFirstMultiItem = first;
619 mNextMultiItem = next; 638 mNextMultiItem = next;
620 mLastMultiItem = last; 639 mLastMultiItem = last;
621} 640}
622 641
623void KOAgendaItem::startMove() 642void KOAgendaItem::startMove()
624{ 643{
625 mStartCellX = mCellX; 644 mStartCellX = mCellX;
626 mStartCellXWidth = mCellXWidth; 645 mStartCellXWidth = mCellXWidth;
627 mStartCellYTop = mCellYTop; 646 mStartCellYTop = mCellYTop;
628 mStartCellYBottom = mCellYBottom; 647 mStartCellYBottom = mCellYBottom;
629} 648}
630 649
631void KOAgendaItem::resetMove() 650void KOAgendaItem::resetMove()
632{ 651{
633 mCellX = mStartCellX; 652 mCellX = mStartCellX;
634 mCellXWidth = mStartCellXWidth; 653 mCellXWidth = mStartCellXWidth;
635 mCellYTop = mStartCellYTop; 654 mCellYTop = mStartCellYTop;
636 mCellYBottom = mStartCellYBottom; 655 mCellYBottom = mStartCellYBottom;
637} 656}
638 657
639void KOAgendaItem::moveRelative(int dx, int dy) 658void KOAgendaItem::moveRelative(int dx, int dy)
640{ 659{
641 int newX = cellX() + dx; 660 int newX = cellX() + dx;
642 int newXWidth = cellXWidth() + dx; 661 int newXWidth = cellXWidth() + dx;
643 int newYTop = cellYTop() + dy; 662 int newYTop = cellYTop() + dy;
644 int newYBottom = cellYBottom() + dy; 663 int newYBottom = cellYBottom() + dy;
645 setCellXY(newX,newYTop,newYBottom); 664 setCellXY(newX,newYTop,newYBottom);
646 setCellXWidth(newXWidth); 665 setCellXWidth(newXWidth);
647} 666}
648 667
649void KOAgendaItem::expandTop(int dy) 668void KOAgendaItem::expandTop(int dy)
650{ 669{
651 int newYTop = cellYTop() + dy; 670 int newYTop = cellYTop() + dy;
652 int newYBottom = cellYBottom(); 671 int newYBottom = cellYBottom();
653 if (newYTop > newYBottom) newYTop = newYBottom; 672 if (newYTop > newYBottom) newYTop = newYBottom;
654 setCellY(newYTop, newYBottom); 673 setCellY(newYTop, newYBottom);
655} 674}
656 675
657void KOAgendaItem::expandBottom(int dy) 676void KOAgendaItem::expandBottom(int dy)
658{ 677{
659 int newYTop = cellYTop(); 678 int newYTop = cellYTop();
660 int newYBottom = cellYBottom() + dy; 679 int newYBottom = cellYBottom() + dy;
661 if (newYBottom < newYTop) newYBottom = newYTop; 680 if (newYBottom < newYTop) newYBottom = newYTop;
662 setCellY(newYTop, newYBottom); 681 setCellY(newYTop, newYBottom);
663} 682}
664 683
665void KOAgendaItem::expandLeft(int dx) 684void KOAgendaItem::expandLeft(int dx)
666{ 685{
667 int newX = cellX() + dx; 686 int newX = cellX() + dx;
668 int newXWidth = cellXWidth(); 687 int newXWidth = cellXWidth();
669 if (newX > newXWidth) newX = newXWidth; 688 if (newX > newXWidth) newX = newXWidth;
670 setCellX(newX,newXWidth); 689 setCellX(newX,newXWidth);
671} 690}
672 691
673void KOAgendaItem::expandRight(int dx) 692void KOAgendaItem::expandRight(int dx)
674{ 693{
675 int newX = cellX(); 694 int newX = cellX();
676 int newXWidth = cellXWidth() + dx; 695 int newXWidth = cellXWidth() + dx;
677 if (newXWidth < newX) newXWidth = newX; 696 if (newXWidth < newX) newXWidth = newX;
678 setCellX(newX,newXWidth); 697 setCellX(newX,newXWidth);
679} 698}
680 699
681QToolTipGroup *KOAgendaItem::toolTipGroup() 700QToolTipGroup *KOAgendaItem::toolTipGroup()
682{ 701{
683 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 702 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
684 return mToolTipGroup; 703 return mToolTipGroup;
685} 704}
686 705
687void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 706void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
688{ 707{
689#ifndef KORG_NODND 708#ifndef KORG_NODND
690 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 709 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
691 !QTextDrag::canDecode( e ) ) { 710 !QTextDrag::canDecode( e ) ) {
692 e->ignore(); 711 e->ignore();
693 return; 712 return;
694 } 713 }
695 e->accept(); 714 e->accept();
696#endif 715#endif
697} 716}
698 717
699void KOAgendaItem::dropEvent( QDropEvent *e ) 718void KOAgendaItem::dropEvent( QDropEvent *e )
700{ 719{
701#ifndef KORG_NODND 720#ifndef KORG_NODND
702 QString text; 721 QString text;
703 if(QTextDrag::decode(e,text)) 722 if(QTextDrag::decode(e,text))
704 { 723 {
705 kdDebug() << "Dropped : " << text << endl; 724 kdDebug() << "Dropped : " << text << endl;
706 QStringList emails = QStringList::split(",",text); 725 QStringList emails = QStringList::split(",",text);
707 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 726 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
708 kdDebug() << " Email: " << (*it) << endl; 727 kdDebug() << " Email: " << (*it) << endl;
709 int pos = (*it).find("<"); 728 int pos = (*it).find("<");
710 QString name = (*it).left(pos); 729 QString name = (*it).left(pos);
711 QString email = (*it).mid(pos); 730 QString email = (*it).mid(pos);
712 if (!email.isEmpty()) { 731 if (!email.isEmpty()) {
713 mIncidence->addAttendee(new Attendee(name,email)); 732 mIncidence->addAttendee(new Attendee(name,email));
714 } 733 }
715 } 734 }
716 } 735 }
717#endif 736#endif
718} 737}
719 738
720 739
721QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 740QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
722{ 741{
723 return mConflictItems; 742 return mConflictItems;
724} 743}
725 744
726void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 745void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
727{ 746{
728 mConflictItems = ci; 747 mConflictItems = ci;
729 KOAgendaItem *item; 748 KOAgendaItem *item;
730 for ( item=mConflictItems.first(); item != 0; 749 for ( item=mConflictItems.first(); item != 0;
731 item=mConflictItems.next() ) { 750 item=mConflictItems.next() ) {
732 item->addConflictItem(this); 751 item->addConflictItem(this);
733 } 752 }
734} 753}
735 754
736void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 755void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
737{ 756{
738 if (mConflictItems.find(ci)<0) 757 if (mConflictItems.find(ci)<0)
739 mConflictItems.append(ci); 758 mConflictItems.append(ci);
740} 759}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 7321af2..5b8f420 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,160 +1,161 @@
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#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class QToolTipGroup; 30class QToolTipGroup;
31class QDragEnterEvent; 31class QDragEnterEvent;
32class QDropEvent; 32class QDropEvent;
33 33
34using namespace KCal; 34using namespace KCal;
35 35
36/* 36/*
37 The KOAgendaItem has to make sure that it receives all mouse events, which are 37 The KOAgendaItem has to make sure that it receives all mouse events, which are
38 to be used for dragging and resizing. That means it has to be installed as 38 to be used for dragging and resizing. That means it has to be installed as
39 eventfiler for its children, if it has children, and it has to pass mouse 39 eventfiler for its children, if it has children, and it has to pass mouse
40 events from the cildren to itself. See eventFilter(). 40 events from the cildren to itself. See eventFilter().
41*/ 41*/
42class KOAgendaItem : public QWidget 42class KOAgendaItem : public QWidget
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 public: 45 public:
46 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 46 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
47 WFlags f=0 ); 47 WFlags f=0 );
48 ~KOAgendaItem(); 48 ~KOAgendaItem();
49 QString getWhatsThisText();
49 void init ( Incidence *incidence, QDate qd ); 50 void init ( Incidence *incidence, QDate qd );
50 int cellX() { return mCellX; } 51 int cellX() { return mCellX; }
51 int cellXWidth() { return mCellXWidth; } 52 int cellXWidth() { return mCellXWidth; }
52 int cellYTop() { return mCellYTop; } 53 int cellYTop() { return mCellYTop; }
53 int cellYBottom() { return mCellYBottom; } 54 int cellYBottom() { return mCellYBottom; }
54 int cellHeight(); 55 int cellHeight();
55 int cellWidth(); 56 int cellWidth();
56 int subCell() { return mSubCell; } 57 int subCell() { return mSubCell; }
57 int subCells() { return mSubCells; } 58 int subCells() { return mSubCells; }
58 59
59 void setCellXY(int X, int YTop, int YBottom); 60 void setCellXY(int X, int YTop, int YBottom);
60 void setCellY(int YTop, int YBottom); 61 void setCellY(int YTop, int YBottom);
61 void setCellX(int XLeft, int XRight); 62 void setCellX(int XLeft, int XRight);
62 void setCellXWidth(int xwidth); 63 void setCellXWidth(int xwidth);
63 void setSubCell(int subCell); 64 void setSubCell(int subCell);
64 void setSubCells(int subCells); 65 void setSubCells(int subCells);
65 66
66 /** Start movement */ 67 /** Start movement */
67 void startMove(); 68 void startMove();
68 /** Reset to original values */ 69 /** Reset to original values */
69 void resetMove(); 70 void resetMove();
70 71
71 void moveRelative(int dx,int dy); 72 void moveRelative(int dx,int dy);
72 void expandTop(int dy); 73 void expandTop(int dy);
73 void expandBottom(int dy); 74 void expandBottom(int dy);
74 void expandLeft(int dx); 75 void expandLeft(int dx);
75 void expandRight(int dx); 76 void expandRight(int dx);
76 int mLastMoveXPos; 77 int mLastMoveXPos;
77 78
78 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 79 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
79 KOAgendaItem *last); 80 KOAgendaItem *last);
80 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 81 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
81 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 82 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
82 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 83 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
83 84
84 Incidence *incidence() const { return mIncidence; } 85 Incidence *incidence() const { return mIncidence; }
85 QDate itemDate() { return mDate; } 86 QDate itemDate() { return mDate; }
86 87
87 /** Update the date of this item's occurence (not in the event) */ 88 /** Update the date of this item's occurence (not in the event) */
88 void setItemDate(QDate qd); 89 void setItemDate(QDate qd);
89 90
90 void setText ( const QString & text ) { mDisplayedText = text; } 91 void setText ( const QString & text ) { mDisplayedText = text; }
91 QString text () { return mDisplayedText; } 92 QString text () { return mDisplayedText; }
92 93
93 virtual bool eventFilter ( QObject *, QEvent * ); 94 virtual bool eventFilter ( QObject *, QEvent * );
94 95
95 static QToolTipGroup *toolTipGroup(); 96 static QToolTipGroup *toolTipGroup();
96 97
97 QPtrList<KOAgendaItem> conflictItems(); 98 QPtrList<KOAgendaItem> conflictItems();
98 void setConflictItems(QPtrList<KOAgendaItem>); 99 void setConflictItems(QPtrList<KOAgendaItem>);
99 void addConflictItem(KOAgendaItem *ci); 100 void addConflictItem(KOAgendaItem *ci);
100 void paintMe( bool, QPainter* painter = 0 ); 101 void paintMe( bool, QPainter* painter = 0 );
101 void repaintMe(); 102 void repaintMe();
102 static void resizePixmap( int, int ); 103 static void resizePixmap( int, int );
103 static QPixmap * paintPix(); 104 static QPixmap * paintPix();
104 static QPixmap * paintPixSel(); 105 static QPixmap * paintPixSel();
105 static QPixmap * paintPixAllday(); 106 static QPixmap * paintPixAllday();
106 void updateItem(); 107 void updateItem();
107 void computeText(); 108 void computeText();
108 void recreateIncidence(); 109 void recreateIncidence();
109 public slots: 110 public slots:
110 bool updateIcons( QPainter *, bool ); 111 bool updateIcons( QPainter *, bool );
111 void select(bool=true); 112 void select(bool=true);
112 113
113 protected: 114 protected:
114 void dragEnterEvent(QDragEnterEvent *e); 115 void dragEnterEvent(QDragEnterEvent *e);
115 void dropEvent(QDropEvent *e); 116 void dropEvent(QDropEvent *e);
116 void paintEvent ( QPaintEvent * ); 117 void paintEvent ( QPaintEvent * );
117 void resizeEvent ( QResizeEvent *ev ); 118 void resizeEvent ( QResizeEvent *ev );
118 119
119 private: 120 private:
120 bool mAllDay; 121 bool mAllDay;
121 int mCellX; 122 int mCellX;
122 int mCellXWidth; 123 int mCellXWidth;
123 int mCellYTop,mCellYBottom; 124 int mCellYTop,mCellYBottom;
124 int mSubCell; // subcell number of this item 125 int mSubCell; // subcell number of this item
125 int mSubCells; // Total number of subcells in cell of this item 126 int mSubCells; // Total number of subcells in cell of this item
126 int xPaintCoord; 127 int xPaintCoord;
127 int yPaintCoord; 128 int yPaintCoord;
128 int wPaintCoord; 129 int wPaintCoord;
129 int hPaintCoord; 130 int hPaintCoord;
130 // Variables to remember start position 131 // Variables to remember start position
131 int mStartCellX; 132 int mStartCellX;
132 int mStartCellXWidth; 133 int mStartCellXWidth;
133 int mStartCellYTop,mStartCellYBottom; 134 int mStartCellYTop,mStartCellYBottom;
134 int mLastMovePos; 135 int mLastMovePos;
135 136
136 // Multi item pointers 137 // Multi item pointers
137 KOAgendaItem *mFirstMultiItem; 138 KOAgendaItem *mFirstMultiItem;
138 KOAgendaItem *mNextMultiItem; 139 KOAgendaItem *mNextMultiItem;
139 KOAgendaItem *mLastMultiItem; 140 KOAgendaItem *mLastMultiItem;
140 141
141 int mFontPixelSize; 142 int mFontPixelSize;
142 Incidence *mIncidence; // corresponding event or todo 143 Incidence *mIncidence; // corresponding event or todo
143 QDate mDate; //date this events occurs (for recurrence) 144 QDate mDate; //date this events occurs (for recurrence)
144 //void showIcon( QLabel*, int ); 145 //void showIcon( QLabel*, int );
145 //QLabel *mTodoIconLabel; 146 //QLabel *mTodoIconLabel;
146 //QLabel *mItemLabel; 147 //QLabel *mItemLabel;
147 //QWidget *mIconBox; 148 //QWidget *mIconBox;
148 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 149 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
149 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 150 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
150 //QLabel *mIconMoreInfo; 151 //QLabel *mIconMoreInfo;
151 static QToolTipGroup *mToolTipGroup; 152 static QToolTipGroup *mToolTipGroup;
152 153
153 QColor mBackgroundColor; 154 QColor mBackgroundColor;
154 QColorGroup mColorGroup; 155 QColorGroup mColorGroup;
155 QString mDisplayedText; 156 QString mDisplayedText;
156 bool mSelected; 157 bool mSelected;
157 QPtrList<KOAgendaItem> mConflictItems; 158 QPtrList<KOAgendaItem> mConflictItems;
158}; 159};
159 160
160#endif // KOAGENDAITEM_H 161#endif // KOAGENDAITEM_H
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index b21b419..732fc46 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1077 +1,1105 @@
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 <qregexp.h> 36#include <qregexp.h>
36 37
37#include <klocale.h> 38#include <klocale.h>
38#include <kdebug.h> 39#include <kdebug.h>
39#include <kiconloader.h> 40#include <kiconloader.h>
40#include <kglobal.h> 41#include <kglobal.h>
41 42
42#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
43#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
44#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
45#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
46#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
47#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
48#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
49#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h>
50#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
51#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
52#else 54#else
53#include <qapplication.h> 55#include <qapplication.h>
54#endif 56#endif
55 57
56#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
57#include "calprinter.h" 59#include "calprinter.h"
58#endif 60#endif
59#include "koglobals.h" 61#include "koglobals.h"
60#include "koprefs.h" 62#include "koprefs.h"
61#include "kfiledialog.h" 63#include "kfiledialog.h"
62 64
63#include "kolistview.h" 65#include "kolistview.h"
64 66
67
68class KOListViewWhatsThis :public QWhatsThis
69{
70public:
71 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
72
73protected:
74 virtual QString text( const QPoint& p)
75 {
76 return _view->getWhatsThisText(p) ;
77 }
78private:
79 QWidget* _wid;
80 KOListView * _view;
81};
82
83
65ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 84ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
66{ 85{
67 mItem = item; 86 mItem = item;
68 mDate = date; 87 mDate = date;
69} 88}
70 89
71ListItemVisitor::~ListItemVisitor() 90ListItemVisitor::~ListItemVisitor()
72{ 91{
73} 92}
74 93
75bool ListItemVisitor::visit(Event *e) 94bool ListItemVisitor::visit(Event *e)
76{ 95{
77 96
78 bool ok = false; 97 bool ok = false;
79 QString start, end; 98 QString start, end;
80 QDate ds, de; 99 QDate ds, de;
81 if ( e->doesRecur() ) { 100 if ( e->doesRecur() ) {
82 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 101 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
83 if ( ok ) { 102 if ( ok ) {
84 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 103 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
85 start = KGlobal::locale()->formatDate(ds,true); 104 start = KGlobal::locale()->formatDate(ds,true);
86 de = ds.addDays( days); 105 de = ds.addDays( days);
87 end = KGlobal::locale()->formatDate(de,true); 106 end = KGlobal::locale()->formatDate(de,true);
88 } 107 }
89 108
90 } 109 }
91 if ( ! ok ) { 110 if ( ! ok ) {
92 start =e->dtStartDateStr(); 111 start =e->dtStartDateStr();
93 end = e->dtEndDateStr(); 112 end = e->dtEndDateStr();
94 ds = e->dtStart().date(); 113 ds = e->dtStart().date();
95 de = e->dtEnd().date(); 114 de = e->dtEnd().date();
96 } 115 }
97 mItem->setText(0,e->summary()); 116 mItem->setText(0,e->summary());
98 mItem->setText(1,start); 117 mItem->setText(1,start);
99 mItem->setText(2,e->dtStartTimeStr()); 118 mItem->setText(2,e->dtStartTimeStr());
100 mItem->setText(3,end); 119 mItem->setText(3,end);
101 mItem->setText(4,e->dtEndTimeStr()); 120 mItem->setText(4,e->dtEndTimeStr());
102 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); 121 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
103 mItem->setText(6, e->recurrence()->recurrenceText()); 122 mItem->setText(6, e->recurrence()->recurrenceText());
104 mItem->setText(7,"---"); 123 mItem->setText(7,"---");
105 mItem->setText(8,"---"); 124 mItem->setText(8,"---");
106 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 125 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
107 mItem->setText(10,e->categoriesStr()); 126 mItem->setText(10,e->categoriesStr());
108 127
109 QString key; 128 QString key;
110 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 129 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
111 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 130 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
112 mItem->setSortKey(1,key); 131 mItem->setSortKey(1,key);
113 132
114 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 133 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
115 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 134 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
116 mItem->setSortKey(3,key); 135 mItem->setSortKey(3,key);
117 136
118 return true; 137 return true;
119} 138}
120 139
121bool ListItemVisitor::visit(Todo *t) 140bool ListItemVisitor::visit(Todo *t)
122{ 141{
123 mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); 142 mItem->setText(0,i18n("To-Do: %1").arg(t->summary()));
124 if (t->hasStartDate()) { 143 if (t->hasStartDate()) {
125 mItem->setText(1,t->dtStartDateStr()); 144 mItem->setText(1,t->dtStartDateStr());
126 if (t->doesFloat()) { 145 if (t->doesFloat()) {
127 mItem->setText(2,"---"); 146 mItem->setText(2,"---");
128 } else { 147 } else {
129 mItem->setText(2,t->dtStartTimeStr()); 148 mItem->setText(2,t->dtStartTimeStr());
130 } 149 }
131 } else { 150 } else {
132 mItem->setText(1,"---"); 151 mItem->setText(1,"---");
133 mItem->setText(2,"---"); 152 mItem->setText(2,"---");
134 } 153 }
135 mItem->setText(3,"---"); 154 mItem->setText(3,"---");
136 mItem->setText(4,"---"); 155 mItem->setText(4,"---");
137 mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No")); 156 mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
138 mItem->setText(6,"---"); 157 mItem->setText(6,"---");
139 if (t->hasDueDate()) { 158 if (t->hasDueDate()) {
140 mItem->setText(7,t->dtDueDateStr()); 159 mItem->setText(7,t->dtDueDateStr());
141 if (t->doesFloat()) { 160 if (t->doesFloat()) {
142 mItem->setText(8,"---"); 161 mItem->setText(8,"---");
143 } else { 162 } else {
144 mItem->setText(8,t->dtDueTimeStr()); 163 mItem->setText(8,t->dtDueTimeStr());
145 } 164 }
146 } else { 165 } else {
147 mItem->setText(7,"---"); 166 mItem->setText(7,"---");
148 mItem->setText(8,"---"); 167 mItem->setText(8,"---");
149 } 168 }
150 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 169 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
151 mItem->setText(10,t->categoriesStr()); 170 mItem->setText(10,t->categoriesStr());
152 171
153 QString key; 172 QString key;
154 QDate d; 173 QDate d;
155 if (t->hasDueDate()) { 174 if (t->hasDueDate()) {
156 d = t->dtDue().date(); 175 d = t->dtDue().date();
157 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 176 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
158 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 177 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
159 mItem->setSortKey(7,key); 178 mItem->setSortKey(7,key);
160 } 179 }
161 if ( t->hasStartDate() ) { 180 if ( t->hasStartDate() ) {
162 d = t->dtStart().date(); 181 d = t->dtStart().date();
163 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 182 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
164 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 183 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
165 mItem->setSortKey(1,key); 184 mItem->setSortKey(1,key);
166 } 185 }
167 return true; 186 return true;
168} 187}
169 188
170bool ListItemVisitor::visit(Journal * j) 189bool ListItemVisitor::visit(Journal * j)
171{ 190{
172 QString des = j->description().left(50); 191 QString des = j->description().left(50);
173 des = des.simplifyWhiteSpace (); 192 des = des.simplifyWhiteSpace ();
174 des.replace (QRegExp ("\\n"),"" ); 193 des.replace (QRegExp ("\\n"),"" );
175 des.replace (QRegExp ("\\r"),"" ); 194 des.replace (QRegExp ("\\r"),"" );
176 mItem->setText(0,i18n("Journal")+": "+des.left(25)); 195 mItem->setText(0,i18n("Journal")+": "+des.left(25));
177 mItem->setText(1,j->dtStartDateStr()); 196 mItem->setText(1,j->dtStartDateStr());
178 mItem->setText(2,"---"); 197 mItem->setText(2,"---");
179 mItem->setText(3,"---"); 198 mItem->setText(3,"---");
180 mItem->setText(4,"---"); 199 mItem->setText(4,"---");
181 mItem->setText(5,"---"); 200 mItem->setText(5,"---");
182 mItem->setText(6,"---"); 201 mItem->setText(6,"---");
183 mItem->setText(7,j->dtStartDateStr()); 202 mItem->setText(7,j->dtStartDateStr());
184 mItem->setText(8,"---"); 203 mItem->setText(8,"---");
185 mItem->setText(9,"---"); 204 mItem->setText(9,"---");
186 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 205 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
187 206
188 QString key; 207 QString key;
189 QDate d = j->dtStart().date(); 208 QDate d = j->dtStart().date();
190 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 209 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
191 mItem->setSortKey(1,key); 210 mItem->setSortKey(1,key);
192 mItem->setSortKey(7,key); 211 mItem->setSortKey(7,key);
193 212
194 return true; 213 return true;
195} 214}
196 215
197KOListView::KOListView(Calendar *calendar, QWidget *parent, 216KOListView::KOListView(Calendar *calendar, QWidget *parent,
198 const char *name) 217 const char *name)
199 : KOEventView(calendar, parent, name) 218 : KOEventView(calendar, parent, name)
200{ 219{
201 mActiveItem = 0; 220 mActiveItem = 0;
202 mListView = new KOListViewListView(this); 221 mListView = new KOListViewListView(this);
203 mListView->addColumn(i18n("Summary")); 222 mListView->addColumn(i18n("Summary"));
204 mListView->addColumn(i18n("Start Date")); 223 mListView->addColumn(i18n("Start Date"));
205 mListView->addColumn(i18n("Start Time")); 224 mListView->addColumn(i18n("Start Time"));
206 mListView->addColumn(i18n("End Date")); 225 mListView->addColumn(i18n("End Date"));
207 mListView->addColumn(i18n("End Time")); 226 mListView->addColumn(i18n("End Time"));
208 mListView->addColumn(i18n("Alarm")); // alarm set? 227 mListView->addColumn(i18n("Alarm")); // alarm set?
209 mListView->addColumn(i18n("Recurs")); // recurs? 228 mListView->addColumn(i18n("Recurs")); // recurs?
210 mListView->addColumn(i18n("Due Date")); 229 mListView->addColumn(i18n("Due Date"));
211 mListView->addColumn(i18n("Due Time")); 230 mListView->addColumn(i18n("Due Time"));
212 mListView->addColumn(i18n("Cancelled")); 231 mListView->addColumn(i18n("Cancelled"));
213 mListView->addColumn(i18n("Categories")); 232 mListView->addColumn(i18n("Categories"));
214 233
215 mListView->setColumnAlignment(0,AlignLeft); 234 mListView->setColumnAlignment(0,AlignLeft);
216 mListView->setColumnAlignment(1,AlignLeft); 235 mListView->setColumnAlignment(1,AlignLeft);
217 mListView->setColumnAlignment(2,AlignHCenter); 236 mListView->setColumnAlignment(2,AlignHCenter);
218 mListView->setColumnAlignment(3,AlignLeft); 237 mListView->setColumnAlignment(3,AlignLeft);
219 mListView->setColumnAlignment(4,AlignHCenter); 238 mListView->setColumnAlignment(4,AlignHCenter);
220 mListView->setColumnAlignment(5,AlignLeft); 239 mListView->setColumnAlignment(5,AlignLeft);
221 mListView->setColumnAlignment(6,AlignLeft); 240 mListView->setColumnAlignment(6,AlignLeft);
222 mListView->setColumnAlignment(7,AlignLeft); 241 mListView->setColumnAlignment(7,AlignLeft);
223 mListView->setColumnAlignment(8,AlignLeft); 242 mListView->setColumnAlignment(8,AlignLeft);
224 mListView->setColumnAlignment(9,AlignLeft); 243 mListView->setColumnAlignment(9,AlignLeft);
225 mListView->setColumnAlignment(10,AlignLeft); 244 mListView->setColumnAlignment(10,AlignLeft);
226 mListView->setColumnWidthMode(10, QListView::Manual); 245 mListView->setColumnWidthMode(10, QListView::Manual);
246 new KOListViewWhatsThis(mListView->viewport(),this);
227 247
228 int iii = 0; 248 int iii = 0;
229 for ( iii = 0; iii< 10 ; ++iii ) 249 for ( iii = 0; iii< 10 ; ++iii )
230 mListView->setColumnWidthMode( iii, QListView::Manual ); 250 mListView->setColumnWidthMode( iii, QListView::Manual );
231 251
232 QBoxLayout *layoutTop = new QVBoxLayout(this); 252 QBoxLayout *layoutTop = new QVBoxLayout(this);
233 layoutTop->addWidget(mListView); 253 layoutTop->addWidget(mListView);
234 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 254 mListView->setFont ( KOPrefs::instance()->mListViewFont );
235 mPopupMenu = eventPopup(); 255 mPopupMenu = eventPopup();
236 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 256 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
237 i18n("Select all"),this, 257 i18n("Select all"),this,
238 SLOT(allSelection()),true); 258 SLOT(allSelection()),true);
239 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 259 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
240 i18n("Deselect All"),this, 260 i18n("Deselect All"),this,
241 SLOT(clearSelection()),true); 261 SLOT(clearSelection()),true);
242 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 262 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
243 i18n("Delete all selected"),this, 263 i18n("Delete all selected"),this,
244 SLOT(deleteAll()),true); 264 SLOT(deleteAll()),true);
245 mPopupMenu->insertSeparator(); 265 mPopupMenu->insertSeparator();
246 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 266 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
247 i18n("Save selected to file..."),this, 267 i18n("Save selected to file..."),this,
248 SLOT(saveToFile()),true); 268 SLOT(saveToFile()),true);
249 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 269 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
250 i18n("Save Journal/Description..."),this, 270 i18n("Save Journal/Description..."),this,
251 SLOT(saveDescriptionToFile()),true); 271 SLOT(saveDescriptionToFile()),true);
252 mPopupMenu->insertSeparator(); 272 mPopupMenu->insertSeparator();
253 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 273 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
254 i18n("Add Categ. to selected..."),this, 274 i18n("Add Categ. to selected..."),this,
255 SLOT(addCat()),true); 275 SLOT(addCat()),true);
256 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 276 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
257 i18n("Set Categ. for selected..."),this, 277 i18n("Set Categ. for selected..."),this,
258 SLOT(setCat()),true); 278 SLOT(setCat()),true);
259 mPopupMenu->insertSeparator(); 279 mPopupMenu->insertSeparator();
260 280
261 281
262#ifndef DESKTOP_VERSION 282#ifndef DESKTOP_VERSION
263 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 283 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
264 i18n("Beam selected via IR"),this, 284 i18n("Beam selected via IR"),this,
265 SLOT(beamSelected()),true); 285 SLOT(beamSelected()),true);
266#endif 286#endif
267 /* 287 /*
268 mPopupMenu = new QPopupMenu; 288 mPopupMenu = new QPopupMenu;
269 mPopupMenu->insertItem(i18n("Edit Event"), this, 289 mPopupMenu->insertItem(i18n("Edit Event"), this,
270 SLOT (editEvent())); 290 SLOT (editEvent()));
271 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 291 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
272 SLOT (deleteEvent())); 292 SLOT (deleteEvent()));
273 mPopupMenu->insertSeparator(); 293 mPopupMenu->insertSeparator();
274 mPopupMenu->insertItem(i18n("Show Dates"), this, 294 mPopupMenu->insertItem(i18n("Show Dates"), this,
275 SLOT(showDates())); 295 SLOT(showDates()));
276 mPopupMenu->insertItem(i18n("Hide Dates"), this, 296 mPopupMenu->insertItem(i18n("Hide Dates"), this,
277 SLOT(hideDates())); 297 SLOT(hideDates()));
278 */ 298 */
279 QObject::connect(mListView,SIGNAL( newEvent()), 299 QObject::connect(mListView,SIGNAL( newEvent()),
280 this,SIGNAL(signalNewEvent())); 300 this,SIGNAL(signalNewEvent()));
281 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 301 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
282 this,SLOT(defaultItemAction(QListViewItem *))); 302 this,SLOT(defaultItemAction(QListViewItem *)));
283 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, 303 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *,
284 const QPoint &, int )), 304 const QPoint &, int )),
285 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 305 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
286 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 306 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
287 SLOT(processSelectionChange(QListViewItem *))); 307 SLOT(processSelectionChange(QListViewItem *)));
288 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 308 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
289 SIGNAL(showIncidenceSignal(Incidence *)) ); 309 SIGNAL(showIncidenceSignal(Incidence *)) );
290 310
291 readSettings(KOGlobals::config(),"KOListView Layout"); 311 readSettings(KOGlobals::config(),"KOListView Layout");
292} 312}
293 313
294KOListView::~KOListView() 314KOListView::~KOListView()
295{ 315{
296 delete mPopupMenu; 316 delete mPopupMenu;
297} 317}
318QString KOListView::getWhatsThisText(QPoint p)
319{
320 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
321 if ( item )
322 return KIncidenceFormatter::instance()->getFormattedText( item->data() );
323 return i18n("That is the list view" );
324
325}
298 326
299void KOListView::updateList() 327void KOListView::updateList()
300{ 328{
301 // qDebug(" KOListView::updateList() "); 329 // qDebug(" KOListView::updateList() ");
302 330
303} 331}
304 332
305void KOListView::addCat( ) 333void KOListView::addCat( )
306{ 334{
307 setCategories( false ); 335 setCategories( false );
308} 336}
309void KOListView::setCat() 337void KOListView::setCat()
310{ 338{
311 setCategories( true ); 339 setCategories( true );
312} 340}
313void KOListView::setCategories( bool removeOld ) 341void KOListView::setCategories( bool removeOld )
314{ 342{
315 343
316 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 344 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
317 if (! csd->exec()) { 345 if (! csd->exec()) {
318 delete csd; 346 delete csd;
319 return; 347 return;
320 } 348 }
321 QStringList catList = csd->selectedCategories(); 349 QStringList catList = csd->selectedCategories();
322 delete csd; 350 delete csd;
323 // if ( catList.count() == 0 ) 351 // if ( catList.count() == 0 )
324 // return; 352 // return;
325 catList.sort(); 353 catList.sort();
326 QString categoriesStr = catList.join(","); 354 QString categoriesStr = catList.join(",");
327 int i; 355 int i;
328 QStringList itemList; 356 QStringList itemList;
329 QPtrList<KOListViewItem> sel ; 357 QPtrList<KOListViewItem> sel ;
330 QListViewItem *qitem = mListView->firstChild (); 358 QListViewItem *qitem = mListView->firstChild ();
331 while ( qitem ) { 359 while ( qitem ) {
332 if ( qitem->isSelected() ) { 360 if ( qitem->isSelected() ) {
333 sel.append(((KOListViewItem *)qitem)); 361 sel.append(((KOListViewItem *)qitem));
334 } 362 }
335 qitem = qitem->nextSibling(); 363 qitem = qitem->nextSibling();
336 } 364 }
337 KOListViewItem * item, *temp; 365 KOListViewItem * item, *temp;
338 item = sel.first(); 366 item = sel.first();
339 Incidence* inc; 367 Incidence* inc;
340 while ( item ) { 368 while ( item ) {
341 inc = item->data(); 369 inc = item->data();
342 if ( removeOld ) { 370 if ( removeOld ) {
343 inc->setCategories( categoriesStr ); 371 inc->setCategories( categoriesStr );
344 } else { 372 } else {
345 itemList = QStringList::split (",", inc->categoriesStr() ); 373 itemList = QStringList::split (",", inc->categoriesStr() );
346 for( i = 0; i< catList.count(); ++i ) { 374 for( i = 0; i< catList.count(); ++i ) {
347 if ( !itemList.contains (catList[i])) 375 if ( !itemList.contains (catList[i]))
348 itemList.append( catList[i] ); 376 itemList.append( catList[i] );
349 } 377 }
350 itemList.sort(); 378 itemList.sort();
351 inc->setCategories( itemList.join(",") ); 379 inc->setCategories( itemList.join(",") );
352 } 380 }
353 temp = item; 381 temp = item;
354 item = sel.next(); 382 item = sel.next();
355 mUidDict.remove( inc->uid() ); 383 mUidDict.remove( inc->uid() );
356 delete temp;; 384 delete temp;;
357 addIncidence( inc ); 385 addIncidence( inc );
358 } 386 }
359} 387}
360 388
361void KOListView::beamSelected() 389void KOListView::beamSelected()
362{ 390{
363 int icount = 0; 391 int icount = 0;
364 QPtrList<Incidence> delSel ; 392 QPtrList<Incidence> delSel ;
365 QListViewItem *item = mListView->firstChild (); 393 QListViewItem *item = mListView->firstChild ();
366 while ( item ) { 394 while ( item ) {
367 if ( item->isSelected() ) { 395 if ( item->isSelected() ) {
368 delSel.append(((KOListViewItem *)item)->data()); 396 delSel.append(((KOListViewItem *)item)->data());
369 ++icount; 397 ++icount;
370 } 398 }
371 399
372 item = item->nextSibling(); 400 item = item->nextSibling();
373 } 401 }
374 if ( icount ) { 402 if ( icount ) {
375 emit beamIncidenceList( delSel ); 403 emit beamIncidenceList( delSel );
376 return; 404 return;
377 QString fn ; 405 QString fn ;
378 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 406 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
379 QString mes; 407 QString mes;
380 bool createbup = true; 408 bool createbup = true;
381 if ( createbup ) { 409 if ( createbup ) {
382 QString description = "\n"; 410 QString description = "\n";
383 CalendarLocal* cal = new CalendarLocal(); 411 CalendarLocal* cal = new CalendarLocal();
384 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 412 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
385 Incidence *incidence = delSel.first(); 413 Incidence *incidence = delSel.first();
386 while ( incidence ) { 414 while ( incidence ) {
387 Incidence *in = incidence->clone(); 415 Incidence *in = incidence->clone();
388 description += in->summary() + "\n"; 416 description += in->summary() + "\n";
389 cal->addIncidence( in ); 417 cal->addIncidence( in );
390 incidence = delSel.next(); 418 incidence = delSel.next();
391 } 419 }
392 FileStorage storage( cal, fn, new VCalFormat ); 420 FileStorage storage( cal, fn, new VCalFormat );
393 storage.save(); 421 storage.save();
394 delete cal; 422 delete cal;
395 mes = i18n("KO/Pi: Ready for beaming"); 423 mes = i18n("KO/Pi: Ready for beaming");
396 topLevelWidget()->setCaption(mes); 424 topLevelWidget()->setCaption(mes);
397 425
398#ifndef DESKTOP_VERSION 426#ifndef DESKTOP_VERSION
399 Ir *ir = new Ir( this ); 427 Ir *ir = new Ir( this );
400 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 428 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
401 ir->send( fn, description, "text/x-vCalendar" ); 429 ir->send( fn, description, "text/x-vCalendar" );
402#endif 430#endif
403 } 431 }
404 } 432 }
405} 433}
406void KOListView::beamDone( Ir *ir ) 434void KOListView::beamDone( Ir *ir )
407{ 435{
408#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
409 delete ir; 437 delete ir;
410#endif 438#endif
411 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 439 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
412} 440}
413 441
414void KOListView::saveDescriptionToFile() 442void KOListView::saveDescriptionToFile()
415{ 443{
416 444
417 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 445 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
418 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 446 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
419 i18n("Continue"), i18n("Cancel"), 0, 447 i18n("Continue"), i18n("Cancel"), 0,
420 0, 1 ); 448 0, 1 );
421 if ( result != 0 ) { 449 if ( result != 0 ) {
422 return; 450 return;
423 } 451 }
424 int icount = 0; 452 int icount = 0;
425 QPtrList<Incidence> delSel ; 453 QPtrList<Incidence> delSel ;
426 QListViewItem *item = mListView->firstChild (); 454 QListViewItem *item = mListView->firstChild ();
427 while ( item ) { 455 while ( item ) {
428 if ( item->isSelected() ) { 456 if ( item->isSelected() ) {
429 delSel.append(((KOListViewItem *)item)->data()); 457 delSel.append(((KOListViewItem *)item)->data());
430 ++icount; 458 ++icount;
431 } 459 }
432 460
433 item = item->nextSibling(); 461 item = item->nextSibling();
434 } 462 }
435 if ( icount ) { 463 if ( icount ) {
436 QString fn = KOPrefs::instance()->mLastSaveFile; 464 QString fn = KOPrefs::instance()->mLastSaveFile;
437 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 465 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
438 466
439 if ( fn == "" ) 467 if ( fn == "" )
440 return; 468 return;
441 QFileInfo info; 469 QFileInfo info;
442 info.setFile( fn ); 470 info.setFile( fn );
443 QString mes; 471 QString mes;
444 bool createbup = true; 472 bool createbup = true;
445 if ( info. exists() ) { 473 if ( info. exists() ) {
446 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 474 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
447 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 475 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
448 i18n("Overwrite!"), i18n("Cancel"), 0, 476 i18n("Overwrite!"), i18n("Cancel"), 0,
449 0, 1 ); 477 0, 1 );
450 if ( result != 0 ) { 478 if ( result != 0 ) {
451 createbup = false; 479 createbup = false;
452 } 480 }
453 } 481 }
454 if ( createbup ) { 482 if ( createbup ) {
455 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 483 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
456 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 484 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
457 Incidence *incidence = delSel.first(); 485 Incidence *incidence = delSel.first();
458 icount = 0; 486 icount = 0;
459 while ( incidence ) { 487 while ( incidence ) {
460 if ( incidence->type() == "Journal" ) { 488 if ( incidence->type() == "Journal" ) {
461 text += "\n************************************\n"; 489 text += "\n************************************\n";
462 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 490 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
463 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 491 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
464 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 492 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
465 ++icount; 493 ++icount;
466 494
467 } else { 495 } else {
468 if ( !incidence->description().isEmpty() ) { 496 if ( !incidence->description().isEmpty() ) {
469 text += "\n************************************\n"; 497 text += "\n************************************\n";
470 if ( incidence->type() == "Todo" ) 498 if ( incidence->type() == "Todo" )
471 text += i18n("To-Do: "); 499 text += i18n("To-Do: ");
472 text += incidence->summary(); 500 text += incidence->summary();
473 if ( incidence->hasStartDate() ) 501 if ( incidence->hasStartDate() )
474 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 502 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
475 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 503 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
476 if ( !incidence->location().isEmpty() ) 504 if ( !incidence->location().isEmpty() )
477 text += "\n" +i18n("Location: ") + incidence->location(); 505 text += "\n" +i18n("Location: ") + incidence->location();
478 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 506 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
479 ++icount; 507 ++icount;
480 508
481 } 509 }
482 } 510 }
483 incidence = delSel.next(); 511 incidence = delSel.next();
484 } 512 }
485 QFile file( fn ); 513 QFile file( fn );
486 if (!file.open( IO_WriteOnly ) ) { 514 if (!file.open( IO_WriteOnly ) ) {
487 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 515 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
488 return; 516 return;
489 } 517 }
490 QTextStream ts( &file ); 518 QTextStream ts( &file );
491 ts << text; 519 ts << text;
492 file.close(); 520 file.close();
493 //qDebug("%s ", text.latin1()); 521 //qDebug("%s ", text.latin1());
494 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 522 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
495 KOPrefs::instance()->mLastSaveFile = fn; 523 KOPrefs::instance()->mLastSaveFile = fn;
496 topLevelWidget()->setCaption(mes); 524 topLevelWidget()->setCaption(mes);
497 } 525 }
498 } 526 }
499} 527}
500void KOListView::saveToFile() 528void KOListView::saveToFile()
501{ 529{
502 530
503 int icount = 0; 531 int icount = 0;
504 QPtrList<Incidence> delSel ; 532 QPtrList<Incidence> delSel ;
505 QListViewItem *item = mListView->firstChild (); 533 QListViewItem *item = mListView->firstChild ();
506 while ( item ) { 534 while ( item ) {
507 if ( item->isSelected() ) { 535 if ( item->isSelected() ) {
508 delSel.append(((KOListViewItem *)item)->data()); 536 delSel.append(((KOListViewItem *)item)->data());
509 ++icount; 537 ++icount;
510 } 538 }
511 539
512 item = item->nextSibling(); 540 item = item->nextSibling();
513 } 541 }
514 if ( icount ) { 542 if ( icount ) {
515 QString fn = KOPrefs::instance()->mLastSaveFile; 543 QString fn = KOPrefs::instance()->mLastSaveFile;
516 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 544 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
517 545
518 if ( fn == "" ) 546 if ( fn == "" )
519 return; 547 return;
520 QFileInfo info; 548 QFileInfo info;
521 info.setFile( fn ); 549 info.setFile( fn );
522 QString mes; 550 QString mes;
523 bool createbup = true; 551 bool createbup = true;
524 if ( info. exists() ) { 552 if ( info. exists() ) {
525 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 553 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
526 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 554 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
527 i18n("Overwrite!"), i18n("Cancel"), 0, 555 i18n("Overwrite!"), i18n("Cancel"), 0,
528 0, 1 ); 556 0, 1 );
529 if ( result != 0 ) { 557 if ( result != 0 ) {
530 createbup = false; 558 createbup = false;
531 } 559 }
532 } 560 }
533 if ( createbup ) { 561 if ( createbup ) {
534 CalendarLocal cal; 562 CalendarLocal cal;
535 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 563 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
536 Incidence *incidence = delSel.first(); 564 Incidence *incidence = delSel.first();
537 while ( incidence ) { 565 while ( incidence ) {
538 cal.addIncidence( incidence->clone() ); 566 cal.addIncidence( incidence->clone() );
539 incidence = delSel.next(); 567 incidence = delSel.next();
540 } 568 }
541 ICalFormat format; 569 ICalFormat format;
542 format.save( &cal, fn ); 570 format.save( &cal, fn );
543 mes = i18n("KO/Pi:Saved %1").arg(fn ); 571 mes = i18n("KO/Pi:Saved %1").arg(fn );
544 KOPrefs::instance()->mLastSaveFile = fn; 572 KOPrefs::instance()->mLastSaveFile = fn;
545 topLevelWidget()->setCaption(mes); 573 topLevelWidget()->setCaption(mes);
546 } 574 }
547 } 575 }
548} 576}
549void KOListView::deleteAll() 577void KOListView::deleteAll()
550{ 578{
551 int icount = 0; 579 int icount = 0;
552 QPtrList<Incidence> delSel ; 580 QPtrList<Incidence> delSel ;
553 QListViewItem *item = mListView->firstChild (); 581 QListViewItem *item = mListView->firstChild ();
554 while ( item ) { 582 while ( item ) {
555 if ( item->isSelected() ) { 583 if ( item->isSelected() ) {
556 delSel.append(((KOListViewItem *)item)->data()); 584 delSel.append(((KOListViewItem *)item)->data());
557 ++icount; 585 ++icount;
558 } 586 }
559 587
560 item = item->nextSibling(); 588 item = item->nextSibling();
561 } 589 }
562 if ( icount ) { 590 if ( icount ) {
563 Incidence *incidence = delSel.first(); 591 Incidence *incidence = delSel.first();
564 Incidence *toDelete; 592 Incidence *toDelete;
565 KOPrefs *p = KOPrefs::instance(); 593 KOPrefs *p = KOPrefs::instance();
566 bool confirm = p->mConfirm; 594 bool confirm = p->mConfirm;
567 QString mess; 595 QString mess;
568 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 596 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
569 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 597 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
570 p->mConfirm = false; 598 p->mConfirm = false;
571 int delCounter = 0; 599 int delCounter = 0;
572 QDialog dia ( this, "p-dialog", true ); 600 QDialog dia ( this, "p-dialog", true );
573 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 601 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
574 QVBoxLayout lay( &dia ); 602 QVBoxLayout lay( &dia );
575 lay.setMargin(7); 603 lay.setMargin(7);
576 lay.setSpacing(7); 604 lay.setSpacing(7);
577 lay.addWidget( &lab); 605 lay.addWidget( &lab);
578 QProgressBar bar( icount, &dia ); 606 QProgressBar bar( icount, &dia );
579 lay.addWidget( &bar); 607 lay.addWidget( &bar);
580 int w = 220; 608 int w = 220;
581 int h = 50; 609 int h = 50;
582 int dw = QApplication::desktop()->width(); 610 int dw = QApplication::desktop()->width();
583 int dh = QApplication::desktop()->height(); 611 int dh = QApplication::desktop()->height();
584 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 612 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
585 //dia.resize( 240,50 ); 613 //dia.resize( 240,50 );
586 dia.show(); 614 dia.show();
587 615
588 while ( incidence ) { 616 while ( incidence ) {
589 bar.setProgress( delCounter ); 617 bar.setProgress( delCounter );
590 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 618 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
591 dia.setCaption( mess ); 619 dia.setCaption( mess );
592 qApp->processEvents(); 620 qApp->processEvents();
593 toDelete = (incidence); 621 toDelete = (incidence);
594 incidence = delSel.next(); 622 incidence = delSel.next();
595 emit deleteIncidenceSignal(toDelete ); 623 emit deleteIncidenceSignal(toDelete );
596 if ( dia.result() != 0 ) 624 if ( dia.result() != 0 )
597 break; 625 break;
598 626
599 } 627 }
600 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 628 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
601 topLevelWidget ()->setCaption( mess ); 629 topLevelWidget ()->setCaption( mess );
602 p->mConfirm = confirm; 630 p->mConfirm = confirm;
603 } 631 }
604 } 632 }
605 633
606 634
607} 635}
608int KOListView::maxDatesHint() 636int KOListView::maxDatesHint()
609{ 637{
610 return 0; 638 return 0;
611} 639}
612 640
613int KOListView::currentDateCount() 641int KOListView::currentDateCount()
614{ 642{
615 return 0; 643 return 0;
616} 644}
617 645
618QPtrList<Incidence> KOListView::selectedIncidences() 646QPtrList<Incidence> KOListView::selectedIncidences()
619{ 647{
620 QPtrList<Incidence> eventList; 648 QPtrList<Incidence> eventList;
621 QListViewItem *item = mListView->firstChild (); 649 QListViewItem *item = mListView->firstChild ();
622 while ( item ) { 650 while ( item ) {
623 if ( item->isSelected() ) { 651 if ( item->isSelected() ) {
624 eventList.append(((KOListViewItem *)item)->data()); 652 eventList.append(((KOListViewItem *)item)->data());
625 } 653 }
626 654
627 item = item->nextSibling(); 655 item = item->nextSibling();
628 } 656 }
629 657
630 // // QListViewItem *item = mListView->selectedItem(); 658 // // QListViewItem *item = mListView->selectedItem();
631 //if (item) eventList.append(((KOListViewItem *)item)->data()); 659 //if (item) eventList.append(((KOListViewItem *)item)->data());
632 660
633 return eventList; 661 return eventList;
634} 662}
635 663
636DateList KOListView::selectedDates() 664DateList KOListView::selectedDates()
637{ 665{
638 DateList eventList; 666 DateList eventList;
639 return eventList; 667 return eventList;
640} 668}
641 669
642void KOListView::showDates(bool show) 670void KOListView::showDates(bool show)
643{ 671{
644 // Shouldn't we set it to a value greater 0? When showDates is called with 672 // Shouldn't we set it to a value greater 0? When showDates is called with
645 // show == true at first, then the columnwidths are set to zero. 673 // show == true at first, then the columnwidths are set to zero.
646 static int oldColWidth1 = 0; 674 static int oldColWidth1 = 0;
647 static int oldColWidth3 = 0; 675 static int oldColWidth3 = 0;
648 676
649 if (!show) { 677 if (!show) {
650 oldColWidth1 = mListView->columnWidth(1); 678 oldColWidth1 = mListView->columnWidth(1);
651 oldColWidth3 = mListView->columnWidth(3); 679 oldColWidth3 = mListView->columnWidth(3);
652 mListView->setColumnWidth(1, 0); 680 mListView->setColumnWidth(1, 0);
653 mListView->setColumnWidth(3, 0); 681 mListView->setColumnWidth(3, 0);
654 } else { 682 } else {
655 mListView->setColumnWidth(1, oldColWidth1); 683 mListView->setColumnWidth(1, oldColWidth1);
656 mListView->setColumnWidth(3, oldColWidth3); 684 mListView->setColumnWidth(3, oldColWidth3);
657 } 685 }
658 mListView->repaint(); 686 mListView->repaint();
659} 687}
660 688
661void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 689void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
662 const QDate &td) 690 const QDate &td)
663{ 691{
664#ifndef KORG_NOPRINTER 692#ifndef KORG_NOPRINTER
665 calPrinter->preview(CalPrinter::Day, fd, td); 693 calPrinter->preview(CalPrinter::Day, fd, td);
666#endif 694#endif
667} 695}
668 696
669void KOListView::showDates() 697void KOListView::showDates()
670{ 698{
671 showDates(true); 699 showDates(true);
672} 700}
673 701
674void KOListView::hideDates() 702void KOListView::hideDates()
675{ 703{
676 showDates(false); 704 showDates(false);
677} 705}
678 706
679void KOListView::updateView() 707void KOListView::updateView()
680{ 708{
681 mListView->setFocus(); 709 mListView->setFocus();
682 if ( mListView->firstChild () ) 710 if ( mListView->firstChild () )
683 mListView->setCurrentItem( mListView->firstChild () ); 711 mListView->setCurrentItem( mListView->firstChild () );
684} 712}
685void KOListView::updateConfig() 713void KOListView::updateConfig()
686{ 714{
687 715
688 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 716 mListView->setFont ( KOPrefs::instance()->mListViewFont );
689 updateView(); 717 updateView();
690 718
691} 719}
692void KOListView::setStartDate(const QDate &start) 720void KOListView::setStartDate(const QDate &start)
693{ 721{
694 mStartDate = start; 722 mStartDate = start;
695} 723}
696 724
697void KOListView::showDates(const QDate &start, const QDate &end) 725void KOListView::showDates(const QDate &start, const QDate &end)
698{ 726{
699 clear(); 727 clear();
700 mStartDate = start; 728 mStartDate = start;
701 QDate date = start; 729 QDate date = start;
702 QPtrList<Journal> j_list; 730 QPtrList<Journal> j_list;
703 while( date <= end ) { 731 while( date <= end ) {
704 addEvents(calendar()->events(date)); 732 addEvents(calendar()->events(date));
705 addTodos(calendar()->todos(date)); 733 addTodos(calendar()->todos(date));
706 Journal* jo = calendar()->journal(date); 734 Journal* jo = calendar()->journal(date);
707 if ( jo ) 735 if ( jo )
708 j_list.append( jo ); 736 j_list.append( jo );
709 date = date.addDays( 1 ); 737 date = date.addDays( 1 );
710 } 738 }
711 addJournals(j_list); 739 addJournals(j_list);
712 emit incidenceSelected( 0 ); 740 emit incidenceSelected( 0 );
713 updateView(); 741 updateView();
714 742
715} 743}
716 744
717void KOListView::addEvents(QPtrList<Event> eventList) 745void KOListView::addEvents(QPtrList<Event> eventList)
718{ 746{
719 Event *ev; 747 Event *ev;
720 for(ev = eventList.first(); ev; ev = eventList.next()) { 748 for(ev = eventList.first(); ev; ev = eventList.next()) {
721 addIncidence(ev); 749 addIncidence(ev);
722 } 750 }
723 if ( !mListView->currentItem() ){ 751 if ( !mListView->currentItem() ){
724 updateView(); 752 updateView();
725 } 753 }
726} 754}
727 755
728void KOListView::addTodos(QPtrList<Todo> eventList) 756void KOListView::addTodos(QPtrList<Todo> eventList)
729{ 757{
730 Todo *ev; 758 Todo *ev;
731 for(ev = eventList.first(); ev; ev = eventList.next()) { 759 for(ev = eventList.first(); ev; ev = eventList.next()) {
732 addIncidence(ev); 760 addIncidence(ev);
733 } 761 }
734 if ( !mListView->currentItem() ){ 762 if ( !mListView->currentItem() ){
735 updateView(); 763 updateView();
736 } 764 }
737} 765}
738void KOListView::addJournals(QPtrList<Journal> eventList) 766void KOListView::addJournals(QPtrList<Journal> eventList)
739{ 767{
740 Journal *ev; 768 Journal *ev;
741 for(ev = eventList.first(); ev; ev = eventList.next()) { 769 for(ev = eventList.first(); ev; ev = eventList.next()) {
742 addIncidence(ev); 770 addIncidence(ev);
743 } 771 }
744 if ( !mListView->currentItem() ){ 772 if ( !mListView->currentItem() ){
745 updateView(); 773 updateView();
746 } 774 }
747} 775}
748 776
749void KOListView::addIncidence(Incidence *incidence) 777void KOListView::addIncidence(Incidence *incidence)
750{ 778{
751 if ( mUidDict.find( incidence->uid() ) ) return; 779 if ( mUidDict.find( incidence->uid() ) ) return;
752 780
753 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 781 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
754 mUidDict.insert( incidence->uid(), incidence ); 782 mUidDict.insert( incidence->uid(), incidence );
755 783
756 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 784 KOListViewItem *item = new KOListViewItem( incidence, mListView );
757 ListItemVisitor v(item, mStartDate ); 785 ListItemVisitor v(item, mStartDate );
758 if (incidence->accept(v)) return; 786 if (incidence->accept(v)) return;
759 else delete item; 787 else delete item;
760 //qDebug("delete item "); 788 //qDebug("delete item ");
761} 789}
762 790
763void KOListView::showEvents(QPtrList<Event> eventList) 791void KOListView::showEvents(QPtrList<Event> eventList)
764{ 792{
765 clear(); 793 clear();
766 794
767 addEvents(eventList); 795 addEvents(eventList);
768 796
769 // After new creation of list view no events are selected. 797 // After new creation of list view no events are selected.
770 emit incidenceSelected( 0 ); 798 emit incidenceSelected( 0 );
771} 799}
772int KOListView::count() 800int KOListView::count()
773{ 801{
774 return mListView->childCount(); 802 return mListView->childCount();
775} 803}
776 804
777void KOListView::changeEventDisplay(Event *event, int action) 805void KOListView::changeEventDisplay(Event *event, int action)
778{ 806{
779 KOListViewItem *item; 807 KOListViewItem *item;
780 808
781 switch(action) { 809 switch(action) {
782 case KOGlobals::EVENTADDED: 810 case KOGlobals::EVENTADDED:
783 addIncidence( event ); 811 addIncidence( event );
784 break; 812 break;
785 case KOGlobals::EVENTEDITED: 813 case KOGlobals::EVENTEDITED:
786 item = getItemForEvent(event); 814 item = getItemForEvent(event);
787 if (item) { 815 if (item) {
788 mUidDict.remove( event->uid() ); 816 mUidDict.remove( event->uid() );
789 delete item; 817 delete item;
790 addIncidence( event ); 818 addIncidence( event );
791 } 819 }
792 break; 820 break;
793 case KOGlobals::EVENTDELETED: 821 case KOGlobals::EVENTDELETED:
794 item = getItemForEvent(event); 822 item = getItemForEvent(event);
795 if (item) { 823 if (item) {
796 mUidDict.remove( event->uid() ); 824 mUidDict.remove( event->uid() );
797 delete item; 825 delete item;
798 } 826 }
799 break; 827 break;
800 default: 828 default:
801 ; 829 ;
802 } 830 }
803} 831}
804 832
805KOListViewItem *KOListView::getItemForEvent(Event *event) 833KOListViewItem *KOListView::getItemForEvent(Event *event)
806{ 834{
807 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 835 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
808 while (item) { 836 while (item) {
809 if (item->data() == event) return item; 837 if (item->data() == event) return item;
810 item = (KOListViewItem *)item->nextSibling(); 838 item = (KOListViewItem *)item->nextSibling();
811 } 839 }
812 return 0; 840 return 0;
813} 841}
814 842
815void KOListView::defaultItemAction(QListViewItem *i) 843void KOListView::defaultItemAction(QListViewItem *i)
816{ 844{
817 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 845 KOListViewItem *item = static_cast<KOListViewItem *>( i );
818 if ( item ) defaultAction( item->data() ); 846 if ( item ) defaultAction( item->data() );
819 847
820} 848}
821 849
822void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 850void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
823{ 851{
824 mActiveItem = (KOListViewItem *)item; 852 mActiveItem = (KOListViewItem *)item;
825 if (mActiveItem) { 853 if (mActiveItem) {
826 Incidence *incidence = mActiveItem->data(); 854 Incidence *incidence = mActiveItem->data();
827 mPopupMenu->showIncidencePopup(incidence); 855 mPopupMenu->showIncidencePopup(incidence);
828 856
829 /* 857 /*
830 if ( incidence && incidence->type() == "Event" ) { 858 if ( incidence && incidence->type() == "Event" ) {
831 Event *event = static_cast<Event *>( incidence ); 859 Event *event = static_cast<Event *>( incidence );
832 mPopupMenu->showEventPopup(event); 860 mPopupMenu->showEventPopup(event);
833 } 861 }
834 */ 862 */
835 } 863 }
836} 864}
837 865
838void KOListView::readSettings(KConfig *config, QString setting) 866void KOListView::readSettings(KConfig *config, QString setting)
839{ 867{
840 // qDebug("KOListView::readSettings "); 868 // qDebug("KOListView::readSettings ");
841 mListView->restoreLayout(config,setting); 869 mListView->restoreLayout(config,setting);
842} 870}
843 871
844void KOListView::writeSettings(KConfig *config, QString setting) 872void KOListView::writeSettings(KConfig *config, QString setting)
845{ 873{
846 // qDebug("KOListView::writeSettings "); 874 // qDebug("KOListView::writeSettings ");
847 mListView->saveLayout(config, setting); 875 mListView->saveLayout(config, setting);
848} 876}
849 877
850void KOListView::processSelectionChange(QListViewItem *) 878void KOListView::processSelectionChange(QListViewItem *)
851{ 879{
852 880
853 KOListViewItem *item = 881 KOListViewItem *item =
854 static_cast<KOListViewItem *>( mListView->currentItem() ); 882 static_cast<KOListViewItem *>( mListView->currentItem() );
855 883
856 if ( !item ) { 884 if ( !item ) {
857 emit incidenceSelected( 0 ); 885 emit incidenceSelected( 0 );
858 } else { 886 } else {
859 emit incidenceSelected( item->data() ); 887 emit incidenceSelected( item->data() );
860 } 888 }
861} 889}
862 890
863void KOListView::clearSelection() 891void KOListView::clearSelection()
864{ 892{
865 mListView->selectAll( false ); 893 mListView->selectAll( false );
866} 894}
867void KOListView::allSelection() 895void KOListView::allSelection()
868{ 896{
869 mListView->selectAll( true ); 897 mListView->selectAll( true );
870} 898}
871 899
872void KOListView::clear() 900void KOListView::clear()
873{ 901{
874 mListView->clear(); 902 mListView->clear();
875 mUidDict.clear(); 903 mUidDict.clear();
876} 904}
877 905
878Incidence* KOListView::currentItem() 906Incidence* KOListView::currentItem()
879{ 907{
880 if ( mListView->currentItem() ) 908 if ( mListView->currentItem() )
881 return ((KOListViewItem*) mListView->currentItem())->data(); 909 return ((KOListViewItem*) mListView->currentItem())->data();
882 return 0; 910 return 0;
883} 911}
884void KOListView::keyPressEvent ( QKeyEvent *e) 912void KOListView::keyPressEvent ( QKeyEvent *e)
885{ 913{
886 914
887 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 915 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
888 deleteAll(); 916 deleteAll();
889 return; 917 return;
890 } 918 }
891 919
892 e->ignore(); 920 e->ignore();
893} 921}
894void KOListViewListView::keyPressEvent ( QKeyEvent *e) 922void KOListViewListView::keyPressEvent ( QKeyEvent *e)
895{ 923{
896 924
897 switch ( e->key() ) { 925 switch ( e->key() ) {
898 case Qt::Key_Down: 926 case Qt::Key_Down:
899 if ( e->state() == ShiftButton ) { 927 if ( e->state() == ShiftButton ) {
900 QListViewItem* cn = currentItem(); 928 QListViewItem* cn = currentItem();
901 if ( !cn ) 929 if ( !cn )
902 cn = firstChild(); 930 cn = firstChild();
903 if ( !cn ) 931 if ( !cn )
904 return; 932 return;
905 while ( cn->nextSibling() ) 933 while ( cn->nextSibling() )
906 cn = cn->nextSibling(); 934 cn = cn->nextSibling();
907 setCurrentItem ( cn ); 935 setCurrentItem ( cn );
908 ensureItemVisible ( cn ); 936 ensureItemVisible ( cn );
909 937
910 e->accept(); 938 e->accept();
911 return; 939 return;
912 } 940 }
913 if ( e->state() == ControlButton ) { 941 if ( e->state() == ControlButton ) {
914 int count = childCount (); 942 int count = childCount ();
915 int jump = count / 5; 943 int jump = count / 5;
916 QListViewItem* cn; 944 QListViewItem* cn;
917 cn = currentItem(); 945 cn = currentItem();
918 if ( ! cn ) 946 if ( ! cn )
919 return; 947 return;
920 if ( jump == 0 ) 948 if ( jump == 0 )
921 jump = 1; 949 jump = 1;
922 while ( jump && cn->nextSibling() ) { 950 while ( jump && cn->nextSibling() ) {
923 cn = cn->nextSibling(); 951 cn = cn->nextSibling();
924 --jump; 952 --jump;
925 } 953 }
926 setCurrentItem ( cn ); 954 setCurrentItem ( cn );
927 ensureItemVisible ( cn ); 955 ensureItemVisible ( cn );
928 956
929 } else 957 } else
930 QListView::keyPressEvent ( e ) ; 958 QListView::keyPressEvent ( e ) ;
931 e->accept(); 959 e->accept();
932 break; 960 break;
933 961
934 case Qt::Key_Up: 962 case Qt::Key_Up:
935 if ( e->state() == ShiftButton ) { 963 if ( e->state() == ShiftButton ) {
936 QListViewItem* cn = firstChild(); 964 QListViewItem* cn = firstChild();
937 if ( cn ) { 965 if ( cn ) {
938 setCurrentItem ( cn ); 966 setCurrentItem ( cn );
939 ensureItemVisible ( cn ); 967 ensureItemVisible ( cn );
940 } 968 }
941 e->accept(); 969 e->accept();
942 return; 970 return;
943 } 971 }
944 if ( e->state() == ControlButton ) { 972 if ( e->state() == ControlButton ) {
945 int count = childCount (); 973 int count = childCount ();
946 int jump = count / 5; 974 int jump = count / 5;
947 QListViewItem* cn; 975 QListViewItem* cn;
948 cn = currentItem(); 976 cn = currentItem();
949 if ( ! cn ) 977 if ( ! cn )
950 return; 978 return;
951 if ( jump == 0 ) 979 if ( jump == 0 )
952 jump = 1; 980 jump = 1;
953 while ( jump && cn->itemAbove ()) { 981 while ( jump && cn->itemAbove ()) {
954 cn = cn->itemAbove (); 982 cn = cn->itemAbove ();
955 --jump; 983 --jump;
956 } 984 }
957 setCurrentItem ( cn ); 985 setCurrentItem ( cn );
958 ensureItemVisible ( cn ); 986 ensureItemVisible ( cn );
959 } else 987 } else
960 QListView::keyPressEvent ( e ) ; 988 QListView::keyPressEvent ( e ) ;
961 e->accept(); 989 e->accept();
962 break; 990 break;
963 case Qt::Key_I: { 991 case Qt::Key_I: {
964 QListViewItem* cn; 992 QListViewItem* cn;
965 cn = currentItem(); 993 cn = currentItem();
966 if ( cn ) { 994 if ( cn ) {
967 KOListViewItem* ci = (KOListViewItem*)( cn ); 995 KOListViewItem* ci = (KOListViewItem*)( cn );
968 if ( ci ){ 996 if ( ci ){
969 emit showIncidence( ci->data()); 997 emit showIncidence( ci->data());
970 cn = cn->nextSibling(); 998 cn = cn->nextSibling();
971 if ( cn ) { 999 if ( cn ) {
972 setCurrentItem ( cn ); 1000 setCurrentItem ( cn );
973 ensureItemVisible ( cn ); 1001 ensureItemVisible ( cn );
974 } 1002 }
975 } 1003 }
976 } 1004 }
977 e->accept(); 1005 e->accept();
978 } 1006 }
979 break; 1007 break;
980 case Qt::Key_Return: 1008 case Qt::Key_Return:
981 case Qt::Key_Enter: 1009 case Qt::Key_Enter:
982 { 1010 {
983 QListViewItem* cn; 1011 QListViewItem* cn;
984 cn = currentItem(); 1012 cn = currentItem();
985 if ( cn ) { 1013 if ( cn ) {
986 KOListViewItem* ci = (KOListViewItem*)( cn ); 1014 KOListViewItem* ci = (KOListViewItem*)( cn );
987 if ( ci ){ 1015 if ( ci ){
988 if ( e->state() == ShiftButton ) 1016 if ( e->state() == ShiftButton )
989 ci->setSelected( false ); 1017 ci->setSelected( false );
990 else 1018 else
991 ci->setSelected( true ); 1019 ci->setSelected( true );
992 cn = cn->nextSibling(); 1020 cn = cn->nextSibling();
993 if ( cn ) { 1021 if ( cn ) {
994 setCurrentItem ( cn ); 1022 setCurrentItem ( cn );
995 ensureItemVisible ( cn ); 1023 ensureItemVisible ( cn );
996 } 1024 }
997 } 1025 }
998 } 1026 }
999 e->accept(); 1027 e->accept();
1000 } 1028 }
1001 break; 1029 break;
1002 default: 1030 default:
1003 e->ignore(); 1031 e->ignore();
1004 } 1032 }
1005} 1033}
1006KOListViewListView::KOListViewListView(KOListView * lv ) 1034KOListViewListView::KOListViewListView(KOListView * lv )
1007 : KListView( lv ) 1035 : KListView( lv )
1008{ 1036{
1009#ifndef DESKTOP_VERSION 1037#ifndef DESKTOP_VERSION
1010 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1038 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1011#endif 1039#endif
1012 mYMousePos = -1000; 1040 mYMousePos = -1000;
1013 setSelectionMode( QListView::Multi ); 1041 setSelectionMode( QListView::Multi );
1014 setMultiSelection( true); 1042 setMultiSelection( true);
1015 mAllowPopupMenu = true; 1043 mAllowPopupMenu = true;
1016 mMouseDown = false; 1044 mMouseDown = false;
1017 1045
1018} 1046}
1019void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1047void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1020{ 1048{
1021 if (!e) return; 1049 if (!e) return;
1022 QPoint vp = contentsToViewport(e->pos()); 1050 QPoint vp = contentsToViewport(e->pos());
1023 QListViewItem *item = itemAt(vp); 1051 QListViewItem *item = itemAt(vp);
1024 if (!item) { 1052 if (!item) {
1025 emit newEvent(); 1053 emit newEvent();
1026 return; 1054 return;
1027 } 1055 }
1028 KListView::contentsMouseDoubleClickEvent(e); 1056 KListView::contentsMouseDoubleClickEvent(e);
1029} 1057}
1030 1058
1031 1059
1032void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1060void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1033{ 1061{
1034 //qDebug("contentsMousePressEvent++++ "); 1062 //qDebug("contentsMousePressEvent++++ ");
1035 if (! mMouseDown ) { 1063 if (! mMouseDown ) {
1036 mAllowPopupMenu = true; 1064 mAllowPopupMenu = true;
1037 mYMousePos = mapToGlobal( (e->pos())).y(); 1065 mYMousePos = mapToGlobal( (e->pos())).y();
1038 } 1066 }
1039 if ( e->button() == RightButton && mMouseDown ) 1067 if ( e->button() == RightButton && mMouseDown )
1040 return; 1068 return;
1041 if ( e->button() == LeftButton ) 1069 if ( e->button() == LeftButton )
1042 mMouseDown = true; 1070 mMouseDown = true;
1043 KListView::contentsMousePressEvent( e ); 1071 KListView::contentsMousePressEvent( e );
1044} 1072}
1045void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1073void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1046{ 1074{
1047 //qDebug("contentsMouseReleaseEv---- "); 1075 //qDebug("contentsMouseReleaseEv---- ");
1048 if ( ! mMouseDown ) { 1076 if ( ! mMouseDown ) {
1049 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1077 if ( e->button() == RightButton && ! mAllowPopupMenu )
1050 return; 1078 return;
1051 QListViewItem* ci = currentItem(); 1079 QListViewItem* ci = currentItem();
1052 if ( ci ) 1080 if ( ci )
1053 ci->setSelected( true ); 1081 ci->setSelected( true );
1054 KListView::contentsMouseReleaseEvent(e); 1082 KListView::contentsMouseReleaseEvent(e);
1055 return; 1083 return;
1056 } 1084 }
1057 if ( e->button() == LeftButton ) 1085 if ( e->button() == LeftButton )
1058 mMouseDown = false; 1086 mMouseDown = false;
1059 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1087 if ( e->button() == RightButton && ! mAllowPopupMenu )
1060 return; 1088 return;
1061 if ( e->button() == RightButton ) { 1089 if ( e->button() == RightButton ) {
1062 QListViewItem* ci = currentItem(); 1090 QListViewItem* ci = currentItem();
1063 if ( ci ) 1091 if ( ci )
1064 ci->setSelected( true ); 1092 ci->setSelected( true );
1065 } 1093 }
1066 KListView::contentsMouseReleaseEvent(e); 1094 KListView::contentsMouseReleaseEvent(e);
1067} 1095}
1068void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1096void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1069{ 1097{
1070 // qDebug("contentsMouseMoveEv....... "); 1098 // qDebug("contentsMouseMoveEv....... ");
1071 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1099 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1072 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1100 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1073 if ( diff < 0 ) diff = -diff; 1101 if ( diff < 0 ) diff = -diff;
1074 if ( diff > 20 ) 1102 if ( diff > 20 )
1075 mAllowPopupMenu = false; 1103 mAllowPopupMenu = false;
1076 KListView::contentsMouseMoveEvent(e); 1104 KListView::contentsMouseMoveEvent(e);
1077} 1105}
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index 23afdb1..be9b09c 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,167 +1,168 @@
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
45typedef CustomListViewItem<Incidence *> KOListViewItem; 45typedef CustomListViewItem<Incidence *> KOListViewItem;
46 46
47/** 47/**
48 This class provides the initialisation of a KOListViewItem for calendar 48 This class provides the initialisation of a KOListViewItem for calendar
49 components using the Incidence::Visitor. 49 components using the Incidence::Visitor.
50*/ 50*/
51class ListItemVisitor : public Incidence::Visitor 51class ListItemVisitor : public Incidence::Visitor
52{ 52{
53 public: 53 public:
54 ListItemVisitor(KOListViewItem *, QDate d); 54 ListItemVisitor(KOListViewItem *, QDate d);
55 ~ListItemVisitor(); 55 ~ListItemVisitor();
56 56
57 bool visit(Event *); 57 bool visit(Event *);
58 bool visit(Todo *); 58 bool visit(Todo *);
59 bool visit(Journal *); 59 bool visit(Journal *);
60 60
61 private: 61 private:
62 KOListViewItem *mItem; 62 KOListViewItem *mItem;
63 QDate mDate; 63 QDate mDate;
64}; 64};
65 65
66/** 66/**
67 This class provides a multi-column list view of events. It can 67 This class provides a multi-column list view of events. It can
68 display events from one particular day or several days, it doesn't 68 display events from one particular day or several days, it doesn't
69 matter. To use a view that only handles one day at a time, use 69 matter. To use a view that only handles one day at a time, use
70 KODayListView. 70 KODayListView.
71 71
72 @short multi-column list view of various events. 72 @short multi-column list view of various events.
73 @author Preston Brown <pbrown@kde.org> 73 @author Preston Brown <pbrown@kde.org>
74 @see KOBaseView, KODayListView 74 @see KOBaseView, KODayListView
75*/ 75*/
76class KOListView; 76class KOListView;
77 77
78class KOListViewListView : public KListView 78class KOListViewListView : public KListView
79{ 79{
80 Q_OBJECT 80 Q_OBJECT
81 public: 81 public:
82 KOListViewListView(KOListView * lv ); 82 KOListViewListView(KOListView * lv );
83 signals: 83 signals:
84 void newEvent(); 84 void newEvent();
85 void showIncidence( Incidence* ); 85 void showIncidence( Incidence* );
86 private: 86 private:
87 void keyPressEvent ( QKeyEvent * ) ; 87 void keyPressEvent ( QKeyEvent * ) ;
88 void contentsMouseDoubleClickEvent(QMouseEvent *e); 88 void contentsMouseDoubleClickEvent(QMouseEvent *e);
89 void contentsMousePressEvent(QMouseEvent *e); 89 void contentsMousePressEvent(QMouseEvent *e);
90 void contentsMouseReleaseEvent(QMouseEvent *e); 90 void contentsMouseReleaseEvent(QMouseEvent *e);
91 void contentsMouseMoveEvent(QMouseEvent *e); 91 void contentsMouseMoveEvent(QMouseEvent *e);
92 bool mAllowPopupMenu; 92 bool mAllowPopupMenu;
93 bool mMouseDown; 93 bool mMouseDown;
94 int mYMousePos; 94 int mYMousePos;
95}; 95};
96 96
97class KOListView : public KOEventView 97class KOListView : public KOEventView
98{ 98{
99 Q_OBJECT 99 Q_OBJECT
100 public: 100 public:
101 KOListView(Calendar *calendar, QWidget *parent = 0, 101 KOListView(Calendar *calendar, QWidget *parent = 0,
102 const char *name = 0); 102 const char *name = 0);
103 ~KOListView(); 103 ~KOListView();
104 104
105 virtual int maxDatesHint(); 105 virtual int maxDatesHint();
106 virtual int currentDateCount(); 106 virtual int currentDateCount();
107 virtual QPtrList<Incidence> selectedIncidences(); 107 virtual QPtrList<Incidence> selectedIncidences();
108 virtual DateList selectedDates(); 108 virtual DateList selectedDates();
109 109
110 void showDates(bool show); 110 void showDates(bool show);
111 Incidence* currentItem(); 111 Incidence* currentItem();
112 void addTodos(QPtrList<Todo> eventList); 112 void addTodos(QPtrList<Todo> eventList);
113 void addJournals(QPtrList<Journal> eventList); 113 void addJournals(QPtrList<Journal> eventList);
114 virtual void printPreview(CalPrinter *calPrinter, 114 virtual void printPreview(CalPrinter *calPrinter,
115 const QDate &, const QDate &); 115 const QDate &, const QDate &);
116 116
117 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 117 void readSettings(KConfig *config, QString setting = "KOListView Layout");
118 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 118 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
119 void updateList(); 119 void updateList();
120 void setStartDate(const QDate &start); 120 void setStartDate(const QDate &start);
121 int count(); 121 int count();
122 QString getWhatsThisText(QPoint p);
122 signals: 123 signals:
123 void signalNewEvent(); 124 void signalNewEvent();
124 void beamIncidenceList(QPtrList<Incidence>); 125 void beamIncidenceList(QPtrList<Incidence>);
125 126
126 public slots: 127 public slots:
127 virtual void updateView(); 128 virtual void updateView();
128 virtual void showDates(const QDate &start, const QDate &end); 129 virtual void showDates(const QDate &start, const QDate &end);
129 virtual void showEvents(QPtrList<Event> eventList); 130 virtual void showEvents(QPtrList<Event> eventList);
130 void clearSelection(); 131 void clearSelection();
131 void allSelection(); 132 void allSelection();
132 133
133 void clear(); 134 void clear();
134 void beamDone( Ir *ir ); 135 void beamDone( Ir *ir );
135 void showDates(); 136 void showDates();
136 void hideDates(); 137 void hideDates();
137 void deleteAll(); 138 void deleteAll();
138 void saveToFile(); 139 void saveToFile();
139 void saveDescriptionToFile(); 140 void saveDescriptionToFile();
140 void beamSelected(); 141 void beamSelected();
141 void updateConfig(); 142 void updateConfig();
142 void addCat(); 143 void addCat();
143 void setCat(); 144 void setCat();
144 void setCategories( bool removeOld ); 145 void setCategories( bool removeOld );
145 void changeEventDisplay(Event *, int); 146 void changeEventDisplay(Event *, int);
146 147
147 void defaultItemAction(QListViewItem *item); 148 void defaultItemAction(QListViewItem *item);
148 void popupMenu(QListViewItem *item,const QPoint &,int); 149 void popupMenu(QListViewItem *item,const QPoint &,int);
149 150
150 protected slots: 151 protected slots:
151 void processSelectionChange(QListViewItem *); 152 void processSelectionChange(QListViewItem *);
152 153
153 protected: 154 protected:
154 void addEvents(QPtrList<Event> eventList); 155 void addEvents(QPtrList<Event> eventList);
155 void addIncidence(Incidence *); 156 void addIncidence(Incidence *);
156 KOListViewItem *getItemForEvent(Event *event); 157 KOListViewItem *getItemForEvent(Event *event);
157 158
158 private: 159 private:
159 KOListViewListView *mListView; 160 KOListViewListView *mListView;
160 KOEventPopupMenu *mPopupMenu; 161 KOEventPopupMenu *mPopupMenu;
161 KOListViewItem *mActiveItem; 162 KOListViewItem *mActiveItem;
162 QDict<Incidence> mUidDict; 163 QDict<Incidence> mUidDict;
163 QDate mStartDate; 164 QDate mStartDate;
164 void keyPressEvent ( QKeyEvent * ) ; 165 void keyPressEvent ( QKeyEvent * ) ;
165}; 166};
166 167
167#endif 168#endif
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index da8b4bc..c5b9a21 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1271 +1,1299 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h>
27 28
28#include <qvbox.h> 29#include <qvbox.h>
29#include <kdebug.h> 30#include <kdebug.h>
30#include "koprefs.h" 31#include "koprefs.h"
31#include <klocale.h> 32#include <klocale.h>
32#include <kglobal.h> 33#include <kglobal.h>
33#include <kiconloader.h> 34#include <kiconloader.h>
34#include <kmessagebox.h> 35#include <kmessagebox.h>
35 36
36#include <libkcal/icaldrag.h> 37#include <libkcal/icaldrag.h>
37#include <libkcal/vcaldrag.h> 38#include <libkcal/vcaldrag.h>
38#include <libkcal/calfilter.h> 39#include <libkcal/calfilter.h>
39#include <libkcal/dndfactory.h> 40#include <libkcal/dndfactory.h>
40#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
42#include <kresources/resourceselectdialog.h> 43#include <kresources/resourceselectdialog.h>
44#include <libkcal/kincidenceformatter.h>
43#ifndef DESKTOP_VERSION 45#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
45#else 47#else
46#include <qapplication.h> 48#include <qapplication.h>
47#endif 49#endif
48#ifndef KORG_NOPRINTER 50#ifndef KORG_NOPRINTER
49#include "calprinter.h" 51#include "calprinter.h"
50#endif 52#endif
51#include "docprefs.h" 53#include "docprefs.h"
52 54
53#include "kotodoview.h" 55#include "kotodoview.h"
54using namespace KOrg; 56using namespace KOrg;
55 57
58
59class KOTodoViewWhatsThis :public QWhatsThis
60{
61public:
62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
63
64protected:
65 virtual QString text( const QPoint& p)
66 {
67 return _view->getWhatsThisText(p) ;
68 }
69private:
70 QWidget* _wid;
71 KOTodoView * _view;
72};
73
56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
57 const char *name) : 75 const char *name) :
58 KListView(parent,name) 76 KListView(parent,name)
59{ 77{
60 mName = QString ( name ); 78 mName = QString ( name );
61 mCalendar = calendar; 79 mCalendar = calendar;
62#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
64#endif 82#endif
65 mOldCurrent = 0; 83 mOldCurrent = 0;
66 mMousePressed = false; 84 mMousePressed = false;
67 85
68 setAcceptDrops(true); 86 setAcceptDrops(true);
69 viewport()->setAcceptDrops(true); 87 viewport()->setAcceptDrops(true);
70 int size = 16; 88 int size = 16;
71 if (qApp->desktop()->width() < 300 ) 89 if (qApp->desktop()->width() < 300 )
72 size = 12; 90 size = 12;
73 setTreeStepSize( size + 6 ); 91 setTreeStepSize( size + 6 );
74 92
75} 93}
76 94
77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
78{ 96{
79#ifndef KORG_NODND 97#ifndef KORG_NODND
80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
82 !QTextDrag::canDecode( e ) ) { 100 !QTextDrag::canDecode( e ) ) {
83 e->ignore(); 101 e->ignore();
84 return; 102 return;
85 } 103 }
86 104
87 mOldCurrent = currentItem(); 105 mOldCurrent = currentItem();
88#endif 106#endif
89} 107}
90 108
91 109
92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
93{ 111{
94#ifndef KORG_NODND 112#ifndef KORG_NODND
95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
96 114
97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
98 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
99 e->ignore(); 117 e->ignore();
100 return; 118 return;
101 } 119 }
102 120
103 e->accept(); 121 e->accept();
104#endif 122#endif
105} 123}
106 124
107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
108{ 126{
109#ifndef KORG_NODND 127#ifndef KORG_NODND
110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
111 129
112 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
113 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
114#endif 132#endif
115} 133}
116 134
117void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
118{ 136{
119#ifndef KORG_NODND 137#ifndef KORG_NODND
120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
121 139
122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
123 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
124 e->ignore(); 142 e->ignore();
125 return; 143 return;
126 } 144 }
127 145
128 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
129 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
130 148
131 if (todo) { 149 if (todo) {
132 e->acceptAction(); 150 e->acceptAction();
133 151
134 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
136 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
137 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
138 156
139 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
140 158
141 if(existingTodo) { 159 if(existingTodo) {
142 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
143 while(to) { 161 while(to) {
144 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
145 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
146 i18n("Cannot move To-Do to itself\nor a child of itself"), 164 i18n("Cannot move To-Do to itself\nor a child of itself"),
147 i18n("Drop To-Do")); 165 i18n("Drop To-Do"));
148 delete todo; 166 delete todo;
149 return; 167 return;
150 } 168 }
151 to = to->relatedTo(); 169 to = to->relatedTo();
152 } 170 }
153 internalDrop = true; 171 internalDrop = true;
154 if ( destinationEvent ) 172 if ( destinationEvent )
155 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
156 else 174 else
157 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
158 delete todo; 176 delete todo;
159 } else { 177 } else {
160 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
161 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
162 if ( destinationEvent ) 180 if ( destinationEvent )
163 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
164 } 182 }
165 } 183 }
166 else { 184 else {
167 QString text; 185 QString text;
168 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
169 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
170 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
171 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
172 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
173 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
174 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
175 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
176 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
177 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
178 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
179 } 197 }
180 } 198 }
181 } 199 }
182 else { 200 else {
183 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
184 e->ignore(); 202 e->ignore();
185 } 203 }
186 } 204 }
187#endif 205#endif
188} 206}
189 207
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
191{ 209{
192#ifndef KORG_NODND 210#ifndef KORG_NODND
193 QPoint p(contentsToViewport(e->pos())); 211 QPoint p(contentsToViewport(e->pos()));
194 QListViewItem *i = itemAt(p); 212 QListViewItem *i = itemAt(p);
195 mMousePressed = false; 213 mMousePressed = false;
196 if (i) { 214 if (i) {
197 // if the user clicked into the root decoration of the item, don't 215 // if the user clicked into the root decoration of the item, don't
198 // try to start a drag! 216 // try to start a drag!
199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
201 itemMargin() || 219 itemMargin() ||
202 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 220 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
203 if (e->button()==Qt::LeftButton) { 221 if (e->button()==Qt::LeftButton) {
204 mPressPos = e->pos(); 222 mPressPos = e->pos();
205 mMousePressed = true; 223 mMousePressed = true;
206 } 224 }
207 } 225 }
208 } 226 }
209#endif 227#endif
210 QListView::contentsMousePressEvent(e); 228 QListView::contentsMousePressEvent(e);
211} 229}
212void KOTodoListView::paintEvent(QPaintEvent* e) 230void KOTodoListView::paintEvent(QPaintEvent* e)
213{ 231{
214 emit paintNeeded(); 232 emit paintNeeded();
215 QListView::paintEvent( e); 233 QListView::paintEvent( e);
216} 234}
217void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
218{ 236{
219 237
220#ifndef KORG_NODND 238#ifndef KORG_NODND
221 //QListView::contentsMouseMoveEvent(e); 239 //QListView::contentsMouseMoveEvent(e);
222 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
223 QApplication::startDragDistance()*3) { 241 QApplication::startDragDistance()*3) {
224 mMousePressed = false; 242 mMousePressed = false;
225 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 243 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
226 if (item) { 244 if (item) {
227 DndFactory factory( mCalendar ); 245 DndFactory factory( mCalendar );
228 ICalDrag *vd = factory.createDrag( 246 ICalDrag *vd = factory.createDrag(
229 ((KOTodoViewItem *)item)->todo(),viewport()); 247 ((KOTodoViewItem *)item)->todo(),viewport());
230 internalDrop = false; 248 internalDrop = false;
231 // we cannot do any senseful here, because the DnD is still broken in Qt 249 // we cannot do any senseful here, because the DnD is still broken in Qt
232 if (vd->drag()) { 250 if (vd->drag()) {
233 if ( !internalDrop ) { 251 if ( !internalDrop ) {
234 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
235 qDebug("Dnd: External move: Delete drag source "); 253 qDebug("Dnd: External move: Delete drag source ");
236 } else 254 } else
237 qDebug("Dnd: Internal move "); 255 qDebug("Dnd: Internal move ");
238 256
239 } else { 257 } else {
240 if ( !internalDrop ) { 258 if ( !internalDrop ) {
241 qDebug("Dnd: External Copy"); 259 qDebug("Dnd: External Copy");
242 } else 260 } else
243 qDebug("DnD: Internal copy: Copy pending"); 261 qDebug("DnD: Internal copy: Copy pending");
244 } 262 }
245 } 263 }
246 } 264 }
247#endif 265#endif
248} 266}
249void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 267void KOTodoListView::keyPressEvent ( QKeyEvent * e )
250{ 268{
251 269
252 QListViewItem* cn; 270 QListViewItem* cn;
253 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 271 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
254 cn = currentItem(); 272 cn = currentItem();
255 if ( cn ) { 273 if ( cn ) {
256 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 274 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
257 if ( ci ){ 275 if ( ci ){
258 if ( e->state() == ShiftButton ) 276 if ( e->state() == ShiftButton )
259 ci->setOn( false ); 277 ci->setOn( false );
260 else 278 else
261 ci->setOn( true ); 279 ci->setOn( true );
262 cn = cn->itemBelow(); 280 cn = cn->itemBelow();
263 if ( cn ) { 281 if ( cn ) {
264 setCurrentItem ( cn ); 282 setCurrentItem ( cn );
265 ensureItemVisible ( cn ); 283 ensureItemVisible ( cn );
266 } 284 }
267 285
268 } 286 }
269 } 287 }
270 288
271 return; 289 return;
272 } 290 }
273 291
274 // qDebug("KOTodoListView::keyPressEvent "); 292 // qDebug("KOTodoListView::keyPressEvent ");
275 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 293 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
276 switch ( e->key() ) { 294 switch ( e->key() ) {
277 case Qt::Key_Down: 295 case Qt::Key_Down:
278 case Qt::Key_Up: 296 case Qt::Key_Up:
279 QListView::keyPressEvent ( e ); 297 QListView::keyPressEvent ( e );
280 break; 298 break;
281 case Qt::Key_Left: 299 case Qt::Key_Left:
282 case Qt::Key_Right: 300 case Qt::Key_Right:
283 QListView::keyPressEvent ( e ); 301 QListView::keyPressEvent ( e );
284 e->accept(); 302 e->accept();
285 return; 303 return;
286 break; 304 break;
287 default: 305 default:
288 e->ignore(); 306 e->ignore();
289 break; 307 break;
290 } 308 }
291 return; 309 return;
292 } 310 }
293 e->ignore(); 311 e->ignore();
294} 312}
295void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 313void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
296{ 314{
297 QListView::contentsMouseReleaseEvent(e); 315 QListView::contentsMouseReleaseEvent(e);
298 mMousePressed = false; 316 mMousePressed = false;
299} 317}
300 318
301void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 319void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
302{ 320{
303 if (!e) return; 321 if (!e) return;
304 322
305 QPoint vp = contentsToViewport(e->pos()); 323 QPoint vp = contentsToViewport(e->pos());
306 324
307 QListViewItem *item = itemAt(vp); 325 QListViewItem *item = itemAt(vp);
308 326
309 emit double_Clicked(item); 327 emit double_Clicked(item);
310 if (!item) return; 328 if (!item) return;
311 329
312 emit doubleClicked(item,vp,0); 330 emit doubleClicked(item,vp,0);
313} 331}
314 332
315///////////////////////////////////////////////////////////////////////////// 333/////////////////////////////////////////////////////////////////////////////
316 334
317KOQuickTodo::KOQuickTodo(QWidget *parent) : 335KOQuickTodo::KOQuickTodo(QWidget *parent) :
318 QLineEdit(parent) 336 QLineEdit(parent)
319{ 337{
320 setText(i18n("Click to add a new Todo")); 338 setText(i18n("Click to add a new Todo"));
321} 339}
322 340
323void KOQuickTodo::focusInEvent(QFocusEvent *ev) 341void KOQuickTodo::focusInEvent(QFocusEvent *ev)
324{ 342{
325 if ( text()==i18n("Click to add a new Todo") ) 343 if ( text()==i18n("Click to add a new Todo") )
326 setText(""); 344 setText("");
327 QLineEdit::focusInEvent(ev); 345 QLineEdit::focusInEvent(ev);
328} 346}
329 347
330void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 348void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
331{ 349{
332 setText(i18n("Click to add a new Todo")); 350 setText(i18n("Click to add a new Todo"));
333 QLineEdit::focusOutEvent(ev); 351 QLineEdit::focusOutEvent(ev);
334} 352}
335 353
336///////////////////////////////////////////////////////////////////////////// 354/////////////////////////////////////////////////////////////////////////////
337 355
338KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 356KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
339 KOrg::BaseView(calendar,parent,name) 357 KOrg::BaseView(calendar,parent,name)
340{ 358{
341 mPendingUpdateBeforeRepaint = false; 359 mPendingUpdateBeforeRepaint = false;
342 isFlatDisplay = false; 360 isFlatDisplay = false;
343 mNavigator = 0; 361 mNavigator = 0;
344 QBoxLayout *topLayout = new QVBoxLayout(this); 362 QBoxLayout *topLayout = new QVBoxLayout(this);
345 mName = QString ( name ); 363 mName = QString ( name );
346 mBlockUpdate = false; 364 mBlockUpdate = false;
347 mQuickAdd = new KOQuickTodo(this); 365 mQuickAdd = new KOQuickTodo(this);
348 topLayout->addWidget(mQuickAdd); 366 topLayout->addWidget(mQuickAdd);
349 367
350 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 368 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
351 369
352 mTodoListView = new KOTodoListView(calendar,this, name ); 370 mTodoListView = new KOTodoListView(calendar,this, name );
353 topLayout->addWidget(mTodoListView); 371 topLayout->addWidget(mTodoListView);
354 //mTodoListView->header()->setMaximumHeight(30); 372 //mTodoListView->header()->setMaximumHeight(30);
355 mTodoListView->setRootIsDecorated(true); 373 mTodoListView->setRootIsDecorated(true);
356 mTodoListView->setAllColumnsShowFocus(true); 374 mTodoListView->setAllColumnsShowFocus(true);
357 375
358 mTodoListView->setShowSortIndicator(true); 376 mTodoListView->setShowSortIndicator(true);
359 377
360 mTodoListView->addColumn(i18n("Todo")); 378 mTodoListView->addColumn(i18n("Todo"));
361 mTodoListView->addColumn(i18n("Prio")); 379 mTodoListView->addColumn(i18n("Prio"));
362 mTodoListView->setColumnAlignment(1,AlignHCenter); 380 mTodoListView->setColumnAlignment(1,AlignHCenter);
363 mTodoListView->addColumn(i18n("Complete")); 381 mTodoListView->addColumn(i18n("Complete"));
364 mTodoListView->setColumnAlignment(2,AlignCenter); 382 mTodoListView->setColumnAlignment(2,AlignCenter);
365 383
366 mTodoListView->addColumn(i18n("Due Date")); 384 mTodoListView->addColumn(i18n("Due Date"));
367 mTodoListView->setColumnAlignment(3,AlignLeft); 385 mTodoListView->setColumnAlignment(3,AlignLeft);
368 mTodoListView->addColumn(i18n("Due Time")); 386 mTodoListView->addColumn(i18n("Due Time"));
369 mTodoListView->setColumnAlignment(4,AlignHCenter); 387 mTodoListView->setColumnAlignment(4,AlignHCenter);
370 388
371 mTodoListView->addColumn(i18n("Start Date")); 389 mTodoListView->addColumn(i18n("Start Date"));
372 mTodoListView->setColumnAlignment(5,AlignLeft); 390 mTodoListView->setColumnAlignment(5,AlignLeft);
373 mTodoListView->addColumn(i18n("Start Time")); 391 mTodoListView->addColumn(i18n("Start Time"));
374 mTodoListView->setColumnAlignment(6,AlignHCenter); 392 mTodoListView->setColumnAlignment(6,AlignHCenter);
375 393
376 mTodoListView->addColumn(i18n("Cancelled")); 394 mTodoListView->addColumn(i18n("Cancelled"));
377 mTodoListView->addColumn(i18n("Categories")); 395 mTodoListView->addColumn(i18n("Categories"));
378#if 0 396#if 0
379 mTodoListView->addColumn(i18n("Sort Id")); 397 mTodoListView->addColumn(i18n("Sort Id"));
380 mTodoListView->setColumnAlignment(4,AlignHCenter); 398 mTodoListView->setColumnAlignment(4,AlignHCenter);
381#endif 399#endif
382 400
383 mTodoListView->setMinimumHeight( 60 ); 401 mTodoListView->setMinimumHeight( 60 );
384 mTodoListView->setItemsRenameable( true ); 402 mTodoListView->setItemsRenameable( true );
385 mTodoListView->setRenameable( 0 ); 403 mTodoListView->setRenameable( 0 );
386 mTodoListView->setColumnWidth( 0, 120 ); 404 mTodoListView->setColumnWidth( 0, 120 );
387 mTodoListView->setColumnWidthMode(0, QListView::Manual); 405 mTodoListView->setColumnWidthMode(0, QListView::Manual);
388 mTodoListView->setColumnWidthMode(1, QListView::Manual); 406 mTodoListView->setColumnWidthMode(1, QListView::Manual);
389 mTodoListView->setColumnWidthMode(2, QListView::Manual); 407 mTodoListView->setColumnWidthMode(2, QListView::Manual);
390 mTodoListView->setColumnWidthMode(3, QListView::Manual); 408 mTodoListView->setColumnWidthMode(3, QListView::Manual);
391 mTodoListView->setColumnWidthMode(4, QListView::Manual); 409 mTodoListView->setColumnWidthMode(4, QListView::Manual);
392 mTodoListView->setColumnWidthMode(5, QListView::Manual); 410 mTodoListView->setColumnWidthMode(5, QListView::Manual);
393 mTodoListView->setColumnWidthMode(6, QListView::Manual); 411 mTodoListView->setColumnWidthMode(6, QListView::Manual);
394 mTodoListView->setColumnWidthMode(7, QListView::Manual); 412 mTodoListView->setColumnWidthMode(7, QListView::Manual);
395 mTodoListView->setColumnWidthMode(8, QListView::Manual); 413 mTodoListView->setColumnWidthMode(8, QListView::Manual);
396 414
397 415
416 new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
417
398 mPriorityPopupMenu = new QPopupMenu(this); 418 mPriorityPopupMenu = new QPopupMenu(this);
399 for (int i = 1; i <= 5; i++) { 419 for (int i = 1; i <= 5; i++) {
400 QString label = QString ("%1").arg (i); 420 QString label = QString ("%1").arg (i);
401 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 421 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
402 } 422 }
403 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 423 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
404 424
405 mPercentageCompletedPopupMenu = new QPopupMenu(this); 425 mPercentageCompletedPopupMenu = new QPopupMenu(this);
406 for (int i = 0; i <= 100; i+=20) { 426 for (int i = 0; i <= 100; i+=20) {
407 QString label = QString ("%1 %").arg (i); 427 QString label = QString ("%1 %").arg (i);
408 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 428 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
409 } 429 }
410 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 430 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
411 431
412 432
413 433
414 mItemPopupMenu = new QPopupMenu(this); 434 mItemPopupMenu = new QPopupMenu(this);
415 mItemPopupMenu->insertItem(i18n("Show..."), this, 435 mItemPopupMenu->insertItem(i18n("Show..."), this,
416 SLOT (showTodo())); 436 SLOT (showTodo()));
417 mItemPopupMenu->insertItem(i18n("Edit..."), this, 437 mItemPopupMenu->insertItem(i18n("Edit..."), this,
418 SLOT (editTodo())); 438 SLOT (editTodo()));
419 mItemPopupMenu->insertItem( i18n("Delete"), this, 439 mItemPopupMenu->insertItem( i18n("Delete"), this,
420 SLOT (deleteTodo())); 440 SLOT (deleteTodo()));
421 mItemPopupMenu->insertItem( i18n("Clone..."), this, 441 mItemPopupMenu->insertItem( i18n("Clone..."), this,
422 SLOT (cloneTodo())); 442 SLOT (cloneTodo()));
423 mItemPopupMenu->insertItem( i18n("Move..."), this, 443 mItemPopupMenu->insertItem( i18n("Move..."), this,
424 SLOT (moveTodo())); 444 SLOT (moveTodo()));
425 mItemPopupMenu->insertItem( i18n("Beam..."), this, 445 mItemPopupMenu->insertItem( i18n("Beam..."), this,
426 SLOT (beamTodo())); 446 SLOT (beamTodo()));
427 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 447 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
428 SLOT (cancelTodo())); 448 SLOT (cancelTodo()));
429 mItemPopupMenu->insertSeparator(); 449 mItemPopupMenu->insertSeparator();
430 450
431 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 451 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
432 SLOT (newTodo())); 452 SLOT (newTodo()));
433 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 453 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
434 SLOT (newSubTodo())); 454 SLOT (newSubTodo()));
435 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 455 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
436 SLOT (unparentTodo()),0,21); 456 SLOT (unparentTodo()),0,21);
437 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 457 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
438 SLOT (reparentTodo()),0,22); 458 SLOT (reparentTodo()),0,22);
439 mItemPopupMenu->insertSeparator(); 459 mItemPopupMenu->insertSeparator();
440#if 0 460#if 0
441 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 461 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
442 this, SLOT( purgeCompleted() ) ); 462 this, SLOT( purgeCompleted() ) );
443 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 463 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
444 this, SLOT( toggleCompleted() ),0, 33 ); 464 this, SLOT( toggleCompleted() ),0, 33 );
445 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 465 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
446 this, SLOT( toggleQuickTodo() ),0, 34 ); 466 this, SLOT( toggleQuickTodo() ),0, 34 );
447 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 467 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
448 this, SLOT( toggleRunning() ),0, 35 ); 468 this, SLOT( toggleRunning() ),0, 35 );
449 469
450#endif 470#endif
451 mPopupMenu = new QPopupMenu(this); 471 mPopupMenu = new QPopupMenu(this);
452 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 472 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
453 SLOT (newTodo()),0,1); 473 SLOT (newTodo()),0,1);
454 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 474 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
455 this, SLOT(purgeCompleted()),0,2); 475 this, SLOT(purgeCompleted()),0,2);
456 mPopupMenu->insertItem(i18n("Show Completed"), 476 mPopupMenu->insertItem(i18n("Show Completed"),
457 this, SLOT( toggleCompleted() ),0,3 ); 477 this, SLOT( toggleCompleted() ),0,3 );
458 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 478 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
459 this, SLOT( toggleQuickTodo() ),0,4 ); 479 this, SLOT( toggleQuickTodo() ),0,4 );
460 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 480 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
461 this, SLOT( toggleRunning() ),0,5 ); 481 this, SLOT( toggleRunning() ),0,5 );
462 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 482 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
463 this, SLOT( setAllOpen() ),0,6 ); 483 this, SLOT( setAllOpen() ),0,6 );
464 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 484 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
465 this, SLOT( setAllClose() ),0,7 ); 485 this, SLOT( setAllClose() ),0,7 );
466 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 486 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
467 this, SLOT( setAllFlat() ),0,8 ); 487 this, SLOT( setAllFlat() ),0,8 );
468 mDocPrefs = new DocPrefs( name ); 488 mDocPrefs = new DocPrefs( name );
469 489
470 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 490 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
471 mPopupMenu->setCheckable( true ); 491 mPopupMenu->setCheckable( true );
472 mItemPopupMenu->setCheckable( true ); 492 mItemPopupMenu->setCheckable( true );
473 493
474 494
475 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 495 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
476 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 496 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
477 497
478 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 498 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
479 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 499 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
480 500
481 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 501 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
482 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 502 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
483 503
484 504
485 // Double clicking conflicts with opening/closing the subtree 505 // Double clicking conflicts with opening/closing the subtree
486 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 506 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
487 SLOT( editItem( QListViewItem *) ) ); 507 SLOT( editItem( QListViewItem *) ) );
488 /* 508 /*
489 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 509 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
490 const QPoint &,int ) ), 510 const QPoint &,int ) ),
491 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 511 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
492 */ 512 */
493 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 513 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
494 const QPoint &,int ) ), 514 const QPoint &,int ) ),
495 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 515 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
496 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 516 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
497 SLOT( itemClicked( QListViewItem * ) ) ); 517 SLOT( itemClicked( QListViewItem * ) ) );
498 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 518 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
499 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 519 SLOT( itemDoubleClicked( QListViewItem * ) ) );
500 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 520 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
501 SLOT( updateView() ) ); 521 SLOT( updateView() ) );
502 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 522 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
503 SLOT( todoModified(Todo *, int) ) ); 523 SLOT( todoModified(Todo *, int) ) );
504 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 524 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
505 SLOT( itemStateChanged( QListViewItem * ) ) ); 525 SLOT( itemStateChanged( QListViewItem * ) ) );
506 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 526 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
507 SLOT( itemStateChanged( QListViewItem * ) ) ); 527 SLOT( itemStateChanged( QListViewItem * ) ) );
508 connect( mTodoListView, SIGNAL( paintNeeded() ), 528 connect( mTodoListView, SIGNAL( paintNeeded() ),
509 SLOT( paintNeeded()) ); 529 SLOT( paintNeeded()) );
510 530
511#if 0 531#if 0
512 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 532 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
513 SLOT(selectionChanged(QListViewItem *))); 533 SLOT(selectionChanged(QListViewItem *)));
514 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 534 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
515 SLOT(selectionChanged(QListViewItem *))); 535 SLOT(selectionChanged(QListViewItem *)));
516 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 536 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
517 SLOT(selectionChanged(QListViewItem *))); 537 SLOT(selectionChanged(QListViewItem *)));
518#endif 538#endif
519 539
520 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 540 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
521 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 541 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
522 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 542 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
523 543
524 connect( mTodoListView, SIGNAL(selectionChanged() ), 544 connect( mTodoListView, SIGNAL(selectionChanged() ),
525 SLOT( processSelectionChange() ) ); 545 SLOT( processSelectionChange() ) );
526 connect( mQuickAdd, SIGNAL( returnPressed () ), 546 connect( mQuickAdd, SIGNAL( returnPressed () ),
527 SLOT( addQuickTodo() ) ); 547 SLOT( addQuickTodo() ) );
528 548
529} 549}
530 550
531KOTodoView::~KOTodoView() 551KOTodoView::~KOTodoView()
532{ 552{
533 delete mDocPrefs; 553 delete mDocPrefs;
534} 554}
555QString KOTodoView::getWhatsThisText(QPoint p)
556{
557 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
558 if ( item )
559 return KIncidenceFormatter::instance()->getFormattedText( item->todo() );
560 return i18n("That is the todo view" );
561
562}
535 563
536void KOTodoView::jumpToDate () 564void KOTodoView::jumpToDate ()
537{ 565{
538 // if (mActiveItem) { 566 // if (mActiveItem) {
539// mActiveItem->todo()); 567// mActiveItem->todo());
540// if ( mActiveItem->todo()->hasDueDate() ) 568// if ( mActiveItem->todo()->hasDueDate() )
541// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 569// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
542} 570}
543void KOTodoView::paintNeeded() 571void KOTodoView::paintNeeded()
544{ 572{
545 if ( mPendingUpdateBeforeRepaint ) { 573 if ( mPendingUpdateBeforeRepaint ) {
546 updateView(); 574 updateView();
547 mPendingUpdateBeforeRepaint = false; 575 mPendingUpdateBeforeRepaint = false;
548 } 576 }
549} 577}
550void KOTodoView::paintEvent(QPaintEvent * pevent) 578void KOTodoView::paintEvent(QPaintEvent * pevent)
551{ 579{
552 if ( mPendingUpdateBeforeRepaint ) { 580 if ( mPendingUpdateBeforeRepaint ) {
553 updateView(); 581 updateView();
554 mPendingUpdateBeforeRepaint = false; 582 mPendingUpdateBeforeRepaint = false;
555 } 583 }
556 KOrg::BaseView::paintEvent( pevent); 584 KOrg::BaseView::paintEvent( pevent);
557} 585}
558 586
559void KOTodoView::updateView() 587void KOTodoView::updateView()
560{ 588{
561 pendingSubtodo = 0; 589 pendingSubtodo = 0;
562 if ( mBlockUpdate ) { 590 if ( mBlockUpdate ) {
563 return; 591 return;
564 } 592 }
565 if ( !isVisible() ) { 593 if ( !isVisible() ) {
566 mPendingUpdateBeforeRepaint = true; 594 mPendingUpdateBeforeRepaint = true;
567 return; 595 return;
568 } 596 }
569 //qDebug("KOTodoView::updateView() %x", this); 597 //qDebug("KOTodoView::updateView() %x", this);
570 if ( isFlatDisplay ) { 598 if ( isFlatDisplay ) {
571 setAllFlat(); 599 setAllFlat();
572 return; 600 return;
573 } 601 }
574 //qDebug("update "); 602 //qDebug("update ");
575// kdDebug() << "KOTodoView::updateView()" << endl; 603// kdDebug() << "KOTodoView::updateView()" << endl;
576 QFont fo = KOPrefs::instance()->mTodoViewFont; 604 QFont fo = KOPrefs::instance()->mTodoViewFont;
577 mTodoListView->clear(); 605 mTodoListView->clear();
578 if ( mName == "todolistsmall" ) { 606 if ( mName == "todolistsmall" ) {
579 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 607 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
580 int ps = fo.pointSize() -2; 608 int ps = fo.pointSize() -2;
581 if ( ps > 12 ) 609 if ( ps > 12 )
582 ps -= 2; 610 ps -= 2;
583 fo.setPointSize( ps ); 611 fo.setPointSize( ps );
584 } 612 }
585 } 613 }
586 614
587 mTodoListView->setFont( fo ); 615 mTodoListView->setFont( fo );
588 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 616 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
589 //mTodoListView->header()->setMaximumHeight(fm.height()); 617 //mTodoListView->header()->setMaximumHeight(fm.height());
590 QPtrList<Todo> todoList = calendar()->todos(); 618 QPtrList<Todo> todoList = calendar()->todos();
591 619
592/* 620/*
593 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 621 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
594 Event *t; 622 Event *t;
595 for(t = todoList.first(); t; t = todoList.next()) { 623 for(t = todoList.first(); t; t = todoList.next()) {
596 kdDebug() << " " << t->getSummary() << endl; 624 kdDebug() << " " << t->getSummary() << endl;
597 625
598 if (t->getRelatedTo()) { 626 if (t->getRelatedTo()) {
599 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 627 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
600 } 628 }
601 629
602 QPtrList<Event> l = t->getRelations(); 630 QPtrList<Event> l = t->getRelations();
603 Event *c; 631 Event *c;
604 for(c=l.first();c;c=l.next()) { 632 for(c=l.first();c;c=l.next()) {
605 kdDebug() << " - relation: " << c->getSummary() << endl; 633 kdDebug() << " - relation: " << c->getSummary() << endl;
606 } 634 }
607 } 635 }
608*/ 636*/
609 637
610 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 638 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
611 // specific order of events. That means that we have to generate parent items 639 // specific order of events. That means that we have to generate parent items
612 // recursively for proper hierarchical display of Todos. 640 // recursively for proper hierarchical display of Todos.
613 mTodoMap.clear(); 641 mTodoMap.clear();
614 Todo *todo; 642 Todo *todo;
615 todo = todoList.first();// todo; todo = todoList.next()) { 643 todo = todoList.first();// todo; todo = todoList.next()) {
616 while ( todo ) { 644 while ( todo ) {
617 bool next = true; 645 bool next = true;
618 // qDebug("todo %s ", todo->summary().latin1()); 646 // qDebug("todo %s ", todo->summary().latin1());
619 Incidence *incidence = todo->relatedTo(); 647 Incidence *incidence = todo->relatedTo();
620 while ( incidence ) { 648 while ( incidence ) {
621 if ( incidence->type() == "Todo") { 649 if ( incidence->type() == "Todo") {
622 //qDebug("related %s ",incidence->summary().latin1() ); 650 //qDebug("related %s ",incidence->summary().latin1() );
623 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 651 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
624 //qDebug("related not found "); 652 //qDebug("related not found ");
625 todoList.remove( ); 653 todoList.remove( );
626 todo = todoList.current(); 654 todo = todoList.current();
627 next = false; 655 next = false;
628 incidence = 0; 656 incidence = 0;
629 657
630 } else { 658 } else {
631 //qDebug("related found "); 659 //qDebug("related found ");
632 incidence = incidence->relatedTo(); 660 incidence = incidence->relatedTo();
633 } 661 }
634 } else 662 } else
635 incidence = 0; 663 incidence = 0;
636 } 664 }
637 if ( next ) 665 if ( next )
638 todo = todoList.next(); 666 todo = todoList.next();
639 } 667 }
640// qDebug("again .... "); 668// qDebug("again .... ");
641// for(todo = todoList.first(); todo; todo = todoList.next()) { 669// for(todo = todoList.first(); todo; todo = todoList.next()) {
642 670
643// qDebug("yytodo %s ", todo->summary().latin1()); 671// qDebug("yytodo %s ", todo->summary().latin1());
644// } 672// }
645 //qDebug("for "); 673 //qDebug("for ");
646 for(todo = todoList.first(); todo; todo = todoList.next()) { 674 for(todo = todoList.first(); todo; todo = todoList.next()) {
647 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 675 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
648 { 676 {
649 insertTodoItem(todo); 677 insertTodoItem(todo);
650 } 678 }
651 } 679 }
652 //qDebug("for end "); 680 //qDebug("for end ");
653 // Restore opened/closed state 681 // Restore opened/closed state
654 mTodoListView->blockSignals( true ); 682 mTodoListView->blockSignals( true );
655 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 683 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
656 mTodoListView->blockSignals( false ); 684 mTodoListView->blockSignals( false );
657 mTodoListView->setFocus(); 685 mTodoListView->setFocus();
658 processSelectionChange(); 686 processSelectionChange();
659} 687}
660 688
661bool KOTodoView::checkTodo( Todo * todo ) 689bool KOTodoView::checkTodo( Todo * todo )
662{ 690{
663 691
664 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 692 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
665 return false; 693 return false;
666 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 694 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
667 if ( todo->hasStartDate() ) 695 if ( todo->hasStartDate() )
668 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 696 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
669 return false; 697 return false;
670 if ( todo->hasDueDate() ) 698 if ( todo->hasDueDate() )
671 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 699 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
672 return false; 700 return false;
673 } 701 }
674 return true; 702 return true;
675} 703}
676 704
677void KOTodoView::restoreItemState( QListViewItem *item ) 705void KOTodoView::restoreItemState( QListViewItem *item )
678{ 706{
679 pendingSubtodo = 0; 707 pendingSubtodo = 0;
680 while( item ) { 708 while( item ) {
681 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 709 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
682 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 710 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
683 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 711 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
684 item = item->nextSibling(); 712 item = item->nextSibling();
685 } 713 }
686} 714}
687 715
688 716
689QMap<Todo *,KOTodoViewItem *>::ConstIterator 717QMap<Todo *,KOTodoViewItem *>::ConstIterator
690 KOTodoView::insertTodoItem(Todo *todo) 718 KOTodoView::insertTodoItem(Todo *todo)
691{ 719{
692 720
693// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 721// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
694 // TODO: Check, if dynmaic cast is necessary 722 // TODO: Check, if dynmaic cast is necessary
695 723
696 pendingSubtodo = 0; 724 pendingSubtodo = 0;
697 Incidence *incidence = todo->relatedTo(); 725 Incidence *incidence = todo->relatedTo();
698 if (incidence && incidence->type() == "Todo") { 726 if (incidence && incidence->type() == "Todo") {
699 Todo *relatedTodo = static_cast<Todo *>(incidence); 727 Todo *relatedTodo = static_cast<Todo *>(incidence);
700 728
701// kdDebug() << " has Related" << endl; 729// kdDebug() << " has Related" << endl;
702 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 730 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
703 itemIterator = mTodoMap.find(relatedTodo); 731 itemIterator = mTodoMap.find(relatedTodo);
704 if (itemIterator == mTodoMap.end()) { 732 if (itemIterator == mTodoMap.end()) {
705// kdDebug() << " related not yet in list" << endl; 733// kdDebug() << " related not yet in list" << endl;
706 itemIterator = insertTodoItem (relatedTodo); 734 itemIterator = insertTodoItem (relatedTodo);
707 } 735 }
708 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 736 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
709 // and one into the map. Sure finding is more easy but why? -zecke 737 // and one into the map. Sure finding is more easy but why? -zecke
710 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 738 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
711 return mTodoMap.insert(todo,todoItem); 739 return mTodoMap.insert(todo,todoItem);
712 } else { 740 } else {
713// kdDebug() << " no Related" << endl; 741// kdDebug() << " no Related" << endl;
714 // see above -zecke 742 // see above -zecke
715 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 743 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
716 return mTodoMap.insert(todo,todoItem); 744 return mTodoMap.insert(todo,todoItem);
717 } 745 }
718} 746}
719 747
720 748
721void KOTodoView::updateConfig() 749void KOTodoView::updateConfig()
722{ 750{
723 updateView(); 751 updateView();
724 mTodoListView->repaintContents(); 752 mTodoListView->repaintContents();
725} 753}
726 754
727QPtrList<Incidence> KOTodoView::selectedIncidences() 755QPtrList<Incidence> KOTodoView::selectedIncidences()
728{ 756{
729 QPtrList<Incidence> selected; 757 QPtrList<Incidence> selected;
730 758
731 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 759 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
732// if (!item) item = mActiveItem; 760// if (!item) item = mActiveItem;
733 if (item) selected.append(item->todo()); 761 if (item) selected.append(item->todo());
734 762
735 return selected; 763 return selected;
736} 764}
737 765
738QPtrList<Todo> KOTodoView::selectedTodos() 766QPtrList<Todo> KOTodoView::selectedTodos()
739{ 767{
740 QPtrList<Todo> selected; 768 QPtrList<Todo> selected;
741 769
742 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 770 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
743// if (!item) item = mActiveItem; 771// if (!item) item = mActiveItem;
744 if (item) selected.append(item->todo()); 772 if (item) selected.append(item->todo());
745 773
746 return selected; 774 return selected;
747} 775}
748 776
749void KOTodoView::changeEventDisplay(Event *, int) 777void KOTodoView::changeEventDisplay(Event *, int)
750{ 778{
751 updateView(); 779 updateView();
752} 780}
753 781
754void KOTodoView::showDates(const QDate &, const QDate &) 782void KOTodoView::showDates(const QDate &, const QDate &)
755{ 783{
756} 784}
757 785
758void KOTodoView::showEvents(QPtrList<Event>) 786void KOTodoView::showEvents(QPtrList<Event>)
759{ 787{
760 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 788 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
761} 789}
762 790
763void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 791void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
764 const QDate &td) 792 const QDate &td)
765{ 793{
766#ifndef KORG_NOPRINTER 794#ifndef KORG_NOPRINTER
767 calPrinter->preview(CalPrinter::Todolist, fd, td); 795 calPrinter->preview(CalPrinter::Todolist, fd, td);
768#endif 796#endif
769} 797}
770 798
771void KOTodoView::editItem(QListViewItem *item ) 799void KOTodoView::editItem(QListViewItem *item )
772{ 800{
773 // qDebug("editItem(QListViewItem *item ) "); 801 // qDebug("editItem(QListViewItem *item ) ");
774 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 802 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
775} 803}
776 804
777void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 805void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
778{ 806{
779 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 807 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
780} 808}
781 809
782void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 810void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
783{ 811{
784 pendingSubtodo = 0; 812 pendingSubtodo = 0;
785 mActiveItem = (KOTodoViewItem *)item; 813 mActiveItem = (KOTodoViewItem *)item;
786 if (item) { 814 if (item) {
787 switch (column){ 815 switch (column){
788 case 1: 816 case 1:
789 mPriorityPopupMenu->popup(QCursor::pos ()); break; 817 mPriorityPopupMenu->popup(QCursor::pos ()); break;
790 case 2: 818 case 2:
791 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 819 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
792 case 3: 820 case 3:
793 moveTodo(); 821 moveTodo();
794 break; 822 break;
795 case 8: 823 case 8:
796 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 824 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
797 default: 825 default:
798 mItemPopupMenu->popup(QCursor::pos()); 826 mItemPopupMenu->popup(QCursor::pos());
799 } 827 }
800 } else mPopupMenu->popup(QCursor::pos()); 828 } else mPopupMenu->popup(QCursor::pos());
801} 829}
802void KOTodoView::newTodo() 830void KOTodoView::newTodo()
803{ 831{
804 emit newTodoSignal(); 832 emit newTodoSignal();
805} 833}
806 834
807void KOTodoView::newSubTodo() 835void KOTodoView::newSubTodo()
808{ 836{
809 if (mActiveItem) { 837 if (mActiveItem) {
810 emit newSubTodoSignal(mActiveItem->todo()); 838 emit newSubTodoSignal(mActiveItem->todo());
811 } 839 }
812} 840}
813void KOTodoView::unparentTodo() 841void KOTodoView::unparentTodo()
814{ 842{
815 if (mActiveItem) { 843 if (mActiveItem) {
816 emit unparentTodoSignal(mActiveItem->todo()); 844 emit unparentTodoSignal(mActiveItem->todo());
817 } 845 }
818} 846}
819 847
820void KOTodoView::reparentTodo() 848void KOTodoView::reparentTodo()
821{ 849{
822 if (mActiveItem) { 850 if (mActiveItem) {
823 qDebug("KOTodoView::reparentTodo() "); 851 qDebug("KOTodoView::reparentTodo() ");
824 topLevelWidget()->setCaption(i18n("Click on new parent item")); 852 topLevelWidget()->setCaption(i18n("Click on new parent item"));
825 pendingSubtodo = mActiveItem; 853 pendingSubtodo = mActiveItem;
826 } 854 }
827} 855}
828void KOTodoView::editTodo() 856void KOTodoView::editTodo()
829{ 857{
830 if (mActiveItem) { 858 if (mActiveItem) {
831 emit editTodoSignal(mActiveItem->todo()); 859 emit editTodoSignal(mActiveItem->todo());
832 } 860 }
833} 861}
834void KOTodoView::cloneTodo() 862void KOTodoView::cloneTodo()
835{ 863{
836 if (mActiveItem) { 864 if (mActiveItem) {
837 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 865 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
838 } 866 }
839} 867}
840void KOTodoView::cancelTodo() 868void KOTodoView::cancelTodo()
841{ 869{
842 if (mActiveItem) { 870 if (mActiveItem) {
843 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 871 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
844 } 872 }
845} 873}
846void KOTodoView::moveTodo() 874void KOTodoView::moveTodo()
847{ 875{
848 if (mActiveItem) { 876 if (mActiveItem) {
849 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 877 emit moveTodoSignal((Incidence*)mActiveItem->todo());
850 } 878 }
851} 879}
852void KOTodoView::beamTodo() 880void KOTodoView::beamTodo()
853{ 881{
854 if (mActiveItem) { 882 if (mActiveItem) {
855 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 883 emit beamTodoSignal((Incidence*)mActiveItem->todo());
856 } 884 }
857} 885}
858 886
859 887
860void KOTodoView::showTodo() 888void KOTodoView::showTodo()
861{ 889{
862 if (mActiveItem) { 890 if (mActiveItem) {
863 emit showTodoSignal(mActiveItem->todo()); 891 emit showTodoSignal(mActiveItem->todo());
864 } 892 }
865} 893}
866 894
867void KOTodoView::deleteTodo() 895void KOTodoView::deleteTodo()
868{ 896{
869 if (mActiveItem) { 897 if (mActiveItem) {
870 emit deleteTodoSignal(mActiveItem->todo()); 898 emit deleteTodoSignal(mActiveItem->todo());
871 } 899 }
872} 900}
873 901
874void KOTodoView::setNewPriority(int index) 902void KOTodoView::setNewPriority(int index)
875{ 903{
876 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 904 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
877 mActiveItem->todo()->setPriority(mPriority[index]); 905 mActiveItem->todo()->setPriority(mPriority[index]);
878 mActiveItem->construct(); 906 mActiveItem->construct();
879 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 907 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
880 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 908 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
881 } 909 }
882} 910}
883 911
884void KOTodoView::setNewPercentage(int index) 912void KOTodoView::setNewPercentage(int index)
885{ 913{
886 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 914 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
887 915
888 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 916 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
889 mActiveItem->setOn( true ); 917 mActiveItem->setOn( true );
890 return; 918 return;
891 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 919 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
892 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 920 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
893 if ( par && par->isOn() ) 921 if ( par && par->isOn() )
894 par->setOn( false ); 922 par->setOn( false );
895 } 923 }
896 if (mPercentage[index] == 100) { 924 if (mPercentage[index] == 100) {
897 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 925 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
898 } else { 926 } else {
899 mActiveItem->todo()->setCompleted(false); 927 mActiveItem->todo()->setCompleted(false);
900 } 928 }
901 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 929 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
902 mActiveItem->construct(); 930 mActiveItem->construct();
903 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 931 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
904 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 932 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
905 } 933 }
906} 934}
907 935
908 936
909QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 937QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
910{ 938{
911 QPopupMenu* tempMenu = new QPopupMenu (this); 939 QPopupMenu* tempMenu = new QPopupMenu (this);
912 QStringList checkedCategories = todoItem->todo()->categories (); 940 QStringList checkedCategories = todoItem->todo()->categories ();
913 941
914 tempMenu->setCheckable (true); 942 tempMenu->setCheckable (true);
915 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 943 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
916 it != KOPrefs::instance()->mCustomCategories.end (); 944 it != KOPrefs::instance()->mCustomCategories.end ();
917 ++it) { 945 ++it) {
918 int index = tempMenu->insertItem (*it); 946 int index = tempMenu->insertItem (*it);
919 mCategory[index] = *it; 947 mCategory[index] = *it;
920 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 948 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
921 } 949 }
922 950
923 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 951 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
924 return tempMenu; 952 return tempMenu;
925 953
926 954
927} 955}
928void KOTodoView::changedCategories(int index) 956void KOTodoView::changedCategories(int index)
929{ 957{
930 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 958 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
931 QStringList categories = mActiveItem->todo()->categories (); 959 QStringList categories = mActiveItem->todo()->categories ();
932 if (categories.find (mCategory[index]) != categories.end ()) 960 if (categories.find (mCategory[index]) != categories.end ())
933 categories.remove (mCategory[index]); 961 categories.remove (mCategory[index]);
934 else 962 else
935 categories.insert (categories.end(), mCategory[index]); 963 categories.insert (categories.end(), mCategory[index]);
936 categories.sort (); 964 categories.sort ();
937 mActiveItem->todo()->setCategories (categories); 965 mActiveItem->todo()->setCategories (categories);
938 mActiveItem->construct(); 966 mActiveItem->construct();
939 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 967 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
940 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 968 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
941 } 969 }
942} 970}
943void KOTodoView::itemDoubleClicked(QListViewItem *item) 971void KOTodoView::itemDoubleClicked(QListViewItem *item)
944{ 972{
945 if ( pendingSubtodo != 0 ) { 973 if ( pendingSubtodo != 0 ) {
946 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 974 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
947 } 975 }
948 pendingSubtodo = 0; 976 pendingSubtodo = 0;
949 if (!item) { 977 if (!item) {
950 newTodo(); 978 newTodo();
951 return; 979 return;
952 } 980 }
953 if ( KOPrefs::instance()->mEditOnDoubleClick ) 981 if ( KOPrefs::instance()->mEditOnDoubleClick )
954 editItem( item ); 982 editItem( item );
955 else 983 else
956 showItem( item , QPoint(), 0 ); 984 showItem( item , QPoint(), 0 );
957} 985}
958void KOTodoView::itemClicked(QListViewItem *item) 986void KOTodoView::itemClicked(QListViewItem *item)
959{ 987{
960 988
961 if (!item) { 989 if (!item) {
962 if ( pendingSubtodo != 0 ) { 990 if ( pendingSubtodo != 0 ) {
963 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 991 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
964 } 992 }
965 pendingSubtodo = 0; 993 pendingSubtodo = 0;
966 return; 994 return;
967 } 995 }
968 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 996 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
969 if ( pendingSubtodo != 0 ) { 997 if ( pendingSubtodo != 0 ) {
970 bool allowReparent = true; 998 bool allowReparent = true;
971 QListViewItem *par = item; 999 QListViewItem *par = item;
972 while ( par ) { 1000 while ( par ) {
973 if ( par == pendingSubtodo ) { 1001 if ( par == pendingSubtodo ) {
974 allowReparent = false; 1002 allowReparent = false;
975 break; 1003 break;
976 } 1004 }
977 par = par->parent(); 1005 par = par->parent();
978 } 1006 }
979 if ( !allowReparent ) { 1007 if ( !allowReparent ) {
980 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1008 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
981 qDebug("Recursive reparenting not possible "); 1009 qDebug("Recursive reparenting not possible ");
982 pendingSubtodo = 0; 1010 pendingSubtodo = 0;
983 } else { 1011 } else {
984 Todo* newParent = todoItem->todo(); 1012 Todo* newParent = todoItem->todo();
985 Todo* newSub = pendingSubtodo->todo(); 1013 Todo* newSub = pendingSubtodo->todo();
986 pendingSubtodo = 0; 1014 pendingSubtodo = 0;
987 emit reparentTodoSignal( newParent,newSub ); 1015 emit reparentTodoSignal( newParent,newSub );
988 return; 1016 return;
989 } 1017 }
990 } 1018 }
991#if 0 1019#if 0
992 // handled by the item itself 1020 // handled by the item itself
993 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 1021 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
994 qDebug("com %d ",completed ); 1022 qDebug("com %d ",completed );
995 qDebug("itemclicked "); 1023 qDebug("itemclicked ");
996 if (todoItem->isOn()) { 1024 if (todoItem->isOn()) {
997 qDebug("on "); 1025 qDebug("on ");
998 if (!completed) { 1026 if (!completed) {
999 qDebug("set true "); 1027 qDebug("set true ");
1000 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 1028 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1001 } 1029 }
1002 } else { 1030 } else {
1003 qDebug("not on "); 1031 qDebug("not on ");
1004 if (completed) { 1032 if (completed) {
1005 qDebug("set false "); 1033 qDebug("set false ");
1006 todoItem->todo()->setCompleted(false); 1034 todoItem->todo()->setCompleted(false);
1007 } 1035 }
1008 } 1036 }
1009#endif 1037#endif
1010} 1038}
1011 1039
1012void KOTodoView::setDocumentId( const QString &id ) 1040void KOTodoView::setDocumentId( const QString &id )
1013{ 1041{
1014 kdDebug() << "KOTodoView::setDocumentId()" << endl; 1042 kdDebug() << "KOTodoView::setDocumentId()" << endl;
1015 1043
1016 mDocPrefs->setDoc( id ); 1044 mDocPrefs->setDoc( id );
1017} 1045}
1018 1046
1019void KOTodoView::itemStateChanged( QListViewItem *item ) 1047void KOTodoView::itemStateChanged( QListViewItem *item )
1020{ 1048{
1021 if (!item) return; 1049 if (!item) return;
1022 1050
1023 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1051 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1024 1052
1025// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1053// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1026 1054
1027 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1055 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1028} 1056}
1029 1057
1030void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1058void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1031{ 1059{
1032 mTodoListView->saveLayout(config,group); 1060 mTodoListView->saveLayout(config,group);
1033} 1061}
1034 1062
1035void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1063void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1036{ 1064{
1037 mTodoListView->restoreLayout(config,group); 1065 mTodoListView->restoreLayout(config,group);
1038} 1066}
1039 1067
1040void KOTodoView::processSelectionChange() 1068void KOTodoView::processSelectionChange()
1041{ 1069{
1042// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1070// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1043 1071
1044 KOTodoViewItem *item = 1072 KOTodoViewItem *item =
1045 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1073 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1046 1074
1047 if ( !item ) { 1075 if ( !item ) {
1048 emit incidenceSelected( 0 ); 1076 emit incidenceSelected( 0 );
1049 } else { 1077 } else {
1050 emit incidenceSelected( item->todo() ); 1078 emit incidenceSelected( item->todo() );
1051 } 1079 }
1052} 1080}
1053 1081
1054void KOTodoView::modified(bool b) 1082void KOTodoView::modified(bool b)
1055{ 1083{
1056 emit isModified(b); 1084 emit isModified(b);
1057} 1085}
1058void KOTodoView::setTodoModified( Todo* todo ) 1086void KOTodoView::setTodoModified( Todo* todo )
1059{ 1087{
1060 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1088 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1061} 1089}
1062void KOTodoView::clearSelection() 1090void KOTodoView::clearSelection()
1063{ 1091{
1064 mTodoListView->selectAll( false ); 1092 mTodoListView->selectAll( false );
1065} 1093}
1066void KOTodoView::setAllOpen() 1094void KOTodoView::setAllOpen()
1067{ 1095{
1068 if ( isFlatDisplay ) { 1096 if ( isFlatDisplay ) {
1069 isFlatDisplay = false; 1097 isFlatDisplay = false;
1070 mPopupMenu->setItemChecked( 8,false ); 1098 mPopupMenu->setItemChecked( 8,false );
1071 updateView(); 1099 updateView();
1072 } 1100 }
1073 setOpen(mTodoListView->firstChild(), true); 1101 setOpen(mTodoListView->firstChild(), true);
1074} 1102}
1075void KOTodoView::setAllClose() 1103void KOTodoView::setAllClose()
1076{ 1104{
1077 if ( isFlatDisplay ) { 1105 if ( isFlatDisplay ) {
1078 isFlatDisplay = false; 1106 isFlatDisplay = false;
1079 mPopupMenu->setItemChecked( 8,false ); 1107 mPopupMenu->setItemChecked( 8,false );
1080 updateView(); 1108 updateView();
1081 } 1109 }
1082 setOpen(mTodoListView->firstChild(), false); 1110 setOpen(mTodoListView->firstChild(), false);
1083} 1111}
1084void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1112void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1085{ 1113{
1086 1114
1087 while ( item ) { 1115 while ( item ) {
1088 setOpen( item->firstChild(), setOpenI ); 1116 setOpen( item->firstChild(), setOpenI );
1089 item->setOpen( setOpenI ); 1117 item->setOpen( setOpenI );
1090 item = item->nextSibling(); 1118 item = item->nextSibling();
1091 } 1119 }
1092} 1120}
1093 1121
1094void KOTodoView::setAllFlat() 1122void KOTodoView::setAllFlat()
1095{ 1123{
1096 if ( isFlatDisplay ) { 1124 if ( isFlatDisplay ) {
1097 isFlatDisplay = false; 1125 isFlatDisplay = false;
1098 mPopupMenu->setItemChecked( 8,false ); 1126 mPopupMenu->setItemChecked( 8,false );
1099 updateView(); 1127 updateView();
1100 return; 1128 return;
1101 } 1129 }
1102 pendingSubtodo = 0; 1130 pendingSubtodo = 0;
1103 if ( mBlockUpdate ) { 1131 if ( mBlockUpdate ) {
1104 return; 1132 return;
1105 } 1133 }
1106 mPopupMenu->setItemChecked( 8,true ); 1134 mPopupMenu->setItemChecked( 8,true );
1107 isFlatDisplay = true; 1135 isFlatDisplay = true;
1108 QPtrList<Todo> todoList = calendar()->todos(); 1136 QPtrList<Todo> todoList = calendar()->todos();
1109 mTodoMap.clear(); 1137 mTodoMap.clear();
1110 mTodoListView->clear(); 1138 mTodoListView->clear();
1111 Todo *todo; 1139 Todo *todo;
1112 for(todo = todoList.first(); todo; todo = todoList.next()) { 1140 for(todo = todoList.first(); todo; todo = todoList.next()) {
1113 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1141 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1114 mTodoMap.insert(todo,todoItem); 1142 mTodoMap.insert(todo,todoItem);
1115 } 1143 }
1116 mTodoListView->setFocus(); 1144 mTodoListView->setFocus();
1117 processSelectionChange(); 1145 processSelectionChange();
1118} 1146}
1119 1147
1120void KOTodoView::purgeCompleted() 1148void KOTodoView::purgeCompleted()
1121{ 1149{
1122 emit purgeCompletedSignal(); 1150 emit purgeCompletedSignal();
1123} 1151}
1124void KOTodoView::toggleQuickTodo() 1152void KOTodoView::toggleQuickTodo()
1125{ 1153{
1126 if ( mQuickAdd->isVisible() ) { 1154 if ( mQuickAdd->isVisible() ) {
1127 mQuickAdd->hide(); 1155 mQuickAdd->hide();
1128 KOPrefs::instance()->mEnableQuickTodo = false; 1156 KOPrefs::instance()->mEnableQuickTodo = false;
1129 } 1157 }
1130 else { 1158 else {
1131 mQuickAdd->show(); 1159 mQuickAdd->show();
1132 KOPrefs::instance()->mEnableQuickTodo = true; 1160 KOPrefs::instance()->mEnableQuickTodo = true;
1133 } 1161 }
1134 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1162 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1135 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1163 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1136} 1164}
1137 1165
1138void KOTodoView::toggleRunning() 1166void KOTodoView::toggleRunning()
1139{ 1167{
1140 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1168 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1141 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1169 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1142 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1170 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1143 updateView(); 1171 updateView();
1144} 1172}
1145 1173
1146void KOTodoView::toggleCompleted() 1174void KOTodoView::toggleCompleted()
1147{ 1175{
1148 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1176 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1149 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1177 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1150 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1178 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1151 updateView(); 1179 updateView();
1152} 1180}
1153 1181
1154void KOTodoView::addQuickTodo() 1182void KOTodoView::addQuickTodo()
1155{ 1183{
1156 Todo *todo = new Todo(); 1184 Todo *todo = new Todo();
1157 todo->setSummary(mQuickAdd->text()); 1185 todo->setSummary(mQuickAdd->text());
1158 todo->setOrganizer(KOPrefs::instance()->email()); 1186 todo->setOrganizer(KOPrefs::instance()->email());
1159 CalFilter * cf = mCalendar->filter(); 1187 CalFilter * cf = mCalendar->filter();
1160 if ( cf ) { 1188 if ( cf ) {
1161 if ( cf->isEnabled()&& cf->showCategories()) { 1189 if ( cf->isEnabled()&& cf->showCategories()) {
1162 todo->setCategories(cf->categoryList()); 1190 todo->setCategories(cf->categoryList());
1163 } 1191 }
1164 if ( cf->isEnabled() ) 1192 if ( cf->isEnabled() )
1165 todo->setSecrecy( cf->getSecrecy()); 1193 todo->setSecrecy( cf->getSecrecy());
1166 } 1194 }
1167 mCalendar->addTodo(todo); 1195 mCalendar->addTodo(todo);
1168 mQuickAdd->setText(""); 1196 mQuickAdd->setText("");
1169 todoModified (todo, KOGlobals::EVENTADDED ); 1197 todoModified (todo, KOGlobals::EVENTADDED );
1170 updateView(); 1198 updateView();
1171} 1199}
1172void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1200void KOTodoView::keyPressEvent ( QKeyEvent * e )
1173{ 1201{
1174 // e->ignore(); 1202 // e->ignore();
1175 //return; 1203 //return;
1176 //qDebug("KOTodoView::keyPressEvent "); 1204 //qDebug("KOTodoView::keyPressEvent ");
1177 switch ( e->key() ) { 1205 switch ( e->key() ) {
1178 case Qt::Key_Down: 1206 case Qt::Key_Down:
1179 case Qt::Key_Up: 1207 case Qt::Key_Up:
1180 QWidget::keyPressEvent ( e ); 1208 QWidget::keyPressEvent ( e );
1181 break; 1209 break;
1182 1210
1183 case Qt::Key_Q: 1211 case Qt::Key_Q:
1184 toggleQuickTodo(); 1212 toggleQuickTodo();
1185 break; 1213 break;
1186 case Qt::Key_U: 1214 case Qt::Key_U:
1187 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1215 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1188 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1216 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1189 unparentTodo(); 1217 unparentTodo();
1190 e->accept(); 1218 e->accept();
1191 } else 1219 } else
1192 e->ignore(); 1220 e->ignore();
1193 break; 1221 break;
1194 case Qt::Key_S: 1222 case Qt::Key_S:
1195 if ( e->state() == Qt::ControlButton ) { 1223 if ( e->state() == Qt::ControlButton ) {
1196 e->ignore(); 1224 e->ignore();
1197 break; 1225 break;
1198 } 1226 }
1199 if ( e->state() == Qt::ShiftButton ) { 1227 if ( e->state() == Qt::ShiftButton ) {
1200 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1228 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1201 reparentTodo(); 1229 reparentTodo();
1202 e->accept(); 1230 e->accept();
1203 } else 1231 } else
1204 e->ignore(); 1232 e->ignore();
1205 break; 1233 break;
1206 case Qt::Key_P: 1234 case Qt::Key_P:
1207 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1235 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1208 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1236 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1209 if ( pendingSubtodo ) 1237 if ( pendingSubtodo )
1210 itemClicked(mActiveItem); 1238 itemClicked(mActiveItem);
1211 e->accept(); 1239 e->accept();
1212 } else 1240 } else
1213 e->ignore(); 1241 e->ignore();
1214 break; 1242 break;
1215 case Qt::Key_Escape: 1243 case Qt::Key_Escape:
1216 if ( pendingSubtodo ) { 1244 if ( pendingSubtodo ) {
1217 itemClicked(0); 1245 itemClicked(0);
1218 e->accept(); 1246 e->accept();
1219 } else 1247 } else
1220 e->ignore(); 1248 e->ignore();
1221 break; 1249 break;
1222 default: 1250 default:
1223 e->ignore(); 1251 e->ignore();
1224 } 1252 }
1225 1253
1226 if ( true ) { 1254 if ( true ) {
1227 if ( e->key() == Qt::Key_I ) { 1255 if ( e->key() == Qt::Key_I ) {
1228 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1256 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1229 if ( cn ) { 1257 if ( cn ) {
1230 mActiveItem = cn; 1258 mActiveItem = cn;
1231 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1259 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1232 if ( ci ){ 1260 if ( ci ){
1233 showTodo(); 1261 showTodo();
1234 cn = (KOTodoViewItem*)cn->itemBelow(); 1262 cn = (KOTodoViewItem*)cn->itemBelow();
1235 if ( cn ) { 1263 if ( cn ) {
1236 mTodoListView->setCurrentItem ( cn ); 1264 mTodoListView->setCurrentItem ( cn );
1237 mTodoListView->ensureItemVisible ( cn ); 1265 mTodoListView->ensureItemVisible ( cn );
1238 } 1266 }
1239 1267
1240 } 1268 }
1241 } 1269 }
1242 e->accept(); 1270 e->accept();
1243 1271
1244 } 1272 }
1245 1273
1246 } 1274 }
1247 1275
1248} 1276}
1249void KOTodoView::updateTodo( Todo * t, int type ) 1277void KOTodoView::updateTodo( Todo * t, int type )
1250{ 1278{
1251 if ( mBlockUpdate) 1279 if ( mBlockUpdate)
1252 return; 1280 return;
1253 1281
1254 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1282 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1255 itemIterator = mTodoMap.find(t); 1283 itemIterator = mTodoMap.find(t);
1256 if (itemIterator != mTodoMap.end()) { 1284 if (itemIterator != mTodoMap.end()) {
1257 (*itemIterator)->construct(); 1285 (*itemIterator)->construct();
1258 } else { 1286 } else {
1259 if ( type == KOGlobals::EVENTADDED ) { 1287 if ( type == KOGlobals::EVENTADDED ) {
1260 insertTodoItem( t ); 1288 insertTodoItem( t );
1261 } 1289 }
1262 } 1290 }
1263 1291
1264} 1292}
1265 1293
1266void KOTodoView::todoModified(Todo * t , int p ) 1294void KOTodoView::todoModified(Todo * t , int p )
1267{ 1295{
1268 mBlockUpdate = true; 1296 mBlockUpdate = true;
1269 emit todoModifiedSignal ( t, p ); 1297 emit todoModifiedSignal ( t, p );
1270 mBlockUpdate = false; 1298 mBlockUpdate = false;
1271} 1299}
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 2a9e737..1642132 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,253 +1,254 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qlistview.h> 35#include <qlistview.h>
36#include <klistview.h> 36#include <klistview.h>
37 37
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40 40
41#include <korganizer/baseview.h> 41#include <korganizer/baseview.h>
42 42
43#include "kotodoviewitem.h" 43#include "kotodoviewitem.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "koglobals.h" 45#include "koglobals.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47 47
48class QDragEnterEvent; 48class QDragEnterEvent;
49class QDragMoveEvent; 49class QDragMoveEvent;
50class QDragLeaveEvent; 50class QDragLeaveEvent;
51class QDropEvent; 51class QDropEvent;
52 52
53class DocPrefs; 53class DocPrefs;
54 54
55class KOTodoListView : public KListView 55class KOTodoListView : public KListView
56{ 56{
57 Q_OBJECT 57 Q_OBJECT
58 public: 58 public:
59 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 59 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
60 virtual ~KOTodoListView() {} 60 virtual ~KOTodoListView() {}
61 61
62 signals: 62 signals:
63 void paintNeeded(); 63 void paintNeeded();
64 void todoDropped(Todo *, int); 64 void todoDropped(Todo *, int);
65 void double_Clicked(QListViewItem *item); 65 void double_Clicked(QListViewItem *item);
66 void reparentTodoSignal( Todo *,Todo * ); 66 void reparentTodoSignal( Todo *,Todo * );
67 void unparentTodoSignal(Todo *); 67 void unparentTodoSignal(Todo *);
68 void deleteTodo( Todo * ); 68 void deleteTodo( Todo * );
69 protected: 69 protected:
70 void contentsDragEnterEvent(QDragEnterEvent *); 70 void contentsDragEnterEvent(QDragEnterEvent *);
71 void contentsDragMoveEvent(QDragMoveEvent *); 71 void contentsDragMoveEvent(QDragMoveEvent *);
72 void contentsDragLeaveEvent(QDragLeaveEvent *); 72 void contentsDragLeaveEvent(QDragLeaveEvent *);
73 void contentsDropEvent(QDropEvent *); 73 void contentsDropEvent(QDropEvent *);
74 74
75 void contentsMousePressEvent(QMouseEvent *); 75 void contentsMousePressEvent(QMouseEvent *);
76 void contentsMouseMoveEvent(QMouseEvent *); 76 void contentsMouseMoveEvent(QMouseEvent *);
77 void contentsMouseReleaseEvent(QMouseEvent *); 77 void contentsMouseReleaseEvent(QMouseEvent *);
78 void contentsMouseDoubleClickEvent(QMouseEvent *); 78 void contentsMouseDoubleClickEvent(QMouseEvent *);
79 79
80 private: 80 private:
81 void paintEvent(QPaintEvent * pevent); 81 void paintEvent(QPaintEvent * pevent);
82 bool internalDrop; 82 bool internalDrop;
83 QString mName; 83 QString mName;
84 Calendar *mCalendar; 84 Calendar *mCalendar;
85 QPoint mPressPos; 85 QPoint mPressPos;
86 bool mMousePressed; 86 bool mMousePressed;
87 QListViewItem *mOldCurrent; 87 QListViewItem *mOldCurrent;
88 void keyPressEvent ( QKeyEvent * ) ; 88 void keyPressEvent ( QKeyEvent * ) ;
89}; 89};
90 90
91 91
92/** 92/**
93 This is the line-edit on top of the todoview for fast addition of new todos 93 This is the line-edit on top of the todoview for fast addition of new todos
94*/ 94*/
95class KOQuickTodo : public QLineEdit 95class KOQuickTodo : public QLineEdit
96{ 96{
97 public: 97 public:
98 KOQuickTodo(QWidget *parent=0); 98 KOQuickTodo(QWidget *parent=0);
99 protected: 99 protected:
100 void focusInEvent(QFocusEvent *ev); 100 void focusInEvent(QFocusEvent *ev);
101 void focusOutEvent(QFocusEvent *ev); 101 void focusOutEvent(QFocusEvent *ev);
102}; 102};
103 103
104 104
105/** 105/**
106 This class provides a multi-column list view of todo events. 106 This class provides a multi-column list view of todo events.
107 107
108 @short multi-column list view of todo events. 108 @short multi-column list view of todo events.
109 @author Cornelius Schumacher <schumacher@kde.org> 109 @author Cornelius Schumacher <schumacher@kde.org>
110*/ 110*/
111class KOTodoView : public KOrg::BaseView 111class KOTodoView : public KOrg::BaseView
112{ 112{
113 Q_OBJECT 113 Q_OBJECT
114 public: 114 public:
115 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 115 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
116 ~KOTodoView(); 116 ~KOTodoView();
117 117
118 QPtrList<Incidence> selectedIncidences(); 118 QPtrList<Incidence> selectedIncidences();
119 QPtrList<Todo> selectedTodos(); 119 QPtrList<Todo> selectedTodos();
120 120
121 DateList selectedDates() 121 DateList selectedDates()
122 {DateList q; 122 {DateList q;
123 return q;} 123 return q;}
124 124
125 /** Return number of shown dates. TodoView does not show dates, */ 125 /** Return number of shown dates. TodoView does not show dates, */
126 int currentDateCount() { return 0; } 126 int currentDateCount() { return 0; }
127 127
128 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 128 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
129 129
130 void setDocumentId( const QString & ); 130 void setDocumentId( const QString & );
131 131
132 void saveLayout(KConfig *config, const QString &group) const; 132 void saveLayout(KConfig *config, const QString &group) const;
133 void restoreLayout(KConfig *config, const QString &group); 133 void restoreLayout(KConfig *config, const QString &group);
134 /** Create a popup menu to set categories */ 134 /** Create a popup menu to set categories */
135 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); 135 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
136 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 136 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
137 QString getWhatsThisText(QPoint p);
137 138
138 public slots: 139 public slots:
139 void updateView(); 140 void updateView();
140 void updateConfig(); 141 void updateConfig();
141 142
142 void changeEventDisplay(Event *, int); 143 void changeEventDisplay(Event *, int);
143 144
144 void showDates(const QDate &start, const QDate &end); 145 void showDates(const QDate &start, const QDate &end);
145 void showEvents(QPtrList<Event> eventList); 146 void showEvents(QPtrList<Event> eventList);
146 147
147 void clearSelection(); 148 void clearSelection();
148 void jumpToDate (); 149 void jumpToDate ();
149 150
150 void editItem(QListViewItem *item); 151 void editItem(QListViewItem *item);
151 void showItem(QListViewItem *item,const QPoint &,int); 152 void showItem(QListViewItem *item,const QPoint &,int);
152 void popupMenu(QListViewItem *item,const QPoint &,int); 153 void popupMenu(QListViewItem *item,const QPoint &,int);
153 void newTodo(); 154 void newTodo();
154 void newSubTodo(); 155 void newSubTodo();
155 void unparentTodo(); 156 void unparentTodo();
156 void reparentTodo(); 157 void reparentTodo();
157 void showTodo(); 158 void showTodo();
158 void editTodo(); 159 void editTodo();
159 void cloneTodo(); 160 void cloneTodo();
160 void cancelTodo(); 161 void cancelTodo();
161 void moveTodo(); 162 void moveTodo();
162 void beamTodo(); 163 void beamTodo();
163 void deleteTodo(); 164 void deleteTodo();
164 165
165 void setNewPriority(int); 166 void setNewPriority(int);
166 void setNewPercentage(int); 167 void setNewPercentage(int);
167 void changedCategories(int); 168 void changedCategories(int);
168 169
169 void setAllOpen(); 170 void setAllOpen();
170 void setAllClose(); 171 void setAllClose();
171 void setAllFlat(); 172 void setAllFlat();
172 173
173 void purgeCompleted(); 174 void purgeCompleted();
174 void toggleCompleted(); 175 void toggleCompleted();
175 void toggleRunning(); 176 void toggleRunning();
176 void toggleQuickTodo(); 177 void toggleQuickTodo();
177 void updateTodo( Todo *, int ); 178 void updateTodo( Todo *, int );
178 179
179 void itemClicked(QListViewItem *); 180 void itemClicked(QListViewItem *);
180 void itemStateChanged(QListViewItem *); 181 void itemStateChanged(QListViewItem *);
181 void modified(bool); 182 void modified(bool);
182 void itemDoubleClicked(QListViewItem *item); 183 void itemDoubleClicked(QListViewItem *item);
183 184
184 signals: 185 signals:
185 void newTodoSignal(); 186 void newTodoSignal();
186 void newSubTodoSignal(Todo *); 187 void newSubTodoSignal(Todo *);
187 void unparentTodoSignal(Todo *); 188 void unparentTodoSignal(Todo *);
188 void reparentTodoSignal( Todo *,Todo * ); 189 void reparentTodoSignal( Todo *,Todo * );
189 void showTodoSignal(Todo *); 190 void showTodoSignal(Todo *);
190 191
191 void editTodoSignal(Todo *); 192 void editTodoSignal(Todo *);
192 void deleteTodoSignal(Todo *); 193 void deleteTodoSignal(Todo *);
193 void todoModifiedSignal (Todo *, int); 194 void todoModifiedSignal (Todo *, int);
194 195
195 void isModified(bool); 196 void isModified(bool);
196 void cloneTodoSignal( Incidence * ); 197 void cloneTodoSignal( Incidence * );
197 void cancelTodoSignal( Incidence * ); 198 void cancelTodoSignal( Incidence * );
198 void moveTodoSignal( Incidence * ); 199 void moveTodoSignal( Incidence * );
199 void beamTodoSignal( Incidence * ); 200 void beamTodoSignal( Incidence * );
200 void purgeCompletedSignal(); 201 void purgeCompletedSignal();
201 202
202 protected slots: 203 protected slots:
203 void paintNeeded(); 204 void paintNeeded();
204 void processSelectionChange(); 205 void processSelectionChange();
205 void addQuickTodo(); 206 void addQuickTodo();
206 void setTodoModified( Todo* ); 207 void setTodoModified( Todo* );
207 void todoModified(Todo *, int ); 208 void todoModified(Todo *, int );
208 209
209 private: 210 private:
210 /* 211 /*
211 * the TodoEditor approach is rather unscaling in the long 212 * the TodoEditor approach is rather unscaling in the long
212 * run. 213 * run.
213 * Korganizer keeps it in memory and we need to update 214 * Korganizer keeps it in memory and we need to update
214 * 1. make KOTodoViewItem a QObject again? 215 * 1. make KOTodoViewItem a QObject again?
215 * 2. add a public method for setting one todo modified? 216 * 2. add a public method for setting one todo modified?
216 * 3. add a private method for setting a todo modified + friend here? 217 * 3. add a private method for setting a todo modified + friend here?
217 * -- zecke 2002-07-08 218 * -- zecke 2002-07-08
218 */ 219 */
219 friend class KOTodoListView; 220 friend class KOTodoListView;
220 void paintEvent(QPaintEvent * pevent); 221 void paintEvent(QPaintEvent * pevent);
221 bool mPendingUpdateBeforeRepaint; 222 bool mPendingUpdateBeforeRepaint;
222 friend class KOTodoViewItem; 223 friend class KOTodoViewItem;
223 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 224 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
224 void restoreItemState( QListViewItem * ); 225 void restoreItemState( QListViewItem * );
225 226
226 bool checkTodo( Todo * ); 227 bool checkTodo( Todo * );
227 bool isFlatDisplay; 228 bool isFlatDisplay;
228 void setOpen( QListViewItem*, bool setOpen); 229 void setOpen( QListViewItem*, bool setOpen);
229 KOTodoListView *mTodoListView; 230 KOTodoListView *mTodoListView;
230 QPopupMenu *mItemPopupMenu; 231 QPopupMenu *mItemPopupMenu;
231 QPopupMenu *mPopupMenu; 232 QPopupMenu *mPopupMenu;
232 QPopupMenu *mPriorityPopupMenu; 233 QPopupMenu *mPriorityPopupMenu;
233 QPopupMenu *mPercentageCompletedPopupMenu; 234 QPopupMenu *mPercentageCompletedPopupMenu;
234 QPopupMenu *mCategoryPopupMenu; 235 QPopupMenu *mCategoryPopupMenu;
235 236
236 QMap<int, int> mPercentage; 237 QMap<int, int> mPercentage;
237 QMap<int, int> mPriority; 238 QMap<int, int> mPriority;
238 QMap<int, QString> mCategory; 239 QMap<int, QString> mCategory;
239 KOTodoViewItem *mActiveItem; 240 KOTodoViewItem *mActiveItem;
240 241
241 QMap<Todo *,KOTodoViewItem *> mTodoMap; 242 QMap<Todo *,KOTodoViewItem *> mTodoMap;
242 QString mName; 243 QString mName;
243 244
244 DocPrefs *mDocPrefs; 245 DocPrefs *mDocPrefs;
245 QString mCurrentDoc; 246 QString mCurrentDoc;
246 KOQuickTodo *mQuickAdd; 247 KOQuickTodo *mQuickAdd;
247 bool mBlockUpdate; 248 bool mBlockUpdate;
248 void keyPressEvent ( QKeyEvent * ) ; 249 void keyPressEvent ( QKeyEvent * ) ;
249 KOTodoViewItem * pendingSubtodo; 250 KOTodoViewItem * pendingSubtodo;
250 DateNavigator* mNavigator; 251 DateNavigator* mNavigator;
251}; 252};
252 253
253#endif 254#endif