summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp1
-rw-r--r--korganizer/koeditorgeneral.cpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index e545ca8..c9e307f 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,549 +1,550 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qwhatsthis.h> 25#include <qwhatsthis.h>
26#include <qdragobject.h> 26#include <qdragobject.h>
27#include <qdrawutil.h> 27#include <qdrawutil.h>
28#include <qpainter.h> 28#include <qpainter.h>
29 29
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#define AGENDA_ICON_SIZE 5 36#define AGENDA_ICON_SIZE 5
37#else 37#else
38#include <qapplication.h>
38#define AGENDA_ICON_SIZE 7 39#define AGENDA_ICON_SIZE 7
39#endif 40#endif
40#include <libkcal/icaldrag.h> 41#include <libkcal/icaldrag.h>
41#include <libkcal/vcaldrag.h> 42#include <libkcal/vcaldrag.h>
42#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
43extern int globalFlagBlockAgenda; 44extern int globalFlagBlockAgenda;
44extern int globalFlagBlockAgendaItemPaint; 45extern int globalFlagBlockAgendaItemPaint;
45extern int globalFlagBlockAgendaItemUpdate; 46extern int globalFlagBlockAgendaItemUpdate;
46 47
47#include "koprefs.h" 48#include "koprefs.h"
48 49
49#include "koagendaitem.h" 50#include "koagendaitem.h"
50//#include "koagendaitem.moc" 51//#include "koagendaitem.moc"
51 52
52 53
53//-------------------------------------------------------------------------- 54//--------------------------------------------------------------------------
54 55
55QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; 56QToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 57
57//-------------------------------------------------------------------------- 58//--------------------------------------------------------------------------
58 59
59class KOAgendaItemWhatsThis :public QWhatsThis 60class KOAgendaItemWhatsThis :public QWhatsThis
60{ 61{
61public: 62public:
62 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; 63 KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { };
63 64
64protected: 65protected:
65 virtual QString text( const QPoint& ) 66 virtual QString text( const QPoint& )
66 { 67 {
67 return _view->getWhatsThisText() ; 68 return _view->getWhatsThisText() ;
68 } 69 }
69private: 70private:
70 KOAgendaItem * _view; 71 KOAgendaItem * _view;
71}; 72};
72 73
73KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 74KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
74 const char *name,WFlags) : 75 const char *name,WFlags) :
75 QWidget(parent, name), mIncidence(incidence), mDate(qd) 76 QWidget(parent, name), mIncidence(incidence), mDate(qd)
76{ 77{
77#ifndef DESKTOP_VERSION 78#ifndef DESKTOP_VERSION
78 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 79 //QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
79#endif 80#endif
80 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this); 81 mKOAgendaItemWhatsThis = new KOAgendaItemWhatsThis(this);
81 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 82 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
82 setWFlags ( wflags); 83 setWFlags ( wflags);
83 mAllDay = allday; 84 mAllDay = allday;
84 init ( incidence, qd ); 85 init ( incidence, qd );
85 //setMouseTracking(true); 86 //setMouseTracking(true);
86 //setAcceptDrops(true); 87 //setAcceptDrops(true);
87 xPaintCoord = -1; 88 xPaintCoord = -1;
88 yPaintCoord = -1; 89 yPaintCoord = -1;
89} 90}
90QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
91{ 92{
92 if ( mIncidence ) 93 if ( mIncidence )
93 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
94 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
95 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
96 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
97 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
98} 99}
99void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100void KOAgendaItem::init ( Incidence *incidence, QDate qd )
100{ 101{
101 mIncidence = incidence; 102 mIncidence = incidence;
102 mDate = qd; 103 mDate = qd;
103 mFirstMultiItem = 0; 104 mFirstMultiItem = 0;
104 mNextMultiItem = 0; 105 mNextMultiItem = 0;
105 mLastMultiItem = 0; 106 mLastMultiItem = 0;
106 computeText(); 107 computeText();
107 108
108 if ( (incidence->type() == "Todo") && 109 if ( (incidence->type() == "Todo") &&
109 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
110 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
111 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
112 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
113 else 114 else
114 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
115 } 116 }
116 else { 117 else {
117 QStringList categories = mIncidence->categories(); 118 QStringList categories = mIncidence->categories();
118 QString cat = categories.first(); 119 QString cat = categories.first();
119 if (cat.isEmpty()) { 120 if (cat.isEmpty()) {
120 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 121 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) )
121 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
122 else 123 else
123 mBackgroundColor =KOPrefs::instance()->mEventColor; 124 mBackgroundColor =KOPrefs::instance()->mEventColor;
124 } else { 125 } else {
125 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
126 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 127 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
127 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
128 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 129 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
129 } 130 }
130 } 131 }
131 132
132 } 133 }
133 mColorGroup = QColorGroup( mBackgroundColor.light(), 134 mColorGroup = QColorGroup( mBackgroundColor.light(),
134 mBackgroundColor.dark(),mBackgroundColor.light(), 135 mBackgroundColor.dark(),mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
136 setBackgroundColor( mBackgroundColor ); 137 setBackgroundColor( mBackgroundColor );
137 138
138 mConflictItems.clear(); 139 mConflictItems.clear();
139 setCellXY(0,0,1); 140 setCellXY(0,0,1);
140 setCellXWidth(0); 141 setCellXWidth(0);
141 setSubCell(0); 142 setSubCell(0);
142 setSubCells(1); 143 setSubCells(1);
143 setMultiItem(0,0,0); 144 setMultiItem(0,0,0);
144 startMove(); 145 startMove();
145 mSelected = true; 146 mSelected = true;
146 select(false); 147 select(false);
147 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
148 mFontPixelSize = fontinf.height();; 149 mFontPixelSize = fontinf.height();;
149 hide(); 150 hide();
150 xPaintCoord = -1; 151 xPaintCoord = -1;
151 yPaintCoord = -1; 152 yPaintCoord = -1;
152} 153}
153 154
154 155
155KOAgendaItem::~KOAgendaItem() 156KOAgendaItem::~KOAgendaItem()
156{ 157{
157 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 158 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
158 // delete mKOAgendaItemWhatsThis; 159 // delete mKOAgendaItemWhatsThis;
159} 160}
160 161
161void KOAgendaItem::recreateIncidence() 162void KOAgendaItem::recreateIncidence()
162{ 163{
163#if 0 164#if 0
164 Incidence* newInc = mIncidence->clone(); 165 Incidence* newInc = mIncidence->clone();
165 newInc->recreate(); 166 newInc->recreate();
166 if ( mIncidence->doesRecur() ) { 167 if ( mIncidence->doesRecur() ) {
167 mIncidence->addExDate( mDate ); 168 mIncidence->addExDate( mDate );
168 newInc->recurrence()->unsetRecurs(); 169 newInc->recurrence()->unsetRecurs();
169 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 170 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
170 QTime tim = mIncidence->dtStart().time(); 171 QTime tim = mIncidence->dtStart().time();
171 newInc->setDtStart( QDateTime(mDate, tim) ); 172 newInc->setDtStart( QDateTime(mDate, tim) );
172 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 173 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
173 } 174 }
174#endif 175#endif
175 mIncidence = mIncidence->recreateCloneException( mDate ); 176 mIncidence = mIncidence->recreateCloneException( mDate );
176} 177}
177bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 178bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
178{ 179{
179 int size = AGENDA_ICON_SIZE; 180 int size = AGENDA_ICON_SIZE;
180 181
181 int yOff = 0; 182 int yOff = 0;
182 int xOff = 0; 183 int xOff = 0;
183 int x = pos().x() +3; 184 int x = pos().x() +3;
184 int y; 185 int y;
185 if ( mAllDay ) 186 if ( mAllDay )
186 y = pos().y()+3; 187 y = pos().y()+3;
187 else 188 else
188 y = mCellYTop * ( height() / cellHeight() ) +3; 189 y = mCellYTop * ( height() / cellHeight() ) +3;
189 if (mIncidence->cancelled()) { 190 if (mIncidence->cancelled()) {
190 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 191 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
191 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 192 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
192 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 193 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
193 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 194 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
194 if ( horLayout ) 195 if ( horLayout )
195 ++xOff; 196 ++xOff;
196 else 197 else
197 ++yOff; 198 ++yOff;
198 } 199 }
199 if (mIncidence->isAlarmEnabled()) { 200 if (mIncidence->isAlarmEnabled()) {
200 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 201 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
201 if ( horLayout ) 202 if ( horLayout )
202 ++xOff; 203 ++xOff;
203 else 204 else
204 ++yOff; 205 ++yOff;
205 } 206 }
206 if (mIncidence->recurrence()->doesRecur()) { 207 if (mIncidence->recurrence()->doesRecur()) {
207 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 208 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
208 if ( horLayout ) 209 if ( horLayout )
209 ++xOff; 210 ++xOff;
210 else 211 else
211 ++yOff; 212 ++yOff;
212 } 213 }
213 if (mIncidence->description().length() > 0) { 214 if (mIncidence->description().length() > 0) {
214 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 215 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
215 if ( horLayout ) 216 if ( horLayout )
216 ++xOff; 217 ++xOff;
217 else 218 else
218 ++yOff; 219 ++yOff;
219 } 220 }
220 if (mIncidence->isReadOnly()) { 221 if (mIncidence->isReadOnly()) {
221 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 222 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
222 if ( horLayout ) 223 if ( horLayout )
223 ++xOff; 224 ++xOff;
224 else 225 else
225 ++yOff; 226 ++yOff;
226 } 227 }
227 228
228 if (mIncidence->attendeeCount()>0) { 229 if (mIncidence->attendeeCount()>0) {
229 230
230 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 231 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 232 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
232 if ( horLayout ) 233 if ( horLayout )
233 ++xOff; 234 ++xOff;
234 else 235 else
235 ++yOff; 236 ++yOff;
236 } else { 237 } else {
237 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 238 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
238 if (me!=0) { 239 if (me!=0) {
239 240
240 241
241 } else { 242 } else {
242 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 243 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
243 if ( horLayout ) 244 if ( horLayout )
244 ++xOff; 245 ++xOff;
245 else 246 else
246 ++yOff; 247 ++yOff;
247 248
248 } 249 }
249 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 250 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
250 if ( horLayout ) 251 if ( horLayout )
251 ++xOff; 252 ++xOff;
252 else 253 else
253 ++yOff; 254 ++yOff;
254 255
255 } 256 }
256 257
257 } 258 }
258 return ( yOff || xOff ); 259 return ( yOff || xOff );
259} 260}
260 261
261 262
262void KOAgendaItem::select(bool selected) 263void KOAgendaItem::select(bool selected)
263{ 264{
264 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 265 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
265 if (mSelected == selected) return; 266 if (mSelected == selected) return;
266 mSelected = selected; 267 mSelected = selected;
267 if ( ! isVisible() ) 268 if ( ! isVisible() )
268 return; 269 return;
269 if ( firstMultiItem() ) 270 if ( firstMultiItem() )
270 firstMultiItem()->select( selected ); 271 firstMultiItem()->select( selected );
271 if ( !firstMultiItem() && nextMultiItem() ) { 272 if ( !firstMultiItem() && nextMultiItem() ) {
272 KOAgendaItem * placeItem = nextMultiItem(); 273 KOAgendaItem * placeItem = nextMultiItem();
273 while ( placeItem ) { 274 while ( placeItem ) {
274 placeItem->select( selected ); 275 placeItem->select( selected );
275 placeItem = placeItem->nextMultiItem(); 276 placeItem = placeItem->nextMultiItem();
276 } 277 }
277 } 278 }
278 globalFlagBlockAgendaItemUpdate = 0; 279 globalFlagBlockAgendaItemUpdate = 0;
279 paintMe( selected ); 280 paintMe( selected );
280 globalFlagBlockAgendaItemUpdate = 1; 281 globalFlagBlockAgendaItemUpdate = 1;
281 repaint( false ); 282 repaint( false );
282} 283}
283 284
284 285
285/* 286/*
286 The eventFilter has to filter the mouse events of the agenda item childs. The 287 The eventFilter has to filter the mouse events of the agenda item childs. The
287 events are fed into the event handling method of KOAgendaItem. This allows the 288 events are fed into the event handling method of KOAgendaItem. This allows the
288 KOAgenda to handle the KOAgendaItems by using an eventFilter. 289 KOAgenda to handle the KOAgendaItems by using an eventFilter.
289*/ 290*/
290bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 291bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
291{ 292{
292 if (e->type() == QEvent::MouseButtonPress || 293 if (e->type() == QEvent::MouseButtonPress ||
293 e->type() == QEvent::MouseButtonDblClick || 294 e->type() == QEvent::MouseButtonDblClick ||
294 e->type() == QEvent::MouseButtonRelease || 295 e->type() == QEvent::MouseButtonRelease ||
295 e->type() == QEvent::MouseMove) { 296 e->type() == QEvent::MouseMove) {
296 QMouseEvent *me = (QMouseEvent *)e; 297 QMouseEvent *me = (QMouseEvent *)e;
297 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 298 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
298 mapToGlobal(me->pos())); 299 mapToGlobal(me->pos()));
299 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 300 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
300 return event(&returnEvent); 301 return event(&returnEvent);
301 } else { 302 } else {
302 return false; 303 return false;
303 } 304 }
304} 305}
305void KOAgendaItem::repaintMe( ) 306void KOAgendaItem::repaintMe( )
306{ 307{
307 paintMe ( mSelected ); 308 paintMe ( mSelected );
308} 309}
309void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 310void KOAgendaItem::paintMe( bool selected, QPainter* paint )
310{ 311{
311 if ( globalFlagBlockAgendaItemUpdate && ! selected) 312 if ( globalFlagBlockAgendaItemUpdate && ! selected)
312 return; 313 return;
313 QPainter pa; 314 QPainter pa;
314 315
315 if ( mSelected ) { 316 if ( mSelected ) {
316 pa.begin( paintPixSel() ); 317 pa.begin( paintPixSel() );
317 } else { 318 } else {
318 if ( mAllDay ) 319 if ( mAllDay )
319 pa.begin( paintPixAllday() ); 320 pa.begin( paintPixAllday() );
320 else 321 else
321 pa.begin( paintPix() ); 322 pa.begin( paintPix() );
322 } 323 }
323 int x, yy, w, h; 324 int x, yy, w, h;
324 float nfh = 7.0; 325 float nfh = 7.0;
325 x = pos().x(); w = width(); h = height (); 326 x = pos().x(); w = width(); h = height ();
326 if ( mAllDay ) 327 if ( mAllDay )
327 yy = y(); 328 yy = y();
328 else 329 else
329 yy = mCellYTop * ( height() / cellHeight() ); 330 yy = mCellYTop * ( height() / cellHeight() );
330 xPaintCoord= x; 331 xPaintCoord= x;
331 yPaintCoord = yy; 332 yPaintCoord = yy;
332 wPaintCoord = width(); 333 wPaintCoord = width();
333 hPaintCoord = height(); 334 hPaintCoord = height();
334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 335 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
335 if ( paint == 0 ) 336 if ( paint == 0 )
336 paint = &pa; 337 paint = &pa;
337 bool horLayout = ( w < h ); 338 bool horLayout = ( w < h );
338 int maxhei = mFontPixelSize+4; 339 int maxhei = mFontPixelSize+4;
339 if ( horLayout ) 340 if ( horLayout )
340 maxhei += AGENDA_ICON_SIZE -4; 341 maxhei += AGENDA_ICON_SIZE -4;
341 bool small = ( h < maxhei ); 342 bool small = ( h < maxhei );
342 if ( ! small ) 343 if ( ! small )
343 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 344 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
344 else { 345 else {
345 QFont f = KOPrefs::instance()->mAgendaViewFont; 346 QFont f = KOPrefs::instance()->mAgendaViewFont;
346 f.setBold( false ); 347 f.setBold( false );
347 int fh = f.pointSize(); 348 int fh = f.pointSize();
348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 349 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
349 if ( nfh < 6 ) 350 if ( nfh < 6 )
350 nfh = 6; 351 nfh = 6;
351 f.setPointSize( nfh ); 352 f.setPointSize( nfh );
352 paint->setFont(f); 353 paint->setFont(f);
353 } 354 }
354 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 355 paint->fillRect ( x, yy, w, h, mBackgroundColor );
355 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 356 static const QPixmap completedPxmp = SmallIcon("greenhook16");
356 static const QPixmap overduePxmp = SmallIcon("redcross16"); 357 static const QPixmap overduePxmp = SmallIcon("redcross16");
357 if ( mIncidence->type() == "Todo" ) { 358 if ( mIncidence->type() == "Todo" ) {
358 Todo* tempTodo = static_cast<Todo*>(mIncidence); 359 Todo* tempTodo = static_cast<Todo*>(mIncidence);
359 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 360 int xx = pos().x()+(width()-completedPxmp.width()-3 );
360 int yyy = yy+3; 361 int yyy = yy+3;
361 if ( tempTodo->isCompleted() ) 362 if ( tempTodo->isCompleted() )
362 paint->drawPixmap ( xx, yyy, completedPxmp ); 363 paint->drawPixmap ( xx, yyy, completedPxmp );
363 else { 364 else {
364 paint->drawPixmap ( xx, yyy, overduePxmp ); 365 paint->drawPixmap ( xx, yyy, overduePxmp );
365 366
366 } 367 }
367 } 368 }
368 bool addIcon = false; 369 bool addIcon = false;
369 if ( ! small || w > 3 * h || h > 3* w ) 370 if ( ! small || w > 3 * h || h > 3* w )
370 addIcon = updateIcons( paint, horLayout ); 371 addIcon = updateIcons( paint, horLayout );
371 372
372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 373 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 374 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
374 if ( ! small ) { 375 if ( ! small ) {
375 x += 3; yy += 3;w -= 6; h-= 5; 376 x += 3; yy += 3;w -= 6; h-= 5;
376 } else { 377 } else {
377 x += 2; yy += 1;w -= 4; h-= 4; 378 x += 2; yy += 1;w -= 4; h-= 4;
378 if ( nfh < 6.01 ) { 379 if ( nfh < 6.01 ) {
379 yy -= 2; 380 yy -= 2;
380 h += 4; 381 h += 4;
381 } 382 }
382 else 383 else
383 if ( nfh < h -2 ) 384 if ( nfh < h -2 )
384 ++yy; 385 ++yy;
385 } 386 }
386 int align; 387 int align;
387#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
388 align = ( AlignLeft|WordBreak|AlignTop); 389 align = ( AlignLeft|WordBreak|AlignTop);
389#else 390#else
390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 391 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
391#endif 392#endif
392 if ( addIcon ) { 393 if ( addIcon ) {
393 if ( ! horLayout ) { 394 if ( ! horLayout ) {
394 x += AGENDA_ICON_SIZE+3; 395 x += AGENDA_ICON_SIZE+3;
395 w -= (AGENDA_ICON_SIZE+3); 396 w -= (AGENDA_ICON_SIZE+3);
396 } 397 }
397 else { 398 else {
398 yy+= AGENDA_ICON_SIZE+2; 399 yy+= AGENDA_ICON_SIZE+2;
399 h -=(AGENDA_ICON_SIZE+3); 400 h -=(AGENDA_ICON_SIZE+3);
400 } 401 }
401 } 402 }
402 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 403 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
403 if ( colsum < 250 ) 404 if ( colsum < 250 )
404 paint->setPen ( white); 405 paint->setPen ( white);
405 if ( x < 0 ) { 406 if ( x < 0 ) {
406 w = w+x-3; 407 w = w+x-3;
407 x = 3; 408 x = 3;
408 if ( w > parentWidget()->width() ){ 409 if ( w > parentWidget()->width() ){
409 w = parentWidget()->width() - 6; 410 w = parentWidget()->width() - 6;
410#ifndef DESKTOP_VERSION 411#ifndef DESKTOP_VERSION
411 align = ( AlignHCenter|WordBreak|AlignTop); 412 align = ( AlignHCenter|WordBreak|AlignTop);
412#else 413#else
413 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 414 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
414#endif 415#endif
415 416
416 } 417 }
417 } 418 }
418 QRect dr; 419 QRect dr;
419 if ( w + x > parentWidget()->width() ) 420 if ( w + x > parentWidget()->width() )
420 w = parentWidget()->width()-x; 421 w = parentWidget()->width()-x;
421 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 422 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
422 //qDebug("%d %d %d %d ", x, yy, w, h ); 423 //qDebug("%d %d %d %d ", x, yy, w, h );
423 if ( mIncidence->cancelled() ){ 424 if ( mIncidence->cancelled() ){
424 425
425 426
426 small = ( height() < 20 ); 427 small = ( height() < 20 );
427 428
428 if ( ! small ) { 429 if ( ! small ) {
429 QFontMetrics fm ( paint->font() ); 430 QFontMetrics fm ( paint->font() );
430 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 431 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
431 } 432 }
432 433
433 } 434 }
434 pa.end(); 435 pa.end();
435 436
436} 437}
437void KOAgendaItem::resizePixmap( int w , int h ) 438void KOAgendaItem::resizePixmap( int w , int h )
438{ 439{
439 paintPix()->resize( w, h ); 440 paintPix()->resize( w, h );
440 paintPixSel()->resize( w, h ); 441 paintPixSel()->resize( w, h );
441 442
442} 443}
443QPixmap * KOAgendaItem::paintPix() 444QPixmap * KOAgendaItem::paintPix()
444{ 445{
445 static QPixmap* mPaintPix = 0; 446 static QPixmap* mPaintPix = 0;
446 if ( ! mPaintPix ) { 447 if ( ! mPaintPix ) {
447 int w = QApplication::desktop()->width(); 448 int w = QApplication::desktop()->width();
448 int h = QApplication::desktop()->height(); 449 int h = QApplication::desktop()->height();
449 mPaintPix = new QPixmap(w,h); 450 mPaintPix = new QPixmap(w,h);
450 } 451 }
451 return mPaintPix ; 452 return mPaintPix ;
452} 453}
453QPixmap * KOAgendaItem::paintPixAllday() 454QPixmap * KOAgendaItem::paintPixAllday()
454{ 455{
455 static QPixmap* mPaintPixA = 0; 456 static QPixmap* mPaintPixA = 0;
456 if ( ! mPaintPixA ) { 457 if ( ! mPaintPixA ) {
457 int w = QApplication::desktop()->width(); 458 int w = QApplication::desktop()->width();
458 int h = QApplication::desktop()->height()/3; 459 int h = QApplication::desktop()->height()/3;
459 mPaintPixA = new QPixmap(w,h); 460 mPaintPixA = new QPixmap(w,h);
460 } 461 }
461 return mPaintPixA ; 462 return mPaintPixA ;
462} 463}
463QPixmap * KOAgendaItem::paintPixSel() 464QPixmap * KOAgendaItem::paintPixSel()
464{ 465{
465 static QPixmap* mPaintPixSel = 0; 466 static QPixmap* mPaintPixSel = 0;
466 if ( ! mPaintPixSel ) { 467 if ( ! mPaintPixSel ) {
467 int w = QApplication::desktop()->width(); 468 int w = QApplication::desktop()->width();
468 int h = QApplication::desktop()->height(); 469 int h = QApplication::desktop()->height();
469 mPaintPixSel = new QPixmap(w,h); 470 mPaintPixSel = new QPixmap(w,h);
470 } 471 }
471 return mPaintPixSel ; 472 return mPaintPixSel ;
472} 473}
473void KOAgendaItem::paintEvent ( QPaintEvent *e ) 474void KOAgendaItem::paintEvent ( QPaintEvent *e )
474{ 475{
475 476
476 if ( globalFlagBlockAgendaItemPaint ) 477 if ( globalFlagBlockAgendaItemPaint )
477 return; 478 return;
478 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 479 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
479 return; 480 return;
480 int yy; 481 int yy;
481 if ( mAllDay ) 482 if ( mAllDay )
482 yy = y(); 483 yy = y();
483 else 484 else
484 yy = mCellYTop * ( height() / cellHeight() ); 485 yy = mCellYTop * ( height() / cellHeight() );
485 int xx = x(); 486 int xx = x();
486 487
487 if ( xPaintCoord != xx || yPaintCoord != yy || 488 if ( xPaintCoord != xx || yPaintCoord != yy ||
488 wPaintCoord != width() || hPaintCoord != height()) { 489 wPaintCoord != width() || hPaintCoord != height()) {
489 xPaintCoord= xx; 490 xPaintCoord= xx;
490 yPaintCoord = yy; 491 yPaintCoord = yy;
491 wPaintCoord = width(); 492 wPaintCoord = width();
492 hPaintCoord = height(); 493 hPaintCoord = height();
493 globalFlagBlockAgendaItemUpdate = 0; 494 globalFlagBlockAgendaItemUpdate = 0;
494 paintMe( mSelected ); 495 paintMe( mSelected );
495 //qDebug("calling paintMe "); 496 //qDebug("calling paintMe ");
496 globalFlagBlockAgendaItemUpdate = 1; 497 globalFlagBlockAgendaItemUpdate = 1;
497 } 498 }
498 int rx, ry, rw, rh; 499 int rx, ry, rw, rh;
499 rx = e->rect().x(); 500 rx = e->rect().x();
500 ry = e->rect().y(); 501 ry = e->rect().y();
501 rw = e->rect().width(); 502 rw = e->rect().width();
502 rh = e->rect().height(); 503 rh = e->rect().height();
503 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 504 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
504 505
505 QPixmap* paintFrom ; 506 QPixmap* paintFrom ;
506 if ( mSelected ) { 507 if ( mSelected ) {
507 paintFrom = paintPixSel(); 508 paintFrom = paintPixSel();
508 } else { 509 } else {
509 if ( mAllDay ) 510 if ( mAllDay )
510 paintFrom = paintPixAllday(); 511 paintFrom = paintPixAllday();
511 else 512 else
512 paintFrom = paintPix(); 513 paintFrom = paintPix();
513 } 514 }
514 xx += rx; 515 xx += rx;
515 516
516 if ( xx < 0 ) { 517 if ( xx < 0 ) {
517 rw = rw + xx; 518 rw = rw + xx;
518 rx -= xx; 519 rx -= xx;
519 xx = 0; 520 xx = 0;
520 if ( rw <= 1 ) { 521 if ( rw <= 1 ) {
521 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 522 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
522 return; 523 return;
523 } 524 }
524 } 525 }
525 if ( paintFrom->width() < xx+rw ) { 526 if ( paintFrom->width() < xx+rw ) {
526 rw = paintFrom->width() - xx; 527 rw = paintFrom->width() - xx;
527 if ( rw <= 1 ) { 528 if ( rw <= 1 ) {
528 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 529 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
529 return; 530 return;
530 } 531 }
531 } 532 }
532 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 533 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
533 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 534 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
534} 535}
535void KOAgendaItem::computeText() 536void KOAgendaItem::computeText()
536{ 537{
537 mDisplayedText = mIncidence->summary(); 538 mDisplayedText = mIncidence->summary();
538 if ( (mIncidence->type() == "Todo") ) { 539 if ( (mIncidence->type() == "Todo") ) {
539 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 540 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
540 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 541 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
541 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 542 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
542 else if ( !(mIncidence->doesFloat())) 543 else if ( !(mIncidence->doesFloat()))
543 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 544 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
544 } 545 }
545 } else { 546 } else {
546 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 547 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
547 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 548 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
548 549
549 if ( mAllDay ) { 550 if ( mAllDay ) {
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index f54660f..9df76e7 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,517 +1,518 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qtimer.h>
32#include <qfile.h> 33#include <qfile.h>
33 34
34 35
35#include <kglobal.h> 36#include <kglobal.h>
36#include <kdebug.h> 37#include <kdebug.h>
37#include <klocale.h> 38#include <klocale.h>
38#include <kiconloader.h> 39#include <kiconloader.h>
39#include <kmessagebox.h> 40#include <kmessagebox.h>
40#include <kfiledialog.h> 41#include <kfiledialog.h>
41#include <kstandarddirs.h> 42#include <kstandarddirs.h>
42 43
43#include <libkcal/todo.h> 44#include <libkcal/todo.h>
44#include <libkcal/event.h> 45#include <libkcal/event.h>
45#include <libkdepim/categoryselectdialog.h> 46#include <libkdepim/categoryselectdialog.h>
46#include <libkdepim/kdateedit.h> 47#include <libkdepim/kdateedit.h>
47 48
48#include "koprefs.h" 49#include "koprefs.h"
49#include "koglobals.h" 50#include "koglobals.h"
50 51
51#include "koeditorgeneral.h" 52#include "koeditorgeneral.h"
52#include "kolocationbox.h" 53#include "kolocationbox.h"
53#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
55#else 56#else
56#include <qapplication.h> 57#include <qapplication.h>
57#endif 58#endif
58 59
59KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
60 QObject( parent, name) 61 QObject( parent, name)
61{ 62{
62 mNextFocus = 0; 63 mNextFocus = 0;
63} 64}
64 65
65KOEditorGeneral::~KOEditorGeneral() 66KOEditorGeneral::~KOEditorGeneral()
66{ 67{
67} 68}
68 69
69void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
70{ 71{
71 QGridLayout *headerLayout = new QGridLayout(topLayout); 72 QGridLayout *headerLayout = new QGridLayout(topLayout);
72 73
73#if 0 74#if 0
74 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 75 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
75 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
76#endif 77#endif
77 78
78 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
79 headerLayout->addWidget(summaryLabel,1,0); 80 headerLayout->addWidget(summaryLabel,1,0);
80 81
81 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
82 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
83 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
84 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
85 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
86 if ( QApplication::desktop()->width() > 320 ) 87 if ( QApplication::desktop()->width() > 320 )
87 mSummaryEdit->setMaximumHeight( hei +6 ); 88 mSummaryEdit->setMaximumHeight( hei +6 );
88 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 89 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
89 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 90 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
90 // mSummaryEdit = new QLineEdit(parent); 91 // mSummaryEdit = new QLineEdit(parent);
91 headerLayout->addWidget(mSummaryEdit,1,1); 92 headerLayout->addWidget(mSummaryEdit,1,1);
92 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
93 94
94 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
95 headerLayout->addWidget(locationLabel,2,0); 96 headerLayout->addWidget(locationLabel,2,0);
96 97
97 mLocationEdit = new KOLocationBox(TRUE,parent,10); 98 mLocationEdit = new KOLocationBox(TRUE,parent,10);
98 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 99 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
99 if ( QApplication::desktop()->width() > 320 ) 100 if ( QApplication::desktop()->width() > 320 )
100 mLocationEdit->setMaximumHeight( hei + 6); 101 mLocationEdit->setMaximumHeight( hei + 6);
101 102
102 // mLocationEdit = new QLineEdit(parent); 103 // mLocationEdit = new QLineEdit(parent);
103 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 104 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
104 headerLayout->addWidget(mLocationEdit,2,1); 105 headerLayout->addWidget(mLocationEdit,2,1);
105 headerLayout->setColStretch( 1, 10); 106 headerLayout->setColStretch( 1, 10);
106} 107}
107void KOEditorGeneral::setFocusOn( int i ) 108void KOEditorGeneral::setFocusOn( int i )
108{ 109{
109 mNextFocus = i; 110 mNextFocus = i;
110 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 111 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
111} 112}
112void KOEditorGeneral::slotSetFocusOn() 113void KOEditorGeneral::slotSetFocusOn()
113{ 114{
114 mNextFocus; 115 mNextFocus;
115 if ( mNextFocus == 1 ) { 116 if ( mNextFocus == 1 ) {
116 mDescriptionEdit->setFocus(); 117 mDescriptionEdit->setFocus();
117 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 118 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
118 } 119 }
119 if ( mNextFocus == 2 ) { 120 if ( mNextFocus == 2 ) {
120 mSummaryEdit->setFocus(); 121 mSummaryEdit->setFocus();
121 } 122 }
122} 123}
123void KOEditorGeneral::editCategories() 124void KOEditorGeneral::editCategories()
124{ 125{
125 // qDebug("KOEditorGeneral::editCategories() "); 126 // qDebug("KOEditorGeneral::editCategories() ");
126 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 127 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
127 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 128 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
128 //KOGlobals::fitDialogToScreen( csd ); 129 //KOGlobals::fitDialogToScreen( csd );
129 csd->setColorEnabled(); 130 csd->setColorEnabled();
130 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 131 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
131 csd->exec(); 132 csd->exec();
132 delete csd; 133 delete csd;
133} 134}
134void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 135void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
135{ 136{
136 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 137 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
137 138
138 mCategoriesButton = new QPushButton(parent); 139 mCategoriesButton = new QPushButton(parent);
139 mCategoriesButton->setText(i18n("Categories...")); 140 mCategoriesButton->setText(i18n("Categories..."));
140 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 141 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
141 categoriesLayout->addWidget(mCategoriesButton); 142 categoriesLayout->addWidget(mCategoriesButton);
142 143
143 mCategoriesLabel = new QLabel(parent); 144 mCategoriesLabel = new QLabel(parent);
144 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 145 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
145 categoriesLayout->addWidget(mCategoriesLabel,1); 146 categoriesLayout->addWidget(mCategoriesLabel,1);
146} 147}
147 148
148void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 149void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
149{ 150{
150 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 151 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
151 152
152 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 153 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
153 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 154 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
154 secrecyLayout->addWidget(mCancelBox); 155 secrecyLayout->addWidget(mCancelBox);
155 secrecyLayout->addWidget(secrecyLabel); 156 secrecyLayout->addWidget(secrecyLabel);
156 157
157 mSecrecyCombo = new QComboBox(parent); 158 mSecrecyCombo = new QComboBox(parent);
158 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 159 mSecrecyCombo->insertStringList(Incidence::secrecyList());
159 secrecyLayout->addWidget(mSecrecyCombo); 160 secrecyLayout->addWidget(mSecrecyCombo);
160} 161}
161 162
162void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 163void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
163{ 164{
164 mDescriptionEdit = new KTextEdit(parent); 165 mDescriptionEdit = new KTextEdit(parent);
165 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 166 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
166 mDescriptionEdit->append(""); 167 mDescriptionEdit->append("");
167 mDescriptionEdit->setReadOnly(false); 168 mDescriptionEdit->setReadOnly(false);
168 mDescriptionEdit->setOverwriteMode(false); 169 mDescriptionEdit->setOverwriteMode(false);
169 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 170 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
170 topLayout->addWidget(mDescriptionEdit); 171 topLayout->addWidget(mDescriptionEdit);
171#ifndef DESKTOP_VERSION 172#ifndef DESKTOP_VERSION
172 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 173 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
173#endif 174#endif
174 175
175} 176}
176 177
177void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 178void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
178{ 179{
179 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 180 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
180 181
181 //mAlarmBell = new QLabel(parent); 182 //mAlarmBell = new QLabel(parent);
182 //mAlarmBell->setPixmap(SmallIcon("bell")); 183 //mAlarmBell->setPixmap(SmallIcon("bell"));
183 //alarmLayout->addWidget(mAlarmBell); 184 //alarmLayout->addWidget(mAlarmBell);
184 if ( QApplication::desktop()->width() < 320 ) 185 if ( QApplication::desktop()->width() < 320 )
185 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 186 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
186 else 187 else
187 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 188 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
188 189
189 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 190 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
190 alarmLayout->addWidget(mAlarmButton); 191 alarmLayout->addWidget(mAlarmButton);
191 192
192 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 193 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
193 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 194 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
194 alarmLayout->addWidget(mAlarmTimeEdit); 195 alarmLayout->addWidget(mAlarmTimeEdit);
195 mAlarmIncrCombo = new QComboBox(false, parent); 196 mAlarmIncrCombo = new QComboBox(false, parent);
196 if ( QApplication::desktop()->width() < 320 ) { 197 if ( QApplication::desktop()->width() < 320 ) {
197 mAlarmIncrCombo->insertItem(i18n("min")); 198 mAlarmIncrCombo->insertItem(i18n("min"));
198 mAlarmIncrCombo->insertItem(i18n("hou")); 199 mAlarmIncrCombo->insertItem(i18n("hou"));
199 mAlarmIncrCombo->insertItem(i18n("day")); 200 mAlarmIncrCombo->insertItem(i18n("day"));
200 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 201 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
201 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 202 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
202 } else { 203 } else {
203 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 204 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
204 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 205 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
205 mAlarmIncrCombo->insertItem(i18n("day(s)")); 206 mAlarmIncrCombo->insertItem(i18n("day(s)"));
206 } 207 }
207 208
208 // mAlarmIncrCombo->setMinimumHeight(20); 209 // mAlarmIncrCombo->setMinimumHeight(20);
209 alarmLayout->addWidget(mAlarmIncrCombo); 210 alarmLayout->addWidget(mAlarmIncrCombo);
210 mAlarmSoundButton = new QPushButton(parent); 211 mAlarmSoundButton = new QPushButton(parent);
211 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 212 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
212 mAlarmSoundButton->setToggleButton(true); 213 mAlarmSoundButton->setToggleButton(true);
213 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 214 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
214 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 215 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
215 alarmLayout->addWidget(mAlarmSoundButton); 216 alarmLayout->addWidget(mAlarmSoundButton);
216 217
217 mAlarmProgramButton = new QPushButton(parent); 218 mAlarmProgramButton = new QPushButton(parent);
218 mAlarmProgramButton->setPixmap(SmallIcon("run")); 219 mAlarmProgramButton->setPixmap(SmallIcon("run"));
219 mAlarmProgramButton->setToggleButton(true); 220 mAlarmProgramButton->setToggleButton(true);
220 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 221 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
221 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 222 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
222 alarmLayout->addWidget(mAlarmProgramButton); 223 alarmLayout->addWidget(mAlarmProgramButton);
223 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 224 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
224 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 225 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
225 // if ( KOPrefs::instance()->mCompactDialogs ) { 226 // if ( KOPrefs::instance()->mCompactDialogs ) {
226 // mAlarmSoundButton->hide(); 227 // mAlarmSoundButton->hide();
227 // mAlarmProgramButton->hide(); 228 // mAlarmProgramButton->hide();
228 // } 229 // }
229} 230}
230 231
231void KOEditorGeneral::pickAlarmSound() 232void KOEditorGeneral::pickAlarmSound()
232{ 233{
233 234
234 qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 235 qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
235 236
236 bool oldState = mAlarmSoundButton->isOn(); 237 bool oldState = mAlarmSoundButton->isOn();
237 238
238 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 239 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
239 i18n("*.wav|Wav Files"), 0)); 240 i18n("*.wav|Wav Files"), 0));
240 if (!fileName.isEmpty()) { 241 if (!fileName.isEmpty()) {
241 mAlarmSound = fileName; 242 mAlarmSound = fileName;
242 QToolTip::remove(mAlarmSoundButton); 243 QToolTip::remove(mAlarmSoundButton);
243 QString dispStr = i18n("Playing '%1'").arg(fileName); 244 QString dispStr = i18n("Playing '%1'").arg(fileName);
244 QToolTip::add(mAlarmSoundButton, dispStr); 245 QToolTip::add(mAlarmSoundButton, dispStr);
245 mAlarmProgramButton->setOn(false); 246 mAlarmProgramButton->setOn(false);
246 mAlarmSoundButton->setOn(true); 247 mAlarmSoundButton->setOn(true);
247 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 248 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
248 } else { 249 } else {
249 mAlarmProgramButton->setOn(oldState); 250 mAlarmProgramButton->setOn(oldState);
250 mAlarmSoundButton->setOn(!oldState); 251 mAlarmSoundButton->setOn(!oldState);
251 252
252 253
253 } 254 }
254 255
255 if (mAlarmProgramButton->isOn()) 256 if (mAlarmProgramButton->isOn())
256 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 257 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
257 if ( mAlarmSoundButton->isOn()) 258 if ( mAlarmSoundButton->isOn())
258 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 259 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
259 260
260} 261}
261 262
262void KOEditorGeneral::pickAlarmProgram() 263void KOEditorGeneral::pickAlarmProgram()
263{ 264{
264 bool oldState = mAlarmProgramButton->isOn(); 265 bool oldState = mAlarmProgramButton->isOn();
265 266
266 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 267 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
267 if (!fileName.isEmpty()) { 268 if (!fileName.isEmpty()) {
268 mAlarmProgram = fileName; 269 mAlarmProgram = fileName;
269 QToolTip::remove(mAlarmProgramButton); 270 QToolTip::remove(mAlarmProgramButton);
270 QString dispStr = i18n("Running '%1'").arg(fileName); 271 QString dispStr = i18n("Running '%1'").arg(fileName);
271 QToolTip::add(mAlarmProgramButton, dispStr); 272 QToolTip::add(mAlarmProgramButton, dispStr);
272 mAlarmSoundButton->setOn(false); 273 mAlarmSoundButton->setOn(false);
273 mAlarmProgramButton->setOn(true); 274 mAlarmProgramButton->setOn(true);
274 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 275 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
275 } else { 276 } else {
276 mAlarmProgramButton->setOn(!oldState); 277 mAlarmProgramButton->setOn(!oldState);
277 mAlarmSoundButton->setOn(oldState); 278 mAlarmSoundButton->setOn(oldState);
278 } 279 }
279 280
280 if (mAlarmProgramButton->isOn()) 281 if (mAlarmProgramButton->isOn())
281 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 282 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
282 if ( mAlarmSoundButton->isOn()) 283 if ( mAlarmSoundButton->isOn())
283 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 284 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
284 285
285} 286}
286 287
287 288
288QString KOEditorGeneral::getFittingPath( const QString s ) 289QString KOEditorGeneral::getFittingPath( const QString s )
289{ 290{
290 int maxlen = 50; 291 int maxlen = 50;
291 if ( QApplication::desktop()->width() < 640 ) { 292 if ( QApplication::desktop()->width() < 640 ) {
292 if ( QApplication::desktop()->width() < 320 ) 293 if ( QApplication::desktop()->width() < 320 )
293 maxlen = 22; 294 maxlen = 22;
294 else 295 else
295 maxlen = 35; 296 maxlen = 35;
296 } 297 }
297 if ( s.length() > maxlen ) { 298 if ( s.length() > maxlen ) {
298 return "..."+s.right(maxlen -3); 299 return "..."+s.right(maxlen -3);
299 } 300 }
300 return s; 301 return s;
301} 302}
302 303
303void KOEditorGeneral::enableAlarmEdit(bool enable) 304void KOEditorGeneral::enableAlarmEdit(bool enable)
304{ 305{
305 if ( enable ) { 306 if ( enable ) {
306 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 307 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
307 mAlarmSoundButton->setOn( true ); 308 mAlarmSoundButton->setOn( true );
308 if ( mAlarmSound.isEmpty() ) 309 if ( mAlarmSound.isEmpty() )
309 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 310 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
310 else { 311 else {
311 if ( ! QFile::exists( mAlarmSound ) ) 312 if ( ! QFile::exists( mAlarmSound ) )
312 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 313 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
313 } 314 }
314 } 315 }
315 } 316 }
316 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 317 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
317 mAlarmTimeEdit->setEnabled(enable); 318 mAlarmTimeEdit->setEnabled(enable);
318 mAlarmSoundButton->setEnabled(enable); 319 mAlarmSoundButton->setEnabled(enable);
319 mAlarmProgramButton->setEnabled(enable); 320 mAlarmProgramButton->setEnabled(enable);
320 mAlarmIncrCombo->setEnabled(enable); 321 mAlarmIncrCombo->setEnabled(enable);
321} 322}
322 323
323void KOEditorGeneral::disableAlarmEdit(bool disable) 324void KOEditorGeneral::disableAlarmEdit(bool disable)
324{ 325{
325 enableAlarmEdit( !disable ); 326 enableAlarmEdit( !disable );
326} 327}
327 328
328void KOEditorGeneral::enableAlarm( bool enable ) 329void KOEditorGeneral::enableAlarm( bool enable )
329{ 330{
330 enableAlarmEdit( enable ); 331 enableAlarmEdit( enable );
331} 332}
332 333
333void KOEditorGeneral::alarmDisable(bool disable) 334void KOEditorGeneral::alarmDisable(bool disable)
334{ 335{
335 if (!disable) { 336 if (!disable) {
336 //mAlarmBell->setEnabled(true); 337 //mAlarmBell->setEnabled(true);
337 mAlarmButton->setEnabled(true); 338 mAlarmButton->setEnabled(true);
338 } else { 339 } else {
339 //mAlarmBell->setEnabled(false); 340 //mAlarmBell->setEnabled(false);
340 mAlarmButton->setEnabled(false); 341 mAlarmButton->setEnabled(false);
341 mAlarmButton->setChecked(false); 342 mAlarmButton->setChecked(false);
342 mAlarmTimeEdit->setEnabled(false); 343 mAlarmTimeEdit->setEnabled(false);
343 mAlarmSoundButton->setEnabled(false); 344 mAlarmSoundButton->setEnabled(false);
344 mAlarmProgramButton->setEnabled(false); 345 mAlarmProgramButton->setEnabled(false);
345 mAlarmIncrCombo->setEnabled(false); 346 mAlarmIncrCombo->setEnabled(false);
346 } 347 }
347} 348}
348 349
349void KOEditorGeneral::setCategories(const QString &str) 350void KOEditorGeneral::setCategories(const QString &str)
350{ 351{
351 mCategoriesLabel->setText(str); 352 mCategoriesLabel->setText(str);
352} 353}
353 354
354void KOEditorGeneral::setDefaults(bool allDay) 355void KOEditorGeneral::setDefaults(bool allDay)
355{ 356{
356#if 0 357#if 0
357 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 358 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
358#endif 359#endif
359 360
360 mAlarmMessage = i18n("Edit new item"); 361 mAlarmMessage = i18n("Edit new item");
361 enableAlarmEdit( !allDay ); 362 enableAlarmEdit( !allDay );
362 363
363 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 364 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
364 int alarmTime; 365 int alarmTime;
365 int a[] = { 1,5,10,15,30,60,180, 1440 }; 366 int a[] = { 1,5,10,15,30,60,180, 1440 };
366 int index = KOPrefs::instance()->mAlarmTime; 367 int index = KOPrefs::instance()->mAlarmTime;
367 if (index < 0 || index > 7) { 368 if (index < 0 || index > 7) {
368 alarmTime = 15; 369 alarmTime = 15;
369 } else { 370 } else {
370 alarmTime = a[index]; 371 alarmTime = a[index];
371 } 372 }
372 mAlarmButton ->setChecked( false ); 373 mAlarmButton ->setChecked( false );
373 mAlarmTimeEdit->setValue(alarmTime); 374 mAlarmTimeEdit->setValue(alarmTime);
374 mAlarmIncrCombo->setCurrentItem(0); 375 mAlarmIncrCombo->setCurrentItem(0);
375 enableAlarmEdit( false ); 376 enableAlarmEdit( false );
376 //alarmDisable (false); 377 //alarmDisable (false);
377 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 378 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
378 mCancelBox->setChecked( false ); 379 mCancelBox->setChecked( false );
379 mSummaryEdit->setEditText(""); 380 mSummaryEdit->setEditText("");
380 mLocationEdit->setEditText(""); 381 mLocationEdit->setEditText("");
381 mDescriptionEdit->setText(""); 382 mDescriptionEdit->setText("");
382 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 383 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
383 setCategories(""); 384 setCategories("");
384} 385}
385void KOEditorGeneral::setSecrecy( int num ) 386void KOEditorGeneral::setSecrecy( int num )
386{ 387{
387 mSecrecyCombo->setCurrentItem(num); 388 mSecrecyCombo->setCurrentItem(num);
388} 389}
389void KOEditorGeneral::readIncidence(Incidence *event) 390void KOEditorGeneral::readIncidence(Incidence *event)
390{ 391{
391 392
392 mAlarmMessage = event->summary(); 393 mAlarmMessage = event->summary();
393 if ( ! event->location().isEmpty() ) 394 if ( ! event->location().isEmpty() )
394 mAlarmMessage += " ("+event->location()+")"; 395 mAlarmMessage += " ("+event->location()+")";
395 mAlarmIncrCombo->setCurrentItem(0); 396 mAlarmIncrCombo->setCurrentItem(0);
396 mSummaryEdit->setEditText(event->summary()); 397 mSummaryEdit->setEditText(event->summary());
397 mLocationEdit->setEditText(event->location()); 398 mLocationEdit->setEditText(event->location());
398 mDescriptionEdit->setText(event->description()); 399 mDescriptionEdit->setText(event->description());
399 400
400#if 0 401#if 0
401 // organizer information 402 // organizer information
402 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 403 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
403#endif 404#endif
404 405
405 enableAlarmEdit( event->isAlarmEnabled() ); 406 enableAlarmEdit( event->isAlarmEnabled() );
406 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 407 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
407 if(!event->isAlarmEnabled()) { 408 if(!event->isAlarmEnabled()) {
408 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 409 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
409 int alarmTime; 410 int alarmTime;
410 int a[] = { 1,5,10,15,30,60,180, 1440 }; 411 int a[] = { 1,5,10,15,30,60,180, 1440 };
411 int index = KOPrefs::instance()->mAlarmTime; 412 int index = KOPrefs::instance()->mAlarmTime;
412 if (index < 0 || index > 7) { 413 if (index < 0 || index > 7) {
413 alarmTime = 15; 414 alarmTime = 15;
414 } else { 415 } else {
415 alarmTime = a[index]; 416 alarmTime = a[index];
416 } 417 }
417 mAlarmTimeEdit->setValue(alarmTime); 418 mAlarmTimeEdit->setValue(alarmTime);
418 } 419 }
419 mAlarmButton->setChecked( event->isAlarmEnabled() ); 420 mAlarmButton->setChecked( event->isAlarmEnabled() );
420 mSecrecyCombo->setCurrentItem(event->secrecy()); 421 mSecrecyCombo->setCurrentItem(event->secrecy());
421 mCancelBox->setChecked( event->cancelled() ); 422 mCancelBox->setChecked( event->cancelled() );
422 mAlarmProgramButton->setOn(false); 423 mAlarmProgramButton->setOn(false);
423 mAlarmSoundButton->setOn(false); 424 mAlarmSoundButton->setOn(false);
424 425
425 // set up alarm stuff 426 // set up alarm stuff
426 QPtrList<Alarm> alarms = event->alarms(); 427 QPtrList<Alarm> alarms = event->alarms();
427 Alarm* alarm; 428 Alarm* alarm;
428 mAlarmIncrCombo->setCurrentItem(0); 429 mAlarmIncrCombo->setCurrentItem(0);
429 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 430 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
430 int offset; 431 int offset;
431 if ( alarm->hasTime() ) { 432 if ( alarm->hasTime() ) {
432 QDateTime t = alarm->time(); 433 QDateTime t = alarm->time();
433 offset = event->dtStart().secsTo( t ); 434 offset = event->dtStart().secsTo( t );
434 } else { 435 } else {
435 offset = alarm->startOffset().asSeconds(); 436 offset = alarm->startOffset().asSeconds();
436 } 437 }
437 if ( offset != 0 ) { 438 if ( offset != 0 ) {
438 offset = offset / -60; // make minutes 439 offset = offset / -60; // make minutes
439 if (offset % 60 == 0) { // divides evenly into hours? 440 if (offset % 60 == 0) { // divides evenly into hours?
440 offset = offset / 60; 441 offset = offset / 60;
441 mAlarmIncrCombo->setCurrentItem(1); 442 mAlarmIncrCombo->setCurrentItem(1);
442 if (offset % 24 == 0) { // divides evenly into days? 443 if (offset % 24 == 0) { // divides evenly into days?
443 offset = offset / 24; 444 offset = offset / 24;
444 mAlarmIncrCombo->setCurrentItem(2); 445 mAlarmIncrCombo->setCurrentItem(2);
445 } 446 }
446 } 447 }
447 } 448 }
448 mAlarmTimeEdit->setValue( offset ); 449 mAlarmTimeEdit->setValue( offset );
449 if (alarm->type() == Alarm::Procedure) { 450 if (alarm->type() == Alarm::Procedure) {
450 451
451 mAlarmProgram = alarm->programFile(); 452 mAlarmProgram = alarm->programFile();
452 mAlarmProgramButton->setOn(true); 453 mAlarmProgramButton->setOn(true);
453 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 454 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
454 QToolTip::add(mAlarmProgramButton, dispStr); 455 QToolTip::add(mAlarmProgramButton, dispStr);
455 } 456 }
456 else if (alarm->type() == Alarm::Audio) { 457 else if (alarm->type() == Alarm::Audio) {
457 mAlarmSound = alarm->audioFile(); 458 mAlarmSound = alarm->audioFile();
458 if ( ! QFile::exists( mAlarmSound ) ) 459 if ( ! QFile::exists( mAlarmSound ) )
459 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 460 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
460 mAlarmSoundButton->setOn(true); 461 mAlarmSoundButton->setOn(true);
461 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 462 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
462 QToolTip::add(mAlarmSoundButton, dispStr); 463 QToolTip::add(mAlarmSoundButton, dispStr);
463 } 464 }
464 mAlarmButton->setChecked(alarm->enabled()); 465 mAlarmButton->setChecked(alarm->enabled());
465 enableAlarmEdit( alarm->enabled() ); 466 enableAlarmEdit( alarm->enabled() );
466 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 467 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
467 // TODO: Deal with multiple alarms 468 // TODO: Deal with multiple alarms
468 break; // For now, stop after the first alarm 469 break; // For now, stop after the first alarm
469 } 470 }
470 471
471 setCategories(event->categoriesStr()); 472 setCategories(event->categoriesStr());
472} 473}
473 474
474void KOEditorGeneral::writeIncidence(Incidence *event) 475void KOEditorGeneral::writeIncidence(Incidence *event)
475{ 476{
476 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 477 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
477 mLocationEdit->save(KOLocationBox::LOCATION); 478 mLocationEdit->save(KOLocationBox::LOCATION);
478 event->setSummary(mSummaryEdit->currentText()); 479 event->setSummary(mSummaryEdit->currentText());
479 event->setLocation(mLocationEdit->currentText()); 480 event->setLocation(mLocationEdit->currentText());
480 event->setDescription(mDescriptionEdit->text()); 481 event->setDescription(mDescriptionEdit->text());
481 event->setCategories(mCategoriesLabel->text()); 482 event->setCategories(mCategoriesLabel->text());
482 event->setSecrecy(mSecrecyCombo->currentItem()); 483 event->setSecrecy(mSecrecyCombo->currentItem());
483 event->setCancelled(mCancelBox->isChecked() );; 484 event->setCancelled(mCancelBox->isChecked() );;
484 // alarm stuff 485 // alarm stuff
485 if (mAlarmButton->isChecked()) { 486 if (mAlarmButton->isChecked()) {
486 if (event->alarms().count() == 0) 487 if (event->alarms().count() == 0)
487 event->newAlarm(); 488 event->newAlarm();
488 QPtrList<Alarm> alarms = event->alarms(); 489 QPtrList<Alarm> alarms = event->alarms();
489 Alarm *alarm; 490 Alarm *alarm;
490 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 491 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
491 alarm->setEnabled(true); 492 alarm->setEnabled(true);
492 int j = mAlarmTimeEdit->value()* -60; 493 int j = mAlarmTimeEdit->value()* -60;
493 if (mAlarmIncrCombo->currentItem() == 1) 494 if (mAlarmIncrCombo->currentItem() == 1)
494 j = j * 60; 495 j = j * 60;
495 else if (mAlarmIncrCombo->currentItem() == 2) 496 else if (mAlarmIncrCombo->currentItem() == 2)
496 j = j * (60 * 24); 497 j = j * (60 * 24);
497 alarm->setStartOffset( j ); 498 alarm->setStartOffset( j );
498 499
499 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 500 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
500 alarm->setProcedureAlarm(mAlarmProgram); 501 alarm->setProcedureAlarm(mAlarmProgram);
501 } 502 }
502 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 503 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
503 alarm->setAudioAlarm(mAlarmSound); 504 alarm->setAudioAlarm(mAlarmSound);
504 else 505 else
505 alarm->setType(Alarm::Invalid); 506 alarm->setType(Alarm::Invalid);
506 //alarm->setAudioAlarm("default"); 507 //alarm->setAudioAlarm("default");
507 // TODO: Deal with multiple alarms 508 // TODO: Deal with multiple alarms
508 break; // For now, stop after the first alarm 509 break; // For now, stop after the first alarm
509 } 510 }
510 } else { 511 } else {
511 Alarm* alarm = event->alarms().first(); 512 Alarm* alarm = event->alarms().first();
512 if ( alarm ) { 513 if ( alarm ) {
513 alarm->setEnabled(false); 514 alarm->setEnabled(false);
514 alarm->setType(Alarm::Invalid); 515 alarm->setType(Alarm::Invalid);
515 } 516 }
516 } 517 }
517} 518}