summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/datenavigator.cpp2
-rw-r--r--korganizer/filtereditdialog.cpp2
-rw-r--r--korganizer/incomingdialog.cpp2
-rw-r--r--korganizer/incomingdialog_base.cpp2
-rw-r--r--korganizer/journalentry.cpp2
-rw-r--r--korganizer/kdatenavigator.cpp2
-rw-r--r--korganizer/koagenda.cpp1
-rw-r--r--korganizer/koagendaitem.cpp2
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/kocounterdialog.cpp2
-rw-r--r--korganizer/kodaymatrix.cpp1
-rw-r--r--korganizer/kodialogmanager.cpp1
-rw-r--r--korganizer/koeditordetails.cpp1
-rw-r--r--korganizer/koeditorgeneral.cpp1
-rw-r--r--korganizer/koeditorgeneralevent.cpp1
-rw-r--r--korganizer/koeditorgeneraltodo.cpp1
-rw-r--r--korganizer/koeditorrecurrence.cpp1
-rw-r--r--korganizer/koeventeditor.cpp1
-rw-r--r--korganizer/koeventpopupmenu.cpp1
-rw-r--r--korganizer/koeventview.cpp3
-rw-r--r--korganizer/koeventviewer.cpp1
-rw-r--r--korganizer/koeventviewerdialog.cpp1
-rw-r--r--korganizer/kofilterview.cpp1
-rw-r--r--korganizer/koincidenceeditor.cpp1
-rw-r--r--korganizer/kojournalview.cpp1
-rw-r--r--korganizer/kolistview.cpp1
-rw-r--r--korganizer/komonthview.cpp1
-rw-r--r--korganizer/koprefsdialog.cpp1
-rw-r--r--korganizer/kosyncprefsdialog.cpp1
-rw-r--r--korganizer/kotimespanview.cpp1
-rw-r--r--korganizer/kotodoeditor.cpp1
-rw-r--r--korganizer/kotodoview.cpp1
-rw-r--r--korganizer/koviewmanager.cpp1
-rw-r--r--korganizer/kowhatsnextview.cpp1
-rw-r--r--korganizer/ktimeedit.cpp1
-rw-r--r--korganizer/lineview.cpp1
-rw-r--r--korganizer/navigatorbar.cpp1
-rw-r--r--korganizer/outgoingdialog.cpp1
-rw-r--r--korganizer/outgoingdialog_base.cpp2
-rw-r--r--korganizer/publishdialog.cpp2
-rw-r--r--korganizer/publishdialog_base.cpp2
-rw-r--r--korganizer/savetemplatedialog.cpp1
-rw-r--r--korganizer/searchdialog.cpp1
-rw-r--r--korganizer/statusdialog.cpp1
-rw-r--r--korganizer/timeline.cpp1
-rw-r--r--korganizer/timespanview.cpp1
47 files changed, 11 insertions, 53 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 7ac5b11..0956c78 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3476 +1,3476 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include "kosyncprefsdialog.h" 61#include "kosyncprefsdialog.h"
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128extern int globalFlagBlockAgenda; 128extern int globalFlagBlockAgenda;
129extern int globalFlagBlockStartup; 129extern int globalFlagBlockStartup;
130 130
131#define SYNC_MODE_NORMAL 0 131#define SYNC_MODE_NORMAL 0
132#define SYNC_MODE_SHARP 1 132#define SYNC_MODE_SHARP 1
133#define SYNC_MODE_QTOPIA 2 133#define SYNC_MODE_QTOPIA 2
134 134
135class KOBeamPrefs : public QDialog 135class KOBeamPrefs : public QDialog
136{ 136{
137 public: 137 public:
138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
139 QDialog( parent, name, true ) 139 QDialog( parent, name, true )
140 { 140 {
141 setCaption( i18n("Beam Options") ); 141 setCaption( i18n("Beam Options") );
142 QVBoxLayout* lay = new QVBoxLayout( this ); 142 QVBoxLayout* lay = new QVBoxLayout( this );
143 lay->setSpacing( 3 ); 143 lay->setSpacing( 3 );
144 lay->setMargin( 3 ); 144 lay->setMargin( 3 );
145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
146 lay->addWidget( format ); 146 lay->addWidget( format );
147 format->setExclusive ( true ) ; 147 format->setExclusive ( true ) ;
148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
149 lay->addWidget( time ); time->setExclusive ( true ) ; 149 lay->addWidget( time ); time->setExclusive ( true ) ;
150 vcal = new QRadioButton(" vCalendar ", format ); 150 vcal = new QRadioButton(" vCalendar ", format );
151 ical = new QRadioButton(" iCalendar ", format ); 151 ical = new QRadioButton(" iCalendar ", format );
152 vcal->setChecked( true ); 152 vcal->setChecked( true );
153 tz = new QRadioButton(i18n(" With timezone "), time ); 153 tz = new QRadioButton(i18n(" With timezone "), time );
154 local = new QRadioButton(i18n(" Local time "), time ); 154 local = new QRadioButton(i18n(" Local time "), time );
155 tz->setChecked( true ); 155 tz->setChecked( true );
156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
157 lay->addWidget( ok ); 157 lay->addWidget( ok );
158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
159 lay->addWidget( cancel ); 159 lay->addWidget( cancel );
160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
162 resize( 200, 200 ); 162 resize( 200, 200 );
163 } 163 }
164 164
165 bool beamVcal() { return vcal->isChecked(); } 165 bool beamVcal() { return vcal->isChecked(); }
166 bool beamLocal() { return local->isChecked(); } 166 bool beamLocal() { return local->isChecked(); }
167private: 167private:
168 QRadioButton* vcal, *ical, *local, *tz; 168 QRadioButton* vcal, *ical, *local, *tz;
169}; 169};
170class KOCatPrefs : public QDialog 170class KOCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from Events/Todos"), format ); 186 new QRadioButton(i18n("Remove from Events/Todos"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202 202
203 203
204CalendarView::CalendarView( CalendarResources *calendar, 204CalendarView::CalendarView( CalendarResources *calendar,
205 QWidget *parent, const char *name ) 205 QWidget *parent, const char *name )
206 : CalendarViewBase( parent, name ), 206 : CalendarViewBase( parent, name ),
207 mCalendar( calendar ), 207 mCalendar( calendar ),
208 mResourceManager( calendar->resourceManager() ) 208 mResourceManager( calendar->resourceManager() )
209{ 209{
210 210
211 mEventEditor = 0; 211 mEventEditor = 0;
212 mTodoEditor = 0; 212 mTodoEditor = 0;
213 213
214 init(); 214 init();
215} 215}
216 216
217CalendarView::CalendarView( Calendar *calendar, 217CalendarView::CalendarView( Calendar *calendar,
218 QWidget *parent, const char *name ) 218 QWidget *parent, const char *name )
219 : CalendarViewBase( parent, name ), 219 : CalendarViewBase( parent, name ),
220 mCalendar( calendar ), 220 mCalendar( calendar ),
221 mResourceManager( 0 ) 221 mResourceManager( 0 )
222{ 222{
223 223
224 mEventEditor = 0; 224 mEventEditor = 0;
225 mTodoEditor = 0; 225 mTodoEditor = 0;
226 init();} 226 init();}
227 227
228void CalendarView::init() 228void CalendarView::init()
229{ 229{
230 beamDialog = new KOBeamPrefs(); 230 beamDialog = new KOBeamPrefs();
231 mDatePickerMode = 0; 231 mDatePickerMode = 0;
232 mCurrentSyncDevice = ""; 232 mCurrentSyncDevice = "";
233 writeLocale(); 233 writeLocale();
234 mViewManager = new KOViewManager( this ); 234 mViewManager = new KOViewManager( this );
235 mDialogManager = new KODialogManager( this ); 235 mDialogManager = new KODialogManager( this );
236 mEventViewerDialog = 0; 236 mEventViewerDialog = 0;
237 mModified = false; 237 mModified = false;
238 mReadOnly = false; 238 mReadOnly = false;
239 mSelectedIncidence = 0; 239 mSelectedIncidence = 0;
240 mSyncProfiles.setAutoDelete(true); 240 mSyncProfiles.setAutoDelete(true);
241 mCalPrinter = 0; 241 mCalPrinter = 0;
242 mFilters.setAutoDelete(true); 242 mFilters.setAutoDelete(true);
243 243
244 mCalendar->registerObserver( this ); 244 mCalendar->registerObserver( this );
245 // TODO: Make sure that view is updated, when calendar is changed. 245 // TODO: Make sure that view is updated, when calendar is changed.
246 246
247 mStorage = new FileStorage( mCalendar ); 247 mStorage = new FileStorage( mCalendar );
248 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 248 mNavigator = new DateNavigator( this, "datevav", mViewManager );
249 249
250 QBoxLayout *topLayout = (QBoxLayout*)layout(); 250 QBoxLayout *topLayout = (QBoxLayout*)layout();
251#ifndef KORG_NOSPLITTER 251#ifndef KORG_NOSPLITTER
252 // create the main layout frames. 252 // create the main layout frames.
253 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 253 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
254 topLayout->addWidget(mPanner); 254 topLayout->addWidget(mPanner);
255 255
256 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 256 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
257 "CalendarView::LeftFrame"); 257 "CalendarView::LeftFrame");
258 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 258 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
259 259
260 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 260 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
261 "CalendarView::DateNavigator", QDate::currentDate() ); 261 "CalendarView::DateNavigator", QDate::currentDate() );
262 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 262 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
263 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 263 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
264 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 264 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
265 265
266#ifdef KORG_NORESOURCEVIEW 266#ifdef KORG_NORESOURCEVIEW
267 mResourceView = 0; 267 mResourceView = 0;
268#else 268#else
269 if ( mResourceManager ) { 269 if ( mResourceManager ) {
270 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 270 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
271 mResourceView->updateView(); 271 mResourceView->updateView();
272 connect( mResourceView, SIGNAL( resourcesChanged() ), 272 connect( mResourceView, SIGNAL( resourcesChanged() ),
273 SLOT( updateView() ) ); 273 SLOT( updateView() ) );
274 } else { 274 } else {
275 mResourceView = 0; 275 mResourceView = 0;
276 } 276 }
277#endif 277#endif
278 QWidget *rightBox = new QWidget( mPanner ); 278 QWidget *rightBox = new QWidget( mPanner );
279 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 279 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
280 280
281 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 281 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
282 rightLayout->addWidget( mNavigatorBar ); 282 rightLayout->addWidget( mNavigatorBar );
283 283
284 mRightFrame = new QWidgetStack( rightBox ); 284 mRightFrame = new QWidgetStack( rightBox );
285 rightLayout->addWidget( mRightFrame, 1 ); 285 rightLayout->addWidget( mRightFrame, 1 );
286 286
287 mLeftFrame = mLeftSplitter; 287 mLeftFrame = mLeftSplitter;
288#else 288#else
289 QWidget *mainBox = new QWidget( this ); 289 QWidget *mainBox = new QWidget( this );
290 QWidget *leftFrame = new QWidget( mainBox ); 290 QWidget *leftFrame = new QWidget( mainBox );
291 291
292 QBoxLayout * mainBoxLayout; 292 QBoxLayout * mainBoxLayout;
293 QBoxLayout * leftFrameLayout; 293 QBoxLayout * leftFrameLayout;
294 if ( KOPrefs::instance()->mVerticalScreen ) { 294 if ( KOPrefs::instance()->mVerticalScreen ) {
295 mainBoxLayout = new QVBoxLayout(mainBox); 295 mainBoxLayout = new QVBoxLayout(mainBox);
296 leftFrameLayout = new QHBoxLayout(leftFrame ); 296 leftFrameLayout = new QHBoxLayout(leftFrame );
297 } else { 297 } else {
298 mainBoxLayout = new QHBoxLayout(mainBox); 298 mainBoxLayout = new QHBoxLayout(mainBox);
299 leftFrameLayout = new QVBoxLayout(leftFrame ); 299 leftFrameLayout = new QVBoxLayout(leftFrame );
300 } 300 }
301 topLayout->addWidget( mainBox ); 301 topLayout->addWidget( mainBox );
302 mainBoxLayout->addWidget (leftFrame); 302 mainBoxLayout->addWidget (leftFrame);
303 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 303 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
304 "CalendarView::DateNavigator", QDate::currentDate()); 304 "CalendarView::DateNavigator", QDate::currentDate());
305 // mDateNavigator->blockSignals( true ); 305 // mDateNavigator->blockSignals( true );
306 leftFrameLayout->addWidget( mDateNavigator ); 306 leftFrameLayout->addWidget( mDateNavigator );
307 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 307 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
308 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 308 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
309 309
310 if ( QApplication::desktop()->width() < 480 ) { 310 if ( QApplication::desktop()->width() < 480 ) {
311 leftFrameLayout->addWidget(mFilterView); 311 leftFrameLayout->addWidget(mFilterView);
312 leftFrameLayout->addWidget(mTodoList, 2 ); 312 leftFrameLayout->addWidget(mTodoList, 2 );
313 313
314 } else { 314 } else {
315 leftFrameLayout->addWidget(mTodoList,2 ); 315 leftFrameLayout->addWidget(mTodoList,2 );
316 leftFrameLayout->addWidget(mFilterView ); 316 leftFrameLayout->addWidget(mFilterView );
317 } 317 }
318 mFilterView->hide(); 318 mFilterView->hide();
319 QWidget *rightBox = new QWidget( mainBox ); 319 QWidget *rightBox = new QWidget( mainBox );
320 mainBoxLayout->addWidget ( rightBox, 10 ); 320 mainBoxLayout->addWidget ( rightBox, 10 );
321 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 321 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
322 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 322 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
323 mRightFrame = new QWidgetStack( rightBox ); 323 mRightFrame = new QWidgetStack( rightBox );
324 rightLayout->addWidget( mNavigatorBar ); 324 rightLayout->addWidget( mNavigatorBar );
325 rightLayout->addWidget( mRightFrame, 10 ); 325 rightLayout->addWidget( mRightFrame, 10 );
326 326
327 mLeftFrame = leftFrame; 327 mLeftFrame = leftFrame;
328 if ( KOPrefs::instance()->mVerticalScreen ) { 328 if ( KOPrefs::instance()->mVerticalScreen ) {
329 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
330 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 330 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
331 } else { 331 } else {
332 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
333 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 333 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
334 } 334 }
335 335
336 //qDebug("Calendarview Size %d %d ", width(), height()); 336 //qDebug("Calendarview Size %d %d ", width(), height());
337#endif 337#endif
338 338
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 SLOT( showDates( const KCal::DateList & ) ) ); 340 SLOT( showDates( const KCal::DateList & ) ) );
341 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 341 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
342 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 342 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
343 343
344 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 344 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
345 mNavigator, SLOT( selectPreviousYear() ) ); 345 mNavigator, SLOT( selectPreviousYear() ) );
346 connect( mNavigatorBar, SIGNAL( goNextYear() ), 346 connect( mNavigatorBar, SIGNAL( goNextYear() ),
347 mNavigator, SLOT( selectNextYear() ) ); 347 mNavigator, SLOT( selectNextYear() ) );
348 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 348 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
349 mNavigator, SLOT( selectPreviousMonth() ) ); 349 mNavigator, SLOT( selectPreviousMonth() ) );
350 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 350 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
351 mNavigator, SLOT( selectNextMonth() ) ); 351 mNavigator, SLOT( selectNextMonth() ) );
352 352
353 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 353 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
354 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 354 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
355 355
356 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 356 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
357 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 357 mNavigator, SLOT( selectWeek( const QDate & ) ) );
358 358
359 connect( mDateNavigator, SIGNAL( goPrevYear() ), 359 connect( mDateNavigator, SIGNAL( goPrevYear() ),
360 mNavigator, SLOT( selectPreviousYear() ) ); 360 mNavigator, SLOT( selectPreviousYear() ) );
361 connect( mDateNavigator, SIGNAL( goNextYear() ), 361 connect( mDateNavigator, SIGNAL( goNextYear() ),
362 mNavigator, SLOT( selectNextYear() ) ); 362 mNavigator, SLOT( selectNextYear() ) );
363 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 363 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
364 mNavigator, SLOT( selectPreviousMonth() ) ); 364 mNavigator, SLOT( selectPreviousMonth() ) );
365 connect( mDateNavigator, SIGNAL( goNextMonth() ), 365 connect( mDateNavigator, SIGNAL( goNextMonth() ),
366 mNavigator, SLOT( selectNextMonth() ) ); 366 mNavigator, SLOT( selectNextMonth() ) );
367 367
368 connect( mDateNavigator, SIGNAL( goPrevious() ), 368 connect( mDateNavigator, SIGNAL( goPrevious() ),
369 mNavigator, SLOT( selectPrevious() ) ); 369 mNavigator, SLOT( selectPrevious() ) );
370 connect( mDateNavigator, SIGNAL( goNext() ), 370 connect( mDateNavigator, SIGNAL( goNext() ),
371 mNavigator, SLOT( selectNext() ) ); 371 mNavigator, SLOT( selectNext() ) );
372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
375 mNavigator, SLOT( slotMonthSelect( int ) ) ); 375 mNavigator, SLOT( slotMonthSelect( int ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
381 SLOT( eventAdded( Event *) ) ); 381 SLOT( eventAdded( Event *) ) );
382 382
383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
384 384
385 connect( this, SIGNAL( configChanged() ), 385 connect( this, SIGNAL( configChanged() ),
386 mDateNavigator, SLOT( updateConfig() ) ); 386 mDateNavigator, SLOT( updateConfig() ) );
387 387
388 connect( mTodoList, SIGNAL( newTodoSignal() ), 388 connect( mTodoList, SIGNAL( newTodoSignal() ),
389 SLOT( newTodo() ) ); 389 SLOT( newTodo() ) );
390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
391 SLOT( newSubTodo( Todo * ) ) ); 391 SLOT( newSubTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
393 SLOT( editTodo( Todo * ) ) ); 393 SLOT( editTodo( Todo * ) ) );
394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
395 SLOT( showTodo( Todo *) ) ); 395 SLOT( showTodo( Todo *) ) );
396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
397 SLOT( deleteTodo( Todo *) ) ); 397 SLOT( deleteTodo( Todo *) ) );
398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
400 SLOT( purgeCompleted() ) ); 400 SLOT( purgeCompleted() ) );
401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
402 SIGNAL( todoModified( Todo *, int ) ) ); 402 SIGNAL( todoModified( Todo *, int ) ) );
403 403
404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
405 this, SLOT ( cloneIncidence( Incidence * ) ) ); 405 this, SLOT ( cloneIncidence( Incidence * ) ) );
406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
407 this, SLOT (cancelIncidence( Incidence * ) ) ); 407 this, SLOT (cancelIncidence( Incidence * ) ) );
408 408
409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
410 this, SLOT ( moveIncidence( Incidence * ) ) ); 410 this, SLOT ( moveIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
412 this, SLOT ( beamIncidence( Incidence * ) ) ); 412 this, SLOT ( beamIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
415 this, SLOT ( todo_unsub( Todo * ) ) ); 415 this, SLOT ( todo_unsub( Todo * ) ) );
416 416
417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
418 SLOT( updateTodo( Todo *, int ) ) ); 418 SLOT( updateTodo( Todo *, int ) ) );
419 connect( this, SIGNAL( todoModified( Todo *, int )), this, 419 connect( this, SIGNAL( todoModified( Todo *, int )), this,
420 SLOT( changeTodoDisplay( Todo *, int ) ) ); 420 SLOT( changeTodoDisplay( Todo *, int ) ) );
421 421
422 422
423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
427 427
428 428
429 429
430 430
431 431
432 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 432 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
433 SLOT(checkClipboard())); 433 SLOT(checkClipboard()));
434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
435 SLOT( processTodoListSelection( Incidence * ) ) ); 435 SLOT( processTodoListSelection( Incidence * ) ) );
436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
437 437
438 // kdDebug() << "CalendarView::CalendarView() done" << endl; 438 // kdDebug() << "CalendarView::CalendarView() done" << endl;
439 439
440 mDateFrame = new QVBox(0,0,WType_Popup); 440 mDateFrame = new QVBox(0,0,WType_Popup);
441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
443 mDateFrame->setLineWidth(3); 443 mDateFrame->setLineWidth(3);
444 mDateFrame->hide(); 444 mDateFrame->hide();
445 mDateFrame->setCaption( i18n( "Pick a date to display")); 445 mDateFrame->setCaption( i18n( "Pick a date to display"));
446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
447 447
448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
449 449
450 mEventEditor = mDialogManager->getEventEditor(); 450 mEventEditor = mDialogManager->getEventEditor();
451 mTodoEditor = mDialogManager->getTodoEditor(); 451 mTodoEditor = mDialogManager->getTodoEditor();
452 452
453 mFlagEditDescription = false; 453 mFlagEditDescription = false;
454 454
455 mSuspendTimer = new QTimer( this ); 455 mSuspendTimer = new QTimer( this );
456 mAlarmTimer = new QTimer( this ); 456 mAlarmTimer = new QTimer( this );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463} 463}
464 464
465 465
466CalendarView::~CalendarView() 466CalendarView::~CalendarView()
467{ 467{
468 // kdDebug() << "~CalendarView()" << endl; 468 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() "); 469 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager; 470 delete mDialogManager;
471 delete mViewManager; 471 delete mViewManager;
472 delete mStorage; 472 delete mStorage;
473 delete mDateFrame ; 473 delete mDateFrame ;
474 delete beamDialog; 474 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl; 475 //kdDebug() << "~CalendarView() done" << endl;
476} 476}
477void CalendarView::timerAlarm() 477void CalendarView::timerAlarm()
478{ 478{
479 //qDebug("CalendarView::timerAlarm() "); 479 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification ); 480 computeAlarm(mAlarmNotification );
481} 481}
482 482
483void CalendarView::suspendAlarm() 483void CalendarView::suspendAlarm()
484{ 484{
485 //qDebug(" CalendarView::suspendAlarm() "); 485 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification ); 486 computeAlarm(mSuspendAlarmNotification );
487 487
488} 488}
489 489
490void CalendarView::startAlarm( QString mess , QString filename) 490void CalendarView::startAlarm( QString mess , QString filename)
491{ 491{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493 493
494} 494}
495 495
496 496
497void CalendarView::computeAlarm( QString msg ) 497void CalendarView::computeAlarm( QString msg )
498{ 498{
499 499
500 QString mess = msg; 500 QString mess = msg;
501 QString mAlarmMessage = mess.mid( 9 ); 501 QString mAlarmMessage = mess.mid( 9 );
502 QString filename = MainWindow::resourcePath(); 502 QString filename = MainWindow::resourcePath();
503 filename += "koalarm.wav"; 503 filename += "koalarm.wav";
504 QString tempfilename; 504 QString tempfilename;
505 if ( mess.left( 13 ) == "suspend_alarm") { 505 if ( mess.left( 13 ) == "suspend_alarm") {
506 bool error = false; 506 bool error = false;
507 int len = mess.mid( 13 ).find("+++"); 507 int len = mess.mid( 13 ).find("+++");
508 if ( len < 2 ) 508 if ( len < 2 )
509 error = true; 509 error = true;
510 else { 510 else {
511 tempfilename = mess.mid( 13, len ); 511 tempfilename = mess.mid( 13, len );
512 if ( !QFile::exists( tempfilename ) ) 512 if ( !QFile::exists( tempfilename ) )
513 error = true; 513 error = true;
514 } 514 }
515 if ( ! error ) { 515 if ( ! error ) {
516 filename = tempfilename; 516 filename = tempfilename;
517 } 517 }
518 mAlarmMessage = mess.mid( 13+len+3 ); 518 mAlarmMessage = mess.mid( 13+len+3 );
519 //qDebug("suspend file %s ",tempfilename.latin1() ); 519 //qDebug("suspend file %s ",tempfilename.latin1() );
520 startAlarm( mAlarmMessage, filename); 520 startAlarm( mAlarmMessage, filename);
521 return; 521 return;
522 } 522 }
523 if ( mess.left( 11 ) == "timer_alarm") { 523 if ( mess.left( 11 ) == "timer_alarm") {
524 //mTimerTime = 0; 524 //mTimerTime = 0;
525 startAlarm( mess.mid( 11 ), filename ); 525 startAlarm( mess.mid( 11 ), filename );
526 return; 526 return;
527 } 527 }
528 if ( mess.left( 10 ) == "proc_alarm") { 528 if ( mess.left( 10 ) == "proc_alarm") {
529 bool error = false; 529 bool error = false;
530 int len = mess.mid( 10 ).find("+++"); 530 int len = mess.mid( 10 ).find("+++");
531 if ( len < 2 ) 531 if ( len < 2 )
532 error = true; 532 error = true;
533 else { 533 else {
534 tempfilename = mess.mid( 10, len ); 534 tempfilename = mess.mid( 10, len );
535 if ( !QFile::exists( tempfilename ) ) 535 if ( !QFile::exists( tempfilename ) )
536 error = true; 536 error = true;
537 } 537 }
538 if ( error ) { 538 if ( error ) {
539 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 539 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
540 mAlarmMessage += mess.mid( 10+len+3+9 ); 540 mAlarmMessage += mess.mid( 10+len+3+9 );
541 } else { 541 } else {
542 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 542 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
543 //qDebug("-----system command %s ",tempfilename.latin1() ); 543 //qDebug("-----system command %s ",tempfilename.latin1() );
544#ifndef _WIN32_ 544#ifndef _WIN32_
545 if ( vfork () == 0 ) { 545 if ( vfork () == 0 ) {
546 execl ( tempfilename.latin1(), 0 ); 546 execl ( tempfilename.latin1(), 0 );
547 return; 547 return;
548 } 548 }
549#else 549#else
550 QProcess* p = new QProcess(); 550 QProcess* p = new QProcess();
551 p->addArgument( tempfilename.latin1() ); 551 p->addArgument( tempfilename.latin1() );
552 p->start(); 552 p->start();
553 return; 553 return;
554#endif 554#endif
555 555
556 return; 556 return;
557 } 557 }
558 558
559 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 559 //qDebug("+++++++system command %s ",tempfilename.latin1() );
560 } 560 }
561 if ( mess.left( 11 ) == "audio_alarm") { 561 if ( mess.left( 11 ) == "audio_alarm") {
562 bool error = false; 562 bool error = false;
563 int len = mess.mid( 11 ).find("+++"); 563 int len = mess.mid( 11 ).find("+++");
564 if ( len < 2 ) 564 if ( len < 2 )
565 error = true; 565 error = true;
566 else { 566 else {
567 tempfilename = mess.mid( 11, len ); 567 tempfilename = mess.mid( 11, len );
568 if ( !QFile::exists( tempfilename ) ) 568 if ( !QFile::exists( tempfilename ) )
569 error = true; 569 error = true;
570 } 570 }
571 if ( ! error ) { 571 if ( ! error ) {
572 filename = tempfilename; 572 filename = tempfilename;
573 } 573 }
574 mAlarmMessage = mess.mid( 11+len+3+9 ); 574 mAlarmMessage = mess.mid( 11+len+3+9 );
575 //qDebug("audio file command %s ",tempfilename.latin1() ); 575 //qDebug("audio file command %s ",tempfilename.latin1() );
576 } 576 }
577 if ( mess.left( 9 ) == "cal_alarm") { 577 if ( mess.left( 9 ) == "cal_alarm") {
578 mAlarmMessage = mess.mid( 9 ) ; 578 mAlarmMessage = mess.mid( 9 ) ;
579 } 579 }
580 580
581 startAlarm( mAlarmMessage, filename ); 581 startAlarm( mAlarmMessage, filename );
582 582
583 583
584} 584}
585 585
586void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 586void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
587{ 587{
588 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 588 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
589 589
590 mSuspendAlarmNotification = noti; 590 mSuspendAlarmNotification = noti;
591 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 591 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
592 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 592 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
593 mSuspendTimer->start( ms , true ); 593 mSuspendTimer->start( ms , true );
594 594
595} 595}
596 596
597void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 597void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
598{ 598{
599 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 599 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
600 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 600 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
601#ifndef DESKTOP_VERSION 601#ifndef DESKTOP_VERSION
602 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 602 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
603#endif 603#endif
604 return; 604 return;
605 } 605 }
606 mAlarmNotification = noti; 606 mAlarmNotification = noti;
607 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 607 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
608 //qDebug("Alarm timer started with secs: %d ", ms/1000); 608 //qDebug("Alarm timer started with secs: %d ", ms/1000);
609 mAlarmTimer->start( ms , true ); 609 mAlarmTimer->start( ms , true );
610 610
611} 611}
612void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 612void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
613{ 613{
614 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 614 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
615 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 615 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
616#ifndef DESKTOP_VERSION 616#ifndef DESKTOP_VERSION
617 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 617 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
618#endif 618#endif
619 return; 619 return;
620 } 620 }
621 mAlarmTimer->stop(); 621 mAlarmTimer->stop();
622} 622}
623void CalendarView::selectWeekNum ( int num ) 623void CalendarView::selectWeekNum ( int num )
624{ 624{
625 dateNavigator()->selectWeek( num ); 625 dateNavigator()->selectWeek( num );
626 mViewManager->showWeekView(); 626 mViewManager->showWeekView();
627} 627}
628KOViewManager *CalendarView::viewManager() 628KOViewManager *CalendarView::viewManager()
629{ 629{
630 return mViewManager; 630 return mViewManager;
631} 631}
632 632
633KODialogManager *CalendarView::dialogManager() 633KODialogManager *CalendarView::dialogManager()
634{ 634{
635 return mDialogManager; 635 return mDialogManager;
636} 636}
637 637
638QDate CalendarView::startDate() 638QDate CalendarView::startDate()
639{ 639{
640 DateList dates = mNavigator->selectedDates(); 640 DateList dates = mNavigator->selectedDates();
641 641
642 return dates.first(); 642 return dates.first();
643} 643}
644 644
645QDate CalendarView::endDate() 645QDate CalendarView::endDate()
646{ 646{
647 DateList dates = mNavigator->selectedDates(); 647 DateList dates = mNavigator->selectedDates();
648 648
649 return dates.last(); 649 return dates.last();
650} 650}
651 651
652 652
653void CalendarView::createPrinter() 653void CalendarView::createPrinter()
654{ 654{
655#ifndef KORG_NOPRINTER 655#ifndef KORG_NOPRINTER
656 if (!mCalPrinter) { 656 if (!mCalPrinter) {
657 mCalPrinter = new CalPrinter(this, mCalendar); 657 mCalPrinter = new CalPrinter(this, mCalendar);
658 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 658 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
659 } 659 }
660#endif 660#endif
661} 661}
662 662
663void CalendarView::confSync() 663void CalendarView::confSync()
664{ 664{
665 static KOSyncPrefsDialog* sp = 0; 665 static KOSyncPrefsDialog* sp = 0;
666 if ( ! sp ) { 666 if ( ! sp ) {
667 sp = new KOSyncPrefsDialog( this, "syncprefs", true ); 667 sp = new KOSyncPrefsDialog( this, "syncprefs", true );
668 } 668 }
669 sp->usrReadConfig(); 669 sp->usrReadConfig();
670#ifndef DESKTOP_VERSION 670#ifndef DESKTOP_VERSION
671 sp->showMaximized(); 671 sp->showMaximized();
672#else 672#else
673 sp->show(); 673 sp->show();
674#endif 674#endif
675 sp->exec(); 675 sp->exec();
676 676
677} 677}
678 678
679 679
680//KOPrefs::instance()->mWriteBackFile 680//KOPrefs::instance()->mWriteBackFile
681//KOPrefs::instance()->mWriteBackExistingOnly 681//KOPrefs::instance()->mWriteBackExistingOnly
682 682
683// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 683// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
684// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 684// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
685// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 685// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
686// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 686// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
687// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 687// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
688// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 688// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
689 689
690int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 690int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
691{ 691{
692 692
693 //void setZaurusId(int id); 693 //void setZaurusId(int id);
694 // int zaurusId() const; 694 // int zaurusId() const;
695 // void setZaurusUid(int id); 695 // void setZaurusUid(int id);
696 // int zaurusUid() const; 696 // int zaurusUid() const;
697 // void setZaurusStat(int id); 697 // void setZaurusStat(int id);
698 // int zaurusStat() const; 698 // int zaurusStat() const;
699 // 0 equal 699 // 0 equal
700 // 1 take local 700 // 1 take local
701 // 2 take remote 701 // 2 take remote
702 // 3 cancel 702 // 3 cancel
703 QDateTime lastSync = mLastCalendarSync; 703 QDateTime lastSync = mLastCalendarSync;
704 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 704 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
705 bool remCh, locCh; 705 bool remCh, locCh;
706 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 706 remCh = ( remote->zaurusUid() != local->zaurusUid() );
707 locCh = ( local->zaurusStat() != local->revision() ); 707 locCh = ( local->zaurusStat() != local->revision() );
708 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 708 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
709 if ( !remCh && ! locCh ) { 709 if ( !remCh && ! locCh ) {
710 //qDebug("both not changed "); 710 //qDebug("both not changed ");
711 lastSync = local->lastModified().addDays(1); 711 lastSync = local->lastModified().addDays(1);
712 } else { 712 } else {
713 if ( locCh ) { 713 if ( locCh ) {
714 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 714 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
715 lastSync = local->lastModified().addDays( -1 ); 715 lastSync = local->lastModified().addDays( -1 );
716 if ( !remCh ) 716 if ( !remCh )
717 remote->setLastModified( lastSync.addDays( -1 ) ); 717 remote->setLastModified( lastSync.addDays( -1 ) );
718 } else { 718 } else {
719 //qDebug(" not loc changed "); 719 //qDebug(" not loc changed ");
720 lastSync = local->lastModified().addDays( 1 ); 720 lastSync = local->lastModified().addDays( 1 );
721 if ( remCh ) 721 if ( remCh )
722 remote->setLastModified( lastSync.addDays( 1 ) ); 722 remote->setLastModified( lastSync.addDays( 1 ) );
723 723
724 } 724 }
725 } 725 }
726 full = true; 726 full = true;
727 if ( mode < 3 ) 727 if ( mode < 3 )
728 mode = 3; 728 mode = 3;
729 } else { 729 } else {
730 if ( local->lastModified() == remote->lastModified() ) 730 if ( local->lastModified() == remote->lastModified() )
731 if ( local->revision() == remote->revision() ) 731 if ( local->revision() == remote->revision() )
732 return 0; 732 return 0;
733 733
734 } 734 }
735 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 735 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
736 736
737 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 737 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
738 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 738 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
739 //full = true; //debug only 739 //full = true; //debug only
740 if ( full ) { 740 if ( full ) {
741 bool equ = false; 741 bool equ = false;
742 if ( local->type() == "Event" ) { 742 if ( local->type() == "Event" ) {
743 equ = (*((Event*) local) == *((Event*) remote)); 743 equ = (*((Event*) local) == *((Event*) remote));
744 } 744 }
745 else if ( local->type() =="Todo" ) 745 else if ( local->type() =="Todo" )
746 equ = (*((Todo*) local) == (*(Todo*) remote)); 746 equ = (*((Todo*) local) == (*(Todo*) remote));
747 else if ( local->type() =="Journal" ) 747 else if ( local->type() =="Journal" )
748 equ = (*((Journal*) local) == *((Journal*) remote)); 748 equ = (*((Journal*) local) == *((Journal*) remote));
749 if ( equ ) { 749 if ( equ ) {
750 //qDebug("equal "); 750 //qDebug("equal ");
751 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 751 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
752 local->setZaurusUid( remote->zaurusUid() ); 752 local->setZaurusUid( remote->zaurusUid() );
753 } 753 }
754 if ( mode < 4 ) 754 if ( mode < 4 )
755 return 0; 755 return 0;
756 756
757 }//else //debug only 757 }//else //debug only
758 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 758 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
759 } 759 }
760 int result; 760 int result;
761 bool localIsNew; 761 bool localIsNew;
762 if ( full && mode < 2 ) 762 if ( full && mode < 2 )
763 mode = 3; 763 mode = 3;
764 764
765 switch( mode ) { 765 switch( mode ) {
766 case 0: 766 case 0:
767 if ( lastSync > remote->lastModified() ) 767 if ( lastSync > remote->lastModified() )
768 return 1; 768 return 1;
769 if ( lastSync > local->lastModified() ) 769 if ( lastSync > local->lastModified() )
770 return 2; 770 return 2;
771 return 1; 771 return 1;
772 break; 772 break;
773 case 1: 773 case 1:
774 if ( lastSync > remote->lastModified() ) 774 if ( lastSync > remote->lastModified() )
775 return 1; 775 return 1;
776 if ( lastSync > local->lastModified() ) 776 if ( lastSync > local->lastModified() )
777 return 2; 777 return 2;
778 return 2; 778 return 2;
779 break; 779 break;
780 case 2: 780 case 2:
781 if ( local->lastModified() > remote->lastModified() ) 781 if ( local->lastModified() > remote->lastModified() )
782 return 1; 782 return 1;
783 else 783 else
784 return 2; 784 return 2;
785 break; 785 break;
786 case 3: 786 case 3:
787 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 787 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
788 if ( lastSync > remote->lastModified() ) 788 if ( lastSync > remote->lastModified() )
789 return 1; 789 return 1;
790 if ( lastSync > local->lastModified() ) 790 if ( lastSync > local->lastModified() )
791 return 2; 791 return 2;
792 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 792 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
793 localIsNew = local->lastModified() > remote->lastModified(); 793 localIsNew = local->lastModified() > remote->lastModified();
794 if ( localIsNew ) 794 if ( localIsNew )
795 getEventViewerDialog()->setColorMode( 1 ); 795 getEventViewerDialog()->setColorMode( 1 );
796 else 796 else
797 getEventViewerDialog()->setColorMode( 2 ); 797 getEventViewerDialog()->setColorMode( 2 );
798 getEventViewerDialog()->setIncidence(local); 798 getEventViewerDialog()->setIncidence(local);
799 if ( localIsNew ) 799 if ( localIsNew )
800 getEventViewerDialog()->setColorMode( 2 ); 800 getEventViewerDialog()->setColorMode( 2 );
801 else 801 else
802 getEventViewerDialog()->setColorMode( 1 ); 802 getEventViewerDialog()->setColorMode( 1 );
803 getEventViewerDialog()->addIncidence(remote); 803 getEventViewerDialog()->addIncidence(remote);
804 getEventViewerDialog()->setColorMode( 0 ); 804 getEventViewerDialog()->setColorMode( 0 );
805 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 805 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
806 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 806 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
807 getEventViewerDialog()->showMe(); 807 getEventViewerDialog()->showMe();
808 result = getEventViewerDialog()->executeS( localIsNew ); 808 result = getEventViewerDialog()->executeS( localIsNew );
809 return result; 809 return result;
810 810
811 break; 811 break;
812 case 4: 812 case 4:
813 return 1; 813 return 1;
814 break; 814 break;
815 case 5: 815 case 5:
816 return 2; 816 return 2;
817 break; 817 break;
818 818
819 default: 819 default:
820 break; 820 break;
821 } 821 }
822 return 0; 822 return 0;
823} 823}
824Event* CalendarView::getLastSyncEvent() 824Event* CalendarView::getLastSyncEvent()
825{ 825{
826 Event* lse; 826 Event* lse;
827 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 827 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
828 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 828 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
829 if (!lse) { 829 if (!lse) {
830 lse = new Event(); 830 lse = new Event();
831 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 831 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
832 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 832 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
833 lse->setDtStart( mLastCalendarSync ); 833 lse->setDtStart( mLastCalendarSync );
834 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 834 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
835 lse->setCategories( i18n("SyncEvent") ); 835 lse->setCategories( i18n("SyncEvent") );
836 lse->setReadOnly( true ); 836 lse->setReadOnly( true );
837 mCalendar->addEvent( lse ); 837 mCalendar->addEvent( lse );
838 } 838 }
839 839
840 return lse; 840 return lse;
841 841
842} 842}
843void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 843void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
844{ 844{
845 if ( ! lastSync ) 845 if ( ! lastSync )
846 return; 846 return;
847 if ( toDelete->zaurusId() < 0 ) 847 if ( toDelete->zaurusId() < 0 )
848 return; 848 return;
849 if ( toDelete->type() == "Journal" ) 849 if ( toDelete->type() == "Journal" )
850 return; 850 return;
851 QString des = lastSync->description(); 851 QString des = lastSync->description();
852 QString pref = "e"; 852 QString pref = "e";
853 if ( toDelete->type() == "Todo" ) 853 if ( toDelete->type() == "Todo" )
854 pref = "t"; 854 pref = "t";
855 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 855 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
856 lastSync->setReadOnly( false ); 856 lastSync->setReadOnly( false );
857 lastSync->setDescription( des ); 857 lastSync->setDescription( des );
858 lastSync->setReadOnly( true ); 858 lastSync->setReadOnly( true );
859 859
860} 860}
861bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 861bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
862{ 862{
863 bool syncOK = true; 863 bool syncOK = true;
864 int addedEvent = 0; 864 int addedEvent = 0;
865 int addedEventR = 0; 865 int addedEventR = 0;
866 int deletedEventR = 0; 866 int deletedEventR = 0;
867 int deletedEventL = 0; 867 int deletedEventL = 0;
868 int changedLocal = 0; 868 int changedLocal = 0;
869 int changedRemote = 0; 869 int changedRemote = 0;
870 //QPtrList<Event> el = local->rawEvents(); 870 //QPtrList<Event> el = local->rawEvents();
871 Event* eventR; 871 Event* eventR;
872 QString uid; 872 QString uid;
873 int take; 873 int take;
874 Event* eventL; 874 Event* eventL;
875 Event* eventRSync; 875 Event* eventRSync;
876 Event* eventLSync; 876 Event* eventLSync;
877 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 877 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
878 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 878 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
879 bool fullDateRange = false; 879 bool fullDateRange = false;
880 mLastCalendarSync = QDateTime::currentDateTime(); 880 mLastCalendarSync = QDateTime::currentDateTime();
881 QDateTime modifiedCalendar = mLastCalendarSync;; 881 QDateTime modifiedCalendar = mLastCalendarSync;;
882 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 882 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
883 if ( eventR ) { 883 if ( eventR ) {
884 eventRSync = (Event*) eventR->clone(); 884 eventRSync = (Event*) eventR->clone();
885 remote->deleteEvent(eventR ); 885 remote->deleteEvent(eventR );
886 886
887 } else { 887 } else {
888 fullDateRange = true; 888 fullDateRange = true;
889 eventRSync = new Event(); 889 eventRSync = new Event();
890 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 890 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
891 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 891 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
892 eventRSync->setDtStart( mLastCalendarSync ); 892 eventRSync->setDtStart( mLastCalendarSync );
893 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 893 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
894 eventRSync->setCategories( i18n("SyncEvent") ); 894 eventRSync->setCategories( i18n("SyncEvent") );
895 } 895 }
896 eventLSync = getLastSyncEvent(); 896 eventLSync = getLastSyncEvent();
897 if ( eventLSync->dtStart() == mLastCalendarSync ) 897 if ( eventLSync->dtStart() == mLastCalendarSync )
898 fullDateRange = true; 898 fullDateRange = true;
899 899
900 if ( ! fullDateRange ) { 900 if ( ! fullDateRange ) {
901 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 901 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
902 902
903 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 903 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
904 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 904 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
905 fullDateRange = true; 905 fullDateRange = true;
906 } 906 }
907 } 907 }
908 if ( fullDateRange ) 908 if ( fullDateRange )
909 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 909 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
910 else 910 else
911 mLastCalendarSync = eventLSync->dtStart(); 911 mLastCalendarSync = eventLSync->dtStart();
912 // for resyncing if own file has changed 912 // for resyncing if own file has changed
913 if ( mCurrentSyncDevice == "deleteaftersync" ) { 913 if ( mCurrentSyncDevice == "deleteaftersync" ) {
914 mLastCalendarSync = loadedFileVersion; 914 mLastCalendarSync = loadedFileVersion;
915 qDebug("setting mLastCalendarSync "); 915 qDebug("setting mLastCalendarSync ");
916 } 916 }
917 //qDebug("*************************** "); 917 //qDebug("*************************** ");
918 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 918 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
919 QPtrList<Incidence> er = remote->rawIncidences(); 919 QPtrList<Incidence> er = remote->rawIncidences();
920 Incidence* inR = er.first(); 920 Incidence* inR = er.first();
921 Incidence* inL; 921 Incidence* inL;
922 QProgressBar bar( er.count(),0 ); 922 QProgressBar bar( er.count(),0 );
923 bar.setCaption (i18n("Syncing - close to abort!") ); 923 bar.setCaption (i18n("Syncing - close to abort!") );
924 924
925 int w = 300; 925 int w = 300;
926 if ( QApplication::desktop()->width() < 320 ) 926 if ( QApplication::desktop()->width() < 320 )
927 w = 220; 927 w = 220;
928 int h = bar.sizeHint().height() ; 928 int h = bar.sizeHint().height() ;
929 int dw = QApplication::desktop()->width(); 929 int dw = QApplication::desktop()->width();
930 int dh = QApplication::desktop()->height(); 930 int dh = QApplication::desktop()->height();
931 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 931 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
932 bar.show(); 932 bar.show();
933 int modulo = (er.count()/10)+1; 933 int modulo = (er.count()/10)+1;
934 int incCounter = 0; 934 int incCounter = 0;
935 while ( inR ) { 935 while ( inR ) {
936 if ( ! bar.isVisible() ) 936 if ( ! bar.isVisible() )
937 return false; 937 return false;
938 if ( incCounter % modulo == 0 ) 938 if ( incCounter % modulo == 0 )
939 bar.setProgress( incCounter ); 939 bar.setProgress( incCounter );
940 ++incCounter; 940 ++incCounter;
941 uid = inR->uid(); 941 uid = inR->uid();
942 bool skipIncidence = false; 942 bool skipIncidence = false;
943 if ( uid.left(21) == QString("last-syncEvent-device") ) 943 if ( uid.left(21) == QString("last-syncEvent-device") )
944 skipIncidence = true; 944 skipIncidence = true;
945 945
946 qApp->processEvents(); 946 qApp->processEvents();
947 if ( !skipIncidence ) { 947 if ( !skipIncidence ) {
948 inL = local->incidence( uid ); 948 inL = local->incidence( uid );
949 if ( inL ) { // maybe conflict - same uid in both calendars 949 if ( inL ) { // maybe conflict - same uid in both calendars
950 int maxrev = inL->revision(); 950 int maxrev = inL->revision();
951 if ( maxrev < inR->revision() ) 951 if ( maxrev < inR->revision() )
952 maxrev = inR->revision(); 952 maxrev = inR->revision();
953 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 953 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
954 //qDebug("take %d %s ", take, inL->summary().latin1()); 954 //qDebug("take %d %s ", take, inL->summary().latin1());
955 if ( take == 3 ) 955 if ( take == 3 )
956 return false; 956 return false;
957 if ( take == 1 ) {// take local 957 if ( take == 1 ) {// take local
958 inL->setZaurusUid( inR->zaurusUid() ); 958 inL->setZaurusUid( inR->zaurusUid() );
959 remote->deleteIncidence( inR ); 959 remote->deleteIncidence( inR );
960 if ( inL->revision() < maxrev ) 960 if ( inL->revision() < maxrev )
961 inL->setRevision( maxrev ); 961 inL->setRevision( maxrev );
962 remote->addIncidence( inL->clone() ); 962 remote->addIncidence( inL->clone() );
963 ++changedRemote; 963 ++changedRemote;
964 } else { 964 } else {
965 if ( inR->revision() < maxrev ) 965 if ( inR->revision() < maxrev )
966 inR->setRevision( maxrev ); 966 inR->setRevision( maxrev );
967 local->deleteIncidence( inL ); 967 local->deleteIncidence( inL );
968 local->addIncidence( inR->clone() ); 968 local->addIncidence( inR->clone() );
969 ++changedLocal; 969 ++changedLocal;
970 } 970 }
971 } 971 }
972 } else { // no conflict 972 } else { // no conflict
973 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 973 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
974 QString des = eventLSync->description(); 974 QString des = eventLSync->description();
975 QString pref = "e"; 975 QString pref = "e";
976 if ( inR->type() == "Todo" ) 976 if ( inR->type() == "Todo" )
977 pref = "t"; 977 pref = "t";
978 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 978 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
979 inR->setZaurusStat( -3 ); 979 inR->setZaurusStat( -3 );
980 //remote->deleteIncidence( inR ); 980 //remote->deleteIncidence( inR );
981 ++deletedEventR; 981 ++deletedEventR;
982 } else { 982 } else {
983 inR->setLastModified( modifiedCalendar ); 983 inR->setLastModified( modifiedCalendar );
984 local->addIncidence( inR->clone() ); 984 local->addIncidence( inR->clone() );
985 ++addedEvent; 985 ++addedEvent;
986 } 986 }
987 } else { 987 } else {
988 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 988 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
989 inR->setLastModified( modifiedCalendar ); 989 inR->setLastModified( modifiedCalendar );
990 local->addIncidence( inR->clone() ); 990 local->addIncidence( inR->clone() );
991 ++addedEvent; 991 ++addedEvent;
992 } else { 992 } else {
993 checkSharpEvent(eventRSyncSharp, inR); 993 checkSharpEvent(eventRSyncSharp, inR);
994 remote->deleteIncidence( inR ); 994 remote->deleteIncidence( inR );
995 ++deletedEventR; 995 ++deletedEventR;
996 } 996 }
997 } 997 }
998 } 998 }
999 } 999 }
1000 inR = er.next(); 1000 inR = er.next();
1001 } 1001 }
1002 QPtrList<Incidence> el = local->rawIncidences(); 1002 QPtrList<Incidence> el = local->rawIncidences();
1003 inL = el.first(); 1003 inL = el.first();
1004 modulo = (el.count()/10)+1; 1004 modulo = (el.count()/10)+1;
1005 bar.setCaption (i18n("Add / remove events") ); 1005 bar.setCaption (i18n("Add / remove events") );
1006 bar.setTotalSteps ( el.count() ) ; 1006 bar.setTotalSteps ( el.count() ) ;
1007 bar.show(); 1007 bar.show();
1008 incCounter = 0; 1008 incCounter = 0;
1009 1009
1010 while ( inL ) { 1010 while ( inL ) {
1011 1011
1012 qApp->processEvents(); 1012 qApp->processEvents();
1013 if ( ! bar.isVisible() ) 1013 if ( ! bar.isVisible() )
1014 return false; 1014 return false;
1015 if ( incCounter % modulo == 0 ) 1015 if ( incCounter % modulo == 0 )
1016 bar.setProgress( incCounter ); 1016 bar.setProgress( incCounter );
1017 ++incCounter; 1017 ++incCounter;
1018 uid = inL->uid(); 1018 uid = inL->uid();
1019 bool skipIncidence = false; 1019 bool skipIncidence = false;
1020 if ( uid.left(21) == QString("last-syncEvent-device") ) 1020 if ( uid.left(21) == QString("last-syncEvent-device") )
1021 skipIncidence = true; 1021 skipIncidence = true;
1022 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" ) 1022 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" )
1023 skipIncidence = true; 1023 skipIncidence = true;
1024 if ( !skipIncidence ) { 1024 if ( !skipIncidence ) {
1025 inR = remote->incidence( uid ); 1025 inR = remote->incidence( uid );
1026 if ( ! inR ) { 1026 if ( ! inR ) {
1027 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 1027 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
1028 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1028 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1029 local->deleteIncidence( inL ); 1029 local->deleteIncidence( inL );
1030 ++deletedEventL; 1030 ++deletedEventL;
1031 } else { 1031 } else {
1032 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1032 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1033 inL->setZaurusId( -1 ); 1033 inL->setZaurusId( -1 );
1034 ++addedEventR; 1034 ++addedEventR;
1035 inL->setLastModified( modifiedCalendar ); 1035 inL->setLastModified( modifiedCalendar );
1036 remote->addIncidence( inL->clone() ); 1036 remote->addIncidence( inL->clone() );
1037 } 1037 }
1038 } 1038 }
1039 } else { 1039 } else {
1040 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1040 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1041 checkSharpEvent(eventLSyncSharp, inL); 1041 checkSharpEvent(eventLSyncSharp, inL);
1042 local->deleteIncidence( inL ); 1042 local->deleteIncidence( inL );
1043 ++deletedEventL; 1043 ++deletedEventL;
1044 } else { 1044 } else {
1045 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1045 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1046 ++addedEventR; 1046 ++addedEventR;
1047 inL->setLastModified( modifiedCalendar ); 1047 inL->setLastModified( modifiedCalendar );
1048 remote->addIncidence( inL->clone() ); 1048 remote->addIncidence( inL->clone() );
1049 } 1049 }
1050 } 1050 }
1051 } 1051 }
1052 } 1052 }
1053 } 1053 }
1054 inL = el.next(); 1054 inL = el.next();
1055 } 1055 }
1056 1056
1057 bar.hide(); 1057 bar.hide();
1058 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1058 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1059 eventLSync->setReadOnly( false ); 1059 eventLSync->setReadOnly( false );
1060 eventLSync->setDtStart( mLastCalendarSync ); 1060 eventLSync->setDtStart( mLastCalendarSync );
1061 eventRSync->setDtStart( mLastCalendarSync ); 1061 eventRSync->setDtStart( mLastCalendarSync );
1062 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1062 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1063 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1063 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1064 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1064 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1065 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1065 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1066 eventLSync->setReadOnly( true ); 1066 eventLSync->setReadOnly( true );
1067 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1067 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1068 remote->addEvent( eventRSync ); 1068 remote->addEvent( eventRSync );
1069 QString mes; 1069 QString mes;
1070 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1070 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1071 if ( KOPrefs::instance()->mShowSyncSummary ) { 1071 if ( KOPrefs::instance()->mShowSyncSummary ) {
1072 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1072 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1073 } 1073 }
1074 qDebug( mes ); 1074 qDebug( mes );
1075 mCalendar->checkAlarmForIncidence( 0, true ); 1075 mCalendar->checkAlarmForIncidence( 0, true );
1076 return syncOK; 1076 return syncOK;
1077} 1077}
1078 1078
1079void CalendarView::setSyncDevice( QString s ) 1079void CalendarView::setSyncDevice( QString s )
1080{ 1080{
1081 mCurrentSyncDevice= s; 1081 mCurrentSyncDevice= s;
1082} 1082}
1083void CalendarView::setSyncName( QString s ) 1083void CalendarView::setSyncName( QString s )
1084{ 1084{
1085 mCurrentSyncName= s; 1085 mCurrentSyncName= s;
1086} 1086}
1087bool CalendarView::syncCalendar(QString filename, int mode) 1087bool CalendarView::syncCalendar(QString filename, int mode)
1088{ 1088{
1089 mGlobalSyncMode = SYNC_MODE_NORMAL; 1089 mGlobalSyncMode = SYNC_MODE_NORMAL;
1090 CalendarLocal* calendar = new CalendarLocal(); 1090 CalendarLocal* calendar = new CalendarLocal();
1091 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1091 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1092 FileStorage* storage = new FileStorage( calendar ); 1092 FileStorage* storage = new FileStorage( calendar );
1093 bool syncOK = false; 1093 bool syncOK = false;
1094 storage->setFileName( filename ); 1094 storage->setFileName( filename );
1095 // qDebug("loading ... "); 1095 // qDebug("loading ... ");
1096 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1096 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1097 getEventViewerDialog()->setSyncMode( true ); 1097 getEventViewerDialog()->setSyncMode( true );
1098 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1098 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1099 getEventViewerDialog()->setSyncMode( false ); 1099 getEventViewerDialog()->setSyncMode( false );
1100 if ( syncOK ) { 1100 if ( syncOK ) {
1101 if ( KOPrefs::instance()->mWriteBackFile ) 1101 if ( KOPrefs::instance()->mWriteBackFile )
1102 { 1102 {
1103 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1103 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1104 storage->save(); 1104 storage->save();
1105 } 1105 }
1106 } 1106 }
1107 setModified( true ); 1107 setModified( true );
1108 } 1108 }
1109 delete storage; 1109 delete storage;
1110 delete calendar; 1110 delete calendar;
1111 if ( syncOK ) 1111 if ( syncOK )
1112 updateView(); 1112 updateView();
1113 return syncOK; 1113 return syncOK;
1114} 1114}
1115void CalendarView::syncSharp() 1115void CalendarView::syncSharp()
1116{ 1116{
1117#ifndef DESKTOP_VERSION 1117#ifndef DESKTOP_VERSION
1118 mGlobalSyncMode = SYNC_MODE_SHARP; 1118 mGlobalSyncMode = SYNC_MODE_SHARP;
1119 //mCurrentSyncDevice = "sharp-DTM"; 1119 //mCurrentSyncDevice = "sharp-DTM";
1120 if ( KOPrefs::instance()->mAskForPreferences ) 1120 if ( KOPrefs::instance()->mAskForPreferences )
1121 edit_sync_options(); 1121 edit_sync_options();
1122 qApp->processEvents(); 1122 qApp->processEvents();
1123 CalendarLocal* calendar = new CalendarLocal(); 1123 CalendarLocal* calendar = new CalendarLocal();
1124 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1124 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1125 bool syncOK = false; 1125 bool syncOK = false;
1126 SharpFormat sharpFormat; 1126 SharpFormat sharpFormat;
1127 if ( sharpFormat.load( calendar, mCalendar ) ) { 1127 if ( sharpFormat.load( calendar, mCalendar ) ) {
1128 getEventViewerDialog()->setSyncMode( true ); 1128 getEventViewerDialog()->setSyncMode( true );
1129 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1129 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1130 getEventViewerDialog()->setSyncMode( false ); 1130 getEventViewerDialog()->setSyncMode( false );
1131 qApp->processEvents(); 1131 qApp->processEvents();
1132 if ( syncOK ) { 1132 if ( syncOK ) {
1133 if ( KOPrefs::instance()->mWriteBackFile ) 1133 if ( KOPrefs::instance()->mWriteBackFile )
1134 { 1134 {
1135 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1135 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1136 Incidence* inc = iL.first(); 1136 Incidence* inc = iL.first();
1137 while ( inc ) { 1137 while ( inc ) {
1138 inc->setZaurusStat( inc->revision () ); 1138 inc->setZaurusStat( inc->revision () );
1139 inc = iL.next(); 1139 inc = iL.next();
1140 } 1140 }
1141 // pending: clean last sync event description 1141 // pending: clean last sync event description
1142 sharpFormat.save(calendar); 1142 sharpFormat.save(calendar);
1143 iL = calendar->rawIncidences(); 1143 iL = calendar->rawIncidences();
1144 inc = iL.first(); 1144 inc = iL.first();
1145 Incidence* loc; 1145 Incidence* loc;
1146 while ( inc ) { 1146 while ( inc ) {
1147 if ( inc->zaurusStat() == -4 ) { 1147 if ( inc->zaurusStat() == -4 ) {
1148 loc = mCalendar->incidence(inc->uid() ); 1148 loc = mCalendar->incidence(inc->uid() );
1149 if ( loc ) { 1149 if ( loc ) {
1150 loc->setZaurusId( inc->zaurusId() ); 1150 loc->setZaurusId( inc->zaurusId() );
1151 loc->setZaurusUid( inc->zaurusUid() ); 1151 loc->setZaurusUid( inc->zaurusUid() );
1152 } 1152 }
1153 } 1153 }
1154 inc = iL.next(); 1154 inc = iL.next();
1155 } 1155 }
1156 Incidence* lse = getLastSyncEvent(); 1156 Incidence* lse = getLastSyncEvent();
1157 if ( lse ) { 1157 if ( lse ) {
1158 lse->setReadOnly( false ); 1158 lse->setReadOnly( false );
1159 lse->setDescription( "" ); 1159 lse->setDescription( "" );
1160 lse->setReadOnly( true ); 1160 lse->setReadOnly( true );
1161 } 1161 }
1162 } 1162 }
1163 } 1163 }
1164 setModified( true ); 1164 setModified( true );
1165 } else { 1165 } else {
1166 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1166 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1167 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1167 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1168 question, i18n("Ok")) ; 1168 question, i18n("Ok")) ;
1169 1169
1170 } 1170 }
1171 delete calendar; 1171 delete calendar;
1172 updateView(); 1172 updateView();
1173 return ;//syncOK; 1173 return ;//syncOK;
1174#endif 1174#endif
1175} 1175}
1176 1176
1177 1177
1178#include <kabc/stdaddressbook.h> 1178#include <kabc/stdaddressbook.h>
1179bool CalendarView::importBday() 1179bool CalendarView::importBday()
1180{ 1180{
1181 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1181 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1182 KABC::AddressBook::Iterator it; 1182 KABC::AddressBook::Iterator it;
1183 int count = 0; 1183 int count = 0;
1184 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1184 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1185 ++count; 1185 ++count;
1186 } 1186 }
1187 QProgressBar bar(count,0 ); 1187 QProgressBar bar(count,0 );
1188 int w = 300; 1188 int w = 300;
1189 if ( QApplication::desktop()->width() < 320 ) 1189 if ( QApplication::desktop()->width() < 320 )
1190 w = 220; 1190 w = 220;
1191 int h = bar.sizeHint().height() ; 1191 int h = bar.sizeHint().height() ;
1192 int dw = QApplication::desktop()->width(); 1192 int dw = QApplication::desktop()->width();
1193 int dh = QApplication::desktop()->height(); 1193 int dh = QApplication::desktop()->height();
1194 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1194 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1195 bar.show(); 1195 bar.show();
1196 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1196 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1197 qApp->processEvents(); 1197 qApp->processEvents();
1198 count = 0; 1198 count = 0;
1199 int addCount = 0; 1199 int addCount = 0;
1200 KCal::Attendee* a = 0; 1200 KCal::Attendee* a = 0;
1201 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1201 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1202 if ( ! bar.isVisible() ) 1202 if ( ! bar.isVisible() )
1203 return false; 1203 return false;
1204 bar.setProgress( count++ ); 1204 bar.setProgress( count++ );
1205 qApp->processEvents(); 1205 qApp->processEvents();
1206 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1206 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1207 if ( (*it).birthday().date().isValid() ){ 1207 if ( (*it).birthday().date().isValid() ){
1208 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1208 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1209 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1209 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1210 ++addCount; 1210 ++addCount;
1211 } 1211 }
1212 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1212 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1213 if ( anni.isValid() ){ 1213 if ( anni.isValid() ){
1214 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1214 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1215 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1215 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1216 ++addCount; 1216 ++addCount;
1217 } 1217 }
1218 } 1218 }
1219 updateView(); 1219 updateView();
1220 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1220 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1221 return true; 1221 return true;
1222} 1222}
1223 1223
1224bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1224bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1225{ 1225{
1226 //qDebug("addAnni "); 1226 //qDebug("addAnni ");
1227 Event * ev = new Event(); 1227 Event * ev = new Event();
1228 if ( a ) { 1228 if ( a ) {
1229 ev->addAttendee( a ); 1229 ev->addAttendee( a );
1230 } 1230 }
1231 QString kind; 1231 QString kind;
1232 if ( birthday ) 1232 if ( birthday )
1233 kind = i18n( "Birthday" ); 1233 kind = i18n( "Birthday" );
1234 else 1234 else
1235 kind = i18n( "Anniversary" ); 1235 kind = i18n( "Anniversary" );
1236 ev->setSummary( name + " - " + kind ); 1236 ev->setSummary( name + " - " + kind );
1237 ev->setOrganizer( "nobody@nowhere" ); 1237 ev->setOrganizer( "nobody@nowhere" );
1238 ev->setCategories( kind ); 1238 ev->setCategories( kind );
1239 ev->setDtStart( QDateTime(date) ); 1239 ev->setDtStart( QDateTime(date) );
1240 ev->setDtEnd( QDateTime(date) ); 1240 ev->setDtEnd( QDateTime(date) );
1241 ev->setFloats( true ); 1241 ev->setFloats( true );
1242 Recurrence * rec = ev->recurrence(); 1242 Recurrence * rec = ev->recurrence();
1243 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1243 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1244 rec->addYearlyNum( date.month() ); 1244 rec->addYearlyNum( date.month() );
1245 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1245 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1246 delete ev; 1246 delete ev;
1247 return false; 1247 return false;
1248 } 1248 }
1249 return true; 1249 return true;
1250 1250
1251} 1251}
1252bool CalendarView::importQtopia( const QString &categories, 1252bool CalendarView::importQtopia( const QString &categories,
1253 const QString &datebook, 1253 const QString &datebook,
1254 const QString &todolist ) 1254 const QString &todolist )
1255{ 1255{
1256 1256
1257 QtopiaFormat qtopiaFormat; 1257 QtopiaFormat qtopiaFormat;
1258 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1258 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1259 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1259 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1260 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1260 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1261 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1261 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1262 1262
1263 updateView(); 1263 updateView();
1264 return true; 1264 return true;
1265 1265
1266#if 0 1266#if 0
1267 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1267 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1268 mCurrentSyncDevice = "qtopia-XML"; 1268 mCurrentSyncDevice = "qtopia-XML";
1269 if ( KOPrefs::instance()->mAskForPreferences ) 1269 if ( KOPrefs::instance()->mAskForPreferences )
1270 edit_sync_options(); 1270 edit_sync_options();
1271 qApp->processEvents(); 1271 qApp->processEvents();
1272 CalendarLocal* calendar = new CalendarLocal(); 1272 CalendarLocal* calendar = new CalendarLocal();
1273 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1273 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1274 bool syncOK = false; 1274 bool syncOK = false;
1275 QtopiaFormat qtopiaFormat; 1275 QtopiaFormat qtopiaFormat;
1276 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1276 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1277 bool loadOk = true; 1277 bool loadOk = true;
1278 if ( !categories.isEmpty() ) 1278 if ( !categories.isEmpty() )
1279 loadOk = qtopiaFormat.load( calendar, categories ); 1279 loadOk = qtopiaFormat.load( calendar, categories );
1280 if ( loadOk && !datebook.isEmpty() ) 1280 if ( loadOk && !datebook.isEmpty() )
1281 loadOk = qtopiaFormat.load( calendar, datebook ); 1281 loadOk = qtopiaFormat.load( calendar, datebook );
1282 if ( loadOk && !todolist.isEmpty() ) 1282 if ( loadOk && !todolist.isEmpty() )
1283 loadOk = qtopiaFormat.load( calendar, todolist ); 1283 loadOk = qtopiaFormat.load( calendar, todolist );
1284 1284
1285 if ( loadOk ) { 1285 if ( loadOk ) {
1286 getEventViewerDialog()->setSyncMode( true ); 1286 getEventViewerDialog()->setSyncMode( true );
1287 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1287 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1288 getEventViewerDialog()->setSyncMode( false ); 1288 getEventViewerDialog()->setSyncMode( false );
1289 qApp->processEvents(); 1289 qApp->processEvents();
1290 if ( syncOK ) { 1290 if ( syncOK ) {
1291 if ( KOPrefs::instance()->mWriteBackFile ) 1291 if ( KOPrefs::instance()->mWriteBackFile )
1292 { 1292 {
1293 // write back XML file 1293 // write back XML file
1294 1294
1295 } 1295 }
1296 setModified( true ); 1296 setModified( true );
1297 } 1297 }
1298 } else { 1298 } else {
1299 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1299 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1300 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1300 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1301 question, i18n("Ok")) ; 1301 question, i18n("Ok")) ;
1302 } 1302 }
1303 delete calendar; 1303 delete calendar;
1304 updateView(); 1304 updateView();
1305 return syncOK; 1305 return syncOK;
1306 1306
1307 1307
1308#endif 1308#endif
1309 1309
1310} 1310}
1311 1311
1312void CalendarView::setSyncEventsReadOnly() 1312void CalendarView::setSyncEventsReadOnly()
1313{ 1313{
1314 Event * ev; 1314 Event * ev;
1315 QPtrList<Event> eL = mCalendar->rawEvents(); 1315 QPtrList<Event> eL = mCalendar->rawEvents();
1316 ev = eL.first(); 1316 ev = eL.first();
1317 while ( ev ) { 1317 while ( ev ) {
1318 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1318 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1319 ev->setReadOnly( true ); 1319 ev->setReadOnly( true );
1320 ev = eL.next(); 1320 ev = eL.next();
1321 } 1321 }
1322} 1322}
1323bool CalendarView::openCalendar(QString filename, bool merge) 1323bool CalendarView::openCalendar(QString filename, bool merge)
1324{ 1324{
1325 1325
1326 if (filename.isEmpty()) { 1326 if (filename.isEmpty()) {
1327 return false; 1327 return false;
1328 } 1328 }
1329 1329
1330 if (!QFile::exists(filename)) { 1330 if (!QFile::exists(filename)) {
1331 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1331 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1332 return false; 1332 return false;
1333 } 1333 }
1334 1334
1335 globalFlagBlockAgenda = 1; 1335 globalFlagBlockAgenda = 1;
1336 if (!merge) mCalendar->close(); 1336 if (!merge) mCalendar->close();
1337 1337
1338 mStorage->setFileName( filename ); 1338 mStorage->setFileName( filename );
1339 1339
1340 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1340 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1341 if ( merge ) ;//setModified( true ); 1341 if ( merge ) ;//setModified( true );
1342 else { 1342 else {
1343 //setModified( true ); 1343 //setModified( true );
1344 mViewManager->setDocumentId( filename ); 1344 mViewManager->setDocumentId( filename );
1345 mDialogManager->setDocumentId( filename ); 1345 mDialogManager->setDocumentId( filename );
1346 mTodoList->setDocumentId( filename ); 1346 mTodoList->setDocumentId( filename );
1347 } 1347 }
1348 globalFlagBlockAgenda = 2; 1348 globalFlagBlockAgenda = 2;
1349 // if ( getLastSyncEvent() ) 1349 // if ( getLastSyncEvent() )
1350 // getLastSyncEvent()->setReadOnly( true ); 1350 // getLastSyncEvent()->setReadOnly( true );
1351 mCalendar->reInitAlarmSettings(); 1351 mCalendar->reInitAlarmSettings();
1352 setSyncEventsReadOnly(); 1352 setSyncEventsReadOnly();
1353 updateUnmanagedViews(); 1353 updateUnmanagedViews();
1354 updateView(); 1354 updateView();
1355 if ( filename != MainWindow::defaultFileName() ) 1355 if ( filename != MainWindow::defaultFileName() )
1356 saveCalendar( MainWindow::defaultFileName() ); 1356 saveCalendar( MainWindow::defaultFileName() );
1357 loadedFileVersion = QDateTime::currentDateTime(); 1357 loadedFileVersion = QDateTime::currentDateTime();
1358 return true; 1358 return true;
1359 } else { 1359 } else {
1360 // while failing to load, the calendar object could 1360 // while failing to load, the calendar object could
1361 // have become partially populated. Clear it out. 1361 // have become partially populated. Clear it out.
1362 if ( !merge ) mCalendar->close(); 1362 if ( !merge ) mCalendar->close();
1363 1363
1364 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1364 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1365 1365
1366 globalFlagBlockAgenda = 2; 1366 globalFlagBlockAgenda = 2;
1367 updateView(); 1367 updateView();
1368 } 1368 }
1369 return false; 1369 return false;
1370} 1370}
1371void CalendarView::setLoadedFileVersion(QDateTime dt) 1371void CalendarView::setLoadedFileVersion(QDateTime dt)
1372{ 1372{
1373 loadedFileVersion = dt; 1373 loadedFileVersion = dt;
1374} 1374}
1375bool CalendarView::checkFileChanged(QString fn) 1375bool CalendarView::checkFileChanged(QString fn)
1376{ 1376{
1377 QFileInfo finf ( fn ); 1377 QFileInfo finf ( fn );
1378 if ( !finf.exists() ) 1378 if ( !finf.exists() )
1379 return true; 1379 return true;
1380 QDateTime dt = finf.lastModified (); 1380 QDateTime dt = finf.lastModified ();
1381 if ( dt <= loadedFileVersion ) 1381 if ( dt <= loadedFileVersion )
1382 return false; 1382 return false;
1383 return true; 1383 return true;
1384 1384
1385} 1385}
1386bool CalendarView::checkFileVersion(QString fn) 1386bool CalendarView::checkFileVersion(QString fn)
1387{ 1387{
1388 QFileInfo finf ( fn ); 1388 QFileInfo finf ( fn );
1389 if ( !finf.exists() ) 1389 if ( !finf.exists() )
1390 return true; 1390 return true;
1391 QDateTime dt = finf.lastModified (); 1391 QDateTime dt = finf.lastModified ();
1392 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1392 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1393 //qDebug("file on disk version %s",dt.toString().latin1()); 1393 //qDebug("file on disk version %s",dt.toString().latin1());
1394 if ( dt <= loadedFileVersion ) 1394 if ( dt <= loadedFileVersion )
1395 return true; 1395 return true;
1396 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1396 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1397 i18n("KO/Pi Warning"),i18n("Overwrite"), 1397 i18n("KO/Pi Warning"),i18n("Overwrite"),
1398 i18n("Sync+save")); 1398 i18n("Sync+save"));
1399 1399
1400 if ( km == KMessageBox::Cancel ) 1400 if ( km == KMessageBox::Cancel )
1401 return false; 1401 return false;
1402 if ( km == KMessageBox::Yes ) 1402 if ( km == KMessageBox::Yes )
1403 return true; 1403 return true;
1404 1404
1405 setSyncDevice("deleteaftersync" ); 1405 setSyncDevice("deleteaftersync" );
1406 KOPrefs::instance()->mAskForPreferences = true; 1406 KOPrefs::instance()->mAskForPreferences = true;
1407 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1407 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1408 KOPrefs::instance()->mWriteBackFile = false; 1408 KOPrefs::instance()->mWriteBackFile = false;
1409 KOPrefs::instance()->mWriteBackExistingOnly = false; 1409 KOPrefs::instance()->mWriteBackExistingOnly = false;
1410 KOPrefs::instance()->mShowSyncSummary = false; 1410 KOPrefs::instance()->mShowSyncSummary = false;
1411 syncCalendar( fn, 3 ); 1411 syncCalendar( fn, 3 );
1412 Event * e = getLastSyncEvent(); 1412 Event * e = getLastSyncEvent();
1413 mCalendar->deleteEvent ( e ); 1413 mCalendar->deleteEvent ( e );
1414 updateView(); 1414 updateView();
1415 return true; 1415 return true;
1416} 1416}
1417 1417
1418bool CalendarView::saveCalendar( QString filename ) 1418bool CalendarView::saveCalendar( QString filename )
1419{ 1419{
1420 1420
1421 // Store back all unsaved data into calendar object 1421 // Store back all unsaved data into calendar object
1422 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1422 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1423 if ( mViewManager->currentView() ) 1423 if ( mViewManager->currentView() )
1424 mViewManager->currentView()->flushView(); 1424 mViewManager->currentView()->flushView();
1425 1425
1426 //mStorage->setFileName( filename ); 1426 //mStorage->setFileName( filename );
1427 1427
1428 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1428 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1429 mStorage->setFileName( filename ); 1429 mStorage->setFileName( filename );
1430 bool success; 1430 bool success;
1431 success = mStorage->save(); 1431 success = mStorage->save();
1432 if ( !success ) { 1432 if ( !success ) {
1433 return false; 1433 return false;
1434 } 1434 }
1435 1435
1436 return true; 1436 return true;
1437} 1437}
1438 1438
1439void CalendarView::closeCalendar() 1439void CalendarView::closeCalendar()
1440{ 1440{
1441 1441
1442 // child windows no longer valid 1442 // child windows no longer valid
1443 emit closingDown(); 1443 emit closingDown();
1444 1444
1445 mCalendar->close(); 1445 mCalendar->close();
1446 setModified(false); 1446 setModified(false);
1447 updateView(); 1447 updateView();
1448} 1448}
1449 1449
1450void CalendarView::archiveCalendar() 1450void CalendarView::archiveCalendar()
1451{ 1451{
1452 mDialogManager->showArchiveDialog(); 1452 mDialogManager->showArchiveDialog();
1453} 1453}
1454 1454
1455 1455
1456void CalendarView::readSettings() 1456void CalendarView::readSettings()
1457{ 1457{
1458 1458
1459 1459
1460 // mViewManager->showAgendaView(); 1460 // mViewManager->showAgendaView();
1461 QString str; 1461 QString str;
1462 //qDebug("CalendarView::readSettings() "); 1462 //qDebug("CalendarView::readSettings() ");
1463 // read settings from the KConfig, supplying reasonable 1463 // read settings from the KConfig, supplying reasonable
1464 // defaults where none are to be found 1464 // defaults where none are to be found
1465 KConfig *config = KOGlobals::config(); 1465 KConfig *config = KOGlobals::config();
1466#ifndef KORG_NOSPLITTER 1466#ifndef KORG_NOSPLITTER
1467 config->setGroup("KOrganizer Geometry"); 1467 config->setGroup("KOrganizer Geometry");
1468 1468
1469 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1469 QValueList<int> sizes = config->readIntListEntry("Separator1");
1470 if (sizes.count() != 2) { 1470 if (sizes.count() != 2) {
1471 sizes << mDateNavigator->minimumSizeHint().width(); 1471 sizes << mDateNavigator->minimumSizeHint().width();
1472 sizes << 300; 1472 sizes << 300;
1473 } 1473 }
1474 mPanner->setSizes(sizes); 1474 mPanner->setSizes(sizes);
1475 1475
1476 sizes = config->readIntListEntry("Separator2"); 1476 sizes = config->readIntListEntry("Separator2");
1477 if ( ( mResourceView && sizes.count() == 4 ) || 1477 if ( ( mResourceView && sizes.count() == 4 ) ||
1478 ( !mResourceView && sizes.count() == 3 ) ) { 1478 ( !mResourceView && sizes.count() == 3 ) ) {
1479 mLeftSplitter->setSizes(sizes); 1479 mLeftSplitter->setSizes(sizes);
1480 } 1480 }
1481#endif 1481#endif
1482 globalFlagBlockAgenda = 1; 1482 globalFlagBlockAgenda = 1;
1483 mViewManager->showAgendaView(); 1483 mViewManager->showAgendaView();
1484 //mViewManager->readSettings( config ); 1484 //mViewManager->readSettings( config );
1485 mTodoList->restoreLayout(config,QString("Todo Layout")); 1485 mTodoList->restoreLayout(config,QString("Todo Layout"));
1486 readFilterSettings(config); 1486 readFilterSettings(config);
1487 config->setGroup( "Views" ); 1487 config->setGroup( "Views" );
1488 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1488 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1489 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1489 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1490 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1490 else if ( dateCount == 7 ) mNavigator->selectWeek();
1491 else mNavigator->selectDates( dateCount ); 1491 else mNavigator->selectDates( dateCount );
1492 // mViewManager->readSettings( config ); 1492 // mViewManager->readSettings( config );
1493 updateConfig(); 1493 updateConfig();
1494 globalFlagBlockAgenda = 2; 1494 globalFlagBlockAgenda = 2;
1495 mViewManager->readSettings( config ); 1495 mViewManager->readSettings( config );
1496#ifdef DESKTOP_VERSION 1496#ifdef DESKTOP_VERSION
1497 config->setGroup("WidgetLayout"); 1497 config->setGroup("WidgetLayout");
1498 QStringList list; 1498 QStringList list;
1499 list = config->readListEntry("MainLayout"); 1499 list = config->readListEntry("MainLayout");
1500 int x,y,w,h; 1500 int x,y,w,h;
1501 if ( ! list.isEmpty() ) { 1501 if ( ! list.isEmpty() ) {
1502 x = list[0].toInt(); 1502 x = list[0].toInt();
1503 y = list[1].toInt(); 1503 y = list[1].toInt();
1504 w = list[2].toInt(); 1504 w = list[2].toInt();
1505 h = list[3].toInt(); 1505 h = list[3].toInt();
1506 topLevelWidget()->setGeometry(x,y,w,h); 1506 topLevelWidget()->setGeometry(x,y,w,h);
1507 1507
1508 } else { 1508 } else {
1509 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1509 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1510 } 1510 }
1511 list = config->readListEntry("EditEventLayout"); 1511 list = config->readListEntry("EditEventLayout");
1512 if ( ! list.isEmpty() ) { 1512 if ( ! list.isEmpty() ) {
1513 x = list[0].toInt(); 1513 x = list[0].toInt();
1514 y = list[1].toInt(); 1514 y = list[1].toInt();
1515 w = list[2].toInt(); 1515 w = list[2].toInt();
1516 h = list[3].toInt(); 1516 h = list[3].toInt();
1517 mEventEditor->setGeometry(x,y,w,h); 1517 mEventEditor->setGeometry(x,y,w,h);
1518 1518
1519 } 1519 }
1520 list = config->readListEntry("EditTodoLayout"); 1520 list = config->readListEntry("EditTodoLayout");
1521 if ( ! list.isEmpty() ) { 1521 if ( ! list.isEmpty() ) {
1522 x = list[0].toInt(); 1522 x = list[0].toInt();
1523 y = list[1].toInt(); 1523 y = list[1].toInt();
1524 w = list[2].toInt(); 1524 w = list[2].toInt();
1525 h = list[3].toInt(); 1525 h = list[3].toInt();
1526 mTodoEditor->setGeometry(x,y,w,h); 1526 mTodoEditor->setGeometry(x,y,w,h);
1527 1527
1528 } 1528 }
1529 list = config->readListEntry("ViewerLayout"); 1529 list = config->readListEntry("ViewerLayout");
1530 if ( ! list.isEmpty() ) { 1530 if ( ! list.isEmpty() ) {
1531 x = list[0].toInt(); 1531 x = list[0].toInt();
1532 y = list[1].toInt(); 1532 y = list[1].toInt();
1533 w = list[2].toInt(); 1533 w = list[2].toInt();
1534 h = list[3].toInt(); 1534 h = list[3].toInt();
1535 getEventViewerDialog()->setGeometry(x,y,w,h); 1535 getEventViewerDialog()->setGeometry(x,y,w,h);
1536 } 1536 }
1537#endif 1537#endif
1538 1538
1539 1539
1540 // pending read sync settings; 1540 // pending read sync settings;
1541 mSyncProfileNames.clear(); 1541 mSyncProfileNames.clear();
1542 mSyncProfileNames << "Profile_1"; 1542 mSyncProfileNames << "Profile_1";
1543 mSyncProfileNames << "Profile_2"; 1543 mSyncProfileNames << "Profile_2";
1544 mSyncProfileNames << "Profile_3"; 1544 mSyncProfileNames << "Profile_3";
1545 mSyncProfileNames << "Profile_4"; 1545 mSyncProfileNames << "Profile_4";
1546 mSyncProfileNames << "Profile_5"; 1546 mSyncProfileNames << "Profile_5";
1547 KSyncProfile* temp = new KSyncProfile (); 1547 KSyncProfile* temp = new KSyncProfile ();
1548 temp->setName("Profile_1" ); 1548 temp->setName("Profile_1" );
1549 mSyncProfiles.append( temp ); 1549 mSyncProfiles.append( temp );
1550 temp = new KSyncProfile (); 1550 temp = new KSyncProfile ();
1551 temp->setName("Profile_2" ); 1551 temp->setName("Profile_2" );
1552 mSyncProfiles.append( temp ); 1552 mSyncProfiles.append( temp );
1553 temp = new KSyncProfile (); 1553 temp = new KSyncProfile ();
1554 temp->setName("Profile_3" ); 1554 temp->setName("Profile_3" );
1555 mSyncProfiles.append( temp ); 1555 mSyncProfiles.append( temp );
1556 temp = new KSyncProfile (); 1556 temp = new KSyncProfile ();
1557 temp->setName("Profile_4" ); 1557 temp->setName("Profile_4" );
1558 mSyncProfiles.append( temp ); 1558 mSyncProfiles.append( temp );
1559 temp = new KSyncProfile (); 1559 temp = new KSyncProfile ();
1560 temp->setName("Profile_5" ); 1560 temp->setName("Profile_5" );
1561 mSyncProfiles.append( temp ); 1561 mSyncProfiles.append( temp );
1562} 1562}
1563 1563
1564 1564
1565void CalendarView::writeSettings() 1565void CalendarView::writeSettings()
1566{ 1566{
1567 // kdDebug() << "CalendarView::writeSettings" << endl; 1567 // kdDebug() << "CalendarView::writeSettings" << endl;
1568 1568
1569 KConfig *config = KOGlobals::config(); 1569 KConfig *config = KOGlobals::config();
1570 1570
1571#ifndef KORG_NOSPLITTER 1571#ifndef KORG_NOSPLITTER
1572 config->setGroup("KOrganizer Geometry"); 1572 config->setGroup("KOrganizer Geometry");
1573 1573
1574 QValueList<int> list = mPanner->sizes(); 1574 QValueList<int> list = mPanner->sizes();
1575 config->writeEntry("Separator1",list); 1575 config->writeEntry("Separator1",list);
1576 1576
1577 list = mLeftSplitter->sizes(); 1577 list = mLeftSplitter->sizes();
1578 config->writeEntry("Separator2",list); 1578 config->writeEntry("Separator2",list);
1579#endif 1579#endif
1580 1580
1581 mViewManager->writeSettings( config ); 1581 mViewManager->writeSettings( config );
1582 mTodoList->saveLayout(config,QString("Todo Layout")); 1582 mTodoList->saveLayout(config,QString("Todo Layout"));
1583 mDialogManager->writeSettings( config ); 1583 mDialogManager->writeSettings( config );
1584 //KOPrefs::instance()->usrWriteConfig(); 1584 //KOPrefs::instance()->usrWriteConfig();
1585 KOPrefs::instance()->writeConfig(); 1585 KOPrefs::instance()->writeConfig();
1586 1586
1587 writeFilterSettings(config); 1587 writeFilterSettings(config);
1588 1588
1589 config->setGroup( "Views" ); 1589 config->setGroup( "Views" );
1590 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1590 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1591 1591
1592#ifdef DESKTOP_VERSION 1592#ifdef DESKTOP_VERSION
1593 config->setGroup("WidgetLayout"); 1593 config->setGroup("WidgetLayout");
1594 QStringList list ;//= config->readListEntry("MainLayout"); 1594 QStringList list ;//= config->readListEntry("MainLayout");
1595 int x,y,w,h; 1595 int x,y,w,h;
1596 QWidget* wid; 1596 QWidget* wid;
1597 wid = topLevelWidget(); 1597 wid = topLevelWidget();
1598 x = wid->geometry().x(); 1598 x = wid->geometry().x();
1599 y = wid->geometry().y(); 1599 y = wid->geometry().y();
1600 w = wid->width(); 1600 w = wid->width();
1601 h = wid->height(); 1601 h = wid->height();
1602 list.clear(); 1602 list.clear();
1603 list << QString::number( x ); 1603 list << QString::number( x );
1604 list << QString::number( y ); 1604 list << QString::number( y );
1605 list << QString::number( w ); 1605 list << QString::number( w );
1606 list << QString::number( h ); 1606 list << QString::number( h );
1607 config->writeEntry("MainLayout",list ); 1607 config->writeEntry("MainLayout",list );
1608 1608
1609 wid = mEventEditor; 1609 wid = mEventEditor;
1610 x = wid->geometry().x(); 1610 x = wid->geometry().x();
1611 y = wid->geometry().y(); 1611 y = wid->geometry().y();
1612 w = wid->width(); 1612 w = wid->width();
1613 h = wid->height(); 1613 h = wid->height();
1614 list.clear(); 1614 list.clear();
1615 list << QString::number( x ); 1615 list << QString::number( x );
1616 list << QString::number( y ); 1616 list << QString::number( y );
1617 list << QString::number( w ); 1617 list << QString::number( w );
1618 list << QString::number( h ); 1618 list << QString::number( h );
1619 config->writeEntry("EditEventLayout",list ); 1619 config->writeEntry("EditEventLayout",list );
1620 1620
1621 wid = mTodoEditor; 1621 wid = mTodoEditor;
1622 x = wid->geometry().x(); 1622 x = wid->geometry().x();
1623 y = wid->geometry().y(); 1623 y = wid->geometry().y();
1624 w = wid->width(); 1624 w = wid->width();
1625 h = wid->height(); 1625 h = wid->height();
1626 list.clear(); 1626 list.clear();
1627 list << QString::number( x ); 1627 list << QString::number( x );
1628 list << QString::number( y ); 1628 list << QString::number( y );
1629 list << QString::number( w ); 1629 list << QString::number( w );
1630 list << QString::number( h ); 1630 list << QString::number( h );
1631 config->writeEntry("EditTodoLayout",list ); 1631 config->writeEntry("EditTodoLayout",list );
1632 wid = getEventViewerDialog(); 1632 wid = getEventViewerDialog();
1633 x = wid->geometry().x(); 1633 x = wid->geometry().x();
1634 y = wid->geometry().y(); 1634 y = wid->geometry().y();
1635 w = wid->width(); 1635 w = wid->width();
1636 h = wid->height(); 1636 h = wid->height();
1637 list.clear(); 1637 list.clear();
1638 list << QString::number( x ); 1638 list << QString::number( x );
1639 list << QString::number( y ); 1639 list << QString::number( y );
1640 list << QString::number( w ); 1640 list << QString::number( w );
1641 list << QString::number( h ); 1641 list << QString::number( h );
1642 config->writeEntry("ViewerLayout",list ); 1642 config->writeEntry("ViewerLayout",list );
1643 wid = mDialogManager->getSearchDialog(); 1643 wid = mDialogManager->getSearchDialog();
1644 if ( wid ) { 1644 if ( wid ) {
1645 x = wid->geometry().x(); 1645 x = wid->geometry().x();
1646 y = wid->geometry().y(); 1646 y = wid->geometry().y();
1647 w = wid->width(); 1647 w = wid->width();
1648 h = wid->height(); 1648 h = wid->height();
1649 list.clear(); 1649 list.clear();
1650 list << QString::number( x ); 1650 list << QString::number( x );
1651 list << QString::number( y ); 1651 list << QString::number( y );
1652 list << QString::number( w ); 1652 list << QString::number( w );
1653 list << QString::number( h ); 1653 list << QString::number( h );
1654 config->writeEntry("SearchLayout",list ); 1654 config->writeEntry("SearchLayout",list );
1655 } 1655 }
1656#endif 1656#endif
1657 1657
1658 1658
1659 config->sync(); 1659 config->sync();
1660} 1660}
1661 1661
1662void CalendarView::readFilterSettings(KConfig *config) 1662void CalendarView::readFilterSettings(KConfig *config)
1663{ 1663{
1664 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1664 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1665 1665
1666 mFilters.clear(); 1666 mFilters.clear();
1667 1667
1668 config->setGroup("General"); 1668 config->setGroup("General");
1669 QStringList filterList = config->readListEntry("CalendarFilters"); 1669 QStringList filterList = config->readListEntry("CalendarFilters");
1670 1670
1671 QStringList::ConstIterator it = filterList.begin(); 1671 QStringList::ConstIterator it = filterList.begin();
1672 QStringList::ConstIterator end = filterList.end(); 1672 QStringList::ConstIterator end = filterList.end();
1673 while(it != end) { 1673 while(it != end) {
1674 // kdDebug() << " filter: " << (*it) << endl; 1674 // kdDebug() << " filter: " << (*it) << endl;
1675 1675
1676 CalFilter *filter; 1676 CalFilter *filter;
1677 filter = new CalFilter(*it); 1677 filter = new CalFilter(*it);
1678 config->setGroup("Filter_" + (*it)); 1678 config->setGroup("Filter_" + (*it));
1679 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1679 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1680 filter->setCriteria(config->readNumEntry("Criteria",0)); 1680 filter->setCriteria(config->readNumEntry("Criteria",0));
1681 filter->setCategoryList(config->readListEntry("CategoryList")); 1681 filter->setCategoryList(config->readListEntry("CategoryList"));
1682 mFilters.append(filter); 1682 mFilters.append(filter);
1683 1683
1684 ++it; 1684 ++it;
1685 } 1685 }
1686 1686
1687 if (mFilters.count() == 0) { 1687 if (mFilters.count() == 0) {
1688 CalFilter *filter = new CalFilter(i18n("Default")); 1688 CalFilter *filter = new CalFilter(i18n("Default"));
1689 mFilters.append(filter); 1689 mFilters.append(filter);
1690 } 1690 }
1691 mFilterView->updateFilters(); 1691 mFilterView->updateFilters();
1692 config->setGroup("FilterView"); 1692 config->setGroup("FilterView");
1693 1693
1694 mFilterView->blockSignals(true); 1694 mFilterView->blockSignals(true);
1695 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1695 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1696 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1696 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1697 mFilterView->blockSignals(false); 1697 mFilterView->blockSignals(false);
1698 // We do it manually to avoid it being done twice by the above calls 1698 // We do it manually to avoid it being done twice by the above calls
1699 updateFilter(); 1699 updateFilter();
1700} 1700}
1701 1701
1702void CalendarView::writeFilterSettings(KConfig *config) 1702void CalendarView::writeFilterSettings(KConfig *config)
1703{ 1703{
1704 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1704 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1705 1705
1706 QStringList filterList; 1706 QStringList filterList;
1707 1707
1708 CalFilter *filter = mFilters.first(); 1708 CalFilter *filter = mFilters.first();
1709 while(filter) { 1709 while(filter) {
1710 // kdDebug() << " fn: " << filter->name() << endl; 1710 // kdDebug() << " fn: " << filter->name() << endl;
1711 filterList << filter->name(); 1711 filterList << filter->name();
1712 config->setGroup("Filter_" + filter->name()); 1712 config->setGroup("Filter_" + filter->name());
1713 config->writeEntry("Criteria",filter->criteria()); 1713 config->writeEntry("Criteria",filter->criteria());
1714 config->writeEntry("CategoryList",filter->categoryList()); 1714 config->writeEntry("CategoryList",filter->categoryList());
1715 filter = mFilters.next(); 1715 filter = mFilters.next();
1716 } 1716 }
1717 config->setGroup("General"); 1717 config->setGroup("General");
1718 config->writeEntry("CalendarFilters",filterList); 1718 config->writeEntry("CalendarFilters",filterList);
1719 1719
1720 config->setGroup("FilterView"); 1720 config->setGroup("FilterView");
1721 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1721 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1722 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1722 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1723} 1723}
1724 1724
1725 1725
1726void CalendarView::goToday() 1726void CalendarView::goToday()
1727{ 1727{
1728 mNavigator->selectToday(); 1728 mNavigator->selectToday();
1729} 1729}
1730 1730
1731void CalendarView::goNext() 1731void CalendarView::goNext()
1732{ 1732{
1733 mNavigator->selectNext(); 1733 mNavigator->selectNext();
1734} 1734}
1735 1735
1736void CalendarView::goPrevious() 1736void CalendarView::goPrevious()
1737{ 1737{
1738 mNavigator->selectPrevious(); 1738 mNavigator->selectPrevious();
1739} 1739}
1740void CalendarView::goNextMonth() 1740void CalendarView::goNextMonth()
1741{ 1741{
1742 mNavigator->selectNextMonth(); 1742 mNavigator->selectNextMonth();
1743} 1743}
1744 1744
1745void CalendarView::goPreviousMonth() 1745void CalendarView::goPreviousMonth()
1746{ 1746{
1747 mNavigator->selectPreviousMonth(); 1747 mNavigator->selectPreviousMonth();
1748} 1748}
1749void CalendarView::writeLocale() 1749void CalendarView::writeLocale()
1750{ 1750{
1751 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1751 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1752 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1752 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1753 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); 1753 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
1754 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1754 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1755 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1755 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1756 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1756 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1757 dummy = KOPrefs::instance()->mUserDateFormatShort; 1757 dummy = KOPrefs::instance()->mUserDateFormatShort;
1758 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1758 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1759 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1759 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1760 KOPrefs::instance()->mDaylightsavingStart, 1760 KOPrefs::instance()->mDaylightsavingStart,
1761 KOPrefs::instance()->mDaylightsavingEnd ); 1761 KOPrefs::instance()->mDaylightsavingEnd );
1762 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1762 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1763} 1763}
1764void CalendarView::updateConfig() 1764void CalendarView::updateConfig()
1765{ 1765{
1766 writeLocale(); 1766 writeLocale();
1767 if ( KOPrefs::instance()->mUseAppColors ) 1767 if ( KOPrefs::instance()->mUseAppColors )
1768 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1768 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1769 emit configChanged(); 1769 emit configChanged();
1770 mTodoList->updateConfig(); 1770 mTodoList->updateConfig();
1771 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1771 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1772 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1772 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1773 // To make the "fill window" configurations work 1773 // To make the "fill window" configurations work
1774 //mViewManager->raiseCurrentView(); 1774 //mViewManager->raiseCurrentView();
1775} 1775}
1776 1776
1777 1777
1778void CalendarView::eventChanged(Event *event) 1778void CalendarView::eventChanged(Event *event)
1779{ 1779{
1780 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1780 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1781 //updateUnmanagedViews(); 1781 //updateUnmanagedViews();
1782} 1782}
1783 1783
1784void CalendarView::eventAdded(Event *event) 1784void CalendarView::eventAdded(Event *event)
1785{ 1785{
1786 changeEventDisplay(event,KOGlobals::EVENTADDED); 1786 changeEventDisplay(event,KOGlobals::EVENTADDED);
1787} 1787}
1788 1788
1789void CalendarView::eventToBeDeleted(Event *) 1789void CalendarView::eventToBeDeleted(Event *)
1790{ 1790{
1791 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1791 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1792} 1792}
1793 1793
1794void CalendarView::eventDeleted() 1794void CalendarView::eventDeleted()
1795{ 1795{
1796 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1796 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1797} 1797}
1798void CalendarView::changeTodoDisplay(Todo *which, int action) 1798void CalendarView::changeTodoDisplay(Todo *which, int action)
1799{ 1799{
1800 changeIncidenceDisplay((Incidence *)which, action); 1800 changeIncidenceDisplay((Incidence *)which, action);
1801} 1801}
1802void CalendarView::checkZaurusId( int id, bool todo ) 1802void CalendarView::checkZaurusId( int id, bool todo )
1803{ 1803{
1804 if ( id >= 0 ) { 1804 if ( id >= 0 ) {
1805 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); 1805 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM");
1806 if ( lse ) { 1806 if ( lse ) {
1807 QString des = lse->description(); 1807 QString des = lse->description();
1808 QString pref = "e"; 1808 QString pref = "e";
1809 if ( todo ) 1809 if ( todo )
1810 pref = "t"; 1810 pref = "t";
1811 des += pref+ QString::number ( id ) + ","; 1811 des += pref+ QString::number ( id ) + ",";
1812 lse->setReadOnly( false ); 1812 lse->setReadOnly( false );
1813 lse->setDescription( des ); 1813 lse->setDescription( des );
1814 lse->setReadOnly( true ); 1814 lse->setReadOnly( true );
1815 } 1815 }
1816 } 1816 }
1817} 1817}
1818void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1818void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1819{ 1819{
1820 updateUnmanagedViews(); 1820 updateUnmanagedViews();
1821 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1821 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1822 if ( action == KOGlobals::EVENTDELETED ) { //delete 1822 if ( action == KOGlobals::EVENTDELETED ) { //delete
1823 mCalendar->checkAlarmForIncidence( 0, true ); 1823 mCalendar->checkAlarmForIncidence( 0, true );
1824 if ( mEventViewerDialog ) 1824 if ( mEventViewerDialog )
1825 mEventViewerDialog->hide(); 1825 mEventViewerDialog->hide();
1826 } 1826 }
1827 else 1827 else
1828 mCalendar->checkAlarmForIncidence( which , false ); 1828 mCalendar->checkAlarmForIncidence( which , false );
1829} 1829}
1830 1830
1831// most of the changeEventDisplays() right now just call the view's 1831// most of the changeEventDisplays() right now just call the view's
1832// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1832// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1833void CalendarView::changeEventDisplay(Event *which, int action) 1833void CalendarView::changeEventDisplay(Event *which, int action)
1834{ 1834{
1835 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1835 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1836 changeIncidenceDisplay((Incidence *)which, action); 1836 changeIncidenceDisplay((Incidence *)which, action);
1837 mDateNavigator->updateView(); 1837 mDateNavigator->updateView();
1838 //mDialogManager->updateSearchDialog(); 1838 //mDialogManager->updateSearchDialog();
1839 1839
1840 if (which) { 1840 if (which) {
1841 // If there is an event view visible update the display 1841 // If there is an event view visible update the display
1842 mViewManager->currentView()->changeEventDisplay(which,action); 1842 mViewManager->currentView()->changeEventDisplay(which,action);
1843 // TODO: check, if update needed 1843 // TODO: check, if update needed
1844 // if (which->getTodoStatus()) { 1844 // if (which->getTodoStatus()) {
1845 mTodoList->updateView(); 1845 mTodoList->updateView();
1846 // } 1846 // }
1847 } else { 1847 } else {
1848 mViewManager->currentView()->updateView(); 1848 mViewManager->currentView()->updateView();
1849 } 1849 }
1850} 1850}
1851 1851
1852 1852
1853void CalendarView::updateTodoViews() 1853void CalendarView::updateTodoViews()
1854{ 1854{
1855 1855
1856 mTodoList->updateView(); 1856 mTodoList->updateView();
1857 mViewManager->currentView()->updateView(); 1857 mViewManager->currentView()->updateView();
1858 1858
1859} 1859}
1860 1860
1861 1861
1862void CalendarView::updateView(const QDate &start, const QDate &end) 1862void CalendarView::updateView(const QDate &start, const QDate &end)
1863{ 1863{
1864 mTodoList->updateView(); 1864 mTodoList->updateView();
1865 mViewManager->updateView(start, end); 1865 mViewManager->updateView(start, end);
1866 //mDateNavigator->updateView(); 1866 //mDateNavigator->updateView();
1867} 1867}
1868 1868
1869void CalendarView::updateView() 1869void CalendarView::updateView()
1870{ 1870{
1871 DateList tmpList = mNavigator->selectedDates(); 1871 DateList tmpList = mNavigator->selectedDates();
1872 1872
1873 // We assume that the navigator only selects consecutive days. 1873 // We assume that the navigator only selects consecutive days.
1874 updateView( tmpList.first(), tmpList.last() ); 1874 updateView( tmpList.first(), tmpList.last() );
1875} 1875}
1876 1876
1877void CalendarView::updateUnmanagedViews() 1877void CalendarView::updateUnmanagedViews()
1878{ 1878{
1879 mDateNavigator->updateDayMatrix(); 1879 mDateNavigator->updateDayMatrix();
1880} 1880}
1881 1881
1882int CalendarView::msgItemDelete() 1882int CalendarView::msgItemDelete()
1883{ 1883{
1884 return KMessageBox::warningContinueCancel(this, 1884 return KMessageBox::warningContinueCancel(this,
1885 i18n("This item will be\npermanently deleted."), 1885 i18n("This item will be\npermanently deleted."),
1886 i18n("KO/Pi Confirmation"),i18n("Delete")); 1886 i18n("KO/Pi Confirmation"),i18n("Delete"));
1887} 1887}
1888 1888
1889 1889
1890void CalendarView::edit_cut() 1890void CalendarView::edit_cut()
1891{ 1891{
1892 Event *anEvent=0; 1892 Event *anEvent=0;
1893 1893
1894 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1894 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1895 1895
1896 if (mViewManager->currentView()->isEventView()) { 1896 if (mViewManager->currentView()->isEventView()) {
1897 if ( incidence && incidence->type() == "Event" ) { 1897 if ( incidence && incidence->type() == "Event" ) {
1898 anEvent = static_cast<Event *>(incidence); 1898 anEvent = static_cast<Event *>(incidence);
1899 } 1899 }
1900 } 1900 }
1901 1901
1902 if (!anEvent) { 1902 if (!anEvent) {
1903 KNotifyClient::beep(); 1903 KNotifyClient::beep();
1904 return; 1904 return;
1905 } 1905 }
1906 DndFactory factory( mCalendar ); 1906 DndFactory factory( mCalendar );
1907 factory.cutEvent(anEvent); 1907 factory.cutEvent(anEvent);
1908 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1908 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1909} 1909}
1910 1910
1911void CalendarView::edit_copy() 1911void CalendarView::edit_copy()
1912{ 1912{
1913 Event *anEvent=0; 1913 Event *anEvent=0;
1914 1914
1915 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1915 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1916 1916
1917 if (mViewManager->currentView()->isEventView()) { 1917 if (mViewManager->currentView()->isEventView()) {
1918 if ( incidence && incidence->type() == "Event" ) { 1918 if ( incidence && incidence->type() == "Event" ) {
1919 anEvent = static_cast<Event *>(incidence); 1919 anEvent = static_cast<Event *>(incidence);
1920 } 1920 }
1921 } 1921 }
1922 1922
1923 if (!anEvent) { 1923 if (!anEvent) {
1924 KNotifyClient::beep(); 1924 KNotifyClient::beep();
1925 return; 1925 return;
1926 } 1926 }
1927 DndFactory factory( mCalendar ); 1927 DndFactory factory( mCalendar );
1928 factory.copyEvent(anEvent); 1928 factory.copyEvent(anEvent);
1929} 1929}
1930 1930
1931void CalendarView::edit_paste() 1931void CalendarView::edit_paste()
1932{ 1932{
1933 QDate date = mNavigator->selectedDates().first(); 1933 QDate date = mNavigator->selectedDates().first();
1934 1934
1935 DndFactory factory( mCalendar ); 1935 DndFactory factory( mCalendar );
1936 Event *pastedEvent = factory.pasteEvent( date ); 1936 Event *pastedEvent = factory.pasteEvent( date );
1937 1937
1938 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1938 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1939} 1939}
1940 1940
1941void CalendarView::edit_options() 1941void CalendarView::edit_options()
1942{ 1942{
1943 mDialogManager->showOptionsDialog(); 1943 mDialogManager->showOptionsDialog();
1944 //writeSettings(); 1944 //writeSettings();
1945} 1945}
1946void CalendarView::edit_sync_options() 1946void CalendarView::edit_sync_options()
1947{ 1947{
1948 //mDialogManager->showSyncOptions(); 1948 //mDialogManager->showSyncOptions();
1949 //KOPrefs::instance()->mSyncAlgoPrefs 1949 //KOPrefs::instance()->mSyncAlgoPrefs
1950 QDialog dia( this, "dia", true ); 1950 QDialog dia( this, "dia", true );
1951 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 1951 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1952 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 1952 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1953 QVBoxLayout lay ( &dia ); 1953 QVBoxLayout lay ( &dia );
1954 lay.setSpacing( 2 ); 1954 lay.setSpacing( 2 );
1955 lay.setMargin( 3 ); 1955 lay.setMargin( 3 );
1956 lay.addWidget(&gr); 1956 lay.addWidget(&gr);
1957 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 1957 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1958 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 1958 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1959 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 1959 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1960 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 1960 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1961 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 1961 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1962 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 1962 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1963 //QRadioButton both( i18n("Take both on conflict"), &gr ); 1963 //QRadioButton both( i18n("Take both on conflict"), &gr );
1964 QPushButton pb ( "OK", &dia); 1964 QPushButton pb ( "OK", &dia);
1965 lay.addWidget( &pb ); 1965 lay.addWidget( &pb );
1966 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1966 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1967 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 1967 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1968 case 0: 1968 case 0:
1969 loc.setChecked( true); 1969 loc.setChecked( true);
1970 break; 1970 break;
1971 case 1: 1971 case 1:
1972 rem.setChecked( true ); 1972 rem.setChecked( true );
1973 break; 1973 break;
1974 case 2: 1974 case 2:
1975 newest.setChecked( true); 1975 newest.setChecked( true);
1976 break; 1976 break;
1977 case 3: 1977 case 3:
1978 ask.setChecked( true); 1978 ask.setChecked( true);
1979 break; 1979 break;
1980 case 4: 1980 case 4:
1981 f_loc.setChecked( true); 1981 f_loc.setChecked( true);
1982 break; 1982 break;
1983 case 5: 1983 case 5:
1984 f_rem.setChecked( true); 1984 f_rem.setChecked( true);
1985 break; 1985 break;
1986 case 6: 1986 case 6:
1987 // both.setChecked( true); 1987 // both.setChecked( true);
1988 break; 1988 break;
1989 default: 1989 default:
1990 break; 1990 break;
1991 } 1991 }
1992 if ( dia.exec() ) { 1992 if ( dia.exec() ) {
1993 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 1993 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
1994 } 1994 }
1995 1995
1996} 1996}
1997 1997
1998void CalendarView::slotSelectPickerDate( QDate d) 1998void CalendarView::slotSelectPickerDate( QDate d)
1999{ 1999{
2000 mDateFrame->hide(); 2000 mDateFrame->hide();
2001 if ( mDatePickerMode == 1 ) { 2001 if ( mDatePickerMode == 1 ) {
2002 mNavigator->slotDaySelect( d ); 2002 mNavigator->slotDaySelect( d );
2003 } else if ( mDatePickerMode == 2 ) { 2003 } else if ( mDatePickerMode == 2 ) {
2004 if ( mMoveIncidence->type() == "Todo" ) { 2004 if ( mMoveIncidence->type() == "Todo" ) {
2005 Todo * to = (Todo *) mMoveIncidence; 2005 Todo * to = (Todo *) mMoveIncidence;
2006 QTime tim; 2006 QTime tim;
2007 if ( to->hasDueDate() ) 2007 if ( to->hasDueDate() )
2008 tim = to->dtDue().time(); 2008 tim = to->dtDue().time();
2009 else { 2009 else {
2010 tim = QTime ( 0,0,0 ); 2010 tim = QTime ( 0,0,0 );
2011 to->setFloats( true ); 2011 to->setFloats( true );
2012 to->setHasDueDate( true ); 2012 to->setHasDueDate( true );
2013 } 2013 }
2014 QDateTime dt ( d,tim ); 2014 QDateTime dt ( d,tim );
2015 to->setDtDue( dt ); 2015 to->setDtDue( dt );
2016 todoChanged( to ); 2016 todoChanged( to );
2017 } else { 2017 } else {
2018 QTime tim = mMoveIncidence->dtStart().time(); 2018 QTime tim = mMoveIncidence->dtStart().time();
2019 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2019 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2020 QDateTime dt ( d,tim ); 2020 QDateTime dt ( d,tim );
2021 mMoveIncidence->setDtStart( dt ); 2021 mMoveIncidence->setDtStart( dt );
2022 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2022 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2023 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2023 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2024 } 2024 }
2025 2025
2026 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2026 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2027 } 2027 }
2028} 2028}
2029 2029
2030void CalendarView::removeCategories() 2030void CalendarView::removeCategories()
2031{ 2031{
2032 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2032 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2033 QStringList catList = KOPrefs::instance()->mCustomCategories; 2033 QStringList catList = KOPrefs::instance()->mCustomCategories;
2034 QStringList catIncList; 2034 QStringList catIncList;
2035 QStringList newCatList; 2035 QStringList newCatList;
2036 Incidence* inc = incList.first(); 2036 Incidence* inc = incList.first();
2037 int i; 2037 int i;
2038 int count = 0; 2038 int count = 0;
2039 while ( inc ) { 2039 while ( inc ) {
2040 newCatList.clear(); 2040 newCatList.clear();
2041 catIncList = inc->categories() ; 2041 catIncList = inc->categories() ;
2042 for( i = 0; i< catIncList.count(); ++i ) { 2042 for( i = 0; i< catIncList.count(); ++i ) {
2043 if ( catList.contains (catIncList[i])) 2043 if ( catList.contains (catIncList[i]))
2044 newCatList.append( catIncList[i] ); 2044 newCatList.append( catIncList[i] );
2045 } 2045 }
2046 newCatList.sort(); 2046 newCatList.sort();
2047 inc->setCategories( newCatList.join(",") ); 2047 inc->setCategories( newCatList.join(",") );
2048 inc = incList.next(); 2048 inc = incList.next();
2049 } 2049 }
2050} 2050}
2051 2051
2052int CalendarView::addCategories() 2052int CalendarView::addCategories()
2053{ 2053{
2054 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2054 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2055 QStringList catList = KOPrefs::instance()->mCustomCategories; 2055 QStringList catList = KOPrefs::instance()->mCustomCategories;
2056 QStringList catIncList; 2056 QStringList catIncList;
2057 Incidence* inc = incList.first(); 2057 Incidence* inc = incList.first();
2058 int i; 2058 int i;
2059 int count = 0; 2059 int count = 0;
2060 while ( inc ) { 2060 while ( inc ) {
2061 catIncList = inc->categories() ; 2061 catIncList = inc->categories() ;
2062 for( i = 0; i< catIncList.count(); ++i ) { 2062 for( i = 0; i< catIncList.count(); ++i ) {
2063 if ( !catList.contains (catIncList[i])) { 2063 if ( !catList.contains (catIncList[i])) {
2064 catList.append( catIncList[i] ); 2064 catList.append( catIncList[i] );
2065 //qDebug("add cat %s ", catIncList[i].latin1()); 2065 //qDebug("add cat %s ", catIncList[i].latin1());
2066 ++count; 2066 ++count;
2067 } 2067 }
2068 } 2068 }
2069 inc = incList.next(); 2069 inc = incList.next();
2070 } 2070 }
2071 catList.sort(); 2071 catList.sort();
2072 KOPrefs::instance()->mCustomCategories = catList; 2072 KOPrefs::instance()->mCustomCategories = catList;
2073 return count; 2073 return count;
2074} 2074}
2075 2075
2076void CalendarView::manageCategories() 2076void CalendarView::manageCategories()
2077{ 2077{
2078 KOCatPrefs* cp = new KOCatPrefs(); 2078 KOCatPrefs* cp = new KOCatPrefs();
2079 cp->show(); 2079 cp->show();
2080 int w =cp->sizeHint().width() ; 2080 int w =cp->sizeHint().width() ;
2081 int h = cp->sizeHint().height() ; 2081 int h = cp->sizeHint().height() ;
2082 int dw = QApplication::desktop()->width(); 2082 int dw = QApplication::desktop()->width();
2083 int dh = QApplication::desktop()->height(); 2083 int dh = QApplication::desktop()->height();
2084 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2084 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2085 if ( !cp->exec() ) { 2085 if ( !cp->exec() ) {
2086 delete cp; 2086 delete cp;
2087 return; 2087 return;
2088 } 2088 }
2089 int count = 0; 2089 int count = 0;
2090 if ( cp->addCat() ) { 2090 if ( cp->addCat() ) {
2091 count = addCategories(); 2091 count = addCategories();
2092 if ( count ) { 2092 if ( count ) {
2093 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2093 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2094 writeSettings(); 2094 writeSettings();
2095 } 2095 }
2096 } else { 2096 } else {
2097 removeCategories(); 2097 removeCategories();
2098 updateView(); 2098 updateView();
2099 } 2099 }
2100 delete cp; 2100 delete cp;
2101} 2101}
2102 2102
2103void CalendarView::beamIncidence(Incidence * Inc) 2103void CalendarView::beamIncidence(Incidence * Inc)
2104{ 2104{
2105 QPtrList<Incidence> delSel ; 2105 QPtrList<Incidence> delSel ;
2106 delSel.append(Inc); 2106 delSel.append(Inc);
2107 beamIncidenceList( delSel ); 2107 beamIncidenceList( delSel );
2108} 2108}
2109void CalendarView::beamCalendar() 2109void CalendarView::beamCalendar()
2110{ 2110{
2111 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2111 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2112 //qDebug("beamCalendar() "); 2112 //qDebug("beamCalendar() ");
2113 beamIncidenceList( delSel ); 2113 beamIncidenceList( delSel );
2114} 2114}
2115void CalendarView::beamFilteredCalendar() 2115void CalendarView::beamFilteredCalendar()
2116{ 2116{
2117 QPtrList<Incidence> delSel = mCalendar->incidences(); 2117 QPtrList<Incidence> delSel = mCalendar->incidences();
2118 //qDebug("beamFilteredCalendar() "); 2118 //qDebug("beamFilteredCalendar() ");
2119 beamIncidenceList( delSel ); 2119 beamIncidenceList( delSel );
2120} 2120}
2121void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2121void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2122{ 2122{
2123 if ( beamDialog->exec () == QDialog::Rejected ) 2123 if ( beamDialog->exec () == QDialog::Rejected )
2124 return; 2124 return;
2125 2125
2126 QString fn = "/tmp/kopibeamfile"; 2126 QString fn = "/tmp/kopibeamfile";
2127 QString mes; 2127 QString mes;
2128 bool createbup = true; 2128 bool createbup = true;
2129 if ( createbup ) { 2129 if ( createbup ) {
2130 QString description = "\n"; 2130 QString description = "\n";
2131 CalendarLocal* cal = new CalendarLocal(); 2131 CalendarLocal* cal = new CalendarLocal();
2132 if ( beamDialog->beamLocal() ) 2132 if ( beamDialog->beamLocal() )
2133 cal->setLocalTime(); 2133 cal->setLocalTime();
2134 else 2134 else
2135 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2135 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2136 Incidence *incidence = delSel.first(); 2136 Incidence *incidence = delSel.first();
2137 bool addText = false; 2137 bool addText = false;
2138 if ( delSel.count() < 10 ) 2138 if ( delSel.count() < 10 )
2139 addText = true; 2139 addText = true;
2140 else { 2140 else {
2141 description.sprintf(i18n(" %d items?"),delSel.count() ); 2141 description.sprintf(i18n(" %d items?"),delSel.count() );
2142 } 2142 }
2143 while ( incidence ) { 2143 while ( incidence ) {
2144 Incidence *in = incidence->clone(); 2144 Incidence *in = incidence->clone();
2145 if ( addText ) 2145 if ( addText )
2146 description += in->summary() + "\n"; 2146 description += in->summary() + "\n";
2147 cal->addIncidence( in ); 2147 cal->addIncidence( in );
2148 incidence = delSel.next(); 2148 incidence = delSel.next();
2149 } 2149 }
2150 if ( beamDialog->beamVcal() ) { 2150 if ( beamDialog->beamVcal() ) {
2151 fn += ".vcs"; 2151 fn += ".vcs";
2152 FileStorage storage( cal, fn, new VCalFormat ); 2152 FileStorage storage( cal, fn, new VCalFormat );
2153 storage.save(); 2153 storage.save();
2154 } else { 2154 } else {
2155 fn += ".ics"; 2155 fn += ".ics";
2156 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2156 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2157 storage.save(); 2157 storage.save();
2158 } 2158 }
2159 delete cal; 2159 delete cal;
2160 mes = i18n("KO/Pi: Ready for beaming"); 2160 mes = i18n("KO/Pi: Ready for beaming");
2161 setCaption(mes); 2161 setCaption(mes);
2162 2162
2163#ifndef DESKTOP_VERSION 2163#ifndef DESKTOP_VERSION
2164 Ir *ir = new Ir( this ); 2164 Ir *ir = new Ir( this );
2165 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2165 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2166 ir->send( fn, description, "text/x-vCalendar" ); 2166 ir->send( fn, description, "text/x-vCalendar" );
2167#endif 2167#endif
2168 } 2168 }
2169} 2169}
2170void CalendarView::beamDone( Ir *ir ) 2170void CalendarView::beamDone( Ir *ir )
2171{ 2171{
2172#ifndef DESKTOP_VERSION 2172#ifndef DESKTOP_VERSION
2173 delete ir; 2173 delete ir;
2174#endif 2174#endif
2175} 2175}
2176 2176
2177void CalendarView::moveIncidence(Incidence * inc ) 2177void CalendarView::moveIncidence(Incidence * inc )
2178{ 2178{
2179 if ( !inc ) return; 2179 if ( !inc ) return;
2180 // qDebug("showDatePickerForIncidence( ) "); 2180 // qDebug("showDatePickerForIncidence( ) ");
2181 if ( mDateFrame->isVisible() ) 2181 if ( mDateFrame->isVisible() )
2182 mDateFrame->hide(); 2182 mDateFrame->hide();
2183 else { 2183 else {
2184 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2184 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2185 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2185 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2186 int dw = QApplication::desktop()->width(); 2186 int dw = QApplication::desktop()->width();
2187 int dh = QApplication::desktop()->height(); 2187 int dh = QApplication::desktop()->height();
2188 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2188 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2189 mDateFrame->show(); 2189 mDateFrame->show();
2190 } 2190 }
2191 mDatePickerMode = 2; 2191 mDatePickerMode = 2;
2192 mMoveIncidence = inc ; 2192 mMoveIncidence = inc ;
2193 QDate da; 2193 QDate da;
2194 if ( mMoveIncidence->type() == "Todo" ) { 2194 if ( mMoveIncidence->type() == "Todo" ) {
2195 Todo * to = (Todo *) mMoveIncidence; 2195 Todo * to = (Todo *) mMoveIncidence;
2196 if ( to->hasDueDate() ) 2196 if ( to->hasDueDate() )
2197 da = to->dtDue().date(); 2197 da = to->dtDue().date();
2198 else 2198 else
2199 da = QDate::currentDate(); 2199 da = QDate::currentDate();
2200 } else { 2200 } else {
2201 da = mMoveIncidence->dtStart().date(); 2201 da = mMoveIncidence->dtStart().date();
2202 } 2202 }
2203 mDatePicker->setDate( da ); 2203 mDatePicker->setDate( da );
2204} 2204}
2205void CalendarView::showDatePicker( ) 2205void CalendarView::showDatePicker( )
2206{ 2206{
2207 //qDebug("CalendarView::showDatePicker( ) "); 2207 //qDebug("CalendarView::showDatePicker( ) ");
2208 if ( mDateFrame->isVisible() ) 2208 if ( mDateFrame->isVisible() )
2209 mDateFrame->hide(); 2209 mDateFrame->hide();
2210 else { 2210 else {
2211 int w =mDatePicker->sizeHint().width() ; 2211 int w =mDatePicker->sizeHint().width() ;
2212 int h = mDatePicker->sizeHint().height() ; 2212 int h = mDatePicker->sizeHint().height() ;
2213 int dw = QApplication::desktop()->width(); 2213 int dw = QApplication::desktop()->width();
2214 int dh = QApplication::desktop()->height(); 2214 int dh = QApplication::desktop()->height();
2215 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2215 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2216 mDateFrame->show(); 2216 mDateFrame->show();
2217 } 2217 }
2218 mDatePickerMode = 1; 2218 mDatePickerMode = 1;
2219 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2219 mDatePicker->setDate( mNavigator->selectedDates().first() );
2220} 2220}
2221 2221
2222void CalendarView::showEventEditor() 2222void CalendarView::showEventEditor()
2223{ 2223{
2224#ifdef DESKTOP_VERSION 2224#ifdef DESKTOP_VERSION
2225 mEventEditor->show(); 2225 mEventEditor->show();
2226#else 2226#else
2227 mEventEditor->showMaximized(); 2227 mEventEditor->showMaximized();
2228#endif 2228#endif
2229} 2229}
2230void CalendarView::showTodoEditor() 2230void CalendarView::showTodoEditor()
2231{ 2231{
2232#ifdef DESKTOP_VERSION 2232#ifdef DESKTOP_VERSION
2233 mTodoEditor->show(); 2233 mTodoEditor->show();
2234#else 2234#else
2235 mTodoEditor->showMaximized(); 2235 mTodoEditor->showMaximized();
2236#endif 2236#endif
2237} 2237}
2238void CalendarView::cancelIncidence(Incidence * inc ) 2238void CalendarView::cancelIncidence(Incidence * inc )
2239{ 2239{
2240 inc->setCancelled( ! inc->cancelled() ); 2240 inc->setCancelled( ! inc->cancelled() );
2241 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2241 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2242 updateView(); 2242 updateView();
2243} 2243}
2244void CalendarView::cloneIncidence(Incidence * orgInc ) 2244void CalendarView::cloneIncidence(Incidence * orgInc )
2245{ 2245{
2246 Incidence * newInc = orgInc->clone(); 2246 Incidence * newInc = orgInc->clone();
2247 newInc->recreate(); 2247 newInc->recreate();
2248 2248
2249 if ( newInc->type() == "Todo" ) { 2249 if ( newInc->type() == "Todo" ) {
2250 Todo* t = (Todo*) newInc; 2250 Todo* t = (Todo*) newInc;
2251 mTodoEditor->editTodo( t ); 2251 mTodoEditor->editTodo( t );
2252 showTodoEditor(); 2252 showTodoEditor();
2253 if ( mTodoEditor->exec() ) { 2253 if ( mTodoEditor->exec() ) {
2254 mCalendar->addTodo( t ); 2254 mCalendar->addTodo( t );
2255 updateView(); 2255 updateView();
2256 } else { 2256 } else {
2257 delete t; 2257 delete t;
2258 } 2258 }
2259 } 2259 }
2260 else { 2260 else {
2261 Event* e = (Event*) newInc; 2261 Event* e = (Event*) newInc;
2262 mEventEditor->editEvent( e ); 2262 mEventEditor->editEvent( e );
2263 showEventEditor(); 2263 showEventEditor();
2264 if ( mEventEditor->exec() ) { 2264 if ( mEventEditor->exec() ) {
2265 mCalendar->addEvent( e ); 2265 mCalendar->addEvent( e );
2266 updateView(); 2266 updateView();
2267 } else { 2267 } else {
2268 delete e; 2268 delete e;
2269 } 2269 }
2270 } 2270 }
2271} 2271}
2272 2272
2273void CalendarView::newEvent() 2273void CalendarView::newEvent()
2274{ 2274{
2275 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2275 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2276 KOAgendaView *aView = mViewManager->agendaView(); 2276 KOAgendaView *aView = mViewManager->agendaView();
2277 if (aView) { 2277 if (aView) {
2278 if (aView->selectionStart().isValid()) { 2278 if (aView->selectionStart().isValid()) {
2279 if (aView->selectedIsAllDay()) { 2279 if (aView->selectedIsAllDay()) {
2280 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2280 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2281 } else { 2281 } else {
2282 newEvent(aView->selectionStart(),aView->selectionEnd()); 2282 newEvent(aView->selectionStart(),aView->selectionEnd());
2283 } 2283 }
2284 return; 2284 return;
2285 } 2285 }
2286 } 2286 }
2287 2287
2288 QDate date = mNavigator->selectedDates().first(); 2288 QDate date = mNavigator->selectedDates().first();
2289 QDateTime current = QDateTime::currentDateTime(); 2289 QDateTime current = QDateTime::currentDateTime();
2290 if ( date <= current.date() ) { 2290 if ( date <= current.date() ) {
2291 int hour = current.time().hour() +1; 2291 int hour = current.time().hour() +1;
2292 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2292 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2293 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2293 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2294 } else 2294 } else
2295 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2295 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2296 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2296 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2297 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2297 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2298} 2298}
2299 2299
2300void CalendarView::newEvent(QDateTime fh) 2300void CalendarView::newEvent(QDateTime fh)
2301{ 2301{
2302 newEvent(fh, 2302 newEvent(fh,
2303 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2303 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2304} 2304}
2305 2305
2306void CalendarView::newEvent(QDate dt) 2306void CalendarView::newEvent(QDate dt)
2307{ 2307{
2308 newEvent(QDateTime(dt, QTime(0,0,0)), 2308 newEvent(QDateTime(dt, QTime(0,0,0)),
2309 QDateTime(dt, QTime(0,0,0)), true); 2309 QDateTime(dt, QTime(0,0,0)), true);
2310} 2310}
2311 2311
2312void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2312void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2313{ 2313{
2314 2314
2315 mEventEditor->newEvent(fromHint,toHint,allDay); 2315 mEventEditor->newEvent(fromHint,toHint,allDay);
2316 if ( mFilterView->filtersEnabled() ) { 2316 if ( mFilterView->filtersEnabled() ) {
2317 CalFilter *filter = mFilterView->selectedFilter(); 2317 CalFilter *filter = mFilterView->selectedFilter();
2318 if (filter && filter->showCategories()) { 2318 if (filter && filter->showCategories()) {
2319 mEventEditor->setCategories(filter->categoryList().join(",") ); 2319 mEventEditor->setCategories(filter->categoryList().join(",") );
2320 } 2320 }
2321 if ( filter ) 2321 if ( filter )
2322 mEventEditor->setSecrecy( filter->getSecrecy() ); 2322 mEventEditor->setSecrecy( filter->getSecrecy() );
2323 } 2323 }
2324 showEventEditor(); 2324 showEventEditor();
2325} 2325}
2326void CalendarView::todoAdded(Todo * t) 2326void CalendarView::todoAdded(Todo * t)
2327{ 2327{
2328 2328
2329 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2329 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2330 updateTodoViews(); 2330 updateTodoViews();
2331} 2331}
2332void CalendarView::todoChanged(Todo * t) 2332void CalendarView::todoChanged(Todo * t)
2333{ 2333{
2334 emit todoModified( t, 4 ); 2334 emit todoModified( t, 4 );
2335 // updateTodoViews(); 2335 // updateTodoViews();
2336} 2336}
2337void CalendarView::todoToBeDeleted(Todo *) 2337void CalendarView::todoToBeDeleted(Todo *)
2338{ 2338{
2339 //qDebug("todoToBeDeleted(Todo *) "); 2339 //qDebug("todoToBeDeleted(Todo *) ");
2340 updateTodoViews(); 2340 updateTodoViews();
2341} 2341}
2342void CalendarView::todoDeleted() 2342void CalendarView::todoDeleted()
2343{ 2343{
2344 //qDebug(" todoDeleted()"); 2344 //qDebug(" todoDeleted()");
2345 updateTodoViews(); 2345 updateTodoViews();
2346} 2346}
2347 2347
2348 2348
2349 2349
2350void CalendarView::newTodo() 2350void CalendarView::newTodo()
2351{ 2351{
2352 2352
2353 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2353 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2354 if ( mFilterView->filtersEnabled() ) { 2354 if ( mFilterView->filtersEnabled() ) {
2355 CalFilter *filter = mFilterView->selectedFilter(); 2355 CalFilter *filter = mFilterView->selectedFilter();
2356 if (filter && filter->showCategories()) { 2356 if (filter && filter->showCategories()) {
2357 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2357 mTodoEditor->setCategories(filter->categoryList().join(",") );
2358 } 2358 }
2359 if ( filter ) 2359 if ( filter )
2360 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2360 mTodoEditor->setSecrecy( filter->getSecrecy() );
2361 } 2361 }
2362 showTodoEditor(); 2362 showTodoEditor();
2363} 2363}
2364 2364
2365void CalendarView::newSubTodo() 2365void CalendarView::newSubTodo()
2366{ 2366{
2367 Todo *todo = selectedTodo(); 2367 Todo *todo = selectedTodo();
2368 if ( todo ) newSubTodo( todo ); 2368 if ( todo ) newSubTodo( todo );
2369} 2369}
2370 2370
2371void CalendarView::newSubTodo(Todo *parentEvent) 2371void CalendarView::newSubTodo(Todo *parentEvent)
2372{ 2372{
2373 2373
2374 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2374 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2375 showTodoEditor(); 2375 showTodoEditor();
2376} 2376}
2377 2377
2378void CalendarView::newFloatingEvent() 2378void CalendarView::newFloatingEvent()
2379{ 2379{
2380 DateList tmpList = mNavigator->selectedDates(); 2380 DateList tmpList = mNavigator->selectedDates();
2381 QDate date = tmpList.first(); 2381 QDate date = tmpList.first();
2382 2382
2383 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2383 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2384 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2384 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2385} 2385}
2386 2386
2387 2387
2388void CalendarView::editEvent( Event *event ) 2388void CalendarView::editEvent( Event *event )
2389{ 2389{
2390 2390
2391 if ( !event ) return; 2391 if ( !event ) return;
2392 if ( event->isReadOnly() ) { 2392 if ( event->isReadOnly() ) {
2393 showEvent( event ); 2393 showEvent( event );
2394 return; 2394 return;
2395 } 2395 }
2396 mEventEditor->editEvent( event , mFlagEditDescription); 2396 mEventEditor->editEvent( event , mFlagEditDescription);
2397 showEventEditor(); 2397 showEventEditor();
2398} 2398}
2399void CalendarView::editJournal( Journal *jour ) 2399void CalendarView::editJournal( Journal *jour )
2400{ 2400{
2401 if ( !jour ) return; 2401 if ( !jour ) return;
2402 mDialogManager->hideSearchDialog(); 2402 mDialogManager->hideSearchDialog();
2403 mViewManager->showJournalView(); 2403 mViewManager->showJournalView();
2404 mNavigator->slotDaySelect( jour->dtStart().date() ); 2404 mNavigator->slotDaySelect( jour->dtStart().date() );
2405} 2405}
2406void CalendarView::editTodo( Todo *todo ) 2406void CalendarView::editTodo( Todo *todo )
2407{ 2407{
2408 if ( !todo ) return; 2408 if ( !todo ) return;
2409 2409
2410 if ( todo->isReadOnly() ) { 2410 if ( todo->isReadOnly() ) {
2411 showTodo( todo ); 2411 showTodo( todo );
2412 return; 2412 return;
2413 } 2413 }
2414 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2414 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2415 showTodoEditor(); 2415 showTodoEditor();
2416 2416
2417} 2417}
2418 2418
2419KOEventViewerDialog* CalendarView::getEventViewerDialog() 2419KOEventViewerDialog* CalendarView::getEventViewerDialog()
2420{ 2420{
2421 if ( !mEventViewerDialog ) { 2421 if ( !mEventViewerDialog ) {
2422 mEventViewerDialog = new KOEventViewerDialog(this); 2422 mEventViewerDialog = new KOEventViewerDialog(this);
2423 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2423 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2424 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2424 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2425 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2425 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2426 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2426 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2427 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2427 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2428 viewManager(), SLOT( showAgendaView( bool ) ) ); 2428 viewManager(), SLOT( showAgendaView( bool ) ) );
2429 mEventViewerDialog->resize( 640, 480 ); 2429 mEventViewerDialog->resize( 640, 480 );
2430 2430
2431 } 2431 }
2432 return mEventViewerDialog; 2432 return mEventViewerDialog;
2433} 2433}
2434void CalendarView::showEvent(Event *event) 2434void CalendarView::showEvent(Event *event)
2435{ 2435{
2436 getEventViewerDialog()->setEvent(event); 2436 getEventViewerDialog()->setEvent(event);
2437 getEventViewerDialog()->showMe(); 2437 getEventViewerDialog()->showMe();
2438} 2438}
2439 2439
2440void CalendarView::showTodo(Todo *event) 2440void CalendarView::showTodo(Todo *event)
2441{ 2441{
2442 getEventViewerDialog()->setTodo(event); 2442 getEventViewerDialog()->setTodo(event);
2443 getEventViewerDialog()->showMe(); 2443 getEventViewerDialog()->showMe();
2444} 2444}
2445void CalendarView::showJournal( Journal *jour ) 2445void CalendarView::showJournal( Journal *jour )
2446{ 2446{
2447 getEventViewerDialog()->setJournal(jour); 2447 getEventViewerDialog()->setJournal(jour);
2448 getEventViewerDialog()->showMe(); 2448 getEventViewerDialog()->showMe();
2449 2449
2450} 2450}
2451// void CalendarView::todoModified (Todo *event, int changed) 2451// void CalendarView::todoModified (Todo *event, int changed)
2452// { 2452// {
2453// // if (mDialogList.find (event) != mDialogList.end ()) { 2453// // if (mDialogList.find (event) != mDialogList.end ()) {
2454// // kdDebug() << "Todo modified and open" << endl; 2454// // kdDebug() << "Todo modified and open" << endl;
2455// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2455// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2456// // temp->modified (changed); 2456// // temp->modified (changed);
2457 2457
2458// // } 2458// // }
2459 2459
2460// mViewManager->updateView(); 2460// mViewManager->updateView();
2461// } 2461// }
2462 2462
2463void CalendarView::appointment_show() 2463void CalendarView::appointment_show()
2464{ 2464{
2465 Event *anEvent = 0; 2465 Event *anEvent = 0;
2466 2466
2467 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2467 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2468 2468
2469 if (mViewManager->currentView()->isEventView()) { 2469 if (mViewManager->currentView()->isEventView()) {
2470 if ( incidence && incidence->type() == "Event" ) { 2470 if ( incidence && incidence->type() == "Event" ) {
2471 anEvent = static_cast<Event *>(incidence); 2471 anEvent = static_cast<Event *>(incidence);
2472 } 2472 }
2473 } 2473 }
2474 2474
2475 if (!anEvent) { 2475 if (!anEvent) {
2476 KNotifyClient::beep(); 2476 KNotifyClient::beep();
2477 return; 2477 return;
2478 } 2478 }
2479 2479
2480 showEvent(anEvent); 2480 showEvent(anEvent);
2481} 2481}
2482 2482
2483void CalendarView::appointment_edit() 2483void CalendarView::appointment_edit()
2484{ 2484{
2485 Event *anEvent = 0; 2485 Event *anEvent = 0;
2486 2486
2487 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2487 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2488 2488
2489 if (mViewManager->currentView()->isEventView()) { 2489 if (mViewManager->currentView()->isEventView()) {
2490 if ( incidence && incidence->type() == "Event" ) { 2490 if ( incidence && incidence->type() == "Event" ) {
2491 anEvent = static_cast<Event *>(incidence); 2491 anEvent = static_cast<Event *>(incidence);
2492 } 2492 }
2493 } 2493 }
2494 2494
2495 if (!anEvent) { 2495 if (!anEvent) {
2496 KNotifyClient::beep(); 2496 KNotifyClient::beep();
2497 return; 2497 return;
2498 } 2498 }
2499 2499
2500 editEvent(anEvent); 2500 editEvent(anEvent);
2501} 2501}
2502 2502
2503void CalendarView::appointment_delete() 2503void CalendarView::appointment_delete()
2504{ 2504{
2505 Event *anEvent = 0; 2505 Event *anEvent = 0;
2506 2506
2507 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2507 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2508 2508
2509 if (mViewManager->currentView()->isEventView()) { 2509 if (mViewManager->currentView()->isEventView()) {
2510 if ( incidence && incidence->type() == "Event" ) { 2510 if ( incidence && incidence->type() == "Event" ) {
2511 anEvent = static_cast<Event *>(incidence); 2511 anEvent = static_cast<Event *>(incidence);
2512 } 2512 }
2513 } 2513 }
2514 2514
2515 if (!anEvent) { 2515 if (!anEvent) {
2516 KNotifyClient::beep(); 2516 KNotifyClient::beep();
2517 return; 2517 return;
2518 } 2518 }
2519 2519
2520 deleteEvent(anEvent); 2520 deleteEvent(anEvent);
2521} 2521}
2522 2522
2523void CalendarView::todo_unsub(Todo *anTodo ) 2523void CalendarView::todo_unsub(Todo *anTodo )
2524{ 2524{
2525 // Todo *anTodo = selectedTodo(); 2525 // Todo *anTodo = selectedTodo();
2526 if (!anTodo) return; 2526 if (!anTodo) return;
2527 if (!anTodo->relatedTo()) return; 2527 if (!anTodo->relatedTo()) return;
2528 anTodo->relatedTo()->removeRelation(anTodo); 2528 anTodo->relatedTo()->removeRelation(anTodo);
2529 anTodo->setRelatedTo(0); 2529 anTodo->setRelatedTo(0);
2530 anTodo->updated(); 2530 anTodo->updated();
2531 anTodo->setRelatedToUid(""); 2531 anTodo->setRelatedToUid("");
2532 setModified(true); 2532 setModified(true);
2533 updateView(); 2533 updateView();
2534} 2534}
2535 2535
2536void CalendarView::deleteTodo(Todo *todo) 2536void CalendarView::deleteTodo(Todo *todo)
2537{ 2537{
2538 if (!todo) { 2538 if (!todo) {
2539 KNotifyClient::beep(); 2539 KNotifyClient::beep();
2540 return; 2540 return;
2541 } 2541 }
2542 if (KOPrefs::instance()->mConfirm) { 2542 if (KOPrefs::instance()->mConfirm) {
2543 switch (msgItemDelete()) { 2543 switch (msgItemDelete()) {
2544 case KMessageBox::Continue: // OK 2544 case KMessageBox::Continue: // OK
2545 if (!todo->relations().isEmpty()) { 2545 if (!todo->relations().isEmpty()) {
2546 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2546 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2547 i18n("Delete To-Do")); 2547 i18n("Delete To-Do"));
2548 } else { 2548 } else {
2549 checkZaurusId( todo->zaurusId(), true ); 2549 checkZaurusId( todo->zaurusId(), true );
2550 calendar()->deleteTodo(todo); 2550 calendar()->deleteTodo(todo);
2551 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2551 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2552 updateView(); 2552 updateView();
2553 } 2553 }
2554 break; 2554 break;
2555 } // switch 2555 } // switch
2556 } else { 2556 } else {
2557 if (!todo->relations().isEmpty()) { 2557 if (!todo->relations().isEmpty()) {
2558 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2558 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2559 i18n("Delete To-Do")); 2559 i18n("Delete To-Do"));
2560 } else { 2560 } else {
2561 checkZaurusId( todo->zaurusId(), true ); 2561 checkZaurusId( todo->zaurusId(), true );
2562 mCalendar->deleteTodo(todo); 2562 mCalendar->deleteTodo(todo);
2563 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2563 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2564 updateView(); 2564 updateView();
2565 } 2565 }
2566 } 2566 }
2567 emit updateSearchDialog(); 2567 emit updateSearchDialog();
2568} 2568}
2569void CalendarView::deleteJournal(Journal *jour) 2569void CalendarView::deleteJournal(Journal *jour)
2570{ 2570{
2571 if (!jour) { 2571 if (!jour) {
2572 KNotifyClient::beep(); 2572 KNotifyClient::beep();
2573 return; 2573 return;
2574 } 2574 }
2575 if (KOPrefs::instance()->mConfirm) { 2575 if (KOPrefs::instance()->mConfirm) {
2576 switch (msgItemDelete()) { 2576 switch (msgItemDelete()) {
2577 case KMessageBox::Continue: // OK 2577 case KMessageBox::Continue: // OK
2578 calendar()->deleteJournal(jour); 2578 calendar()->deleteJournal(jour);
2579 updateView(); 2579 updateView();
2580 break; 2580 break;
2581 } // switch 2581 } // switch
2582 } else { 2582 } else {
2583 calendar()->deleteJournal(jour);; 2583 calendar()->deleteJournal(jour);;
2584 updateView(); 2584 updateView();
2585 } 2585 }
2586 emit updateSearchDialog(); 2586 emit updateSearchDialog();
2587} 2587}
2588 2588
2589void CalendarView::deleteEvent(Event *anEvent) 2589void CalendarView::deleteEvent(Event *anEvent)
2590{ 2590{
2591 if (!anEvent) { 2591 if (!anEvent) {
2592 KNotifyClient::beep(); 2592 KNotifyClient::beep();
2593 return; 2593 return;
2594 } 2594 }
2595 2595
2596 if (anEvent->recurrence()->doesRecur()) { 2596 if (anEvent->recurrence()->doesRecur()) {
2597 QDate itemDate = mViewManager->currentSelectionDate(); 2597 QDate itemDate = mViewManager->currentSelectionDate();
2598 int km; 2598 int km;
2599 if (!itemDate.isValid()) { 2599 if (!itemDate.isValid()) {
2600 //kdDebug() << "Date Not Valid" << endl; 2600 //kdDebug() << "Date Not Valid" << endl;
2601 if (KOPrefs::instance()->mConfirm) { 2601 if (KOPrefs::instance()->mConfirm) {
2602 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2602 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2603 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2603 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2604 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2604 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2605 if ( km == KMessageBox::Continue ) 2605 if ( km == KMessageBox::Continue )
2606 km = KMessageBox::No; // No = all below 2606 km = KMessageBox::No; // No = all below
2607 } else 2607 } else
2608 km = KMessageBox::No; 2608 km = KMessageBox::No;
2609 } else { 2609 } else {
2610 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2610 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2611 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2611 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2612 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2612 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2613 i18n("KO/Pi Confirmation"),i18n("Current"), 2613 i18n("KO/Pi Confirmation"),i18n("Current"),
2614 i18n("All")); 2614 i18n("All"));
2615 } 2615 }
2616 switch(km) { 2616 switch(km) {
2617 2617
2618 case KMessageBox::No: // Continue // all 2618 case KMessageBox::No: // Continue // all
2619 //qDebug("KMessageBox::No "); 2619 //qDebug("KMessageBox::No ");
2620 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2620 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2621 schedule(Scheduler::Cancel,anEvent); 2621 schedule(Scheduler::Cancel,anEvent);
2622 2622
2623 checkZaurusId( anEvent->zaurusId()); 2623 checkZaurusId( anEvent->zaurusId());
2624 mCalendar->deleteEvent(anEvent); 2624 mCalendar->deleteEvent(anEvent);
2625 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2625 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2626 break; 2626 break;
2627 2627
2628 // Disabled because it does not work 2628 // Disabled because it does not work
2629 //#if 0 2629 //#if 0
2630 case KMessageBox::Yes: // just this one 2630 case KMessageBox::Yes: // just this one
2631 //QDate qd = mNavigator->selectedDates().first(); 2631 //QDate qd = mNavigator->selectedDates().first();
2632 //if (!qd.isValid()) { 2632 //if (!qd.isValid()) {
2633 // kdDebug() << "no date selected, or invalid date" << endl; 2633 // kdDebug() << "no date selected, or invalid date" << endl;
2634 // KNotifyClient::beep(); 2634 // KNotifyClient::beep();
2635 // return; 2635 // return;
2636 //} 2636 //}
2637 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2637 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2638 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2638 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2639 anEvent->addExDate(itemDate); 2639 anEvent->addExDate(itemDate);
2640 int duration = anEvent->recurrence()->duration(); 2640 int duration = anEvent->recurrence()->duration();
2641 if ( duration > 0 ) { 2641 if ( duration > 0 ) {
2642 anEvent->recurrence()->setDuration( duration - 1 ); 2642 anEvent->recurrence()->setDuration( duration - 1 );
2643 } 2643 }
2644 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2644 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2645 } 2645 }
2646 break; 2646 break;
2647 //#endif 2647 //#endif
2648 } // switch 2648 } // switch
2649 } else { 2649 } else {
2650 if (KOPrefs::instance()->mConfirm) { 2650 if (KOPrefs::instance()->mConfirm) {
2651 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2651 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2652 i18n("\nAre you sure you want\nto delete this event?"), 2652 i18n("\nAre you sure you want\nto delete this event?"),
2653 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2653 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2654 case KMessageBox::Continue: // OK 2654 case KMessageBox::Continue: // OK
2655 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2655 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2656 schedule(Scheduler::Cancel,anEvent); 2656 schedule(Scheduler::Cancel,anEvent);
2657 checkZaurusId( anEvent->zaurusId()); 2657 checkZaurusId( anEvent->zaurusId());
2658 mCalendar->deleteEvent(anEvent); 2658 mCalendar->deleteEvent(anEvent);
2659 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2659 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2660 break; 2660 break;
2661 } // switch 2661 } // switch
2662 } else { 2662 } else {
2663 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2663 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2664 schedule(Scheduler::Cancel,anEvent); 2664 schedule(Scheduler::Cancel,anEvent);
2665 checkZaurusId( anEvent->zaurusId()); 2665 checkZaurusId( anEvent->zaurusId());
2666 mCalendar->deleteEvent(anEvent); 2666 mCalendar->deleteEvent(anEvent);
2667 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2667 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2668 } 2668 }
2669 } // if-else 2669 } // if-else
2670 emit updateSearchDialog(); 2670 emit updateSearchDialog();
2671} 2671}
2672 2672
2673bool CalendarView::deleteEvent(const QString &uid) 2673bool CalendarView::deleteEvent(const QString &uid)
2674{ 2674{
2675 Event *ev = mCalendar->event(uid); 2675 Event *ev = mCalendar->event(uid);
2676 if (ev) { 2676 if (ev) {
2677 deleteEvent(ev); 2677 deleteEvent(ev);
2678 return true; 2678 return true;
2679 } else { 2679 } else {
2680 return false; 2680 return false;
2681 } 2681 }
2682} 2682}
2683 2683
2684/*****************************************************************************/ 2684/*****************************************************************************/
2685 2685
2686void CalendarView::action_mail() 2686void CalendarView::action_mail()
2687{ 2687{
2688#ifndef KORG_NOMAIL 2688#ifndef KORG_NOMAIL
2689 KOMailClient mailClient; 2689 KOMailClient mailClient;
2690 2690
2691 Incidence *incidence = currentSelection(); 2691 Incidence *incidence = currentSelection();
2692 2692
2693 if (!incidence) { 2693 if (!incidence) {
2694 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2694 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2695 return; 2695 return;
2696 } 2696 }
2697 if(incidence->attendeeCount() == 0 ) { 2697 if(incidence->attendeeCount() == 0 ) {
2698 KMessageBox::sorry(this, 2698 KMessageBox::sorry(this,
2699 i18n("Can't generate mail:\nNo attendees defined.\n")); 2699 i18n("Can't generate mail:\nNo attendees defined.\n"));
2700 return; 2700 return;
2701 } 2701 }
2702 2702
2703 CalendarLocal cal_tmp; 2703 CalendarLocal cal_tmp;
2704 Event *event = 0; 2704 Event *event = 0;
2705 Event *ev = 0; 2705 Event *ev = 0;
2706 if ( incidence && incidence->type() == "Event" ) { 2706 if ( incidence && incidence->type() == "Event" ) {
2707 event = static_cast<Event *>(incidence); 2707 event = static_cast<Event *>(incidence);
2708 ev = new Event(*event); 2708 ev = new Event(*event);
2709 cal_tmp.addEvent(ev); 2709 cal_tmp.addEvent(ev);
2710 } 2710 }
2711 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2711 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2712 QString attachment = mForm.toString( &cal_tmp ); 2712 QString attachment = mForm.toString( &cal_tmp );
2713 if (ev) delete(ev); 2713 if (ev) delete(ev);
2714 2714
2715 mailClient.mailAttendees(currentSelection(), attachment); 2715 mailClient.mailAttendees(currentSelection(), attachment);
2716 2716
2717#endif 2717#endif
2718 2718
2719#if 0 2719#if 0
2720 Event *anEvent = 0; 2720 Event *anEvent = 0;
2721 if (mViewManager->currentView()->isEventView()) { 2721 if (mViewManager->currentView()->isEventView()) {
2722 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2722 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2723 } 2723 }
2724 2724
2725 if (!anEvent) { 2725 if (!anEvent) {
2726 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2726 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2727 return; 2727 return;
2728 } 2728 }
2729 if(anEvent->attendeeCount() == 0 ) { 2729 if(anEvent->attendeeCount() == 0 ) {
2730 KMessageBox::sorry(this, 2730 KMessageBox::sorry(this,
2731 i18n("Can't generate mail:\nNo attendees defined.\n")); 2731 i18n("Can't generate mail:\nNo attendees defined.\n"));
2732 return; 2732 return;
2733 } 2733 }
2734 2734
2735 mailobject.emailEvent(anEvent); 2735 mailobject.emailEvent(anEvent);
2736#endif 2736#endif
2737} 2737}
2738 2738
2739 2739
2740void CalendarView::schedule_publish(Incidence *incidence) 2740void CalendarView::schedule_publish(Incidence *incidence)
2741{ 2741{
2742 Event *event = 0; 2742 Event *event = 0;
2743 Todo *todo = 0; 2743 Todo *todo = 0;
2744 2744
2745 if (incidence == 0) { 2745 if (incidence == 0) {
2746 incidence = mViewManager->currentView()->selectedIncidences().first(); 2746 incidence = mViewManager->currentView()->selectedIncidences().first();
2747 if (incidence == 0) { 2747 if (incidence == 0) {
2748 incidence = mTodoList->selectedIncidences().first(); 2748 incidence = mTodoList->selectedIncidences().first();
2749 } 2749 }
2750 } 2750 }
2751 if ( incidence && incidence->type() == "Event" ) { 2751 if ( incidence && incidence->type() == "Event" ) {
2752 event = static_cast<Event *>(incidence); 2752 event = static_cast<Event *>(incidence);
2753 } else { 2753 } else {
2754 if ( incidence && incidence->type() == "Todo" ) { 2754 if ( incidence && incidence->type() == "Todo" ) {
2755 todo = static_cast<Todo *>(incidence); 2755 todo = static_cast<Todo *>(incidence);
2756 } 2756 }
2757 } 2757 }
2758 2758
2759 if (!event && !todo) { 2759 if (!event && !todo) {
2760 KMessageBox::sorry(this,i18n("No event selected.")); 2760 KMessageBox::sorry(this,i18n("No event selected."));
2761 return; 2761 return;
2762 } 2762 }
2763 2763
2764 PublishDialog *publishdlg = new PublishDialog(); 2764 PublishDialog *publishdlg = new PublishDialog();
2765 if (incidence->attendeeCount()>0) { 2765 if (incidence->attendeeCount()>0) {
2766 QPtrList<Attendee> attendees = incidence->attendees(); 2766 QPtrList<Attendee> attendees = incidence->attendees();
2767 attendees.first(); 2767 attendees.first();
2768 while ( attendees.current()!=0 ) { 2768 while ( attendees.current()!=0 ) {
2769 publishdlg->addAttendee(attendees.current()); 2769 publishdlg->addAttendee(attendees.current());
2770 attendees.next(); 2770 attendees.next();
2771 } 2771 }
2772 } 2772 }
2773 bool send = true; 2773 bool send = true;
2774 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2774 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2775 if ( publishdlg->exec() != QDialog::Accepted ) 2775 if ( publishdlg->exec() != QDialog::Accepted )
2776 send = false; 2776 send = false;
2777 } 2777 }
2778 if ( send ) { 2778 if ( send ) {
2779 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2779 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2780 if ( event ) { 2780 if ( event ) {
2781 Event *ev = new Event(*event); 2781 Event *ev = new Event(*event);
2782 ev->registerObserver(0); 2782 ev->registerObserver(0);
2783 ev->clearAttendees(); 2783 ev->clearAttendees();
2784 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2784 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2785 delete(ev); 2785 delete(ev);
2786 } 2786 }
2787 } else { 2787 } else {
2788 if ( todo ) { 2788 if ( todo ) {
2789 Todo *ev = new Todo(*todo); 2789 Todo *ev = new Todo(*todo);
2790 ev->registerObserver(0); 2790 ev->registerObserver(0);
2791 ev->clearAttendees(); 2791 ev->clearAttendees();
2792 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2792 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2793 delete(ev); 2793 delete(ev);
2794 } 2794 }
2795 } 2795 }
2796 } 2796 }
2797 } 2797 }
2798 delete publishdlg; 2798 delete publishdlg;
2799} 2799}
2800 2800
2801void CalendarView::schedule_request(Incidence *incidence) 2801void CalendarView::schedule_request(Incidence *incidence)
2802{ 2802{
2803 schedule(Scheduler::Request,incidence); 2803 schedule(Scheduler::Request,incidence);
2804} 2804}
2805 2805
2806void CalendarView::schedule_refresh(Incidence *incidence) 2806void CalendarView::schedule_refresh(Incidence *incidence)
2807{ 2807{
2808 schedule(Scheduler::Refresh,incidence); 2808 schedule(Scheduler::Refresh,incidence);
2809} 2809}
2810 2810
2811void CalendarView::schedule_cancel(Incidence *incidence) 2811void CalendarView::schedule_cancel(Incidence *incidence)
2812{ 2812{
2813 schedule(Scheduler::Cancel,incidence); 2813 schedule(Scheduler::Cancel,incidence);
2814} 2814}
2815 2815
2816void CalendarView::schedule_add(Incidence *incidence) 2816void CalendarView::schedule_add(Incidence *incidence)
2817{ 2817{
2818 schedule(Scheduler::Add,incidence); 2818 schedule(Scheduler::Add,incidence);
2819} 2819}
2820 2820
2821void CalendarView::schedule_reply(Incidence *incidence) 2821void CalendarView::schedule_reply(Incidence *incidence)
2822{ 2822{
2823 schedule(Scheduler::Reply,incidence); 2823 schedule(Scheduler::Reply,incidence);
2824} 2824}
2825 2825
2826void CalendarView::schedule_counter(Incidence *incidence) 2826void CalendarView::schedule_counter(Incidence *incidence)
2827{ 2827{
2828 schedule(Scheduler::Counter,incidence); 2828 schedule(Scheduler::Counter,incidence);
2829} 2829}
2830 2830
2831void CalendarView::schedule_declinecounter(Incidence *incidence) 2831void CalendarView::schedule_declinecounter(Incidence *incidence)
2832{ 2832{
2833 schedule(Scheduler::Declinecounter,incidence); 2833 schedule(Scheduler::Declinecounter,incidence);
2834} 2834}
2835 2835
2836void CalendarView::schedule_publish_freebusy(int daysToPublish) 2836void CalendarView::schedule_publish_freebusy(int daysToPublish)
2837{ 2837{
2838 QDateTime start = QDateTime::currentDateTime(); 2838 QDateTime start = QDateTime::currentDateTime();
2839 QDateTime end = start.addDays(daysToPublish); 2839 QDateTime end = start.addDays(daysToPublish);
2840 2840
2841 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2841 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2842 freebusy->setOrganizer(KOPrefs::instance()->email()); 2842 freebusy->setOrganizer(KOPrefs::instance()->email());
2843 2843
2844 2844
2845 PublishDialog *publishdlg = new PublishDialog(); 2845 PublishDialog *publishdlg = new PublishDialog();
2846 if ( publishdlg->exec() == QDialog::Accepted ) { 2846 if ( publishdlg->exec() == QDialog::Accepted ) {
2847 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2847 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2848 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2848 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2849 delete(freebusy); 2849 delete(freebusy);
2850 } 2850 }
2851 } 2851 }
2852 delete publishdlg; 2852 delete publishdlg;
2853} 2853}
2854 2854
2855void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2855void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2856{ 2856{
2857 Event *event = 0; 2857 Event *event = 0;
2858 Todo *todo = 0; 2858 Todo *todo = 0;
2859 2859
2860 if (incidence == 0) { 2860 if (incidence == 0) {
2861 incidence = mViewManager->currentView()->selectedIncidences().first(); 2861 incidence = mViewManager->currentView()->selectedIncidences().first();
2862 if (incidence == 0) { 2862 if (incidence == 0) {
2863 incidence = mTodoList->selectedIncidences().first(); 2863 incidence = mTodoList->selectedIncidences().first();
2864 } 2864 }
2865 } 2865 }
2866 if ( incidence && incidence->type() == "Event" ) { 2866 if ( incidence && incidence->type() == "Event" ) {
2867 event = static_cast<Event *>(incidence); 2867 event = static_cast<Event *>(incidence);
2868 } 2868 }
2869 if ( incidence && incidence->type() == "Todo" ) { 2869 if ( incidence && incidence->type() == "Todo" ) {
2870 todo = static_cast<Todo *>(incidence); 2870 todo = static_cast<Todo *>(incidence);
2871 } 2871 }
2872 2872
2873 if (!event && !todo) { 2873 if (!event && !todo) {
2874 KMessageBox::sorry(this,i18n("No event selected.")); 2874 KMessageBox::sorry(this,i18n("No event selected."));
2875 return; 2875 return;
2876 } 2876 }
2877 2877
2878 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2878 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2879 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2879 KMessageBox::sorry(this,i18n("The event has no attendees."));
2880 return; 2880 return;
2881 } 2881 }
2882 2882
2883 Event *ev = 0; 2883 Event *ev = 0;
2884 if (event) ev = new Event(*event); 2884 if (event) ev = new Event(*event);
2885 Todo *to = 0; 2885 Todo *to = 0;
2886 if (todo) to = new Todo(*todo); 2886 if (todo) to = new Todo(*todo);
2887 2887
2888 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2888 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2889 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2889 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2890 if (!me) { 2890 if (!me) {
2891 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2891 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2892 return; 2892 return;
2893 } 2893 }
2894 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2894 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2895 StatusDialog *statdlg = new StatusDialog(this); 2895 StatusDialog *statdlg = new StatusDialog(this);
2896 if (!statdlg->exec()==QDialog::Accepted) return; 2896 if (!statdlg->exec()==QDialog::Accepted) return;
2897 me->setStatus( statdlg->status() ); 2897 me->setStatus( statdlg->status() );
2898 delete(statdlg); 2898 delete(statdlg);
2899 } 2899 }
2900 Attendee *menew = new Attendee(*me); 2900 Attendee *menew = new Attendee(*me);
2901 if (ev) { 2901 if (ev) {
2902 ev->clearAttendees(); 2902 ev->clearAttendees();
2903 ev->addAttendee(menew,false); 2903 ev->addAttendee(menew,false);
2904 } else { 2904 } else {
2905 if (to) { 2905 if (to) {
2906 todo->clearAttendees(); 2906 todo->clearAttendees();
2907 todo->addAttendee(menew,false); 2907 todo->addAttendee(menew,false);
2908 } 2908 }
2909 } 2909 }
2910 } 2910 }
2911 2911
2912 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2912 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2913 if (ev) { 2913 if (ev) {
2914 if ( !dlg->addMessage(ev,method) ) delete(ev); 2914 if ( !dlg->addMessage(ev,method) ) delete(ev);
2915 } else { 2915 } else {
2916 if (to) { 2916 if (to) {
2917 if ( !dlg->addMessage(to,method) ) delete(to); 2917 if ( !dlg->addMessage(to,method) ) delete(to);
2918 } 2918 }
2919 } 2919 }
2920} 2920}
2921 2921
2922void CalendarView::openAddressbook() 2922void CalendarView::openAddressbook()
2923{ 2923{
2924 KRun::runCommand("kaddressbook"); 2924 KRun::runCommand("kaddressbook");
2925} 2925}
2926 2926
2927void CalendarView::setModified(bool modified) 2927void CalendarView::setModified(bool modified)
2928{ 2928{
2929 if ( modified ) 2929 if ( modified )
2930 emit signalmodified(); 2930 emit signalmodified();
2931 if (mModified != modified) { 2931 if (mModified != modified) {
2932 mModified = modified; 2932 mModified = modified;
2933 emit modifiedChanged(mModified); 2933 emit modifiedChanged(mModified);
2934 } 2934 }
2935} 2935}
2936 2936
2937bool CalendarView::isReadOnly() 2937bool CalendarView::isReadOnly()
2938{ 2938{
2939 return mReadOnly; 2939 return mReadOnly;
2940} 2940}
2941 2941
2942void CalendarView::setReadOnly(bool readOnly) 2942void CalendarView::setReadOnly(bool readOnly)
2943{ 2943{
2944 if (mReadOnly != readOnly) { 2944 if (mReadOnly != readOnly) {
2945 mReadOnly = readOnly; 2945 mReadOnly = readOnly;
2946 emit readOnlyChanged(mReadOnly); 2946 emit readOnlyChanged(mReadOnly);
2947 } 2947 }
2948} 2948}
2949 2949
2950bool CalendarView::isModified() 2950bool CalendarView::isModified()
2951{ 2951{
2952 return mModified; 2952 return mModified;
2953} 2953}
2954 2954
2955void CalendarView::printSetup() 2955void CalendarView::printSetup()
2956{ 2956{
2957#ifndef KORG_NOPRINTER 2957#ifndef KORG_NOPRINTER
2958 createPrinter(); 2958 createPrinter();
2959 2959
2960 mCalPrinter->setupPrinter(); 2960 mCalPrinter->setupPrinter();
2961#endif 2961#endif
2962} 2962}
2963 2963
2964void CalendarView::print() 2964void CalendarView::print()
2965{ 2965{
2966#ifndef KORG_NOPRINTER 2966#ifndef KORG_NOPRINTER
2967 createPrinter(); 2967 createPrinter();
2968 2968
2969 DateList tmpDateList = mNavigator->selectedDates(); 2969 DateList tmpDateList = mNavigator->selectedDates();
2970 mCalPrinter->print(CalPrinter::Month, 2970 mCalPrinter->print(CalPrinter::Month,
2971 tmpDateList.first(), tmpDateList.last()); 2971 tmpDateList.first(), tmpDateList.last());
2972#endif 2972#endif
2973} 2973}
2974 2974
2975void CalendarView::printPreview() 2975void CalendarView::printPreview()
2976{ 2976{
2977#ifndef KORG_NOPRINTER 2977#ifndef KORG_NOPRINTER
2978 kdDebug() << "CalendarView::printPreview()" << endl; 2978 kdDebug() << "CalendarView::printPreview()" << endl;
2979 2979
2980 createPrinter(); 2980 createPrinter();
2981 2981
2982 DateList tmpDateList = mNavigator->selectedDates(); 2982 DateList tmpDateList = mNavigator->selectedDates();
2983 2983
2984 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 2984 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
2985 tmpDateList.last()); 2985 tmpDateList.last());
2986#endif 2986#endif
2987} 2987}
2988 2988
2989void CalendarView::exportICalendar() 2989void CalendarView::exportICalendar()
2990{ 2990{
2991 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 2991 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
2992 2992
2993 // Force correct extension 2993 // Force correct extension
2994 if (filename.right(4) != ".ics") filename += ".ics"; 2994 if (filename.right(4) != ".ics") filename += ".ics";
2995 2995
2996 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2996 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2997 storage.save(); 2997 storage.save();
2998} 2998}
2999 2999
3000bool CalendarView::exportVCalendar( QString filename ) 3000bool CalendarView::exportVCalendar( QString filename )
3001{ 3001{
3002 if (mCalendar->journals().count() > 0) { 3002 if (mCalendar->journals().count() > 0) {
3003 int result = KMessageBox::warningContinueCancel(this, 3003 int result = KMessageBox::warningContinueCancel(this,
3004 i18n("The journal entries can not be\nexported to a vCalendar file."), 3004 i18n("The journal entries can not be\nexported to a vCalendar file."),
3005 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3005 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3006 true); 3006 true);
3007 if (result != KMessageBox::Continue) return false; 3007 if (result != KMessageBox::Continue) return false;
3008 } 3008 }
3009 3009
3010 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3010 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3011 3011
3012 // Force correct extension 3012 // Force correct extension
3013 if (filename.right(4) != ".vcs") filename += ".vcs"; 3013 if (filename.right(4) != ".vcs") filename += ".vcs";
3014 3014
3015 FileStorage storage( mCalendar, filename, new VCalFormat ); 3015 FileStorage storage( mCalendar, filename, new VCalFormat );
3016 return storage.save(); 3016 return storage.save();
3017 3017
3018} 3018}
3019 3019
3020void CalendarView::eventUpdated(Incidence *) 3020void CalendarView::eventUpdated(Incidence *)
3021{ 3021{
3022 setModified(); 3022 setModified();
3023 // Don't call updateView here. The code, which has caused the update of the 3023 // Don't call updateView here. The code, which has caused the update of the
3024 // event is responsible for updating the view. 3024 // event is responsible for updating the view.
3025 // updateView(); 3025 // updateView();
3026} 3026}
3027 3027
3028void CalendarView::adaptNavigationUnits() 3028void CalendarView::adaptNavigationUnits()
3029{ 3029{
3030 if (mViewManager->currentView()->isEventView()) { 3030 if (mViewManager->currentView()->isEventView()) {
3031 int days = mViewManager->currentView()->currentDateCount(); 3031 int days = mViewManager->currentView()->currentDateCount();
3032 if (days == 1) { 3032 if (days == 1) {
3033 emit changeNavStringPrev(i18n("&Previous Day")); 3033 emit changeNavStringPrev(i18n("&Previous Day"));
3034 emit changeNavStringNext(i18n("&Next Day")); 3034 emit changeNavStringNext(i18n("&Next Day"));
3035 } else { 3035 } else {
3036 emit changeNavStringPrev(i18n("&Previous Week")); 3036 emit changeNavStringPrev(i18n("&Previous Week"));
3037 emit changeNavStringNext(i18n("&Next Week")); 3037 emit changeNavStringNext(i18n("&Next Week"));
3038 } 3038 }
3039 } 3039 }
3040} 3040}
3041 3041
3042void CalendarView::processMainViewSelection( Incidence *incidence ) 3042void CalendarView::processMainViewSelection( Incidence *incidence )
3043{ 3043{
3044 if ( incidence ) mTodoList->clearSelection(); 3044 if ( incidence ) mTodoList->clearSelection();
3045 processIncidenceSelection( incidence ); 3045 processIncidenceSelection( incidence );
3046} 3046}
3047 3047
3048void CalendarView::processTodoListSelection( Incidence *incidence ) 3048void CalendarView::processTodoListSelection( Incidence *incidence )
3049{ 3049{
3050 if ( incidence && mViewManager->currentView() ) { 3050 if ( incidence && mViewManager->currentView() ) {
3051 mViewManager->currentView()->clearSelection(); 3051 mViewManager->currentView()->clearSelection();
3052 } 3052 }
3053 processIncidenceSelection( incidence ); 3053 processIncidenceSelection( incidence );
3054} 3054}
3055 3055
3056void CalendarView::processIncidenceSelection( Incidence *incidence ) 3056void CalendarView::processIncidenceSelection( Incidence *incidence )
3057{ 3057{
3058 if ( incidence == mSelectedIncidence ) return; 3058 if ( incidence == mSelectedIncidence ) return;
3059 3059
3060 mSelectedIncidence = incidence; 3060 mSelectedIncidence = incidence;
3061 3061
3062 emit incidenceSelected( mSelectedIncidence ); 3062 emit incidenceSelected( mSelectedIncidence );
3063 3063
3064 if ( incidence && incidence->type() == "Event" ) { 3064 if ( incidence && incidence->type() == "Event" ) {
3065 Event *event = static_cast<Event *>( incidence ); 3065 Event *event = static_cast<Event *>( incidence );
3066 if ( event->organizer() == KOPrefs::instance()->email() ) { 3066 if ( event->organizer() == KOPrefs::instance()->email() ) {
3067 emit organizerEventsSelected( true ); 3067 emit organizerEventsSelected( true );
3068 } else { 3068 } else {
3069 emit organizerEventsSelected(false); 3069 emit organizerEventsSelected(false);
3070 } 3070 }
3071 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3071 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3072 KOPrefs::instance()->email() ) ) { 3072 KOPrefs::instance()->email() ) ) {
3073 emit groupEventsSelected( true ); 3073 emit groupEventsSelected( true );
3074 } else { 3074 } else {
3075 emit groupEventsSelected(false); 3075 emit groupEventsSelected(false);
3076 } 3076 }
3077 return; 3077 return;
3078 } else { 3078 } else {
3079 if ( incidence && incidence->type() == "Todo" ) { 3079 if ( incidence && incidence->type() == "Todo" ) {
3080 emit todoSelected( true ); 3080 emit todoSelected( true );
3081 Todo *event = static_cast<Todo *>( incidence ); 3081 Todo *event = static_cast<Todo *>( incidence );
3082 if ( event->organizer() == KOPrefs::instance()->email() ) { 3082 if ( event->organizer() == KOPrefs::instance()->email() ) {
3083 emit organizerEventsSelected( true ); 3083 emit organizerEventsSelected( true );
3084 } else { 3084 } else {
3085 emit organizerEventsSelected(false); 3085 emit organizerEventsSelected(false);
3086 } 3086 }
3087 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3087 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3088 KOPrefs::instance()->email() ) ) { 3088 KOPrefs::instance()->email() ) ) {
3089 emit groupEventsSelected( true ); 3089 emit groupEventsSelected( true );
3090 } else { 3090 } else {
3091 emit groupEventsSelected(false); 3091 emit groupEventsSelected(false);
3092 } 3092 }
3093 return; 3093 return;
3094 } else { 3094 } else {
3095 emit todoSelected( false ); 3095 emit todoSelected( false );
3096 emit organizerEventsSelected(false); 3096 emit organizerEventsSelected(false);
3097 emit groupEventsSelected(false); 3097 emit groupEventsSelected(false);
3098 } 3098 }
3099 return; 3099 return;
3100 } 3100 }
3101 3101
3102 /* if ( incidence && incidence->type() == "Todo" ) { 3102 /* if ( incidence && incidence->type() == "Todo" ) {
3103 emit todoSelected( true ); 3103 emit todoSelected( true );
3104 } else { 3104 } else {
3105 emit todoSelected( false ); 3105 emit todoSelected( false );
3106 }*/ 3106 }*/
3107} 3107}
3108 3108
3109 3109
3110void CalendarView::checkClipboard() 3110void CalendarView::checkClipboard()
3111{ 3111{
3112#ifndef KORG_NODND 3112#ifndef KORG_NODND
3113 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3113 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3114 emit pasteEnabled(true); 3114 emit pasteEnabled(true);
3115 } else { 3115 } else {
3116 emit pasteEnabled(false); 3116 emit pasteEnabled(false);
3117 } 3117 }
3118#endif 3118#endif
3119} 3119}
3120 3120
3121void CalendarView::showDates(const DateList &selectedDates) 3121void CalendarView::showDates(const DateList &selectedDates)
3122{ 3122{
3123 // kdDebug() << "CalendarView::selectDates()" << endl; 3123 // kdDebug() << "CalendarView::selectDates()" << endl;
3124 3124
3125 if ( mViewManager->currentView() ) { 3125 if ( mViewManager->currentView() ) {
3126 updateView( selectedDates.first(), selectedDates.last() ); 3126 updateView( selectedDates.first(), selectedDates.last() );
3127 } else { 3127 } else {
3128 mViewManager->showAgendaView(); 3128 mViewManager->showAgendaView();
3129 } 3129 }
3130 3130
3131 QString selDates; 3131 QString selDates;
3132 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3132 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3133 if (selectedDates.first() < selectedDates.last() ) 3133 if (selectedDates.first() < selectedDates.last() )
3134 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3134 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3135 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3135 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3136 3136
3137} 3137}
3138 3138
3139void CalendarView::editFilters() 3139void CalendarView::editFilters()
3140{ 3140{
3141 // kdDebug() << "CalendarView::editFilters()" << endl; 3141 // kdDebug() << "CalendarView::editFilters()" << endl;
3142 3142
3143 CalFilter *filter = mFilters.first(); 3143 CalFilter *filter = mFilters.first();
3144 while(filter) { 3144 while(filter) {
3145 kdDebug() << " Filter: " << filter->name() << endl; 3145 kdDebug() << " Filter: " << filter->name() << endl;
3146 filter = mFilters.next(); 3146 filter = mFilters.next();
3147 } 3147 }
3148 3148
3149 mDialogManager->showFilterEditDialog(&mFilters); 3149 mDialogManager->showFilterEditDialog(&mFilters);
3150} 3150}
3151void CalendarView::toggleFilter() 3151void CalendarView::toggleFilter()
3152{ 3152{
3153 showFilter(! mFilterView->isVisible()); 3153 showFilter(! mFilterView->isVisible());
3154} 3154}
3155 3155
3156void CalendarView::selectFilter( int fil ) 3156void CalendarView::selectFilter( int fil )
3157{ 3157{
3158 mFilterView->setSelectedFilter( fil ); 3158 mFilterView->setSelectedFilter( fil );
3159} 3159}
3160void CalendarView::showFilter(bool visible) 3160void CalendarView::showFilter(bool visible)
3161{ 3161{
3162 if (visible) mFilterView->show(); 3162 if (visible) mFilterView->show();
3163 else mFilterView->hide(); 3163 else mFilterView->hide();
3164} 3164}
3165void CalendarView::toggleFilerEnabled( ) 3165void CalendarView::toggleFilerEnabled( )
3166{ 3166{
3167 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3167 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3168 if ( !mFilterView->filtersEnabled() ) 3168 if ( !mFilterView->filtersEnabled() )
3169 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3169 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3170 3170
3171} 3171}
3172void CalendarView::updateFilter() 3172void CalendarView::updateFilter()
3173{ 3173{
3174 CalFilter *filter = mFilterView->selectedFilter(); 3174 CalFilter *filter = mFilterView->selectedFilter();
3175 if (filter) { 3175 if (filter) {
3176 if (mFilterView->filtersEnabled()) { 3176 if (mFilterView->filtersEnabled()) {
3177 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3177 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3178 filter->setEnabled(true); 3178 filter->setEnabled(true);
3179 } 3179 }
3180 else filter->setEnabled(false); 3180 else filter->setEnabled(false);
3181 mCalendar->setFilter(filter); 3181 mCalendar->setFilter(filter);
3182 updateView(); 3182 updateView();
3183 } 3183 }
3184} 3184}
3185 3185
3186void CalendarView::filterEdited() 3186void CalendarView::filterEdited()
3187{ 3187{
3188 mFilterView->updateFilters(); 3188 mFilterView->updateFilters();
3189 updateFilter(); 3189 updateFilter();
3190 writeSettings(); 3190 writeSettings();
3191} 3191}
3192 3192
3193 3193
3194void CalendarView::takeOverEvent() 3194void CalendarView::takeOverEvent()
3195{ 3195{
3196 Incidence *incidence = currentSelection(); 3196 Incidence *incidence = currentSelection();
3197 3197
3198 if (!incidence) return; 3198 if (!incidence) return;
3199 3199
3200 incidence->setOrganizer(KOPrefs::instance()->email()); 3200 incidence->setOrganizer(KOPrefs::instance()->email());
3201 incidence->recreate(); 3201 incidence->recreate();
3202 incidence->setReadOnly(false); 3202 incidence->setReadOnly(false);
3203 3203
3204 updateView(); 3204 updateView();
3205} 3205}
3206 3206
3207void CalendarView::takeOverCalendar() 3207void CalendarView::takeOverCalendar()
3208{ 3208{
3209 // TODO: Create Calendar::allIncidences() function and use it here 3209 // TODO: Create Calendar::allIncidences() function and use it here
3210 3210
3211 QPtrList<Event> events = mCalendar->events(); 3211 QPtrList<Event> events = mCalendar->events();
3212 for(uint i=0; i<events.count(); ++i) { 3212 for(uint i=0; i<events.count(); ++i) {
3213 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3213 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3214 events.at(i)->recreate(); 3214 events.at(i)->recreate();
3215 events.at(i)->setReadOnly(false); 3215 events.at(i)->setReadOnly(false);
3216 } 3216 }
3217 3217
3218 QPtrList<Todo> todos = mCalendar->todos(); 3218 QPtrList<Todo> todos = mCalendar->todos();
3219 for(uint i=0; i<todos.count(); ++i) { 3219 for(uint i=0; i<todos.count(); ++i) {
3220 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3220 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3221 todos.at(i)->recreate(); 3221 todos.at(i)->recreate();
3222 todos.at(i)->setReadOnly(false); 3222 todos.at(i)->setReadOnly(false);
3223 } 3223 }
3224 3224
3225 QPtrList<Journal> journals = mCalendar->journals(); 3225 QPtrList<Journal> journals = mCalendar->journals();
3226 for(uint i=0; i<journals.count(); ++i) { 3226 for(uint i=0; i<journals.count(); ++i) {
3227 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3227 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3228 journals.at(i)->recreate(); 3228 journals.at(i)->recreate();
3229 journals.at(i)->setReadOnly(false); 3229 journals.at(i)->setReadOnly(false);
3230 } 3230 }
3231 3231
3232 updateView(); 3232 updateView();
3233} 3233}
3234 3234
3235void CalendarView::showIntro() 3235void CalendarView::showIntro()
3236{ 3236{
3237 kdDebug() << "To be implemented." << endl; 3237 kdDebug() << "To be implemented." << endl;
3238} 3238}
3239 3239
3240QWidgetStack *CalendarView::viewStack() 3240QWidgetStack *CalendarView::viewStack()
3241{ 3241{
3242 return mRightFrame; 3242 return mRightFrame;
3243} 3243}
3244 3244
3245QWidget *CalendarView::leftFrame() 3245QWidget *CalendarView::leftFrame()
3246{ 3246{
3247 return mLeftFrame; 3247 return mLeftFrame;
3248} 3248}
3249 3249
3250DateNavigator *CalendarView::dateNavigator() 3250DateNavigator *CalendarView::dateNavigator()
3251{ 3251{
3252 return mNavigator; 3252 return mNavigator;
3253} 3253}
3254 3254
3255KDateNavigator* CalendarView::dateNavigatorWidget() 3255KDateNavigator* CalendarView::dateNavigatorWidget()
3256{ 3256{
3257 return mDateNavigator; 3257 return mDateNavigator;
3258} 3258}
3259void CalendarView::toggleDateNavigatorWidget() 3259void CalendarView::toggleDateNavigatorWidget()
3260{ 3260{
3261 if (mDateNavigator->isVisible()) 3261 if (mDateNavigator->isVisible())
3262 mDateNavigator->hide(); 3262 mDateNavigator->hide();
3263 else 3263 else
3264 mDateNavigator->show(); 3264 mDateNavigator->show();
3265} 3265}
3266void CalendarView::addView(KOrg::BaseView *view) 3266void CalendarView::addView(KOrg::BaseView *view)
3267{ 3267{
3268 mViewManager->addView(view); 3268 mViewManager->addView(view);
3269} 3269}
3270 3270
3271void CalendarView::showView(KOrg::BaseView *view) 3271void CalendarView::showView(KOrg::BaseView *view)
3272{ 3272{
3273 mViewManager->showView(view, mLeftFrame->isVisible()); 3273 mViewManager->showView(view, mLeftFrame->isVisible());
3274} 3274}
3275 3275
3276Incidence *CalendarView::currentSelection() 3276Incidence *CalendarView::currentSelection()
3277{ 3277{
3278 return mViewManager->currentSelection(); 3278 return mViewManager->currentSelection();
3279} 3279}
3280void CalendarView::toggleAllDaySize() 3280void CalendarView::toggleAllDaySize()
3281{ 3281{
3282 /* 3282 /*
3283 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3283 if ( KOPrefs::instance()->mAllDaySize > 47 )
3284 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3284 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3285 else 3285 else
3286 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3286 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3287 */ 3287 */
3288 viewManager()->agendaView()->toggleAllDay(); 3288 viewManager()->agendaView()->toggleAllDay();
3289} 3289}
3290void CalendarView::toggleExpand() 3290void CalendarView::toggleExpand()
3291{ 3291{
3292 // if ( mLeftFrame->isHidden() ) { 3292 // if ( mLeftFrame->isHidden() ) {
3293 // mLeftFrame->show(); 3293 // mLeftFrame->show();
3294 // emit calendarViewExpanded( false ); 3294 // emit calendarViewExpanded( false );
3295 // } else { 3295 // } else {
3296 // mLeftFrame->hide(); 3296 // mLeftFrame->hide();
3297 // emit calendarViewExpanded( true ); 3297 // emit calendarViewExpanded( true );
3298 // } 3298 // }
3299 3299
3300 globalFlagBlockAgenda = 1; 3300 globalFlagBlockAgenda = 1;
3301 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3301 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3302 globalFlagBlockAgenda = 5; 3302 globalFlagBlockAgenda = 5;
3303 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3303 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3304 //mViewManager->showView( 0, true ); 3304 //mViewManager->showView( 0, true );
3305} 3305}
3306 3306
3307void CalendarView::calendarModified( bool modified, Calendar * ) 3307void CalendarView::calendarModified( bool modified, Calendar * )
3308{ 3308{
3309 setModified( modified ); 3309 setModified( modified );
3310} 3310}
3311 3311
3312Todo *CalendarView::selectedTodo() 3312Todo *CalendarView::selectedTodo()
3313{ 3313{
3314 Incidence *incidence = currentSelection(); 3314 Incidence *incidence = currentSelection();
3315 if ( incidence && incidence->type() == "Todo" ) { 3315 if ( incidence && incidence->type() == "Todo" ) {
3316 return static_cast<Todo *>( incidence ); 3316 return static_cast<Todo *>( incidence );
3317 } 3317 }
3318 3318
3319 incidence = mTodoList->selectedIncidences().first(); 3319 incidence = mTodoList->selectedIncidences().first();
3320 if ( incidence && incidence->type() == "Todo" ) { 3320 if ( incidence && incidence->type() == "Todo" ) {
3321 return static_cast<Todo *>( incidence ); 3321 return static_cast<Todo *>( incidence );
3322 } 3322 }
3323 3323
3324 return 0; 3324 return 0;
3325} 3325}
3326 3326
3327void CalendarView::dialogClosing(Incidence *in) 3327void CalendarView::dialogClosing(Incidence *in)
3328{ 3328{
3329 // mDialogList.remove(in); 3329 // mDialogList.remove(in);
3330} 3330}
3331 3331
3332void CalendarView::showIncidence() 3332void CalendarView::showIncidence()
3333{ 3333{
3334 Incidence *incidence = currentSelection(); 3334 Incidence *incidence = currentSelection();
3335 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3335 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3336 if ( incidence ) { 3336 if ( incidence ) {
3337 ShowIncidenceVisitor v; 3337 ShowIncidenceVisitor v;
3338 v.act( incidence, this ); 3338 v.act( incidence, this );
3339 } 3339 }
3340} 3340}
3341void CalendarView::editIncidenceDescription() 3341void CalendarView::editIncidenceDescription()
3342{ 3342{
3343 mFlagEditDescription = true; 3343 mFlagEditDescription = true;
3344 editIncidence(); 3344 editIncidence();
3345 mFlagEditDescription = false; 3345 mFlagEditDescription = false;
3346} 3346}
3347void CalendarView::editIncidence() 3347void CalendarView::editIncidence()
3348{ 3348{
3349 // qDebug("editIncidence() "); 3349 // qDebug("editIncidence() ");
3350 Incidence *incidence = currentSelection(); 3350 Incidence *incidence = currentSelection();
3351 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3351 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3352 if ( incidence ) { 3352 if ( incidence ) {
3353 EditIncidenceVisitor v; 3353 EditIncidenceVisitor v;
3354 v.act( incidence, this ); 3354 v.act( incidence, this );
3355 } 3355 }
3356} 3356}
3357 3357
3358void CalendarView::deleteIncidence() 3358void CalendarView::deleteIncidence()
3359{ 3359{
3360 Incidence *incidence = currentSelection(); 3360 Incidence *incidence = currentSelection();
3361 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3361 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3362 if ( incidence ) { 3362 if ( incidence ) {
3363 deleteIncidence(incidence); 3363 deleteIncidence(incidence);
3364 } 3364 }
3365} 3365}
3366 3366
3367void CalendarView::showIncidence(Incidence *incidence) 3367void CalendarView::showIncidence(Incidence *incidence)
3368{ 3368{
3369 if ( incidence ) { 3369 if ( incidence ) {
3370 ShowIncidenceVisitor v; 3370 ShowIncidenceVisitor v;
3371 v.act( incidence, this ); 3371 v.act( incidence, this );
3372 } 3372 }
3373} 3373}
3374 3374
3375void CalendarView::editIncidence(Incidence *incidence) 3375void CalendarView::editIncidence(Incidence *incidence)
3376{ 3376{
3377 if ( incidence ) { 3377 if ( incidence ) {
3378 3378
3379 EditIncidenceVisitor v; 3379 EditIncidenceVisitor v;
3380 v.act( incidence, this ); 3380 v.act( incidence, this );
3381 3381
3382 } 3382 }
3383} 3383}
3384 3384
3385void CalendarView::deleteIncidence(Incidence *incidence) 3385void CalendarView::deleteIncidence(Incidence *incidence)
3386{ 3386{
3387 //qDebug(" CalendarView::deleteIncidence "); 3387 //qDebug(" CalendarView::deleteIncidence ");
3388 if ( incidence ) { 3388 if ( incidence ) {
3389 DeleteIncidenceVisitor v; 3389 DeleteIncidenceVisitor v;
3390 v.act( incidence, this ); 3390 v.act( incidence, this );
3391 } 3391 }
3392} 3392}
3393 3393
3394 3394
3395void CalendarView::lookForOutgoingMessages() 3395void CalendarView::lookForOutgoingMessages()
3396{ 3396{
3397 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3397 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3398 ogd->loadMessages(); 3398 ogd->loadMessages();
3399} 3399}
3400 3400
3401void CalendarView::lookForIncomingMessages() 3401void CalendarView::lookForIncomingMessages()
3402{ 3402{
3403 IncomingDialog *icd = mDialogManager->incomingDialog(); 3403 IncomingDialog *icd = mDialogManager->incomingDialog();
3404 icd->retrieve(); 3404 icd->retrieve();
3405} 3405}
3406 3406
3407bool CalendarView::removeCompletedSubTodos( Todo* t ) 3407bool CalendarView::removeCompletedSubTodos( Todo* t )
3408{ 3408{
3409 bool deleteTodo = true; 3409 bool deleteTodo = true;
3410 QPtrList<Incidence> subTodos; 3410 QPtrList<Incidence> subTodos;
3411 Incidence *aTodo; 3411 Incidence *aTodo;
3412 subTodos = t->relations(); 3412 subTodos = t->relations();
3413 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3413 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3414 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3414 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3415 deleteTodo = false; 3415 deleteTodo = false;
3416 } 3416 }
3417 if ( deleteTodo ) { 3417 if ( deleteTodo ) {
3418 if ( t->isCompleted() ) { 3418 if ( t->isCompleted() ) {
3419 checkZaurusId( t->zaurusId(), true ); 3419 checkZaurusId( t->zaurusId(), true );
3420 mCalendar->deleteTodo( t ); 3420 mCalendar->deleteTodo( t );
3421 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3421 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3422 } 3422 }
3423 else 3423 else
3424 deleteTodo = false; 3424 deleteTodo = false;
3425 } 3425 }
3426 return deleteTodo; 3426 return deleteTodo;
3427 3427
3428} 3428}
3429void CalendarView::purgeCompleted() 3429void CalendarView::purgeCompleted()
3430{ 3430{
3431 int result = KMessageBox::warningContinueCancel(this, 3431 int result = KMessageBox::warningContinueCancel(this,
3432 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3432 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3433 3433
3434 if (result == KMessageBox::Continue) { 3434 if (result == KMessageBox::Continue) {
3435 3435
3436 QPtrList<Todo> todoCal; 3436 QPtrList<Todo> todoCal;
3437 QPtrList<Todo> rootTodos; 3437 QPtrList<Todo> rootTodos;
3438 //QPtrList<Incidence> rel; 3438 //QPtrList<Incidence> rel;
3439 Todo *aTodo;//, *rTodo; 3439 Todo *aTodo;//, *rTodo;
3440 Incidence *rIncidence; 3440 Incidence *rIncidence;
3441 bool childDelete = false; 3441 bool childDelete = false;
3442 bool deletedOne = true; 3442 bool deletedOne = true;
3443 todoCal = calendar()->todos(); 3443 todoCal = calendar()->todos();
3444 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3444 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3445 if ( !aTodo->relatedTo() ) 3445 if ( !aTodo->relatedTo() )
3446 rootTodos.append( aTodo ); 3446 rootTodos.append( aTodo );
3447 } 3447 }
3448 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3448 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3449 removeCompletedSubTodos( aTodo ); 3449 removeCompletedSubTodos( aTodo );
3450 } 3450 }
3451 3451
3452 updateView(); 3452 updateView();
3453 } 3453 }
3454} 3454}
3455 3455
3456void CalendarView::slotCalendarChanged() 3456void CalendarView::slotCalendarChanged()
3457{ 3457{
3458 ; 3458 ;
3459} 3459}
3460 3460
3461NavigatorBar *CalendarView::navigatorBar() 3461NavigatorBar *CalendarView::navigatorBar()
3462{ 3462{
3463 return mNavigatorBar; 3463 return mNavigatorBar;
3464} 3464}
3465 3465
3466 3466
3467 3467
3468void CalendarView::keyPressEvent ( QKeyEvent *e) 3468void CalendarView::keyPressEvent ( QKeyEvent *e)
3469{ 3469{
3470 //qDebug(" alendarView::keyPressEvent "); 3470 //qDebug(" alendarView::keyPressEvent ");
3471 e->ignore(); 3471 e->ignore();
3472} 3472}
3473 3473
3474#include "calendarview.moc" 3474//#include "calendarview.moc"
3475 3475
3476#include "calendarviewbase.moc" 3476//#include "calendarviewbase.moc"
diff --git a/korganizer/datenavigator.cpp b/korganizer/datenavigator.cpp
index 8d35c42..e26e20b 100644
--- a/korganizer/datenavigator.cpp
+++ b/korganizer/datenavigator.cpp
@@ -1,287 +1,287 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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 "datenavigator.h" 24#include "datenavigator.h"
25 25
26#include "koglobals.h" 26#include "koglobals.h"
27 27
28#include <kcalendarsystem.h> 28#include <kcalendarsystem.h>
29 29
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <klocale.h> 32#include <klocale.h>
33 33
34using namespace KCal; 34using namespace KCal;
35 35
36DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager * v) 36DateNavigator::DateNavigator( QObject *parent, const char *name , KOViewManager * v)
37 : QObject( parent, name ) 37 : QObject( parent, name )
38{ 38{
39 mViewManager = v; 39 mViewManager = v;
40 mSelectedDates.append( QDate::currentDate() ); 40 mSelectedDates.append( QDate::currentDate() );
41} 41}
42 42
43DateNavigator::~DateNavigator() 43DateNavigator::~DateNavigator()
44{ 44{
45} 45}
46 46
47void DateNavigator::slotMonthSelect( int m ) 47void DateNavigator::slotMonthSelect( int m )
48{ 48{
49 QDate firstSelected = mSelectedDates.first(); 49 QDate firstSelected = mSelectedDates.first();
50 int weekDay = firstSelected.dayOfWeek(); 50 int weekDay = firstSelected.dayOfWeek();
51 int diff = m - firstSelected.month() ; 51 int diff = m - firstSelected.month() ;
52 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff ); 52 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, diff );
53 53
54 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) 54 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
55 selectMonthByDate( firstSelected ); 55 selectMonthByDate( firstSelected );
56 else 56 else
57 selectWeekByDay( weekDay, firstSelected ); 57 selectWeekByDay( weekDay, firstSelected );
58 58
59} 59}
60 60
61void DateNavigator::slotDaySelect( QDate d ) 61void DateNavigator::slotDaySelect( QDate d )
62{ 62{
63 QDate firstSelected = mSelectedDates.first(); 63 QDate firstSelected = mSelectedDates.first();
64 int weekDay = firstSelected.dayOfWeek(); 64 int weekDay = firstSelected.dayOfWeek();
65 //int diff = firstSelected.daysTo( d ) ; 65 //int diff = firstSelected.daysTo( d ) ;
66 firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) ); 66 firstSelected = firstSelected.addDays( firstSelected .daysTo( d ) );
67 67
68 selectWeekByDay( weekDay, firstSelected ); 68 selectWeekByDay( weekDay, firstSelected );
69 69
70} 70}
71 71
72void DateNavigator::selectMonthByDate( const QDate & firstSelected ) 72void DateNavigator::selectMonthByDate( const QDate & firstSelected )
73{ 73{
74 74
75 int monthDay = firstSelected.day(); 75 int monthDay = firstSelected.day();
76 QDate date = firstSelected.addDays( 1-monthDay ); 76 QDate date = firstSelected.addDays( 1-monthDay );
77 selectDates( date , date.daysInMonth ()); 77 selectDates( date , date.daysInMonth ());
78 78
79} 79}
80void DateNavigator::selectMonth() 80void DateNavigator::selectMonth()
81{ 81{
82 82
83 QDate date =mSelectedDates.first(); 83 QDate date =mSelectedDates.first();
84 selectMonthByDate( date ); 84 selectMonthByDate( date );
85} 85}
86 86
87DateList DateNavigator::selectedDates() 87DateList DateNavigator::selectedDates()
88{ 88{
89 return mSelectedDates; 89 return mSelectedDates;
90} 90}
91 91
92int DateNavigator::datesCount() const 92int DateNavigator::datesCount() const
93{ 93{
94 return mSelectedDates.count(); 94 return mSelectedDates.count();
95} 95}
96 96
97void DateNavigator::selectDates( const DateList& dateList ) 97void DateNavigator::selectDates( const DateList& dateList )
98{ 98{
99 if (dateList.count() > 0) { 99 if (dateList.count() > 0) {
100 mSelectedDates = dateList; 100 mSelectedDates = dateList;
101 emitSelected(); 101 emitSelected();
102 } 102 }
103} 103}
104 104
105void DateNavigator::selectDate( const QDate &date ) 105void DateNavigator::selectDate( const QDate &date )
106{ 106{
107 QDate d = date; 107 QDate d = date;
108 108
109 if ( !d.isValid() ) { 109 if ( !d.isValid() ) {
110 d = QDate::currentDate(); 110 d = QDate::currentDate();
111 } 111 }
112 112
113 mSelectedDates.clear(); 113 mSelectedDates.clear();
114 mSelectedDates.append( d ); 114 mSelectedDates.append( d );
115 115
116 emitSelected(); 116 emitSelected();
117} 117}
118 118
119void DateNavigator::selectDates( int count ) 119void DateNavigator::selectDates( int count )
120{ 120{
121 121
122 QDate d = mSelectedDates.first(); 122 QDate d = mSelectedDates.first();
123 selectDates( d, count ); 123 selectDates( d, count );
124} 124}
125 125
126void DateNavigator::selectDates( const QDate &d, int count ) 126void DateNavigator::selectDates( const QDate &d, int count )
127{ 127{
128 DateList dates; 128 DateList dates;
129 129
130 int i; 130 int i;
131 for( i = 0; i < count; ++i ) { 131 for( i = 0; i < count; ++i ) {
132 dates.append( d.addDays( i ) ); 132 dates.append( d.addDays( i ) );
133 } 133 }
134 134
135 mSelectedDates = dates; 135 mSelectedDates = dates;
136 136
137 emitSelected(); 137 emitSelected();
138} 138}
139 139
140void DateNavigator::selectWeekByDay( int weekDay, const QDate &d ) 140void DateNavigator::selectWeekByDay( int weekDay, const QDate &d )
141{ 141{
142 // qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1()); 142 // qDebug("selectWeekByDay( %d %s ", weekDay, d.toString().latin1());
143 int dateCount = mSelectedDates.count(); 143 int dateCount = mSelectedDates.count();
144 bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() ); 144 bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() );
145 if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d ); 145 if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d );
146 else if ( weekStart && dateCount == 7 ) selectWeek( d ); 146 else if ( weekStart && dateCount == 7 ) selectWeek( d );
147 else selectDates( d, dateCount ); 147 else selectDates( d, dateCount );
148} 148}
149 149
150void DateNavigator::selectWeek() 150void DateNavigator::selectWeek()
151{ 151{
152 QDate d = mSelectedDates.first(); 152 QDate d = mSelectedDates.first();
153 selectWeek( d ); 153 selectWeek( d );
154} 154}
155void DateNavigator::selectWeek( int num ) 155void DateNavigator::selectWeek( int num )
156{ 156{
157 int year = mSelectedDates.first().year(); 157 int year = mSelectedDates.first().year();
158 if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 ) 158 if ( mSelectedDates.first().dayOfYear() > 300 && num < 10 )
159 ++year; 159 ++year;
160 if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 ) 160 if ( mSelectedDates.first().dayOfYear() < 70 && num > 40 )
161 --year; 161 --year;
162 QDate d = QDate ( year, 1,1); 162 QDate d = QDate ( year, 1,1);
163 while ( d.dayOfWeek() != 4 ) 163 while ( d.dayOfWeek() != 4 )
164 d = d.addDays( 1 ); 164 d = d.addDays( 1 );
165 selectWeek( d.addDays ( (num-1) *7 ) ); 165 selectWeek( d.addDays ( (num-1) *7 ) );
166} 166}
167void DateNavigator::selectWeek( const QDate &d ) 167void DateNavigator::selectWeek( const QDate &d )
168{ 168{
169 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); 169 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
170 170
171 int weekStart = KGlobal::locale()->weekStartDay(); 171 int weekStart = KGlobal::locale()->weekStartDay();
172 QDate firstDate = d.addDays( weekStart - dayOfWeek ); 172 QDate firstDate = d.addDays( weekStart - dayOfWeek );
173 173
174 if ( weekStart != 1 && dayOfWeek < weekStart ) { 174 if ( weekStart != 1 && dayOfWeek < weekStart ) {
175 firstDate = firstDate.addDays(-7 ); 175 firstDate = firstDate.addDays(-7 );
176 } 176 }
177 177
178 178
179 selectDates( firstDate, 7 ); 179 selectDates( firstDate, 7 );
180} 180}
181 181
182void DateNavigator::selectWorkWeek() 182void DateNavigator::selectWorkWeek()
183{ 183{
184 QDate d = mSelectedDates.first(); 184 QDate d = mSelectedDates.first();
185 selectWorkWeek( d ); 185 selectWorkWeek( d );
186} 186}
187 187
188void DateNavigator::selectWorkWeek( const QDate &d ) 188void DateNavigator::selectWorkWeek( const QDate &d )
189{ 189{
190 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d ); 190 int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
191 191
192 QDate firstDate = d.addDays( 1 - dayOfWeek ); 192 QDate firstDate = d.addDays( 1 - dayOfWeek );
193 193
194 int weekStart = KGlobal::locale()->weekStartDay(); 194 int weekStart = KGlobal::locale()->weekStartDay();
195 if ( weekStart != 1 && dayOfWeek >= weekStart ) { 195 if ( weekStart != 1 && dayOfWeek >= weekStart ) {
196 firstDate = firstDate.addDays( 7 ); 196 firstDate = firstDate.addDays( 7 );
197 } 197 }
198 198
199 selectDates( firstDate, 5 ); 199 selectDates( firstDate, 5 );
200} 200}
201 201
202void DateNavigator::selectToday() 202void DateNavigator::selectToday()
203{ 203{
204 QDate d = QDate::currentDate(); 204 QDate d = QDate::currentDate();
205 205
206 int dateCount = mSelectedDates.count(); 206 int dateCount = mSelectedDates.count();
207 207
208 if ( dateCount == 5 ) selectWorkWeek( d ); 208 if ( dateCount == 5 ) selectWorkWeek( d );
209 else if ( dateCount == 7 ) selectWeek( d ); 209 else if ( dateCount == 7 ) selectWeek( d );
210 else selectDates( d, dateCount ); 210 else selectDates( d, dateCount );
211} 211}
212 212
213void DateNavigator::selectPreviousYear() 213void DateNavigator::selectPreviousYear()
214{ 214{
215 QDate firstSelected = mSelectedDates.first(); 215 QDate firstSelected = mSelectedDates.first();
216 int weekDay = firstSelected.dayOfWeek(); 216 int weekDay = firstSelected.dayOfWeek();
217 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 ); 217 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, -1 );
218 218
219 selectWeekByDay( weekDay, firstSelected ); 219 selectWeekByDay( weekDay, firstSelected );
220} 220}
221 221
222void DateNavigator::selectPreviousMonth() 222void DateNavigator::selectPreviousMonth()
223{ 223{
224 QDate firstSelected = mSelectedDates.first(); 224 QDate firstSelected = mSelectedDates.first();
225 int weekDay = firstSelected.dayOfWeek(); 225 int weekDay = firstSelected.dayOfWeek();
226 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 ); 226 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, -1 );
227 227
228 228
229 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) 229 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
230 selectMonthByDate( firstSelected ); 230 selectMonthByDate( firstSelected );
231 else 231 else
232 selectWeekByDay( weekDay, firstSelected ); 232 selectWeekByDay( weekDay, firstSelected );
233} 233}
234 234
235void DateNavigator::selectNextMonth() 235void DateNavigator::selectNextMonth()
236{ 236{
237 QDate firstSelected = mSelectedDates.first(); 237 QDate firstSelected = mSelectedDates.first();
238 int weekDay = firstSelected.dayOfWeek(); 238 int weekDay = firstSelected.dayOfWeek();
239 239
240 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 ); 240 firstSelected = KOGlobals::self()->calendarSystem()->addMonths( firstSelected, 1 );
241 241
242 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 ) 242 if ( mSelectedDates.first().day() == 1 && mSelectedDates.count() > 27 )
243 selectMonthByDate( firstSelected ); 243 selectMonthByDate( firstSelected );
244 else 244 else
245 selectWeekByDay( weekDay, firstSelected ); 245 selectWeekByDay( weekDay, firstSelected );
246 246
247} 247}
248 248
249void DateNavigator::selectNextYear() 249void DateNavigator::selectNextYear()
250{ 250{
251 QDate firstSelected = mSelectedDates.first(); 251 QDate firstSelected = mSelectedDates.first();
252 int weekDay = firstSelected.dayOfWeek(); 252 int weekDay = firstSelected.dayOfWeek();
253 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 ); 253 firstSelected = KOGlobals::self()->calendarSystem()->addYears( firstSelected, 1 );
254 254
255 selectWeekByDay( weekDay, firstSelected ); 255 selectWeekByDay( weekDay, firstSelected );
256} 256}
257 257
258void DateNavigator::selectPrevious() 258void DateNavigator::selectPrevious()
259{ 259{
260 int offset = -7; 260 int offset = -7;
261 if ( datesCount() == 1 ) { 261 if ( datesCount() == 1 ) {
262 offset = -1; 262 offset = -1;
263 } 263 }
264 if ( mViewManager ) 264 if ( mViewManager )
265 if ( mViewManager->showsNextDays() ) 265 if ( mViewManager->showsNextDays() )
266 offset = -datesCount(); 266 offset = -datesCount();
267 selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); 267 selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
268} 268}
269 269
270void DateNavigator::selectNext() 270void DateNavigator::selectNext()
271{ 271{
272 int offset = 7; 272 int offset = 7;
273 if ( datesCount() == 1 ) { 273 if ( datesCount() == 1 ) {
274 offset = 1; 274 offset = 1;
275 } 275 }
276 if ( mViewManager ) 276 if ( mViewManager )
277 if ( mViewManager->showsNextDays() ) 277 if ( mViewManager->showsNextDays() )
278 offset = datesCount(); 278 offset = datesCount();
279 selectDates( mSelectedDates.first().addDays( offset ), datesCount() ); 279 selectDates( mSelectedDates.first().addDays( offset ), datesCount() );
280} 280}
281 281
282void DateNavigator::emitSelected() 282void DateNavigator::emitSelected()
283{ 283{
284 emit datesSelected( mSelectedDates ); 284 emit datesSelected( mSelectedDates );
285} 285}
286 286
287#include "datenavigator.moc" 287//#include "datenavigator.moc"
diff --git a/korganizer/filtereditdialog.cpp b/korganizer/filtereditdialog.cpp
index 2943e41..ca09844 100644
--- a/korganizer/filtereditdialog.cpp
+++ b/korganizer/filtereditdialog.cpp
@@ -1,270 +1,270 @@
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 <qlayout.h> 24#include <qlayout.h>
25#include <qpushbutton.h> 25#include <qpushbutton.h>
26#include <qcombobox.h> 26#include <qcombobox.h>
27#include <qcheckbox.h> 27#include <qcheckbox.h>
28#include <qradiobutton.h> 28#include <qradiobutton.h>
29#include <qlistbox.h> 29#include <qlistbox.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <klineeditdlg.h> 34#include <klineeditdlg.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/categoryselectdialog.h> 37#include <libkdepim/categoryselectdialog.h>
38 38
39#include "koprefs.h" 39#include "koprefs.h"
40#include "filteredit_base.h" 40#include "filteredit_base.h"
41 41
42#include "filtereditdialog.h" 42#include "filtereditdialog.h"
43#include "filtereditdialog.moc" 43//#include "filtereditdialog.moc"
44 44
45// TODO: Make dialog work on a copy of the filters objects. 45// TODO: Make dialog work on a copy of the filters objects.
46 46
47class ComboFilterBox: public QComboBox 47class ComboFilterBox: public QComboBox
48{ 48{
49public: 49public:
50 ComboFilterBox( QWidget *parent=0, const char *name=0) : 50 ComboFilterBox( QWidget *parent=0, const char *name=0) :
51 QComboBox( parent,name ) { } 51 QComboBox( parent,name ) { }
52 void popupBox() { popup(); } 52 void popupBox() { popup(); }
53 53
54}; 54};
55 55
56FilterEditDialog::FilterEditDialog(QPtrList<CalFilter> *filters,QWidget *parent, 56FilterEditDialog::FilterEditDialog(QPtrList<CalFilter> *filters,QWidget *parent,
57 const char *name) : 57 const char *name) :
58 KDialogBase(parent,name,true,i18n("Edit Calendar Filters"), 58 KDialogBase(parent,name,true,i18n("Edit Calendar Filters"),
59 Ok|Apply|Cancel) 59 Ok|Apply|Cancel)
60{ 60{
61 mFilters = filters; 61 mFilters = filters;
62 62
63 QWidget *mainWidget = new QWidget(this); 63 QWidget *mainWidget = new QWidget(this);
64 setMainWidget(mainWidget); 64 setMainWidget(mainWidget);
65 65
66 mSelectionCombo = new ComboFilterBox(mainWidget); 66 mSelectionCombo = new ComboFilterBox(mainWidget);
67 connect(mSelectionCombo,SIGNAL(activated(int)),SLOT(filterSelected())); 67 connect(mSelectionCombo,SIGNAL(activated(int)),SLOT(filterSelected()));
68 // mSelectionCombo->setEditable ( true ); 68 // mSelectionCombo->setEditable ( true );
69 QPushButton *addButton = new QPushButton(i18n("Add Filter"),mainWidget); 69 QPushButton *addButton = new QPushButton(i18n("Add Filter"),mainWidget);
70 connect(addButton,SIGNAL(clicked()),SLOT(slotAdd())); 70 connect(addButton,SIGNAL(clicked()),SLOT(slotAdd()));
71 addButton->setMaximumSize( addButton->sizeHint()); 71 addButton->setMaximumSize( addButton->sizeHint());
72 mRemoveButton = new QPushButton( i18n("Remove"), mainWidget ); 72 mRemoveButton = new QPushButton( i18n("Remove"), mainWidget );
73 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotRemove() ) ); 73 connect( mRemoveButton, SIGNAL( clicked() ), SLOT( slotRemove() ) );
74 mRemoveButton->setMaximumSize( mRemoveButton->sizeHint()); 74 mRemoveButton->setMaximumSize( mRemoveButton->sizeHint());
75 75
76 QPushButton *upButton = new QPushButton(i18n("Up"),mainWidget); 76 QPushButton *upButton = new QPushButton(i18n("Up"),mainWidget);
77 upButton->setMaximumSize( upButton->sizeHint()); 77 upButton->setMaximumSize( upButton->sizeHint());
78 connect(upButton,SIGNAL(clicked()),SLOT(slotUp())); 78 connect(upButton,SIGNAL(clicked()),SLOT(slotUp()));
79 79
80 80
81 mEditor = new FilterEdit_base(mainWidget); 81 mEditor = new FilterEdit_base(mainWidget);
82 82
83 QGridLayout *topLayout = new QGridLayout(mainWidget,2,2); 83 QGridLayout *topLayout = new QGridLayout(mainWidget,2,2);
84 topLayout->setSpacing(spacingHint()); 84 topLayout->setSpacing(spacingHint());
85 topLayout->addWidget(mSelectionCombo,0,0); 85 topLayout->addWidget(mSelectionCombo,0,0);
86 topLayout->addWidget(upButton,0,1); 86 topLayout->addWidget(upButton,0,1);
87 topLayout->addWidget(addButton,0,2); 87 topLayout->addWidget(addButton,0,2);
88 topLayout->addWidget(mRemoveButton,0,3); 88 topLayout->addWidget(mRemoveButton,0,3);
89 topLayout->addMultiCellWidget(mEditor,1,1,0,3); 89 topLayout->addMultiCellWidget(mEditor,1,1,0,3);
90 mSelectionCombo->setMaximumWidth ( QApplication::desktop()->width() - 90 mSelectionCombo->setMaximumWidth ( QApplication::desktop()->width() -
91 addButton->maximumWidth() - 91 addButton->maximumWidth() -
92 mRemoveButton->maximumWidth() - 92 mRemoveButton->maximumWidth() -
93 upButton->maximumWidth() - 93 upButton->maximumWidth() -
94 spacingHint() * 5 ); 94 spacingHint() * 5 );
95 connect(mEditor->mCatEditButton,SIGNAL(clicked()), 95 connect(mEditor->mCatEditButton,SIGNAL(clicked()),
96 SLOT(editCategorySelection())); 96 SLOT(editCategorySelection()));
97 97
98 // Clicking cancel exits the dialog without saving 98 // Clicking cancel exits the dialog without saving
99 connect(this,SIGNAL(cancelClicked()),SLOT(reject())); 99 connect(this,SIGNAL(cancelClicked()),SLOT(reject()));
100 updateFilterList(); 100 updateFilterList();
101} 101}
102 102
103FilterEditDialog::~FilterEditDialog() 103FilterEditDialog::~FilterEditDialog()
104{ 104{
105} 105}
106void FilterEditDialog::slotUp() 106void FilterEditDialog::slotUp()
107{ 107{
108 108
109 if ( mFilters->count() <= 1 ) return; 109 if ( mFilters->count() <= 1 ) return;
110 if ( mSelectionCombo->currentItem() == 0 ) return; 110 if ( mSelectionCombo->currentItem() == 0 ) return;
111 int num = mSelectionCombo->currentItem(); 111 int num = mSelectionCombo->currentItem();
112 CalFilter* f = new CalFilter( ); 112 CalFilter* f = new CalFilter( );
113 *f = *(mFilters->at( num )); 113 *f = *(mFilters->at( num ));
114 mFilters->remove( num ); 114 mFilters->remove( num );
115 mFilters->insert( num-1, f ); 115 mFilters->insert( num-1, f );
116 updateFilterList(); 116 updateFilterList();
117 mSelectionCombo->setCurrentItem( num-1 ); 117 mSelectionCombo->setCurrentItem( num-1 );
118 readFilter(f); 118 readFilter(f);
119 //qApp->processEvents(); 119 //qApp->processEvents();
120 //mSelectionCombo->popupBox(); 120 //mSelectionCombo->popupBox();
121} 121}
122void FilterEditDialog::updateFilterList() 122void FilterEditDialog::updateFilterList()
123{ 123{
124 mSelectionCombo->clear(); 124 mSelectionCombo->clear();
125 125
126 CalFilter *filter = mFilters->first(); 126 CalFilter *filter = mFilters->first();
127 127
128 if (!filter) { 128 if (!filter) {
129 enableButtonOK(false); 129 enableButtonOK(false);
130 enableButtonApply(false); 130 enableButtonApply(false);
131 } else { 131 } else {
132 while(filter) { 132 while(filter) {
133 mSelectionCombo->insertItem(filter->name()); 133 mSelectionCombo->insertItem(filter->name());
134 filter = mFilters->next(); 134 filter = mFilters->next();
135 } 135 }
136 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 136 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
137 if (f) readFilter(f); 137 if (f) readFilter(f);
138 138
139 enableButtonOK(true); 139 enableButtonOK(true);
140 enableButtonApply(true); 140 enableButtonApply(true);
141 } 141 }
142 142
143 mRemoveButton->setEnabled( mFilters->count() > 1 ); 143 mRemoveButton->setEnabled( mFilters->count() > 1 );
144} 144}
145 145
146void FilterEditDialog::slotDefault() 146void FilterEditDialog::slotDefault()
147{ 147{
148} 148}
149 149
150void FilterEditDialog::slotApply() 150void FilterEditDialog::slotApply()
151{ 151{
152 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 152 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
153 writeFilter(f); 153 writeFilter(f);
154 emit filterChanged(); 154 emit filterChanged();
155} 155}
156void FilterEditDialog::accept() 156void FilterEditDialog::accept()
157{ 157{
158 slotOk(); 158 slotOk();
159} 159}
160void FilterEditDialog::slotOk() 160void FilterEditDialog::slotOk()
161{ 161{
162 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 162 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
163 writeFilter(f); 163 writeFilter(f);
164 emit filterChanged(); 164 emit filterChanged();
165 QDialog::accept(); 165 QDialog::accept();
166} 166}
167 167
168void FilterEditDialog::slotAdd() 168void FilterEditDialog::slotAdd()
169{ 169{
170 KLineEditDlg dlg(i18n("Enter filter name:"), "New Filter", this); 170 KLineEditDlg dlg(i18n("Enter filter name:"), "New Filter", this);
171 dlg.setCaption(i18n("Add Filter")); 171 dlg.setCaption(i18n("Add Filter"));
172 if (dlg.exec()) { 172 if (dlg.exec()) {
173 if ( dlg.text().length() > 0 ) { 173 if ( dlg.text().length() > 0 ) {
174 mFilters->append(new CalFilter(dlg.text())); 174 mFilters->append(new CalFilter(dlg.text()));
175 updateFilterList(); 175 updateFilterList();
176 int num = mSelectionCombo->count() -1 ; 176 int num = mSelectionCombo->count() -1 ;
177 mSelectionCombo->setCurrentItem( num ); 177 mSelectionCombo->setCurrentItem( num );
178 readFilter(mFilters->at( num ) ); 178 readFilter(mFilters->at( num ) );
179 } 179 }
180 } 180 }
181} 181}
182 182
183void FilterEditDialog::slotRemove() 183void FilterEditDialog::slotRemove()
184{ 184{
185 int currentItem = mSelectionCombo->currentItem(); 185 int currentItem = mSelectionCombo->currentItem();
186 if ( currentItem < 0 ) return; 186 if ( currentItem < 0 ) return;
187 187
188 // We need at least a default filter object. 188 // We need at least a default filter object.
189 if ( mFilters->count() <= 1 ) return; 189 if ( mFilters->count() <= 1 ) return;
190 190
191 int result = KMessageBox::questionYesNo( this, 191 int result = KMessageBox::questionYesNo( this,
192 i18n("This item will be\npermanently deleted.") ); 192 i18n("This item will be\npermanently deleted.") );
193 193
194 if ( result != KMessageBox::Yes ) { 194 if ( result != KMessageBox::Yes ) {
195 return; 195 return;
196 } 196 }
197 197
198 mFilters->remove( currentItem ); 198 mFilters->remove( currentItem );
199 updateFilterList(); 199 updateFilterList();
200 emit filterChanged(); 200 emit filterChanged();
201} 201}
202 202
203void FilterEditDialog::editCategorySelection() 203void FilterEditDialog::editCategorySelection()
204{ 204{
205 KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog( 205 KPIM::CategorySelectDialog *dlg = new KPIM::CategorySelectDialog(
206 KOPrefs::instance(), this, "filterCatSelect", true ); 206 KOPrefs::instance(), this, "filterCatSelect", true );
207 dlg->setSelected(mCategories); 207 dlg->setSelected(mCategories);
208 208
209 connect(dlg,SIGNAL(categoriesSelected(const QStringList &)), 209 connect(dlg,SIGNAL(categoriesSelected(const QStringList &)),
210 SLOT(updateCategorySelection(const QStringList &))); 210 SLOT(updateCategorySelection(const QStringList &)));
211 211
212 dlg->exec(); 212 dlg->exec();
213} 213}
214 214
215void FilterEditDialog::updateCategorySelection(const QStringList &categories) 215void FilterEditDialog::updateCategorySelection(const QStringList &categories)
216{ 216{
217 mCategories = categories; 217 mCategories = categories;
218 218
219 mEditor->mCatList->clear(); 219 mEditor->mCatList->clear();
220 mEditor->mCatList->insertStringList(mCategories); 220 mEditor->mCatList->insertStringList(mCategories);
221} 221}
222 222
223void FilterEditDialog::filterSelected() 223void FilterEditDialog::filterSelected()
224{ 224{
225 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 225 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
226 if (f) readFilter(f); 226 if (f) readFilter(f);
227} 227}
228 228
229void FilterEditDialog::readFilter(CalFilter *filter) 229void FilterEditDialog::readFilter(CalFilter *filter)
230{ 230{
231 int c = filter->criteria(); 231 int c = filter->criteria();
232 232
233 mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted); 233 mEditor->mCompletedCheck->setChecked(c & CalFilter::HideCompleted);
234 mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring); 234 mEditor->mRecurringCheck->setChecked(c & CalFilter::HideRecurring);
235 mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic); 235 mEditor->mPublicCheck->setChecked(c & CalFilter::ShowPublic);
236 mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate); 236 mEditor->mPrivateCheck->setChecked(c & CalFilter::ShowPrivate);
237 mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential); 237 mEditor->mConfidentialCheck->setChecked(c & CalFilter::ShowConfidential);
238 238
239 if (c & CalFilter::ShowCategories) { 239 if (c & CalFilter::ShowCategories) {
240 mEditor->mCatShowCheck->setChecked(true); 240 mEditor->mCatShowCheck->setChecked(true);
241 } else { 241 } else {
242 mEditor->mCatHideCheck->setChecked(true); 242 mEditor->mCatHideCheck->setChecked(true);
243 } 243 }
244 244
245 mEditor->mCatList->clear(); 245 mEditor->mCatList->clear();
246 mEditor->mCatList->insertStringList(filter->categoryList()); 246 mEditor->mCatList->insertStringList(filter->categoryList());
247 mCategories = filter->categoryList(); 247 mCategories = filter->categoryList();
248 248
249 setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 )); 249 setCaption( i18n("Filter position: ") + QString::number ( mSelectionCombo->currentItem()+1 ));
250} 250}
251 251
252void FilterEditDialog::writeFilter(CalFilter *filter) 252void FilterEditDialog::writeFilter(CalFilter *filter)
253{ 253{
254 int c = 0; 254 int c = 0;
255 255
256 if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted; 256 if (mEditor->mCompletedCheck->isChecked()) c |= CalFilter::HideCompleted;
257 if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring; 257 if (mEditor->mRecurringCheck->isChecked()) c |= CalFilter::HideRecurring;
258 if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories; 258 if (mEditor->mCatShowCheck->isChecked()) c |= CalFilter::ShowCategories;
259 if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic; 259 if (mEditor->mPublicCheck->isChecked()) c |= CalFilter::ShowPublic;
260 if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate; 260 if (mEditor->mPrivateCheck->isChecked()) c |= CalFilter::ShowPrivate;
261 if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential; 261 if (mEditor->mConfidentialCheck->isChecked()) c |= CalFilter::ShowConfidential;
262 262
263 filter->setCriteria(c); 263 filter->setCriteria(c);
264 264
265 QStringList categoryList; 265 QStringList categoryList;
266 for(uint i=0;i<mEditor->mCatList->count();++i) { 266 for(uint i=0;i<mEditor->mCatList->count();++i) {
267 categoryList.append(mEditor->mCatList->text(i)); 267 categoryList.append(mEditor->mCatList->text(i));
268 } 268 }
269 filter->setCategoryList(categoryList); 269 filter->setCategoryList(categoryList);
270} 270}
diff --git a/korganizer/incomingdialog.cpp b/korganizer/incomingdialog.cpp
index 490d21e..f3bd09f 100644
--- a/korganizer/incomingdialog.cpp
+++ b/korganizer/incomingdialog.cpp
@@ -1,527 +1,527 @@
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 19
20#include <qlistview.h> 20#include <qlistview.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qdir.h> 22#include <qdir.h>
23#include <qmap.h> 23#include <qmap.h>
24 24
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kstandarddirs.h> 28#include <kstandarddirs.h>
29#include <kmessagebox.h> 29#include <kmessagebox.h>
30 30
31#include <libkcal/incidence.h> 31#include <libkcal/incidence.h>
32#include <libkcal/event.h> 32#include <libkcal/event.h>
33#include <libkcal/calendar.h> 33#include <libkcal/calendar.h>
34#include <libkcal/freebusy.h> 34#include <libkcal/freebusy.h>
35#include <libkcal/attendee.h> 35#include <libkcal/attendee.h>
36#include <libkcal/calendarresources.h> 36#include <libkcal/calendarresources.h>
37#include <libkcal/resourcecalendar.h> 37#include <libkcal/resourcecalendar.h>
38#include <kresources/resourceselectdialog.h> 38#include <kresources/resourceselectdialog.h>
39 39
40#ifndef KORG_NOMAIL 40#ifndef KORG_NOMAIL
41#include "mailscheduler.h" 41#include "mailscheduler.h"
42#else 42#else
43#include <libkcal/dummyscheduler.h> 43#include <libkcal/dummyscheduler.h>
44#endif 44#endif
45 45
46 46
47#include "incomingdialog.h" 47#include "incomingdialog.h"
48#include "koeventviewerdialog.h" 48#include "koeventviewerdialog.h"
49#include "kocounterdialog.h" 49#include "kocounterdialog.h"
50#include "koprefs.h" 50#include "koprefs.h"
51 51
52#ifndef KORG_NOKABC 52#ifndef KORG_NOKABC
53#include <kabc/stdaddressbook.h> 53#include <kabc/stdaddressbook.h>
54#define size count 54#define size count
55#endif 55#endif
56 56
57 57
58ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev, 58ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev,
59 Scheduler::Method method,ScheduleMessage::Status status) 59 Scheduler::Method method,ScheduleMessage::Status status)
60 : QListViewItem(parent) 60 : QListViewItem(parent)
61{ 61{
62 mIncidence = ev; 62 mIncidence = ev;
63 mMethod = method; 63 mMethod = method;
64 mStatus = status; 64 mStatus = status;
65 setText(6,Scheduler::translatedMethodName(mMethod)+" "); 65 setText(6,Scheduler::translatedMethodName(mMethod)+" ");
66 setText(7,ScheduleMessage::statusName(status)); 66 setText(7,ScheduleMessage::statusName(status));
67} 67}
68 68
69 69
70/* Visitor */ 70/* Visitor */
71ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) 71ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item)
72{ 72{
73 mItem = item; 73 mItem = item;
74} 74}
75 75
76ScheduleItemVisitor::~ScheduleItemVisitor() 76ScheduleItemVisitor::~ScheduleItemVisitor()
77{ 77{
78} 78}
79 79
80bool ScheduleItemVisitor::visit(Event *e) 80bool ScheduleItemVisitor::visit(Event *e)
81{ 81{
82 mItem->setText(0,e->summary()); 82 mItem->setText(0,e->summary());
83 mItem->setText(1,e->dtStartDateStr()); 83 mItem->setText(1,e->dtStartDateStr());
84 if (e->doesFloat()) { 84 if (e->doesFloat()) {
85 mItem->setText(2,i18n("no time ")); 85 mItem->setText(2,i18n("no time "));
86 mItem->setText(4,i18n("no time ")); 86 mItem->setText(4,i18n("no time "));
87 } 87 }
88 else { 88 else {
89 mItem->setText(2,e->dtStartTimeStr()); 89 mItem->setText(2,e->dtStartTimeStr());
90 mItem->setText(4,e->dtEndTimeStr()); 90 mItem->setText(4,e->dtEndTimeStr());
91 } 91 }
92 if (e->hasEndDate()) { 92 if (e->hasEndDate()) {
93 mItem->setText(3,e->dtEndDateStr()); 93 mItem->setText(3,e->dtEndDateStr());
94 } 94 }
95 else { 95 else {
96 mItem->setText(3,""); 96 mItem->setText(3,"");
97 } 97 }
98 mItem->setText(5,e->organizer()+" "); 98 mItem->setText(5,e->organizer()+" ");
99 99
100 return true; 100 return true;
101} 101}
102 102
103bool ScheduleItemVisitor::visit(Todo *e) 103bool ScheduleItemVisitor::visit(Todo *e)
104{ 104{
105 mItem->setText(0,e->summary()); 105 mItem->setText(0,e->summary());
106 if (e->hasStartDate()) { 106 if (e->hasStartDate()) {
107 mItem->setText(1,e->dtStartDateStr()); 107 mItem->setText(1,e->dtStartDateStr());
108 if (!e->doesFloat()) { 108 if (!e->doesFloat()) {
109 mItem->setText(2,e->dtStartTimeStr()); 109 mItem->setText(2,e->dtStartTimeStr());
110 } 110 }
111 } 111 }
112 if (e->hasDueDate()) { 112 if (e->hasDueDate()) {
113 mItem->setText(1,e->dtDueDateStr()); 113 mItem->setText(1,e->dtDueDateStr());
114 if (!e->doesFloat()) { 114 if (!e->doesFloat()) {
115 mItem->setText(2,e->dtDueTimeStr()); 115 mItem->setText(2,e->dtDueTimeStr());
116 } 116 }
117 } 117 }
118 mItem->setText(5,e->organizer()+" "); 118 mItem->setText(5,e->organizer()+" ");
119 119
120 return true; 120 return true;
121} 121}
122 122
123bool ScheduleItemVisitor::visit(Journal *) 123bool ScheduleItemVisitor::visit(Journal *)
124{ 124{
125 return false; 125 return false;
126} 126}
127 127
128 128
129/* 129/*
130 * Constructs a IncomingDialog which is a child of 'parent', with the 130 * Constructs a IncomingDialog which is a child of 'parent', with the
131 * name 'name' and widget flags set to 'f' 131 * name 'name' and widget flags set to 'f'
132 * 132 *
133 * The dialog will by default be modeless, unless you set 'modal' to 133 * The dialog will by default be modeless, unless you set 'modal' to
134 * TRUE to construct a modal dialog. 134 * TRUE to construct a modal dialog.
135 */ 135 */
136IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, 136IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing,
137 QWidget* parent,const char* name,bool modal,WFlags fl) : 137 QWidget* parent,const char* name,bool modal,WFlags fl) :
138 IncomingDialog_base(parent,name,modal,fl) 138 IncomingDialog_base(parent,name,modal,fl)
139{ 139{
140 mCalendar = calendar; 140 mCalendar = calendar;
141 mOutgoing = outgoing; 141 mOutgoing = outgoing;
142#ifndef KORG_NOMAIL 142#ifndef KORG_NOMAIL
143 mScheduler = new MailScheduler(mCalendar); 143 mScheduler = new MailScheduler(mCalendar);
144#else 144#else
145 mScheduler = new DummyScheduler(mCalendar); 145 mScheduler = new DummyScheduler(mCalendar);
146#endif 146#endif
147 mMessageListView->setColumnAlignment(1,AlignHCenter); 147 mMessageListView->setColumnAlignment(1,AlignHCenter);
148 mMessageListView->setColumnAlignment(2,AlignHCenter); 148 mMessageListView->setColumnAlignment(2,AlignHCenter);
149 mMessageListView->setColumnAlignment(3,AlignHCenter); 149 mMessageListView->setColumnAlignment(3,AlignHCenter);
150 mMessageListView->setColumnAlignment(4,AlignHCenter); 150 mMessageListView->setColumnAlignment(4,AlignHCenter);
151 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), 151 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)),
152 this,SLOT(showEvent(QListViewItem *))); 152 this,SLOT(showEvent(QListViewItem *)));
153 retrieve(); 153 retrieve();
154} 154}
155 155
156/* 156/*
157 * Destroys the object and frees any allocated resources 157 * Destroys the object and frees any allocated resources
158 */ 158 */
159IncomingDialog::~IncomingDialog() 159IncomingDialog::~IncomingDialog()
160{ 160{
161 // no need to delete child widgets, Qt does it all for us 161 // no need to delete child widgets, Qt does it all for us
162} 162}
163 163
164void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) 164void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing)
165{ 165{
166 mOutgoing = outgoing; 166 mOutgoing = outgoing;
167} 167}
168 168
169void IncomingDialog::retrieve() 169void IncomingDialog::retrieve()
170{ 170{
171 QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); 171 QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions();
172 172
173 ScheduleMessage *message; 173 ScheduleMessage *message;
174 for(message = messages.first();message;message = messages.next()) { 174 for(message = messages.first();message;message = messages.next()) {
175 IncidenceBase *inc = message->event(); 175 IncidenceBase *inc = message->event();
176 Scheduler::Method method = (Scheduler::Method)message->method(); 176 Scheduler::Method method = (Scheduler::Method)message->method();
177 ScheduleMessage::Status status = message->status(); 177 ScheduleMessage::Status status = message->status();
178 178
179 ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); 179 ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status);
180 if(inc->type()!="FreeBusy") { 180 if(inc->type()!="FreeBusy") {
181 Incidence *incidence = static_cast<Incidence *>(inc); 181 Incidence *incidence = static_cast<Incidence *>(inc);
182 ScheduleItemVisitor v(item); 182 ScheduleItemVisitor v(item);
183 if (!incidence->accept(v)) delete item; 183 if (!incidence->accept(v)) delete item;
184 } else { 184 } else {
185 FreeBusy *fb = static_cast<FreeBusy *>(item->event()); 185 FreeBusy *fb = static_cast<FreeBusy *>(item->event());
186 item->setText(0, "FreeBusy"); 186 item->setText(0, "FreeBusy");
187 item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); 187 item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) );
188 item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); 188 item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) );
189 item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); 189 item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) );
190 item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); 190 item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) );
191 item->setText(5, fb->organizer()); 191 item->setText(5, fb->organizer());
192 } 192 }
193 automaticAction(item); 193 automaticAction(item);
194 } 194 }
195 emit numMessagesChanged(mMessageListView->childCount()); 195 emit numMessagesChanged(mMessageListView->childCount());
196} 196}
197 197
198void IncomingDialog::acceptAllMessages() 198void IncomingDialog::acceptAllMessages()
199{ 199{
200 bool success = false; 200 bool success = false;
201 201
202 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); 202 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild();
203 while(item) { 203 while(item) {
204 ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); 204 ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling());
205 if (acceptMessage(item)) success = true; 205 if (acceptMessage(item)) success = true;
206 item = nextitem; 206 item = nextitem;
207 } 207 }
208 208
209 if (success) emit calendarUpdated(); 209 if (success) emit calendarUpdated();
210} 210}
211 211
212void IncomingDialog::acceptMessage() 212void IncomingDialog::acceptMessage()
213{ 213{
214 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); 214 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem();
215 if (item) { 215 if (item) {
216 if (acceptMessage(item)) emit calendarUpdated(); 216 if (acceptMessage(item)) emit calendarUpdated();
217 } 217 }
218} 218}
219 219
220bool IncomingDialog::acceptMessage(ScheduleItemIn *item) 220bool IncomingDialog::acceptMessage(ScheduleItemIn *item)
221{ 221{
222 switch (item->method()) { 222 switch (item->method()) {
223 case Scheduler::Refresh: 223 case Scheduler::Refresh:
224 return incomeRefresh(item); 224 return incomeRefresh(item);
225 break; 225 break;
226 case Scheduler::Counter: 226 case Scheduler::Counter:
227 return incomeCounter(item); 227 return incomeCounter(item);
228 break; 228 break;
229 case Scheduler::Declinecounter: 229 case Scheduler::Declinecounter:
230 return incomeDeclineCounter(item); 230 return incomeDeclineCounter(item);
231 break; 231 break;
232 case Scheduler::Add: 232 case Scheduler::Add:
233 return incomeAdd(item); 233 return incomeAdd(item);
234 break; 234 break;
235 case Scheduler::Request: 235 case Scheduler::Request:
236 return incomeRequest(item); 236 return incomeRequest(item);
237 break; 237 break;
238 default: 238 default:
239 return incomeDefault(item); 239 return incomeDefault(item);
240 } 240 }
241 return false; 241 return false;
242} 242}
243 243
244void IncomingDialog::rejectMessage() 244void IncomingDialog::rejectMessage()
245{ 245{
246 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); 246 ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem();
247 if (item) { 247 if (item) {
248 mScheduler->deleteTransaction(item->event()); 248 mScheduler->deleteTransaction(item->event());
249 delete item; 249 delete item;
250 emit numMessagesChanged(mMessageListView->childCount()); 250 emit numMessagesChanged(mMessageListView->childCount());
251 } 251 }
252} 252}
253 253
254void IncomingDialog::showEvent(QListViewItem *item) 254void IncomingDialog::showEvent(QListViewItem *item)
255{ 255{
256 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); 256 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
257 if( incidence && incidence->type() == "Event" ) { 257 if( incidence && incidence->type() == "Event" ) {
258 Event *event = static_cast<Event *>(incidence); 258 Event *event = static_cast<Event *>(incidence);
259 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); 259 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this);
260 eventViewer->setEvent(event); 260 eventViewer->setEvent(event);
261 eventViewer->show(); 261 eventViewer->show();
262 } 262 }
263} 263}
264 264
265bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) 265bool IncomingDialog::incomeRefresh(ScheduleItemIn *item)
266{ 266{
267 Event *ev = mCalendar->event(item->event()->uid()); 267 Event *ev = mCalendar->event(item->event()->uid());
268 if (ev) { 268 if (ev) {
269 //user interaction before?? 269 //user interaction before??
270 Attendee *att; 270 Attendee *att;
271 QPtrList<Attendee> attlist = ev->attendees(); 271 QPtrList<Attendee> attlist = ev->attendees();
272 for (att=attlist.first(); att; att=attlist.next()) { 272 for (att=attlist.first(); att; att=attlist.next()) {
273 Event *event = new Event(*ev); 273 Event *event = new Event(*ev);
274 mOutgoing->addMessage(event,Scheduler::Request,att->email()); 274 mOutgoing->addMessage(event,Scheduler::Request,att->email());
275 delete(event); 275 delete(event);
276 } 276 }
277 mScheduler->deleteTransaction(item->event()); 277 mScheduler->deleteTransaction(item->event());
278 delete item; 278 delete item;
279 emit numMessagesChanged(mMessageListView->childCount()); 279 emit numMessagesChanged(mMessageListView->childCount());
280 return true; 280 return true;
281 } 281 }
282 mScheduler->deleteTransaction(item->event()); 282 mScheduler->deleteTransaction(item->event());
283 delete item; 283 delete item;
284 emit numMessagesChanged(mMessageListView->childCount()); 284 emit numMessagesChanged(mMessageListView->childCount());
285 return false; 285 return false;
286} 286}
287 287
288bool IncomingDialog::incomeCounter(ScheduleItemIn *item) 288bool IncomingDialog::incomeCounter(ScheduleItemIn *item)
289{ 289{
290 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); 290 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
291 // currently only events supportet - attetion at insertion below! 291 // currently only events supportet - attetion at insertion below!
292 if ( incidence->type() != "Event" ) return false; 292 if ( incidence->type() != "Event" ) return false;
293 293
294 Event *counterEvent = static_cast<Event *>( incidence ); 294 Event *counterEvent = static_cast<Event *>( incidence );
295 295
296 Event *even = mCalendar->event(counterEvent->uid()); 296 Event *even = mCalendar->event(counterEvent->uid());
297 297
298 KOCounterDialog *eventViewer = new KOCounterDialog(this); 298 KOCounterDialog *eventViewer = new KOCounterDialog(this);
299 eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); 299 eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>"));
300 eventViewer->addEvent(counterEvent); 300 eventViewer->addEvent(counterEvent);
301 eventViewer->addText("<hr>"); 301 eventViewer->addText("<hr>");
302 eventViewer->addText(i18n("<b>Original event:</b><p>")); 302 eventViewer->addText(i18n("<b>Original event:</b><p>"));
303 if (even) eventViewer->addEvent(even); 303 if (even) eventViewer->addEvent(even);
304 else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); 304 else eventViewer->addText(i18n("A corresponding event is missing in your calendar!"));
305 eventViewer->addText("<hr>"); 305 eventViewer->addText("<hr>");
306 eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); 306 eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event"));
307 eventViewer->show(); 307 eventViewer->show();
308 308
309 eventViewer->exec(); 309 eventViewer->exec();
310 if (eventViewer->result()) { 310 if (eventViewer->result()) {
311 kdDebug() << "IncomingDialog::Counter:Accept" << endl; 311 kdDebug() << "IncomingDialog::Counter:Accept" << endl;
312 int revision = 0; 312 int revision = 0;
313 if (even) { 313 if (even) {
314 revision = even->revision(); 314 revision = even->revision();
315 mCalendar->deleteEvent(even); 315 mCalendar->deleteEvent(even);
316 } 316 }
317 mCalendar->addIncidence(counterEvent); 317 mCalendar->addIncidence(counterEvent);
318 318
319 even = mCalendar->event(item->event()->uid()); 319 even = mCalendar->event(item->event()->uid());
320 if (even) { 320 if (even) {
321 if (revision < even->revision()) 321 if (revision < even->revision())
322 even->setRevision(even->revision()+1); 322 even->setRevision(even->revision()+1);
323 else 323 else
324 even->setRevision(revision+1); 324 even->setRevision(revision+1);
325 Event *ev = new Event(*even); 325 Event *ev = new Event(*even);
326 mOutgoing->addMessage(ev,Scheduler::Request); 326 mOutgoing->addMessage(ev,Scheduler::Request);
327 delete(ev); 327 delete(ev);
328 } 328 }
329 mScheduler->deleteTransaction(item->event()); 329 mScheduler->deleteTransaction(item->event());
330 delete item; 330 delete item;
331 emit numMessagesChanged(mMessageListView->childCount()); 331 emit numMessagesChanged(mMessageListView->childCount());
332 return true; 332 return true;
333 } else { 333 } else {
334 kdDebug() << "IncomingDialog::Counter:Decline" << endl; 334 kdDebug() << "IncomingDialog::Counter:Decline" << endl;
335 //the counter-sender's email is missing... 335 //the counter-sender's email is missing...
336 //now every attendee gets an declinecounter :-( 336 //now every attendee gets an declinecounter :-(
337 mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); 337 mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter);
338 delete item; 338 delete item;
339 emit numMessagesChanged(mMessageListView->childCount()); 339 emit numMessagesChanged(mMessageListView->childCount());
340 mScheduler->deleteTransaction(item->event()); 340 mScheduler->deleteTransaction(item->event());
341 delete item; 341 delete item;
342 emit numMessagesChanged(mMessageListView->childCount()); 342 emit numMessagesChanged(mMessageListView->childCount());
343 return true; 343 return true;
344 } 344 }
345 //mScheduler->deleteTransaction(item->event()); 345 //mScheduler->deleteTransaction(item->event());
346 delete item; 346 delete item;
347 emit numMessagesChanged(mMessageListView->childCount()); 347 emit numMessagesChanged(mMessageListView->childCount());
348 return false; 348 return false;
349} 349}
350 350
351bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) 351bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item)
352{ 352{
353 Event *even = mCalendar->event(item->event()->uid()); 353 Event *even = mCalendar->event(item->event()->uid());
354 if (even) { 354 if (even) {
355 mOutgoing->addMessage(even,Scheduler::Refresh); 355 mOutgoing->addMessage(even,Scheduler::Refresh);
356 mScheduler->deleteTransaction(item->event()); 356 mScheduler->deleteTransaction(item->event());
357 delete item; 357 delete item;
358 emit numMessagesChanged(mMessageListView->childCount()); 358 emit numMessagesChanged(mMessageListView->childCount());
359 return true; 359 return true;
360 } 360 }
361 mScheduler->deleteTransaction(item->event()); 361 mScheduler->deleteTransaction(item->event());
362 delete item; 362 delete item;
363 emit numMessagesChanged(mMessageListView->childCount()); 363 emit numMessagesChanged(mMessageListView->childCount());
364 return false; 364 return false;
365} 365}
366 366
367bool IncomingDialog::incomeAdd(ScheduleItemIn *item) 367bool IncomingDialog::incomeAdd(ScheduleItemIn *item)
368{ 368{
369 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); 369 IncidenceBase *incidence = ((ScheduleItemIn *)item)->event();
370 if (incidence->type() == "Event" ) { 370 if (incidence->type() == "Event" ) {
371 Event *refr = static_cast<Event *>( incidence ); 371 Event *refr = static_cast<Event *>( incidence );
372 mOutgoing->addMessage(refr,Scheduler::Refresh); 372 mOutgoing->addMessage(refr,Scheduler::Refresh);
373 mScheduler->deleteTransaction( incidence ); 373 mScheduler->deleteTransaction( incidence );
374 delete item; 374 delete item;
375 emit numMessagesChanged(mMessageListView->childCount()); 375 emit numMessagesChanged(mMessageListView->childCount());
376 return true; 376 return true;
377 } 377 }
378 else { 378 else {
379 kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl; 379 kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl;
380 mScheduler->deleteTransaction( incidence ); 380 mScheduler->deleteTransaction( incidence );
381 delete item; 381 delete item;
382 emit numMessagesChanged(mMessageListView->childCount()); 382 emit numMessagesChanged(mMessageListView->childCount());
383 return false; 383 return false;
384 } 384 }
385} 385}
386 386
387bool IncomingDialog::incomeDefault(ScheduleItemIn *item) 387bool IncomingDialog::incomeDefault(ScheduleItemIn *item)
388{ 388{
389 if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) { 389 if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) {
390 delete item; 390 delete item;
391 emit numMessagesChanged(mMessageListView->childCount()); 391 emit numMessagesChanged(mMessageListView->childCount());
392 return true; 392 return true;
393 } 393 }
394 else { 394 else {
395 KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses.")); 395 KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses."));
396 kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl; 396 kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl;
397 return false; 397 return false;
398 } 398 }
399 return false; 399 return false;
400} 400}
401 401
402bool IncomingDialog::incomeRequest(ScheduleItemIn *item) 402bool IncomingDialog::incomeRequest(ScheduleItemIn *item)
403{ 403{
404 if (item->event()->type()=="FreeBusy") { 404 if (item->event()->type()=="FreeBusy") {
405 //handel freebusy request 405 //handel freebusy request
406 IncidenceBase *inc = item->event(); 406 IncidenceBase *inc = item->event();
407 QDateTime start = inc->dtStart(); 407 QDateTime start = inc->dtStart();
408 QDateTime end = start.addDays(inc->duration()/86400); 408 QDateTime end = start.addDays(inc->duration()/86400);
409 409
410 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 410 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
411 freebusy->setOrganizer(inc->organizer()); 411 freebusy->setOrganizer(inc->organizer());
412 Attendee *att = new Attendee(KOPrefs::instance()->fullName(), 412 Attendee *att = new Attendee(KOPrefs::instance()->fullName(),
413 KOPrefs::instance()->email()); 413 KOPrefs::instance()->email());
414 freebusy->addAttendee(att); 414 freebusy->addAttendee(att);
415 415
416 kdDebug() << "calendarview: schedule_publish_freebusy: startDate: " 416 kdDebug() << "calendarview: schedule_publish_freebusy: startDate: "
417 << KGlobal::locale()->formatDateTime( start ) << " End Date: " 417 << KGlobal::locale()->formatDateTime( start ) << " End Date: "
418 << KGlobal::locale()->formatDateTime( end ) << endl; 418 << KGlobal::locale()->formatDateTime( end ) << endl;
419 419
420 if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { 420 if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) {
421 delete item; 421 delete item;
422 emit numMessagesChanged(mMessageListView->childCount()); 422 emit numMessagesChanged(mMessageListView->childCount());
423 delete(freebusy); 423 delete(freebusy);
424 return true; 424 return true;
425 } 425 }
426 return false; 426 return false;
427 } else { 427 } else {
428 return incomeDefault(item); 428 return incomeDefault(item);
429 } 429 }
430 return false; 430 return false;
431} 431}
432 432
433bool IncomingDialog::automaticAction(ScheduleItemIn *item) 433bool IncomingDialog::automaticAction(ScheduleItemIn *item)
434{ 434{
435 bool autoAction = false; 435 bool autoAction = false;
436 IncidenceBase *inc = item->event(); 436 IncidenceBase *inc = item->event();
437 Scheduler::Method method = item->method(); 437 Scheduler::Method method = item->method();
438 438
439 if( inc->type()=="FreeBusy" ) { 439 if( inc->type()=="FreeBusy" ) {
440 if ( method==Scheduler::Request ) { 440 if ( method==Scheduler::Request ) {
441 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { 441 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
442 // reply freebusy information 442 // reply freebusy information
443 if ( checkOrganizerInAddressbook(inc->organizer()) ) { 443 if ( checkOrganizerInAddressbook(inc->organizer()) ) {
444 incomeRequest(item); 444 incomeRequest(item);
445 } 445 }
446 } else return false; 446 } else return false;
447 } else { 447 } else {
448 448
449 if ( method==Scheduler::Reply ) { 449 if ( method==Scheduler::Reply ) {
450 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { 450 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
451 // insert freebusy information 451 // insert freebusy information
452 //if ( checkAttendeesInAddressbook(inc) ) 452 //if ( checkAttendeesInAddressbook(inc) )
453 453
454 } else return false; 454 } else return false;
455 } else { 455 } else {
456 if ( method==Scheduler::Publish) { 456 if ( method==Scheduler::Publish) {
457 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { 457 if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) {
458 // insert freebusy information 458 // insert freebusy information
459 //if ( checkOrganizerInAddressbook(inc->organizer()) ) 459 //if ( checkOrganizerInAddressbook(inc->organizer()) )
460 460
461 } 461 }
462 } else return false; 462 } else return false;
463 } 463 }
464 } 464 }
465 } 465 }
466 466
467 if ( inc->type()=="Event" ) { 467 if ( inc->type()=="Event" ) {
468 if ( method==Scheduler::Request || method==Scheduler::Publish ) { 468 if ( method==Scheduler::Request || method==Scheduler::Publish ) {
469 if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { 469 if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) {
470 // insert event 470 // insert event
471 if ( checkOrganizerInAddressbook(inc->organizer()) ) 471 if ( checkOrganizerInAddressbook(inc->organizer()) )
472 autoAction = acceptMessage(item); 472 autoAction = acceptMessage(item);
473 } else return false; 473 } else return false;
474 } else { 474 } else {
475 475
476 if ( method==Scheduler::Reply ) { 476 if ( method==Scheduler::Reply ) {
477 if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { 477 if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) {
478 // update event information 478 // update event information
479 if ( checkAttendeesInAddressbook(inc) ) 479 if ( checkAttendeesInAddressbook(inc) )
480 autoAction = acceptMessage(item); 480 autoAction = acceptMessage(item);
481 } else return false; 481 } else return false;
482 } else { 482 } else {
483 483
484 if ( method==Scheduler::Refresh ) { 484 if ( method==Scheduler::Refresh ) {
485 if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { 485 if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) {
486 // send refresh-information 486 // send refresh-information
487 if ( checkAttendeesInAddressbook(inc) ) 487 if ( checkAttendeesInAddressbook(inc) )
488 autoAction = acceptMessage(item); 488 autoAction = acceptMessage(item);
489 else return false; 489 else return false;
490 } else return false; 490 } else return false;
491 } else return false; 491 } else return false;
492 } 492 }
493 } 493 }
494 } 494 }
495 return autoAction; 495 return autoAction;
496} 496}
497 497
498bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) 498bool IncomingDialog::checkOrganizerInAddressbook(QString organizer)
499{ 499{
500 bool inBook = false; 500 bool inBook = false;
501#ifndef KORG_NOKABC 501#ifndef KORG_NOKABC
502 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 502 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
503 KABC::Addressee::List addressList; 503 KABC::Addressee::List addressList;
504 addressList = add_book->findByEmail(organizer); 504 addressList = add_book->findByEmail(organizer);
505 if ( addressList.size()>0 ) inBook = true; 505 if ( addressList.size()>0 ) inBook = true;
506#endif 506#endif
507 return inBook; 507 return inBook;
508} 508}
509 509
510bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) 510bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc)
511{ 511{
512 bool inBook = false; 512 bool inBook = false;
513#ifndef KORG_NOKABC 513#ifndef KORG_NOKABC
514 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 514 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
515 KABC::Addressee::List addressList; 515 KABC::Addressee::List addressList;
516 QPtrList <Attendee> attendees; 516 QPtrList <Attendee> attendees;
517 Attendee *att; 517 Attendee *att;
518 attendees = inc->attendees(); 518 attendees = inc->attendees();
519 for (att=attendees.first();att;att=attendees.next()) { 519 for (att=attendees.first();att;att=attendees.next()) {
520 addressList = add_book->findByEmail(att->email()); 520 addressList = add_book->findByEmail(att->email());
521 if (addressList.size()>0 ) inBook = true; 521 if (addressList.size()>0 ) inBook = true;
522 } 522 }
523#endif 523#endif
524 return inBook; 524 return inBook;
525} 525}
526 526
527#include "incomingdialog.moc" 527//#include "incomingdialog.moc"
diff --git a/korganizer/incomingdialog_base.cpp b/korganizer/incomingdialog_base.cpp
index 91740a4..8589803 100644
--- a/korganizer/incomingdialog_base.cpp
+++ b/korganizer/incomingdialog_base.cpp
@@ -1,137 +1,137 @@
1#include <klocale.h> 1#include <klocale.h>
2/**************************************************************************** 2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/incomingdialog_base.ui' 3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/incomingdialog_base.ui'
4** 4**
5** Created: Sat Mar 29 22:31:27 2003 5** Created: Sat Mar 29 22:31:27 2003
6** by: The User Interface Compiler () 6** by: The User Interface Compiler ()
7** 7**
8** WARNING! All changes made in this file will be lost! 8** WARNING! All changes made in this file will be lost!
9****************************************************************************/ 9****************************************************************************/
10 10
11#include "incomingdialog_base.h" 11#include "incomingdialog_base.h"
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qheader.h> 14#include <qheader.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qpushbutton.h> 16#include <qpushbutton.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qtooltip.h> 18#include <qtooltip.h>
19#include <qwhatsthis.h> 19#include <qwhatsthis.h>
20 20
21/* 21/*
22 * Constructs a IncomingDialog_base as a child of 'parent', with the 22 * Constructs a IncomingDialog_base as a child of 'parent', with the
23 * name 'name' and widget flags set to 'f'. 23 * name 'name' and widget flags set to 'f'.
24 * 24 *
25 * The dialog will by default be modeless, unless you set 'modal' to 25 * The dialog will by default be modeless, unless you set 'modal' to
26 * TRUE to construct a modal dialog. 26 * TRUE to construct a modal dialog.
27 */ 27 */
28IncomingDialog_base::IncomingDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl ) 28IncomingDialog_base::IncomingDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
29 : QDialog( parent, name, modal, fl ) 29 : QDialog( parent, name, modal, fl )
30 30
31{ 31{
32 if ( !name ) 32 if ( !name )
33 setName( "IncomingDialog_base" ); 33 setName( "IncomingDialog_base" );
34 IncomingDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "IncomingDialog_baseLayout"); 34 IncomingDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "IncomingDialog_baseLayout");
35 35
36 PushButton4 = new QPushButton( this, "PushButton4" ); 36 PushButton4 = new QPushButton( this, "PushButton4" );
37 37
38 IncomingDialog_baseLayout->addWidget( PushButton4, 0, 1 ); 38 IncomingDialog_baseLayout->addWidget( PushButton4, 0, 1 );
39 39
40 PushButton7 = new QPushButton( this, "PushButton7" ); 40 PushButton7 = new QPushButton( this, "PushButton7" );
41 PushButton7->setDefault( TRUE ); 41 PushButton7->setDefault( TRUE );
42 42
43 IncomingDialog_baseLayout->addWidget( PushButton7, 5, 1 ); 43 IncomingDialog_baseLayout->addWidget( PushButton7, 5, 1 );
44 44
45 mMessageListView = new QListView( this, "mMessageListView" ); 45 mMessageListView = new QListView( this, "mMessageListView" );
46 mMessageListView->addColumn( tr2i18n( "Summary" ) ); 46 mMessageListView->addColumn( tr2i18n( "Summary" ) );
47 mMessageListView->addColumn( tr2i18n( "Start Date" ) ); 47 mMessageListView->addColumn( tr2i18n( "Start Date" ) );
48 mMessageListView->addColumn( tr2i18n( "Start Time" ) ); 48 mMessageListView->addColumn( tr2i18n( "Start Time" ) );
49 mMessageListView->addColumn( tr2i18n( "End Date" ) ); 49 mMessageListView->addColumn( tr2i18n( "End Date" ) );
50 mMessageListView->addColumn( tr2i18n( "End Time" ) ); 50 mMessageListView->addColumn( tr2i18n( "End Time" ) );
51 mMessageListView->addColumn( tr2i18n( "Organizer" ) ); 51 mMessageListView->addColumn( tr2i18n( "Organizer" ) );
52 mMessageListView->addColumn( tr2i18n( "Method" ) ); 52 mMessageListView->addColumn( tr2i18n( "Method" ) );
53 mMessageListView->addColumn( tr2i18n( "Status" ) ); 53 mMessageListView->addColumn( tr2i18n( "Status" ) );
54 mMessageListView->setAllColumnsShowFocus( FALSE ); 54 mMessageListView->setAllColumnsShowFocus( FALSE );
55 55
56 IncomingDialog_baseLayout->addMultiCellWidget( mMessageListView, 0, 5, 0, 0 ); 56 IncomingDialog_baseLayout->addMultiCellWidget( mMessageListView, 0, 5, 0, 0 );
57 57
58 PushButton7_2 = new QPushButton( this, "PushButton7_2" ); 58 PushButton7_2 = new QPushButton( this, "PushButton7_2" );
59 59
60 IncomingDialog_baseLayout->addWidget( PushButton7_2, 3, 1 ); 60 IncomingDialog_baseLayout->addWidget( PushButton7_2, 3, 1 );
61 61
62 PushButton8 = new QPushButton( this, "PushButton8" ); 62 PushButton8 = new QPushButton( this, "PushButton8" );
63 63
64 IncomingDialog_baseLayout->addWidget( PushButton8, 1, 1 ); 64 IncomingDialog_baseLayout->addWidget( PushButton8, 1, 1 );
65 65
66 PushButton9 = new QPushButton( this, "PushButton9" ); 66 PushButton9 = new QPushButton( this, "PushButton9" );
67 67
68 IncomingDialog_baseLayout->addWidget( PushButton9, 2, 1 ); 68 IncomingDialog_baseLayout->addWidget( PushButton9, 2, 1 );
69 QSpacerItem* spacer = new QSpacerItem( 20, 70, QSizePolicy::Minimum, QSizePolicy::Expanding ); 69 QSpacerItem* spacer = new QSpacerItem( 20, 70, QSizePolicy::Minimum, QSizePolicy::Expanding );
70 IncomingDialog_baseLayout->addItem( spacer, 4, 1 ); 70 IncomingDialog_baseLayout->addItem( spacer, 4, 1 );
71 languageChange(); 71 languageChange();
72 resize( QSize(525, 262).expandedTo(minimumSizeHint()) ); 72 resize( QSize(525, 262).expandedTo(minimumSizeHint()) );
73 73
74 // signals and slots connections 74 // signals and slots connections
75 connect( PushButton7, SIGNAL( clicked() ), this, SLOT( accept() ) ); 75 connect( PushButton7, SIGNAL( clicked() ), this, SLOT( accept() ) );
76 connect( PushButton4, SIGNAL( clicked() ), this, SLOT( retrieve() ) ); 76 connect( PushButton4, SIGNAL( clicked() ), this, SLOT( retrieve() ) );
77 connect( PushButton7_2, SIGNAL( clicked() ), this, SLOT( acceptAllMessages() ) ); 77 connect( PushButton7_2, SIGNAL( clicked() ), this, SLOT( acceptAllMessages() ) );
78 78
79 // tab order 79 // tab order
80 setTabOrder( PushButton7, PushButton4 ); 80 setTabOrder( PushButton7, PushButton4 );
81 setTabOrder( PushButton4, PushButton7_2 ); 81 setTabOrder( PushButton4, PushButton7_2 );
82 setTabOrder( PushButton7_2, mMessageListView ); 82 setTabOrder( PushButton7_2, mMessageListView );
83 setTabOrder( mMessageListView, PushButton8 ); 83 setTabOrder( mMessageListView, PushButton8 );
84 setTabOrder( PushButton8, PushButton9 ); 84 setTabOrder( PushButton8, PushButton9 );
85} 85}
86 86
87/* 87/*
88 * Destroys the object and frees any allocated resources 88 * Destroys the object and frees any allocated resources
89 */ 89 */
90IncomingDialog_base::~IncomingDialog_base() 90IncomingDialog_base::~IncomingDialog_base()
91{ 91{
92 // no need to delete child widgets, Qt does it all for us 92 // no need to delete child widgets, Qt does it all for us
93} 93}
94 94
95/* 95/*
96 * Sets the strings of the subwidgets using the current 96 * Sets the strings of the subwidgets using the current
97 * language. 97 * language.
98 */ 98 */
99void IncomingDialog_base::languageChange() 99void IncomingDialog_base::languageChange()
100{ 100{
101 setCaption( tr2i18n( "Scheduler - Incoming Messages" ) ); 101 setCaption( tr2i18n( "Scheduler - Incoming Messages" ) );
102 PushButton4->setText( tr2i18n( "Retrieve &Messages" ) ); 102 PushButton4->setText( tr2i18n( "Retrieve &Messages" ) );
103 PushButton7->setText( tr2i18n( "&Close" ) ); 103 PushButton7->setText( tr2i18n( "&Close" ) );
104 mMessageListView->header()->setLabel( 0, tr2i18n( "Summary" ) ); 104 mMessageListView->header()->setLabel( 0, tr2i18n( "Summary" ) );
105 mMessageListView->header()->setLabel( 1, tr2i18n( "Start Date" ) ); 105 mMessageListView->header()->setLabel( 1, tr2i18n( "Start Date" ) );
106 mMessageListView->header()->setLabel( 2, tr2i18n( "Start Time" ) ); 106 mMessageListView->header()->setLabel( 2, tr2i18n( "Start Time" ) );
107 mMessageListView->header()->setLabel( 3, tr2i18n( "End Date" ) ); 107 mMessageListView->header()->setLabel( 3, tr2i18n( "End Date" ) );
108 mMessageListView->header()->setLabel( 4, tr2i18n( "End Time" ) ); 108 mMessageListView->header()->setLabel( 4, tr2i18n( "End Time" ) );
109 mMessageListView->header()->setLabel( 5, tr2i18n( "Organizer" ) ); 109 mMessageListView->header()->setLabel( 5, tr2i18n( "Organizer" ) );
110 mMessageListView->header()->setLabel( 6, tr2i18n( "Method" ) ); 110 mMessageListView->header()->setLabel( 6, tr2i18n( "Method" ) );
111 mMessageListView->header()->setLabel( 7, tr2i18n( "Status" ) ); 111 mMessageListView->header()->setLabel( 7, tr2i18n( "Status" ) );
112 PushButton7_2->setText( tr2i18n( "Accept A&ll" ) ); 112 PushButton7_2->setText( tr2i18n( "Accept A&ll" ) );
113 PushButton8->setText( tr2i18n( "&Accept" ) ); 113 PushButton8->setText( tr2i18n( "&Accept" ) );
114 PushButton9->setText( tr2i18n( "&Reject" ) ); 114 PushButton9->setText( tr2i18n( "&Reject" ) );
115} 115}
116 116
117void IncomingDialog_base::acceptAllMessages() 117void IncomingDialog_base::acceptAllMessages()
118{ 118{
119 qWarning( "IncomingDialog_base::acceptAllMessages(): Not implemented yet" ); 119 qWarning( "IncomingDialog_base::acceptAllMessages(): Not implemented yet" );
120} 120}
121 121
122void IncomingDialog_base::acceptMessage() 122void IncomingDialog_base::acceptMessage()
123{ 123{
124 qWarning( "IncomingDialog_base::acceptMessage(): Not implemented yet" ); 124 qWarning( "IncomingDialog_base::acceptMessage(): Not implemented yet" );
125} 125}
126 126
127void IncomingDialog_base::rejectMessage() 127void IncomingDialog_base::rejectMessage()
128{ 128{
129 qWarning( "IncomingDialog_base::rejectMessage(): Not implemented yet" ); 129 qWarning( "IncomingDialog_base::rejectMessage(): Not implemented yet" );
130} 130}
131 131
132void IncomingDialog_base::retrieve() 132void IncomingDialog_base::retrieve()
133{ 133{
134 qWarning( "IncomingDialog_base::retrieve(): Not implemented yet" ); 134 qWarning( "IncomingDialog_base::retrieve(): Not implemented yet" );
135} 135}
136 136
137#include "incomingdialog_base.moc" 137//#include "incomingdialog_base.moc"
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp
index d1d7946..7af5cf4 100644
--- a/korganizer/journalentry.cpp
+++ b/korganizer/journalentry.cpp
@@ -1,170 +1,170 @@
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// 24//
25// Journal Entry 25// Journal Entry
26 26
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qlayout.h> 28#include <qlayout.h>
29 29
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <klocale.h> 32#include <klocale.h>
33#include <ktextedit.h> 33#include <ktextedit.h>
34#include "koprefs.h" 34#include "koprefs.h"
35 35
36#include <libkcal/journal.h> 36#include <libkcal/journal.h>
37#include <libkcal/calendarresources.h> 37#include <libkcal/calendarresources.h>
38#include <libkcal/resourcecalendar.h> 38#include <libkcal/resourcecalendar.h>
39#include <kresources/resourceselectdialog.h> 39#include <kresources/resourceselectdialog.h>
40 40
41#include "journalentry.h" 41#include "journalentry.h"
42#include "journalentry.moc" 42//#include "journalentry.moc"
43#ifndef DESKTOP_VERSION 43#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#endif 45#endif
46JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : 46JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) :
47 QFrame(parent) 47 QFrame(parent)
48{ 48{
49 mCalendar = calendar; 49 mCalendar = calendar;
50 mJournal = 0; 50 mJournal = 0;
51 mDirty = false; 51 mDirty = false;
52 52
53 mTitleLabel = new QLabel(i18n("Title"),this); 53 mTitleLabel = new QLabel(i18n("Title"),this);
54 mTitleLabel->setMargin(2); 54 mTitleLabel->setMargin(2);
55 mTitleLabel->setAlignment(AlignCenter); 55 mTitleLabel->setAlignment(AlignCenter);
56 56
57 mEditor = new KTextEdit(this); 57 mEditor = new KTextEdit(this);
58 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); 58 connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty()));
59#ifndef DESKTOP_VERSION 59#ifndef DESKTOP_VERSION
60 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); 60 QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold );
61#endif 61#endif
62 mEditor->setWordWrap( KTextEdit::WidgetWidth ); 62 mEditor->setWordWrap( KTextEdit::WidgetWidth );
63 QBoxLayout *topLayout = new QVBoxLayout(this); 63 QBoxLayout *topLayout = new QVBoxLayout(this);
64 topLayout->addWidget(mTitleLabel); 64 topLayout->addWidget(mTitleLabel);
65 topLayout->addWidget(mEditor); 65 topLayout->addWidget(mEditor);
66 mEditor->installEventFilter(this); 66 mEditor->installEventFilter(this);
67} 67}
68 68
69JournalEntry::~JournalEntry() 69JournalEntry::~JournalEntry()
70{ 70{
71} 71}
72 72
73void JournalEntry::setDate(const QDate &date) 73void JournalEntry::setDate(const QDate &date)
74{ 74{
75 writeJournal(); 75 writeJournal();
76 76
77 mTitleLabel->setText(KGlobal::locale()->formatDate(date)); 77 mTitleLabel->setText(KGlobal::locale()->formatDate(date));
78 78
79 79
80 mDate = date; 80 mDate = date;
81} 81}
82 82
83void JournalEntry::setJournal(Journal *journal) 83void JournalEntry::setJournal(Journal *journal)
84{ 84{
85 writeJournal(); 85 writeJournal();
86 86
87 mJournal = journal; 87 mJournal = journal;
88 88
89 mEditor->setText(mJournal->description()); 89 mEditor->setText(mJournal->description());
90 90
91 mDirty = false; 91 mDirty = false;
92} 92}
93 93
94Journal *JournalEntry::journal() const 94Journal *JournalEntry::journal() const
95{ 95{
96 return mJournal; 96 return mJournal;
97} 97}
98 98
99void JournalEntry::setDirty() 99void JournalEntry::setDirty()
100{ 100{
101 mDirty = true; 101 mDirty = true;
102 102
103// kdDebug() << "JournalEntry::setDirty()" << endl; 103// kdDebug() << "JournalEntry::setDirty()" << endl;
104} 104}
105 105
106void JournalEntry::clear() 106void JournalEntry::clear()
107{ 107{
108 mJournal = 0; 108 mJournal = 0;
109 mEditor->setText(""); 109 mEditor->setText("");
110} 110}
111 111
112bool JournalEntry::eventFilter( QObject *o, QEvent *e ) 112bool JournalEntry::eventFilter( QObject *o, QEvent *e )
113{ 113{
114// kdDebug() << "JournalEntry::event received " << e->type() << endl; 114// kdDebug() << "JournalEntry::event received " << e->type() << endl;
115 115
116 if ( e->type() == QEvent::FocusOut ) { 116 if ( e->type() == QEvent::FocusOut ) {
117 writeJournal(); 117 writeJournal();
118 } 118 }
119 if ( e->type() == QEvent::KeyPress ) { 119 if ( e->type() == QEvent::KeyPress ) {
120 QKeyEvent * k = (QKeyEvent *) e; 120 QKeyEvent * k = (QKeyEvent *) e;
121 if ( k->state() == Qt::ControlButton ) { 121 if ( k->state() == Qt::ControlButton ) {
122 k->ignore(); 122 k->ignore();
123 //return true; 123 //return true;
124 } 124 }
125 } 125 }
126 126
127 return QFrame::eventFilter( o, e ); // standard event processing 127 return QFrame::eventFilter( o, e ); // standard event processing
128} 128}
129 129
130void JournalEntry::writeJournal() 130void JournalEntry::writeJournal()
131{ 131{
132// kdDebug() << "JournalEntry::writeJournal()" << endl; 132// kdDebug() << "JournalEntry::writeJournal()" << endl;
133 if (!mDirty) return; 133 if (!mDirty) return;
134 134
135 if (mEditor->text().isEmpty()) { 135 if (mEditor->text().isEmpty()) {
136 if ( mJournal ) { 136 if ( mJournal ) {
137 mDirty = false; 137 mDirty = false;
138 bool conf = KOPrefs::instance()->mConfirm; 138 bool conf = KOPrefs::instance()->mConfirm;
139 KOPrefs::instance()->mConfirm = false; 139 KOPrefs::instance()->mConfirm = false;
140 emit deleteJournal(mJournal); 140 emit deleteJournal(mJournal);
141 KOPrefs::instance()->mConfirm = conf; 141 KOPrefs::instance()->mConfirm = conf;
142 mJournal = 0; 142 mJournal = 0;
143 } 143 }
144 return; 144 return;
145 } 145 }
146 146
147// kdDebug() << "JournalEntry::writeJournal()..." << endl; 147// kdDebug() << "JournalEntry::writeJournal()..." << endl;
148 148
149 if (!mJournal) { 149 if (!mJournal) {
150 mJournal = new Journal; 150 mJournal = new Journal;
151 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); 151 mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0)));
152 mCalendar->addJournal(mJournal); 152 mCalendar->addJournal(mJournal);
153 } 153 }
154 154
155 mJournal->setDescription(mEditor->text()); 155 mJournal->setDescription(mEditor->text());
156 156
157 mDirty = false; 157 mDirty = false;
158} 158}
159 159
160void JournalEntry::flushEntry() 160void JournalEntry::flushEntry()
161{ 161{
162 if (!mDirty) return; 162 if (!mDirty) return;
163 163
164 writeJournal(); 164 writeJournal();
165} 165}
166void JournalEntry::keyPressEvent ( QKeyEvent * e ) 166void JournalEntry::keyPressEvent ( QKeyEvent * e )
167{ 167{
168 e->ignore(); 168 e->ignore();
169 169
170} 170}
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 12e983b..7d0c516 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -1,364 +1,364 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 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 <qstring.h> 24#include <qstring.h>
25#include <qkeycode.h> 25#include <qkeycode.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qframe.h> 28#include <qframe.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qapplication.h> 30#include <qapplication.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kglobal.h> 34#include <kglobal.h>
35 35
36#include "koglobals.h" 36#include "koglobals.h"
37#include "koprefs.h" 37#include "koprefs.h"
38#ifndef KORG_NOPLUGINS 38#ifndef KORG_NOPLUGINS
39#include "kocore.h" 39#include "kocore.h"
40#endif 40#endif
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "navigatorbar.h" 44#include "navigatorbar.h"
45 45
46#include "kdatenavigator.h" 46#include "kdatenavigator.h"
47 47
48KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar, 48KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar,
49 bool show_week_nums, const char *name, 49 bool show_week_nums, const char *name,
50 QDate startDate ) 50 QDate startDate )
51 : QFrame(parent, name), 51 : QFrame(parent, name),
52 updateTimer(0L) 52 updateTimer(0L)
53{ 53{
54 mCalendar = calendar; 54 mCalendar = calendar;
55 55
56 setFrameStyle(QFrame::NoFrame); 56 setFrameStyle(QFrame::NoFrame);
57 57
58 QGridLayout *topLayout = new QGridLayout(this,8,8); 58 QGridLayout *topLayout = new QGridLayout(this,8,8);
59 59
60 if (! startDate.isValid()) { 60 if (! startDate.isValid()) {
61 kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl; 61 kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl;
62 startDate = QDate::currentDate(); 62 startDate = QDate::currentDate();
63 } 63 }
64 64
65 mSelectedDates.append(startDate); 65 mSelectedDates.append(startDate);
66 m_MthYr = startDate; 66 m_MthYr = startDate;
67 m_bShowWeekNums = show_week_nums; 67 m_bShowWeekNums = show_week_nums;
68 68
69 setFont( KOPrefs::instance()->mDateNavigatorFont ); 69 setFont( KOPrefs::instance()->mDateNavigatorFont );
70 mNavigatorBar = new NavigatorBar( startDate, this ); 70 mNavigatorBar = new NavigatorBar( startDate, this );
71 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); 71 topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 );
72 //mNavigatorBar->resize( 1,1); 72 //mNavigatorBar->resize( 1,1);
73 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); 73 connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
74 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); 74 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
75 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); 75 connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
76 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); 76 connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
77 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 77 connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
78 78
79 // get the day of the week on the first day 79 // get the day of the week on the first day
80 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 80 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
81 m_fstDayOfWk = dayone.dayOfWeek(); 81 m_fstDayOfWk = dayone.dayOfWeek();
82 82
83 int i; 83 int i;
84 84
85 // Set up the heading fields. 85 // Set up the heading fields.
86 for( i = 0; i < 7; i++ ) { 86 for( i = 0; i < 7; i++ ) {
87 headings[i] = new QLabel("",this); 87 headings[i] = new QLabel("",this);
88 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); 88 //headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
89 headings[i]->setAlignment(AlignCenter); 89 headings[i]->setAlignment(AlignCenter);
90 90
91 topLayout->addWidget(headings[i],1,i+1); 91 topLayout->addWidget(headings[i],1,i+1);
92 } 92 }
93 93
94 // Create the weeknumber labels 94 // Create the weeknumber labels
95 for( i = 0; i < 6; i++ ) { 95 for( i = 0; i < 6; i++ ) {
96 weeknos[i] = new QLabel(this); 96 weeknos[i] = new QLabel(this);
97 weeknos[i]->setAlignment(AlignCenter); 97 weeknos[i]->setAlignment(AlignCenter);
98 //weeknos[i]->setFont(QFont("Arial", 10)); 98 //weeknos[i]->setFont(QFont("Arial", 10));
99 if(!show_week_nums) { 99 if(!show_week_nums) {
100 weeknos[i]->hide(); 100 weeknos[i]->hide();
101 } 101 }
102 weeknos[i]->installEventFilter(this); 102 weeknos[i]->installEventFilter(this);
103 103
104 topLayout->addWidget(weeknos[i],i+2,0); 104 topLayout->addWidget(weeknos[i],i+2,0);
105 } 105 }
106 106
107 daymatrix = new KODayMatrix( this, mCalendar, dayone, 107 daymatrix = new KODayMatrix( this, mCalendar, dayone,
108 "KDateNavigator::DayMatrix"); 108 "KDateNavigator::DayMatrix");
109 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 109 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
110 daymatrix->setLineWidth(1); 110 daymatrix->setLineWidth(1);
111 111
112 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 112 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
113 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 113 SIGNAL( datesSelected( const KCal::DateList & ) ) );
114 114
115 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 115 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
116 SIGNAL( eventDropped( Event * ) ) ); 116 SIGNAL( eventDropped( Event * ) ) );
117 117
118 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 118 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
119 119
120 // read settings from configuration file. 120 // read settings from configuration file.
121 updateConfig(); 121 updateConfig();
122 enableRollover(FollowMonth); 122 enableRollover(FollowMonth);
123 setFixedSize ( sizeHint() ); 123 setFixedSize ( sizeHint() );
124} 124}
125 125
126void KDateNavigator::enableRollover(RolloverType r) 126void KDateNavigator::enableRollover(RolloverType r)
127{ 127{
128 switch(r) 128 switch(r)
129 { 129 {
130 case None : 130 case None :
131 if (updateTimer) 131 if (updateTimer)
132 { 132 {
133 updateTimer->stop(); 133 updateTimer->stop();
134 delete updateTimer; 134 delete updateTimer;
135 updateTimer=0L; 135 updateTimer=0L;
136 } 136 }
137 break; 137 break;
138 case FollowDay : 138 case FollowDay :
139 case FollowMonth : 139 case FollowMonth :
140 if (!updateTimer) 140 if (!updateTimer)
141 { 141 {
142 updateTimer = new QTimer(this); 142 updateTimer = new QTimer(this);
143 QObject::connect(updateTimer,SIGNAL(timeout()), 143 QObject::connect(updateTimer,SIGNAL(timeout()),
144 this,SLOT(possiblyPastMidnight())); 144 this,SLOT(possiblyPastMidnight()));
145 } 145 }
146 updateTimer->start(0,true); 146 updateTimer->start(0,true);
147 lastDayChecked = QDate::currentDate(); 147 lastDayChecked = QDate::currentDate();
148 } 148 }
149 updateRollover=r; 149 updateRollover=r;
150} 150}
151 151
152 152
153KDateNavigator::~KDateNavigator() 153KDateNavigator::~KDateNavigator()
154{ 154{
155} 155}
156 156
157 157
158void KDateNavigator::passedMidnight() 158void KDateNavigator::passedMidnight()
159{ 159{
160 QDate today = QDate::currentDate(); 160 QDate today = QDate::currentDate();
161 bool emitMonth = false; 161 bool emitMonth = false;
162 162
163 if (today.month() != lastDayChecked.month()) 163 if (today.month() != lastDayChecked.month())
164 { 164 {
165 if (updateRollover==FollowMonth && 165 if (updateRollover==FollowMonth &&
166 daymatrix->isEndOfMonth()) { 166 daymatrix->isEndOfMonth()) {
167 goNextMonth(); 167 goNextMonth();
168 emitMonth=true; 168 emitMonth=true;
169 } 169 }
170 } 170 }
171 daymatrix->recalculateToday(); 171 daymatrix->recalculateToday();
172 daymatrix->repaint(); 172 daymatrix->repaint();
173 emit dayPassed(today); 173 emit dayPassed(today);
174 if (emitMonth) { emit monthPassed(today); } 174 if (emitMonth) { emit monthPassed(today); }
175} 175}
176 176
177/* slot */ void KDateNavigator::possiblyPastMidnight() 177/* slot */ void KDateNavigator::possiblyPastMidnight()
178{ 178{
179 if (lastDayChecked!=QDate::currentDate()) 179 if (lastDayChecked!=QDate::currentDate())
180 { 180 {
181 passedMidnight(); 181 passedMidnight();
182 lastDayChecked=QDate::currentDate(); 182 lastDayChecked=QDate::currentDate();
183 } 183 }
184 // Set the timer to go off 1 second after midnight 184 // Set the timer to go off 1 second after midnight
185 // or after 8 minutes, whichever comes first. 185 // or after 8 minutes, whichever comes first.
186 if (updateTimer) 186 if (updateTimer)
187 { 187 {
188 QTime now = QTime::currentTime(); 188 QTime now = QTime::currentTime();
189 QTime midnight = QTime(23,59,59); 189 QTime midnight = QTime(23,59,59);
190 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); 190 int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000);
191 191
192 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) 192 // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait))
193 //.arg(now.toString()).arg(midnight.toString())); 193 //.arg(now.toString()).arg(midnight.toString()));
194 194
195 updateTimer->stop(); 195 updateTimer->stop();
196 updateTimer->start(msecsWait,true); 196 updateTimer->start(msecsWait,true);
197 } 197 }
198} 198}
199 199
200void KDateNavigator::updateDates() 200void KDateNavigator::updateDates()
201{ 201{
202 // Find the first day of the week of the current month. 202 // Find the first day of the week of the current month.
203 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); 203 //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr );
204 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); 204 QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
205 int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); 205 int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
206 //int di = d1 - d2 + 1; 206 //int di = d1 - d2 + 1;
207 dayone = dayone.addDays( -d2 + 1 ); 207 dayone = dayone.addDays( -d2 + 1 );
208 208
209 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); 209 int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
210 210
211 // If month begins on Monday and Monday is first day of week, 211 // If month begins on Monday and Monday is first day of week,
212 // month should begin on second line. Sunday doesn't have this problem. 212 // month should begin on second line. Sunday doesn't have this problem.
213 int nextLine = ( ( m_fstDayOfWkCalsys == 1) && 213 int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
214 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; 214 ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
215 215
216 // update the matrix dates 216 // update the matrix dates
217 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; 217 int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
218 218
219 219
220 daymatrix->updateView(dayone.addDays(index)); 220 daymatrix->updateView(dayone.addDays(index));
221//each updateDates is followed by an updateView -> repaint is issued there ! 221//each updateDates is followed by an updateView -> repaint is issued there !
222// daymatrix->repaint(); 222// daymatrix->repaint();
223} 223}
224 224
225void KDateNavigator::updateDayMatrix() 225void KDateNavigator::updateDayMatrix()
226{ 226{
227 daymatrix->updateView(); 227 daymatrix->updateView();
228 daymatrix->repaint(); 228 daymatrix->repaint();
229} 229}
230 230
231 231
232void KDateNavigator::updateView() 232void KDateNavigator::updateView()
233{ 233{
234 234
235 setUpdatesEnabled( false ); 235 setUpdatesEnabled( false );
236 236
237 int i; 237 int i;
238 238
239// kdDebug() << "updateView() -> daymatrix->updateView()" << endl; 239// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
240 daymatrix->updateView(); 240 daymatrix->updateView();
241 241
242 // set the week numbers. 242 // set the week numbers.
243 for(i = 0; i < 6; i++) { 243 for(i = 0; i < 6; i++) {
244 QString weeknum; 244 QString weeknum;
245 // remember, according to ISO 8601, the first week of the year is the 245 // remember, according to ISO 8601, the first week of the year is the
246 // first week that contains a thursday. Thus we must subtract off 4, 246 // first week that contains a thursday. Thus we must subtract off 4,
247 // not just 1. 247 // not just 1.
248 248
249 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); 249 //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
250 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); 250 int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
251 251
252 if (dayOfYear % 7 != 0) 252 if (dayOfYear % 7 != 0)
253 weeknum.setNum(dayOfYear / 7 + 1); 253 weeknum.setNum(dayOfYear / 7 + 1);
254 else 254 else
255 weeknum.setNum(dayOfYear / 7); 255 weeknum.setNum(dayOfYear / 7);
256 weeknos[i]->setText(weeknum); 256 weeknos[i]->setText(weeknum);
257 } 257 }
258 258
259 setUpdatesEnabled( true ); 259 setUpdatesEnabled( true );
260// kdDebug() << "updateView() -> repaint()" << endl; 260// kdDebug() << "updateView() -> repaint()" << endl;
261 repaint(); 261 repaint();
262 daymatrix->repaint(); 262 daymatrix->repaint();
263} 263}
264 264
265void KDateNavigator::updateConfig() 265void KDateNavigator::updateConfig()
266{ 266{
267 int day; 267 int day;
268 for(int i=0; i<7; i++) { 268 for(int i=0; i<7; i++) {
269 // take the first letter of the day name to be the abbreviation 269 // take the first letter of the day name to be the abbreviation
270 if (KGlobal::locale()->weekStartsMonday()) { 270 if (KGlobal::locale()->weekStartsMonday()) {
271 day = i+1; 271 day = i+1;
272 } else { 272 } else {
273 if (i==0) day = 7; 273 if (i==0) day = 7;
274 else day = i; 274 else day = i;
275 } 275 }
276 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, 276 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
277 true ); 277 true );
278 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); 278 if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
279 headings[i]->setText( dayName ); 279 headings[i]->setText( dayName );
280 } 280 }
281 updateDates(); 281 updateDates();
282 updateView(); 282 updateView();
283} 283}
284 284
285void KDateNavigator::setShowWeekNums(bool enabled) 285void KDateNavigator::setShowWeekNums(bool enabled)
286{ 286{
287 m_bShowWeekNums = enabled; 287 m_bShowWeekNums = enabled;
288 for(int i=0; i<6; i++) { 288 for(int i=0; i<6; i++) {
289 if(enabled) 289 if(enabled)
290 weeknos[i]->show(); 290 weeknos[i]->show();
291 else 291 else
292 weeknos[i]->hide(); 292 weeknos[i]->hide();
293 } 293 }
294 resize(size()); 294 resize(size());
295} 295}
296 296
297void KDateNavigator::selectDates(const DateList& dateList) 297void KDateNavigator::selectDates(const DateList& dateList)
298{ 298{
299 299
300 if (dateList.count() > 0) { 300 if (dateList.count() > 0) {
301 mNavigatorBar->selectDates( dateList ); 301 mNavigatorBar->selectDates( dateList );
302 mSelectedDates = dateList; 302 mSelectedDates = dateList;
303 303
304 // set our record of the month and year that this datetbl is 304 // set our record of the month and year that this datetbl is
305 // displaying. 305 // displaying.
306 m_MthYr = mSelectedDates.first(); 306 m_MthYr = mSelectedDates.first();
307 307
308 308
309 // set our record of the first day of the week of the current 309 // set our record of the first day of the week of the current
310 // month. This needs to be done before calling dayToIndex, since it 310 // month. This needs to be done before calling dayToIndex, since it
311 // relies on this information being up to date. 311 // relies on this information being up to date.
312 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); 312 QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
313 m_fstDayOfWk = dayone.dayOfWeek(); 313 m_fstDayOfWk = dayone.dayOfWeek();
314 314
315 updateDates(); 315 updateDates();
316 316
317 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 317 daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
318 318
319 updateView(); 319 updateView();
320 } 320 }
321} 321}
322 322
323int KDateNavigator::dayNum(int row, int col) 323int KDateNavigator::dayNum(int row, int col)
324{ 324{
325 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; 325 return 7 * (row - 1) + (col + 1) - m_fstDayOfWk;
326} 326}
327 327
328int KDateNavigator::dayToIndex(int dayNum) 328int KDateNavigator::dayToIndex(int dayNum)
329{ 329{
330 int row, col; 330 int row, col;
331 331
332 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; 332 row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7;
333 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) 333 if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1))
334 row++; 334 row++;
335 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; 335 col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7;
336 return row * 7 + col; 336 return row * 7 + col;
337} 337}
338 338
339void KDateNavigator::wheelEvent (QWheelEvent *e) 339void KDateNavigator::wheelEvent (QWheelEvent *e)
340{ 340{
341 if(e->delta()>0) emit goPrevious(); 341 if(e->delta()>0) emit goPrevious();
342 else emit goNext(); 342 else emit goNext();
343 343
344 e->accept(); 344 e->accept();
345} 345}
346 346
347bool KDateNavigator::eventFilter (QObject *o,QEvent *e) 347bool KDateNavigator::eventFilter (QObject *o,QEvent *e)
348{ 348{
349 if (e->type() == QEvent::MouseButtonPress) { 349 if (e->type() == QEvent::MouseButtonPress) {
350 int i; 350 int i;
351 for(i=0;i<6;++i) { 351 for(i=0;i<6;++i) {
352 if (o == weeknos[i]) { 352 if (o == weeknos[i]) {
353 QDate weekstart = daymatrix->getDate(i*7); 353 QDate weekstart = daymatrix->getDate(i*7);
354 emit weekClicked(weekstart); 354 emit weekClicked(weekstart);
355 break; 355 break;
356 } 356 }
357 } 357 }
358 return true; 358 return true;
359 } else { 359 } else {
360 return false; 360 return false;
361 } 361 }
362} 362}
363 363
364#include "kdatenavigator.moc" 364//#include "kdatenavigator.moc"
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 607c250..6532705 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,1932 +1,1931 @@
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 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49#include "koagenda.moc"
50 49
51#include <libkcal/event.h> 50#include <libkcal/event.h>
52#include <libkcal/todo.h> 51#include <libkcal/todo.h>
53 52
54#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
56#endif 55#endif
57 56
58//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
59extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
60extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
61extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
62extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
63 62
64//////////////////////////////////////////////////////////////////////////// 63////////////////////////////////////////////////////////////////////////////
65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
66 : QFrame(_agenda->viewport(),name), agenda(_agenda) 65 : QFrame(_agenda->viewport(),name), agenda(_agenda)
67{ 66{
68 setLineWidth(0); 67 setLineWidth(0);
69 setMargin(0); 68 setMargin(0);
70 setBackgroundColor(Qt::red); 69 setBackgroundColor(Qt::red);
71 minutes = new QTimer(this); 70 minutes = new QTimer(this);
72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
73 minutes->start(0, true); 72 minutes->start(0, true);
74 73
75 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
76 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
77 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
78 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
79 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
80 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
81 80
82 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
83 82
84 oldToday = -1; 83 oldToday = -1;
85} 84}
86 85
87MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
88{ 87{
89 delete minutes; 88 delete minutes;
90} 89}
91 90
92int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
93{ 92{
94 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
95 94
96 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
97 DateList::ConstIterator it; 96 DateList::ConstIterator it;
98 int col = 0; 97 int col = 0;
99 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
100 if((*it) == currentDate) 99 if((*it) == currentDate)
101 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
102 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
103 ++col; 102 ++col;
104 } 103 }
105 104
106 return -1; 105 return -1;
107} 106}
108void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
109{ 108{
110 updateLocation(); 109 updateLocation();
111} 110}
112void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
113{ 112{
114 113
115 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
116 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
117 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
118 recalculate = true; 117 recalculate = true;
119 118
120 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
121 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
122 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
123 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
124 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
125 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
126 125
127 oldTime = tim; 126 oldTime = tim;
128 oldToday = today; 127 oldToday = today;
129 128
130 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
131 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
132 return; 131 return;
133 } else { 132 } else {
134 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
135 } 134 }
136 135
137 if(recalculate) 136 if(recalculate)
138 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
139 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
140 raise(); 139 raise();
141 140
142 if(recalculate) 141 if(recalculate)
143 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
144 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
145 144
146 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
147 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
148 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
149 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
150 // narrower than the other columns. 149 // narrower than the other columns.
151 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
152 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
153 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
154 y-mTimeBox->height()); 153 y-mTimeBox->height());
155 154
156 mTimeBox->raise(); 155 mTimeBox->raise();
157 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
158 minutes->start(5000,true); 157 minutes->start(5000,true);
159} 158}
160 159
161 160
162//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
163 162
164 163
165/* 164/*
166 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
167*/ 166*/
168KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
169 const char *name,WFlags f) : 168 const char *name,WFlags f) :
170 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
171{ 170{
172 171
173 mColumns = columns; 172 mColumns = columns;
174 mRows = rows; 173 mRows = rows;
175 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
176 mAllDayMode = false; 175 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
178 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 178#endif
180 mHolidayMask = 0; 179 mHolidayMask = 0;
181 init(); 180 init();
182} 181}
183 182
184/* 183/*
185 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
186 all-day events. 185 all-day events.
187*/ 186*/
188KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
189 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
190{ 189{
191 190
192 blockResize = false; 191 blockResize = false;
193 mColumns = columns; 192 mColumns = columns;
194 mRows = 1; 193 mRows = 1;
195 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
196 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 195 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
197 mAllDayMode = true; 196 mAllDayMode = true;
198#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
199 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 198 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
200#endif 199#endif
201 mHolidayMask = 0; 200 mHolidayMask = 0;
202 init(); 201 init();
203} 202}
204 203
205 204
206KOAgenda::~KOAgenda() 205KOAgenda::~KOAgenda()
207{ 206{
208 if(mMarcusBains) delete mMarcusBains; 207 if(mMarcusBains) delete mMarcusBains;
209 208
210} 209}
211 210
212Incidence *KOAgenda::selectedIncidence() const 211Incidence *KOAgenda::selectedIncidence() const
213{ 212{
214 return (mSelectedItem ? mSelectedItem->incidence() : 0); 213 return (mSelectedItem ? mSelectedItem->incidence() : 0);
215} 214}
216 215
217 216
218QDate KOAgenda::selectedIncidenceDate() const 217QDate KOAgenda::selectedIncidenceDate() const
219{ 218{
220 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
221} 220}
222 221
223 222
224void KOAgenda::init() 223void KOAgenda::init()
225{ 224{
226#ifndef _WIN32_ 225#ifndef _WIN32_
227 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 226 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
228 viewport()->setWFlags ( wflags); 227 viewport()->setWFlags ( wflags);
229#endif 228#endif
230 mGridSpacingX = 80; 229 mGridSpacingX = 80;
231 mResizeBorderWidth = 8; 230 mResizeBorderWidth = 8;
232 mScrollBorderWidth = 8; 231 mScrollBorderWidth = 8;
233 mScrollDelay = 30; 232 mScrollDelay = 30;
234 mScrollOffset = 10; 233 mScrollOffset = 10;
235 mPaintPixmap.resize( 20,20); 234 mPaintPixmap.resize( 20,20);
236 //enableClipper(true); 235 //enableClipper(true);
237 236
238 // Grab key strokes for keyboard navigation of agenda. Seems to have no 237 // Grab key strokes for keyboard navigation of agenda. Seems to have no
239 // effect. Has to be fixed. 238 // effect. Has to be fixed.
240 setFocusPolicy(WheelFocus); 239 setFocusPolicy(WheelFocus);
241 240
242 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 241 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
243 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 242 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
244 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 243 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
245 244
246 mStartCellX = 0; 245 mStartCellX = 0;
247 mStartCellY = 0; 246 mStartCellY = 0;
248 mCurrentCellX = 0; 247 mCurrentCellX = 0;
249 mCurrentCellY = 0; 248 mCurrentCellY = 0;
250 249
251 mSelectionCellX = 0; 250 mSelectionCellX = 0;
252 mSelectionYTop = 0; 251 mSelectionYTop = 0;
253 mSelectionHeight = 0; 252 mSelectionHeight = 0;
254 253
255 mOldLowerScrollValue = -1; 254 mOldLowerScrollValue = -1;
256 mOldUpperScrollValue = -1; 255 mOldUpperScrollValue = -1;
257 256
258 mClickedItem = 0; 257 mClickedItem = 0;
259 258
260 mActionItem = 0; 259 mActionItem = 0;
261 mActionType = NOP; 260 mActionType = NOP;
262 mItemMoved = false; 261 mItemMoved = false;
263 262
264 mSelectedItem = 0; 263 mSelectedItem = 0;
265 264
266 // mItems.setAutoDelete(true); 265 // mItems.setAutoDelete(true);
267 266
268 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 267 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
269 268
270 viewport()->update(); 269 viewport()->update();
271 270
272 setMinimumSize(30, 1); 271 setMinimumSize(30, 1);
273// setMaximumHeight(mGridSpacingY * mRows + 5); 272// setMaximumHeight(mGridSpacingY * mRows + 5);
274 273
275 // Disable horizontal scrollbar. This is a hack. The geometry should be 274 // Disable horizontal scrollbar. This is a hack. The geometry should be
276 // controlled in a way that the contents horizontally always fits. Then it is 275 // controlled in a way that the contents horizontally always fits. Then it is
277 // not necessary to turn off the scrollbar. 276 // not necessary to turn off the scrollbar.
278 setHScrollBarMode(AlwaysOff); 277 setHScrollBarMode(AlwaysOff);
279 if ( ! mAllDayMode ) 278 if ( ! mAllDayMode )
280 setVScrollBarMode(AlwaysOn); 279 setVScrollBarMode(AlwaysOn);
281 else 280 else
282 setVScrollBarMode(AlwaysOff); 281 setVScrollBarMode(AlwaysOff);
283 282
284 setStartHour(KOPrefs::instance()->mDayBegins); 283 setStartHour(KOPrefs::instance()->mDayBegins);
285 284
286 calculateWorkingHours(); 285 calculateWorkingHours();
287 286
288 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 287 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
289 SLOT(checkScrollBoundaries(int))); 288 SLOT(checkScrollBoundaries(int)));
290 289
291 // Create the Marcus Bains line. 290 // Create the Marcus Bains line.
292 if(mAllDayMode) 291 if(mAllDayMode)
293 mMarcusBains = 0; 292 mMarcusBains = 0;
294 else { 293 else {
295 mMarcusBains = new MarcusBains(this); 294 mMarcusBains = new MarcusBains(this);
296 addChild(mMarcusBains); 295 addChild(mMarcusBains);
297 } 296 }
298} 297}
299 298
300void KOAgenda::clear() 299void KOAgenda::clear()
301{ 300{
302 KOAgendaItem *item; 301 KOAgendaItem *item;
303 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 302 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
304 mUnusedItems.append( item ); 303 mUnusedItems.append( item );
305 //item->hide(); 304 //item->hide();
306 } 305 }
307 mItems.clear(); 306 mItems.clear();
308 mSelectedItem = 0; 307 mSelectedItem = 0;
309 clearSelection(); 308 clearSelection();
310} 309}
311 310
312void KOAgenda::clearSelection() 311void KOAgenda::clearSelection()
313{ 312{
314 mSelectionCellX = 0; 313 mSelectionCellX = 0;
315 mSelectionYTop = 0; 314 mSelectionYTop = 0;
316 mSelectionHeight = 0; 315 mSelectionHeight = 0;
317} 316}
318 317
319void KOAgenda::marcus_bains() 318void KOAgenda::marcus_bains()
320{ 319{
321 if(mMarcusBains) mMarcusBains->updateLocation(true); 320 if(mMarcusBains) mMarcusBains->updateLocation(true);
322} 321}
323 322
324 323
325void KOAgenda::changeColumns(int columns) 324void KOAgenda::changeColumns(int columns)
326{ 325{
327 if (columns == 0) { 326 if (columns == 0) {
328 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; 327 kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl;
329 return; 328 return;
330 } 329 }
331 330
332 clear(); 331 clear();
333 332
334 mColumns = columns; 333 mColumns = columns;
335// setMinimumSize(mColumns * 10, mGridSpacingY + 1); 334// setMinimumSize(mColumns * 10, mGridSpacingY + 1);
336// init(); 335// init();
337// update(); 336// update();
338 //qDebug("KOAgenda::changeColumns "); 337 //qDebug("KOAgenda::changeColumns ");
339 computeSizes(); 338 computeSizes();
340 // QResizeEvent event( size(), size() ); 339 // QResizeEvent event( size(), size() );
341 340
342 //QApplication::sendEvent( this, &event ); 341 //QApplication::sendEvent( this, &event );
343} 342}
344 343
345/* 344/*
346 This is the eventFilter function, which gets all events from the KOAgendaItems 345 This is the eventFilter function, which gets all events from the KOAgendaItems
347 contained in the agenda. It has to handle moving and resizing for all items. 346 contained in the agenda. It has to handle moving and resizing for all items.
348*/ 347*/
349bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 348bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
350{ 349{
351// kdDebug() << "KOAgenda::eventFilter" << endl; 350// kdDebug() << "KOAgenda::eventFilter" << endl;
352 switch(event->type()) { 351 switch(event->type()) {
353 case QEvent::MouseButtonPress: 352 case QEvent::MouseButtonPress:
354 case QEvent::MouseButtonDblClick: 353 case QEvent::MouseButtonDblClick:
355 case QEvent::MouseButtonRelease: 354 case QEvent::MouseButtonRelease:
356 case QEvent::MouseMove: 355 case QEvent::MouseMove:
357 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 356 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
358 357
359 case (QEvent::Leave): 358 case (QEvent::Leave):
360 if (!mActionItem) 359 if (!mActionItem)
361 setCursor(arrowCursor); 360 setCursor(arrowCursor);
362 return true; 361 return true;
363 362
364 default: 363 default:
365 return QScrollView::eventFilter(object,event); 364 return QScrollView::eventFilter(object,event);
366 } 365 }
367} 366}
368 367
369 368
370bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 369bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
371{ 370{
372 //qDebug("KOAgenda::eventFilter_mous "); 371 //qDebug("KOAgenda::eventFilter_mous ");
373 QPoint viewportPos; 372 QPoint viewportPos;
374 if (object != viewport()) { 373 if (object != viewport()) {
375 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 374 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
376 } else { 375 } else {
377 viewportPos = me->pos(); 376 viewportPos = me->pos();
378 } 377 }
379 static int startX = 0; 378 static int startX = 0;
380 static int startY = 0; 379 static int startY = 0;
381 static bool block = true; 380 static bool block = true;
382 switch (me->type()) { 381 switch (me->type()) {
383 case QEvent::MouseButtonPress: 382 case QEvent::MouseButtonPress:
384 //qDebug("QEvent::MouseButtonPress: "); 383 //qDebug("QEvent::MouseButtonPress: ");
385 // kdDebug() << "koagenda: filtered button press" << endl; 384 // kdDebug() << "koagenda: filtered button press" << endl;
386 if (object != viewport()) { 385 if (object != viewport()) {
387 if (me->button() == RightButton) { 386 if (me->button() == RightButton) {
388 387
389 mClickedItem = (KOAgendaItem *)object; 388 mClickedItem = (KOAgendaItem *)object;
390 if (mClickedItem) { 389 if (mClickedItem) {
391 selectItem(mClickedItem); 390 selectItem(mClickedItem);
392 // emit showIncidencePopupSignal(mClickedItem->incidence()); 391 // emit showIncidencePopupSignal(mClickedItem->incidence());
393 } 392 }
394 //mItemPopup->popup(QCursor::pos()); 393 //mItemPopup->popup(QCursor::pos());
395 } else { 394 } else {
396 mActionItem = (KOAgendaItem *)object; 395 mActionItem = (KOAgendaItem *)object;
397 if (mActionItem) { 396 if (mActionItem) {
398 if ( mSelectionHeight > 0 ) { 397 if ( mSelectionHeight > 0 ) {
399 int selectionCellX = mSelectionCellX * mGridSpacingX; 398 int selectionCellX = mSelectionCellX * mGridSpacingX;
400 int selectionYTop = mSelectionYTop; 399 int selectionYTop = mSelectionYTop;
401 int gridSpacingX = mGridSpacingX; 400 int gridSpacingX = mGridSpacingX;
402 int selectionHeight = mSelectionHeight; 401 int selectionHeight = mSelectionHeight;
403 clearSelection(); 402 clearSelection();
404 repaintContents( selectionCellX, selectionYTop, 403 repaintContents( selectionCellX, selectionYTop,
405 gridSpacingX, selectionHeight,false ); 404 gridSpacingX, selectionHeight,false );
406 } 405 }
407 selectItem(mActionItem); 406 selectItem(mActionItem);
408 Incidence *incidence = mActionItem->incidence(); 407 Incidence *incidence = mActionItem->incidence();
409 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 408 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
410 mActionItem = 0; 409 mActionItem = 0;
411 } else { 410 } else {
412 startItemAction(viewportPos); 411 startItemAction(viewportPos);
413 startX = viewportPos.x(); 412 startX = viewportPos.x();
414 startY = viewportPos.y(); 413 startY = viewportPos.y();
415 block = true; 414 block = true;
416 } 415 }
417 } 416 }
418 } 417 }
419 } else { 418 } else {
420 selectItem(0); 419 selectItem(0);
421 mActionItem = 0; 420 mActionItem = 0;
422 setCursor(arrowCursor); 421 setCursor(arrowCursor);
423 startSelectAction(viewportPos); 422 startSelectAction(viewportPos);
424 } 423 }
425 break; 424 break;
426 425
427 case QEvent::MouseButtonRelease: 426 case QEvent::MouseButtonRelease:
428 //qDebug("QEvent::MouseButtonRelease: "); 427 //qDebug("QEvent::MouseButtonRelease: ");
429 if (me->button() == RightButton && block ) { 428 if (me->button() == RightButton && block ) {
430 if (object != viewport()) { 429 if (object != viewport()) {
431 mClickedItem = (KOAgendaItem *)object; 430 mClickedItem = (KOAgendaItem *)object;
432 if (mActionItem ) { 431 if (mActionItem ) {
433 endItemAction(); 432 endItemAction();
434 } 433 }
435 if (mClickedItem) { 434 if (mClickedItem) {
436 selectItem(mClickedItem); 435 selectItem(mClickedItem);
437 emit showIncidencePopupSignal(mClickedItem->incidence()); 436 emit showIncidencePopupSignal(mClickedItem->incidence());
438 } 437 }
439 } 438 }
440 break; 439 break;
441 } 440 }
442 block = true; 441 block = true;
443 if (mActionItem) { 442 if (mActionItem) {
444 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 443 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
445 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 444 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
446 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 445 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
447 mScrollUpTimer.stop(); 446 mScrollUpTimer.stop();
448 mScrollDownTimer.stop(); 447 mScrollDownTimer.stop();
449 mActionItem->resetMove(); 448 mActionItem->resetMove();
450 placeSubCells( mActionItem ); 449 placeSubCells( mActionItem );
451 // emit startDragSignal( mActionItem->incidence() ); 450 // emit startDragSignal( mActionItem->incidence() );
452 setCursor( arrowCursor ); 451 setCursor( arrowCursor );
453 mActionItem = 0; 452 mActionItem = 0;
454 mActionType = NOP; 453 mActionType = NOP;
455 mItemMoved = 0; 454 mItemMoved = 0;
456 return true; 455 return true;
457 } 456 }
458 endItemAction(); 457 endItemAction();
459 } else if ( mActionType == SELECT ) { 458 } else if ( mActionType == SELECT ) {
460 endSelectAction(); 459 endSelectAction();
461 } 460 }
462 break; 461 break;
463 462
464 case QEvent::MouseMove: 463 case QEvent::MouseMove:
465 if (object != viewport()) { 464 if (object != viewport()) {
466 KOAgendaItem *moveItem = (KOAgendaItem *)object; 465 KOAgendaItem *moveItem = (KOAgendaItem *)object;
467 //qDebug("moveItem %d ",moveItem ); 466 //qDebug("moveItem %d ",moveItem );
468 if (!moveItem->incidence()->isReadOnly() /*&& 467 if (!moveItem->incidence()->isReadOnly() /*&&
469 !moveItem->incidence()->recurrence()->doesRecur()*/ ) 468 !moveItem->incidence()->recurrence()->doesRecur()*/ )
470 if (!mActionItem) 469 if (!mActionItem)
471 setNoActionCursor(moveItem,viewportPos); 470 setNoActionCursor(moveItem,viewportPos);
472 else { 471 else {
473 if ( block ) { 472 if ( block ) {
474 int dX, dY; 473 int dX, dY;
475 dX = startX - viewportPos.x(); 474 dX = startX - viewportPos.x();
476 if ( dX < 0 ) 475 if ( dX < 0 )
477 dX = -dX; 476 dX = -dX;
478 dY = viewportPos.y() - startY; 477 dY = viewportPos.y() - startY;
479 if ( dY < 0 ) 478 if ( dY < 0 )
480 dY = -dY; 479 dY = -dY;
481 int diff = 30; 480 int diff = 30;
482 if ( QApplication::desktop()->width() < 480 ) 481 if ( QApplication::desktop()->width() < 480 )
483 diff = 15; 482 diff = 15;
484 // qDebug(" %d %d ",dX, dY ); 483 // qDebug(" %d %d ",dX, dY );
485 if ( dX > diff || dY > diff ) { 484 if ( dX > diff || dY > diff ) {
486 block = false; 485 block = false;
487 } 486 }
488 } 487 }
489 if ( !block ) 488 if ( !block )
490 performItemAction(viewportPos); 489 performItemAction(viewportPos);
491 } 490 }
492 } else { 491 } else {
493 if ( mActionType == SELECT ) { 492 if ( mActionType == SELECT ) {
494 performSelectAction( viewportPos ); 493 performSelectAction( viewportPos );
495 } 494 }
496 } 495 }
497 break; 496 break;
498 497
499 case QEvent::MouseButtonDblClick: 498 case QEvent::MouseButtonDblClick:
500 if (object == viewport()) { 499 if (object == viewport()) {
501 selectItem(0); 500 selectItem(0);
502 int x,y; 501 int x,y;
503 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 502 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
504 int gx,gy; 503 int gx,gy;
505 contentsToGrid(x,y,gx,gy); 504 contentsToGrid(x,y,gx,gy);
506 emit newEventSignal(gx,gy); 505 emit newEventSignal(gx,gy);
507 } else { 506 } else {
508 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 507 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
509 selectItem(doubleClickedItem); 508 selectItem(doubleClickedItem);
510 if ( KOPrefs::instance()->mEditOnDoubleClick ) 509 if ( KOPrefs::instance()->mEditOnDoubleClick )
511 emit editIncidenceSignal(doubleClickedItem->incidence()); 510 emit editIncidenceSignal(doubleClickedItem->incidence());
512 else 511 else
513 emit showIncidenceSignal(doubleClickedItem->incidence()); 512 emit showIncidenceSignal(doubleClickedItem->incidence());
514 } 513 }
515 break; 514 break;
516 515
517 default: 516 default:
518 break; 517 break;
519 } 518 }
520 519
521 return true; 520 return true;
522} 521}
523 522
524void KOAgenda::startSelectAction(QPoint viewportPos) 523void KOAgenda::startSelectAction(QPoint viewportPos)
525{ 524{
526 //emit newStartSelectSignal(); 525 //emit newStartSelectSignal();
527 526
528 mActionType = SELECT; 527 mActionType = SELECT;
529 528
530 int x,y; 529 int x,y;
531 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 530 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
532 int gx,gy; 531 int gx,gy;
533 contentsToGrid(x,y,gx,gy); 532 contentsToGrid(x,y,gx,gy);
534 533
535 mStartCellX = gx; 534 mStartCellX = gx;
536 mStartCellY = gy; 535 mStartCellY = gy;
537 mCurrentCellX = gx; 536 mCurrentCellX = gx;
538 mCurrentCellY = gy; 537 mCurrentCellY = gy;
539 538
540 // Store coordinates of old selection 539 // Store coordinates of old selection
541 int selectionX = mSelectionCellX * mGridSpacingX; 540 int selectionX = mSelectionCellX * mGridSpacingX;
542 int selectionYTop = mSelectionYTop; 541 int selectionYTop = mSelectionYTop;
543 int selectionHeight = mSelectionHeight; 542 int selectionHeight = mSelectionHeight;
544 543
545 // Store new selection 544 // Store new selection
546 mSelectionCellX = gx; 545 mSelectionCellX = gx;
547 mSelectionYTop = gy * mGridSpacingY; 546 mSelectionYTop = gy * mGridSpacingY;
548 mSelectionHeight = mGridSpacingY; 547 mSelectionHeight = mGridSpacingY;
549 548
550 // Clear old selection 549 // Clear old selection
551 repaintContents( selectionX, selectionYTop, 550 repaintContents( selectionX, selectionYTop,
552 mGridSpacingX, selectionHeight,false ); 551 mGridSpacingX, selectionHeight,false );
553 552
554 // Paint new selection 553 // Paint new selection
555 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 554 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
556 // mGridSpacingX, mSelectionHeight ); 555 // mGridSpacingX, mSelectionHeight );
557} 556}
558 557
559void KOAgenda::performSelectAction(QPoint viewportPos) 558void KOAgenda::performSelectAction(QPoint viewportPos)
560{ 559{
561 int x,y; 560 int x,y;
562 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 561 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
563 int gx,gy; 562 int gx,gy;
564 contentsToGrid(x,y,gx,gy); 563 contentsToGrid(x,y,gx,gy);
565 564
566 QPoint clipperPos = clipper()-> 565 QPoint clipperPos = clipper()->
567 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 566 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
568 567
569 // Scroll if cursor was moved to upper or lower end of agenda. 568 // Scroll if cursor was moved to upper or lower end of agenda.
570 if (clipperPos.y() < mScrollBorderWidth) { 569 if (clipperPos.y() < mScrollBorderWidth) {
571 mScrollUpTimer.start(mScrollDelay); 570 mScrollUpTimer.start(mScrollDelay);
572 } else if (visibleHeight() - clipperPos.y() < 571 } else if (visibleHeight() - clipperPos.y() <
573 mScrollBorderWidth) { 572 mScrollBorderWidth) {
574 mScrollDownTimer.start(mScrollDelay); 573 mScrollDownTimer.start(mScrollDelay);
575 } else { 574 } else {
576 mScrollUpTimer.stop(); 575 mScrollUpTimer.stop();
577 mScrollDownTimer.stop(); 576 mScrollDownTimer.stop();
578 } 577 }
579 578
580 if ( gy > mCurrentCellY ) { 579 if ( gy > mCurrentCellY ) {
581 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 580 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
582 581
583#if 0 582#if 0
584 // FIXME: Repaint only the newly selected region 583 // FIXME: Repaint only the newly selected region
585 repaintContents( mSelectionCellX * mGridSpacingX, 584 repaintContents( mSelectionCellX * mGridSpacingX,
586 mCurrentCellY + mGridSpacingY, 585 mCurrentCellY + mGridSpacingY,
587 mGridSpacingX, 586 mGridSpacingX,
588 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 587 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
589#else 588#else
590 repaintContents( (KOGlobals::self()->reverseLayout() ? 589 repaintContents( (KOGlobals::self()->reverseLayout() ?
591 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 590 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
592 mGridSpacingX, mSelectionYTop, 591 mGridSpacingX, mSelectionYTop,
593 mGridSpacingX, mSelectionHeight , false); 592 mGridSpacingX, mSelectionHeight , false);
594#endif 593#endif
595 594
596 mCurrentCellY = gy; 595 mCurrentCellY = gy;
597 } else if ( gy < mCurrentCellY ) { 596 } else if ( gy < mCurrentCellY ) {
598 if ( gy >= mStartCellY ) { 597 if ( gy >= mStartCellY ) {
599 int selectionHeight = mSelectionHeight; 598 int selectionHeight = mSelectionHeight;
600 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 599 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
601 600
602 repaintContents( (KOGlobals::self()->reverseLayout() ? 601 repaintContents( (KOGlobals::self()->reverseLayout() ?
603 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 602 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
604 mGridSpacingX, mSelectionYTop, 603 mGridSpacingX, mSelectionYTop,
605 mGridSpacingX, selectionHeight,false ); 604 mGridSpacingX, selectionHeight,false );
606 605
607 mCurrentCellY = gy; 606 mCurrentCellY = gy;
608 } else { 607 } else {
609 } 608 }
610 } 609 }
611} 610}
612 611
613void KOAgenda::endSelectAction() 612void KOAgenda::endSelectAction()
614{ 613{
615 mActionType = NOP; 614 mActionType = NOP;
616 mScrollUpTimer.stop(); 615 mScrollUpTimer.stop();
617 mScrollDownTimer.stop(); 616 mScrollDownTimer.stop();
618 617
619 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 618 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
620} 619}
621 620
622void KOAgenda::startItemAction(QPoint viewportPos) 621void KOAgenda::startItemAction(QPoint viewportPos)
623{ 622{
624 int x,y; 623 int x,y;
625 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 624 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
626 int gx,gy; 625 int gx,gy;
627 contentsToGrid(x,y,gx,gy); 626 contentsToGrid(x,y,gx,gy);
628 627
629 mStartCellX = gx; 628 mStartCellX = gx;
630 mStartCellY = gy; 629 mStartCellY = gy;
631 mCurrentCellX = gx; 630 mCurrentCellX = gx;
632 mCurrentCellY = gy; 631 mCurrentCellY = gy;
633 632
634 if (mAllDayMode) { 633 if (mAllDayMode) {
635 int gridDistanceX = (x - gx * mGridSpacingX); 634 int gridDistanceX = (x - gx * mGridSpacingX);
636 if (gridDistanceX < mResizeBorderWidth && 635 if (gridDistanceX < mResizeBorderWidth &&
637 mActionItem->cellX() == mCurrentCellX) { 636 mActionItem->cellX() == mCurrentCellX) {
638 mActionType = RESIZELEFT; 637 mActionType = RESIZELEFT;
639 setCursor(sizeHorCursor); 638 setCursor(sizeHorCursor);
640 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 639 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
641 mActionItem->cellXWidth() == mCurrentCellX) { 640 mActionItem->cellXWidth() == mCurrentCellX) {
642 mActionType = RESIZERIGHT; 641 mActionType = RESIZERIGHT;
643 setCursor(sizeHorCursor); 642 setCursor(sizeHorCursor);
644 } else { 643 } else {
645 mActionType = MOVE; 644 mActionType = MOVE;
646 mActionItem->startMove(); 645 mActionItem->startMove();
647 setCursor(sizeAllCursor); 646 setCursor(sizeAllCursor);
648 } 647 }
649 } else { 648 } else {
650 int gridDistanceY = (y - gy * mGridSpacingY); 649 int gridDistanceY = (y - gy * mGridSpacingY);
651 bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); 650 bool allowResize = ( mActionItem->incidence()->type() != "Todo" );
652 if (allowResize && gridDistanceY < mResizeBorderWidth && 651 if (allowResize && gridDistanceY < mResizeBorderWidth &&
653 mActionItem->cellYTop() == mCurrentCellY && 652 mActionItem->cellYTop() == mCurrentCellY &&
654 !mActionItem->firstMultiItem()) { 653 !mActionItem->firstMultiItem()) {
655 mActionType = RESIZETOP; 654 mActionType = RESIZETOP;
656 setCursor(sizeVerCursor); 655 setCursor(sizeVerCursor);
657 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 656 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
658 mActionItem->cellYBottom() == mCurrentCellY && 657 mActionItem->cellYBottom() == mCurrentCellY &&
659 !mActionItem->lastMultiItem()) { 658 !mActionItem->lastMultiItem()) {
660 mActionType = RESIZEBOTTOM; 659 mActionType = RESIZEBOTTOM;
661 setCursor(sizeVerCursor); 660 setCursor(sizeVerCursor);
662 } else { 661 } else {
663 mActionType = MOVE; 662 mActionType = MOVE;
664 mActionItem->startMove(); 663 mActionItem->startMove();
665 setCursor(sizeAllCursor); 664 setCursor(sizeAllCursor);
666 } 665 }
667 } 666 }
668} 667}
669 668
670void KOAgenda::performItemAction(QPoint viewportPos) 669void KOAgenda::performItemAction(QPoint viewportPos)
671{ 670{
672// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 671// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
673// QPoint point = viewport()->mapToGlobal(viewportPos); 672// QPoint point = viewport()->mapToGlobal(viewportPos);
674// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 673// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
675// point = clipper()->mapFromGlobal(point); 674// point = clipper()->mapFromGlobal(point);
676// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 675// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
677// kdDebug() << "visible height: " << visibleHeight() << endl; 676// kdDebug() << "visible height: " << visibleHeight() << endl;
678 int x,y; 677 int x,y;
679 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 678 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
680// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 679// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
681 int gx,gy; 680 int gx,gy;
682 contentsToGrid(x,y,gx,gy); 681 contentsToGrid(x,y,gx,gy);
683 QPoint clipperPos = clipper()-> 682 QPoint clipperPos = clipper()->
684 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 683 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
685 684
686 // Cursor left active agenda area. 685 // Cursor left active agenda area.
687 // This starts a drag. 686 // This starts a drag.
688 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 687 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
689 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 688 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
690 if ( mActionType == MOVE ) { 689 if ( mActionType == MOVE ) {
691 mScrollUpTimer.stop(); 690 mScrollUpTimer.stop();
692 mScrollDownTimer.stop(); 691 mScrollDownTimer.stop();
693 mActionItem->resetMove(); 692 mActionItem->resetMove();
694 placeSubCells( mActionItem ); 693 placeSubCells( mActionItem );
695 // emit startDragSignal( mActionItem->incidence() ); 694 // emit startDragSignal( mActionItem->incidence() );
696 setCursor( arrowCursor ); 695 setCursor( arrowCursor );
697 mActionItem = 0; 696 mActionItem = 0;
698 mActionType = NOP; 697 mActionType = NOP;
699 mItemMoved = 0; 698 mItemMoved = 0;
700 return; 699 return;
701 } 700 }
702 } else { 701 } else {
703 switch ( mActionType ) { 702 switch ( mActionType ) {
704 case MOVE: 703 case MOVE:
705 setCursor( sizeAllCursor ); 704 setCursor( sizeAllCursor );
706 break; 705 break;
707 case RESIZETOP: 706 case RESIZETOP:
708 case RESIZEBOTTOM: 707 case RESIZEBOTTOM:
709 setCursor( sizeVerCursor ); 708 setCursor( sizeVerCursor );
710 break; 709 break;
711 case RESIZELEFT: 710 case RESIZELEFT:
712 case RESIZERIGHT: 711 case RESIZERIGHT:
713 setCursor( sizeHorCursor ); 712 setCursor( sizeHorCursor );
714 break; 713 break;
715 default: 714 default:
716 setCursor( arrowCursor ); 715 setCursor( arrowCursor );
717 } 716 }
718 } 717 }
719 718
720 // Scroll if item was moved to upper or lower end of agenda. 719 // Scroll if item was moved to upper or lower end of agenda.
721 if (clipperPos.y() < mScrollBorderWidth) { 720 if (clipperPos.y() < mScrollBorderWidth) {
722 mScrollUpTimer.start(mScrollDelay); 721 mScrollUpTimer.start(mScrollDelay);
723 } else if (visibleHeight() - clipperPos.y() < 722 } else if (visibleHeight() - clipperPos.y() <
724 mScrollBorderWidth) { 723 mScrollBorderWidth) {
725 mScrollDownTimer.start(mScrollDelay); 724 mScrollDownTimer.start(mScrollDelay);
726 } else { 725 } else {
727 mScrollUpTimer.stop(); 726 mScrollUpTimer.stop();
728 mScrollDownTimer.stop(); 727 mScrollDownTimer.stop();
729 } 728 }
730 729
731 // Move or resize item if necessary 730 // Move or resize item if necessary
732 if (mCurrentCellX != gx || mCurrentCellY != gy) { 731 if (mCurrentCellX != gx || mCurrentCellY != gy) {
733 mItemMoved = true; 732 mItemMoved = true;
734 mActionItem->raise(); 733 mActionItem->raise();
735 if (mActionType == MOVE) { 734 if (mActionType == MOVE) {
736 // Move all items belonging to a multi item 735 // Move all items belonging to a multi item
737 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 736 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
738 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 737 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
739 if (!moveItem) moveItem = mActionItem; 738 if (!moveItem) moveItem = mActionItem;
740 while (moveItem) { 739 while (moveItem) {
741 int dy; 740 int dy;
742 if (isMultiItem) dy = 0; 741 if (isMultiItem) dy = 0;
743 else dy = gy - mCurrentCellY; 742 else dy = gy - mCurrentCellY;
744 moveItem->moveRelative(gx - mCurrentCellX,dy); 743 moveItem->moveRelative(gx - mCurrentCellX,dy);
745 int x,y; 744 int x,y;
746 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 745 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
747 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 746 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
748 mGridSpacingY * moveItem->cellHeight()); 747 mGridSpacingY * moveItem->cellHeight());
749 moveChild(moveItem,x,y); 748 moveChild(moveItem,x,y);
750 moveItem = moveItem->nextMultiItem(); 749 moveItem = moveItem->nextMultiItem();
751 } 750 }
752 } else if (mActionType == RESIZETOP) { 751 } else if (mActionType == RESIZETOP) {
753 if (mCurrentCellY <= mActionItem->cellYBottom()) { 752 if (mCurrentCellY <= mActionItem->cellYBottom()) {
754 mActionItem->expandTop(gy - mCurrentCellY); 753 mActionItem->expandTop(gy - mCurrentCellY);
755 mActionItem->resize(mActionItem->width(), 754 mActionItem->resize(mActionItem->width(),
756 mGridSpacingY * mActionItem->cellHeight()); 755 mGridSpacingY * mActionItem->cellHeight());
757 int x,y; 756 int x,y;
758 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 757 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
759 //moveChild(mActionItem,childX(mActionItem),y); 758 //moveChild(mActionItem,childX(mActionItem),y);
760 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 759 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
761 } 760 }
762 } else if (mActionType == RESIZEBOTTOM) { 761 } else if (mActionType == RESIZEBOTTOM) {
763 if (mCurrentCellY >= mActionItem->cellYTop()) { 762 if (mCurrentCellY >= mActionItem->cellYTop()) {
764 mActionItem->expandBottom(gy - mCurrentCellY); 763 mActionItem->expandBottom(gy - mCurrentCellY);
765 mActionItem->resize(mActionItem->width(), 764 mActionItem->resize(mActionItem->width(),
766 mGridSpacingY * mActionItem->cellHeight()); 765 mGridSpacingY * mActionItem->cellHeight());
767 } 766 }
768 } else if (mActionType == RESIZELEFT) { 767 } else if (mActionType == RESIZELEFT) {
769 if (mCurrentCellX <= mActionItem->cellXWidth()) { 768 if (mCurrentCellX <= mActionItem->cellXWidth()) {
770 mActionItem->expandLeft(gx - mCurrentCellX); 769 mActionItem->expandLeft(gx - mCurrentCellX);
771 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 770 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
772 mActionItem->height()); 771 mActionItem->height());
773 int x,y; 772 int x,y;
774 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 773 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
775 moveChild(mActionItem,x,childY(mActionItem)); 774 moveChild(mActionItem,x,childY(mActionItem));
776 } 775 }
777 } else if (mActionType == RESIZERIGHT) { 776 } else if (mActionType == RESIZERIGHT) {
778 if (mCurrentCellX >= mActionItem->cellX()) { 777 if (mCurrentCellX >= mActionItem->cellX()) {
779 mActionItem->expandRight(gx - mCurrentCellX); 778 mActionItem->expandRight(gx - mCurrentCellX);
780 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 779 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
781 mActionItem->height()); 780 mActionItem->height());
782 } 781 }
783 } 782 }
784 mCurrentCellX = gx; 783 mCurrentCellX = gx;
785 mCurrentCellY = gy; 784 mCurrentCellY = gy;
786 } 785 }
787} 786}
788 787
789void KOAgenda::endItemAction() 788void KOAgenda::endItemAction()
790{ 789{
791 790
792 if ( mItemMoved ) { 791 if ( mItemMoved ) {
793 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 792 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
794 if ( !placeItem ) { 793 if ( !placeItem ) {
795 placeItem = mActionItem; 794 placeItem = mActionItem;
796 } 795 }
797 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 796 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
798 Incidence* oldInc = placeItem->incidence(); 797 Incidence* oldInc = placeItem->incidence();
799 placeItem->recreateIncidence(); 798 placeItem->recreateIncidence();
800 emit addToCalSignal(placeItem->incidence(), oldInc ); 799 emit addToCalSignal(placeItem->incidence(), oldInc );
801 } 800 }
802 int type = mActionType; 801 int type = mActionType;
803 if ( mAllDayMode ) 802 if ( mAllDayMode )
804 type = -1; 803 type = -1;
805 KOAgendaItem *modifiedItem = placeItem; 804 KOAgendaItem *modifiedItem = placeItem;
806 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 805 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
807 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 806 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
808 KOAgendaItem *item; 807 KOAgendaItem *item;
809 808
810 if ( placeItem->incidence()->type() == "Todo" ) { 809 if ( placeItem->incidence()->type() == "Todo" ) {
811 mSelectedItem = 0; 810 mSelectedItem = 0;
812 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 811 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
813 modifiedItem->mLastMoveXPos = mCurrentCellX; 812 modifiedItem->mLastMoveXPos = mCurrentCellX;
814 emit itemModified( modifiedItem, mActionType ); 813 emit itemModified( modifiedItem, mActionType );
815 } 814 }
816 else { 815 else {
817#if 0 816#if 0
818 for ( item=oldconflictItems.first(); item != 0; 817 for ( item=oldconflictItems.first(); item != 0;
819 item=oldconflictItems.next() ) { 818 item=oldconflictItems.next() ) {
820 placeSubCells(item); 819 placeSubCells(item);
821 } 820 }
822 while ( placeItem ) { 821 while ( placeItem ) {
823 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 822 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
824 placeSubCells( placeItem ); 823 placeSubCells( placeItem );
825 placeItem = placeItem->nextMultiItem(); 824 placeItem = placeItem->nextMultiItem();
826 } 825 }
827#endif 826#endif
828 827
829 globalFlagBlockAgendaItemPaint = 1; 828 globalFlagBlockAgendaItemPaint = 1;
830 for ( item=oldconflictItems.first(); item != 0; 829 for ( item=oldconflictItems.first(); item != 0;
831 item=oldconflictItems.next() ) { 830 item=oldconflictItems.next() ) {
832 placeSubCells(item); 831 placeSubCells(item);
833 } 832 }
834 while ( placeItem ) { 833 while ( placeItem ) {
835 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 834 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
836 oldconflictItems = placeItem->conflictItems(); 835 oldconflictItems = placeItem->conflictItems();
837 for ( item=oldconflictItems.first(); item != 0; 836 for ( item=oldconflictItems.first(); item != 0;
838 item=oldconflictItems.next() ) { 837 item=oldconflictItems.next() ) {
839 placeSubCells(item); 838 placeSubCells(item);
840 } 839 }
841 placeSubCells( placeItem ); 840 placeSubCells( placeItem );
842 placeItem = placeItem->nextMultiItem(); 841 placeItem = placeItem->nextMultiItem();
843 } 842 }
844 globalFlagBlockAgendaItemPaint = 0; 843 globalFlagBlockAgendaItemPaint = 0;
845 for ( item=oldconflictItems.first(); item != 0; 844 for ( item=oldconflictItems.first(); item != 0;
846 item=oldconflictItems.next() ) { 845 item=oldconflictItems.next() ) {
847 globalFlagBlockAgendaItemUpdate = 0; 846 globalFlagBlockAgendaItemUpdate = 0;
848 item->repaintMe(); 847 item->repaintMe();
849 globalFlagBlockAgendaItemUpdate = 1; 848 globalFlagBlockAgendaItemUpdate = 1;
850 item->repaint( false ); 849 item->repaint( false );
851 } 850 }
852 placeItem = modifiedItem; 851 placeItem = modifiedItem;
853 852
854 while ( placeItem ) { 853 while ( placeItem ) {
855 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 854 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
856 globalFlagBlockAgendaItemUpdate = 0; 855 globalFlagBlockAgendaItemUpdate = 0;
857 placeItem->repaintMe(); 856 placeItem->repaintMe();
858 globalFlagBlockAgendaItemUpdate = 1; 857 globalFlagBlockAgendaItemUpdate = 1;
859 placeItem->repaint(false); 858 placeItem->repaint(false);
860 placeItem = placeItem->nextMultiItem(); 859 placeItem = placeItem->nextMultiItem();
861 } 860 }
862 emit itemModified( modifiedItem, mActionType ); 861 emit itemModified( modifiedItem, mActionType );
863 862
864 863
865 placeItem = modifiedItem; 864 placeItem = modifiedItem;
866 while ( placeItem ) { 865 while ( placeItem ) {
867 oldconflictItems = placeItem->conflictItems(); 866 oldconflictItems = placeItem->conflictItems();
868 for ( item=oldconflictItems.first(); item != 0; 867 for ( item=oldconflictItems.first(); item != 0;
869 item=oldconflictItems.next() ) { 868 item=oldconflictItems.next() ) {
870 placeSubCells(item); 869 placeSubCells(item);
871 } 870 }
872 placeSubCells( placeItem ); 871 placeSubCells( placeItem );
873 placeItem = placeItem->nextMultiItem(); 872 placeItem = placeItem->nextMultiItem();
874 873
875 } 874 }
876 placeItem = modifiedItem; 875 placeItem = modifiedItem;
877 while ( placeItem ) { 876 while ( placeItem ) {
878 oldconflictItems = placeItem->conflictItems(); 877 oldconflictItems = placeItem->conflictItems();
879 for ( item=oldconflictItems.first(); item != 0; 878 for ( item=oldconflictItems.first(); item != 0;
880 item=oldconflictItems.next() ) { 879 item=oldconflictItems.next() ) {
881 globalFlagBlockAgendaItemUpdate = 0; 880 globalFlagBlockAgendaItemUpdate = 0;
882 item->repaintMe(); 881 item->repaintMe();
883 globalFlagBlockAgendaItemUpdate = 1; 882 globalFlagBlockAgendaItemUpdate = 1;
884 item->repaint(false); 883 item->repaint(false);
885 } 884 }
886 placeItem = placeItem->nextMultiItem(); 885 placeItem = placeItem->nextMultiItem();
887 } 886 }
888 /* 887 /*
889 888
890 oldconflictItems = modifiedItem->conflictItems(); 889 oldconflictItems = modifiedItem->conflictItems();
891 for ( item=oldconflictItems.first(); item != 0; 890 for ( item=oldconflictItems.first(); item != 0;
892 item=oldconflictItems.next() ) { 891 item=oldconflictItems.next() ) {
893 globalFlagBlockAgendaItemUpdate = 0; 892 globalFlagBlockAgendaItemUpdate = 0;
894 item->paintMe(false); 893 item->paintMe(false);
895 globalFlagBlockAgendaItemUpdate = 1; 894 globalFlagBlockAgendaItemUpdate = 1;
896 item->repaint(false); 895 item->repaint(false);
897 } 896 }
898 */ 897 */
899 898
900 899
901 } 900 }
902 901
903 } 902 }
904 903
905 mScrollUpTimer.stop(); 904 mScrollUpTimer.stop();
906 mScrollDownTimer.stop(); 905 mScrollDownTimer.stop();
907 setCursor( arrowCursor ); 906 setCursor( arrowCursor );
908 mActionItem = 0; 907 mActionItem = 0;
909 mActionType = NOP; 908 mActionType = NOP;
910 mItemMoved = 0; 909 mItemMoved = 0;
911 910
912} 911}
913 912
914void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 913void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
915{ 914{
916// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 915// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
917// QPoint point = viewport()->mapToGlobal(viewportPos); 916// QPoint point = viewport()->mapToGlobal(viewportPos);
918// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 917// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
919// point = clipper()->mapFromGlobal(point); 918// point = clipper()->mapFromGlobal(point);
920// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 919// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
921 920
922 int x,y; 921 int x,y;
923 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 922 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
924// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 923// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
925 int gx,gy; 924 int gx,gy;
926 contentsToGrid(x,y,gx,gy); 925 contentsToGrid(x,y,gx,gy);
927 926
928 // Change cursor to resize cursor if appropriate 927 // Change cursor to resize cursor if appropriate
929 if (mAllDayMode) { 928 if (mAllDayMode) {
930 int gridDistanceX = (x - gx * mGridSpacingX); 929 int gridDistanceX = (x - gx * mGridSpacingX);
931 if (gridDistanceX < mResizeBorderWidth && 930 if (gridDistanceX < mResizeBorderWidth &&
932 moveItem->cellX() == gx) { 931 moveItem->cellX() == gx) {
933 setCursor(sizeHorCursor); 932 setCursor(sizeHorCursor);
934 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 933 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
935 moveItem->cellXWidth() == gx) { 934 moveItem->cellXWidth() == gx) {
936 setCursor(sizeHorCursor); 935 setCursor(sizeHorCursor);
937 } else { 936 } else {
938 setCursor(arrowCursor); 937 setCursor(arrowCursor);
939 } 938 }
940 } else { 939 } else {
941 int gridDistanceY = (y - gy * mGridSpacingY); 940 int gridDistanceY = (y - gy * mGridSpacingY);
942 if (gridDistanceY < mResizeBorderWidth && 941 if (gridDistanceY < mResizeBorderWidth &&
943 moveItem->cellYTop() == gy && 942 moveItem->cellYTop() == gy &&
944 !moveItem->firstMultiItem()) { 943 !moveItem->firstMultiItem()) {
945 setCursor(sizeVerCursor); 944 setCursor(sizeVerCursor);
946 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 945 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
947 moveItem->cellYBottom() == gy && 946 moveItem->cellYBottom() == gy &&
948 !moveItem->lastMultiItem()) { 947 !moveItem->lastMultiItem()) {
949 setCursor(sizeVerCursor); 948 setCursor(sizeVerCursor);
950 } else { 949 } else {
951 setCursor(arrowCursor); 950 setCursor(arrowCursor);
952 } 951 }
953 } 952 }
954} 953}
955 954
956 955
957/* 956/*
958 Place item in cell and take care that multiple items using the same cell do 957 Place item in cell and take care that multiple items using the same cell do
959 not overlap. This method is not yet optimal. It doesn´t use the maximum space 958 not overlap. This method is not yet optimal. It doesn´t use the maximum space
960 it can get in all cases. 959 it can get in all cases.
961 At the moment the method has a bug: When an item is placed only the sub cell 960 At the moment the method has a bug: When an item is placed only the sub cell
962 widths of the items are changed, which are within the Y region the item to 961 widths of the items are changed, which are within the Y region the item to
963 place spans. When the sub cell width change of one of this items affects a 962 place spans. When the sub cell width change of one of this items affects a
964 cell, where other items are, which do not overlap in Y with the item to place, 963 cell, where other items are, which do not overlap in Y with the item to place,
965 the display gets corrupted, although the corruption looks quite nice. 964 the display gets corrupted, although the corruption looks quite nice.
966*/ 965*/
967void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 966void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
968{ 967{
969 968
970 QPtrList<KOAgendaItem> conflictItems; 969 QPtrList<KOAgendaItem> conflictItems;
971 int maxSubCells = 0; 970 int maxSubCells = 0;
972 QIntDict<KOAgendaItem> subCellDict(5); 971 QIntDict<KOAgendaItem> subCellDict(5);
973 972
974 KOAgendaItem *item; 973 KOAgendaItem *item;
975 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 974 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
976 if (item != placeItem) { 975 if (item != placeItem) {
977 if (placeItem->cellX() <= item->cellXWidth() && 976 if (placeItem->cellX() <= item->cellXWidth() &&
978 placeItem->cellXWidth() >= item->cellX()) { 977 placeItem->cellXWidth() >= item->cellX()) {
979 if ((placeItem->cellYTop() <= item->cellYBottom()) && 978 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
980 (placeItem->cellYBottom() >= item->cellYTop())) { 979 (placeItem->cellYBottom() >= item->cellYTop())) {
981 conflictItems.append(item); 980 conflictItems.append(item);
982 if (item->subCells() > maxSubCells) 981 if (item->subCells() > maxSubCells)
983 maxSubCells = item->subCells(); 982 maxSubCells = item->subCells();
984 subCellDict.insert(item->subCell(),item); 983 subCellDict.insert(item->subCell(),item);
985 } 984 }
986 } 985 }
987 } 986 }
988 } 987 }
989 988
990 if (conflictItems.count() > 0) { 989 if (conflictItems.count() > 0) {
991 // Look for unused sub cell and insert item 990 // Look for unused sub cell and insert item
992 int i; 991 int i;
993 for(i=0;i<maxSubCells;++i) { 992 for(i=0;i<maxSubCells;++i) {
994 if (!subCellDict.find(i)) { 993 if (!subCellDict.find(i)) {
995 placeItem->setSubCell(i); 994 placeItem->setSubCell(i);
996 break; 995 break;
997 } 996 }
998 } 997 }
999 if (i == maxSubCells) { 998 if (i == maxSubCells) {
1000 placeItem->setSubCell(maxSubCells); 999 placeItem->setSubCell(maxSubCells);
1001 maxSubCells++; // add new item to number of sub cells 1000 maxSubCells++; // add new item to number of sub cells
1002 } 1001 }
1003 1002
1004 // Prepare for sub cell geometry adjustment 1003 // Prepare for sub cell geometry adjustment
1005 int newSubCellWidth; 1004 int newSubCellWidth;
1006 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1005 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1007 else newSubCellWidth = mGridSpacingX / maxSubCells; 1006 else newSubCellWidth = mGridSpacingX / maxSubCells;
1008 conflictItems.append(placeItem); 1007 conflictItems.append(placeItem);
1009 1008
1010 1009
1011 // Adjust sub cell geometry of all items 1010 // Adjust sub cell geometry of all items
1012 for ( item=conflictItems.first(); item != 0; 1011 for ( item=conflictItems.first(); item != 0;
1013 item=conflictItems.next() ) { 1012 item=conflictItems.next() ) {
1014 item->setSubCells(maxSubCells); 1013 item->setSubCells(maxSubCells);
1015 if (mAllDayMode) { 1014 if (mAllDayMode) {
1016 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1015 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1017 } else { 1016 } else {
1018 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1017 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1019 } 1018 }
1020 int x,y; 1019 int x,y;
1021 gridToContents(item->cellX(),item->cellYTop(),x,y); 1020 gridToContents(item->cellX(),item->cellYTop(),x,y);
1022 if (mAllDayMode) { 1021 if (mAllDayMode) {
1023 y += item->subCell() * newSubCellWidth; 1022 y += item->subCell() * newSubCellWidth;
1024 } else { 1023 } else {
1025 x += item->subCell() * newSubCellWidth; 1024 x += item->subCell() * newSubCellWidth;
1026 } 1025 }
1027 moveChild(item,x,y); 1026 moveChild(item,x,y);
1028 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1027 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1029 //item->updateItem(); 1028 //item->updateItem();
1030 } 1029 }
1031 1030
1032 } else { 1031 } else {
1033 placeItem->setSubCell(0); 1032 placeItem->setSubCell(0);
1034 placeItem->setSubCells(1); 1033 placeItem->setSubCells(1);
1035 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1034 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1036 else placeItem->resize(mGridSpacingX,placeItem->height()); 1035 else placeItem->resize(mGridSpacingX,placeItem->height());
1037 int x,y; 1036 int x,y;
1038 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1037 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1039 moveChild(placeItem,x,y); 1038 moveChild(placeItem,x,y);
1040 } 1039 }
1041 placeItem->setConflictItems(conflictItems); 1040 placeItem->setConflictItems(conflictItems);
1042 // for ( item=conflictItems.first(); item != 0; 1041 // for ( item=conflictItems.first(); item != 0;
1043// item=conflictItems.next() ) { 1042// item=conflictItems.next() ) {
1044// //item->updateItem(); 1043// //item->updateItem();
1045// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1044// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1046// } 1045// }
1047// placeItem->updateItem(); 1046// placeItem->updateItem();
1048} 1047}
1049 1048
1050void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1049void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1051{ 1050{
1052 if ( globalFlagBlockAgenda ) 1051 if ( globalFlagBlockAgenda )
1053 return; 1052 return;
1054 //qDebug("KOAgenda::drawContents "); 1053 //qDebug("KOAgenda::drawContents ");
1055 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1054 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1056 ;//drawContentsToPainter(); 1055 ;//drawContentsToPainter();
1057 1056
1058 QPaintDevice* pd = p->device(); 1057 QPaintDevice* pd = p->device();
1059 p->end(); 1058 p->end();
1060 int vx, vy; 1059 int vx, vy;
1061 int selectionX = KOGlobals::self()->reverseLayout() ? 1060 int selectionX = KOGlobals::self()->reverseLayout() ?
1062 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1061 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1063 mSelectionCellX * mGridSpacingX; 1062 mSelectionCellX * mGridSpacingX;
1064 contentsToViewport ( cx, cy, vx,vy); 1063 contentsToViewport ( cx, cy, vx,vy);
1065 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1064 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1066 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1065 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1067 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1066 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1068 1067
1069 if ( mSelectionHeight > 0 ) { 1068 if ( mSelectionHeight > 0 ) {
1070 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1069 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1071 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1070 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1072 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1071 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1073 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1072 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1074 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1073 bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1075 } 1074 }
1076 } 1075 }
1077 //qDebug("btbl "); 1076 //qDebug("btbl ");
1078 p->begin( pd ); 1077 p->begin( pd );
1079 //qDebug("end "); 1078 //qDebug("end ");
1080} 1079}
1081 1080
1082void KOAgenda::finishUpdate() 1081void KOAgenda::finishUpdate()
1083{ 1082{
1084 1083
1085 KOAgendaItem *item; 1084 KOAgendaItem *item;
1086 globalFlagBlockAgendaItemPaint = 1; 1085 globalFlagBlockAgendaItemPaint = 1;
1087 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1086 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1088 if ( !item->isVisible() ) 1087 if ( !item->isVisible() )
1089 item->show(); 1088 item->show();
1090 1089
1091 } 1090 }
1092 globalFlagBlockAgendaItemUpdate = 0; 1091 globalFlagBlockAgendaItemUpdate = 0;
1093 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1092 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1094 item->repaintMe( ); 1093 item->repaintMe( );
1095 } 1094 }
1096 globalFlagBlockAgendaItemUpdate = 1; 1095 globalFlagBlockAgendaItemUpdate = 1;
1097 qApp->processEvents(); 1096 qApp->processEvents();
1098 globalFlagBlockAgendaItemPaint = 0; 1097 globalFlagBlockAgendaItemPaint = 0;
1099 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1098 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1100 item->repaint( false ); 1099 item->repaint( false );
1101 } 1100 }
1102 1101
1103} 1102}
1104 1103
1105/* 1104/*
1106 Draw grid in the background of the agenda. 1105 Draw grid in the background of the agenda.
1107*/ 1106*/
1108void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1107void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1109{ 1108{
1110 1109
1111 1110
1112 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1111 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1113 return; 1112 return;
1114 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1113 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1115 return; 1114 return;
1116 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1115 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1117 if ( ch < 1 ) 1116 if ( ch < 1 )
1118 ch = 1; 1117 ch = 1;
1119 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1118 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1120 mPaintPixmap.resize( contentsWidth()+42, ch ); 1119 mPaintPixmap.resize( contentsWidth()+42, ch );
1121 } 1120 }
1122 mCurPixWid = contentsWidth(); 1121 mCurPixWid = contentsWidth();
1123 mCurPixHei = ch; 1122 mCurPixHei = ch;
1124 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { 1123 if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) {
1125 mHighlightPixmap.resize( mGridSpacingX-1, ch ); 1124 mHighlightPixmap.resize( mGridSpacingX-1, ch );
1126 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1125 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1127 } 1126 }
1128 mPixPainter.begin( &mPaintPixmap) ; 1127 mPixPainter.begin( &mPaintPixmap) ;
1129 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1128 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1130 QPainter * p ; 1129 QPainter * p ;
1131 if (paint == 0) { 1130 if (paint == 0) {
1132 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1131 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1133 p = &mPixPainter; 1132 p = &mPixPainter;
1134 } 1133 }
1135 else 1134 else
1136 p = paint ; 1135 p = paint ;
1137 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1136 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1138 1137
1139 //--cx;++cw; 1138 //--cx;++cw;
1140 int lGridSpacingY = mGridSpacingY*2; 1139 int lGridSpacingY = mGridSpacingY*2;
1141 int selDay; 1140 int selDay;
1142 if ( !backgroundOnly ) 1141 if ( !backgroundOnly )
1143 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1142 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1144 { 1143 {
1145 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { 1144 if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
1146 int x1 = cx; 1145 int x1 = cx;
1147 int y1 = 0; 1146 int y1 = 0;
1148 if (y1 < cy) y1 = cy; 1147 if (y1 < cy) y1 = cy;
1149 int x2 = cx+cw-1; 1148 int x2 = cx+cw-1;
1150 int y2 = contentsHeight(); 1149 int y2 = contentsHeight();
1151 if (y2 > cy+ch-1) y2=cy+ch-1; 1150 if (y2 > cy+ch-1) y2=cy+ch-1;
1152 if (x2 >= x1 && y2 >= y1) { 1151 if (x2 >= x1 && y2 >= y1) {
1153 int gxStart = selDay; 1152 int gxStart = selDay;
1154 int gxEnd = gxStart ; 1153 int gxEnd = gxStart ;
1155 int xStart = KOGlobals::self()->reverseLayout() ? 1154 int xStart = KOGlobals::self()->reverseLayout() ?
1156 (mColumns - 1 - gxStart)*mGridSpacingX : 1155 (mColumns - 1 - gxStart)*mGridSpacingX :
1157 gxStart*mGridSpacingX; 1156 gxStart*mGridSpacingX;
1158 if (xStart < x1) xStart = x1; 1157 if (xStart < x1) xStart = x1;
1159 int xEnd = KOGlobals::self()->reverseLayout() ? 1158 int xEnd = KOGlobals::self()->reverseLayout() ?
1160 (mColumns - gxStart)*mGridSpacingX-1 : 1159 (mColumns - gxStart)*mGridSpacingX-1 :
1161 (gxStart+1)*mGridSpacingX-1; 1160 (gxStart+1)*mGridSpacingX-1;
1162 if (xEnd > x2) xEnd = x2; 1161 if (xEnd > x2) xEnd = x2;
1163 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1162 if ( KOPrefs::instance()->mUseHighlightLightColor )
1164 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1163 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1165 KOPrefs::instance()->mAgendaBgColor.light()); 1164 KOPrefs::instance()->mAgendaBgColor.light());
1166 else 1165 else
1167 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1166 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1168 KOPrefs::instance()->mAgendaBgColor.dark()); 1167 KOPrefs::instance()->mAgendaBgColor.dark());
1169 1168
1170 } 1169 }
1171 } 1170 }
1172 } 1171 }
1173 // Highlight working hours 1172 // Highlight working hours
1174 1173
1175 if ( !backgroundOnly ) 1174 if ( !backgroundOnly )
1176 if (mWorkingHoursEnable) { 1175 if (mWorkingHoursEnable) {
1177 int x1 = cx; 1176 int x1 = cx;
1178 int y1 = mWorkingHoursYTop; 1177 int y1 = mWorkingHoursYTop;
1179 if (y1 < cy) y1 = cy; 1178 if (y1 < cy) y1 = cy;
1180 int x2 = cx+cw-1; 1179 int x2 = cx+cw-1;
1181 // int x2 = mGridSpacingX * 5 - 1; 1180 // int x2 = mGridSpacingX * 5 - 1;
1182 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1181 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1183 int y2 = mWorkingHoursYBottom; 1182 int y2 = mWorkingHoursYBottom;
1184 if (y2 > cy+ch-1) y2=cy+ch-1; 1183 if (y2 > cy+ch-1) y2=cy+ch-1;
1185 1184
1186 if (x2 >= x1 && y2 >= y1) { 1185 if (x2 >= x1 && y2 >= y1) {
1187 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1186 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1188 int gxStart = x1/mGridSpacingX; 1187 int gxStart = x1/mGridSpacingX;
1189 int gxEnd = x2/mGridSpacingX; 1188 int gxEnd = x2/mGridSpacingX;
1190 while(gxStart <= gxEnd) { 1189 while(gxStart <= gxEnd) {
1191 if (gxStart < int(mHolidayMask->count()) && 1190 if (gxStart < int(mHolidayMask->count()) &&
1192 !mHolidayMask->at(gxStart)) { 1191 !mHolidayMask->at(gxStart)) {
1193 int xStart = KOGlobals::self()->reverseLayout() ? 1192 int xStart = KOGlobals::self()->reverseLayout() ?
1194 (mColumns - 1 - gxStart)*mGridSpacingX : 1193 (mColumns - 1 - gxStart)*mGridSpacingX :
1195 gxStart*mGridSpacingX; 1194 gxStart*mGridSpacingX;
1196 if (xStart < x1) xStart = x1; 1195 if (xStart < x1) xStart = x1;
1197 int xEnd = KOGlobals::self()->reverseLayout() ? 1196 int xEnd = KOGlobals::self()->reverseLayout() ?
1198 (mColumns - gxStart)*mGridSpacingX-1 : 1197 (mColumns - gxStart)*mGridSpacingX-1 :
1199 (gxStart+1)*mGridSpacingX-1; 1198 (gxStart+1)*mGridSpacingX-1;
1200 if (xEnd > x2) xEnd = x2; 1199 if (xEnd > x2) xEnd = x2;
1201 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { 1200 if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
1202 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1201 if ( KOPrefs::instance()->mUseHighlightLightColor )
1203 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1202 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1204 KOPrefs::instance()->mWorkingHoursColor.light()); 1203 KOPrefs::instance()->mWorkingHoursColor.light());
1205 else 1204 else
1206 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1205 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1207 KOPrefs::instance()->mWorkingHoursColor.dark()); 1206 KOPrefs::instance()->mWorkingHoursColor.dark());
1208 } else { 1207 } else {
1209 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1208 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1210 KOPrefs::instance()->mWorkingHoursColor); 1209 KOPrefs::instance()->mWorkingHoursColor);
1211 } 1210 }
1212 } 1211 }
1213 ++gxStart; 1212 ++gxStart;
1214 } 1213 }
1215 } 1214 }
1216 } 1215 }
1217 /* 1216 /*
1218 int selectionX = KOGlobals::self()->reverseLayout() ? 1217 int selectionX = KOGlobals::self()->reverseLayout() ?
1219 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1218 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1220 mSelectionCellX * mGridSpacingX; 1219 mSelectionCellX * mGridSpacingX;
1221 1220
1222 // Draw selection 1221 // Draw selection
1223 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1222 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1224 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1223 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1225 // TODO: paint only part within cx,cy,cw,ch 1224 // TODO: paint only part within cx,cy,cw,ch
1226 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1225 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1227 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1226 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1228 } 1227 }
1229 */ 1228 */
1230 // Draw vertical lines of grid 1229 // Draw vertical lines of grid
1231 1230
1232 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1231 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1233 if ( mGridSpacingX > 0 ) { 1232 if ( mGridSpacingX > 0 ) {
1234 while (x < cx + cw) { 1233 while (x < cx + cw) {
1235 p->drawLine(x,cy,x,cy+ch); 1234 p->drawLine(x,cy,x,cy+ch);
1236 x+=mGridSpacingX; 1235 x+=mGridSpacingX;
1237 } 1236 }
1238 } 1237 }
1239 // Draw horizontal lines of grid 1238 // Draw horizontal lines of grid
1240 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1239 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1241 if ( lGridSpacingY > 0 ) { 1240 if ( lGridSpacingY > 0 ) {
1242 while (y < cy + ch) { 1241 while (y < cy + ch) {
1243 p->drawLine(cx,y,cx+cw,y); 1242 p->drawLine(cx,y,cx+cw,y);
1244 y+=lGridSpacingY; 1243 y+=lGridSpacingY;
1245 } 1244 }
1246 } 1245 }
1247 mPixPainter.end() ; 1246 mPixPainter.end() ;
1248} 1247}
1249 1248
1250/* 1249/*
1251 Convert srcollview contents coordinates to agenda grid coordinates. 1250 Convert srcollview contents coordinates to agenda grid coordinates.
1252*/ 1251*/
1253void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1252void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1254{ 1253{
1255 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1254 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1256 x/mGridSpacingX; 1255 x/mGridSpacingX;
1257 gy = y/mGridSpacingY; 1256 gy = y/mGridSpacingY;
1258} 1257}
1259 1258
1260/* 1259/*
1261 Convert agenda grid coordinates to scrollview contents coordinates. 1260 Convert agenda grid coordinates to scrollview contents coordinates.
1262*/ 1261*/
1263void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1262void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1264{ 1263{
1265 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1264 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1266 gx*mGridSpacingX; 1265 gx*mGridSpacingX;
1267 y = gy*mGridSpacingY; 1266 y = gy*mGridSpacingY;
1268} 1267}
1269 1268
1270 1269
1271/* 1270/*
1272 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1271 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1273 the grid. 1272 the grid.
1274*/ 1273*/
1275int KOAgenda::timeToY(const QTime &time) 1274int KOAgenda::timeToY(const QTime &time)
1276{ 1275{
1277 int minutesPerCell = 24 * 60 / mRows; 1276 int minutesPerCell = 24 * 60 / mRows;
1278 int timeMinutes = time.hour() * 60 + time.minute(); 1277 int timeMinutes = time.hour() * 60 + time.minute();
1279 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1278 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1280 return Y; 1279 return Y;
1281} 1280}
1282 1281
1283 1282
1284/* 1283/*
1285 Return time corresponding to cell y coordinate. Coordinates are rounded to 1284 Return time corresponding to cell y coordinate. Coordinates are rounded to
1286 fit into the grid. 1285 fit into the grid.
1287*/ 1286*/
1288QTime KOAgenda::gyToTime(int gy) 1287QTime KOAgenda::gyToTime(int gy)
1289{ 1288{
1290 1289
1291 int secondsPerCell = 24 * 60 * 60/ mRows; 1290 int secondsPerCell = 24 * 60 * 60/ mRows;
1292 1291
1293 int timeSeconds = secondsPerCell * gy; 1292 int timeSeconds = secondsPerCell * gy;
1294 1293
1295 QTime time( 0, 0, 0 ); 1294 QTime time( 0, 0, 0 );
1296 if ( timeSeconds < 24 * 60 * 60 ) { 1295 if ( timeSeconds < 24 * 60 * 60 ) {
1297 time = time.addSecs(timeSeconds); 1296 time = time.addSecs(timeSeconds);
1298 } else { 1297 } else {
1299 time.setHMS( 23, 59, 59 ); 1298 time.setHMS( 23, 59, 59 );
1300 } 1299 }
1301 1300
1302 return time; 1301 return time;
1303} 1302}
1304 1303
1305void KOAgenda::setStartHour(int startHour) 1304void KOAgenda::setStartHour(int startHour)
1306{ 1305{
1307 int startCell = startHour * mRows / 24; 1306 int startCell = startHour * mRows / 24;
1308 setContentsPos(0,startCell * gridSpacingY()); 1307 setContentsPos(0,startCell * gridSpacingY());
1309} 1308}
1310void KOAgenda::hideUnused() 1309void KOAgenda::hideUnused()
1311{ 1310{
1312 // experimental only 1311 // experimental only
1313 // return; 1312 // return;
1314 KOAgendaItem *item; 1313 KOAgendaItem *item;
1315 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1314 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1316 item->hide(); 1315 item->hide();
1317 } 1316 }
1318} 1317}
1319 1318
1320 1319
1321KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1320KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1322{ 1321{
1323 1322
1324 KOAgendaItem *fi; 1323 KOAgendaItem *fi;
1325 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1324 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1326 if ( fi->incidence() == event ) { 1325 if ( fi->incidence() == event ) {
1327 mUnusedItems.remove(); 1326 mUnusedItems.remove();
1328 fi->init( event, qd ); 1327 fi->init( event, qd );
1329 return fi; 1328 return fi;
1330 } 1329 }
1331 } 1330 }
1332 fi=mUnusedItems.first(); 1331 fi=mUnusedItems.first();
1333 if ( fi ) { 1332 if ( fi ) {
1334 mUnusedItems.remove(); 1333 mUnusedItems.remove();
1335 fi->init( event, qd ); 1334 fi->init( event, qd );
1336 return fi; 1335 return fi;
1337 } 1336 }
1338 // qDebug("new KOAgendaItem "); 1337 // qDebug("new KOAgendaItem ");
1339 1338
1340 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1339 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1341 agendaItem->installEventFilter(this); 1340 agendaItem->installEventFilter(this);
1342 addChild(agendaItem,0,0); 1341 addChild(agendaItem,0,0);
1343 return agendaItem; 1342 return agendaItem;
1344} 1343}
1345KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1344KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1346{ 1345{
1347 KOAgendaItem *item; 1346 KOAgendaItem *item;
1348 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1347 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1349 if ( item->incidence() == todo ) { 1348 if ( item->incidence() == todo ) {
1350 mItems.remove(); 1349 mItems.remove();
1351 return item; 1350 return item;
1352 } 1351 }
1353 } 1352 }
1354 return 0; 1353 return 0;
1355} 1354}
1356 1355
1357 1356
1358void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1357void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1359{ 1358{
1360 1359
1361 KOAgendaItem *item; 1360 KOAgendaItem *item;
1362 item = getItemForTodo ( todo ); 1361 item = getItemForTodo ( todo );
1363 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1362 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1364 if ( item ) { 1363 if ( item ) {
1365 blockSignals( true ); 1364 blockSignals( true );
1366 //qDebug("item found "); 1365 //qDebug("item found ");
1367 item->hide(); 1366 item->hide();
1368 item->setCellX(-2, -1 ); 1367 item->setCellX(-2, -1 );
1369 item->select(false); 1368 item->select(false);
1370 mUnusedItems.append( item ); 1369 mUnusedItems.append( item );
1371 mItems.remove( item ); 1370 mItems.remove( item );
1372 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1371 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1373 KOAgendaItem *itemit; 1372 KOAgendaItem *itemit;
1374 //globalFlagBlockAgendaItemPaint = 1; 1373 //globalFlagBlockAgendaItemPaint = 1;
1375 for ( itemit=oldconflictItems.first(); itemit != 0; 1374 for ( itemit=oldconflictItems.first(); itemit != 0;
1376 itemit=oldconflictItems.next() ) { 1375 itemit=oldconflictItems.next() ) {
1377 if ( itemit != item ) 1376 if ( itemit != item )
1378 placeSubCells(itemit); 1377 placeSubCells(itemit);
1379 } 1378 }
1380 qApp->processEvents(); 1379 qApp->processEvents();
1381 //globalFlagBlockAgendaItemPaint = 0; 1380 //globalFlagBlockAgendaItemPaint = 0;
1382 for ( itemit=oldconflictItems.first(); itemit != 0; 1381 for ( itemit=oldconflictItems.first(); itemit != 0;
1383 itemit=oldconflictItems.next() ) { 1382 itemit=oldconflictItems.next() ) {
1384 globalFlagBlockAgendaItemUpdate = 0; 1383 globalFlagBlockAgendaItemUpdate = 0;
1385 if ( itemit != item ) 1384 if ( itemit != item )
1386 itemit->repaintMe(); 1385 itemit->repaintMe();
1387 globalFlagBlockAgendaItemUpdate = 1; 1386 globalFlagBlockAgendaItemUpdate = 1;
1388 itemit->repaint(); 1387 itemit->repaint();
1389 } 1388 }
1390 blockSignals( false ); 1389 blockSignals( false );
1391 } 1390 }
1392 if ( remove ) { 1391 if ( remove ) {
1393 //qDebug("remove****************************************** "); 1392 //qDebug("remove****************************************** ");
1394 return; 1393 return;
1395 } 1394 }
1396 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1395 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1397 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1396 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
1398 QDate currentDate; 1397 QDate currentDate;
1399 if ( overdue ) { 1398 if ( overdue ) {
1400 currentDate = QDate::currentDate(); 1399 currentDate = QDate::currentDate();
1401 days += todo->dtDue().date().daysTo( currentDate ); 1400 days += todo->dtDue().date().daysTo( currentDate );
1402 } 1401 }
1403 else 1402 else
1404 currentDate = todo->dtDue().date(); 1403 currentDate = todo->dtDue().date();
1405 1404
1406 if ( todo->doesFloat() || overdue ) { 1405 if ( todo->doesFloat() || overdue ) {
1407 if ( ! mAllDayMode ) return; 1406 if ( ! mAllDayMode ) return;
1408 // aldayagenda 1407 // aldayagenda
1409 globalFlagBlockAgendaItemPaint = 1; 1408 globalFlagBlockAgendaItemPaint = 1;
1410 item = insertAllDayItem(todo, currentDate,days, days); 1409 item = insertAllDayItem(todo, currentDate,days, days);
1411 item->show(); 1410 item->show();
1412 1411
1413 } 1412 }
1414 else { 1413 else {
1415 if ( mAllDayMode ) return; 1414 if ( mAllDayMode ) return;
1416 // mAgenda 1415 // mAgenda
1417 globalFlagBlockAgendaItemPaint = 1; 1416 globalFlagBlockAgendaItemPaint = 1;
1418 int endY = timeToY(todo->dtDue().time()) - 1; 1417 int endY = timeToY(todo->dtDue().time()) - 1;
1419 int hi = 12/KOPrefs::instance()->mHourSize; 1418 int hi = 12/KOPrefs::instance()->mHourSize;
1420 int startY = endY - 1-hi; 1419 int startY = endY - 1-hi;
1421 item = insertItem(todo,currentDate,days,startY,endY); 1420 item = insertItem(todo,currentDate,days,startY,endY);
1422 item->show(); 1421 item->show();
1423 } 1422 }
1424 qApp->processEvents(); 1423 qApp->processEvents();
1425 globalFlagBlockAgendaItemPaint = 0; 1424 globalFlagBlockAgendaItemPaint = 0;
1426 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1425 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1427 KOAgendaItem *itemit; 1426 KOAgendaItem *itemit;
1428 for ( itemit=oldconflictItems.first(); itemit != 0; 1427 for ( itemit=oldconflictItems.first(); itemit != 0;
1429 itemit=oldconflictItems.next() ) { 1428 itemit=oldconflictItems.next() ) {
1430 globalFlagBlockAgendaItemUpdate = 0; 1429 globalFlagBlockAgendaItemUpdate = 0;
1431 itemit->repaintMe(); 1430 itemit->repaintMe();
1432 globalFlagBlockAgendaItemUpdate = 1; 1431 globalFlagBlockAgendaItemUpdate = 1;
1433 itemit->repaint(); 1432 itemit->repaint();
1434 } 1433 }
1435 globalFlagBlockAgendaItemUpdate = 0; 1434 globalFlagBlockAgendaItemUpdate = 0;
1436 item->repaintMe(); 1435 item->repaintMe();
1437 globalFlagBlockAgendaItemUpdate = 1; 1436 globalFlagBlockAgendaItemUpdate = 1;
1438 item->repaint(); 1437 item->repaint();
1439} 1438}
1440/* 1439/*
1441 Insert KOAgendaItem into agenda. 1440 Insert KOAgendaItem into agenda.
1442*/ 1441*/
1443KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1442KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1444{ 1443{
1445 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; 1444 //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl;
1446 1445
1447 if (mAllDayMode) { 1446 if (mAllDayMode) {
1448 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; 1447 kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl;
1449 return 0; 1448 return 0;
1450 } 1449 }
1451 1450
1452 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1451 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1453 //agendaItem->setFrameStyle(WinPanel|Raised); 1452 //agendaItem->setFrameStyle(WinPanel|Raised);
1454 1453
1455 int YSize = YBottom - YTop + 1; 1454 int YSize = YBottom - YTop + 1;
1456 if (YSize < 0) { 1455 if (YSize < 0) {
1457 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; 1456 kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl;
1458 YSize = 1; 1457 YSize = 1;
1459 } 1458 }
1460 int iheight = mGridSpacingY * YSize; 1459 int iheight = mGridSpacingY * YSize;
1461 1460
1462 agendaItem->resize(mGridSpacingX,iheight ); 1461 agendaItem->resize(mGridSpacingX,iheight );
1463 agendaItem->setCellXY(X,YTop,YBottom); 1462 agendaItem->setCellXY(X,YTop,YBottom);
1464 agendaItem->setCellXWidth(X); 1463 agendaItem->setCellXWidth(X);
1465 1464
1466 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1465 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1467 mItems.append(agendaItem); 1466 mItems.append(agendaItem);
1468 1467
1469 placeSubCells(agendaItem); 1468 placeSubCells(agendaItem);
1470 1469
1471 //agendaItem->show(); 1470 //agendaItem->show();
1472 1471
1473 marcus_bains(); 1472 marcus_bains();
1474 1473
1475 return agendaItem; 1474 return agendaItem;
1476} 1475}
1477 1476
1478 1477
1479/* 1478/*
1480 Insert all-day KOAgendaItem into agenda. 1479 Insert all-day KOAgendaItem into agenda.
1481*/ 1480*/
1482KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1481KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1483{ 1482{
1484 if (!mAllDayMode) { 1483 if (!mAllDayMode) {
1485 return 0; 1484 return 0;
1486 } 1485 }
1487 1486
1488 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1487 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1489 1488
1490 agendaItem->setCellXY(XBegin,0,0); 1489 agendaItem->setCellXY(XBegin,0,0);
1491 agendaItem->setCellXWidth(XEnd); 1490 agendaItem->setCellXWidth(XEnd);
1492 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1491 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1493 1492
1494 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1493 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1495 mItems.append(agendaItem); 1494 mItems.append(agendaItem);
1496 1495
1497 placeSubCells(agendaItem); 1496 placeSubCells(agendaItem);
1498 1497
1499 //agendaItem->show(); 1498 //agendaItem->show();
1500 1499
1501 return agendaItem; 1500 return agendaItem;
1502} 1501}
1503 1502
1504 1503
1505void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1504void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1506 int YTop,int YBottom) 1505 int YTop,int YBottom)
1507{ 1506{
1508 if (mAllDayMode) { 1507 if (mAllDayMode) {
1509 ; 1508 ;
1510 return; 1509 return;
1511 } 1510 }
1512 1511
1513 int cellX,cellYTop,cellYBottom; 1512 int cellX,cellYTop,cellYBottom;
1514 QString newtext; 1513 QString newtext;
1515 int width = XEnd - XBegin + 1; 1514 int width = XEnd - XBegin + 1;
1516 int count = 0; 1515 int count = 0;
1517 KOAgendaItem *current = 0; 1516 KOAgendaItem *current = 0;
1518 QPtrList<KOAgendaItem> multiItems; 1517 QPtrList<KOAgendaItem> multiItems;
1519 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1518 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1520 if (cellX == XBegin) cellYTop = YTop; 1519 if (cellX == XBegin) cellYTop = YTop;
1521 else cellYTop = 0; 1520 else cellYTop = 0;
1522 if (cellX == XEnd) cellYBottom = YBottom; 1521 if (cellX == XEnd) cellYBottom = YBottom;
1523 else cellYBottom = rows() - 1; 1522 else cellYBottom = rows() - 1;
1524 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1523 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1525 newtext.append(event->summary()); 1524 newtext.append(event->summary());
1526 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1525 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1527 current->setText(newtext); 1526 current->setText(newtext);
1528 multiItems.append(current); 1527 multiItems.append(current);
1529 } 1528 }
1530 1529
1531 KOAgendaItem *next = 0; 1530 KOAgendaItem *next = 0;
1532 KOAgendaItem *last = multiItems.last(); 1531 KOAgendaItem *last = multiItems.last();
1533 KOAgendaItem *first = multiItems.first(); 1532 KOAgendaItem *first = multiItems.first();
1534 KOAgendaItem *setFirst,*setLast; 1533 KOAgendaItem *setFirst,*setLast;
1535 current = first; 1534 current = first;
1536 while (current) { 1535 while (current) {
1537 next = multiItems.next(); 1536 next = multiItems.next();
1538 if (current == first) setFirst = 0; 1537 if (current == first) setFirst = 0;
1539 else setFirst = first; 1538 else setFirst = first;
1540 if (current == last) setLast = 0; 1539 if (current == last) setLast = 0;
1541 else setLast = last; 1540 else setLast = last;
1542 1541
1543 current->setMultiItem(setFirst,next,setLast); 1542 current->setMultiItem(setFirst,next,setLast);
1544 current = next; 1543 current = next;
1545 } 1544 }
1546 1545
1547 marcus_bains(); 1546 marcus_bains();
1548} 1547}
1549 1548
1550 1549
1551//QSizePolicy KOAgenda::sizePolicy() const 1550//QSizePolicy KOAgenda::sizePolicy() const
1552//{ 1551//{
1553 // Thought this would make the all-day event agenda minimum size and the 1552 // Thought this would make the all-day event agenda minimum size and the
1554 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1553 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1555 // don´t seem to think that an Expanding widget needs more space than a 1554 // don´t seem to think that an Expanding widget needs more space than a
1556 // Preferred one. 1555 // Preferred one.
1557 // But it doesn´t hurt, so it stays. 1556 // But it doesn´t hurt, so it stays.
1558// if (mAllDayMode) { 1557// if (mAllDayMode) {
1559// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1558// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1560// } else { 1559// } else {
1561// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1560// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1562// } 1561// }
1563//} 1562//}
1564void KOAgenda::finishResize ( ) 1563void KOAgenda::finishResize ( )
1565{ 1564{
1566 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1565 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1567 if ( globalFlagBlockAgenda == 0 ) { 1566 if ( globalFlagBlockAgenda == 0 ) {
1568 finishUpdate(); 1567 finishUpdate();
1569 //qDebug("finishUpdate() called "); 1568 //qDebug("finishUpdate() called ");
1570 } 1569 }
1571} 1570}
1572/* 1571/*
1573 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1572 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1574*/ 1573*/
1575void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1574void KOAgenda::resizeEvent ( QResizeEvent *ev )
1576{ 1575{
1577 1576
1578 mResizeTimer.start( 150 , true ); 1577 mResizeTimer.start( 150 , true );
1579 computeSizes(); 1578 computeSizes();
1580 return; 1579 return;
1581 1580
1582} 1581}
1583void KOAgenda::computeSizes() 1582void KOAgenda::computeSizes()
1584{ 1583{
1585 if ( globalFlagBlockStartup ) 1584 if ( globalFlagBlockStartup )
1586 return; 1585 return;
1587 1586
1588 if (mAllDayMode) { 1587 if (mAllDayMode) {
1589 mGridSpacingX = (width()-3) / mColumns; 1588 mGridSpacingX = (width()-3) / mColumns;
1590 mGridSpacingY = height() - 2 * frameWidth() - 1; 1589 mGridSpacingY = height() - 2 * frameWidth() - 1;
1591 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1590 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1592// mGridSpacingY = height(); 1591// mGridSpacingY = height();
1593// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1592// resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1594 1593
1595 KOAgendaItem *item; 1594 KOAgendaItem *item;
1596 int subCellWidth; 1595 int subCellWidth;
1597 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1596 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1598 subCellWidth = mGridSpacingY / item->subCells(); 1597 subCellWidth = mGridSpacingY / item->subCells();
1599 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1598 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1600 moveChild(item,KOGlobals::self()->reverseLayout() ? 1599 moveChild(item,KOGlobals::self()->reverseLayout() ?
1601 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1600 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1602 item->cellX() * mGridSpacingX, 1601 item->cellX() * mGridSpacingX,
1603 item->subCell() * subCellWidth); 1602 item->subCell() * subCellWidth);
1604 } 1603 }
1605 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1604 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1606 } else { 1605 } else {
1607 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; 1606 mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns;
1608 if (height() > mGridSpacingY * mRows + 1 ) { 1607 if (height() > mGridSpacingY * mRows + 1 ) {
1609 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1608 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1610 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1609 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1611 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1610 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1612 emit resizedSignal(); 1611 emit resizedSignal();
1613 } else 1612 } else
1614 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1613 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1615 KOAgendaItem *item; 1614 KOAgendaItem *item;
1616 int subCellWidth; 1615 int subCellWidth;
1617 1616
1618 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1617 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1619 subCellWidth = mGridSpacingX / item->subCells(); 1618 subCellWidth = mGridSpacingX / item->subCells();
1620 item->resize(subCellWidth,item->height()); 1619 item->resize(subCellWidth,item->height());
1621 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1620 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1622 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1621 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1623 item->cellX() * mGridSpacingX) + 1622 item->cellX() * mGridSpacingX) +
1624 item->subCell() * subCellWidth,childY(item)); 1623 item->subCell() * subCellWidth,childY(item));
1625 } 1624 }
1626 } 1625 }
1627 int cw = contentsWidth(); 1626 int cw = contentsWidth();
1628 int ch = contentsHeight(); 1627 int ch = contentsHeight();
1629 if ( mAllDayMode ) { 1628 if ( mAllDayMode ) {
1630 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1629 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1631 if ( paintPixAll->width() < cw || paintPixAll->height() < ch ) 1630 if ( paintPixAll->width() < cw || paintPixAll->height() < ch )
1632 paintPixAll->resize( cw, ch ); 1631 paintPixAll->resize( cw, ch );
1633 } else { 1632 } else {
1634 QPixmap* paintPix = KOAgendaItem::paintPix(); 1633 QPixmap* paintPix = KOAgendaItem::paintPix();
1635 if ( paintPix->width() < cw || paintPix->height() < ch ) 1634 if ( paintPix->width() < cw || paintPix->height() < ch )
1636 KOAgendaItem::resizePixmap( cw , ch ); 1635 KOAgendaItem::resizePixmap( cw , ch );
1637 } 1636 }
1638 1637
1639 checkScrollBoundaries(); 1638 checkScrollBoundaries();
1640 marcus_bains(); 1639 marcus_bains();
1641 drawContentsToPainter(); 1640 drawContentsToPainter();
1642 viewport()->repaint(false); 1641 viewport()->repaint(false);
1643} 1642}
1644 1643
1645void KOAgenda::scrollUp() 1644void KOAgenda::scrollUp()
1646{ 1645{
1647 scrollBy(0,-mScrollOffset); 1646 scrollBy(0,-mScrollOffset);
1648} 1647}
1649 1648
1650 1649
1651void KOAgenda::scrollDown() 1650void KOAgenda::scrollDown()
1652{ 1651{
1653 scrollBy(0,mScrollOffset); 1652 scrollBy(0,mScrollOffset);
1654} 1653}
1655 1654
1656void KOAgenda::popupAlarm() 1655void KOAgenda::popupAlarm()
1657{ 1656{
1658 if (!mClickedItem) { 1657 if (!mClickedItem) {
1659 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl; 1658 kdDebug() << "KOAgenda::popupAlarm() called without having a clicked item" << endl;
1660 return; 1659 return;
1661 } 1660 }
1662// TODO: deal correctly with multiple alarms 1661// TODO: deal correctly with multiple alarms
1663 Alarm* alarm; 1662 Alarm* alarm;
1664 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1663 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1665 for(alarm=list.first();alarm;alarm=list.next()) { 1664 for(alarm=list.first();alarm;alarm=list.next()) {
1666 alarm->toggleAlarm(); 1665 alarm->toggleAlarm();
1667 } 1666 }
1668 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1667 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1669 mClickedItem->paintMe( true ); 1668 mClickedItem->paintMe( true );
1670 mClickedItem->repaint( false ); 1669 mClickedItem->repaint( false );
1671} 1670}
1672 1671
1673/* 1672/*
1674 Calculates the minimum width 1673 Calculates the minimum width
1675*/ 1674*/
1676int KOAgenda::minimumWidth() const 1675int KOAgenda::minimumWidth() const
1677{ 1676{
1678 // TODO:: develop a way to dynamically determine the minimum width 1677 // TODO:: develop a way to dynamically determine the minimum width
1679 int min = 100; 1678 int min = 100;
1680 1679
1681 return min; 1680 return min;
1682} 1681}
1683 1682
1684void KOAgenda::updateConfig() 1683void KOAgenda::updateConfig()
1685{ 1684{
1686 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 1685 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
1687 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 1686 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
1688 if ( mAllDayMode ) { 1687 if ( mAllDayMode ) {
1689 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 1688 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
1690 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 1689 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
1691 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 1690 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
1692 // setMaximumHeight( mGridSpacingY+1 ); 1691 // setMaximumHeight( mGridSpacingY+1 );
1693 viewport()->repaint( false ); 1692 viewport()->repaint( false );
1694 //setFixedHeight( mGridSpacingY+1 ); 1693 //setFixedHeight( mGridSpacingY+1 );
1695 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 1694 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
1696 } 1695 }
1697 else { 1696 else {
1698 mGridSpacingY = KOPrefs::instance()->mHourSize; 1697 mGridSpacingY = KOPrefs::instance()->mHourSize;
1699 calculateWorkingHours(); 1698 calculateWorkingHours();
1700 marcus_bains(); 1699 marcus_bains();
1701 } 1700 }
1702} 1701}
1703 1702
1704void KOAgenda::checkScrollBoundaries() 1703void KOAgenda::checkScrollBoundaries()
1705{ 1704{
1706 // Invalidate old values to force update 1705 // Invalidate old values to force update
1707 mOldLowerScrollValue = -1; 1706 mOldLowerScrollValue = -1;
1708 mOldUpperScrollValue = -1; 1707 mOldUpperScrollValue = -1;
1709 1708
1710 checkScrollBoundaries(verticalScrollBar()->value()); 1709 checkScrollBoundaries(verticalScrollBar()->value());
1711} 1710}
1712 1711
1713void KOAgenda::checkScrollBoundaries(int v) 1712void KOAgenda::checkScrollBoundaries(int v)
1714{ 1713{
1715 if ( mGridSpacingY == 0 ) 1714 if ( mGridSpacingY == 0 )
1716 return; 1715 return;
1717 int yMin = v/mGridSpacingY; 1716 int yMin = v/mGridSpacingY;
1718 int yMax = (v+visibleHeight())/mGridSpacingY; 1717 int yMax = (v+visibleHeight())/mGridSpacingY;
1719 1718
1720// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 1719// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
1721 1720
1722 if (yMin != mOldLowerScrollValue) { 1721 if (yMin != mOldLowerScrollValue) {
1723 mOldLowerScrollValue = yMin; 1722 mOldLowerScrollValue = yMin;
1724 emit lowerYChanged(yMin); 1723 emit lowerYChanged(yMin);
1725 } 1724 }
1726 if (yMax != mOldUpperScrollValue) { 1725 if (yMax != mOldUpperScrollValue) {
1727 mOldUpperScrollValue = yMax; 1726 mOldUpperScrollValue = yMax;
1728 emit upperYChanged(yMax); 1727 emit upperYChanged(yMax);
1729 } 1728 }
1730} 1729}
1731 1730
1732void KOAgenda::deselectItem() 1731void KOAgenda::deselectItem()
1733{ 1732{
1734 if (mSelectedItem.isNull()) return; 1733 if (mSelectedItem.isNull()) return;
1735 mSelectedItem->select(false); 1734 mSelectedItem->select(false);
1736 mSelectedItem = 0; 1735 mSelectedItem = 0;
1737} 1736}
1738 1737
1739void KOAgenda::selectItem(KOAgendaItem *item) 1738void KOAgenda::selectItem(KOAgendaItem *item)
1740{ 1739{
1741 if ((KOAgendaItem *)mSelectedItem == item) return; 1740 if ((KOAgendaItem *)mSelectedItem == item) return;
1742 deselectItem(); 1741 deselectItem();
1743 if (item == 0) { 1742 if (item == 0) {
1744 emit incidenceSelected( 0 ); 1743 emit incidenceSelected( 0 );
1745 return; 1744 return;
1746 } 1745 }
1747 mSelectedItem = item; 1746 mSelectedItem = item;
1748 mSelectedItem->select(); 1747 mSelectedItem->select();
1749 emit incidenceSelected( mSelectedItem->incidence() ); 1748 emit incidenceSelected( mSelectedItem->incidence() );
1750} 1749}
1751 1750
1752// This function seems never be called. 1751// This function seems never be called.
1753void KOAgenda::keyPressEvent( QKeyEvent *kev ) 1752void KOAgenda::keyPressEvent( QKeyEvent *kev )
1754{ 1753{
1755 switch(kev->key()) { 1754 switch(kev->key()) {
1756 case Key_PageDown: 1755 case Key_PageDown:
1757 verticalScrollBar()->addPage(); 1756 verticalScrollBar()->addPage();
1758 break; 1757 break;
1759 case Key_PageUp: 1758 case Key_PageUp:
1760 verticalScrollBar()->subtractPage(); 1759 verticalScrollBar()->subtractPage();
1761 break; 1760 break;
1762 case Key_Down: 1761 case Key_Down:
1763 verticalScrollBar()->addLine(); 1762 verticalScrollBar()->addLine();
1764 break; 1763 break;
1765 case Key_Up: 1764 case Key_Up:
1766 verticalScrollBar()->subtractLine(); 1765 verticalScrollBar()->subtractLine();
1767 break; 1766 break;
1768 default: 1767 default:
1769 ; 1768 ;
1770 } 1769 }
1771} 1770}
1772 1771
1773void KOAgenda::calculateWorkingHours() 1772void KOAgenda::calculateWorkingHours()
1774{ 1773{
1775// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 1774// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
1776 mWorkingHoursEnable = !mAllDayMode; 1775 mWorkingHoursEnable = !mAllDayMode;
1777 1776
1778 mWorkingHoursYTop = mGridSpacingY * 1777 mWorkingHoursYTop = mGridSpacingY *
1779 KOPrefs::instance()->mWorkingHoursStart * 4; 1778 KOPrefs::instance()->mWorkingHoursStart * 4;
1780 mWorkingHoursYBottom = mGridSpacingY * 1779 mWorkingHoursYBottom = mGridSpacingY *
1781 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 1780 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
1782} 1781}
1783 1782
1784 1783
1785DateList KOAgenda::dateList() const 1784DateList KOAgenda::dateList() const
1786{ 1785{
1787 return mSelectedDates; 1786 return mSelectedDates;
1788} 1787}
1789 1788
1790void KOAgenda::setDateList(const DateList &selectedDates) 1789void KOAgenda::setDateList(const DateList &selectedDates)
1791{ 1790{
1792 mSelectedDates = selectedDates; 1791 mSelectedDates = selectedDates;
1793 marcus_bains(); 1792 marcus_bains();
1794} 1793}
1795 1794
1796void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 1795void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
1797{ 1796{
1798 mHolidayMask = mask; 1797 mHolidayMask = mask;
1799 1798
1800/* 1799/*
1801 kdDebug() << "HolidayMask: "; 1800 kdDebug() << "HolidayMask: ";
1802 for(uint i=0;i<mask->count();++i) { 1801 for(uint i=0;i<mask->count();++i) {
1803 kdDebug() << (mask->at(i) ? "*" : "o"); 1802 kdDebug() << (mask->at(i) ? "*" : "o");
1804 } 1803 }
1805 kdDebug() << endl; 1804 kdDebug() << endl;
1806*/ 1805*/
1807} 1806}
1808 1807
1809void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 1808void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
1810{ 1809{
1811 1810
1812 QScrollView::contentsMousePressEvent(event); 1811 QScrollView::contentsMousePressEvent(event);
1813} 1812}
1814 1813
1815void KOAgenda::storePosition() 1814void KOAgenda::storePosition()
1816{ 1815{
1817 //mContentPosition 1816 //mContentPosition
1818 int max = mGridSpacingY*4*24; 1817 int max = mGridSpacingY*4*24;
1819 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 1818 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
1820 mContentPosition = 0; 1819 mContentPosition = 0;
1821 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 1820 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
1822 mContentPosition = -1.0; 1821 mContentPosition = -1.0;
1823 else 1822 else
1824 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 1823 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
1825 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 1824 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
1826 1825
1827} 1826}
1828void KOAgenda::restorePosition() 1827void KOAgenda::restorePosition()
1829{ 1828{
1830 int posY; 1829 int posY;
1831 int max = mGridSpacingY*4*24; 1830 int max = mGridSpacingY*4*24;
1832 if ( mContentPosition < 0 ) 1831 if ( mContentPosition < 0 )
1833 posY = max-viewport()->height(); 1832 posY = max-viewport()->height();
1834 else 1833 else
1835 if ( mContentPosition == 0 ) 1834 if ( mContentPosition == 0 )
1836 posY = 0; 1835 posY = 0;
1837 else 1836 else
1838 posY = (max/mContentPosition)-(viewport()->height()/2); 1837 posY = (max/mContentPosition)-(viewport()->height()/2);
1839 setContentsPos (0, posY ); 1838 setContentsPos (0, posY );
1840 //qDebug("posY %d hei %d", posY, max); 1839 //qDebug("posY %d hei %d", posY, max);
1841 1840
1842} 1841}
1843void KOAgenda::moveChild( QWidget *w, int x , int y ) 1842void KOAgenda::moveChild( QWidget *w, int x , int y )
1844{ 1843{
1845 ++x; 1844 ++x;
1846 QScrollView::moveChild( w, x , y ); 1845 QScrollView::moveChild( w, x , y );
1847} 1846}
1848#include <qmessagebox.h> 1847#include <qmessagebox.h>
1849#ifdef DESKTOP_VERSION 1848#ifdef DESKTOP_VERSION
1850#include <qprinter.h> 1849#include <qprinter.h>
1851#include <qpainter.h> 1850#include <qpainter.h>
1852#include <qpaintdevicemetrics.h> 1851#include <qpaintdevicemetrics.h>
1853 1852
1854#endif 1853#endif
1855void KOAgenda::printSelection() 1854void KOAgenda::printSelection()
1856{ 1855{
1857#ifdef DESKTOP_VERSION 1856#ifdef DESKTOP_VERSION
1858 if ( mStartCellY == mCurrentCellY ) { 1857 if ( mStartCellY == mCurrentCellY ) {
1859 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1858 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1860 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 1859 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
1861 i18n("OK"), 0, 0, 1860 i18n("OK"), 0, 0,
1862 0, 1 ); 1861 0, 1 );
1863 return; 1862 return;
1864 } 1863 }
1865 1864
1866 float dx, dy; 1865 float dx, dy;
1867 int x,y,w,h; 1866 int x,y,w,h;
1868 x= 0; 1867 x= 0;
1869 w= contentsWidth()+2; 1868 w= contentsWidth()+2;
1870 // h= contentsHeight(); 1869 // h= contentsHeight();
1871 y = mGridSpacingY*mStartCellY; 1870 y = mGridSpacingY*mStartCellY;
1872 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 1871 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
1873 1872
1874 //return; 1873 //return;
1875 QPrinter* printer = new QPrinter(); 1874 QPrinter* printer = new QPrinter();
1876 if ( !printer->setup()) { 1875 if ( !printer->setup()) {
1877 delete printer; 1876 delete printer;
1878 return; 1877 return;
1879 } 1878 }
1880 QPainter p( printer ); 1879 QPainter p( printer );
1881 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 1880 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
1882 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 1881 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
1883 date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 1882 date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
1884 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 1883 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
1885 // p.drawText( 0, 0, date ); 1884 // p.drawText( 0, 0, date );
1886 int offset = m.width()/8; 1885 int offset = m.width()/8;
1887 // compute the scale 1886 // compute the scale
1888 dx = ((float) m.width()-offset) / (float)w; 1887 dx = ((float) m.width()-offset) / (float)w;
1889 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 1888 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
1890 float scale; 1889 float scale;
1891 // scale to fit the width or height of the paper 1890 // scale to fit the width or height of the paper
1892 if ( dx < dy ) 1891 if ( dx < dy )
1893 scale = dx; 1892 scale = dx;
1894 else 1893 else
1895 scale = dy; 1894 scale = dy;
1896 // set the scale 1895 // set the scale
1897 p.drawText( offset* scale, offset* scale*3/4, date ); 1896 p.drawText( offset* scale, offset* scale*3/4, date );
1898 1897
1899 int selDay; 1898 int selDay;
1900 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 1899 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
1901 float startX = 1; 1900 float startX = 1;
1902 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1901 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1903 { 1902 {
1904 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 1903 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
1905 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); 1904 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) );
1906 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 1905 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
1907 startX += widOffset; 1906 startX += widOffset;
1908 1907
1909 } 1908 }
1910 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 1909 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
1911 p.scale( scale, scale ); 1910 p.scale( scale, scale );
1912 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); 1911 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale );
1913 // now printing with y offset: 2 hei 1912 // now printing with y offset: 2 hei
1914 // p.translate( 0, -y*scale); 1913 // p.translate( 0, -y*scale);
1915 1914
1916 drawContentsToPainter(&p, true ); 1915 drawContentsToPainter(&p, true );
1917 globalFlagBlockAgendaItemUpdate = false; 1916 globalFlagBlockAgendaItemUpdate = false;
1918 KOAgendaItem *item; 1917 KOAgendaItem *item;
1919 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1918 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1920 item->select(false); 1919 item->select(false);
1921 item->paintMe( false, &p ); 1920 item->paintMe( false, &p );
1922 } 1921 }
1923 globalFlagBlockAgendaItemUpdate = true; 1922 globalFlagBlockAgendaItemUpdate = true;
1924 p.end(); 1923 p.end();
1925 delete printer; 1924 delete printer;
1926#else 1925#else
1927 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1926 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1928 i18n("Not supported \non PDA!\n"), 1927 i18n("Not supported \non PDA!\n"),
1929 i18n("OK"), 0, 0, 1928 i18n("OK"), 0, 0,
1930 0, 1 ); 1929 0, 1 );
1931#endif 1930#endif
1932} 1931}
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 02fd33b..a39feb1 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -1,720 +1,720 @@
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 <libkdepim/kincidenceformatter.h> 42#include <libkdepim/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
59KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, 59KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday,
60 const char *name,WFlags) : 60 const char *name,WFlags) :
61 QWidget(parent, name), mIncidence(incidence), mDate(qd) 61 QWidget(parent, name), mIncidence(incidence), mDate(qd)
62{ 62{
63#ifndef DESKTOP_VERSION 63#ifndef DESKTOP_VERSION
64 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 64 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
65#endif 65#endif
66 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase 66 int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase
67 setWFlags ( wflags); 67 setWFlags ( wflags);
68 mAllDay = allday; 68 mAllDay = allday;
69 init ( incidence, qd ); 69 init ( incidence, qd );
70 setMouseTracking(true); 70 setMouseTracking(true);
71 //setAcceptDrops(true); 71 //setAcceptDrops(true);
72 xPaintCoord = -1; 72 xPaintCoord = -1;
73 yPaintCoord = -1; 73 yPaintCoord = -1;
74} 74}
75 75
76void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 76void KOAgendaItem::init ( Incidence *incidence, QDate qd )
77{ 77{
78 mIncidence = incidence; 78 mIncidence = incidence;
79 mDate = qd; 79 mDate = qd;
80 mFirstMultiItem = 0; 80 mFirstMultiItem = 0;
81 mNextMultiItem = 0; 81 mNextMultiItem = 0;
82 mLastMultiItem = 0; 82 mLastMultiItem = 0;
83 computeText(); 83 computeText();
84 84
85 if ( (incidence->type() == "Todo") && 85 if ( (incidence->type() == "Todo") &&
86 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 86 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
87 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 87 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
88 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 88 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
89 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 89 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
90 else 90 else
91 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 91 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
92 } 92 }
93 else { 93 else {
94 QStringList categories = mIncidence->categories(); 94 QStringList categories = mIncidence->categories();
95 QString cat = categories.first(); 95 QString cat = categories.first();
96 if (cat.isEmpty()) { 96 if (cat.isEmpty()) {
97 mBackgroundColor =KOPrefs::instance()->mEventColor; 97 mBackgroundColor =KOPrefs::instance()->mEventColor;
98 } else { 98 } else {
99 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 99 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
100 } 100 }
101 } 101 }
102 mColorGroup = QColorGroup( mBackgroundColor.light(), 102 mColorGroup = QColorGroup( mBackgroundColor.light(),
103 mBackgroundColor.dark(),mBackgroundColor.light(), 103 mBackgroundColor.dark(),mBackgroundColor.light(),
104 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 104 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
105 setBackgroundColor( mBackgroundColor ); 105 setBackgroundColor( mBackgroundColor );
106 106
107 setCellXY(0,0,1); 107 setCellXY(0,0,1);
108 setCellXWidth(0); 108 setCellXWidth(0);
109 setSubCell(0); 109 setSubCell(0);
110 setSubCells(1); 110 setSubCells(1);
111 setMultiItem(0,0,0); 111 setMultiItem(0,0,0);
112 startMove(); 112 startMove();
113 mSelected = true; 113 mSelected = true;
114 select(false); 114 select(false);
115 QString tipText = mIncidence->summary(); 115 QString tipText = mIncidence->summary();
116 // QToolTip::add(this,tipText); 116 // QToolTip::add(this,tipText);
117 QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 117 QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
118 if ( !mIncidence->doesFloat() ) 118 if ( !mIncidence->doesFloat() )
119 if ( mIncidence->type() == "Event" ) { 119 if ( mIncidence->type() == "Event" ) {
120 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 120 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
121 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 121 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
122 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 122 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
123 } 123 }
124 else { 124 else {
125 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 125 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
126 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 126 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
127 } 127 }
128 } 128 }
129 else if ( mIncidence->type() == "Todo" ) { 129 else if ( mIncidence->type() == "Todo" ) {
130 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr(); 130 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr();
131 } 131 }
132 132
133 if (!mIncidence->location().isEmpty()) { 133 if (!mIncidence->location().isEmpty()) {
134 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 134 tipText += "\n"+i18n("Location: ")+mIncidence->location();
135 } 135 }
136 QToolTip::add(this,tipText,toolTipGroup(),""); 136 QToolTip::add(this,tipText,toolTipGroup(),"");
137 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 137 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
138 mFontPixelSize = fontinf.height();; 138 mFontPixelSize = fontinf.height();;
139 hide(); 139 hide();
140 xPaintCoord = -1; 140 xPaintCoord = -1;
141 yPaintCoord = -1; 141 yPaintCoord = -1;
142} 142}
143 143
144 144
145KOAgendaItem::~KOAgendaItem() 145KOAgendaItem::~KOAgendaItem()
146{ 146{
147 // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); 147 // qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
148 148
149} 149}
150 150
151void KOAgendaItem::recreateIncidence() 151void KOAgendaItem::recreateIncidence()
152{ 152{
153 Incidence* newInc = mIncidence->clone(); 153 Incidence* newInc = mIncidence->clone();
154 newInc->recreate(); 154 newInc->recreate();
155 if ( mIncidence->doesRecur() ) { 155 if ( mIncidence->doesRecur() ) {
156 mIncidence->addExDate( mDate ); 156 mIncidence->addExDate( mDate );
157 newInc->recurrence()->unsetRecurs(); 157 newInc->recurrence()->unsetRecurs();
158 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 158 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
159 QTime tim = mIncidence->dtStart().time(); 159 QTime tim = mIncidence->dtStart().time();
160 newInc->setDtStart( QDateTime(mDate, tim) ); 160 newInc->setDtStart( QDateTime(mDate, tim) );
161 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 161 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
162 } 162 }
163 mIncidence = newInc; 163 mIncidence = newInc;
164} 164}
165bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 165bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
166{ 166{
167 int size = AGENDA_ICON_SIZE; 167 int size = AGENDA_ICON_SIZE;
168 168
169 int yOff = 0; 169 int yOff = 0;
170 int xOff = 0; 170 int xOff = 0;
171 int x = pos().x() +3; 171 int x = pos().x() +3;
172 int y; 172 int y;
173 if ( mAllDay ) 173 if ( mAllDay )
174 y = pos().y()+3; 174 y = pos().y()+3;
175 else 175 else
176 y = mCellYTop * ( height() / cellHeight() ) +3; 176 y = mCellYTop * ( height() / cellHeight() ) +3;
177 if (mIncidence->cancelled()) { 177 if (mIncidence->cancelled()) {
178 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 178 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
179 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 179 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
180 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 180 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
181 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 181 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
182 if ( horLayout ) 182 if ( horLayout )
183 ++xOff; 183 ++xOff;
184 else 184 else
185 ++yOff; 185 ++yOff;
186 } 186 }
187 if (mIncidence->isAlarmEnabled()) { 187 if (mIncidence->isAlarmEnabled()) {
188 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 188 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
189 if ( horLayout ) 189 if ( horLayout )
190 ++xOff; 190 ++xOff;
191 else 191 else
192 ++yOff; 192 ++yOff;
193 } 193 }
194 if (mIncidence->recurrence()->doesRecur()) { 194 if (mIncidence->recurrence()->doesRecur()) {
195 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 195 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
196 if ( horLayout ) 196 if ( horLayout )
197 ++xOff; 197 ++xOff;
198 else 198 else
199 ++yOff; 199 ++yOff;
200 } 200 }
201 if (mIncidence->description().length() > 0) { 201 if (mIncidence->description().length() > 0) {
202 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 202 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
203 if ( horLayout ) 203 if ( horLayout )
204 ++xOff; 204 ++xOff;
205 else 205 else
206 ++yOff; 206 ++yOff;
207 } 207 }
208 if (mIncidence->isReadOnly()) { 208 if (mIncidence->isReadOnly()) {
209 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 209 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
210 if ( horLayout ) 210 if ( horLayout )
211 ++xOff; 211 ++xOff;
212 else 212 else
213 ++yOff; 213 ++yOff;
214 } 214 }
215 215
216 if (mIncidence->attendeeCount()>0) { 216 if (mIncidence->attendeeCount()>0) {
217 217
218 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 218 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
219 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 219 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
220 if ( horLayout ) 220 if ( horLayout )
221 ++xOff; 221 ++xOff;
222 else 222 else
223 ++yOff; 223 ++yOff;
224 } else { 224 } else {
225 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 225 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
226 if (me!=0) { 226 if (me!=0) {
227 227
228 228
229 } else { 229 } else {
230 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 230 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
231 if ( horLayout ) 231 if ( horLayout )
232 ++xOff; 232 ++xOff;
233 else 233 else
234 ++yOff; 234 ++yOff;
235 235
236 } 236 }
237 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 237 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
238 if ( horLayout ) 238 if ( horLayout )
239 ++xOff; 239 ++xOff;
240 else 240 else
241 ++yOff; 241 ++yOff;
242 242
243 } 243 }
244 244
245 } 245 }
246 return ( yOff || xOff ); 246 return ( yOff || xOff );
247} 247}
248 248
249 249
250void KOAgendaItem::select(bool selected) 250void KOAgendaItem::select(bool selected)
251{ 251{
252 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 252 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
253 if (mSelected == selected) return; 253 if (mSelected == selected) return;
254 mSelected = selected; 254 mSelected = selected;
255 if ( ! isVisible() ) 255 if ( ! isVisible() )
256 return; 256 return;
257 if ( firstMultiItem() ) 257 if ( firstMultiItem() )
258 firstMultiItem()->select( selected ); 258 firstMultiItem()->select( selected );
259 if ( !firstMultiItem() && nextMultiItem() ) { 259 if ( !firstMultiItem() && nextMultiItem() ) {
260 KOAgendaItem * placeItem = nextMultiItem(); 260 KOAgendaItem * placeItem = nextMultiItem();
261 while ( placeItem ) { 261 while ( placeItem ) {
262 placeItem->select( selected ); 262 placeItem->select( selected );
263 placeItem = placeItem->nextMultiItem(); 263 placeItem = placeItem->nextMultiItem();
264 } 264 }
265 } 265 }
266 globalFlagBlockAgendaItemUpdate = 0; 266 globalFlagBlockAgendaItemUpdate = 0;
267 paintMe( selected ); 267 paintMe( selected );
268 globalFlagBlockAgendaItemUpdate = 1; 268 globalFlagBlockAgendaItemUpdate = 1;
269 repaint( false ); 269 repaint( false );
270} 270}
271 271
272 272
273/* 273/*
274 The eventFilter has to filter the mouse events of the agenda item childs. The 274 The eventFilter has to filter the mouse events of the agenda item childs. The
275 events are fed into the event handling method of KOAgendaItem. This allows the 275 events are fed into the event handling method of KOAgendaItem. This allows the
276 KOAgenda to handle the KOAgendaItems by using an eventFilter. 276 KOAgenda to handle the KOAgendaItems by using an eventFilter.
277*/ 277*/
278bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 278bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
279{ 279{
280 if (e->type() == QEvent::MouseButtonPress || 280 if (e->type() == QEvent::MouseButtonPress ||
281 e->type() == QEvent::MouseButtonDblClick || 281 e->type() == QEvent::MouseButtonDblClick ||
282 e->type() == QEvent::MouseButtonRelease || 282 e->type() == QEvent::MouseButtonRelease ||
283 e->type() == QEvent::MouseMove) { 283 e->type() == QEvent::MouseMove) {
284 QMouseEvent *me = (QMouseEvent *)e; 284 QMouseEvent *me = (QMouseEvent *)e;
285 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 285 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
286 mapToGlobal(me->pos())); 286 mapToGlobal(me->pos()));
287 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 287 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
288 return event(&returnEvent); 288 return event(&returnEvent);
289 } else { 289 } else {
290 return false; 290 return false;
291 } 291 }
292} 292}
293void KOAgendaItem::repaintMe( ) 293void KOAgendaItem::repaintMe( )
294{ 294{
295 paintMe ( mSelected ); 295 paintMe ( mSelected );
296} 296}
297void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 297void KOAgendaItem::paintMe( bool selected, QPainter* paint )
298{ 298{
299 if ( globalFlagBlockAgendaItemUpdate && ! selected) 299 if ( globalFlagBlockAgendaItemUpdate && ! selected)
300 return; 300 return;
301 QPainter pa; 301 QPainter pa;
302 302
303 if ( mSelected ) { 303 if ( mSelected ) {
304 pa.begin( paintPixSel() ); 304 pa.begin( paintPixSel() );
305 } else { 305 } else {
306 if ( mAllDay ) 306 if ( mAllDay )
307 pa.begin( paintPixAllday() ); 307 pa.begin( paintPixAllday() );
308 else 308 else
309 pa.begin( paintPix() ); 309 pa.begin( paintPix() );
310 } 310 }
311 int x, yy, w, h; 311 int x, yy, w, h;
312 float nfh; 312 float nfh;
313 x = pos().x(); w = width(); h = height (); 313 x = pos().x(); w = width(); h = height ();
314 if ( mAllDay ) 314 if ( mAllDay )
315 yy = y(); 315 yy = y();
316 else 316 else
317 yy = mCellYTop * ( height() / cellHeight() ); 317 yy = mCellYTop * ( height() / cellHeight() );
318 xPaintCoord= x; 318 xPaintCoord= x;
319 yPaintCoord = yy; 319 yPaintCoord = yy;
320 wPaintCoord = width(); 320 wPaintCoord = width();
321 hPaintCoord = height(); 321 hPaintCoord = height();
322 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 322 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
323 if ( paint == 0 ) 323 if ( paint == 0 )
324 paint = &pa; 324 paint = &pa;
325 bool horLayout = ( w < h ); 325 bool horLayout = ( w < h );
326 int maxhei = mFontPixelSize+4; 326 int maxhei = mFontPixelSize+4;
327 if ( horLayout ) 327 if ( horLayout )
328 maxhei += AGENDA_ICON_SIZE -4; 328 maxhei += AGENDA_ICON_SIZE -4;
329 bool small = ( h < maxhei ); 329 bool small = ( h < maxhei );
330 if ( ! small ) 330 if ( ! small )
331 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 331 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
332 else { 332 else {
333 QFont f = KOPrefs::instance()->mAgendaViewFont; 333 QFont f = KOPrefs::instance()->mAgendaViewFont;
334 f.setBold( false ); 334 f.setBold( false );
335 int fh = f.pointSize(); 335 int fh = f.pointSize();
336 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 336 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
337 if ( nfh < 6 ) 337 if ( nfh < 6 )
338 nfh = 6; 338 nfh = 6;
339 f.setPointSize( nfh ); 339 f.setPointSize( nfh );
340 paint->setFont(f); 340 paint->setFont(f);
341 } 341 }
342 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 342 paint->fillRect ( x, yy, w, h, mBackgroundColor );
343 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 343 static const QPixmap completedPxmp = SmallIcon("greenhook16");
344 static const QPixmap overduePxmp = SmallIcon("redcross16"); 344 static const QPixmap overduePxmp = SmallIcon("redcross16");
345 if ( mIncidence->type() == "Todo" ) { 345 if ( mIncidence->type() == "Todo" ) {
346 Todo* tempTodo = static_cast<Todo*>(mIncidence); 346 Todo* tempTodo = static_cast<Todo*>(mIncidence);
347 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 347 int xx = pos().x()+(width()-completedPxmp.width()-3 );
348 int yyy = yy+3; 348 int yyy = yy+3;
349 if ( tempTodo->isCompleted() ) 349 if ( tempTodo->isCompleted() )
350 paint->drawPixmap ( xx, yyy, completedPxmp ); 350 paint->drawPixmap ( xx, yyy, completedPxmp );
351 else { 351 else {
352 paint->drawPixmap ( xx, yyy, overduePxmp ); 352 paint->drawPixmap ( xx, yyy, overduePxmp );
353 353
354 } 354 }
355 } 355 }
356 bool addIcon = false; 356 bool addIcon = false;
357 if ( ! small || w > 3 * h || h > 3* w ) 357 if ( ! small || w > 3 * h || h > 3* w )
358 addIcon = updateIcons( paint, horLayout ); 358 addIcon = updateIcons( paint, horLayout );
359 359
360 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 360 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
361 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 361 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
362 if ( ! small ) { 362 if ( ! small ) {
363 x += 3; yy += 3;w -= 6; h-= 5; 363 x += 3; yy += 3;w -= 6; h-= 5;
364 } else { 364 } else {
365 x += 2; yy += 1;w -= 4; h-= 4; 365 x += 2; yy += 1;w -= 4; h-= 4;
366 if ( nfh < 6.01 ) { 366 if ( nfh < 6.01 ) {
367 yy -= 2; 367 yy -= 2;
368 h += 4; 368 h += 4;
369 } 369 }
370 else 370 else
371 if ( nfh < h -2 ) 371 if ( nfh < h -2 )
372 ++yy; 372 ++yy;
373 } 373 }
374 int align; 374 int align;
375#ifndef DESKTOP_VERSION 375#ifndef DESKTOP_VERSION
376 align = ( AlignLeft|WordBreak|AlignTop); 376 align = ( AlignLeft|WordBreak|AlignTop);
377#else 377#else
378 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 378 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
379#endif 379#endif
380 if ( addIcon ) { 380 if ( addIcon ) {
381 if ( ! horLayout ) { 381 if ( ! horLayout ) {
382 x += AGENDA_ICON_SIZE+3; 382 x += AGENDA_ICON_SIZE+3;
383 w -= (AGENDA_ICON_SIZE+3); 383 w -= (AGENDA_ICON_SIZE+3);
384 } 384 }
385 else { 385 else {
386 yy+= AGENDA_ICON_SIZE+2; 386 yy+= AGENDA_ICON_SIZE+2;
387 h -=(AGENDA_ICON_SIZE+3); 387 h -=(AGENDA_ICON_SIZE+3);
388 } 388 }
389 } 389 }
390 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); 390 int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue();
391 if ( colsum < 250 ) 391 if ( colsum < 250 )
392 paint->setPen ( white); 392 paint->setPen ( white);
393 if ( x < 0 ) { 393 if ( x < 0 ) {
394 w = w+x-3; 394 w = w+x-3;
395 x = 3; 395 x = 3;
396 if ( w > parentWidget()->width() ){ 396 if ( w > parentWidget()->width() ){
397 w = parentWidget()->width() - 6; 397 w = parentWidget()->width() - 6;
398#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
399 align = ( AlignCenter|WordBreak); 399 align = ( AlignCenter|WordBreak);
400#else 400#else
401 align = ( AlignCenter|BreakAnywhere|WordBreak); 401 align = ( AlignCenter|BreakAnywhere|WordBreak);
402#endif 402#endif
403 403
404 } 404 }
405 } 405 }
406 QRect dr; 406 QRect dr;
407 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 407 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
408 if ( mIncidence->cancelled() ){ 408 if ( mIncidence->cancelled() ){
409 if ( ! small ) { 409 if ( ! small ) {
410 QFontMetrics fm ( paint->font() ); 410 QFontMetrics fm ( paint->font() );
411 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 411 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
412 } 412 }
413 413
414 } 414 }
415 pa.end(); 415 pa.end();
416 416
417} 417}
418void KOAgendaItem::resizePixmap( int w , int h ) 418void KOAgendaItem::resizePixmap( int w , int h )
419{ 419{
420 paintPix()->resize( w, h ); 420 paintPix()->resize( w, h );
421 paintPixSel()->resize( w, h ); 421 paintPixSel()->resize( w, h );
422 422
423} 423}
424QPixmap * KOAgendaItem::paintPix() 424QPixmap * KOAgendaItem::paintPix()
425{ 425{
426 static QPixmap* mPaintPix = 0; 426 static QPixmap* mPaintPix = 0;
427 if ( ! mPaintPix ) 427 if ( ! mPaintPix )
428 mPaintPix = new QPixmap(); 428 mPaintPix = new QPixmap();
429 return mPaintPix ; 429 return mPaintPix ;
430} 430}
431QPixmap * KOAgendaItem::paintPixAllday() 431QPixmap * KOAgendaItem::paintPixAllday()
432{ 432{
433 static QPixmap* mPaintPixA = 0; 433 static QPixmap* mPaintPixA = 0;
434 if ( ! mPaintPixA ) 434 if ( ! mPaintPixA )
435 mPaintPixA = new QPixmap(); 435 mPaintPixA = new QPixmap();
436 return mPaintPixA ; 436 return mPaintPixA ;
437} 437}
438QPixmap * KOAgendaItem::paintPixSel() 438QPixmap * KOAgendaItem::paintPixSel()
439{ 439{
440 static QPixmap* mPaintPixSel = 0; 440 static QPixmap* mPaintPixSel = 0;
441 if ( ! mPaintPixSel ) 441 if ( ! mPaintPixSel )
442 mPaintPixSel = new QPixmap(); 442 mPaintPixSel = new QPixmap();
443 return mPaintPixSel ; 443 return mPaintPixSel ;
444} 444}
445void KOAgendaItem::paintEvent ( QPaintEvent *e ) 445void KOAgendaItem::paintEvent ( QPaintEvent *e )
446{ 446{
447 447
448 if ( globalFlagBlockAgendaItemPaint ) 448 if ( globalFlagBlockAgendaItemPaint )
449 return; 449 return;
450 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 450 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
451 return; 451 return;
452 int yy; 452 int yy;
453 if ( mAllDay ) 453 if ( mAllDay )
454 yy = y(); 454 yy = y();
455 else 455 else
456 yy = mCellYTop * ( height() / cellHeight() ); 456 yy = mCellYTop * ( height() / cellHeight() );
457 int xx = x(); 457 int xx = x();
458 if ( xPaintCoord != xx || yPaintCoord != yy || 458 if ( xPaintCoord != xx || yPaintCoord != yy ||
459 wPaintCoord != width() || hPaintCoord != height()) { 459 wPaintCoord != width() || hPaintCoord != height()) {
460 xPaintCoord= xx; 460 xPaintCoord= xx;
461 yPaintCoord = yy; 461 yPaintCoord = yy;
462 wPaintCoord = width(); 462 wPaintCoord = width();
463 hPaintCoord = height(); 463 hPaintCoord = height();
464 globalFlagBlockAgendaItemUpdate = 0; 464 globalFlagBlockAgendaItemUpdate = 0;
465 paintMe( mSelected ); 465 paintMe( mSelected );
466 //qDebug("calling paintMe "); 466 //qDebug("calling paintMe ");
467 globalFlagBlockAgendaItemUpdate = 1; 467 globalFlagBlockAgendaItemUpdate = 1;
468 } 468 }
469 int rx, ry, rw, rh; 469 int rx, ry, rw, rh;
470 rx = e->rect().x(); 470 rx = e->rect().x();
471 ry = e->rect().y(); 471 ry = e->rect().y();
472 rw = e->rect().width(); 472 rw = e->rect().width();
473 rh = e->rect().height(); 473 rh = e->rect().height();
474 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 474 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
475 475
476 QPixmap* paintFrom ; 476 QPixmap* paintFrom ;
477 if ( mSelected ) { 477 if ( mSelected ) {
478 paintFrom = paintPixSel(); 478 paintFrom = paintPixSel();
479 } else { 479 } else {
480 if ( mAllDay ) 480 if ( mAllDay )
481 paintFrom = paintPixAllday(); 481 paintFrom = paintPixAllday();
482 else 482 else
483 paintFrom = paintPix(); 483 paintFrom = paintPix();
484 } 484 }
485 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); 485 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP);
486} 486}
487void KOAgendaItem::computeText() 487void KOAgendaItem::computeText()
488{ 488{
489 mDisplayedText = mIncidence->summary(); 489 mDisplayedText = mIncidence->summary();
490 if ( (mIncidence->type() == "Todo") ) { 490 if ( (mIncidence->type() == "Todo") ) {
491 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 491 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
492 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 492 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
493 else if ( !(mIncidence->doesFloat())) 493 else if ( !(mIncidence->doesFloat()))
494 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 494 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
495 495
496 496
497 497
498 } else { 498 } else {
499 if ( !(mIncidence->doesFloat())) 499 if ( !(mIncidence->doesFloat()))
500 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 500 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
501 501
502 if ( mAllDay ) { 502 if ( mAllDay ) {
503 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 503 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
504 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 504 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
505 } 505 }
506 } 506 }
507 507
508 } 508 }
509 509
510 if ( !mIncidence->location().isEmpty() ) { 510 if ( !mIncidence->location().isEmpty() ) {
511 if ( mAllDay ) 511 if ( mAllDay )
512 mDisplayedText += " ("; 512 mDisplayedText += " (";
513 else 513 else
514 mDisplayedText += "\n("; 514 mDisplayedText += "\n(";
515 mDisplayedText += mIncidence->location() +")"; 515 mDisplayedText += mIncidence->location() +")";
516 } 516 }
517} 517}
518void KOAgendaItem::updateItem() 518void KOAgendaItem::updateItem()
519{ 519{
520 computeText(); 520 computeText();
521 521
522 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 522 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
523 paintMe( mSelected ); 523 paintMe( mSelected );
524 repaint( false); 524 repaint( false);
525} 525}
526 526
527void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 527void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
528{ 528{
529 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 529 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
530 paintMe( mSelected ); 530 paintMe( mSelected );
531 repaint( false ); 531 repaint( false );
532} 532}
533 533
534/* 534/*
535 Return height of item in units of agenda cells 535 Return height of item in units of agenda cells
536*/ 536*/
537int KOAgendaItem::cellHeight() 537int KOAgendaItem::cellHeight()
538{ 538{
539 int ret = mCellYBottom - mCellYTop + 1; 539 int ret = mCellYBottom - mCellYTop + 1;
540 if ( ret <= 0 ) { 540 if ( ret <= 0 ) {
541 ret = 1; 541 ret = 1;
542 mCellYBottom = 0; 542 mCellYBottom = 0;
543 mCellYTop = 0; 543 mCellYTop = 0;
544 } 544 }
545 return ret; 545 return ret;
546} 546}
547 547
548/* 548/*
549 Return height of item in units of agenda cells 549 Return height of item in units of agenda cells
550*/ 550*/
551int KOAgendaItem::cellWidth() 551int KOAgendaItem::cellWidth()
552{ 552{
553 return mCellXWidth - mCellX + 1; 553 return mCellXWidth - mCellX + 1;
554} 554}
555 555
556void KOAgendaItem::setItemDate(QDate qd) 556void KOAgendaItem::setItemDate(QDate qd)
557{ 557{
558 mDate = qd; 558 mDate = qd;
559} 559}
560 560
561void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 561void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
562{ 562{
563 mCellX = X; 563 mCellX = X;
564 mCellYTop = YTop; 564 mCellYTop = YTop;
565 mCellYBottom = YBottom; 565 mCellYBottom = YBottom;
566} 566}
567 567
568void KOAgendaItem::setCellXWidth(int xwidth) 568void KOAgendaItem::setCellXWidth(int xwidth)
569{ 569{
570 mCellXWidth = xwidth; 570 mCellXWidth = xwidth;
571} 571}
572 572
573void KOAgendaItem::setCellX(int XLeft, int XRight) 573void KOAgendaItem::setCellX(int XLeft, int XRight)
574{ 574{
575 mCellX = XLeft; 575 mCellX = XLeft;
576 mCellXWidth = XRight; 576 mCellXWidth = XRight;
577} 577}
578 578
579void KOAgendaItem::setCellY(int YTop, int YBottom) 579void KOAgendaItem::setCellY(int YTop, int YBottom)
580{ 580{
581 mCellYTop = YTop; 581 mCellYTop = YTop;
582 mCellYBottom = YBottom; 582 mCellYBottom = YBottom;
583} 583}
584 584
585void KOAgendaItem::setSubCell(int subCell) 585void KOAgendaItem::setSubCell(int subCell)
586{ 586{
587 mSubCell = subCell; 587 mSubCell = subCell;
588} 588}
589 589
590void KOAgendaItem::setSubCells(int subCells) 590void KOAgendaItem::setSubCells(int subCells)
591{ 591{
592 mSubCells = subCells; 592 mSubCells = subCells;
593} 593}
594 594
595void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 595void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
596 KOAgendaItem *last) 596 KOAgendaItem *last)
597{ 597{
598 mFirstMultiItem = first; 598 mFirstMultiItem = first;
599 mNextMultiItem = next; 599 mNextMultiItem = next;
600 mLastMultiItem = last; 600 mLastMultiItem = last;
601} 601}
602 602
603void KOAgendaItem::startMove() 603void KOAgendaItem::startMove()
604{ 604{
605 mStartCellX = mCellX; 605 mStartCellX = mCellX;
606 mStartCellXWidth = mCellXWidth; 606 mStartCellXWidth = mCellXWidth;
607 mStartCellYTop = mCellYTop; 607 mStartCellYTop = mCellYTop;
608 mStartCellYBottom = mCellYBottom; 608 mStartCellYBottom = mCellYBottom;
609} 609}
610 610
611void KOAgendaItem::resetMove() 611void KOAgendaItem::resetMove()
612{ 612{
613 mCellX = mStartCellX; 613 mCellX = mStartCellX;
614 mCellXWidth = mStartCellXWidth; 614 mCellXWidth = mStartCellXWidth;
615 mCellYTop = mStartCellYTop; 615 mCellYTop = mStartCellYTop;
616 mCellYBottom = mStartCellYBottom; 616 mCellYBottom = mStartCellYBottom;
617} 617}
618 618
619void KOAgendaItem::moveRelative(int dx, int dy) 619void KOAgendaItem::moveRelative(int dx, int dy)
620{ 620{
621 int newX = cellX() + dx; 621 int newX = cellX() + dx;
622 int newXWidth = cellXWidth() + dx; 622 int newXWidth = cellXWidth() + dx;
623 int newYTop = cellYTop() + dy; 623 int newYTop = cellYTop() + dy;
624 int newYBottom = cellYBottom() + dy; 624 int newYBottom = cellYBottom() + dy;
625 setCellXY(newX,newYTop,newYBottom); 625 setCellXY(newX,newYTop,newYBottom);
626 setCellXWidth(newXWidth); 626 setCellXWidth(newXWidth);
627} 627}
628 628
629void KOAgendaItem::expandTop(int dy) 629void KOAgendaItem::expandTop(int dy)
630{ 630{
631 int newYTop = cellYTop() + dy; 631 int newYTop = cellYTop() + dy;
632 int newYBottom = cellYBottom(); 632 int newYBottom = cellYBottom();
633 if (newYTop > newYBottom) newYTop = newYBottom; 633 if (newYTop > newYBottom) newYTop = newYBottom;
634 setCellY(newYTop, newYBottom); 634 setCellY(newYTop, newYBottom);
635} 635}
636 636
637void KOAgendaItem::expandBottom(int dy) 637void KOAgendaItem::expandBottom(int dy)
638{ 638{
639 int newYTop = cellYTop(); 639 int newYTop = cellYTop();
640 int newYBottom = cellYBottom() + dy; 640 int newYBottom = cellYBottom() + dy;
641 if (newYBottom < newYTop) newYBottom = newYTop; 641 if (newYBottom < newYTop) newYBottom = newYTop;
642 setCellY(newYTop, newYBottom); 642 setCellY(newYTop, newYBottom);
643} 643}
644 644
645void KOAgendaItem::expandLeft(int dx) 645void KOAgendaItem::expandLeft(int dx)
646{ 646{
647 int newX = cellX() + dx; 647 int newX = cellX() + dx;
648 int newXWidth = cellXWidth(); 648 int newXWidth = cellXWidth();
649 if (newX > newXWidth) newX = newXWidth; 649 if (newX > newXWidth) newX = newXWidth;
650 setCellX(newX,newXWidth); 650 setCellX(newX,newXWidth);
651} 651}
652 652
653void KOAgendaItem::expandRight(int dx) 653void KOAgendaItem::expandRight(int dx)
654{ 654{
655 int newX = cellX(); 655 int newX = cellX();
656 int newXWidth = cellXWidth() + dx; 656 int newXWidth = cellXWidth() + dx;
657 if (newXWidth < newX) newXWidth = newX; 657 if (newXWidth < newX) newXWidth = newX;
658 setCellX(newX,newXWidth); 658 setCellX(newX,newXWidth);
659} 659}
660 660
661QToolTipGroup *KOAgendaItem::toolTipGroup() 661QToolTipGroup *KOAgendaItem::toolTipGroup()
662{ 662{
663 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 663 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
664 return mToolTipGroup; 664 return mToolTipGroup;
665} 665}
666 666
667void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) 667void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e )
668{ 668{
669#ifndef KORG_NODND 669#ifndef KORG_NODND
670 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || 670 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ||
671 !QTextDrag::canDecode( e ) ) { 671 !QTextDrag::canDecode( e ) ) {
672 e->ignore(); 672 e->ignore();
673 return; 673 return;
674 } 674 }
675 e->accept(); 675 e->accept();
676#endif 676#endif
677} 677}
678 678
679void KOAgendaItem::dropEvent( QDropEvent *e ) 679void KOAgendaItem::dropEvent( QDropEvent *e )
680{ 680{
681#ifndef KORG_NODND 681#ifndef KORG_NODND
682 QString text; 682 QString text;
683 if(QTextDrag::decode(e,text)) 683 if(QTextDrag::decode(e,text))
684 { 684 {
685 kdDebug() << "Dropped : " << text << endl; 685 kdDebug() << "Dropped : " << text << endl;
686 QStringList emails = QStringList::split(",",text); 686 QStringList emails = QStringList::split(",",text);
687 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 687 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
688 kdDebug() << " Email: " << (*it) << endl; 688 kdDebug() << " Email: " << (*it) << endl;
689 int pos = (*it).find("<"); 689 int pos = (*it).find("<");
690 QString name = (*it).left(pos); 690 QString name = (*it).left(pos);
691 QString email = (*it).mid(pos); 691 QString email = (*it).mid(pos);
692 if (!email.isEmpty()) { 692 if (!email.isEmpty()) {
693 mIncidence->addAttendee(new Attendee(name,email)); 693 mIncidence->addAttendee(new Attendee(name,email));
694 } 694 }
695 } 695 }
696 } 696 }
697#endif 697#endif
698} 698}
699 699
700 700
701QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() 701QPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
702{ 702{
703 return mConflictItems; 703 return mConflictItems;
704} 704}
705 705
706void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) 706void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci)
707{ 707{
708 mConflictItems = ci; 708 mConflictItems = ci;
709 KOAgendaItem *item; 709 KOAgendaItem *item;
710 for ( item=mConflictItems.first(); item != 0; 710 for ( item=mConflictItems.first(); item != 0;
711 item=mConflictItems.next() ) { 711 item=mConflictItems.next() ) {
712 item->addConflictItem(this); 712 item->addConflictItem(this);
713 } 713 }
714} 714}
715 715
716void KOAgendaItem::addConflictItem(KOAgendaItem *ci) 716void KOAgendaItem::addConflictItem(KOAgendaItem *ci)
717{ 717{
718 if (mConflictItems.find(ci)<0) 718 if (mConflictItems.find(ci)<0)
719 mConflictItems.append(ci); 719 mConflictItems.append(ci);
720} 720}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 9e057e4..77a3164 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1436 +1,1436 @@
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 <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
80 QScrollView(parent,name,f) 80 QScrollView(parent,name,f)
81{ 81{
82 mRows = rows; 82 mRows = rows;
83 83
84 setMinimumHeight( 20 ); 84 setMinimumHeight( 20 );
85 mCellHeight = KOPrefs::instance()->mHourSize*4; 85 mCellHeight = KOPrefs::instance()->mHourSize*4;
86 86
87 enableClipper(true); 87 enableClipper(true);
88 88
89 setHScrollBarMode(AlwaysOff); 89 setHScrollBarMode(AlwaysOff);
90 setVScrollBarMode(AlwaysOff); 90 setVScrollBarMode(AlwaysOff);
91 91
92 resizeContents(50,mRows * mCellHeight); 92 resizeContents(50,mRows * mCellHeight);
93 93
94 viewport()->setBackgroundMode( PaletteBackground ); 94 viewport()->setBackgroundMode( PaletteBackground );
95} 95}
96 96
97void TimeLabels::setCellHeight(int height) 97void TimeLabels::setCellHeight(int height)
98{ 98{
99 mCellHeight = height; 99 mCellHeight = height;
100} 100}
101 101
102/* 102/*
103 Optimization so that only the "dirty" portion of the scroll view 103 Optimization so that only the "dirty" portion of the scroll view
104 is redrawn. Unfortunately, this is not called by default paintEvent() method. 104 is redrawn. Unfortunately, this is not called by default paintEvent() method.
105*/ 105*/
106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
107{ 107{
108 108
109 // if ( globalFlagBlockAgenda ) 109 // if ( globalFlagBlockAgenda )
110 // return; 110 // return;
111 // bug: the parameters cx, cy, cw, ch are the areas that need to be 111 // bug: the parameters cx, cy, cw, ch are the areas that need to be
112 // redrawn, not the area of the widget. unfortunately, this 112 // redrawn, not the area of the widget. unfortunately, this
113 // code assumes the latter... 113 // code assumes the latter...
114 114
115 // now, for a workaround... 115 // now, for a workaround...
116 // these two assignments fix the weird redraw bug 116 // these two assignments fix the weird redraw bug
117 cx = contentsX() + 2; 117 cx = contentsX() + 2;
118 cw = contentsWidth() - 2; 118 cw = contentsWidth() - 2;
119 // end of workaround 119 // end of workaround
120 120
121 int cell = ((int)(cy/mCellHeight)); 121 int cell = ((int)(cy/mCellHeight));
122 int y = cell * mCellHeight; 122 int y = cell * mCellHeight;
123 QFontMetrics fm = fontMetrics(); 123 QFontMetrics fm = fontMetrics();
124 QString hour; 124 QString hour;
125 QString suffix; 125 QString suffix;
126 QString fullTime; 126 QString fullTime;
127 int tW = fm.width("24:00i"); 127 int tW = fm.width("24:00i");
128 128
129 while (y < cy + ch) { 129 while (y < cy + ch) {
130 p->drawLine(cx,y,cx+tW,y); 130 p->drawLine(cx,y,cx+tW,y);
131 hour.setNum(cell); 131 hour.setNum(cell);
132 suffix = "am"; 132 suffix = "am";
133 133
134 // handle 24h and am/pm time formats 134 // handle 24h and am/pm time formats
135 if (KGlobal::locale()->use12Clock()) { 135 if (KGlobal::locale()->use12Clock()) {
136 if (cell > 11) suffix = "pm"; 136 if (cell > 11) suffix = "pm";
137 if (cell == 0) hour.setNum(12); 137 if (cell == 0) hour.setNum(12);
138 if (cell > 12) hour.setNum(cell - 12); 138 if (cell > 12) hour.setNum(cell - 12);
139 } else { 139 } else {
140 suffix = ":00"; 140 suffix = ":00";
141 } 141 }
142 142
143 // create string in format of "XX:XX" or "XXpm/am" 143 // create string in format of "XX:XX" or "XXpm/am"
144 fullTime = hour + suffix; 144 fullTime = hour + suffix;
145 145
146 // center and draw the time label 146 // center and draw the time label
147 int timeWidth = fm.width(fullTime+"i"); 147 int timeWidth = fm.width(fullTime+"i");
148 int offset = this->width() - timeWidth; 148 int offset = this->width() - timeWidth;
149 int borderWidth = 5; 149 int borderWidth = 5;
150 int timeHeight = fm.height(); 150 int timeHeight = fm.height();
151 timeHeight = timeHeight + 2 - ( timeHeight / 4 ); 151 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); 152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
153 153
154 // increment indices 154 // increment indices
155 y += mCellHeight; 155 y += mCellHeight;
156 cell++; 156 cell++;
157 } 157 }
158} 158}
159 159
160/** 160/**
161 Calculates the minimum width. 161 Calculates the minimum width.
162*/ 162*/
163int TimeLabels::minimumWidth() const 163int TimeLabels::minimumWidth() const
164{ 164{
165 QFontMetrics fm = fontMetrics(); 165 QFontMetrics fm = fontMetrics();
166 166
167 //TODO: calculate this value 167 //TODO: calculate this value
168 int borderWidth = 4; 168 int borderWidth = 4;
169 169
170 // the maximum width possible 170 // the maximum width possible
171 int width = fm.width("88:88x") + borderWidth; 171 int width = fm.width("88:88x") + borderWidth;
172 172
173 return width; 173 return width;
174} 174}
175 175
176/** updates widget's internal state */ 176/** updates widget's internal state */
177void TimeLabels::updateConfig() 177void TimeLabels::updateConfig()
178{ 178{
179 // set the font 179 // set the font
180 // config->setGroup("Fonts"); 180 // config->setGroup("Fonts");
181 // QFont font = config->readFontEntry("TimeBar Font"); 181 // QFont font = config->readFontEntry("TimeBar Font");
182 setFont(KOPrefs::instance()->mTimeBarFont); 182 setFont(KOPrefs::instance()->mTimeBarFont);
183 183
184 // update geometry restrictions based on new settings 184 // update geometry restrictions based on new settings
185 setFixedWidth(minimumWidth()); 185 setFixedWidth(minimumWidth());
186 186
187 // update HourSize 187 // update HourSize
188 mCellHeight = KOPrefs::instance()->mHourSize*4; 188 mCellHeight = KOPrefs::instance()->mHourSize*4;
189 resizeContents(50,mRows * mCellHeight); 189 resizeContents(50,mRows * mCellHeight);
190} 190}
191 191
192/** update time label positions */ 192/** update time label positions */
193void TimeLabels::positionChanged() 193void TimeLabels::positionChanged()
194{ 194{
195 int adjustment = mAgenda->contentsY(); 195 int adjustment = mAgenda->contentsY();
196 setContentsPos(0, adjustment); 196 setContentsPos(0, adjustment);
197} 197}
198 198
199/** */ 199/** */
200void TimeLabels::setAgenda(KOAgenda* agenda) 200void TimeLabels::setAgenda(KOAgenda* agenda)
201{ 201{
202 mAgenda = agenda; 202 mAgenda = agenda;
203} 203}
204 204
205 205
206/** This is called in response to repaint() */ 206/** This is called in response to repaint() */
207void TimeLabels::paintEvent(QPaintEvent*) 207void TimeLabels::paintEvent(QPaintEvent*)
208{ 208{
209 209
210 // kdDebug() << "paintevent..." << endl; 210 // kdDebug() << "paintevent..." << endl;
211 // this is another hack! 211 // this is another hack!
212 // QPainter painter(this); 212 // QPainter painter(this);
213 //QString c 213 //QString c
214 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 214 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
215} 215}
216 216
217//////////////////////////////////////////////////////////////////////////// 217////////////////////////////////////////////////////////////////////////////
218 218
219EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 219EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
220 : QFrame(parent,name) 220 : QFrame(parent,name)
221{ 221{
222 mColumns = 1; 222 mColumns = 1;
223 mTopBox = 0; 223 mTopBox = 0;
224 mLocation = loc; 224 mLocation = loc;
225 mTopLayout = 0; 225 mTopLayout = 0;
226 mPaintWidget = 0; 226 mPaintWidget = 0;
227 mXOffset = 0; 227 mXOffset = 0;
228 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 228 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
229 else mPixmap = SmallIcon("1downarrow"); 229 else mPixmap = SmallIcon("1downarrow");
230 mEnabled.resize(mColumns); 230 mEnabled.resize(mColumns);
231 if (mLocation == Top) 231 if (mLocation == Top)
232 setMaximumHeight(0); 232 setMaximumHeight(0);
233 else 233 else
234 setMinimumHeight(mPixmap.height()); 234 setMinimumHeight(mPixmap.height());
235} 235}
236 236
237EventIndicator::~EventIndicator() 237EventIndicator::~EventIndicator()
238{ 238{
239} 239}
240 240
241void EventIndicator::drawContents(QPainter *p) 241void EventIndicator::drawContents(QPainter *p)
242{ 242{
243 243
244 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 244 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
245 KDGanttSplitterHandle* han = 0; 245 KDGanttSplitterHandle* han = 0;
246 if ( mPaintWidget ) 246 if ( mPaintWidget )
247 han = mPaintWidget->firstHandle(); 247 han = mPaintWidget->firstHandle();
248 if ( ! han ) { 248 if ( ! han ) {
249 int i; 249 int i;
250 for(i=0;i<mColumns;++i) { 250 for(i=0;i<mColumns;++i) {
251 if (mEnabled[i]) { 251 if (mEnabled[i]) {
252 int cellWidth = contentsRect().right()/mColumns; 252 int cellWidth = contentsRect().right()/mColumns;
253 int xOffset = KOGlobals::self()->reverseLayout() ? 253 int xOffset = KOGlobals::self()->reverseLayout() ?
254 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 254 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
255 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 255 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
256 p->drawPixmap(QPoint(xOffset,0),mPixmap); 256 p->drawPixmap(QPoint(xOffset,0),mPixmap);
257 } 257 }
258 } 258 }
259 } else { 259 } else {
260 han->repaint(); 260 han->repaint();
261 //mPaintWidget->setBackgroundColor( red ); 261 //mPaintWidget->setBackgroundColor( red );
262 262
263 QPainter pa( han ); 263 QPainter pa( han );
264 int i; 264 int i;
265 bool setColor = false; 265 bool setColor = false;
266 for(i=0;i<mColumns;++i) { 266 for(i=0;i<mColumns;++i) {
267 if (mEnabled[i]) { 267 if (mEnabled[i]) {
268 setColor = true; 268 setColor = true;
269 269
270 int cellWidth = contentsRect().right()/mColumns; 270 int cellWidth = contentsRect().right()/mColumns;
271 int xOffset = KOGlobals::self()->reverseLayout() ? 271 int xOffset = KOGlobals::self()->reverseLayout() ?
272 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 272 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
273 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 273 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
274 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 274 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
275 //qDebug("222draw pix %d ",xOffset ); 275 //qDebug("222draw pix %d ",xOffset );
276 276
277 } 277 }
278 278
279 } 279 }
280 pa.end(); 280 pa.end();
281 281
282 } 282 }
283} 283}
284 284
285void EventIndicator::setXOffset( int x ) 285void EventIndicator::setXOffset( int x )
286{ 286{
287 mXOffset = x; 287 mXOffset = x;
288} 288}
289void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 289void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
290{ 290{
291 mPaintWidget = w; 291 mPaintWidget = w;
292} 292}
293void EventIndicator::changeColumns(int columns) 293void EventIndicator::changeColumns(int columns)
294{ 294{
295 mColumns = columns; 295 mColumns = columns;
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 297
298 update(); 298 update();
299} 299}
300 300
301void EventIndicator::enableColumn(int column, bool enable) 301void EventIndicator::enableColumn(int column, bool enable)
302{ 302{
303 mEnabled[column] = enable; 303 mEnabled[column] = enable;
304} 304}
305 305
306 306
307//////////////////////////////////////////////////////////////////////////// 307////////////////////////////////////////////////////////////////////////////
308//////////////////////////////////////////////////////////////////////////// 308////////////////////////////////////////////////////////////////////////////
309//////////////////////////////////////////////////////////////////////////// 309////////////////////////////////////////////////////////////////////////////
310 310
311KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 311KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
312 KOEventView (cal,parent,name) 312 KOEventView (cal,parent,name)
313{ 313{
314 mBlockUpdating = true; 314 mBlockUpdating = true;
315 mStartHour = 8; 315 mStartHour = 8;
316 mSelectedDates.append(QDate::currentDate()); 316 mSelectedDates.append(QDate::currentDate());
317 317
318 mLayoutDayLabels = 0; 318 mLayoutDayLabels = 0;
319 mDayLabelsFrame = 0; 319 mDayLabelsFrame = 0;
320 mDayLabels = 0; 320 mDayLabels = 0;
321 bool isRTL = KOGlobals::self()->reverseLayout(); 321 bool isRTL = KOGlobals::self()->reverseLayout();
322 322
323 if ( KOPrefs::instance()->mVerticalScreen ) { 323 if ( KOPrefs::instance()->mVerticalScreen ) {
324 mExpandedPixmap = SmallIcon( "1downarrow" ); 324 mExpandedPixmap = SmallIcon( "1downarrow" );
325 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 325 mNotExpandedPixmap = SmallIcon( "1uparrow" );
326 } else { 326 } else {
327 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 327 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
328 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 328 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
329 } 329 }
330 330
331 QBoxLayout *topLayout = new QVBoxLayout(this); 331 QBoxLayout *topLayout = new QVBoxLayout(this);
332 332
333 // Create day name labels for agenda columns 333 // Create day name labels for agenda columns
334 mDayLabelsFrame = new QHBox(this); 334 mDayLabelsFrame = new QHBox(this);
335 topLayout->addWidget(mDayLabelsFrame); 335 topLayout->addWidget(mDayLabelsFrame);
336 mDayLabels = new QFrame (mDayLabelsFrame); 336 mDayLabels = new QFrame (mDayLabelsFrame);
337 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 337 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
338 // Create agenda splitter 338 // Create agenda splitter
339#ifndef KORG_NOSPLITTER 339#ifndef KORG_NOSPLITTER
340 mSplitterAgenda = new QSplitter(Vertical,this); 340 mSplitterAgenda = new QSplitter(Vertical,this);
341 topLayout->addWidget(mSplitterAgenda); 341 topLayout->addWidget(mSplitterAgenda);
342 mSplitterAgenda->setOpaqueResize(); 342 mSplitterAgenda->setOpaqueResize();
343 343
344 mAllDayFrame = new QHBox(mSplitterAgenda); 344 mAllDayFrame = new QHBox(mSplitterAgenda);
345 345
346 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 346 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
347#else 347#else
348#if 0 348#if 0
349 QWidget *mainBox = new QWidget( this ); 349 QWidget *mainBox = new QWidget( this );
350 topLayout->addWidget( mainBox ); 350 topLayout->addWidget( mainBox );
351 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 351 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
352 mAllDayFrame = new QHBox(mainBox); 352 mAllDayFrame = new QHBox(mainBox);
353 mainLayout->addWidget(mAllDayFrame); 353 mainLayout->addWidget(mAllDayFrame);
354 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 354 mainLayout->setStretchFactor( mAllDayFrame, 0 );
355 mAllDayFrame->setFocusPolicy(NoFocus); 355 mAllDayFrame->setFocusPolicy(NoFocus);
356 QWidget *agendaFrame = new QWidget(mainBox); 356 QWidget *agendaFrame = new QWidget(mainBox);
357 mainLayout->addWidget(agendaFrame); 357 mainLayout->addWidget(agendaFrame);
358 mainLayout->setStretchFactor( agendaFrame, 10 ); 358 mainLayout->setStretchFactor( agendaFrame, 10 );
359 359
360 agendaFrame->setFocusPolicy(NoFocus); 360 agendaFrame->setFocusPolicy(NoFocus);
361#endif 361#endif
362 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 362 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
363 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 363 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
364 topLayout->addWidget( mSplitterAgenda ); 364 topLayout->addWidget( mSplitterAgenda );
365 mAllDayFrame = new QHBox(mSplitterAgenda); 365 mAllDayFrame = new QHBox(mSplitterAgenda);
366 mAllDayFrame->setFocusPolicy(NoFocus); 366 mAllDayFrame->setFocusPolicy(NoFocus);
367 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 367 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
368 agendaFrame->setFocusPolicy(NoFocus); 368 agendaFrame->setFocusPolicy(NoFocus);
369 369
370#endif 370#endif
371 371
372 // Create all-day agenda widget 372 // Create all-day agenda widget
373 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 373 mDummyAllDayLeft = new QVBox( mAllDayFrame );
374 374
375 mExpandButton = new QPushButton(mDummyAllDayLeft); 375 mExpandButton = new QPushButton(mDummyAllDayLeft);
376 mExpandButton->setPixmap( mNotExpandedPixmap ); 376 mExpandButton->setPixmap( mNotExpandedPixmap );
377 mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 377 mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
378 QSizePolicy::Fixed ) ); 378 QSizePolicy::Fixed ) );
379 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 379 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
380 mExpandButton->setFocusPolicy(NoFocus); 380 mExpandButton->setFocusPolicy(NoFocus);
381 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 381 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
382 mAllDayAgenda->setFocusPolicy(NoFocus); 382 mAllDayAgenda->setFocusPolicy(NoFocus);
383 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 383 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
384 384
385 // Create event context menu for all day agenda 385 // Create event context menu for all day agenda
386 mAllDayAgendaPopup = eventPopup(); 386 mAllDayAgendaPopup = eventPopup();
387 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 387 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
388 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 388 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
389 389
390 // Create agenda frame 390 // Create agenda frame
391 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 391 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
392 // QHBox *agendaFrame = new QHBox(splitterAgenda); 392 // QHBox *agendaFrame = new QHBox(splitterAgenda);
393 393
394 // create event indicator bars 394 // create event indicator bars
395 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 395 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
396 agendaLayout->addWidget(mEventIndicatorTop,0,1); 396 agendaLayout->addWidget(mEventIndicatorTop,0,1);
397 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 397 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
398 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 398 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
399 agendaFrame); 399 agendaFrame);
400 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 400 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
401 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 401 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
402 agendaLayout->addWidget(dummyAgendaRight,0,2); 402 agendaLayout->addWidget(dummyAgendaRight,0,2);
403 403
404 // Create time labels 404 // Create time labels
405 mTimeLabels = new TimeLabels(24,agendaFrame); 405 mTimeLabels = new TimeLabels(24,agendaFrame);
406 agendaLayout->addWidget(mTimeLabels,1,0); 406 agendaLayout->addWidget(mTimeLabels,1,0);
407 407
408 // Create agenda 408 // Create agenda
409 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 409 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
410 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 410 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
411 agendaLayout->setColStretch(1,1); 411 agendaLayout->setColStretch(1,1);
412 mAgenda->setFocusPolicy(NoFocus); 412 mAgenda->setFocusPolicy(NoFocus);
413 // Create event context menu for agenda 413 // Create event context menu for agenda
414 mAgendaPopup = eventPopup(); 414 mAgendaPopup = eventPopup();
415 415
416 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 416 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
417 i18n("Toggle Alarm"),mAgenda, 417 i18n("Toggle Alarm"),mAgenda,
418 SLOT(popupAlarm()),true); 418 SLOT(popupAlarm()),true);
419 419
420 420
421 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 421 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
422 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 422 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
423 423
424 // make connections between dependent widgets 424 // make connections between dependent widgets
425 mTimeLabels->setAgenda(mAgenda); 425 mTimeLabels->setAgenda(mAgenda);
426 426
427 // Update widgets to reflect user preferences 427 // Update widgets to reflect user preferences
428 // updateConfig(); 428 // updateConfig();
429 429
430 // createDayLabels(); 430 // createDayLabels();
431 431
432 // these blank widgets make the All Day Event box line up with the agenda 432 // these blank widgets make the All Day Event box line up with the agenda
433 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 433 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
434 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 434 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
435 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 435 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
436 436
437 // Scrolling 437 // Scrolling
438 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 438 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
439 mTimeLabels, SLOT(positionChanged())); 439 mTimeLabels, SLOT(positionChanged()));
440 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 440 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
441 SLOT(setContentsPos(int))); 441 SLOT(setContentsPos(int)));
442 442
443 // Create/Show/Edit/Delete Event 443 // Create/Show/Edit/Delete Event
444 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 444 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
445 SLOT(newEvent(int,int))); 445 SLOT(newEvent(int,int)));
446 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 446 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
447 SLOT(newEvent(int,int,int,int))); 447 SLOT(newEvent(int,int,int,int)));
448 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 448 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
449 SLOT(newEventAllDay(int,int))); 449 SLOT(newEventAllDay(int,int)));
450 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 450 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
451 SLOT(newEventAllDay(int,int))); 451 SLOT(newEventAllDay(int,int)));
452 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 452 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
453 SLOT(newTimeSpanSelected(int,int,int,int))); 453 SLOT(newTimeSpanSelected(int,int,int,int)));
454 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 454 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
455 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 455 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
456 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 456 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
457 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 457 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
458 458
459 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 459 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
460 SIGNAL(editIncidenceSignal(Incidence *))); 460 SIGNAL(editIncidenceSignal(Incidence *)));
461 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 461 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
462 SIGNAL(editIncidenceSignal(Incidence *))); 462 SIGNAL(editIncidenceSignal(Incidence *)));
463 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 463 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
464 SIGNAL(showIncidenceSignal(Incidence *))); 464 SIGNAL(showIncidenceSignal(Incidence *)));
465 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 465 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
466 SIGNAL(showIncidenceSignal(Incidence *))); 466 SIGNAL(showIncidenceSignal(Incidence *)));
467 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 467 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
468 SIGNAL(deleteIncidenceSignal(Incidence *))); 468 SIGNAL(deleteIncidenceSignal(Incidence *)));
469 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 469 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
470 SIGNAL(deleteIncidenceSignal(Incidence *))); 470 SIGNAL(deleteIncidenceSignal(Incidence *)));
471 471
472 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 472 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
473 SLOT(updateEventDates(KOAgendaItem *, int ))); 473 SLOT(updateEventDates(KOAgendaItem *, int )));
474 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 474 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
475 SLOT(updateEventDates(KOAgendaItem *, int))); 475 SLOT(updateEventDates(KOAgendaItem *, int)));
476 476
477 // event indicator update 477 // event indicator update
478 connect(mAgenda,SIGNAL(lowerYChanged(int)), 478 connect(mAgenda,SIGNAL(lowerYChanged(int)),
479 SLOT(updateEventIndicatorTop(int))); 479 SLOT(updateEventIndicatorTop(int)));
480 connect(mAgenda,SIGNAL(upperYChanged(int)), 480 connect(mAgenda,SIGNAL(upperYChanged(int)),
481 SLOT(updateEventIndicatorBottom(int))); 481 SLOT(updateEventIndicatorBottom(int)));
482 // drag signals 482 // drag signals
483 /* 483 /*
484 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 484 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
485 SLOT(startDrag(Event *))); 485 SLOT(startDrag(Event *)));
486 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 486 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
487 SLOT(startDrag(Event *))); 487 SLOT(startDrag(Event *)));
488 */ 488 */
489 // synchronize selections 489 // synchronize selections
490 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 490 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
491 mAllDayAgenda, SLOT( deselectItem() ) ); 491 mAllDayAgenda, SLOT( deselectItem() ) );
492 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 492 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
493 mAgenda, SLOT( deselectItem() ) ); 493 mAgenda, SLOT( deselectItem() ) );
494 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 494 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
495 SIGNAL( incidenceSelected( Incidence * ) ) ); 495 SIGNAL( incidenceSelected( Incidence * ) ) );
496 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 496 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
497 SIGNAL( incidenceSelected( Incidence * ) ) ); 497 SIGNAL( incidenceSelected( Incidence * ) ) );
498 connect( mAgenda, SIGNAL( resizedSignal() ), 498 connect( mAgenda, SIGNAL( resizedSignal() ),
499 SLOT( updateConfig( ) ) ); 499 SLOT( updateConfig( ) ) );
500 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 500 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
501 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 501 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
502 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 502 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
503 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 503 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
504 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 504 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
505 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 505 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
506 506
507 507
508} 508}
509 509
510void KOAgendaView::toggleAllDay() 510void KOAgendaView::toggleAllDay()
511{ 511{
512 if ( mSplitterAgenda->firstHandle() ) 512 if ( mSplitterAgenda->firstHandle() )
513 mSplitterAgenda->firstHandle()->toggle(); 513 mSplitterAgenda->firstHandle()->toggle();
514} 514}
515void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 515void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
516{ 516{
517 calendar()->addIncidence( inc ); 517 calendar()->addIncidence( inc );
518 518
519 if ( incOld ) { 519 if ( incOld ) {
520 if ( incOld->type() == "Todo" ) 520 if ( incOld->type() == "Todo" )
521 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 521 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
522 else 522 else
523 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 523 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
524 } 524 }
525 525
526} 526}
527 527
528KOAgendaView::~KOAgendaView() 528KOAgendaView::~KOAgendaView()
529{ 529{
530 delete mAgendaPopup; 530 delete mAgendaPopup;
531 delete mAllDayAgendaPopup; 531 delete mAllDayAgendaPopup;
532 delete KOAgendaItem::paintPix(); 532 delete KOAgendaItem::paintPix();
533 delete KOAgendaItem::paintPixSel(); 533 delete KOAgendaItem::paintPixSel();
534} 534}
535void KOAgendaView::resizeEvent( QResizeEvent* e ) 535void KOAgendaView::resizeEvent( QResizeEvent* e )
536{ 536{
537 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 537 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
538 bool uc = false; 538 bool uc = false;
539 int ow = e->oldSize().width(); 539 int ow = e->oldSize().width();
540 int oh = e->oldSize().height(); 540 int oh = e->oldSize().height();
541 int w = e->size().width(); 541 int w = e->size().width();
542 int h = e->size().height(); 542 int h = e->size().height();
543 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 543 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
544 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 544 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
545 uc = true; 545 uc = true;
546 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 546 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
547 } 547 }
548 mUpcomingWidth = e->size().width() ; 548 mUpcomingWidth = e->size().width() ;
549 if ( mBlockUpdating || uc ) { 549 if ( mBlockUpdating || uc ) {
550 mBlockUpdating = false; 550 mBlockUpdating = false;
551 //mAgenda->setMinimumSize(800 , 600 ); 551 //mAgenda->setMinimumSize(800 , 600 );
552 //qDebug("mAgenda->resize+++++++++++++++ "); 552 //qDebug("mAgenda->resize+++++++++++++++ ");
553 updateConfig(); 553 updateConfig();
554 //qDebug("KOAgendaView::Updating now possible "); 554 //qDebug("KOAgendaView::Updating now possible ");
555 } else 555 } else
556 createDayLabels(); 556 createDayLabels();
557 //qDebug("resizeEvent end "); 557 //qDebug("resizeEvent end ");
558 558
559} 559}
560void KOAgendaView::createDayLabels() 560void KOAgendaView::createDayLabels()
561{ 561{
562 562
563 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 563 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
564 // qDebug(" KOAgendaView::createDayLabels() blocked "); 564 // qDebug(" KOAgendaView::createDayLabels() blocked ");
565 return; 565 return;
566 566
567 } 567 }
568 int newHight; 568 int newHight;
569 569
570 // ### Before deleting and recreating we could check if mSelectedDates changed... 570 // ### Before deleting and recreating we could check if mSelectedDates changed...
571 // It would remove some flickering and gain speed (since this is called by 571 // It would remove some flickering and gain speed (since this is called by
572 // each updateView() call) 572 // each updateView() call)
573 573
574 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 574 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
575 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 575 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
576 if ( maxWid < 0 ) 576 if ( maxWid < 0 )
577 maxWid = 20; 577 maxWid = 20;
578 578
579 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 579 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
580 QFontMetrics fm ( dlf ); 580 QFontMetrics fm ( dlf );
581 int selCount = mSelectedDates.count(); 581 int selCount = mSelectedDates.count();
582 QString dayTest = "Mon 20"; 582 QString dayTest = "Mon 20";
583 int wid = fm.width( dayTest ); 583 int wid = fm.width( dayTest );
584 maxWid -= ( selCount * 3 ); 584 maxWid -= ( selCount * 3 );
585 if ( maxWid < 0 ) 585 if ( maxWid < 0 )
586 maxWid = 20; 586 maxWid = 20;
587 int needWid = wid * selCount; 587 int needWid = wid * selCount;
588 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 588 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
589 //if ( needWid > maxWid ) 589 //if ( needWid > maxWid )
590 // qDebug("DAYLABELS TOOOOOOO BIG "); 590 // qDebug("DAYLABELS TOOOOOOO BIG ");
591 while ( needWid > maxWid ) { 591 while ( needWid > maxWid ) {
592 dayTest = dayTest.left( dayTest.length() - 1 ); 592 dayTest = dayTest.left( dayTest.length() - 1 );
593 wid = fm.width( dayTest ); 593 wid = fm.width( dayTest );
594 needWid = wid * selCount; 594 needWid = wid * selCount;
595 } 595 }
596 int maxLen = dayTest.length(); 596 int maxLen = dayTest.length();
597 int fontPoint = dlf.pointSize(); 597 int fontPoint = dlf.pointSize();
598 if ( maxLen < 2 ) { 598 if ( maxLen < 2 ) {
599 int fontPoint = dlf.pointSize(); 599 int fontPoint = dlf.pointSize();
600 while ( fontPoint > 4 ) { 600 while ( fontPoint > 4 ) {
601 --fontPoint; 601 --fontPoint;
602 dlf.setPointSize( fontPoint ); 602 dlf.setPointSize( fontPoint );
603 QFontMetrics f( dlf ); 603 QFontMetrics f( dlf );
604 wid = f.width( "20" ); 604 wid = f.width( "20" );
605 needWid = wid * selCount; 605 needWid = wid * selCount;
606 if ( needWid < maxWid ) 606 if ( needWid < maxWid )
607 break; 607 break;
608 } 608 }
609 maxLen = 2; 609 maxLen = 2;
610 } 610 }
611 //qDebug("Max len %d ", dayTest.length() ); 611 //qDebug("Max len %d ", dayTest.length() );
612 612
613 QFontMetrics tempF( dlf ); 613 QFontMetrics tempF( dlf );
614 newHight = tempF.height(); 614 newHight = tempF.height();
615 mDayLabels->setFont( dlf ); 615 mDayLabels->setFont( dlf );
616 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 616 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
617 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 617 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
618 //mLayoutDayLabels->addSpacing( 2 ); 618 //mLayoutDayLabels->addSpacing( 2 );
619 // QFont lFont = dlf; 619 // QFont lFont = dlf;
620 bool appendLabels = false; 620 bool appendLabels = false;
621 QLabel *dayLabel; 621 QLabel *dayLabel;
622 dayLabel = mDayLabelsList.first(); 622 dayLabel = mDayLabelsList.first();
623 if ( !dayLabel ) { 623 if ( !dayLabel ) {
624 appendLabels = true; 624 appendLabels = true;
625 dayLabel = new QLabel(mDayLabels); 625 dayLabel = new QLabel(mDayLabels);
626 mDayLabelsList.append( dayLabel ); 626 mDayLabelsList.append( dayLabel );
627 mLayoutDayLabels->addWidget(dayLabel); 627 mLayoutDayLabels->addWidget(dayLabel);
628 } 628 }
629 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 629 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
630 dayLabel->setFont( dlf ); 630 dayLabel->setFont( dlf );
631 dayLabel->setAlignment(QLabel::AlignHCenter); 631 dayLabel->setAlignment(QLabel::AlignHCenter);
632 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 632 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
633 dayLabel->show(); 633 dayLabel->show();
634 DateList::ConstIterator dit; 634 DateList::ConstIterator dit;
635 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 635 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
636 QDate date = *dit; 636 QDate date = *dit;
637 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 637 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
638 if ( ! appendLabels ) { 638 if ( ! appendLabels ) {
639 dayLabel = mDayLabelsList.next(); 639 dayLabel = mDayLabelsList.next();
640 if ( !dayLabel ) 640 if ( !dayLabel )
641 appendLabels = true; 641 appendLabels = true;
642 } 642 }
643 if ( appendLabels ) { 643 if ( appendLabels ) {
644 dayLabel = new QLabel(mDayLabels); 644 dayLabel = new QLabel(mDayLabels);
645 mDayLabelsList.append( dayLabel ); 645 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 646 mLayoutDayLabels->addWidget(dayLabel);
647 } 647 }
648 dayLabel->setMinimumWidth( 1 ); 648 dayLabel->setMinimumWidth( 1 );
649 dayLabel->setMaximumWidth( 2048 ); 649 dayLabel->setMaximumWidth( 2048 );
650 dayLabel->setFont( dlf ); 650 dayLabel->setFont( dlf );
651 dayLabel->show(); 651 dayLabel->show();
652 QString str; 652 QString str;
653 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 653 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
654 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 654 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
655 switch ( maxLen ) { 655 switch ( maxLen ) {
656 case 2: 656 case 2:
657 str = QString::number( date.day() ); 657 str = QString::number( date.day() );
658 break; 658 break;
659 659
660 case 3: 660 case 3:
661 str = dayName.left( 1 ) +QString::number( date.day()); 661 str = dayName.left( 1 ) +QString::number( date.day());
662 662
663 break; 663 break;
664 case 4: 664 case 4:
665 str = dayName.left( 1 ) + " " +QString::number( date.day()); 665 str = dayName.left( 1 ) + " " +QString::number( date.day());
666 666
667 break; 667 break;
668 case 5: 668 case 5:
669 str = dayName.left( 2 ) + " " +QString::number( date.day()); 669 str = dayName.left( 2 ) + " " +QString::number( date.day());
670 670
671 break; 671 break;
672 case 6: 672 case 6:
673 str = dayName.left( 3 ) + " " +QString::number( date.day()); 673 str = dayName.left( 3 ) + " " +QString::number( date.day());
674 break; 674 break;
675 675
676 default: 676 default:
677 break; 677 break;
678 } 678 }
679 679
680 dayLabel->setText(str); 680 dayLabel->setText(str);
681 dayLabel->setAlignment(QLabel::AlignHCenter); 681 dayLabel->setAlignment(QLabel::AlignHCenter);
682 if (date == QDate::currentDate()) { 682 if (date == QDate::currentDate()) {
683 QFont bFont = dlf; 683 QFont bFont = dlf;
684 bFont.setBold( true ); 684 bFont.setBold( true );
685 dayLabel->setFont(bFont); 685 dayLabel->setFont(bFont);
686 } 686 }
687 //dayLayout->addWidget(dayLabel); 687 //dayLayout->addWidget(dayLabel);
688 688
689#ifndef KORG_NOPLUGINS 689#ifndef KORG_NOPLUGINS
690 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 690 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
691 CalendarDecoration *it; 691 CalendarDecoration *it;
692 for(it = cds.first(); it; it = cds.next()) { 692 for(it = cds.first(); it; it = cds.next()) {
693 QString text = it->shortText( date ); 693 QString text = it->shortText( date );
694 if ( !text.isEmpty() ) { 694 if ( !text.isEmpty() ) {
695 QLabel *label = new QLabel(text,mDayLabels); 695 QLabel *label = new QLabel(text,mDayLabels);
696 label->setAlignment(AlignCenter); 696 label->setAlignment(AlignCenter);
697 dayLayout->addWidget(label); 697 dayLayout->addWidget(label);
698 } 698 }
699 } 699 }
700 700
701 for(it = cds.first(); it; it = cds.next()) { 701 for(it = cds.first(); it; it = cds.next()) {
702 QWidget *wid = it->smallWidget(mDayLabels,date); 702 QWidget *wid = it->smallWidget(mDayLabels,date);
703 if ( wid ) { 703 if ( wid ) {
704 // wid->setHeight(20); 704 // wid->setHeight(20);
705 dayLayout->addWidget(wid); 705 dayLayout->addWidget(wid);
706 } 706 }
707 } 707 }
708#endif 708#endif
709 } 709 }
710 if ( ! appendLabels ) { 710 if ( ! appendLabels ) {
711 dayLabel = mDayLabelsList.next(); 711 dayLabel = mDayLabelsList.next();
712 if ( !dayLabel ) 712 if ( !dayLabel )
713 appendLabels = true; 713 appendLabels = true;
714 } 714 }
715 if ( appendLabels ) { 715 if ( appendLabels ) {
716 dayLabel = new QLabel(mDayLabels); 716 dayLabel = new QLabel(mDayLabels);
717 mDayLabelsList.append( dayLabel ); 717 mDayLabelsList.append( dayLabel );
718 mLayoutDayLabels->addWidget(dayLabel); 718 mLayoutDayLabels->addWidget(dayLabel);
719 } 719 }
720 //dayLabel->hide();//test only 720 //dayLabel->hide();//test only
721 721
722 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 722 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
723 if ( offset < 0 ) offset = 0; 723 if ( offset < 0 ) offset = 0;
724 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 724 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
725 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); 725 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) );
726 dayLabel->show(); 726 dayLabel->show();
727 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 727 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
728 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 728 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
729 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 729 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
730 if ( !appendLabels ) { 730 if ( !appendLabels ) {
731 dayLabel = mDayLabelsList.next(); 731 dayLabel = mDayLabelsList.next();
732 while ( dayLabel ) { 732 while ( dayLabel ) {
733 //qDebug("!dayLabel %d",dayLabel ); 733 //qDebug("!dayLabel %d",dayLabel );
734 dayLabel->hide(); 734 dayLabel->hide();
735 dayLabel = mDayLabelsList.next(); 735 dayLabel = mDayLabelsList.next();
736 } 736 }
737 } 737 }
738 //mDayLabelsFrame->show(); 738 //mDayLabelsFrame->show();
739 //mDayLabels->show(); 739 //mDayLabels->show();
740 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 740 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
741 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 741 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
742 mDayLabelsFrame->setFixedHeight( newHight ); 742 mDayLabelsFrame->setFixedHeight( newHight );
743} 743}
744 744
745int KOAgendaView::maxDatesHint() 745int KOAgendaView::maxDatesHint()
746{ 746{
747 // Not sure about the max number of events, so return 0 for now. 747 // Not sure about the max number of events, so return 0 for now.
748 return 0; 748 return 0;
749} 749}
750 750
751int KOAgendaView::currentDateCount() 751int KOAgendaView::currentDateCount()
752{ 752{
753 return mSelectedDates.count(); 753 return mSelectedDates.count();
754} 754}
755 755
756QPtrList<Incidence> KOAgendaView::selectedIncidences() 756QPtrList<Incidence> KOAgendaView::selectedIncidences()
757{ 757{
758 QPtrList<Incidence> selected; 758 QPtrList<Incidence> selected;
759 Incidence *incidence; 759 Incidence *incidence;
760 760
761 incidence = mAgenda->selectedIncidence(); 761 incidence = mAgenda->selectedIncidence();
762 if (incidence) selected.append(incidence); 762 if (incidence) selected.append(incidence);
763 763
764 incidence = mAllDayAgenda->selectedIncidence(); 764 incidence = mAllDayAgenda->selectedIncidence();
765 if (incidence) selected.append(incidence); 765 if (incidence) selected.append(incidence);
766 766
767 return selected; 767 return selected;
768} 768}
769 769
770DateList KOAgendaView::selectedDates() 770DateList KOAgendaView::selectedDates()
771{ 771{
772 DateList selected; 772 DateList selected;
773 QDate qd; 773 QDate qd;
774 774
775 qd = mAgenda->selectedIncidenceDate(); 775 qd = mAgenda->selectedIncidenceDate();
776 if (qd.isValid()) selected.append(qd); 776 if (qd.isValid()) selected.append(qd);
777 777
778 qd = mAllDayAgenda->selectedIncidenceDate(); 778 qd = mAllDayAgenda->selectedIncidenceDate();
779 if (qd.isValid()) selected.append(qd); 779 if (qd.isValid()) selected.append(qd);
780 780
781 return selected; 781 return selected;
782} 782}
783 783
784 784
785void KOAgendaView::updateView() 785void KOAgendaView::updateView()
786{ 786{
787 if ( mBlockUpdating ) 787 if ( mBlockUpdating )
788 return; 788 return;
789 // kdDebug() << "KOAgendaView::updateView()" << endl; 789 // kdDebug() << "KOAgendaView::updateView()" << endl;
790 fillAgenda(); 790 fillAgenda();
791 791
792} 792}
793 793
794 794
795/* 795/*
796 Update configuration settings for the agenda view. This method is not 796 Update configuration settings for the agenda view. This method is not
797 complete. 797 complete.
798*/ 798*/
799void KOAgendaView::updateConfig() 799void KOAgendaView::updateConfig()
800{ 800{
801 if ( mBlockUpdating ) 801 if ( mBlockUpdating )
802 return; 802 return;
803 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 803 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
804 804
805 // update config for children 805 // update config for children
806 mTimeLabels->updateConfig(); 806 mTimeLabels->updateConfig();
807 mAgenda->storePosition(); 807 mAgenda->storePosition();
808 mAgenda->updateConfig(); 808 mAgenda->updateConfig();
809 mAllDayAgenda->updateConfig(); 809 mAllDayAgenda->updateConfig();
810 // widget synchronization 810 // widget synchronization
811 //TODO: find a better way, maybe signal/slot 811 //TODO: find a better way, maybe signal/slot
812 mTimeLabels->positionChanged(); 812 mTimeLabels->positionChanged();
813 813
814 // for some reason, this needs to be called explicitly 814 // for some reason, this needs to be called explicitly
815 mTimeLabels->repaint(); 815 mTimeLabels->repaint();
816 816
817 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 817 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
818 818
819 // ToolTips displaying summary of events 819 // ToolTips displaying summary of events
820 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 820 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
821 ->mEnableToolTips); 821 ->mEnableToolTips);
822 822
823 //setHolidayMasks(); 823 //setHolidayMasks();
824 824
825 //createDayLabels(); called by via updateView(); 825 //createDayLabels(); called by via updateView();
826 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 826 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
827 updateView(); 827 updateView();
828 mAgenda->restorePosition(); 828 mAgenda->restorePosition();
829} 829}
830 830
831 831
832void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 832void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
833{ 833{
834 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 834 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
835 //qDebug("KOAgendaView::updateEventDates "); 835 //qDebug("KOAgendaView::updateEventDates ");
836 QDateTime startDt,endDt; 836 QDateTime startDt,endDt;
837 QDate startDate; 837 QDate startDate;
838 int lenInSecs; 838 int lenInSecs;
839 // if ( type == KOAgenda::RESIZETOP ) 839 // if ( type == KOAgenda::RESIZETOP )
840 // qDebug("RESIZETOP "); 840 // qDebug("RESIZETOP ");
841 // if ( type == KOAgenda::RESIZEBOTTOM ) 841 // if ( type == KOAgenda::RESIZEBOTTOM )
842 // qDebug("RESIZEBOTTOM "); 842 // qDebug("RESIZEBOTTOM ");
843 // if ( type == KOAgenda::MOVE ) 843 // if ( type == KOAgenda::MOVE )
844 // qDebug("MOVE "); 844 // qDebug("MOVE ");
845 if ( item->incidence()->type() == "Event" ) { 845 if ( item->incidence()->type() == "Event" ) {
846 startDt =item->incidence()->dtStart(); 846 startDt =item->incidence()->dtStart();
847 endDt = item->incidence()->dtEnd(); 847 endDt = item->incidence()->dtEnd();
848 lenInSecs = startDt.secsTo( endDt ); 848 lenInSecs = startDt.secsTo( endDt );
849 } 849 }
850 850
851 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 851 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
852 852
853 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 853 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
854 startDate = mSelectedDates[item->mLastMoveXPos]; 854 startDate = mSelectedDates[item->mLastMoveXPos];
855 } else { 855 } else {
856 if (item->cellX() < 0) { 856 if (item->cellX() < 0) {
857 startDate = (mSelectedDates.first()).addDays(item->cellX()); 857 startDate = (mSelectedDates.first()).addDays(item->cellX());
858 } else { 858 } else {
859 startDate = mSelectedDates[item->cellX()]; 859 startDate = mSelectedDates[item->cellX()];
860 } 860 }
861 } 861 }
862 startDt.setDate(startDate); 862 startDt.setDate(startDate);
863 863
864 if (item->incidence()->doesFloat()) { 864 if (item->incidence()->doesFloat()) {
865 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 865 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
866 } else { 866 } else {
867 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 867 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
868 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 868 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
869 if ( item->incidence()->type() == "Event" ) { 869 if ( item->incidence()->type() == "Event" ) {
870 if ( type == KOAgenda::MOVE ) { 870 if ( type == KOAgenda::MOVE ) {
871 endDt = startDt.addSecs(lenInSecs); 871 endDt = startDt.addSecs(lenInSecs);
872 872
873 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 873 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
874 if (item->lastMultiItem()) { 874 if (item->lastMultiItem()) {
875 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 875 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
876 endDt.setDate(startDate. 876 endDt.setDate(startDate.
877 addDays(item->lastMultiItem()->cellX() - item->cellX())); 877 addDays(item->lastMultiItem()->cellX() - item->cellX()));
878 } else { 878 } else {
879 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 879 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
880 endDt.setDate(startDate); 880 endDt.setDate(startDate);
881 } 881 }
882 } 882 }
883 } else { 883 } else {
884 // todo 884 // todo
885 if (item->lastMultiItem()) { 885 if (item->lastMultiItem()) {
886 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 886 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
887 endDt.setDate(startDate. 887 endDt.setDate(startDate.
888 addDays(item->lastMultiItem()->cellX() - item->cellX())); 888 addDays(item->lastMultiItem()->cellX() - item->cellX()));
889 } else { 889 } else {
890 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 890 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
891 if ( item->cellYBottom() > 0 ) 891 if ( item->cellYBottom() > 0 )
892 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 892 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
893 else 893 else
894 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 894 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
895 endDt.setDate(startDate); 895 endDt.setDate(startDate);
896 } 896 }
897 } 897 }
898 } 898 }
899 899
900 900
901 if ( item->incidence()->type() == "Event" ) { 901 if ( item->incidence()->type() == "Event" ) {
902 item->incidence()->setDtStart(startDt); 902 item->incidence()->setDtStart(startDt);
903 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 903 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
904 } else if ( item->incidence()->type() == "Todo" ) { 904 } else if ( item->incidence()->type() == "Todo" ) {
905 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 905 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
906 } 906 }
907 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 907 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
908 item->incidence()->setRevision(item->incidence()->revision()+1); 908 item->incidence()->setRevision(item->incidence()->revision()+1);
909 item->setItemDate(startDt.date()); 909 item->setItemDate(startDt.date());
910 //item->updateItem(); 910 //item->updateItem();
911 if ( item->incidence()->type() == "Todo" ) { 911 if ( item->incidence()->type() == "Todo" ) {
912 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 912 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
913 913
914 } 914 }
915 else 915 else
916 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 916 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
917 item->updateItem(); 917 item->updateItem();
918} 918}
919 919
920void KOAgendaView::showDates( const QDate &start, const QDate &end ) 920void KOAgendaView::showDates( const QDate &start, const QDate &end )
921{ 921{
922 // kdDebug() << "KOAgendaView::selectDates" << endl; 922 // kdDebug() << "KOAgendaView::selectDates" << endl;
923 923
924 mSelectedDates.clear(); 924 mSelectedDates.clear();
925 // qDebug("KOAgendaView::showDates "); 925 // qDebug("KOAgendaView::showDates ");
926 QDate d = start; 926 QDate d = start;
927 while (d <= end) { 927 while (d <= end) {
928 mSelectedDates.append(d); 928 mSelectedDates.append(d);
929 d = d.addDays( 1 ); 929 d = d.addDays( 1 );
930 } 930 }
931 931
932 // and update the view 932 // and update the view
933 fillAgenda(); 933 fillAgenda();
934} 934}
935 935
936 936
937void KOAgendaView::showEvents(QPtrList<Event>) 937void KOAgendaView::showEvents(QPtrList<Event>)
938{ 938{
939 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 939 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
940} 940}
941 941
942void KOAgendaView::changeEventDisplay(Event *, int) 942void KOAgendaView::changeEventDisplay(Event *, int)
943{ 943{
944 // qDebug("KOAgendaView::changeEventDisplay "); 944 // qDebug("KOAgendaView::changeEventDisplay ");
945 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 945 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
946 // this should be re-written to be MUCH smarter. Right now we 946 // this should be re-written to be MUCH smarter. Right now we
947 // are just playing dumb. 947 // are just playing dumb.
948 fillAgenda(); 948 fillAgenda();
949} 949}
950 950
951void KOAgendaView::fillAgenda(const QDate &) 951void KOAgendaView::fillAgenda(const QDate &)
952{ 952{
953 // qDebug("KOAgendaView::fillAgenda "); 953 // qDebug("KOAgendaView::fillAgenda ");
954 fillAgenda(); 954 fillAgenda();
955} 955}
956 956
957void KOAgendaView::fillAgenda() 957void KOAgendaView::fillAgenda()
958{ 958{
959 if ( globalFlagBlockStartup ) 959 if ( globalFlagBlockStartup )
960 return; 960 return;
961 if ( globalFlagBlockAgenda == 1 ) 961 if ( globalFlagBlockAgenda == 1 )
962 return; 962 return;
963 //if ( globalFlagBlockAgenda == 2 ) 963 //if ( globalFlagBlockAgenda == 2 )
964 //globalFlagBlockAgenda = 0; 964 //globalFlagBlockAgenda = 0;
965 // globalFlagBlockPainting = false; 965 // globalFlagBlockPainting = false;
966 if ( globalFlagBlockAgenda == 0 ) 966 if ( globalFlagBlockAgenda == 0 )
967 globalFlagBlockAgenda = 1; 967 globalFlagBlockAgenda = 1;
968 // clearView(); 968 // clearView();
969 //qDebug("fillAgenda()++++ "); 969 //qDebug("fillAgenda()++++ ");
970 globalFlagBlockAgendaItemPaint = 1; 970 globalFlagBlockAgendaItemPaint = 1;
971 mAllDayAgenda->changeColumns(mSelectedDates.count()); 971 mAllDayAgenda->changeColumns(mSelectedDates.count());
972 mAgenda->changeColumns(mSelectedDates.count()); 972 mAgenda->changeColumns(mSelectedDates.count());
973 qApp->processEvents(); 973 qApp->processEvents();
974 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 974 mEventIndicatorTop->changeColumns(mSelectedDates.count());
975 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 975 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
976 setHolidayMasks(); 976 setHolidayMasks();
977 977
978 //mAgenda->hideUnused(); 978 //mAgenda->hideUnused();
979 //mAllDayAgenda->hideUnused(); 979 //mAllDayAgenda->hideUnused();
980 980
981 // mAgenda->blockNextRepaint( false ); 981 // mAgenda->blockNextRepaint( false );
982 // mAgenda->viewport()->repaint(); 982 // mAgenda->viewport()->repaint();
983 // mAgenda->blockNextRepaint( true ); 983 // mAgenda->blockNextRepaint( true );
984 mMinY.resize(mSelectedDates.count()); 984 mMinY.resize(mSelectedDates.count());
985 mMaxY.resize(mSelectedDates.count()); 985 mMaxY.resize(mSelectedDates.count());
986 986
987 QPtrList<Event> dayEvents; 987 QPtrList<Event> dayEvents;
988 988
989 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 989 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
990 // Therefore, get all of them. 990 // Therefore, get all of them.
991 QPtrList<Todo> todos = calendar()->todos(); 991 QPtrList<Todo> todos = calendar()->todos();
992 992
993 mAgenda->setDateList(mSelectedDates); 993 mAgenda->setDateList(mSelectedDates);
994 994
995 QDate today = QDate::currentDate(); 995 QDate today = QDate::currentDate();
996 996
997 DateList::ConstIterator dit; 997 DateList::ConstIterator dit;
998 int curCol = 0; 998 int curCol = 0;
999 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 999 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1000 QDate currentDate = *dit; 1000 QDate currentDate = *dit;
1001 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1001 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1002 // << endl; 1002 // << endl;
1003 1003
1004 dayEvents = calendar()->events(currentDate,true); 1004 dayEvents = calendar()->events(currentDate,true);
1005 1005
1006 // Default values, which can never be reached 1006 // Default values, which can never be reached
1007 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1007 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1008 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1008 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1009 1009
1010 unsigned int numEvent; 1010 unsigned int numEvent;
1011 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1011 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1012 Event *event = dayEvents.at(numEvent); 1012 Event *event = dayEvents.at(numEvent);
1013 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(21) == QString("last-syncEvent-device") ) 1013 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(21) == QString("last-syncEvent-device") )
1014 continue; 1014 continue;
1015 // kdDebug() << " Event: " << event->summary() << endl; 1015 // kdDebug() << " Event: " << event->summary() << endl;
1016 1016
1017 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1017 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1018 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1018 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1019 1019
1020 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1020 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1021 1021
1022 if (event->doesFloat()) { 1022 if (event->doesFloat()) {
1023 if (event->recurrence()->doesRecur()) { 1023 if (event->recurrence()->doesRecur()) {
1024 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1024 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1025 } else { 1025 } else {
1026 if (beginX <= 0 && curCol == 0) { 1026 if (beginX <= 0 && curCol == 0) {
1027 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1027 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1028 } else if (beginX == curCol) { 1028 } else if (beginX == curCol) {
1029 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1029 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1030 } 1030 }
1031 } 1031 }
1032 } else if (event->isMultiDay()) { 1032 } else if (event->isMultiDay()) {
1033 if ( event->doesRecur () ) { 1033 if ( event->doesRecur () ) {
1034 QDate dateit = currentDate; 1034 QDate dateit = currentDate;
1035 int count = 0; 1035 int count = 0;
1036 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1036 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1037 while (! event->recursOn( dateit ) && count <= max ) { 1037 while (! event->recursOn( dateit ) && count <= max ) {
1038 ++count; 1038 ++count;
1039 dateit = dateit.addDays( -1 ); 1039 dateit = dateit.addDays( -1 );
1040 } 1040 }
1041 bool ok; 1041 bool ok;
1042 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1042 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1043 if ( ok ) 1043 if ( ok )
1044 { 1044 {
1045 int secs = event->dtStart().secsTo( event->dtEnd() ); 1045 int secs = event->dtStart().secsTo( event->dtEnd() );
1046 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1046 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1047 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1047 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1048 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1048 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1049 1049
1050 } 1050 }
1051 } 1051 }
1052 int startY = mAgenda->timeToY(event->dtStart().time()); 1052 int startY = mAgenda->timeToY(event->dtStart().time());
1053 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1053 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1054 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1054 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1055 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1055 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1056 //qDebug("insert!!! "); 1056 //qDebug("insert!!! ");
1057 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1057 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1058 } 1058 }
1059 if (beginX == curCol) { 1059 if (beginX == curCol) {
1060 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1060 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1061 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1061 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1062 } else if (endX == curCol) { 1062 } else if (endX == curCol) {
1063 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1063 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1064 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1064 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1065 } else { 1065 } else {
1066 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1066 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1068 } 1068 }
1069 } else { 1069 } else {
1070 int startY = mAgenda->timeToY(event->dtStart().time()); 1070 int startY = mAgenda->timeToY(event->dtStart().time());
1071 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1071 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1072 if (endY < startY) endY = startY; 1072 if (endY < startY) endY = startY;
1073 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1073 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1074 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1074 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1075 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1075 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1076 } 1076 }
1077 } 1077 }
1078 // ---------- [display Todos -------------- 1078 // ---------- [display Todos --------------
1079 unsigned int numTodo; 1079 unsigned int numTodo;
1080 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1080 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1081 Todo *todo = todos.at(numTodo); 1081 Todo *todo = todos.at(numTodo);
1082 1082
1083 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1083 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1084 1084
1085 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1085 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1086 // Already completed items can be displayed on their original due date 1086 // Already completed items can be displayed on their original due date
1087 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1087 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1088 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1088 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1089 1089
1090 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1090 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1091 ((currentDate == today) && overdue) ) { 1091 ((currentDate == today) && overdue) ) {
1092 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1092 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1093 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1093 if ( KOPrefs::instance()->mShowTodoInAgenda )
1094 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1094 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1095 } 1095 }
1096 else { 1096 else {
1097 1097
1098 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1098 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1099 int hi = (18/KOPrefs::instance()->mHourSize); 1099 int hi = (18/KOPrefs::instance()->mHourSize);
1100 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1100 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1101 int startY = endY -hi; 1101 int startY = endY -hi;
1102 1102
1103 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1103 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1104 1104
1105 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1105 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1106 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1106 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1107 } 1107 }
1108 } 1108 }
1109 } 1109 }
1110 // ---------- display Todos] -------------- 1110 // ---------- display Todos] --------------
1111 1111
1112 ++curCol; 1112 ++curCol;
1113 } 1113 }
1114 mAgenda->hideUnused(); 1114 mAgenda->hideUnused();
1115 mAllDayAgenda->hideUnused(); 1115 mAllDayAgenda->hideUnused();
1116 mAgenda->checkScrollBoundaries(); 1116 mAgenda->checkScrollBoundaries();
1117 1117
1118 deleteSelectedDateTime(); 1118 deleteSelectedDateTime();
1119 1119
1120 createDayLabels(); 1120 createDayLabels();
1121 emit incidenceSelected( 0 ); 1121 emit incidenceSelected( 0 );
1122 1122
1123 if ( globalFlagBlockAgenda == 2 ) { 1123 if ( globalFlagBlockAgenda == 2 ) {
1124 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1124 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1125 setStartHour( KOPrefs::instance()->mDayBegins ); 1125 setStartHour( KOPrefs::instance()->mDayBegins );
1126 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1126 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1127 setStartHour( QTime::currentTime ().hour() ); 1127 setStartHour( QTime::currentTime ().hour() );
1128 // qApp->processEvents(); 1128 // qApp->processEvents();
1129 } 1129 }
1130 qApp->processEvents(); 1130 qApp->processEvents();
1131 //qDebug("qApp->processEvents(); END "); 1131 //qDebug("qApp->processEvents(); END ");
1132 globalFlagBlockAgenda = 0; 1132 globalFlagBlockAgenda = 0;
1133 1133
1134 // mAgenda->hideUnused(); 1134 // mAgenda->hideUnused();
1135 //mAllDayAgenda->hideUnused(); 1135 //mAllDayAgenda->hideUnused();
1136 mAllDayAgenda->drawContentsToPainter(); 1136 mAllDayAgenda->drawContentsToPainter();
1137 mAgenda->drawContentsToPainter(); 1137 mAgenda->drawContentsToPainter();
1138 repaintAgenda(); 1138 repaintAgenda();
1139 // mAgenda->finishUpdate(); 1139 // mAgenda->finishUpdate();
1140 //mAllDayAgenda->finishUpdate(); 1140 //mAllDayAgenda->finishUpdate();
1141 1141
1142 // repaintAgenda(); 1142 // repaintAgenda();
1143 //qApp->processEvents(); 1143 //qApp->processEvents();
1144 // globalFlagBlockAgenda = 0; 1144 // globalFlagBlockAgenda = 0;
1145} 1145}
1146void KOAgendaView::repaintAgenda() 1146void KOAgendaView::repaintAgenda()
1147{ 1147{
1148 // mAllDayAgenda->drawContentsToPainter(); 1148 // mAllDayAgenda->drawContentsToPainter();
1149// mAllDayAgenda->viewport()->repaint( false ); 1149// mAllDayAgenda->viewport()->repaint( false );
1150// mAgenda->drawContentsToPainter(); 1150// mAgenda->drawContentsToPainter();
1151// mAgenda->viewport()->repaint( false ); 1151// mAgenda->viewport()->repaint( false );
1152// qApp->processEvents(); 1152// qApp->processEvents();
1153 1153
1154 //qDebug("KOAgendaView::repaintAgenda() "); 1154 //qDebug("KOAgendaView::repaintAgenda() ");
1155 //qApp->processEvents(); 1155 //qApp->processEvents();
1156 mAgenda->viewport()->repaint( false ); 1156 mAgenda->viewport()->repaint( false );
1157 mAllDayAgenda->viewport()->repaint( false ); 1157 mAllDayAgenda->viewport()->repaint( false );
1158 mAgenda->finishUpdate(); 1158 mAgenda->finishUpdate();
1159 mAllDayAgenda->finishUpdate(); 1159 mAllDayAgenda->finishUpdate();
1160} 1160}
1161 1161
1162 1162
1163void KOAgendaView::clearView() 1163void KOAgendaView::clearView()
1164{ 1164{
1165 // kdDebug() << "ClearView" << endl; 1165 // kdDebug() << "ClearView" << endl;
1166 mAllDayAgenda->clear(); 1166 mAllDayAgenda->clear();
1167 mAgenda->clear(); 1167 mAgenda->clear();
1168} 1168}
1169 1169
1170void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1170void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1171 const QDate &td) 1171 const QDate &td)
1172{ 1172{
1173#ifndef KORG_NOPRINTER 1173#ifndef KORG_NOPRINTER
1174 if (fd == td) 1174 if (fd == td)
1175 calPrinter->preview(CalPrinter::Day, fd, td); 1175 calPrinter->preview(CalPrinter::Day, fd, td);
1176 else 1176 else
1177 calPrinter->preview(CalPrinter::Week, fd, td); 1177 calPrinter->preview(CalPrinter::Week, fd, td);
1178#endif 1178#endif
1179} 1179}
1180 1180
1181// void KOAgendaView::updateMovedTodo() 1181// void KOAgendaView::updateMovedTodo()
1182// { 1182// {
1183// // updateConfig(); 1183// // updateConfig();
1184// // emit updateTodoViews(); 1184// // emit updateTodoViews();
1185// } 1185// }
1186 1186
1187void KOAgendaView::newEvent(int gx, int gy) 1187void KOAgendaView::newEvent(int gx, int gy)
1188{ 1188{
1189 if (!mSelectedDates.count()) return; 1189 if (!mSelectedDates.count()) return;
1190 1190
1191 QDate day = mSelectedDates[gx]; 1191 QDate day = mSelectedDates[gx];
1192 1192
1193 QTime time = mAgenda->gyToTime(gy); 1193 QTime time = mAgenda->gyToTime(gy);
1194 QDateTime dt(day,time); 1194 QDateTime dt(day,time);
1195 // if ( dt < QDateTime::currentDateTime () ) 1195 // if ( dt < QDateTime::currentDateTime () )
1196 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1196 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1197 emit newEventSignal(dt); 1197 emit newEventSignal(dt);
1198} 1198}
1199 1199
1200void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1200void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1201{ 1201{
1202 if (!mSelectedDates.count()) return; 1202 if (!mSelectedDates.count()) return;
1203 1203
1204 QDate dayStart = mSelectedDates[gxStart]; 1204 QDate dayStart = mSelectedDates[gxStart];
1205 QDate dayEnd = mSelectedDates[gxEnd]; 1205 QDate dayEnd = mSelectedDates[gxEnd];
1206 1206
1207 QTime timeStart = mAgenda->gyToTime(gyStart); 1207 QTime timeStart = mAgenda->gyToTime(gyStart);
1208 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1208 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1209 1209
1210 QDateTime dtStart(dayStart,timeStart); 1210 QDateTime dtStart(dayStart,timeStart);
1211 QDateTime dtEnd(dayEnd,timeEnd); 1211 QDateTime dtEnd(dayEnd,timeEnd);
1212 1212
1213 emit newEventSignal(dtStart,dtEnd); 1213 emit newEventSignal(dtStart,dtEnd);
1214} 1214}
1215 1215
1216void KOAgendaView::newEventAllDay(int gx, int ) 1216void KOAgendaView::newEventAllDay(int gx, int )
1217{ 1217{
1218 if (!mSelectedDates.count()) return; 1218 if (!mSelectedDates.count()) return;
1219 1219
1220 QDate day = mSelectedDates[gx]; 1220 QDate day = mSelectedDates[gx];
1221 1221
1222 emit newEventSignal(day); 1222 emit newEventSignal(day);
1223} 1223}
1224 1224
1225void KOAgendaView::updateEventIndicatorTop(int newY) 1225void KOAgendaView::updateEventIndicatorTop(int newY)
1226{ 1226{
1227 uint i; 1227 uint i;
1228 for(i=0;i<mMinY.size();++i) { 1228 for(i=0;i<mMinY.size();++i) {
1229 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1229 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1230 else mEventIndicatorTop->enableColumn(i,false); 1230 else mEventIndicatorTop->enableColumn(i,false);
1231 } 1231 }
1232 1232
1233 mEventIndicatorTop->update(); 1233 mEventIndicatorTop->update();
1234} 1234}
1235 1235
1236void KOAgendaView::updateEventIndicatorBottom(int newY) 1236void KOAgendaView::updateEventIndicatorBottom(int newY)
1237{ 1237{
1238 uint i; 1238 uint i;
1239 for(i=0;i<mMaxY.size();++i) { 1239 for(i=0;i<mMaxY.size();++i) {
1240 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1240 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1241 else mEventIndicatorBottom->enableColumn(i,false); 1241 else mEventIndicatorBottom->enableColumn(i,false);
1242 } 1242 }
1243 1243
1244 mEventIndicatorBottom->update(); 1244 mEventIndicatorBottom->update();
1245} 1245}
1246 1246
1247void KOAgendaView::startDrag(Event *event) 1247void KOAgendaView::startDrag(Event *event)
1248{ 1248{
1249#ifndef KORG_NODND 1249#ifndef KORG_NODND
1250 DndFactory factory( calendar() ); 1250 DndFactory factory( calendar() );
1251 ICalDrag *vd = factory.createDrag(event,this); 1251 ICalDrag *vd = factory.createDrag(event,this);
1252 if (vd->drag()) { 1252 if (vd->drag()) {
1253 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1253 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1254 } 1254 }
1255#endif 1255#endif
1256} 1256}
1257 1257
1258void KOAgendaView::readSettings() 1258void KOAgendaView::readSettings()
1259{ 1259{
1260 readSettings(KOGlobals::config()); 1260 readSettings(KOGlobals::config());
1261} 1261}
1262 1262
1263void KOAgendaView::readSettings(KConfig *config) 1263void KOAgendaView::readSettings(KConfig *config)
1264{ 1264{
1265 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1265 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1266 1266
1267 config->setGroup("Views"); 1267 config->setGroup("Views");
1268 1268
1269 //#ifndef KORG_NOSPLITTER 1269 //#ifndef KORG_NOSPLITTER
1270 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1270 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1271 if (sizes.count() == 2) { 1271 if (sizes.count() == 2) {
1272 if ( sizes[0] < 20 ) { 1272 if ( sizes[0] < 20 ) {
1273 sizes[1] = sizes[1] +20 - sizes[0]; 1273 sizes[1] = sizes[1] +20 - sizes[0];
1274 sizes[0] = 20; 1274 sizes[0] = 20;
1275 } 1275 }
1276 mSplitterAgenda->setSizes(sizes); 1276 mSplitterAgenda->setSizes(sizes);
1277 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1277 // qDebug("read %d %d ",sizes[0],sizes[1] );
1278 } 1278 }
1279 //#endif 1279 //#endif
1280 1280
1281 // updateConfig(); 1281 // updateConfig();
1282} 1282}
1283 1283
1284void KOAgendaView::writeSettings(KConfig *config) 1284void KOAgendaView::writeSettings(KConfig *config)
1285{ 1285{
1286 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1286 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1287 1287
1288 config->setGroup("Views"); 1288 config->setGroup("Views");
1289 1289
1290 //#ifndef KORG_NOSPLITTER 1290 //#ifndef KORG_NOSPLITTER
1291 QValueList<int> list = mSplitterAgenda->sizes(); 1291 QValueList<int> list = mSplitterAgenda->sizes();
1292 config->writeEntry("Separator AgendaView",list); 1292 config->writeEntry("Separator AgendaView",list);
1293 //qDebug("write %d %d ", list[0],list[1] ); 1293 //qDebug("write %d %d ", list[0],list[1] );
1294 //#endif 1294 //#endif
1295} 1295}
1296 1296
1297void KOAgendaView::setHolidayMasks() 1297void KOAgendaView::setHolidayMasks()
1298{ 1298{
1299 mHolidayMask.resize(mSelectedDates.count()); 1299 mHolidayMask.resize(mSelectedDates.count());
1300 1300
1301 uint i; 1301 uint i;
1302 for(i=0;i<mSelectedDates.count();++i) { 1302 for(i=0;i<mSelectedDates.count();++i) {
1303 QDate date = mSelectedDates[i]; 1303 QDate date = mSelectedDates[i];
1304 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1304 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1305 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1305 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1306#ifndef KORG_NOPLUGINS 1306#ifndef KORG_NOPLUGINS
1307 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1307 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1308 !KOCore::self()->holiday(date).isEmpty(); 1308 !KOCore::self()->holiday(date).isEmpty();
1309 bool showDay = showSaturday || showSunday || showHoliday; 1309 bool showDay = showSaturday || showSunday || showHoliday;
1310#else 1310#else
1311 bool showDay = showSaturday || showSunday; 1311 bool showDay = showSaturday || showSunday;
1312#endif 1312#endif
1313 if (showDay) { 1313 if (showDay) {
1314 mHolidayMask.at(i) = true; 1314 mHolidayMask.at(i) = true;
1315 } else { 1315 } else {
1316 mHolidayMask.at(i) = false; 1316 mHolidayMask.at(i) = false;
1317 } 1317 }
1318 } 1318 }
1319 1319
1320 mAgenda->setHolidayMask(&mHolidayMask); 1320 mAgenda->setHolidayMask(&mHolidayMask);
1321 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1321 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1322} 1322}
1323 1323
1324void KOAgendaView::setContentsPos(int y) 1324void KOAgendaView::setContentsPos(int y)
1325{ 1325{
1326 mAgenda->setContentsPos(0,y); 1326 mAgenda->setContentsPos(0,y);
1327} 1327}
1328 1328
1329void KOAgendaView::setExpandedButton( bool expanded ) 1329void KOAgendaView::setExpandedButton( bool expanded )
1330{ 1330{
1331 if ( expanded ) { 1331 if ( expanded ) {
1332 mExpandButton->setPixmap( mExpandedPixmap ); 1332 mExpandButton->setPixmap( mExpandedPixmap );
1333 } else { 1333 } else {
1334 mExpandButton->setPixmap( mNotExpandedPixmap ); 1334 mExpandButton->setPixmap( mNotExpandedPixmap );
1335 } 1335 }
1336} 1336}
1337 1337
1338void KOAgendaView::clearSelection() 1338void KOAgendaView::clearSelection()
1339{ 1339{
1340 mAgenda->deselectItem(); 1340 mAgenda->deselectItem();
1341 mAllDayAgenda->deselectItem(); 1341 mAllDayAgenda->deselectItem();
1342} 1342}
1343 1343
1344void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1344void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1345 int gxEnd, int gyEnd) 1345 int gxEnd, int gyEnd)
1346{ 1346{
1347 mTimeSpanInAllDay = true; 1347 mTimeSpanInAllDay = true;
1348 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1348 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1349} 1349}
1350 1350
1351 1351
1352 1352
1353 1353
1354void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1354void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1355 int gxEnd, int gyEnd) 1355 int gxEnd, int gyEnd)
1356{ 1356{
1357 if (!mSelectedDates.count()) return; 1357 if (!mSelectedDates.count()) return;
1358 1358
1359 QDate dayStart = mSelectedDates[gxStart]; 1359 QDate dayStart = mSelectedDates[gxStart];
1360 QDate dayEnd = mSelectedDates[gxEnd]; 1360 QDate dayEnd = mSelectedDates[gxEnd];
1361 1361
1362 QTime timeStart = mAgenda->gyToTime(gyStart); 1362 QTime timeStart = mAgenda->gyToTime(gyStart);
1363 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1363 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1364 1364
1365 QDateTime dtStart(dayStart,timeStart); 1365 QDateTime dtStart(dayStart,timeStart);
1366 QDateTime dtEnd(dayEnd,timeEnd); 1366 QDateTime dtEnd(dayEnd,timeEnd);
1367 1367
1368 mTimeSpanBegin = dtStart; 1368 mTimeSpanBegin = dtStart;
1369 mTimeSpanEnd = dtEnd; 1369 mTimeSpanEnd = dtEnd;
1370 1370
1371} 1371}
1372 1372
1373void KOAgendaView::deleteSelectedDateTime() 1373void KOAgendaView::deleteSelectedDateTime()
1374{ 1374{
1375 mTimeSpanBegin.setDate(QDate()); 1375 mTimeSpanBegin.setDate(QDate());
1376 mTimeSpanEnd.setDate(QDate()); 1376 mTimeSpanEnd.setDate(QDate());
1377 mTimeSpanInAllDay = false; 1377 mTimeSpanInAllDay = false;
1378} 1378}
1379 1379
1380void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1380void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1381{ 1381{
1382 e->ignore(); 1382 e->ignore();
1383} 1383}
1384 1384
1385void KOAgendaView::scrollOneHourUp() 1385void KOAgendaView::scrollOneHourUp()
1386{ 1386{
1387 1387
1388 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1388 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1389} 1389}
1390void KOAgendaView::scrollOneHourDown() 1390void KOAgendaView::scrollOneHourDown()
1391{ 1391{
1392 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1392 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1393} 1393}
1394 1394
1395void KOAgendaView::setStartHour( int h ) 1395void KOAgendaView::setStartHour( int h )
1396{ 1396{
1397 mAgenda->setStartHour( h ); 1397 mAgenda->setStartHour( h );
1398 1398
1399} 1399}
1400 1400
1401void KOAgendaView::updateTodo( Todo * t, int ) 1401void KOAgendaView::updateTodo( Todo * t, int )
1402{ 1402{
1403 1403
1404 bool remove = false; 1404 bool remove = false;
1405 bool removeAD = false; 1405 bool removeAD = false;
1406 if ( ! t->hasDueDate() ) { 1406 if ( ! t->hasDueDate() ) {
1407 remove = true; 1407 remove = true;
1408 removeAD = true; 1408 removeAD = true;
1409 } 1409 }
1410 else { 1410 else {
1411 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1411 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1412 if ( overdue && 1412 if ( overdue &&
1413 QDate::currentDate() >= mSelectedDates.first() && 1413 QDate::currentDate() >= mSelectedDates.first() &&
1414 QDate::currentDate() <= mSelectedDates.last()) { 1414 QDate::currentDate() <= mSelectedDates.last()) {
1415 removeAD = false; 1415 removeAD = false;
1416 remove = true; 1416 remove = true;
1417 } 1417 }
1418 else { 1418 else {
1419 if ( t->dtDue().date() < mSelectedDates.first() || 1419 if ( t->dtDue().date() < mSelectedDates.first() ||
1420 t->dtDue().date() > mSelectedDates.last() ) { 1420 t->dtDue().date() > mSelectedDates.last() ) {
1421 remove = true; 1421 remove = true;
1422 removeAD = true; 1422 removeAD = true;
1423 } else { 1423 } else {
1424 remove = t->doesFloat(); 1424 remove = t->doesFloat();
1425 removeAD = !remove; 1425 removeAD = !remove;
1426 } 1426 }
1427 } 1427 }
1428 } 1428 }
1429 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1429 int days = mSelectedDates.first().daysTo( t->dtDue().date() );
1430 // qDebug("daysto %d ", days ); 1430 // qDebug("daysto %d ", days );
1431 mAgenda->updateTodo( t , days, remove); 1431 mAgenda->updateTodo( t , days, remove);
1432 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1432 if ( KOPrefs::instance()->mShowTodoInAgenda )
1433 mAllDayAgenda->updateTodo( t , days, removeAD); 1433 mAllDayAgenda->updateTodo( t , days, removeAD);
1434 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1434 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1435 1435
1436} 1436}
diff --git a/korganizer/kocounterdialog.cpp b/korganizer/kocounterdialog.cpp
index 8a9ae44..82a7072 100644
--- a/korganizer/kocounterdialog.cpp
+++ b/korganizer/kocounterdialog.cpp
@@ -1,66 +1,66 @@
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 20
21#include <klocale.h> 21#include <klocale.h>
22 22
23#include <libkcal/event.h> 23#include <libkcal/event.h>
24#include "koeventviewer.h" 24#include "koeventviewer.h"
25 25
26#include "kocounterdialog.h" 26#include "kocounterdialog.h"
27#include "kocounterdialog.moc" 27//#include "kocounterdialog.moc"
28 28
29KOCounterDialog::KOCounterDialog(QWidget *parent,const char *name) 29KOCounterDialog::KOCounterDialog(QWidget *parent,const char *name)
30 : KDialogBase(parent,name,false,i18n("Counter-event Viewer"),User1|User2,User1, 30 : KDialogBase(parent,name,false,i18n("Counter-event Viewer"),User1|User2,User1,
31 false,i18n("Decline"),i18n("Accept")) 31 false,i18n("Decline"),i18n("Accept"))
32{ 32{
33 mEventViewer = new KOEventViewer(this); 33 mEventViewer = new KOEventViewer(this);
34 setMainWidget(mEventViewer); 34 setMainWidget(mEventViewer);
35 35
36 connect(this,SIGNAL(user1Clicked()),this,SLOT(slotCancel())); 36 connect(this,SIGNAL(user1Clicked()),this,SLOT(slotCancel()));
37 connect(this,SIGNAL(user2Clicked()),this,SLOT(slotOk())); 37 connect(this,SIGNAL(user2Clicked()),this,SLOT(slotOk()));
38 38
39 // TODO: Set a sensible size (based on the content?). 39 // TODO: Set a sensible size (based on the content?).
40 setMinimumSize(300,200); 40 setMinimumSize(300,200);
41 resize(320,300); 41 resize(320,300);
42} 42}
43 43
44KOCounterDialog::~KOCounterDialog() 44KOCounterDialog::~KOCounterDialog()
45{ 45{
46} 46}
47 47
48void KOCounterDialog::setEvent(Event *event) 48void KOCounterDialog::setEvent(Event *event)
49{ 49{
50 mEventViewer->setEvent(event); 50 mEventViewer->setEvent(event);
51} 51}
52 52
53void KOCounterDialog::addEvent(Event *event) 53void KOCounterDialog::addEvent(Event *event)
54{ 54{
55 mEventViewer->addEvent(event); 55 mEventViewer->addEvent(event);
56} 56}
57 57
58void KOCounterDialog::setTodo(Todo *event) 58void KOCounterDialog::setTodo(Todo *event)
59{ 59{
60 mEventViewer->setTodo(event); 60 mEventViewer->setTodo(event);
61} 61}
62 62
63void KOCounterDialog::addText(QString text) 63void KOCounterDialog::addText(QString text)
64{ 64{
65 mEventViewer->addText(text); 65 mEventViewer->addText(text);
66} 66}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 779d67c..fc00828 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,597 +1,596 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source 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 <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28 28
29#include <kglobal.h> 29#include <kglobal.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <klocale.h> 31#include <klocale.h>
32 32
33#include <libkcal/vcaldrag.h> 33#include <libkcal/vcaldrag.h>
34#include <libkcal/icaldrag.h> 34#include <libkcal/icaldrag.h>
35#include <libkcal/dndfactory.h> 35#include <libkcal/dndfactory.h>
36#include <libkcal/calendarresources.h> 36#include <libkcal/calendarresources.h>
37#include <libkcal/resourcecalendar.h> 37#include <libkcal/resourcecalendar.h>
38#include <kresources/resourceselectdialog.h> 38#include <kresources/resourceselectdialog.h>
39 39
40#include <kcalendarsystem.h> 40#include <kcalendarsystem.h>
41 41
42#ifndef KORG_NOPLUGINS 42#ifndef KORG_NOPLUGINS
43#include "kocore.h" 43#include "kocore.h"
44#endif 44#endif
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "kodaymatrix.h" 48#include "kodaymatrix.h"
49#include "kodaymatrix.moc"
50 49
51// ============================================================================ 50// ============================================================================
52// D Y N A M I C T I P 51// D Y N A M I C T I P
53// ============================================================================ 52// ============================================================================
54 53
55DynamicTip::DynamicTip( QWidget * parent ) 54DynamicTip::DynamicTip( QWidget * parent )
56 : QToolTip( parent ) 55 : QToolTip( parent )
57{ 56{
58 matrix = (KODayMatrix*)parent; 57 matrix = (KODayMatrix*)parent;
59} 58}
60 59
61 60
62void DynamicTip::maybeTip( const QPoint &pos ) 61void DynamicTip::maybeTip( const QPoint &pos )
63{ 62{
64 //calculate which cell of the matrix the mouse is in 63 //calculate which cell of the matrix the mouse is in
65 QRect sz = matrix->frameRect(); 64 QRect sz = matrix->frameRect();
66 int dheight = sz.height()*7 / 42; 65 int dheight = sz.height()*7 / 42;
67 int dwidth = sz.width() / 7; 66 int dwidth = sz.width() / 7;
68 int row = pos.y()/dheight; 67 int row = pos.y()/dheight;
69 int col = pos.x()/dwidth; 68 int col = pos.x()/dwidth;
70 69
71 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 70 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
72 71
73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 72// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
74// col << "][" << row << "] => " <<(col+row*7) << endl; 73// col << "][" << row << "] => " <<(col+row*7) << endl;
75 74
76 //show holiday names only 75 //show holiday names only
77 QString str = matrix->getHolidayLabel(col+row*7); 76 QString str = matrix->getHolidayLabel(col+row*7);
78 if (str.isEmpty()) return; 77 if (str.isEmpty()) return;
79 tip(rct, str); 78 tip(rct, str);
80} 79}
81 80
82 81
83// ============================================================================ 82// ============================================================================
84// K O D A Y M A T R I X 83// K O D A Y M A T R I X
85// ============================================================================ 84// ============================================================================
86 85
87const int KODayMatrix::NOSELECTION = -1000; 86const int KODayMatrix::NOSELECTION = -1000;
88const int KODayMatrix::NUMDAYS = 42; 87const int KODayMatrix::NUMDAYS = 42;
89 88
90KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 89KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
91 QFrame(parent, name) 90 QFrame(parent, name)
92{ 91{
93 mCalendar = calendar; 92 mCalendar = calendar;
94 93
95 // initialize dynamic arrays 94 // initialize dynamic arrays
96 days = new QDate[NUMDAYS]; 95 days = new QDate[NUMDAYS];
97 daylbls = new QString[NUMDAYS]; 96 daylbls = new QString[NUMDAYS];
98 events = new int[NUMDAYS]; 97 events = new int[NUMDAYS];
99 mToolTip = new DynamicTip(this); 98 mToolTip = new DynamicTip(this);
100 99
101 // set default values used for drawing the matrix 100 // set default values used for drawing the matrix
102 mDefaultBackColor = palette().active().base(); 101 mDefaultBackColor = palette().active().base();
103 mDefaultTextColor = palette().active().foreground(); 102 mDefaultTextColor = palette().active().foreground();
104 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 103 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
105 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 104 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
106 mSelectedDaysColor = QColor("white"); 105 mSelectedDaysColor = QColor("white");
107 mTodayMarginWidth = 2; 106 mTodayMarginWidth = 2;
108 mSelEnd = mSelStart = NOSELECTION; 107 mSelEnd = mSelStart = NOSELECTION;
109 108
110 setAcceptDrops(true); 109 setAcceptDrops(true);
111 //setFont( QFont("Arial", 10) ); 110 //setFont( QFont("Arial", 10) );
112 updateView(date); 111 updateView(date);
113} 112}
114 113
115QColor KODayMatrix::getShadedColor(QColor color) 114QColor KODayMatrix::getShadedColor(QColor color)
116{ 115{
117 QColor shaded; 116 QColor shaded;
118 int h=0; 117 int h=0;
119 int s=0; 118 int s=0;
120 int v=0; 119 int v=0;
121 color.hsv(&h,&s,&v); 120 color.hsv(&h,&s,&v);
122 s = s/4; 121 s = s/4;
123 v = 192+v/4; 122 v = 192+v/4;
124 shaded.setHsv(h,s,v); 123 shaded.setHsv(h,s,v);
125 124
126 return shaded; 125 return shaded;
127} 126}
128 127
129KODayMatrix::~KODayMatrix() 128KODayMatrix::~KODayMatrix()
130{ 129{
131 delete [] days; 130 delete [] days;
132 delete [] daylbls; 131 delete [] daylbls;
133 delete [] events; 132 delete [] events;
134 delete mToolTip; 133 delete mToolTip;
135} 134}
136 135
137/* 136/*
138void KODayMatrix::setStartDate(QDate start) 137void KODayMatrix::setStartDate(QDate start)
139{ 138{
140 updateView(start); 139 updateView(start);
141} 140}
142*/ 141*/
143 142
144void KODayMatrix::addSelectedDaysTo(DateList& selDays) 143void KODayMatrix::addSelectedDaysTo(DateList& selDays)
145{ 144{
146 kdDebug() << "KODayMatrix::addSelectedDaysTo() - " << "mSelStart:" << mSelStart << endl; 145 kdDebug() << "KODayMatrix::addSelectedDaysTo() - " << "mSelStart:" << mSelStart << endl;
147 146
148 if (mSelStart == NOSELECTION) { 147 if (mSelStart == NOSELECTION) {
149 return; 148 return;
150 } 149 }
151 150
152 //cope with selection being out of matrix limits at top (< 0) 151 //cope with selection being out of matrix limits at top (< 0)
153 int i0 = mSelStart; 152 int i0 = mSelStart;
154 if (i0 < 0) { 153 if (i0 < 0) {
155 for (int i = i0; i < 0; i++) { 154 for (int i = i0; i < 0; i++) {
156 selDays.append(days[0].addDays(i)); 155 selDays.append(days[0].addDays(i));
157 } 156 }
158 i0 = 0; 157 i0 = 0;
159 } 158 }
160 159
161 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 160 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
162 if (mSelEnd > NUMDAYS-1) { 161 if (mSelEnd > NUMDAYS-1) {
163 for (int i = i0; i <= NUMDAYS-1; i++) { 162 for (int i = i0; i <= NUMDAYS-1; i++) {
164 selDays.append(days[i]); 163 selDays.append(days[i]);
165 } 164 }
166 for (int i = NUMDAYS; i < mSelEnd; i++) { 165 for (int i = NUMDAYS; i < mSelEnd; i++) {
167 selDays.append(days[0].addDays(i)); 166 selDays.append(days[0].addDays(i));
168 } 167 }
169 168
170 // apply normal routine to selection being entirely within matrix limits 169 // apply normal routine to selection being entirely within matrix limits
171 } else { 170 } else {
172 for (int i = i0; i <= mSelEnd; i++) { 171 for (int i = i0; i <= mSelEnd; i++) {
173 selDays.append(days[i]); 172 selDays.append(days[i]);
174 } 173 }
175 } 174 }
176} 175}
177 176
178void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 177void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
179{ 178{
180 mSelStart = startdate.daysTo(start); 179 mSelStart = startdate.daysTo(start);
181 mSelEnd = startdate.daysTo(end); 180 mSelEnd = startdate.daysTo(end);
182} 181}
183 182
184 183
185void KODayMatrix::recalculateToday() 184void KODayMatrix::recalculateToday()
186{ 185{
187 today = -1; 186 today = -1;
188 for (int i=0; i<NUMDAYS; i++) { 187 for (int i=0; i<NUMDAYS; i++) {
189 days[i] = startdate.addDays(i); 188 days[i] = startdate.addDays(i);
190 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 189 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
191 190
192 // if today is in the currently displayed month, hilight today 191 // if today is in the currently displayed month, hilight today
193 if (days[i].year() == QDate::currentDate().year() && 192 if (days[i].year() == QDate::currentDate().year() &&
194 days[i].month() == QDate::currentDate().month() && 193 days[i].month() == QDate::currentDate().month() &&
195 days[i].day() == QDate::currentDate().day()) { 194 days[i].day() == QDate::currentDate().day()) {
196 today = i; 195 today = i;
197 } 196 }
198 } 197 }
199 // qDebug(QString("Today is visible at %1.").arg(today)); 198 // qDebug(QString("Today is visible at %1.").arg(today));
200} 199}
201 200
202void KODayMatrix::updateView() 201void KODayMatrix::updateView()
203{ 202{
204 updateView(startdate); 203 updateView(startdate);
205} 204}
206 205
207void KODayMatrix::updateView(QDate actdate) 206void KODayMatrix::updateView(QDate actdate)
208{ 207{
209 208
210// kdDebug() << "KODayMatrix::updateView() " << actdate.toString() << endl; 209// kdDebug() << "KODayMatrix::updateView() " << actdate.toString() << endl;
211 210
212 //flag to indicate if the starting day of the matrix has changed by this call 211 //flag to indicate if the starting day of the matrix has changed by this call
213 bool daychanged = false; 212 bool daychanged = false;
214 // if a new startdate is to be set then apply Cornelius's calculation 213 // if a new startdate is to be set then apply Cornelius's calculation
215 // of the first day to be shown 214 // of the first day to be shown
216 if (actdate != startdate) { 215 if (actdate != startdate) {
217 // reset index of selection according to shift of starting date from startdate to actdate 216 // reset index of selection according to shift of starting date from startdate to actdate
218 if (mSelStart != NOSELECTION) { 217 if (mSelStart != NOSELECTION) {
219 int tmp = actdate.daysTo(startdate); 218 int tmp = actdate.daysTo(startdate);
220 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 219 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
221 // shift selection if new one would be visible at least partly ! 220 // shift selection if new one would be visible at least partly !
222 221
223 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 222 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
224 // nested if is required for next X display pushed from a different month - correction required 223 // nested if is required for next X display pushed from a different month - correction required
225 // otherwise, for month forward and backward, it must be avoided 224 // otherwise, for month forward and backward, it must be avoided
226 if( mSelStart > NUMDAYS || mSelStart < 0 ) 225 if( mSelStart > NUMDAYS || mSelStart < 0 )
227 mSelStart = mSelStart + tmp; 226 mSelStart = mSelStart + tmp;
228 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 227 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
229 mSelEnd = mSelEnd + tmp; 228 mSelEnd = mSelEnd + tmp;
230 } 229 }
231 } 230 }
232 231
233 startdate = actdate; 232 startdate = actdate;
234 daychanged = true; 233 daychanged = true;
235 } 234 }
236 235
237 if (daychanged) { 236 if (daychanged) {
238 recalculateToday(); 237 recalculateToday();
239 } 238 }
240 239
241 for(int i = 0; i < NUMDAYS; i++) { 240 for(int i = 0; i < NUMDAYS; i++) {
242 241
243 // if events are set for the day then remember to draw it bold 242 // if events are set for the day then remember to draw it bold
244 QPtrList<Event> eventlist = mCalendar->events(days[i]); 243 QPtrList<Event> eventlist = mCalendar->events(days[i]);
245 Event *event; 244 Event *event;
246 int numEvents = eventlist.count(); 245 int numEvents = eventlist.count();
247 246
248 for(event=eventlist.first();event != 0;event=eventlist.next()) { 247 for(event=eventlist.first();event != 0;event=eventlist.next()) {
249 ushort recurType = event->recurrence()->doesRecur(); 248 ushort recurType = event->recurrence()->doesRecur();
250 249
251 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 250 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
252 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 251 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
253 numEvents--; 252 numEvents--;
254 } 253 }
255 } 254 }
256 events[i] = numEvents; 255 events[i] = numEvents;
257 256
258 //if it is a holy day then draw it red. Sundays are consider holidays, too 257 //if it is a holy day then draw it red. Sundays are consider holidays, too
259#ifndef KORG_NOPLUGINS 258#ifndef KORG_NOPLUGINS
260 QString holiStr = KOCore::self()->holiday(days[i]); 259 QString holiStr = KOCore::self()->holiday(days[i]);
261#else 260#else
262 QString holiStr = QString::null; 261 QString holiStr = QString::null;
263#endif 262#endif
264 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 263 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
265 !holiStr.isEmpty()) { 264 !holiStr.isEmpty()) {
266 if (holiStr.isNull()) holiStr = ""; 265 if (holiStr.isNull()) holiStr = "";
267 mHolidays[i] = holiStr; 266 mHolidays[i] = holiStr;
268 267
269 } else { 268 } else {
270 mHolidays[i] = QString::null; 269 mHolidays[i] = QString::null;
271 } 270 }
272 } 271 }
273} 272}
274 273
275const QDate& KODayMatrix::getDate(int offset) 274const QDate& KODayMatrix::getDate(int offset)
276{ 275{
277 if (offset < 0 || offset > NUMDAYS-1) { 276 if (offset < 0 || offset > NUMDAYS-1) {
278 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getDate(int)" << endl; 277 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getDate(int)" << endl;
279 return days[0]; 278 return days[0];
280 } 279 }
281 return days[offset]; 280 return days[offset];
282} 281}
283 282
284QString KODayMatrix::getHolidayLabel(int offset) 283QString KODayMatrix::getHolidayLabel(int offset)
285{ 284{
286 if (offset < 0 || offset > NUMDAYS-1) { 285 if (offset < 0 || offset > NUMDAYS-1) {
287 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getHolidayLabel(int)" << endl; 286 kdDebug() << "Wrong offset (" << offset << ") in KODayMatrix::getHolidayLabel(int)" << endl;
288 return 0; 287 return 0;
289 } 288 }
290 return mHolidays[offset]; 289 return mHolidays[offset];
291} 290}
292 291
293int KODayMatrix::getDayIndexFrom(int x, int y) 292int KODayMatrix::getDayIndexFrom(int x, int y)
294{ 293{
295 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 294 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
296 6 - x/daysize.width() : x/daysize.width()); 295 6 - x/daysize.width() : x/daysize.width());
297} 296}
298 297
299// ---------------------------------------------------------------------------- 298// ----------------------------------------------------------------------------
300// M O U S E E V E N T H A N D L I N G 299// M O U S E E V E N T H A N D L I N G
301// ---------------------------------------------------------------------------- 300// ----------------------------------------------------------------------------
302 301
303void KODayMatrix::mousePressEvent (QMouseEvent* e) 302void KODayMatrix::mousePressEvent (QMouseEvent* e)
304{ 303{
305 mSelStart = getDayIndexFrom(e->x(), e->y()); 304 mSelStart = getDayIndexFrom(e->x(), e->y());
306 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 305 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
307 mSelInit = mSelStart; 306 mSelInit = mSelStart;
308} 307}
309 308
310void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 309void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
311{ 310{
312 311
313 int tmp = getDayIndexFrom(e->x(), e->y()); 312 int tmp = getDayIndexFrom(e->x(), e->y());
314 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 313 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
315 314
316 if (mSelInit > tmp) { 315 if (mSelInit > tmp) {
317 mSelEnd = mSelInit; 316 mSelEnd = mSelInit;
318 if (tmp != mSelStart) { 317 if (tmp != mSelStart) {
319 mSelStart = tmp; 318 mSelStart = tmp;
320 repaint(); 319 repaint();
321 } 320 }
322 } else { 321 } else {
323 mSelStart = mSelInit; 322 mSelStart = mSelInit;
324 323
325 //repaint only if selection has changed 324 //repaint only if selection has changed
326 if (tmp != mSelEnd) { 325 if (tmp != mSelEnd) {
327 mSelEnd = tmp; 326 mSelEnd = tmp;
328 repaint(); 327 repaint();
329 } 328 }
330 } 329 }
331 330
332 DateList daylist; 331 DateList daylist;
333 if ( mSelStart < 0 ) 332 if ( mSelStart < 0 )
334 mSelStart = 0; 333 mSelStart = 0;
335 for (int i = mSelStart; i <= mSelEnd; i++) { 334 for (int i = mSelStart; i <= mSelEnd; i++) {
336 daylist.append(days[i]); 335 daylist.append(days[i]);
337 } 336 }
338 emit selected((const DateList)daylist); 337 emit selected((const DateList)daylist);
339 338
340} 339}
341 340
342void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 341void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
343{ 342{
344 int tmp = getDayIndexFrom(e->x(), e->y()); 343 int tmp = getDayIndexFrom(e->x(), e->y());
345 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 344 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
346 345
347 if (mSelInit > tmp) { 346 if (mSelInit > tmp) {
348 mSelEnd = mSelInit; 347 mSelEnd = mSelInit;
349 if (tmp != mSelStart) { 348 if (tmp != mSelStart) {
350 mSelStart = tmp; 349 mSelStart = tmp;
351 repaint(); 350 repaint();
352 } 351 }
353 } else { 352 } else {
354 mSelStart = mSelInit; 353 mSelStart = mSelInit;
355 354
356 //repaint only if selection has changed 355 //repaint only if selection has changed
357 if (tmp != mSelEnd) { 356 if (tmp != mSelEnd) {
358 mSelEnd = tmp; 357 mSelEnd = tmp;
359 repaint(); 358 repaint();
360 } 359 }
361 } 360 }
362} 361}
363 362
364// ---------------------------------------------------------------------------- 363// ----------------------------------------------------------------------------
365// D R A G ' N D R O P H A N D L I N G 364// D R A G ' N D R O P H A N D L I N G
366// ---------------------------------------------------------------------------- 365// ----------------------------------------------------------------------------
367 366
368void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 367void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
369{ 368{
370#ifndef KORG_NODND 369#ifndef KORG_NODND
371 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 370 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
372 e->ignore(); 371 e->ignore();
373 return; 372 return;
374 } 373 }
375 374
376 // some visual feedback 375 // some visual feedback
377// oldPalette = palette(); 376// oldPalette = palette();
378// setPalette(my_HilitePalette); 377// setPalette(my_HilitePalette);
379// update(); 378// update();
380#endif 379#endif
381} 380}
382 381
383void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 382void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
384{ 383{
385#ifndef KORG_NODND 384#ifndef KORG_NODND
386 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 385 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
387 e->ignore(); 386 e->ignore();
388 return; 387 return;
389 } 388 }
390 389
391 e->accept(); 390 e->accept();
392#endif 391#endif
393} 392}
394 393
395void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 394void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
396{ 395{
397#ifndef KORG_NODND 396#ifndef KORG_NODND
398// setPalette(oldPalette); 397// setPalette(oldPalette);
399// update(); 398// update();
400#endif 399#endif
401} 400}
402 401
403void KODayMatrix::dropEvent(QDropEvent *e) 402void KODayMatrix::dropEvent(QDropEvent *e)
404{ 403{
405#ifndef KORG_NODND 404#ifndef KORG_NODND
406// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 405// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
407 406
408 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 407 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
409 e->ignore(); 408 e->ignore();
410 return; 409 return;
411 } 410 }
412 411
413 DndFactory factory( mCalendar ); 412 DndFactory factory( mCalendar );
414 Event *event = factory.createDrop(e); 413 Event *event = factory.createDrop(e);
415 414
416 if (event) { 415 if (event) {
417 e->acceptAction(); 416 e->acceptAction();
418 417
419 Event *existingEvent = mCalendar->event(event->uid()); 418 Event *existingEvent = mCalendar->event(event->uid());
420 419
421 if(existingEvent) { 420 if(existingEvent) {
422 // uniquify event 421 // uniquify event
423 event->recreate(); 422 event->recreate();
424/* 423/*
425 KMessageBox::sorry(this, 424 KMessageBox::sorry(this,
426 i18n("Event already exists in this calendar."), 425 i18n("Event already exists in this calendar."),
427 i18n("Drop Event")); 426 i18n("Drop Event"));
428 delete event; 427 delete event;
429 return; 428 return;
430*/ 429*/
431 } 430 }
432// kdDebug() << "Drop new Event" << endl; 431// kdDebug() << "Drop new Event" << endl;
433 // Adjust date 432 // Adjust date
434 QDateTime start = event->dtStart(); 433 QDateTime start = event->dtStart();
435 QDateTime end = event->dtEnd(); 434 QDateTime end = event->dtEnd();
436 int duration = start.daysTo(end); 435 int duration = start.daysTo(end);
437 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 436 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
438 437
439 start.setDate(days[idx]); 438 start.setDate(days[idx]);
440 end.setDate(days[idx].addDays(duration)); 439 end.setDate(days[idx].addDays(duration));
441 440
442 event->setDtStart(start); 441 event->setDtStart(start);
443 event->setDtEnd(end); 442 event->setDtEnd(end);
444 mCalendar->addEvent(event); 443 mCalendar->addEvent(event);
445 444
446 emit eventDropped(event); 445 emit eventDropped(event);
447 } else { 446 } else {
448// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 447// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
449 e->ignore(); 448 e->ignore();
450 } 449 }
451#endif 450#endif
452} 451}
453 452
454// ---------------------------------------------------------------------------- 453// ----------------------------------------------------------------------------
455// P A I N T E V E N T H A N D L I N G 454// P A I N T E V E N T H A N D L I N G
456// ---------------------------------------------------------------------------- 455// ----------------------------------------------------------------------------
457 456
458void KODayMatrix::paintEvent(QPaintEvent * pevent) 457void KODayMatrix::paintEvent(QPaintEvent * pevent)
459{ 458{
460//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; 459//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl;
461 460
462 QPainter p(this); 461 QPainter p(this);
463 462
464 QRect sz = frameRect(); 463 QRect sz = frameRect();
465 int dheight = daysize.height(); 464 int dheight = daysize.height();
466 int dwidth = daysize.width(); 465 int dwidth = daysize.width();
467 int row,col; 466 int row,col;
468 int selw, selh; 467 int selw, selh;
469 bool isRTL = KOGlobals::self()->reverseLayout(); 468 bool isRTL = KOGlobals::self()->reverseLayout();
470 469
471 // draw background and topleft frame 470 // draw background and topleft frame
472 p.fillRect(pevent->rect(), mDefaultBackColor); 471 p.fillRect(pevent->rect(), mDefaultBackColor);
473 p.setPen(mDefaultTextColor); 472 p.setPen(mDefaultTextColor);
474 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 473 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
475 474
476 // draw selected days with highlighted background color 475 // draw selected days with highlighted background color
477 if (mSelStart != NOSELECTION) { 476 if (mSelStart != NOSELECTION) {
478 477
479 row = mSelStart/7; 478 row = mSelStart/7;
480 col = mSelStart -row*7; 479 col = mSelStart -row*7;
481 QColor selcol = KOPrefs::instance()->mHighlightColor; 480 QColor selcol = KOPrefs::instance()->mHighlightColor;
482 481
483 if (row == mSelEnd/7) { 482 if (row == mSelEnd/7) {
484 // Single row selection 483 // Single row selection
485 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, 484 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth,
486 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); 485 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol);
487 } else { 486 } else {
488 // draw first row to the right 487 // draw first row to the right
489 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, 488 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
490 dheight, selcol); 489 dheight, selcol);
491 // draw full block till last line 490 // draw full block till last line
492 selh = mSelEnd/7-row; 491 selh = mSelEnd/7-row;
493 if (selh > 1) { 492 if (selh > 1) {
494 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); 493 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
495 } 494 }
496 // draw last block from left to mSelEnd 495 // draw last block from left to mSelEnd
497 selw = mSelEnd-7*(mSelEnd/7)+1; 496 selw = mSelEnd-7*(mSelEnd/7)+1;
498 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, 497 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
499 selw*dwidth, dheight, selcol); 498 selw*dwidth, dheight, selcol);
500 } 499 }
501 } 500 }
502 501
503 // iterate over all days in the matrix and draw the day label in appropriate colors 502 // iterate over all days in the matrix and draw the day label in appropriate colors
504 QColor actcol = mDefaultTextColorShaded; 503 QColor actcol = mDefaultTextColorShaded;
505 p.setPen(actcol); 504 p.setPen(actcol);
506 QPen tmppen; 505 QPen tmppen;
507 for(int i = 0; i < NUMDAYS; i++) { 506 for(int i = 0; i < NUMDAYS; i++) {
508 row = i/7; 507 row = i/7;
509 col = isRTL ? 6-(i-row*7) : i-row*7; 508 col = isRTL ? 6-(i-row*7) : i-row*7;
510 509
511 // if it is the first day of a month switch color from normal to shaded and vice versa 510 // if it is the first day of a month switch color from normal to shaded and vice versa
512 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 511 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
513 if (actcol == mDefaultTextColorShaded) { 512 if (actcol == mDefaultTextColorShaded) {
514 actcol = mDefaultTextColor; 513 actcol = mDefaultTextColor;
515 } else { 514 } else {
516 actcol = mDefaultTextColorShaded; 515 actcol = mDefaultTextColorShaded;
517 } 516 }
518 p.setPen(actcol); 517 p.setPen(actcol);
519 } 518 }
520 519
521 //Reset pen color after selected days block 520 //Reset pen color after selected days block
522 if (i == mSelEnd+1) { 521 if (i == mSelEnd+1) {
523 p.setPen(actcol); 522 p.setPen(actcol);
524 } 523 }
525 524
526 // if today then draw rectangle around day 525 // if today then draw rectangle around day
527 if (today == i) { 526 if (today == i) {
528 tmppen = p.pen(); 527 tmppen = p.pen();
529 QPen mTodayPen(p.pen()); 528 QPen mTodayPen(p.pen());
530 529
531 mTodayPen.setWidth(mTodayMarginWidth); 530 mTodayPen.setWidth(mTodayMarginWidth);
532 //draw red rectangle for holidays 531 //draw red rectangle for holidays
533 if (!mHolidays[i].isNull()) { 532 if (!mHolidays[i].isNull()) {
534 if (actcol == mDefaultTextColor) { 533 if (actcol == mDefaultTextColor) {
535 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 534 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
536 } else { 535 } else {
537 mTodayPen.setColor(mHolidayColorShaded); 536 mTodayPen.setColor(mHolidayColorShaded);
538 } 537 }
539 } 538 }
540 //draw gray rectangle for today if in selection 539 //draw gray rectangle for today if in selection
541 if (i >= mSelStart && i <= mSelEnd) { 540 if (i >= mSelStart && i <= mSelEnd) {
542 QColor grey("grey"); 541 QColor grey("grey");
543 mTodayPen.setColor(grey); 542 mTodayPen.setColor(grey);
544 } 543 }
545 p.setPen(mTodayPen); 544 p.setPen(mTodayPen);
546 p.drawRect(col*dwidth, row*dheight, dwidth, dheight); 545 p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
547 p.setPen(tmppen); 546 p.setPen(tmppen);
548 } 547 }
549 548
550 // if any events are on that day then draw it using a bold font 549 // if any events are on that day then draw it using a bold font
551 if (events[i] > 0) { 550 if (events[i] > 0) {
552 QFont myFont = font(); 551 QFont myFont = font();
553 myFont.setBold(true); 552 myFont.setBold(true);
554 p.setFont(myFont); 553 p.setFont(myFont);
555 } 554 }
556 555
557 // if it is a holiday then use the default holiday color 556 // if it is a holiday then use the default holiday color
558 if (!mHolidays[i].isNull()) { 557 if (!mHolidays[i].isNull()) {
559 if (actcol == mDefaultTextColor) { 558 if (actcol == mDefaultTextColor) {
560 p.setPen(KOPrefs::instance()->mHolidayColor); 559 p.setPen(KOPrefs::instance()->mHolidayColor);
561 } else { 560 } else {
562 p.setPen(mHolidayColorShaded); 561 p.setPen(mHolidayColorShaded);
563 } 562 }
564 } 563 }
565 564
566 // draw selected days with special color 565 // draw selected days with special color
567 // DO NOT specially highlight holidays in selection ! 566 // DO NOT specially highlight holidays in selection !
568 if (i >= mSelStart && i <= mSelEnd) { 567 if (i >= mSelStart && i <= mSelEnd) {
569 p.setPen(mSelectedDaysColor); 568 p.setPen(mSelectedDaysColor);
570 } 569 }
571 570
572 p.drawText(col*dwidth, row*dheight, dwidth, dheight, 571 p.drawText(col*dwidth, row*dheight, dwidth, dheight,
573 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 572 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
574 573
575 // reset color to actual color 574 // reset color to actual color
576 if (!mHolidays[i].isNull()) { 575 if (!mHolidays[i].isNull()) {
577 p.setPen(actcol); 576 p.setPen(actcol);
578 } 577 }
579 // reset bold font to plain font 578 // reset bold font to plain font
580 if (events[i] > 0) { 579 if (events[i] > 0) {
581 QFont myFont = font(); 580 QFont myFont = font();
582 myFont.setBold(false); 581 myFont.setBold(false);
583 p.setFont(myFont); 582 p.setFont(myFont);
584 } 583 }
585 } 584 }
586} 585}
587 586
588// ---------------------------------------------------------------------------- 587// ----------------------------------------------------------------------------
589// R E SI Z E E V E N T H A N D L I N G 588// R E SI Z E E V E N T H A N D L I N G
590// ---------------------------------------------------------------------------- 589// ----------------------------------------------------------------------------
591 590
592void KODayMatrix::resizeEvent(QResizeEvent *) 591void KODayMatrix::resizeEvent(QResizeEvent *)
593{ 592{
594 QRect sz = frameRect(); 593 QRect sz = frameRect();
595 daysize.setHeight(sz.height()*7 / NUMDAYS); 594 daysize.setHeight(sz.height()*7 / NUMDAYS);
596 daysize.setWidth(sz.width() / 7); 595 daysize.setWidth(sz.width() / 7);
597} 596}
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
index caf7599..58198a2 100644
--- a/korganizer/kodialogmanager.cpp
+++ b/korganizer/kodialogmanager.cpp
@@ -1,343 +1,342 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <libkdepim/categoryeditdialog.h> 22#include <libkdepim/categoryeditdialog.h>
23 23
24#include "calendarview.h" 24#include "calendarview.h"
25#include "incomingdialog.h" 25#include "incomingdialog.h"
26#include "outgoingdialog.h" 26#include "outgoingdialog.h"
27#include "koprefsdialog.h" 27#include "koprefsdialog.h"
28#include "koeventeditor.h" 28#include "koeventeditor.h"
29#include "koprefs.h" 29#include "koprefs.h"
30#include "datenavigator.h" 30#include "datenavigator.h"
31#include "kotodoeditor.h" 31#include "kotodoeditor.h"
32#include "searchdialog.h" 32#include "searchdialog.h"
33#include "filtereditdialog.h" 33#include "filtereditdialog.h"
34#ifndef KORG_NOPLUGINS 34#ifndef KORG_NOPLUGINS
35#include "plugindialog.h" 35#include "plugindialog.h"
36#endif 36#endif
37#ifndef KORG_NOARCHIVE 37#ifndef KORG_NOARCHIVE
38#include "archivedialog.h" 38#include "archivedialog.h"
39#endif 39#endif
40 40
41#include "kconfig.h" 41#include "kconfig.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43#include "kodialogmanager.moc"
44 43
45KODialogManager::KODialogManager( CalendarView *mainView ) : 44KODialogManager::KODialogManager( CalendarView *mainView ) :
46 QObject(), mMainView( mainView ) 45 QObject(), mMainView( mainView )
47{ 46{
48 mOutgoingDialog = 0; 47 mOutgoingDialog = 0;
49 mIncomingDialog = 0; 48 mIncomingDialog = 0;
50 mOptionsDialog = 0; 49 mOptionsDialog = 0;
51 mSearchDialog = 0; 50 mSearchDialog = 0;
52 mArchiveDialog = 0; 51 mArchiveDialog = 0;
53 mFilterEditDialog = 0; 52 mFilterEditDialog = 0;
54 mPluginDialog = 0; 53 mPluginDialog = 0;
55 54
56 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView); 55 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView);
57 //KOGlobals::fitDialogToScreen( mCategoryEditDialog ); 56 //KOGlobals::fitDialogToScreen( mCategoryEditDialog );
58} 57}
59 58
60KODialogManager::~KODialogManager() 59KODialogManager::~KODialogManager()
61{ 60{
62 delete mOutgoingDialog; 61 delete mOutgoingDialog;
63 delete mIncomingDialog; 62 delete mIncomingDialog;
64 delete mOptionsDialog; 63 delete mOptionsDialog;
65 delete mSearchDialog; 64 delete mSearchDialog;
66#ifndef KORG_NOARCHIVE 65#ifndef KORG_NOARCHIVE
67 delete mArchiveDialog; 66 delete mArchiveDialog;
68#endif 67#endif
69 delete mFilterEditDialog; 68 delete mFilterEditDialog;
70#ifndef KORG_NOPLUGINS 69#ifndef KORG_NOPLUGINS
71 delete mPluginDialog; 70 delete mPluginDialog;
72#endif 71#endif
73} 72}
74 73
75OutgoingDialog *KODialogManager::outgoingDialog() 74OutgoingDialog *KODialogManager::outgoingDialog()
76{ 75{
77 createOutgoingDialog(); 76 createOutgoingDialog();
78 return mOutgoingDialog; 77 return mOutgoingDialog;
79} 78}
80 79
81void KODialogManager::createOutgoingDialog() 80void KODialogManager::createOutgoingDialog()
82{ 81{
83 if (!mOutgoingDialog) { 82 if (!mOutgoingDialog) {
84 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView); 83 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView);
85 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog); 84 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog);
86 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)), 85 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)),
87 mMainView,SIGNAL(numOutgoingChanged(int))); 86 mMainView,SIGNAL(numOutgoingChanged(int)));
88 } 87 }
89} 88}
90 89
91void KODialogManager::showOptionsDialog( bool showSync ) 90void KODialogManager::showOptionsDialog( bool showSync )
92{ 91{
93 int curLanguage = KOPrefs::instance()->mPreferredLanguage; 92 int curLanguage = KOPrefs::instance()->mPreferredLanguage;
94 if (!mOptionsDialog) { 93 if (!mOptionsDialog) {
95 mOptionsDialog = new KOPrefsDialog(mMainView); 94 mOptionsDialog = new KOPrefsDialog(mMainView);
96 //mOptionsDialog->readConfig(); 95 //mOptionsDialog->readConfig();
97 connect(mOptionsDialog,SIGNAL(configChanged()), 96 connect(mOptionsDialog,SIGNAL(configChanged()),
98 mMainView,SLOT(updateConfig())); 97 mMainView,SLOT(updateConfig()));
99 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 98 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
100 // mOptionsDialog,SLOT(updateCategories())); 99 // mOptionsDialog,SLOT(updateCategories()));
101 100
102 } 101 }
103 mOptionsDialog->readConfig(); 102 mOptionsDialog->readConfig();
104#ifndef DESKTOP_VERSION 103#ifndef DESKTOP_VERSION
105 mOptionsDialog->showMaximized(); 104 mOptionsDialog->showMaximized();
106#else 105#else
107 mOptionsDialog->show(); 106 mOptionsDialog->show();
108#endif 107#endif
109 if ( showSync ) 108 if ( showSync )
110 mOptionsDialog->showSyncPage(); 109 mOptionsDialog->showSyncPage();
111 mOptionsDialog->exec(); 110 mOptionsDialog->exec();
112 if ( curLanguage != KOPrefs::instance()->mPreferredLanguage ) 111 if ( curLanguage != KOPrefs::instance()->mPreferredLanguage )
113 KOPrefs::instance()->mLanguageChanged = true; 112 KOPrefs::instance()->mLanguageChanged = true;
114} 113}
115void KODialogManager::showSyncOptions() 114void KODialogManager::showSyncOptions()
116{ 115{
117 showOptionsDialog( true ); 116 showOptionsDialog( true );
118 117
119} 118}
120void KODialogManager::showOutgoingDialog() 119void KODialogManager::showOutgoingDialog()
121{ 120{
122 createOutgoingDialog(); 121 createOutgoingDialog();
123 mOutgoingDialog->show(); 122 mOutgoingDialog->show();
124 mOutgoingDialog->raise(); 123 mOutgoingDialog->raise();
125} 124}
126 125
127IncomingDialog *KODialogManager::incomingDialog() 126IncomingDialog *KODialogManager::incomingDialog()
128{ 127{
129 createOutgoingDialog(); 128 createOutgoingDialog();
130 if (!mIncomingDialog) { 129 if (!mIncomingDialog) {
131 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 130 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
132 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 131 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
133 mMainView,SIGNAL(numIncomingChanged(int))); 132 mMainView,SIGNAL(numIncomingChanged(int)));
134 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 133 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
135 mMainView,SLOT(updateView())); 134 mMainView,SLOT(updateView()));
136 } 135 }
137 return mIncomingDialog; 136 return mIncomingDialog;
138} 137}
139 138
140void KODialogManager::createIncomingDialog() 139void KODialogManager::createIncomingDialog()
141{ 140{
142 createOutgoingDialog(); 141 createOutgoingDialog();
143 if (!mIncomingDialog) { 142 if (!mIncomingDialog) {
144 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 143 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
145 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 144 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
146 mMainView,SIGNAL(numIncomingChanged(int))); 145 mMainView,SIGNAL(numIncomingChanged(int)));
147 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 146 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
148 mMainView,SLOT(updateView())); 147 mMainView,SLOT(updateView()));
149 } 148 }
150} 149}
151 150
152void KODialogManager::showIncomingDialog() 151void KODialogManager::showIncomingDialog()
153{ 152{
154 createIncomingDialog(); 153 createIncomingDialog();
155 mIncomingDialog->show(); 154 mIncomingDialog->show();
156 mIncomingDialog->raise(); 155 mIncomingDialog->raise();
157} 156}
158/* 157/*
159void KODialogManager::showCategoryEditDialog() 158void KODialogManager::showCategoryEditDialog()
160{ 159{
161 mCategoryEditDialog->show(); 160 mCategoryEditDialog->show();
162} 161}
163*/ 162*/
164void KODialogManager::hideSearchDialog() 163void KODialogManager::hideSearchDialog()
165{ 164{
166 if (mSearchDialog) 165 if (mSearchDialog)
167 mSearchDialog->hide(); 166 mSearchDialog->hide();
168} 167}
169 168
170void KODialogManager::showSearchDialog() 169void KODialogManager::showSearchDialog()
171{ 170{
172 if (!mSearchDialog) { 171 if (!mSearchDialog) {
173 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView); 172 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView);
174 KOListView * lview = mSearchDialog->listview(); 173 KOListView * lview = mSearchDialog->listview();
175 174
176 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)), 175 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)),
177 mMainView, SLOT(showIncidence(Incidence *))); 176 mMainView, SLOT(showIncidence(Incidence *)));
178 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)), 177 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)),
179 mMainView, SLOT(editIncidence(Incidence *))); 178 mMainView, SLOT(editIncidence(Incidence *)));
180 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)), 179 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)),
181 mMainView, SLOT(deleteIncidence(Incidence *))); 180 mMainView, SLOT(deleteIncidence(Incidence *)));
182 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)), 181 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)),
183 mMainView, SLOT(cloneIncidence(Incidence *))); 182 mMainView, SLOT(cloneIncidence(Incidence *)));
184 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)), 183 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)),
185 mMainView, SLOT(beamIncidence(Incidence *))); 184 mMainView, SLOT(beamIncidence(Incidence *)));
186 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)), 185 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)),
187 mMainView, SLOT(moveIncidence(Incidence *))); 186 mMainView, SLOT(moveIncidence(Incidence *)));
188 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )), 187 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )),
189 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> ))); 188 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> )));
190 189
191 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig())); 190 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig()));
192 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList())); 191 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList()));
193 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ), 192 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ),
194 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 193 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
195#ifndef DESKTOP_VERSION 194#ifndef DESKTOP_VERSION
196 mSearchDialog->setMaximumSize( 640, 480 ); 195 mSearchDialog->setMaximumSize( 640, 480 );
197 //mSearchDialog->setGeometry( 40,40, 400, 300); 196 //mSearchDialog->setGeometry( 40,40, 400, 300);
198 mSearchDialog->showMaximized(); 197 mSearchDialog->showMaximized();
199#else 198#else
200 KConfig *config = KOGlobals::config(); 199 KConfig *config = KOGlobals::config();
201 config->setGroup("WidgetLayout"); 200 config->setGroup("WidgetLayout");
202 QStringList list; 201 QStringList list;
203 list = config->readListEntry("SearchLayout"); 202 list = config->readListEntry("SearchLayout");
204 int x,y,w,h; 203 int x,y,w,h;
205 if ( ! list.isEmpty() ) { 204 if ( ! list.isEmpty() ) {
206 x = list[0].toInt(); 205 x = list[0].toInt();
207 y = list[1].toInt(); 206 y = list[1].toInt();
208 w = list[2].toInt(); 207 w = list[2].toInt();
209 h = list[3].toInt(); 208 h = list[3].toInt();
210 mSearchDialog->setGeometry(x,y,w,h); 209 mSearchDialog->setGeometry(x,y,w,h);
211 210
212 } 211 }
213 212
214#endif 213#endif
215 } 214 }
216 // make sure the widget is on top again 215 // make sure the widget is on top again
217 mSearchDialog->show(); 216 mSearchDialog->show();
218 mSearchDialog->raise(); 217 mSearchDialog->raise();
219} 218}
220 219
221SearchDialog * KODialogManager::getSearchDialog() 220SearchDialog * KODialogManager::getSearchDialog()
222{ 221{
223 return mSearchDialog; 222 return mSearchDialog;
224} 223}
225void KODialogManager::showArchiveDialog() 224void KODialogManager::showArchiveDialog()
226{ 225{
227#ifndef KORG_NOARCHIVE 226#ifndef KORG_NOARCHIVE
228 if (!mArchiveDialog) { 227 if (!mArchiveDialog) {
229 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView); 228 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView);
230 connect(mArchiveDialog,SIGNAL(eventsDeleted()), 229 connect(mArchiveDialog,SIGNAL(eventsDeleted()),
231 mMainView,SLOT(updateView())); 230 mMainView,SLOT(updateView()));
232 } 231 }
233 mArchiveDialog->show(); 232 mArchiveDialog->show();
234 mArchiveDialog->raise(); 233 mArchiveDialog->raise();
235 234
236 // Workaround. 235 // Workaround.
237 QApplication::restoreOverrideCursor(); 236 QApplication::restoreOverrideCursor();
238#endif 237#endif
239} 238}
240 239
241void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters) 240void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters)
242{ 241{
243 if (!mFilterEditDialog) { 242 if (!mFilterEditDialog) {
244 mFilterEditDialog = new FilterEditDialog(filters,mMainView); 243 mFilterEditDialog = new FilterEditDialog(filters,mMainView);
245 connect(mFilterEditDialog,SIGNAL(filterChanged()), 244 connect(mFilterEditDialog,SIGNAL(filterChanged()),
246 mMainView,SLOT(filterEdited())); 245 mMainView,SLOT(filterEdited()));
247 246
248 } 247 }
249 248
250#ifndef DESKTOP_VERSION 249#ifndef DESKTOP_VERSION
251 mFilterEditDialog->showMaximized(); 250 mFilterEditDialog->showMaximized();
252#else 251#else
253 mFilterEditDialog->show(); 252 mFilterEditDialog->show();
254#endif 253#endif
255 mFilterEditDialog->raise(); 254 mFilterEditDialog->raise();
256} 255}
257 256
258void KODialogManager::showPluginDialog() 257void KODialogManager::showPluginDialog()
259{ 258{
260#ifndef KORG_NOPLUGINS 259#ifndef KORG_NOPLUGINS
261 if (!mPluginDialog) { 260 if (!mPluginDialog) {
262 mPluginDialog = new PluginDialog(mMainView); 261 mPluginDialog = new PluginDialog(mMainView);
263 connect(mPluginDialog,SIGNAL(configChanged()), 262 connect(mPluginDialog,SIGNAL(configChanged()),
264 mMainView,SLOT(updateConfig())); 263 mMainView,SLOT(updateConfig()));
265 } 264 }
266 mPluginDialog->show(); 265 mPluginDialog->show();
267 mPluginDialog->raise(); 266 mPluginDialog->raise();
268#endif 267#endif
269} 268}
270 269
271KOEventEditor *KODialogManager::getEventEditor() 270KOEventEditor *KODialogManager::getEventEditor()
272{ 271{
273 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(), 272 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(),
274 mMainView ); 273 mMainView );
275 274
276 connect(eventEditor,SIGNAL(eventAdded(Event *)), 275 connect(eventEditor,SIGNAL(eventAdded(Event *)),
277 mMainView,SLOT(eventAdded(Event *))); 276 mMainView,SLOT(eventAdded(Event *)));
278 connect(eventEditor,SIGNAL(eventChanged(Event *)), 277 connect(eventEditor,SIGNAL(eventChanged(Event *)),
279 mMainView,SLOT(eventChanged(Event *))); 278 mMainView,SLOT(eventChanged(Event *)));
280 connect(eventEditor,SIGNAL(eventDeleted()), 279 connect(eventEditor,SIGNAL(eventDeleted()),
281 mMainView,SLOT(eventDeleted())); 280 mMainView,SLOT(eventDeleted()));
282 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)), 281 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)),
283 mMainView,SLOT(schedule_cancel(Incidence *))); 282 mMainView,SLOT(schedule_cancel(Incidence *)));
284 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)), 283 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)),
285 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 284 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
286 connect( eventEditor, SIGNAL( showAgendaView( bool)), 285 connect( eventEditor, SIGNAL( showAgendaView( bool)),
287 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 286 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
288 287
289 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 288 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
290 // eventEditor,SLOT(updateCategoryConfig())); 289 // eventEditor,SLOT(updateCategoryConfig()));
291 // connect(eventEditor,SIGNAL(editCategories()), 290 // connect(eventEditor,SIGNAL(editCategories()),
292 // mCategoryEditDialog,SLOT(show())); 291 // mCategoryEditDialog,SLOT(show()));
293 connect(eventEditor,SIGNAL(dialogClose(Incidence*)), 292 connect(eventEditor,SIGNAL(dialogClose(Incidence*)),
294 mMainView,SLOT(dialogClosing(Incidence*))); 293 mMainView,SLOT(dialogClosing(Incidence*)));
295 294
296 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject())); 295 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject()));
297 296
298 return eventEditor; 297 return eventEditor;
299} 298}
300 299
301KOTodoEditor *KODialogManager::getTodoEditor() 300KOTodoEditor *KODialogManager::getTodoEditor()
302{ 301{
303 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(), 302 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(),
304 mMainView ); 303 mMainView );
305 304
306 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 305 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
307 // todoEditor,SLOT(updateCategoryConfig())); 306 // todoEditor,SLOT(updateCategoryConfig()));
308 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show())); 307 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show()));
309 308
310 connect(todoEditor,SIGNAL(todoAdded(Todo *)), 309 connect(todoEditor,SIGNAL(todoAdded(Todo *)),
311 mMainView,SLOT(todoAdded(Todo *))); 310 mMainView,SLOT(todoAdded(Todo *)));
312 connect(todoEditor,SIGNAL(todoChanged(Todo *)), 311 connect(todoEditor,SIGNAL(todoChanged(Todo *)),
313 mMainView,SLOT(todoChanged(Todo *))); 312 mMainView,SLOT(todoChanged(Todo *)));
314 connect(todoEditor,SIGNAL(todoDeleted()), 313 connect(todoEditor,SIGNAL(todoDeleted()),
315 mMainView,SLOT(todoDeleted())); 314 mMainView,SLOT(todoDeleted()));
316 connect(todoEditor,SIGNAL(dialogClose(Incidence*)), 315 connect(todoEditor,SIGNAL(dialogClose(Incidence*)),
317 mMainView,SLOT(dialogClosing(Incidence*))); 316 mMainView,SLOT(dialogClosing(Incidence*)));
318 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)), 317 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)),
319 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 318 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
320 connect( todoEditor, SIGNAL( showAgendaView( bool)), 319 connect( todoEditor, SIGNAL( showAgendaView( bool)),
321 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 320 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
322 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)), 321 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)),
323 // mMainView,SLOT(schedule_cancel(Incidence *))); 322 // mMainView,SLOT(schedule_cancel(Incidence *)));
324 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject())); 323 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject()));
325 324
326 return todoEditor; 325 return todoEditor;
327} 326}
328 327
329void KODialogManager::updateSearchDialog() 328void KODialogManager::updateSearchDialog()
330{ 329{
331 if (mSearchDialog) mSearchDialog->updateView(); 330 if (mSearchDialog) mSearchDialog->updateView();
332} 331}
333 332
334void KODialogManager::setDocumentId( const QString &id ) 333void KODialogManager::setDocumentId( const QString &id )
335{ 334{
336 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id ); 335 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id );
337} 336}
338 337
339void KODialogManager::writeSettings( KConfig *config ) 338void KODialogManager::writeSettings( KConfig *config )
340{ 339{
341 if (mSearchDialog) 340 if (mSearchDialog)
342 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout"); 341 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout");
343} 342}
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp
index 7c4c382..c0e7bdd 100644
--- a/korganizer/koeditordetails.cpp
+++ b/korganizer/koeditordetails.cpp
@@ -1,398 +1,397 @@
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 thse hope that it will be useful, 10 This program is distributed in thse 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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.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 <qapp.h> 32#include <qapp.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#ifndef KORG_NOKABC 39#ifndef KORG_NOKABC
40#include <kabc/addresseedialog.h> 40#include <kabc/addresseedialog.h>
41#endif 41#endif
42 42
43#include <libkcal/incidence.h> 43#include <libkcal/incidence.h>
44 44
45#include "koprefs.h" 45#include "koprefs.h"
46 46
47#include "koeditordetails.h" 47#include "koeditordetails.h"
48#include "koeditordetails.moc"
49 48
50template <> 49template <>
51CustomListViewItem<class Attendee *>::~CustomListViewItem() 50CustomListViewItem<class Attendee *>::~CustomListViewItem()
52{ 51{
53 delete mData; 52 delete mData;
54} 53}
55 54
56template <> 55template <>
57void CustomListViewItem<class Attendee *>::updateItem() 56void CustomListViewItem<class Attendee *>::updateItem()
58{ 57{
59 setText(0,mData->name()); 58 setText(0,mData->name());
60 setText(1,mData->email()); 59 setText(1,mData->email());
61 setText(2,mData->roleStr()); 60 setText(2,mData->roleStr());
62 setText(3,mData->statusStr()); 61 setText(3,mData->statusStr());
63 if (mData->RSVP() && !mData->email().isEmpty()) 62 if (mData->RSVP() && !mData->email().isEmpty())
64 setPixmap(4,SmallIcon("mailappt")); 63 setPixmap(4,SmallIcon("mailappt"));
65 else 64 else
66 setPixmap(4,SmallIcon("nomailappt")); 65 setPixmap(4,SmallIcon("nomailappt"));
67} 66}
68 67
69 68
70KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) 69KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name)
71 : QWidget( parent, name), mDisableItemUpdate( false ) 70 : QWidget( parent, name), mDisableItemUpdate( false )
72{ 71{
73 QGridLayout *topLayout = new QGridLayout(this); 72 QGridLayout *topLayout = new QGridLayout(this);
74 topLayout->setSpacing(spacing); 73 topLayout->setSpacing(spacing);
75 74
76 QString organizer = KOPrefs::instance()->email(); 75 QString organizer = KOPrefs::instance()->email();
77 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); 76 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this);
78 77
79 mListView = new KListView(this,"mListView"); 78 mListView = new KListView(this,"mListView");
80 mListView->addColumn(i18n("Name"),180); 79 mListView->addColumn(i18n("Name"),180);
81 mListView->addColumn(i18n("Email"),180); 80 mListView->addColumn(i18n("Email"),180);
82 mListView->addColumn(i18n("Role"),60); 81 mListView->addColumn(i18n("Role"),60);
83 mListView->addColumn(i18n("Status"),100); 82 mListView->addColumn(i18n("Status"),100);
84 mListView->addColumn(i18n("RSVP"),35); 83 mListView->addColumn(i18n("RSVP"),35);
85 if ( KOPrefs::instance()->mCompactDialogs ) { 84 if ( KOPrefs::instance()->mCompactDialogs ) {
86 //mListView->setFixedHeight(78); 85 //mListView->setFixedHeight(78);
87 } 86 }
88 87
89 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), 88 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)),
90 SLOT(updateAttendeeInput())); 89 SLOT(updateAttendeeInput()));
91 90
92 QLabel *attendeeLabel = new QLabel(this); 91 QLabel *attendeeLabel = new QLabel(this);
93 attendeeLabel->setText(i18n("Name:")); 92 attendeeLabel->setText(i18n("Name:"));
94 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); 93 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() );
95 mNameEdit = new QLineEdit(this); 94 mNameEdit = new QLineEdit(this);
96 connect(mNameEdit,SIGNAL(textChanged(const QString &)), 95 connect(mNameEdit,SIGNAL(textChanged(const QString &)),
97 SLOT(updateAttendeeItem())); 96 SLOT(updateAttendeeItem()));
98 97
99 mUidEdit = new QLineEdit(0); 98 mUidEdit = new QLineEdit(0);
100 mUidEdit->setText(""); 99 mUidEdit->setText("");
101 100
102 QLabel *emailLabel = new QLabel(this); 101 QLabel *emailLabel = new QLabel(this);
103 emailLabel->setText(i18n("Email:")); 102 emailLabel->setText(i18n("Email:"));
104 mEmailEdit = new QLineEdit(this); 103 mEmailEdit = new QLineEdit(this);
105 connect(mEmailEdit,SIGNAL(textChanged(const QString &)), 104 connect(mEmailEdit,SIGNAL(textChanged(const QString &)),
106 SLOT(updateAttendeeItem())); 105 SLOT(updateAttendeeItem()));
107 106
108 QLabel *attendeeRoleLabel = new QLabel(this); 107 QLabel *attendeeRoleLabel = new QLabel(this);
109 attendeeRoleLabel->setText(i18n("Role:")); 108 attendeeRoleLabel->setText(i18n("Role:"));
110 mRoleCombo = new QComboBox(false,this); 109 mRoleCombo = new QComboBox(false,this);
111 mRoleCombo->insertStringList(Attendee::roleList()); 110 mRoleCombo->insertStringList(Attendee::roleList());
112 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 111 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
113 112
114 QLabel *statusLabel = new QLabel(this); 113 QLabel *statusLabel = new QLabel(this);
115 statusLabel->setText( i18n("Status:") ); 114 statusLabel->setText( i18n("Status:") );
116 115
117 mStatusCombo = new QComboBox(false,this); 116 mStatusCombo = new QComboBox(false,this);
118 mStatusCombo->insertStringList(Attendee::statusList()); 117 mStatusCombo->insertStringList(Attendee::statusList());
119 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 118 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
120 119
121 mRsvpButton = new QCheckBox(this); 120 mRsvpButton = new QCheckBox(this);
122 mRsvpButton->setText(i18n("Request response")); 121 mRsvpButton->setText(i18n("Request response"));
123 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); 122 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem()));
124 QWidget *buttonBox = new QWidget(this); 123 QWidget *buttonBox = new QWidget(this);
125 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); 124 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox);
126 125
127 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); 126 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox);
128 buttonLayout->addWidget(newButton); 127 buttonLayout->addWidget(newButton);
129 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); 128 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee()));
130 129
131 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); 130 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox);
132 buttonLayout->addWidget(mRemoveButton); 131 buttonLayout->addWidget(mRemoveButton);
133 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); 132 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee()));
134 133
135 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); 134 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this);
136 // buttonLayout->addWidget(mAddressBookButton); 135 // buttonLayout->addWidget(mAddressBookButton);
137 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); 136 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook()));
138 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); 137 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () );
139 138
140 if (qApp->desktop()->width() < 300 ) { 139 if (qApp->desktop()->width() < 300 ) {
141 mListView->setFixedHeight(80); 140 mListView->setFixedHeight(80);
142 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); 141 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3);
143 topLayout->addMultiCellWidget(mListView,1,1,0,3); 142 topLayout->addMultiCellWidget(mListView,1,1,0,3);
144 topLayout->addWidget(attendeeLabel,3,0); 143 topLayout->addWidget(attendeeLabel,3,0);
145 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); 144 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2);
146 topLayout->addWidget(emailLabel,4,0); 145 topLayout->addWidget(emailLabel,4,0);
147 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); 146 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2);
148 topLayout->addWidget(attendeeRoleLabel,5,0); 147 topLayout->addWidget(attendeeRoleLabel,5,0);
149 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); 148 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
150 topLayout->addWidget(statusLabel,6,0); 149 topLayout->addWidget(statusLabel,6,0);
151 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,2); 150 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,2);
152 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); 151 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3);
153 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 152 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
154 topLayout->addMultiCellWidget(buttonBox,3,4,3,3); 153 topLayout->addMultiCellWidget(buttonBox,3,4,3,3);
155 topLayout->setRowStretch(1,2); 154 topLayout->setRowStretch(1,2);
156 topLayout->setColStretch(0,0); 155 topLayout->setColStretch(0,0);
157 topLayout->setColStretch(1,2); 156 topLayout->setColStretch(1,2);
158 topLayout->setColStretch(2,1); 157 topLayout->setColStretch(2,1);
159 topLayout->setColStretch(3,1); 158 topLayout->setColStretch(3,1);
160 159
161 } else { 160 } else {
162 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); 161 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5);
163 topLayout->addMultiCellWidget(mListView,1,1,0,5); 162 topLayout->addMultiCellWidget(mListView,1,1,0,5);
164 topLayout->addWidget(attendeeLabel,3,0); 163 topLayout->addWidget(attendeeLabel,3,0);
165 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); 164 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4);
166 topLayout->addWidget(emailLabel,4,0); 165 topLayout->addWidget(emailLabel,4,0);
167 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); 166 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4);
168 topLayout->addWidget(attendeeRoleLabel,5,0); 167 topLayout->addWidget(attendeeRoleLabel,5,0);
169 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); 168 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
170 topLayout->addWidget(statusLabel,5,3); 169 topLayout->addWidget(statusLabel,5,3);
171 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); 170 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5);
172 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); 171 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5);
173 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 172 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
174 topLayout->addMultiCellWidget(buttonBox,3,4,5,5); 173 topLayout->addMultiCellWidget(buttonBox,3,4,5,5);
175 topLayout->setRowStretch(1,5); 174 topLayout->setRowStretch(1,5);
176 topLayout->setColStretch(0,0); 175 topLayout->setColStretch(0,0);
177 } 176 }
178// #if 0 177// #if 0
179// topLayout->setColStretch(2,1); 178// topLayout->setColStretch(2,1);
180// topLayout->addWidget(statusLabel,3,3); 179// topLayout->addWidget(statusLabel,3,3);
181// topLayout->addWidget(mStatusCombo,3,4); 180// topLayout->addWidget(mStatusCombo,3,4);
182// #else 181// #else
183// topLayout->addWidget(statusLabel,4,3); 182// topLayout->addWidget(statusLabel,4,3);
184// // topLayout->addWidget(mStatusCombo,4,3); 183// // topLayout->addWidget(mStatusCombo,4,3);
185// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); 184// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5);
186 185
187// #endif 186// #endif
188// // topLayout->setRowStretch(5,1); 187// // topLayout->setRowStretch(5,1);
189// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); 188// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1);
190// topLayout->addMultiCellWidget(buttonBox,2,3,5,5); 189// topLayout->addMultiCellWidget(buttonBox,2,3,5,5);
191// topLayout->setRowStretch(1,5); 190// topLayout->setRowStretch(1,5);
192// topLayout->setColStretch(0,0); 191// topLayout->setColStretch(0,0);
193 192
194#ifdef KORG_NOKABC 193#ifdef KORG_NOKABC
195 mAddressBookButton->hide(); 194 mAddressBookButton->hide();
196#endif 195#endif
197 196
198 updateAttendeeInput(); 197 updateAttendeeInput();
199} 198}
200 199
201KOEditorDetails::~KOEditorDetails() 200KOEditorDetails::~KOEditorDetails()
202{ 201{
203} 202}
204 203
205void KOEditorDetails::removeAttendee() 204void KOEditorDetails::removeAttendee()
206{ 205{
207 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); 206 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem();
208 if (!aItem) return; 207 if (!aItem) return;
209 208
210 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), 209 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(),
211 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), 210 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(),
212 aItem->data()->uid()); 211 aItem->data()->uid());
213 mdelAttendees.append(delA); 212 mdelAttendees.append(delA);
214 213
215 delete aItem; 214 delete aItem;
216 215
217 updateAttendeeInput(); 216 updateAttendeeInput();
218} 217}
219 218
220 219
221void KOEditorDetails::openAddressBook() 220void KOEditorDetails::openAddressBook()
222{ 221{
223#ifndef KORG_NOKABC 222#ifndef KORG_NOKABC
224 223
225 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 224 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
226 uint i=0; 225 uint i=0;
227 for (i=0; i < list.count(); i++) { 226 for (i=0; i < list.count(); i++) {
228 insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); 227 insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) );
229 } 228 }
230 229
231#if 0 230#if 0
232 KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); 231 KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
233 if (!a.isEmpty()) { 232 if (!a.isEmpty()) {
234 insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); 233 insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) );
235 } 234 }
236#endif 235#endif
237#endif 236#endif
238} 237}
239 238
240 239
241void KOEditorDetails::addNewAttendee() 240void KOEditorDetails::addNewAttendee()
242{ 241{
243#if 0 242#if 0
244 // this is cool. If they didn't enter an email address, 243 // this is cool. If they didn't enter an email address,
245 // try to look it up in the address book and fill it in for them. 244 // try to look it up in the address book and fill it in for them.
246 if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { 245 if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) {
247 KabAPI addrBook; 246 KabAPI addrBook;
248 QString name; 247 QString name;
249 std::list<AddressBook::Entry> entries; 248 std::list<AddressBook::Entry> entries;
250 name = mNameEdit->text(); 249 name = mNameEdit->text();
251 if (addrBook.init() == AddressBook::NoError) { 250 if (addrBook.init() == AddressBook::NoError) {
252 if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { 251 if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) {
253 kdDebug() << "positive match" << endl; 252 kdDebug() << "positive match" << endl;
254 // take first email address 253 // take first email address
255 if (!entries.front().emails.isEmpty() && 254 if (!entries.front().emails.isEmpty() &&
256 entries.front().emails.first().length()>0) 255 entries.front().emails.first().length()>0)
257 mEmailEdit->setText(entries.front().emails.first()); 256 mEmailEdit->setText(entries.front().emails.first());
258 } 257 }
259 } 258 }
260 } 259 }
261#endif 260#endif
262 261
263 Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); 262 Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)"));
264 insertAttendee(a); 263 insertAttendee(a);
265} 264}
266 265
267 266
268void KOEditorDetails::insertAttendee(Attendee *a) 267void KOEditorDetails::insertAttendee(Attendee *a)
269{ 268{
270 AttendeeListItem *item = new AttendeeListItem(a,mListView); 269 AttendeeListItem *item = new AttendeeListItem(a,mListView);
271 mListView->setSelected( item, true ); 270 mListView->setSelected( item, true );
272} 271}
273 272
274void KOEditorDetails::setDefaults() 273void KOEditorDetails::setDefaults()
275{ 274{
276 mRsvpButton->setChecked(true); 275 mRsvpButton->setChecked(true);
277 mListView->clear(); 276 mListView->clear();
278 mdelAttendees.clear(); 277 mdelAttendees.clear();
279 clearAttendeeInput(); 278 clearAttendeeInput();
280 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); 279 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email()));
281 280
282 mNameEdit->setText(""); 281 mNameEdit->setText("");
283 mUidEdit->setText(""); 282 mUidEdit->setText("");
284 mEmailEdit->setText(""); 283 mEmailEdit->setText("");
285 mRoleCombo->setCurrentItem( 0 ); 284 mRoleCombo->setCurrentItem( 0 );
286 mStatusCombo->setCurrentItem( 0 ); 285 mStatusCombo->setCurrentItem( 0 );
287 286
288} 287}
289 288
290void KOEditorDetails::readEvent(Incidence *event) 289void KOEditorDetails::readEvent(Incidence *event)
291{ 290{
292 setDefaults(); 291 setDefaults();
293 //mListView->clear(); 292 //mListView->clear();
294 //mdelAttendees.clear(); 293 //mdelAttendees.clear();
295 QPtrList<Attendee> tmpAList = event->attendees(); 294 QPtrList<Attendee> tmpAList = event->attendees();
296 Attendee *a; 295 Attendee *a;
297 for (a = tmpAList.first(); a; a = tmpAList.next()) 296 for (a = tmpAList.first(); a; a = tmpAList.next())
298 insertAttendee(new Attendee(*a)); 297 insertAttendee(new Attendee(*a));
299 298
300 mListView->setSelected( mListView->firstChild(), true ); 299 mListView->setSelected( mListView->firstChild(), true );
301 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); 300 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer()));
302} 301}
303 302
304void KOEditorDetails::writeEvent(Incidence *event) 303void KOEditorDetails::writeEvent(Incidence *event)
305{ 304{
306 event->clearAttendees(); 305 event->clearAttendees();
307 QListViewItem *item; 306 QListViewItem *item;
308 AttendeeListItem *a; 307 AttendeeListItem *a;
309 for (item = mListView->firstChild(); item; 308 for (item = mListView->firstChild(); item;
310 item = item->nextSibling()) { 309 item = item->nextSibling()) {
311 a = (AttendeeListItem *)item; 310 a = (AttendeeListItem *)item;
312 event->addAttendee(new Attendee(*(a->data()))); 311 event->addAttendee(new Attendee(*(a->data())));
313 } 312 }
314 event->setOrganizer(KOPrefs::instance()->email()); 313 event->setOrganizer(KOPrefs::instance()->email());
315} 314}
316 315
317void KOEditorDetails::cancelAttendeeEvent(Incidence *event) 316void KOEditorDetails::cancelAttendeeEvent(Incidence *event)
318{ 317{
319 event->clearAttendees(); 318 event->clearAttendees();
320 Attendee * att; 319 Attendee * att;
321 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { 320 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) {
322 event->addAttendee(new Attendee(*att)); 321 event->addAttendee(new Attendee(*att));
323 } 322 }
324 mdelAttendees.clear(); 323 mdelAttendees.clear();
325} 324}
326 325
327bool KOEditorDetails::validateInput() 326bool KOEditorDetails::validateInput()
328{ 327{
329 return true; 328 return true;
330} 329}
331 330
332void KOEditorDetails::updateAttendeeInput() 331void KOEditorDetails::updateAttendeeInput()
333{ 332{
334 QListViewItem *item = mListView->selectedItem(); 333 QListViewItem *item = mListView->selectedItem();
335 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 334 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
336 if (aItem) { 335 if (aItem) {
337 fillAttendeeInput( aItem ); 336 fillAttendeeInput( aItem );
338 } else { 337 } else {
339 clearAttendeeInput(); 338 clearAttendeeInput();
340 } 339 }
341} 340}
342 341
343void KOEditorDetails::clearAttendeeInput() 342void KOEditorDetails::clearAttendeeInput()
344{ 343{
345 mNameEdit->setText(""); 344 mNameEdit->setText("");
346 mUidEdit->setText(""); 345 mUidEdit->setText("");
347 mEmailEdit->setText(""); 346 mEmailEdit->setText("");
348 mRoleCombo->setCurrentItem(0); 347 mRoleCombo->setCurrentItem(0);
349 mStatusCombo->setCurrentItem(0); 348 mStatusCombo->setCurrentItem(0);
350 mRsvpButton->setChecked(true); 349 mRsvpButton->setChecked(true);
351 setEnabledAttendeeInput( false ); 350 setEnabledAttendeeInput( false );
352} 351}
353 352
354void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) 353void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem )
355{ 354{
356 Attendee *a = aItem->data(); 355 Attendee *a = aItem->data();
357 mDisableItemUpdate = true; 356 mDisableItemUpdate = true;
358 mNameEdit->setText(a->name()); 357 mNameEdit->setText(a->name());
359 mUidEdit->setText(a->uid()); 358 mUidEdit->setText(a->uid());
360 mEmailEdit->setText(a->email()); 359 mEmailEdit->setText(a->email());
361 mRoleCombo->setCurrentItem(a->role()); 360 mRoleCombo->setCurrentItem(a->role());
362 mStatusCombo->setCurrentItem(a->status()); 361 mStatusCombo->setCurrentItem(a->status());
363 mRsvpButton->setChecked(a->RSVP()); 362 mRsvpButton->setChecked(a->RSVP());
364 363
365 mDisableItemUpdate = false; 364 mDisableItemUpdate = false;
366 365
367 setEnabledAttendeeInput( true ); 366 setEnabledAttendeeInput( true );
368} 367}
369 368
370void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) 369void KOEditorDetails::setEnabledAttendeeInput( bool enabled )
371{ 370{
372 mNameEdit->setEnabled( enabled ); 371 mNameEdit->setEnabled( enabled );
373 mEmailEdit->setEnabled( enabled ); 372 mEmailEdit->setEnabled( enabled );
374 mRoleCombo->setEnabled( enabled ); 373 mRoleCombo->setEnabled( enabled );
375 mStatusCombo->setEnabled( enabled ); 374 mStatusCombo->setEnabled( enabled );
376 mRsvpButton->setEnabled( enabled ); 375 mRsvpButton->setEnabled( enabled );
377 376
378 mRemoveButton->setEnabled( enabled ); 377 mRemoveButton->setEnabled( enabled );
379} 378}
380 379
381void KOEditorDetails::updateAttendeeItem() 380void KOEditorDetails::updateAttendeeItem()
382{ 381{
383 if (mDisableItemUpdate) return; 382 if (mDisableItemUpdate) return;
384 383
385 QListViewItem *item = mListView->selectedItem(); 384 QListViewItem *item = mListView->selectedItem();
386 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 385 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
387 if ( !aItem ) return; 386 if ( !aItem ) return;
388 387
389 Attendee *a = aItem->data(); 388 Attendee *a = aItem->data();
390 389
391 a->setName( mNameEdit->text() ); 390 a->setName( mNameEdit->text() );
392 a->setUid( mUidEdit->text() ); 391 a->setUid( mUidEdit->text() );
393 a->setEmail( mEmailEdit->text() ); 392 a->setEmail( mEmailEdit->text() );
394 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); 393 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) );
395 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); 394 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) );
396 a->setRSVP( mRsvpButton->isChecked() ); 395 a->setRSVP( mRsvpButton->isChecked() );
397 aItem->updateItem(); 396 aItem->updateItem();
398} 397}
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index ad1389f..94e1f4c 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,505 +1,504 @@
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 <qfile.h> 32#include <qfile.h>
33 33
34 34
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kiconloader.h> 38#include <kiconloader.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kfiledialog.h> 40#include <kfiledialog.h>
41#include <kstandarddirs.h> 41#include <kstandarddirs.h>
42 42
43#include <libkcal/todo.h> 43#include <libkcal/todo.h>
44#include <libkcal/event.h> 44#include <libkcal/event.h>
45#include <libkdepim/categoryselectdialog.h> 45#include <libkdepim/categoryselectdialog.h>
46#include <libkdepim/kdateedit.h> 46#include <libkdepim/kdateedit.h>
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49#include "koglobals.h" 49#include "koglobals.h"
50 50
51#include "koeditorgeneral.h" 51#include "koeditorgeneral.h"
52#include "kolocationbox.h" 52#include "kolocationbox.h"
53#include "koeditorgeneral.moc"
54#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
56#else 55#else
57#include <qapplication.h> 56#include <qapplication.h>
58#endif 57#endif
59 58
60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 59KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
61 QObject( parent, name) 60 QObject( parent, name)
62{ 61{
63} 62}
64 63
65KOEditorGeneral::~KOEditorGeneral() 64KOEditorGeneral::~KOEditorGeneral()
66{ 65{
67} 66}
68 67
69void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 68void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
70{ 69{
71 QGridLayout *headerLayout = new QGridLayout(topLayout); 70 QGridLayout *headerLayout = new QGridLayout(topLayout);
72 71
73#if 0 72#if 0
74 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 73 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
75 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 74 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
76#endif 75#endif
77 76
78 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 77 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
79 headerLayout->addWidget(summaryLabel,1,0); 78 headerLayout->addWidget(summaryLabel,1,0);
80 79
81 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 80 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
82 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 81 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
83 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 82 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
84 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 83 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
85 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 84 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
86 if ( QApplication::desktop()->width() > 320 ) 85 if ( QApplication::desktop()->width() > 320 )
87 mSummaryEdit->setMaximumHeight( hei +6 ); 86 mSummaryEdit->setMaximumHeight( hei +6 );
88 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 87 //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 } 88 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
90 // mSummaryEdit = new QLineEdit(parent); 89 // mSummaryEdit = new QLineEdit(parent);
91 headerLayout->addWidget(mSummaryEdit,1,1); 90 headerLayout->addWidget(mSummaryEdit,1,1);
92 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 91 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
93 92
94 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 93 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
95 headerLayout->addWidget(locationLabel,2,0); 94 headerLayout->addWidget(locationLabel,2,0);
96 95
97 mLocationEdit = new KOLocationBox(TRUE,parent,10); 96 mLocationEdit = new KOLocationBox(TRUE,parent,10);
98 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 97 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
99 if ( QApplication::desktop()->width() > 320 ) 98 if ( QApplication::desktop()->width() > 320 )
100 mLocationEdit->setMaximumHeight( hei + 6); 99 mLocationEdit->setMaximumHeight( hei + 6);
101 100
102 // mLocationEdit = new QLineEdit(parent); 101 // mLocationEdit = new QLineEdit(parent);
103 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 102 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
104 headerLayout->addWidget(mLocationEdit,2,1); 103 headerLayout->addWidget(mLocationEdit,2,1);
105 headerLayout->setColStretch( 1, 10); 104 headerLayout->setColStretch( 1, 10);
106} 105}
107void KOEditorGeneral::setFocusOn( int i ) 106void KOEditorGeneral::setFocusOn( int i )
108{ 107{
109 qApp->processEvents(); 108 qApp->processEvents();
110 if ( i == 1 ) { 109 if ( i == 1 ) {
111 mDescriptionEdit->setFocus(); 110 mDescriptionEdit->setFocus();
112 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 111 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
113 } 112 }
114 if ( i == 2 ) { 113 if ( i == 2 ) {
115 mSummaryEdit->setFocus(); 114 mSummaryEdit->setFocus();
116 } 115 }
117 116
118} 117}
119void KOEditorGeneral::editCategories() 118void KOEditorGeneral::editCategories()
120{ 119{
121 // qDebug("KOEditorGeneral::editCategories() "); 120 // qDebug("KOEditorGeneral::editCategories() ");
122 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 121 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
123 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 122 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
124 //KOGlobals::fitDialogToScreen( csd ); 123 //KOGlobals::fitDialogToScreen( csd );
125 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 124 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
126 csd->exec(); 125 csd->exec();
127 delete csd; 126 delete csd;
128} 127}
129void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 128void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
130{ 129{
131 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 130 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
132 131
133 mCategoriesButton = new QPushButton(parent); 132 mCategoriesButton = new QPushButton(parent);
134 mCategoriesButton->setText(i18n("Categories...")); 133 mCategoriesButton->setText(i18n("Categories..."));
135 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 134 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
136 categoriesLayout->addWidget(mCategoriesButton); 135 categoriesLayout->addWidget(mCategoriesButton);
137 136
138 mCategoriesLabel = new QLabel(parent); 137 mCategoriesLabel = new QLabel(parent);
139 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 138 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
140 categoriesLayout->addWidget(mCategoriesLabel,1); 139 categoriesLayout->addWidget(mCategoriesLabel,1);
141} 140}
142 141
143void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 142void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
144{ 143{
145 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 144 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
146 145
147 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 146 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
148 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 147 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
149 secrecyLayout->addWidget(mCancelBox); 148 secrecyLayout->addWidget(mCancelBox);
150 secrecyLayout->addWidget(secrecyLabel); 149 secrecyLayout->addWidget(secrecyLabel);
151 150
152 mSecrecyCombo = new QComboBox(parent); 151 mSecrecyCombo = new QComboBox(parent);
153 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 152 mSecrecyCombo->insertStringList(Incidence::secrecyList());
154 secrecyLayout->addWidget(mSecrecyCombo); 153 secrecyLayout->addWidget(mSecrecyCombo);
155} 154}
156 155
157void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 156void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
158{ 157{
159 mDescriptionEdit = new KTextEdit(parent); 158 mDescriptionEdit = new KTextEdit(parent);
160 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 159 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
161 mDescriptionEdit->append(""); 160 mDescriptionEdit->append("");
162 mDescriptionEdit->setReadOnly(false); 161 mDescriptionEdit->setReadOnly(false);
163 mDescriptionEdit->setOverwriteMode(false); 162 mDescriptionEdit->setOverwriteMode(false);
164 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 163 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
165 topLayout->addWidget(mDescriptionEdit); 164 topLayout->addWidget(mDescriptionEdit);
166#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
167 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 166 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
168#endif 167#endif
169 168
170} 169}
171 170
172void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 171void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
173{ 172{
174 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
175 174
176 //mAlarmBell = new QLabel(parent); 175 //mAlarmBell = new QLabel(parent);
177 //mAlarmBell->setPixmap(SmallIcon("bell")); 176 //mAlarmBell->setPixmap(SmallIcon("bell"));
178 //alarmLayout->addWidget(mAlarmBell); 177 //alarmLayout->addWidget(mAlarmBell);
179 if ( QApplication::desktop()->width() < 320 ) 178 if ( QApplication::desktop()->width() < 320 )
180 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 179 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
181 else 180 else
182 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 181 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
183 182
184 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 183 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
185 alarmLayout->addWidget(mAlarmButton); 184 alarmLayout->addWidget(mAlarmButton);
186 185
187 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 186 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
188 alarmLayout->addWidget(mAlarmTimeEdit); 187 alarmLayout->addWidget(mAlarmTimeEdit);
189 mAlarmIncrCombo = new QComboBox(false, parent); 188 mAlarmIncrCombo = new QComboBox(false, parent);
190 if ( QApplication::desktop()->width() < 320 ) { 189 if ( QApplication::desktop()->width() < 320 ) {
191 mAlarmIncrCombo->insertItem(i18n("min")); 190 mAlarmIncrCombo->insertItem(i18n("min"));
192 mAlarmIncrCombo->insertItem(i18n("hou")); 191 mAlarmIncrCombo->insertItem(i18n("hou"));
193 mAlarmIncrCombo->insertItem(i18n("day")); 192 mAlarmIncrCombo->insertItem(i18n("day"));
194 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 193 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
195 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 194 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
196 } else { 195 } else {
197 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 196 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
198 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 197 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
199 mAlarmIncrCombo->insertItem(i18n("day(s)")); 198 mAlarmIncrCombo->insertItem(i18n("day(s)"));
200 } 199 }
201 200
202 // mAlarmIncrCombo->setMinimumHeight(20); 201 // mAlarmIncrCombo->setMinimumHeight(20);
203 alarmLayout->addWidget(mAlarmIncrCombo); 202 alarmLayout->addWidget(mAlarmIncrCombo);
204 mAlarmSoundButton = new QPushButton(parent); 203 mAlarmSoundButton = new QPushButton(parent);
205 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 204 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
206 mAlarmSoundButton->setToggleButton(true); 205 mAlarmSoundButton->setToggleButton(true);
207 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 206 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
208 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 207 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
209 alarmLayout->addWidget(mAlarmSoundButton); 208 alarmLayout->addWidget(mAlarmSoundButton);
210 209
211 mAlarmProgramButton = new QPushButton(parent); 210 mAlarmProgramButton = new QPushButton(parent);
212 mAlarmProgramButton->setPixmap(SmallIcon("run")); 211 mAlarmProgramButton->setPixmap(SmallIcon("run"));
213 mAlarmProgramButton->setToggleButton(true); 212 mAlarmProgramButton->setToggleButton(true);
214 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 213 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
215 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 214 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
216 alarmLayout->addWidget(mAlarmProgramButton); 215 alarmLayout->addWidget(mAlarmProgramButton);
217 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 216 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
218 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 217 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
219 // if ( KOPrefs::instance()->mCompactDialogs ) { 218 // if ( KOPrefs::instance()->mCompactDialogs ) {
220 // mAlarmSoundButton->hide(); 219 // mAlarmSoundButton->hide();
221 // mAlarmProgramButton->hide(); 220 // mAlarmProgramButton->hide();
222 // } 221 // }
223} 222}
224 223
225void KOEditorGeneral::pickAlarmSound() 224void KOEditorGeneral::pickAlarmSound()
226{ 225{
227 226
228 //QString prefix = mAlarmSound; 227 //QString prefix = mAlarmSound;
229 if (!mAlarmSoundButton->isOn()) { 228 if (!mAlarmSoundButton->isOn()) {
230 //mAlarmSound = ""; 229 //mAlarmSound = "";
231 QToolTip::remove(mAlarmSoundButton); 230 QToolTip::remove(mAlarmSoundButton);
232 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 231 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
233 mAlarmProgramButton->setOn(true); 232 mAlarmProgramButton->setOn(true);
234 mAlarmSoundButton->setOn(false); 233 mAlarmSoundButton->setOn(false);
235 } else { 234 } else {
236 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 235 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
237 i18n("*.wav|Wav Files"), 0)); 236 i18n("*.wav|Wav Files"), 0));
238 if (!fileName.isEmpty()) { 237 if (!fileName.isEmpty()) {
239 mAlarmSound = fileName; 238 mAlarmSound = fileName;
240 QToolTip::remove(mAlarmSoundButton); 239 QToolTip::remove(mAlarmSoundButton);
241 QString dispStr = i18n("Playing '%1'").arg(fileName); 240 QString dispStr = i18n("Playing '%1'").arg(fileName);
242 QToolTip::add(mAlarmSoundButton, dispStr); 241 QToolTip::add(mAlarmSoundButton, dispStr);
243 mAlarmProgramButton->setOn(false); 242 mAlarmProgramButton->setOn(false);
244 mAlarmSoundButton->setOn(true); 243 mAlarmSoundButton->setOn(true);
245 } else { 244 } else {
246 mAlarmProgramButton->setOn(true); 245 mAlarmProgramButton->setOn(true);
247 mAlarmSoundButton->setOn(false); 246 mAlarmSoundButton->setOn(false);
248 247
249 } 248 }
250 } 249 }
251 250
252 if (mAlarmProgramButton->isOn()) 251 if (mAlarmProgramButton->isOn())
253 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram ); 252 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
254 if ( mAlarmSoundButton->isOn()) 253 if ( mAlarmSoundButton->isOn())
255 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + mAlarmSound ); 254 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + mAlarmSound );
256} 255}
257 256
258void KOEditorGeneral::pickAlarmProgram() 257void KOEditorGeneral::pickAlarmProgram()
259{ 258{
260 if (!mAlarmProgramButton->isOn()) { 259 if (!mAlarmProgramButton->isOn()) {
261 //mAlarmProgram = ""; 260 //mAlarmProgram = "";
262 QToolTip::remove(mAlarmProgramButton); 261 QToolTip::remove(mAlarmProgramButton);
263 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 262 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
264 mAlarmProgramButton->setOn(false); 263 mAlarmProgramButton->setOn(false);
265 mAlarmSoundButton->setOn(true); 264 mAlarmSoundButton->setOn(true);
266 } else { 265 } else {
267 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 266 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
268 if (!fileName.isEmpty()) { 267 if (!fileName.isEmpty()) {
269 mAlarmProgram = fileName; 268 mAlarmProgram = fileName;
270 QToolTip::remove(mAlarmProgramButton); 269 QToolTip::remove(mAlarmProgramButton);
271 QString dispStr = i18n("Running '%1'").arg(fileName); 270 QString dispStr = i18n("Running '%1'").arg(fileName);
272 QToolTip::add(mAlarmProgramButton, dispStr); 271 QToolTip::add(mAlarmProgramButton, dispStr);
273 mAlarmSoundButton->setOn(false); 272 mAlarmSoundButton->setOn(false);
274 mAlarmProgramButton->setOn(true); 273 mAlarmProgramButton->setOn(true);
275 } else { 274 } else {
276 mAlarmProgramButton->setOn(false); 275 mAlarmProgramButton->setOn(false);
277 mAlarmSoundButton->setOn(true); 276 mAlarmSoundButton->setOn(true);
278 } 277 }
279 } 278 }
280 if (mAlarmProgramButton->isOn()) 279 if (mAlarmProgramButton->isOn())
281 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram ); 280 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
282 if ( mAlarmSoundButton->isOn()) 281 if ( mAlarmSoundButton->isOn())
283 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound ); 282 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound );
284} 283}
285 284
286 285
287 286
288void KOEditorGeneral::enableAlarmEdit(bool enable) 287void KOEditorGeneral::enableAlarmEdit(bool enable)
289{ 288{
290 if ( enable ) { 289 if ( enable ) {
291 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 290 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
292 mAlarmSoundButton->setOn( true ); 291 mAlarmSoundButton->setOn( true );
293 if ( mAlarmSound.isEmpty() ) 292 if ( mAlarmSound.isEmpty() )
294 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 293 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
295 else { 294 else {
296 if ( ! QFile::exists( mAlarmSound ) ) 295 if ( ! QFile::exists( mAlarmSound ) )
297 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 296 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
298 } 297 }
299 } 298 }
300 if (mAlarmProgramButton->isOn()) 299 if (mAlarmProgramButton->isOn())
301 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram ); 300 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
302 if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 301 if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
303 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound ); 302 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound );
304 } 303 }
305 else { 304 else {
306 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled")); 305 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled"));
307 306
308 } 307 }
309 mAlarmTimeEdit->setEnabled(enable); 308 mAlarmTimeEdit->setEnabled(enable);
310 mAlarmSoundButton->setEnabled(enable); 309 mAlarmSoundButton->setEnabled(enable);
311 mAlarmProgramButton->setEnabled(enable); 310 mAlarmProgramButton->setEnabled(enable);
312 mAlarmIncrCombo->setEnabled(enable); 311 mAlarmIncrCombo->setEnabled(enable);
313} 312}
314 313
315void KOEditorGeneral::disableAlarmEdit(bool disable) 314void KOEditorGeneral::disableAlarmEdit(bool disable)
316{ 315{
317 enableAlarmEdit( !disable ); 316 enableAlarmEdit( !disable );
318} 317}
319 318
320void KOEditorGeneral::enableAlarm( bool enable ) 319void KOEditorGeneral::enableAlarm( bool enable )
321{ 320{
322 enableAlarmEdit( enable ); 321 enableAlarmEdit( enable );
323} 322}
324 323
325void KOEditorGeneral::alarmDisable(bool disable) 324void KOEditorGeneral::alarmDisable(bool disable)
326{ 325{
327 if (!disable) { 326 if (!disable) {
328 //mAlarmBell->setEnabled(true); 327 //mAlarmBell->setEnabled(true);
329 mAlarmButton->setEnabled(true); 328 mAlarmButton->setEnabled(true);
330 } else { 329 } else {
331 //mAlarmBell->setEnabled(false); 330 //mAlarmBell->setEnabled(false);
332 mAlarmButton->setEnabled(false); 331 mAlarmButton->setEnabled(false);
333 mAlarmButton->setChecked(false); 332 mAlarmButton->setChecked(false);
334 mAlarmTimeEdit->setEnabled(false); 333 mAlarmTimeEdit->setEnabled(false);
335 mAlarmSoundButton->setEnabled(false); 334 mAlarmSoundButton->setEnabled(false);
336 mAlarmProgramButton->setEnabled(false); 335 mAlarmProgramButton->setEnabled(false);
337 mAlarmIncrCombo->setEnabled(false); 336 mAlarmIncrCombo->setEnabled(false);
338 } 337 }
339} 338}
340 339
341void KOEditorGeneral::setCategories(const QString &str) 340void KOEditorGeneral::setCategories(const QString &str)
342{ 341{
343 mCategoriesLabel->setText(str); 342 mCategoriesLabel->setText(str);
344} 343}
345 344
346void KOEditorGeneral::setDefaults(bool allDay) 345void KOEditorGeneral::setDefaults(bool allDay)
347{ 346{
348#if 0 347#if 0
349 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 348 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
350#endif 349#endif
351 350
352 enableAlarmEdit( !allDay ); 351 enableAlarmEdit( !allDay );
353 352
354 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 353 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
355 int alarmTime; 354 int alarmTime;
356 int a[] = { 1,5,10,15,30,60,180, 1440 }; 355 int a[] = { 1,5,10,15,30,60,180, 1440 };
357 int index = KOPrefs::instance()->mAlarmTime; 356 int index = KOPrefs::instance()->mAlarmTime;
358 if (index < 0 || index > 7) { 357 if (index < 0 || index > 7) {
359 alarmTime = 15; 358 alarmTime = 15;
360 } else { 359 } else {
361 alarmTime = a[index]; 360 alarmTime = a[index];
362 } 361 }
363 mAlarmButton ->setChecked( false ); 362 mAlarmButton ->setChecked( false );
364 mAlarmTimeEdit->setValue(alarmTime); 363 mAlarmTimeEdit->setValue(alarmTime);
365 mAlarmIncrCombo->setCurrentItem(0); 364 mAlarmIncrCombo->setCurrentItem(0);
366 enableAlarmEdit( false ); 365 enableAlarmEdit( false );
367 //alarmDisable (false); 366 //alarmDisable (false);
368 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 367 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
369 mCancelBox->setChecked( false ); 368 mCancelBox->setChecked( false );
370 mSummaryEdit->setEditText(""); 369 mSummaryEdit->setEditText("");
371 mLocationEdit->setEditText(""); 370 mLocationEdit->setEditText("");
372 mDescriptionEdit->setText(""); 371 mDescriptionEdit->setText("");
373 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 372 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
374 setCategories(""); 373 setCategories("");
375} 374}
376void KOEditorGeneral::setSecrecy( int num ) 375void KOEditorGeneral::setSecrecy( int num )
377{ 376{
378 mSecrecyCombo->setCurrentItem(num); 377 mSecrecyCombo->setCurrentItem(num);
379} 378}
380void KOEditorGeneral::readIncidence(Incidence *event) 379void KOEditorGeneral::readIncidence(Incidence *event)
381{ 380{
382 381
383 mAlarmIncrCombo->setCurrentItem(0); 382 mAlarmIncrCombo->setCurrentItem(0);
384 mSummaryEdit->setEditText(event->summary()); 383 mSummaryEdit->setEditText(event->summary());
385 mLocationEdit->setEditText(event->location()); 384 mLocationEdit->setEditText(event->location());
386 mDescriptionEdit->setText(event->description()); 385 mDescriptionEdit->setText(event->description());
387 386
388#if 0 387#if 0
389 // organizer information 388 // organizer information
390 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 389 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
391#endif 390#endif
392 391
393 enableAlarmEdit( event->isAlarmEnabled() ); 392 enableAlarmEdit( event->isAlarmEnabled() );
394 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 393 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
395 if(!event->isAlarmEnabled()) { 394 if(!event->isAlarmEnabled()) {
396 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 395 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
397 int alarmTime; 396 int alarmTime;
398 int a[] = { 1,5,10,15,30,60,180, 1440 }; 397 int a[] = { 1,5,10,15,30,60,180, 1440 };
399 int index = KOPrefs::instance()->mAlarmTime; 398 int index = KOPrefs::instance()->mAlarmTime;
400 if (index < 0 || index > 7) { 399 if (index < 0 || index > 7) {
401 alarmTime = 15; 400 alarmTime = 15;
402 } else { 401 } else {
403 alarmTime = a[index]; 402 alarmTime = a[index];
404 } 403 }
405 mAlarmTimeEdit->setValue(alarmTime); 404 mAlarmTimeEdit->setValue(alarmTime);
406 } 405 }
407 mAlarmButton->setChecked( event->isAlarmEnabled() ); 406 mAlarmButton->setChecked( event->isAlarmEnabled() );
408 mSecrecyCombo->setCurrentItem(event->secrecy()); 407 mSecrecyCombo->setCurrentItem(event->secrecy());
409 mCancelBox->setChecked( event->cancelled() ); 408 mCancelBox->setChecked( event->cancelled() );
410 mAlarmProgramButton->setOn(false); 409 mAlarmProgramButton->setOn(false);
411 mAlarmSoundButton->setOn(false); 410 mAlarmSoundButton->setOn(false);
412 411
413 // set up alarm stuff 412 // set up alarm stuff
414 QPtrList<Alarm> alarms = event->alarms(); 413 QPtrList<Alarm> alarms = event->alarms();
415 Alarm* alarm; 414 Alarm* alarm;
416 mAlarmIncrCombo->setCurrentItem(0); 415 mAlarmIncrCombo->setCurrentItem(0);
417 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 416 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
418 int offset; 417 int offset;
419 if ( alarm->hasTime() ) { 418 if ( alarm->hasTime() ) {
420 QDateTime t = alarm->time(); 419 QDateTime t = alarm->time();
421 offset = event->dtStart().secsTo( t ); 420 offset = event->dtStart().secsTo( t );
422 } else { 421 } else {
423 offset = alarm->startOffset().asSeconds(); 422 offset = alarm->startOffset().asSeconds();
424 } 423 }
425 if ( offset != 0 ) { 424 if ( offset != 0 ) {
426 offset = offset / -60; // make minutes 425 offset = offset / -60; // make minutes
427 if (offset % 60 == 0) { // divides evenly into hours? 426 if (offset % 60 == 0) { // divides evenly into hours?
428 offset = offset / 60; 427 offset = offset / 60;
429 mAlarmIncrCombo->setCurrentItem(1); 428 mAlarmIncrCombo->setCurrentItem(1);
430 if (offset % 24 == 0) { // divides evenly into days? 429 if (offset % 24 == 0) { // divides evenly into days?
431 offset = offset / 24; 430 offset = offset / 24;
432 mAlarmIncrCombo->setCurrentItem(2); 431 mAlarmIncrCombo->setCurrentItem(2);
433 } 432 }
434 } 433 }
435 } 434 }
436 mAlarmTimeEdit->setValue( offset ); 435 mAlarmTimeEdit->setValue( offset );
437 if (alarm->type() == Alarm::Procedure) { 436 if (alarm->type() == Alarm::Procedure) {
438 437
439 mAlarmProgram = alarm->programFile(); 438 mAlarmProgram = alarm->programFile();
440 mAlarmProgramButton->setOn(true); 439 mAlarmProgramButton->setOn(true);
441 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 440 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
442 QToolTip::add(mAlarmProgramButton, dispStr); 441 QToolTip::add(mAlarmProgramButton, dispStr);
443 } 442 }
444 else if (alarm->type() == Alarm::Audio) { 443 else if (alarm->type() == Alarm::Audio) {
445 mAlarmSound = alarm->audioFile(); 444 mAlarmSound = alarm->audioFile();
446 if ( ! QFile::exists( mAlarmSound ) ) 445 if ( ! QFile::exists( mAlarmSound ) )
447 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 446 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
448 mAlarmSoundButton->setOn(true); 447 mAlarmSoundButton->setOn(true);
449 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 448 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
450 QToolTip::add(mAlarmSoundButton, dispStr); 449 QToolTip::add(mAlarmSoundButton, dispStr);
451 } 450 }
452 mAlarmButton->setChecked(alarm->enabled()); 451 mAlarmButton->setChecked(alarm->enabled());
453 enableAlarmEdit( alarm->enabled() ); 452 enableAlarmEdit( alarm->enabled() );
454 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 453 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
455 // TODO: Deal with multiple alarms 454 // TODO: Deal with multiple alarms
456 break; // For now, stop after the first alarm 455 break; // For now, stop after the first alarm
457 } 456 }
458 457
459 setCategories(event->categoriesStr()); 458 setCategories(event->categoriesStr());
460} 459}
461 460
462void KOEditorGeneral::writeIncidence(Incidence *event) 461void KOEditorGeneral::writeIncidence(Incidence *event)
463{ 462{
464 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 463 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
465 mLocationEdit->save(KOLocationBox::LOCATION); 464 mLocationEdit->save(KOLocationBox::LOCATION);
466 event->setSummary(mSummaryEdit->currentText()); 465 event->setSummary(mSummaryEdit->currentText());
467 event->setLocation(mLocationEdit->currentText()); 466 event->setLocation(mLocationEdit->currentText());
468 event->setDescription(mDescriptionEdit->text()); 467 event->setDescription(mDescriptionEdit->text());
469 event->setCategories(mCategoriesLabel->text()); 468 event->setCategories(mCategoriesLabel->text());
470 event->setSecrecy(mSecrecyCombo->currentItem()); 469 event->setSecrecy(mSecrecyCombo->currentItem());
471 event->setCancelled(mCancelBox->isChecked() );; 470 event->setCancelled(mCancelBox->isChecked() );;
472 // alarm stuff 471 // alarm stuff
473 if (mAlarmButton->isChecked()) { 472 if (mAlarmButton->isChecked()) {
474 if (event->alarms().count() == 0) 473 if (event->alarms().count() == 0)
475 event->newAlarm(); 474 event->newAlarm();
476 QPtrList<Alarm> alarms = event->alarms(); 475 QPtrList<Alarm> alarms = event->alarms();
477 Alarm *alarm; 476 Alarm *alarm;
478 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 477 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
479 alarm->setEnabled(true); 478 alarm->setEnabled(true);
480 int j = mAlarmTimeEdit->value()* -60; 479 int j = mAlarmTimeEdit->value()* -60;
481 if (mAlarmIncrCombo->currentItem() == 1) 480 if (mAlarmIncrCombo->currentItem() == 1)
482 j = j * 60; 481 j = j * 60;
483 else if (mAlarmIncrCombo->currentItem() == 2) 482 else if (mAlarmIncrCombo->currentItem() == 2)
484 j = j * (60 * 24); 483 j = j * (60 * 24);
485 alarm->setStartOffset( j ); 484 alarm->setStartOffset( j );
486 485
487 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 486 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
488 alarm->setProcedureAlarm(mAlarmProgram); 487 alarm->setProcedureAlarm(mAlarmProgram);
489 } 488 }
490 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 489 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
491 alarm->setAudioAlarm(mAlarmSound); 490 alarm->setAudioAlarm(mAlarmSound);
492 else 491 else
493 alarm->setType(Alarm::Invalid); 492 alarm->setType(Alarm::Invalid);
494 //alarm->setAudioAlarm("default"); 493 //alarm->setAudioAlarm("default");
495 // TODO: Deal with multiple alarms 494 // TODO: Deal with multiple alarms
496 break; // For now, stop after the first alarm 495 break; // For now, stop after the first alarm
497 } 496 }
498 } else { 497 } else {
499 Alarm* alarm = event->alarms().first(); 498 Alarm* alarm = event->alarms().first();
500 if ( alarm ) { 499 if ( alarm ) {
501 alarm->setEnabled(false); 500 alarm->setEnabled(false);
502 alarm->setType(Alarm::Invalid); 501 alarm->setType(Alarm::Invalid);
503 } 502 }
504 } 503 }
505} 504}
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp
index 9b93e7e..42c3df1 100644
--- a/korganizer/koeditorgeneralevent.cpp
+++ b/korganizer/koeditorgeneralevent.cpp
@@ -1,443 +1,442 @@
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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qvgroupbox.h> 28#include <qvgroupbox.h>
29#include <qwidgetstack.h> 29#include <qwidgetstack.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kiconloader.h> 35#include <kiconloader.h>
36#include <kmessagebox.h> 36#include <kmessagebox.h>
37#include <kfiledialog.h> 37#include <kfiledialog.h>
38#include <kstandarddirs.h> 38#include <kstandarddirs.h>
39 39
40#include <libkcal/event.h> 40#include <libkcal/event.h>
41 41
42#include <libkdepim/kdateedit.h> 42#include <libkdepim/kdateedit.h>
43 43
44#include "koprefs.h" 44#include "koprefs.h"
45 45
46#include "koeditorgeneralevent.h" 46#include "koeditorgeneralevent.h"
47#include "kolocationbox.h" 47#include "kolocationbox.h"
48#include "koeditorgeneralevent.moc"
49 48
50KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, 49KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent,
51 const char* name) : 50 const char* name) :
52 KOEditorGeneral( parent, name) 51 KOEditorGeneral( parent, name)
53{ 52{
54 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 53 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
55 SLOT(setDuration())); 54 SLOT(setDuration()));
56 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 55 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
57 SLOT(emitDateTimeStr())); 56 SLOT(emitDateTimeStr()));
58} 57}
59 58
60KOEditorGeneralEvent::~KOEditorGeneralEvent() 59KOEditorGeneralEvent::~KOEditorGeneralEvent()
61{ 60{
62} 61}
63 62
64void KOEditorGeneralEvent::finishSetup() 63void KOEditorGeneralEvent::finishSetup()
65{ 64{
66 65
67 //disabled 66 //disabled
68// QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); 67// QWidget::setTabOrder( mSummaryEdit, mLocationEdit );
69// QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); 68// QWidget::setTabOrder( mLocationEdit, mStartDateEdit );
70// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); 69// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit );
71// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); 70// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit );
72// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); 71// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit );
73// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); 72// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton );
74// QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); 73// QWidget::setTabOrder( mNoTimeButton, mAlarmButton );
75// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); 74// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit );
76// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); 75// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton );
77// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); 76// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo );
78// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit ); 77// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit );
79 78
80 79
81 80
82 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 81 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
83 mSummaryEdit->setFocus(); 82 mSummaryEdit->setFocus();
84} 83}
85 84
86void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) 85void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout)
87{ 86{
88 QBoxLayout *timeLayout = new QVBoxLayout(topLayout); 87 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
89 88
90 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, 89 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
91 i18n("Date && Time"),parent); 90 i18n("Date && Time"),parent);
92 timeLayout->addWidget(timeGroupBox); 91 timeLayout->addWidget(timeGroupBox);
93 92
94 timeGroupBox->layout()->setSpacing( 0 ); 93 timeGroupBox->layout()->setSpacing( 0 );
95 timeGroupBox->layout()->setMargin( 5 ); 94 timeGroupBox->layout()->setMargin( 5 );
96 QFrame *timeBoxFrame = new QFrame(timeGroupBox); 95 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
97 96
98 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3); 97 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3);
99 layoutTimeBox->setSpacing(topLayout->spacing()); 98 layoutTimeBox->setSpacing(topLayout->spacing());
100 99
101 mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame); 100 mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame);
102 layoutTimeBox->addWidget(mStartDateLabel,0,0); 101 layoutTimeBox->addWidget(mStartDateLabel,0,0);
103 102
104 mStartDateEdit = new KDateEdit(timeBoxFrame); 103 mStartDateEdit = new KDateEdit(timeBoxFrame);
105 layoutTimeBox->addWidget(mStartDateEdit,0,1); 104 layoutTimeBox->addWidget(mStartDateEdit,0,1);
106 105
107 mStartTimeEdit = new KOTimeEdit(timeBoxFrame); 106 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
108 layoutTimeBox->addWidget(mStartTimeEdit,0,2); 107 layoutTimeBox->addWidget(mStartTimeEdit,0,2);
109 108
110 109
111 mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame); 110 mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame);
112 layoutTimeBox->addWidget(mEndDateLabel,1,0); 111 layoutTimeBox->addWidget(mEndDateLabel,1,0);
113 112
114 mEndDateEdit = new KDateEdit(timeBoxFrame); 113 mEndDateEdit = new KDateEdit(timeBoxFrame);
115 layoutTimeBox->addWidget(mEndDateEdit,1,1); 114 layoutTimeBox->addWidget(mEndDateEdit,1,1);
116 115
117 mEndTimeEdit = new KOTimeEdit(timeBoxFrame); 116 mEndTimeEdit = new KOTimeEdit(timeBoxFrame);
118 layoutTimeBox->addWidget(mEndTimeEdit,1,2); 117 layoutTimeBox->addWidget(mEndTimeEdit,1,2);
119 QWidget* duration = new QWidget( timeBoxFrame ); 118 QWidget* duration = new QWidget( timeBoxFrame );
120 QHBoxLayout *flagsBox = new QHBoxLayout( duration ); 119 QHBoxLayout *flagsBox = new QHBoxLayout( duration );
121 mNoTimeButton = new QCheckBox(i18n("Allday"),duration); 120 mNoTimeButton = new QCheckBox(i18n("Allday"),duration);
122 flagsBox->addWidget(mNoTimeButton); 121 flagsBox->addWidget(mNoTimeButton);
123 connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool))); 122 connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool)));
124 mDurationLabel = new QLabel( duration ); 123 mDurationLabel = new QLabel( duration );
125 // if ( KOPrefs::instance()->mCompactDialogs ) { 124 // if ( KOPrefs::instance()->mCompactDialogs ) {
126 //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 ); 125 //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 );
127 //} else { 126 //} else {
128 flagsBox->addWidget( mDurationLabel ); 127 flagsBox->addWidget( mDurationLabel );
129 //} 128 //}
130 flagsBox->setStretchFactor(mDurationLabel, 10 ); 129 flagsBox->setStretchFactor(mDurationLabel, 10 );
131 mDurationLabel->setAlignment( AlignRight | AlignVCenter); 130 mDurationLabel->setAlignment( AlignRight | AlignVCenter);
132 layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 ); 131 layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 );
133 132
134 // time widgets are checked if they contain a valid time 133 // time widgets are checked if they contain a valid time
135 connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)), 134 connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)),
136 this, SLOT(startTimeChanged(QTime))); 135 this, SLOT(startTimeChanged(QTime)));
137 connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)), 136 connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)),
138 this, SLOT(endTimeChanged(QTime))); 137 this, SLOT(endTimeChanged(QTime)));
139 138
140 // date widgets are checked if they contain a valid date 139 // date widgets are checked if they contain a valid date
141 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), 140 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
142 this, SLOT(startDateChanged(QDate))); 141 this, SLOT(startDateChanged(QDate)));
143 connect(mEndDateEdit, SIGNAL(dateChanged(QDate)), 142 connect(mEndDateEdit, SIGNAL(dateChanged(QDate)),
144 this, SLOT(endDateChanged(QDate))); 143 this, SLOT(endDateChanged(QDate)));
145} 144}
146 145
147void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) 146void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout)
148{ 147{
149 QBoxLayout *classLayout = new QHBoxLayout(topLayout); 148 QBoxLayout *classLayout = new QHBoxLayout(topLayout);
150 149
151 QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); 150 QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent);
152 classLayout->addWidget(freeTimeLabel); 151 classLayout->addWidget(freeTimeLabel);
153 152
154 mFreeTimeCombo = new QComboBox(false, parent); 153 mFreeTimeCombo = new QComboBox(false, parent);
155 mFreeTimeCombo->insertItem(i18n("Busy")); 154 mFreeTimeCombo->insertItem(i18n("Busy"));
156 mFreeTimeCombo->insertItem(i18n("Free")); 155 mFreeTimeCombo->insertItem(i18n("Free"));
157 classLayout->addWidget(mFreeTimeCombo); 156 classLayout->addWidget(mFreeTimeCombo);
158} 157}
159 158
160void KOEditorGeneralEvent::timeStuffDisable(bool disable) 159void KOEditorGeneralEvent::timeStuffDisable(bool disable)
161{ 160{
162 mStartTimeEdit->setEnabled( !disable ); 161 mStartTimeEdit->setEnabled( !disable );
163 mEndTimeEdit->setEnabled( !disable ); 162 mEndTimeEdit->setEnabled( !disable );
164 163
165 setDuration(); 164 setDuration();
166 emitDateTimeStr(); 165 emitDateTimeStr();
167} 166}
168 167
169void KOEditorGeneralEvent::dontAssociateTime(bool noTime) 168void KOEditorGeneralEvent::dontAssociateTime(bool noTime)
170{ 169{
171 timeStuffDisable(noTime); 170 timeStuffDisable(noTime);
172 //if(alarmButton->isChecked()) alarmStuffDisable(noTime); 171 //if(alarmButton->isChecked()) alarmStuffDisable(noTime);
173 allDayChanged(noTime); 172 allDayChanged(noTime);
174} 173}
175 174
176void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) 175void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end)
177{ 176{
178// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; 177// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl;
179 178
180 mStartDateEdit->setDate(start.date()); 179 mStartDateEdit->setDate(start.date());
181 // KTimeEdit seems to emit some signals when setTime() is called. 180 // KTimeEdit seems to emit some signals when setTime() is called.
182 mStartTimeEdit->blockSignals( true ); 181 mStartTimeEdit->blockSignals( true );
183 mStartTimeEdit->setTime(start.time()); 182 mStartTimeEdit->setTime(start.time());
184 mStartTimeEdit->blockSignals( false ); 183 mStartTimeEdit->blockSignals( false );
185 mEndDateEdit->setDate(end.date()); 184 mEndDateEdit->setDate(end.date());
186 mEndTimeEdit->setTime(end.time()); 185 mEndTimeEdit->setTime(end.time());
187 186
188 mCurrStartDateTime = start; 187 mCurrStartDateTime = start;
189 mCurrEndDateTime = end; 188 mCurrEndDateTime = end;
190 189
191 setDuration(); 190 setDuration();
192 emitDateTimeStr(); 191 emitDateTimeStr();
193} 192}
194 193
195void KOEditorGeneralEvent::startTimeChanged(QTime newtime) 194void KOEditorGeneralEvent::startTimeChanged(QTime newtime)
196{ 195{
197 kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl; 196 kdDebug() << "KOEditorGeneralEvent::startTimeChanged() " << newtime.toString() << endl;
198 197
199 int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); 198 int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime);
200 199
201 mCurrStartDateTime.setTime(newtime); 200 mCurrStartDateTime.setTime(newtime);
202 201
203 // adjust end time so that the event has the same duration as before. 202 // adjust end time so that the event has the same duration as before.
204 mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); 203 mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep);
205 mEndTimeEdit->setTime(mCurrEndDateTime.time()); 204 mEndTimeEdit->setTime(mCurrEndDateTime.time());
206 mEndDateEdit->setDate(mCurrEndDateTime.date()); 205 mEndDateEdit->setDate(mCurrEndDateTime.date());
207 206
208 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 207 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
209} 208}
210 209
211void KOEditorGeneralEvent::endTimeChanged(QTime newtime) 210void KOEditorGeneralEvent::endTimeChanged(QTime newtime)
212{ 211{
213// kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl; 212// kdDebug() << "KOEditorGeneralEvent::endTimeChanged " << newtime.toString() << endl;
214 213
215 QDateTime newdt(mCurrEndDateTime.date(), newtime); 214 QDateTime newdt(mCurrEndDateTime.date(), newtime);
216 mCurrEndDateTime = newdt; 215 mCurrEndDateTime = newdt;
217 216
218 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 217 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
219} 218}
220 219
221void KOEditorGeneralEvent::startDateChanged(QDate newdate) 220void KOEditorGeneralEvent::startDateChanged(QDate newdate)
222{ 221{
223 int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); 222 int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime);
224 223
225 mCurrStartDateTime.setDate(newdate); 224 mCurrStartDateTime.setDate(newdate);
226 225
227 // adjust end date so that the event has the same duration as before 226 // adjust end date so that the event has the same duration as before
228 mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); 227 mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep));
229 mEndDateEdit->setDate(mCurrEndDateTime.date()); 228 mEndDateEdit->setDate(mCurrEndDateTime.date());
230 229
231 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 230 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
232} 231}
233 232
234void KOEditorGeneralEvent::endDateChanged(QDate newdate) 233void KOEditorGeneralEvent::endDateChanged(QDate newdate)
235{ 234{
236 QDateTime newdt(newdate, mCurrEndDateTime.time()); 235 QDateTime newdt(newdate, mCurrEndDateTime.time());
237 236
238 if(newdt < mCurrStartDateTime) { 237 if(newdt < mCurrStartDateTime) {
239 // oops, we can't let that happen. 238 // oops, we can't let that happen.
240 newdt = mCurrStartDateTime; 239 newdt = mCurrStartDateTime;
241 mEndDateEdit->setDate(newdt.date()); 240 mEndDateEdit->setDate(newdt.date());
242 mEndTimeEdit->setTime(newdt.time()); 241 mEndTimeEdit->setTime(newdt.time());
243 } 242 }
244 mCurrEndDateTime = newdt; 243 mCurrEndDateTime = newdt;
245 244
246 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 245 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
247} 246}
248 247
249void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) 248void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay)
250{ 249{
251 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 250 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
252 mLocationEdit->load(KOLocationBox::LOCATION); 251 mLocationEdit->load(KOLocationBox::LOCATION);
253 KOEditorGeneral::setDefaults(allDay); 252 KOEditorGeneral::setDefaults(allDay);
254 253
255 mNoTimeButton->setChecked(allDay); 254 mNoTimeButton->setChecked(allDay);
256 timeStuffDisable(allDay); 255 timeStuffDisable(allDay);
257 mFreeTimeCombo->setCurrentItem( 0 ); 256 mFreeTimeCombo->setCurrentItem( 0 );
258 setDateTimes(from,to); 257 setDateTimes(from,to);
259} 258}
260 259
261void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) 260void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl )
262{ 261{
263 QString tmpStr; 262 QString tmpStr;
264 263
265 if ( !tmpl ) { 264 if ( !tmpl ) {
266 // the rest is for the events only 265 // the rest is for the events only
267 mNoTimeButton->setChecked(event->doesFloat()); 266 mNoTimeButton->setChecked(event->doesFloat());
268 timeStuffDisable(event->doesFloat()); 267 timeStuffDisable(event->doesFloat());
269 268
270 setDateTimes(event->dtStart(),event->dtEnd()); 269 setDateTimes(event->dtStart(),event->dtEnd());
271 } 270 }
272 271
273 switch( event->transparency() ) { 272 switch( event->transparency() ) {
274 case Event::Transparent: 273 case Event::Transparent:
275 mFreeTimeCombo->setCurrentItem(1); 274 mFreeTimeCombo->setCurrentItem(1);
276 break; 275 break;
277 case Event::Opaque: 276 case Event::Opaque:
278 mFreeTimeCombo->setCurrentItem(0); 277 mFreeTimeCombo->setCurrentItem(0);
279 break; 278 break;
280 } 279 }
281 280
282 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 281 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
283 mLocationEdit->load(KOLocationBox::LOCATION); 282 mLocationEdit->load(KOLocationBox::LOCATION);
284 readIncidence(event); 283 readIncidence(event);
285} 284}
286 285
287void KOEditorGeneralEvent::writeEvent(Event *event) 286void KOEditorGeneralEvent::writeEvent(Event *event)
288{ 287{
289// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; 288// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl;
290 289
291 writeIncidence(event); 290 writeIncidence(event);
292 291
293 QDate tmpDate; 292 QDate tmpDate;
294 QTime tmpTime; 293 QTime tmpTime;
295 QDateTime tmpDT; 294 QDateTime tmpDT;
296 295
297 // temp. until something better happens. 296 // temp. until something better happens.
298 QString tmpStr; 297 QString tmpStr;
299 298
300 if (mNoTimeButton->isChecked()) { 299 if (mNoTimeButton->isChecked()) {
301 event->setFloats(true); 300 event->setFloats(true);
302 // need to change this. 301 // need to change this.
303 tmpDate = mStartDateEdit->date(); 302 tmpDate = mStartDateEdit->date();
304 tmpTime.setHMS(0,0,0); 303 tmpTime.setHMS(0,0,0);
305 tmpDT.setDate(tmpDate); 304 tmpDT.setDate(tmpDate);
306 tmpDT.setTime(tmpTime); 305 tmpDT.setTime(tmpTime);
307 event->setDtStart(tmpDT); 306 event->setDtStart(tmpDT);
308 307
309 tmpDate = mEndDateEdit->date(); 308 tmpDate = mEndDateEdit->date();
310 tmpTime.setHMS(0,0,0); 309 tmpTime.setHMS(0,0,0);
311 tmpDT.setDate(tmpDate); 310 tmpDT.setDate(tmpDate);
312 tmpDT.setTime(tmpTime); 311 tmpDT.setTime(tmpTime);
313 event->setDtEnd(tmpDT); 312 event->setDtEnd(tmpDT);
314 } else { 313 } else {
315 event->setFloats(false); 314 event->setFloats(false);
316 315
317 // set date/time end 316 // set date/time end
318 tmpDate = mEndDateEdit->date(); 317 tmpDate = mEndDateEdit->date();
319 tmpTime = mEndTimeEdit->getTime(); 318 tmpTime = mEndTimeEdit->getTime();
320 tmpDT.setDate(tmpDate); 319 tmpDT.setDate(tmpDate);
321 tmpDT.setTime(tmpTime); 320 tmpDT.setTime(tmpTime);
322 event->setDtEnd(tmpDT); 321 event->setDtEnd(tmpDT);
323 322
324 // set date/time start 323 // set date/time start
325 tmpDate = mStartDateEdit->date(); 324 tmpDate = mStartDateEdit->date();
326 tmpTime = mStartTimeEdit->getTime(); 325 tmpTime = mStartTimeEdit->getTime();
327 tmpDT.setDate(tmpDate); 326 tmpDT.setDate(tmpDate);
328 tmpDT.setTime(tmpTime); 327 tmpDT.setTime(tmpTime);
329 event->setDtStart(tmpDT); 328 event->setDtStart(tmpDT);
330 } // check for float 329 } // check for float
331 mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); 330 mSummaryEdit->save(KOLocationBox::SUMMARYEVENT);
332 331
333 event->setTransparency(mFreeTimeCombo->currentItem() > 0 332 event->setTransparency(mFreeTimeCombo->currentItem() > 0
334 ? KCal::Event::Transparent 333 ? KCal::Event::Transparent
335 : KCal::Event::Opaque); 334 : KCal::Event::Opaque);
336 335
337// kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; 336// kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl;
338} 337}
339 338
340void KOEditorGeneralEvent::setDuration() 339void KOEditorGeneralEvent::setDuration()
341{ 340{
342 QString tmpStr = "", catStr; 341 QString tmpStr = "", catStr;
343 int hourdiff, minutediff; 342 int hourdiff, minutediff;
344 // end<date is an accepted temporary state while typing, but don't show 343 // end<date is an accepted temporary state while typing, but don't show
345 // any duration if this happens 344 // any duration if this happens
346 if(mCurrEndDateTime >= mCurrStartDateTime) { 345 if(mCurrEndDateTime >= mCurrStartDateTime) {
347 346
348 if (mNoTimeButton->isChecked()) { 347 if (mNoTimeButton->isChecked()) {
349 int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; 348 int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1;
350 tmpStr = i18n("Duration: "); 349 tmpStr = i18n("Duration: ");
351 tmpStr.append(i18n("1 Day","%n Days",daydiff)); 350 tmpStr.append(i18n("1 Day","%n Days",daydiff));
352 } else { 351 } else {
353 int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); 352 int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime );
354 hourdiff = secto / 3600; 353 hourdiff = secto / 3600;
355 minutediff = (secto/60 ) % 60; 354 minutediff = (secto/60 ) % 60;
356 if (hourdiff || minutediff){ 355 if (hourdiff || minutediff){
357 tmpStr = i18n("Duration: "); 356 tmpStr = i18n("Duration: ");
358 if (hourdiff){ 357 if (hourdiff){
359 catStr = i18n("1 h","%n h",hourdiff); 358 catStr = i18n("1 h","%n h",hourdiff);
360 tmpStr.append(catStr); 359 tmpStr.append(catStr);
361 } 360 }
362 if (hourdiff && minutediff){ 361 if (hourdiff && minutediff){
363 tmpStr += i18n(", "); 362 tmpStr += i18n(", ");
364 } 363 }
365 if (minutediff){ 364 if (minutediff){
366 catStr = i18n("1 min","%n min",minutediff); 365 catStr = i18n("1 min","%n min",minutediff);
367 tmpStr += catStr; 366 tmpStr += catStr;
368 } 367 }
369 } else tmpStr = ""; 368 } else tmpStr = "";
370 } 369 }
371 } 370 }
372 mDurationLabel->setText(tmpStr); 371 mDurationLabel->setText(tmpStr);
373} 372}
374 373
375void KOEditorGeneralEvent::emitDateTimeStr() 374void KOEditorGeneralEvent::emitDateTimeStr()
376{ 375{
377 KLocale *l = KGlobal::locale(); 376 KLocale *l = KGlobal::locale();
378 377
379 QString from,to; 378 QString from,to;
380 if (mNoTimeButton->isChecked()) { 379 if (mNoTimeButton->isChecked()) {
381 from = l->formatDate(mCurrStartDateTime.date()); 380 from = l->formatDate(mCurrStartDateTime.date());
382 to = l->formatDate(mCurrEndDateTime.date()); 381 to = l->formatDate(mCurrEndDateTime.date());
383 } else { 382 } else {
384 from = l->formatDateTime(mCurrStartDateTime); 383 from = l->formatDateTime(mCurrStartDateTime);
385 to = l->formatDateTime(mCurrEndDateTime); 384 to = l->formatDateTime(mCurrEndDateTime);
386 } 385 }
387 386
388 QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to) 387 QString str = i18n("From: %1 To: %2 %3").arg(from).arg(to)
389 .arg(mDurationLabel->text()); 388 .arg(mDurationLabel->text());
390 389
391 emit dateTimeStrChanged(str); 390 emit dateTimeStrChanged(str);
392} 391}
393 392
394bool KOEditorGeneralEvent::validateInput() 393bool KOEditorGeneralEvent::validateInput()
395{ 394{
396// kdDebug() << "KOEditorGeneralEvent::validateInput()" << endl; 395// kdDebug() << "KOEditorGeneralEvent::validateInput()" << endl;
397 396
398 if (!mNoTimeButton->isChecked()) { 397 if (!mNoTimeButton->isChecked()) {
399 if (!mStartTimeEdit->inputIsValid()) { 398 if (!mStartTimeEdit->inputIsValid()) {
400 KMessageBox::sorry( 0, 399 KMessageBox::sorry( 0,
401 i18n("Please specify a valid start time, for example '%1'.") 400 i18n("Please specify a valid start time, for example '%1'.")
402 .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) ); 401 .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) );
403 return false; 402 return false;
404 } 403 }
405 404
406 if (!mEndTimeEdit->inputIsValid()) { 405 if (!mEndTimeEdit->inputIsValid()) {
407 KMessageBox::sorry( 0, 406 KMessageBox::sorry( 0,
408 i18n("Please specify a valid end time, for example '%1'.") 407 i18n("Please specify a valid end time, for example '%1'.")
409 .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) ); 408 .arg( KGlobal::locale()->formatTime( QTime::currentTime() ) ) );
410 return false; 409 return false;
411 } 410 }
412 } 411 }
413 412
414 if (!mStartDateEdit->inputIsValid()) { 413 if (!mStartDateEdit->inputIsValid()) {
415 KMessageBox::sorry( 0, 414 KMessageBox::sorry( 0,
416 i18n("Please specify a valid start date, for example '%1'.") 415 i18n("Please specify a valid start date, for example '%1'.")
417 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); 416 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) );
418 return false; 417 return false;
419 } 418 }
420 419
421 if (!mEndDateEdit->inputIsValid()) { 420 if (!mEndDateEdit->inputIsValid()) {
422 KMessageBox::sorry( 0, 421 KMessageBox::sorry( 0,
423 i18n("Please specify a valid end date, for example '%1'.") 422 i18n("Please specify a valid end date, for example '%1'.")
424 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) ); 423 .arg( KGlobal::locale()->formatDate( QDate::currentDate() ) ) );
425 return false; 424 return false;
426 } 425 }
427 426
428 QDateTime startDt,endDt; 427 QDateTime startDt,endDt;
429 startDt.setDate(mStartDateEdit->date()); 428 startDt.setDate(mStartDateEdit->date());
430 endDt.setDate(mEndDateEdit->date()); 429 endDt.setDate(mEndDateEdit->date());
431 if (!mNoTimeButton->isChecked()) { 430 if (!mNoTimeButton->isChecked()) {
432 startDt.setTime(mStartTimeEdit->getTime()); 431 startDt.setTime(mStartTimeEdit->getTime());
433 endDt.setTime(mEndTimeEdit->getTime()); 432 endDt.setTime(mEndTimeEdit->getTime());
434 } 433 }
435 434
436 if (startDt > endDt) { 435 if (startDt > endDt) {
437 KMessageBox::sorry(0,i18n("The event ends before it starts.\n" 436 KMessageBox::sorry(0,i18n("The event ends before it starts.\n"
438 "Please correct dates and times.")); 437 "Please correct dates and times."));
439 return false; 438 return false;
440 } 439 }
441 440
442 return KOEditorGeneral::validateInput(); 441 return KOEditorGeneral::validateInput();
443} 442}
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index 57837bb..7db7da0 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -1,467 +1,466 @@
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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.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 32
33#include <kglobal.h> 33#include <kglobal.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kiconloader.h> 35#include <kiconloader.h>
36#include <kmessagebox.h> 36#include <kmessagebox.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <krestrictedline.h> 38#include <krestrictedline.h>
39#include <kstandarddirs.h> 39#include <kstandarddirs.h>
40#include <kfiledialog.h> 40#include <kfiledialog.h>
41 41
42#include <libkcal/todo.h> 42#include <libkcal/todo.h>
43 43
44#include <libkdepim/kdateedit.h> 44#include <libkdepim/kdateedit.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "ktimeedit.h" 47#include "ktimeedit.h"
48 48
49#include "koeditorgeneraltodo.h" 49#include "koeditorgeneraltodo.h"
50#include "kolocationbox.h" 50#include "kolocationbox.h"
51#include "koeditorgeneraltodo.moc"
52 51
53KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, 52KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent,
54 const char* name) 53 const char* name)
55 : KOEditorGeneral( parent, name) 54 : KOEditorGeneral( parent, name)
56{ 55{
57} 56}
58 57
59KOEditorGeneralTodo::~KOEditorGeneralTodo() 58KOEditorGeneralTodo::~KOEditorGeneralTodo()
60{ 59{
61} 60}
62 61
63void KOEditorGeneralTodo::finishSetup() 62void KOEditorGeneralTodo::finishSetup()
64{ 63{
65 64
66// QWidget::setTabOrder(mSummaryEdit, mLocationEdit); 65// QWidget::setTabOrder(mSummaryEdit, mLocationEdit);
67// QWidget::setTabOrder(mLocationEdit, mDueCheck); 66// QWidget::setTabOrder(mLocationEdit, mDueCheck);
68// QWidget::setTabOrder(mDueCheck, mDueDateEdit); 67// QWidget::setTabOrder(mDueCheck, mDueDateEdit);
69// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); 68// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit);
70// QWidget::setTabOrder(mDueTimeEdit, mStartCheck); 69// QWidget::setTabOrder(mDueTimeEdit, mStartCheck);
71// QWidget::setTabOrder(mStartCheck, mStartDateEdit); 70// QWidget::setTabOrder(mStartCheck, mStartDateEdit);
72// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); 71// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit);
73// QWidget::setTabOrder(mStartTimeEdit, mTimeButton); 72// QWidget::setTabOrder(mStartTimeEdit, mTimeButton);
74// QWidget::setTabOrder(mTimeButton, mCompletedCombo); 73// QWidget::setTabOrder(mTimeButton, mCompletedCombo);
75// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); 74// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo);
76// QWidget::setTabOrder(mPriorityCombo, mAlarmButton); 75// QWidget::setTabOrder(mPriorityCombo, mAlarmButton);
77// QWidget::setTabOrder(mAlarmButton, mCategoriesButton); 76// QWidget::setTabOrder(mAlarmButton, mCategoriesButton);
78// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); 77// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo);
79// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); 78// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit);
80 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 79 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
81 mSummaryEdit->setFocus(); 80 mSummaryEdit->setFocus();
82} 81}
83 82
84void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) 83void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout)
85{ 84{
86 QBoxLayout *timeLayout = new QVBoxLayout(topLayout); 85 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
87 86
88 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, 87 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
89 i18n("Date && Time"),parent); 88 i18n("Date && Time"),parent);
90 timeLayout->addWidget(timeGroupBox); 89 timeLayout->addWidget(timeGroupBox);
91 timeGroupBox->layout()->setSpacing( 0 ); 90 timeGroupBox->layout()->setSpacing( 0 );
92 timeGroupBox->layout()->setMargin( 5 ); 91 timeGroupBox->layout()->setMargin( 5 );
93 QFrame *timeBoxFrame = new QFrame(timeGroupBox); 92 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
94 93
95 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); 94 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3);
96 layoutTimeBox->setSpacing(topLayout->spacing()); 95 layoutTimeBox->setSpacing(topLayout->spacing());
97 layoutTimeBox->setColStretch( 1, 1 ); 96 layoutTimeBox->setColStretch( 1, 1 );
98 97
99 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); 98 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame);
100 layoutTimeBox->addWidget(mDueCheck,0,0); 99 layoutTimeBox->addWidget(mDueCheck,0,0);
101 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); 100 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool)));
102 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); 101 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm()));
103 102
104 103
105 mDueDateEdit = new KDateEdit(timeBoxFrame); 104 mDueDateEdit = new KDateEdit(timeBoxFrame);
106 layoutTimeBox->addWidget(mDueDateEdit,0,1); 105 layoutTimeBox->addWidget(mDueDateEdit,0,1);
107 106
108 mDueTimeEdit = new KOTimeEdit(timeBoxFrame); 107 mDueTimeEdit = new KOTimeEdit(timeBoxFrame);
109 layoutTimeBox->addWidget(mDueTimeEdit,0,2); 108 layoutTimeBox->addWidget(mDueTimeEdit,0,2);
110 109
111 110
112 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); 111 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame);
113 layoutTimeBox->addWidget(mStartCheck,1,0); 112 layoutTimeBox->addWidget(mStartCheck,1,0);
114 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); 113 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool)));
115 114
116 mStartDateEdit = new KDateEdit(timeBoxFrame); 115 mStartDateEdit = new KDateEdit(timeBoxFrame);
117 layoutTimeBox->addWidget(mStartDateEdit,1,1); 116 layoutTimeBox->addWidget(mStartDateEdit,1,1);
118 117
119 mStartTimeEdit = new KOTimeEdit(timeBoxFrame); 118 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
120 layoutTimeBox->addWidget(mStartTimeEdit,1,2); 119 layoutTimeBox->addWidget(mStartTimeEdit,1,2);
121 120
122 121
123 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); 122 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame);
124 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); 123 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1);
125 124
126 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); 125 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool)));
127 126
128 // some more layouting 127 // some more layouting
129 //layoutTimeBox->setColStretch(3,1); 128 //layoutTimeBox->setColStretch(3,1);
130} 129}
131 130
132 131
133void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) 132void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout)
134{ 133{
135 mCompletedCombo = new QComboBox(parent); 134 mCompletedCombo = new QComboBox(parent);
136 // xgettext:no-c-format 135 // xgettext:no-c-format
137 mCompletedCombo->insertItem(i18n(" 0 %")); 136 mCompletedCombo->insertItem(i18n(" 0 %"));
138 // xgettext:no-c-format 137 // xgettext:no-c-format
139 mCompletedCombo->insertItem(i18n(" 20 %")); 138 mCompletedCombo->insertItem(i18n(" 20 %"));
140 // xgettext:no-c-format 139 // xgettext:no-c-format
141 mCompletedCombo->insertItem(i18n(" 40 %")); 140 mCompletedCombo->insertItem(i18n(" 40 %"));
142 // xgettext:no-c-format 141 // xgettext:no-c-format
143 mCompletedCombo->insertItem(i18n(" 60 %")); 142 mCompletedCombo->insertItem(i18n(" 60 %"));
144 // xgettext:no-c-format 143 // xgettext:no-c-format
145 mCompletedCombo->insertItem(i18n(" 80 %")); 144 mCompletedCombo->insertItem(i18n(" 80 %"));
146 // xgettext:no-c-format 145 // xgettext:no-c-format
147 mCompletedCombo->insertItem(i18n("100 %")); 146 mCompletedCombo->insertItem(i18n("100 %"));
148 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); 147 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int)));
149 topLayout->addWidget(mCompletedCombo); 148 topLayout->addWidget(mCompletedCombo);
150 149
151 mCompletedLabel = new QLabel(i18n("completed"),parent); 150 mCompletedLabel = new QLabel(i18n("completed"),parent);
152 topLayout->addWidget(mCompletedLabel); 151 topLayout->addWidget(mCompletedLabel);
153} 152}
154 153
155void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) 154void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout)
156{ 155{
157 156
158 QHBox* h = new QHBox ( parent ); 157 QHBox* h = new QHBox ( parent );
159 topLayout->addWidget( h ); 158 topLayout->addWidget( h );
160 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); 159 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h);
161 // topLayout->addWidget(priorityLabel); 160 // topLayout->addWidget(priorityLabel);
162 161
163 mPriorityCombo = new QComboBox( h ); 162 mPriorityCombo = new QComboBox( h );
164 mPriorityCombo->insertItem(i18n("1 (high)")); 163 mPriorityCombo->insertItem(i18n("1 (high)"));
165 mPriorityCombo->insertItem(i18n("2")); 164 mPriorityCombo->insertItem(i18n("2"));
166 mPriorityCombo->insertItem(i18n("3")); 165 mPriorityCombo->insertItem(i18n("3"));
167 mPriorityCombo->insertItem(i18n("4")); 166 mPriorityCombo->insertItem(i18n("4"));
168 mPriorityCombo->insertItem(i18n("5 (low)")); 167 mPriorityCombo->insertItem(i18n("5 (low)"));
169 //topLayout->addWidget(mPriorityCombo); 168 //topLayout->addWidget(mPriorityCombo);
170} 169}
171 170
172void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) 171void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout)
173{ 172{
174 QBoxLayout *statusLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *statusLayout = new QHBoxLayout(topLayout);
175 174
176 initCompletion( parent, statusLayout ); 175 initCompletion( parent, statusLayout );
177 176
178 statusLayout->addStretch( 1 ); 177 statusLayout->addStretch( 1 );
179 178
180 initPriority( parent, statusLayout ); 179 initPriority( parent, statusLayout );
181} 180}
182 181
183void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) 182void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
184{ 183{
185 184
186 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 185 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
187 mLocationEdit->load(KOLocationBox::LOCATION); 186 mLocationEdit->load(KOLocationBox::LOCATION);
188 KOEditorGeneral::setDefaults(allDay); 187 KOEditorGeneral::setDefaults(allDay);
189 188
190 mTimeButton->setChecked( !allDay ); 189 mTimeButton->setChecked( !allDay );
191 if(mTimeButton->isChecked()) { 190 if(mTimeButton->isChecked()) {
192 mTimeButton->setEnabled(true); 191 mTimeButton->setEnabled(true);
193 } 192 }
194 else { 193 else {
195 mTimeButton->setEnabled(false); 194 mTimeButton->setEnabled(false);
196 } 195 }
197 196
198 enableTimeEdits( !allDay ); 197 enableTimeEdits( !allDay );
199 198
200 mDueCheck->setChecked(false); 199 mDueCheck->setChecked(false);
201 enableDueEdit(false); 200 enableDueEdit(false);
202 201
203 alarmDisable(true); 202 alarmDisable(true);
204 203
205 mStartCheck->setChecked(false); 204 mStartCheck->setChecked(false);
206 enableStartEdit(false); 205 enableStartEdit(false);
207 206
208 mDueDateEdit->setDate(due.date()); 207 mDueDateEdit->setDate(due.date());
209 mDueTimeEdit->setTime(due.time()); 208 mDueTimeEdit->setTime(due.time());
210 209
211 mStartDateEdit->setDate(QDate::currentDate()); 210 mStartDateEdit->setDate(QDate::currentDate());
212 mStartTimeEdit->setTime(QTime::currentTime()); 211 mStartTimeEdit->setTime(QTime::currentTime());
213 212
214 mPriorityCombo->setCurrentItem(2); 213 mPriorityCombo->setCurrentItem(2);
215 mCompletedLabel->setText(i18n("completed"));; 214 mCompletedLabel->setText(i18n("completed"));;
216 mCompletedCombo->setCurrentItem(0); 215 mCompletedCombo->setCurrentItem(0);
217} 216}
218 217
219void KOEditorGeneralTodo::readTodo(Todo *todo) 218void KOEditorGeneralTodo::readTodo(Todo *todo)
220{ 219{
221 220
222 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 221 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
223 mLocationEdit->load(KOLocationBox::LOCATION); 222 mLocationEdit->load(KOLocationBox::LOCATION);
224 KOEditorGeneral::readIncidence(todo); 223 KOEditorGeneral::readIncidence(todo);
225 224
226 QDateTime dueDT; 225 QDateTime dueDT;
227 226
228 if (todo->hasDueDate()) { 227 if (todo->hasDueDate()) {
229 enableAlarmEdit(true); 228 enableAlarmEdit(true);
230 dueDT = todo->dtDue(); 229 dueDT = todo->dtDue();
231 mDueDateEdit->setDate(todo->dtDue().date()); 230 mDueDateEdit->setDate(todo->dtDue().date());
232 mDueTimeEdit->setTime(todo->dtDue().time()); 231 mDueTimeEdit->setTime(todo->dtDue().time());
233 mDueCheck->setChecked(true); 232 mDueCheck->setChecked(true);
234 } else { 233 } else {
235 alarmDisable(true); 234 alarmDisable(true);
236 mDueDateEdit->setEnabled(false); 235 mDueDateEdit->setEnabled(false);
237 mDueTimeEdit->setEnabled(false); 236 mDueTimeEdit->setEnabled(false);
238 mDueDateEdit->setDate(QDate::currentDate()); 237 mDueDateEdit->setDate(QDate::currentDate());
239 mDueTimeEdit->setTime(QTime::currentTime()); 238 mDueTimeEdit->setTime(QTime::currentTime());
240 mDueCheck->setChecked(false); 239 mDueCheck->setChecked(false);
241 } 240 }
242 241
243 if (todo->hasStartDate()) { 242 if (todo->hasStartDate()) {
244 mStartDateEdit->setDate(todo->dtStart().date()); 243 mStartDateEdit->setDate(todo->dtStart().date());
245 mStartTimeEdit->setTime(todo->dtStart().time()); 244 mStartTimeEdit->setTime(todo->dtStart().time());
246 mStartCheck->setChecked(true); 245 mStartCheck->setChecked(true);
247 } else { 246 } else {
248 mStartDateEdit->setEnabled(false); 247 mStartDateEdit->setEnabled(false);
249 mStartTimeEdit->setEnabled(false); 248 mStartTimeEdit->setEnabled(false);
250 mStartDateEdit->setDate(QDate::currentDate()); 249 mStartDateEdit->setDate(QDate::currentDate());
251 mStartTimeEdit->setTime(QTime::currentTime()); 250 mStartTimeEdit->setTime(QTime::currentTime());
252 mStartCheck->setChecked(false); 251 mStartCheck->setChecked(false);
253 } 252 }
254 253
255 mTimeButton->setChecked( !todo->doesFloat() ); 254 mTimeButton->setChecked( !todo->doesFloat() );
256 255
257 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); 256 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
258 if (todo->isCompleted() && todo->hasCompletedDate()) { 257 if (todo->isCompleted() && todo->hasCompletedDate()) {
259 mCompleted = todo->completed(); 258 mCompleted = todo->completed();
260 } 259 }
261 setCompletedDate(); 260 setCompletedDate();
262 261
263 mPriorityCombo->setCurrentItem(todo->priority()-1); 262 mPriorityCombo->setCurrentItem(todo->priority()-1);
264} 263}
265 264
266void KOEditorGeneralTodo::writeTodo(Todo *todo) 265void KOEditorGeneralTodo::writeTodo(Todo *todo)
267{ 266{
268 KOEditorGeneral::writeIncidence(todo); 267 KOEditorGeneral::writeIncidence(todo);
269 268
270 // temp. until something better happens. 269 // temp. until something better happens.
271 QString tmpStr; 270 QString tmpStr;
272 271
273 todo->setHasDueDate(mDueCheck->isChecked()); 272 todo->setHasDueDate(mDueCheck->isChecked());
274 todo->setHasStartDate(mStartCheck->isChecked()); 273 todo->setHasStartDate(mStartCheck->isChecked());
275 274
276 QDate tmpDate; 275 QDate tmpDate;
277 QTime tmpTime; 276 QTime tmpTime;
278 QDateTime tmpDT; 277 QDateTime tmpDT;
279 if ( mTimeButton->isChecked() ) { 278 if ( mTimeButton->isChecked() ) {
280 todo->setFloats(false); 279 todo->setFloats(false);
281 280
282 // set due date/time 281 // set due date/time
283 tmpDate = mDueDateEdit->date(); 282 tmpDate = mDueDateEdit->date();
284 tmpTime = mDueTimeEdit->getTime(); 283 tmpTime = mDueTimeEdit->getTime();
285 tmpDT.setDate(tmpDate); 284 tmpDT.setDate(tmpDate);
286 tmpDT.setTime(tmpTime); 285 tmpDT.setTime(tmpTime);
287 todo->setDtDue(tmpDT); 286 todo->setDtDue(tmpDT);
288 287
289 // set start date/time 288 // set start date/time
290 tmpDate = mStartDateEdit->date(); 289 tmpDate = mStartDateEdit->date();
291 tmpTime = mStartTimeEdit->getTime(); 290 tmpTime = mStartTimeEdit->getTime();
292 tmpDT.setDate(tmpDate); 291 tmpDT.setDate(tmpDate);
293 tmpDT.setTime(tmpTime); 292 tmpDT.setTime(tmpTime);
294 todo->setDtStart(tmpDT); 293 todo->setDtStart(tmpDT);
295 } else { 294 } else {
296 todo->setFloats(true); 295 todo->setFloats(true);
297 296
298 // need to change this. 297 // need to change this.
299 tmpDate = mDueDateEdit->date(); 298 tmpDate = mDueDateEdit->date();
300 tmpTime.setHMS(0,0,0); 299 tmpTime.setHMS(0,0,0);
301 tmpDT.setDate(tmpDate); 300 tmpDT.setDate(tmpDate);
302 tmpDT.setTime(tmpTime); 301 tmpDT.setTime(tmpTime);
303 todo->setDtDue(tmpDT); 302 todo->setDtDue(tmpDT);
304 303
305 tmpDate = mStartDateEdit->date(); 304 tmpDate = mStartDateEdit->date();
306 tmpTime.setHMS(0,0,0); 305 tmpTime.setHMS(0,0,0);
307 tmpDT.setDate(tmpDate); 306 tmpDT.setDate(tmpDate);
308 tmpDT.setTime(tmpTime); 307 tmpDT.setTime(tmpTime);
309 todo->setDtStart(tmpDT); 308 todo->setDtStart(tmpDT);
310 } 309 }
311 310
312 todo->setPriority(mPriorityCombo->currentItem()+1); 311 todo->setPriority(mPriorityCombo->currentItem()+1);
313 312
314 // set completion state 313 // set completion state
315 todo->setPercentComplete(mCompletedCombo->currentItem() * 20); 314 todo->setPercentComplete(mCompletedCombo->currentItem() * 20);
316 315
317 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { 316 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) {
318 todo->setCompleted(mCompleted); 317 todo->setCompleted(mCompleted);
319 } 318 }
320 mSummaryEdit->save(KOLocationBox::SUMMARYTODO); 319 mSummaryEdit->save(KOLocationBox::SUMMARYTODO);
321} 320}
322 321
323void KOEditorGeneralTodo::enableDueEdit(bool enable) 322void KOEditorGeneralTodo::enableDueEdit(bool enable)
324{ 323{
325 mDueDateEdit->setEnabled( enable ); 324 mDueDateEdit->setEnabled( enable );
326 325
327 if(mDueCheck->isChecked() || mStartCheck->isChecked()) { 326 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
328 mTimeButton->setEnabled(true); 327 mTimeButton->setEnabled(true);
329 } 328 }
330 else { 329 else {
331 mTimeButton->setEnabled(false); 330 mTimeButton->setEnabled(false);
332 mTimeButton->setChecked(false); 331 mTimeButton->setChecked(false);
333 } 332 }
334 333
335 if (enable) { 334 if (enable) {
336 mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); 335 mDueTimeEdit->setEnabled( mTimeButton->isChecked() );
337 } else { 336 } else {
338 mDueTimeEdit->setEnabled( false ); 337 mDueTimeEdit->setEnabled( false );
339 } 338 }
340} 339}
341 340
342void KOEditorGeneralTodo::enableStartEdit( bool enable ) 341void KOEditorGeneralTodo::enableStartEdit( bool enable )
343{ 342{
344 mStartDateEdit->setEnabled( enable ); 343 mStartDateEdit->setEnabled( enable );
345 344
346 if(mDueCheck->isChecked() || mStartCheck->isChecked()) { 345 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
347 mTimeButton->setEnabled(true); 346 mTimeButton->setEnabled(true);
348 } 347 }
349 else { 348 else {
350 mTimeButton->setEnabled(false); 349 mTimeButton->setEnabled(false);
351 mTimeButton->setChecked(false); 350 mTimeButton->setChecked(false);
352 } 351 }
353 352
354 if (enable) { 353 if (enable) {
355 mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); 354 mStartTimeEdit->setEnabled( mTimeButton->isChecked() );
356 } else { 355 } else {
357 mStartTimeEdit->setEnabled( false ); 356 mStartTimeEdit->setEnabled( false );
358 } 357 }
359} 358}
360 359
361void KOEditorGeneralTodo::enableTimeEdits(bool enable) 360void KOEditorGeneralTodo::enableTimeEdits(bool enable)
362{ 361{
363 if(mStartCheck->isChecked()) { 362 if(mStartCheck->isChecked()) {
364 mStartTimeEdit->setEnabled( enable ); 363 mStartTimeEdit->setEnabled( enable );
365 } 364 }
366 if(mDueCheck->isChecked()) { 365 if(mDueCheck->isChecked()) {
367 mDueTimeEdit->setEnabled( enable ); 366 mDueTimeEdit->setEnabled( enable );
368 } 367 }
369} 368}
370 369
371void KOEditorGeneralTodo::showAlarm() 370void KOEditorGeneralTodo::showAlarm()
372{ 371{
373 if ( mDueCheck->isChecked() ) { 372 if ( mDueCheck->isChecked() ) {
374 alarmDisable(false); 373 alarmDisable(false);
375 } 374 }
376 else { 375 else {
377 alarmDisable(true); 376 alarmDisable(true);
378 } 377 }
379} 378}
380 379
381bool KOEditorGeneralTodo::validateInput() 380bool KOEditorGeneralTodo::validateInput()
382{ 381{
383 if (mDueCheck->isChecked()) { 382 if (mDueCheck->isChecked()) {
384 if (!mDueDateEdit->inputIsValid()) { 383 if (!mDueDateEdit->inputIsValid()) {
385 KMessageBox::sorry(0,i18n("Please specify a valid due date.")); 384 KMessageBox::sorry(0,i18n("Please specify a valid due date."));
386 return false; 385 return false;
387 } 386 }
388 if (mTimeButton->isChecked()) { 387 if (mTimeButton->isChecked()) {
389 if (!mDueTimeEdit->inputIsValid()) { 388 if (!mDueTimeEdit->inputIsValid()) {
390 KMessageBox::sorry(0,i18n("Please specify a valid due time.")); 389 KMessageBox::sorry(0,i18n("Please specify a valid due time."));
391 return false; 390 return false;
392 } 391 }
393 } 392 }
394 } 393 }
395 394
396 if (mStartCheck->isChecked()) { 395 if (mStartCheck->isChecked()) {
397 if (!mStartDateEdit->inputIsValid()) { 396 if (!mStartDateEdit->inputIsValid()) {
398 KMessageBox::sorry(0,i18n("Please specify a valid start date.")); 397 KMessageBox::sorry(0,i18n("Please specify a valid start date."));
399 return false; 398 return false;
400 } 399 }
401 if (mTimeButton->isChecked()) { 400 if (mTimeButton->isChecked()) {
402 if (!mStartTimeEdit->inputIsValid()) { 401 if (!mStartTimeEdit->inputIsValid()) {
403 KMessageBox::sorry(0,i18n("Please specify a valid start time.")); 402 KMessageBox::sorry(0,i18n("Please specify a valid start time."));
404 return false; 403 return false;
405 } 404 }
406 } 405 }
407 } 406 }
408 407
409 if (mStartCheck->isChecked() && mDueCheck->isChecked()) { 408 if (mStartCheck->isChecked() && mDueCheck->isChecked()) {
410 QDateTime startDate; 409 QDateTime startDate;
411 QDateTime dueDate; 410 QDateTime dueDate;
412 startDate.setDate(mStartDateEdit->date()); 411 startDate.setDate(mStartDateEdit->date());
413 dueDate.setDate(mDueDateEdit->date()); 412 dueDate.setDate(mDueDateEdit->date());
414 if (mTimeButton->isChecked()) { 413 if (mTimeButton->isChecked()) {
415 startDate.setTime(mStartTimeEdit->getTime()); 414 startDate.setTime(mStartTimeEdit->getTime());
416 dueDate.setTime(mDueTimeEdit->getTime()); 415 dueDate.setTime(mDueTimeEdit->getTime());
417 } 416 }
418 if (startDate > dueDate) { 417 if (startDate > dueDate) {
419 KMessageBox::sorry(0, 418 KMessageBox::sorry(0,
420 i18n("The start date cannot be after the due date.")); 419 i18n("The start date cannot be after the due date."));
421 return false; 420 return false;
422 } 421 }
423 } 422 }
424 423
425 return KOEditorGeneral::validateInput(); 424 return KOEditorGeneral::validateInput();
426} 425}
427 426
428void KOEditorGeneralTodo::completedChanged(int index) 427void KOEditorGeneralTodo::completedChanged(int index)
429{ 428{
430 if (index == 5) { 429 if (index == 5) {
431 mCompleted = QDateTime::currentDateTime(); 430 mCompleted = QDateTime::currentDateTime();
432 } 431 }
433 setCompletedDate(); 432 setCompletedDate();
434} 433}
435 434
436void KOEditorGeneralTodo::setCompletedDate() 435void KOEditorGeneralTodo::setCompletedDate()
437{ 436{
438 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { 437 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) {
439 mCompletedLabel->setText(i18n("completed on %1") 438 mCompletedLabel->setText(i18n("completed on %1")
440 .arg(KGlobal::locale()->formatDateTime(mCompleted))); 439 .arg(KGlobal::locale()->formatDateTime(mCompleted)));
441 } else { 440 } else {
442 mCompletedLabel->setText(i18n("completed")); 441 mCompletedLabel->setText(i18n("completed"));
443 } 442 }
444} 443}
445 444
446void KOEditorGeneralTodo::modified (Todo* todo, int modification) 445void KOEditorGeneralTodo::modified (Todo* todo, int modification)
447{ 446{
448 switch (modification) { 447 switch (modification) {
449 case KOGlobals::PRIORITY_MODIFIED: 448 case KOGlobals::PRIORITY_MODIFIED:
450 mPriorityCombo->setCurrentItem(todo->priority()-1); 449 mPriorityCombo->setCurrentItem(todo->priority()-1);
451 break; 450 break;
452 case KOGlobals::COMPLETION_MODIFIED: 451 case KOGlobals::COMPLETION_MODIFIED:
453 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); 452 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
454 if (todo->isCompleted() && todo->hasCompletedDate()) { 453 if (todo->isCompleted() && todo->hasCompletedDate()) {
455 mCompleted = todo->completed(); 454 mCompleted = todo->completed();
456 } 455 }
457 setCompletedDate(); 456 setCompletedDate();
458 break; 457 break;
459 case KOGlobals::CATEGORY_MODIFIED: 458 case KOGlobals::CATEGORY_MODIFIED:
460 setCategories (todo->categoriesStr ()); 459 setCategories (todo->categoriesStr ());
461 break; 460 break;
462 case KOGlobals::UNKNOWN_MODIFIED: // fall through 461 case KOGlobals::UNKNOWN_MODIFIED: // fall through
463 default: 462 default:
464 readTodo( todo ); 463 readTodo( todo );
465 break; 464 break;
466 } 465 }
467} 466}
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp
index d82172f..98356fe 100644
--- a/korganizer/koeditorrecurrence.cpp
+++ b/korganizer/koeditorrecurrence.cpp
@@ -1,1117 +1,1116 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000-2003 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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.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 <qlistbox.h> 32#include <qlistbox.h>
33#include <qspinbox.h> 33#include <qspinbox.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qapplication.h> 35#include <qapplication.h>
36 36
37#include <kdialog.h> 37#include <kdialog.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <knumvalidator.h> 42#include <knumvalidator.h>
43 43
44#include <libkcal/event.h> 44#include <libkcal/event.h>
45 45
46#include <libkdepim/kdateedit.h> 46#include <libkdepim/kdateedit.h>
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49 49
50#include "koeditorrecurrence.h" 50#include "koeditorrecurrence.h"
51#include "koeditorrecurrence.moc"
52 51
53/////////////////////////// RecurBase /////////////////////////////// 52/////////////////////////// RecurBase ///////////////////////////////
54 53
55RecurBase::RecurBase( QWidget *parent, const char *name ) : 54RecurBase::RecurBase( QWidget *parent, const char *name ) :
56 QWidget( parent, name ) 55 QWidget( parent, name )
57{ 56{
58 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); 57 mFrequencyEdit = new QSpinBox( 1, 9999, 1, this );
59 mFrequencyEdit->setValue( 1 ); 58 mFrequencyEdit->setValue( 1 );
60} 59}
61 60
62QWidget *RecurBase::frequencyEdit() 61QWidget *RecurBase::frequencyEdit()
63{ 62{
64 return mFrequencyEdit; 63 return mFrequencyEdit;
65} 64}
66 65
67void RecurBase::setFrequency( int f ) 66void RecurBase::setFrequency( int f )
68{ 67{
69 if ( f < 1 ) f = 1; 68 if ( f < 1 ) f = 1;
70 69
71 mFrequencyEdit->setValue( f ); 70 mFrequencyEdit->setValue( f );
72} 71}
73 72
74int RecurBase::frequency() 73int RecurBase::frequency()
75{ 74{
76 return mFrequencyEdit->value(); 75 return mFrequencyEdit->value();
77} 76}
78 77
79/////////////////////////// RecurDaily /////////////////////////////// 78/////////////////////////// RecurDaily ///////////////////////////////
80 79
81RecurDaily::RecurDaily( QWidget *parent, const char *name ) : 80RecurDaily::RecurDaily( QWidget *parent, const char *name ) :
82 RecurBase( parent, name ) 81 RecurBase( parent, name )
83{ 82{
84 QBoxLayout *topLayout = new QHBoxLayout( this ); 83 QBoxLayout *topLayout = new QHBoxLayout( this );
85 topLayout->setSpacing( KDialog::spacingHint() ); 84 topLayout->setSpacing( KDialog::spacingHint() );
86 85
87 QLabel *preLabel = new QLabel( i18n("Recur every"), this ); 86 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
88 topLayout->addWidget( preLabel ); 87 topLayout->addWidget( preLabel );
89 88
90 topLayout->addWidget( frequencyEdit() ); 89 topLayout->addWidget( frequencyEdit() );
91 90
92 QLabel *postLabel = new QLabel( i18n("day(s)"), this ); 91 QLabel *postLabel = new QLabel( i18n("day(s)"), this );
93 topLayout->addWidget( postLabel ); 92 topLayout->addWidget( postLabel );
94} 93}
95 94
96 95
97/////////////////////////// RecurWeekly /////////////////////////////// 96/////////////////////////// RecurWeekly ///////////////////////////////
98 97
99RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : 98RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) :
100 RecurBase( parent, name ) 99 RecurBase( parent, name )
101{ 100{
102 QBoxLayout *topLayout = new QVBoxLayout( this ); 101 QBoxLayout *topLayout = new QVBoxLayout( this );
103 topLayout->setSpacing( KDialog::spacingHint() ); 102 topLayout->setSpacing( KDialog::spacingHint() );
104 103
105 topLayout->addStretch( 1 ); 104 topLayout->addStretch( 1 );
106 105
107 QBoxLayout *weeksLayout = new QHBoxLayout( topLayout ); 106 QBoxLayout *weeksLayout = new QHBoxLayout( topLayout );
108 107
109 QLabel *preLabel = new QLabel( i18n("Recur every"), this ); 108 QLabel *preLabel = new QLabel( i18n("Recur every"), this );
110 weeksLayout->addWidget( preLabel ); 109 weeksLayout->addWidget( preLabel );
111 110
112 weeksLayout->addWidget( frequencyEdit() ); 111 weeksLayout->addWidget( frequencyEdit() );
113 112
114 QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); 113 QLabel *postLabel = new QLabel( i18n("week(s) on:"), this );
115 weeksLayout->addWidget( postLabel ); 114 weeksLayout->addWidget( postLabel );
116 115
117 QHBox *dayBox = new QHBox( this ); 116 QHBox *dayBox = new QHBox( this );
118 topLayout->addWidget( dayBox, 1, AlignVCenter ); 117 topLayout->addWidget( dayBox, 1, AlignVCenter );
119 // TODO: Respect start of week setting 118 // TODO: Respect start of week setting
120 for ( int i = 0; i < 7; ++i ) { 119 for ( int i = 0; i < 7; ++i ) {
121 QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); 120 QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true );
122 if ( KOPrefs::instance()->mCompactDialogs ) { 121 if ( KOPrefs::instance()->mCompactDialogs ) {
123 weekDayName = weekDayName.left( 1 ); 122 weekDayName = weekDayName.left( 1 );
124 } 123 }
125 mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox ); 124 mDayBoxes[ i ] = new QCheckBox( weekDayName, dayBox );
126 } 125 }
127 126
128 topLayout->addStretch( 1 ); 127 topLayout->addStretch( 1 );
129} 128}
130 129
131void RecurWeekly::setDays( const QBitArray &days ) 130void RecurWeekly::setDays( const QBitArray &days )
132{ 131{
133 for ( int i = 0; i < 7; ++i ) { 132 for ( int i = 0; i < 7; ++i ) {
134 mDayBoxes[ i ]->setChecked( days.testBit( i ) ); 133 mDayBoxes[ i ]->setChecked( days.testBit( i ) );
135 } 134 }
136} 135}
137 136
138QBitArray RecurWeekly::days() 137QBitArray RecurWeekly::days()
139{ 138{
140 QBitArray days( 7 ); 139 QBitArray days( 7 );
141 140
142 for ( int i = 0; i < 7; ++i ) { 141 for ( int i = 0; i < 7; ++i ) {
143 days.setBit( i, mDayBoxes[ i ]->isChecked() ); 142 days.setBit( i, mDayBoxes[ i ]->isChecked() );
144 } 143 }
145 144
146 return days; 145 return days;
147} 146}
148 147
149/////////////////////////// RecurMonthly /////////////////////////////// 148/////////////////////////// RecurMonthly ///////////////////////////////
150 149
151RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : 150RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) :
152 RecurBase( parent, name ) 151 RecurBase( parent, name )
153{ 152{
154 QBoxLayout *topLayout = new QVBoxLayout( this ); 153 QBoxLayout *topLayout = new QVBoxLayout( this );
155 topLayout->setSpacing( KDialog::spacingHint() ); 154 topLayout->setSpacing( KDialog::spacingHint() );
156 155
157 156
158 QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); 157 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
159 158
160 QLabel *preLabel = new QLabel( i18n("every"), this ); 159 QLabel *preLabel = new QLabel( i18n("every"), this );
161 freqLayout->addWidget( preLabel ); 160 freqLayout->addWidget( preLabel );
162 161
163 freqLayout->addWidget( frequencyEdit() ); 162 freqLayout->addWidget( frequencyEdit() );
164 163
165 QLabel *postLabel = new QLabel( i18n("month(s)"), this ); 164 QLabel *postLabel = new QLabel( i18n("month(s)"), this );
166 freqLayout->addWidget( postLabel ); 165 freqLayout->addWidget( postLabel );
167 166
168 167
169 QButtonGroup *buttonGroup = new QButtonGroup( this ); 168 QButtonGroup *buttonGroup = new QButtonGroup( this );
170 buttonGroup->setFrameStyle( QFrame::NoFrame ); 169 buttonGroup->setFrameStyle( QFrame::NoFrame );
171 topLayout->addWidget( buttonGroup, 1, AlignVCenter ); 170 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
172 171
173 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); 172 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
174 buttonLayout->setSpacing( KDialog::spacingHint() ); 173 buttonLayout->setSpacing( KDialog::spacingHint() );
175 174
176 175
177 QString recurOnText; 176 QString recurOnText;
178 if ( !KOPrefs::instance()->mCompactDialogs ) { 177 if ( !KOPrefs::instance()->mCompactDialogs ) {
179 recurOnText = i18n("Recur on the"); 178 recurOnText = i18n("Recur on the");
180 } 179 }
181 180
182 mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); 181 mByDayRadio = new QRadioButton( recurOnText, buttonGroup );
183 buttonLayout->addWidget( mByDayRadio, 0, 0 ); 182 buttonLayout->addWidget( mByDayRadio, 0, 0 );
184 183
185 mByDayCombo = new QComboBox( buttonGroup ); 184 mByDayCombo = new QComboBox( buttonGroup );
186 mByDayCombo->setSizeLimit( 7 ); 185 mByDayCombo->setSizeLimit( 7 );
187 mByDayCombo->insertItem( i18n("1st") ); 186 mByDayCombo->insertItem( i18n("1st") );
188 mByDayCombo->insertItem( i18n("2nd") ); 187 mByDayCombo->insertItem( i18n("2nd") );
189 mByDayCombo->insertItem( i18n("3rd") ); 188 mByDayCombo->insertItem( i18n("3rd") );
190 mByDayCombo->insertItem( i18n("4th") ); 189 mByDayCombo->insertItem( i18n("4th") );
191 mByDayCombo->insertItem( i18n("5th") ); 190 mByDayCombo->insertItem( i18n("5th") );
192 mByDayCombo->insertItem( i18n("6th") ); 191 mByDayCombo->insertItem( i18n("6th") );
193 mByDayCombo->insertItem( i18n("7th") ); 192 mByDayCombo->insertItem( i18n("7th") );
194 mByDayCombo->insertItem( i18n("8th") ); 193 mByDayCombo->insertItem( i18n("8th") );
195 mByDayCombo->insertItem( i18n("9th") ); 194 mByDayCombo->insertItem( i18n("9th") );
196 mByDayCombo->insertItem( i18n("10th") ); 195 mByDayCombo->insertItem( i18n("10th") );
197 mByDayCombo->insertItem( i18n("11th") ); 196 mByDayCombo->insertItem( i18n("11th") );
198 mByDayCombo->insertItem( i18n("12th") ); 197 mByDayCombo->insertItem( i18n("12th") );
199 mByDayCombo->insertItem( i18n("13th") ); 198 mByDayCombo->insertItem( i18n("13th") );
200 mByDayCombo->insertItem( i18n("14th") ); 199 mByDayCombo->insertItem( i18n("14th") );
201 mByDayCombo->insertItem( i18n("15th") ); 200 mByDayCombo->insertItem( i18n("15th") );
202 mByDayCombo->insertItem( i18n("16th") ); 201 mByDayCombo->insertItem( i18n("16th") );
203 mByDayCombo->insertItem( i18n("17th") ); 202 mByDayCombo->insertItem( i18n("17th") );
204 mByDayCombo->insertItem( i18n("18th") ); 203 mByDayCombo->insertItem( i18n("18th") );
205 mByDayCombo->insertItem( i18n("19th") ); 204 mByDayCombo->insertItem( i18n("19th") );
206 mByDayCombo->insertItem( i18n("20th") ); 205 mByDayCombo->insertItem( i18n("20th") );
207 mByDayCombo->insertItem( i18n("21st") ); 206 mByDayCombo->insertItem( i18n("21st") );
208 mByDayCombo->insertItem( i18n("22nd") ); 207 mByDayCombo->insertItem( i18n("22nd") );
209 mByDayCombo->insertItem( i18n("23rd") ); 208 mByDayCombo->insertItem( i18n("23rd") );
210 mByDayCombo->insertItem( i18n("24th") ); 209 mByDayCombo->insertItem( i18n("24th") );
211 mByDayCombo->insertItem( i18n("25th") ); 210 mByDayCombo->insertItem( i18n("25th") );
212 mByDayCombo->insertItem( i18n("26th") ); 211 mByDayCombo->insertItem( i18n("26th") );
213 mByDayCombo->insertItem( i18n("27th") ); 212 mByDayCombo->insertItem( i18n("27th") );
214 mByDayCombo->insertItem( i18n("28th") ); 213 mByDayCombo->insertItem( i18n("28th") );
215 mByDayCombo->insertItem( i18n("29th") ); 214 mByDayCombo->insertItem( i18n("29th") );
216 mByDayCombo->insertItem( i18n("30th") ); 215 mByDayCombo->insertItem( i18n("30th") );
217 mByDayCombo->insertItem( i18n("31st") ); 216 mByDayCombo->insertItem( i18n("31st") );
218 buttonLayout->addWidget( mByDayCombo, 0, 1 ); 217 buttonLayout->addWidget( mByDayCombo, 0, 1 );
219 218
220 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); 219 QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup );
221 buttonLayout->addWidget( byDayLabel, 0, 2 ); 220 buttonLayout->addWidget( byDayLabel, 0, 2 );
222 221
223 222
224 mByPosRadio = new QRadioButton( recurOnText, buttonGroup); 223 mByPosRadio = new QRadioButton( recurOnText, buttonGroup);
225 buttonLayout->addWidget( mByPosRadio, 1, 0 ); 224 buttonLayout->addWidget( mByPosRadio, 1, 0 );
226 225
227 mByPosCountCombo = new QComboBox( buttonGroup ); 226 mByPosCountCombo = new QComboBox( buttonGroup );
228 mByPosCountCombo->insertItem( i18n("1st") ); 227 mByPosCountCombo->insertItem( i18n("1st") );
229 mByPosCountCombo->insertItem( i18n("2nd") ); 228 mByPosCountCombo->insertItem( i18n("2nd") );
230 mByPosCountCombo->insertItem( i18n("3rd") ); 229 mByPosCountCombo->insertItem( i18n("3rd") );
231 mByPosCountCombo->insertItem( i18n("4th") ); 230 mByPosCountCombo->insertItem( i18n("4th") );
232 mByPosCountCombo->insertItem( i18n("5th") ); 231 mByPosCountCombo->insertItem( i18n("5th") );
233 buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); 232 buttonLayout->addWidget( mByPosCountCombo, 1, 1 );
234 233
235 mByPosWeekdayCombo = new QComboBox( buttonGroup ); 234 mByPosWeekdayCombo = new QComboBox( buttonGroup );
236 mByPosWeekdayCombo->insertItem( i18n("Monday") ); 235 mByPosWeekdayCombo->insertItem( i18n("Monday") );
237 mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); 236 mByPosWeekdayCombo->insertItem( i18n("Tuesday") );
238 mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); 237 mByPosWeekdayCombo->insertItem( i18n("Wednesday") );
239 mByPosWeekdayCombo->insertItem( i18n("Thursday") ); 238 mByPosWeekdayCombo->insertItem( i18n("Thursday") );
240 mByPosWeekdayCombo->insertItem( i18n("Friday") ); 239 mByPosWeekdayCombo->insertItem( i18n("Friday") );
241 mByPosWeekdayCombo->insertItem( i18n("Saturday") ); 240 mByPosWeekdayCombo->insertItem( i18n("Saturday") );
242 mByPosWeekdayCombo->insertItem( i18n("Sunday") ); 241 mByPosWeekdayCombo->insertItem( i18n("Sunday") );
243 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); 242 buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 );
244} 243}
245 244
246void RecurMonthly::setByDay( int day ) 245void RecurMonthly::setByDay( int day )
247{ 246{
248 mByDayRadio->setChecked( true ); 247 mByDayRadio->setChecked( true );
249 mByDayCombo->setCurrentItem( day ); 248 mByDayCombo->setCurrentItem( day );
250} 249}
251 250
252void RecurMonthly::setByPos( int count, int weekday ) 251void RecurMonthly::setByPos( int count, int weekday )
253{ 252{
254 mByPosRadio->setChecked( true ); 253 mByPosRadio->setChecked( true );
255 mByPosCountCombo->setCurrentItem( count ); 254 mByPosCountCombo->setCurrentItem( count );
256 mByPosWeekdayCombo->setCurrentItem( weekday ); 255 mByPosWeekdayCombo->setCurrentItem( weekday );
257} 256}
258 257
259bool RecurMonthly::byDay() 258bool RecurMonthly::byDay()
260{ 259{
261 return mByDayRadio->isChecked(); 260 return mByDayRadio->isChecked();
262} 261}
263 262
264bool RecurMonthly::byPos() 263bool RecurMonthly::byPos()
265{ 264{
266 return mByPosRadio->isChecked(); 265 return mByPosRadio->isChecked();
267} 266}
268 267
269int RecurMonthly::day() 268int RecurMonthly::day()
270{ 269{
271 return mByDayCombo->currentItem() + 1; 270 return mByDayCombo->currentItem() + 1;
272} 271}
273 272
274int RecurMonthly::count() 273int RecurMonthly::count()
275{ 274{
276 return mByPosCountCombo->currentItem() + 1; 275 return mByPosCountCombo->currentItem() + 1;
277} 276}
278 277
279int RecurMonthly::weekday() 278int RecurMonthly::weekday()
280{ 279{
281 return mByPosWeekdayCombo->currentItem(); 280 return mByPosWeekdayCombo->currentItem();
282} 281}
283 282
284/////////////////////////// RecurYearly /////////////////////////////// 283/////////////////////////// RecurYearly ///////////////////////////////
285 284
286RecurYearly::RecurYearly( QWidget *parent, const char *name ) : 285RecurYearly::RecurYearly( QWidget *parent, const char *name ) :
287 RecurBase( parent, name ) 286 RecurBase( parent, name )
288{ 287{
289 QBoxLayout *topLayout = new QVBoxLayout( this ); 288 QBoxLayout *topLayout = new QVBoxLayout( this );
290 topLayout->setSpacing( KDialog::spacingHint() ); 289 topLayout->setSpacing( KDialog::spacingHint() );
291 290
292 291
293 QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); 292 QBoxLayout *freqLayout = new QHBoxLayout( topLayout );
294 293
295 QLabel *preLabel = new QLabel( i18n("every"), this ); 294 QLabel *preLabel = new QLabel( i18n("every"), this );
296 freqLayout->addWidget( preLabel ); 295 freqLayout->addWidget( preLabel );
297 296
298 freqLayout->addWidget( frequencyEdit() ); 297 freqLayout->addWidget( frequencyEdit() );
299 298
300 QLabel *postLabel = new QLabel( i18n("year(s)"), this ); 299 QLabel *postLabel = new QLabel( i18n("year(s)"), this );
301 freqLayout->addWidget( postLabel ); 300 freqLayout->addWidget( postLabel );
302 301
303 302
304 QButtonGroup *buttonGroup = new QButtonGroup( this ); 303 QButtonGroup *buttonGroup = new QButtonGroup( this );
305 buttonGroup->setFrameStyle( QFrame::NoFrame ); 304 buttonGroup->setFrameStyle( QFrame::NoFrame );
306 topLayout->addWidget( buttonGroup, 1, AlignVCenter ); 305 topLayout->addWidget( buttonGroup, 1, AlignVCenter );
307 306
308 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); 307 QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 );
309 308
310 QString recurInMonthText; 309 QString recurInMonthText;
311 if ( !KOPrefs::instance()->mCompactDialogs ) { 310 if ( !KOPrefs::instance()->mCompactDialogs ) {
312 recurInMonthText = i18n("Recur in the month of"); 311 recurInMonthText = i18n("Recur in the month of");
313 } 312 }
314 313
315 mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup); 314 mByMonthRadio = new QRadioButton( recurInMonthText, buttonGroup);
316 buttonLayout->addWidget( mByMonthRadio, 0, 0 ); 315 buttonLayout->addWidget( mByMonthRadio, 0, 0 );
317 316
318 mByMonthCombo = new QComboBox( buttonGroup ); 317 mByMonthCombo = new QComboBox( buttonGroup );
319 mByMonthCombo->insertItem( i18n("January") ); 318 mByMonthCombo->insertItem( i18n("January") );
320 mByMonthCombo->insertItem( i18n("February") ); 319 mByMonthCombo->insertItem( i18n("February") );
321 mByMonthCombo->insertItem( i18n("March") ); 320 mByMonthCombo->insertItem( i18n("March") );
322 mByMonthCombo->insertItem( i18n("April") ); 321 mByMonthCombo->insertItem( i18n("April") );
323 mByMonthCombo->insertItem( i18n("May") ); 322 mByMonthCombo->insertItem( i18n("May") );
324 mByMonthCombo->insertItem( i18n("June") ); 323 mByMonthCombo->insertItem( i18n("June") );
325 mByMonthCombo->insertItem( i18n("July") ); 324 mByMonthCombo->insertItem( i18n("July") );
326 mByMonthCombo->insertItem( i18n("August") ); 325 mByMonthCombo->insertItem( i18n("August") );
327 mByMonthCombo->insertItem( i18n("September") ); 326 mByMonthCombo->insertItem( i18n("September") );
328 mByMonthCombo->insertItem( i18n("October") ); 327 mByMonthCombo->insertItem( i18n("October") );
329 mByMonthCombo->insertItem( i18n("November") ); 328 mByMonthCombo->insertItem( i18n("November") );
330 mByMonthCombo->insertItem( i18n("December") ); 329 mByMonthCombo->insertItem( i18n("December") );
331 buttonLayout->addWidget( mByMonthCombo, 0, 1 ); 330 buttonLayout->addWidget( mByMonthCombo, 0, 1 );
332 331
333 mByMonthCombo->setSizeLimit( 6 ); 332 mByMonthCombo->setSizeLimit( 6 );
334 333
335 buttonLayout->setRowStretch( 1, 1 ); 334 buttonLayout->setRowStretch( 1, 1 );
336 335
337 QString recurOnDayText; 336 QString recurOnDayText;
338 if ( KOPrefs::instance()->mCompactDialogs ) { 337 if ( KOPrefs::instance()->mCompactDialogs ) {
339 recurOnDayText = i18n("This day"); 338 recurOnDayText = i18n("This day");
340 } else { 339 } else {
341 recurOnDayText = i18n("Recur on this day"); 340 recurOnDayText = i18n("Recur on this day");
342 } 341 }
343 342
344 mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup); 343 mByDayRadio = new QRadioButton( recurOnDayText, buttonGroup);
345 buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 ); 344 buttonLayout->addMultiCellWidget( mByDayRadio, 2, 2, 0, 1 );
346} 345}
347 346
348void RecurYearly::setByDay() 347void RecurYearly::setByDay()
349{ 348{
350 mByDayRadio->setChecked( true ); 349 mByDayRadio->setChecked( true );
351} 350}
352 351
353void RecurYearly::setByMonth( int month ) 352void RecurYearly::setByMonth( int month )
354{ 353{
355 mByMonthRadio->setChecked( true ); 354 mByMonthRadio->setChecked( true );
356 mByMonthCombo->setCurrentItem( month - 1 ); 355 mByMonthCombo->setCurrentItem( month - 1 );
357} 356}
358 357
359bool RecurYearly::byMonth() 358bool RecurYearly::byMonth()
360{ 359{
361 return mByMonthRadio->isChecked(); 360 return mByMonthRadio->isChecked();
362} 361}
363 362
364bool RecurYearly::byDay() 363bool RecurYearly::byDay()
365{ 364{
366 return mByDayRadio->isChecked(); 365 return mByDayRadio->isChecked();
367} 366}
368 367
369int RecurYearly::month() 368int RecurYearly::month()
370{ 369{
371 return mByMonthCombo->currentItem() + 1; 370 return mByMonthCombo->currentItem() + 1;
372} 371}
373 372
374//////////////////////////// ExceptionsWidget ////////////////////////// 373//////////////////////////// ExceptionsWidget //////////////////////////
375 374
376ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : 375ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) :
377 QWidget( parent, name ) 376 QWidget( parent, name )
378{ 377{
379 QBoxLayout *topLayout = new QVBoxLayout( this ); 378 QBoxLayout *topLayout = new QVBoxLayout( this );
380 379
381 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), 380 QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"),
382 this ); 381 this );
383 topLayout->addWidget( groupBox ); 382 topLayout->addWidget( groupBox );
384 383
385 QWidget *box = new QWidget( groupBox ); 384 QWidget *box = new QWidget( groupBox );
386 385
387 QGridLayout *boxLayout = new QGridLayout( box ); 386 QGridLayout *boxLayout = new QGridLayout( box );
388 387
389 mExceptionDateEdit = new KDateEdit( box ); 388 mExceptionDateEdit = new KDateEdit( box );
390 boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); 389 boxLayout->addWidget( mExceptionDateEdit, 0, 0 );
391 390
392 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); 391 QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box );
393 boxLayout->addWidget( addExceptionButton, 1, 0 ); 392 boxLayout->addWidget( addExceptionButton, 1, 0 );
394 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); 393 QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box );
395 boxLayout->addWidget( changeExceptionButton, 2, 0 ); 394 boxLayout->addWidget( changeExceptionButton, 2, 0 );
396 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); 395 QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box );
397 boxLayout->addWidget( deleteExceptionButton, 3, 0 ); 396 boxLayout->addWidget( deleteExceptionButton, 3, 0 );
398 397
399 mExceptionList = new QListBox( box ); 398 mExceptionList = new QListBox( box );
400 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); 399 boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 );
401 400
402 boxLayout->setRowStretch( 4, 1 ); 401 boxLayout->setRowStretch( 4, 1 );
403 boxLayout->setColStretch( 1, 3 ); 402 boxLayout->setColStretch( 1, 3 );
404 403
405 connect( addExceptionButton, SIGNAL( clicked() ), 404 connect( addExceptionButton, SIGNAL( clicked() ),
406 SLOT( addException() ) ); 405 SLOT( addException() ) );
407 connect( changeExceptionButton, SIGNAL( clicked() ), 406 connect( changeExceptionButton, SIGNAL( clicked() ),
408 SLOT( changeException() ) ); 407 SLOT( changeException() ) );
409 connect( deleteExceptionButton, SIGNAL( clicked() ), 408 connect( deleteExceptionButton, SIGNAL( clicked() ),
410 SLOT( deleteException() ) ); 409 SLOT( deleteException() ) );
411 if ( QApplication::desktop()->width() < 480 ) { 410 if ( QApplication::desktop()->width() < 480 ) {
412 setMinimumWidth( 220 ); 411 setMinimumWidth( 220 );
413 } else { 412 } else {
414 setMinimumWidth( 440 ); 413 setMinimumWidth( 440 );
415 mExceptionDateEdit->setMinimumWidth( 200 ); 414 mExceptionDateEdit->setMinimumWidth( 200 );
416 } 415 }
417} 416}
418 417
419void ExceptionsWidget::setDefaults( const QDateTime &from ) 418void ExceptionsWidget::setDefaults( const QDateTime &from )
420{ 419{
421 mExceptionDateEdit->setDate( from.date() ); 420 mExceptionDateEdit->setDate( from.date() );
422} 421}
423 422
424void ExceptionsWidget::addException() 423void ExceptionsWidget::addException()
425{ 424{
426 QDate date = mExceptionDateEdit->date(); 425 QDate date = mExceptionDateEdit->date();
427 QString dateStr = KGlobal::locale()->formatDate( date ); 426 QString dateStr = KGlobal::locale()->formatDate( date );
428 if( !mExceptionList->findItem( dateStr ) ) { 427 if( !mExceptionList->findItem( dateStr ) ) {
429 mExceptionDates.append( date ); 428 mExceptionDates.append( date );
430 mExceptionList->insertItem( dateStr ); 429 mExceptionList->insertItem( dateStr );
431 } 430 }
432} 431}
433 432
434void ExceptionsWidget::changeException() 433void ExceptionsWidget::changeException()
435{ 434{
436 int pos = mExceptionList->currentItem(); 435 int pos = mExceptionList->currentItem();
437 if ( pos < 0 ) return; 436 if ( pos < 0 ) return;
438 437
439 QDate date = mExceptionDateEdit->date(); 438 QDate date = mExceptionDateEdit->date();
440 mExceptionDates[ pos ] = date; 439 mExceptionDates[ pos ] = date;
441 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); 440 mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos );
442} 441}
443 442
444void ExceptionsWidget::deleteException() 443void ExceptionsWidget::deleteException()
445{ 444{
446 int pos = mExceptionList->currentItem(); 445 int pos = mExceptionList->currentItem();
447 if ( pos < 0 ) return; 446 if ( pos < 0 ) return;
448 447
449 mExceptionDates.remove( mExceptionDates.at( pos ) ); 448 mExceptionDates.remove( mExceptionDates.at( pos ) );
450 mExceptionList->removeItem( pos ); 449 mExceptionList->removeItem( pos );
451} 450}
452 451
453void ExceptionsWidget::setDates( const DateList &dates ) 452void ExceptionsWidget::setDates( const DateList &dates )
454{ 453{
455 mExceptionList->clear(); 454 mExceptionList->clear();
456 mExceptionDates.clear(); 455 mExceptionDates.clear();
457 DateList::ConstIterator dit; 456 DateList::ConstIterator dit;
458 for ( dit = dates.begin(); dit != dates.end(); ++dit ) { 457 for ( dit = dates.begin(); dit != dates.end(); ++dit ) {
459 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); 458 mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) );
460 mExceptionDates.append( *dit ); 459 mExceptionDates.append( *dit );
461 } 460 }
462} 461}
463 462
464DateList ExceptionsWidget::dates() 463DateList ExceptionsWidget::dates()
465{ 464{
466 return mExceptionDates; 465 return mExceptionDates;
467} 466}
468 467
469///////////////////////// ExceptionsDialog /////////////////////////// 468///////////////////////// ExceptionsDialog ///////////////////////////
470 469
471ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : 470ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) :
472 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) 471 KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel )
473{ 472{
474 mExceptions = new ExceptionsWidget( this ); 473 mExceptions = new ExceptionsWidget( this );
475 setMainWidget( mExceptions ); 474 setMainWidget( mExceptions );
476 resize(220,10); 475 resize(220,10);
477} 476}
478 477
479void ExceptionsDialog::setDefaults( const QDateTime &from ) 478void ExceptionsDialog::setDefaults( const QDateTime &from )
480{ 479{
481 mExceptions->setDefaults( from ); 480 mExceptions->setDefaults( from );
482} 481}
483 482
484void ExceptionsDialog::setDates( const DateList &dates ) 483void ExceptionsDialog::setDates( const DateList &dates )
485{ 484{
486 mExceptions->setDates( dates ); 485 mExceptions->setDates( dates );
487} 486}
488 487
489DateList ExceptionsDialog::dates() 488DateList ExceptionsDialog::dates()
490{ 489{
491 return mExceptions->dates(); 490 return mExceptions->dates();
492} 491}
493 492
494///////////////////////// RecurrenceRangeWidget /////////////////////////// 493///////////////////////// RecurrenceRangeWidget ///////////////////////////
495 494
496RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, 495RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent,
497 const char *name ) 496 const char *name )
498 : QWidget( parent, name ) 497 : QWidget( parent, name )
499{ 498{
500 QBoxLayout *topLayout = new QVBoxLayout( this ); 499 QBoxLayout *topLayout = new QVBoxLayout( this );
501 500
502 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), 501 mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"),
503 this ); 502 this );
504 topLayout->addWidget( mRangeGroupBox ); 503 topLayout->addWidget( mRangeGroupBox );
505 504
506 QWidget *rangeBox = new QWidget( mRangeGroupBox ); 505 QWidget *rangeBox = new QWidget( mRangeGroupBox );
507 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); 506 QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox );
508 rangeLayout->setSpacing( KDialog::spacingHint() ); 507 rangeLayout->setSpacing( KDialog::spacingHint() );
509 508
510 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); 509 mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox );
511 rangeLayout->addWidget( mStartDateLabel ); 510 rangeLayout->addWidget( mStartDateLabel );
512 511
513 QButtonGroup *rangeButtonGroup = new QButtonGroup; 512 QButtonGroup *rangeButtonGroup = new QButtonGroup;
514 513
515 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); 514 mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox );
516 rangeButtonGroup->insert( mNoEndDateButton ); 515 rangeButtonGroup->insert( mNoEndDateButton );
517 rangeLayout->addWidget( mNoEndDateButton ); 516 rangeLayout->addWidget( mNoEndDateButton );
518 517
519 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); 518 QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout );
520 durationLayout->setSpacing( KDialog::spacingHint() ); 519 durationLayout->setSpacing( KDialog::spacingHint() );
521 520
522 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); 521 mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox );
523 rangeButtonGroup->insert( mEndDurationButton ); 522 rangeButtonGroup->insert( mEndDurationButton );
524 durationLayout->addWidget( mEndDurationButton ); 523 durationLayout->addWidget( mEndDurationButton );
525 524
526 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); 525 mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox );
527 durationLayout->addWidget( mEndDurationEdit ); 526 durationLayout->addWidget( mEndDurationEdit );
528 527
529 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); 528 QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox );
530 durationLayout ->addWidget( endDurationLabel ); 529 durationLayout ->addWidget( endDurationLabel );
531 530
532 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); 531 QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout );
533 endDateLayout->setSpacing( KDialog::spacingHint() ); 532 endDateLayout->setSpacing( KDialog::spacingHint() );
534 533
535 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); 534 mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox );
536 rangeButtonGroup->insert( mEndDateButton ); 535 rangeButtonGroup->insert( mEndDateButton );
537 endDateLayout->addWidget( mEndDateButton ); 536 endDateLayout->addWidget( mEndDateButton );
538 537
539 mEndDateEdit = new KDateEdit( rangeBox ); 538 mEndDateEdit = new KDateEdit( rangeBox );
540 endDateLayout->addWidget( mEndDateEdit ); 539 endDateLayout->addWidget( mEndDateEdit );
541 540
542 endDateLayout->addStretch( 1 ); 541 endDateLayout->addStretch( 1 );
543 542
544 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), 543 connect( mNoEndDateButton, SIGNAL( toggled( bool ) ),
545 SLOT( showCurrentRange() ) ); 544 SLOT( showCurrentRange() ) );
546 connect( mEndDurationButton, SIGNAL( toggled( bool ) ), 545 connect( mEndDurationButton, SIGNAL( toggled( bool ) ),
547 SLOT( showCurrentRange() ) ); 546 SLOT( showCurrentRange() ) );
548 connect( mEndDateButton, SIGNAL( toggled( bool ) ), 547 connect( mEndDateButton, SIGNAL( toggled( bool ) ),
549 SLOT( showCurrentRange() ) ); 548 SLOT( showCurrentRange() ) );
550} 549}
551 550
552void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) 551void RecurrenceRangeWidget::setDefaults( const QDateTime &from )
553{ 552{
554 mNoEndDateButton->setChecked( true ); 553 mNoEndDateButton->setChecked( true );
555 554
556 setDateTimes( from ); 555 setDateTimes( from );
557 mEndDateEdit->setDate( from.date() ); 556 mEndDateEdit->setDate( from.date() );
558} 557}
559 558
560void RecurrenceRangeWidget::setDuration( int duration ) 559void RecurrenceRangeWidget::setDuration( int duration )
561{ 560{
562 if ( duration == -1 ) { 561 if ( duration == -1 ) {
563 mNoEndDateButton->setChecked( true ); 562 mNoEndDateButton->setChecked( true );
564 } else if ( duration == 0 ) { 563 } else if ( duration == 0 ) {
565 mEndDateButton->setChecked( true ); 564 mEndDateButton->setChecked( true );
566 } else { 565 } else {
567 mEndDurationButton->setChecked( true ); 566 mEndDurationButton->setChecked( true );
568 mEndDurationEdit->setValue( duration ); 567 mEndDurationEdit->setValue( duration );
569 } 568 }
570} 569}
571 570
572int RecurrenceRangeWidget::duration() 571int RecurrenceRangeWidget::duration()
573{ 572{
574 if ( mNoEndDateButton->isChecked() ) { 573 if ( mNoEndDateButton->isChecked() ) {
575 return -1; 574 return -1;
576 } else if ( mEndDurationButton->isChecked() ) { 575 } else if ( mEndDurationButton->isChecked() ) {
577 return mEndDurationEdit->value(); 576 return mEndDurationEdit->value();
578 } else { 577 } else {
579 return 0; 578 return 0;
580 } 579 }
581} 580}
582 581
583void RecurrenceRangeWidget::setEndDate( const QDate &date ) 582void RecurrenceRangeWidget::setEndDate( const QDate &date )
584{ 583{
585 mEndDateEdit->setDate( date ); 584 mEndDateEdit->setDate( date );
586} 585}
587 586
588QDate RecurrenceRangeWidget::endDate() 587QDate RecurrenceRangeWidget::endDate()
589{ 588{
590 return mEndDateEdit->date(); 589 return mEndDateEdit->date();
591} 590}
592 591
593void RecurrenceRangeWidget::showCurrentRange() 592void RecurrenceRangeWidget::showCurrentRange()
594{ 593{
595 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); 594 mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() );
596 mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); 595 mEndDateEdit->setEnabled( mEndDateButton->isChecked() );
597} 596}
598 597
599void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, 598void RecurrenceRangeWidget::setDateTimes( const QDateTime &start,
600 const QDateTime & ) 599 const QDateTime & )
601{ 600{
602 mStartDateLabel->setText( i18n("Start date: %1") 601 mStartDateLabel->setText( i18n("Start date: %1")
603 .arg( KGlobal::locale()->formatDate( start.date() ) ) ); 602 .arg( KGlobal::locale()->formatDate( start.date() ) ) );
604 603
605 if(!mEndDateButton->isChecked()) 604 if(!mEndDateButton->isChecked())
606 mEndDateEdit->setDate( start.date() ); 605 mEndDateEdit->setDate( start.date() );
607} 606}
608 607
609///////////////////////// RecurrenceRangeDialog /////////////////////////// 608///////////////////////// RecurrenceRangeDialog ///////////////////////////
610 609
611RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, 610RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent,
612 const char *name ) : 611 const char *name ) :
613 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) 612 KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel )
614{ 613{
615 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); 614 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
616 setMainWidget( mRecurrenceRangeWidget ); 615 setMainWidget( mRecurrenceRangeWidget );
617} 616}
618 617
619void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) 618void RecurrenceRangeDialog::setDefaults( const QDateTime &from )
620{ 619{
621 mRecurrenceRangeWidget->setDefaults( from ); 620 mRecurrenceRangeWidget->setDefaults( from );
622} 621}
623 622
624void RecurrenceRangeDialog::setDuration( int duration ) 623void RecurrenceRangeDialog::setDuration( int duration )
625{ 624{
626 mRecurrenceRangeWidget->setDuration( duration ); 625 mRecurrenceRangeWidget->setDuration( duration );
627} 626}
628 627
629int RecurrenceRangeDialog::duration() 628int RecurrenceRangeDialog::duration()
630{ 629{
631 return mRecurrenceRangeWidget->duration(); 630 return mRecurrenceRangeWidget->duration();
632} 631}
633 632
634void RecurrenceRangeDialog::setEndDate( const QDate &date ) 633void RecurrenceRangeDialog::setEndDate( const QDate &date )
635{ 634{
636 mRecurrenceRangeWidget->setEndDate( date ); 635 mRecurrenceRangeWidget->setEndDate( date );
637} 636}
638 637
639QDate RecurrenceRangeDialog::endDate() 638QDate RecurrenceRangeDialog::endDate()
640{ 639{
641 return mRecurrenceRangeWidget->endDate(); 640 return mRecurrenceRangeWidget->endDate();
642} 641}
643 642
644void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, 643void RecurrenceRangeDialog::setDateTimes( const QDateTime &start,
645 const QDateTime &end ) 644 const QDateTime &end )
646{ 645{
647 mRecurrenceRangeWidget->setDateTimes( start, end ); 646 mRecurrenceRangeWidget->setDateTimes( start, end );
648} 647}
649 648
650//////////////////////////// RecurrenceChooser //////////////////////// 649//////////////////////////// RecurrenceChooser ////////////////////////
651 650
652RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : 651RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) :
653 QWidget( parent, name ) 652 QWidget( parent, name )
654{ 653{
655 QBoxLayout *topLayout = new QVBoxLayout( this ); 654 QBoxLayout *topLayout = new QVBoxLayout( this );
656 655
657 if ( KOPrefs::instance()->mCompactDialogs ) { 656 if ( KOPrefs::instance()->mCompactDialogs ) {
658 mTypeCombo = new QComboBox( this ); 657 mTypeCombo = new QComboBox( this );
659 mTypeCombo->insertItem( i18n("Daily") ); 658 mTypeCombo->insertItem( i18n("Daily") );
660 mTypeCombo->insertItem( i18n("Weekly") ); 659 mTypeCombo->insertItem( i18n("Weekly") );
661 mTypeCombo->insertItem( i18n("Monthly") ); 660 mTypeCombo->insertItem( i18n("Monthly") );
662 mTypeCombo->insertItem( i18n("Yearly") ); 661 mTypeCombo->insertItem( i18n("Yearly") );
663 662
664 topLayout->addWidget( mTypeCombo ); 663 topLayout->addWidget( mTypeCombo );
665 664
666 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); 665 connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) );
667 } else { 666 } else {
668 mTypeCombo = 0; 667 mTypeCombo = 0;
669 668
670 QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this ); 669 QButtonGroup *ruleButtonGroup = new QButtonGroup( 1, Horizontal, this );
671 ruleButtonGroup->setFrameStyle( QFrame::NoFrame ); 670 ruleButtonGroup->setFrameStyle( QFrame::NoFrame );
672 topLayout->addWidget( ruleButtonGroup ); 671 topLayout->addWidget( ruleButtonGroup );
673 672
674 mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup ); 673 mDailyButton = new QRadioButton( i18n("Daily"), ruleButtonGroup );
675 mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup ); 674 mWeeklyButton = new QRadioButton( i18n("Weekly"), ruleButtonGroup );
676 mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup ); 675 mMonthlyButton = new QRadioButton( i18n("Monthly"), ruleButtonGroup );
677 mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup ); 676 mYearlyButton = new QRadioButton( i18n("Yearly"), ruleButtonGroup );
678 677
679 connect( mDailyButton, SIGNAL( toggled( bool ) ), 678 connect( mDailyButton, SIGNAL( toggled( bool ) ),
680 SLOT( emitChoice() ) ); 679 SLOT( emitChoice() ) );
681 connect( mWeeklyButton, SIGNAL( toggled( bool ) ), 680 connect( mWeeklyButton, SIGNAL( toggled( bool ) ),
682 SLOT( emitChoice() ) ); 681 SLOT( emitChoice() ) );
683 connect( mMonthlyButton, SIGNAL( toggled( bool ) ), 682 connect( mMonthlyButton, SIGNAL( toggled( bool ) ),
684 SLOT( emitChoice() ) ); 683 SLOT( emitChoice() ) );
685 connect( mYearlyButton, SIGNAL( toggled( bool ) ), 684 connect( mYearlyButton, SIGNAL( toggled( bool ) ),
686 SLOT( emitChoice() ) ); 685 SLOT( emitChoice() ) );
687 } 686 }
688} 687}
689 688
690int RecurrenceChooser::type() 689int RecurrenceChooser::type()
691{ 690{
692 if ( mTypeCombo ) { 691 if ( mTypeCombo ) {
693 return mTypeCombo->currentItem(); 692 return mTypeCombo->currentItem();
694 } else { 693 } else {
695 if ( mDailyButton->isChecked() ) return Daily; 694 if ( mDailyButton->isChecked() ) return Daily;
696 else if ( mWeeklyButton->isChecked() ) return Weekly; 695 else if ( mWeeklyButton->isChecked() ) return Weekly;
697 else if ( mMonthlyButton->isChecked() ) return Monthly; 696 else if ( mMonthlyButton->isChecked() ) return Monthly;
698 else return Yearly; 697 else return Yearly;
699 } 698 }
700} 699}
701 700
702void RecurrenceChooser::setType( int type ) 701void RecurrenceChooser::setType( int type )
703{ 702{
704 if ( mTypeCombo ) { 703 if ( mTypeCombo ) {
705 mTypeCombo->setCurrentItem( type ); 704 mTypeCombo->setCurrentItem( type );
706 } else { 705 } else {
707 switch ( type ) { 706 switch ( type ) {
708 case Daily: 707 case Daily:
709 mDailyButton->setChecked( true ); 708 mDailyButton->setChecked( true );
710 break; 709 break;
711 case Weekly: 710 case Weekly:
712 mWeeklyButton->setChecked( true ); 711 mWeeklyButton->setChecked( true );
713 break; 712 break;
714 case Monthly: 713 case Monthly:
715 mMonthlyButton->setChecked( true ); 714 mMonthlyButton->setChecked( true );
716 break; 715 break;
717 case Yearly: 716 case Yearly:
718 default: 717 default:
719 mYearlyButton->setChecked( true ); 718 mYearlyButton->setChecked( true );
720 break; 719 break;
721 } 720 }
722 } 721 }
723} 722}
724 723
725void RecurrenceChooser::emitChoice() 724void RecurrenceChooser::emitChoice()
726{ 725{
727 emit chosen ( type() ); 726 emit chosen ( type() );
728} 727}
729 728
730/////////////////////////////// Main Widget ///////////////////////////// 729/////////////////////////////// Main Widget /////////////////////////////
731 730
732KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : 731KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) :
733 QWidget( parent, name ) 732 QWidget( parent, name )
734{ 733{
735 QGridLayout *topLayout = new QGridLayout( this, 2,2 ); 734 QGridLayout *topLayout = new QGridLayout( this, 2,2 );
736 topLayout->setSpacing( KDialog::spacingHint() ); 735 topLayout->setSpacing( KDialog::spacingHint() );
737 736
738 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); 737 mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this );
739 connect( mEnabledCheck, SIGNAL( toggled( bool ) ), 738 connect( mEnabledCheck, SIGNAL( toggled( bool ) ),
740 SLOT( setEnabled( bool ) ) ); 739 SLOT( setEnabled( bool ) ) );
741 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); 740 topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 );
742 741
743 742
744 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "), 743 mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Appointment Time "),
745 this ); 744 this );
746 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); 745 topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 );
747 746
748 if ( KOPrefs::instance()->mCompactDialogs ) { 747 if ( KOPrefs::instance()->mCompactDialogs ) {
749 mTimeGroupBox->hide(); 748 mTimeGroupBox->hide();
750 } 749 }
751 750
752// QFrame *timeFrame = new QFrame( mTimeGroupBox ); 751// QFrame *timeFrame = new QFrame( mTimeGroupBox );
753// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); 752// QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame );
754// layoutTimeFrame->setSpacing( KDialog::spacingHint() ); 753// layoutTimeFrame->setSpacing( KDialog::spacingHint() );
755 754
756 mDateTimeLabel = new QLabel( mTimeGroupBox ); 755 mDateTimeLabel = new QLabel( mTimeGroupBox );
757// mDateTimeLabel = new QLabel( timeFrame ); 756// mDateTimeLabel = new QLabel( timeFrame );
758// layoutTimeFrame->addWidget( mDateTimeLabel ); 757// layoutTimeFrame->addWidget( mDateTimeLabel );
759 758
760 Qt::Orientation orientation; 759 Qt::Orientation orientation;
761 if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal; 760 if ( KOPrefs::instance()->mCompactDialogs ) orientation = Horizontal;
762 else orientation = Vertical; 761 else orientation = Vertical;
763 762
764 mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this ); 763 mRuleBox = new QGroupBox( 1, orientation, i18n("Recurrence Rule"), this );
765 if ( KOPrefs::instance()->mCompactDialogs ) { 764 if ( KOPrefs::instance()->mCompactDialogs ) {
766 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); 765 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
767 } else { 766 } else {
768 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); 767 topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 );
769 } 768 }
770 769
771 mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); 770 mRecurrenceChooser = new RecurrenceChooser( mRuleBox );
772 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), 771 connect( mRecurrenceChooser, SIGNAL( chosen( int ) ),
773 SLOT( showCurrentRule( int ) ) ); 772 SLOT( showCurrentRule( int ) ) );
774 773
775 if ( !KOPrefs::instance()->mCompactDialogs ) { 774 if ( !KOPrefs::instance()->mCompactDialogs ) {
776 QFrame *ruleSepFrame = new QFrame( mRuleBox ); 775 QFrame *ruleSepFrame = new QFrame( mRuleBox );
777 ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken ); 776 ruleSepFrame->setFrameStyle( QFrame::VLine | QFrame::Sunken );
778 } 777 }
779 778
780 mRuleStack = new QWidgetStack( mRuleBox ); 779 mRuleStack = new QWidgetStack( mRuleBox );
781 780
782 mDaily = new RecurDaily( mRuleStack ); 781 mDaily = new RecurDaily( mRuleStack );
783 mRuleStack->addWidget( mDaily, 0 ); 782 mRuleStack->addWidget( mDaily, 0 );
784 783
785 mWeekly = new RecurWeekly( mRuleStack ); 784 mWeekly = new RecurWeekly( mRuleStack );
786 mRuleStack->addWidget( mWeekly, 0 ); 785 mRuleStack->addWidget( mWeekly, 0 );
787 786
788 mMonthly = new RecurMonthly( mRuleStack ); 787 mMonthly = new RecurMonthly( mRuleStack );
789 mRuleStack->addWidget( mMonthly, 0 ); 788 mRuleStack->addWidget( mMonthly, 0 );
790 789
791 mYearly = new RecurYearly( mRuleStack ); 790 mYearly = new RecurYearly( mRuleStack );
792 mRuleStack->addWidget( mYearly, 0 ); 791 mRuleStack->addWidget( mYearly, 0 );
793 792
794 showCurrentRule( mRecurrenceChooser->type() ); 793 showCurrentRule( mRecurrenceChooser->type() );
795 794
796 if ( KOPrefs::instance()->mCompactDialogs ) { 795 if ( KOPrefs::instance()->mCompactDialogs ) {
797 mRecurrenceRangeWidget = 0; 796 mRecurrenceRangeWidget = 0;
798 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); 797 mRecurrenceRangeDialog = new RecurrenceRangeDialog( this );
799 mRecurrenceRange = mRecurrenceRangeDialog; 798 mRecurrenceRange = mRecurrenceRangeDialog;
800 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), 799 mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."),
801 this ); 800 this );
802 801
803 connect( mRecurrenceRangeButton, SIGNAL( clicked() ), 802 connect( mRecurrenceRangeButton, SIGNAL( clicked() ),
804 SLOT( showRecurrenceRangeDialog() ) ); 803 SLOT( showRecurrenceRangeDialog() ) );
805 804
806 mExceptionsWidget = 0; 805 mExceptionsWidget = 0;
807 mExceptionsDialog = new ExceptionsDialog( this ); 806 mExceptionsDialog = new ExceptionsDialog( this );
808 mExceptions = mExceptionsDialog; 807 mExceptions = mExceptionsDialog;
809 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); 808 mExceptionsButton = new QPushButton( i18n("Exceptions..."), this );
810 if ( QApplication::desktop()->width() < 320 ) { 809 if ( QApplication::desktop()->width() < 320 ) {
811 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); 810 topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 );
812 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); 811 topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 );
813 } else { 812 } else {
814 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); 813 topLayout->addWidget( mRecurrenceRangeButton, 3, 0 );
815 topLayout->addWidget( mExceptionsButton, 3, 1 ); 814 topLayout->addWidget( mExceptionsButton, 3, 1 );
816 } 815 }
817 connect( mExceptionsButton, SIGNAL( clicked() ), 816 connect( mExceptionsButton, SIGNAL( clicked() ),
818 SLOT( showExceptionsDialog() ) ); 817 SLOT( showExceptionsDialog() ) );
819 818
820 } else { 819 } else {
821 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); 820 mRecurrenceRangeWidget = new RecurrenceRangeWidget( this );
822 mRecurrenceRangeDialog = 0; 821 mRecurrenceRangeDialog = 0;
823 mRecurrenceRange = mRecurrenceRangeWidget; 822 mRecurrenceRange = mRecurrenceRangeWidget;
824 mRecurrenceRangeButton = 0; 823 mRecurrenceRangeButton = 0;
825 topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 ); 824 topLayout->addWidget( mRecurrenceRangeWidget, 3, 0 );
826 825
827 mExceptionsWidget = new ExceptionsWidget( this ); 826 mExceptionsWidget = new ExceptionsWidget( this );
828 mExceptionsDialog = 0; 827 mExceptionsDialog = 0;
829 mExceptions = mExceptionsWidget; 828 mExceptions = mExceptionsWidget;
830 mExceptionsButton = 0; 829 mExceptionsButton = 0;
831 topLayout->addWidget( mExceptionsWidget, 3, 1 ); 830 topLayout->addWidget( mExceptionsWidget, 3, 1 );
832 } 831 }
833} 832}
834 833
835KOEditorRecurrence::~KOEditorRecurrence() 834KOEditorRecurrence::~KOEditorRecurrence()
836{ 835{
837} 836}
838 837
839void KOEditorRecurrence::setEnabled( bool enabled ) 838void KOEditorRecurrence::setEnabled( bool enabled )
840{ 839{
841// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; 840// kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl;
842 841
843 mTimeGroupBox->setEnabled( enabled ); 842 mTimeGroupBox->setEnabled( enabled );
844 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); 843 if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled );
845 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); 844 if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled );
846 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); 845 if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled );
847 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); 846 if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled );
848} 847}
849 848
850void KOEditorRecurrence::showCurrentRule( int current ) 849void KOEditorRecurrence::showCurrentRule( int current )
851{ 850{
852 switch ( current ) { 851 switch ( current ) {
853 case Daily: 852 case Daily:
854 mRuleStack->raiseWidget( mDaily ); 853 mRuleStack->raiseWidget( mDaily );
855 break; 854 break;
856 case Weekly: 855 case Weekly:
857 mRuleStack->raiseWidget( mWeekly ); 856 mRuleStack->raiseWidget( mWeekly );
858 break; 857 break;
859 case Monthly: 858 case Monthly:
860 mRuleStack->raiseWidget( mMonthly ); 859 mRuleStack->raiseWidget( mMonthly );
861 break; 860 break;
862 default: 861 default:
863 case Yearly: 862 case Yearly:
864 mRuleStack->raiseWidget( mYearly ); 863 mRuleStack->raiseWidget( mYearly );
865 break; 864 break;
866 } 865 }
867} 866}
868 867
869void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) 868void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end )
870{ 869{
871// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; 870// kdDebug() << "KOEditorRecurrence::setDateTimes" << endl;
872 871
873 mRecurrenceRange->setDateTimes( start, end ); 872 mRecurrenceRange->setDateTimes( start, end );
874 mExceptions->setDefaults( end ); 873 mExceptions->setDefaults( end );
875 874
876} 875}
877 876
878void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) 877void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool )
879{ 878{
880 879
881 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); 880 // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() );
882 setDateTimes( from, to ); 881 setDateTimes( from, to );
883 882
884 bool enabled = false; 883 bool enabled = false;
885 mEnabledCheck->setChecked( enabled ); 884 mEnabledCheck->setChecked( enabled );
886 setEnabled( enabled ); 885 setEnabled( enabled );
887 886
888 mExceptions->setDefaults( to ); 887 mExceptions->setDefaults( to );
889 mRecurrenceRange->setDefaults( to ); 888 mRecurrenceRange->setDefaults( to );
890 889
891 mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); 890 mRecurrenceChooser->setType( RecurrenceChooser::Weekly );
892 showCurrentRule( mRecurrenceChooser->type() ); 891 showCurrentRule( mRecurrenceChooser->type() );
893 892
894 mDaily->setFrequency( 1 ); 893 mDaily->setFrequency( 1 );
895 894
896 mWeekly->setFrequency( 1 ); 895 mWeekly->setFrequency( 1 );
897 QBitArray days( 7 ); 896 QBitArray days( 7 );
898 days.fill( 0 ); 897 days.fill( 0 );
899 mWeekly->setDays( days ); 898 mWeekly->setDays( days );
900 899
901 mMonthly->setFrequency( 1 ); 900 mMonthly->setFrequency( 1 );
902 mMonthly->setByDay( from.date().day()-1 ); 901 mMonthly->setByDay( from.date().day()-1 );
903 902
904 mYearly->setFrequency( 1 ); 903 mYearly->setFrequency( 1 );
905 mYearly->setByDay(); 904 mYearly->setByDay();
906} 905}
907 906
908void KOEditorRecurrence::readEvent(Event *event) 907void KOEditorRecurrence::readEvent(Event *event)
909{ 908{
910 QBitArray rDays( 7 ); 909 QBitArray rDays( 7 );
911 QPtrList<Recurrence::rMonthPos> rmp; 910 QPtrList<Recurrence::rMonthPos> rmp;
912 QPtrList<int> rmd; 911 QPtrList<int> rmd;
913 int day = 0; 912 int day = 0;
914 int count = 0; 913 int count = 0;
915 int month = 0; 914 int month = 0;
916 setDateTimes( event->dtStart(), event->dtEnd() ); 915 setDateTimes( event->dtStart(), event->dtEnd() );
917 916
918 Recurrence *r = event->recurrence(); 917 Recurrence *r = event->recurrence();
919 int f = r->frequency(); 918 int f = r->frequency();
920 919
921 int recurs = r->doesRecur(); 920 int recurs = r->doesRecur();
922 921
923 mEnabledCheck->setChecked( recurs ); 922 mEnabledCheck->setChecked( recurs );
924 setEnabled( recurs ); 923 setEnabled( recurs );
925 924
926 int recurrenceType = RecurrenceChooser::Weekly; 925 int recurrenceType = RecurrenceChooser::Weekly;
927 926
928 switch ( recurs ) { 927 switch ( recurs ) {
929 case Recurrence::rNone: 928 case Recurrence::rNone:
930 setDefaults( event->dtStart(), event->dtEnd(), true ); 929 setDefaults( event->dtStart(), event->dtEnd(), true );
931 break; 930 break;
932 case Recurrence::rDaily: 931 case Recurrence::rDaily:
933 recurrenceType = RecurrenceChooser::Daily; 932 recurrenceType = RecurrenceChooser::Daily;
934 mDaily->setFrequency( f ); 933 mDaily->setFrequency( f );
935 break; 934 break;
936 case Recurrence::rWeekly: 935 case Recurrence::rWeekly:
937 recurrenceType = RecurrenceChooser::Weekly; 936 recurrenceType = RecurrenceChooser::Weekly;
938 mWeekly->setFrequency( f ); 937 mWeekly->setFrequency( f );
939 mWeekly->setDays( r->days() ); 938 mWeekly->setDays( r->days() );
940 break; 939 break;
941 case Recurrence::rMonthlyPos: 940 case Recurrence::rMonthlyPos:
942 // we only handle one possibility in the list right now, 941 // we only handle one possibility in the list right now,
943 // so I have hardcoded calls with first(). If we make the GUI 942 // so I have hardcoded calls with first(). If we make the GUI
944 // more extended, this can be changed. 943 // more extended, this can be changed.
945 recurrenceType = RecurrenceChooser::Monthly; 944 recurrenceType = RecurrenceChooser::Monthly;
946 945
947 rmp = r->monthPositions(); 946 rmp = r->monthPositions();
948 if ( rmp.first()->negative ) 947 if ( rmp.first()->negative )
949 count = 5 - rmp.first()->rPos - 1; 948 count = 5 - rmp.first()->rPos - 1;
950 else 949 else
951 count = rmp.first()->rPos - 1; 950 count = rmp.first()->rPos - 1;
952 day = 0; 951 day = 0;
953 while ( !rmp.first()->rDays.testBit( day ) ) ++day; 952 while ( !rmp.first()->rDays.testBit( day ) ) ++day;
954 mMonthly->setByPos( count, day ); 953 mMonthly->setByPos( count, day );
955 954
956 mMonthly->setFrequency( f ); 955 mMonthly->setFrequency( f );
957 956
958 break; 957 break;
959 case Recurrence::rMonthlyDay: 958 case Recurrence::rMonthlyDay:
960 recurrenceType = RecurrenceChooser::Monthly; 959 recurrenceType = RecurrenceChooser::Monthly;
961 960
962 rmd = r->monthDays(); 961 rmd = r->monthDays();
963 day = *rmd.first() - 1; 962 day = *rmd.first() - 1;
964 mMonthly->setByDay( day ); 963 mMonthly->setByDay( day );
965 964
966 mMonthly->setFrequency( f ); 965 mMonthly->setFrequency( f );
967 966
968 break; 967 break;
969 case Recurrence::rYearlyMonth: 968 case Recurrence::rYearlyMonth:
970 case Recurrence::rYearlyDay: 969 case Recurrence::rYearlyDay:
971 recurrenceType = RecurrenceChooser::Yearly; 970 recurrenceType = RecurrenceChooser::Yearly;
972 971
973 rmd = r->yearNums(); 972 rmd = r->yearNums();
974 month = *rmd.first(); 973 month = *rmd.first();
975 if ( month == event->dtStart().date().month() ) { 974 if ( month == event->dtStart().date().month() ) {
976 mYearly->setByDay(); 975 mYearly->setByDay();
977 } else { 976 } else {
978 mYearly->setByMonth( month ); 977 mYearly->setByMonth( month );
979 } 978 }
980 979
981 mYearly->setFrequency( f ); 980 mYearly->setFrequency( f );
982 break; 981 break;
983 default: 982 default:
984 setDefaults( event->dtStart(), event->dtEnd(), true ); 983 setDefaults( event->dtStart(), event->dtEnd(), true );
985 break; 984 break;
986 } 985 }
987 986
988 mRecurrenceChooser->setType( recurrenceType ); 987 mRecurrenceChooser->setType( recurrenceType );
989 showCurrentRule( recurrenceType ); 988 showCurrentRule( recurrenceType );
990 989
991 mRecurrenceRange->setDateTimes( event->dtStart() ); 990 mRecurrenceRange->setDateTimes( event->dtStart() );
992 991
993 if ( r->doesRecur() ) { 992 if ( r->doesRecur() ) {
994 mRecurrenceRange->setDuration( r->duration() ); 993 mRecurrenceRange->setDuration( r->duration() );
995 if ( r->duration() == 0 ) 994 if ( r->duration() == 0 )
996 { 995 {
997 if ( r->endDate() < event->dtStart().date() ) 996 if ( r->endDate() < event->dtStart().date() )
998 mRecurrenceRange->setEndDate( event->dtStart().date() ); 997 mRecurrenceRange->setEndDate( event->dtStart().date() );
999 else 998 else
1000 mRecurrenceRange->setEndDate( r->endDate() ); 999 mRecurrenceRange->setEndDate( r->endDate() );
1001 } else 1000 } else
1002 mRecurrenceRange->setEndDate( event->dtStart().date() ); 1001 mRecurrenceRange->setEndDate( event->dtStart().date() );
1003 } 1002 }
1004 1003
1005 mExceptions->setDates( event->exDates() ); 1004 mExceptions->setDates( event->exDates() );
1006} 1005}
1007 1006
1008void KOEditorRecurrence::writeEvent( Event *event ) 1007void KOEditorRecurrence::writeEvent( Event *event )
1009{ 1008{
1010 Recurrence *r = event->recurrence(); 1009 Recurrence *r = event->recurrence();
1011 1010
1012 // clear out any old settings; 1011 // clear out any old settings;
1013 r->unsetRecurs(); 1012 r->unsetRecurs();
1014 1013
1015 if ( mEnabledCheck->isChecked() ) { 1014 if ( mEnabledCheck->isChecked() ) {
1016 int duration = mRecurrenceRange->duration(); 1015 int duration = mRecurrenceRange->duration();
1017 QDate endDate; 1016 QDate endDate;
1018 if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); 1017 if ( duration == 0 ) endDate = mRecurrenceRange->endDate();
1019 1018
1020 int recurrenceType = mRecurrenceChooser->type(); 1019 int recurrenceType = mRecurrenceChooser->type();
1021 1020
1022 if ( recurrenceType == RecurrenceChooser::Daily ) { 1021 if ( recurrenceType == RecurrenceChooser::Daily ) {
1023 int freq = mDaily->frequency(); 1022 int freq = mDaily->frequency();
1024 if ( duration != 0 ) r->setDaily( freq, duration ); 1023 if ( duration != 0 ) r->setDaily( freq, duration );
1025 else r->setDaily( freq, endDate ); 1024 else r->setDaily( freq, endDate );
1026 } else if ( recurrenceType == RecurrenceChooser::Weekly ) { 1025 } else if ( recurrenceType == RecurrenceChooser::Weekly ) {
1027 int freq = mWeekly->frequency(); 1026 int freq = mWeekly->frequency();
1028 QBitArray days = mWeekly->days(); 1027 QBitArray days = mWeekly->days();
1029 int j; 1028 int j;
1030 bool found = false; 1029 bool found = false;
1031 for (j = 0; j < 7 ; ++j ) { 1030 for (j = 0; j < 7 ; ++j ) {
1032 found |=days.at(j); 1031 found |=days.at(j);
1033 } 1032 }
1034 if ( !found ) { 1033 if ( !found ) {
1035 days.setBit( event->dtStart().date().dayOfWeek()-1); 1034 days.setBit( event->dtStart().date().dayOfWeek()-1);
1036 qDebug("bit set %d "); 1035 qDebug("bit set %d ");
1037 } 1036 }
1038 if ( duration != 0 ) r->setWeekly( freq, days, duration ); 1037 if ( duration != 0 ) r->setWeekly( freq, days, duration );
1039 else r->setWeekly( freq, days, endDate ); 1038 else r->setWeekly( freq, days, endDate );
1040 } else if ( recurrenceType == RecurrenceChooser::Monthly ) { 1039 } else if ( recurrenceType == RecurrenceChooser::Monthly ) {
1041 int freq = mMonthly->frequency(); 1040 int freq = mMonthly->frequency();
1042 if ( mMonthly->byPos() ) { 1041 if ( mMonthly->byPos() ) {
1043 int pos = mMonthly->count(); 1042 int pos = mMonthly->count();
1044 1043
1045 QBitArray days( 7 ); 1044 QBitArray days( 7 );
1046 days.fill( false ); 1045 days.fill( false );
1047 1046
1048 days.setBit( mMonthly->weekday() ); 1047 days.setBit( mMonthly->weekday() );
1049 if ( duration != 0 ) 1048 if ( duration != 0 )
1050 r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); 1049 r->setMonthly( Recurrence::rMonthlyPos, freq, duration );
1051 else 1050 else
1052 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 1051 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
1053 r->addMonthlyPos( pos, days ); 1052 r->addMonthlyPos( pos, days );
1054 } else { 1053 } else {
1055 // it's by day 1054 // it's by day
1056 int day = mMonthly->day(); 1055 int day = mMonthly->day();
1057 1056
1058 if ( duration != 0 ) { 1057 if ( duration != 0 ) {
1059 r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); 1058 r->setMonthly( Recurrence::rMonthlyDay, freq, duration );
1060 } else { 1059 } else {
1061 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 1060 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
1062 } 1061 }
1063 r->addMonthlyDay( day ); 1062 r->addMonthlyDay( day );
1064 } 1063 }
1065 } else if ( recurrenceType == RecurrenceChooser::Yearly ) { 1064 } else if ( recurrenceType == RecurrenceChooser::Yearly ) {
1066 int freq = mYearly->frequency(); 1065 int freq = mYearly->frequency();
1067 1066
1068 int month; 1067 int month;
1069 if ( mYearly->byMonth() ) { 1068 if ( mYearly->byMonth() ) {
1070 month = mYearly->month(); 1069 month = mYearly->month();
1071 } else { 1070 } else {
1072 month = event->dtStart().date().month(); 1071 month = event->dtStart().date().month();
1073 } 1072 }
1074 if ( duration != 0 ) { 1073 if ( duration != 0 ) {
1075 r->setYearly( Recurrence::rYearlyMonth, freq, duration ); 1074 r->setYearly( Recurrence::rYearlyMonth, freq, duration );
1076 } else { 1075 } else {
1077 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 1076 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
1078 } 1077 }
1079 1078
1080 r->addYearlyNum( month ); 1079 r->addYearlyNum( month );
1081 } 1080 }
1082 1081
1083 event->setExDates( mExceptions->dates() ); 1082 event->setExDates( mExceptions->dates() );
1084 } 1083 }
1085} 1084}
1086 1085
1087void KOEditorRecurrence::setDateTimeStr( const QString &str ) 1086void KOEditorRecurrence::setDateTimeStr( const QString &str )
1088{ 1087{
1089 mDateTimeLabel->setText( str ); 1088 mDateTimeLabel->setText( str );
1090} 1089}
1091 1090
1092bool KOEditorRecurrence::validateInput() 1091bool KOEditorRecurrence::validateInput()
1093{ 1092{
1094 // Check input here 1093 // Check input here
1095 1094
1096 return true; 1095 return true;
1097} 1096}
1098 1097
1099void KOEditorRecurrence::showExceptionsDialog() 1098void KOEditorRecurrence::showExceptionsDialog()
1100{ 1099{
1101 DateList dates = mExceptions->dates(); 1100 DateList dates = mExceptions->dates();
1102 int result = mExceptionsDialog->exec(); 1101 int result = mExceptionsDialog->exec();
1103 if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); 1102 if ( result == QDialog::Rejected ) mExceptions->setDates( dates );
1104} 1103}
1105 1104
1106void KOEditorRecurrence::showRecurrenceRangeDialog() 1105void KOEditorRecurrence::showRecurrenceRangeDialog()
1107{ 1106{
1108 int duration = mRecurrenceRange->duration(); 1107 int duration = mRecurrenceRange->duration();
1109 QDate endDate = mRecurrenceRange->endDate(); 1108 QDate endDate = mRecurrenceRange->endDate();
1110 1109
1111 int result = mRecurrenceRangeDialog->exec(); 1110 int result = mRecurrenceRangeDialog->exec();
1112 if ( result == QDialog::Rejected ) { 1111 if ( result == QDialog::Rejected ) {
1113 mRecurrenceRange->setDuration( duration ); 1112 mRecurrenceRange->setDuration( duration );
1114 mRecurrenceRange->setEndDate( endDate ); 1113 mRecurrenceRange->setEndDate( endDate );
1115 } 1114 }
1116 1115
1117} 1116}
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp
index b3edec6..0ff99a4 100644
--- a/korganizer/koeventeditor.cpp
+++ b/korganizer/koeventeditor.cpp
@@ -1,378 +1,377 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qhbox.h> 27#include <qhbox.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kfiledialog.h> 37#include <kfiledialog.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#include <libkcal/calendarresources.h> 39#include <libkcal/calendarresources.h>
40#include <libkcal/resourcecalendar.h> 40#include <libkcal/resourcecalendar.h>
41#include <kresources/resourceselectdialog.h> 41#include <kresources/resourceselectdialog.h>
42 42
43#include <libkdepim/categoryselectdialog.h> 43#include <libkdepim/categoryselectdialog.h>
44#include <libkcal/calendarlocal.h> 44#include <libkcal/calendarlocal.h>
45#include <libkcal/icalformat.h> 45#include <libkcal/icalformat.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koeventeditor.h" 49#include "koeventeditor.h"
50#include "koeventeditor.moc"
51extern int globalFlagBlockAgenda; 50extern int globalFlagBlockAgenda;
52 51
53KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : 52KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) :
54 KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) 53 KOIncidenceEditor( i18n("Edit Event"), calendar, parent )
55{ 54{
56 mEvent = 0; 55 mEvent = 0;
57 init(); 56 init();
58} 57}
59 58
60KOEventEditor::~KOEventEditor() 59KOEventEditor::~KOEventEditor()
61{ 60{
62 //emit dialogClose( mEvent ); 61 //emit dialogClose( mEvent );
63} 62}
64 63
65void KOEventEditor::init() 64void KOEventEditor::init()
66{ 65{
67 66
68 setupGeneral(); 67 setupGeneral();
69 setupAttendeesTab(); 68 setupAttendeesTab();
70 setupRecurrence(); 69 setupRecurrence();
71 70
72 // Propagate date time settings to recurrence tab 71 // Propagate date time settings to recurrence tab
73 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 72 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
74 mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime))); 73 mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime)));
75 connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), 74 connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)),
76 mRecurrence,SLOT(setDateTimeStr(const QString &))); 75 mRecurrence,SLOT(setDateTimeStr(const QString &)));
77 76
78 // Category dialog 77 // Category dialog
79 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 78 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
80 //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), 79 //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)),
81 // mGeneral,SLOT(setCategories(const QString &))); 80 // mGeneral,SLOT(setCategories(const QString &)));
82 81
83 82
84} 83}
85 84
86void KOEventEditor::reload() 85void KOEventEditor::reload()
87{ 86{
88 if ( mEvent ) readEvent( mEvent ); 87 if ( mEvent ) readEvent( mEvent );
89} 88}
90 89
91void KOEventEditor::setSecrecy( int sec ) 90void KOEventEditor::setSecrecy( int sec )
92{ 91{
93 mGeneral->setSecrecy( sec ); 92 mGeneral->setSecrecy( sec );
94} 93}
95void KOEventEditor::setCategories( QString s ) 94void KOEventEditor::setCategories( QString s )
96{ 95{
97 mGeneral->setCategories(s); 96 mGeneral->setCategories(s);
98 97
99} 98}
100void KOEventEditor::setupGeneral() 99void KOEventEditor::setupGeneral()
101{ 100{
102 mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); 101 mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" );
103 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 102 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
104 103
105 if( KOPrefs::instance()->mCompactDialogs ) { 104 if( KOPrefs::instance()->mCompactDialogs ) {
106 QFrame *topFrame = addPage(i18n("General")); 105 QFrame *topFrame = addPage(i18n("General"));
107 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 106 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
108 topLayout->setSpacing(spacingHint()-1); 107 topLayout->setSpacing(spacingHint()-1);
109 topLayout->setMargin(marginHint()-1); 108 topLayout->setMargin(marginHint()-1);
110 mGeneral->initHeader(topFrame,topLayout); 109 mGeneral->initHeader(topFrame,topLayout);
111 mGeneral->initTime(topFrame,topLayout); 110 mGeneral->initTime(topFrame,topLayout);
112// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 111// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
113 mGeneral->initAlarm(topFrame,topLayout); 112 mGeneral->initAlarm(topFrame,topLayout);
114 mGeneral->enableAlarm( false ); 113 mGeneral->enableAlarm( false );
115 114
116 QBoxLayout *buttonLayout; 115 QBoxLayout *buttonLayout;
117 if ( QApplication::desktop()->width() < 500 ) 116 if ( QApplication::desktop()->width() < 500 )
118 buttonLayout = new QVBoxLayout( topLayout ); 117 buttonLayout = new QVBoxLayout( topLayout );
119 else 118 else
120 buttonLayout = new QHBoxLayout( topLayout ); 119 buttonLayout = new QHBoxLayout( topLayout );
121 QHBox* buttonWidget = new QHBox (topFrame); 120 QHBox* buttonWidget = new QHBox (topFrame);
122 QIconSet icon; 121 QIconSet icon;
123 if ( QApplication::desktop()->width() < 321 ) 122 if ( QApplication::desktop()->width() < 321 )
124 icon = SmallIcon("fileexport16"); 123 icon = SmallIcon("fileexport16");
125 else 124 else
126 icon = SmallIcon("fileexport"); 125 icon = SmallIcon("fileexport");
127 QPushButton * loadTemplate = new QPushButton( buttonWidget); 126 QPushButton * loadTemplate = new QPushButton( buttonWidget);
128 QPushButton * saveTemplate = new QPushButton( buttonWidget); 127 QPushButton * saveTemplate = new QPushButton( buttonWidget);
129 saveTemplate->setIconSet (icon ) ; 128 saveTemplate->setIconSet (icon ) ;
130 int size = saveTemplate->sizeHint().height(); 129 int size = saveTemplate->sizeHint().height();
131 saveTemplate->setFixedSize( size, size ); 130 saveTemplate->setFixedSize( size, size );
132 if ( QApplication::desktop()->width() < 321 ) 131 if ( QApplication::desktop()->width() < 321 )
133 icon = SmallIcon("fileimport16"); 132 icon = SmallIcon("fileimport16");
134 else 133 else
135 icon = SmallIcon("fileimport"); 134 icon = SmallIcon("fileimport");
136 loadTemplate->setIconSet (icon ) ; 135 loadTemplate->setIconSet (icon ) ;
137 loadTemplate->setFixedSize( size, size ); 136 loadTemplate->setFixedSize( size, size );
138 buttonLayout->addWidget( buttonWidget ); 137 buttonLayout->addWidget( buttonWidget );
139 mGeneral->initCategories( topFrame, buttonLayout ); 138 mGeneral->initCategories( topFrame, buttonLayout );
140 139
141 topLayout->addStretch( 1 ); 140 topLayout->addStretch( 1 );
142 141
143 QFrame *topFrame2 = addPage(i18n("Details")); 142 QFrame *topFrame2 = addPage(i18n("Details"));
144 143
145 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 144 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
146 topLayout2->setSpacing(spacingHint()); 145 topLayout2->setSpacing(spacingHint());
147 146
148 mGeneral->initClass(topFrame2,topLayout2); 147 mGeneral->initClass(topFrame2,topLayout2);
149 mGeneral->initSecrecy( topFrame2, topLayout2 ); 148 mGeneral->initSecrecy( topFrame2, topLayout2 );
150 mGeneral->initDescription(topFrame2,topLayout2); 149 mGeneral->initDescription(topFrame2,topLayout2);
151 150
152 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 151 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
153 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 152 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
154 } else { 153 } else {
155 QFrame *topFrame = addPage(i18n("General")); 154 QFrame *topFrame = addPage(i18n("General"));
156 155
157 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 156 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
158 topLayout->setSpacing(spacingHint()); 157 topLayout->setSpacing(spacingHint());
159 158
160 mGeneral->initHeader(topFrame,topLayout); 159 mGeneral->initHeader(topFrame,topLayout);
161 mGeneral->initTime(topFrame,topLayout); 160 mGeneral->initTime(topFrame,topLayout);
162 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 161 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
163 mGeneral->initAlarm(topFrame,alarmLineLayout); 162 mGeneral->initAlarm(topFrame,alarmLineLayout);
164 mGeneral->initClass(topFrame,alarmLineLayout); 163 mGeneral->initClass(topFrame,alarmLineLayout);
165 mGeneral->initDescription(topFrame,topLayout); 164 mGeneral->initDescription(topFrame,topLayout);
166 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 165 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
167 mGeneral->initCategories( topFrame, detailsLayout ); 166 mGeneral->initCategories( topFrame, detailsLayout );
168 mGeneral->initSecrecy( topFrame, detailsLayout ); 167 mGeneral->initSecrecy( topFrame, detailsLayout );
169 } 168 }
170 169
171 mGeneral->finishSetup(); 170 mGeneral->finishSetup();
172 171
173} 172}
174 173
175void KOEventEditor::setupRecurrence() 174void KOEventEditor::setupRecurrence()
176{ 175{
177 QFrame *topFrame = addPage( i18n("Recurrence") ); 176 QFrame *topFrame = addPage( i18n("Recurrence") );
178 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 177 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
179 178
180 mRecurrence = new KOEditorRecurrence( topFrame ); 179 mRecurrence = new KOEditorRecurrence( topFrame );
181 topLayout->addWidget( mRecurrence ); 180 topLayout->addWidget( mRecurrence );
182} 181}
183 182
184void KOEventEditor::editEvent(Event *event, bool showDescription) 183void KOEventEditor::editEvent(Event *event, bool showDescription)
185{ 184{
186 // init(); 185 // init();
187 186
188 mEvent = event; 187 mEvent = event;
189 readEvent(mEvent); 188 readEvent(mEvent);
190 qApp->processEvents(); 189 qApp->processEvents();
191 if ( showDescription ) { 190 if ( showDescription ) {
192 showPage( 1 ); 191 showPage( 1 );
193 mGeneral->setFocusOn( 1 ); 192 mGeneral->setFocusOn( 1 );
194 } else { 193 } else {
195 showPage( 0 ); 194 showPage( 0 );
196 mGeneral->setFocusOn( 2 ); 195 mGeneral->setFocusOn( 2 );
197 } 196 }
198} 197}
199 198
200void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) 199void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay )
201{ 200{
202 // init(); 201 // init();
203 202
204 mEvent = 0; 203 mEvent = 0;
205 setDefaults(from,to,allDay); 204 setDefaults(from,to,allDay);
206} 205}
207 206
208void KOEventEditor::loadDefaults() 207void KOEventEditor::loadDefaults()
209{ 208{
210 int fmt = KOPrefs::instance()->mStartTime; 209 int fmt = KOPrefs::instance()->mStartTime;
211 210
212 QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); 211 QDateTime from(QDate::currentDate(), QTime(fmt,0,0));
213 QDateTime to(QDate::currentDate(), 212 QDateTime to(QDate::currentDate(),
214 QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); 213 QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0));
215 214
216 setDefaults(from,to,false); 215 setDefaults(from,to,false);
217} 216}
218 217
219bool KOEventEditor::processInput( bool emitTime ) 218bool KOEventEditor::processInput( bool emitTime )
220{ 219{
221 if (!validateInput()) return false; 220 if (!validateInput()) return false;
222 221
223 Event *event = 0; 222 Event *event = 0;
224 223
225 if (mEvent) event = mEvent; 224 if (mEvent) event = mEvent;
226 else { 225 else {
227 event = new Event; 226 event = new Event;
228 event->setOrganizer(KOPrefs::instance()->email()); 227 event->setOrganizer(KOPrefs::instance()->email());
229 } 228 }
230 229
231 writeEvent(event); 230 writeEvent(event);
232 if ( emitTime ) { 231 if ( emitTime ) {
233 globalFlagBlockAgenda = 1; 232 globalFlagBlockAgenda = 1;
234 emit showAgendaView( false ); 233 emit showAgendaView( false );
235 emit jumpToTime( event->dtStart().date() ); 234 emit jumpToTime( event->dtStart().date() );
236 globalFlagBlockAgenda = 2; 235 globalFlagBlockAgenda = 2;
237 236
238 } 237 }
239 if (mEvent) { 238 if (mEvent) {
240 event->setRevision(event->revision()+1); 239 event->setRevision(event->revision()+1);
241 emit eventChanged(event); 240 emit eventChanged(event);
242 } else { 241 } else {
243 mCalendar->addEvent(event); 242 mCalendar->addEvent(event);
244 mEvent = event; 243 mEvent = event;
245 emit eventAdded(event); 244 emit eventAdded(event);
246 } 245 }
247 246
248 return true; 247 return true;
249} 248}
250 249
251void KOEventEditor::deleteEvent() 250void KOEventEditor::deleteEvent()
252{ 251{
253 kdDebug() << "Delete event" << endl; 252 kdDebug() << "Delete event" << endl;
254 253
255 if (mEvent) { 254 if (mEvent) {
256 if (KOPrefs::instance()->mConfirm) { 255 if (KOPrefs::instance()->mConfirm) {
257 switch (msgItemDelete()) { 256 switch (msgItemDelete()) {
258 case KMessageBox::Continue: // OK 257 case KMessageBox::Continue: // OK
259 emit eventToBeDeleted(mEvent); 258 emit eventToBeDeleted(mEvent);
260 emit dialogClose(mEvent); 259 emit dialogClose(mEvent);
261 mCalendar->deleteEvent(mEvent); 260 mCalendar->deleteEvent(mEvent);
262 emit eventDeleted(); 261 emit eventDeleted();
263 reject(); 262 reject();
264 break; 263 break;
265 } 264 }
266 } 265 }
267 else { 266 else {
268 emit eventToBeDeleted(mEvent); 267 emit eventToBeDeleted(mEvent);
269 emit dialogClose(mEvent); 268 emit dialogClose(mEvent);
270 mCalendar->deleteEvent(mEvent); 269 mCalendar->deleteEvent(mEvent);
271 emit eventDeleted(); 270 emit eventDeleted();
272 reject(); 271 reject();
273 } 272 }
274 } else { 273 } else {
275 reject(); 274 reject();
276 } 275 }
277} 276}
278 277
279void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) 278void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay)
280{ 279{
281 mGeneral->setDefaults(from,to,allDay); 280 mGeneral->setDefaults(from,to,allDay);
282 mDetails->setDefaults(); 281 mDetails->setDefaults();
283 mRecurrence->setDefaults(from,to,allDay); 282 mRecurrence->setDefaults(from,to,allDay);
284 showPage( 0 ); 283 showPage( 0 );
285 mGeneral->setFocusOn( 2 ); 284 mGeneral->setFocusOn( 2 );
286} 285}
287 286
288void KOEventEditor::readEvent( Event *event, bool tmpl ) 287void KOEventEditor::readEvent( Event *event, bool tmpl )
289{ 288{
290 mGeneral->readEvent( event, tmpl ); 289 mGeneral->readEvent( event, tmpl );
291 mDetails->readEvent( event ); 290 mDetails->readEvent( event );
292 mRecurrence->readEvent( event ); 291 mRecurrence->readEvent( event );
293 292
294 // categories 293 // categories
295 //mCategoryDialog->setSelected( event->categories() ); 294 //mCategoryDialog->setSelected( event->categories() );
296} 295}
297 296
298void KOEventEditor::writeEvent(Event *event) 297void KOEventEditor::writeEvent(Event *event)
299{ 298{
300 mGeneral->writeEvent( event ); 299 mGeneral->writeEvent( event );
301 mDetails->writeEvent( event ); 300 mDetails->writeEvent( event );
302 301
303 if ( event->organizer() == KOPrefs::instance()->email() ) { 302 if ( event->organizer() == KOPrefs::instance()->email() ) {
304 Event *ev = new Event( *event ); 303 Event *ev = new Event( *event );
305 ev->registerObserver(0); 304 ev->registerObserver(0);
306 mDetails->cancelAttendeeEvent( ev ); 305 mDetails->cancelAttendeeEvent( ev );
307 if ( ev->attendeeCount() > 0 ) { 306 if ( ev->attendeeCount() > 0 ) {
308 emit deleteAttendee( ev ); 307 emit deleteAttendee( ev );
309 } 308 }
310 delete(ev); 309 delete(ev);
311 } 310 }
312 311
313 mRecurrence->writeEvent(event); 312 mRecurrence->writeEvent(event);
314} 313}
315 314
316bool KOEventEditor::validateInput() 315bool KOEventEditor::validateInput()
317{ 316{
318 if (!mGeneral->validateInput()) return false; 317 if (!mGeneral->validateInput()) return false;
319 if (!mDetails->validateInput()) return false; 318 if (!mDetails->validateInput()) return false;
320 if (!mRecurrence->validateInput()) return false; 319 if (!mRecurrence->validateInput()) return false;
321 return true; 320 return true;
322} 321}
323 322
324int KOEventEditor::msgItemDelete() 323int KOEventEditor::msgItemDelete()
325{ 324{
326 return KMessageBox::warningContinueCancel(this, 325 return KMessageBox::warningContinueCancel(this,
327 i18n("This item will be permanently deleted."), 326 i18n("This item will be permanently deleted."),
328 i18n("KOrganizer Confirmation"),i18n("Delete")); 327 i18n("KOrganizer Confirmation"),i18n("Delete"));
329} 328}
330 329
331void KOEventEditor::slotLoadTemplate() 330void KOEventEditor::slotLoadTemplate()
332{ 331{
333 332
334 QString fileName =locateLocal( "templates", "events" ); 333 QString fileName =locateLocal( "templates", "events" );
335 QDir t_dir; 334 QDir t_dir;
336 if ( !t_dir.exists(fileName) ) 335 if ( !t_dir.exists(fileName) )
337 t_dir.mkdir ( fileName ); 336 t_dir.mkdir ( fileName );
338 fileName += "/event"; 337 fileName += "/event";
339 fileName = KFileDialog::getSaveFileName( fileName , "Load Event template", this ); 338 fileName = KFileDialog::getSaveFileName( fileName , "Load Event template", this );
340 if ( fileName.length() == 0 ) 339 if ( fileName.length() == 0 )
341 return; 340 return;
342 CalendarLocal cal; 341 CalendarLocal cal;
343 ICalFormat format; 342 ICalFormat format;
344 if ( !format.load( &cal, fileName ) ) { 343 if ( !format.load( &cal, fileName ) ) {
345 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 344 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
346 .arg( fileName ) ); 345 .arg( fileName ) );
347 return ; 346 return ;
348 } 347 }
349 QPtrList<Event> events = cal.events(); 348 QPtrList<Event> events = cal.events();
350 Event* event = events.first(); 349 Event* event = events.first();
351 if ( !event ) { 350 if ( !event ) {
352 KMessageBox::error( this, 351 KMessageBox::error( this,
353 i18n("Template does not contain\na valid Event.")); 352 i18n("Template does not contain\na valid Event."));
354 } else { 353 } else {
355 kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; 354 kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl;
356 readEvent( event, true ); 355 readEvent( event, true );
357 } 356 }
358} 357}
359 358
360 359
361void KOEventEditor::slotSaveTemplate() 360void KOEventEditor::slotSaveTemplate()
362{ 361{
363 QString fileName =locateLocal( "templates", "events" ); 362 QString fileName =locateLocal( "templates", "events" );
364 QDir t_dir; 363 QDir t_dir;
365 if ( !t_dir.exists(fileName) ) 364 if ( !t_dir.exists(fileName) )
366 t_dir.mkdir ( fileName ); 365 t_dir.mkdir ( fileName );
367 fileName += "/event"; 366 fileName += "/event";
368 fileName = KFileDialog::getSaveFileName( fileName , "Save as Event template", this ); 367 fileName = KFileDialog::getSaveFileName( fileName , "Save as Event template", this );
369 if ( fileName.length() > 0 ) 368 if ( fileName.length() > 0 )
370 saveTemplate( fileName ); 369 saveTemplate( fileName );
371} 370}
372 371
373void KOEventEditor::saveTemplate( const QString &templateName ) 372void KOEventEditor::saveTemplate( const QString &templateName )
374{ 373{
375 Event *event = new Event; 374 Event *event = new Event;
376 writeEvent( event ); 375 writeEvent( event );
377 saveAsTemplate( event, templateName ); 376 saveAsTemplate( event, templateName );
378} 377}
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp
index 410bceb..b274810 100644
--- a/korganizer/koeventpopupmenu.cpp
+++ b/korganizer/koeventpopupmenu.cpp
@@ -1,114 +1,113 @@
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 <qcursor.h> 24#include <qcursor.h>
25 25
26#include <klocale.h> 26#include <klocale.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kiconloader.h> 28#include <kiconloader.h>
29 29
30#include <libkcal/event.h> 30#include <libkcal/event.h>
31 31
32#include "koeventpopupmenu.h" 32#include "koeventpopupmenu.h"
33#include "koeventpopupmenu.moc"
34 33
35KOEventPopupMenu::KOEventPopupMenu() 34KOEventPopupMenu::KOEventPopupMenu()
36{ 35{
37 mCurrentIncidence = 0; 36 mCurrentIncidence = 0;
38 mHasAdditionalItems = false; 37 mHasAdditionalItems = false;
39 38
40 insertItem (i18n("&Show"),this,SLOT(popupShow())); 39 insertItem (i18n("&Show"),this,SLOT(popupShow()));
41 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); 40 mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit())));
42 mEditOnlyItems.append(insertItem (i18n("&Delete"), 41 mEditOnlyItems.append(insertItem (i18n("&Delete"),
43 this,SLOT(popupDelete()))); 42 this,SLOT(popupDelete())));
44 mEditOnlyItems.append(insertItem (i18n("&Clone..."), 43 mEditOnlyItems.append(insertItem (i18n("&Clone..."),
45 this,SLOT(popupClone()))); 44 this,SLOT(popupClone())));
46 mEditOnlyItems.append(insertItem (i18n("&Move..."), 45 mEditOnlyItems.append(insertItem (i18n("&Move..."),
47 this,SLOT(popupMove()))); 46 this,SLOT(popupMove())));
48#ifndef DESKTOP_VERSION 47#ifndef DESKTOP_VERSION
49 mEditOnlyItems.append(insertItem (i18n("&Beam..."), 48 mEditOnlyItems.append(insertItem (i18n("&Beam..."),
50 this,SLOT(popupBeam()))); 49 this,SLOT(popupBeam())));
51#endif 50#endif
52 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), 51 mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"),
53 this,SLOT(popupCancel()))); 52 this,SLOT(popupCancel())));
54} 53}
55 54
56void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) 55void KOEventPopupMenu::showIncidencePopup(Incidence *incidence)
57{ 56{
58 mCurrentIncidence = incidence; 57 mCurrentIncidence = incidence;
59 58
60 if (mCurrentIncidence) { 59 if (mCurrentIncidence) {
61 // Enable/Disabled menu items only valid for editable events. 60 // Enable/Disabled menu items only valid for editable events.
62 QValueList<int>::Iterator it; 61 QValueList<int>::Iterator it;
63 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { 62 for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) {
64 setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); 63 setItemEnabled(*it,!mCurrentIncidence->isReadOnly());
65 } 64 }
66 popup(QCursor::pos()); 65 popup(QCursor::pos());
67 } else { 66 } else {
68 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; 67 kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl;
69 } 68 }
70} 69}
71 70
72void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, 71void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text,
73 const QObject *receiver, const char *member, 72 const QObject *receiver, const char *member,
74 bool editOnly) 73 bool editOnly)
75{ 74{
76 if (!mHasAdditionalItems) { 75 if (!mHasAdditionalItems) {
77 mHasAdditionalItems = true; 76 mHasAdditionalItems = true;
78 insertSeparator(); 77 insertSeparator();
79 } 78 }
80 int id = insertItem(icon,text,receiver,member); 79 int id = insertItem(icon,text,receiver,member);
81 if (editOnly) mEditOnlyItems.append(id); 80 if (editOnly) mEditOnlyItems.append(id);
82} 81}
83 82
84void KOEventPopupMenu::popupShow() 83void KOEventPopupMenu::popupShow()
85{ 84{
86 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); 85 if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence);
87} 86}
88 87
89void KOEventPopupMenu::popupEdit() 88void KOEventPopupMenu::popupEdit()
90{ 89{
91 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); 90 if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence);
92} 91}
93 92
94void KOEventPopupMenu::popupDelete() 93void KOEventPopupMenu::popupDelete()
95{ 94{
96 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); 95 if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence);
97} 96}
98void KOEventPopupMenu::popupClone() 97void KOEventPopupMenu::popupClone()
99{ 98{
100 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); 99 if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence);
101} 100}
102void KOEventPopupMenu::popupCancel() 101void KOEventPopupMenu::popupCancel()
103{ 102{
104 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); 103 if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence);
105} 104}
106void KOEventPopupMenu::popupMove() 105void KOEventPopupMenu::popupMove()
107{ 106{
108 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); 107 if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence);
109} 108}
110 109
111void KOEventPopupMenu::popupBeam() 110void KOEventPopupMenu::popupBeam()
112{ 111{
113 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); 112 if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence);
114} 113}
diff --git a/korganizer/koeventview.cpp b/korganizer/koeventview.cpp
index 4553b0b..bce2626 100644
--- a/korganizer/koeventview.cpp
+++ b/korganizer/koeventview.cpp
@@ -1,133 +1,130 @@
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 <qpopupmenu.h> 24#include <qpopupmenu.h>
25#include <qcursor.h> 25#include <qcursor.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kdebug.h> 28#include <kdebug.h>
29#include <kiconloader.h> 29#include <kiconloader.h>
30#include <kmessagebox.h> 30#include <kmessagebox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33#include "koprefs.h" 33#include "koprefs.h"
34#include "koeventview.h" 34#include "koeventview.h"
35using namespace KOrg; 35using namespace KOrg;
36#include "koeventview.moc"
37 36
38//--------------------------------------------------------------------------- 37//---------------------------------------------------------------------------
39 38
40KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name) 39KOEventView::KOEventView(Calendar *cal,QWidget *parent,const char *name)
41 : KOrg::BaseView(cal,parent,name) 40 : KOrg::BaseView(cal,parent,name)
42{ 41{
43} 42}
44 43
45//--------------------------------------------------------------------------- 44//---------------------------------------------------------------------------
46 45
47KOEventView::~KOEventView() 46KOEventView::~KOEventView()
48{ 47{
49} 48}
50 49
51//--------------------------------------------------------------------------- 50//---------------------------------------------------------------------------
52 51
53KOEventPopupMenu *KOEventView::eventPopup() 52KOEventPopupMenu *KOEventView::eventPopup()
54{ 53{
55 KOEventPopupMenu *eventPopup = new KOEventPopupMenu; 54 KOEventPopupMenu *eventPopup = new KOEventPopupMenu;
56 55
57 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)), 56 connect(eventPopup,SIGNAL(editIncidenceSignal(Incidence *)),
58 SIGNAL(editIncidenceSignal(Incidence *))); 57 SIGNAL(editIncidenceSignal(Incidence *)));
59 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)), 58 connect(eventPopup,SIGNAL(showIncidenceSignal(Incidence *)),
60 SIGNAL(showIncidenceSignal(Incidence *))); 59 SIGNAL(showIncidenceSignal(Incidence *)));
61 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)), 60 connect(eventPopup,SIGNAL(deleteIncidenceSignal(Incidence *)),
62 SIGNAL(deleteIncidenceSignal(Incidence *))); 61 SIGNAL(deleteIncidenceSignal(Incidence *)));
63 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)), 62 connect(eventPopup,SIGNAL(cancelIncidenceSignal(Incidence *)),
64 SIGNAL(cancelIncidenceSignal(Incidence *))); 63 SIGNAL(cancelIncidenceSignal(Incidence *)));
65 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)), 64 connect(eventPopup,SIGNAL(cloneIncidenceSignal(Incidence *)),
66 SIGNAL(cloneIncidenceSignal(Incidence *))); 65 SIGNAL(cloneIncidenceSignal(Incidence *)));
67 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)), 66 connect(eventPopup,SIGNAL(beamIncidenceSignal(Incidence *)),
68 SIGNAL(beamIncidenceSignal(Incidence *))); 67 SIGNAL(beamIncidenceSignal(Incidence *)));
69 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)), 68 connect(eventPopup,SIGNAL(moveIncidenceSignal(Incidence *)),
70 SIGNAL(moveIncidenceSignal(Incidence *))); 69 SIGNAL(moveIncidenceSignal(Incidence *)));
71 70
72 return eventPopup; 71 return eventPopup;
73} 72}
74 73
75//--------------------------------------------------------------------------- 74//---------------------------------------------------------------------------
76 75
77void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event) 76void KOEventView::showIncidencePopup(QPopupMenu *popup,Incidence *event)
78{ 77{
79 mCurrentIncidence = event; 78 mCurrentIncidence = event;
80 if (event) popup->popup(QCursor::pos()); 79 if (event) popup->popup(QCursor::pos());
81 else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl; 80 else kdDebug() << "KOEventView::showEventPopup(): No event selected" << endl;
82} 81}
83 82
84//--------------------------------------------------------------------------- 83//---------------------------------------------------------------------------
85 84
86void KOEventView::popupShow() 85void KOEventView::popupShow()
87{ 86{
88 emit showIncidenceSignal(mCurrentIncidence); 87 emit showIncidenceSignal(mCurrentIncidence);
89} 88}
90 89
91//--------------------------------------------------------------------------- 90//---------------------------------------------------------------------------
92 91
93void KOEventView::popupEdit() 92void KOEventView::popupEdit()
94{ 93{
95 emit editIncidenceSignal(mCurrentIncidence); 94 emit editIncidenceSignal(mCurrentIncidence);
96} 95}
97 96
98//--------------------------------------------------------------------------- 97//---------------------------------------------------------------------------
99 98
100void KOEventView::popupDelete() 99void KOEventView::popupDelete()
101{ 100{
102 emit deleteIncidenceSignal(mCurrentIncidence); 101 emit deleteIncidenceSignal(mCurrentIncidence);
103} 102}
104void KOEventView::popupClone() 103void KOEventView::popupClone()
105{ 104{
106 emit cloneIncidenceSignal(mCurrentIncidence); 105 emit cloneIncidenceSignal(mCurrentIncidence);
107} 106}
108void KOEventView::popupCancel() 107void KOEventView::popupCancel()
109{ 108{
110 emit cancelIncidenceSignal(mCurrentIncidence); 109 emit cancelIncidenceSignal(mCurrentIncidence);
111} 110}
112 111
113//--------------------------------------------------------------------------- 112//---------------------------------------------------------------------------
114 113
115void KOEventView::defaultAction( Incidence *incidence ) 114void KOEventView::defaultAction( Incidence *incidence )
116{ 115{
117 116
118 if ( !incidence ) return; 117 if ( !incidence ) return;
119 118
120 if ( incidence->isReadOnly() ) 119 if ( incidence->isReadOnly() )
121 emit showIncidenceSignal(incidence); 120 emit showIncidenceSignal(incidence);
122 else { 121 else {
123 if ( KOPrefs::instance()->mEditOnDoubleClick ) 122 if ( KOPrefs::instance()->mEditOnDoubleClick )
124 emit editIncidenceSignal(incidence); 123 emit editIncidenceSignal(incidence);
125 else 124 else
126 emit showIncidenceSignal(incidence); 125 emit showIncidenceSignal(incidence);
127 } 126 }
128} 127}
129 128
130//--------------------------------------------------------------------------- 129//---------------------------------------------------------------------------
131 130
132#include "baseview.moc"
133
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 9f8bd9b..bac66d3 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,510 +1,509 @@
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 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <libkdepim/addresseeview.h> 38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h> 39#include <kabc/stdaddressbook.h>
40 40
41#ifndef KORG_NODCOP 41#ifndef KORG_NODCOP
42#include <dcopclient.h> 42#include <dcopclient.h>
43#include "korganizer.h" 43#include "korganizer.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "actionmanager.h" 45#include "actionmanager.h"
46#endif 46#endif
47 47
48#include "koeventviewer.h" 48#include "koeventviewer.h"
49#include "koeventviewer.moc"
50#ifndef KORG_NOKABC 49#ifndef KORG_NOKABC
51#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
52#define size count 51#define size count
53#endif 52#endif
54KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 53KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
55 : QTextBrowser(parent,name) 54 : QTextBrowser(parent,name)
56{ 55{
57 mSyncMode = false; 56 mSyncMode = false;
58 mColorMode = 0; 57 mColorMode = 0;
59} 58}
60 59
61KOEventViewer::~KOEventViewer() 60KOEventViewer::~KOEventViewer()
62{ 61{
63} 62}
64 63
65void KOEventViewer::setSource(const QString& n) 64void KOEventViewer::setSource(const QString& n)
66{ 65{
67 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 66 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
68 KABC::AddressBook::Iterator it; 67 KABC::AddressBook::Iterator it;
69 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 68 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
70 // LR I do not understand, why the uid string is different on zaurus and desktop 69 // LR I do not understand, why the uid string is different on zaurus and desktop
71#ifdef DESKTOP_VERSION 70#ifdef DESKTOP_VERSION
72 QString uid = "uid://"+(*it).uid(); 71 QString uid = "uid://"+(*it).uid();
73#else 72#else
74 QString uid = "uid:"+(*it).uid(); 73 QString uid = "uid:"+(*it).uid();
75#endif 74#endif
76 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 75 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
77 if (n == uid ) { 76 if (n == uid ) {
78 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 77 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
79 QDialog dia( this,"dia123", true ); 78 QDialog dia( this,"dia123", true );
80 dia.setCaption( i18n("Details of attendee") ); 79 dia.setCaption( i18n("Details of attendee") );
81 QVBoxLayout lay ( &dia ); 80 QVBoxLayout lay ( &dia );
82 KPIM::AddresseeView av ( &dia ); 81 KPIM::AddresseeView av ( &dia );
83 av.setAddressee( (*it) ); 82 av.setAddressee( (*it) );
84 lay.addWidget( &av ); 83 lay.addWidget( &av );
85 if ( QApplication::desktop()->width() < 480 ) 84 if ( QApplication::desktop()->width() < 480 )
86 dia.resize( 220, 240); 85 dia.resize( 220, 240);
87 else { 86 else {
88 dia.resize( 400,400); 87 dia.resize( 400,400);
89 88
90 } 89 }
91 dia.exec(); 90 dia.exec();
92 break; 91 break;
93 } 92 }
94 } 93 }
95 94
96 95
97#ifndef KORG_NODCOP 96#ifndef KORG_NODCOP
98 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 97 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
99 QString tmpStr; 98 QString tmpStr;
100 if (n.startsWith("mailto:")) { 99 if (n.startsWith("mailto:")) {
101 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 100 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
102 //emit showIncidence(n); 101 //emit showIncidence(n);
103 return; 102 return;
104 } else if (n.startsWith("uid:")) { 103 } else if (n.startsWith("uid:")) {
105 DCOPClient *client = KApplication::kApplication()->dcopClient(); 104 DCOPClient *client = KApplication::kApplication()->dcopClient();
106 const QByteArray noParamData; 105 const QByteArray noParamData;
107 const QByteArray paramData; 106 const QByteArray paramData;
108 QByteArray replyData; 107 QByteArray replyData;
109 QCString replyTypeStr; 108 QCString replyTypeStr;
110#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 109#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
111 bool foundAbbrowser = PING_ABBROWSER; 110 bool foundAbbrowser = PING_ABBROWSER;
112 111
113 if (foundAbbrowser) { 112 if (foundAbbrowser) {
114 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 113 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
115 //client->send("kaddressbook","KAddressBookIface", 114 //client->send("kaddressbook","KAddressBookIface",
116 QDataStream arg(paramData, IO_WriteOnly); 115 QDataStream arg(paramData, IO_WriteOnly);
117 arg << n.mid(6); 116 arg << n.mid(6);
118 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 117 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
119 return; 118 return;
120 } else { 119 } else {
121 /* 120 /*
122 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 121 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
123 We start it without its main interface 122 We start it without its main interface
124 */ 123 */
125 KIconLoader* iconLoader = new KIconLoader(); 124 KIconLoader* iconLoader = new KIconLoader();
126 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 125 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
127 ActionManager::setStartedKAddressBook(true); 126 ActionManager::setStartedKAddressBook(true);
128 tmpStr = "kaddressbook --editor-only --uid "; 127 tmpStr = "kaddressbook --editor-only --uid ";
129 tmpStr += KProcess::quote(n.mid(6)); 128 tmpStr += KProcess::quote(n.mid(6));
130 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 129 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
131 return; 130 return;
132 } 131 }
133 } else { 132 } else {
134 //QTextBrowser::setSource(n); 133 //QTextBrowser::setSource(n);
135 } 134 }
136#endif 135#endif
137} 136}
138 137
139void KOEventViewer::addTag(const QString & tag,const QString & text) 138void KOEventViewer::addTag(const QString & tag,const QString & text)
140{ 139{
141 int number=text.contains("\n"); 140 int number=text.contains("\n");
142 QString str = "<" + tag + ">"; 141 QString str = "<" + tag + ">";
143 QString tmpText=text; 142 QString tmpText=text;
144 QString tmpStr=str; 143 QString tmpStr=str;
145 if(number !=-1) 144 if(number !=-1)
146 { 145 {
147 if (number > 0) { 146 if (number > 0) {
148 int pos=0; 147 int pos=0;
149 QString tmp; 148 QString tmp;
150 for(int i=0;i<=number;i++) { 149 for(int i=0;i<=number;i++) {
151 pos=tmpText.find("\n"); 150 pos=tmpText.find("\n");
152 tmp=tmpText.left(pos); 151 tmp=tmpText.left(pos);
153 tmpText=tmpText.right(tmpText.length()-pos-1); 152 tmpText=tmpText.right(tmpText.length()-pos-1);
154 tmpStr+=tmp+"<br>"; 153 tmpStr+=tmp+"<br>";
155 } 154 }
156 } 155 }
157 else tmpStr += tmpText; 156 else tmpStr += tmpText;
158 tmpStr+="</" + tag + ">"; 157 tmpStr+="</" + tag + ">";
159 mText.append(tmpStr); 158 mText.append(tmpStr);
160 } 159 }
161 else 160 else
162 { 161 {
163 str += text + "</" + tag + ">"; 162 str += text + "</" + tag + ">";
164 mText.append(str); 163 mText.append(str);
165 } 164 }
166} 165}
167 166
168void KOEventViewer::setColorMode( int m ) 167void KOEventViewer::setColorMode( int m )
169{ 168{
170 mColorMode = m; 169 mColorMode = m;
171} 170}
172void KOEventViewer::appendEvent(Event *event, int mode ) 171void KOEventViewer::appendEvent(Event *event, int mode )
173{ 172{
174 mCurrentIncidence = event; 173 mCurrentIncidence = event;
175 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 174 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
176 topLevelWidget()->setCaption(i18n("Event Viewer")); 175 topLevelWidget()->setCaption(i18n("Event Viewer"));
177 if ( mode == 0 ) { 176 if ( mode == 0 ) {
178 addTag("h2",event->summary()); 177 addTag("h2",event->summary());
179 } 178 }
180 else { 179 else {
181 if ( mColorMode == 1 ) { 180 if ( mColorMode == 1 ) {
182 mText +="<font color=\"#00A000\">"; 181 mText +="<font color=\"#00A000\">";
183 } 182 }
184 if ( mColorMode == 2 ) { 183 if ( mColorMode == 2 ) {
185 mText +="<font color=\"#C00000\">"; 184 mText +="<font color=\"#C00000\">";
186 } 185 }
187 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 186 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
188 if ( mode == 1 ) { 187 if ( mode == 1 ) {
189 addTag("h2",i18n( "Local: " ) +event->summary()); 188 addTag("h2",i18n( "Local: " ) +event->summary());
190 } else { 189 } else {
191 addTag("h2",i18n( "Remote: " ) +event->summary()); 190 addTag("h2",i18n( "Remote: " ) +event->summary());
192 } 191 }
193 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 192 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
194 if ( mColorMode ) 193 if ( mColorMode )
195 mText += "</font>"; 194 mText += "</font>";
196 } 195 }
197 if (event->cancelled ()) { 196 if (event->cancelled ()) {
198 mText +="<font color=\"#B00000\">"; 197 mText +="<font color=\"#B00000\">";
199 addTag("i",i18n("This event has been cancelled!")); 198 addTag("i",i18n("This event has been cancelled!"));
200 mText.append("<br>"); 199 mText.append("<br>");
201 mText += "</font>"; 200 mText += "</font>";
202 } 201 }
203 if (!event->location().isEmpty()) { 202 if (!event->location().isEmpty()) {
204 addTag("b",i18n("Location: ")); 203 addTag("b",i18n("Location: "));
205 mText.append(event->location()+"<br>"); 204 mText.append(event->location()+"<br>");
206 } 205 }
207 if (event->doesFloat()) { 206 if (event->doesFloat()) {
208 if (event->isMultiDay()) { 207 if (event->isMultiDay()) {
209 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 208 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
210 .arg(event->dtStartDateStr(shortDate)) 209 .arg(event->dtStartDateStr(shortDate))
211 .arg(event->dtEndDateStr(shortDate))); 210 .arg(event->dtEndDateStr(shortDate)));
212 } else { 211 } else {
213 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 212 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
214 } 213 }
215 } else { 214 } else {
216 if (event->isMultiDay()) { 215 if (event->isMultiDay()) {
217 mText.append(i18n("<p><b>From:</b> %1</p> ") 216 mText.append(i18n("<p><b>From:</b> %1</p> ")
218 .arg(event->dtStartStr( shortDate))); 217 .arg(event->dtStartStr( shortDate)));
219 mText.append(i18n("<p><b>To:</b> %1</p>") 218 mText.append(i18n("<p><b>To:</b> %1</p>")
220 .arg(event->dtEndStr(shortDate))); 219 .arg(event->dtEndStr(shortDate)));
221 } else { 220 } else {
222 mText.append(i18n("<p><b>On:</b> %1</p> ") 221 mText.append(i18n("<p><b>On:</b> %1</p> ")
223 .arg(event->dtStartDateStr( shortDate ))); 222 .arg(event->dtStartDateStr( shortDate )));
224 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 223 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
225 .arg(event->dtStartTimeStr()) 224 .arg(event->dtStartTimeStr())
226 .arg(event->dtEndTimeStr())); 225 .arg(event->dtEndTimeStr()));
227 } 226 }
228 } 227 }
229 228
230 if (event->recurrence()->doesRecur()) { 229 if (event->recurrence()->doesRecur()) {
231 230
232 QString recurText = event->recurrence()->recurrenceText(); 231 QString recurText = event->recurrence()->recurrenceText();
233 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 232 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
234 bool last; 233 bool last;
235 QDate start = QDate::currentDate(); 234 QDate start = QDate::currentDate();
236 QDate next; 235 QDate next;
237 next = event->recurrence()->getPreviousDate( start , &last ); 236 next = event->recurrence()->getPreviousDate( start , &last );
238 if ( !last ) { 237 if ( !last ) {
239 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 238 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
240 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 239 addTag("p",i18n("<b>Next recurrence is on:</b>") );
241 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 240 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
242 } else { 241 } else {
243 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 242 addTag("p",i18n("<b>Last recurrence was on:</b>") );
244 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 243 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
245 } 244 }
246 } 245 }
247 246
248 247
249 if (event->isAlarmEnabled()) { 248 if (event->isAlarmEnabled()) {
250 Alarm *alarm =event->alarms().first() ; 249 Alarm *alarm =event->alarms().first() ;
251 QDateTime t = alarm->time(); 250 QDateTime t = alarm->time();
252 int min = t.secsTo( event->dtStart() )/60; 251 int min = t.secsTo( event->dtStart() )/60;
253 QString s =i18n("( %1 min before )").arg( min ); 252 QString s =i18n("( %1 min before )").arg( min );
254 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 253 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
255 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 254 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
256 //addTag("p",s); 255 //addTag("p",s);
257 } 256 }
258 257
259 addTag("b",i18n("Access: ")); 258 addTag("b",i18n("Access: "));
260 mText.append(event->secrecyStr()+"<br>"); 259 mText.append(event->secrecyStr()+"<br>");
261 if (!event->description().isEmpty()) { 260 if (!event->description().isEmpty()) {
262 addTag("p",i18n("<b>Details: </b>")); 261 addTag("p",i18n("<b>Details: </b>"));
263 addTag("p",event->description()); 262 addTag("p",event->description());
264 } 263 }
265 264
266 formatCategories(event); 265 formatCategories(event);
267 266
268 formatReadOnly(event); 267 formatReadOnly(event);
269 formatAttendees(event); 268 formatAttendees(event);
270 269
271 setText(mText); 270 setText(mText);
272 //QWhatsThis::add(this,mText); 271 //QWhatsThis::add(this,mText);
273 272
274} 273}
275 274
276void KOEventViewer::appendTodo(Todo *event, int mode ) 275void KOEventViewer::appendTodo(Todo *event, int mode )
277{ 276{
278 mCurrentIncidence = event; 277 mCurrentIncidence = event;
279 topLevelWidget()->setCaption(i18n("Todo Viewer")); 278 topLevelWidget()->setCaption(i18n("Todo Viewer"));
280 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 279 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
281 if (mode == 0 ) 280 if (mode == 0 )
282 addTag("h2",event->summary()); 281 addTag("h2",event->summary());
283 else { 282 else {
284 if ( mColorMode == 1 ) { 283 if ( mColorMode == 1 ) {
285 mText +="<font color=\"#00A000\">"; 284 mText +="<font color=\"#00A000\">";
286 } 285 }
287 if ( mColorMode == 2 ) { 286 if ( mColorMode == 2 ) {
288 mText +="<font color=\"#B00000\">"; 287 mText +="<font color=\"#B00000\">";
289 } 288 }
290 if ( mode == 1 ) { 289 if ( mode == 1 ) {
291 addTag("h2",i18n( "Local: " ) +event->summary()); 290 addTag("h2",i18n( "Local: " ) +event->summary());
292 } else { 291 } else {
293 addTag("h2",i18n( "Remote: " ) +event->summary()); 292 addTag("h2",i18n( "Remote: " ) +event->summary());
294 } 293 }
295 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 294 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
296 if ( mColorMode ) 295 if ( mColorMode )
297 mText += "</font>"; 296 mText += "</font>";
298 } 297 }
299 if (event->cancelled ()) { 298 if (event->cancelled ()) {
300 mText +="<font color=\"#B00000\">"; 299 mText +="<font color=\"#B00000\">";
301 addTag("i",i18n("This todo has been cancelled!")); 300 addTag("i",i18n("This todo has been cancelled!"));
302 mText.append("<br>"); 301 mText.append("<br>");
303 mText += "</font>"; 302 mText += "</font>";
304 } 303 }
305 304
306 if (!event->location().isEmpty()) { 305 if (!event->location().isEmpty()) {
307 addTag("b",i18n("Location: ")); 306 addTag("b",i18n("Location: "));
308 mText.append(event->location()+"<br>"); 307 mText.append(event->location()+"<br>");
309 } 308 }
310 if (event->hasDueDate()) { 309 if (event->hasDueDate()) {
311 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 310 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
312 } 311 }
313 addTag("b",i18n("Access: ")); 312 addTag("b",i18n("Access: "));
314 mText.append(event->secrecyStr()+"<br>"); 313 mText.append(event->secrecyStr()+"<br>");
315 if (!event->description().isEmpty()) { 314 if (!event->description().isEmpty()) {
316 addTag("p",i18n("<b>Details: </b>")); 315 addTag("p",i18n("<b>Details: </b>"));
317 addTag("p",event->description()); 316 addTag("p",event->description());
318 } 317 }
319 318
320 formatCategories(event); 319 formatCategories(event);
321 320
322 mText.append(i18n("<p><b>Priority:</b> %2</p>") 321 mText.append(i18n("<p><b>Priority:</b> %2</p>")
323 .arg(QString::number(event->priority()))); 322 .arg(QString::number(event->priority())));
324 323
325 mText.append(i18n("<p><i>%1 % completed</i></p>") 324 mText.append(i18n("<p><i>%1 % completed</i></p>")
326 .arg(event->percentComplete())); 325 .arg(event->percentComplete()));
327 326
328 formatReadOnly(event); 327 formatReadOnly(event);
329 formatAttendees(event); 328 formatAttendees(event);
330 329
331 setText(mText); 330 setText(mText);
332} 331}
333 332
334void KOEventViewer::formatCategories(Incidence *event) 333void KOEventViewer::formatCategories(Incidence *event)
335{ 334{
336 if (!event->categoriesStr().isEmpty()) { 335 if (!event->categoriesStr().isEmpty()) {
337 if (event->categories().count() == 1) { 336 if (event->categories().count() == 1) {
338 addTag("h3",i18n("Category")); 337 addTag("h3",i18n("Category"));
339 } else { 338 } else {
340 addTag("h3",i18n("Categories")); 339 addTag("h3",i18n("Categories"));
341 } 340 }
342 addTag("p",event->categoriesStr()); 341 addTag("p",event->categoriesStr());
343 } 342 }
344} 343}
345void KOEventViewer::formatAttendees(Incidence *event) 344void KOEventViewer::formatAttendees(Incidence *event)
346{ 345{
347 QPtrList<Attendee> attendees = event->attendees(); 346 QPtrList<Attendee> attendees = event->attendees();
348 if (attendees.count()) { 347 if (attendees.count()) {
349 348
350 349
351 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 350 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
352 addTag("h3",i18n("Organizer")); 351 addTag("h3",i18n("Organizer"));
353 mText.append("<ul><li>"); 352 mText.append("<ul><li>");
354#ifndef KORG_NOKABC 353#ifndef KORG_NOKABC
355 354
356 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 355 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
357 KABC::Addressee::List addressList; 356 KABC::Addressee::List addressList;
358 addressList = add_book->findByEmail(event->organizer()); 357 addressList = add_book->findByEmail(event->organizer());
359 KABC::Addressee o = addressList.first(); 358 KABC::Addressee o = addressList.first();
360 if (!o.isEmpty() && addressList.size()<2) { 359 if (!o.isEmpty() && addressList.size()<2) {
361 mText += "<a href=\"uid:" + o.uid() + "\">"; 360 mText += "<a href=\"uid:" + o.uid() + "\">";
362 mText += o.formattedName(); 361 mText += o.formattedName();
363 mText += "</a>\n"; 362 mText += "</a>\n";
364 } else { 363 } else {
365 mText.append(event->organizer()); 364 mText.append(event->organizer());
366 } 365 }
367#else 366#else
368 mText.append(event->organizer()); 367 mText.append(event->organizer());
369#endif 368#endif
370 369
371 if (iconPath) { 370 if (iconPath) {
372 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 371 mText += " <a href=\"mailto:" + event->organizer() + "\">";
373 mText += "<IMG src=\"" + iconPath + "\">"; 372 mText += "<IMG src=\"" + iconPath + "\">";
374 mText += "</a>\n"; 373 mText += "</a>\n";
375 } 374 }
376 mText.append("</li></ul>"); 375 mText.append("</li></ul>");
377 376
378 addTag("h3",i18n("Attendees")); 377 addTag("h3",i18n("Attendees"));
379 Attendee *a; 378 Attendee *a;
380 mText.append("<ul>"); 379 mText.append("<ul>");
381 for(a=attendees.first();a;a=attendees.next()) { 380 for(a=attendees.first();a;a=attendees.next()) {
382#ifndef KORG_NOKABC 381#ifndef KORG_NOKABC
383 if (a->name().isEmpty()) { 382 if (a->name().isEmpty()) {
384 addressList = add_book->findByEmail(a->email()); 383 addressList = add_book->findByEmail(a->email());
385 KABC::Addressee o = addressList.first(); 384 KABC::Addressee o = addressList.first();
386 if (!o.isEmpty() && addressList.size()<2) { 385 if (!o.isEmpty() && addressList.size()<2) {
387 mText += "<a href=\"uid:" + o.uid() + "\">"; 386 mText += "<a href=\"uid:" + o.uid() + "\">";
388 mText += o.formattedName(); 387 mText += o.formattedName();
389 mText += "</a>\n"; 388 mText += "</a>\n";
390 } else { 389 } else {
391 mText += "<li>"; 390 mText += "<li>";
392 mText.append(a->email()); 391 mText.append(a->email());
393 mText += "\n"; 392 mText += "\n";
394 } 393 }
395 } else { 394 } else {
396 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 395 mText += "<li><a href=\"uid:" + a->uid() + "\">";
397 if (!a->name().isEmpty()) mText += a->name(); 396 if (!a->name().isEmpty()) mText += a->name();
398 else mText += a->email(); 397 else mText += a->email();
399 mText += "</a>\n"; 398 mText += "</a>\n";
400 } 399 }
401#else 400#else
402 //qDebug("nokabc "); 401 //qDebug("nokabc ");
403 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 402 mText += "<li><a href=\"uid:" + a->uid() + "\">";
404 if (!a->name().isEmpty()) mText += a->name(); 403 if (!a->name().isEmpty()) mText += a->name();
405 else mText += a->email(); 404 else mText += a->email();
406 mText += "</a>\n"; 405 mText += "</a>\n";
407#endif 406#endif
408 407
409 if (!a->email().isEmpty()) { 408 if (!a->email().isEmpty()) {
410 if (iconPath) { 409 if (iconPath) {
411 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 410 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
412 mText += "<IMG src=\"" + iconPath + "\">"; 411 mText += "<IMG src=\"" + iconPath + "\">";
413 mText += "</a>\n"; 412 mText += "</a>\n";
414 } 413 }
415 } 414 }
416 if (a->status() != Attendee::NeedsAction ) 415 if (a->status() != Attendee::NeedsAction )
417 mText +="[" + a->statusStr() + "] "; 416 mText +="[" + a->statusStr() + "] ";
418 if (a->role() == Attendee::Chair ) 417 if (a->role() == Attendee::Chair )
419 mText +="(" + a->roleStr().left(1) + ".)"; 418 mText +="(" + a->roleStr().left(1) + ".)";
420 } 419 }
421 mText.append("</li></ul>"); 420 mText.append("</li></ul>");
422 } 421 }
423 422
424} 423}
425void KOEventViewer::appendJournal(Journal *jour, int mode ) 424void KOEventViewer::appendJournal(Journal *jour, int mode )
426{ 425{
427 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 426 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
428 if (mode == 0 ) 427 if (mode == 0 )
429 addTag("h2",i18n("Journal from: ")); 428 addTag("h2",i18n("Journal from: "));
430 else { 429 else {
431 if ( mode == 1 ) { 430 if ( mode == 1 ) {
432 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 431 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
433 } else { 432 } else {
434 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 433 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
435 } 434 }
436 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 435 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
437 } 436 }
438 topLevelWidget()->setCaption("Journal Viewer"); 437 topLevelWidget()->setCaption("Journal Viewer");
439 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 438 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
440 if (!jour->description().isEmpty()) { 439 if (!jour->description().isEmpty()) {
441 addTag("p",jour->description()); 440 addTag("p",jour->description());
442 } 441 }
443 setText(mText); 442 setText(mText);
444} 443}
445 444
446void KOEventViewer::formatReadOnly(Incidence *event) 445void KOEventViewer::formatReadOnly(Incidence *event)
447{ 446{
448 if (event->isReadOnly()) { 447 if (event->isReadOnly()) {
449 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 448 addTag("p","<em>(" + i18n("read-only") + ")</em>");
450 } 449 }
451} 450}
452void KOEventViewer::setSyncMode( bool b ) 451void KOEventViewer::setSyncMode( bool b )
453{ 452{
454 mSyncMode = b; 453 mSyncMode = b;
455} 454}
456 455
457 456
458void KOEventViewer::setTodo(Todo *event, bool clearV ) 457void KOEventViewer::setTodo(Todo *event, bool clearV )
459{ 458{
460 if ( clearV ) 459 if ( clearV )
461 clearEvents(); 460 clearEvents();
462 if ( mSyncMode ) { 461 if ( mSyncMode ) {
463 if ( clearV ) 462 if ( clearV )
464 appendTodo(event,1 ); 463 appendTodo(event,1 );
465 else 464 else
466 appendTodo(event,2); 465 appendTodo(event,2);
467 } else 466 } else
468 appendTodo(event); 467 appendTodo(event);
469} 468}
470void KOEventViewer::setJournal(Journal *event, bool clearV ) 469void KOEventViewer::setJournal(Journal *event, bool clearV )
471{ 470{
472 if ( clearV ) 471 if ( clearV )
473 clearEvents(); 472 clearEvents();
474 if ( mSyncMode ) { 473 if ( mSyncMode ) {
475 if ( clearV ) 474 if ( clearV )
476 appendJournal(event, 1); 475 appendJournal(event, 1);
477 else 476 else
478 appendJournal(event, 2); 477 appendJournal(event, 2);
479 } else 478 } else
480 appendJournal(event); 479 appendJournal(event);
481} 480}
482 481
483void KOEventViewer::setEvent(Event *event) 482void KOEventViewer::setEvent(Event *event)
484{ 483{
485 clearEvents(); 484 clearEvents();
486 if ( mSyncMode ) 485 if ( mSyncMode )
487 appendEvent(event, 1); 486 appendEvent(event, 1);
488 else 487 else
489 appendEvent(event); 488 appendEvent(event);
490} 489}
491 490
492void KOEventViewer::addEvent(Event *event) 491void KOEventViewer::addEvent(Event *event)
493{ 492{
494 if ( mSyncMode ) 493 if ( mSyncMode )
495 appendEvent(event, 2); 494 appendEvent(event, 2);
496 else 495 else
497 appendEvent(event); 496 appendEvent(event);
498} 497}
499 498
500void KOEventViewer::clearEvents(bool now) 499void KOEventViewer::clearEvents(bool now)
501{ 500{
502 mText = ""; 501 mText = "";
503 if (now) setText(mText); 502 if (now) setText(mText);
504} 503}
505 504
506void KOEventViewer::addText(QString text) 505void KOEventViewer::addText(QString text)
507{ 506{
508 mText.append(text); 507 mText.append(text);
509 setText(mText); 508 setText(mText);
510} 509}
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index 64ab94d..be183eb 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -1,240 +1,239 @@
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 <klocale.h> 20#include <klocale.h>
21 21
22#include <libkcal/event.h> 22#include <libkcal/event.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24 24
25#include "koeventviewer.h" 25#include "koeventviewer.h"
26#include "koprefs.h" 26#include "koprefs.h"
27#include <libkcal/todo.h> 27#include <libkcal/todo.h>
28#include "qapp.h" 28#include "qapp.h"
29 29
30#include "koeventviewerdialog.h" 30#include "koeventviewerdialog.h"
31#include "koeventviewerdialog.moc"
32extern int globalFlagBlockAgenda; 31extern int globalFlagBlockAgenda;
33 32
34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) 33KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
35 : KDialogBase(parent,name, 34 : KDialogBase(parent,name,
36#ifndef DESKTOP_VERSION 35#ifndef DESKTOP_VERSION
37 true , 36 true ,
38#else 37#else
39 false, 38 false,
40#endif 39#endif
41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) 40 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
42{ 41{
43 42
44 mEventViewer = new KOEventViewer(this); 43 mEventViewer = new KOEventViewer(this);
45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 44 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
46 setMainWidget(mEventViewer); 45 setMainWidget(mEventViewer);
47 setButtonText(Ok, i18n("Edit") ); 46 setButtonText(Ok, i18n("Edit") );
48 47
49 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 48 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
50 SLOT(editIncidence())); 49 SLOT(editIncidence()));
51 QObject::connect(this,SIGNAL(user1Clicked()), 50 QObject::connect(this,SIGNAL(user1Clicked()),
52 SLOT(showIncidence())); 51 SLOT(showIncidence()));
53 mIncidence = 0; 52 mIncidence = 0;
54 // TODO: Set a sensible size (based on the content?). 53 // TODO: Set a sensible size (based on the content?).
55 //showMaximized(); 54 //showMaximized();
56 //qDebug("++++++++++++KOEventViewerDialog() "); 55 //qDebug("++++++++++++KOEventViewerDialog() ");
57 // if ( KOPrefs::instance()->mCompactDialogs ) { 56 // if ( KOPrefs::instance()->mCompactDialogs ) {
58// setFixedSize( 240,284 ); 57// setFixedSize( 240,284 );
59// move( 0, 15 ); 58// move( 0, 15 );
60// } else { 59// } else {
61// setMinimumSize(300,200); 60// setMinimumSize(300,200);
62// resize(320,300); 61// resize(320,300);
63// } 62// }
64 mSyncMode = false; 63 mSyncMode = false;
65 mSyncResult = 0; 64 mSyncResult = 0;
66 65
67} 66}
68 67
69KOEventViewerDialog::~KOEventViewerDialog() 68KOEventViewerDialog::~KOEventViewerDialog()
70{ 69{
71 //qDebug("-------~KOEventViewerDialog() "); 70 //qDebug("-------~KOEventViewerDialog() ");
72} 71}
73void KOEventViewerDialog::showMe() 72void KOEventViewerDialog::showMe()
74{ 73{
75 74
76#ifdef DESKTOP_VERSION 75#ifdef DESKTOP_VERSION
77 show(); 76 show();
78#else 77#else
79 showMaximized(); 78 showMaximized();
80#endif 79#endif
81 setFocus(); 80 setFocus();
82 setActiveWindow(); 81 setActiveWindow();
83 82
84} 83}
85void KOEventViewerDialog::setSyncMode( bool b ) 84void KOEventViewerDialog::setSyncMode( bool b )
86{ 85{
87 mSyncMode = b; 86 mSyncMode = b;
88 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); 87 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
89 if ( mSyncMode ) { 88 if ( mSyncMode ) {
90 findButton( Close )->setText( i18n("Cancel Sync")); 89 findButton( Close )->setText( i18n("Cancel Sync"));
91 findButton( Ok )->setText( i18n("Remote")); 90 findButton( Ok )->setText( i18n("Remote"));
92 findButton( User1 )->setText( i18n("Local")); 91 findButton( User1 )->setText( i18n("Local"));
93 } else { 92 } else {
94 findButton( Close )->setText( i18n("Close")); 93 findButton( Close )->setText( i18n("Close"));
95 findButton( Ok )->setText( i18n("Edit")); 94 findButton( Ok )->setText( i18n("Edit"));
96 findButton( User1 )->setText( i18n("Agenda")); 95 findButton( User1 )->setText( i18n("Agenda"));
97 } 96 }
98 mEventViewer->setSyncMode( b ); 97 mEventViewer->setSyncMode( b );
99} 98}
100void KOEventViewerDialog::setColorMode( int m ) 99void KOEventViewerDialog::setColorMode( int m )
101{ 100{
102 mEventViewer->setColorMode( m ); 101 mEventViewer->setColorMode( m );
103} 102}
104int KOEventViewerDialog::executeS( bool local ) 103int KOEventViewerDialog::executeS( bool local )
105{ 104{
106 mSyncResult = 3; 105 mSyncResult = 3;
107 if ( local ) 106 if ( local )
108 findButton( User1 )->setFocus(); 107 findButton( User1 )->setFocus();
109 else 108 else
110 findButton( Ok )->setFocus(); 109 findButton( Ok )->setFocus();
111 exec(); 110 exec();
112 return mSyncResult; 111 return mSyncResult;
113} 112}
114 113
115void KOEventViewerDialog::updateConfig() 114void KOEventViewerDialog::updateConfig()
116{ 115{
117 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 116 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
118 117
119} 118}
120void KOEventViewerDialog::setEvent(Event *event) 119void KOEventViewerDialog::setEvent(Event *event)
121{ 120{
122 mEventViewer->setEvent(event); 121 mEventViewer->setEvent(event);
123 mIncidence = event; 122 mIncidence = event;
124 findButton( Close )->setFocus(); 123 findButton( Close )->setFocus();
125} 124}
126void KOEventViewerDialog::setIncidence(Incidence *in ) 125void KOEventViewerDialog::setIncidence(Incidence *in )
127{ 126{
128 if ( in->type() == "Event" ) 127 if ( in->type() == "Event" )
129 setEvent( (Event*) in ); 128 setEvent( (Event*) in );
130 else if ( in->type() =="Todo" ) 129 else if ( in->type() =="Todo" )
131 setTodo( (Todo*) in ); 130 setTodo( (Todo*) in );
132 else if ( in->type() =="Journal" ) 131 else if ( in->type() =="Journal" )
133 setJournal( (Journal*) in ); 132 setJournal( (Journal*) in );
134} 133}
135void KOEventViewerDialog::addIncidence(Incidence *in) 134void KOEventViewerDialog::addIncidence(Incidence *in)
136{ 135{
137 if ( in->type() == "Event" ) 136 if ( in->type() == "Event" )
138 addEvent( (Event*) in ); 137 addEvent( (Event*) in );
139 else if ( in->type() =="Todo" ) 138 else if ( in->type() =="Todo" )
140 mEventViewer->setTodo( (Todo*) in, false ); 139 mEventViewer->setTodo( (Todo*) in, false );
141 else if ( in->type() =="Journal" ) 140 else if ( in->type() =="Journal" )
142 mEventViewer->setJournal( (Journal*) in, false ); 141 mEventViewer->setJournal( (Journal*) in, false );
143 if ( mSyncMode ) { 142 if ( mSyncMode ) {
144 findButton( User1 )->setFocus(); 143 findButton( User1 )->setFocus();
145 setCaption(i18n("Conflict! Please choose entry")); 144 setCaption(i18n("Conflict! Please choose entry"));
146 } 145 }
147} 146}
148 147
149void KOEventViewerDialog::addEvent(Event *event) 148void KOEventViewerDialog::addEvent(Event *event)
150{ 149{
151 mEventViewer->addEvent(event); 150 mEventViewer->addEvent(event);
152 mIncidence = event; 151 mIncidence = event;
153 findButton( Close )->setFocus(); 152 findButton( Close )->setFocus();
154} 153}
155 154
156void KOEventViewerDialog::setTodo(Todo *event) 155void KOEventViewerDialog::setTodo(Todo *event)
157{ 156{
158 mEventViewer->setTodo(event); 157 mEventViewer->setTodo(event);
159 mIncidence = (Incidence*)event; 158 mIncidence = (Incidence*)event;
160 findButton( Close )->setFocus(); 159 findButton( Close )->setFocus();
161} 160}
162void KOEventViewerDialog::setJournal(Journal *j) 161void KOEventViewerDialog::setJournal(Journal *j)
163{ 162{
164 mEventViewer->setJournal(j); 163 mEventViewer->setJournal(j);
165 mIncidence = (Incidence*)j; 164 mIncidence = (Incidence*)j;
166 findButton( Close )->setFocus(); 165 findButton( Close )->setFocus();
167} 166}
168 167
169void KOEventViewerDialog::addText(QString text) 168void KOEventViewerDialog::addText(QString text)
170{ 169{
171 mEventViewer->addText(text); 170 mEventViewer->addText(text);
172 findButton( Close )->setFocus(); 171 findButton( Close )->setFocus();
173} 172}
174void KOEventViewerDialog::editIncidence() 173void KOEventViewerDialog::editIncidence()
175{ 174{
176 if ( mSyncMode ) { 175 if ( mSyncMode ) {
177 mSyncResult = 2; 176 mSyncResult = 2;
178 accept(); 177 accept();
179 return; 178 return;
180 } 179 }
181 if ( mIncidence ){ 180 if ( mIncidence ){
182#ifndef DESKTOP_VERSION 181#ifndef DESKTOP_VERSION
183 hide(); 182 hide();
184#endif 183#endif
185 emit editIncidence( mIncidence ); 184 emit editIncidence( mIncidence );
186 } 185 }
187} 186}
188void KOEventViewerDialog::showIncidence() 187void KOEventViewerDialog::showIncidence()
189{ 188{
190 189
191 if ( mSyncMode ) { 190 if ( mSyncMode ) {
192 mSyncResult = 1; 191 mSyncResult = 1;
193 accept(); 192 accept();
194 return; 193 return;
195 } 194 }
196 195
197 if ( mIncidence ){ 196 if ( mIncidence ){
198#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
199 hide(); 198 hide();
200#endif 199#endif
201 QDate date; 200 QDate date;
202 if ( mIncidence->type() == "Todo" ) { 201 if ( mIncidence->type() == "Todo" ) {
203 if ( ((Todo*)mIncidence)->hasDueDate() ) 202 if ( ((Todo*)mIncidence)->hasDueDate() )
204 date = ((Todo*)mIncidence)->dtDue().date(); 203 date = ((Todo*)mIncidence)->dtDue().date();
205 else { 204 else {
206 globalFlagBlockAgenda = 2; 205 globalFlagBlockAgenda = 2;
207 emit showAgendaView( false ); 206 emit showAgendaView( false );
208 return; 207 return;
209 } 208 }
210 } else 209 } else
211 date = mIncidence->dtStart().date(); 210 date = mIncidence->dtStart().date();
212 globalFlagBlockAgenda = 1; 211 globalFlagBlockAgenda = 1;
213 emit showAgendaView( false ); 212 emit showAgendaView( false );
214 globalFlagBlockAgenda = 2; 213 globalFlagBlockAgenda = 2;
215 emit jumpToTime( date ); 214 emit jumpToTime( date );
216 } 215 }
217} 216}
218void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 217void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
219{ 218{
220 switch ( e->key() ) { 219 switch ( e->key() ) {
221 220
222 case Qt::Key_A : 221 case Qt::Key_A :
223 case Qt::Key_L : 222 case Qt::Key_L :
224 showIncidence(); 223 showIncidence();
225 break; 224 break;
226 case Qt::Key_E : 225 case Qt::Key_E :
227 case Qt::Key_R : 226 case Qt::Key_R :
228 editIncidence(); 227 editIncidence();
229 break; 228 break;
230 case Qt::Key_C: 229 case Qt::Key_C:
231 close(); 230 close();
232 break; 231 break;
233 case Qt::Key_I: 232 case Qt::Key_I:
234 accept(); 233 accept();
235 break; 234 break;
236 default: 235 default:
237 break; 236 break;
238 } 237 }
239 238
240} 239}
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index b22bc54..1479208 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,96 +1,95 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27 27
28#include <libkcal/calfilter.h> 28#include <libkcal/calfilter.h>
29 29
30#include "kofilterview.h" 30#include "kofilterview.h"
31#include "kofilterview.moc"
32 31
33KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 32KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
34 const char* name,WFlags fl ) 33 const char* name,WFlags fl )
35 : KOFilterView_base(parent,name,fl) 34 : KOFilterView_base(parent,name,fl)
36{ 35{
37 mFilters = filterList; 36 mFilters = filterList;
38 37
39 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 38 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
40 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 39 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
41 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 40 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
42} 41}
43 42
44KOFilterView::~KOFilterView() 43KOFilterView::~KOFilterView()
45{ 44{
46 // no need to delete child widgets, Qt does it all for us 45 // no need to delete child widgets, Qt does it all for us
47} 46}
48 47
49bool KOFilterView::filtersEnabled() 48bool KOFilterView::filtersEnabled()
50{ 49{
51 return mEnabledCheck->isChecked(); 50 return mEnabledCheck->isChecked();
52} 51}
53 52
54void KOFilterView::setFiltersEnabled(bool set) 53void KOFilterView::setFiltersEnabled(bool set)
55{ 54{
56 mEnabledCheck->setChecked(set); 55 mEnabledCheck->setChecked(set);
57 emit filterChanged(); 56 emit filterChanged();
58} 57}
59 58
60 59
61void KOFilterView::updateFilters() 60void KOFilterView::updateFilters()
62{ 61{
63 mSelectionCombo->clear(); 62 mSelectionCombo->clear();
64 63
65 CalFilter *filter = mFilters->first(); 64 CalFilter *filter = mFilters->first();
66 while(filter) { 65 while(filter) {
67 mSelectionCombo->insertItem(filter->name()); 66 mSelectionCombo->insertItem(filter->name());
68 filter = mFilters->next(); 67 filter = mFilters->next();
69 } 68 }
70} 69}
71 70
72CalFilter *KOFilterView::selectedFilter() 71CalFilter *KOFilterView::selectedFilter()
73{ 72{
74 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 73 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
75 return f; 74 return f;
76} 75}
77 76
78void KOFilterView::setSelectedFilter(QString filterName) 77void KOFilterView::setSelectedFilter(QString filterName)
79{ 78{
80 int filter_num = mSelectionCombo->count(); 79 int filter_num = mSelectionCombo->count();
81 int i; 80 int i;
82 for (i=0;i<filter_num;i++) { 81 for (i=0;i<filter_num;i++) {
83 if (mSelectionCombo->text(i)==filterName) 82 if (mSelectionCombo->text(i)==filterName)
84 mSelectionCombo->setCurrentItem(i); 83 mSelectionCombo->setCurrentItem(i);
85 } 84 }
86 emit filterChanged(); 85 emit filterChanged();
87} 86}
88void KOFilterView::setSelectedFilter( int fil ) 87void KOFilterView::setSelectedFilter( int fil )
89{ 88{
90 if ( fil >= mSelectionCombo->count() ) 89 if ( fil >= mSelectionCombo->count() )
91 return; 90 return;
92 mSelectionCombo->setCurrentItem( fil ); 91 mSelectionCombo->setCurrentItem( fil );
93 emit filterChanged(); 92 emit filterChanged();
94} 93}
95 94
96 95
diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp
index e10a188..51df123 100644
--- a/korganizer/koincidenceeditor.cpp
+++ b/korganizer/koincidenceeditor.cpp
@@ -1,187 +1,186 @@
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 <qtooltip.h> 24#include <qtooltip.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qdatetime.h> 29#include <qdatetime.h>
30#include <qdir.h> 30#include <qdir.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37 37
38#include <libkdepim/categoryselectdialog.h> 38#include <libkdepim/categoryselectdialog.h>
39#include <libkdepim/kinputdialog.h> 39#include <libkdepim/kinputdialog.h>
40 40
41#include <libkcal/calendarlocal.h> 41#include <libkcal/calendarlocal.h>
42#include <libkcal/icalformat.h> 42#include <libkcal/icalformat.h>
43 43
44#include "koprefs.h" 44#include "koprefs.h"
45#include "koglobals.h" 45#include "koglobals.h"
46 46
47#include "koincidenceeditor.h" 47#include "koincidenceeditor.h"
48#include "koincidenceeditor.moc"
49 48
50KOIncidenceEditor::KOIncidenceEditor( const QString &caption, 49KOIncidenceEditor::KOIncidenceEditor( const QString &caption,
51 Calendar *calendar, QWidget *parent ) : 50 Calendar *calendar, QWidget *parent ) :
52 KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok, 51 KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok,
53 parent, caption, true, false ), 52 parent, caption, true, false ),
54 mSaveTemplateDialog( 0 ) 53 mSaveTemplateDialog( 0 )
55{ 54{
56 mCalendar = calendar; 55 mCalendar = calendar;
57 56
58 setButtonText( Default, i18n("Template...") ); 57 setButtonText( Default, i18n("Template...") );
59 58
60 QString saveTemplateText; 59 QString saveTemplateText;
61 // if ( KOPrefs::instance()->mCompactDialogs ) { 60 // if ( KOPrefs::instance()->mCompactDialogs ) {
62// showButton( User1, false ); 61// showButton( User1, false );
63// showButton( Apply, false ); 62// showButton( Apply, false );
64// } else { 63// } else {
65 showButton( Apply, false ); 64 showButton( Apply, false );
66 saveTemplateText = i18n("Ok+Agenda"); 65 saveTemplateText = i18n("Ok+Agenda");
67 // } 66 // }
68 setButtonText( User1, saveTemplateText ); 67 setButtonText( User1, saveTemplateText );
69 68
70 //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this ); 69 //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this );
71 // KOGlobals::fitDialogToScreen( mCategoryDialog ); 70 // KOGlobals::fitDialogToScreen( mCategoryDialog );
72 71
73 //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories())); 72 //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories()));
74 73
75 //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) ); 74 //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) );
76 // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) ); 75 // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) );
77 connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) ); 76 connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) );
78} 77}
79 78
80KOIncidenceEditor::~KOIncidenceEditor() 79KOIncidenceEditor::~KOIncidenceEditor()
81{ 80{
82 //delete mCategoryDialog; 81 //delete mCategoryDialog;
83} 82}
84 83
85void KOIncidenceEditor::setupAttendeesTab() 84void KOIncidenceEditor::setupAttendeesTab()
86{ 85{
87 QFrame *topFrame = addPage(i18n("Attendees")); 86 QFrame *topFrame = addPage(i18n("Attendees"));
88 87
89 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 88 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
90 89
91 mDetails = new KOEditorDetails(spacingHint(),topFrame); 90 mDetails = new KOEditorDetails(spacingHint(),topFrame);
92 topLayout->addWidget(mDetails); 91 topLayout->addWidget(mDetails);
93} 92}
94 93
95 94
96void KOIncidenceEditor::slotApply() 95void KOIncidenceEditor::slotApply()
97{ 96{
98 processInput( false ); 97 processInput( false );
99} 98}
100void KOIncidenceEditor::accept() 99void KOIncidenceEditor::accept()
101{ 100{
102 slotOk(); 101 slotOk();
103} 102}
104void KOIncidenceEditor::slotOk() 103void KOIncidenceEditor::slotOk()
105{ 104{
106 if ( processInput( false ) ) QDialog::accept(); 105 if ( processInput( false ) ) QDialog::accept();
107} 106}
108 107
109void KOIncidenceEditor::updateCategoryConfig() 108void KOIncidenceEditor::updateCategoryConfig()
110{ 109{
111 qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! "); 110 qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! ");
112 //mCategoryDialog->updateCategoryConfig(); 111 //mCategoryDialog->updateCategoryConfig();
113} 112}
114 113
115void KOIncidenceEditor::slotCancel() 114void KOIncidenceEditor::slotCancel()
116{ 115{
117 reject(); 116 reject();
118} 117}
119 118
120void KOIncidenceEditor::slotLoadTemplate() 119void KOIncidenceEditor::slotLoadTemplate()
121{ 120{
122 kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl; 121 kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl;
123} 122}
124void KOIncidenceEditor::slotShowIncidence() 123void KOIncidenceEditor::slotShowIncidence()
125{ 124{
126 125
127 if ( processInput(true ) ) { 126 if ( processInput(true ) ) {
128 accept(); 127 accept();
129 } 128 }
130} 129}
131 130
132void KOIncidenceEditor::slotSaveTemplate() 131void KOIncidenceEditor::slotSaveTemplate()
133{ 132{
134 kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl; 133 kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl;
135} 134}
136 135
137void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type ) 136void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type )
138{ 137{
139 if ( !mSaveTemplateDialog ) { 138 if ( !mSaveTemplateDialog ) {
140 mSaveTemplateDialog = new SaveTemplateDialog( type, this ); 139 mSaveTemplateDialog = new SaveTemplateDialog( type, this );
141 connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ), 140 connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ),
142 SLOT( saveTemplate( const QString & ) ) ); 141 SLOT( saveTemplate( const QString & ) ) );
143 } 142 }
144 mSaveTemplateDialog->show(); 143 mSaveTemplateDialog->show();
145 mSaveTemplateDialog->raise(); 144 mSaveTemplateDialog->raise();
146} 145}
147 146
148void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, 147void KOIncidenceEditor::saveAsTemplate( Incidence *incidence,
149 const QString &templateName ) 148 const QString &templateName )
150{ 149{
151 CalendarLocal cal; 150 CalendarLocal cal;
152 cal.addIncidence( incidence ); 151 cal.addIncidence( incidence );
153 ICalFormat format; 152 ICalFormat format;
154 format.save( &cal, templateName ); 153 format.save( &cal, templateName );
155} 154}
156 155
157QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type, 156QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type,
158 const QStringList &templates ) 157 const QStringList &templates )
159{ 158{
160 // bool ok = false; 159 // bool ok = false;
161// QString templateName = KInputDialog::getItem( i18n("Load Template"), 160// QString templateName = KInputDialog::getItem( i18n("Load Template"),
162// i18n("Select a template to load:"), templates, 0, &ok ); 161// i18n("Select a template to load:"), templates, 0, &ok );
163// if ( !ok || templateName.isEmpty() ) return QString::null; 162// if ( !ok || templateName.isEmpty() ) return QString::null;
164 163
165// QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" + 164// QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" +
166// templateName ); 165// templateName );
167// fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); 166// fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this );
168 167
169 // QString fileName;// =locateLocal( "templates", incidence->type() ); 168 // QString fileName;// =locateLocal( "templates", incidence->type() );
170// fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this ); 169// fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this );
171// if ( fileNamelength() == 0) 170// if ( fileNamelength() == 0)
172// return QString::null; 171// return QString::null;
173// if ( fileName.isEmpty() ) { 172// if ( fileName.isEmpty() ) {
174// KMessageBox::error( this, i18n("Unable to find template '%1'.") 173// KMessageBox::error( this, i18n("Unable to find template '%1'.")
175// .arg( fileName ) ); 174// .arg( fileName ) );
176// return QString::null; 175// return QString::null;
177// } else { 176// } else {
178// ICalFormat format; 177// ICalFormat format;
179// if ( !format.load( cal, fileName ) ) { 178// if ( !format.load( cal, fileName ) ) {
180// KMessageBox::error( this, i18n("Error loading template file '%1'.") 179// KMessageBox::error( this, i18n("Error loading template file '%1'.")
181// .arg( fileName ) ); 180// .arg( fileName ) );
182// return QString::null; 181// return QString::null;
183// } 182// }
184// } 183// }
185 184
186 return ""; 185 return "";
187} 186}
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 579f24d..6e6a939 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,113 +1,112 @@
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// 24//
25// View of Journal entries 25// View of Journal entries
26 26
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29 29
30#include <klocale.h> 30#include <klocale.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include "koprefs.h" 32#include "koprefs.h"
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35 35
36#include "journalentry.h" 36#include "journalentry.h"
37 37
38#include "kojournalview.h" 38#include "kojournalview.h"
39using namespace KOrg; 39using namespace KOrg;
40#include "kojournalview.moc"
41 40
42KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 41KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
43 const char *name) 42 const char *name)
44 : KOrg::BaseView(calendar, parent, name) 43 : KOrg::BaseView(calendar, parent, name)
45{ 44{
46 mEntry = new JournalEntry(calendar,this); 45 mEntry = new JournalEntry(calendar,this);
47 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 46 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
48 QBoxLayout *topLayout = new QVBoxLayout(this); 47 QBoxLayout *topLayout = new QVBoxLayout(this);
49 topLayout->addWidget(mEntry); 48 topLayout->addWidget(mEntry);
50 connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; 49 connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
51} 50}
52 51
53KOJournalView::~KOJournalView() 52KOJournalView::~KOJournalView()
54{ 53{
55} 54}
56 55
57int KOJournalView::currentDateCount() 56int KOJournalView::currentDateCount()
58{ 57{
59 return 0; 58 return 0;
60} 59}
61 60
62QPtrList<Incidence> KOJournalView::selectedIncidences() 61QPtrList<Incidence> KOJournalView::selectedIncidences()
63{ 62{
64 QPtrList<Incidence> eventList; 63 QPtrList<Incidence> eventList;
65 64
66 return eventList; 65 return eventList;
67} 66}
68void KOJournalView::updateConfig() 67void KOJournalView::updateConfig()
69{ 68{
70 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 69 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
71} 70}
72void KOJournalView::updateView() 71void KOJournalView::updateView()
73{ 72{
74 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 73 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
75} 74}
76 75
77void KOJournalView::flushView() 76void KOJournalView::flushView()
78{ 77{
79 mEntry->flushEntry(); 78 mEntry->flushEntry();
80} 79}
81 80
82void KOJournalView::showDates(const QDate &start, const QDate &) 81void KOJournalView::showDates(const QDate &start, const QDate &)
83{ 82{
84// kdDebug() << "KOJournalView::selectDates()" << endl; 83// kdDebug() << "KOJournalView::selectDates()" << endl;
85 84
86 mEntry->setDate(start); 85 mEntry->setDate(start);
87 86
88 Journal *j = calendar()->journal(start); 87 Journal *j = calendar()->journal(start);
89 if (j) mEntry->setJournal(j); 88 if (j) mEntry->setJournal(j);
90 else mEntry->clear(); 89 else mEntry->clear();
91 90
92// emit incidenceSelected( 0 ); 91// emit incidenceSelected( 0 );
93} 92}
94 93
95void KOJournalView::showEvents(QPtrList<Event>) 94void KOJournalView::showEvents(QPtrList<Event>)
96{ 95{
97 // After new creation of list view no events are selected. 96 // After new creation of list view no events are selected.
98// emit incidenceSelected( 0 ); 97// emit incidenceSelected( 0 );
99} 98}
100 99
101void KOJournalView::changeEventDisplay(Event *, int /*action*/) 100void KOJournalView::changeEventDisplay(Event *, int /*action*/)
102{ 101{
103 updateView(); 102 updateView();
104} 103}
105 104
106void KOJournalView::keyPressEvent ( QKeyEvent * e ) 105void KOJournalView::keyPressEvent ( QKeyEvent * e )
107{ 106{
108 //qDebug("keyPressEven "); 107 //qDebug("keyPressEven ");
109 if ( e->state() == Qt::ControlButton ) { 108 if ( e->state() == Qt::ControlButton ) {
110 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) 109 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
111 e->ignore(); 110 e->ignore();
112 } 111 }
113} 112}
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index b6061d0..9a3ba73 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1062 +1,1061 @@
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 35
36#include <klocale.h> 36#include <klocale.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <kiconloader.h> 38#include <kiconloader.h>
39#include <kglobal.h> 39#include <kglobal.h>
40 40
41#include <libkcal/calendar.h> 41#include <libkcal/calendar.h>
42#include <libkcal/calendarlocal.h> 42#include <libkcal/calendarlocal.h>
43#include <libkcal/icalformat.h> 43#include <libkcal/icalformat.h>
44#include <libkcal/vcalformat.h> 44#include <libkcal/vcalformat.h>
45#include <libkcal/recurrence.h> 45#include <libkcal/recurrence.h>
46#include <libkcal/filestorage.h> 46#include <libkcal/filestorage.h>
47#include <libkdepim/categoryselectdialog.h> 47#include <libkdepim/categoryselectdialog.h>
48#ifndef DESKTOP_VERSION 48#ifndef DESKTOP_VERSION
49#include <qpe/qpeapplication.h> 49#include <qpe/qpeapplication.h>
50#else 50#else
51#include <qapplication.h> 51#include <qapplication.h>
52#endif 52#endif
53 53
54#ifndef KORG_NOPRINTER 54#ifndef KORG_NOPRINTER
55#include "calprinter.h" 55#include "calprinter.h"
56#endif 56#endif
57#include "koglobals.h" 57#include "koglobals.h"
58#include "koprefs.h" 58#include "koprefs.h"
59#include "kfiledialog.h" 59#include "kfiledialog.h"
60 60
61#include "kolistview.h" 61#include "kolistview.h"
62#include "kolistview.moc"
63 62
64ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 63ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
65{ 64{
66 mItem = item; 65 mItem = item;
67 mDate = date; 66 mDate = date;
68} 67}
69 68
70ListItemVisitor::~ListItemVisitor() 69ListItemVisitor::~ListItemVisitor()
71{ 70{
72} 71}
73 72
74bool ListItemVisitor::visit(Event *e) 73bool ListItemVisitor::visit(Event *e)
75{ 74{
76 75
77 bool ok = false; 76 bool ok = false;
78 QString start, end; 77 QString start, end;
79 if ( e->doesRecur() ) { 78 if ( e->doesRecur() ) {
80 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 79 QDate d = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
81 if ( ok ) { 80 if ( ok ) {
82 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 81 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
83 start = KGlobal::locale()->formatDate(d,true); 82 start = KGlobal::locale()->formatDate(d,true);
84 end = KGlobal::locale()->formatDate(d.addDays( days),true); 83 end = KGlobal::locale()->formatDate(d.addDays( days),true);
85 } 84 }
86 85
87 } 86 }
88 if ( ! ok ) { 87 if ( ! ok ) {
89 start =e->dtStartDateStr(); 88 start =e->dtStartDateStr();
90 end = e->dtEndDateStr(); 89 end = e->dtEndDateStr();
91 } 90 }
92 mItem->setText(0,e->summary()); 91 mItem->setText(0,e->summary());
93 mItem->setText(1,start); 92 mItem->setText(1,start);
94 mItem->setText(2,e->dtStartTimeStr()); 93 mItem->setText(2,e->dtStartTimeStr());
95 mItem->setText(3,end); 94 mItem->setText(3,end);
96 mItem->setText(4,e->dtEndTimeStr()); 95 mItem->setText(4,e->dtEndTimeStr());
97 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); 96 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
98 mItem->setText(6, e->recurrence()->recurrenceText()); 97 mItem->setText(6, e->recurrence()->recurrenceText());
99 mItem->setText(7,"---"); 98 mItem->setText(7,"---");
100 mItem->setText(8,"---"); 99 mItem->setText(8,"---");
101 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 100 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
102 mItem->setText(10,e->categoriesStr()); 101 mItem->setText(10,e->categoriesStr());
103 102
104 QString key; 103 QString key;
105 QDate d = e->dtStart().date(); 104 QDate d = e->dtStart().date();
106 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 105 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
107 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); 106 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
108 mItem->setSortKey(1,key); 107 mItem->setSortKey(1,key);
109 108
110 d = e->dtEnd().date(); 109 d = e->dtEnd().date();
111 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 110 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
112 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute()); 111 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute());
113 mItem->setSortKey(3,key); 112 mItem->setSortKey(3,key);
114 113
115 return true; 114 return true;
116} 115}
117 116
118bool ListItemVisitor::visit(Todo *t) 117bool ListItemVisitor::visit(Todo *t)
119{ 118{
120 mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); 119 mItem->setText(0,i18n("To-Do: %1").arg(t->summary()));
121 if (t->hasStartDate()) { 120 if (t->hasStartDate()) {
122 mItem->setText(1,t->dtStartDateStr()); 121 mItem->setText(1,t->dtStartDateStr());
123 if (t->doesFloat()) { 122 if (t->doesFloat()) {
124 mItem->setText(2,"---"); 123 mItem->setText(2,"---");
125 } else { 124 } else {
126 mItem->setText(2,t->dtStartTimeStr()); 125 mItem->setText(2,t->dtStartTimeStr());
127 } 126 }
128 } else { 127 } else {
129 mItem->setText(1,"---"); 128 mItem->setText(1,"---");
130 mItem->setText(2,"---"); 129 mItem->setText(2,"---");
131 } 130 }
132 mItem->setText(3,"---"); 131 mItem->setText(3,"---");
133 mItem->setText(4,"---"); 132 mItem->setText(4,"---");
134 mItem->setText(5,"---"); 133 mItem->setText(5,"---");
135 mItem->setText(6,"---"); 134 mItem->setText(6,"---");
136 if (t->hasDueDate()) { 135 if (t->hasDueDate()) {
137 mItem->setText(7,t->dtDueDateStr()); 136 mItem->setText(7,t->dtDueDateStr());
138 if (t->doesFloat()) { 137 if (t->doesFloat()) {
139 mItem->setText(8,"---"); 138 mItem->setText(8,"---");
140 } else { 139 } else {
141 mItem->setText(8,t->dtDueTimeStr()); 140 mItem->setText(8,t->dtDueTimeStr());
142 } 141 }
143 } else { 142 } else {
144 mItem->setText(7,"---"); 143 mItem->setText(7,"---");
145 mItem->setText(8,"---"); 144 mItem->setText(8,"---");
146 } 145 }
147 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 146 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
148 mItem->setText(10,t->categoriesStr()); 147 mItem->setText(10,t->categoriesStr());
149 148
150 QString key; 149 QString key;
151 QDate d; 150 QDate d;
152 if (t->hasDueDate()) { 151 if (t->hasDueDate()) {
153 d = t->dtDue().date(); 152 d = t->dtDue().date();
154 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 153 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
155 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 154 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
156 mItem->setSortKey(7,key); 155 mItem->setSortKey(7,key);
157 } 156 }
158 if ( t->hasStartDate() ) { 157 if ( t->hasStartDate() ) {
159 d = t->dtStart().date(); 158 d = t->dtStart().date();
160 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 159 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
161 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 160 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
162 mItem->setSortKey(1,key); 161 mItem->setSortKey(1,key);
163 } 162 }
164 return true; 163 return true;
165} 164}
166 165
167bool ListItemVisitor::visit(Journal * j) 166bool ListItemVisitor::visit(Journal * j)
168{ 167{
169 mItem->setText(0,i18n("Journal")); 168 mItem->setText(0,i18n("Journal"));
170 mItem->setText(1,j->dtStartDateStr()); 169 mItem->setText(1,j->dtStartDateStr());
171 mItem->setText(2,"---"); 170 mItem->setText(2,"---");
172 mItem->setText(3,"---"); 171 mItem->setText(3,"---");
173 mItem->setText(4,"---"); 172 mItem->setText(4,"---");
174 mItem->setText(5,"---"); 173 mItem->setText(5,"---");
175 mItem->setText(6,"---"); 174 mItem->setText(6,"---");
176 mItem->setText(7,j->dtStartDateStr()); 175 mItem->setText(7,j->dtStartDateStr());
177 mItem->setText(8,"---"); 176 mItem->setText(8,"---");
178 mItem->setText(9,"---"); 177 mItem->setText(9,"---");
179 178
180 QString key; 179 QString key;
181 QDate d = j->dtStart().date(); 180 QDate d = j->dtStart().date();
182 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 181 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
183 mItem->setSortKey(1,key); 182 mItem->setSortKey(1,key);
184 mItem->setSortKey(7,key); 183 mItem->setSortKey(7,key);
185 184
186 return true; 185 return true;
187} 186}
188 187
189KOListView::KOListView(Calendar *calendar, QWidget *parent, 188KOListView::KOListView(Calendar *calendar, QWidget *parent,
190 const char *name) 189 const char *name)
191 : KOEventView(calendar, parent, name) 190 : KOEventView(calendar, parent, name)
192{ 191{
193 mActiveItem = 0; 192 mActiveItem = 0;
194 mListView = new KOListViewListView(this); 193 mListView = new KOListViewListView(this);
195 mListView->addColumn(i18n("Summary")); 194 mListView->addColumn(i18n("Summary"));
196 mListView->addColumn(i18n("Start Date")); 195 mListView->addColumn(i18n("Start Date"));
197 mListView->addColumn(i18n("Start Time")); 196 mListView->addColumn(i18n("Start Time"));
198 mListView->addColumn(i18n("End Date")); 197 mListView->addColumn(i18n("End Date"));
199 mListView->addColumn(i18n("End Time")); 198 mListView->addColumn(i18n("End Time"));
200 mListView->addColumn(i18n("Alarm")); // alarm set? 199 mListView->addColumn(i18n("Alarm")); // alarm set?
201 mListView->addColumn(i18n("Recurs")); // recurs? 200 mListView->addColumn(i18n("Recurs")); // recurs?
202 mListView->addColumn(i18n("Due Date")); 201 mListView->addColumn(i18n("Due Date"));
203 mListView->addColumn(i18n("Due Time")); 202 mListView->addColumn(i18n("Due Time"));
204 mListView->addColumn(i18n("Cancelled")); 203 mListView->addColumn(i18n("Cancelled"));
205 mListView->addColumn(i18n("Categories")); 204 mListView->addColumn(i18n("Categories"));
206 205
207 mListView->setColumnAlignment(0,AlignLeft); 206 mListView->setColumnAlignment(0,AlignLeft);
208 mListView->setColumnAlignment(1,AlignLeft); 207 mListView->setColumnAlignment(1,AlignLeft);
209 mListView->setColumnAlignment(2,AlignHCenter); 208 mListView->setColumnAlignment(2,AlignHCenter);
210 mListView->setColumnAlignment(3,AlignLeft); 209 mListView->setColumnAlignment(3,AlignLeft);
211 mListView->setColumnAlignment(4,AlignHCenter); 210 mListView->setColumnAlignment(4,AlignHCenter);
212 mListView->setColumnAlignment(5,AlignLeft); 211 mListView->setColumnAlignment(5,AlignLeft);
213 mListView->setColumnAlignment(6,AlignLeft); 212 mListView->setColumnAlignment(6,AlignLeft);
214 mListView->setColumnAlignment(7,AlignLeft); 213 mListView->setColumnAlignment(7,AlignLeft);
215 mListView->setColumnAlignment(8,AlignLeft); 214 mListView->setColumnAlignment(8,AlignLeft);
216 mListView->setColumnAlignment(9,AlignLeft); 215 mListView->setColumnAlignment(9,AlignLeft);
217 mListView->setColumnAlignment(10,AlignLeft); 216 mListView->setColumnAlignment(10,AlignLeft);
218 217
219 int iii = 0; 218 int iii = 0;
220 for ( iii = 0; iii< 10 ; ++iii ) 219 for ( iii = 0; iii< 10 ; ++iii )
221 mListView->setColumnWidthMode( iii, QListView::Manual ); 220 mListView->setColumnWidthMode( iii, QListView::Manual );
222 221
223 QBoxLayout *layoutTop = new QVBoxLayout(this); 222 QBoxLayout *layoutTop = new QVBoxLayout(this);
224 layoutTop->addWidget(mListView); 223 layoutTop->addWidget(mListView);
225 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 224 mListView->setFont ( KOPrefs::instance()->mListViewFont );
226 mPopupMenu = eventPopup(); 225 mPopupMenu = eventPopup();
227 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 226 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
228 i18n("Select all"),this, 227 i18n("Select all"),this,
229 SLOT(allSelection()),true); 228 SLOT(allSelection()),true);
230 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 229 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
231 i18n("Deselect All"),this, 230 i18n("Deselect All"),this,
232 SLOT(clearSelection()),true); 231 SLOT(clearSelection()),true);
233 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 232 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
234 i18n("Delete all selected"),this, 233 i18n("Delete all selected"),this,
235 SLOT(deleteAll()),true); 234 SLOT(deleteAll()),true);
236 mPopupMenu->insertSeparator(); 235 mPopupMenu->insertSeparator();
237 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 236 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
238 i18n("Save selected to file..."),this, 237 i18n("Save selected to file..."),this,
239 SLOT(saveToFile()),true); 238 SLOT(saveToFile()),true);
240 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 239 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
241 i18n("Save Journal/Description..."),this, 240 i18n("Save Journal/Description..."),this,
242 SLOT(saveDescriptionToFile()),true); 241 SLOT(saveDescriptionToFile()),true);
243 mPopupMenu->insertSeparator(); 242 mPopupMenu->insertSeparator();
244 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 243 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
245 i18n("Add Categ. to selected..."),this, 244 i18n("Add Categ. to selected..."),this,
246 SLOT(addCat()),true); 245 SLOT(addCat()),true);
247 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 246 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
248 i18n("Set Categ. for selected..."),this, 247 i18n("Set Categ. for selected..."),this,
249 SLOT(setCat()),true); 248 SLOT(setCat()),true);
250 mPopupMenu->insertSeparator(); 249 mPopupMenu->insertSeparator();
251 250
252 251
253#ifndef DESKTOP_VERSION 252#ifndef DESKTOP_VERSION
254 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 253 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
255 i18n("Beam selected via IR"),this, 254 i18n("Beam selected via IR"),this,
256 SLOT(beamSelected()),true); 255 SLOT(beamSelected()),true);
257#endif 256#endif
258 /* 257 /*
259 mPopupMenu = new QPopupMenu; 258 mPopupMenu = new QPopupMenu;
260 mPopupMenu->insertItem(i18n("Edit Event"), this, 259 mPopupMenu->insertItem(i18n("Edit Event"), this,
261 SLOT (editEvent())); 260 SLOT (editEvent()));
262 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 261 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
263 SLOT (deleteEvent())); 262 SLOT (deleteEvent()));
264 mPopupMenu->insertSeparator(); 263 mPopupMenu->insertSeparator();
265 mPopupMenu->insertItem(i18n("Show Dates"), this, 264 mPopupMenu->insertItem(i18n("Show Dates"), this,
266 SLOT(showDates())); 265 SLOT(showDates()));
267 mPopupMenu->insertItem(i18n("Hide Dates"), this, 266 mPopupMenu->insertItem(i18n("Hide Dates"), this,
268 SLOT(hideDates())); 267 SLOT(hideDates()));
269 */ 268 */
270 QObject::connect(mListView,SIGNAL( newEvent()), 269 QObject::connect(mListView,SIGNAL( newEvent()),
271 this,SIGNAL(signalNewEvent())); 270 this,SIGNAL(signalNewEvent()));
272 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 271 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
273 this,SLOT(defaultItemAction(QListViewItem *))); 272 this,SLOT(defaultItemAction(QListViewItem *)));
274 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, 273 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *,
275 const QPoint &, int )), 274 const QPoint &, int )),
276 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 275 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
277 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 276 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
278 SLOT(processSelectionChange(QListViewItem *))); 277 SLOT(processSelectionChange(QListViewItem *)));
279 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 278 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
280 SIGNAL(showIncidenceSignal(Incidence *)) ); 279 SIGNAL(showIncidenceSignal(Incidence *)) );
281 280
282 readSettings(KOGlobals::config(),"KOListView Layout"); 281 readSettings(KOGlobals::config(),"KOListView Layout");
283} 282}
284 283
285KOListView::~KOListView() 284KOListView::~KOListView()
286{ 285{
287 delete mPopupMenu; 286 delete mPopupMenu;
288} 287}
289 288
290void KOListView::updateList() 289void KOListView::updateList()
291{ 290{
292 // qDebug(" KOListView::updateList() "); 291 // qDebug(" KOListView::updateList() ");
293 292
294} 293}
295 294
296void KOListView::addCat( ) 295void KOListView::addCat( )
297{ 296{
298 setCategories( false ); 297 setCategories( false );
299} 298}
300void KOListView::setCat() 299void KOListView::setCat()
301{ 300{
302 setCategories( true ); 301 setCategories( true );
303} 302}
304void KOListView::setCategories( bool removeOld ) 303void KOListView::setCategories( bool removeOld )
305{ 304{
306 305
307 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 306 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
308 if (! csd->exec()) { 307 if (! csd->exec()) {
309 delete csd; 308 delete csd;
310 return; 309 return;
311 } 310 }
312 QStringList catList = csd->selectedCategories(); 311 QStringList catList = csd->selectedCategories();
313 delete csd; 312 delete csd;
314 // if ( catList.count() == 0 ) 313 // if ( catList.count() == 0 )
315 // return; 314 // return;
316 catList.sort(); 315 catList.sort();
317 QString categoriesStr = catList.join(","); 316 QString categoriesStr = catList.join(",");
318 int i; 317 int i;
319 QStringList itemList; 318 QStringList itemList;
320 QPtrList<KOListViewItem> sel ; 319 QPtrList<KOListViewItem> sel ;
321 QListViewItem *qitem = mListView->firstChild (); 320 QListViewItem *qitem = mListView->firstChild ();
322 while ( qitem ) { 321 while ( qitem ) {
323 if ( qitem->isSelected() ) { 322 if ( qitem->isSelected() ) {
324 sel.append(((KOListViewItem *)qitem)); 323 sel.append(((KOListViewItem *)qitem));
325 } 324 }
326 qitem = qitem->nextSibling(); 325 qitem = qitem->nextSibling();
327 } 326 }
328 KOListViewItem * item, *temp; 327 KOListViewItem * item, *temp;
329 item = sel.first(); 328 item = sel.first();
330 Incidence* inc; 329 Incidence* inc;
331 while ( item ) { 330 while ( item ) {
332 inc = item->data(); 331 inc = item->data();
333 if ( removeOld ) { 332 if ( removeOld ) {
334 inc->setCategories( categoriesStr ); 333 inc->setCategories( categoriesStr );
335 } else { 334 } else {
336 itemList = QStringList::split (",", inc->categoriesStr() ); 335 itemList = QStringList::split (",", inc->categoriesStr() );
337 for( i = 0; i< catList.count(); ++i ) { 336 for( i = 0; i< catList.count(); ++i ) {
338 if ( !itemList.contains (catList[i])) 337 if ( !itemList.contains (catList[i]))
339 itemList.append( catList[i] ); 338 itemList.append( catList[i] );
340 } 339 }
341 itemList.sort(); 340 itemList.sort();
342 inc->setCategories( itemList.join(",") ); 341 inc->setCategories( itemList.join(",") );
343 } 342 }
344 temp = item; 343 temp = item;
345 item = sel.next(); 344 item = sel.next();
346 mUidDict.remove( inc->uid() ); 345 mUidDict.remove( inc->uid() );
347 delete temp;; 346 delete temp;;
348 addIncidence( inc ); 347 addIncidence( inc );
349 } 348 }
350} 349}
351 350
352void KOListView::beamSelected() 351void KOListView::beamSelected()
353{ 352{
354 int icount = 0; 353 int icount = 0;
355 QPtrList<Incidence> delSel ; 354 QPtrList<Incidence> delSel ;
356 QListViewItem *item = mListView->firstChild (); 355 QListViewItem *item = mListView->firstChild ();
357 while ( item ) { 356 while ( item ) {
358 if ( item->isSelected() ) { 357 if ( item->isSelected() ) {
359 delSel.append(((KOListViewItem *)item)->data()); 358 delSel.append(((KOListViewItem *)item)->data());
360 ++icount; 359 ++icount;
361 } 360 }
362 361
363 item = item->nextSibling(); 362 item = item->nextSibling();
364 } 363 }
365 if ( icount ) { 364 if ( icount ) {
366 emit beamIncidenceList( delSel ); 365 emit beamIncidenceList( delSel );
367 return; 366 return;
368 QString fn ; 367 QString fn ;
369 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 368 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
370 QString mes; 369 QString mes;
371 bool createbup = true; 370 bool createbup = true;
372 if ( createbup ) { 371 if ( createbup ) {
373 QString description = "\n"; 372 QString description = "\n";
374 CalendarLocal* cal = new CalendarLocal(); 373 CalendarLocal* cal = new CalendarLocal();
375 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 374 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
376 Incidence *incidence = delSel.first(); 375 Incidence *incidence = delSel.first();
377 while ( incidence ) { 376 while ( incidence ) {
378 Incidence *in = incidence->clone(); 377 Incidence *in = incidence->clone();
379 description += in->summary() + "\n"; 378 description += in->summary() + "\n";
380 cal->addIncidence( in ); 379 cal->addIncidence( in );
381 incidence = delSel.next(); 380 incidence = delSel.next();
382 } 381 }
383 FileStorage storage( cal, fn, new VCalFormat ); 382 FileStorage storage( cal, fn, new VCalFormat );
384 storage.save(); 383 storage.save();
385 delete cal; 384 delete cal;
386 mes = i18n("KO/Pi: Ready for beaming"); 385 mes = i18n("KO/Pi: Ready for beaming");
387 topLevelWidget()->setCaption(mes); 386 topLevelWidget()->setCaption(mes);
388 387
389#ifndef DESKTOP_VERSION 388#ifndef DESKTOP_VERSION
390 Ir *ir = new Ir( this ); 389 Ir *ir = new Ir( this );
391 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 390 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
392 ir->send( fn, description, "text/x-vCalendar" ); 391 ir->send( fn, description, "text/x-vCalendar" );
393#endif 392#endif
394 } 393 }
395 } 394 }
396} 395}
397void KOListView::beamDone( Ir *ir ) 396void KOListView::beamDone( Ir *ir )
398{ 397{
399#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
400 delete ir; 399 delete ir;
401#endif 400#endif
402 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 401 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
403} 402}
404 403
405void KOListView::saveDescriptionToFile() 404void KOListView::saveDescriptionToFile()
406{ 405{
407 406
408 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 407 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
409 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 408 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
410 i18n("Continue"), i18n("Cancel"), 0, 409 i18n("Continue"), i18n("Cancel"), 0,
411 0, 1 ); 410 0, 1 );
412 if ( result != 0 ) { 411 if ( result != 0 ) {
413 return; 412 return;
414 } 413 }
415 int icount = 0; 414 int icount = 0;
416 QPtrList<Incidence> delSel ; 415 QPtrList<Incidence> delSel ;
417 QListViewItem *item = mListView->firstChild (); 416 QListViewItem *item = mListView->firstChild ();
418 while ( item ) { 417 while ( item ) {
419 if ( item->isSelected() ) { 418 if ( item->isSelected() ) {
420 delSel.append(((KOListViewItem *)item)->data()); 419 delSel.append(((KOListViewItem *)item)->data());
421 ++icount; 420 ++icount;
422 } 421 }
423 422
424 item = item->nextSibling(); 423 item = item->nextSibling();
425 } 424 }
426 if ( icount ) { 425 if ( icount ) {
427 QString fn = KOPrefs::instance()->mLastSaveFile; 426 QString fn = KOPrefs::instance()->mLastSaveFile;
428 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 427 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
429 428
430 if ( fn == "" ) 429 if ( fn == "" )
431 return; 430 return;
432 QFileInfo info; 431 QFileInfo info;
433 info.setFile( fn ); 432 info.setFile( fn );
434 QString mes; 433 QString mes;
435 bool createbup = true; 434 bool createbup = true;
436 if ( info. exists() ) { 435 if ( info. exists() ) {
437 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 436 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
438 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 437 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
439 i18n("Overwrite!"), i18n("Cancel"), 0, 438 i18n("Overwrite!"), i18n("Cancel"), 0,
440 0, 1 ); 439 0, 1 );
441 if ( result != 0 ) { 440 if ( result != 0 ) {
442 createbup = false; 441 createbup = false;
443 } 442 }
444 } 443 }
445 if ( createbup ) { 444 if ( createbup ) {
446 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 445 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
447 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 446 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
448 Incidence *incidence = delSel.first(); 447 Incidence *incidence = delSel.first();
449 icount = 0; 448 icount = 0;
450 while ( incidence ) { 449 while ( incidence ) {
451 if ( incidence->type() == "Journal" ) { 450 if ( incidence->type() == "Journal" ) {
452 text += "\n************************************\n"; 451 text += "\n************************************\n";
453 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 452 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
454 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 453 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
455 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 454 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
456 ++icount; 455 ++icount;
457 456
458 } else { 457 } else {
459 if ( !incidence->description().isEmpty() ) { 458 if ( !incidence->description().isEmpty() ) {
460 text += "\n************************************\n"; 459 text += "\n************************************\n";
461 if ( incidence->type() == "Todo" ) 460 if ( incidence->type() == "Todo" )
462 text += i18n("To-Do: "); 461 text += i18n("To-Do: ");
463 text += incidence->summary(); 462 text += incidence->summary();
464 if ( incidence->hasStartDate() ) 463 if ( incidence->hasStartDate() )
465 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 464 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
466 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 465 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
467 if ( !incidence->location().isEmpty() ) 466 if ( !incidence->location().isEmpty() )
468 text += "\n" +i18n("Location: ") + incidence->location(); 467 text += "\n" +i18n("Location: ") + incidence->location();
469 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 468 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
470 ++icount; 469 ++icount;
471 470
472 } 471 }
473 } 472 }
474 incidence = delSel.next(); 473 incidence = delSel.next();
475 } 474 }
476 QFile file( fn ); 475 QFile file( fn );
477 if (!file.open( IO_WriteOnly ) ) { 476 if (!file.open( IO_WriteOnly ) ) {
478 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 477 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
479 return; 478 return;
480 } 479 }
481 QTextStream ts( &file ); 480 QTextStream ts( &file );
482 ts << text; 481 ts << text;
483 file.close(); 482 file.close();
484 //qDebug("%s ", text.latin1()); 483 //qDebug("%s ", text.latin1());
485 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 484 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
486 KOPrefs::instance()->mLastSaveFile = fn; 485 KOPrefs::instance()->mLastSaveFile = fn;
487 topLevelWidget()->setCaption(mes); 486 topLevelWidget()->setCaption(mes);
488 } 487 }
489 } 488 }
490} 489}
491void KOListView::saveToFile() 490void KOListView::saveToFile()
492{ 491{
493 492
494 int icount = 0; 493 int icount = 0;
495 QPtrList<Incidence> delSel ; 494 QPtrList<Incidence> delSel ;
496 QListViewItem *item = mListView->firstChild (); 495 QListViewItem *item = mListView->firstChild ();
497 while ( item ) { 496 while ( item ) {
498 if ( item->isSelected() ) { 497 if ( item->isSelected() ) {
499 delSel.append(((KOListViewItem *)item)->data()); 498 delSel.append(((KOListViewItem *)item)->data());
500 ++icount; 499 ++icount;
501 } 500 }
502 501
503 item = item->nextSibling(); 502 item = item->nextSibling();
504 } 503 }
505 if ( icount ) { 504 if ( icount ) {
506 QString fn = KOPrefs::instance()->mLastSaveFile; 505 QString fn = KOPrefs::instance()->mLastSaveFile;
507 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 506 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
508 507
509 if ( fn == "" ) 508 if ( fn == "" )
510 return; 509 return;
511 QFileInfo info; 510 QFileInfo info;
512 info.setFile( fn ); 511 info.setFile( fn );
513 QString mes; 512 QString mes;
514 bool createbup = true; 513 bool createbup = true;
515 if ( info. exists() ) { 514 if ( info. exists() ) {
516 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 515 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
517 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 516 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
518 i18n("Overwrite!"), i18n("Cancel"), 0, 517 i18n("Overwrite!"), i18n("Cancel"), 0,
519 0, 1 ); 518 0, 1 );
520 if ( result != 0 ) { 519 if ( result != 0 ) {
521 createbup = false; 520 createbup = false;
522 } 521 }
523 } 522 }
524 if ( createbup ) { 523 if ( createbup ) {
525 CalendarLocal cal; 524 CalendarLocal cal;
526 cal.setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 525 cal.setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
527 Incidence *incidence = delSel.first(); 526 Incidence *incidence = delSel.first();
528 while ( incidence ) { 527 while ( incidence ) {
529 cal.addIncidence( incidence->clone() ); 528 cal.addIncidence( incidence->clone() );
530 incidence = delSel.next(); 529 incidence = delSel.next();
531 } 530 }
532 ICalFormat format; 531 ICalFormat format;
533 format.save( &cal, fn ); 532 format.save( &cal, fn );
534 mes = i18n("KO/Pi:Saved %1").arg(fn ); 533 mes = i18n("KO/Pi:Saved %1").arg(fn );
535 KOPrefs::instance()->mLastSaveFile = fn; 534 KOPrefs::instance()->mLastSaveFile = fn;
536 topLevelWidget()->setCaption(mes); 535 topLevelWidget()->setCaption(mes);
537 } 536 }
538 } 537 }
539} 538}
540void KOListView::deleteAll() 539void KOListView::deleteAll()
541{ 540{
542 int icount = 0; 541 int icount = 0;
543 QPtrList<Incidence> delSel ; 542 QPtrList<Incidence> delSel ;
544 QListViewItem *item = mListView->firstChild (); 543 QListViewItem *item = mListView->firstChild ();
545 while ( item ) { 544 while ( item ) {
546 if ( item->isSelected() ) { 545 if ( item->isSelected() ) {
547 delSel.append(((KOListViewItem *)item)->data()); 546 delSel.append(((KOListViewItem *)item)->data());
548 ++icount; 547 ++icount;
549 } 548 }
550 549
551 item = item->nextSibling(); 550 item = item->nextSibling();
552 } 551 }
553 if ( icount ) { 552 if ( icount ) {
554 Incidence *incidence = delSel.first(); 553 Incidence *incidence = delSel.first();
555 Incidence *toDelete; 554 Incidence *toDelete;
556 KOPrefs *p = KOPrefs::instance(); 555 KOPrefs *p = KOPrefs::instance();
557 bool confirm = p->mConfirm; 556 bool confirm = p->mConfirm;
558 QString mess; 557 QString mess;
559 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 558 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
560 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")) ) { 559 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")) ) {
561 p->mConfirm = false; 560 p->mConfirm = false;
562 int delCounter = 0; 561 int delCounter = 0;
563 QDialog dia ( this, "p-dialog", true ); 562 QDialog dia ( this, "p-dialog", true );
564 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 563 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
565 QVBoxLayout lay( &dia ); 564 QVBoxLayout lay( &dia );
566 lay.setMargin(7); 565 lay.setMargin(7);
567 lay.setSpacing(7); 566 lay.setSpacing(7);
568 lay.addWidget( &lab); 567 lay.addWidget( &lab);
569 QProgressBar bar( icount, &dia ); 568 QProgressBar bar( icount, &dia );
570 lay.addWidget( &bar); 569 lay.addWidget( &bar);
571 int w = 220; 570 int w = 220;
572 int h = 50; 571 int h = 50;
573 int dw = QApplication::desktop()->width(); 572 int dw = QApplication::desktop()->width();
574 int dh = QApplication::desktop()->height(); 573 int dh = QApplication::desktop()->height();
575 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 574 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
576 //dia.resize( 240,50 ); 575 //dia.resize( 240,50 );
577 dia.show(); 576 dia.show();
578 577
579 while ( incidence ) { 578 while ( incidence ) {
580 bar.setProgress( delCounter ); 579 bar.setProgress( delCounter );
581 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 580 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
582 dia.setCaption( mess ); 581 dia.setCaption( mess );
583 qApp->processEvents(); 582 qApp->processEvents();
584 toDelete = (incidence); 583 toDelete = (incidence);
585 incidence = delSel.next(); 584 incidence = delSel.next();
586 emit deleteIncidenceSignal(toDelete ); 585 emit deleteIncidenceSignal(toDelete );
587 if ( dia.result() != 0 ) 586 if ( dia.result() != 0 )
588 break; 587 break;
589 588
590 } 589 }
591 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 590 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
592 topLevelWidget ()->setCaption( mess ); 591 topLevelWidget ()->setCaption( mess );
593 p->mConfirm = confirm; 592 p->mConfirm = confirm;
594 } 593 }
595 } 594 }
596 595
597 596
598} 597}
599int KOListView::maxDatesHint() 598int KOListView::maxDatesHint()
600{ 599{
601 return 0; 600 return 0;
602} 601}
603 602
604int KOListView::currentDateCount() 603int KOListView::currentDateCount()
605{ 604{
606 return 0; 605 return 0;
607} 606}
608 607
609QPtrList<Incidence> KOListView::selectedIncidences() 608QPtrList<Incidence> KOListView::selectedIncidences()
610{ 609{
611 QPtrList<Incidence> eventList; 610 QPtrList<Incidence> eventList;
612 QListViewItem *item = mListView->firstChild (); 611 QListViewItem *item = mListView->firstChild ();
613 while ( item ) { 612 while ( item ) {
614 if ( item->isSelected() ) { 613 if ( item->isSelected() ) {
615 eventList.append(((KOListViewItem *)item)->data()); 614 eventList.append(((KOListViewItem *)item)->data());
616 } 615 }
617 616
618 item = item->nextSibling(); 617 item = item->nextSibling();
619 } 618 }
620 619
621 // // QListViewItem *item = mListView->selectedItem(); 620 // // QListViewItem *item = mListView->selectedItem();
622 //if (item) eventList.append(((KOListViewItem *)item)->data()); 621 //if (item) eventList.append(((KOListViewItem *)item)->data());
623 622
624 return eventList; 623 return eventList;
625} 624}
626 625
627DateList KOListView::selectedDates() 626DateList KOListView::selectedDates()
628{ 627{
629 DateList eventList; 628 DateList eventList;
630 return eventList; 629 return eventList;
631} 630}
632 631
633void KOListView::showDates(bool show) 632void KOListView::showDates(bool show)
634{ 633{
635 // Shouldn't we set it to a value greater 0? When showDates is called with 634 // Shouldn't we set it to a value greater 0? When showDates is called with
636 // show == true at first, then the columnwidths are set to zero. 635 // show == true at first, then the columnwidths are set to zero.
637 static int oldColWidth1 = 0; 636 static int oldColWidth1 = 0;
638 static int oldColWidth3 = 0; 637 static int oldColWidth3 = 0;
639 638
640 if (!show) { 639 if (!show) {
641 oldColWidth1 = mListView->columnWidth(1); 640 oldColWidth1 = mListView->columnWidth(1);
642 oldColWidth3 = mListView->columnWidth(3); 641 oldColWidth3 = mListView->columnWidth(3);
643 mListView->setColumnWidth(1, 0); 642 mListView->setColumnWidth(1, 0);
644 mListView->setColumnWidth(3, 0); 643 mListView->setColumnWidth(3, 0);
645 } else { 644 } else {
646 mListView->setColumnWidth(1, oldColWidth1); 645 mListView->setColumnWidth(1, oldColWidth1);
647 mListView->setColumnWidth(3, oldColWidth3); 646 mListView->setColumnWidth(3, oldColWidth3);
648 } 647 }
649 mListView->repaint(); 648 mListView->repaint();
650} 649}
651 650
652void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 651void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
653 const QDate &td) 652 const QDate &td)
654{ 653{
655#ifndef KORG_NOPRINTER 654#ifndef KORG_NOPRINTER
656 calPrinter->preview(CalPrinter::Day, fd, td); 655 calPrinter->preview(CalPrinter::Day, fd, td);
657#endif 656#endif
658} 657}
659 658
660void KOListView::showDates() 659void KOListView::showDates()
661{ 660{
662 showDates(true); 661 showDates(true);
663} 662}
664 663
665void KOListView::hideDates() 664void KOListView::hideDates()
666{ 665{
667 showDates(false); 666 showDates(false);
668} 667}
669 668
670void KOListView::updateView() 669void KOListView::updateView()
671{ 670{
672 mListView->setFocus(); 671 mListView->setFocus();
673 if ( mListView->firstChild () ) 672 if ( mListView->firstChild () )
674 mListView->setCurrentItem( mListView->firstChild () ); 673 mListView->setCurrentItem( mListView->firstChild () );
675} 674}
676void KOListView::updateConfig() 675void KOListView::updateConfig()
677{ 676{
678 677
679 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 678 mListView->setFont ( KOPrefs::instance()->mListViewFont );
680 updateView(); 679 updateView();
681 680
682} 681}
683void KOListView::setStartDate(const QDate &start) 682void KOListView::setStartDate(const QDate &start)
684{ 683{
685 mStartDate = start; 684 mStartDate = start;
686} 685}
687 686
688void KOListView::showDates(const QDate &start, const QDate &end) 687void KOListView::showDates(const QDate &start, const QDate &end)
689{ 688{
690 clear(); 689 clear();
691 mStartDate = start; 690 mStartDate = start;
692 QDate date = start; 691 QDate date = start;
693 while( date <= end ) { 692 while( date <= end ) {
694 addEvents(calendar()->events(date)); 693 addEvents(calendar()->events(date));
695 addTodos(calendar()->todos(date)); 694 addTodos(calendar()->todos(date));
696 date = date.addDays( 1 ); 695 date = date.addDays( 1 );
697 } 696 }
698 emit incidenceSelected( 0 ); 697 emit incidenceSelected( 0 );
699 updateView(); 698 updateView();
700 699
701} 700}
702 701
703void KOListView::addEvents(QPtrList<Event> eventList) 702void KOListView::addEvents(QPtrList<Event> eventList)
704{ 703{
705 Event *ev; 704 Event *ev;
706 for(ev = eventList.first(); ev; ev = eventList.next()) { 705 for(ev = eventList.first(); ev; ev = eventList.next()) {
707 addIncidence(ev); 706 addIncidence(ev);
708 } 707 }
709 if ( !mListView->currentItem() ){ 708 if ( !mListView->currentItem() ){
710 updateView(); 709 updateView();
711 } 710 }
712} 711}
713 712
714void KOListView::addTodos(QPtrList<Todo> eventList) 713void KOListView::addTodos(QPtrList<Todo> eventList)
715{ 714{
716 Todo *ev; 715 Todo *ev;
717 for(ev = eventList.first(); ev; ev = eventList.next()) { 716 for(ev = eventList.first(); ev; ev = eventList.next()) {
718 addIncidence(ev); 717 addIncidence(ev);
719 } 718 }
720 if ( !mListView->currentItem() ){ 719 if ( !mListView->currentItem() ){
721 updateView(); 720 updateView();
722 } 721 }
723} 722}
724void KOListView::addJournals(QPtrList<Journal> eventList) 723void KOListView::addJournals(QPtrList<Journal> eventList)
725{ 724{
726 Journal *ev; 725 Journal *ev;
727 for(ev = eventList.first(); ev; ev = eventList.next()) { 726 for(ev = eventList.first(); ev; ev = eventList.next()) {
728 addIncidence(ev); 727 addIncidence(ev);
729 } 728 }
730 if ( !mListView->currentItem() ){ 729 if ( !mListView->currentItem() ){
731 updateView(); 730 updateView();
732 } 731 }
733} 732}
734 733
735void KOListView::addIncidence(Incidence *incidence) 734void KOListView::addIncidence(Incidence *incidence)
736{ 735{
737 if ( mUidDict.find( incidence->uid() ) ) return; 736 if ( mUidDict.find( incidence->uid() ) ) return;
738 737
739 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 738 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
740 mUidDict.insert( incidence->uid(), incidence ); 739 mUidDict.insert( incidence->uid(), incidence );
741 740
742 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 741 KOListViewItem *item = new KOListViewItem( incidence, mListView );
743 ListItemVisitor v(item, mStartDate ); 742 ListItemVisitor v(item, mStartDate );
744 if (incidence->accept(v)) return; 743 if (incidence->accept(v)) return;
745 else delete item; 744 else delete item;
746 //qDebug("delete item "); 745 //qDebug("delete item ");
747} 746}
748 747
749void KOListView::showEvents(QPtrList<Event> eventList) 748void KOListView::showEvents(QPtrList<Event> eventList)
750{ 749{
751 clear(); 750 clear();
752 751
753 addEvents(eventList); 752 addEvents(eventList);
754 753
755 // After new creation of list view no events are selected. 754 // After new creation of list view no events are selected.
756 emit incidenceSelected( 0 ); 755 emit incidenceSelected( 0 );
757} 756}
758int KOListView::count() 757int KOListView::count()
759{ 758{
760 return mListView->childCount(); 759 return mListView->childCount();
761} 760}
762 761
763void KOListView::changeEventDisplay(Event *event, int action) 762void KOListView::changeEventDisplay(Event *event, int action)
764{ 763{
765 KOListViewItem *item; 764 KOListViewItem *item;
766 765
767 switch(action) { 766 switch(action) {
768 case KOGlobals::EVENTADDED: 767 case KOGlobals::EVENTADDED:
769 addIncidence( event ); 768 addIncidence( event );
770 break; 769 break;
771 case KOGlobals::EVENTEDITED: 770 case KOGlobals::EVENTEDITED:
772 item = getItemForEvent(event); 771 item = getItemForEvent(event);
773 if (item) { 772 if (item) {
774 mUidDict.remove( event->uid() ); 773 mUidDict.remove( event->uid() );
775 delete item; 774 delete item;
776 addIncidence( event ); 775 addIncidence( event );
777 } 776 }
778 break; 777 break;
779 case KOGlobals::EVENTDELETED: 778 case KOGlobals::EVENTDELETED:
780 item = getItemForEvent(event); 779 item = getItemForEvent(event);
781 if (item) { 780 if (item) {
782 mUidDict.remove( event->uid() ); 781 mUidDict.remove( event->uid() );
783 delete item; 782 delete item;
784 } 783 }
785 break; 784 break;
786 default: 785 default:
787 ; 786 ;
788 } 787 }
789} 788}
790 789
791KOListViewItem *KOListView::getItemForEvent(Event *event) 790KOListViewItem *KOListView::getItemForEvent(Event *event)
792{ 791{
793 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 792 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
794 while (item) { 793 while (item) {
795 if (item->data() == event) return item; 794 if (item->data() == event) return item;
796 item = (KOListViewItem *)item->nextSibling(); 795 item = (KOListViewItem *)item->nextSibling();
797 } 796 }
798 return 0; 797 return 0;
799} 798}
800 799
801void KOListView::defaultItemAction(QListViewItem *i) 800void KOListView::defaultItemAction(QListViewItem *i)
802{ 801{
803 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 802 KOListViewItem *item = static_cast<KOListViewItem *>( i );
804 if ( item ) defaultAction( item->data() ); 803 if ( item ) defaultAction( item->data() );
805 804
806} 805}
807 806
808void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 807void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
809{ 808{
810 mActiveItem = (KOListViewItem *)item; 809 mActiveItem = (KOListViewItem *)item;
811 if (mActiveItem) { 810 if (mActiveItem) {
812 Incidence *incidence = mActiveItem->data(); 811 Incidence *incidence = mActiveItem->data();
813 mPopupMenu->showIncidencePopup(incidence); 812 mPopupMenu->showIncidencePopup(incidence);
814 813
815 /* 814 /*
816 if ( incidence && incidence->type() == "Event" ) { 815 if ( incidence && incidence->type() == "Event" ) {
817 Event *event = static_cast<Event *>( incidence ); 816 Event *event = static_cast<Event *>( incidence );
818 mPopupMenu->showEventPopup(event); 817 mPopupMenu->showEventPopup(event);
819 } 818 }
820 */ 819 */
821 } 820 }
822} 821}
823 822
824void KOListView::readSettings(KConfig *config, QString setting) 823void KOListView::readSettings(KConfig *config, QString setting)
825{ 824{
826 // qDebug("KOListView::readSettings "); 825 // qDebug("KOListView::readSettings ");
827 mListView->restoreLayout(config,setting); 826 mListView->restoreLayout(config,setting);
828} 827}
829 828
830void KOListView::writeSettings(KConfig *config, QString setting) 829void KOListView::writeSettings(KConfig *config, QString setting)
831{ 830{
832 // qDebug("KOListView::writeSettings "); 831 // qDebug("KOListView::writeSettings ");
833 mListView->saveLayout(config, setting); 832 mListView->saveLayout(config, setting);
834} 833}
835 834
836void KOListView::processSelectionChange(QListViewItem *) 835void KOListView::processSelectionChange(QListViewItem *)
837{ 836{
838 837
839 KOListViewItem *item = 838 KOListViewItem *item =
840 static_cast<KOListViewItem *>( mListView->currentItem() ); 839 static_cast<KOListViewItem *>( mListView->currentItem() );
841 840
842 if ( !item ) { 841 if ( !item ) {
843 emit incidenceSelected( 0 ); 842 emit incidenceSelected( 0 );
844 } else { 843 } else {
845 emit incidenceSelected( item->data() ); 844 emit incidenceSelected( item->data() );
846 } 845 }
847} 846}
848 847
849void KOListView::clearSelection() 848void KOListView::clearSelection()
850{ 849{
851 mListView->selectAll( false ); 850 mListView->selectAll( false );
852} 851}
853void KOListView::allSelection() 852void KOListView::allSelection()
854{ 853{
855 mListView->selectAll( true ); 854 mListView->selectAll( true );
856} 855}
857 856
858void KOListView::clear() 857void KOListView::clear()
859{ 858{
860 mListView->clear(); 859 mListView->clear();
861 mUidDict.clear(); 860 mUidDict.clear();
862} 861}
863 862
864Incidence* KOListView::currentItem() 863Incidence* KOListView::currentItem()
865{ 864{
866 if ( mListView->currentItem() ) 865 if ( mListView->currentItem() )
867 return ((KOListViewItem*) mListView->currentItem())->data(); 866 return ((KOListViewItem*) mListView->currentItem())->data();
868 return 0; 867 return 0;
869} 868}
870void KOListView::keyPressEvent ( QKeyEvent *e) 869void KOListView::keyPressEvent ( QKeyEvent *e)
871{ 870{
872 871
873 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 872 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
874 deleteAll(); 873 deleteAll();
875 return; 874 return;
876 } 875 }
877 876
878 e->ignore(); 877 e->ignore();
879} 878}
880void KOListViewListView::keyPressEvent ( QKeyEvent *e) 879void KOListViewListView::keyPressEvent ( QKeyEvent *e)
881{ 880{
882 881
883 switch ( e->key() ) { 882 switch ( e->key() ) {
884 case Qt::Key_Down: 883 case Qt::Key_Down:
885 if ( e->state() == ShiftButton ) { 884 if ( e->state() == ShiftButton ) {
886 QListViewItem* cn = currentItem(); 885 QListViewItem* cn = currentItem();
887 if ( !cn ) 886 if ( !cn )
888 cn = firstChild(); 887 cn = firstChild();
889 if ( !cn ) 888 if ( !cn )
890 return; 889 return;
891 while ( cn->nextSibling() ) 890 while ( cn->nextSibling() )
892 cn = cn->nextSibling(); 891 cn = cn->nextSibling();
893 setCurrentItem ( cn ); 892 setCurrentItem ( cn );
894 ensureItemVisible ( cn ); 893 ensureItemVisible ( cn );
895 894
896 e->accept(); 895 e->accept();
897 return; 896 return;
898 } 897 }
899 if ( e->state() == ControlButton ) { 898 if ( e->state() == ControlButton ) {
900 int count = childCount (); 899 int count = childCount ();
901 int jump = count / 5; 900 int jump = count / 5;
902 QListViewItem* cn; 901 QListViewItem* cn;
903 cn = currentItem(); 902 cn = currentItem();
904 if ( ! cn ) 903 if ( ! cn )
905 return; 904 return;
906 if ( jump == 0 ) 905 if ( jump == 0 )
907 jump = 1; 906 jump = 1;
908 while ( jump && cn->nextSibling() ) { 907 while ( jump && cn->nextSibling() ) {
909 cn = cn->nextSibling(); 908 cn = cn->nextSibling();
910 --jump; 909 --jump;
911 } 910 }
912 setCurrentItem ( cn ); 911 setCurrentItem ( cn );
913 ensureItemVisible ( cn ); 912 ensureItemVisible ( cn );
914 913
915 } else 914 } else
916 QListView::keyPressEvent ( e ) ; 915 QListView::keyPressEvent ( e ) ;
917 e->accept(); 916 e->accept();
918 break; 917 break;
919 918
920 case Qt::Key_Up: 919 case Qt::Key_Up:
921 if ( e->state() == ShiftButton ) { 920 if ( e->state() == ShiftButton ) {
922 QListViewItem* cn = firstChild(); 921 QListViewItem* cn = firstChild();
923 if ( cn ) { 922 if ( cn ) {
924 setCurrentItem ( cn ); 923 setCurrentItem ( cn );
925 ensureItemVisible ( cn ); 924 ensureItemVisible ( cn );
926 } 925 }
927 e->accept(); 926 e->accept();
928 return; 927 return;
929 } 928 }
930 if ( e->state() == ControlButton ) { 929 if ( e->state() == ControlButton ) {
931 int count = childCount (); 930 int count = childCount ();
932 int jump = count / 5; 931 int jump = count / 5;
933 QListViewItem* cn; 932 QListViewItem* cn;
934 cn = currentItem(); 933 cn = currentItem();
935 if ( ! cn ) 934 if ( ! cn )
936 return; 935 return;
937 if ( jump == 0 ) 936 if ( jump == 0 )
938 jump = 1; 937 jump = 1;
939 while ( jump && cn->itemAbove ()) { 938 while ( jump && cn->itemAbove ()) {
940 cn = cn->itemAbove (); 939 cn = cn->itemAbove ();
941 --jump; 940 --jump;
942 } 941 }
943 setCurrentItem ( cn ); 942 setCurrentItem ( cn );
944 ensureItemVisible ( cn ); 943 ensureItemVisible ( cn );
945 } else 944 } else
946 QListView::keyPressEvent ( e ) ; 945 QListView::keyPressEvent ( e ) ;
947 e->accept(); 946 e->accept();
948 break; 947 break;
949 case Qt::Key_I: { 948 case Qt::Key_I: {
950 QListViewItem* cn; 949 QListViewItem* cn;
951 cn = currentItem(); 950 cn = currentItem();
952 if ( cn ) { 951 if ( cn ) {
953 KOListViewItem* ci = (KOListViewItem*)( cn ); 952 KOListViewItem* ci = (KOListViewItem*)( cn );
954 if ( ci ){ 953 if ( ci ){
955 emit showIncidence( ci->data()); 954 emit showIncidence( ci->data());
956 cn = cn->nextSibling(); 955 cn = cn->nextSibling();
957 if ( cn ) { 956 if ( cn ) {
958 setCurrentItem ( cn ); 957 setCurrentItem ( cn );
959 ensureItemVisible ( cn ); 958 ensureItemVisible ( cn );
960 } 959 }
961 } 960 }
962 } 961 }
963 e->accept(); 962 e->accept();
964 } 963 }
965 break; 964 break;
966 case Qt::Key_Return: 965 case Qt::Key_Return:
967 case Qt::Key_Enter: 966 case Qt::Key_Enter:
968 { 967 {
969 QListViewItem* cn; 968 QListViewItem* cn;
970 cn = currentItem(); 969 cn = currentItem();
971 if ( cn ) { 970 if ( cn ) {
972 KOListViewItem* ci = (KOListViewItem*)( cn ); 971 KOListViewItem* ci = (KOListViewItem*)( cn );
973 if ( ci ){ 972 if ( ci ){
974 if ( e->state() == ShiftButton ) 973 if ( e->state() == ShiftButton )
975 ci->setSelected( false ); 974 ci->setSelected( false );
976 else 975 else
977 ci->setSelected( true ); 976 ci->setSelected( true );
978 cn = cn->nextSibling(); 977 cn = cn->nextSibling();
979 if ( cn ) { 978 if ( cn ) {
980 setCurrentItem ( cn ); 979 setCurrentItem ( cn );
981 ensureItemVisible ( cn ); 980 ensureItemVisible ( cn );
982 } 981 }
983 } 982 }
984 } 983 }
985 e->accept(); 984 e->accept();
986 } 985 }
987 break; 986 break;
988 default: 987 default:
989 e->ignore(); 988 e->ignore();
990 } 989 }
991} 990}
992KOListViewListView::KOListViewListView(KOListView * lv ) 991KOListViewListView::KOListViewListView(KOListView * lv )
993 : KListView( lv ) 992 : KListView( lv )
994{ 993{
995#ifndef DESKTOP_VERSION 994#ifndef DESKTOP_VERSION
996 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 995 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
997#endif 996#endif
998 setSelectionMode( QListView::Multi ); 997 setSelectionMode( QListView::Multi );
999 setMultiSelection( true); 998 setMultiSelection( true);
1000 mAllowPopupMenu = true; 999 mAllowPopupMenu = true;
1001 mMouseDown = false; 1000 mMouseDown = false;
1002 1001
1003} 1002}
1004void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1003void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1005{ 1004{
1006 if (!e) return; 1005 if (!e) return;
1007 QPoint vp = contentsToViewport(e->pos()); 1006 QPoint vp = contentsToViewport(e->pos());
1008 QListViewItem *item = itemAt(vp); 1007 QListViewItem *item = itemAt(vp);
1009 if (!item) { 1008 if (!item) {
1010 emit newEvent(); 1009 emit newEvent();
1011 return; 1010 return;
1012 } 1011 }
1013 KListView::contentsMouseDoubleClickEvent(e); 1012 KListView::contentsMouseDoubleClickEvent(e);
1014} 1013}
1015 1014
1016 1015
1017void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1016void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1018{ 1017{
1019 //qDebug("contentsMousePressEvent++++ "); 1018 //qDebug("contentsMousePressEvent++++ ");
1020 if (! mMouseDown ) { 1019 if (! mMouseDown ) {
1021 mAllowPopupMenu = true; 1020 mAllowPopupMenu = true;
1022 mYMousePos = mapToGlobal( (e->pos())).y(); 1021 mYMousePos = mapToGlobal( (e->pos())).y();
1023 } 1022 }
1024 if ( e->button() == RightButton && mMouseDown ) 1023 if ( e->button() == RightButton && mMouseDown )
1025 return; 1024 return;
1026 if ( e->button() == LeftButton ) 1025 if ( e->button() == LeftButton )
1027 mMouseDown = true; 1026 mMouseDown = true;
1028 KListView::contentsMousePressEvent( e ); 1027 KListView::contentsMousePressEvent( e );
1029} 1028}
1030void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1029void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1031{ 1030{
1032 //qDebug("contentsMouseReleaseEv---- "); 1031 //qDebug("contentsMouseReleaseEv---- ");
1033 if ( ! mMouseDown ) { 1032 if ( ! mMouseDown ) {
1034 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1033 if ( e->button() == RightButton && ! mAllowPopupMenu )
1035 return; 1034 return;
1036 QListViewItem* ci = currentItem(); 1035 QListViewItem* ci = currentItem();
1037 if ( ci ) 1036 if ( ci )
1038 ci->setSelected( true ); 1037 ci->setSelected( true );
1039 KListView::contentsMouseReleaseEvent(e); 1038 KListView::contentsMouseReleaseEvent(e);
1040 return; 1039 return;
1041 } 1040 }
1042 if ( e->button() == LeftButton ) 1041 if ( e->button() == LeftButton )
1043 mMouseDown = false; 1042 mMouseDown = false;
1044 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1043 if ( e->button() == RightButton && ! mAllowPopupMenu )
1045 return; 1044 return;
1046 if ( e->button() == RightButton ) { 1045 if ( e->button() == RightButton ) {
1047 QListViewItem* ci = currentItem(); 1046 QListViewItem* ci = currentItem();
1048 if ( ci ) 1047 if ( ci )
1049 ci->setSelected( true ); 1048 ci->setSelected( true );
1050 } 1049 }
1051 KListView::contentsMouseReleaseEvent(e); 1050 KListView::contentsMouseReleaseEvent(e);
1052} 1051}
1053void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1052void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1054{ 1053{
1055 // qDebug("contentsMouseMoveEv....... "); 1054 // qDebug("contentsMouseMoveEv....... ");
1056 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1055 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1057 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1056 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1058 if ( diff < 0 ) diff = -diff; 1057 if ( diff < 0 ) diff = -diff;
1059 if ( diff > 20 ) 1058 if ( diff > 20 )
1060 mAllowPopupMenu = false; 1059 mAllowPopupMenu = false;
1061 KListView::contentsMouseMoveEvent(e); 1060 KListView::contentsMouseMoveEvent(e);
1062} 1061}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index c4bc51b..df60564 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1057 +1,1056 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtooltip.h> 27#include <qtooltip.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35 35
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45#include "calprinter.h" 45#include "calprinter.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
49#include "kocore.h" 49#include "kocore.h"
50#endif 50#endif
51#include "koglobals.h" 51#include "koglobals.h"
52#include <libkdepim/kincidenceformatter.h> 52#include <libkdepim/kincidenceformatter.h>
53 53
54#include "komonthview.h" 54#include "komonthview.h"
55#include "komonthview.moc"
56 55
57#define PIXMAP_SIZE 5 56#define PIXMAP_SIZE 5
58 57
59class KNOWhatsThis :public QWhatsThis 58class KNOWhatsThis :public QWhatsThis
60{ 59{
61public: 60public:
62 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 61 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
63 62
64protected: 63protected:
65 virtual QString text( const QPoint& p) 64 virtual QString text( const QPoint& p)
66 { 65 {
67 return _wid->getWhatsThisText(p) ; 66 return _wid->getWhatsThisText(p) ;
68 }; 67 };
69private: 68private:
70 KNoScrollListBox* _wid; 69 KNoScrollListBox* _wid;
71 70
72}; 71};
73 72
74 73
75KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 74KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
76 : QListBox(parent, name) 75 : QListBox(parent, name)
77{ 76{
78#ifndef DESKTOP_VERSION 77#ifndef DESKTOP_VERSION
79 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 78 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
80#endif 79#endif
81 new KNOWhatsThis(this); 80 new KNOWhatsThis(this);
82} 81}
83 82
84QString KNoScrollListBox::getWhatsThisText(QPoint p) 83QString KNoScrollListBox::getWhatsThisText(QPoint p)
85{ 84{
86 QListBoxItem* item = itemAt ( p ); 85 QListBoxItem* item = itemAt ( p );
87 if ( ! item ) { 86 if ( ! item ) {
88 return i18n("Click in the cell or\non the date label\nto add an event!"); 87 return i18n("Click in the cell or\non the date label\nto add an event!");
89 } 88 }
90 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 89 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
91} 90}
92void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 91void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
93{ 92{
94 93
95 switch(e->key()) { 94 switch(e->key()) {
96 case Key_Right: 95 case Key_Right:
97 // if ( e->state() == Qt::ControlButton ) 96 // if ( e->state() == Qt::ControlButton )
98 { 97 {
99 e->ignore(); 98 e->ignore();
100 return; 99 return;
101 } 100 }
102 scrollBy(4,0); 101 scrollBy(4,0);
103 break; 102 break;
104 case Key_Left: 103 case Key_Left:
105 // if ( e->state() == Qt::ControlButton ) 104 // if ( e->state() == Qt::ControlButton )
106 { 105 {
107 e->ignore(); 106 e->ignore();
108 return; 107 return;
109 } 108 }
110 scrollBy(-4,0); 109 scrollBy(-4,0);
111 break; 110 break;
112 case Key_Up: 111 case Key_Up:
113 if(!count()) break; 112 if(!count()) break;
114 setCurrentItem((currentItem()+count()-1)%count()); 113 setCurrentItem((currentItem()+count()-1)%count());
115 if(!itemVisible(currentItem())) { 114 if(!itemVisible(currentItem())) {
116 if((unsigned int) currentItem() == (count()-1)) { 115 if((unsigned int) currentItem() == (count()-1)) {
117 setTopItem(currentItem()-numItemsVisible()+1); 116 setTopItem(currentItem()-numItemsVisible()+1);
118 } else { 117 } else {
119 setTopItem(topItem()-1); 118 setTopItem(topItem()-1);
120 } 119 }
121 } 120 }
122 break; 121 break;
123 case Key_Down: 122 case Key_Down:
124 if(!count()) break; 123 if(!count()) break;
125 setCurrentItem((currentItem()+1)%count()); 124 setCurrentItem((currentItem()+1)%count());
126 if(!itemVisible(currentItem())) { 125 if(!itemVisible(currentItem())) {
127 if(currentItem() == 0) { 126 if(currentItem() == 0) {
128 setTopItem(0); 127 setTopItem(0);
129 } else { 128 } else {
130 setTopItem(topItem()+1); 129 setTopItem(topItem()+1);
131 } 130 }
132 } 131 }
133 break; 132 break;
134 case Key_Shift: 133 case Key_Shift:
135 emit shiftDown(); 134 emit shiftDown();
136 break; 135 break;
137 default: 136 default:
138 e->ignore(); 137 e->ignore();
139 break; 138 break;
140 } 139 }
141} 140}
142 141
143void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 142void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
144{ 143{
145 switch(e->key()) { 144 switch(e->key()) {
146 case Key_Shift: 145 case Key_Shift:
147 emit shiftUp(); 146 emit shiftUp();
148 break; 147 break;
149 default: 148 default:
150 break; 149 break;
151 } 150 }
152} 151}
153 152
154void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 153void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
155{ 154{
156 QListBox::mousePressEvent(e); 155 QListBox::mousePressEvent(e);
157 156
158 if(e->button() == RightButton) { 157 if(e->button() == RightButton) {
159 emit rightClick(); 158 emit rightClick();
160 } 159 }
161} 160}
162 161
163MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 162MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
164 : QListBoxItem() 163 : QListBoxItem()
165{ 164{
166 setText( s ); 165 setText( s );
167 166
168 mIncidence = incidence; 167 mIncidence = incidence;
169 mDate = qd; 168 mDate = qd;
170 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 169 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
171 mRecur = false; 170 mRecur = false;
172 mAlarm = false; 171 mAlarm = false;
173 mReply = false; 172 mReply = false;
174 mInfo = false; 173 mInfo = false;
175} 174}
176 175
177void MonthViewItem::paint(QPainter *p) 176void MonthViewItem::paint(QPainter *p)
178{ 177{
179#if QT_VERSION >= 0x030000 178#if QT_VERSION >= 0x030000
180 bool sel = isSelected(); 179 bool sel = isSelected();
181#else 180#else
182 bool sel = selected(); 181 bool sel = selected();
183#endif 182#endif
184 183
185 184
186 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 185 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
187 { 186 {
188 p->setBackgroundColor( palette().color( QPalette::Normal, \ 187 p->setBackgroundColor( palette().color( QPalette::Normal, \
189 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 188 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
190 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 189 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
191 } 190 }
192 int x = 1; 191 int x = 1;
193 int y = 3;//(height() - mRecurPixmap.height()) /2; 192 int y = 3;//(height() - mRecurPixmap.height()) /2;
194 int size = PIXMAP_SIZE; 193 int size = PIXMAP_SIZE;
195 if ( QApplication::desktop()->width() < 300 ) 194 if ( QApplication::desktop()->width() < 300 )
196 size = 3; 195 size = 3;
197 if ( KOPrefs::instance()->mMonthShowIcons ) { 196 if ( KOPrefs::instance()->mMonthShowIcons ) {
198 if ( mInfo ) { 197 if ( mInfo ) {
199 p->fillRect ( x, y,size,size, Qt::darkGreen ); 198 p->fillRect ( x, y,size,size, Qt::darkGreen );
200 x += size + 1; 199 x += size + 1;
201 } 200 }
202 if ( mRecur ) { 201 if ( mRecur ) {
203 p->fillRect ( x, y,size,size, Qt::blue ); 202 p->fillRect ( x, y,size,size, Qt::blue );
204 x += size + 1; 203 x += size + 1;
205 } 204 }
206 if ( mAlarm ) { 205 if ( mAlarm ) {
207 p->fillRect ( x, y,size,size, Qt::red ); 206 p->fillRect ( x, y,size,size, Qt::red );
208 x += size + 1; 207 x += size + 1;
209 } 208 }
210 if ( mReply ) { 209 if ( mReply ) {
211 p->fillRect ( x, y,size,size, Qt::yellow ); 210 p->fillRect ( x, y,size,size, Qt::yellow );
212 x += size + 1; 211 x += size + 1;
213 } 212 }
214 } 213 }
215 QFontMetrics fm = p->fontMetrics(); 214 QFontMetrics fm = p->fontMetrics();
216 int yPos; 215 int yPos;
217 int pmheight = size; 216 int pmheight = size;
218 if( pmheight < fm.height() ) 217 if( pmheight < fm.height() )
219 yPos = fm.ascent() + fm.leading()/2; 218 yPos = fm.ascent() + fm.leading()/2;
220 else 219 else
221 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 220 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
222 p->setPen( palette().color( QPalette::Normal, sel ? \ 221 p->setPen( palette().color( QPalette::Normal, sel ? \
223 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 222 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
224 p->drawText( x, yPos, text() ); 223 p->drawText( x, yPos, text() );
225 if ( mIncidence->cancelled() ) { 224 if ( mIncidence->cancelled() ) {
226 int wid = fm.width( text() ); 225 int wid = fm.width( text() );
227 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 226 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
228 } 227 }
229 228
230} 229}
231 230
232int MonthViewItem::height(const QListBox *lb) const 231int MonthViewItem::height(const QListBox *lb) const
233{ 232{
234 return lb->fontMetrics().lineSpacing()+1; 233 return lb->fontMetrics().lineSpacing()+1;
235} 234}
236 235
237int MonthViewItem::width(const QListBox *lb) const 236int MonthViewItem::width(const QListBox *lb) const
238{ 237{
239 int size = PIXMAP_SIZE; 238 int size = PIXMAP_SIZE;
240 if ( QApplication::desktop()->width() < 300 ) 239 if ( QApplication::desktop()->width() < 300 )
241 size = 3; 240 size = 3;
242 int x = 1; 241 int x = 1;
243 if ( mInfo ) { 242 if ( mInfo ) {
244 x += size + 1; 243 x += size + 1;
245 } 244 }
246 if( mRecur ) { 245 if( mRecur ) {
247 x += size+1; 246 x += size+1;
248 } 247 }
249 if( mAlarm ) { 248 if( mAlarm ) {
250 x += size+1; 249 x += size+1;
251 } 250 }
252 if( mReply ) { 251 if( mReply ) {
253 x += size+1; 252 x += size+1;
254 } 253 }
255 254
256 return( x + lb->fontMetrics().width( text() ) + 1 ); 255 return( x + lb->fontMetrics().width( text() ) + 1 );
257} 256}
258 257
259 258
260MonthViewCell::MonthViewCell( KOMonthView *parent) 259MonthViewCell::MonthViewCell( KOMonthView *parent)
261 : QWidget( parent ), 260 : QWidget( parent ),
262 mMonthView( parent ) 261 mMonthView( parent )
263{ 262{
264 263
265 QVBoxLayout *topLayout = new QVBoxLayout( this ); 264 QVBoxLayout *topLayout = new QVBoxLayout( this );
266 265
267 // mLabel = new QLabel( this );QPushButton 266 // mLabel = new QLabel( this );QPushButton
268 mLabel = new QPushButton( this ); 267 mLabel = new QPushButton( this );
269 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 268 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
270 //mLabel->setLineWidth( 1 ); 269 //mLabel->setLineWidth( 1 );
271 //mLabel->setAlignment( AlignCenter ); 270 //mLabel->setAlignment( AlignCenter );
272 mLabel->setFlat( true ); 271 mLabel->setFlat( true );
273 mItemList = new KNoScrollListBox( this ); 272 mItemList = new KNoScrollListBox( this );
274 mItemList->setMinimumSize( 10, 10 ); 273 mItemList->setMinimumSize( 10, 10 );
275 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 274 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
276 mItemList->setLineWidth( 1 ); 275 mItemList->setLineWidth( 1 );
277 topLayout->addWidget( mItemList ); 276 topLayout->addWidget( mItemList );
278 mLabel->raise(); 277 mLabel->raise();
279 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 278 // QColor( 0,0,255 ) QColor( 160,1600,255 )
280 mStandardPalette = palette(); 279 mStandardPalette = palette();
281 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 280 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
282 281
283 enableScrollBars( false ); 282 enableScrollBars( false );
284 updateConfig(); 283 updateConfig();
285 connect( mLabel, SIGNAL( clicked( )), 284 connect( mLabel, SIGNAL( clicked( )),
286 SLOT( newEvent() )); 285 SLOT( newEvent() ));
287 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 286 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
288 SLOT( defaultAction( QListBoxItem * ) ) ); 287 SLOT( defaultAction( QListBoxItem * ) ) );
289 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 288 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
290 const QPoint &) ), 289 const QPoint &) ),
291 SLOT( contextMenu( QListBoxItem * ) ) ); 290 SLOT( contextMenu( QListBoxItem * ) ) );
292 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 291 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
293 SLOT( selection( QListBoxItem * ) ) ); 292 SLOT( selection( QListBoxItem * ) ) );
294 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 293 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
295 SLOT( cellClicked( QListBoxItem * ) ) ); 294 SLOT( cellClicked( QListBoxItem * ) ) );
296 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 295 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
297 SLOT( selection( QListBoxItem * ) ) ); 296 SLOT( selection( QListBoxItem * ) ) );
298} 297}
299 298
300void MonthViewCell::setDate( const QDate &date ) 299void MonthViewCell::setDate( const QDate &date )
301{ 300{
302// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 301// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
303 302
304 mDate = date; 303 mDate = date;
305 304
306 QString text; 305 QString text;
307 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 306 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
308 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 307 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
309 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " "; 308 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " ";
310 mLabel->resize( mLabelBigSize ); 309 mLabel->resize( mLabelBigSize );
311 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 310 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
312 } else { 311 } else {
313 mLabel->resize( mLabelSize ); 312 mLabel->resize( mLabelSize );
314 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 313 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
315 } 314 }
316 mLabel->setText( text ); 315 mLabel->setText( text );
317 316
318 //resizeEvent( 0 ); 317 //resizeEvent( 0 );
319} 318}
320 319
321QDate MonthViewCell::date() const 320QDate MonthViewCell::date() const
322{ 321{
323 return mDate; 322 return mDate;
324} 323}
325 324
326void MonthViewCell::setPrimary( bool primary ) 325void MonthViewCell::setPrimary( bool primary )
327{ 326{
328 mPrimary = primary; 327 mPrimary = primary;
329 //setMyPalette(); 328 //setMyPalette();
330} 329}
331void MonthViewCell::setMyPalette() 330void MonthViewCell::setMyPalette()
332{ 331{
333 332
334 if ( mHoliday) { 333 if ( mHoliday) {
335 setPalette( mHolidayPalette ); 334 setPalette( mHolidayPalette );
336 } else { 335 } else {
337 if ( mPrimary ) { 336 if ( mPrimary ) {
338 setPalette( mPrimaryPalette ); 337 setPalette( mPrimaryPalette );
339 } else { 338 } else {
340 setPalette( mNonPrimaryPalette ); 339 setPalette( mNonPrimaryPalette );
341 } 340 }
342 } 341 }
343 QPalette pal = palette(); 342 QPalette pal = palette();
344 343
345 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 344 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
346} 345}
347QPalette MonthViewCell::getPalette () 346QPalette MonthViewCell::getPalette ()
348{ 347{
349 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 348 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
350 return mStandardPalette; 349 return mStandardPalette;
351 if ( mHoliday) { 350 if ( mHoliday) {
352 return mHolidayPalette ; 351 return mHolidayPalette ;
353 } else { 352 } else {
354 if ( mPrimary ) { 353 if ( mPrimary ) {
355 return mPrimaryPalette ; 354 return mPrimaryPalette ;
356 } 355 }
357 } 356 }
358 return mNonPrimaryPalette; 357 return mNonPrimaryPalette;
359} 358}
360bool MonthViewCell::isPrimary() const 359bool MonthViewCell::isPrimary() const
361{ 360{
362 return mPrimary; 361 return mPrimary;
363} 362}
364 363
365void MonthViewCell::setHoliday( bool holiday ) 364void MonthViewCell::setHoliday( bool holiday )
366{ 365{
367 mHoliday = holiday; 366 mHoliday = holiday;
368 //setMyPalette(); 367 //setMyPalette();
369} 368}
370 369
371void MonthViewCell::setHoliday( const QString &holiday ) 370void MonthViewCell::setHoliday( const QString &holiday )
372{ 371{
373 mHolidayString = holiday; 372 mHolidayString = holiday;
374 373
375 if ( !holiday.isEmpty() ) { 374 if ( !holiday.isEmpty() ) {
376 setHoliday( true ); 375 setHoliday( true );
377 } 376 }
378} 377}
379void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 378void MonthViewCell::keyPressEvent ( QKeyEvent * e )
380{ 379{
381 380
382 e->ignore(); 381 e->ignore();
383 382
384} 383}
385void MonthViewCell::updateCell() 384void MonthViewCell::updateCell()
386{ 385{
387 386
388 setPrimary( mDate.month()%2 ); 387 setPrimary( mDate.month()%2 );
389 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() ); 388 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() );
390 if ( mDate == QDate::currentDate() ) { 389 if ( mDate == QDate::currentDate() ) {
391 mItemList->setLineWidth( 3 ); 390 mItemList->setLineWidth( 3 );
392 } else { 391 } else {
393 mItemList->setLineWidth( 1 ); 392 mItemList->setLineWidth( 1 );
394 } 393 }
395 mItemList->clear(); 394 mItemList->clear();
396 //qApp->processEvents(); 395 //qApp->processEvents();
397 if ( !mHolidayString.isEmpty() ) { 396 if ( !mHolidayString.isEmpty() ) {
398 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 397 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
399 item->setPalette( mHolidayPalette ); 398 item->setPalette( mHolidayPalette );
400 mItemList->insertItem( item ); 399 mItemList->insertItem( item );
401 } 400 }
402 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 401 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
403 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 402 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
404 Event *event; 403 Event *event;
405 for( event = events.first(); event; event = events.next() ) { 404 for( event = events.first(); event; event = events.next() ) {
406 if ( event->categories().contains("Holiday") || 405 if ( event->categories().contains("Holiday") ||
407 event->categories().contains(i18n("Holiday"))) { 406 event->categories().contains(i18n("Holiday"))) {
408 setHoliday( true ); 407 setHoliday( true );
409 if ( mDate.dayOfWeek() == 7 ) 408 if ( mDate.dayOfWeek() == 7 )
410 mItemList->setLineWidth( 3 ); 409 mItemList->setLineWidth( 3 );
411 } 410 }
412 QString text; 411 QString text;
413 if (event->isMultiDay()) { 412 if (event->isMultiDay()) {
414 QString prefix = "<->"; 413 QString prefix = "<->";
415 if ( event->doesRecur() ) { 414 if ( event->doesRecur() ) {
416 if ( event->recursOn( mDate) ) 415 if ( event->recursOn( mDate) )
417 prefix ="->" ; 416 prefix ="->" ;
418 else { 417 else {
419 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 418 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
420 if ( event->recursOn( mDate.addDays( -days)) ) 419 if ( event->recursOn( mDate.addDays( -days)) )
421 prefix ="<-" ; 420 prefix ="<-" ;
422 } 421 }
423 422
424 } else { 423 } else {
425 if (mDate == event->dtStart().date()) { 424 if (mDate == event->dtStart().date()) {
426 prefix ="->" ; 425 prefix ="->" ;
427 } else if (mDate == event->dtEnd().date()) { 426 } else if (mDate == event->dtEnd().date()) {
428 prefix ="<-" ; 427 prefix ="<-" ;
429 } 428 }
430 } 429 }
431 text = prefix + event->summary(); 430 text = prefix + event->summary();
432 } else { 431 } else {
433 if (event->doesFloat()) 432 if (event->doesFloat())
434 text = event->summary(); 433 text = event->summary();
435 else { 434 else {
436 text = KGlobal::locale()->formatTime(event->dtStart().time()); 435 text = KGlobal::locale()->formatTime(event->dtStart().time());
437 text += " " + event->summary(); 436 text += " " + event->summary();
438 } 437 }
439 } 438 }
440 439
441 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 440 MonthViewItem *item = new MonthViewItem( event, mDate, text );
442 QPalette pal; 441 QPalette pal;
443 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 442 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
444 QStringList categories = event->categories(); 443 QStringList categories = event->categories();
445 QString cat = categories.first(); 444 QString cat = categories.first();
446 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 445 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
447 pal = getPalette(); 446 pal = getPalette();
448 if (cat.isEmpty()) { 447 if (cat.isEmpty()) {
449 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 448 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
450 } else { 449 } else {
451 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 450 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
452 } 451 }
453 452
454 } else { 453 } else {
455 if (cat.isEmpty()) { 454 if (cat.isEmpty()) {
456 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 455 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
457 } else { 456 } else {
458 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 457 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
459 } 458 }
460 } 459 }
461 460
462 } else { 461 } else {
463 pal = mStandardPalette ; 462 pal = mStandardPalette ;
464 } 463 }
465 item->setPalette( pal ); 464 item->setPalette( pal );
466 item->setRecur( event->recurrence()->doesRecur() ); 465 item->setRecur( event->recurrence()->doesRecur() );
467 item->setAlarm( event->isAlarmEnabled() ); 466 item->setAlarm( event->isAlarmEnabled() );
468 item->setMoreInfo( event->description().length() > 0 ); 467 item->setMoreInfo( event->description().length() > 0 );
469 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 468 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
470 KOPrefs::instance()->email()); 469 KOPrefs::instance()->email());
471 if ( me != 0 ) { 470 if ( me != 0 ) {
472 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 471 if ( me->status() == Attendee::NeedsAction && me->RSVP())
473 item->setReply(true); 472 item->setReply(true);
474 else 473 else
475 item->setReply(false); 474 item->setReply(false);
476 } else 475 } else
477 item->setReply(false); 476 item->setReply(false);
478 bool insert = true; 477 bool insert = true;
479 if ( !(event->doesRecur() == Recurrence::rNone) ) { 478 if ( !(event->doesRecur() == Recurrence::rNone) ) {
480 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 479 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
481 insert = false; 480 insert = false;
482 else 481 else
483 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 482 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
484 insert = false; 483 insert = false;
485 484
486 } 485 }
487 if ( insert ) 486 if ( insert )
488 mItemList->insertItem( item ); 487 mItemList->insertItem( item );
489 } 488 }
490 489
491 // insert due todos 490 // insert due todos
492 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 491 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
493 Todo *todo; 492 Todo *todo;
494 for(todo = todos.first(); todo; todo = todos.next()) { 493 for(todo = todos.first(); todo; todo = todos.next()) {
495 QString text; 494 QString text;
496 if (todo->hasDueDate()) { 495 if (todo->hasDueDate()) {
497 if (!todo->doesFloat()) { 496 if (!todo->doesFloat()) {
498 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 497 text += KGlobal::locale()->formatTime(todo->dtDue().time());
499 text += " "; 498 text += " ";
500 } 499 }
501 } 500 }
502 text += i18n("To-Do: %1").arg(todo->summary()); 501 text += i18n("To-Do: %1").arg(todo->summary());
503 502
504 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 503 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
505 //item->setPalette( mStandardPalette ); 504 //item->setPalette( mStandardPalette );
506 QPalette pal; 505 QPalette pal;
507 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 506 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
508 QStringList categories = todo->categories(); 507 QStringList categories = todo->categories();
509 QString cat = categories.first(); 508 QString cat = categories.first();
510 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 509 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
511 pal = getPalette(); 510 pal = getPalette();
512 if (cat.isEmpty()) { 511 if (cat.isEmpty()) {
513 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 512 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
514 } else { 513 } else {
515 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 514 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
516 } 515 }
517 516
518 } else { 517 } else {
519 if (cat.isEmpty()) { 518 if (cat.isEmpty()) {
520 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
521 } else { 520 } else {
522 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
523 } 522 }
524 } 523 }
525 524
526 } else { 525 } else {
527 pal = mStandardPalette ; 526 pal = mStandardPalette ;
528 } 527 }
529 item->setPalette( pal ); 528 item->setPalette( pal );
530 mItemList->insertItem( item ); 529 mItemList->insertItem( item );
531 } 530 }
532 //setMyPalette(); 531 //setMyPalette();
533 setMyPalette(); 532 setMyPalette();
534 resizeEvent( 0 ); 533 resizeEvent( 0 );
535 // if ( isVisible()) 534 // if ( isVisible())
536 // qApp->processEvents(); 535 // qApp->processEvents();
537} 536}
538 537
539void MonthViewCell::updateConfig() 538void MonthViewCell::updateConfig()
540{ 539{
541 540
542 setFont( KOPrefs::instance()->mMonthViewFont ); 541 setFont( KOPrefs::instance()->mMonthViewFont );
543 542
544 QFontMetrics fm( font() ); 543 QFontMetrics fm( font() );
545 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 544 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
546 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 545 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
547 mHolidayPalette = mStandardPalette; 546 mHolidayPalette = mStandardPalette;
548 mPrimaryPalette = mStandardPalette; 547 mPrimaryPalette = mStandardPalette;
549 mNonPrimaryPalette = mStandardPalette; 548 mNonPrimaryPalette = mStandardPalette;
550 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 549 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
551 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 550 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
552 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 551 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
553 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 552 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
554 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 553 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
555 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 554 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
556 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 555 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
557 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 556 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
558 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 557 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
559 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 558 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
560 } 559 }
561 updateCell(); 560 updateCell();
562} 561}
563 562
564void MonthViewCell::enableScrollBars( bool enabled ) 563void MonthViewCell::enableScrollBars( bool enabled )
565{ 564{
566 if ( enabled ) { 565 if ( enabled ) {
567 mItemList->setVScrollBarMode(QScrollView::Auto); 566 mItemList->setVScrollBarMode(QScrollView::Auto);
568 mItemList->setHScrollBarMode(QScrollView::Auto); 567 mItemList->setHScrollBarMode(QScrollView::Auto);
569 } else { 568 } else {
570 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 569 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
571 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 570 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
572 } 571 }
573} 572}
574 573
575Incidence *MonthViewCell::selectedIncidence() 574Incidence *MonthViewCell::selectedIncidence()
576{ 575{
577 int index = mItemList->currentItem(); 576 int index = mItemList->currentItem();
578 if ( index < 0 ) return 0; 577 if ( index < 0 ) return 0;
579 578
580 MonthViewItem *item = 579 MonthViewItem *item =
581 static_cast<MonthViewItem *>( mItemList->item( index ) ); 580 static_cast<MonthViewItem *>( mItemList->item( index ) );
582 581
583 if ( !item ) return 0; 582 if ( !item ) return 0;
584 583
585 return item->incidence(); 584 return item->incidence();
586} 585}
587 586
588QDate MonthViewCell::selectedIncidenceDate() 587QDate MonthViewCell::selectedIncidenceDate()
589{ 588{
590 QDate qd; 589 QDate qd;
591 int index = mItemList->currentItem(); 590 int index = mItemList->currentItem();
592 if ( index < 0 ) return qd; 591 if ( index < 0 ) return qd;
593 592
594 MonthViewItem *item = 593 MonthViewItem *item =
595 static_cast<MonthViewItem *>( mItemList->item( index ) ); 594 static_cast<MonthViewItem *>( mItemList->item( index ) );
596 595
597 if ( !item ) return qd; 596 if ( !item ) return qd;
598 597
599 return item->incidenceDate(); 598 return item->incidenceDate();
600} 599}
601 600
602void MonthViewCell::deselect() 601void MonthViewCell::deselect()
603{ 602{
604 mItemList->clearSelection(); 603 mItemList->clearSelection();
605 enableScrollBars( false ); 604 enableScrollBars( false );
606 // updateCell(); 605 // updateCell();
607} 606}
608void MonthViewCell::select() 607void MonthViewCell::select()
609{ 608{
610 ;// updateCell(); 609 ;// updateCell();
611} 610}
612 611
613void MonthViewCell::resizeEvent ( QResizeEvent * ) 612void MonthViewCell::resizeEvent ( QResizeEvent * )
614{ 613{
615 int size = height() - mLabel->height(); 614 int size = height() - mLabel->height();
616 if ( size > 0 ) 615 if ( size > 0 )
617 mItemList->verticalScrollBar()->setMaximumHeight( size ); 616 mItemList->verticalScrollBar()->setMaximumHeight( size );
618 size = width() - mLabel->width(); 617 size = width() - mLabel->width();
619 if ( size > 0 ) 618 if ( size > 0 )
620 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 619 mItemList->horizontalScrollBar()->setMaximumWidth( size );
621 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 620 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
622 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 621 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
623} 622}
624 623
625void MonthViewCell::defaultAction( QListBoxItem *item ) 624void MonthViewCell::defaultAction( QListBoxItem *item )
626{ 625{
627 if ( !item ) return; 626 if ( !item ) return;
628 627
629 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 628 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
630 Incidence *incidence = eventItem->incidence(); 629 Incidence *incidence = eventItem->incidence();
631 if ( incidence ) mMonthView->defaultAction( incidence ); 630 if ( incidence ) mMonthView->defaultAction( incidence );
632} 631}
633void MonthViewCell::newEvent() 632void MonthViewCell::newEvent()
634{ 633{
635 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 634 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
636 emit newEventSignal( dt ); 635 emit newEventSignal( dt );
637} 636}
638void MonthViewCell::cellClicked( QListBoxItem *item ) 637void MonthViewCell::cellClicked( QListBoxItem *item )
639{ 638{
640 static QListBoxItem * lastClicked = 0; 639 static QListBoxItem * lastClicked = 0;
641 if ( item == 0 ) { 640 if ( item == 0 ) {
642 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 641 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
643 emit newEventSignal( dt ); 642 emit newEventSignal( dt );
644 return; 643 return;
645 } 644 }
646 /* 645 /*
647 if ( lastClicked ) 646 if ( lastClicked )
648 if ( ! item ) { 647 if ( ! item ) {
649 if ( lastClicked->listBox() != item->listBox() ) 648 if ( lastClicked->listBox() != item->listBox() )
650 lastClicked->listBox()->clearSelection(); 649 lastClicked->listBox()->clearSelection();
651 } 650 }
652 */ 651 */
653 652
654 mMonthView->setSelectedCell( this ); 653 mMonthView->setSelectedCell( this );
655 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 654 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
656 select(); 655 select();
657} 656}
658 657
659void MonthViewCell::contextMenu( QListBoxItem *item ) 658void MonthViewCell::contextMenu( QListBoxItem *item )
660{ 659{
661 if ( !item ) return; 660 if ( !item ) return;
662 661
663 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 662 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
664 Incidence *incidence = eventItem->incidence(); 663 Incidence *incidence = eventItem->incidence();
665 if ( incidence ) mMonthView->showContextMenu( incidence ); 664 if ( incidence ) mMonthView->showContextMenu( incidence );
666} 665}
667 666
668void MonthViewCell::selection( QListBoxItem *item ) 667void MonthViewCell::selection( QListBoxItem *item )
669{ 668{
670 if ( !item ) return; 669 if ( !item ) return;
671 670
672 mMonthView->setSelectedCell( this ); 671 mMonthView->setSelectedCell( this );
673} 672}
674 673
675 674
676// ******************************************************************************* 675// *******************************************************************************
677// ******************************************************************************* 676// *******************************************************************************
678// ******************************************************************************* 677// *******************************************************************************
679 678
680 679
681KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 680KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
682 : KOEventView( calendar, parent, name ), 681 : KOEventView( calendar, parent, name ),
683 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 682 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
684 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 683 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
685{ 684{
686 mCells.setAutoDelete( true ); 685 mCells.setAutoDelete( true );
687 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 686 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
688 // mDayLayout = new QGridLayout( this ); 687 // mDayLayout = new QGridLayout( this );
689 // create the day of the week labels (Sun, Mon, etc) and add them to 688 // create the day of the week labels (Sun, Mon, etc) and add them to
690 // the layout. 689 // the layout.
691 mDayLabels.resize( mDaysPerWeek ); 690 mDayLabels.resize( mDaysPerWeek );
692 QFont bfont = font(); 691 QFont bfont = font();
693 if ( QApplication::desktop()->width() < 650 ) { 692 if ( QApplication::desktop()->width() < 650 ) {
694 bfont.setPointSize( bfont.pointSize() - 2 ); 693 bfont.setPointSize( bfont.pointSize() - 2 );
695 } 694 }
696 bfont.setBold( true ); 695 bfont.setBold( true );
697 int i; 696 int i;
698 697
699 for( i = 0; i < mDaysPerWeek; i++ ) { 698 for( i = 0; i < mDaysPerWeek; i++ ) {
700 QLabel *label = new QLabel( this ); 699 QLabel *label = new QLabel( this );
701 label->setFont(bfont); 700 label->setFont(bfont);
702 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 701 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
703 label->setLineWidth(1); 702 label->setLineWidth(1);
704 label->setAlignment(AlignCenter); 703 label->setAlignment(AlignCenter);
705 mDayLabels.insert( i, label ); 704 mDayLabels.insert( i, label );
706 } 705 }
707 706
708 bfont.setBold( false ); 707 bfont.setBold( false );
709 mWeekLabels.resize( mNumWeeks+1 ); 708 mWeekLabels.resize( mNumWeeks+1 );
710 for( i = 0; i < mNumWeeks+1; i++ ) { 709 for( i = 0; i < mNumWeeks+1; i++ ) {
711 KOWeekButton *label = new KOWeekButton( this ); 710 KOWeekButton *label = new KOWeekButton( this );
712 label->setFont(bfont); 711 label->setFont(bfont);
713 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); 712 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
714 label->setFlat(true); 713 label->setFlat(true);
715 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); 714 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
716 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 715 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
717 //label->setLineWidth(1); 716 //label->setLineWidth(1);
718 //label->setAlignment(AlignCenter); 717 //label->setAlignment(AlignCenter);
719 mWeekLabels.insert( i, label ); 718 mWeekLabels.insert( i, label );
720 } 719 }
721 mWeekLabels[mNumWeeks]->setText( i18n("W")); 720 mWeekLabels[mNumWeeks]->setText( i18n("W"));
722 int row, col; 721 int row, col;
723 mCells.resize( mNumCells ); 722 mCells.resize( mNumCells );
724 for( row = 0; row < mNumWeeks; ++row ) { 723 for( row = 0; row < mNumWeeks; ++row ) {
725 for( col = 0; col < mDaysPerWeek; ++col ) { 724 for( col = 0; col < mDaysPerWeek; ++col ) {
726 MonthViewCell *cell = new MonthViewCell( this ); 725 MonthViewCell *cell = new MonthViewCell( this );
727 mCells.insert( row * mDaysPerWeek + col, cell ); 726 mCells.insert( row * mDaysPerWeek + col, cell );
728 727
729 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 728 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
730 SLOT( defaultAction( Incidence * ) ) ); 729 SLOT( defaultAction( Incidence * ) ) );
731 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 730 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
732 SIGNAL( newEventSignal( QDateTime ) ) ); 731 SIGNAL( newEventSignal( QDateTime ) ) );
733 } 732 }
734 } 733 }
735 734
736 mContextMenu = eventPopup(); 735 mContextMenu = eventPopup();
737 // updateConfig(); //useless here 736 // updateConfig(); //useless here
738 737
739 emit incidenceSelected( 0 ); 738 emit incidenceSelected( 0 );
740} 739}
741 740
742KOMonthView::~KOMonthView() 741KOMonthView::~KOMonthView()
743{ 742{
744 delete mContextMenu; 743 delete mContextMenu;
745} 744}
746 745
747int KOMonthView::maxDatesHint() 746int KOMonthView::maxDatesHint()
748{ 747{
749 return mNumCells; 748 return mNumCells;
750} 749}
751 750
752int KOMonthView::currentDateCount() 751int KOMonthView::currentDateCount()
753{ 752{
754 return mNumCells; 753 return mNumCells;
755} 754}
756 755
757QPtrList<Incidence> KOMonthView::selectedIncidences() 756QPtrList<Incidence> KOMonthView::selectedIncidences()
758{ 757{
759 QPtrList<Incidence> selected; 758 QPtrList<Incidence> selected;
760 759
761 if ( mSelectedCell ) { 760 if ( mSelectedCell ) {
762 Incidence *incidence = mSelectedCell->selectedIncidence(); 761 Incidence *incidence = mSelectedCell->selectedIncidence();
763 if ( incidence ) selected.append( incidence ); 762 if ( incidence ) selected.append( incidence );
764 } 763 }
765 764
766 return selected; 765 return selected;
767} 766}
768 767
769DateList KOMonthView::selectedDates() 768DateList KOMonthView::selectedDates()
770{ 769{
771 DateList selected; 770 DateList selected;
772 771
773 if ( mSelectedCell ) { 772 if ( mSelectedCell ) {
774 QDate qd = mSelectedCell->selectedIncidenceDate(); 773 QDate qd = mSelectedCell->selectedIncidenceDate();
775 if ( qd.isValid() ) selected.append( qd ); 774 if ( qd.isValid() ) selected.append( qd );
776 } 775 }
777 776
778 return selected; 777 return selected;
779} 778}
780 779
781void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 780void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
782 const QDate &td) 781 const QDate &td)
783{ 782{
784#ifndef KORG_NOPRINTER 783#ifndef KORG_NOPRINTER
785 calPrinter->preview(CalPrinter::Month, fd, td); 784 calPrinter->preview(CalPrinter::Month, fd, td);
786#endif 785#endif
787} 786}
788 787
789void KOMonthView::updateConfig() 788void KOMonthView::updateConfig()
790{ 789{
791 790
792 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 791 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
793 792
794 QFontMetrics fontmetric(mDayLabels[0]->font()); 793 QFontMetrics fontmetric(mDayLabels[0]->font());
795 mWidthLongDayLabel = 0; 794 mWidthLongDayLabel = 0;
796 795
797 for (int i = 0; i < 7; i++) { 796 for (int i = 0; i < 7; i++) {
798 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 797 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
799 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 798 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
800 } 799 }
801 bool temp = mShowSatSunComp ; 800 bool temp = mShowSatSunComp ;
802 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 801 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
803 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 802 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
804 computeLayout(); 803 computeLayout();
805 updateDayLabels(); 804 updateDayLabels();
806 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 805 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
807 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 806 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
808 //resizeEvent( 0 ); 807 //resizeEvent( 0 );
809 for (uint i = 0; i < mCells.count(); ++i) { 808 for (uint i = 0; i < mCells.count(); ++i) {
810 mCells[i]->updateConfig(); 809 mCells[i]->updateConfig();
811 } 810 }
812} 811}
813 812
814void KOMonthView::updateDayLabels() 813void KOMonthView::updateDayLabels()
815{ 814{
816 815
817 for (int i = 0; i < 7; i++) { 816 for (int i = 0; i < 7; i++) {
818 if (mWeekStartsMonday) { 817 if (mWeekStartsMonday) {
819 bool show = mShortDayLabels; 818 bool show = mShortDayLabels;
820 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 819 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
821 show = true; 820 show = true;
822 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 821 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
823 } else { 822 } else {
824 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 823 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
825 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 824 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
826 825
827 } 826 }
828 } 827 }
829} 828}
830 829
831void KOMonthView::showDates(const QDate &start, const QDate &) 830void KOMonthView::showDates(const QDate &start, const QDate &)
832{ 831{
833// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 832// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
834 833
835 834
836 mStartDate = start; 835 mStartDate = start;
837 836
838 int startWeekDay = mWeekStartsMonday ? 1 : 7; 837 int startWeekDay = mWeekStartsMonday ? 1 : 7;
839 838
840 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 839 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
841 mStartDate = mStartDate.addDays( -1 ); 840 mStartDate = mStartDate.addDays( -1 );
842 } 841 }
843 842
844 bool primary = false; 843 bool primary = false;
845 uint i; 844 uint i;
846 for( i = 0; i < mCells.size(); ++i ) { 845 for( i = 0; i < mCells.size(); ++i ) {
847 QDate date = mStartDate.addDays( i ); 846 QDate date = mStartDate.addDays( i );
848 mCells[i]->setDate( date ); 847 mCells[i]->setDate( date );
849 848
850#ifndef KORG_NOPLUGINS 849#ifndef KORG_NOPLUGINS
851 // add holiday, if present 850 // add holiday, if present
852 QString hstring(KOCore::self()->holiday(date)); 851 QString hstring(KOCore::self()->holiday(date));
853 mCells[i]->setHoliday( hstring ); 852 mCells[i]->setHoliday( hstring );
854#endif 853#endif
855 854
856 } 855 }
857 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 856 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
858 for( i = 0; i < 6; ++i ) { 857 for( i = 0; i < 6; ++i ) {
859 int wno; 858 int wno;
860 // remember, according to ISO 8601, the first week of the year is the 859 // remember, according to ISO 8601, the first week of the year is the
861 // first week that contains a thursday. Thus we must subtract off 4, 860 // first week that contains a thursday. Thus we must subtract off 4,
862 // not just 1. 861 // not just 1.
863 int dayOfYear = date.dayOfYear(); 862 int dayOfYear = date.dayOfYear();
864 if (dayOfYear % 7 != 0) 863 if (dayOfYear % 7 != 0)
865 wno = dayOfYear / 7 + 1; 864 wno = dayOfYear / 7 + 1;
866 else 865 else
867 wno =dayOfYear / 7; 866 wno =dayOfYear / 7;
868 mWeekLabels[i]->setWeekNum( wno ); 867 mWeekLabels[i]->setWeekNum( wno );
869 date = date.addDays( 7 ); 868 date = date.addDays( 7 );
870 } 869 }
871 updateView(); 870 updateView();
872} 871}
873 872
874void KOMonthView::showEvents(QPtrList<Event>) 873void KOMonthView::showEvents(QPtrList<Event>)
875{ 874{
876 qDebug("KOMonthView::selectEvents is not implemented yet. "); 875 qDebug("KOMonthView::selectEvents is not implemented yet. ");
877} 876}
878 877
879void KOMonthView::changeEventDisplay(Event *, int) 878void KOMonthView::changeEventDisplay(Event *, int)
880{ 879{
881 // this should be re-written to be much more efficient, but this 880 // this should be re-written to be much more efficient, but this
882 // quick-and-dirty-hack gets the job done for right now. 881 // quick-and-dirty-hack gets the job done for right now.
883 updateView(); 882 updateView();
884} 883}
885 884
886void KOMonthView::updateView() 885void KOMonthView::updateView()
887{ 886{
888 887
889 uint i; 888 uint i;
890 for( i = 0; i < mCells.count(); ++i ) { 889 for( i = 0; i < mCells.count(); ++i ) {
891 mCells[i]->updateCell(); 890 mCells[i]->updateCell();
892 } 891 }
893 //qDebug("KOMonthView::updateView() "); 892 //qDebug("KOMonthView::updateView() ");
894 processSelectionChange(); 893 processSelectionChange();
895} 894}
896 895
897void KOMonthView::resizeEvent(QResizeEvent * e) 896void KOMonthView::resizeEvent(QResizeEvent * e)
898{ 897{
899 computeLayout(); 898 computeLayout();
900} 899}
901void KOMonthView::computeLayout() 900void KOMonthView::computeLayout()
902{ 901{
903 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 902 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
904 // note this only changes the text if the requested size crosses the 903 // note this only changes the text if the requested size crosses the
905 // threshold between big enough to support the full name and not big 904 // threshold between big enough to support the full name and not big
906 // enough. 905 // enough.
907 906
908 int daysToShow = 7; 907 int daysToShow = 7;
909 bool combinedSatSun = false; 908 bool combinedSatSun = false;
910 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 909 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
911 daysToShow = 6; 910 daysToShow = 6;
912 combinedSatSun = true; 911 combinedSatSun = true;
913 } 912 }
914 int tWid = topLevelWidget()->size().width(); 913 int tWid = topLevelWidget()->size().width();
915 int tHei = topLevelWidget()->size().height(); 914 int tHei = topLevelWidget()->size().height();
916 915
917 int wid = size().width();//e 916 int wid = size().width();//e
918 int hei = size().height()-1; 917 int hei = size().height()-1;
919 918
920 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 919 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
921 return; 920 return;
922 921
923 QFontMetrics fm ( mWeekLabels[0]->font() ); 922 QFontMetrics fm ( mWeekLabels[0]->font() );
924 int weeklabelwid = fm.width( "888" ); 923 int weeklabelwid = fm.width( "888" );
925 wid -= weeklabelwid; 924 wid -= weeklabelwid;
926 925
927 int colWid = wid / daysToShow; 926 int colWid = wid / daysToShow;
928 int lastCol = wid - ( colWid*6 ); 927 int lastCol = wid - ( colWid*6 );
929 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 928 int dayLabelHei = mDayLabels[0]->sizeHint().height();
930 int cellHei = (hei - dayLabelHei) /6; 929 int cellHei = (hei - dayLabelHei) /6;
931 int colModulo = wid % daysToShow; 930 int colModulo = wid % daysToShow;
932 int rowModulo = (hei- dayLabelHei) % 6; 931 int rowModulo = (hei- dayLabelHei) % 6;
933 //qDebug("rowmod %d ", rowModulo); 932 //qDebug("rowmod %d ", rowModulo);
934 int i; 933 int i;
935 int x,y,w,h; 934 int x,y,w,h;
936 x= 0; 935 x= 0;
937 y= 0; 936 y= 0;
938 w = colWid; 937 w = colWid;
939 h = dayLabelHei ; 938 h = dayLabelHei ;
940 for ( i = 0; i < 7; i++) { 939 for ( i = 0; i < 7; i++) {
941 if ( i == daysToShow-colModulo ) 940 if ( i == daysToShow-colModulo )
942 ++w; 941 ++w;
943 if ( combinedSatSun ) { 942 if ( combinedSatSun ) {
944 if ( i >= daysToShow-1 ) { 943 if ( i >= daysToShow-1 ) {
945 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 944 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
946 x -= w/2 ; 945 x -= w/2 ;
947 } 946 }
948 else 947 else
949 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 948 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
950 } else 949 } else
951 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 950 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
952 x += w; 951 x += w;
953 } 952 }
954 x= 0; 953 x= 0;
955 y= dayLabelHei; 954 y= dayLabelHei;
956 w = colWid; 955 w = colWid;
957 h = cellHei ; 956 h = cellHei ;
958 for ( i = 0; i < mCells.count(); ++i) { 957 for ( i = 0; i < mCells.count(); ++i) {
959 958
960 w = colWid; 959 w = colWid;
961 if ( ((i) % 7) >= 7-colModulo ) { 960 if ( ((i) % 7) >= 7-colModulo ) {
962 ++w; 961 ++w;
963 } 962 }
964 if ( i == (6-rowModulo)*7) 963 if ( i == (6-rowModulo)*7)
965 ++h; 964 ++h;
966 if ( combinedSatSun ) { 965 if ( combinedSatSun ) {
967 if ( (i)%7 >= daysToShow-1 ) { 966 if ( (i)%7 >= daysToShow-1 ) {
968 if ( (i)%7 == daysToShow-1 ) { 967 if ( (i)%7 == daysToShow-1 ) {
969 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 968 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
970 x -= w ;y += h/2; 969 x -= w ;y += h/2;
971 } else { 970 } else {
972 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 971 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
973 y -= h/2; 972 y -= h/2;
974 } 973 }
975 } else 974 } else
976 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 975 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
977 976
978 } 977 }
979 else 978 else
980 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 979 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
981 x += w; 980 x += w;
982 if ( x + w/2 > wid ) { 981 if ( x + w/2 > wid ) {
983 x = 0; 982 x = 0;
984 y += h; 983 y += h;
985 } 984 }
986 } 985 }
987 y= dayLabelHei; 986 y= dayLabelHei;
988 h = cellHei ; 987 h = cellHei ;
989 for ( i = 0; i < 6; i++) { 988 for ( i = 0; i < 6; i++) {
990 if ( i == (6-rowModulo)) 989 if ( i == (6-rowModulo))
991 ++h; 990 ++h;
992 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 991 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
993 y += h; 992 y += h;
994 } 993 }
995 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 994 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
996 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 995 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
997 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 996 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
998 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 997 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
999 updateDayLabels(); 998 updateDayLabels();
1000} 999}
1001 1000
1002void KOMonthView::showContextMenu( Incidence *incidence ) 1001void KOMonthView::showContextMenu( Incidence *incidence )
1003{ 1002{
1004 mContextMenu->showIncidencePopup(incidence); 1003 mContextMenu->showIncidencePopup(incidence);
1005 /* 1004 /*
1006 if( incidence && incidence->type() == "Event" ) { 1005 if( incidence && incidence->type() == "Event" ) {
1007 Event *event = static_cast<Event *>(incidence); 1006 Event *event = static_cast<Event *>(incidence);
1008 mContextMenu->showEventPopup(event); 1007 mContextMenu->showEventPopup(event);
1009 } else { 1008 } else {
1010 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1009 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1011 } 1010 }
1012 */ 1011 */
1013} 1012}
1014MonthViewCell * KOMonthView::selectedCell( ) 1013MonthViewCell * KOMonthView::selectedCell( )
1015{ 1014{
1016 return mSelectedCell; 1015 return mSelectedCell;
1017} 1016}
1018void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1017void KOMonthView::setSelectedCell( MonthViewCell *cell )
1019{ 1018{
1020 // qDebug("KOMonthView::setSelectedCell "); 1019 // qDebug("KOMonthView::setSelectedCell ");
1021 if ( mSelectedCell && mSelectedCell != cell ) { 1020 if ( mSelectedCell && mSelectedCell != cell ) {
1022 MonthViewCell * mvc = mSelectedCell; 1021 MonthViewCell * mvc = mSelectedCell;
1023 mSelectedCell = cell; 1022 mSelectedCell = cell;
1024 mvc->deselect(); 1023 mvc->deselect();
1025 } else 1024 } else
1026 mSelectedCell = cell; 1025 mSelectedCell = cell;
1027 // if ( mSelectedCell ) 1026 // if ( mSelectedCell )
1028// mSelectedCell->select(); 1027// mSelectedCell->select();
1029 if ( !mSelectedCell ) 1028 if ( !mSelectedCell )
1030 emit incidenceSelected( 0 ); 1029 emit incidenceSelected( 0 );
1031 else 1030 else
1032 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1031 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1033} 1032}
1034 1033
1035void KOMonthView::processSelectionChange() 1034void KOMonthView::processSelectionChange()
1036{ 1035{
1037 QPtrList<Incidence> incidences = selectedIncidences(); 1036 QPtrList<Incidence> incidences = selectedIncidences();
1038 if (incidences.count() > 0) { 1037 if (incidences.count() > 0) {
1039 emit incidenceSelected( incidences.first() ); 1038 emit incidenceSelected( incidences.first() );
1040 } else { 1039 } else {
1041 emit incidenceSelected( 0 ); 1040 emit incidenceSelected( 0 );
1042 } 1041 }
1043} 1042}
1044 1043
1045void KOMonthView::clearSelection() 1044void KOMonthView::clearSelection()
1046{ 1045{
1047 if ( mSelectedCell ) { 1046 if ( mSelectedCell ) {
1048 mSelectedCell->deselect(); 1047 mSelectedCell->deselect();
1049 mSelectedCell = 0; 1048 mSelectedCell = 0;
1050 } 1049 }
1051} 1050}
1052void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1051void KOMonthView::keyPressEvent ( QKeyEvent * e )
1053{ 1052{
1054 1053
1055 e->ignore(); 1054 e->ignore();
1056 1055
1057} 1056}
diff --git a/korganizer/koprefsdialog.cpp b/korganizer/koprefsdialog.cpp
index 04fffe2..da6644f 100644
--- a/korganizer/koprefsdialog.cpp
+++ b/korganizer/koprefsdialog.cpp
@@ -1,1610 +1,1609 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qvbox.h> 34#include <qvbox.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44 44
45#include <kcolorbutton.h> 45#include <kcolorbutton.h>
46#include <kdebug.h> 46#include <kdebug.h>
47#include <klocale.h> 47#include <klocale.h>
48#include <kglobal.h> 48#include <kglobal.h>
49#include <kfontdialog.h> 49#include <kfontdialog.h>
50#include <kfiledialog.h> 50#include <kfiledialog.h>
51#include <kmessagebox.h> 51#include <kmessagebox.h>
52#include <kcolordialog.h> 52#include <kcolordialog.h>
53#include <kiconloader.h> 53#include <kiconloader.h>
54#include <kemailsettings.h> 54#include <kemailsettings.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56 56
57#include <kurlrequester.h> 57#include <kurlrequester.h>
58#include <klineedit.h> 58#include <klineedit.h>
59 59
60#if defined(USE_SOLARIS) 60#if defined(USE_SOLARIS)
61#include <sys/param.h> 61#include <sys/param.h>
62 62
63#define ZONEINFODIR "/usr/share/lib/zoneinfo" 63#define ZONEINFODIR "/usr/share/lib/zoneinfo"
64#define INITFILE "/etc/default/init" 64#define INITFILE "/etc/default/init"
65#endif 65#endif
66 66
67#include "koprefs.h" 67#include "koprefs.h"
68 68
69#include "koprefsdialog.h" 69#include "koprefsdialog.h"
70#include "koprefsdialog.moc"
71 70
72 71
73KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) : 72KOPrefsDialog::KOPrefsDialog(QWidget *parent, char *name, bool modal) :
74 KPrefsDialog(KOPrefs::instance(),parent,name,true) 73 KPrefsDialog(KOPrefs::instance(),parent,name,true)
75{ 74{
76 75
77 setCaption( i18n("Preferences - some settings need a restart (nr)")); 76 setCaption( i18n("Preferences - some settings need a restart (nr)"));
78 mCategoryDict.setAutoDelete(true); 77 mCategoryDict.setAutoDelete(true);
79 78
80 KGlobal::locale()->insertCatalogue("timezones"); 79 KGlobal::locale()->insertCatalogue("timezones");
81 80
82 setupMainTab(); 81 setupMainTab();
83 setupLocaleTab(); 82 setupLocaleTab();
84 setupTimeZoneTab(); 83 setupTimeZoneTab();
85 setupTimeTab(); 84 setupTimeTab();
86 setupLocaleDateTab(); 85 setupLocaleDateTab();
87 setupFontsTab(); 86 setupFontsTab();
88 setupColorsTab(); 87 setupColorsTab();
89 setupViewsTab(); 88 setupViewsTab();
90 //setupSyncTab(); 89 //setupSyncTab();
91 //setupSyncAlgTab(); 90 //setupSyncAlgTab();
92 //setupPrinterTab(); 91 //setupPrinterTab();
93 //setupGroupSchedulingTab(); 92 //setupGroupSchedulingTab();
94 //setupGroupAutomationTab(); 93 //setupGroupAutomationTab();
95} 94}
96 95
97 96
98KOPrefsDialog::~KOPrefsDialog() 97KOPrefsDialog::~KOPrefsDialog()
99{ 98{
100} 99}
101 100
102void KOPrefsDialog::setupLocaleDateTab() 101void KOPrefsDialog::setupLocaleDateTab()
103{ 102{
104QFrame *topFrame = addPage(i18n("Date Format"),0,0); 103QFrame *topFrame = addPage(i18n("Date Format"),0,0);
105 QGridLayout *topLayout = new QGridLayout(topFrame,3,2); 104 QGridLayout *topLayout = new QGridLayout(topFrame,3,2);
106 topLayout->setSpacing(spacingHint()); 105 topLayout->setSpacing(spacingHint());
107 topLayout->setMargin(marginHint()); 106 topLayout->setMargin(marginHint());
108 int iii = 0; 107 int iii = 0;
109 108
110 109
111 KPrefsWidRadios *syncPrefsGroup = 110 KPrefsWidRadios *syncPrefsGroup =
112 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame); 111 addWidRadios(i18n("Date Format:"),&(KOPrefs::instance()->mPreferredDate),topFrame);
113 QString format; 112 QString format;
114 if ( QApplication::desktop()->width() < 480 ) 113 if ( QApplication::desktop()->width() < 480 )
115 format = "(%d.%m.%Y)"; 114 format = "(%d.%m.%Y)";
116 else 115 else
117 format = "(%d.%m.%Y|%A %d %B %Y)"; 116 format = "(%d.%m.%Y|%A %d %B %Y)";
118 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 117 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
119 if ( QApplication::desktop()->width() < 480 ) 118 if ( QApplication::desktop()->width() < 480 )
120 format = "(%m.%d.%Y)"; 119 format = "(%m.%d.%Y)";
121 else 120 else
122 format = "(%m.%d.%Y|%A %B %d %Y)"; 121 format = "(%m.%d.%Y|%A %B %d %Y)";
123 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 122 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
124 if ( QApplication::desktop()->width() < 480 ) 123 if ( QApplication::desktop()->width() < 480 )
125 format = "(%Y-%m-%d)"; 124 format = "(%Y-%m-%d)";
126 else 125 else
127 format = "(%Y-%m-%d|%A %Y %B %d)"; 126 format = "(%Y-%m-%d|%A %Y %B %d)";
128 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 127 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
129 syncPrefsGroup->addRadio(i18n("User defined")); 128 syncPrefsGroup->addRadio(i18n("User defined"));
130 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 129 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
131 ++iii; 130 ++iii;
132 ++iii; 131 ++iii;
133 QLabel * lab; 132 QLabel * lab;
134 mUserDateFormatLong = new QLineEdit(topFrame); 133 mUserDateFormatLong = new QLineEdit(topFrame);
135 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 134 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
136 topLayout->addWidget(lab ,iii,0); 135 topLayout->addWidget(lab ,iii,0);
137 topLayout->addWidget(mUserDateFormatLong,iii,1); 136 topLayout->addWidget(mUserDateFormatLong,iii,1);
138 ++iii; 137 ++iii;
139 mUserDateFormatShort = new QLineEdit(topFrame); 138 mUserDateFormatShort = new QLineEdit(topFrame);
140 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 139 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
141 topLayout->addWidget(lab ,iii,0); 140 topLayout->addWidget(lab ,iii,0);
142 topLayout->addWidget(mUserDateFormatShort,iii,1); 141 topLayout->addWidget(mUserDateFormatShort,iii,1);
143 ++iii; 142 ++iii;
144 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 143 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
145 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 144 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
146 ++iii; 145 ++iii;
147 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 146 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
148 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 147 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
149 ++iii; 148 ++iii;
150 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 149 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
151 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 150 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
152 ++iii; 151 ++iii;
153 152
154} 153}
155 154
156void KOPrefsDialog::setupLocaleTab() 155void KOPrefsDialog::setupLocaleTab()
157{ 156{
158 QFrame *topFrame = addPage(i18n("Locale"),0,0); 157 QFrame *topFrame = addPage(i18n("Locale"),0,0);
159 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 158 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
160 topLayout->setSpacing(spacingHint()); 159 topLayout->setSpacing(spacingHint());
161 topLayout->setMargin(marginHint()); 160 topLayout->setMargin(marginHint());
162 int iii = 0; 161 int iii = 0;
163 KPrefsWidRadios *syncPrefsGroup = 162 KPrefsWidRadios *syncPrefsGroup =
164 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame); 163 addWidRadios(i18n("Language:(needs restart)"),&(KOPrefs::instance()->mPreferredLanguage),topFrame);
165 syncPrefsGroup->addRadio(i18n("English")); 164 syncPrefsGroup->addRadio(i18n("English"));
166 syncPrefsGroup->addRadio(i18n("German")); 165 syncPrefsGroup->addRadio(i18n("German"));
167 syncPrefsGroup->addRadio(i18n("French(nyi)")); 166 syncPrefsGroup->addRadio(i18n("French(nyi)"));
168 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 167 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
169 if ( QApplication::desktop()->width() < 300 ) 168 if ( QApplication::desktop()->width() < 300 )
170 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 169 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
171 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 170 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
172 ++iii; 171 ++iii;
173 172
174 syncPrefsGroup = 173 syncPrefsGroup =
175 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame); 174 addWidRadios(i18n("Time Format(nr):"),&(KOPrefs::instance()->mPreferredTime),topFrame);
176 if ( QApplication::desktop()->width() > 300 ) 175 if ( QApplication::desktop()->width() > 300 )
177 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 176 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
178 syncPrefsGroup->addRadio(i18n("24:00")); 177 syncPrefsGroup->addRadio(i18n("24:00"));
179 syncPrefsGroup->addRadio(i18n("12:00am")); 178 syncPrefsGroup->addRadio(i18n("12:00am"));
180 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 179 syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
181 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 180 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
182 ++iii; 181 ++iii;
183 KPrefsWidBool *sb; 182 KPrefsWidBool *sb;
184 if ( QApplication::desktop()->width() < 300 ) { 183 if ( QApplication::desktop()->width() < 300 ) {
185 sb = 184 sb =
186 addWidBool(i18n("Week starts on Sunday"), 185 addWidBool(i18n("Week starts on Sunday"),
187 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame); 186 &(KOPrefs::instance()->mWeekStartsOnSunday),topFrame);
188 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 187 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
189 ++iii; 188 ++iii;
190 sb = 189 sb =
191 addWidBool(i18n("Use short date in (WN/E) view"), 190 addWidBool(i18n("Use short date in (WN/E) view"),
192 &(KOPrefs::instance()->mShortDateInViewer),topFrame); 191 &(KOPrefs::instance()->mShortDateInViewer),topFrame);
193 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 192 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
194 } 193 }
195 else { 194 else {
196 QWidget * hb = new QWidget( topFrame ); 195 QWidget * hb = new QWidget( topFrame );
197 QHBoxLayout *hbLayout = new QHBoxLayout(hb); 196 QHBoxLayout *hbLayout = new QHBoxLayout(hb);
198 sb = 197 sb =
199 addWidBool(i18n("Week starts on Sunday"), 198 addWidBool(i18n("Week starts on Sunday"),
200 &(KOPrefs::instance()->mWeekStartsOnSunday),hb); 199 &(KOPrefs::instance()->mWeekStartsOnSunday),hb);
201 hbLayout->addWidget(sb->checkBox() ); 200 hbLayout->addWidget(sb->checkBox() );
202 sb = 201 sb =
203 addWidBool(i18n("Use short date in (WN/E) view"), 202 addWidBool(i18n("Use short date in (WN/E) view"),
204 &(KOPrefs::instance()->mShortDateInViewer),hb); 203 &(KOPrefs::instance()->mShortDateInViewer),hb);
205 hbLayout->addWidget(sb->checkBox() ); 204 hbLayout->addWidget(sb->checkBox() );
206 topLayout->addMultiCellWidget(hb, iii,iii,0,1); 205 topLayout->addMultiCellWidget(hb, iii,iii,0,1);
207 206
208 } 207 }
209 //#ifndef DESKTOP_VERSION 208 //#ifndef DESKTOP_VERSION
210#if 0 209#if 0
211 ++iii; 210 ++iii;
212 sb = 211 sb =
213 addWidBool(i18n("Quick load/save (w/o Unicode)"), 212 addWidBool(i18n("Quick load/save (w/o Unicode)"),
214 &(KOPrefs::instance()->mUseQuicksave),topFrame); 213 &(KOPrefs::instance()->mUseQuicksave),topFrame);
215 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 214 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
216#endif 215#endif
217} 216}
218void KOPrefsDialog::showSyncPage() 217void KOPrefsDialog::showSyncPage()
219{ 218{
220 showPage ( 2 ) ; 219 showPage ( 2 ) ;
221 220
222} 221}
223void KOPrefsDialog::setupSyncAlgTab() 222void KOPrefsDialog::setupSyncAlgTab()
224{ 223{
225#if 0 224#if 0
226 QLabel * lab; 225 QLabel * lab;
227 QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0); 226 QFrame *topFrame = addPage(i18n("Sync Prefs"),0,0);
228 mSetupSyncAlgTab = topFrame; 227 mSetupSyncAlgTab = topFrame;
229 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 228 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
230 topLayout->setSpacing(spacingHint()); 229 topLayout->setSpacing(spacingHint());
231 topLayout->setMargin(marginHint()); 230 topLayout->setMargin(marginHint());
232 int iii = 0; 231 int iii = 0;
233 232
234 KPrefsWidBool *sb = 233 KPrefsWidBool *sb =
235 addWidBool(i18n("Ask for preferences before syncing"), 234 addWidBool(i18n("Ask for preferences before syncing"),
236 &(KOPrefs::instance()->mAskForPreferences),topFrame); 235 &(KOPrefs::instance()->mAskForPreferences),topFrame);
237 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 236 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
238 237
239 ++iii; 238 ++iii;
240 239
241 KPrefsWidRadios *syncPrefsGroup = 240 KPrefsWidRadios *syncPrefsGroup =
242 addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs), 241 addWidRadios(i18n("Sync preferences:"),&(KOPrefs::instance()->mSyncAlgoPrefs),
243 topFrame); 242 topFrame);
244 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 243 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
245 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 244 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
246 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 245 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
247 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 246 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
248 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 247 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
249 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 248 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
250 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 249 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
251 ++iii; 250 ++iii;
252 sb = 251 sb =
253 addWidBool(i18n("Show summary after syncing"), 252 addWidBool(i18n("Show summary after syncing"),
254 &(KOPrefs::instance()->mShowSyncSummary),topFrame); 253 &(KOPrefs::instance()->mShowSyncSummary),topFrame);
255 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 254 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
256 255
257 ++iii; 256 ++iii;
258#endif 257#endif
259 258
260 259
261 260
262} 261}
263 262
264 263
265void KOPrefsDialog::setupSyncTab() 264void KOPrefsDialog::setupSyncTab()
266{ 265{
267#if 0 266#if 0
268 QLabel * lab; 267 QLabel * lab;
269 QFrame *topFrame = addPage(i18n("Sync Network"),0,0); 268 QFrame *topFrame = addPage(i18n("Sync Network"),0,0);
270 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 269 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
271 topLayout->setSpacing(spacingHint()); 270 topLayout->setSpacing(spacingHint());
272 topLayout->setMargin(marginHint()); 271 topLayout->setMargin(marginHint());
273 lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame); 272 lab = new QLabel(i18n("Remote syncing (via ssh/scp)\nnetwork settings "), topFrame);
274 int iii = 0; 273 int iii = 0;
275 topLayout->addMultiCellWidget(lab , iii,iii,0,1); 274 topLayout->addMultiCellWidget(lab , iii,iii,0,1);
276 ++iii; 275 ++iii;
277 276
278 mRemoteIPEdit = new QLineEdit(topFrame); 277 mRemoteIPEdit = new QLineEdit(topFrame);
279 lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame); 278 lab = new QLabel(mRemoteIPEdit, i18n("Remote IP:"), topFrame);
280 topLayout->addWidget(lab ,iii,0); 279 topLayout->addWidget(lab ,iii,0);
281 topLayout->addWidget(mRemoteIPEdit,iii,1); 280 topLayout->addWidget(mRemoteIPEdit,iii,1);
282 ++iii; 281 ++iii;
283 mRemoteUser = new QLineEdit(topFrame); 282 mRemoteUser = new QLineEdit(topFrame);
284 lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame); 283 lab = new QLabel(mRemoteUser, i18n("Remote user:"), topFrame);
285 topLayout->addWidget(lab ,iii,0); 284 topLayout->addWidget(lab ,iii,0);
286 topLayout->addWidget(mRemoteUser, iii,1); 285 topLayout->addWidget(mRemoteUser, iii,1);
287 ++iii; 286 ++iii;
288 287
289 mRemoteFile = new QLineEdit(topFrame); 288 mRemoteFile = new QLineEdit(topFrame);
290 lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame); 289 lab = new QLabel(mRemoteFile, i18n("Remote file:"), topFrame);
291 topLayout->addWidget(lab ,iii,0); 290 topLayout->addWidget(lab ,iii,0);
292 topLayout->addWidget(mRemoteFile,iii,1); 291 topLayout->addWidget(mRemoteFile,iii,1);
293 ++iii; 292 ++iii;
294 293
295 mLocalTempFile = new QLineEdit(topFrame); 294 mLocalTempFile = new QLineEdit(topFrame);
296 lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame); 295 lab = new QLabel(mLocalTempFile, i18n("Local temp file:"), topFrame);
297 topLayout->addWidget(lab ,iii,0); 296 topLayout->addWidget(lab ,iii,0);
298 topLayout->addWidget(mLocalTempFile,iii,1); 297 topLayout->addWidget(mLocalTempFile,iii,1);
299 ++iii; 298 ++iii;
300 299
301 KPrefsWidBool *wb = 300 KPrefsWidBool *wb =
302 addWidBool(i18n("Write back synced file"), 301 addWidBool(i18n("Write back synced file"),
303 &(KOPrefs::instance()->mWriteBackFile),topFrame); 302 &(KOPrefs::instance()->mWriteBackFile),topFrame);
304 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); 303 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1);
305 ++iii; 304 ++iii;
306 wb = 305 wb =
307 addWidBool(i18n("Write back existing entries only"), 306 addWidBool(i18n("Write back existing entries only"),
308 &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame); 307 &(KOPrefs::instance()->mWriteBackExistingOnly),topFrame);
309 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1); 308 topLayout->addMultiCellWidget(wb->checkBox(), iii,iii,0,1);
310 ++iii; 309 ++iii;
311 310
312#endif 311#endif
313} 312}
314 313
315void KOPrefsDialog::setupMainTab() 314void KOPrefsDialog::setupMainTab()
316{ 315{
317 QFrame *topFrame = addPage(i18n("General"),0,0); 316 QFrame *topFrame = addPage(i18n("General"),0,0);
318 // DesktopIcon("identity",KIcon::SizeMedium)); 317 // DesktopIcon("identity",KIcon::SizeMedium));
319 318
320 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 319 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
321 topLayout->setSpacing(spacingHint()); 320 topLayout->setSpacing(spacingHint());
322 topLayout->setMargin(marginHint()); 321 topLayout->setMargin(marginHint());
323 322
324 // KPrefsWidBool *emailControlCenter = 323 // KPrefsWidBool *emailControlCenter =
325// addWidBool(i18n("&Use email settings from Control Center"), 324// addWidBool(i18n("&Use email settings from Control Center"),
326// &(KOPrefs::instance()->mEmailControlCenter),topFrame); 325// &(KOPrefs::instance()->mEmailControlCenter),topFrame);
327// topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1); 326// topLayout->addMultiCellWidget(emailControlCenter->checkBox(),0,0,0,1);
328 // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)), 327 // connect(emailControlCenter->checkBox(),SIGNAL(toggled(bool)),
329 // SLOT(toggleEmailSettings(bool))); 328 // SLOT(toggleEmailSettings(bool)));
330 329
331 mNameEdit = new QLineEdit(topFrame); 330 mNameEdit = new QLineEdit(topFrame);
332 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame); 331 mNameLabel = new QLabel(mNameEdit, i18n("Full &name:"), topFrame);
333 topLayout->addWidget(mNameLabel,0,0); 332 topLayout->addWidget(mNameLabel,0,0);
334 topLayout->addWidget(mNameEdit,0,1); 333 topLayout->addWidget(mNameEdit,0,1);
335 334
336 mEmailEdit = new QLineEdit(topFrame); 335 mEmailEdit = new QLineEdit(topFrame);
337 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame); 336 mEmailLabel = new QLabel(mEmailEdit, i18n("E&mail address:"),topFrame);
338 topLayout->addWidget(mEmailLabel,1,0); 337 topLayout->addWidget(mEmailLabel,1,0);
339 topLayout->addWidget(mEmailEdit,1,1); 338 topLayout->addWidget(mEmailEdit,1,1);
340 KPrefsWidBool *wb; 339 KPrefsWidBool *wb;
341 QHBox *dummy; 340 QHBox *dummy;
342 if ( QApplication::desktop()->width() > 480 ) { 341 if ( QApplication::desktop()->width() > 480 ) {
343 dummy = new QHBox(topFrame); 342 dummy = new QHBox(topFrame);
344 } else { 343 } else {
345 dummy = new QVBox(topFrame); 344 dummy = new QVBox(topFrame);
346 } 345 }
347 346
348 topLayout->addMultiCellWidget(dummy, 2,2,0,1); 347 topLayout->addMultiCellWidget(dummy, 2,2,0,1);
349 addWidBool(i18n("Full menu bar(nr)"), 348 addWidBool(i18n("Full menu bar(nr)"),
350 &(KOPrefs::instance()->mShowFullMenu),dummy); 349 &(KOPrefs::instance()->mShowFullMenu),dummy);
351 350
352 351
353 addWidBool(i18n("Mini icons in toolbar(nr)"), 352 addWidBool(i18n("Mini icons in toolbar(nr)"),
354 &(KOPrefs::instance()->mToolBarMiniIcons),dummy); 353 &(KOPrefs::instance()->mToolBarMiniIcons),dummy);
355 354
356 355
357 dummy = new QHBox(topFrame); 356 dummy = new QHBox(topFrame);
358 new QLabel(i18n("Days in What's Next:"),dummy); 357 new QLabel(i18n("Days in What's Next:"),dummy);
359 mWhatsNextSpin = new QSpinBox(1,14,1,dummy); 358 mWhatsNextSpin = new QSpinBox(1,14,1,dummy);
360 359
361 topLayout->addMultiCellWidget(dummy,3,3,0,1); 360 topLayout->addMultiCellWidget(dummy,3,3,0,1);
362 361
363 362
364 363
365 dummy = new QHBox(topFrame); 364 dummy = new QHBox(topFrame);
366 new QLabel(i18n("Days in Next-X-Days:"),dummy); 365 new QLabel(i18n("Days in Next-X-Days:"),dummy);
367 mNextXDaysSpin = new QSpinBox(2,14,1,dummy); 366 mNextXDaysSpin = new QSpinBox(2,14,1,dummy);
368 367
369 topLayout->addMultiCellWidget(dummy,4,4,0,1); 368 topLayout->addMultiCellWidget(dummy,4,4,0,1);
370 369
371 QHBox *prioBox = new QHBox(topFrame); 370 QHBox *prioBox = new QHBox(topFrame);
372 // intervalBox->setSpacing(spacingHint()); 371 // intervalBox->setSpacing(spacingHint());
373 topLayout->addMultiCellWidget(prioBox,5,5,0,1); 372 topLayout->addMultiCellWidget(prioBox,5,5,0,1);
374 QString messa = i18n("Show topmost todo prios in What's Next:"); 373 QString messa = i18n("Show topmost todo prios in What's Next:");
375 374
376 if ( QApplication::desktop()->width() < 300 ) 375 if ( QApplication::desktop()->width() < 300 )
377 messa = i18n("Show topmost todo prios in What's N.:"); 376 messa = i18n("Show topmost todo prios in What's N.:");
378 QLabel *prioLabel = new QLabel(messa, prioBox); 377 QLabel *prioLabel = new QLabel(messa, prioBox);
379 mPrioSpin = new QSpinBox(0,5,1,prioBox); 378 mPrioSpin = new QSpinBox(0,5,1,prioBox);
380 if ( QApplication::desktop()->width() < 300 ) 379 if ( QApplication::desktop()->width() < 300 )
381 mPrioSpin->setFixedWidth( 40 ); 380 mPrioSpin->setFixedWidth( 40 );
382 381
383 // KPrefsWidBool *bcc = 382 // KPrefsWidBool *bcc =
384// addWidBool(i18n("Send copy to owner when mailing events"), 383// addWidBool(i18n("Send copy to owner when mailing events"),
385// &(KOPrefs::instance()->mBcc),topFrame); 384// &(KOPrefs::instance()->mBcc),topFrame);
386// topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1); 385// topLayout->addMultiCellWidget(bcc->checkBox(),4,4,0,1);
387 386
388 387
389 // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame); 388 // QGroupBox *autoSaveGroup = new QGroupBox(1,Horizontal,i18n("Auto-Save"), topFrame);
390 //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1); 389 //topLayout->addMultiCellWidget(autoSaveGroup,6,6,0,1);
391 390
392 // addWidBool(i18n("Enable automatic saving of calendar"), 391 // addWidBool(i18n("Enable automatic saving of calendar"),
393 // &(KOPrefs::instance()->mAutoSave),autoSaveGroup); 392 // &(KOPrefs::instance()->mAutoSave),autoSaveGroup);
394 393
395 QHBox *intervalBox = new QHBox(topFrame); 394 QHBox *intervalBox = new QHBox(topFrame);
396 // intervalBox->setSpacing(spacingHint()); 395 // intervalBox->setSpacing(spacingHint());
397 topLayout->addMultiCellWidget(intervalBox,6,6,0,1); 396 topLayout->addMultiCellWidget(intervalBox,6,6,0,1);
398 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox); 397 QLabel *autoSaveIntervalLabel = new QLabel(i18n("Auto save delay in minutes:"),intervalBox);
399 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox); 398 mAutoSaveIntervalSpin = new QSpinBox(0,500,1,intervalBox);
400 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin); 399 autoSaveIntervalLabel->setBuddy(mAutoSaveIntervalSpin);
401 /* 400 /*
402 QHBox * agendasize = new QHBox ( topFrame ); 401 QHBox * agendasize = new QHBox ( topFrame );
403 402
404 new QLabel (i18n("AllDayAgenda Height:"), agendasize ); 403 new QLabel (i18n("AllDayAgenda Height:"), agendasize );
405 404
406 405
407 mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize); 406 mHourSizeSlider = new QSlider(24,47,1,24,Horizontal,agendasize);
408 topLayout->addMultiCellWidget(agendasize,7,7,0,1); 407 topLayout->addMultiCellWidget(agendasize,7,7,0,1);
409 */ 408 */
410 KPrefsWidBool *verticalScreen = 409 KPrefsWidBool *verticalScreen =
411 addWidBool(i18n("Show vertical screen (Needs restart)"), 410 addWidBool(i18n("Show vertical screen (Needs restart)"),
412 &(KOPrefs::instance()->mVerticalScreen),topFrame); 411 &(KOPrefs::instance()->mVerticalScreen),topFrame);
413 //topLayout->addWidget(verticalScreen->checkBox(),ii++,0); 412 //topLayout->addWidget(verticalScreen->checkBox(),ii++,0);
414 topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1); 413 topLayout->addMultiCellWidget(verticalScreen->checkBox(),7,7,0,1);
415 414
416 KPrefsWidBool *ask = 415 KPrefsWidBool *ask =
417 addWidBool(i18n("Ask for quit when closing KO/Pi"), 416 addWidBool(i18n("Ask for quit when closing KO/Pi"),
418 &(KOPrefs::instance()->mAskForQuit),topFrame); 417 &(KOPrefs::instance()->mAskForQuit),topFrame);
419 topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1); 418 topLayout->addMultiCellWidget(ask->checkBox(),8,8,0,1);
420 419
421 420
422 /* 421 /*
423 KPrefsWidBool *confirmCheck = 422 KPrefsWidBool *confirmCheck =
424 addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm), 423 addWidBool(i18n("Confirm &deletes"),&(KOPrefs::instance()->mConfirm),
425 topFrame); 424 topFrame);
426 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1); 425 topLayout->addMultiCellWidget(confirmCheck->checkBox(),7,7,0,1);
427 426
428 427
429 mEnableGroupScheduling = 428 mEnableGroupScheduling =
430 addWidBool(i18n("Enable group scheduling"), 429 addWidBool(i18n("Enable group scheduling"),
431 &(KOPrefs::instance()->mEnableGroupScheduling),topFrame); 430 &(KOPrefs::instance()->mEnableGroupScheduling),topFrame);
432 topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0); 431 topLayout->addWidget(mEnableGroupScheduling->checkBox(),8,0);
433 connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()), 432 connect(mEnableGroupScheduling->checkBox(),SIGNAL(clicked()),
434 SLOT(warningGroupScheduling())); 433 SLOT(warningGroupScheduling()));
435 434
436 mEnableProjectView = 435 mEnableProjectView =
437 addWidBool(i18n("Enable project view"), 436 addWidBool(i18n("Enable project view"),
438 &(KOPrefs::instance()->mEnableProjectView),topFrame); 437 &(KOPrefs::instance()->mEnableProjectView),topFrame);
439 topLayout->addWidget(mEnableProjectView->checkBox(),9,0); 438 topLayout->addWidget(mEnableProjectView->checkBox(),9,0);
440 connect(mEnableProjectView->checkBox(),SIGNAL(clicked()), 439 connect(mEnableProjectView->checkBox(),SIGNAL(clicked()),
441 SLOT(warningProjectView())); 440 SLOT(warningProjectView()));
442 441
443 // Can't be disabled anymore 442 // Can't be disabled anymore
444 mEnableGroupScheduling->checkBox()->hide(); 443 mEnableGroupScheduling->checkBox()->hide();
445 444
446 // Disable setting, because this feature now becomes stable 445 // Disable setting, because this feature now becomes stable
447 mEnableProjectView->checkBox()->hide(); 446 mEnableProjectView->checkBox()->hide();
448 447
449 KPrefsWidRadios *defaultFormatGroup = 448 KPrefsWidRadios *defaultFormatGroup =
450 addWidRadios(i18n("Default Calendar Format"), 449 addWidRadios(i18n("Default Calendar Format"),
451 &(KOPrefs::instance()->mDefaultFormat),topFrame); 450 &(KOPrefs::instance()->mDefaultFormat),topFrame);
452 defaultFormatGroup->addRadio(i18n("vCalendar")); 451 defaultFormatGroup->addRadio(i18n("vCalendar"));
453 defaultFormatGroup->addRadio(i18n("iCalendar")); 452 defaultFormatGroup->addRadio(i18n("iCalendar"));
454 453
455 topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1); 454 topLayout->addMultiCellWidget(defaultFormatGroup->groupBox(),10,10,0,1);
456 455
457 // Default format unconditionally is iCalendar 456 // Default format unconditionally is iCalendar
458 defaultFormatGroup->groupBox()->hide(); 457 defaultFormatGroup->groupBox()->hide();
459 458
460 KPrefsWidRadios *mailClientGroup = 459 KPrefsWidRadios *mailClientGroup =
461 addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient), 460 addWidRadios(i18n("Mail Client"),&(KOPrefs::instance()->mMailClient),
462 topFrame); 461 topFrame);
463 mailClientGroup->addRadio(i18n("KMail")); 462 mailClientGroup->addRadio(i18n("KMail"));
464 mailClientGroup->addRadio(i18n("Sendmail")); 463 mailClientGroup->addRadio(i18n("Sendmail"));
465 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1); 464 topLayout->addMultiCellWidget(mailClientGroup->groupBox(),11,11,0,1);
466 465
467 KPrefsWidBool *htmlsave = 466 KPrefsWidBool *htmlsave =
468 addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave), 467 addWidBool(i18n("Export to HTML with every save"),&(KOPrefs::instance()->mHtmlWithSave),
469 topFrame); 468 topFrame);
470 topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1); 469 topLayout->addMultiCellWidget(htmlsave->checkBox(),12,12,0,1);
471 470
472 KPrefsWidRadios *destinationGroup = 471 KPrefsWidRadios *destinationGroup =
473 addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination), 472 addWidRadios(i18n("New Events/Todos should"),&(KOPrefs::instance()->mDestination),
474 topFrame); 473 topFrame);
475 destinationGroup->addRadio(i18n("be added to the standard resource")); 474 destinationGroup->addRadio(i18n("be added to the standard resource"));
476 destinationGroup->addRadio(i18n("be asked which resource to use")); 475 destinationGroup->addRadio(i18n("be asked which resource to use"));
477 topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1); 476 topLayout->addMultiCellWidget(destinationGroup->groupBox(),13,13,0,1);
478 477
479 topLayout->setRowStretch(14,1); 478 topLayout->setRowStretch(14,1);
480 */ 479 */
481} 480}
482 481
483 482
484void KOPrefsDialog::setupTimeTab() 483void KOPrefsDialog::setupTimeTab()
485{ 484{
486 QFrame *topFrame = addPage(i18n("Time"),0,0); 485 QFrame *topFrame = addPage(i18n("Time"),0,0);
487 // DesktopIcon("clock",KIcon::SizeMedium)); 486 // DesktopIcon("clock",KIcon::SizeMedium));
488 487
489 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 488 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
490 topLayout->setSpacing(spacingHint()); 489 topLayout->setSpacing(spacingHint());
491 topLayout->setMargin(marginHint()); 490 topLayout->setMargin(marginHint());
492 491
493 QHBox *dummy = new QHBox(topFrame); 492 QHBox *dummy = new QHBox(topFrame);
494 KPrefsWidTime *dayBegins = 493 KPrefsWidTime *dayBegins =
495 addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), 494 addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
496 dummy); 495 dummy);
497 //topLayout->addWidget(dayBegins->label(),2,0); 496 //topLayout->addWidget(dayBegins->label(),2,0);
498 497
499 //topLayout->addWidget(dayBegins->spinBox(),2,1); 498 //topLayout->addWidget(dayBegins->spinBox(),2,1);
500 topLayout->addMultiCellWidget(dummy,0,0,0,1); 499 topLayout->addMultiCellWidget(dummy,0,0,0,1);
501 500
502 topLayout->addWidget(new QLabel(i18n("Default appointment time:"), 501 topLayout->addWidget(new QLabel(i18n("Default appointment time:"),
503 topFrame),1,0); 502 topFrame),1,0);
504 mStartTimeSpin = new QSpinBox(0,23,1,topFrame); 503 mStartTimeSpin = new QSpinBox(0,23,1,topFrame);
505 mStartTimeSpin->setSuffix(":00"); 504 mStartTimeSpin->setSuffix(":00");
506 topLayout->addWidget(mStartTimeSpin,1,1); 505 topLayout->addWidget(mStartTimeSpin,1,1);
507 506
508 topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"), 507 topLayout->addWidget(new QLabel(i18n("Def. duration of new app.:"),
509 topFrame),2,0); 508 topFrame),2,0);
510 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame); 509 mDefaultDurationSpin = new QSpinBox(0,23,1,topFrame);
511 mDefaultDurationSpin->setSuffix(":00"); 510 mDefaultDurationSpin->setSuffix(":00");
512 topLayout->addWidget(mDefaultDurationSpin,2,1); 511 topLayout->addWidget(mDefaultDurationSpin,2,1);
513 512
514 QStringList alarmList; 513 QStringList alarmList;
515 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes") 514 alarmList << i18n("1 minute") << i18n("5 minutes") << i18n("10 minutes")
516 << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ; 515 << i18n("15 minutes") << i18n("30 minutes")<< i18n("1 hour")<< i18n("3 hours") << i18n("24 hours") ;
517 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame), 516 topLayout->addWidget(new QLabel(i18n("Default alarm time:"),topFrame),
518 3,0); 517 3,0);
519 mAlarmTimeCombo = new QComboBox(topFrame); 518 mAlarmTimeCombo = new QComboBox(topFrame);
520 mAlarmTimeCombo->insertStringList(alarmList); 519 mAlarmTimeCombo->insertStringList(alarmList);
521 topLayout->addWidget(mAlarmTimeCombo,3,1); 520 topLayout->addWidget(mAlarmTimeCombo,3,1);
522 521
523 522
524 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal, 523 QGroupBox *workingHoursGroup = new QGroupBox(1,Horizontal,
525 i18n("Working Hours"), 524 i18n("Working Hours"),
526 topFrame); 525 topFrame);
527 topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1); 526 topLayout->addMultiCellWidget(workingHoursGroup,4,4,0,1);
528 workingHoursGroup->layout()->setSpacing( 0 ); 527 workingHoursGroup->layout()->setSpacing( 0 );
529 workingHoursGroup->layout()->setMargin( 4 ); 528 workingHoursGroup->layout()->setMargin( 4 );
530 QHBox *workStartBox = new QHBox(workingHoursGroup); 529 QHBox *workStartBox = new QHBox(workingHoursGroup);
531 // workStartBox->setMargin( 0 ); 530 // workStartBox->setMargin( 0 );
532 addWidTime(i18n("Daily starting hour:"), 531 addWidTime(i18n("Daily starting hour:"),
533 &(KOPrefs::instance()->mWorkingHoursStart),workStartBox); 532 &(KOPrefs::instance()->mWorkingHoursStart),workStartBox);
534 533
535 QHBox *workEndBox = new QHBox(workingHoursGroup); 534 QHBox *workEndBox = new QHBox(workingHoursGroup);
536 //workEndBox->setMargin( 0 ); 535 //workEndBox->setMargin( 0 );
537 addWidTime(i18n("Daily ending hour:"), 536 addWidTime(i18n("Daily ending hour:"),
538 &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox); 537 &(KOPrefs::instance()->mWorkingHoursEnd),workEndBox);
539 QVBox *excludeBox = new QVBox(workingHoursGroup); 538 QVBox *excludeBox = new QVBox(workingHoursGroup);
540 //excludeBox->setMargin( 0 ); 539 //excludeBox->setMargin( 0 );
541 addWidBool(i18n("Exclude holidays"), 540 addWidBool(i18n("Exclude holidays"),
542 &(KOPrefs::instance()->mExcludeHolidays),excludeBox); 541 &(KOPrefs::instance()->mExcludeHolidays),excludeBox);
543 542
544 addWidBool(i18n("Exclude Saturdays"), 543 addWidBool(i18n("Exclude Saturdays"),
545 &(KOPrefs::instance()->mExcludeSaturdays),excludeBox); 544 &(KOPrefs::instance()->mExcludeSaturdays),excludeBox);
546 545
547// KPrefsWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"), 546// KPrefsWidBool *marcusBainsShowSeconds = addWidBool(i18n("Show seconds on Marcus Bains line"),
548 // &(KOPrefs::instance()->mMarcusBainsShowSeconds), 547 // &(KOPrefs::instance()->mMarcusBainsShowSeconds),
549 // topFrame); 548 // topFrame);
550// topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0); 549// topLayout->addWidget(marcusBainsShowSeconds->checkBox(),5,0);
551 550
552 // topLayout->setRowStretch(6,1); 551 // topLayout->setRowStretch(6,1);
553} 552}
554 553
555 554
556void KOPrefsDialog::setupViewsTab() 555void KOPrefsDialog::setupViewsTab()
557{ 556{
558 557
559 QFrame *topFrame = addPage(i18n("Views"),0,0); 558 QFrame *topFrame = addPage(i18n("Views"),0,0);
560 // DesktopIcon("viewmag",KIcon::SizeMedium)); 559 // DesktopIcon("viewmag",KIcon::SizeMedium));
561 560
562 QGridLayout *topLayout = new QGridLayout(topFrame,6,1); 561 QGridLayout *topLayout = new QGridLayout(topFrame,6,1);
563 topLayout->setSpacing(spacingHint()); 562 topLayout->setSpacing(spacingHint());
564 topLayout->setMargin(marginHint()); 563 topLayout->setMargin(marginHint());
565 564
566// QBoxLayout *dayBeginsLayout = new QHBoxLayout; 565// QBoxLayout *dayBeginsLayout = new QHBoxLayout;
567// topLayout->addLayout(dayBeginsLayout,0,0); 566// topLayout->addLayout(dayBeginsLayout,0,0);
568 567
569// KPrefsWidTime *dayBegins = 568// KPrefsWidTime *dayBegins =
570// addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins), 569// addWidTime(i18n("Day begins at:"),&(KOPrefs::instance()->mDayBegins),
571// topFrame); 570// topFrame);
572// dayBeginsLayout->addWidget(dayBegins->label()); 571// dayBeginsLayout->addWidget(dayBegins->label());
573// dayBeginsLayout->addStretch(1); 572// dayBeginsLayout->addStretch(1);
574// dayBeginsLayout->addWidget(dayBegins->spinBox()); 573// dayBeginsLayout->addWidget(dayBegins->spinBox());
575 574
576// QBoxLayout *nextDaysLayout = new QHBoxLayout; 575// QBoxLayout *nextDaysLayout = new QHBoxLayout;
577// topLayout->addLayout(nextDaysLayout,1,0); 576// topLayout->addLayout(nextDaysLayout,1,0);
578// nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame)); 577// nextDaysLayout->addWidget(new QLabel(i18n("Days to show in Next-X-Days view:"),topFrame));
579// mNextXDaysSpin = new QSpinBox(2,14,1,topFrame); 578// mNextXDaysSpin = new QSpinBox(2,14,1,topFrame);
580// nextDaysLayout->addStretch(1); 579// nextDaysLayout->addStretch(1);
581// nextDaysLayout->addWidget(mNextXDaysSpin); 580// nextDaysLayout->addWidget(mNextXDaysSpin);
582 581
583 582
584 int ii = 0; 583 int ii = 0;
585 KPrefsWidBool *dummy = 584 KPrefsWidBool *dummy =
586 addWidBool(i18n("Edit item on doubleclick (if not, show)"), 585 addWidBool(i18n("Edit item on doubleclick (if not, show)"),
587 &(KOPrefs::instance()->mEditOnDoubleClick),topFrame); 586 &(KOPrefs::instance()->mEditOnDoubleClick),topFrame);
588 topLayout->addWidget(dummy->checkBox(),ii++,0); 587 topLayout->addWidget(dummy->checkBox(),ii++,0);
589 588
590 dummy = 589 dummy =
591 addWidBool(i18n("Highlight current day in agenda"), 590 addWidBool(i18n("Highlight current day in agenda"),
592 &(KOPrefs::instance()->mHighlightCurrentDay),topFrame); 591 &(KOPrefs::instance()->mHighlightCurrentDay),topFrame);
593 topLayout->addWidget(dummy->checkBox(),ii++,0); 592 topLayout->addWidget(dummy->checkBox(),ii++,0);
594 593
595 dummy = 594 dummy =
596 addWidBool(i18n("Use light color for highlight current day"), 595 addWidBool(i18n("Use light color for highlight current day"),
597 &(KOPrefs::instance()->mUseHighlightLightColor),topFrame); 596 &(KOPrefs::instance()->mUseHighlightLightColor),topFrame);
598 topLayout->addWidget(dummy->checkBox(),ii++,0); 597 topLayout->addWidget(dummy->checkBox(),ii++,0);
599 598
600 KPrefsWidBool *dailyRecur = 599 KPrefsWidBool *dailyRecur =
601 addWidBool(i18n("Show events that recur daily in date nav."), 600 addWidBool(i18n("Show events that recur daily in date nav."),
602 &(KOPrefs::instance()->mDailyRecur),topFrame); 601 &(KOPrefs::instance()->mDailyRecur),topFrame);
603 topLayout->addWidget(dailyRecur->checkBox(),ii++,0); 602 topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
604 603
605 KPrefsWidBool *weeklyRecur = 604 KPrefsWidBool *weeklyRecur =
606 addWidBool(i18n("Show ev. that recur weekly in date nav."), 605 addWidBool(i18n("Show ev. that recur weekly in date nav."),
607 &(KOPrefs::instance()->mWeeklyRecur),topFrame); 606 &(KOPrefs::instance()->mWeeklyRecur),topFrame);
608 topLayout->addWidget(weeklyRecur->checkBox(),ii++,0); 607 topLayout->addWidget(weeklyRecur->checkBox(),ii++,0);
609 if ( QApplication::desktop()->width() > 640 ) { 608 if ( QApplication::desktop()->width() > 640 ) {
610 609
611 KPrefsWidBool *enableToolTips = 610 KPrefsWidBool *enableToolTips =
612 addWidBool(i18n("Enable tooltips displaying summary of ev."), 611 addWidBool(i18n("Enable tooltips displaying summary of ev."),
613 &(KOPrefs::instance()->mEnableToolTips),topFrame); 612 &(KOPrefs::instance()->mEnableToolTips),topFrame);
614 topLayout->addWidget(enableToolTips->checkBox(),ii++,0); 613 topLayout->addWidget(enableToolTips->checkBox(),ii++,0);
615 614
616 } 615 }
617 KPrefsWidBool *passwdk = 616 KPrefsWidBool *passwdk =
618 addWidBool(i18n("Show parent To-Do's in What's Next view"), 617 addWidBool(i18n("Show parent To-Do's in What's Next view"),
619 &(KOPrefs::instance()->mWNViewShowsParents),topFrame); 618 &(KOPrefs::instance()->mWNViewShowsParents),topFrame);
620 topLayout->addWidget(passwdk->checkBox(), ii++,0); 619 topLayout->addWidget(passwdk->checkBox(), ii++,0);
621 620
622 passwdk = 621 passwdk =
623 addWidBool(i18n("Show location in What's Next view"), 622 addWidBool(i18n("Show location in What's Next view"),
624 &(KOPrefs::instance()->mWNViewShowLocation),topFrame); 623 &(KOPrefs::instance()->mWNViewShowLocation),topFrame);
625 topLayout->addWidget(passwdk->checkBox(), ii++,0); 624 topLayout->addWidget(passwdk->checkBox(), ii++,0);
626 625
627 passwdk = 626 passwdk =
628 addWidBool(i18n("Show Sync Events in WN/Agenda view"), 627 addWidBool(i18n("Show Sync Events in WN/Agenda view"),
629 &(KOPrefs::instance()->mShowSyncEvents),topFrame); 628 &(KOPrefs::instance()->mShowSyncEvents),topFrame);
630 topLayout->addWidget(passwdk->checkBox(), ii++,0); 629 topLayout->addWidget(passwdk->checkBox(), ii++,0);
631 630
632 631
633 KPrefsWidBool *marcusBainsEnabled = 632 KPrefsWidBool *marcusBainsEnabled =
634 addWidBool(i18n("Show Marcus Bains line"), 633 addWidBool(i18n("Show Marcus Bains line"),
635 &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame); 634 &(KOPrefs::instance()->mMarcusBainsEnabled),topFrame);
636 topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0); 635 topLayout->addWidget(marcusBainsEnabled->checkBox(),ii++,0);
637 636
638 637
639 // topLayout->addWidget(hourSizeGroup,ii++,0); 638 // topLayout->addWidget(hourSizeGroup,ii++,0);
640 // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0); 639 // topLayout->addMultiCellWidget(hourSizeGroup,ii,ii,0,0);
641 //topLayout->setRowStretch(11,1); 640 //topLayout->setRowStretch(11,1);
642 641
643 642
644 643
645 644
646 645
647 646
648 topFrame = addPage(i18n("ViewChange"),0,0); 647 topFrame = addPage(i18n("ViewChange"),0,0);
649 // DesktopIcon("viewmag",KIcon::SizeMedium)); 648 // DesktopIcon("viewmag",KIcon::SizeMedium));
650 649
651 topLayout = new QGridLayout(topFrame,6,1); 650 topLayout = new QGridLayout(topFrame,6,1);
652 topLayout->setSpacing(spacingHint()); 651 topLayout->setSpacing(spacingHint());
653 topLayout->setMargin(marginHint()); 652 topLayout->setMargin(marginHint());
654 ii = 0; 653 ii = 0;
655 654
656 655
657 dummy = 656 dummy =
658 addWidBool(i18n("Hold fullscreen on view change"), 657 addWidBool(i18n("Hold fullscreen on view change"),
659 &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame); 658 &(KOPrefs::instance()->mViewChangeHoldFullscreen),topFrame);
660 topLayout->addWidget(dummy->checkBox(),ii++,0); 659 topLayout->addWidget(dummy->checkBox(),ii++,0);
661 660
662 dummy = 661 dummy =
663 addWidBool(i18n("Hold non-fullscreen on view change"), 662 addWidBool(i18n("Hold non-fullscreen on view change"),
664 &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame); 663 &(KOPrefs::instance()->mViewChangeHoldNonFullscreen),topFrame);
665 topLayout->addWidget(dummy->checkBox(),ii++,0); 664 topLayout->addWidget(dummy->checkBox(),ii++,0);
666 665
667 666
668 KPrefsWidBool *fullViewTodo = 667 KPrefsWidBool *fullViewTodo =
669 addWidBool(i18n("Event list view uses full window"), 668 addWidBool(i18n("Event list view uses full window"),
670 &(KOPrefs::instance()->mFullViewTodo),topFrame); 669 &(KOPrefs::instance()->mFullViewTodo),topFrame);
671 topLayout->addWidget(fullViewTodo->checkBox(),ii++,0); 670 topLayout->addWidget(fullViewTodo->checkBox(),ii++,0);
672 671
673 KPrefsWidBool *fullViewMonth = 672 KPrefsWidBool *fullViewMonth =
674 addWidBool(i18n("Next days view uses full window"), 673 addWidBool(i18n("Next days view uses full window"),
675 &(KOPrefs::instance()->mFullViewMonth),topFrame); 674 &(KOPrefs::instance()->mFullViewMonth),topFrame);
676 topLayout->addWidget(fullViewMonth->checkBox(),ii++,0); 675 topLayout->addWidget(fullViewMonth->checkBox(),ii++,0);
677 676
678 dummy = 677 dummy =
679 addWidBool(i18n("Set agenda to DayBeginsAt on change"), 678 addWidBool(i18n("Set agenda to DayBeginsAt on change"),
680 &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame); 679 &(KOPrefs::instance()->mSetTimeToDayStartAt),topFrame);
681 topLayout->addWidget(dummy->checkBox(),ii++,0); 680 topLayout->addWidget(dummy->checkBox(),ii++,0);
682 681
683 dummy = 682 dummy =
684 addWidBool(i18n("Set agenda to current time on change"), 683 addWidBool(i18n("Set agenda to current time on change"),
685 &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame); 684 &(KOPrefs::instance()->mCenterOnCurrentTime),topFrame);
686 topLayout->addWidget(dummy->checkBox(),ii++,0); 685 topLayout->addWidget(dummy->checkBox(),ii++,0);
687 686
688 dummy = 687 dummy =
689 addWidBool(i18n("Listview uses monthly timespan"), 688 addWidBool(i18n("Listview uses monthly timespan"),
690 &(KOPrefs::instance()->mListViewMonthTimespan),topFrame); 689 &(KOPrefs::instance()->mListViewMonthTimespan),topFrame);
691 topLayout->addWidget(dummy->checkBox(),ii++,0); 690 topLayout->addWidget(dummy->checkBox(),ii++,0);
692 dummy = 691 dummy =
693 addWidBool(i18n("Highlight selection in Time Edit"), 692 addWidBool(i18n("Highlight selection in Time Edit"),
694 &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame); 693 &(KOPrefs::instance()->mHightlightDateTimeEdit),topFrame);
695 topLayout->addWidget( dummy->checkBox(), ii++,0); 694 topLayout->addWidget( dummy->checkBox(), ii++,0);
696 695
697 696
698 697
699 698
700 699
701 topFrame = addPage(i18n("Month View"),0,0); 700 topFrame = addPage(i18n("Month View"),0,0);
702 // DesktopIcon("viewmag",KIcon::SizeMedium)); 701 // DesktopIcon("viewmag",KIcon::SizeMedium));
703 702
704 topLayout = new QGridLayout(topFrame,5,1); 703 topLayout = new QGridLayout(topFrame,5,1);
705 topLayout->setSpacing(spacingHint()); 704 topLayout->setSpacing(spacingHint());
706 topLayout->setMargin(marginHint()); 705 topLayout->setMargin(marginHint());
707 ii = 0; 706 ii = 0;
708 QLabel *lab; 707 QLabel *lab;
709 QHBox *habo = new QHBox( topFrame ); 708 QHBox *habo = new QHBox( topFrame );
710 if ( QApplication::desktop()->width() < 320 ) { 709 if ( QApplication::desktop()->width() < 320 ) {
711 lab = new QLabel ( i18n("Show events that recur "), topFrame ); 710 lab = new QLabel ( i18n("Show events that recur "), topFrame );
712 topLayout->addMultiCellWidget(lab,ii, ii,0,1); 711 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
713 ii++; 712 ii++;
714 713
715 } else { 714 } else {
716 new QLabel ( i18n("Show events that recur "), habo ); 715 new QLabel ( i18n("Show events that recur "), habo );
717 716
718 } 717 }
719 dailyRecur = 718 dailyRecur =
720 addWidBool(i18n("daily"), 719 addWidBool(i18n("daily"),
721 &(KOPrefs::instance()->mMonthDailyRecur),habo); 720 &(KOPrefs::instance()->mMonthDailyRecur),habo);
722 // topLayout->addWidget(dailyRecur->checkBox(),ii++,0); 721 // topLayout->addWidget(dailyRecur->checkBox(),ii++,0);
723 722
724 weeklyRecur = 723 weeklyRecur =
725 addWidBool(i18n("weekly"), 724 addWidBool(i18n("weekly"),
726 &(KOPrefs::instance()->mMonthWeeklyRecur),habo); 725 &(KOPrefs::instance()->mMonthWeeklyRecur),habo);
727 topLayout->addMultiCellWidget(habo,ii, ii,0,1); 726 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
728 ii++; 727 ii++;
729 728
730 729
731 habo = new QHBox( topFrame ); 730 habo = new QHBox( topFrame );
732 if ( QApplication::desktop()->width() < 320 ) { 731 if ( QApplication::desktop()->width() < 320 ) {
733 lab = new QLabel (i18n("Show in every cell ") , topFrame ); 732 lab = new QLabel (i18n("Show in every cell ") , topFrame );
734 topLayout->addMultiCellWidget(lab,ii, ii,0,1); 733 topLayout->addMultiCellWidget(lab,ii, ii,0,1);
735 ii++; 734 ii++;
736 735
737 } else { 736 } else {
738 new QLabel ( i18n("Show in every cell "), habo ); 737 new QLabel ( i18n("Show in every cell "), habo );
739 } 738 }
740 weeklyRecur = 739 weeklyRecur =
741 addWidBool(i18n("short month"), 740 addWidBool(i18n("short month"),
742 &(KOPrefs::instance()->mMonthShowShort),habo); 741 &(KOPrefs::instance()->mMonthShowShort),habo);
743 weeklyRecur = 742 weeklyRecur =
744 addWidBool(i18n("icons"), 743 addWidBool(i18n("icons"),
745 &(KOPrefs::instance()->mMonthShowIcons),habo); 744 &(KOPrefs::instance()->mMonthShowIcons),habo);
746 745
747 topLayout->addMultiCellWidget(habo,ii, ii,0,1); 746 topLayout->addMultiCellWidget(habo,ii, ii,0,1);
748 ii++; 747 ii++;
749#ifdef DESKTOP_VERSION 748#ifdef DESKTOP_VERSION
750 KPrefsWidBool *enableMonthScroll = 749 KPrefsWidBool *enableMonthScroll =
751 addWidBool(i18n("Enable scrollbars in month view cells"), 750 addWidBool(i18n("Enable scrollbars in month view cells"),
752 &(KOPrefs::instance()->mEnableMonthScroll),topFrame); 751 &(KOPrefs::instance()->mEnableMonthScroll),topFrame);
753 topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0); 752 topLayout->addWidget(enableMonthScroll->checkBox(),ii++,0);
754#endif 753#endif
755 754
756 dummy = 755 dummy =
757 addWidBool(i18n("Show Sat/Sun together"), 756 addWidBool(i18n("Show Sat/Sun together"),
758 &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame); 757 &(KOPrefs::instance()->mMonthViewSatSunTog),topFrame);
759 topLayout->addWidget(dummy->checkBox(),ii++,0); 758 topLayout->addWidget(dummy->checkBox(),ii++,0);
760 759
761 KPrefsWidBool *coloredCategoriesInMonthView = 760 KPrefsWidBool *coloredCategoriesInMonthView =
762 addWidBool(i18n("Month view uses category colors"), 761 addWidBool(i18n("Month view uses category colors"),
763 &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame); 762 &(KOPrefs::instance()->mMonthViewUsesCategoryColor),topFrame);
764 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); 763 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
765 764
766 dummy = 765 dummy =
767 addWidBool(i18n("Categorie colors are applied to text"), 766 addWidBool(i18n("Categorie colors are applied to text"),
768 &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame); 767 &(KOPrefs::instance()->mMonthViewUsesForegroundColor),topFrame);
769 topLayout->addWidget(dummy->checkBox(),ii++,0); 768 topLayout->addWidget(dummy->checkBox(),ii++,0);
770 coloredCategoriesInMonthView = 769 coloredCategoriesInMonthView =
771 addWidBool(i18n("Month view uses day colors"), 770 addWidBool(i18n("Month view uses day colors"),
772 &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame); 771 &(KOPrefs::instance()->mMonthViewUsesDayColors),topFrame);
773 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0); 772 topLayout->addWidget(coloredCategoriesInMonthView->checkBox(),ii++,0);
774 773
775 KPrefsWidColor *holidayColor = 774 KPrefsWidColor *holidayColor =
776 addWidColor(i18n("Day color odd months"), 775 addWidColor(i18n("Day color odd months"),
777 &(KOPrefs::instance()->mMonthViewOddColor),topFrame); 776 &(KOPrefs::instance()->mMonthViewOddColor),topFrame);
778 topLayout->addWidget(holidayColor->label(),ii,0); 777 topLayout->addWidget(holidayColor->label(),ii,0);
779 topLayout->addWidget(holidayColor->button(),ii++,1); 778 topLayout->addWidget(holidayColor->button(),ii++,1);
780 779
781 holidayColor = 780 holidayColor =
782 addWidColor(i18n("Day color even months"), 781 addWidColor(i18n("Day color even months"),
783 &(KOPrefs::instance()->mMonthViewEvenColor),topFrame); 782 &(KOPrefs::instance()->mMonthViewEvenColor),topFrame);
784 topLayout->addWidget(holidayColor->label(),ii,0); 783 topLayout->addWidget(holidayColor->label(),ii,0);
785 topLayout->addWidget(holidayColor->button(),ii++,1); 784 topLayout->addWidget(holidayColor->button(),ii++,1);
786 785
787 786
788 holidayColor = 787 holidayColor =
789 addWidColor(i18n("Color for Sundays + category \"Holiday\""), 788 addWidColor(i18n("Color for Sundays + category \"Holiday\""),
790 &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame); 789 &(KOPrefs::instance()->mMonthViewHolidayColor),topFrame);
791 topLayout->addWidget(holidayColor->label(),ii,0); 790 topLayout->addWidget(holidayColor->label(),ii,0);
792 topLayout->addWidget(holidayColor->button(),ii++,1); 791 topLayout->addWidget(holidayColor->button(),ii++,1);
793 792
794 // *********************** Todo View 793 // *********************** Todo View
795 794
796 topFrame = addPage(i18n("Todo View"),0,0); 795 topFrame = addPage(i18n("Todo View"),0,0);
797 // DesktopIcon("viewmag",KIcon::SizeMedium)); 796 // DesktopIcon("viewmag",KIcon::SizeMedium));
798 797
799 topLayout = new QGridLayout(topFrame,4,1); 798 topLayout = new QGridLayout(topFrame,4,1);
800 topLayout->setSpacing(spacingHint()); 799 topLayout->setSpacing(spacingHint());
801 topLayout->setMargin(marginHint()); 800 topLayout->setMargin(marginHint());
802 ii = 0; 801 ii = 0;
803 802
804 KPrefsWidBool *showCompletedTodo = 803 KPrefsWidBool *showCompletedTodo =
805 addWidBool(i18n("To-do view shows completed Todos"), 804 addWidBool(i18n("To-do view shows completed Todos"),
806 &(KOPrefs::instance()->mShowCompletedTodo),topFrame); 805 &(KOPrefs::instance()->mShowCompletedTodo),topFrame);
807 topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0); 806 topLayout->addWidget(showCompletedTodo->checkBox(),ii++,0);
808 dummy = 807 dummy =
809 addWidBool(i18n("To-do view shows complete as 'xx %'"), 808 addWidBool(i18n("To-do view shows complete as 'xx %'"),
810 &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame); 809 &(KOPrefs::instance()->mTodoViewShowsPercentage),topFrame);
811 topLayout->addWidget(dummy->checkBox(),ii++,0); 810 topLayout->addWidget(dummy->checkBox(),ii++,0);
812 811
813 dummy = 812 dummy =
814 addWidBool(i18n("Small To-do view uses smaller font"), 813 addWidBool(i18n("Small To-do view uses smaller font"),
815 &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame); 814 &(KOPrefs::instance()->mTodoViewUsesSmallFont),topFrame);
816 topLayout->addWidget(dummy->checkBox(),ii++,0); 815 topLayout->addWidget(dummy->checkBox(),ii++,0);
817 816
818 817
819 818
820 dummy = 819 dummy =
821 addWidBool(i18n("Todo view uses category colors"), 820 addWidBool(i18n("Todo view uses category colors"),
822 &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame); 821 &(KOPrefs::instance()->mTodoViewUsesCatColors),topFrame);
823 topLayout->addWidget(dummy->checkBox(),ii++,0); 822 topLayout->addWidget(dummy->checkBox(),ii++,0);
824 823
825 824
826 QWidget* wid = new QWidget( topFrame ); 825 QWidget* wid = new QWidget( topFrame );
827 // Todo due today color 826 // Todo due today color
828 KPrefsWidColor *todoDueTodayColor = 827 KPrefsWidColor *todoDueTodayColor =
829 addWidColor(i18n("Todo due today color:"), 828 addWidColor(i18n("Todo due today color:"),
830 &(KOPrefs::instance()->mTodoDueTodayColor),wid); 829 &(KOPrefs::instance()->mTodoDueTodayColor),wid);
831 QHBoxLayout *widLayout = new QHBoxLayout(wid); 830 QHBoxLayout *widLayout = new QHBoxLayout(wid);
832 widLayout->addWidget( todoDueTodayColor->label() ); 831 widLayout->addWidget( todoDueTodayColor->label() );
833 widLayout->addWidget( todoDueTodayColor->button() ); 832 widLayout->addWidget( todoDueTodayColor->button() );
834 topLayout->addWidget(wid,ii++,0); 833 topLayout->addWidget(wid,ii++,0);
835 //topLayout->addWidget(todoDueTodayColor->button(),ii++,1); 834 //topLayout->addWidget(todoDueTodayColor->button(),ii++,1);
836 835
837 // Todo overdue color 836 // Todo overdue color
838 wid = new QWidget( topFrame ); 837 wid = new QWidget( topFrame );
839 widLayout = new QHBoxLayout(wid); 838 widLayout = new QHBoxLayout(wid);
840 KPrefsWidColor *todoOverdueColor = 839 KPrefsWidColor *todoOverdueColor =
841 addWidColor(i18n("Todo overdue color:"), 840 addWidColor(i18n("Todo overdue color:"),
842 &(KOPrefs::instance()->mTodoOverdueColor),wid); 841 &(KOPrefs::instance()->mTodoOverdueColor),wid);
843 widLayout->addWidget(todoOverdueColor->label()); 842 widLayout->addWidget(todoOverdueColor->label());
844 widLayout->addWidget(todoOverdueColor->button()); 843 widLayout->addWidget(todoOverdueColor->button());
845 topLayout->addWidget(wid,ii++,0); 844 topLayout->addWidget(wid,ii++,0);
846 845
847 dummy = 846 dummy =
848 addWidBool(i18n("Colors are applied to text"), 847 addWidBool(i18n("Colors are applied to text"),
849 &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame); 848 &(KOPrefs::instance()->mTodoViewUsesForegroundColor),topFrame);
850 topLayout->addWidget(dummy->checkBox(),ii++,0); 849 topLayout->addWidget(dummy->checkBox(),ii++,0);
851 850
852 dummy = 851 dummy =
853 addWidBool(i18n("Allday Agenda view shows todos"), 852 addWidBool(i18n("Allday Agenda view shows todos"),
854 &(KOPrefs::instance()->mShowTodoInAgenda),topFrame); 853 &(KOPrefs::instance()->mShowTodoInAgenda),topFrame);
855 topLayout->addWidget(dummy->checkBox(),ii++,0); 854 topLayout->addWidget(dummy->checkBox(),ii++,0);
856 855
857 856
858 857
859 858
860 topFrame = addPage(i18n("Alarm"),0,0); 859 topFrame = addPage(i18n("Alarm"),0,0);
861 // DesktopIcon("viewmag",KIcon::SizeMedium)); 860 // DesktopIcon("viewmag",KIcon::SizeMedium));
862 861
863 topLayout = new QGridLayout(topFrame,2,1); 862 topLayout = new QGridLayout(topFrame,2,1);
864 topLayout->setSpacing(spacingHint()); 863 topLayout->setSpacing(spacingHint());
865 topLayout->setMargin(marginHint()); 864 topLayout->setMargin(marginHint());
866 int iii = 0; 865 int iii = 0;
867 866
868 dummy = 867 dummy =
869 addWidBool(i18n("Use internal alarm notification"), 868 addWidBool(i18n("Use internal alarm notification"),
870 &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame); 869 &(KOPrefs::instance()->mUseInternalAlarmNotification),topFrame);
871 topLayout->addWidget(dummy->checkBox(),iii++,0); 870 topLayout->addWidget(dummy->checkBox(),iii++,0);
872 lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame); 871 lab = new QLabel( i18n("Note: KO/Pi must be running to notify you about an alarm. Recommended for use on Zaurus: Disable this option and install KO/Pi alarm applet.\n"), topFrame);
873 872
874 topLayout->addWidget(lab ,iii++,0); 873 topLayout->addWidget(lab ,iii++,0);
875#ifndef DESKTOP_VERSION 874#ifndef DESKTOP_VERSION
876 lab->setAlignment( AlignLeft|WordBreak|AlignTop); 875 lab->setAlignment( AlignLeft|WordBreak|AlignTop);
877#else 876#else
878 lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 877 lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
879 lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); 878 lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
880#endif 879#endif
881 880
882 QHBox* dummyBox = new QHBox(topFrame); 881 QHBox* dummyBox = new QHBox(topFrame);
883 new QLabel(i18n("Play beeps count:"),dummyBox); 882 new QLabel(i18n("Play beeps count:"),dummyBox);
884 mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox); 883 mAlarmPlayBeeps = new QSpinBox(0,500,1,dummyBox);
885 topLayout->addWidget(dummyBox,iii++,0); 884 topLayout->addWidget(dummyBox,iii++,0);
886 885
887 dummyBox = new QHBox(topFrame); 886 dummyBox = new QHBox(topFrame);
888 new QLabel(i18n("Beeps interval in sec:"),dummyBox); 887 new QLabel(i18n("Beeps interval in sec:"),dummyBox);
889 mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox); 888 mAlarmBeepInterval = new QSpinBox(1,600,1,dummyBox);
890 topLayout->addWidget(dummyBox,iii++,0); 889 topLayout->addWidget(dummyBox,iii++,0);
891 890
892 dummyBox = new QHBox(topFrame); 891 dummyBox = new QHBox(topFrame);
893 new QLabel(i18n("Default suspend time in min:"),dummyBox); 892 new QLabel(i18n("Default suspend time in min:"),dummyBox);
894 mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox); 893 mAlarmSuspendTime = new QSpinBox(1,600,1,dummyBox);
895 topLayout->addWidget(dummyBox,iii++,0); 894 topLayout->addWidget(dummyBox,iii++,0);
896 895
897 dummyBox = new QHBox(topFrame); 896 dummyBox = new QHBox(topFrame);
898 new QLabel(i18n("Auto suspend count:"),dummyBox); 897 new QLabel(i18n("Auto suspend count:"),dummyBox);
899 mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox); 898 mAlarmSuspendCount = new QSpinBox(0,60,1,dummyBox);
900 topLayout->addWidget(dummyBox,iii++,0); 899 topLayout->addWidget(dummyBox,iii++,0);
901 900
902 901
903 902
904 903
905 904
906 905
907 906
908 QHBox* hbo = new QHBox ( topFrame ); 907 QHBox* hbo = new QHBox ( topFrame );
909 mDefaultAlarmFile = new QLineEdit(hbo); 908 mDefaultAlarmFile = new QLineEdit(hbo);
910 QPushButton * loadTemplate = new QPushButton(hbo); 909 QPushButton * loadTemplate = new QPushButton(hbo);
911 QPixmap icon; 910 QPixmap icon;
912 if ( QApplication::desktop()->width() < 321 ) 911 if ( QApplication::desktop()->width() < 321 )
913 icon = SmallIcon("fileimport16"); 912 icon = SmallIcon("fileimport16");
914 else 913 else
915 icon = SmallIcon("fileimport"); 914 icon = SmallIcon("fileimport");
916 loadTemplate->setIconSet (icon ) ; 915 loadTemplate->setIconSet (icon ) ;
917 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) ); 916 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( selectSoundFile() ) );
918 int size = loadTemplate->sizeHint().height(); 917 int size = loadTemplate->sizeHint().height();
919 loadTemplate->setFixedSize( size, size ); 918 loadTemplate->setFixedSize( size, size );
920 //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame); 919 //lab = new QLabel( i18n("This setting is useless for 5500 user!"), topFrame);
921 // topLayout->addWidget(lab ,iii++,0); 920 // topLayout->addWidget(lab ,iii++,0);
922 lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame); 921 lab = new QLabel( i18n("Alarm *.wav file for newly created alarm:"), topFrame);
923 topLayout->addWidget(lab ,iii++,0); 922 topLayout->addWidget(lab ,iii++,0);
924 topLayout->addWidget(hbo,iii++,0); 923 topLayout->addWidget(hbo,iii++,0);
925 // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame); 924 // lab = new QLabel( i18n("Note: This does not mean, that for every alarm this file is replayed. This file here is associated with a newly created alarm."), topFrame);
926 925
927// topLayout->addWidget(lab ,iii++,0); 926// topLayout->addWidget(lab ,iii++,0);
928// #ifndef DESKTOP_VERSION 927// #ifndef DESKTOP_VERSION
929// lab->setAlignment( AlignLeft|WordBreak|AlignTop); 928// lab->setAlignment( AlignLeft|WordBreak|AlignTop);
930// #else 929// #else
931// lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 930// lab->setAlignment( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
932// lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) ); 931// lab->setSizePolicy( QSizePolicy( QSizePolicy::Ignored , QSizePolicy::Ignored,true) );
933// #endif 932// #endif
934 933
935 934
936} 935}
937 936
938void KOPrefsDialog::selectSoundFile() 937void KOPrefsDialog::selectSoundFile()
939{ 938{
940 QString fileName = mDefaultAlarmFile->text(); 939 QString fileName = mDefaultAlarmFile->text();
941 fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this ); 940 fileName = KFileDialog::getSaveFileName( mDefaultAlarmFile->text() , "Choose default alarm file", this );
942 if ( fileName.length() > 0 ) 941 if ( fileName.length() > 0 )
943 mDefaultAlarmFile->setText( fileName ); 942 mDefaultAlarmFile->setText( fileName );
944} 943}
945void KOPrefsDialog::setupFontsTab() 944void KOPrefsDialog::setupFontsTab()
946{ 945{
947 946
948 QFrame *topFrame = addPage(i18n("Fonts"),0,0); 947 QFrame *topFrame = addPage(i18n("Fonts"),0,0);
949 // DesktopIcon("fonts",KIcon::SizeMedium)); 948 // DesktopIcon("fonts",KIcon::SizeMedium));
950 949
951 QGridLayout *topLayout = new QGridLayout(topFrame,7,3); 950 QGridLayout *topLayout = new QGridLayout(topFrame,7,3);
952 topLayout->setSpacing(1); 951 topLayout->setSpacing(1);
953 topLayout->setMargin(3); 952 topLayout->setMargin(3);
954 KPrefsWidFont * tVFont; 953 KPrefsWidFont * tVFont;
955 int i = 0; 954 int i = 0;
956 KPrefsWidFont *timeLabelsFont = 955 KPrefsWidFont *timeLabelsFont =
957 addWidFont(i18n("23"),i18n("DateNavigator:(nr)"), 956 addWidFont(i18n("23"),i18n("DateNavigator:(nr)"),
958 &(KOPrefs::instance()->mDateNavigatorFont),topFrame); 957 &(KOPrefs::instance()->mDateNavigatorFont),topFrame);
959 topLayout->addWidget(timeLabelsFont->label(),i,0); 958 topLayout->addWidget(timeLabelsFont->label(),i,0);
960 topLayout->addWidget(timeLabelsFont->preview(),i,1); 959 topLayout->addWidget(timeLabelsFont->preview(),i,1);
961 topLayout->addWidget(timeLabelsFont->button(),i,2); 960 topLayout->addWidget(timeLabelsFont->button(),i,2);
962 ++i; 961 ++i;
963 962
964 963
965 timeLabelsFont = 964 timeLabelsFont =
966 addWidFont(i18n("Mon 15"),i18n("Date Labels:"), 965 addWidFont(i18n("Mon 15"),i18n("Date Labels:"),
967 &(KOPrefs::instance()->mTimeLabelsFont),topFrame); 966 &(KOPrefs::instance()->mTimeLabelsFont),topFrame);
968 topLayout->addWidget(timeLabelsFont->label(),i,0); 967 topLayout->addWidget(timeLabelsFont->label(),i,0);
969 topLayout->addWidget(timeLabelsFont->preview(),i,1); 968 topLayout->addWidget(timeLabelsFont->preview(),i,1);
970 topLayout->addWidget(timeLabelsFont->button(),i,2); 969 topLayout->addWidget(timeLabelsFont->button(),i,2);
971 ++i; 970 ++i;
972 971
973 KPrefsWidFont *timeBarFont = 972 KPrefsWidFont *timeBarFont =
974 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"), 973 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)),i18n("Time bar:"),
975 &(KOPrefs::instance()->mTimeBarFont),topFrame); 974 &(KOPrefs::instance()->mTimeBarFont),topFrame);
976 topLayout->addWidget(timeBarFont->label(),i,0); 975 topLayout->addWidget(timeBarFont->label(),i,0);
977 topLayout->addWidget(timeBarFont->preview(),i,1); 976 topLayout->addWidget(timeBarFont->preview(),i,1);
978 topLayout->addWidget(timeBarFont->button(),i,2); 977 topLayout->addWidget(timeBarFont->button(),i,2);
979 ++i; 978 ++i;
980 979
981 980
982 KPrefsWidFont *marcusBainsFont = 981 KPrefsWidFont *marcusBainsFont =
983 addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"), 982 addWidFont(KGlobal::locale()->formatTime(QTime(12,34,23)),i18n("M. Bains line:"),
984 &(KOPrefs::instance()->mMarcusBainsFont),topFrame); 983 &(KOPrefs::instance()->mMarcusBainsFont),topFrame);
985 topLayout->addWidget(marcusBainsFont->label(),i,0); 984 topLayout->addWidget(marcusBainsFont->label(),i,0);
986 topLayout->addWidget(marcusBainsFont->preview(),i,1); 985 topLayout->addWidget(marcusBainsFont->preview(),i,1);
987 topLayout->addWidget(marcusBainsFont->button(),i,2); 986 topLayout->addWidget(marcusBainsFont->button(),i,2);
988 ++i; 987 ++i;
989 988
990 tVFont = 989 tVFont =
991 addWidFont(i18n("Summary"),i18n("Event Viewer:"), 990 addWidFont(i18n("Summary"),i18n("Event Viewer:"),
992 &(KOPrefs::instance()->mEventViewFont),topFrame); 991 &(KOPrefs::instance()->mEventViewFont),topFrame);
993 topLayout->addWidget(tVFont->label(),i,0); 992 topLayout->addWidget(tVFont->label(),i,0);
994 topLayout->addWidget(tVFont->preview(),i,1); 993 topLayout->addWidget(tVFont->preview(),i,1);
995 topLayout->addWidget(tVFont->button(),i,2); 994 topLayout->addWidget(tVFont->button(),i,2);
996 ++i; 995 ++i;
997 996
998 997
999 998
1000 tVFont = 999 tVFont =
1001 addWidFont(i18n("Details"),i18n("EditorBox:"), 1000 addWidFont(i18n("Details"),i18n("EditorBox:"),
1002 &(KOPrefs::instance()->mEditBoxFont),topFrame); 1001 &(KOPrefs::instance()->mEditBoxFont),topFrame);
1003 topLayout->addWidget(tVFont->label(),i,0); 1002 topLayout->addWidget(tVFont->label(),i,0);
1004 topLayout->addWidget(tVFont->preview(),i,1); 1003 topLayout->addWidget(tVFont->preview(),i,1);
1005 topLayout->addWidget(tVFont->button(),i,2); 1004 topLayout->addWidget(tVFont->button(),i,2);
1006 ++i; 1005 ++i;
1007 1006
1008 1007
1009 1008
1010 topLayout->setColStretch(1,1); 1009 topLayout->setColStretch(1,1);
1011 topLayout->setRowStretch(4,1); 1010 topLayout->setRowStretch(4,1);
1012 1011
1013 1012
1014 i = 0; 1013 i = 0;
1015 topFrame = addPage(i18n("View Fonts"),0, 1014 topFrame = addPage(i18n("View Fonts"),0,
1016 DesktopIcon("fonts",KIcon::SizeMedium)); 1015 DesktopIcon("fonts",KIcon::SizeMedium));
1017 1016
1018 topLayout = new QGridLayout(topFrame,7,3); 1017 topLayout = new QGridLayout(topFrame,7,3);
1019 topLayout->setSpacing(1); 1018 topLayout->setSpacing(1);
1020 topLayout->setMargin(3); 1019 topLayout->setMargin(3);
1021 1020
1022 tVFont = 1021 tVFont =
1023 addWidFont(i18n("Configure KO"),i18n("What's Next View:"), 1022 addWidFont(i18n("Configure KO"),i18n("What's Next View:"),
1024 &(KOPrefs::instance()->mWhatsNextFont),topFrame); 1023 &(KOPrefs::instance()->mWhatsNextFont),topFrame);
1025 topLayout->addWidget(tVFont->label(),i,0); 1024 topLayout->addWidget(tVFont->label(),i,0);
1026 topLayout->addWidget(tVFont->preview(),i,1); 1025 topLayout->addWidget(tVFont->preview(),i,1);
1027 topLayout->addWidget(tVFont->button(),i,2); 1026 topLayout->addWidget(tVFont->button(),i,2);
1028 ++i; 1027 ++i;
1029 KPrefsWidFont *agendaViewFont = 1028 KPrefsWidFont *agendaViewFont =
1030 addWidFont(i18n("Event text"),i18n("Agenda view:"), 1029 addWidFont(i18n("Event text"),i18n("Agenda view:"),
1031 &(KOPrefs::instance()->mAgendaViewFont),topFrame); 1030 &(KOPrefs::instance()->mAgendaViewFont),topFrame);
1032 topLayout->addWidget(agendaViewFont->label(),i,0); 1031 topLayout->addWidget(agendaViewFont->label(),i,0);
1033 topLayout->addWidget(agendaViewFont->preview(),i,1); 1032 topLayout->addWidget(agendaViewFont->preview(),i,1);
1034 topLayout->addWidget(agendaViewFont->button(),i,2); 1033 topLayout->addWidget(agendaViewFont->button(),i,2);
1035 ++i; 1034 ++i;
1036 1035
1037 1036
1038 KPrefsWidFont *monthViewFont = 1037 KPrefsWidFont *monthViewFont =
1039 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"), 1038 addWidFont(KGlobal::locale()->formatTime(QTime(12,34)) + " " + i18n("Event"),
1040 i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame); 1039 i18n("Month view:"),&(KOPrefs::instance()->mMonthViewFont),topFrame);
1041 topLayout->addWidget(monthViewFont->label(),i,0); 1040 topLayout->addWidget(monthViewFont->label(),i,0);
1042 topLayout->addWidget(monthViewFont->preview(),i,1); 1041 topLayout->addWidget(monthViewFont->preview(),i,1);
1043 topLayout->addWidget(monthViewFont->button(),i,2); 1042 topLayout->addWidget(monthViewFont->button(),i,2);
1044 ++i; 1043 ++i;
1045 1044
1046 1045
1047 KPrefsWidFont *lVFont = 1046 KPrefsWidFont *lVFont =
1048 addWidFont(i18n("Event"),i18n("List View:"), 1047 addWidFont(i18n("Event"),i18n("List View:"),
1049 &(KOPrefs::instance()->mListViewFont),topFrame); 1048 &(KOPrefs::instance()->mListViewFont),topFrame);
1050 topLayout->addWidget(lVFont->label(),i,0); 1049 topLayout->addWidget(lVFont->label(),i,0);
1051 topLayout->addWidget(lVFont->preview(),i,1); 1050 topLayout->addWidget(lVFont->preview(),i,1);
1052 topLayout->addWidget(lVFont->button(),i,2); 1051 topLayout->addWidget(lVFont->button(),i,2);
1053 ++i; 1052 ++i;
1054 1053
1055 1054
1056 tVFont = 1055 tVFont =
1057 addWidFont(i18n("ToDo"),i18n("ToDoView:"), 1056 addWidFont(i18n("ToDo"),i18n("ToDoView:"),
1058 &(KOPrefs::instance()->mTodoViewFont),topFrame); 1057 &(KOPrefs::instance()->mTodoViewFont),topFrame);
1059 topLayout->addWidget(tVFont->label(),i,0); 1058 topLayout->addWidget(tVFont->label(),i,0);
1060 topLayout->addWidget(tVFont->preview(),i,1); 1059 topLayout->addWidget(tVFont->preview(),i,1);
1061 topLayout->addWidget(tVFont->button(),i,2); 1060 topLayout->addWidget(tVFont->button(),i,2);
1062 ++i; 1061 ++i;
1063 1062
1064 1063
1065 tVFont = 1064 tVFont =
1066 addWidFont(i18n("Today"),i18n("JournalView:"), 1065 addWidFont(i18n("Today"),i18n("JournalView:"),
1067 &(KOPrefs::instance()->mJornalViewFont),topFrame); 1066 &(KOPrefs::instance()->mJornalViewFont),topFrame);
1068 topLayout->addWidget(tVFont->label(),i,0); 1067 topLayout->addWidget(tVFont->label(),i,0);
1069 topLayout->addWidget(tVFont->preview(),i,1); 1068 topLayout->addWidget(tVFont->preview(),i,1);
1070 topLayout->addWidget(tVFont->button(),i,2); 1069 topLayout->addWidget(tVFont->button(),i,2);
1071 ++i; 1070 ++i;
1072 1071
1073 1072
1074 1073
1075 1074
1076 topLayout->setColStretch(1,1); 1075 topLayout->setColStretch(1,1);
1077 topLayout->setRowStretch(4,1); 1076 topLayout->setRowStretch(4,1);
1078 1077
1079 1078
1080 1079
1081 1080
1082} 1081}
1083 1082
1084void KOPrefsDialog::setupColorsTab() 1083void KOPrefsDialog::setupColorsTab()
1085{ 1084{
1086 QFrame *topFrame = addPage(i18n("Colors"),0,0); 1085 QFrame *topFrame = addPage(i18n("Colors"),0,0);
1087 // DesktopIcon("colorize",KIcon::SizeMedium)); 1086 // DesktopIcon("colorize",KIcon::SizeMedium));
1088 1087
1089 QGridLayout *topLayout = new QGridLayout(topFrame,5,2); 1088 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
1090 // topLayout->setSpacing(spacingHint()); 1089 // topLayout->setSpacing(spacingHint());
1091 // topLayout->setMargin(marginHint()); 1090 // topLayout->setMargin(marginHint());
1092 1091
1093 topLayout->setSpacing(2); 1092 topLayout->setSpacing(2);
1094 topLayout->setMargin(3); 1093 topLayout->setMargin(3);
1095 1094
1096 int ii = 1; 1095 int ii = 1;
1097 QGroupBox *categoryGroup ; 1096 QGroupBox *categoryGroup ;
1098 1097
1099 categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"), 1098 categoryGroup = new QGroupBox(1,Vertical,i18n("Categories"),
1100 topFrame); 1099 topFrame);
1101 topLayout->addMultiCellWidget(categoryGroup,0,0,0,1); 1100 topLayout->addMultiCellWidget(categoryGroup,0,0,0,1);
1102 1101
1103 mCategoryCombo = new QComboBox(categoryGroup); 1102 mCategoryCombo = new QComboBox(categoryGroup);
1104 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 1103 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1105 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor())); 1104 connect(mCategoryCombo,SIGNAL(activated(int)),SLOT(updateCategoryColor()));
1106 1105
1107 mCategoryButton = new KColorButton(categoryGroup); 1106 mCategoryButton = new KColorButton(categoryGroup);
1108 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor())); 1107 connect(mCategoryButton,SIGNAL(changed(const QColor &)),SLOT(setCategoryColor()));
1109 updateCategoryColor(); 1108 updateCategoryColor();
1110 1109
1111 1110
1112 // Holiday Color 1111 // Holiday Color
1113 1112
1114 KPrefsWidColor *holidayColor = 1113 KPrefsWidColor *holidayColor =
1115 addWidColor(i18n("Holiday color:"), 1114 addWidColor(i18n("Holiday color:"),
1116 &(KOPrefs::instance()->mHolidayColor),topFrame); 1115 &(KOPrefs::instance()->mHolidayColor),topFrame);
1117 topLayout->addWidget(holidayColor->label(),ii,0); 1116 topLayout->addWidget(holidayColor->label(),ii,0);
1118 topLayout->addWidget(holidayColor->button(),ii++,1); 1117 topLayout->addWidget(holidayColor->button(),ii++,1);
1119 1118
1120 // Highlight Color 1119 // Highlight Color
1121 KPrefsWidColor *highlightColor = 1120 KPrefsWidColor *highlightColor =
1122 addWidColor(i18n("Highlight color:"), 1121 addWidColor(i18n("Highlight color:"),
1123 &(KOPrefs::instance()->mHighlightColor),topFrame); 1122 &(KOPrefs::instance()->mHighlightColor),topFrame);
1124 topLayout->addWidget(highlightColor->label(),ii,0); 1123 topLayout->addWidget(highlightColor->label(),ii,0);
1125 topLayout->addWidget(highlightColor->button(),ii++,1); 1124 topLayout->addWidget(highlightColor->button(),ii++,1);
1126 1125
1127 // Event color 1126 // Event color
1128 KPrefsWidColor *eventColor = 1127 KPrefsWidColor *eventColor =
1129 addWidColor(i18n("Default event color:"), 1128 addWidColor(i18n("Default event color:"),
1130 &(KOPrefs::instance()->mEventColor),topFrame); 1129 &(KOPrefs::instance()->mEventColor),topFrame);
1131 topLayout->addWidget(eventColor->label(),ii,0); 1130 topLayout->addWidget(eventColor->label(),ii,0);
1132 topLayout->addWidget(eventColor->button(),ii++,1); 1131 topLayout->addWidget(eventColor->button(),ii++,1);
1133 1132
1134 // agenda view background color 1133 // agenda view background color
1135 KPrefsWidColor *agendaBgColor = 1134 KPrefsWidColor *agendaBgColor =
1136 addWidColor(i18n("Agenda view background color:"), 1135 addWidColor(i18n("Agenda view background color:"),
1137 &(KOPrefs::instance()->mAgendaBgColor),topFrame); 1136 &(KOPrefs::instance()->mAgendaBgColor),topFrame);
1138 topLayout->addWidget(agendaBgColor->label(),ii,0); 1137 topLayout->addWidget(agendaBgColor->label(),ii,0);
1139 topLayout->addWidget(agendaBgColor->button(),ii++,1); 1138 topLayout->addWidget(agendaBgColor->button(),ii++,1);
1140 1139
1141 // working hours color 1140 // working hours color
1142 KPrefsWidColor *workingHoursColor = 1141 KPrefsWidColor *workingHoursColor =
1143 addWidColor(i18n("Working hours color:"), 1142 addWidColor(i18n("Working hours color:"),
1144 &(KOPrefs::instance()->mWorkingHoursColor),topFrame); 1143 &(KOPrefs::instance()->mWorkingHoursColor),topFrame);
1145 topLayout->addWidget(workingHoursColor->label(),ii,0); 1144 topLayout->addWidget(workingHoursColor->label(),ii,0);
1146 topLayout->addWidget(workingHoursColor->button(),ii++,1); 1145 topLayout->addWidget(workingHoursColor->button(),ii++,1);
1147 1146
1148 KPrefsWidBool *sb = 1147 KPrefsWidBool *sb =
1149 addWidBool(i18n("Use colors for application:"), 1148 addWidBool(i18n("Use colors for application:"),
1150 &(KOPrefs::instance()->mUseAppColors),topFrame); 1149 &(KOPrefs::instance()->mUseAppColors),topFrame);
1151 topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 ); 1150 topLayout->addMultiCellWidget(sb->checkBox(), ii, ii, 0,1 );
1152 1151
1153 ii++; 1152 ii++;
1154 KPrefsWidColor * workingHoursColor1 = 1153 KPrefsWidColor * workingHoursColor1 =
1155 addWidColor(i18n("Buttons, menus, etc.:"), 1154 addWidColor(i18n("Buttons, menus, etc.:"),
1156 &(KOPrefs::instance()->mAppColor1),topFrame); 1155 &(KOPrefs::instance()->mAppColor1),topFrame);
1157 topLayout->addWidget(workingHoursColor1->label(),ii,0); 1156 topLayout->addWidget(workingHoursColor1->label(),ii,0);
1158 topLayout->addWidget(workingHoursColor1->button(),ii++,1); 1157 topLayout->addWidget(workingHoursColor1->button(),ii++,1);
1159 1158
1160 KPrefsWidColor * workingHoursColor2 = 1159 KPrefsWidColor * workingHoursColor2 =
1161 addWidColor(i18n("Frames, labels, etc.:"), 1160 addWidColor(i18n("Frames, labels, etc.:"),
1162 &(KOPrefs::instance()->mAppColor2),topFrame); 1161 &(KOPrefs::instance()->mAppColor2),topFrame);
1163 topLayout->addWidget(workingHoursColor2->label(),ii,0); 1162 topLayout->addWidget(workingHoursColor2->label(),ii,0);
1164 topLayout->addWidget(workingHoursColor2->button(),ii++,1); 1163 topLayout->addWidget(workingHoursColor2->button(),ii++,1);
1165 1164
1166 1165
1167 1166
1168} 1167}
1169 1168
1170void KOPrefsDialog::setCategoryColor() 1169void KOPrefsDialog::setCategoryColor()
1171{ 1170{
1172 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color())); 1171 mCategoryDict.replace(mCategoryCombo->currentText(), new QColor(mCategoryButton->color()));
1173} 1172}
1174 1173
1175void KOPrefsDialog::updateCategoryColor() 1174void KOPrefsDialog::updateCategoryColor()
1176{ 1175{
1177 QString cat = mCategoryCombo->currentText(); 1176 QString cat = mCategoryCombo->currentText();
1178 QColor *color = mCategoryDict.find(cat); 1177 QColor *color = mCategoryDict.find(cat);
1179 if (!color) { 1178 if (!color) {
1180 color = KOPrefs::instance()->categoryColor(cat); 1179 color = KOPrefs::instance()->categoryColor(cat);
1181 } 1180 }
1182 if (color) { 1181 if (color) {
1183 mCategoryButton->setColor(*color); 1182 mCategoryButton->setColor(*color);
1184 } 1183 }
1185} 1184}
1186 1185
1187void KOPrefsDialog::setupPrinterTab() 1186void KOPrefsDialog::setupPrinterTab()
1188{ 1187{
1189 mPrinterTab = addPage(i18n("Printing"),0, 1188 mPrinterTab = addPage(i18n("Printing"),0,
1190 DesktopIcon("fileprint",KIcon::SizeMedium)); 1189 DesktopIcon("fileprint",KIcon::SizeMedium));
1191 1190
1192 QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2); 1191 QGridLayout *topLayout = new QGridLayout(mPrinterTab,5,2);
1193 topLayout->setSpacing(spacingHint()); 1192 topLayout->setSpacing(spacingHint());
1194 topLayout->setMargin(marginHint()); 1193 topLayout->setMargin(marginHint());
1195 1194
1196 topLayout->setRowStretch(4,1); 1195 topLayout->setRowStretch(4,1);
1197} 1196}
1198 1197
1199void KOPrefsDialog::setupGroupSchedulingTab() 1198void KOPrefsDialog::setupGroupSchedulingTab()
1200{ 1199{
1201#if 0 1200#if 0
1202 QFrame *topFrame = addPage(i18n("Group Scheduling"),0, 1201 QFrame *topFrame = addPage(i18n("Group Scheduling"),0,
1203 DesktopIcon("personal",KIcon::SizeMedium)); 1202 DesktopIcon("personal",KIcon::SizeMedium));
1204 1203
1205 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 1204 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
1206 topLayout->setSpacing(spacingHint()); 1205 topLayout->setSpacing(spacingHint());
1207 topLayout->setMargin(marginHint()); 1206 topLayout->setMargin(marginHint());
1208 1207
1209#if 0 1208#if 0
1210 KPrefsWidRadios *schedulerGroup = 1209 KPrefsWidRadios *schedulerGroup =
1211 addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler), 1210 addWidRadios(i18n("Scheduler Mail Client"),&(KOPrefs::instance()->mIMIPScheduler),
1212 topFrame); 1211 topFrame);
1213 schedulerGroup->addRadio("Dummy"); // Only for debugging 1212 schedulerGroup->addRadio("Dummy"); // Only for debugging
1214 schedulerGroup->addRadio(i18n("Mail client")); 1213 schedulerGroup->addRadio(i18n("Mail client"));
1215 1214
1216 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1); 1215 topLayout->addMultiCellWidget(schedulerGroup->groupBox(),0,0,0,1);
1217#endif 1216#endif
1218 1217
1219 KPrefsWidRadios *sendGroup = 1218 KPrefsWidRadios *sendGroup =
1220 addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend), 1219 addWidRadios(i18n("Scheduler Mails Should Be"),&(KOPrefs::instance()->mIMIPSend),
1221 topFrame); 1220 topFrame);
1222 sendGroup->addRadio(i18n("Send to outbox")); 1221 sendGroup->addRadio(i18n("Send to outbox"));
1223 sendGroup->addRadio(i18n("Send directly")); 1222 sendGroup->addRadio(i18n("Send directly"));
1224 1223
1225 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1); 1224 topLayout->addMultiCellWidget(sendGroup->groupBox(),1,1,0,1);
1226 1225
1227 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1); 1226 topLayout->addMultiCellWidget(new QLabel(i18n("Additional email addresses:"),topFrame),2,2,0,1);
1228 mAMails = new QListView(topFrame); 1227 mAMails = new QListView(topFrame);
1229 mAMails->addColumn(i18n("Email"),300); 1228 mAMails->addColumn(i18n("Email"),300);
1230 topLayout->addMultiCellWidget(mAMails,3,3,0,1); 1229 topLayout->addMultiCellWidget(mAMails,3,3,0,1);
1231 1230
1232 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0); 1231 topLayout->addWidget(new QLabel(i18n("Additional email address:"),topFrame),4,0);
1233 aEmailsEdit = new QLineEdit(topFrame); 1232 aEmailsEdit = new QLineEdit(topFrame);
1234 aEmailsEdit->setEnabled(false); 1233 aEmailsEdit->setEnabled(false);
1235 topLayout->addWidget(aEmailsEdit,4,1); 1234 topLayout->addWidget(aEmailsEdit,4,1);
1236 1235
1237 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new"); 1236 QPushButton *add = new QPushButton(i18n("New"),topFrame,"new");
1238 topLayout->addWidget(add,5,0); 1237 topLayout->addWidget(add,5,0);
1239 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove"); 1238 QPushButton *del = new QPushButton(i18n("Remove"),topFrame,"remove");
1240 topLayout->addWidget(del,5,1); 1239 topLayout->addWidget(del,5,1);
1241 1240
1242 //topLayout->setRowStretch(2,1); 1241 //topLayout->setRowStretch(2,1);
1243 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) ); 1242 connect(add, SIGNAL( clicked() ), this, SLOT(addItem()) );
1244 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) ); 1243 connect(del, SIGNAL( clicked() ), this, SLOT(removeItem()) );
1245 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem())); 1244 connect(aEmailsEdit,SIGNAL( textChanged(const QString&) ), this,SLOT(updateItem()));
1246 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput())); 1245 connect(mAMails,SIGNAL(selectionChanged(QListViewItem *)),SLOT(updateInput()));
1247#endif 1246#endif
1248} 1247}
1249 1248
1250void KOPrefsDialog::setupGroupAutomationTab() 1249void KOPrefsDialog::setupGroupAutomationTab()
1251{ 1250{
1252 return; 1251 return;
1253 QFrame *topFrame = addPage(i18n("Group Automation"),0, 1252 QFrame *topFrame = addPage(i18n("Group Automation"),0,
1254 DesktopIcon("personal",KIcon::SizeMedium)); 1253 DesktopIcon("personal",KIcon::SizeMedium));
1255 1254
1256 QGridLayout *topLayout = new QGridLayout(topFrame,5,1); 1255 QGridLayout *topLayout = new QGridLayout(topFrame,5,1);
1257 topLayout->setSpacing(spacingHint()); 1256 topLayout->setSpacing(spacingHint());
1258 topLayout->setMargin(marginHint()); 1257 topLayout->setMargin(marginHint());
1259 1258
1260 KPrefsWidRadios *autoRefreshGroup = 1259 KPrefsWidRadios *autoRefreshGroup =
1261 addWidRadios(i18n("Auto Send Refresh"), 1260 addWidRadios(i18n("Auto Send Refresh"),
1262 &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame); 1261 &(KOPrefs::instance()->mIMIPAutoRefresh),topFrame);
1263 autoRefreshGroup->addRadio(i18n("Never")); 1262 autoRefreshGroup->addRadio(i18n("Never"));
1264 autoRefreshGroup->addRadio(i18n("If attendee is in addressbook")); 1263 autoRefreshGroup->addRadio(i18n("If attendee is in addressbook"));
1265 //autoRefreshGroup->addRadio(i18n("selected emails")); 1264 //autoRefreshGroup->addRadio(i18n("selected emails"));
1266 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0); 1265 topLayout->addMultiCellWidget(autoRefreshGroup->groupBox(),0,0,0,0);
1267 1266
1268 KPrefsWidRadios *autoInsertGroup = 1267 KPrefsWidRadios *autoInsertGroup =
1269 addWidRadios(i18n("Auto Insert IMIP Replies"), 1268 addWidRadios(i18n("Auto Insert IMIP Replies"),
1270 &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame); 1269 &(KOPrefs::instance()->mIMIPAutoInsertReply),topFrame);
1271 autoInsertGroup->addRadio(i18n("Never")); 1270 autoInsertGroup->addRadio(i18n("Never"));
1272 autoInsertGroup->addRadio(i18n("If attendee is in addressbook")); 1271 autoInsertGroup->addRadio(i18n("If attendee is in addressbook"));
1273 //autoInsertGroup->addRadio(i18n("selected emails")); 1272 //autoInsertGroup->addRadio(i18n("selected emails"));
1274 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0); 1273 topLayout->addMultiCellWidget(autoInsertGroup->groupBox(),1,1,0,0);
1275 1274
1276 KPrefsWidRadios *autoRequestGroup = 1275 KPrefsWidRadios *autoRequestGroup =
1277 addWidRadios(i18n("Auto Insert IMIP Requests"), 1276 addWidRadios(i18n("Auto Insert IMIP Requests"),
1278 &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame); 1277 &(KOPrefs::instance()->mIMIPAutoInsertRequest),topFrame);
1279 autoRequestGroup->addRadio(i18n("Never")); 1278 autoRequestGroup->addRadio(i18n("Never"));
1280 autoRequestGroup->addRadio(i18n("If organizer is in addressbook")); 1279 autoRequestGroup->addRadio(i18n("If organizer is in addressbook"));
1281 //autoInsertGroup->addRadio(i18n("selected emails")); 1280 //autoInsertGroup->addRadio(i18n("selected emails"));
1282 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0); 1281 topLayout->addMultiCellWidget(autoRequestGroup->groupBox(),2,2,0,0);
1283 1282
1284 KPrefsWidRadios *autoFreeBusyGroup = 1283 KPrefsWidRadios *autoFreeBusyGroup =
1285 addWidRadios(i18n("Auto Send FreeBusy Information"), 1284 addWidRadios(i18n("Auto Send FreeBusy Information"),
1286 &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame); 1285 &(KOPrefs::instance()->mIMIPAutoFreeBusy),topFrame);
1287 autoFreeBusyGroup->addRadio(i18n("Never")); 1286 autoFreeBusyGroup->addRadio(i18n("Never"));
1288 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook")); 1287 autoFreeBusyGroup->addRadio(i18n("If requested from an email in addressbook"));
1289 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 1288 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1290 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0); 1289 topLayout->addMultiCellWidget(autoFreeBusyGroup->groupBox(),3,3,0,0);
1291 1290
1292 KPrefsWidRadios *autoFreeBusyReplyGroup = 1291 KPrefsWidRadios *autoFreeBusyReplyGroup =
1293 addWidRadios(i18n("Auto Save FreeBusy Replies"), 1292 addWidRadios(i18n("Auto Save FreeBusy Replies"),
1294 &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame); 1293 &(KOPrefs::instance()->mIMIPAutoFreeBusyReply),topFrame);
1295 autoFreeBusyReplyGroup->addRadio(i18n("Never")); 1294 autoFreeBusyReplyGroup->addRadio(i18n("Never"));
1296 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook")); 1295 autoFreeBusyReplyGroup->addRadio(i18n("If attendee is in addressbook"));
1297 //autoFreeBusyGroup->addRadio(i18n("selected emails")); 1296 //autoFreeBusyGroup->addRadio(i18n("selected emails"));
1298 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0); 1297 topLayout->addMultiCellWidget(autoFreeBusyReplyGroup->groupBox(),4,4,0,0);
1299} 1298}
1300 1299
1301void KOPrefsDialog::showPrinterTab() 1300void KOPrefsDialog::showPrinterTab()
1302{ 1301{
1303 showPage(pageIndex(mPrinterTab)); 1302 showPage(pageIndex(mPrinterTab));
1304} 1303}
1305 1304
1306 1305
1307void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text, 1306void KOPrefsDialog::setCombo(QComboBox *combo, const QString & text,
1308 const QStringList *tags) 1307 const QStringList *tags)
1309{ 1308{
1310 if (tags) { 1309 if (tags) {
1311 int i = tags->findIndex(text); 1310 int i = tags->findIndex(text);
1312 if (i > 0) combo->setCurrentItem(i); 1311 if (i > 0) combo->setCurrentItem(i);
1313 } else { 1312 } else {
1314 for(int i=0;i<combo->count();++i) { 1313 for(int i=0;i<combo->count();++i) {
1315 if (combo->text(i) == text) { 1314 if (combo->text(i) == text) {
1316 combo->setCurrentItem(i); 1315 combo->setCurrentItem(i);
1317 break; 1316 break;
1318 } 1317 }
1319 } 1318 }
1320 } 1319 }
1321} 1320}
1322 1321
1323void KOPrefsDialog::usrReadConfig() 1322void KOPrefsDialog::usrReadConfig()
1324{ 1323{
1325 mNameEdit->setText(KOPrefs::instance()->fullName()); 1324 mNameEdit->setText(KOPrefs::instance()->fullName());
1326 mEmailEdit->setText(KOPrefs::instance()->email()); 1325 mEmailEdit->setText(KOPrefs::instance()->email());
1327 1326
1328 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval); 1327 mAutoSaveIntervalSpin->setValue(KOPrefs::instance()->mAutoSaveInterval);
1329 QDate current ( 2001, 1,1); 1328 QDate current ( 2001, 1,1);
1330 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); 1329 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1));
1331 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); 1330 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1));
1332 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId)); 1331 setCombo(mTimeZoneCombo,i18n(KOPrefs::instance()->mTimeZoneId));
1333 //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); 1332 //mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset);
1334 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime); 1333 mStartTimeSpin->setValue(KOPrefs::instance()->mStartTime);
1335 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration); 1334 mDefaultDurationSpin->setValue(KOPrefs::instance()->mDefaultDuration);
1336 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime); 1335 mAlarmTimeCombo->setCurrentItem(KOPrefs::instance()->mAlarmTime);
1337 // if (KOPrefs::instance()->mAllDaySize > 47 ) 1336 // if (KOPrefs::instance()->mAllDaySize > 47 )
1338 // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2; 1337 // KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize/2;
1339 //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize); 1338 //mHourSizeSlider->setValue(KOPrefs::instance()->mAllDaySize);
1340 1339
1341 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays); 1340 mNextXDaysSpin->setValue(KOPrefs::instance()->mNextXDays);
1342 mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays); 1341 mWhatsNextSpin->setValue(KOPrefs::instance()->mWhatsNextDays);
1343 mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios); 1342 mPrioSpin->setValue(KOPrefs::instance()->mWhatsNextPrios);
1344 // mAMails->clear(); 1343 // mAMails->clear();
1345 // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin(); 1344 // for ( QStringList::Iterator it = KOPrefs::instance()->mAdditionalMails.begin();
1346// it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) { 1345// it != KOPrefs::instance()->mAdditionalMails.end(); ++it ) {
1347// QListViewItem *item = new QListViewItem(mAMails); 1346// QListViewItem *item = new QListViewItem(mAMails);
1348// item->setText(0,*it); 1347// item->setText(0,*it);
1349// mAMails->insertItem(item); 1348// mAMails->insertItem(item);
1350// } 1349// }
1351 1350
1352 // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP); 1351 // mRemoteIPEdit->setText(KOPrefs::instance()->mRemoteIP);
1353 //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser); 1352 //mRemoteUser->setText(KOPrefs::instance()->mRemoteUser);
1354 //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd); 1353 //mRemotePassWd->setText(KOPrefs::instance()->mRemotePassWd);
1355 //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile); 1354 //mRemoteFile->setText(KOPrefs::instance()->mRemoteFile);
1356 1355
1357 //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile); 1356 //that soundmLocalTempFile->setText(KOPrefs::instance()->mLocalTempFile);
1358 mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile); 1357 mDefaultAlarmFile->setText(KOPrefs::instance()->mDefaultAlarmFile);
1359 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1358 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1360 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 1359 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
1361 dummy = KOPrefs::instance()->mUserDateFormatShort; 1360 dummy = KOPrefs::instance()->mUserDateFormatShort;
1362 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 1361 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
1363 updateCategories(); 1362 updateCategories();
1364 mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps ); 1363 mAlarmPlayBeeps->setValue(KOPrefs::instance()->mAlarmPlayBeeps );
1365 mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime ); 1364 mAlarmSuspendTime->setValue(KOPrefs::instance()->mAlarmSuspendTime );
1366 mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount ); 1365 mAlarmSuspendCount->setValue(KOPrefs::instance()->mAlarmSuspendCount );
1367 mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval ); 1366 mAlarmBeepInterval->setValue(KOPrefs::instance()->mAlarmBeepInterval );
1368} 1367}
1369 1368
1370 1369
1371void KOPrefsDialog::usrWriteConfig() 1370void KOPrefsDialog::usrWriteConfig()
1372{ 1371{
1373 1372
1374 // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text(); 1373 // KOPrefs::instance()->mRemoteIP = mRemoteIPEdit->text();
1375 //KOPrefs::instance()->mRemoteUser = mRemoteUser->text(); 1374 //KOPrefs::instance()->mRemoteUser = mRemoteUser->text();
1376 //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text(); 1375 //KOPrefs::instance()->mRemotePassWd = mRemotePassWd->text();
1377 //KOPrefs::instance()->mRemoteFile= mRemoteFile->text(); 1376 //KOPrefs::instance()->mRemoteFile= mRemoteFile->text();
1378 //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text(); 1377 //KOPrefs::instance()->mLocalTempFile =mLocalTempFile->text();
1379 KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text(); 1378 KOPrefs::instance()->mDefaultAlarmFile =mDefaultAlarmFile->text();
1380 1379
1381 KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 1380 KOPrefs::instance()->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
1382 KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 1381 KOPrefs::instance()->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
1383 KOPrefs::instance()->setFullName(mNameEdit->text()); 1382 KOPrefs::instance()->setFullName(mNameEdit->text());
1384 KOPrefs::instance()->setEmail(mEmailEdit->text()); 1383 KOPrefs::instance()->setEmail(mEmailEdit->text());
1385 1384
1386 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value(); 1385 KOPrefs::instance()->mAutoSaveInterval = mAutoSaveIntervalSpin->value();
1387 1386
1388 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText(); 1387 KOPrefs::instance()->mTimeZoneId = mTimeZoneCombo->currentText();
1389 QDate date; 1388 QDate date;
1390 date = mStartDateSavingEdit->date(); 1389 date = mStartDateSavingEdit->date();
1391 int sub = 0; 1390 int sub = 0;
1392 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 1391 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
1393 sub = 1; 1392 sub = 1;
1394 KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub; 1393 KOPrefs::instance()->mDaylightsavingStart = date.dayOfYear()-sub;
1395 date = mEndDateSavingEdit->date(); 1394 date = mEndDateSavingEdit->date();
1396 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 1395 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
1397 sub = 1; 1396 sub = 1;
1398 else 1397 else
1399 sub = 0; 1398 sub = 0;
1400 KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub; 1399 KOPrefs::instance()->mDaylightsavingEnd = date.dayOfYear()-sub;
1401 // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value(); 1400 // KOPrefs::instance()->mTimeZoneOffset = mTimezoneOffsetSpin->value();
1402 1401
1403 KOPrefs::instance()->mStartTime = mStartTimeSpin->value(); 1402 KOPrefs::instance()->mStartTime = mStartTimeSpin->value();
1404 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value(); 1403 KOPrefs::instance()->mDefaultDuration = mDefaultDurationSpin->value();
1405 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem(); 1404 KOPrefs::instance()->mAlarmTime = mAlarmTimeCombo->currentItem();
1406 1405
1407 //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value(); 1406 //KOPrefs::instance()->mAllDaySize = mHourSizeSlider->value();
1408 1407
1409 QDictIterator<QColor> it(mCategoryDict); 1408 QDictIterator<QColor> it(mCategoryDict);
1410 while (it.current()) { 1409 while (it.current()) {
1411 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current()); 1410 KOPrefs::instance()->setCategoryColor(it.currentKey(),*it.current());
1412 ++it; 1411 ++it;
1413 } 1412 }
1414 1413
1415 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value(); 1414 KOPrefs::instance()->mNextXDays = mNextXDaysSpin->value();
1416 KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value(); 1415 KOPrefs::instance()->mWhatsNextDays = mWhatsNextSpin->value();
1417 KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value(); 1416 KOPrefs::instance()->mWhatsNextPrios = mPrioSpin->value();
1418 1417
1419 KOPrefs::instance()->mAdditionalMails.clear(); 1418 KOPrefs::instance()->mAdditionalMails.clear();
1420 // QListViewItem *item; 1419 // QListViewItem *item;
1421 // item = mAMails->firstChild(); 1420 // item = mAMails->firstChild();
1422 // while (item) 1421 // while (item)
1423 // { 1422 // {
1424 // KOPrefs::instance()->mAdditionalMails.append( item->text(0) ); 1423 // KOPrefs::instance()->mAdditionalMails.append( item->text(0) );
1425 // item = item->nextSibling(); 1424 // item = item->nextSibling();
1426 // } 1425 // }
1427 KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value(); 1426 KOPrefs::instance()->mAlarmPlayBeeps = mAlarmPlayBeeps->value();
1428 KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ; 1427 KOPrefs::instance()->mAlarmSuspendTime = mAlarmSuspendTime->value() ;
1429 KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ; 1428 KOPrefs::instance()->mAlarmSuspendCount= mAlarmSuspendCount->value() ;
1430 KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ; 1429 KOPrefs::instance()->mAlarmBeepInterval= mAlarmBeepInterval->value() ;
1431 1430
1432} 1431}
1433 1432
1434void KOPrefsDialog::updateCategories() 1433void KOPrefsDialog::updateCategories()
1435{ 1434{
1436 mCategoryCombo->clear(); 1435 mCategoryCombo->clear();
1437 mCategoryDict.clear(); 1436 mCategoryDict.clear();
1438 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories); 1437 mCategoryCombo->insertStringList(KOPrefs::instance()->mCustomCategories);
1439 updateCategoryColor(); 1438 updateCategoryColor();
1440} 1439}
1441 1440
1442void KOPrefsDialog::warningGroupScheduling() 1441void KOPrefsDialog::warningGroupScheduling()
1443{ 1442{
1444 warningExperimental(mEnableGroupScheduling->checkBox()->isChecked()); 1443 warningExperimental(mEnableGroupScheduling->checkBox()->isChecked());
1445} 1444}
1446 1445
1447void KOPrefsDialog::warningProjectView() 1446void KOPrefsDialog::warningProjectView()
1448{ 1447{
1449 warningExperimental(mEnableProjectView->checkBox()->isChecked()); 1448 warningExperimental(mEnableProjectView->checkBox()->isChecked());
1450} 1449}
1451 1450
1452void KOPrefsDialog::warningExperimental(bool on) 1451void KOPrefsDialog::warningExperimental(bool on)
1453{ 1452{
1454 if (on) { 1453 if (on) {
1455 KMessageBox::information(this,i18n("This is an experimental feature. " 1454 KMessageBox::information(this,i18n("This is an experimental feature. "
1456 "It may not work, it may do nothing useful and it may cause data loss. " 1455 "It may not work, it may do nothing useful and it may cause data loss. "
1457 "Use with care.\n" 1456 "Use with care.\n"
1458 "You have to restart KOrganizer for this setting to take effect.")); 1457 "You have to restart KOrganizer for this setting to take effect."));
1459 } else { 1458 } else {
1460 KMessageBox::information(this, 1459 KMessageBox::information(this,
1461 i18n("You have to restart KOrganizer for this setting to take effect.")); 1460 i18n("You have to restart KOrganizer for this setting to take effect."));
1462 } 1461 }
1463} 1462}
1464 1463
1465void KOPrefsDialog::toggleEmailSettings(bool on) 1464void KOPrefsDialog::toggleEmailSettings(bool on)
1466{ 1465{
1467 if (on) { 1466 if (on) {
1468 mEmailEdit->setEnabled(false); 1467 mEmailEdit->setEnabled(false);
1469 mNameEdit->setEnabled(false); 1468 mNameEdit->setEnabled(false);
1470 mEmailLabel->setEnabled(false); 1469 mEmailLabel->setEnabled(false);
1471 mNameLabel->setEnabled(false); 1470 mNameLabel->setEnabled(false);
1472 1471
1473 KEMailSettings settings; 1472 KEMailSettings settings;
1474 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName)); 1473 mNameEdit->setText(settings.getSetting(KEMailSettings::RealName));
1475 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress)); 1474 mEmailEdit->setText(settings.getSetting(KEMailSettings::EmailAddress));
1476 } else { 1475 } else {
1477 mEmailEdit->setEnabled(true); 1476 mEmailEdit->setEnabled(true);
1478 mNameEdit->setEnabled(true); 1477 mNameEdit->setEnabled(true);
1479 mEmailLabel->setEnabled(true); 1478 mEmailLabel->setEnabled(true);
1480 mNameLabel->setEnabled(true); 1479 mNameLabel->setEnabled(true);
1481 } 1480 }
1482} 1481}
1483 1482
1484void KOPrefsDialog::addItem() 1483void KOPrefsDialog::addItem()
1485{ 1484{
1486 // aEmailsEdit->setEnabled(true); 1485 // aEmailsEdit->setEnabled(true);
1487// QListViewItem *item = new QListViewItem(mAMails); 1486// QListViewItem *item = new QListViewItem(mAMails);
1488// mAMails->insertItem(item); 1487// mAMails->insertItem(item);
1489// mAMails->setSelected(item,true); 1488// mAMails->setSelected(item,true);
1490// aEmailsEdit->setText(i18n("(EmptyEmail)")); 1489// aEmailsEdit->setText(i18n("(EmptyEmail)"));
1491} 1490}
1492 1491
1493void KOPrefsDialog::removeItem() 1492void KOPrefsDialog::removeItem()
1494{ 1493{
1495// QListViewItem *item; 1494// QListViewItem *item;
1496// item = mAMails->selectedItem(); 1495// item = mAMails->selectedItem();
1497// if (!item) return; 1496// if (!item) return;
1498// mAMails->takeItem(item); 1497// mAMails->takeItem(item);
1499// item = mAMails->selectedItem(); 1498// item = mAMails->selectedItem();
1500// if (!item) { 1499// if (!item) {
1501// aEmailsEdit->setText(""); 1500// aEmailsEdit->setText("");
1502// aEmailsEdit->setEnabled(false); 1501// aEmailsEdit->setEnabled(false);
1503// } 1502// }
1504// if (mAMails->childCount() == 0) { 1503// if (mAMails->childCount() == 0) {
1505// aEmailsEdit->setEnabled(false); 1504// aEmailsEdit->setEnabled(false);
1506// } 1505// }
1507} 1506}
1508 1507
1509void KOPrefsDialog::updateItem() 1508void KOPrefsDialog::updateItem()
1510{ 1509{
1511 // QListViewItem *item; 1510 // QListViewItem *item;
1512// item = mAMails->selectedItem(); 1511// item = mAMails->selectedItem();
1513// if (!item) return; 1512// if (!item) return;
1514// item->setText(0,aEmailsEdit->text()); 1513// item->setText(0,aEmailsEdit->text());
1515} 1514}
1516 1515
1517void KOPrefsDialog::updateInput() 1516void KOPrefsDialog::updateInput()
1518{ 1517{
1519// QListViewItem *item; 1518// QListViewItem *item;
1520// item = mAMails->selectedItem(); 1519// item = mAMails->selectedItem();
1521// if (!item) return; 1520// if (!item) return;
1522// aEmailsEdit->setEnabled(true); 1521// aEmailsEdit->setEnabled(true);
1523// aEmailsEdit->setText(item->text(0)); 1522// aEmailsEdit->setText(item->text(0));
1524} 1523}
1525void KOPrefsDialog::updateTimezoneOffset( int index ) 1524void KOPrefsDialog::updateTimezoneOffset( int index )
1526{ 1525{
1527 /* 1526 /*
1528 qDebug("updateTimezoneOffset %d ", index); 1527 qDebug("updateTimezoneOffset %d ", index);
1529 if ( index < 24 ) { 1528 if ( index < 24 ) {
1530 mTimezoneOffsetSpin->setEnabled ( false ); 1529 mTimezoneOffsetSpin->setEnabled ( false );
1531 mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 ); 1530 mTimezoneOffsetSpin->setValue( ( index-11 ) * 60 );
1532 1531
1533 1532
1534 } else { 1533 } else {
1535 if ( index == 24 ) { 1534 if ( index == 24 ) {
1536 mTimezoneOffsetSpin->setEnabled ( true ); 1535 mTimezoneOffsetSpin->setEnabled ( true );
1537 mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset); 1536 mTimezoneOffsetSpin->setValue( KOPrefs::instance()->mTimeZoneOffset);
1538 1537
1539 } else { 1538 } else {
1540 mTimezoneOffsetSpin->setEnabled ( false ); 1539 mTimezoneOffsetSpin->setEnabled ( false );
1541 mTimezoneOffsetSpin->setValue( 0 ); 1540 mTimezoneOffsetSpin->setValue( 0 );
1542 } 1541 }
1543 } 1542 }
1544 */ 1543 */
1545} 1544}
1546 1545
1547void KOPrefsDialog::setupTimeZoneTab() 1546void KOPrefsDialog::setupTimeZoneTab()
1548{ 1547{
1549 QFrame *topFrame = addPage(i18n("Time Zone"),0,0); 1548 QFrame *topFrame = addPage(i18n("Time Zone"),0,0);
1550 // DesktopIcon("clock",KIcon::SizeMedium)); 1549 // DesktopIcon("clock",KIcon::SizeMedium));
1551 1550
1552 QGridLayout *topLayout = new QGridLayout(topFrame,5,2); 1551 QGridLayout *topLayout = new QGridLayout(topFrame,5,2);
1553 topLayout->setSpacing(spacingHint()); 1552 topLayout->setSpacing(spacingHint());
1554 topLayout->setMargin(marginHint()); 1553 topLayout->setMargin(marginHint());
1555 1554
1556 QHBox *timeZoneBox = new QHBox( topFrame ); 1555 QHBox *timeZoneBox = new QHBox( topFrame );
1557 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 1556 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
1558 1557
1559 new QLabel( i18n("Timezone:"), timeZoneBox ); 1558 new QLabel( i18n("Timezone:"), timeZoneBox );
1560 mTimeZoneCombo = new QComboBox( timeZoneBox ); 1559 mTimeZoneCombo = new QComboBox( timeZoneBox );
1561 if ( QApplication::desktop()->width() < 300 ) { 1560 if ( QApplication::desktop()->width() < 300 ) {
1562 mTimeZoneCombo->setMaximumWidth(150); 1561 mTimeZoneCombo->setMaximumWidth(150);
1563 } 1562 }
1564 1563
1565 QStringList list; 1564 QStringList list;
1566 list = KGlobal::locale()->timeZoneList(); 1565 list = KGlobal::locale()->timeZoneList();
1567 mTimeZoneCombo->insertStringList(list); 1566 mTimeZoneCombo->insertStringList(list);
1568 1567
1569 // find the currently set time zone and select it 1568 // find the currently set time zone and select it
1570 QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId; 1569 QString sCurrentlySet = KOPrefs::instance()->mTimeZoneId;
1571 int nCurrentlySet = 11; 1570 int nCurrentlySet = 11;
1572 for (int i = 0; i < mTimeZoneCombo->count(); i++) 1571 for (int i = 0; i < mTimeZoneCombo->count(); i++)
1573 { 1572 {
1574 if (mTimeZoneCombo->text(i) == sCurrentlySet) 1573 if (mTimeZoneCombo->text(i) == sCurrentlySet)
1575 { 1574 {
1576 nCurrentlySet = i; 1575 nCurrentlySet = i;
1577 break; 1576 break;
1578 } 1577 }
1579 } 1578 }
1580 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 1579 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
1581 int iii = 1; 1580 int iii = 1;
1582 KPrefsWidBool *sb = 1581 KPrefsWidBool *sb =
1583 addWidBool(i18n("Timezone has daylight saving"), 1582 addWidBool(i18n("Timezone has daylight saving"),
1584 &(KOPrefs::instance()->mUseDaylightsaving),topFrame); 1583 &(KOPrefs::instance()->mUseDaylightsaving),topFrame);
1585 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1); 1584 topLayout->addMultiCellWidget(sb->checkBox(), iii,iii,0,1);
1586 ++iii; 1585 ++iii;
1587 QLabel* lab = new QLabel( i18n("Actual start/end is the\nsunday before this date."), topFrame ); 1586 QLabel* lab = new QLabel( i18n("Actual start/end is the\nsunday before this date."), topFrame );
1588 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 1587 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
1589 ++iii; 1588 ++iii;
1590 lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); 1589 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
1591 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 1590 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
1592 ++iii; 1591 ++iii;
1593 lab = new QLabel( i18n("Daylight start:"), topFrame ); 1592 lab = new QLabel( i18n("Daylight start:"), topFrame );
1594 topLayout->addWidget(lab, iii,0); 1593 topLayout->addWidget(lab, iii,0);
1595 mStartDateSavingEdit = new KDateEdit(topFrame); 1594 mStartDateSavingEdit = new KDateEdit(topFrame);
1596 topLayout->addWidget(mStartDateSavingEdit, iii,1); 1595 topLayout->addWidget(mStartDateSavingEdit, iii,1);
1597 ++iii; 1596 ++iii;
1598 1597
1599 lab = new QLabel( i18n("Daylight end:"), topFrame ); 1598 lab = new QLabel( i18n("Daylight end:"), topFrame );
1600 topLayout->addWidget(lab, iii,0); 1599 topLayout->addWidget(lab, iii,0);
1601 mEndDateSavingEdit = new KDateEdit(topFrame); 1600 mEndDateSavingEdit = new KDateEdit(topFrame);
1602 topLayout->addWidget(mEndDateSavingEdit, iii,1); 1601 topLayout->addWidget(mEndDateSavingEdit, iii,1);
1603 ++iii; 1602 ++iii;
1604 QDate current ( 2001, 1,1); 1603 QDate current ( 2001, 1,1);
1605 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1)); 1604 mStartDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingStart-1));
1606 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1)); 1605 mEndDateSavingEdit->setDate(current.addDays(KOPrefs::instance()->mDaylightsavingEnd-1));
1607 1606
1608 1607
1609} 1608}
1610 1609
diff --git a/korganizer/kosyncprefsdialog.cpp b/korganizer/kosyncprefsdialog.cpp
index 2e051f2..b7e4265 100644
--- a/korganizer/kosyncprefsdialog.cpp
+++ b/korganizer/kosyncprefsdialog.cpp
@@ -1,453 +1,452 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qvbox.h> 34#include <qvbox.h>
35#include <qhbox.h> 35#include <qhbox.h>
36#include <qspinbox.h> 36#include <qspinbox.h>
37#include <qdatetime.h> 37#include <qdatetime.h>
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qradiobutton.h> 39#include <qradiobutton.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42#include <qapplication.h> 42#include <qapplication.h>
43 43
44#include <kcolorbutton.h> 44#include <kcolorbutton.h>
45#include <kdebug.h> 45#include <kdebug.h>
46#include <klocale.h> 46#include <klocale.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include <kfontdialog.h> 48#include <kfontdialog.h>
49#include <kmessagebox.h> 49#include <kmessagebox.h>
50#include <kcolordialog.h> 50#include <kcolordialog.h>
51#include <kiconloader.h> 51#include <kiconloader.h>
52#include <kemailsettings.h> 52#include <kemailsettings.h>
53#include <kstandarddirs.h> 53#include <kstandarddirs.h>
54#include <kfiledialog.h> 54#include <kfiledialog.h>
55#include <kmessagebox.h> 55#include <kmessagebox.h>
56 56
57#include <kurlrequester.h> 57#include <kurlrequester.h>
58#include <klineedit.h> 58#include <klineedit.h>
59#include <libkdepim/ksyncprofile.h> 59#include <libkdepim/ksyncprofile.h>
60 60
61 61
62#include "koprefs.h" 62#include "koprefs.h"
63 63
64#include "kosyncprefsdialog.h" 64#include "kosyncprefsdialog.h"
65#include "koglobals.h" 65#include "koglobals.h"
66#include "kosyncprefsdialog.moc"
67 66
68 67
69KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 68KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
70 KDialog(parent,name,true) 69 KDialog(parent,name,true)
71{ 70{
72 71
73 setCaption( i18n("Synchronization Preferences")); 72 setCaption( i18n("Synchronization Preferences"));
74 73
75 mSyncProfiles.setAutoDelete( true ); 74 mSyncProfiles.setAutoDelete( true );
76 setupSyncAlgTab(); 75 setupSyncAlgTab();
77} 76}
78 77
79 78
80KOSyncPrefsDialog::~KOSyncPrefsDialog() 79KOSyncPrefsDialog::~KOSyncPrefsDialog()
81{ 80{
82} 81}
83 82
84#include <qlayout.h> 83#include <qlayout.h>
85#include <qscrollview.h> 84#include <qscrollview.h>
86void KOSyncPrefsDialog::setupSyncAlgTab() 85void KOSyncPrefsDialog::setupSyncAlgTab()
87{ 86{
88 QLabel * lab; 87 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 88 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this ); 89 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox ); 90 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this ); 91 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox ); 92 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox ); 93 QHBox * b_box = new QHBox( mainbox );
95 94
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 95 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 96 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box ); 97 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 98 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this ); 99 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv ); 100 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit ); 101 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv ); 102 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame ); 103 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame; 104 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 105 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint()); 106 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 107 topLayout->setMargin(marginHint());
109 108
110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 109 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
111 int iii = 0; 110 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 111 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 112 //++iii;
114 113
115 mMyMachineName = new QLineEdit(topFrame); 114 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 115 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 116 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 117 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 118 ++iii;
120 119
121 QHBox* buttonbox = new QHBox( topFrame); 120 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 121 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 122 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 123 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 124 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 125
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 126 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 127 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 128
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 129 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 130 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 131
133 mProfileBox = new QComboBox(topFrame); 132 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 133 mProfileBox->setEditable ( true );
135 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 134 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
136 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 135 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
137 136
138 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 137 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
139 topLayout->addWidget(lab ,iii,0); 138 topLayout->addWidget(lab ,iii,0);
140 topLayout->addWidget(mProfileBox, iii,1); 139 topLayout->addWidget(mProfileBox, iii,1);
141 ++iii; 140 ++iii;
142 141
143 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame ); 142 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame );
144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 143 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
145 ++iii; 144 ++iii;
146 145
147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 146 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 147 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
149 ++iii; 148 ++iii;
150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 149 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
151 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 150 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
152 ++iii; 151 ++iii;
153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 152 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 153 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 154 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 155 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 156 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 157 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
159 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 158 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
160 159
161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 160 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 161 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
163 ++iii; 162 ++iii;
164 163
165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame ); 164 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame );
166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 165 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
167 ++iii; 166 ++iii;
168 167
169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame ); 168 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame );
170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 169 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
171 ++iii; 170 ++iii;
172 171
173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 172 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
174 gr = proGr; 173 gr = proGr;
175 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 174 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
176 ++iii; 175 ++iii;
177 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 176 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 177 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 178 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
180 179
181 localFileWidget = new QVBox( topFrame); 180 localFileWidget = new QVBox( topFrame);
182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 181 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
183 ++iii; 182 ++iii;
184 QHBox* temphb = new QHBox( localFileWidget ); 183 QHBox* temphb = new QHBox( localFileWidget );
185 lab = new QLabel( i18n("Local file:"), temphb); 184 lab = new QLabel( i18n("Local file:"), temphb);
186 mRemoteFile = new QLineEdit(localFileWidget); 185 mRemoteFile = new QLineEdit(localFileWidget);
187 186
188 button = new QPushButton( i18n("Choose..."), temphb ); 187 button = new QPushButton( i18n("Choose..."), temphb );
189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 188 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
190 189
191 190
192 remoteFileWidget = new QVBox( topFrame); 191 remoteFileWidget = new QVBox( topFrame);
193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 192 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
194 ++iii; 193 ++iii;
195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 194 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
196 mRemotePrecommand = new QLineEdit(remoteFileWidget); 195 mRemotePrecommand = new QLineEdit(remoteFileWidget);
197 196
198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 197 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
199 mLocalTempFile = new QLineEdit(remoteFileWidget); 198 mLocalTempFile = new QLineEdit(remoteFileWidget);
200 199
201 200
202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 201 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
203 mRemotePostcommand = new QLineEdit(remoteFileWidget); 202 mRemotePostcommand = new QLineEdit(remoteFileWidget);
204 203
205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 204 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
206 temphb = new QHBox( remoteFileWidget ); 205 temphb = new QHBox( remoteFileWidget );
207 button = new QPushButton( i18n("ssh/scp"), temphb ); 206 button = new QPushButton( i18n("ssh/scp"), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 207 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
209 button = new QPushButton( i18n("ftp"), temphb ); 208 button = new QPushButton( i18n("ftp"), temphb );
210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 209 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 210 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
212 211
213 212
214} 213}
215void KOSyncPrefsDialog::slotOK() 214void KOSyncPrefsDialog::slotOK()
216{ 215{
217 if ( mMyMachineName->text() == "undefined" ) { 216 if ( mMyMachineName->text() == "undefined" ) {
218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 217 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
219 return; 218 return;
220 } 219 }
221 int i; 220 int i;
222 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 221 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 222 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
224 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 223 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
225 return; 224 return;
226 } 225 }
227 } 226 }
228 usrWriteConfig(); 227 usrWriteConfig();
229 QDialog::accept(); 228 QDialog::accept();
230} 229}
231void KOSyncPrefsDialog::accept() 230void KOSyncPrefsDialog::accept()
232{ 231{
233 slotOK(); 232 slotOK();
234} 233}
235void KOSyncPrefsDialog::chooseFile() 234void KOSyncPrefsDialog::chooseFile()
236{ 235{
237 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 236 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
238 237
239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 238 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
240 if ( fn == "" ) 239 if ( fn == "" )
241 return; 240 return;
242 mRemoteFile->setText( fn ); 241 mRemoteFile->setText( fn );
243} 242}
244 243
245void KOSyncPrefsDialog::textChanged( const QString & s ) 244void KOSyncPrefsDialog::textChanged( const QString & s )
246{ 245{
247 if ( mProfileBox->count() == 0 ) 246 if ( mProfileBox->count() == 0 )
248 return; 247 return;
249 if ( currentSelection < 3 ) { 248 if ( currentSelection < 3 ) {
250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 249 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
251 mProfileBox->blockSignals( true ); 250 mProfileBox->blockSignals( true );
252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 251 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
253 mProfileBox->blockSignals( false ); 252 mProfileBox->blockSignals( false );
254 return; 253 return;
255 } 254 }
256 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 255 //qDebug("cur i %d ",mProfileBox-> currentItem () );
257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 256 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 257 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
259 prof->setName( s ); 258 prof->setName( s );
260 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 259 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
261} 260}
262void KOSyncPrefsDialog::profileChanged( int item ) 261void KOSyncPrefsDialog::profileChanged( int item )
263{ 262{
264 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item ); 263 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item );
265 KSyncProfile* prof; 264 KSyncProfile* prof;
266 saveProfile(); 265 saveProfile();
267 currentSelection = item; 266 currentSelection = item;
268 prof = mSyncProfiles.at(item) ; 267 prof = mSyncProfiles.at(item) ;
269 mRemotePrecommand->setText(prof->getPreSyncCommand()); 268 mRemotePrecommand->setText(prof->getPreSyncCommand());
270 mRemotePostcommand->setText(prof->getPostSyncCommand()); 269 mRemotePostcommand->setText(prof->getPostSyncCommand());
271 mLocalTempFile->setText(prof->getLocalTempFile()); 270 mLocalTempFile->setText(prof->getLocalTempFile());
272 mRemoteFile->setText(prof->getRemoteFileName()) ; 271 mRemoteFile->setText(prof->getRemoteFileName()) ;
273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 272 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
274 mAskForPreferences->setChecked( prof->getAskForPreferences()); 273 mAskForPreferences->setChecked( prof->getAskForPreferences());
275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 274 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
276 mWriteBackFile->setChecked( prof->getWriteBackFile()); 275 mWriteBackFile->setChecked( prof->getWriteBackFile());
277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 276 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
278 277
279 switch ( prof->getSyncPrefs() ) { 278 switch ( prof->getSyncPrefs() ) {
280 case 0: 279 case 0:
281 loc->setChecked( true); 280 loc->setChecked( true);
282 break; 281 break;
283 case 1: 282 case 1:
284 rem->setChecked( true ); 283 rem->setChecked( true );
285 break; 284 break;
286 case 2: 285 case 2:
287 newest->setChecked( true); 286 newest->setChecked( true);
288 break; 287 break;
289 case 3: 288 case 3:
290 ask->setChecked( true); 289 ask->setChecked( true);
291 break; 290 break;
292 case 4: 291 case 4:
293 f_loc->setChecked( true); 292 f_loc->setChecked( true);
294 break; 293 break;
295 case 5: 294 case 5:
296 f_rem->setChecked( true); 295 f_rem->setChecked( true);
297 break; 296 break;
298 case 6: 297 case 6:
299 //both->setChecked( true); 298 //both->setChecked( true);
300 break; 299 break;
301 default: 300 default:
302 break; 301 break;
303 } 302 }
304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 303 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); 304 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
306 proGr->setEnabled( item > 2 ); 305 proGr->setEnabled( item > 2 );
307 if ( item < 3 ) { 306 if ( item < 3 ) {
308 localFileWidget->setEnabled(false); 307 localFileWidget->setEnabled(false);
309 remoteFileWidget->setEnabled(false); 308 remoteFileWidget->setEnabled(false);
310 309
311 } else 310 } else
312 kindChanged( prof->getIsLocalFileSync() ); 311 kindChanged( prof->getIsLocalFileSync() );
313} 312}
314 313
315void KOSyncPrefsDialog::fillSSH() 314void KOSyncPrefsDialog::fillSSH()
316{ 315{
317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 316 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
318 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 317 mLocalTempFile->setText("/tmp/mycalendar.ics" );
319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 318 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
320} 319}
321void KOSyncPrefsDialog::fillFTP() 320void KOSyncPrefsDialog::fillFTP()
322{ 321{
323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 322 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
324 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 323 mLocalTempFile->setText("/tmp/mycalendar.ics" );
325 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 324 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
326 325
327} 326}
328void KOSyncPrefsDialog::kindChanged( bool b ) 327void KOSyncPrefsDialog::kindChanged( bool b )
329{ 328{
330 329
331 localFileWidget->setEnabled(b); 330 localFileWidget->setEnabled(b);
332 remoteFileWidget->setEnabled(!b); 331 remoteFileWidget->setEnabled(!b);
333 332
334} 333}
335void KOSyncPrefsDialog::deleteProfile() 334void KOSyncPrefsDialog::deleteProfile()
336{ 335{
337 //qDebug("KOSyncPrefsDialog::deleteProfile() "); 336 //qDebug("KOSyncPrefsDialog::deleteProfile() ");
338 if ( currentSelection >= 0 ) { 337 if ( currentSelection >= 0 ) {
339 if ( currentSelection < 3 ) { 338 if ( currentSelection < 3 ) {
340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 339 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
341 return; 340 return;
342 } 341 }
343 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 342 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
344 mSyncProfiles.remove( temp ); 343 mSyncProfiles.remove( temp );
345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 344 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
346 insertProfiles(); 345 insertProfiles();
347 } 346 }
348} 347}
349 348
350void KOSyncPrefsDialog::saveProfile() 349void KOSyncPrefsDialog::saveProfile()
351{ 350{
352 KSyncProfile* prof; 351 KSyncProfile* prof;
353 if ( currentSelection >= 0 ) { 352 if ( currentSelection >= 0 ) {
354 prof = mSyncProfiles.at(currentSelection) ; 353 prof = mSyncProfiles.at(currentSelection) ;
355 prof->setPreSyncCommand( mRemotePrecommand->text()); 354 prof->setPreSyncCommand( mRemotePrecommand->text());
356 prof->setPostSyncCommand( mRemotePostcommand->text() ); 355 prof->setPostSyncCommand( mRemotePostcommand->text() );
357 prof->setLocalTempFile( mLocalTempFile->text()); 356 prof->setLocalTempFile( mLocalTempFile->text());
358 prof->setRemoteFileName( mRemoteFile->text() ); 357 prof->setRemoteFileName( mRemoteFile->text() );
359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 358 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
360 prof->setAskForPreferences( mAskForPreferences->isChecked()); 359 prof->setAskForPreferences( mAskForPreferences->isChecked());
361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 360 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
362 prof->setWriteBackFile( mWriteBackFile->isChecked()); 361 prof->setWriteBackFile( mWriteBackFile->isChecked());
363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 362 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 363 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
365 prof->setSyncPrefs( syncprefs); 364 prof->setSyncPrefs( syncprefs);
366 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 365 prof->setIsLocalFileSync( mIsLocal->isChecked() );
367 } 366 }
368 367
369} 368}
370 369
371void KOSyncPrefsDialog::insertProfiles() 370void KOSyncPrefsDialog::insertProfiles()
372{ 371{
373 int curItem = mProfileBox->currentItem(); 372 int curItem = mProfileBox->currentItem();
374 mProfileBox->blockSignals( true ); 373 mProfileBox->blockSignals( true );
375 mProfileBox->clear(); 374 mProfileBox->clear();
376 mProfileBox->insertStringList (mSyncProfileNames ); 375 mProfileBox->insertStringList (mSyncProfileNames );
377 int item = mSyncProfileNames.count() -1; 376 int item = mSyncProfileNames.count() -1;
378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 377 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
379 mProfileBox->setCurrentItem( curItem ); 378 mProfileBox->setCurrentItem( curItem );
380 else if ( item >= 0 ) { 379 else if ( item >= 0 ) {
381 mProfileBox->setCurrentItem( item ); 380 mProfileBox->setCurrentItem( item );
382 } 381 }
383 currentSelection = -1; 382 currentSelection = -1;
384 if ( mSyncProfileNames.count() > 0 ) { 383 if ( mSyncProfileNames.count() > 0 ) {
385 //qDebug(" profileChanged( mProfileBox->currentItem() "); 384 //qDebug(" profileChanged( mProfileBox->currentItem() ");
386 profileChanged( mProfileBox->currentItem() ); 385 profileChanged( mProfileBox->currentItem() );
387 currentSelection = mProfileBox->currentItem(); 386 currentSelection = mProfileBox->currentItem();
388 } 387 }
389 mProfileBox->blockSignals( false ); 388 mProfileBox->blockSignals( false );
390} 389}
391 390
392void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 391void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp )
393{ 392{
394 saveProfile(); 393 saveProfile();
395 mSyncProfiles.append( temp ); 394 mSyncProfiles.append( temp );
396 mSyncProfileNames << temp->getName(); 395 mSyncProfileNames << temp->getName();
397 insertProfiles(); 396 insertProfiles();
398 int last = mProfileBox->count() -1; 397 int last = mProfileBox->count() -1;
399 mProfileBox->blockSignals( true ); 398 mProfileBox->blockSignals( true );
400 mProfileBox->setCurrentItem( last ); 399 mProfileBox->setCurrentItem( last );
401 mProfileBox->blockSignals( false ); 400 mProfileBox->blockSignals( false );
402 profileChanged(last); 401 profileChanged(last);
403} 402}
404void KOSyncPrefsDialog::newProfile() 403void KOSyncPrefsDialog::newProfile()
405{ 404{
406 addProfile ( new KSyncProfile () ); 405 addProfile ( new KSyncProfile () );
407} 406}
408 407
409void KOSyncPrefsDialog::cloneProfile() 408void KOSyncPrefsDialog::cloneProfile()
410{ 409{
411 if ( currentSelection >= 0 ) 410 if ( currentSelection >= 0 )
412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 411 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
413 else 412 else
414 newProfile(); 413 newProfile();
415} 414}
416 415
417 416
418void KOSyncPrefsDialog::usrReadConfig() 417void KOSyncPrefsDialog::usrReadConfig()
419{ 418{
420 KConfig *config = KOGlobals::config(); 419 KConfig *config = KOGlobals::config();
421 config->setGroup("SyncProfiles"); 420 config->setGroup("SyncProfiles");
422 mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames; 421 mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames;
423 int i; 422 int i;
424 KSyncProfile* temp ; 423 KSyncProfile* temp ;
425 mSyncProfiles.clear(); 424 mSyncProfiles.clear();
426 for ( i = 0; i < mSyncProfileNames.count();++i ) { 425 for ( i = 0; i < mSyncProfileNames.count();++i ) {
427 temp = new KSyncProfile (); 426 temp = new KSyncProfile ();
428 temp->setName( mSyncProfileNames[i] ); 427 temp->setName( mSyncProfileNames[i] );
429 temp->readConfig( config ); 428 temp->readConfig( config );
430 mSyncProfiles.append( temp ); 429 mSyncProfiles.append( temp );
431 } 430 }
432 insertProfiles(); 431 insertProfiles();
433 mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 432 mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
434} 433}
435 434
436 435
437void KOSyncPrefsDialog::usrWriteConfig() 436void KOSyncPrefsDialog::usrWriteConfig()
438{ 437{
439 saveProfile(); 438 saveProfile();
440 if ( currentSelection >= 0 ) 439 if ( currentSelection >= 0 )
441 profileChanged(currentSelection); 440 profileChanged(currentSelection);
442 KConfig *config = KOGlobals::config(); 441 KConfig *config = KOGlobals::config();
443 config->setGroup("SyncProfiles"); 442 config->setGroup("SyncProfiles");
444 KSyncProfile* prof = mSyncProfiles.first(); 443 KSyncProfile* prof = mSyncProfiles.first();
445 while ( prof ) { 444 while ( prof ) {
446 prof->writeConfig(config); 445 prof->writeConfig(config);
447 prof = mSyncProfiles.next(); 446 prof = mSyncProfiles.next();
448 } 447 }
449 KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 448 KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
450 KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 449 KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
451 config->writeEntry("SyncProfileNames",&mSyncProfileNames); 450 config->writeEntry("SyncProfileNames",&mSyncProfileNames);
452} 451}
453 452
diff --git a/korganizer/kotimespanview.cpp b/korganizer/kotimespanview.cpp
index 266a403..3265a3a 100644
--- a/korganizer/kotimespanview.cpp
+++ b/korganizer/kotimespanview.cpp
@@ -1,110 +1,109 @@
1#include <qlayout.h> 1#include <qlayout.h>
2 2
3#include <kconfig.h> 3#include <kconfig.h>
4 4
5#include "timespanview.h" 5#include "timespanview.h"
6#include "koglobals.h" 6#include "koglobals.h"
7 7
8#include "kotimespanview.h" 8#include "kotimespanview.h"
9#include "kotimespanview.moc"
10 9
11KOTimeSpanView::KOTimeSpanView(Calendar *calendar, QWidget *parent, 10KOTimeSpanView::KOTimeSpanView(Calendar *calendar, QWidget *parent,
12 const char *name) : 11 const char *name) :
13 KOEventView( calendar, parent, name ) 12 KOEventView( calendar, parent, name )
14{ 13{
15 QBoxLayout *topLayout = new QVBoxLayout( this ); 14 QBoxLayout *topLayout = new QVBoxLayout( this );
16 15
17 mTimeSpanView = new TimeSpanView( this ); 16 mTimeSpanView = new TimeSpanView( this );
18 topLayout->addWidget( mTimeSpanView ); 17 topLayout->addWidget( mTimeSpanView );
19 18
20 connect( mTimeSpanView, SIGNAL( dateRangeChanged() ), SLOT( updateView() ) ); 19 connect( mTimeSpanView, SIGNAL( dateRangeChanged() ), SLOT( updateView() ) );
21} 20}
22 21
23KOTimeSpanView::~KOTimeSpanView() 22KOTimeSpanView::~KOTimeSpanView()
24{ 23{
25} 24}
26 25
27void KOTimeSpanView::readSettings() 26void KOTimeSpanView::readSettings()
28{ 27{
29 readSettings(KOGlobals::config()); 28 readSettings(KOGlobals::config());
30} 29}
31 30
32void KOTimeSpanView::readSettings(KConfig *config) 31void KOTimeSpanView::readSettings(KConfig *config)
33{ 32{
34// kdDebug() << "KOTimeSpanView::readSettings()" << endl; 33// kdDebug() << "KOTimeSpanView::readSettings()" << endl;
35 34
36 config->setGroup("Views"); 35 config->setGroup("Views");
37 36
38 QValueList<int> sizes = config->readIntListEntry("Separator TimeSpanView"); 37 QValueList<int> sizes = config->readIntListEntry("Separator TimeSpanView");
39 if (sizes.count() == 2) { 38 if (sizes.count() == 2) {
40 mTimeSpanView->setSplitterSizes(sizes); 39 mTimeSpanView->setSplitterSizes(sizes);
41 } 40 }
42} 41}
43 42
44void KOTimeSpanView::writeSettings(KConfig *config) 43void KOTimeSpanView::writeSettings(KConfig *config)
45{ 44{
46// kdDebug() << "KOTimeSpanView::writeSettings()" << endl; 45// kdDebug() << "KOTimeSpanView::writeSettings()" << endl;
47 46
48 config->setGroup("Views"); 47 config->setGroup("Views");
49 48
50 QValueList<int> list = mTimeSpanView->splitterSizes(); 49 QValueList<int> list = mTimeSpanView->splitterSizes();
51 config->writeEntry("Separator TimeSpanView",list); 50 config->writeEntry("Separator TimeSpanView",list);
52} 51}
53 52
54int KOTimeSpanView::maxDatesHint() 53int KOTimeSpanView::maxDatesHint()
55{ 54{
56 return 0; 55 return 0;
57} 56}
58 57
59int KOTimeSpanView::currentDateCount() 58int KOTimeSpanView::currentDateCount()
60{ 59{
61 return 0; 60 return 0;
62} 61}
63 62
64QPtrList<Incidence> KOTimeSpanView::selectedIncidences() 63QPtrList<Incidence> KOTimeSpanView::selectedIncidences()
65{ 64{
66 QPtrList<Incidence> selected; 65 QPtrList<Incidence> selected;
67 66
68 return selected; 67 return selected;
69} 68}
70 69
71void KOTimeSpanView::updateView() 70void KOTimeSpanView::updateView()
72{ 71{
73 insertItems( mTimeSpanView->startDateTime().date(), 72 insertItems( mTimeSpanView->startDateTime().date(),
74 mTimeSpanView->endDateTime().date() ); 73 mTimeSpanView->endDateTime().date() );
75} 74}
76 75
77void KOTimeSpanView::showDates(const QDate &start, const QDate &end) 76void KOTimeSpanView::showDates(const QDate &start, const QDate &end)
78{ 77{
79 QDate s = start.addDays( -2 ); 78 QDate s = start.addDays( -2 );
80 QDate e = end.addDays( 2 ); 79 QDate e = end.addDays( 2 );
81 80
82 insertItems( s, e ); 81 insertItems( s, e );
83} 82}
84 83
85void KOTimeSpanView::insertItems(const QDate &start, const QDate &end) 84void KOTimeSpanView::insertItems(const QDate &start, const QDate &end)
86{ 85{
87 mTimeSpanView->clear(); 86 mTimeSpanView->clear();
88 mTimeSpanView->setDateRange( start, end ); 87 mTimeSpanView->setDateRange( start, end );
89 88
90 QPtrList<Event> events = calendar()->events( start, end ); 89 QPtrList<Event> events = calendar()->events( start, end );
91 Event *event = events.first(); 90 Event *event = events.first();
92 while( event ) { 91 while( event ) {
93// kdDebug() << "KOTimeSpanView::showDates() add event: " << event->summary() 92// kdDebug() << "KOTimeSpanView::showDates() add event: " << event->summary()
94// << endl; 93// << endl;
95 94
96 mTimeSpanView->addItem( event ); 95 mTimeSpanView->addItem( event );
97 96
98 event = events.next(); 97 event = events.next();
99 } 98 }
100 99
101 mTimeSpanView->updateView(); 100 mTimeSpanView->updateView();
102} 101}
103 102
104void KOTimeSpanView::showEvents(QPtrList<Event> eventList) 103void KOTimeSpanView::showEvents(QPtrList<Event> eventList)
105{ 104{
106} 105}
107 106
108void KOTimeSpanView::changeEventDisplay(Event *, int) 107void KOTimeSpanView::changeEventDisplay(Event *, int)
109{ 108{
110} 109}
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 1c44f2b..abeb068 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,373 +1,372 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1997, 1998 Preston Brown 3 Copyright (c) 1997, 1998 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 <qtooltip.h> 25#include <qtooltip.h>
26#include <qframe.h> 26#include <qframe.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qhbox.h> 29#include <qhbox.h>
30#include <qdir.h> 30#include <qdir.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapplication.h> 32#include <qapplication.h>
33 33
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39 39
40#include <libkdepim/categoryselectdialog.h> 40#include <libkdepim/categoryselectdialog.h>
41#include <libkcal/calendarlocal.h> 41#include <libkcal/calendarlocal.h>
42#include <libkcal/calendarresources.h> 42#include <libkcal/calendarresources.h>
43#include <libkcal/resourcecalendar.h> 43#include <libkcal/resourcecalendar.h>
44#include <libkcal/icalformat.h> 44#include <libkcal/icalformat.h>
45#include <kresources/resourceselectdialog.h> 45#include <kresources/resourceselectdialog.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "kotodoeditor.h" 49#include "kotodoeditor.h"
50#include "kotodoeditor.moc"
51extern int globalFlagBlockAgenda; 50extern int globalFlagBlockAgenda;
52 51
53KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : 52KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
54 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) 53 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
55{ 54{
56 mTodo = 0; 55 mTodo = 0;
57 mRelatedTodo = 0; 56 mRelatedTodo = 0;
58 findButton(User1)->hide(); 57 findButton(User1)->hide();
59 init(); 58 init();
60} 59}
61 60
62KOTodoEditor::~KOTodoEditor() 61KOTodoEditor::~KOTodoEditor()
63{ 62{
64 emit dialogClose( mTodo ); 63 emit dialogClose( mTodo );
65} 64}
66 65
67void KOTodoEditor::init() 66void KOTodoEditor::init()
68{ 67{
69 setupGeneral(); 68 setupGeneral();
70 setupAttendeesTab(); 69 setupAttendeesTab();
71} 70}
72void KOTodoEditor::setCategories( QString s ) 71void KOTodoEditor::setCategories( QString s )
73{ 72{
74 mGeneral->setCategories(s); 73 mGeneral->setCategories(s);
75} 74}
76void KOTodoEditor::setSecrecy( int sec ) 75void KOTodoEditor::setSecrecy( int sec )
77{ 76{
78 mGeneral->setSecrecy( sec ); 77 mGeneral->setSecrecy( sec );
79} 78}
80void KOTodoEditor::reload() 79void KOTodoEditor::reload()
81{ 80{
82 if ( mTodo ) readTodo( mTodo ); 81 if ( mTodo ) readTodo( mTodo );
83} 82}
84 83
85void KOTodoEditor::setupGeneral() 84void KOTodoEditor::setupGeneral()
86{ 85{
87 mGeneral = new KOEditorGeneralTodo(this); 86 mGeneral = new KOEditorGeneralTodo(this);
88 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 87 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
89 88
90 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 89 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
91 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), 90 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
92 // mGeneral,SLOT(setCategories(const QString &))); 91 // mGeneral,SLOT(setCategories(const QString &)));
93 92
94 if (KOPrefs::instance()->mCompactDialogs) { 93 if (KOPrefs::instance()->mCompactDialogs) {
95 QFrame *topFrame = addPage(i18n("General")); 94 QFrame *topFrame = addPage(i18n("General"));
96 95
97 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 96 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
98 if ( QApplication::desktop()->width() < 480 ) { 97 if ( QApplication::desktop()->width() < 480 ) {
99 topLayout->setMargin(1); 98 topLayout->setMargin(1);
100 topLayout->setSpacing(1); 99 topLayout->setSpacing(1);
101 } else { 100 } else {
102 topLayout->setMargin(marginHint()-1); 101 topLayout->setMargin(marginHint()-1);
103 topLayout->setSpacing(spacingHint()-1); 102 topLayout->setSpacing(spacingHint()-1);
104 } 103 }
105 mGeneral->initHeader(topFrame,topLayout); 104 mGeneral->initHeader(topFrame,topLayout);
106 mGeneral->initTime(topFrame,topLayout); 105 mGeneral->initTime(topFrame,topLayout);
107 mGeneral->initAlarm(topFrame,topLayout); 106 mGeneral->initAlarm(topFrame,topLayout);
108 mGeneral->enableAlarm( false ); 107 mGeneral->enableAlarm( false );
109 108
110 109
111 QBoxLayout *priorityLayout; 110 QBoxLayout *priorityLayout;
112 if ( QApplication::desktop()->width() < 500 ) 111 if ( QApplication::desktop()->width() < 500 )
113 priorityLayout = new QVBoxLayout( topLayout ); 112 priorityLayout = new QVBoxLayout( topLayout );
114 else 113 else
115 priorityLayout = new QHBoxLayout( topLayout ); 114 priorityLayout = new QHBoxLayout( topLayout );
116 QWidget* prioWidget = new QWidget (topFrame); 115 QWidget* prioWidget = new QWidget (topFrame);
117 priorityLayout->addWidget( prioWidget ); 116 priorityLayout->addWidget( prioWidget );
118 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); 117 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget);
119 118
120 119
121 QIconSet icon; 120 QIconSet icon;
122 if ( QApplication::desktop()->width() < 321 ) 121 if ( QApplication::desktop()->width() < 321 )
123 icon = SmallIcon("fileexport16"); 122 icon = SmallIcon("fileexport16");
124 else 123 else
125 icon = SmallIcon("fileexport"); 124 icon = SmallIcon("fileexport");
126 QPushButton * saveTemplate = new QPushButton( prioWidget); 125 QPushButton * saveTemplate = new QPushButton( prioWidget);
127 saveTemplate->setIconSet (icon ) ; 126 saveTemplate->setIconSet (icon ) ;
128 int size = saveTemplate->sizeHint().height(); 127 int size = saveTemplate->sizeHint().height();
129 saveTemplate->setFixedSize( size, size ); 128 saveTemplate->setFixedSize( size, size );
130 if ( QApplication::desktop()->width() < 321 ) 129 if ( QApplication::desktop()->width() < 321 )
131 icon = SmallIcon("fileimport16"); 130 icon = SmallIcon("fileimport16");
132 else 131 else
133 icon = SmallIcon("fileimport"); 132 icon = SmallIcon("fileimport");
134 QPushButton * loadTemplate = new QPushButton( prioWidget); 133 QPushButton * loadTemplate = new QPushButton( prioWidget);
135 loadTemplate->setIconSet (icon ) ; 134 loadTemplate->setIconSet (icon ) ;
136 loadTemplate->setFixedSize( size, size ); 135 loadTemplate->setFixedSize( size, size );
137 136
138 priorityLayout2->addWidget(loadTemplate); 137 priorityLayout2->addWidget(loadTemplate);
139 priorityLayout2->addWidget(saveTemplate); 138 priorityLayout2->addWidget(saveTemplate);
140 mGeneral->initPriority(prioWidget,priorityLayout2); 139 mGeneral->initPriority(prioWidget,priorityLayout2);
141 mGeneral->initCategories( topFrame, priorityLayout ); 140 mGeneral->initCategories( topFrame, priorityLayout );
142 topLayout->addStretch(1); 141 topLayout->addStretch(1);
143 142
144 QFrame *topFrame2 = addPage(i18n("Details")); 143 QFrame *topFrame2 = addPage(i18n("Details"));
145 144
146 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 145 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
147 topLayout2->setMargin(marginHint()); 146 topLayout2->setMargin(marginHint());
148 topLayout2->setSpacing(spacingHint()); 147 topLayout2->setSpacing(spacingHint());
149 148
150 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); 149 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
151 mGeneral->initCompletion(topFrame2,completionLayout); 150 mGeneral->initCompletion(topFrame2,completionLayout);
152 151
153 152
154 mGeneral->initSecrecy( topFrame2, topLayout2 ); 153 mGeneral->initSecrecy( topFrame2, topLayout2 );
155 mGeneral->initDescription(topFrame2,topLayout2); 154 mGeneral->initDescription(topFrame2,topLayout2);
156 155
157 // QHBox * hb = new QHBox ( topFrame2 ); 156 // QHBox * hb = new QHBox ( topFrame2 );
158 // topLayout2->addWidget(hb); 157 // topLayout2->addWidget(hb);
159 // hb->setSpacing( 3 ); 158 // hb->setSpacing( 3 );
160 159
161 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 160 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
162 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 161 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
163 162
164 } else { 163 } else {
165 QFrame *topFrame = addPage(i18n("General")); 164 QFrame *topFrame = addPage(i18n("General"));
166 165
167 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 166 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
168 topLayout->setSpacing(spacingHint()); 167 topLayout->setSpacing(spacingHint());
169 168
170 mGeneral->initHeader(topFrame,topLayout); 169 mGeneral->initHeader(topFrame,topLayout);
171 mGeneral->initTime(topFrame,topLayout); 170 mGeneral->initTime(topFrame,topLayout);
172 mGeneral->initStatus(topFrame,topLayout); 171 mGeneral->initStatus(topFrame,topLayout);
173 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 172 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
174 mGeneral->initAlarm(topFrame,alarmLineLayout); 173 mGeneral->initAlarm(topFrame,alarmLineLayout);
175 mGeneral->initDescription(topFrame,topLayout); 174 mGeneral->initDescription(topFrame,topLayout);
176 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 175 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
177 mGeneral->initCategories( topFrame, detailsLayout ); 176 mGeneral->initCategories( topFrame, detailsLayout );
178 mGeneral->initSecrecy( topFrame, detailsLayout ); 177 mGeneral->initSecrecy( topFrame, detailsLayout );
179 } 178 }
180 mGeneral->finishSetup(); 179 mGeneral->finishSetup();
181 180
182} 181}
183 182
184void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 183void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
185{ 184{
186 //init(); 185 //init();
187 186
188 mTodo = todo; 187 mTodo = todo;
189 readTodo(mTodo); 188 readTodo(mTodo);
190 if ( editDescription ) { 189 if ( editDescription ) {
191 showPage( 1 ); 190 showPage( 1 );
192 mGeneral->setFocusOn( 1 ); 191 mGeneral->setFocusOn( 1 );
193 } else { 192 } else {
194 showPage( 0 ); 193 showPage( 0 );
195 mGeneral->setFocusOn( 2 ); 194 mGeneral->setFocusOn( 2 );
196 } 195 }
197} 196}
198 197
199void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 198void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
200{ 199{
201 //init(); 200 //init();
202 201
203 mTodo = 0; 202 mTodo = 0;
204 setDefaults(due,relatedTodo,allDay); 203 setDefaults(due,relatedTodo,allDay);
205} 204}
206 205
207void KOTodoEditor::loadDefaults() 206void KOTodoEditor::loadDefaults()
208{ 207{
209 setDefaults(QDateTime::currentDateTime().addDays(7),0,false); 208 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
210} 209}
211 210
212bool KOTodoEditor::processInput( bool emitTime ) 211bool KOTodoEditor::processInput( bool emitTime )
213{ 212{
214 if (!validateInput()) return false; 213 if (!validateInput()) return false;
215 214
216 Todo *todo = 0; 215 Todo *todo = 0;
217 216
218 if (mTodo) todo = mTodo; 217 if (mTodo) todo = mTodo;
219 else { 218 else {
220 todo = new Todo; 219 todo = new Todo;
221 todo->setOrganizer(KOPrefs::instance()->email()); 220 todo->setOrganizer(KOPrefs::instance()->email());
222 } 221 }
223 222
224 writeTodo(todo); 223 writeTodo(todo);
225 if ( emitTime ) { 224 if ( emitTime ) {
226 globalFlagBlockAgenda = 1; 225 globalFlagBlockAgenda = 1;
227 emit showAgendaView( false ); 226 emit showAgendaView( false );
228 if ( todo->hasDueDate() ) 227 if ( todo->hasDueDate() )
229 emit jumpToTime( todo->dtDue().date() ); 228 emit jumpToTime( todo->dtDue().date() );
230 globalFlagBlockAgenda = 2; 229 globalFlagBlockAgenda = 2;
231 } 230 }
232 if (mTodo) { 231 if (mTodo) {
233 todo->setRevision(todo->revision()+1); 232 todo->setRevision(todo->revision()+1);
234 emit todoChanged(todo); 233 emit todoChanged(todo);
235 } else { 234 } else {
236 mCalendar->addTodo(todo); 235 mCalendar->addTodo(todo);
237 mTodo = todo; 236 mTodo = todo;
238 emit todoAdded(todo); 237 emit todoAdded(todo);
239 } 238 }
240 239
241 return true; 240 return true;
242} 241}
243 242
244void KOTodoEditor::deleteTodo() 243void KOTodoEditor::deleteTodo()
245{ 244{
246 if (mTodo) { 245 if (mTodo) {
247 if (KOPrefs::instance()->mConfirm) { 246 if (KOPrefs::instance()->mConfirm) {
248 switch (msgItemDelete()) { 247 switch (msgItemDelete()) {
249 case KMessageBox::Continue: // OK 248 case KMessageBox::Continue: // OK
250 emit todoToBeDeleted(mTodo); 249 emit todoToBeDeleted(mTodo);
251 emit dialogClose(mTodo); 250 emit dialogClose(mTodo);
252 mCalendar->deleteTodo(mTodo); 251 mCalendar->deleteTodo(mTodo);
253 emit todoDeleted(); 252 emit todoDeleted();
254 reject(); 253 reject();
255 break; 254 break;
256 } 255 }
257 } 256 }
258 else { 257 else {
259 emit todoToBeDeleted(mTodo); 258 emit todoToBeDeleted(mTodo);
260 emit dialogClose(mTodo); 259 emit dialogClose(mTodo);
261 mCalendar->deleteTodo(mTodo); 260 mCalendar->deleteTodo(mTodo);
262 emit todoDeleted(); 261 emit todoDeleted();
263 reject(); 262 reject();
264 } 263 }
265 } else { 264 } else {
266 reject(); 265 reject();
267 } 266 }
268} 267}
269 268
270void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) 269void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
271{ 270{
272 mRelatedTodo = relatedEvent; 271 mRelatedTodo = relatedEvent;
273 272
274 mGeneral->setDefaults(due,allDay); 273 mGeneral->setDefaults(due,allDay);
275 mDetails->setDefaults(); 274 mDetails->setDefaults();
276 showPage( 0 ); 275 showPage( 0 );
277 if ( mRelatedTodo ) 276 if ( mRelatedTodo )
278 mGeneral->setCategories (mRelatedTodo->categoriesStr ()); 277 mGeneral->setCategories (mRelatedTodo->categoriesStr ());
279 mGeneral->setFocusOn( 2 ); 278 mGeneral->setFocusOn( 2 );
280} 279}
281 280
282void KOTodoEditor::readTodo(Todo *todo) 281void KOTodoEditor::readTodo(Todo *todo)
283{ 282{
284 mGeneral->readTodo(todo); 283 mGeneral->readTodo(todo);
285 mDetails->readEvent(todo); 284 mDetails->readEvent(todo);
286 mRelatedTodo = 0;//todo->relatedTo(); 285 mRelatedTodo = 0;//todo->relatedTo();
287 // categories 286 // categories
288 // mCategoryDialog->setSelected(todo->categories()); 287 // mCategoryDialog->setSelected(todo->categories());
289 288
290 // We should handle read-only events here. 289 // We should handle read-only events here.
291} 290}
292 291
293void KOTodoEditor::writeTodo(Todo *event) 292void KOTodoEditor::writeTodo(Todo *event)
294{ 293{
295 mGeneral->writeTodo(event); 294 mGeneral->writeTodo(event);
296 mDetails->writeEvent(event); 295 mDetails->writeEvent(event);
297 296
298 // set related event, i.e. parent to-do in this case. 297 // set related event, i.e. parent to-do in this case.
299 if (mRelatedTodo) { 298 if (mRelatedTodo) {
300 event->setRelatedTo(mRelatedTodo); 299 event->setRelatedTo(mRelatedTodo);
301 } 300 }
302} 301}
303 302
304bool KOTodoEditor::validateInput() 303bool KOTodoEditor::validateInput()
305{ 304{
306 if (!mGeneral->validateInput()) return false; 305 if (!mGeneral->validateInput()) return false;
307 if (!mDetails->validateInput()) return false; 306 if (!mDetails->validateInput()) return false;
308 return true; 307 return true;
309} 308}
310 309
311int KOTodoEditor::msgItemDelete() 310int KOTodoEditor::msgItemDelete()
312{ 311{
313 return KMessageBox::warningContinueCancel(this, 312 return KMessageBox::warningContinueCancel(this,
314 i18n("This item will be permanently deleted."), 313 i18n("This item will be permanently deleted."),
315 i18n("KOrganizer Confirmation"),i18n("Delete")); 314 i18n("KOrganizer Confirmation"),i18n("Delete"));
316} 315}
317 316
318void KOTodoEditor::modified (int modification) 317void KOTodoEditor::modified (int modification)
319{ 318{
320 if (modification == KOGlobals::CATEGORY_MODIFIED || 319 if (modification == KOGlobals::CATEGORY_MODIFIED ||
321 KOGlobals::UNKNOWN_MODIFIED == modification ) 320 KOGlobals::UNKNOWN_MODIFIED == modification )
322 // mCategoryDialog->setSelected (mTodo->categories ()); 321 // mCategoryDialog->setSelected (mTodo->categories ());
323 mGeneral->modified (mTodo, modification); 322 mGeneral->modified (mTodo, modification);
324 323
325} 324}
326 325
327void KOTodoEditor::slotLoadTemplate() 326void KOTodoEditor::slotLoadTemplate()
328{ 327{
329 328
330 QString fileName =locateLocal( "templates", "todos" ); 329 QString fileName =locateLocal( "templates", "todos" );
331 QDir t_dir; 330 QDir t_dir;
332 if ( !t_dir.exists(fileName) ) 331 if ( !t_dir.exists(fileName) )
333 t_dir.mkdir ( fileName ); 332 t_dir.mkdir ( fileName );
334 fileName += "/todo"; 333 fileName += "/todo";
335 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 334 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
336 if ( fileName.length() == 0 ) 335 if ( fileName.length() == 0 )
337 return; 336 return;
338 CalendarLocal cal; 337 CalendarLocal cal;
339 ICalFormat format; 338 ICalFormat format;
340 if ( !format.load( &cal, fileName ) ) { 339 if ( !format.load( &cal, fileName ) ) {
341 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 340 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
342 .arg( fileName ) ); 341 .arg( fileName ) );
343 return ; 342 return ;
344 } 343 }
345 QPtrList<Todo> todos = cal.todos(); 344 QPtrList<Todo> todos = cal.todos();
346 Todo * todo = todos.first(); 345 Todo * todo = todos.first();
347 if ( !todo ) { 346 if ( !todo ) {
348 KMessageBox::error( this, 347 KMessageBox::error( this,
349 i18n("Template does not\ncontain a valid Todo.")); 348 i18n("Template does not\ncontain a valid Todo."));
350 } else { 349 } else {
351 readTodo( todo ); 350 readTodo( todo );
352 } 351 }
353 352
354} 353}
355 354
356void KOTodoEditor::slotSaveTemplate() 355void KOTodoEditor::slotSaveTemplate()
357{ 356{
358 QString fileName =locateLocal( "templates", "todos" ); 357 QString fileName =locateLocal( "templates", "todos" );
359 QDir t_dir; 358 QDir t_dir;
360 if ( !t_dir.exists(fileName) ) 359 if ( !t_dir.exists(fileName) )
361 t_dir.mkdir ( fileName ); 360 t_dir.mkdir ( fileName );
362 fileName += "/todo"; 361 fileName += "/todo";
363 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); 362 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
364 if ( fileName.length() > 0 ) 363 if ( fileName.length() > 0 )
365 saveTemplate( fileName ); 364 saveTemplate( fileName );
366} 365}
367 366
368void KOTodoEditor::saveTemplate( const QString &templateName ) 367void KOTodoEditor::saveTemplate( const QString &templateName )
369{ 368{
370 Todo *todo = new Todo; 369 Todo *todo = new Todo;
371 writeTodo( todo ); 370 writeTodo( todo );
372 saveAsTemplate( todo, templateName ); 371 saveAsTemplate( todo, templateName );
373} 372}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 0708a69..d9e0a03 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1028 +1,1027 @@
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 27
28#include <qvbox.h> 28#include <qvbox.h>
29#include <kdebug.h> 29#include <kdebug.h>
30#include "koprefs.h" 30#include "koprefs.h"
31#include <klocale.h> 31#include <klocale.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/vcaldrag.h> 37#include <libkcal/vcaldrag.h>
38#include <libkcal/calfilter.h> 38#include <libkcal/calfilter.h>
39#include <libkcal/dndfactory.h> 39#include <libkcal/dndfactory.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <kresources/resourceselectdialog.h> 42#include <kresources/resourceselectdialog.h>
43#ifndef DESKTOP_VERSION 43#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#else 45#else
46#include <qapplication.h> 46#include <qapplication.h>
47#endif 47#endif
48#ifndef KORG_NOPRINTER 48#ifndef KORG_NOPRINTER
49#include "calprinter.h" 49#include "calprinter.h"
50#endif 50#endif
51#include "docprefs.h" 51#include "docprefs.h"
52 52
53#include "kotodoview.h" 53#include "kotodoview.h"
54using namespace KOrg; 54using namespace KOrg;
55#include "kotodoview.moc"
56 55
57KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
58 const char *name) : 57 const char *name) :
59 KListView(parent,name) 58 KListView(parent,name)
60{ 59{
61 mCalendar = calendar; 60 mCalendar = calendar;
62#ifndef DESKTOP_VERSION 61#ifndef DESKTOP_VERSION
63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 62 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
64#endif 63#endif
65 mOldCurrent = 0; 64 mOldCurrent = 0;
66 mMousePressed = false; 65 mMousePressed = false;
67 66
68 setAcceptDrops(true); 67 setAcceptDrops(true);
69 viewport()->setAcceptDrops(true); 68 viewport()->setAcceptDrops(true);
70 int size = 16; 69 int size = 16;
71 if (qApp->desktop()->width() < 300 ) 70 if (qApp->desktop()->width() < 300 )
72 size = 12; 71 size = 12;
73 setTreeStepSize( size + 6 ); 72 setTreeStepSize( size + 6 );
74 73
75} 74}
76 75
77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 76void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
78{ 77{
79#ifndef KORG_NODND 78#ifndef KORG_NODND
80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 79// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 80 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
82 !QTextDrag::canDecode( e ) ) { 81 !QTextDrag::canDecode( e ) ) {
83 e->ignore(); 82 e->ignore();
84 return; 83 return;
85 } 84 }
86 85
87 mOldCurrent = currentItem(); 86 mOldCurrent = currentItem();
88#endif 87#endif
89} 88}
90 89
91 90
92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 91void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
93{ 92{
94#ifndef KORG_NODND 93#ifndef KORG_NODND
95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 94// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
96 95
97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 96 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
98 !QTextDrag::canDecode( e ) ) { 97 !QTextDrag::canDecode( e ) ) {
99 e->ignore(); 98 e->ignore();
100 return; 99 return;
101 } 100 }
102 101
103 e->accept(); 102 e->accept();
104#endif 103#endif
105} 104}
106 105
107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 106void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
108{ 107{
109#ifndef KORG_NODND 108#ifndef KORG_NODND
110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 109// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
111 110
112 setCurrentItem(mOldCurrent); 111 setCurrentItem(mOldCurrent);
113 setSelected(mOldCurrent,true); 112 setSelected(mOldCurrent,true);
114#endif 113#endif
115} 114}
116 115
117void KOTodoListView::contentsDropEvent(QDropEvent *e) 116void KOTodoListView::contentsDropEvent(QDropEvent *e)
118{ 117{
119#ifndef KORG_NODND 118#ifndef KORG_NODND
120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 119// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
121 120
122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 121 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
123 !QTextDrag::canDecode( e ) ) { 122 !QTextDrag::canDecode( e ) ) {
124 e->ignore(); 123 e->ignore();
125 return; 124 return;
126 } 125 }
127 126
128 DndFactory factory( mCalendar ); 127 DndFactory factory( mCalendar );
129 Todo *todo = factory.createDropTodo(e); 128 Todo *todo = factory.createDropTodo(e);
130 129
131 if (todo) { 130 if (todo) {
132 e->acceptAction(); 131 e->acceptAction();
133 132
134 KOTodoViewItem *destination = 133 KOTodoViewItem *destination =
135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 134 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
136 Todo *destinationEvent = 0; 135 Todo *destinationEvent = 0;
137 if (destination) destinationEvent = destination->todo(); 136 if (destination) destinationEvent = destination->todo();
138 137
139 Todo *existingTodo = mCalendar->todo(todo->uid()); 138 Todo *existingTodo = mCalendar->todo(todo->uid());
140 139
141 if(existingTodo) { 140 if(existingTodo) {
142// kdDebug() << "Drop existing Todo" << endl; 141// kdDebug() << "Drop existing Todo" << endl;
143 Incidence *to = destinationEvent; 142 Incidence *to = destinationEvent;
144 while(to) { 143 while(to) {
145 if (to->uid() == todo->uid()) { 144 if (to->uid() == todo->uid()) {
146 KMessageBox::sorry(this, 145 KMessageBox::sorry(this,
147 i18n("Cannot move To-Do to itself or a child of itself"), 146 i18n("Cannot move To-Do to itself or a child of itself"),
148 i18n("Drop To-Do")); 147 i18n("Drop To-Do"));
149 delete todo; 148 delete todo;
150 return; 149 return;
151 } 150 }
152 to = to->relatedTo(); 151 to = to->relatedTo();
153 } 152 }
154 existingTodo->setRelatedTo(destinationEvent); 153 existingTodo->setRelatedTo(destinationEvent);
155 emit todoDropped(todo); 154 emit todoDropped(todo);
156 delete todo; 155 delete todo;
157 } else { 156 } else {
158// kdDebug() << "Drop new Todo" << endl; 157// kdDebug() << "Drop new Todo" << endl;
159 todo->setRelatedTo(destinationEvent); 158 todo->setRelatedTo(destinationEvent);
160 mCalendar->addTodo(todo); 159 mCalendar->addTodo(todo);
161 160
162 emit todoDropped(todo); 161 emit todoDropped(todo);
163 } 162 }
164 } 163 }
165 else { 164 else {
166 QString text; 165 QString text;
167 if (QTextDrag::decode(e,text)) { 166 if (QTextDrag::decode(e,text)) {
168 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 167 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
169 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 168 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
170 kdDebug() << "Dropped : " << text << endl; 169 kdDebug() << "Dropped : " << text << endl;
171 QStringList emails = QStringList::split(",",text); 170 QStringList emails = QStringList::split(",",text);
172 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 171 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
173 kdDebug() << " Email: " << (*it) << endl; 172 kdDebug() << " Email: " << (*it) << endl;
174 int pos = (*it).find("<"); 173 int pos = (*it).find("<");
175 QString name = (*it).left(pos); 174 QString name = (*it).left(pos);
176 QString email = (*it).mid(pos); 175 QString email = (*it).mid(pos);
177 if (!email.isEmpty() && todoi) { 176 if (!email.isEmpty() && todoi) {
178 todoi->todo()->addAttendee(new Attendee(name,email)); 177 todoi->todo()->addAttendee(new Attendee(name,email));
179 } 178 }
180 } 179 }
181 } 180 }
182 else { 181 else {
183 kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; 182 kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl;
184 e->ignore(); 183 e->ignore();
185 } 184 }
186 } 185 }
187#endif 186#endif
188} 187}
189 188
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 189void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
191{ 190{
192 QListView::contentsMousePressEvent(e); 191 QListView::contentsMousePressEvent(e);
193#ifndef KORG_NODND 192#ifndef KORG_NODND
194 QPoint p(contentsToViewport(e->pos())); 193 QPoint p(contentsToViewport(e->pos()));
195 QListViewItem *i = itemAt(p); 194 QListViewItem *i = itemAt(p);
196 if (i) { 195 if (i) {
197 // if the user clicked into the root decoration of the item, don't 196 // if the user clicked into the root decoration of the item, don't
198 // try to start a drag! 197 // try to start a drag!
199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 198 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 199 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
201 itemMargin() || 200 itemMargin() ||
202 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 201 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
203 if (e->button()==Qt::LeftButton) { 202 if (e->button()==Qt::LeftButton) {
204 mPressPos = e->pos(); 203 mPressPos = e->pos();
205 mMousePressed = true; 204 mMousePressed = true;
206 } 205 }
207 } 206 }
208 } 207 }
209#endif 208#endif
210} 209}
211 210
212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 211void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
213{ 212{
214#ifndef KORG_NODND 213#ifndef KORG_NODND
215// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; 214// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
216 QListView::contentsMouseMoveEvent(e); 215 QListView::contentsMouseMoveEvent(e);
217 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 216 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
218 QApplication::startDragDistance()) { 217 QApplication::startDragDistance()) {
219 mMousePressed = false; 218 mMousePressed = false;
220 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 219 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
221 if (item) { 220 if (item) {
222// kdDebug() << "Start Drag for item " << item->text(0) << endl; 221// kdDebug() << "Start Drag for item " << item->text(0) << endl;
223 DndFactory factory( mCalendar ); 222 DndFactory factory( mCalendar );
224 ICalDrag *vd = factory.createDragTodo( 223 ICalDrag *vd = factory.createDragTodo(
225 ((KOTodoViewItem *)item)->todo(),viewport()); 224 ((KOTodoViewItem *)item)->todo(),viewport());
226 if (vd->drag()) { 225 if (vd->drag()) {
227 kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; 226 kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl;
228 } 227 }
229/* 228/*
230 QString source = fullPath(item); 229 QString source = fullPath(item);
231 if ( QFile::exists(source) ) { 230 if ( QFile::exists(source) ) {
232 QUriDrag* ud = new QUriDrag(viewport()); 231 QUriDrag* ud = new QUriDrag(viewport());
233 ud->setFilenames( source ); 232 ud->setFilenames( source );
234 if ( ud->drag() ) 233 if ( ud->drag() )
235 QMessageBox::information( this, "Drag source", 234 QMessageBox::information( this, "Drag source",
236 QString("Delete ")+source, "Not implemented" ); 235 QString("Delete ")+source, "Not implemented" );
237*/ 236*/
238 } 237 }
239 } 238 }
240#endif 239#endif
241} 240}
242void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 241void KOTodoListView::keyPressEvent ( QKeyEvent * e )
243{ 242{
244 243
245 QListViewItem* cn; 244 QListViewItem* cn;
246 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 245 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
247 cn = currentItem(); 246 cn = currentItem();
248 if ( cn ) { 247 if ( cn ) {
249 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 248 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
250 if ( ci ){ 249 if ( ci ){
251 if ( e->state() == ShiftButton ) 250 if ( e->state() == ShiftButton )
252 ci->setOn( false ); 251 ci->setOn( false );
253 else 252 else
254 ci->setOn( true ); 253 ci->setOn( true );
255 cn = cn->nextSibling(); 254 cn = cn->nextSibling();
256 if ( cn ) { 255 if ( cn ) {
257 setCurrentItem ( cn ); 256 setCurrentItem ( cn );
258 ensureItemVisible ( cn ); 257 ensureItemVisible ( cn );
259 } 258 }
260 259
261 } 260 }
262 } 261 }
263 262
264 return; 263 return;
265 } 264 }
266 265
267 // qDebug("KOTodoListView::keyPressEvent "); 266 // qDebug("KOTodoListView::keyPressEvent ");
268 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || ( height() > 150 && width() > 200 ) ) { 267 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || ( height() > 150 && width() > 200 ) ) {
269 switch ( e->key() ) { 268 switch ( e->key() ) {
270 case Qt::Key_Down: 269 case Qt::Key_Down:
271 case Qt::Key_Up: 270 case Qt::Key_Up:
272 QListView::keyPressEvent ( e ); 271 QListView::keyPressEvent ( e );
273 break; 272 break;
274 default: 273 default:
275 e->ignore(); 274 e->ignore();
276 break; 275 break;
277 } 276 }
278 return; 277 return;
279 } 278 }
280 e->ignore(); 279 e->ignore();
281} 280}
282void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 281void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
283{ 282{
284 QListView::contentsMouseReleaseEvent(e); 283 QListView::contentsMouseReleaseEvent(e);
285 mMousePressed = false; 284 mMousePressed = false;
286} 285}
287 286
288void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 287void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
289{ 288{
290 if (!e) return; 289 if (!e) return;
291 290
292 QPoint vp = contentsToViewport(e->pos()); 291 QPoint vp = contentsToViewport(e->pos());
293 292
294 QListViewItem *item = itemAt(vp); 293 QListViewItem *item = itemAt(vp);
295 294
296 emit double_Clicked(item); 295 emit double_Clicked(item);
297 if (!item) return; 296 if (!item) return;
298 297
299 emit doubleClicked(item,vp,0); 298 emit doubleClicked(item,vp,0);
300} 299}
301 300
302///////////////////////////////////////////////////////////////////////////// 301/////////////////////////////////////////////////////////////////////////////
303 302
304KOQuickTodo::KOQuickTodo(QWidget *parent) : 303KOQuickTodo::KOQuickTodo(QWidget *parent) :
305 QLineEdit(parent) 304 QLineEdit(parent)
306{ 305{
307 setText(i18n("Click to add a new Todo")); 306 setText(i18n("Click to add a new Todo"));
308} 307}
309 308
310void KOQuickTodo::focusInEvent(QFocusEvent *ev) 309void KOQuickTodo::focusInEvent(QFocusEvent *ev)
311{ 310{
312 if ( text()==i18n("Click to add a new Todo") ) 311 if ( text()==i18n("Click to add a new Todo") )
313 setText(""); 312 setText("");
314 QLineEdit::focusInEvent(ev); 313 QLineEdit::focusInEvent(ev);
315} 314}
316 315
317void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 316void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
318{ 317{
319 setText(i18n("Click to add a new Todo")); 318 setText(i18n("Click to add a new Todo"));
320 QLineEdit::focusOutEvent(ev); 319 QLineEdit::focusOutEvent(ev);
321} 320}
322 321
323///////////////////////////////////////////////////////////////////////////// 322/////////////////////////////////////////////////////////////////////////////
324 323
325KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 324KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
326 KOrg::BaseView(calendar,parent,name) 325 KOrg::BaseView(calendar,parent,name)
327{ 326{
328 QBoxLayout *topLayout = new QVBoxLayout(this); 327 QBoxLayout *topLayout = new QVBoxLayout(this);
329 mName = QString ( name ); 328 mName = QString ( name );
330 mBlockUpdate = false; 329 mBlockUpdate = false;
331 mQuickAdd = new KOQuickTodo(this); 330 mQuickAdd = new KOQuickTodo(this);
332 topLayout->addWidget(mQuickAdd); 331 topLayout->addWidget(mQuickAdd);
333 332
334 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 333 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
335 334
336 mTodoListView = new KOTodoListView(calendar,this); 335 mTodoListView = new KOTodoListView(calendar,this);
337 topLayout->addWidget(mTodoListView); 336 topLayout->addWidget(mTodoListView);
338 //mTodoListView->header()->setMaximumHeight(30); 337 //mTodoListView->header()->setMaximumHeight(30);
339 mTodoListView->setRootIsDecorated(true); 338 mTodoListView->setRootIsDecorated(true);
340 mTodoListView->setAllColumnsShowFocus(true); 339 mTodoListView->setAllColumnsShowFocus(true);
341 340
342 mTodoListView->setShowSortIndicator(true); 341 mTodoListView->setShowSortIndicator(true);
343 342
344 mTodoListView->addColumn(i18n("Todo")); 343 mTodoListView->addColumn(i18n("Todo"));
345 mTodoListView->addColumn(i18n("Prio")); 344 mTodoListView->addColumn(i18n("Prio"));
346 mTodoListView->setColumnAlignment(1,AlignHCenter); 345 mTodoListView->setColumnAlignment(1,AlignHCenter);
347 mTodoListView->addColumn(i18n("Complete")); 346 mTodoListView->addColumn(i18n("Complete"));
348 mTodoListView->setColumnAlignment(2,AlignHCenter); 347 mTodoListView->setColumnAlignment(2,AlignHCenter);
349 mTodoListView->addColumn(i18n("Due Date")); 348 mTodoListView->addColumn(i18n("Due Date"));
350 mTodoListView->setColumnAlignment(3,AlignLeft); 349 mTodoListView->setColumnAlignment(3,AlignLeft);
351 mTodoListView->addColumn(i18n("Due Time")); 350 mTodoListView->addColumn(i18n("Due Time"));
352 mTodoListView->setColumnAlignment(4,AlignHCenter); 351 mTodoListView->setColumnAlignment(4,AlignHCenter);
353 mTodoListView->addColumn(i18n("Cancelled")); 352 mTodoListView->addColumn(i18n("Cancelled"));
354 mTodoListView->addColumn(i18n("Categories")); 353 mTodoListView->addColumn(i18n("Categories"));
355#if 0 354#if 0
356 mTodoListView->addColumn(i18n("Sort Id")); 355 mTodoListView->addColumn(i18n("Sort Id"));
357 mTodoListView->setColumnAlignment(4,AlignHCenter); 356 mTodoListView->setColumnAlignment(4,AlignHCenter);
358#endif 357#endif
359 358
360 mTodoListView->setMinimumHeight( 60 ); 359 mTodoListView->setMinimumHeight( 60 );
361 mTodoListView->setItemsRenameable( true ); 360 mTodoListView->setItemsRenameable( true );
362 mTodoListView->setRenameable( 0 ); 361 mTodoListView->setRenameable( 0 );
363 mTodoListView->setColumnWidth( 0, 120 ); 362 mTodoListView->setColumnWidth( 0, 120 );
364 mTodoListView->setColumnWidthMode(0, QListView::Manual); 363 mTodoListView->setColumnWidthMode(0, QListView::Manual);
365 mTodoListView->setColumnWidthMode(1, QListView::Manual); 364 mTodoListView->setColumnWidthMode(1, QListView::Manual);
366 mTodoListView->setColumnWidthMode(2, QListView::Manual); 365 mTodoListView->setColumnWidthMode(2, QListView::Manual);
367 mTodoListView->setColumnWidthMode(3, QListView::Manual); 366 mTodoListView->setColumnWidthMode(3, QListView::Manual);
368 mTodoListView->setColumnWidthMode(4, QListView::Manual); 367 mTodoListView->setColumnWidthMode(4, QListView::Manual);
369 mTodoListView->setColumnWidthMode(5, QListView::Manual); 368 mTodoListView->setColumnWidthMode(5, QListView::Manual);
370 mTodoListView->setColumnAlignment( 2, AlignCenter ); 369 mTodoListView->setColumnAlignment( 2, AlignCenter );
371#if 0 370#if 0
372 mTodoListView->setColumnWidthMode(6, QListView::Manual); 371 mTodoListView->setColumnWidthMode(6, QListView::Manual);
373#endif 372#endif
374 373
375 mPriorityPopupMenu = new QPopupMenu(this); 374 mPriorityPopupMenu = new QPopupMenu(this);
376 for (int i = 1; i <= 5; i++) { 375 for (int i = 1; i <= 5; i++) {
377 QString label = QString ("%1").arg (i); 376 QString label = QString ("%1").arg (i);
378 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 377 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
379 } 378 }
380 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 379 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
381 380
382 mPercentageCompletedPopupMenu = new QPopupMenu(this); 381 mPercentageCompletedPopupMenu = new QPopupMenu(this);
383 for (int i = 0; i <= 100; i+=20) { 382 for (int i = 0; i <= 100; i+=20) {
384 QString label = QString ("%1 %").arg (i); 383 QString label = QString ("%1 %").arg (i);
385 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 384 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
386 } 385 }
387 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 386 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
388 387
389 388
390 389
391 mItemPopupMenu = new QPopupMenu(this); 390 mItemPopupMenu = new QPopupMenu(this);
392 mItemPopupMenu->insertItem(i18n("Show..."), this, 391 mItemPopupMenu->insertItem(i18n("Show..."), this,
393 SLOT (showTodo())); 392 SLOT (showTodo()));
394 mItemPopupMenu->insertItem(i18n("Edit..."), this, 393 mItemPopupMenu->insertItem(i18n("Edit..."), this,
395 SLOT (editTodo())); 394 SLOT (editTodo()));
396 mItemPopupMenu->insertItem( i18n("Delete"), this, 395 mItemPopupMenu->insertItem( i18n("Delete"), this,
397 SLOT (deleteTodo())); 396 SLOT (deleteTodo()));
398 mItemPopupMenu->insertItem( i18n("Clone..."), this, 397 mItemPopupMenu->insertItem( i18n("Clone..."), this,
399 SLOT (cloneTodo())); 398 SLOT (cloneTodo()));
400 mItemPopupMenu->insertItem( i18n("Move..."), this, 399 mItemPopupMenu->insertItem( i18n("Move..."), this,
401 SLOT (moveTodo())); 400 SLOT (moveTodo()));
402 mItemPopupMenu->insertItem( i18n("Beam..."), this, 401 mItemPopupMenu->insertItem( i18n("Beam..."), this,
403 SLOT (beamTodo())); 402 SLOT (beamTodo()));
404 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 403 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
405 SLOT (cancelTodo())); 404 SLOT (cancelTodo()));
406 mItemPopupMenu->insertSeparator(); 405 mItemPopupMenu->insertSeparator();
407 406
408 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 407 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
409 SLOT (newTodo())); 408 SLOT (newTodo()));
410 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 409 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
411 SLOT (newSubTodo())); 410 SLOT (newSubTodo()));
412 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 411 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
413 SLOT (unparentTodo())); 412 SLOT (unparentTodo()));
414 mItemPopupMenu->insertSeparator(); 413 mItemPopupMenu->insertSeparator();
415 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 414 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
416 this, SLOT( purgeCompleted() ) ); 415 this, SLOT( purgeCompleted() ) );
417 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 416 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
418 this, SLOT( toggleCompleted() ),0, 33 ); 417 this, SLOT( toggleCompleted() ),0, 33 );
419 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 418 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
420 this, SLOT( toggleQuickTodo() ),0, 34 ); 419 this, SLOT( toggleQuickTodo() ),0, 34 );
421 420
422 mPopupMenu = new QPopupMenu(this); 421 mPopupMenu = new QPopupMenu(this);
423 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 422 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
424 SLOT (newTodo()),0,1); 423 SLOT (newTodo()),0,1);
425 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 424 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
426 this, SLOT(purgeCompleted()),0,2); 425 this, SLOT(purgeCompleted()),0,2);
427 mPopupMenu->insertItem(i18n("Show Completed"), 426 mPopupMenu->insertItem(i18n("Show Completed"),
428 this, SLOT( toggleCompleted() ),0,3 ); 427 this, SLOT( toggleCompleted() ),0,3 );
429 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 428 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
430 this, SLOT( toggleQuickTodo() ),0,4 ); 429 this, SLOT( toggleQuickTodo() ),0,4 );
431 mDocPrefs = new DocPrefs( name ); 430 mDocPrefs = new DocPrefs( name );
432 431
433 mPopupMenu->setCheckable( true ); 432 mPopupMenu->setCheckable( true );
434 mItemPopupMenu->setCheckable( true ); 433 mItemPopupMenu->setCheckable( true );
435 // Double clicking conflicts with opening/closing the subtree 434 // Double clicking conflicts with opening/closing the subtree
436 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 435 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
437 SLOT( editItem( QListViewItem *) ) ); 436 SLOT( editItem( QListViewItem *) ) );
438 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 437 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
439 const QPoint &,int ) ), 438 const QPoint &,int ) ),
440 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 439 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
441 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 440 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
442 SLOT( itemClicked( QListViewItem * ) ) ); 441 SLOT( itemClicked( QListViewItem * ) ) );
443 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 442 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
444 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 443 SLOT( itemDoubleClicked( QListViewItem * ) ) );
445 connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), 444 connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ),
446 SLOT( updateView() ) ); 445 SLOT( updateView() ) );
447 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 446 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
448 SLOT( itemStateChanged( QListViewItem * ) ) ); 447 SLOT( itemStateChanged( QListViewItem * ) ) );
449 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 448 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
450 SLOT( itemStateChanged( QListViewItem * ) ) ); 449 SLOT( itemStateChanged( QListViewItem * ) ) );
451 450
452#if 0 451#if 0
453 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 452 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
454 SLOT(selectionChanged(QListViewItem *))); 453 SLOT(selectionChanged(QListViewItem *)));
455 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 454 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
456 SLOT(selectionChanged(QListViewItem *))); 455 SLOT(selectionChanged(QListViewItem *)));
457 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 456 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
458 SLOT(selectionChanged(QListViewItem *))); 457 SLOT(selectionChanged(QListViewItem *)));
459#endif 458#endif
460 connect( mTodoListView, SIGNAL(selectionChanged() ), 459 connect( mTodoListView, SIGNAL(selectionChanged() ),
461 SLOT( processSelectionChange() ) ); 460 SLOT( processSelectionChange() ) );
462 connect( mQuickAdd, SIGNAL( returnPressed () ), 461 connect( mQuickAdd, SIGNAL( returnPressed () ),
463 SLOT( addQuickTodo() ) ); 462 SLOT( addQuickTodo() ) );
464// if ( QApplication::desktop()->width() < 480 ) { 463// if ( QApplication::desktop()->width() < 480 ) {
465// setNarrow(); 464// setNarrow();
466 // mTodoListView->setColumnWidth( 0, 100 ); 465 // mTodoListView->setColumnWidth( 0, 100 );
467 466
468 // } 467 // }
469 468
470} 469}
471 470
472KOTodoView::~KOTodoView() 471KOTodoView::~KOTodoView()
473{ 472{
474 delete mDocPrefs; 473 delete mDocPrefs;
475} 474}
476 475
477void KOTodoView::jumpToDate () 476void KOTodoView::jumpToDate ()
478{ 477{
479 // if (mActiveItem) { 478 // if (mActiveItem) {
480// mActiveItem->todo()); 479// mActiveItem->todo());
481// if ( mActiveItem->todo()->hasDueDate() ) 480// if ( mActiveItem->todo()->hasDueDate() )
482// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 481// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
483} 482}
484 483
485void KOTodoView::setNarrow() 484void KOTodoView::setNarrow()
486{ 485{
487 //mTodoListView->setColumnWidth( 0, 120 ); 486 //mTodoListView->setColumnWidth( 0, 120 );
488 mTodoListView->setColumnWidth( 1, 35 ); 487 mTodoListView->setColumnWidth( 1, 35 );
489 mTodoListView->setColumnWidth( 2, 40 ); 488 mTodoListView->setColumnWidth( 2, 40 );
490 mTodoListView->setColumnWidth( 3, 80 ); 489 mTodoListView->setColumnWidth( 3, 80 );
491 mTodoListView->setColumnWidth( 4, 40 ); 490 mTodoListView->setColumnWidth( 4, 40 );
492 mTodoListView->setColumnWidth( 5, 90 ); 491 mTodoListView->setColumnWidth( 5, 90 );
493 492
494} 493}
495void KOTodoView::updateView() 494void KOTodoView::updateView()
496{ 495{
497// kdDebug() << "KOTodoView::updateView()" << endl; 496// kdDebug() << "KOTodoView::updateView()" << endl;
498 QFont fo = KOPrefs::instance()->mTodoViewFont; 497 QFont fo = KOPrefs::instance()->mTodoViewFont;
499 mTodoListView->clear(); 498 mTodoListView->clear();
500 if ( mName == "todolistsmall" ) { 499 if ( mName == "todolistsmall" ) {
501 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 500 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
502 int ps = fo.pointSize() -2; 501 int ps = fo.pointSize() -2;
503 if ( ps > 12 ) 502 if ( ps > 12 )
504 ps -= 2; 503 ps -= 2;
505 fo.setPointSize( ps ); 504 fo.setPointSize( ps );
506 } 505 }
507 } 506 }
508 507
509 mTodoListView->setFont( fo ); 508 mTodoListView->setFont( fo );
510 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 509 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
511 //mTodoListView->header()->setMaximumHeight(fm.height()); 510 //mTodoListView->header()->setMaximumHeight(fm.height());
512 QPtrList<Todo> todoList = calendar()->todos(); 511 QPtrList<Todo> todoList = calendar()->todos();
513 512
514/* 513/*
515 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 514 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
516 Event *t; 515 Event *t;
517 for(t = todoList.first(); t; t = todoList.next()) { 516 for(t = todoList.first(); t; t = todoList.next()) {
518 kdDebug() << " " << t->getSummary() << endl; 517 kdDebug() << " " << t->getSummary() << endl;
519 518
520 if (t->getRelatedTo()) { 519 if (t->getRelatedTo()) {
521 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 520 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
522 } 521 }
523 522
524 QPtrList<Event> l = t->getRelations(); 523 QPtrList<Event> l = t->getRelations();
525 Event *c; 524 Event *c;
526 for(c=l.first();c;c=l.next()) { 525 for(c=l.first();c;c=l.next()) {
527 kdDebug() << " - relation: " << c->getSummary() << endl; 526 kdDebug() << " - relation: " << c->getSummary() << endl;
528 } 527 }
529 } 528 }
530*/ 529*/
531 530
532 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 531 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
533 // specific order of events. That means that we have to generate parent items 532 // specific order of events. That means that we have to generate parent items
534 // recursively for proper hierarchical display of Todos. 533 // recursively for proper hierarchical display of Todos.
535 mTodoMap.clear(); 534 mTodoMap.clear();
536 Todo *todo; 535 Todo *todo;
537 todo = todoList.first();// todo; todo = todoList.next()) { 536 todo = todoList.first();// todo; todo = todoList.next()) {
538 while ( todo ) { 537 while ( todo ) {
539 bool next = true; 538 bool next = true;
540 // qDebug("todo %s ", todo->summary().latin1()); 539 // qDebug("todo %s ", todo->summary().latin1());
541 Incidence *incidence = todo->relatedTo(); 540 Incidence *incidence = todo->relatedTo();
542 while ( incidence ) { 541 while ( incidence ) {
543 if ( incidence->type() == "Todo") { 542 if ( incidence->type() == "Todo") {
544 //qDebug("related %s ",incidence->summary().latin1() ); 543 //qDebug("related %s ",incidence->summary().latin1() );
545 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 544 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
546 //qDebug("related not found "); 545 //qDebug("related not found ");
547 todoList.remove( ); 546 todoList.remove( );
548 todo = todoList.current(); 547 todo = todoList.current();
549 next = false; 548 next = false;
550 incidence = 0; 549 incidence = 0;
551 550
552 } else { 551 } else {
553 //qDebug("related found "); 552 //qDebug("related found ");
554 incidence = incidence->relatedTo(); 553 incidence = incidence->relatedTo();
555 } 554 }
556 } else 555 } else
557 incidence = 0; 556 incidence = 0;
558 } 557 }
559 if ( next ) 558 if ( next )
560 todo = todoList.next(); 559 todo = todoList.next();
561 } 560 }
562// qDebug("again .... "); 561// qDebug("again .... ");
563// for(todo = todoList.first(); todo; todo = todoList.next()) { 562// for(todo = todoList.first(); todo; todo = todoList.next()) {
564 563
565// qDebug("yytodo %s ", todo->summary().latin1()); 564// qDebug("yytodo %s ", todo->summary().latin1());
566// } 565// }
567 //qDebug("for "); 566 //qDebug("for ");
568 for(todo = todoList.first(); todo; todo = todoList.next()) { 567 for(todo = todoList.first(); todo; todo = todoList.next()) {
569 if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) 568 if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) )
570 { 569 {
571 insertTodoItem(todo); 570 insertTodoItem(todo);
572 } 571 }
573 } 572 }
574 //qDebug("for end "); 573 //qDebug("for end ");
575 // Restore opened/closed state 574 // Restore opened/closed state
576 mTodoListView->blockSignals( true ); 575 mTodoListView->blockSignals( true );
577 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 576 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
578 mTodoListView->blockSignals( false ); 577 mTodoListView->blockSignals( false );
579 mTodoListView->setFocus(); 578 mTodoListView->setFocus();
580 processSelectionChange(); 579 processSelectionChange();
581} 580}
582 581
583void KOTodoView::restoreItemState( QListViewItem *item ) 582void KOTodoView::restoreItemState( QListViewItem *item )
584{ 583{
585 while( item ) { 584 while( item ) {
586 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 585 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
587 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 586 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
588 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 587 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
589 item = item->nextSibling(); 588 item = item->nextSibling();
590 } 589 }
591} 590}
592 591
593 592
594QMap<Todo *,KOTodoViewItem *>::ConstIterator 593QMap<Todo *,KOTodoViewItem *>::ConstIterator
595 KOTodoView::insertTodoItem(Todo *todo) 594 KOTodoView::insertTodoItem(Todo *todo)
596{ 595{
597// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 596// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
598 // TODO: Check, if dynmaic cast is necessary 597 // TODO: Check, if dynmaic cast is necessary
599 598
600 599
601 Incidence *incidence = todo->relatedTo(); 600 Incidence *incidence = todo->relatedTo();
602 if (incidence && incidence->type() == "Todo") { 601 if (incidence && incidence->type() == "Todo") {
603 Todo *relatedTodo = static_cast<Todo *>(incidence); 602 Todo *relatedTodo = static_cast<Todo *>(incidence);
604 603
605// kdDebug() << " has Related" << endl; 604// kdDebug() << " has Related" << endl;
606 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 605 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
607 itemIterator = mTodoMap.find(relatedTodo); 606 itemIterator = mTodoMap.find(relatedTodo);
608 if (itemIterator == mTodoMap.end()) { 607 if (itemIterator == mTodoMap.end()) {
609// kdDebug() << " related not yet in list" << endl; 608// kdDebug() << " related not yet in list" << endl;
610 itemIterator = insertTodoItem (relatedTodo); 609 itemIterator = insertTodoItem (relatedTodo);
611 } 610 }
612 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 611 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
613 // and one into the map. Sure finding is more easy but why? -zecke 612 // and one into the map. Sure finding is more easy but why? -zecke
614 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 613 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
615 return mTodoMap.insert(todo,todoItem); 614 return mTodoMap.insert(todo,todoItem);
616 } else { 615 } else {
617// kdDebug() << " no Related" << endl; 616// kdDebug() << " no Related" << endl;
618 // see above -zecke 617 // see above -zecke
619 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 618 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
620 return mTodoMap.insert(todo,todoItem); 619 return mTodoMap.insert(todo,todoItem);
621 } 620 }
622} 621}
623 622
624 623
625void KOTodoView::updateConfig() 624void KOTodoView::updateConfig()
626{ 625{
627 updateView(); 626 updateView();
628 mTodoListView->repaintContents(); 627 mTodoListView->repaintContents();
629} 628}
630 629
631QPtrList<Incidence> KOTodoView::selectedIncidences() 630QPtrList<Incidence> KOTodoView::selectedIncidences()
632{ 631{
633 QPtrList<Incidence> selected; 632 QPtrList<Incidence> selected;
634 633
635 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 634 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
636// if (!item) item = mActiveItem; 635// if (!item) item = mActiveItem;
637 if (item) selected.append(item->todo()); 636 if (item) selected.append(item->todo());
638 637
639 return selected; 638 return selected;
640} 639}
641 640
642QPtrList<Todo> KOTodoView::selectedTodos() 641QPtrList<Todo> KOTodoView::selectedTodos()
643{ 642{
644 QPtrList<Todo> selected; 643 QPtrList<Todo> selected;
645 644
646 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 645 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
647// if (!item) item = mActiveItem; 646// if (!item) item = mActiveItem;
648 if (item) selected.append(item->todo()); 647 if (item) selected.append(item->todo());
649 648
650 return selected; 649 return selected;
651} 650}
652 651
653void KOTodoView::changeEventDisplay(Event *, int) 652void KOTodoView::changeEventDisplay(Event *, int)
654{ 653{
655 updateView(); 654 updateView();
656} 655}
657 656
658void KOTodoView::showDates(const QDate &, const QDate &) 657void KOTodoView::showDates(const QDate &, const QDate &)
659{ 658{
660} 659}
661 660
662void KOTodoView::showEvents(QPtrList<Event>) 661void KOTodoView::showEvents(QPtrList<Event>)
663{ 662{
664 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 663 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
665} 664}
666 665
667void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 666void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
668 const QDate &td) 667 const QDate &td)
669{ 668{
670#ifndef KORG_NOPRINTER 669#ifndef KORG_NOPRINTER
671 calPrinter->preview(CalPrinter::Todolist, fd, td); 670 calPrinter->preview(CalPrinter::Todolist, fd, td);
672#endif 671#endif
673} 672}
674 673
675void KOTodoView::editItem(QListViewItem *item ) 674void KOTodoView::editItem(QListViewItem *item )
676{ 675{
677 // qDebug("editItem(QListViewItem *item ) "); 676 // qDebug("editItem(QListViewItem *item ) ");
678 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 677 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
679} 678}
680 679
681void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 680void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
682{ 681{
683 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 682 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
684} 683}
685 684
686void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) 685void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
687{ 686{
688 687
689 mActiveItem = (KOTodoViewItem *)item; 688 mActiveItem = (KOTodoViewItem *)item;
690 if (item) { 689 if (item) {
691 switch (column){ 690 switch (column){
692 case 1: 691 case 1:
693 mPriorityPopupMenu->popup(QCursor::pos ()); break; 692 mPriorityPopupMenu->popup(QCursor::pos ()); break;
694 case 2: 693 case 2:
695 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 694 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
696 case 3: 695 case 3:
697 moveTodo(); 696 moveTodo();
698 break; 697 break;
699 case 6: 698 case 6:
700 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 699 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
701 default: 700 default:
702 mItemPopupMenu->popup(QCursor::pos()); 701 mItemPopupMenu->popup(QCursor::pos());
703 } 702 }
704 } else mPopupMenu->popup(QCursor::pos()); 703 } else mPopupMenu->popup(QCursor::pos());
705} 704}
706void KOTodoView::newTodo() 705void KOTodoView::newTodo()
707{ 706{
708 emit newTodoSignal(); 707 emit newTodoSignal();
709} 708}
710 709
711void KOTodoView::newSubTodo() 710void KOTodoView::newSubTodo()
712{ 711{
713 if (mActiveItem) { 712 if (mActiveItem) {
714 emit newSubTodoSignal(mActiveItem->todo()); 713 emit newSubTodoSignal(mActiveItem->todo());
715 } 714 }
716} 715}
717void KOTodoView::unparentTodo() 716void KOTodoView::unparentTodo()
718{ 717{
719 if (mActiveItem) { 718 if (mActiveItem) {
720 emit unparentTodoSignal(mActiveItem->todo()); 719 emit unparentTodoSignal(mActiveItem->todo());
721 } 720 }
722} 721}
723void KOTodoView::editTodo() 722void KOTodoView::editTodo()
724{ 723{
725 if (mActiveItem) { 724 if (mActiveItem) {
726 emit editTodoSignal(mActiveItem->todo()); 725 emit editTodoSignal(mActiveItem->todo());
727 } 726 }
728} 727}
729void KOTodoView::cloneTodo() 728void KOTodoView::cloneTodo()
730{ 729{
731 if (mActiveItem) { 730 if (mActiveItem) {
732 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 731 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
733 } 732 }
734} 733}
735void KOTodoView::cancelTodo() 734void KOTodoView::cancelTodo()
736{ 735{
737 if (mActiveItem) { 736 if (mActiveItem) {
738 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 737 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
739 } 738 }
740} 739}
741void KOTodoView::moveTodo() 740void KOTodoView::moveTodo()
742{ 741{
743 if (mActiveItem) { 742 if (mActiveItem) {
744 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 743 emit moveTodoSignal((Incidence*)mActiveItem->todo());
745 } 744 }
746} 745}
747void KOTodoView::beamTodo() 746void KOTodoView::beamTodo()
748{ 747{
749 if (mActiveItem) { 748 if (mActiveItem) {
750 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 749 emit beamTodoSignal((Incidence*)mActiveItem->todo());
751 } 750 }
752} 751}
753 752
754 753
755void KOTodoView::showTodo() 754void KOTodoView::showTodo()
756{ 755{
757 if (mActiveItem) { 756 if (mActiveItem) {
758 emit showTodoSignal(mActiveItem->todo()); 757 emit showTodoSignal(mActiveItem->todo());
759 } 758 }
760} 759}
761 760
762void KOTodoView::deleteTodo() 761void KOTodoView::deleteTodo()
763{ 762{
764 if (mActiveItem) { 763 if (mActiveItem) {
765 if (mActiveItem->childCount()) { 764 if (mActiveItem->childCount()) {
766 KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), 765 KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."),
767 i18n("Delete To-Do")); 766 i18n("Delete To-Do"));
768 } else { 767 } else {
769 emit deleteTodoSignal(mActiveItem->todo()); 768 emit deleteTodoSignal(mActiveItem->todo());
770 } 769 }
771 } 770 }
772} 771}
773 772
774void KOTodoView::setNewPriority(int index) 773void KOTodoView::setNewPriority(int index)
775{ 774{
776 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 775 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
777 mActiveItem->todo()->setPriority(mPriority[index]); 776 mActiveItem->todo()->setPriority(mPriority[index]);
778 mActiveItem->construct(); 777 mActiveItem->construct();
779 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 778 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
780 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 779 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
781 } 780 }
782} 781}
783 782
784void KOTodoView::setNewPercentage(int index) 783void KOTodoView::setNewPercentage(int index)
785{ 784{
786 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 785 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
787 if (mPercentage[index] == 100) { 786 if (mPercentage[index] == 100) {
788 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 787 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
789 } else { 788 } else {
790 mActiveItem->todo()->setCompleted(false); 789 mActiveItem->todo()->setCompleted(false);
791 } 790 }
792 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 791 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
793 mActiveItem->construct(); 792 mActiveItem->construct();
794 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 793 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
795 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 794 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
796 } 795 }
797} 796}
798 797
799 798
800QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 799QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
801{ 800{
802 QPopupMenu* tempMenu = new QPopupMenu (this); 801 QPopupMenu* tempMenu = new QPopupMenu (this);
803 QStringList checkedCategories = todoItem->todo()->categories (); 802 QStringList checkedCategories = todoItem->todo()->categories ();
804 803
805 tempMenu->setCheckable (true); 804 tempMenu->setCheckable (true);
806 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 805 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
807 it != KOPrefs::instance()->mCustomCategories.end (); 806 it != KOPrefs::instance()->mCustomCategories.end ();
808 ++it) { 807 ++it) {
809 int index = tempMenu->insertItem (*it); 808 int index = tempMenu->insertItem (*it);
810 mCategory[index] = *it; 809 mCategory[index] = *it;
811 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 810 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
812 } 811 }
813 812
814 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 813 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
815 return tempMenu; 814 return tempMenu;
816 815
817 816
818} 817}
819void KOTodoView::changedCategories(int index) 818void KOTodoView::changedCategories(int index)
820{ 819{
821 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 820 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
822 QStringList categories = mActiveItem->todo()->categories (); 821 QStringList categories = mActiveItem->todo()->categories ();
823 if (categories.find (mCategory[index]) != categories.end ()) 822 if (categories.find (mCategory[index]) != categories.end ())
824 categories.remove (mCategory[index]); 823 categories.remove (mCategory[index]);
825 else 824 else
826 categories.insert (categories.end(), mCategory[index]); 825 categories.insert (categories.end(), mCategory[index]);
827 categories.sort (); 826 categories.sort ();
828 mActiveItem->todo()->setCategories (categories); 827 mActiveItem->todo()->setCategories (categories);
829 mActiveItem->construct(); 828 mActiveItem->construct();
830 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 829 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
831 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 830 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
832 } 831 }
833} 832}
834void KOTodoView::itemDoubleClicked(QListViewItem *item) 833void KOTodoView::itemDoubleClicked(QListViewItem *item)
835{ 834{
836 if (!item) { 835 if (!item) {
837 newTodo(); 836 newTodo();
838 return; 837 return;
839 } 838 }
840 if ( KOPrefs::instance()->mEditOnDoubleClick ) 839 if ( KOPrefs::instance()->mEditOnDoubleClick )
841 editItem( item ); 840 editItem( item );
842 else 841 else
843 showItem( item , QPoint(), 0 ); 842 showItem( item , QPoint(), 0 );
844} 843}
845void KOTodoView::itemClicked(QListViewItem *item) 844void KOTodoView::itemClicked(QListViewItem *item)
846{ 845{
847 if (!item) { 846 if (!item) {
848 return; 847 return;
849 } 848 }
850 849
851 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 850 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
852 int completed = todoItem->todo()->isCompleted(); // Completed or not? 851 int completed = todoItem->todo()->isCompleted(); // Completed or not?
853 852
854 if (todoItem->isOn()) { 853 if (todoItem->isOn()) {
855 if (!completed) { 854 if (!completed) {
856 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 855 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
857 } 856 }
858 } else { 857 } else {
859 if (completed) { 858 if (completed) {
860 todoItem->todo()->setCompleted(false); 859 todoItem->todo()->setCompleted(false);
861 } 860 }
862 } 861 }
863} 862}
864 863
865void KOTodoView::setDocumentId( const QString &id ) 864void KOTodoView::setDocumentId( const QString &id )
866{ 865{
867 kdDebug() << "KOTodoView::setDocumentId()" << endl; 866 kdDebug() << "KOTodoView::setDocumentId()" << endl;
868 867
869 mDocPrefs->setDoc( id ); 868 mDocPrefs->setDoc( id );
870} 869}
871 870
872void KOTodoView::itemStateChanged( QListViewItem *item ) 871void KOTodoView::itemStateChanged( QListViewItem *item )
873{ 872{
874 if (!item) return; 873 if (!item) return;
875 874
876 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 875 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
877 876
878// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 877// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
879 878
880 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 879 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
881} 880}
882 881
883void KOTodoView::saveLayout(KConfig *config, const QString &group) const 882void KOTodoView::saveLayout(KConfig *config, const QString &group) const
884{ 883{
885 mTodoListView->saveLayout(config,group); 884 mTodoListView->saveLayout(config,group);
886} 885}
887 886
888void KOTodoView::restoreLayout(KConfig *config, const QString &group) 887void KOTodoView::restoreLayout(KConfig *config, const QString &group)
889{ 888{
890 mTodoListView->restoreLayout(config,group); 889 mTodoListView->restoreLayout(config,group);
891} 890}
892 891
893void KOTodoView::processSelectionChange() 892void KOTodoView::processSelectionChange()
894{ 893{
895// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 894// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
896 895
897 KOTodoViewItem *item = 896 KOTodoViewItem *item =
898 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 897 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
899 898
900 if ( !item ) { 899 if ( !item ) {
901 emit incidenceSelected( 0 ); 900 emit incidenceSelected( 0 );
902 } else { 901 } else {
903 emit incidenceSelected( item->todo() ); 902 emit incidenceSelected( item->todo() );
904 } 903 }
905} 904}
906 905
907void KOTodoView::modified(bool b) 906void KOTodoView::modified(bool b)
908{ 907{
909 emit isModified(b); 908 emit isModified(b);
910} 909}
911void KOTodoView::setTodoModified( Todo* todo ) 910void KOTodoView::setTodoModified( Todo* todo )
912{ 911{
913 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 912 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
914} 913}
915void KOTodoView::clearSelection() 914void KOTodoView::clearSelection()
916{ 915{
917 mTodoListView->selectAll( false ); 916 mTodoListView->selectAll( false );
918} 917}
919 918
920void KOTodoView::purgeCompleted() 919void KOTodoView::purgeCompleted()
921{ 920{
922 emit purgeCompletedSignal(); 921 emit purgeCompletedSignal();
923} 922}
924void KOTodoView::toggleQuickTodo() 923void KOTodoView::toggleQuickTodo()
925{ 924{
926 if ( mQuickAdd->isVisible() ) { 925 if ( mQuickAdd->isVisible() ) {
927 mQuickAdd->hide(); 926 mQuickAdd->hide();
928 KOPrefs::instance()->mEnableQuickTodo = false; 927 KOPrefs::instance()->mEnableQuickTodo = false;
929 } 928 }
930 else { 929 else {
931 mQuickAdd->show(); 930 mQuickAdd->show();
932 KOPrefs::instance()->mEnableQuickTodo = true; 931 KOPrefs::instance()->mEnableQuickTodo = true;
933 } 932 }
934 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 933 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
935 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 934 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
936} 935}
937void KOTodoView::toggleCompleted() 936void KOTodoView::toggleCompleted()
938{ 937{
939 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 938 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
940 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 939 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
941 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 940 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
942 updateView(); 941 updateView();
943} 942}
944 943
945void KOTodoView::addQuickTodo() 944void KOTodoView::addQuickTodo()
946{ 945{
947 Todo *todo = new Todo(); 946 Todo *todo = new Todo();
948 todo->setSummary(mQuickAdd->text()); 947 todo->setSummary(mQuickAdd->text());
949 todo->setOrganizer(KOPrefs::instance()->email()); 948 todo->setOrganizer(KOPrefs::instance()->email());
950 CalFilter * cf = mCalendar->filter(); 949 CalFilter * cf = mCalendar->filter();
951 if ( cf ) { 950 if ( cf ) {
952 if ( cf->isEnabled()&& cf->showCategories()) { 951 if ( cf->isEnabled()&& cf->showCategories()) {
953 todo->setCategories(cf->categoryList()); 952 todo->setCategories(cf->categoryList());
954 } 953 }
955 if ( cf->isEnabled() ) 954 if ( cf->isEnabled() )
956 todo->setSecrecy( cf->getSecrecy()); 955 todo->setSecrecy( cf->getSecrecy());
957 } 956 }
958 mCalendar->addTodo(todo); 957 mCalendar->addTodo(todo);
959 mQuickAdd->setText(""); 958 mQuickAdd->setText("");
960 todoModified (todo, KOGlobals::EVENTADDED ); 959 todoModified (todo, KOGlobals::EVENTADDED );
961 updateView(); 960 updateView();
962} 961}
963void KOTodoView::keyPressEvent ( QKeyEvent * e ) 962void KOTodoView::keyPressEvent ( QKeyEvent * e )
964{ 963{
965 // e->ignore(); 964 // e->ignore();
966 //return; 965 //return;
967 switch ( e->key() ) { 966 switch ( e->key() ) {
968 case Qt::Key_Down: 967 case Qt::Key_Down:
969 QWidget::keyPressEvent ( e ); 968 QWidget::keyPressEvent ( e );
970 break; 969 break;
971 970
972 case Qt::Key_Up: 971 case Qt::Key_Up:
973 QWidget::keyPressEvent ( e ); 972 QWidget::keyPressEvent ( e );
974 break; 973 break;
975 case Qt::Key_Q: 974 case Qt::Key_Q:
976 toggleQuickTodo(); 975 toggleQuickTodo();
977 break; 976 break;
978 977
979 default: 978 default:
980 e->ignore(); 979 e->ignore();
981 } 980 }
982 981
983 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || ( height() > 150 && width() > 200 ) ) { 982 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || ( height() > 150 && width() > 200 ) ) {
984 if ( e->key() == Qt::Key_I ) { 983 if ( e->key() == Qt::Key_I ) {
985 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 984 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
986 if ( cn ) { 985 if ( cn ) {
987 mActiveItem = cn; 986 mActiveItem = cn;
988 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 987 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
989 if ( ci ){ 988 if ( ci ){
990 showTodo(); 989 showTodo();
991 cn = (KOTodoViewItem*)cn->itemBelow(); 990 cn = (KOTodoViewItem*)cn->itemBelow();
992 if ( cn ) { 991 if ( cn ) {
993 mTodoListView->setCurrentItem ( cn ); 992 mTodoListView->setCurrentItem ( cn );
994 mTodoListView->ensureItemVisible ( cn ); 993 mTodoListView->ensureItemVisible ( cn );
995 } 994 }
996 995
997 } 996 }
998 } 997 }
999 e->accept(); 998 e->accept();
1000 999
1001 } 1000 }
1002 1001
1003 } 1002 }
1004 1003
1005} 1004}
1006void KOTodoView::updateTodo( Todo * t, int type ) 1005void KOTodoView::updateTodo( Todo * t, int type )
1007{ 1006{
1008 if ( mBlockUpdate) 1007 if ( mBlockUpdate)
1009 return; 1008 return;
1010 1009
1011 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1010 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1012 itemIterator = mTodoMap.find(t); 1011 itemIterator = mTodoMap.find(t);
1013 if (itemIterator != mTodoMap.end()) { 1012 if (itemIterator != mTodoMap.end()) {
1014 (*itemIterator)->construct(); 1013 (*itemIterator)->construct();
1015 } else { 1014 } else {
1016 if ( type == KOGlobals::EVENTADDED ) { 1015 if ( type == KOGlobals::EVENTADDED ) {
1017 insertTodoItem( t ); 1016 insertTodoItem( t );
1018 } 1017 }
1019 } 1018 }
1020 1019
1021} 1020}
1022 1021
1023void KOTodoView::todoModified(Todo * t , int p ) 1022void KOTodoView::todoModified(Todo * t , int p )
1024{ 1023{
1025 mBlockUpdate = true; 1024 mBlockUpdate = true;
1026 emit todoModifiedSignal ( t, p ); 1025 emit todoModifiedSignal ( t, p );
1027 mBlockUpdate = false; 1026 mBlockUpdate = false;
1028} 1027}
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 88d69c6..fc2bc77 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,570 +1,569 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include "calendarview.h" 35#include "calendarview.h"
36#include "datenavigator.h" 36#include "datenavigator.h"
37#include "kotodoview.h" 37#include "kotodoview.h"
38#include "koagendaview.h" 38#include "koagendaview.h"
39#include "kodialogmanager.h" 39#include "kodialogmanager.h"
40#include "komonthview.h" 40#include "komonthview.h"
41#include "kolistview.h" 41#include "kolistview.h"
42#include "kowhatsnextview.h" 42#include "kowhatsnextview.h"
43#include "kojournalview.h" 43#include "kojournalview.h"
44#include "kotimespanview.h" 44#include "kotimespanview.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "navigatorbar.h" 46#include "navigatorbar.h"
47 47
48#include "koviewmanager.h" 48#include "koviewmanager.h"
49#include "koviewmanager.moc"
50//extern bool externFlagMonthviewBlockPainting; 49//extern bool externFlagMonthviewBlockPainting;
51 50
52//bool globalFlagBlockPainting = false; 51//bool globalFlagBlockPainting = false;
53int globalFlagBlockAgenda = 0; 52int globalFlagBlockAgenda = 0;
54int globalFlagBlockLabel = 0; 53int globalFlagBlockLabel = 0;
55int globalFlagBlockAgendaItemPaint = 1; 54int globalFlagBlockAgendaItemPaint = 1;
56int globalFlagBlockAgendaItemUpdate = 1; 55int globalFlagBlockAgendaItemUpdate = 1;
57 56
58 57
59KOViewManager::KOViewManager( CalendarView *mainView ) : 58KOViewManager::KOViewManager( CalendarView *mainView ) :
60 QObject(), mMainView( mainView ) 59 QObject(), mMainView( mainView )
61{ 60{
62 mCurrentView = 0; 61 mCurrentView = 0;
63 62
64 mWhatsNextView = 0; 63 mWhatsNextView = 0;
65 mTodoView = 0; 64 mTodoView = 0;
66 mAgendaView = 0; 65 mAgendaView = 0;
67 mMonthView = 0; 66 mMonthView = 0;
68 mListView = 0; 67 mListView = 0;
69 mJournalView = 0; 68 mJournalView = 0;
70 mTimeSpanView = 0; 69 mTimeSpanView = 0;
71 mCurrentAgendaView = 0 ; 70 mCurrentAgendaView = 0 ;
72 mFlagShowNextxDays = false; 71 mFlagShowNextxDays = false;
73} 72}
74 73
75KOViewManager::~KOViewManager() 74KOViewManager::~KOViewManager()
76{ 75{
77} 76}
78 77
79 78
80KOrg::BaseView *KOViewManager::currentView() 79KOrg::BaseView *KOViewManager::currentView()
81{ 80{
82 return mCurrentView; 81 return mCurrentView;
83} 82}
84 83
85void KOViewManager::readSettings(KConfig *config) 84void KOViewManager::readSettings(KConfig *config)
86{ 85{
87 config->setGroup("General"); 86 config->setGroup("General");
88 QString view = config->readEntry("Current View"); 87 QString view = config->readEntry("Current View");
89 if (view == "WhatsNext") showWhatsNextView(); 88 if (view == "WhatsNext") showWhatsNextView();
90 else if (view == "Month") showMonthView(); 89 else if (view == "Month") showMonthView();
91 else if (view == "List") showListView(); 90 else if (view == "List") showListView();
92 else if (view == "Journal") showJournalView(); 91 else if (view == "Journal") showJournalView();
93 else if (view == "TimeSpan") showTimeSpanView(); 92 else if (view == "TimeSpan") showTimeSpanView();
94 else if (view == "Todo") showTodoView(); 93 else if (view == "Todo") showTodoView();
95 else { 94 else {
96 showAgendaView(); 95 showAgendaView();
97 } 96 }
98} 97}
99 98
100void KOViewManager::writeSettings(KConfig *config) 99void KOViewManager::writeSettings(KConfig *config)
101{ 100{
102 config->setGroup("General"); 101 config->setGroup("General");
103 102
104 QString view; 103 QString view;
105 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 104 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
106 else if (mCurrentView == mMonthView) view = "Month"; 105 else if (mCurrentView == mMonthView) view = "Month";
107 else if (mCurrentView == mListView) view = "List"; 106 else if (mCurrentView == mListView) view = "List";
108 else if (mCurrentView == mJournalView) view = "Journal"; 107 else if (mCurrentView == mJournalView) view = "Journal";
109 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 108 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
110 else if (mCurrentView == mTodoView) view = "Todo"; 109 else if (mCurrentView == mTodoView) view = "Todo";
111 else view = "Agenda"; 110 else view = "Agenda";
112 111
113 config->writeEntry("Current View",view); 112 config->writeEntry("Current View",view);
114 113
115 if (mAgendaView) { 114 if (mAgendaView) {
116 mAgendaView->writeSettings(config); 115 mAgendaView->writeSettings(config);
117 } 116 }
118 if (mTimeSpanView) { 117 if (mTimeSpanView) {
119 mTimeSpanView->writeSettings(config); 118 mTimeSpanView->writeSettings(config);
120 } 119 }
121 if (mListView) { 120 if (mListView) {
122 mListView->writeSettings(config); 121 mListView->writeSettings(config);
123 } 122 }
124 if (mTodoView) { 123 if (mTodoView) {
125 mTodoView->saveLayout(config,"Todo View"); 124 mTodoView->saveLayout(config,"Todo View");
126 } 125 }
127} 126}
128 127
129void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 128void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
130{ 129{
131 130
132 //mFlagShowNextxDays = false; 131 //mFlagShowNextxDays = false;
133 //if(view == mCurrentView) return; 132 //if(view == mCurrentView) return;
134 if ( view == 0 ) { 133 if ( view == 0 ) {
135 view = mCurrentView; 134 view = mCurrentView;
136 if ( view == 0 ) 135 if ( view == 0 )
137 return; 136 return;
138 } 137 }
139 bool full = fullScreen; 138 bool full = fullScreen;
140 if(view == mCurrentView && view != mWhatsNextView ) { 139 if(view == mCurrentView && view != mWhatsNextView ) {
141 if ( mCurrentAgendaView < 0 ) 140 if ( mCurrentAgendaView < 0 )
142 return; 141 return;
143 full = mMainView->leftFrame()->isVisible(); 142 full = mMainView->leftFrame()->isVisible();
144 } else { 143 } else {
145 mCurrentView = view; 144 mCurrentView = view;
146 145
147 // bool full = fullScreen; 146 // bool full = fullScreen;
148 bool isFull = !mMainView->leftFrame()->isVisible(); 147 bool isFull = !mMainView->leftFrame()->isVisible();
149 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 148 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
150 full = true; 149 full = true;
151 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 150 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
152 full = false; 151 full = false;
153 } 152 }
154 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 153 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
155 raiseCurrentView( full ); 154 raiseCurrentView( full );
156 mMainView->processIncidenceSelection( 0 ); 155 mMainView->processIncidenceSelection( 0 );
157 mMainView->updateView(); 156 mMainView->updateView();
158 mMainView->adaptNavigationUnits(); 157 mMainView->adaptNavigationUnits();
159} 158}
160 159
161void KOViewManager::raiseCurrentView( bool fullScreen ) 160void KOViewManager::raiseCurrentView( bool fullScreen )
162{ 161{
163 //qDebug("raiseCurrentView "); 162 //qDebug("raiseCurrentView ");
164 mCurrentAgendaView = 0; 163 mCurrentAgendaView = 0;
165 int wid = mMainView->width() ; 164 int wid = mMainView->width() ;
166 int hei = mMainView->height(); 165 int hei = mMainView->height();
167 if ( mCurrentView == mMonthView ) { 166 if ( mCurrentView == mMonthView ) {
168 mMainView->navigatorBar()->show(); 167 mMainView->navigatorBar()->show();
169 hei -= mMainView->navigatorBar()->sizeHint().height(); 168 hei -= mMainView->navigatorBar()->sizeHint().height();
170 //mMainView->navigatorBar()->hide(); 169 //mMainView->navigatorBar()->hide();
171 } else { 170 } else {
172 mMainView->navigatorBar()->hide(); 171 mMainView->navigatorBar()->hide();
173 } 172 }
174 if ( fullScreen ) { 173 if ( fullScreen ) {
175 mMainView->leftFrame()->hide(); 174 mMainView->leftFrame()->hide();
176 } else { 175 } else {
177 mMainView->leftFrame()->show(); 176 mMainView->leftFrame()->show();
178 if ( KOPrefs::instance()->mVerticalScreen ) 177 if ( KOPrefs::instance()->mVerticalScreen )
179 hei -= mMainView->leftFrame()->height(); 178 hei -= mMainView->leftFrame()->height();
180 else 179 else
181 wid -= mMainView->leftFrame()->width(); 180 wid -= mMainView->leftFrame()->width();
182 } 181 }
183 182
184 if ( globalFlagBlockAgenda == 5 ) { 183 if ( globalFlagBlockAgenda == 5 ) {
185 globalFlagBlockAgenda = 4; 184 globalFlagBlockAgenda = 4;
186 globalFlagBlockAgendaItemPaint = 1; 185 globalFlagBlockAgendaItemPaint = 1;
187 } 186 }
188 mMainView->viewStack()->raiseWidget(mCurrentView); 187 mMainView->viewStack()->raiseWidget(mCurrentView);
189 if ( globalFlagBlockAgenda == 4 ) { 188 if ( globalFlagBlockAgenda == 4 ) {
190 if ( mCurrentView == mAgendaView ) { 189 if ( mCurrentView == mAgendaView ) {
191 //globalFlagBlockAgenda =1 ; 190 //globalFlagBlockAgenda =1 ;
192 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 191 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
193 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 192 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
194 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 193 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
195 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 194 mAgendaView->setStartHour( QTime::currentTime ().hour() );
196 qApp->processEvents(); 195 qApp->processEvents();
197 //qDebug("qApp->processEvents() "); 196 //qDebug("qApp->processEvents() ");
198 globalFlagBlockAgenda = 0; 197 globalFlagBlockAgenda = 0;
199 mAgendaView->repaintAgenda(); 198 mAgendaView->repaintAgenda();
200 199
201 } 200 }
202 globalFlagBlockAgenda = 0; 201 globalFlagBlockAgenda = 0;
203 } 202 }
204 //qDebug("raiseCurrentView ende "); 203 //qDebug("raiseCurrentView ende ");
205} 204}
206 205
207void KOViewManager::updateView() 206void KOViewManager::updateView()
208{ 207{
209 // qDebug("KOViewManager::updateView() "); 208 // qDebug("KOViewManager::updateView() ");
210 // if we are updating mTodoView, we get endless recursion 209 // if we are updating mTodoView, we get endless recursion
211 if ( mTodoView == mCurrentView ) 210 if ( mTodoView == mCurrentView )
212 return; 211 return;
213 if ( mCurrentView ) mCurrentView->updateView(); 212 if ( mCurrentView ) mCurrentView->updateView();
214 213
215} 214}
216 215
217void KOViewManager::updateView(const QDate &start, const QDate &end) 216void KOViewManager::updateView(const QDate &start, const QDate &end)
218{ 217{
219 // kdDebug() << "KOViewManager::updateView()" << endl; 218 // kdDebug() << "KOViewManager::updateView()" << endl;
220 219
221 if (mCurrentView) mCurrentView->showDates(start, end); 220 if (mCurrentView) mCurrentView->showDates(start, end);
222 221
223 if (mTodoView) mTodoView->updateView(); 222 if (mTodoView) mTodoView->updateView();
224} 223}
225 224
226 225
227void KOViewManager::showWhatsNextView() 226void KOViewManager::showWhatsNextView()
228{ 227{
229 if (!mWhatsNextView) { 228 if (!mWhatsNextView) {
230 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 229 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
231 "KOViewManager::WhatsNextView"); 230 "KOViewManager::WhatsNextView");
232 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 231 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
233 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 232 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
234 addView(mWhatsNextView); 233 addView(mWhatsNextView);
235 } 234 }
236 globalFlagBlockAgenda = 1; 235 globalFlagBlockAgenda = 1;
237 showView(mWhatsNextView, true ); 236 showView(mWhatsNextView, true );
238 mWhatsNextView->updateView(); 237 mWhatsNextView->updateView();
239 238
240} 239}
241 240
242void KOViewManager::showListView() 241void KOViewManager::showListView()
243{ 242{
244 if (!mListView) { 243 if (!mListView) {
245 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 244 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
246 addView(mListView); 245 addView(mListView);
247 246
248 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 247 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
249 mMainView, SLOT(showIncidence(Incidence *))); 248 mMainView, SLOT(showIncidence(Incidence *)));
250 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 249 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
251 mMainView, SLOT(editIncidence(Incidence *))); 250 mMainView, SLOT(editIncidence(Incidence *)));
252 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 251 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
253 mMainView, SLOT(deleteIncidence(Incidence *))); 252 mMainView, SLOT(deleteIncidence(Incidence *)));
254 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 253 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
255 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 254 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
256 connect( mListView, SIGNAL( signalNewEvent() ), 255 connect( mListView, SIGNAL( signalNewEvent() ),
257 mMainView, SLOT( newEvent() ) ); 256 mMainView, SLOT( newEvent() ) );
258 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 257 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
259 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 258 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
260 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 259 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
261 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 260 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
262 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 261 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
263 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 262 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
264 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 263 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
265 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 264 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
266 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 265 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
267 } 266 }
268 // bool temp = mFlagShowNextxDays; 267 // bool temp = mFlagShowNextxDays;
269 //globalFlagBlockPainting = true; 268 //globalFlagBlockPainting = true;
270 globalFlagBlockAgenda = 1; 269 globalFlagBlockAgenda = 1;
271 if ( KOPrefs::instance()->mListViewMonthTimespan ) 270 if ( KOPrefs::instance()->mListViewMonthTimespan )
272 mMainView->dateNavigator()->selectMonth(); 271 mMainView->dateNavigator()->selectMonth();
273 showView(mListView, KOPrefs::instance()->mFullViewTodo); 272 showView(mListView, KOPrefs::instance()->mFullViewTodo);
274 //mFlagShowNextxDays = temp; 273 //mFlagShowNextxDays = temp;
275} 274}
276 275
277void KOViewManager::showAgendaView( bool fullScreen ) 276void KOViewManager::showAgendaView( bool fullScreen )
278{ 277{
279 278
280 mMainView->dialogManager()->hideSearchDialog(); 279 mMainView->dialogManager()->hideSearchDialog();
281 // qDebug("KOViewManager::showAgendaView "); 280 // qDebug("KOViewManager::showAgendaView ");
282 bool full; 281 bool full;
283 full = fullScreen; 282 full = fullScreen;
284 if (!mAgendaView) { 283 if (!mAgendaView) {
285 full = false; 284 full = false;
286 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 285 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
287 addView(mAgendaView); 286 addView(mAgendaView);
288#ifndef DESKTOP_VERSION 287#ifndef DESKTOP_VERSION
289 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 288 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
290#endif 289#endif
291 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 290 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
292 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 291 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
293 292
294 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 293 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
295 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 294 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
296 mMainView, SLOT(newEvent(QDateTime))); 295 mMainView, SLOT(newEvent(QDateTime)));
297 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 296 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
298 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 297 // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
299 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 298 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
300 mMainView, SLOT(newEvent(QDate))); 299 mMainView, SLOT(newEvent(QDate)));
301 300
302 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 301 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
303 mMainView, SLOT(editIncidence(Incidence *))); 302 mMainView, SLOT(editIncidence(Incidence *)));
304 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 303 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
305 mMainView, SLOT(showIncidence(Incidence *))); 304 mMainView, SLOT(showIncidence(Incidence *)));
306 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 305 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
307 mMainView, SLOT(deleteIncidence(Incidence *))); 306 mMainView, SLOT(deleteIncidence(Incidence *)));
308 307
309 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 308 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
310 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 309 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
311 310
312 connect(mAgendaView, SIGNAL( toggleExpand() ), 311 connect(mAgendaView, SIGNAL( toggleExpand() ),
313 mMainView, SLOT( toggleExpand() ) ); 312 mMainView, SLOT( toggleExpand() ) );
314 313
315 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 314 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
316 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 315 mAgendaView, SLOT( setExpandedButton( bool ) ) );
317 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 316 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
318 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 317 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
319 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 318 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
320 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 319 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
321 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 320 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
322 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 321 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
323 SLOT( updateTodo( Todo *, int ) ) ); 322 SLOT( updateTodo( Todo *, int ) ) );
324 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 323 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
325 mMainView, SIGNAL( todoModified( Todo *, int ))); 324 mMainView, SIGNAL( todoModified( Todo *, int )));
326 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 325 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
327 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 326 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
328 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 327 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
329 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 328 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
330 mAgendaView->readSettings(); 329 mAgendaView->readSettings();
331 mAgendaView->updateConfig(); 330 mAgendaView->updateConfig();
332 } 331 }
333 332
334 showView( mAgendaView, full); 333 showView( mAgendaView, full);
335 334
336} 335}
337 336
338void KOViewManager::showDayView() 337void KOViewManager::showDayView()
339{ 338{
340 mFlagShowNextxDays = false; 339 mFlagShowNextxDays = false;
341 globalFlagBlockLabel = 1; 340 globalFlagBlockLabel = 1;
342 globalFlagBlockAgenda = 1; 341 globalFlagBlockAgenda = 1;
343 if ( mCurrentAgendaView != 1 ) 342 if ( mCurrentAgendaView != 1 )
344 mCurrentAgendaView = -1; 343 mCurrentAgendaView = -1;
345 showAgendaView(); 344 showAgendaView();
346 qApp->processEvents(); 345 qApp->processEvents();
347 globalFlagBlockAgenda = 2; 346 globalFlagBlockAgenda = 2;
348 globalFlagBlockLabel = 0; 347 globalFlagBlockLabel = 0;
349 mMainView->dateNavigator()->selectDates( 1 ); 348 mMainView->dateNavigator()->selectDates( 1 );
350 mCurrentAgendaView = 1 ; 349 mCurrentAgendaView = 1 ;
351 350
352} 351}
353 352
354void KOViewManager::showWorkWeekView() 353void KOViewManager::showWorkWeekView()
355{ 354{
356 mFlagShowNextxDays = false; 355 mFlagShowNextxDays = false;
357 globalFlagBlockAgenda = 1; 356 globalFlagBlockAgenda = 1;
358 globalFlagBlockLabel = 1; 357 globalFlagBlockLabel = 1;
359 if ( mCurrentAgendaView != 5 ) 358 if ( mCurrentAgendaView != 5 )
360 mCurrentAgendaView = -1; 359 mCurrentAgendaView = -1;
361 showAgendaView(); 360 showAgendaView();
362 qApp->processEvents(); 361 qApp->processEvents();
363 globalFlagBlockAgenda = 2; 362 globalFlagBlockAgenda = 2;
364 globalFlagBlockLabel = 0; 363 globalFlagBlockLabel = 0;
365 mMainView->dateNavigator()->selectWorkWeek(); 364 mMainView->dateNavigator()->selectWorkWeek();
366 mCurrentAgendaView = 5 ; 365 mCurrentAgendaView = 5 ;
367 366
368} 367}
369 368
370void KOViewManager::showWeekView() 369void KOViewManager::showWeekView()
371{ 370{
372 /* 371 /*
373 globalFlagBlockAgenda = 2; 372 globalFlagBlockAgenda = 2;
374 qDebug("4globalFlagBlockAgenda = 2; "); 373 qDebug("4globalFlagBlockAgenda = 2; ");
375 //globalFlagBlockPainting = true; 374 //globalFlagBlockPainting = true;
376 mMainView->dateNavigator()->selectWeek(); 375 mMainView->dateNavigator()->selectWeek();
377 showAgendaView(); 376 showAgendaView();
378 */ 377 */
379 378
380 379
381 mFlagShowNextxDays = false; 380 mFlagShowNextxDays = false;
382 globalFlagBlockAgenda = 1; 381 globalFlagBlockAgenda = 1;
383 globalFlagBlockLabel = 1; 382 globalFlagBlockLabel = 1;
384 if ( mCurrentAgendaView != 7 ) 383 if ( mCurrentAgendaView != 7 )
385 mCurrentAgendaView = -1; 384 mCurrentAgendaView = -1;
386 showAgendaView(); 385 showAgendaView();
387 qApp->processEvents(); 386 qApp->processEvents();
388 globalFlagBlockAgenda = 2; 387 globalFlagBlockAgenda = 2;
389 globalFlagBlockLabel = 0; 388 globalFlagBlockLabel = 0;
390 mMainView->dateNavigator()->selectWeek(); 389 mMainView->dateNavigator()->selectWeek();
391 mCurrentAgendaView = 7 ; 390 mCurrentAgendaView = 7 ;
392} 391}
393 392
394void KOViewManager::showNextXView() 393void KOViewManager::showNextXView()
395{ 394{
396 395
397 globalFlagBlockAgenda = 1; 396 globalFlagBlockAgenda = 1;
398 if ( mCurrentAgendaView != 3 ) 397 if ( mCurrentAgendaView != 3 )
399 mCurrentAgendaView = -1; 398 mCurrentAgendaView = -1;
400 showAgendaView(KOPrefs::instance()->mFullViewMonth); 399 showAgendaView(KOPrefs::instance()->mFullViewMonth);
401 globalFlagBlockAgenda = 2; 400 globalFlagBlockAgenda = 2;
402 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 401 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
403 KOPrefs::instance()->mNextXDays ); 402 KOPrefs::instance()->mNextXDays );
404 mFlagShowNextxDays = true; 403 mFlagShowNextxDays = true;
405 mCurrentAgendaView = 3 ; 404 mCurrentAgendaView = 3 ;
406} 405}
407bool KOViewManager::showsNextDays() 406bool KOViewManager::showsNextDays()
408{ 407{
409 return mFlagShowNextxDays; 408 return mFlagShowNextxDays;
410} 409}
411void KOViewManager::showMonthView() 410void KOViewManager::showMonthView()
412{ 411{
413 if (!mMonthView) { 412 if (!mMonthView) {
414 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 413 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
415 414
416 addView(mMonthView); 415 addView(mMonthView);
417 // mMonthView->show(); 416 // mMonthView->show();
418 // SIGNALS/SLOTS FOR MONTH VIEW 417 // SIGNALS/SLOTS FOR MONTH VIEW
419 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 418 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
420 mMainView, SLOT(newEvent(QDateTime))); 419 mMainView, SLOT(newEvent(QDateTime)));
421 420
422 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 421 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
423 mMainView, SLOT(showIncidence(Incidence *))); 422 mMainView, SLOT(showIncidence(Incidence *)));
424 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 423 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
425 mMainView, SLOT(editIncidence(Incidence *))); 424 mMainView, SLOT(editIncidence(Incidence *)));
426 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 425 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
427 mMainView, SLOT(deleteIncidence(Incidence *))); 426 mMainView, SLOT(deleteIncidence(Incidence *)));
428 427
429 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 428 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
430 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 429 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
431 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 430 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
432 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 431 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
433 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 432 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
434 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 433 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
435 434
436 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 435 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
437 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 436 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
438 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 437 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
439 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 438 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
440 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 439 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
441 mMainView, SLOT ( selectWeekNum( int ) ) ); 440 mMainView, SLOT ( selectWeekNum( int ) ) );
442 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 441 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
443 mMonthView->updateConfig(); 442 mMonthView->updateConfig();
444 } 443 }
445 444
446 globalFlagBlockAgenda = 1; 445 globalFlagBlockAgenda = 1;
447 //mFlagShowNextxDays = false; 446 //mFlagShowNextxDays = false;
448 // if(mMonthView == mCurrentView) return; 447 // if(mMonthView == mCurrentView) return;
449 mMainView->dateNavigator()->selectMonth(); 448 mMainView->dateNavigator()->selectMonth();
450 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 449 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
451 //mMonthView->showDates(tmpList.first(), tmpList.last()); 450 //mMonthView->showDates(tmpList.first(), tmpList.last());
452 451
453 showView(mMonthView, true ); 452 showView(mMonthView, true );
454 453
455} 454}
456 455
457void KOViewManager::showTodoView() 456void KOViewManager::showTodoView()
458{ 457{
459 //mFlagShowNextxDays = false; 458 //mFlagShowNextxDays = false;
460 if ( !mTodoView ) { 459 if ( !mTodoView ) {
461 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 460 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
462 "KOViewManager::TodoView" ); 461 "KOViewManager::TodoView" );
463 462
464 addView( mTodoView ); 463 addView( mTodoView );
465 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 464 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
466 465
467 // SIGNALS/SLOTS FOR TODO VIEW 466 // SIGNALS/SLOTS FOR TODO VIEW
468 connect( mTodoView, SIGNAL( newTodoSignal() ), 467 connect( mTodoView, SIGNAL( newTodoSignal() ),
469 mMainView, SLOT( newTodo() ) ); 468 mMainView, SLOT( newTodo() ) );
470 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 469 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
471 mMainView, SLOT( newSubTodo( Todo *) ) ); 470 mMainView, SLOT( newSubTodo( Todo *) ) );
472 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 471 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
473 mMainView, SLOT( showTodo( Todo * ) ) ); 472 mMainView, SLOT( showTodo( Todo * ) ) );
474 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 473 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
475 mMainView, SLOT( editTodo( Todo * ) ) ); 474 mMainView, SLOT( editTodo( Todo * ) ) );
476 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 475 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
477 mMainView, SLOT( deleteTodo( Todo * ) ) ); 476 mMainView, SLOT( deleteTodo( Todo * ) ) );
478 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 477 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
479 mMainView, SLOT( purgeCompleted() ) ); 478 mMainView, SLOT( purgeCompleted() ) );
480 479
481 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 480 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
482 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 481 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
483 482
484 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 483 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
485 SLOT( updateConfig() ) ); 484 SLOT( updateConfig() ) );
486 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 485 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
487 SLOT( updateTodo( Todo *, int ) ) ); 486 SLOT( updateTodo( Todo *, int ) ) );
488 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 487 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
489 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 488 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
490 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 489 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
491 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 490 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
492 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 491 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
493 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 492 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
494 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 493 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
495 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 494 mMainView, SLOT ( todo_unsub( Todo * ) ) );
496 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 495 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
497 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 496 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
498 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 497 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
499 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 498 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
500 KConfig *config = KOGlobals::config(); 499 KConfig *config = KOGlobals::config();
501 mTodoView->restoreLayout(config,"Todo View"); 500 mTodoView->restoreLayout(config,"Todo View");
502 } 501 }
503 502
504 globalFlagBlockAgenda = 1; 503 globalFlagBlockAgenda = 1;
505 showView( mTodoView, true ); 504 showView( mTodoView, true );
506 505
507} 506}
508 507
509void KOViewManager::showJournalView() 508void KOViewManager::showJournalView()
510{ 509{
511 //mFlagShowNextxDays = false; 510 //mFlagShowNextxDays = false;
512 if (!mJournalView) { 511 if (!mJournalView) {
513 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 512 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
514 "KOViewManager::JournalView"); 513 "KOViewManager::JournalView");
515 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 514 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
516 SLOT( updateConfig() ) ); 515 SLOT( updateConfig() ) );
517 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 516 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
518 addView(mJournalView); 517 addView(mJournalView);
519 } 518 }
520 519
521 showView(mJournalView); 520 showView(mJournalView);
522} 521}
523 522
524void KOViewManager::showTimeSpanView() 523void KOViewManager::showTimeSpanView()
525{ 524{
526 //mFlagShowNextxDays = false; 525 //mFlagShowNextxDays = false;
527 if (!mTimeSpanView) { 526 if (!mTimeSpanView) {
528 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 527 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
529 "KOViewManager::TimeSpanView"); 528 "KOViewManager::TimeSpanView");
530 addView(mTimeSpanView); 529 addView(mTimeSpanView);
531 530
532 mTimeSpanView->readSettings(); 531 mTimeSpanView->readSettings();
533 } 532 }
534 533
535 showView(mTimeSpanView); 534 showView(mTimeSpanView);
536} 535}
537 536
538Incidence *KOViewManager::currentSelection() 537Incidence *KOViewManager::currentSelection()
539{ 538{
540 if (!mCurrentView) return 0; 539 if (!mCurrentView) return 0;
541 if ( mCurrentView == mListView ) { 540 if ( mCurrentView == mListView ) {
542 if ( mListView->currentItem() ) 541 if ( mListView->currentItem() )
543 return mListView->currentItem(); 542 return mListView->currentItem();
544 } 543 }
545 return mCurrentView->selectedIncidences().first(); 544 return mCurrentView->selectedIncidences().first();
546} 545}
547 546
548QDate KOViewManager::currentSelectionDate() 547QDate KOViewManager::currentSelectionDate()
549{ 548{
550 QDate qd; 549 QDate qd;
551 if (mCurrentView) { 550 if (mCurrentView) {
552 DateList qvl = mCurrentView->selectedDates(); 551 DateList qvl = mCurrentView->selectedDates();
553 if (!qvl.isEmpty()) qd = qvl.first(); 552 if (!qvl.isEmpty()) qd = qvl.first();
554 } 553 }
555 return qd; 554 return qd;
556} 555}
557 556
558void KOViewManager::addView(KOrg::BaseView *view) 557void KOViewManager::addView(KOrg::BaseView *view)
559{ 558{
560#if QT_VERSION >= 300 559#if QT_VERSION >= 300
561 mMainView->viewStack()->addWidget( view ); 560 mMainView->viewStack()->addWidget( view );
562#else 561#else
563 mMainView->viewStack()->addWidget( view, 1 ); 562 mMainView->viewStack()->addWidget( view, 1 );
564#endif 563#endif
565} 564}
566 565
567void KOViewManager::setDocumentId( const QString &id ) 566void KOViewManager::setDocumentId( const QString &id )
568{ 567{
569 if (mTodoView) mTodoView->setDocumentId( id ); 568 if (mTodoView) mTodoView->setDocumentId( id );
570} 569}
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index ffaea37..0547a2e 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,650 +1,649 @@
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 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27 27
28#include <kglobal.h> 28#include <kglobal.h>
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include <kiconloader.h> 31#include <kiconloader.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35 35
36#ifndef KORG_NOPRINTER 36#ifndef KORG_NOPRINTER
37#include "calprinter.h" 37#include "calprinter.h"
38#endif 38#endif
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "koeventviewerdialog.h" 41#include "koeventviewerdialog.h"
42 42
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44using namespace KOrg; 44using namespace KOrg;
45#include "kowhatsnextview.moc"
46 45
47void WhatsNextTextBrowser::setSource(const QString& n) 46void WhatsNextTextBrowser::setSource(const QString& n)
48{ 47{
49 48
50 if (n.startsWith("event:")) { 49 if (n.startsWith("event:")) {
51 emit showIncidence(n); 50 emit showIncidence(n);
52 return; 51 return;
53 } else if (n.startsWith("todo:")) { 52 } else if (n.startsWith("todo:")) {
54 emit showIncidence(n); 53 emit showIncidence(n);
55 return; 54 return;
56 } else { 55 } else {
57 QTextBrowser::setSource(n); 56 QTextBrowser::setSource(n);
58 } 57 }
59} 58}
60 59
61KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 60KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
62 const char *name) 61 const char *name)
63 : KOrg::BaseView(calendar, parent, name) 62 : KOrg::BaseView(calendar, parent, name)
64{ 63{
65 // mDateLabel = 64 // mDateLabel =
66 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 65 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
67 // mDateLabel->setMargin(2); 66 // mDateLabel->setMargin(2);
68 // mDateLabel->setAlignment(AlignCenter); 67 // mDateLabel->setAlignment(AlignCenter);
69 setFont( KOPrefs::instance()->mWhatsNextFont ); 68 setFont( KOPrefs::instance()->mWhatsNextFont );
70 mView = new WhatsNextTextBrowser(this); 69 mView = new WhatsNextTextBrowser(this);
71 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 70 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
72 71
73 mEventViewer = 0; 72 mEventViewer = 0;
74 73
75 QBoxLayout *topLayout = new QVBoxLayout(this); 74 QBoxLayout *topLayout = new QVBoxLayout(this);
76 // topLayout->addWidget(mDateLabel); 75 // topLayout->addWidget(mDateLabel);
77 topLayout->addWidget(mView); 76 topLayout->addWidget(mView);
78} 77}
79 78
80KOWhatsNextView::~KOWhatsNextView() 79KOWhatsNextView::~KOWhatsNextView()
81{ 80{
82} 81}
83 82
84int KOWhatsNextView::maxDatesHint() 83int KOWhatsNextView::maxDatesHint()
85{ 84{
86 return 0; 85 return 0;
87} 86}
88 87
89int KOWhatsNextView::currentDateCount() 88int KOWhatsNextView::currentDateCount()
90{ 89{
91 return 0; 90 return 0;
92} 91}
93 92
94QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 93QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
95{ 94{
96 QPtrList<Incidence> eventList; 95 QPtrList<Incidence> eventList;
97 96
98 return eventList; 97 return eventList;
99} 98}
100 99
101 100
102void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 101void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
103 const QDate &td) 102 const QDate &td)
104{ 103{
105#ifndef KORG_NOPRINTER 104#ifndef KORG_NOPRINTER
106 calPrinter->preview(CalPrinter::Day, fd, td); 105 calPrinter->preview(CalPrinter::Day, fd, td);
107#endif 106#endif
108} 107}
109void KOWhatsNextView::updateConfig() 108void KOWhatsNextView::updateConfig()
110{ 109{
111 setFont( KOPrefs::instance()->mWhatsNextFont ); 110 setFont( KOPrefs::instance()->mWhatsNextFont );
112 updateView(); 111 updateView();
113 112
114} 113}
115void KOWhatsNextView::updateView() 114void KOWhatsNextView::updateView()
116{ 115{
117 116
118 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 117 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
119 KIconLoader kil("korganizer"); 118 KIconLoader kil("korganizer");
120 QString ipath;// = new QString(); 119 QString ipath;// = new QString();
121 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 120 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
122 //<big><big><strong>" + date + "</strong></big></big>\n"; 121 //<big><big><strong>" + date + "</strong></big></big>\n";
123 mText = "<table width=\"100%\">\n"; 122 mText = "<table width=\"100%\">\n";
124 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 123 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
125#ifdef DESKTOP_VERSION 124#ifdef DESKTOP_VERSION
126 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 125 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
127#else 126#else
128 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 127 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
129#endif 128#endif
130 // mText += "<img src=\""; 129 // mText += "<img src=\"";
131 // mText += ipath; 130 // mText += ipath;
132 // mText += "\">"; 131 // mText += "\">";
133 mEventDate = QDate::currentDate(); 132 mEventDate = QDate::currentDate();
134#ifdef DESKTOP_VERSION 133#ifdef DESKTOP_VERSION
135 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 134 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
136#else 135#else
137 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 136 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
138#endif 137#endif
139 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 138 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
140 int iii; 139 int iii;
141 mTodos.clear(); 140 mTodos.clear();
142 QPtrList<Event> events; 141 QPtrList<Event> events;
143 QPtrList<Todo> todos = calendar()->todos(); 142 QPtrList<Todo> todos = calendar()->todos();
144 Todo * todo; 143 Todo * todo;
145 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 144 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
146 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 145 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
147 bool itemAdded = false; 146 bool itemAdded = false;
148 for ( iii = 0; iii < daysToShow; ++iii ) { 147 for ( iii = 0; iii < daysToShow; ++iii ) {
149 QString date; 148 QString date;
150 itemAdded = false; 149 itemAdded = false;
151 events = calendar()->events( mEventDate, true ); 150 events = calendar()->events( mEventDate, true );
152 151
153 if ( iii == 0 ) { // today !!! 152 if ( iii == 0 ) { // today !!!
154 todo = todos.first(); 153 todo = todos.first();
155 while(todo) { 154 while(todo) {
156 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 155 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
157 if ( ! itemAdded ) { 156 if ( ! itemAdded ) {
158 appendDay ( iii, mEventDate ); 157 appendDay ( iii, mEventDate );
159 itemAdded = true; 158 itemAdded = true;
160 159
161 } 160 }
162 appendEvent(todo); 161 appendEvent(todo);
163 } 162 }
164 todo = todos.next(); 163 todo = todos.next();
165 } 164 }
166 } 165 }
167 166
168 167
169 if (events.count() > 0) { 168 if (events.count() > 0) {
170 // mText += "<p></p>"; 169 // mText += "<p></p>";
171 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 170 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
172 // mText += "<h2>"; 171 // mText += "<h2>";
173 //mText += " <img src=\""; 172 //mText += " <img src=\"";
174 //mText += ipath; 173 //mText += ipath;
175 //mText += "\">"; 174 //mText += "\">";
176 if ( ! itemAdded ) { 175 if ( ! itemAdded ) {
177 appendDay ( iii, mEventDate ); 176 appendDay ( iii, mEventDate );
178 itemAdded = true; 177 itemAdded = true;
179 178
180 } 179 }
181 Event *ev = events.first(); 180 Event *ev = events.first();
182 while(ev) { 181 while(ev) {
183 //qDebug("+++++event append %s", ev->summary().latin1()); 182 //qDebug("+++++event append %s", ev->summary().latin1());
184 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 183 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
185 appendEvent(ev, false , iii!= 0 ); 184 appendEvent(ev, false , iii!= 0 );
186 } 185 }
187 ev = events.next(); 186 ev = events.next();
188 } 187 }
189 188
190 //mText += "</table>\n"; 189 //mText += "</table>\n";
191 } 190 }
192 191
193 todo = todos.first(); 192 todo = todos.first();
194 while(todo) { 193 while(todo) {
195 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 194 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
196 if ( ! itemAdded ) { 195 if ( ! itemAdded ) {
197 appendDay ( iii, mEventDate ); 196 appendDay ( iii, mEventDate );
198 itemAdded = true; 197 itemAdded = true;
199 } 198 }
200 appendEvent(todo); 199 appendEvent(todo);
201 } 200 }
202 todo = todos.next(); 201 todo = todos.next();
203 } 202 }
204 if ( !itemAdded && iii == 0 ) { 203 if ( !itemAdded && iii == 0 ) {
205 // appendDay ( iii, mEventDate ); 204 // appendDay ( iii, mEventDate );
206 //mText += "<table>"; 205 //mText += "<table>";
207 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 206 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
208 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n"; 207 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do. ") +"</em></font></h3>\n";
209 //mText +="</table>"; 208 //mText +="</table>";
210 } 209 }
211 if ( itemAdded ) 210 if ( itemAdded )
212 mText += "</table>\n"; 211 mText += "</table>\n";
213 mEventDate = mEventDate.addDays( 1 ); 212 mEventDate = mEventDate.addDays( 1 );
214 } 213 }
215 214
216 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 215 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
217 if (todos.count() > 0 && topmostPrios > 0 ) { 216 if (todos.count() > 0 && topmostPrios > 0 ) {
218 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 217 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
219 // mText += "<h2>"; 218 // mText += "<h2>";
220 //<img src=\""; 219 //<img src=\"";
221 // mText += ipath; 220 // mText += ipath;
222 // mText += "\">"; 221 // mText += "\">";
223 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 222 // mText += i18n("Overdue To-Do:") + "</h2>\n";
224 223
225 //mText += "<ul>\n"; 224 //mText += "<ul>\n";
226 bool gotone = false; 225 bool gotone = false;
227 int priority = 1; 226 int priority = 1;
228 int priosFound = 0; 227 int priosFound = 0;
229#ifdef DESKTOP_VERSION 228#ifdef DESKTOP_VERSION
230 mText +="<p></p>"; 229 mText +="<p></p>";
231#endif 230#endif
232 231
233 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n"; 232 mText +="<big><big><strong><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></strong></big></big>\n";
234 mText += "<ul>\n"; 233 mText += "<ul>\n";
235 while (!gotone && priority<6) { 234 while (!gotone && priority<6) {
236 todo = todos.first(); 235 todo = todos.first();
237 while(todo) { 236 while(todo) {
238 if (!todo->isCompleted() && (todo->priority() == priority) ) { 237 if (!todo->isCompleted() && (todo->priority() == priority) ) {
239 if ( appendTodo(todo) ) 238 if ( appendTodo(todo) )
240 gotone = true; 239 gotone = true;
241 } 240 }
242 todo = todos.next(); 241 todo = todos.next();
243 } 242 }
244 if ( gotone ) { 243 if ( gotone ) {
245 gotone = false; 244 gotone = false;
246 ++priosFound; 245 ++priosFound;
247 if ( priosFound == topmostPrios ) 246 if ( priosFound == topmostPrios )
248 break; 247 break;
249 } 248 }
250 priority++; 249 priority++;
251 // kdDebug() << "adding the todos..." << endl; 250 // kdDebug() << "adding the todos..." << endl;
252 } 251 }
253 mText += "</ul>\n"; 252 mText += "</ul>\n";
254 } 253 }
255 254
256 int replys = 0; 255 int replys = 0;
257 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 256 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
258 if (events.count() > 0) { 257 if (events.count() > 0) {
259 Event *ev = events.first(); 258 Event *ev = events.first();
260 while(ev) { 259 while(ev) {
261 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 260 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
262 if (me!=0) { 261 if (me!=0) {
263 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 262 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
264 if (replys == 0) { 263 if (replys == 0) {
265 mText += "<p></p>"; 264 mText += "<p></p>";
266 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 265 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
267 mText += "<h2>"; 266 mText += "<h2>";
268 //<img src=\""; 267 //<img src=\"";
269 // mText += ipath; 268 // mText += ipath;
270 // mText += "\">"; 269 // mText += "\">";
271 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 270 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
272 mText += "<table>\n"; 271 mText += "<table>\n";
273 } 272 }
274 replys++; 273 replys++;
275 appendEvent(ev,true); 274 appendEvent(ev,true);
276 } 275 }
277 } 276 }
278 ev = events.next(); 277 ev = events.next();
279 } 278 }
280 } 279 }
281 todos = calendar()->todos(); 280 todos = calendar()->todos();
282 if (todos.count() > 0) { 281 if (todos.count() > 0) {
283 Todo *to = todos.first(); 282 Todo *to = todos.first();
284 while(to) { 283 while(to) {
285 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 284 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
286 if (me!=0) { 285 if (me!=0) {
287 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 286 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
288 if (replys == 0) { 287 if (replys == 0) {
289 mText += "<p></p>"; 288 mText += "<p></p>";
290 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 289 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
291 mText += "<h2>"; 290 mText += "<h2>";
292 //<img src=\""; 291 //<img src=\"";
293 // mText += ipath; 292 // mText += ipath;
294 // mText += "\">"; 293 // mText += "\">";
295 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 294 mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
296 mText += "<table>\n"; 295 mText += "<table>\n";
297 } 296 }
298 replys++; 297 replys++;
299 appendEvent(to); 298 appendEvent(to);
300 } 299 }
301 } 300 }
302 kdDebug () << "check for todo-replys..." << endl; 301 kdDebug () << "check for todo-replys..." << endl;
303 to = todos.next(); 302 to = todos.next();
304 } 303 }
305 } 304 }
306 if (replys > 0 ) mText += "</table>\n"; 305 if (replys > 0 ) mText += "</table>\n";
307 306
308 307
309 mText += "</td></tr>\n</table>\n"; 308 mText += "</td></tr>\n</table>\n";
310 309
311 kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl; 310 kdDebug() << "KOWhatsNextView::updateView: text: " << mText << endl;
312 mView->setText(mText); 311 mView->setText(mText);
313 mView->setFocus(); 312 mView->setFocus();
314 313
315 // QPixmap bPix = SmallIcon( "back" ); 314 // QPixmap bPix = SmallIcon( "back" );
316 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 315 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
317 // QWidget* test = new QWidget(); 316 // QWidget* test = new QWidget();
318 // test->setBackgroundMode(FixedPixmap ); 317 // test->setBackgroundMode(FixedPixmap );
319 // test->setBackgroundPixmap ( bPix ); 318 // test->setBackgroundPixmap ( bPix );
320 // test->resize( 300, 400 ); 319 // test->resize( 300, 400 );
321 // test->show(); 320 // test->show();
322 // mView->setBackgroundMode(FixedPixmap ); 321 // mView->setBackgroundMode(FixedPixmap );
323 // mView->setBackgroundPixmap ( bPix ); 322 // mView->setBackgroundPixmap ( bPix );
324} 323}
325 324
326void KOWhatsNextView::appendDay( int i, QDate eventDate ) 325void KOWhatsNextView::appendDay( int i, QDate eventDate )
327{ 326{
328 QString date; 327 QString date;
329 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 328 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
330 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 329 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
331 if ( i == 0 ) { 330 if ( i == 0 ) {
332 mText += "<table>\n"; 331 mText += "<table>\n";
333 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 332 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
334 } 333 }
335 else if ( i == 1 ) 334 else if ( i == 1 )
336 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 335 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
337 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 336 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
338 //mText += "<h2>" + date + "</h2>\n"; 337 //mText += "<h2>" + date + "</h2>\n";
339 mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 338 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
340 mText += "<table>\n"; 339 mText += "<table>\n";
341 340
342 341
343 342
344 } else { 343 } else {
345 if ( i == 0 ) { 344 if ( i == 0 ) {
346 mText += "<table>\n"; 345 mText += "<table>\n";
347 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 346 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
348 } 347 }
349 348
350#ifdef DESKTOP_VERSION 349#ifdef DESKTOP_VERSION
351 else if ( i == 1 ) { 350 else if ( i == 1 ) {
352 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 351 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
353 } 352 }
354 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 353 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
355#else 354#else
356 else if ( i == 1 ) { 355 else if ( i == 1 ) {
357 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 356 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
358 } 357 }
359 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 358 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
360 359
361#endif 360#endif
362 //mText += "<h2>" + date + "</h2>\n"; 361 //mText += "<h2>" + date + "</h2>\n";
363 mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 362 mText += "<big><big><strong>" + date + "</strong></big></big>\n";
364 mText += "<table>\n"; 363 mText += "<table>\n";
365 } 364 }
366} 365}
367 366
368 367
369void KOWhatsNextView::showDates(const QDate &, const QDate &) 368void KOWhatsNextView::showDates(const QDate &, const QDate &)
370{ 369{
371 updateView(); 370 updateView();
372} 371}
373 372
374void KOWhatsNextView::showEvents(QPtrList<Event>) 373void KOWhatsNextView::showEvents(QPtrList<Event>)
375{ 374{
376} 375}
377 376
378void KOWhatsNextView::changeEventDisplay(Event *, int action) 377void KOWhatsNextView::changeEventDisplay(Event *, int action)
379{ 378{
380 switch(action) { 379 switch(action) {
381 case KOGlobals::EVENTADDED: 380 case KOGlobals::EVENTADDED:
382 updateView(); 381 updateView();
383 break; 382 break;
384 case KOGlobals::EVENTEDITED: 383 case KOGlobals::EVENTEDITED:
385 updateView(); 384 updateView();
386 break; 385 break;
387 case KOGlobals::EVENTDELETED: 386 case KOGlobals::EVENTDELETED:
388 updateView(); 387 updateView();
389 break; 388 break;
390 default: 389 default:
391 updateView(); 390 updateView();
392 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 391 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
393 } 392 }
394} 393}
395 394
396void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed ) 395void KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed )
397{ 396{
398 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") ) 397 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(21) == QString("last-syncEvent-device") )
399 return; 398 return;
400 QDateTime cdt = QDateTime::currentDateTime(); 399 QDateTime cdt = QDateTime::currentDateTime();
401 mText += "<tr><td><b>"; 400 mText += "<tr><td><b>";
402 if (ev->type()=="Event") { 401 if (ev->type()=="Event") {
403 402
404 if (!ev->doesFloat()) { 403 if (!ev->doesFloat()) {
405 Event *event = static_cast<Event *>(ev); 404 Event *event = static_cast<Event *>(ev);
406 QDateTime st,end; 405 QDateTime st,end;
407 if ( event->recurrence()->doesRecur() ) { 406 if ( event->recurrence()->doesRecur() ) {
408 QDate recDate= mEventDate; 407 QDate recDate= mEventDate;
409 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 408 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
410 while ( ! event->recursOn( recDate ) ) { 409 while ( ! event->recursOn( recDate ) ) {
411 recDate = recDate.addDays( -1 ); 410 recDate = recDate.addDays( -1 );
412 411
413 } 412 }
414 st = QDateTime ( recDate, event->dtStart().time() ); 413 st = QDateTime ( recDate, event->dtStart().time() );
415 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 414 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
416 } 415 }
417 else { 416 else {
418 st = event->dtStart(); 417 st = event->dtStart();
419 end = event->dtEnd(); 418 end = event->dtEnd();
420 } 419 }
421 420
422 if (reply) mText += "on " + event->dtStartDateStr() + ": "; 421 if (reply) mText += "on " + event->dtStartDateStr() + ": ";
423 QString dateText; 422 QString dateText;
424 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 423 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
425 if ( st.date() < mEventDate ) 424 if ( st.date() < mEventDate )
426 dateText = "++:++-"; 425 dateText = "++:++-";
427 else 426 else
428 dateText = event->dtStartTimeStr() + "-"; 427 dateText = event->dtStartTimeStr() + "-";
429 if ( end.date() > mEventDate ) 428 if ( end.date() > mEventDate )
430 dateText += "++:++"; 429 dateText += "++:++";
431 else 430 else
432 dateText += event->dtEndTimeStr(); 431 dateText += event->dtEndTimeStr();
433 if ( notRed ) 432 if ( notRed )
434 mText += dateText; 433 mText += dateText;
435 else { 434 else {
436 if ( end < cdt ) 435 if ( end < cdt )
437 mText += "<font color=\"#F00000\">" + dateText + "</font>"; 436 mText += "<font color=\"#F00000\">" + dateText + "</font>";
438 else if ( st < cdt ) 437 else if ( st < cdt )
439 mText += "<font color=\"#008000\">" + dateText + "</font>"; 438 mText += "<font color=\"#008000\">" + dateText + "</font>";
440 else 439 else
441 mText += dateText; 440 mText += dateText;
442 } 441 }
443 442
444 } else { 443 } else {
445 mText += i18n("Allday:"); 444 mText += i18n("Allday:");
446 445
447 } 446 }
448 } else { 447 } else {
449 mTodos.append( ev ); 448 mTodos.append( ev );
450 mText += i18n("ToDo:"); 449 mText += i18n("ToDo:");
451 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 450 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
452 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 451 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
453 QString dfs = KGlobal::locale()->dateFormatShort(); 452 QString dfs = KGlobal::locale()->dateFormatShort();
454 KGlobal::locale()->setIntDateFormat( 3 ); 453 KGlobal::locale()->setIntDateFormat( 3 );
455 KGlobal::locale()->setDateFormatShort("%d.%b"); 454 KGlobal::locale()->setDateFormatShort("%d.%b");
456 mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "</font>"; 455 mText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "</font>";
457 456
458 KGlobal::locale()->setDateFormatShort(dfs); 457 KGlobal::locale()->setDateFormatShort(dfs);
459 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); 458 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
460 } else { 459 } else {
461 if (!ev->doesFloat() ) 460 if (!ev->doesFloat() )
462 if( ( (Todo*)ev)->dtDue() < cdt ) { 461 if( ( (Todo*)ev)->dtDue() < cdt ) {
463 mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 462 mText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
464 463
465 464
466 } else 465 } else
467 mText +=((Todo*)ev)->dtDueTimeStr(); 466 mText +=((Todo*)ev)->dtDueTimeStr();
468 mTodos.append( ev ); 467 mTodos.append( ev );
469 } 468 }
470 } 469 }
471 mText += "</b></td><td>"; 470 mText += "</b></td><td>";
472 bool needClose = false; 471 bool needClose = false;
473 if ( ev->cancelled() ) { 472 if ( ev->cancelled() ) {
474 mText += "<font color=\"#F00000\">[c"; 473 mText += "<font color=\"#F00000\">[c";
475 needClose =true; 474 needClose =true;
476 475
477 } 476 }
478 if ( ev->isAlarmEnabled() ) { 477 if ( ev->isAlarmEnabled() ) {
479 if ( !needClose) 478 if ( !needClose)
480 mText +="["; 479 mText +="[";
481 mText += "a"; 480 mText += "a";
482 needClose =true; 481 needClose =true;
483 482
484 } 483 }
485 if ( ev->description().length() > 0 ) { 484 if ( ev->description().length() > 0 ) {
486 if ( !needClose) 485 if ( !needClose)
487 mText +="["; 486 mText +="[";
488 mText += "i"; 487 mText += "i";
489 needClose =true; 488 needClose =true;
490 } 489 }
491 if ( ev->recurrence()->doesRecur() ) { 490 if ( ev->recurrence()->doesRecur() ) {
492 if ( !needClose) 491 if ( !needClose)
493 mText +="["; 492 mText +="[";
494 mText += "r"; 493 mText += "r";
495 needClose =true; 494 needClose =true;
496 } 495 }
497 if ( needClose ) { 496 if ( needClose ) {
498 mText += "] "; 497 mText += "] ";
499 } 498 }
500 if ( ev->cancelled() ) 499 if ( ev->cancelled() )
501 mText += "</font>"; 500 mText += "</font>";
502 mText += "<a "; 501 mText += "<a ";
503 if (ev->type()=="Event") mText += "href=\"event:"; 502 if (ev->type()=="Event") mText += "href=\"event:";
504 if (ev->type()=="Todo") mText += "href=\"todo:"; 503 if (ev->type()=="Todo") mText += "href=\"todo:";
505 mText += ev->uid() + "\">"; 504 mText += ev->uid() + "\">";
506 if ( ev->summary().length() > 0 ) 505 if ( ev->summary().length() > 0 )
507 mText += ev->summary(); 506 mText += ev->summary();
508 else 507 else
509 mText += i18n("-no summary-"); 508 mText += i18n("-no summary-");
510 mText += "</a>"; 509 mText += "</a>";
511 if ( KOPrefs::instance()->mWNViewShowLocation ) 510 if ( KOPrefs::instance()->mWNViewShowLocation )
512 if ( !ev->location().isEmpty() ) 511 if ( !ev->location().isEmpty() )
513 mText += " ("+ev->location() +")"; 512 mText += " ("+ev->location() +")";
514 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 513 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
515 mText += " ["+ev->relatedTo()->summary() +"]"; 514 mText += " ["+ev->relatedTo()->summary() +"]";
516 mText += "</td></tr>\n"; 515 mText += "</td></tr>\n";
517} 516}
518 517
519bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 518bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
520{ 519{
521 if ( mTodos.find( ev ) != mTodos.end() ) return false; 520 if ( mTodos.find( ev ) != mTodos.end() ) return false;
522 521
523 mTodos.append( ev ); 522 mTodos.append( ev );
524 if ( !isSub ) 523 if ( !isSub )
525 mText += "<p>"; 524 mText += "<p>";
526 else 525 else
527 mText += "<li>"; 526 mText += "<li>";
528 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 527 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
529 528
530 529
531 mText += ind; 530 mText += ind;
532 bool needClose = false; 531 bool needClose = false;
533 if ( ev->cancelled() ) { 532 if ( ev->cancelled() ) {
534 mText += "<font color=\"#F00000\">[c"; 533 mText += "<font color=\"#F00000\">[c";
535 needClose =true; 534 needClose =true;
536 535
537 } 536 }
538 if ( ev->isAlarmEnabled() ) { 537 if ( ev->isAlarmEnabled() ) {
539 if ( !needClose) 538 if ( !needClose)
540 mText +="["; 539 mText +="[";
541 mText += "a"; 540 mText += "a";
542 needClose =true; 541 needClose =true;
543 542
544 } 543 }
545 544
546 if ( ev->description().length() > 0 ) { 545 if ( ev->description().length() > 0 ) {
547 if ( !needClose) 546 if ( !needClose)
548 mText +="["; 547 mText +="[";
549 mText += "i"; 548 mText += "i";
550 needClose =true; 549 needClose =true;
551 } 550 }
552 // if ( ev->recurrence()->doesRecur() ) { 551 // if ( ev->recurrence()->doesRecur() ) {
553 // if ( !needClose) 552 // if ( !needClose)
554 // mText +="("; 553 // mText +="(";
555 // mText += "r"; 554 // mText += "r";
556 // needClose =true; 555 // needClose =true;
557 // } 556 // }
558 if ( needClose ) 557 if ( needClose )
559 mText += "] "; 558 mText += "] ";
560 if ( ev->cancelled() ) 559 if ( ev->cancelled() )
561 mText += "</font>"; 560 mText += "</font>";
562 mText += "<a href=\"todo:" + ev->uid() + "\">"; 561 mText += "<a href=\"todo:" + ev->uid() + "\">";
563 mText += ev->summary(); 562 mText += ev->summary();
564 mText += "</a>"; 563 mText += "</a>";
565 if ( ((Todo*)ev)->hasDueDate () ) { 564 if ( ((Todo*)ev)->hasDueDate () ) {
566 QString year = ""; 565 QString year = "";
567 int ye = ((Todo*)ev)->dtDue().date().year(); 566 int ye = ((Todo*)ev)->dtDue().date().year();
568 if ( QDateTime::currentDateTime().date().year() != ye ) 567 if ( QDateTime::currentDateTime().date().year() != ye )
569 year = QString::number( ye ); 568 year = QString::number( ye );
570 QString dfs = KGlobal::locale()->dateFormatShort(); 569 QString dfs = KGlobal::locale()->dateFormatShort();
571 KGlobal::locale()->setIntDateFormat( 3 ); 570 KGlobal::locale()->setIntDateFormat( 3 );
572 KGlobal::locale()->setDateFormatShort("%d.%b"); 571 KGlobal::locale()->setDateFormatShort("%d.%b");
573 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "."+ year +"]</font>"; 572 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true) + "."+ year +"]</font>";
574 573
575 KGlobal::locale()->setDateFormatShort(dfs); 574 KGlobal::locale()->setDateFormatShort(dfs);
576 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate ); 575 KGlobal::locale()->setIntDateFormat( KOPrefs::instance()->mPreferredDate );
577 } 576 }
578 if ( KOPrefs::instance()->mWNViewShowLocation ) 577 if ( KOPrefs::instance()->mWNViewShowLocation )
579 if ( !ev->location().isEmpty() ) 578 if ( !ev->location().isEmpty() )
580 mText += " ("+ev->location() +")"; 579 mText += " ("+ev->location() +")";
581 if ( !isSub ) { 580 if ( !isSub ) {
582 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 581 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
583 mText += " ["+ev->relatedTo()->summary() +"]"; 582 mText += " ["+ev->relatedTo()->summary() +"]";
584 mText += "</p>\n"; 583 mText += "</p>\n";
585 } 584 }
586 else { 585 else {
587 ind += "-"; 586 ind += "-";
588 mText += "</li>\n"; 587 mText += "</li>\n";
589 } 588 }
590 QPtrList<Incidence> Relations = ev->relations(); 589 QPtrList<Incidence> Relations = ev->relations();
591 Incidence *to; 590 Incidence *to;
592 for (to=Relations.first();to;to=Relations.next()) { 591 for (to=Relations.first();to;to=Relations.next()) {
593 if (!((Todo*)to)->isCompleted()) 592 if (!((Todo*)to)->isCompleted())
594 appendTodo( to, ind , true ); 593 appendTodo( to, ind , true );
595 } 594 }
596 595
597 return true; 596 return true;
598} 597}
599 598
600/* 599/*
601 void KOWhatsNextView::createEventViewer() 600 void KOWhatsNextView::createEventViewer()
602 { 601 {
603 if (!mEventViewer) { 602 if (!mEventViewer) {
604 603
605 mEventViewer = new KOEventViewerDialog(this); 604 mEventViewer = new KOEventViewerDialog(this);
606 } 605 }
607 } 606 }
608*/ 607*/
609void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 608void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
610{ 609{
611 if ( mEventViewer ) 610 if ( mEventViewer )
612 delete mEventViewer; 611 delete mEventViewer;
613 mEventViewer = v; 612 mEventViewer = v;
614} 613}
615 614
616// TODO: Create this function in CalendarView and remove it from here 615// TODO: Create this function in CalendarView and remove it from here
617void KOWhatsNextView::showIncidence(const QString &uid) 616void KOWhatsNextView::showIncidence(const QString &uid)
618{ 617{
619 if ( !mEventViewer ) { 618 if ( !mEventViewer ) {
620 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 619 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
621 return; 620 return;
622 } 621 }
623 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 622 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
624 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 623 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
625 if (uid.startsWith("event:")) { 624 if (uid.startsWith("event:")) {
626#ifdef DESKTOP_VERSION 625#ifdef DESKTOP_VERSION
627 Event *event = calendar()->event(uid.mid(8)); 626 Event *event = calendar()->event(uid.mid(8));
628#else 627#else
629 Event *event = calendar()->event(uid.mid(6)); 628 Event *event = calendar()->event(uid.mid(6));
630#endif 629#endif
631 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 630 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
632 if (!event) return; 631 if (!event) return;
633 //createEventViewer(); 632 //createEventViewer();
634 mEventViewer->setEvent(event); 633 mEventViewer->setEvent(event);
635 } else if (uid.startsWith("todo:")) { 634 } else if (uid.startsWith("todo:")) {
636#ifdef DESKTOP_VERSION 635#ifdef DESKTOP_VERSION
637 Todo *todo = calendar()->todo(uid.mid(7)); 636 Todo *todo = calendar()->todo(uid.mid(7));
638#else 637#else
639 Todo *todo = calendar()->todo(uid.mid(5)); 638 Todo *todo = calendar()->todo(uid.mid(5));
640#endif 639#endif
641 if (!todo) return; 640 if (!todo) return;
642 //createEventViewer(); 641 //createEventViewer();
643 mEventViewer->setTodo(todo); 642 mEventViewer->setTodo(todo);
644 } else { 643 } else {
645 return; 644 return;
646 645
647 } 646 }
648 mEventViewer->showMe(); 647 mEventViewer->showMe();
649 mEventViewer->raise(); 648 mEventViewer->raise();
650} 649}
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index f9720f6..cf07a1a 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -1,528 +1,527 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown, Ian Dawes 3 Copyright (c) 1999 Preston Brown, Ian Dawes
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 <qkeycode.h> 24#include <qkeycode.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qapplication.h> 28#include <qapplication.h>
29 29
30#include <kmessagebox.h> 30#include <kmessagebox.h>
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35#include "ktimeedit.h" 35#include "ktimeedit.h"
36#include "koprefs.h" 36#include "koprefs.h"
37#include <qvalidator.h> 37#include <qvalidator.h>
38#include "ktimeedit.moc"
39 38
40// Validator for a time value with only hours and minutes (no seconds) 39// Validator for a time value with only hours and minutes (no seconds)
41// Mostly locale aware. Author: David Faure <faure@kde.org> 40// Mostly locale aware. Author: David Faure <faure@kde.org>
42class KOTimeValidator : public QValidator 41class KOTimeValidator : public QValidator
43{ 42{
44public: 43public:
45 KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {} 44 KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {}
46 45
47 virtual State validate(QString& str, int& /*cursorPos*/) const 46 virtual State validate(QString& str, int& /*cursorPos*/) const
48 { 47 {
49 return Acceptable; 48 return Acceptable;
50 bool ok = false; 49 bool ok = false;
51 // TODO use KLocale::WithoutSeconds in HEAD 50 // TODO use KLocale::WithoutSeconds in HEAD
52 /*QTime time =*/ KGlobal::locale()->readTime(str, &ok); 51 /*QTime time =*/ KGlobal::locale()->readTime(str, &ok);
53 if ( ok ) 52 if ( ok )
54 return Acceptable; 53 return Acceptable;
55 // readTime doesn't help knowing when the string is "Intermediate". 54 // readTime doesn't help knowing when the string is "Intermediate".
56 int length = str.length(); 55 int length = str.length();
57 if ( !str ) // empty string? 56 if ( !str ) // empty string?
58 return Invalid; // there should always be a ':' in it, right? 57 return Invalid; // there should always be a ':' in it, right?
59 // HACK. Not fully locale aware etc. (esp. the separator is '.' in sv_SE...) 58 // HACK. Not fully locale aware etc. (esp. the separator is '.' in sv_SE...)
60 QChar sep = ':'; 59 QChar sep = ':';
61 // I want to allow "HH:", ":MM" and ":" to make editing easier 60 // I want to allow "HH:", ":MM" and ":" to make editing easier
62 if ( str[0] == sep ) 61 if ( str[0] == sep )
63 { 62 {
64 if ( length == 1 ) // just ":" 63 if ( length == 1 ) // just ":"
65 return Intermediate; 64 return Intermediate;
66 QString minutes = str.mid(1); 65 QString minutes = str.mid(1);
67 int m = minutes.toInt(&ok); 66 int m = minutes.toInt(&ok);
68 if ( ok && m >= 0 && m < 60 ) 67 if ( ok && m >= 0 && m < 60 )
69 return Intermediate; 68 return Intermediate;
70 } else if ( str.at(str.length()-1) == sep ) 69 } else if ( str.at(str.length()-1) == sep )
71 { 70 {
72 QString hours = str.left(length-1); 71 QString hours = str.left(length-1);
73 int h = hours.toInt(&ok); 72 int h = hours.toInt(&ok);
74 if ( ok && h >= 0 && h < 24 ) 73 if ( ok && h >= 0 && h < 24 )
75 return Intermediate; 74 return Intermediate;
76 } 75 }
77 return Invalid; 76 return Invalid;
78 } 77 }
79}; 78};
80 79
81// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. 80// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox.
82// Difficult to get all in one... 81// Difficult to get all in one...
83// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. 82// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help.
84KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) 83KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
85 : QComboBox(TRUE, parent, name) 84 : QComboBox(TRUE, parent, name)
86{ 85{
87 setInsertionPolicy(NoInsertion); 86 setInsertionPolicy(NoInsertion);
88 setValidator( new KOTimeValidator( this ) ); 87 setValidator( new KOTimeValidator( this ) );
89 mFlagKeyPressed = false; 88 mFlagKeyPressed = false;
90 89
91 if ( QApplication::desktop()->width() < 650 ) 90 if ( QApplication::desktop()->width() < 650 )
92 setSizeLimit ( 6 ); 91 setSizeLimit ( 6 );
93 mTime = qt; 92 mTime = qt;
94 93
95// mNoTimeString = i18n("No Time"); 94// mNoTimeString = i18n("No Time");
96// insertItem( mNoTimeString ); 95// insertItem( mNoTimeString );
97 96
98 // Fill combo box with selection of times in localized format. 97 // Fill combo box with selection of times in localized format.
99 QTime timeEntry(0,0,0); 98 QTime timeEntry(0,0,0);
100 do { 99 do {
101 insertItem(KGlobal::locale()->formatTime(timeEntry)); 100 insertItem(KGlobal::locale()->formatTime(timeEntry));
102 timeEntry = timeEntry.addSecs(60*15); 101 timeEntry = timeEntry.addSecs(60*15);
103 } while (!timeEntry.isNull()); 102 } while (!timeEntry.isNull());
104 // Add end of day. 103 // Add end of day.
105 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); 104 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) );
106 105
107 updateText(); 106 updateText();
108 setFocusPolicy(QWidget::StrongFocus); 107 setFocusPolicy(QWidget::StrongFocus);
109 108
110 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); 109 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int)));
111 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); 110 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
112 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); 111 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText()));
113 QFontMetrics fm ( font() ); 112 QFontMetrics fm ( font() );
114 QString timeString = "24:00"; 113 QString timeString = "24:00";
115 if ( KOPrefs::instance()->mPreferredTime == 1 ) 114 if ( KOPrefs::instance()->mPreferredTime == 1 )
116 timeString = "02:00pm"; 115 timeString = "02:00pm";
117 int addSpace = 32; 116 int addSpace = 32;
118 if ( QApplication::desktop()->width() > 320 ) 117 if ( QApplication::desktop()->width() > 320 )
119 timeString += ":00"; 118 timeString += ":00";
120 setFixedWidth(fm.width( timeString ) + 32 ); 119 setFixedWidth(fm.width( timeString ) + 32 );
121 120
122 // Highlight Background and Textcolor change from default 121 // Highlight Background and Textcolor change from default
123 QPalette palette = QWidget::palette(); 122 QPalette palette = QWidget::palette();
124 unsigned char red, green, blue; 123 unsigned char red, green, blue;
125 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; 124 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10;
126 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; 125 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10;
127 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; 126 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10;
128 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); 127 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) );
129 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); 128 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) );
130 setPalette( palette ); 129 setPalette( palette );
131} 130}
132 131
133KOTimeEdit::~KOTimeEdit() 132KOTimeEdit::~KOTimeEdit()
134{ 133{
135} 134}
136 135
137bool KOTimeEdit::hasTime() const 136bool KOTimeEdit::hasTime() const
138{ 137{
139 // Can't happen 138 // Can't happen
140 if ( currentText().isEmpty() ) return false; 139 if ( currentText().isEmpty() ) return false;
141 //if ( currentText() == mNoTimeString ) return false; 140 //if ( currentText() == mNoTimeString ) return false;
142 141
143 return true; // always 142 return true; // always
144} 143}
145 144
146QTime KOTimeEdit::getTime() const 145QTime KOTimeEdit::getTime() const
147{ 146{
148 //kdDebug(5850) << "KOTimeEdit::getTime(), currentText() = " << currentText() << endl; 147 //kdDebug(5850) << "KOTimeEdit::getTime(), currentText() = " << currentText() << endl;
149 // TODO use KLocale::WithoutSeconds in HEAD 148 // TODO use KLocale::WithoutSeconds in HEAD
150 QTime time = KGlobal::locale()->readTime(currentText()); 149 QTime time = KGlobal::locale()->readTime(currentText());
151 // kdDebug(5850) << "KOTimeEdit::getTime(): " << time.toString() << endl; 150 // kdDebug(5850) << "KOTimeEdit::getTime(): " << time.toString() << endl;
152 return time; 151 return time;
153} 152}
154/* 153/*
155QSizePolicy KOTimeEdit::sizePolicy() const 154QSizePolicy KOTimeEdit::sizePolicy() const
156{ 155{
157 // Set size policy to Fixed, because edit cannot contain more text than the 156 // Set size policy to Fixed, because edit cannot contain more text than the
158 // string representing the time. It doesn't make sense to provide more space. 157 // string representing the time. It doesn't make sense to provide more space.
159 QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); 158 QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
160 159
161 return sizePolicy; 160 return sizePolicy;
162} 161}
163*/ 162*/
164void KOTimeEdit::setTime(QTime newTime) 163void KOTimeEdit::setTime(QTime newTime)
165{ 164{
166 if ( mTime != newTime ) 165 if ( mTime != newTime )
167 { 166 {
168 kdDebug(5850) << "KOTimeEdit::setTime(): " << newTime.toString() << endl; 167 kdDebug(5850) << "KOTimeEdit::setTime(): " << newTime.toString() << endl;
169 168
170 mTime = newTime; 169 mTime = newTime;
171 updateText(); 170 updateText();
172 } 171 }
173 172
174} 173}
175 174
176void KOTimeEdit::activ(int i) 175void KOTimeEdit::activ(int i)
177{ 176{
178 // The last entry, 23:59, is a special case 177 // The last entry, 23:59, is a special case
179 if( i == count() - 1 ) 178 if( i == count() - 1 )
180 mTime = QTime( 23, 59, 0 ); 179 mTime = QTime( 23, 59, 0 );
181 else 180 else
182 mTime = QTime(0,0,0).addSecs(i*15*60); 181 mTime = QTime(0,0,0).addSecs(i*15*60);
183 emit timeChanged(mTime); 182 emit timeChanged(mTime);
184} 183}
185 184
186void KOTimeEdit::hilit(int ) 185void KOTimeEdit::hilit(int )
187{ 186{
188 // we don't currently need to do anything here. 187 // we don't currently need to do anything here.
189} 188}
190 189
191void KOTimeEdit::addTime(QTime qt, bool update) 190void KOTimeEdit::addTime(QTime qt, bool update)
192{ 191{
193 // Calculate the new time. 192 // Calculate the new time.
194 //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); 193 //qDebug("add h %d min %d ", qt.hour(),qt.minute() );
195 mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); 194 mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600);
196 // if ( update ) 195 // if ( update )
197 updateText(); 196 updateText();
198 emit timeChanged(mTime); 197 emit timeChanged(mTime);
199} 198}
200 199
201void KOTimeEdit::subTime(QTime qt, bool update) 200void KOTimeEdit::subTime(QTime qt, bool update)
202{ 201{
203 int h, m; 202 int h, m;
204 //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); 203 //qDebug("sub h %d min %d ", qt.hour(),qt.minute() );
205 204
206 mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); 205 mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600));
207 // store the newly calculated time. 206 // store the newly calculated time.
208 // mTime.setHMS(h, m, 0); 207 // mTime.setHMS(h, m, 0);
209 //if ( update ) 208 //if ( update )
210 updateText(); 209 updateText();
211 emit timeChanged(mTime); 210 emit timeChanged(mTime);
212} 211}
213 212
214// void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) 213// void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * )
215// { 214// {
216// qDebug("mouseReleaseEvent ( QMouseEvent * ) "); 215// qDebug("mouseReleaseEvent ( QMouseEvent * ) ");
217// } 216// }
218 217
219// void KOTimeEdit::focusInEvent ( QFocusEvent * ) 218// void KOTimeEdit::focusInEvent ( QFocusEvent * )
220// { 219// {
221// qDebug("focusInEvent ( QFocusEvent * ) "); 220// qDebug("focusInEvent ( QFocusEvent * ) ");
222// } 221// }
223 222
224void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) 223void KOTimeEdit::keyReleaseEvent(QKeyEvent *e)
225{ 224{
226 if ( !e->isAutoRepeat() ) { 225 if ( !e->isAutoRepeat() ) {
227 mFlagKeyPressed = false; 226 mFlagKeyPressed = false;
228 } 227 }
229 228
230} 229}
231void KOTimeEdit::setSelect( int from, int to ) 230void KOTimeEdit::setSelect( int from, int to )
232{ 231{
233 if ( KOPrefs::instance()->mHightlightDateTimeEdit) 232 if ( KOPrefs::instance()->mHightlightDateTimeEdit)
234 lineEdit()->setSelection( from , to ); 233 lineEdit()->setSelection( from , to );
235} 234}
236 235
237 236
238void KOTimeEdit::keyPressEvent(QKeyEvent *e) 237void KOTimeEdit::keyPressEvent(QKeyEvent *e)
239{ 238{
240 239
241 qApp->processEvents(); 240 qApp->processEvents();
242 bool hour12Format = ( KOPrefs::instance()->mPreferredTime == 1 ); 241 bool hour12Format = ( KOPrefs::instance()->mPreferredTime == 1 );
243 int maxpos = hour12Format?7:5; 242 int maxpos = hour12Format?7:5;
244 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 243 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
245 e->ignore(); 244 e->ignore();
246 // qDebug(" ignore %d",e->isAutoRepeat() ); 245 // qDebug(" ignore %d",e->isAutoRepeat() );
247 return; 246 return;
248 } 247 }
249 if (! e->isAutoRepeat() ) { 248 if (! e->isAutoRepeat() ) {
250 mFlagKeyPressed = true; 249 mFlagKeyPressed = true;
251 } 250 }
252 // Tap -> Focus Next Widget 251 // Tap -> Focus Next Widget
253 if ( e->key() == Key_Tab ) { 252 if ( e->key() == Key_Tab ) {
254 QComboBox::keyPressEvent(e); 253 QComboBox::keyPressEvent(e);
255 return; 254 return;
256 } 255 }
257 256
258 // save Text from QLineEdit and CursorPosition 257 // save Text from QLineEdit and CursorPosition
259 QString text = lineEdit()->text(); 258 QString text = lineEdit()->text();
260 int cpos = lineEdit()->cursorPosition(); 259 int cpos = lineEdit()->cursorPosition();
261 // qDebug("cpos %d ", cpos); 260 // qDebug("cpos %d ", cpos);
262 261
263 // Switch for arrows, backspace and escape 262 // Switch for arrows, backspace and escape
264 switch(e->key()) { 263 switch(e->key()) {
265 case Key_Escape: 264 case Key_Escape:
266 lineEdit()->deselect(); 265 lineEdit()->deselect();
267 case Key_Tab: 266 case Key_Tab:
268 QComboBox::keyPressEvent(e); 267 QComboBox::keyPressEvent(e);
269 break; 268 break;
270 case Key_Up: 269 case Key_Up:
271 if ( e->state () == Qt::ControlButton ) { 270 if ( e->state () == Qt::ControlButton ) {
272 addTime(QTime(0,15,0), false ); 271 addTime(QTime(0,15,0), false );
273 lineEdit()->setCursorPosition(3); 272 lineEdit()->setCursorPosition(3);
274 setSelect( 3 , 2 ); 273 setSelect( 3 , 2 );
275 } 274 }
276 else 275 else
277 if ( e->state () == Qt::ShiftButton ) { 276 if ( e->state () == Qt::ShiftButton ) {
278 addTime(QTime(1,0,0), false ); 277 addTime(QTime(1,0,0), false );
279 lineEdit()->setCursorPosition(0); 278 lineEdit()->setCursorPosition(0);
280 setSelect( 0 , 2 ); 279 setSelect( 0 , 2 );
281 } 280 }
282 else 281 else
283 // switch time up, cursor location depend 282 // switch time up, cursor location depend
284 switch (cpos) { 283 switch (cpos) {
285 case 7: 284 case 7:
286 case 6: 285 case 6:
287 case 5: 286 case 5:
288 if(!hour12Format) { 287 if(!hour12Format) {
289 lineEdit()->setCursorPosition(cpos = 4); 288 lineEdit()->setCursorPosition(cpos = 4);
290 } else { 289 } else {
291 addTime(QTime(12,0,0), false ); 290 addTime(QTime(12,0,0), false );
292 setSelect ( 5 , 2 ); 291 setSelect ( 5 , 2 );
293 break; 292 break;
294 } 293 }
295 case 4: 294 case 4:
296 addTime(QTime(0,1,0), false ); 295 addTime(QTime(0,1,0), false );
297 setSelect ( cpos , 1 ); 296 setSelect ( cpos , 1 );
298 break; 297 break;
299 case 3: 298 case 3:
300 addTime(QTime(0,10,0), false ); 299 addTime(QTime(0,10,0), false );
301 setSelect ( cpos , 1 ); 300 setSelect ( cpos , 1 );
302 break; 301 break;
303 case 2: 302 case 2:
304 lineEdit()->setCursorPosition(--cpos); 303 lineEdit()->setCursorPosition(--cpos);
305 case 1: 304 case 1:
306 case 0: 305 case 0:
307 addTime(QTime(1,0,0), false ); 306 addTime(QTime(1,0,0), false );
308 setSelect ( 0, 2 ); 307 setSelect ( 0, 2 );
309 break; 308 break;
310 } 309 }
311 break; 310 break;
312 case Key_Down: 311 case Key_Down:
313 if ( e->state () == Qt::ControlButton ) { 312 if ( e->state () == Qt::ControlButton ) {
314 subTime(QTime(0,15,0), false ); 313 subTime(QTime(0,15,0), false );
315 lineEdit()->setCursorPosition(3); 314 lineEdit()->setCursorPosition(3);
316 setSelect( 3 , 2 ); 315 setSelect( 3 , 2 );
317 } 316 }
318 else 317 else
319 if ( e->state () == Qt::ShiftButton ) { 318 if ( e->state () == Qt::ShiftButton ) {
320 subTime(QTime(1,0,0), false ); 319 subTime(QTime(1,0,0), false );
321 lineEdit()->setCursorPosition(0); 320 lineEdit()->setCursorPosition(0);
322 setSelect( 0 , 2 ); 321 setSelect( 0 , 2 );
323 } 322 }
324 else 323 else
325 // switch time down, cursor location depend 324 // switch time down, cursor location depend
326 switch (cpos) { 325 switch (cpos) {
327 case 7: 326 case 7:
328 case 6: 327 case 6:
329 case 5: 328 case 5:
330 if(!hour12Format) { 329 if(!hour12Format) {
331 lineEdit()->setCursorPosition(cpos = 4); 330 lineEdit()->setCursorPosition(cpos = 4);
332 } else { 331 } else {
333 subTime(QTime(12,0,0), false ); 332 subTime(QTime(12,0,0), false );
334 setSelect ( 5 , 2 ); 333 setSelect ( 5 , 2 );
335 break; 334 break;
336 } 335 }
337 case 4: 336 case 4:
338 subTime(QTime(0,1,0), false ); 337 subTime(QTime(0,1,0), false );
339 setSelect ( cpos , 1 ); 338 setSelect ( cpos , 1 );
340 break; 339 break;
341 case 3: 340 case 3:
342 subTime(QTime(0,10,0), false ); 341 subTime(QTime(0,10,0), false );
343 setSelect ( cpos , 1 ); 342 setSelect ( cpos , 1 );
344 break; 343 break;
345 case 2: 344 case 2:
346 lineEdit()->setCursorPosition(--cpos); 345 lineEdit()->setCursorPosition(--cpos);
347 case 1: 346 case 1:
348 case 0: 347 case 0:
349 subTime(QTime(1,0,0), false ); 348 subTime(QTime(1,0,0), false );
350 setSelect ( 0 , 2 ); 349 setSelect ( 0 , 2 );
351 break; 350 break;
352 } 351 }
353 break; 352 break;
354 // set cursor to correct place 353 // set cursor to correct place
355 case Key_Left: 354 case Key_Left:
356 if ( cpos == 3 ) 355 if ( cpos == 3 )
357 --cpos; 356 --cpos;
358 if ( cpos > 0) { 357 if ( cpos > 0) {
359 lineEdit()->setCursorPosition(--cpos); 358 lineEdit()->setCursorPosition(--cpos);
360 setSelect ( cpos , 1 ); 359 setSelect ( cpos , 1 );
361 } 360 }
362 else 361 else
363 setSelect ( 0 , 1 ); 362 setSelect ( 0 , 1 );
364 break; 363 break;
365 // set cursor to correct place 364 // set cursor to correct place
366 case Key_Right: 365 case Key_Right:
367 if ( cpos == 1 ) 366 if ( cpos == 1 )
368 ++cpos; 367 ++cpos;
369 if ( cpos < maxpos ) { 368 if ( cpos < maxpos ) {
370 lineEdit()->setCursorPosition(++cpos); 369 lineEdit()->setCursorPosition(++cpos);
371 setSelect ( cpos , 1 ); 370 setSelect ( cpos , 1 );
372 } 371 }
373 break; 372 break;
374 // rest 373 // rest
375 case Key_Prior: 374 case Key_Prior:
376 subTime(QTime(1,0,0)); 375 subTime(QTime(1,0,0));
377 break; 376 break;
378 case Key_Next: 377 case Key_Next:
379 addTime(QTime(1,0,0)); 378 addTime(QTime(1,0,0));
380 break; 379 break;
381 case Key_Backspace: 380 case Key_Backspace:
382 if ( cpos > 0) { 381 if ( cpos > 0) {
383 if ( cpos == 3 ) 382 if ( cpos == 3 )
384 --cpos; 383 --cpos;
385 if ( cpos > 5) 384 if ( cpos > 5)
386 cpos = 5; 385 cpos = 5;
387 text.at( cpos-1 ) = '0'; 386 text.at( cpos-1 ) = '0';
388 lineEdit()->setText( text ); 387 lineEdit()->setText( text );
389 lineEdit()->setCursorPosition(--cpos); 388 lineEdit()->setCursorPosition(--cpos);
390 setSelect ( cpos , 1 ); 389 setSelect ( cpos , 1 );
391 changedText(); 390 changedText();
392 } 391 }
393 break; 392 break;
394 } // switch arrows 393 } // switch arrows
395 394
396 // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos 395 // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos
397 if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { 396 if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) {
398 lineEdit()->deselect(); 397 lineEdit()->deselect();
399 cpos = 0; 398 cpos = 0;
400 lineEdit()->setCursorPosition(cpos); 399 lineEdit()->setCursorPosition(cpos);
401 setSelect(cpos , 1); 400 setSelect(cpos , 1);
402 } 401 }
403 402
404 if ( cpos == 2 ) { 403 if ( cpos == 2 ) {
405 lineEdit()->setCursorPosition(++cpos); 404 lineEdit()->setCursorPosition(++cpos);
406 } 405 }
407 406
408 // num keys when cursorPos preEnd 407 // num keys when cursorPos preEnd
409 if ( cpos < 5 ) { 408 if ( cpos < 5 ) {
410 // switch another keys 409 // switch another keys
411 switch(e->key()) { 410 switch(e->key()) {
412 case Key_Delete: 411 case Key_Delete:
413 text.at( cpos ) = '0'; 412 text.at( cpos ) = '0';
414 lineEdit()->setText( text ); 413 lineEdit()->setText( text );
415 lineEdit()->setCursorPosition(cpos); 414 lineEdit()->setCursorPosition(cpos);
416 setSelect ( cpos , 1 ); 415 setSelect ( cpos , 1 );
417 changedText(); 416 changedText();
418 break; 417 break;
419 case Key_9: 418 case Key_9:
420 case Key_8: 419 case Key_8:
421 case Key_7: 420 case Key_7:
422 case Key_6: 421 case Key_6:
423 if ( !(cpos == 1 || cpos == 4) ) 422 if ( !(cpos == 1 || cpos == 4) )
424 return; 423 return;
425 if ( cpos == 1 && text.at( 0 ) > '1') 424 if ( cpos == 1 && text.at( 0 ) > '1')
426 text.at( 0 ) = '1'; 425 text.at( 0 ) = '1';
427 case Key_5: 426 case Key_5:
428 case Key_4: 427 case Key_4:
429 case Key_3: 428 case Key_3:
430 if ( cpos < 1 ) 429 if ( cpos < 1 )
431 return; 430 return;
432 if ( hour12Format && cpos == 1 ) 431 if ( hour12Format && cpos == 1 )
433 return; 432 return;
434 case Key_2: 433 case Key_2:
435 if ( hour12Format && cpos == 0 ) 434 if ( hour12Format && cpos == 0 )
436 return; 435 return;
437 if ( cpos == 0 && text.at( 1 ) > '3') 436 if ( cpos == 0 && text.at( 1 ) > '3')
438 text.at( 1 ) = '3'; 437 text.at( 1 ) = '3';
439 case Key_1: 438 case Key_1:
440 case Key_0: 439 case Key_0:
441 if ( hour12Format ) { 440 if ( hour12Format ) {
442 if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) 441 if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' )
443 return; 442 return;
444 if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) 443 if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' )
445 text.at( 1 ) = '1'; 444 text.at( 1 ) = '1';
446 } 445 }
447 text.at( cpos ) = QChar ( e->key() ); 446 text.at( cpos ) = QChar ( e->key() );
448 lineEdit()->setText( text ); 447 lineEdit()->setText( text );
449 if ( cpos == 1 ) 448 if ( cpos == 1 )
450 ++cpos; 449 ++cpos;
451 if ( cpos < 5) 450 if ( cpos < 5)
452 lineEdit()->setCursorPosition(++cpos); 451 lineEdit()->setCursorPosition(++cpos);
453 setSelect( cpos , 1 ); 452 setSelect( cpos , 1 );
454 changedText(); 453 changedText();
455 break; 454 break;
456 case Key_Home: 455 case Key_Home:
457 lineEdit()->setCursorPosition(0); 456 lineEdit()->setCursorPosition(0);
458 setSelect( cpos , 1 ); 457 setSelect( cpos , 1 );
459 break; 458 break;
460 case Key_End: 459 case Key_End:
461 lineEdit()->setCursorPosition(5); 460 lineEdit()->setCursorPosition(5);
462 lineEdit()->deselect(); 461 lineEdit()->deselect();
463 break; 462 break;
464 default: 463 default:
465// QComboBox::keyPressEvent(e); 464// QComboBox::keyPressEvent(e);
466 break; 465 break;
467 } // switch num keys 466 } // switch num keys
468 } else if ( cpos == 5 ) {// if cpos < 5 467 } else if ( cpos == 5 ) {// if cpos < 5
469 if ( hour12Format ) { 468 if ( hour12Format ) {
470 if ( e->key() == Key_A ) { 469 if ( e->key() == Key_A ) {
471 text.at( 5 ) = 'a'; 470 text.at( 5 ) = 'a';
472 lineEdit()->setText( text ); 471 lineEdit()->setText( text );
473 lineEdit()->setCursorPosition(5); 472 lineEdit()->setCursorPosition(5);
474 473
475 } else if ( e->key() == Key_P ) { 474 } else if ( e->key() == Key_P ) {
476 text.at( 5 ) = 'p'; 475 text.at( 5 ) = 'p';
477 lineEdit()->setText( text ); 476 lineEdit()->setText( text );
478 lineEdit()->setCursorPosition(5); 477 lineEdit()->setCursorPosition(5);
479 478
480 } 479 }
481 } 480 }
482 } 481 }
483 482
484 483
485} 484}
486 485
487void KOTimeEdit::updateText() 486void KOTimeEdit::updateText()
488{ 487{
489// kdDebug(5850) << "KOTimeEdit::updateText() " << endl 488// kdDebug(5850) << "KOTimeEdit::updateText() " << endl
490 QString s = KGlobal::locale()->formatTime(mTime); 489 QString s = KGlobal::locale()->formatTime(mTime);
491 // Set the text but without emitting signals, nor losing the cursor position 490 // Set the text but without emitting signals, nor losing the cursor position
492 QLineEdit *line = lineEdit(); 491 QLineEdit *line = lineEdit();
493 line->blockSignals(true); 492 line->blockSignals(true);
494 int pos = line->cursorPosition(); 493 int pos = line->cursorPosition();
495 // qDebug(" settext *%s* ", s.latin1()); 494 // qDebug(" settext *%s* ", s.latin1());
496 line->setText(s); 495 line->setText(s);
497 // line->setCursorPosition(pos); 496 // line->setCursorPosition(pos);
498// line->blockSignals(false); 497// line->blockSignals(false);
499 498
500// kdDebug(5850) << "KOTimeEdit::updateText(): " << s << endl; 499// kdDebug(5850) << "KOTimeEdit::updateText(): " << s << endl;
501 500
502 if (!mTime.minute() % 15) { 501 if (!mTime.minute() % 15) {
503 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); 502 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15));
504 } 503 }
505 line->setCursorPosition(pos); 504 line->setCursorPosition(pos);
506 line->blockSignals(false); 505 line->blockSignals(false);
507 506
508} 507}
509 508
510bool KOTimeEdit::inputIsValid() const 509bool KOTimeEdit::inputIsValid() const
511{ 510{
512 int cursorPos = lineEdit()->cursorPosition(); 511 int cursorPos = lineEdit()->cursorPosition();
513 QString str = currentText(); 512 QString str = currentText();
514 return validator()->validate( str, cursorPos ) == QValidator::Acceptable; 513 return validator()->validate( str, cursorPos ) == QValidator::Acceptable;
515} 514}
516 515
517void KOTimeEdit::changedText() 516void KOTimeEdit::changedText()
518{ 517{
519 //kdDebug(5850) << "KOTimeEdit::changedText()" << endl; 518 //kdDebug(5850) << "KOTimeEdit::changedText()" << endl;
520 if ( inputIsValid() ) 519 if ( inputIsValid() )
521 { 520 {
522 int pos = lineEdit()->cursorPosition(); 521 int pos = lineEdit()->cursorPosition();
523 mTime = getTime(); 522 mTime = getTime();
524 // updateText(); 523 // updateText();
525 emit timeChanged(mTime); 524 emit timeChanged(mTime);
526 lineEdit()->setCursorPosition(pos); 525 lineEdit()->setCursorPosition(pos);
527 } 526 }
528} 527}
diff --git a/korganizer/lineview.cpp b/korganizer/lineview.cpp
index f1ff29f..e72e41c 100644
--- a/korganizer/lineview.cpp
+++ b/korganizer/lineview.cpp
@@ -1,94 +1,93 @@
1#include <qpainter.h> 1#include <qpainter.h>
2 2
3#include <kdebug.h> 3#include <kdebug.h>
4 4
5#include "koprefs.h" 5#include "koprefs.h"
6 6
7#include "lineview.h" 7#include "lineview.h"
8#include "lineview.moc"
9 8
10LineView::LineView( QWidget *parent, const char *name ) : 9LineView::LineView( QWidget *parent, const char *name ) :
11 QScrollView( parent, name ) 10 QScrollView( parent, name )
12{ 11{
13 mPixelWidth = 1000; 12 mPixelWidth = 1000;
14 13
15 mLines.setAutoDelete( true ); 14 mLines.setAutoDelete( true );
16 15
17 resizeContents( mPixelWidth, contentsHeight() ); 16 resizeContents( mPixelWidth, contentsHeight() );
18 17
19 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 18 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
20} 19}
21 20
22LineView::~LineView() 21LineView::~LineView()
23{ 22{
24} 23}
25 24
26int LineView::pixelWidth() 25int LineView::pixelWidth()
27{ 26{
28 return mPixelWidth; 27 return mPixelWidth;
29} 28}
30 29
31void LineView::addLine( int start, int end ) 30void LineView::addLine( int start, int end )
32{ 31{
33 int count = mLines.count(); 32 int count = mLines.count();
34 33
35 if( start < 0 ) start = 0; 34 if( start < 0 ) start = 0;
36 if( end > mPixelWidth) end = mPixelWidth; 35 if( end > mPixelWidth) end = mPixelWidth;
37 36
38 kdDebug() << "LineView::addLine() col: " << count << " start: " << start 37 kdDebug() << "LineView::addLine() col: " << count << " start: " << start
39 << " end: " << end << endl; 38 << " end: " << end << endl;
40 39
41 mLines.append( new Line( count, start, end ) ); 40 mLines.append( new Line( count, start, end ) );
42} 41}
43 42
44void LineView::clear() 43void LineView::clear()
45{ 44{
46 mLines.clear(); 45 mLines.clear();
47 update(); 46 update();
48} 47}
49 48
50void LineView::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 49void LineView::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
51{ 50{
52// kdDebug() << "LineView::drawContents()" << endl; 51// kdDebug() << "LineView::drawContents()" << endl;
53 52
54 int mGridSpacingX = 10; 53 int mGridSpacingX = 10;
55 int mGridSpacingY = 20; 54 int mGridSpacingY = 20;
56 55
57#if 0 56#if 0
58 // Draw vertical lines of grid 57 // Draw vertical lines of grid
59 // kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl; 58 // kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl;
60 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 59 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
61 while (x < cx + cw) { 60 while (x < cx + cw) {
62 p->drawLine(x,cy,x,cy+ch); 61 p->drawLine(x,cy,x,cy+ch);
63 x+=mGridSpacingX; 62 x+=mGridSpacingX;
64 } 63 }
65#endif 64#endif
66 65
67 // Draw horizontal lines of grid 66 // Draw horizontal lines of grid
68 int y = ((int)(cy/mGridSpacingY))*mGridSpacingY + 10; 67 int y = ((int)(cy/mGridSpacingY))*mGridSpacingY + 10;
69 while (y < cy + ch) { 68 while (y < cy + ch) {
70// kdDebug() << " y: " << y << endl; 69// kdDebug() << " y: " << y << endl;
71 p->drawLine(cx,y,cx+cw,y); 70 p->drawLine(cx,y,cx+cw,y);
72 y+=mGridSpacingY; 71 y+=mGridSpacingY;
73 } 72 }
74 73
75 Line *line; 74 Line *line;
76 for( line = mLines.first(); line; line = mLines.next() ) { 75 for( line = mLines.first(); line; line = mLines.next() ) {
77 int ctop = line->column * 20 + 10 - 5; 76 int ctop = line->column * 20 + 10 - 5;
78 int cbottom = line->column * 20 + 10 + 5; 77 int cbottom = line->column * 20 + 10 + 5;
79 int s = line->start; 78 int s = line->start;
80 int e = line->end; 79 int e = line->end;
81// kdDebug() << " LineView::drawContents(): ctop: " << ctop << " cbottom: " 80// kdDebug() << " LineView::drawContents(): ctop: " << ctop << " cbottom: "
82// << cbottom << " s: " << s << " e: " << e << endl; 81// << cbottom << " s: " << s << " e: " << e << endl;
83 if ( ctop <= (cy+ch) && cbottom >= cy && 82 if ( ctop <= (cy+ch) && cbottom >= cy &&
84 s <= (cx+cw) && e >= cx ) { 83 s <= (cx+cw) && e >= cx ) {
85 if ( s < cx ) s = cx; 84 if ( s < cx ) s = cx;
86 if ( e > (cx+cw) ) e = cx+cw; 85 if ( e > (cx+cw) ) e = cx+cw;
87 if ( ctop < cy ) ctop = cy; 86 if ( ctop < cy ) ctop = cy;
88 if ( cbottom > (cy+ch) ) cbottom = cy+ch; 87 if ( cbottom > (cy+ch) ) cbottom = cy+ch;
89// kdDebug() << " drawContents(): ctop: " << ctop << " cbottom: " 88// kdDebug() << " drawContents(): ctop: " << ctop << " cbottom: "
90// << cbottom << " s: " << s << " e: " << e << endl; 89// << cbottom << " s: " << s << " e: " << e << endl;
91 p->fillRect( s, ctop, e - s + 1, cbottom - ctop + 1, QBrush("red") ); 90 p->fillRect( s, ctop, e - s + 1, cbottom - ctop + 1, QBrush("red") );
92 } 91 }
93 } 92 }
94} 93}
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index 1052a99..f339c67 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -1,199 +1,198 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 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 <qstring.h> 25#include <qstring.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qframe.h> 29#include <qframe.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <kdebug.h> 33#include <kdebug.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include "libkdepim/kdatepicker.h" 37#include "libkdepim/kdatepicker.h"
38#include <knotifyclient.h> 38#include <knotifyclient.h>
39#include "kdatetbl.h" 39#include "kdatetbl.h"
40 40
41#include "koglobals.h" 41#include "koglobals.h"
42#include "koprefs.h" 42#include "koprefs.h"
43#ifndef KORG_NOPLUGINS 43#ifndef KORG_NOPLUGINS
44#include "kocore.h" 44#include "kocore.h"
45#endif 45#endif
46 46
47#include <kcalendarsystem.h> 47#include <kcalendarsystem.h>
48 48
49#include "navigatorbar.h" 49#include "navigatorbar.h"
50 50
51NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) 51NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
52 : QWidget( parent, name ) 52 : QWidget( parent, name )
53{ 53{
54 QBoxLayout *topLayout = new QHBoxLayout( this ); 54 QBoxLayout *topLayout = new QHBoxLayout( this );
55 55
56 // Set up the control buttons and date label 56 // Set up the control buttons and date label
57 mCtrlFrame = new QFrame( this ); 57 mCtrlFrame = new QFrame( this );
58 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); 58 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
59 mCtrlFrame->setLineWidth(1); 59 mCtrlFrame->setLineWidth(1);
60 60
61 topLayout->addWidget( mCtrlFrame ); 61 topLayout->addWidget( mCtrlFrame );
62 62
63 QFont tfont = font(); 63 QFont tfont = font();
64 if ( QApplication::desktop()->width() >= 480 ) 64 if ( QApplication::desktop()->width() >= 480 )
65 tfont.setPointSize(tfont.pointSize()+2); 65 tfont.setPointSize(tfont.pointSize()+2);
66 tfont.setBold(true); 66 tfont.setBold(true);
67 67
68 bool isRTL = KOGlobals::self()->reverseLayout(); 68 bool isRTL = KOGlobals::self()->reverseLayout();
69#ifndef DESKTOP_VERSION 69#ifndef DESKTOP_VERSION
70 bool isDesktop = false; 70 bool isDesktop = false;
71#else 71#else
72 bool isDesktop = true; 72 bool isDesktop = true;
73#endif 73#endif
74 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 74 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
75 isDesktop = true; 75 isDesktop = true;
76 // Create backward navigation buttons 76 // Create backward navigation buttons
77 mPrevYear = new QPushButton( mCtrlFrame ); 77 mPrevYear = new QPushButton( mCtrlFrame );
78 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 78 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
79 QToolTip::add( mPrevYear, i18n("Previous Year") ); 79 QToolTip::add( mPrevYear, i18n("Previous Year") );
80 80
81 mPrevMonth = new QPushButton( mCtrlFrame ); 81 mPrevMonth = new QPushButton( mCtrlFrame );
82 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 82 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
83 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 83 QToolTip::add( mPrevMonth, i18n("Previous Month") );
84 84
85 // Create forward navigation buttons 85 // Create forward navigation buttons
86 mNextMonth = new QPushButton( mCtrlFrame ); 86 mNextMonth = new QPushButton( mCtrlFrame );
87 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 87 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
88 QToolTip::add( mNextMonth, i18n("Next Month") ); 88 QToolTip::add( mNextMonth, i18n("Next Month") );
89 89
90 mNextYear = new QPushButton( mCtrlFrame ); 90 mNextYear = new QPushButton( mCtrlFrame );
91 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 91 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
92 QToolTip::add( mNextYear, i18n("Next Year") ); 92 QToolTip::add( mNextYear, i18n("Next Year") );
93 mSelectMonth = new QPushButton( mCtrlFrame ); 93 mSelectMonth = new QPushButton( mCtrlFrame );
94 // Create month name label 94 // Create month name label
95 //selectMonth->setFont( tfont ); 95 //selectMonth->setFont( tfont );
96 // selectMonth->setAlignment( AlignCenter ); 96 // selectMonth->setAlignment( AlignCenter );
97 //mDateLabel = new QLabel( selectMonth ); 97 //mDateLabel = new QLabel( selectMonth );
98 //mDateLabel->setFont( tfont ); 98 //mDateLabel->setFont( tfont );
99 //mDateLabel->setAlignment( AlignCenter ); 99 //mDateLabel->setAlignment( AlignCenter );
100 if ( QString ( name ) == QString("useBigPixmaps") ) { 100 if ( QString ( name ) == QString("useBigPixmaps") ) {
101 mNextMonth->setFlat( true); 101 mNextMonth->setFlat( true);
102 mNextYear->setFlat( true); 102 mNextYear->setFlat( true);
103 mSelectMonth->setFlat( true); 103 mSelectMonth->setFlat( true);
104 mPrevYear->setFlat( true); 104 mPrevYear->setFlat( true);
105 mPrevMonth->setFlat( true); 105 mPrevMonth->setFlat( true);
106 } 106 }
107 mSelectMonth->setFont( tfont ); 107 mSelectMonth->setFont( tfont );
108 // Set minimum width to width of widest month name label 108 // Set minimum width to width of widest month name label
109 int i; 109 int i;
110 int maxwidth = 0; 110 int maxwidth = 0;
111 QFontMetrics fm ( mSelectMonth->font() ); 111 QFontMetrics fm ( mSelectMonth->font() );
112 int width = fm.width("September '00" ); 112 int width = fm.width("September '00" );
113// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); 113// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
114// ++i ) { 114// ++i ) {
115// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, 115// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
116// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); 116// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
117// int width = fm.width("September 2000" ); 117// int width = fm.width("September 2000" );
118// if ( width > maxwidth ) maxwidth = width; 118// if ( width > maxwidth ) maxwidth = width;
119// } 119// }
120 maxwidth = width+2; 120 maxwidth = width+2;
121 int size = fm.height()+2; 121 int size = fm.height()+2;
122 if ( QApplication::desktop()->width() >= 480 ) { 122 if ( QApplication::desktop()->width() >= 480 ) {
123 size += 6; 123 size += 6;
124 maxwidth+= 6; 124 maxwidth+= 6;
125 } 125 }
126 mSelectMonth->setFixedWidth( maxwidth ); 126 mSelectMonth->setFixedWidth( maxwidth );
127 mSelectMonth->setFixedHeight( size ); 127 mSelectMonth->setFixedHeight( size );
128 mPrevYear->setFixedHeight( size ); 128 mPrevYear->setFixedHeight( size );
129 mPrevMonth->setFixedHeight( size ); 129 mPrevMonth->setFixedHeight( size );
130 mNextMonth->setFixedHeight( size ); 130 mNextMonth->setFixedHeight( size );
131 mNextYear->setFixedHeight ( size ); 131 mNextYear->setFixedHeight ( size );
132 // set up control frame layout 132 // set up control frame layout
133 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 133 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
134 ctrlLayout->addWidget( mPrevYear, 3 ); 134 ctrlLayout->addWidget( mPrevYear, 3 );
135 ctrlLayout->addWidget( mPrevMonth, 3 ); 135 ctrlLayout->addWidget( mPrevMonth, 3 );
136 //ctrlLayout->addStretch( 1 ); 136 //ctrlLayout->addStretch( 1 );
137 // ctrlLayout->addSpacing( 1 ); 137 // ctrlLayout->addSpacing( 1 );
138 // ctrlLayout->addWidget( mDateLabel ); 138 // ctrlLayout->addWidget( mDateLabel );
139 ctrlLayout->addWidget( mSelectMonth ); 139 ctrlLayout->addWidget( mSelectMonth );
140 // ctrlLayout->addSpacing( 1 ); 140 // ctrlLayout->addSpacing( 1 );
141 // ctrlLayout->addStretch( 1 ); 141 // ctrlLayout->addStretch( 1 );
142 ctrlLayout->addWidget( mNextMonth, 3 ); 142 ctrlLayout->addWidget( mNextMonth, 3 );
143 ctrlLayout->addWidget( mNextYear, 3 ); 143 ctrlLayout->addWidget( mNextYear, 3 );
144 144
145 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 145 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
146 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 146 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
147 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 147 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
148 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 148 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
149 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 149 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
150 mPrevYear->setFocusPolicy(NoFocus); 150 mPrevYear->setFocusPolicy(NoFocus);
151 mPrevMonth->setFocusPolicy(NoFocus); 151 mPrevMonth->setFocusPolicy(NoFocus);
152 mNextMonth->setFocusPolicy(NoFocus); 152 mNextMonth->setFocusPolicy(NoFocus);
153 mNextYear->setFocusPolicy(NoFocus); 153 mNextYear->setFocusPolicy(NoFocus);
154 mSelectMonth->setFocusPolicy(NoFocus); 154 mSelectMonth->setFocusPolicy(NoFocus);
155} 155}
156 156
157NavigatorBar::~NavigatorBar() 157NavigatorBar::~NavigatorBar()
158{ 158{
159} 159}
160 160
161void NavigatorBar::selectMonth() 161void NavigatorBar::selectMonth()
162{ 162{
163 163
164 int month; 164 int month;
165 KPopupFrame* popup = new KPopupFrame(this); 165 KPopupFrame* popup = new KPopupFrame(this);
166 int size = 12; 166 int size = 12;
167 if ( QApplication::desktop()->width() >= 480 ) 167 if ( QApplication::desktop()->width() >= 480 )
168 size = 18; 168 size = 18;
169 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); 169 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup);
170 // ----- 170 // -----
171 picker->resize(picker->sizeHint()); 171 picker->resize(picker->sizeHint());
172 popup->setMainWidget(picker); 172 popup->setMainWidget(picker);
173 picker->setFocus(); 173 picker->setFocus();
174 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 174 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
175 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) 175 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
176 { 176 {
177 month = picker->getResult(); 177 month = picker->getResult();
178 emit monthSelected ( month ); 178 emit monthSelected ( month );
179 } else { 179 } else {
180 KNotifyClient::beep(); 180 KNotifyClient::beep();
181 } 181 }
182 delete popup; 182 delete popup;
183} 183}
184void NavigatorBar::selectDates( const KCal::DateList &dateList ) 184void NavigatorBar::selectDates( const KCal::DateList &dateList )
185{ 185{
186 if (dateList.count() > 0) { 186 if (dateList.count() > 0) {
187 QDate date = dateList.first(); 187 QDate date = dateList.first();
188 188
189 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 189 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
190 190
191 // compute the label at the top of the navigator 191 // compute the label at the top of the navigator
192 QString dtstr = i18n(calSys->monthName( date )) + " '" + 192 QString dtstr = i18n(calSys->monthName( date )) + " '" +
193 QString::number( calSys->year( date ) ).right(2); 193 QString::number( calSys->year( date ) ).right(2);
194 194
195 mSelectMonth->setText( dtstr ); 195 mSelectMonth->setText( dtstr );
196 } 196 }
197} 197}
198 198
199#include "navigatorbar.moc"
diff --git a/korganizer/outgoingdialog.cpp b/korganizer/outgoingdialog.cpp
index 4eb64f3..0fc90c4 100644
--- a/korganizer/outgoingdialog.cpp
+++ b/korganizer/outgoingdialog.cpp
@@ -1,394 +1,393 @@
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 19
20#include <kdebug.h> 20#include <kdebug.h>
21 21
22#include <qfile.h> 22#include <qfile.h>
23#include <qdir.h> 23#include <qdir.h>
24#include <qtextstream.h> 24#include <qtextstream.h>
25 25
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28#include <ktempfile.h> 28#include <ktempfile.h>
29#include <kstandarddirs.h> 29#include <kstandarddirs.h>
30 30
31#include <libkcal/event.h> 31#include <libkcal/event.h>
32#include <libkcal/freebusy.h> 32#include <libkcal/freebusy.h>
33//#include <libkcal/imipscheduler.h> 33//#include <libkcal/imipscheduler.h>
34#include <libkcal/dummyscheduler.h> 34#include <libkcal/dummyscheduler.h>
35#include <libkcal/icalformat.h> 35#include <libkcal/icalformat.h>
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37 37
38#ifndef KORG_NOMAIL 38#ifndef KORG_NOMAIL
39#include "mailscheduler.h" 39#include "mailscheduler.h"
40#endif 40#endif
41 41
42#include "koprefs.h" 42#include "koprefs.h"
43#include "outgoingdialog.h" 43#include "outgoingdialog.h"
44#include "koeventviewerdialog.h" 44#include "koeventviewerdialog.h"
45#include "docprefs.h" 45#include "docprefs.h"
46 46
47ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev, 47ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev,
48 Scheduler::Method method, 48 Scheduler::Method method,
49 const QString &recipients) 49 const QString &recipients)
50 : QListViewItem(parent) 50 : QListViewItem(parent)
51{ 51{
52 mIncidence = ev; 52 mIncidence = ev;
53 mMethod = method; 53 mMethod = method;
54 mRecipients = recipients; 54 mRecipients = recipients;
55 55
56// kdDebug() << "ScheduleItemOut: setting the summary" << endl; 56// kdDebug() << "ScheduleItemOut: setting the summary" << endl;
57 //Set the summary 57 //Set the summary
58 if(ev->type() != "FreeBusy") { 58 if(ev->type() != "FreeBusy") {
59 Incidence *incidence = static_cast<Incidence *>(ev); 59 Incidence *incidence = static_cast<Incidence *>(ev);
60 setText(0,incidence->summary()); 60 setText(0,incidence->summary());
61 } else { 61 } else {
62 setText(0,i18n("Free Busy Object")); 62 setText(0,i18n("Free Busy Object"));
63 } 63 }
64 64
65// kdDebug() << "ScheduleItemOut: checking if the object is an event" << endl; 65// kdDebug() << "ScheduleItemOut: checking if the object is an event" << endl;
66 //If the object is an event 66 //If the object is an event
67 if(ev->type()=="Event") { 67 if(ev->type()=="Event") {
68 Event *event = static_cast<Event *>(ev); 68 Event *event = static_cast<Event *>(ev);
69 69
70 setText(1,event->dtStartDateStr()); 70 setText(1,event->dtStartDateStr());
71 if (event->doesFloat()) { //If the event floats set the start and end times to no time 71 if (event->doesFloat()) { //If the event floats set the start and end times to no time
72 setText(2,i18n("no time")); 72 setText(2,i18n("no time"));
73 setText(4,i18n("no time")); 73 setText(4,i18n("no time"));
74 } else { //If it does not float 74 } else { //If it does not float
75 setText(2,event->dtStartTimeStr()); 75 setText(2,event->dtStartTimeStr());
76 if (event->hasDuration()) { 76 if (event->hasDuration()) {
77 setText(4,event->dtEndTimeStr()); 77 setText(4,event->dtEndTimeStr());
78 } else { 78 } else {
79 setText(4,i18n("no time")); 79 setText(4,i18n("no time"));
80 } 80 }
81 } 81 }
82 if (event->hasEndDate()) { 82 if (event->hasEndDate()) {
83 setText(3,event->dtEndDateStr()); 83 setText(3,event->dtEndDateStr());
84 } 84 }
85 else { 85 else {
86 setText(3,i18n("no time")); 86 setText(3,i18n("no time"));
87 } 87 }
88 } 88 }
89 89
90 //If the object is an Todo 90 //If the object is an Todo
91 if(ev->type()=="Todo") { 91 if(ev->type()=="Todo") {
92 Todo *event = static_cast<Todo *>(ev); 92 Todo *event = static_cast<Todo *>(ev);
93 if (event->hasStartDate()) { 93 if (event->hasStartDate()) {
94 setText(1,event->dtStartDateStr()); 94 setText(1,event->dtStartDateStr());
95 if (!event->doesFloat()) { 95 if (!event->doesFloat()) {
96 setText(2,event->dtStartTimeStr()); 96 setText(2,event->dtStartTimeStr());
97 } 97 }
98 } 98 }
99 if (event->hasDueDate()) { 99 if (event->hasDueDate()) {
100 setText(3,event->dtDueDateStr()); 100 setText(3,event->dtDueDateStr());
101 if (!event->doesFloat()) { 101 if (!event->doesFloat()) {
102 setText(4,event->dtDueTimeStr()); 102 setText(4,event->dtDueTimeStr());
103 } 103 }
104 } 104 }
105 } 105 }
106 106
107// kdDebug() << "ScheduleItemOut: checking if the object is a FreeBusy object" << endl; 107// kdDebug() << "ScheduleItemOut: checking if the object is a FreeBusy object" << endl;
108 //If the object is a freebusy object 108 //If the object is a freebusy object
109 if(ev->type() == "FreeBusy") { 109 if(ev->type() == "FreeBusy") {
110 FreeBusy *freebusy = static_cast<FreeBusy *>(ev); 110 FreeBusy *freebusy = static_cast<FreeBusy *>(ev);
111 111
112 setText(1,freebusy->dtStartDateStr()); 112 setText(1,freebusy->dtStartDateStr());
113 setText(2,freebusy->dtStartTimeStr()); 113 setText(2,freebusy->dtStartTimeStr());
114 //Must try and get this to the users local settings 114 //Must try and get this to the users local settings
115 setText(3,KGlobal::locale()->formatDate( freebusy->dtEnd().date() ) ); 115 setText(3,KGlobal::locale()->formatDate( freebusy->dtEnd().date() ) );
116 setText(4,KGlobal::locale()->formatTime( freebusy->dtEnd().time() ) ); 116 setText(4,KGlobal::locale()->formatTime( freebusy->dtEnd().time() ) );
117 } 117 }
118 118
119// kdDebug() << "ScheduleItemOut: Setting the method" << endl; 119// kdDebug() << "ScheduleItemOut: Setting the method" << endl;
120 //Set the Method 120 //Set the Method
121 setText(5,Scheduler::translatedMethodName(mMethod)); 121 setText(5,Scheduler::translatedMethodName(mMethod));
122} 122}
123 123
124OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent, 124OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent,
125 const char* name,bool modal, 125 const char* name,bool modal,
126 WFlags fl) 126 WFlags fl)
127 : OutgoingDialog_base(parent,name,modal,fl) 127 : OutgoingDialog_base(parent,name,modal,fl)
128{ 128{
129 mCalendar = calendar; 129 mCalendar = calendar;
130 130
131 mFormat = new ICalFormat; 131 mFormat = new ICalFormat;
132 132
133 if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) { 133 if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) {
134 mScheduler = new DummyScheduler(mCalendar); 134 mScheduler = new DummyScheduler(mCalendar);
135 } else { 135 } else {
136#ifndef KORG_NOMAIL 136#ifndef KORG_NOMAIL
137 mScheduler = new MailScheduler(mCalendar); 137 mScheduler = new MailScheduler(mCalendar);
138#else 138#else
139 mScheduler = new DummyScheduler(mCalendar); 139 mScheduler = new DummyScheduler(mCalendar);
140#endif 140#endif
141 } 141 }
142 mMessageListView->setColumnAlignment(1,AlignHCenter); 142 mMessageListView->setColumnAlignment(1,AlignHCenter);
143 mMessageListView->setColumnAlignment(2,AlignHCenter); 143 mMessageListView->setColumnAlignment(2,AlignHCenter);
144 mMessageListView->setColumnAlignment(3,AlignHCenter); 144 mMessageListView->setColumnAlignment(3,AlignHCenter);
145 mMessageListView->setColumnAlignment(4,AlignHCenter); 145 mMessageListView->setColumnAlignment(4,AlignHCenter);
146 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), 146 QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)),
147 this,SLOT(showEvent(QListViewItem *))); 147 this,SLOT(showEvent(QListViewItem *)));
148 mDocPrefs = new DocPrefs("groupschedule"); 148 mDocPrefs = new DocPrefs("groupschedule");
149 loadMessages(); 149 loadMessages();
150} 150}
151 151
152OutgoingDialog::~OutgoingDialog() 152OutgoingDialog::~OutgoingDialog()
153{ 153{
154 delete mDocPrefs; 154 delete mDocPrefs;
155 delete mFormat; 155 delete mFormat;
156} 156}
157 157
158bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method) 158bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method)
159{ 159{
160 kdDebug() << "Outgoing::addMessage" << "Method:" << method << endl; 160 kdDebug() << "Outgoing::addMessage" << "Method:" << method << endl;
161 if (method == Scheduler::Publish) return false; 161 if (method == Scheduler::Publish) return false;
162 if( mDocPrefs ) { 162 if( mDocPrefs ) {
163 if (method != Scheduler::Cancel) { 163 if (method != Scheduler::Cancel) {
164 mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); 164 mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true );
165 } else { 165 } else {
166 if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) 166 if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") )
167 return true; 167 return true;
168 } 168 }
169 } 169 }
170 170
171 if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { 171 if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) {
172 new ScheduleItemOut(mMessageListView,incidence,method); 172 new ScheduleItemOut(mMessageListView,incidence,method);
173 saveMessage(incidence,method); 173 saveMessage(incidence,method);
174 emit numMessagesChanged(mMessageListView->childCount()); 174 emit numMessagesChanged(mMessageListView->childCount());
175 } 175 }
176 else { 176 else {
177 mScheduler->performTransaction(incidence,method); 177 mScheduler->performTransaction(incidence,method);
178 } 178 }
179 return true; 179 return true;
180} 180}
181 181
182bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method, 182bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method,
183 const QString &recipients) 183 const QString &recipients)
184{ 184{
185 //if (method != Scheduler::Publish) return false; 185 //if (method != Scheduler::Publish) return false;
186 if( mDocPrefs ) { 186 if( mDocPrefs ) {
187 if (method != Scheduler::Cancel) { 187 if (method != Scheduler::Cancel) {
188 mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); 188 mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true );
189 } else { 189 } else {
190 if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) 190 if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") )
191 return true; 191 return true;
192 } 192 }
193 } 193 }
194 if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { 194 if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) {
195 new ScheduleItemOut(mMessageListView,incidence,method,recipients); 195 new ScheduleItemOut(mMessageListView,incidence,method,recipients);
196 saveMessage(incidence,method,recipients); 196 saveMessage(incidence,method,recipients);
197 emit numMessagesChanged(mMessageListView->childCount()); 197 emit numMessagesChanged(mMessageListView->childCount());
198 } 198 }
199 else { 199 else {
200 mScheduler->performTransaction(incidence,method,recipients); 200 mScheduler->performTransaction(incidence,method,recipients);
201 } 201 }
202 return true; 202 return true;
203} 203}
204 204
205void OutgoingDialog::send() 205void OutgoingDialog::send()
206{ 206{
207 kdDebug() << "OutgoingDialog::send" << endl; 207 kdDebug() << "OutgoingDialog::send" << endl;
208 ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild()); 208 ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild());
209 while(item) { 209 while(item) {
210 bool success; 210 bool success;
211 if (item->method() == Scheduler::Publish) { 211 if (item->method() == Scheduler::Publish) {
212 success = mScheduler->publish(item->event(),item->recipients()); 212 success = mScheduler->publish(item->event(),item->recipients());
213 } else { 213 } else {
214 success = mScheduler->performTransaction(item->event(),item->method()); 214 success = mScheduler->performTransaction(item->event(),item->method());
215 } 215 }
216 ScheduleItemOut *oldItem = item; 216 ScheduleItemOut *oldItem = item;
217 item = (ScheduleItemOut *)(item->nextSibling()); 217 item = (ScheduleItemOut *)(item->nextSibling());
218 if (success) { 218 if (success) {
219 deleteMessage(oldItem->event()); 219 deleteMessage(oldItem->event());
220 delete (oldItem->event()); 220 delete (oldItem->event());
221 delete oldItem; 221 delete oldItem;
222 } 222 }
223 } 223 }
224 224
225 emit numMessagesChanged(mMessageListView->childCount()); 225 emit numMessagesChanged(mMessageListView->childCount());
226} 226}
227 227
228void OutgoingDialog::deleteItem() 228void OutgoingDialog::deleteItem()
229{ 229{
230 ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->selectedItem()); 230 ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->selectedItem());
231 if(!item) 231 if(!item)
232 return; 232 return;
233 deleteMessage(item->event()); 233 deleteMessage(item->event());
234 delete(item->event()); 234 delete(item->event());
235 mMessageListView->takeItem(item); 235 mMessageListView->takeItem(item);
236 emit numMessagesChanged(mMessageListView->childCount()); 236 emit numMessagesChanged(mMessageListView->childCount());
237} 237}
238 238
239void OutgoingDialog::showEvent(QListViewItem *qitem) 239void OutgoingDialog::showEvent(QListViewItem *qitem)
240{ 240{
241 ScheduleItemOut *item = (ScheduleItemOut *)qitem; 241 ScheduleItemOut *item = (ScheduleItemOut *)qitem;
242 Event *event = 0; 242 Event *event = 0;
243 Todo *todo = 0; 243 Todo *todo = 0;
244 if ( item->event()->type()=="Event" ) { 244 if ( item->event()->type()=="Event" ) {
245 event = static_cast<Event *>(item->event()); 245 event = static_cast<Event *>(item->event());
246 } 246 }
247 if ( item->event()->type()=="Todo" ) { 247 if ( item->event()->type()=="Todo" ) {
248 todo = static_cast<Todo *>(item->event()); 248 todo = static_cast<Todo *>(item->event());
249 } 249 }
250 QString sendText; 250 QString sendText;
251 if (event || todo) { 251 if (event || todo) {
252 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); 252 KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this);
253 if (event) eventViewer->setEvent(event); 253 if (event) eventViewer->setEvent(event);
254 if (todo) eventViewer->setTodo(todo); 254 if (todo) eventViewer->setTodo(todo);
255 sendText = "<hr><h4>"+i18n("Event will be sent to:")+"</h4>"; 255 sendText = "<hr><h4>"+i18n("Event will be sent to:")+"</h4>";
256 switch (item->method()) { 256 switch (item->method()) {
257 case Scheduler::Publish: { 257 case Scheduler::Publish: {
258 sendText += item->recipients(); 258 sendText += item->recipients();
259 break; } 259 break; }
260 case Scheduler::Request: { 260 case Scheduler::Request: {
261 sendText += i18n("All attendees"); 261 sendText += i18n("All attendees");
262 break; } 262 break; }
263 case Scheduler::Refresh: { 263 case Scheduler::Refresh: {
264 sendText += i18n("All attendees"); 264 sendText += i18n("All attendees");
265 break; } 265 break; }
266 case Scheduler::Cancel: { 266 case Scheduler::Cancel: {
267 sendText += i18n("All attendees"); 267 sendText += i18n("All attendees");
268 break; } 268 break; }
269 case Scheduler::Add: { 269 case Scheduler::Add: {
270 sendText += i18n("All attendees"); 270 sendText += i18n("All attendees");
271 break; } 271 break; }
272 case Scheduler::Reply: { 272 case Scheduler::Reply: {
273 sendText += i18n("The organizer %1").arg(item->event()->organizer()); 273 sendText += i18n("The organizer %1").arg(item->event()->organizer());
274 break; } 274 break; }
275 case Scheduler::Counter: { 275 case Scheduler::Counter: {
276 sendText += i18n("The organizer %1").arg(item->event()->organizer()); 276 sendText += i18n("The organizer %1").arg(item->event()->organizer());
277 break; } 277 break; }
278 case Scheduler::Declinecounter: { 278 case Scheduler::Declinecounter: {
279 sendText += i18n("All attendees"); 279 sendText += i18n("All attendees");
280 break; } 280 break; }
281 case Scheduler::NoMethod: { 281 case Scheduler::NoMethod: {
282 sendText += ""; 282 sendText += "";
283 break; } 283 break; }
284 default: 284 default:
285 sendText = ""; 285 sendText = "";
286 } 286 }
287 eventViewer->addText(sendText); 287 eventViewer->addText(sendText);
288 eventViewer->show(); 288 eventViewer->show();
289 } 289 }
290} 290}
291 291
292bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method, 292bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method,
293 const QString &recipients) 293 const QString &recipients)
294{ 294{
295 KTempFile ktfile(locateLocal("data","korganizer/outgoing/"),"ics"); 295 KTempFile ktfile(locateLocal("data","korganizer/outgoing/"),"ics");
296 QString messageText = mFormat->createScheduleMessage(incidence,method); 296 QString messageText = mFormat->createScheduleMessage(incidence,method);
297 QTextStream *qts = ktfile.textStream(); 297 QTextStream *qts = ktfile.textStream();
298 *qts << messageText; 298 *qts << messageText;
299 *qts << "METHOD-BEGIN:" << endl << method << endl << ":METHOD-END" << endl; 299 *qts << "METHOD-BEGIN:" << endl << method << endl << ":METHOD-END" << endl;
300 *qts << "RECIPIENTS-BEGIN:" << endl << recipients << endl << ":RECIPIENTS-END" << endl; 300 *qts << "RECIPIENTS-BEGIN:" << endl << recipients << endl << ":RECIPIENTS-END" << endl;
301 mMessageMap[incidence]=ktfile.name(); 301 mMessageMap[incidence]=ktfile.name();
302 302
303 return true; 303 return true;
304} 304}
305 305
306bool OutgoingDialog::deleteMessage(IncidenceBase *incidence) 306bool OutgoingDialog::deleteMessage(IncidenceBase *incidence)
307{ 307{
308 QFile f( mMessageMap[incidence] ); 308 QFile f( mMessageMap[incidence] );
309 mMessageMap.remove(incidence); 309 mMessageMap.remove(incidence);
310 if ( !f.exists() ) return false; 310 if ( !f.exists() ) return false;
311 else 311 else
312 return f.remove(); 312 return f.remove();
313} 313}
314 314
315void OutgoingDialog::loadMessages() 315void OutgoingDialog::loadMessages()
316{ 316{
317 Scheduler::Method method; 317 Scheduler::Method method;
318 QString recipients; 318 QString recipients;
319 319
320 QString outgoingDirName = locateLocal("data","korganizer/outgoing"); 320 QString outgoingDirName = locateLocal("data","korganizer/outgoing");
321 QDir outgoingDir(outgoingDirName); 321 QDir outgoingDir(outgoingDirName);
322 QStringList outgoing = outgoingDir.entryList(QDir::Files); 322 QStringList outgoing = outgoingDir.entryList(QDir::Files);
323 QStringList::ConstIterator it; 323 QStringList::ConstIterator it;
324 for(it = outgoing.begin(); it != outgoing.end(); ++it) { 324 for(it = outgoing.begin(); it != outgoing.end(); ++it) {
325 kdDebug() << "-- File: " << (*it) << endl; 325 kdDebug() << "-- File: " << (*it) << endl;
326 QFile f(outgoingDirName + "/" + (*it)); 326 QFile f(outgoingDirName + "/" + (*it));
327 bool inserted = false; 327 bool inserted = false;
328 QMap<IncidenceBase*, QString>::Iterator iter; 328 QMap<IncidenceBase*, QString>::Iterator iter;
329 for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { 329 for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) {
330 if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; 330 if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true;
331 } 331 }
332 if (!inserted) { 332 if (!inserted) {
333 if (!f.open(IO_ReadOnly)) { 333 if (!f.open(IO_ReadOnly)) {
334 kdDebug() << "OutgoingDialog::loadMessage(): Can't open file'" 334 kdDebug() << "OutgoingDialog::loadMessage(): Can't open file'"
335 << (*it) << "'" << endl; 335 << (*it) << "'" << endl;
336 } else { 336 } else {
337 QTextStream t(&f); 337 QTextStream t(&f);
338 QString messageString = t.read(); 338 QString messageString = t.read();
339 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, 339 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar,
340 messageString); 340 messageString);
341 int begin_pos = messageString.find("METHOD-BEGIN:"); 341 int begin_pos = messageString.find("METHOD-BEGIN:");
342 begin_pos = messageString.find('\n',begin_pos)+1; 342 begin_pos = messageString.find('\n',begin_pos)+1;
343 QString meth = messageString.mid(begin_pos,1); 343 QString meth = messageString.mid(begin_pos,1);
344 switch (meth.toInt()) { 344 switch (meth.toInt()) {
345 case 0:method=Scheduler::Publish; break; 345 case 0:method=Scheduler::Publish; break;
346 case 1:method=Scheduler::Request; break; 346 case 1:method=Scheduler::Request; break;
347 case 2:method=Scheduler::Refresh; break; 347 case 2:method=Scheduler::Refresh; break;
348 case 3:method=Scheduler::Cancel; break; 348 case 3:method=Scheduler::Cancel; break;
349 case 4:method=Scheduler::Add; break; 349 case 4:method=Scheduler::Add; break;
350 case 5:method=Scheduler::Reply; break; 350 case 5:method=Scheduler::Reply; break;
351 case 6:method=Scheduler::Counter; break; 351 case 6:method=Scheduler::Counter; break;
352 case 7:method=Scheduler::Declinecounter; break; 352 case 7:method=Scheduler::Declinecounter; break;
353 default :method=Scheduler::NoMethod; break; 353 default :method=Scheduler::NoMethod; break;
354 } 354 }
355 begin_pos = messageString.find("RECIPIENTS-BEGIN:"); 355 begin_pos = messageString.find("RECIPIENTS-BEGIN:");
356 begin_pos = messageString.find('\n',begin_pos)+1; 356 begin_pos = messageString.find('\n',begin_pos)+1;
357 int end_pos = messageString.find(":RECIPIENTS-END",begin_pos)-1; 357 int end_pos = messageString.find(":RECIPIENTS-END",begin_pos)-1;
358 recipients = messageString.mid(begin_pos, end_pos-begin_pos); 358 recipients = messageString.mid(begin_pos, end_pos-begin_pos);
359 kdDebug() << "Outgoing::loadMessage(): Recipients: " << recipients << endl; 359 kdDebug() << "Outgoing::loadMessage(): Recipients: " << recipients << endl;
360 360
361 if (message) { 361 if (message) {
362 bool inserted = false; 362 bool inserted = false;
363 QMap<IncidenceBase*, QString>::Iterator iter; 363 QMap<IncidenceBase*, QString>::Iterator iter;
364 for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { 364 for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) {
365 if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; 365 if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true;
366 } 366 }
367 if (!inserted) { 367 if (!inserted) {
368 kdDebug() << "OutgoingDialog::loadMessage(): got message '" 368 kdDebug() << "OutgoingDialog::loadMessage(): got message '"
369 << (*it) << "'" << endl; 369 << (*it) << "'" << endl;
370 IncidenceBase *inc = message->event(); 370 IncidenceBase *inc = message->event();
371 new ScheduleItemOut(mMessageListView,inc,method,recipients); 371 new ScheduleItemOut(mMessageListView,inc,method,recipients);
372 mMessageMap[message->event()]=outgoingDirName + "/" + (*it); 372 mMessageMap[message->event()]=outgoingDirName + "/" + (*it);
373 } 373 }
374 } else { 374 } else {
375 QString errorMessage; 375 QString errorMessage;
376 if (mFormat->exception()) { 376 if (mFormat->exception()) {
377 errorMessage = mFormat->exception()->message(); 377 errorMessage = mFormat->exception()->message();
378 } 378 }
379 kdDebug() << "OutgoingDialog::loadMessage(): Error parsing " 379 kdDebug() << "OutgoingDialog::loadMessage(): Error parsing "
380 "message: " << errorMessage << endl; 380 "message: " << errorMessage << endl;
381 } 381 }
382 f.close(); 382 f.close();
383 } 383 }
384 } 384 }
385 } 385 }
386 emit numMessagesChanged(mMessageListView->childCount()); 386 emit numMessagesChanged(mMessageListView->childCount());
387} 387}
388 388
389void OutgoingDialog::setDocumentId( const QString &id ) 389void OutgoingDialog::setDocumentId( const QString &id )
390{ 390{
391 mDocPrefs->setDoc( id ); 391 mDocPrefs->setDoc( id );
392} 392}
393 393
394#include "outgoingdialog.moc"
diff --git a/korganizer/outgoingdialog_base.cpp b/korganizer/outgoingdialog_base.cpp
index e5b913a..1873b44 100644
--- a/korganizer/outgoingdialog_base.cpp
+++ b/korganizer/outgoingdialog_base.cpp
@@ -1,109 +1,107 @@
1#include <klocale.h> 1#include <klocale.h>
2/**************************************************************************** 2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/outgoingdialog_base.ui' 3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/outgoingdialog_base.ui'
4** 4**
5** Created: Sat Mar 29 22:31:21 2003 5** Created: Sat Mar 29 22:31:21 2003
6** by: The User Interface Compiler () 6** by: The User Interface Compiler ()
7** 7**
8** WARNING! All changes made in this file will be lost! 8** WARNING! All changes made in this file will be lost!
9****************************************************************************/ 9****************************************************************************/
10 10
11#include "outgoingdialog_base.h" 11#include "outgoingdialog_base.h"
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qheader.h> 14#include <qheader.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qpushbutton.h> 16#include <qpushbutton.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qtooltip.h> 18#include <qtooltip.h>
19#include <qwhatsthis.h> 19#include <qwhatsthis.h>
20 20
21/* 21/*
22 * Constructs a OutgoingDialog_base as a child of 'parent', with the 22 * Constructs a OutgoingDialog_base as a child of 'parent', with the
23 * name 'name' and widget flags set to 'f'. 23 * name 'name' and widget flags set to 'f'.
24 * 24 *
25 * The dialog will by default be modeless, unless you set 'modal' to 25 * The dialog will by default be modeless, unless you set 'modal' to
26 * TRUE to construct a modal dialog. 26 * TRUE to construct a modal dialog.
27 */ 27 */
28OutgoingDialog_base::OutgoingDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl ) 28OutgoingDialog_base::OutgoingDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
29 : QDialog( parent, name, modal, fl ) 29 : QDialog( parent, name, modal, fl )
30 30
31{ 31{
32 if ( !name ) 32 if ( !name )
33 setName( "OutgoingDialog_base" ); 33 setName( "OutgoingDialog_base" );
34 OutgoingDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "OutgoingDialog_baseLayout"); 34 OutgoingDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "OutgoingDialog_baseLayout");
35 35
36 mMessageListView = new QListView( this, "mMessageListView" ); 36 mMessageListView = new QListView( this, "mMessageListView" );
37 mMessageListView->addColumn( tr2i18n( "Summary" ) ); 37 mMessageListView->addColumn( tr2i18n( "Summary" ) );
38 mMessageListView->addColumn( tr2i18n( "Start Date" ) ); 38 mMessageListView->addColumn( tr2i18n( "Start Date" ) );
39 mMessageListView->addColumn( tr2i18n( "Start Time" ) ); 39 mMessageListView->addColumn( tr2i18n( "Start Time" ) );
40 mMessageListView->addColumn( tr2i18n( "End Date" ) ); 40 mMessageListView->addColumn( tr2i18n( "End Date" ) );
41 mMessageListView->addColumn( tr2i18n( "End Time" ) ); 41 mMessageListView->addColumn( tr2i18n( "End Time" ) );
42 mMessageListView->addColumn( tr2i18n( "Method" ) ); 42 mMessageListView->addColumn( tr2i18n( "Method" ) );
43 mMessageListView->setFrameShape( QListView::StyledPanel ); 43 mMessageListView->setFrameShape( QListView::StyledPanel );
44 mMessageListView->setFrameShadow( QListView::Sunken ); 44 mMessageListView->setFrameShadow( QListView::Sunken );
45 mMessageListView->setAllColumnsShowFocus( TRUE ); 45 mMessageListView->setAllColumnsShowFocus( TRUE );
46 46
47 OutgoingDialog_baseLayout->addMultiCellWidget( mMessageListView, 0, 3, 0, 0 ); 47 OutgoingDialog_baseLayout->addMultiCellWidget( mMessageListView, 0, 3, 0, 0 );
48 48
49 PushButton5 = new QPushButton( this, "PushButton5" ); 49 PushButton5 = new QPushButton( this, "PushButton5" );
50 PushButton5->setDefault( FALSE ); 50 PushButton5->setDefault( FALSE );
51 51
52 OutgoingDialog_baseLayout->addWidget( PushButton5, 0, 1 ); 52 OutgoingDialog_baseLayout->addWidget( PushButton5, 0, 1 );
53 53
54 PushButton7 = new QPushButton( this, "PushButton7" ); 54 PushButton7 = new QPushButton( this, "PushButton7" );
55 55
56 OutgoingDialog_baseLayout->addWidget( PushButton7, 1, 1 ); 56 OutgoingDialog_baseLayout->addWidget( PushButton7, 1, 1 );
57 57
58 PushButton6 = new QPushButton( this, "PushButton6" ); 58 PushButton6 = new QPushButton( this, "PushButton6" );
59 PushButton6->setDefault( TRUE ); 59 PushButton6->setDefault( TRUE );
60 60
61 OutgoingDialog_baseLayout->addWidget( PushButton6, 3, 1 ); 61 OutgoingDialog_baseLayout->addWidget( PushButton6, 3, 1 );
62 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 62 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
63 OutgoingDialog_baseLayout->addItem( spacer, 2, 1 ); 63 OutgoingDialog_baseLayout->addItem( spacer, 2, 1 );
64 languageChange(); 64 languageChange();
65 resize( QSize(582, 274).expandedTo(minimumSizeHint()) ); 65 resize( QSize(582, 274).expandedTo(minimumSizeHint()) );
66 66
67 // signals and slots connections 67 // signals and slots connections
68 connect( PushButton6, SIGNAL( clicked() ), this, SLOT( accept() ) ); 68 connect( PushButton6, SIGNAL( clicked() ), this, SLOT( accept() ) );
69 connect( PushButton5, SIGNAL( clicked() ), this, SLOT( send() ) ); 69 connect( PushButton5, SIGNAL( clicked() ), this, SLOT( send() ) );
70 connect( PushButton7, SIGNAL( clicked() ), this, SLOT( deleteItem() ) ); 70 connect( PushButton7, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
71} 71}
72 72
73/* 73/*
74 * Destroys the object and frees any allocated resources 74 * Destroys the object and frees any allocated resources
75 */ 75 */
76OutgoingDialog_base::~OutgoingDialog_base() 76OutgoingDialog_base::~OutgoingDialog_base()
77{ 77{
78 // no need to delete child widgets, Qt does it all for us 78 // no need to delete child widgets, Qt does it all for us
79} 79}
80 80
81/* 81/*
82 * Sets the strings of the subwidgets using the current 82 * Sets the strings of the subwidgets using the current
83 * language. 83 * language.
84 */ 84 */
85void OutgoingDialog_base::languageChange() 85void OutgoingDialog_base::languageChange()
86{ 86{
87 setCaption( tr2i18n( "Scheduler - Outgoing Messages" ) ); 87 setCaption( tr2i18n( "Scheduler - Outgoing Messages" ) );
88 mMessageListView->header()->setLabel( 0, tr2i18n( "Summary" ) ); 88 mMessageListView->header()->setLabel( 0, tr2i18n( "Summary" ) );
89 mMessageListView->header()->setLabel( 1, tr2i18n( "Start Date" ) ); 89 mMessageListView->header()->setLabel( 1, tr2i18n( "Start Date" ) );
90 mMessageListView->header()->setLabel( 2, tr2i18n( "Start Time" ) ); 90 mMessageListView->header()->setLabel( 2, tr2i18n( "Start Time" ) );
91 mMessageListView->header()->setLabel( 3, tr2i18n( "End Date" ) ); 91 mMessageListView->header()->setLabel( 3, tr2i18n( "End Date" ) );
92 mMessageListView->header()->setLabel( 4, tr2i18n( "End Time" ) ); 92 mMessageListView->header()->setLabel( 4, tr2i18n( "End Time" ) );
93 mMessageListView->header()->setLabel( 5, tr2i18n( "Method" ) ); 93 mMessageListView->header()->setLabel( 5, tr2i18n( "Method" ) );
94 PushButton5->setText( tr2i18n( "&Send Messages" ) ); 94 PushButton5->setText( tr2i18n( "&Send Messages" ) );
95 PushButton7->setText( tr2i18n( "&Remove" ) ); 95 PushButton7->setText( tr2i18n( "&Remove" ) );
96 PushButton6->setText( tr2i18n( "&Close" ) ); 96 PushButton6->setText( tr2i18n( "&Close" ) );
97} 97}
98 98
99void OutgoingDialog_base::send() 99void OutgoingDialog_base::send()
100{ 100{
101 qWarning( "OutgoingDialog_base::send(): Not implemented yet" ); 101 qWarning( "OutgoingDialog_base::send(): Not implemented yet" );
102} 102}
103 103
104void OutgoingDialog_base::deleteItem() 104void OutgoingDialog_base::deleteItem()
105{ 105{
106 qWarning( "OutgoingDialog_base::deleteItem(): Not implemented yet" ); 106 qWarning( "OutgoingDialog_base::deleteItem(): Not implemented yet" );
107} 107}
108
109#include "outgoingdialog_base.moc"
diff --git a/korganizer/publishdialog.cpp b/korganizer/publishdialog.cpp
index 176595a..4323b91 100644
--- a/korganizer/publishdialog.cpp
+++ b/korganizer/publishdialog.cpp
@@ -1,152 +1,150 @@
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 <qlineedit.h> 24#include <qlineedit.h>
25#include <kdebug.h> 25#include <kdebug.h>
26 26
27#include <kglobal.h> 27#include <kglobal.h>
28#include <klocale.h> 28#include <klocale.h>
29#ifndef KORG_NOKABC 29#ifndef KORG_NOKABC
30#include <kabc/addresseedialog.h> 30#include <kabc/addresseedialog.h>
31#endif 31#endif
32 32
33#include "koprefs.h" 33#include "koprefs.h"
34#include "publishdialog.h" 34#include "publishdialog.h"
35 35
36PublishDialog::PublishDialog(QWidget* parent, const char* name, 36PublishDialog::PublishDialog(QWidget* parent, const char* name,
37 bool modal, WFlags fl) 37 bool modal, WFlags fl)
38 : PublishDialog_base(parent,name,modal,fl) 38 : PublishDialog_base(parent,name,modal,fl)
39{ 39{
40 setCaption(i18n("Select Addresses")); 40 setCaption(i18n("Select Addresses"));
41 mNameLineEdit->setEnabled(false); 41 mNameLineEdit->setEnabled(false);
42 mEmailLineEdit->setEnabled(false); 42 mEmailLineEdit->setEnabled(false);
43 connect(mAddressListView,SIGNAL(selectionChanged(QListViewItem *)), 43 connect(mAddressListView,SIGNAL(selectionChanged(QListViewItem *)),
44 SLOT(updateInput())); 44 SLOT(updateInput()));
45} 45}
46 46
47PublishDialog::~PublishDialog() 47PublishDialog::~PublishDialog()
48{ 48{
49} 49}
50 50
51void PublishDialog::addAttendee(Attendee *attendee) 51void PublishDialog::addAttendee(Attendee *attendee)
52{ 52{
53 mNameLineEdit->setEnabled(true); 53 mNameLineEdit->setEnabled(true);
54 mEmailLineEdit->setEnabled(true); 54 mEmailLineEdit->setEnabled(true);
55 QListViewItem *item = new QListViewItem(mAddressListView); 55 QListViewItem *item = new QListViewItem(mAddressListView);
56 item->setText(0,attendee->name()); 56 item->setText(0,attendee->name());
57 item->setText(1,attendee->email()); 57 item->setText(1,attendee->email());
58 mAddressListView->insertItem(item); 58 mAddressListView->insertItem(item);
59} 59}
60 60
61QString PublishDialog::addresses() 61QString PublishDialog::addresses()
62{ 62{
63 QString to = ""; 63 QString to = "";
64 QListViewItem *item; 64 QListViewItem *item;
65 int i, count; 65 int i, count;
66 count = mAddressListView->childCount(); 66 count = mAddressListView->childCount();
67 for (i=0;i<count;i++) { 67 for (i=0;i<count;i++) {
68 item = mAddressListView->firstChild(); 68 item = mAddressListView->firstChild();
69 mAddressListView->takeItem(item); 69 mAddressListView->takeItem(item);
70 to += item->text(1); 70 to += item->text(1);
71 if (i<count-1) { 71 if (i<count-1) {
72 to += ", "; 72 to += ", ";
73 } 73 }
74 } 74 }
75 return to; 75 return to;
76} 76}
77 77
78void PublishDialog::addItem() 78void PublishDialog::addItem()
79{ 79{
80 mNameLineEdit->setEnabled(true); 80 mNameLineEdit->setEnabled(true);
81 mEmailLineEdit->setEnabled(true); 81 mEmailLineEdit->setEnabled(true);
82 QListViewItem *item = new QListViewItem(mAddressListView); 82 QListViewItem *item = new QListViewItem(mAddressListView);
83 mAddressListView->insertItem(item); 83 mAddressListView->insertItem(item);
84 mAddressListView->setSelected(item,true); 84 mAddressListView->setSelected(item,true);
85 mNameLineEdit->setText(i18n("(EmptyName)")); 85 mNameLineEdit->setText(i18n("(EmptyName)"));
86 mEmailLineEdit->setText(i18n("(EmptyEmail)")); 86 mEmailLineEdit->setText(i18n("(EmptyEmail)"));
87} 87}
88 88
89void PublishDialog::removeItem() 89void PublishDialog::removeItem()
90{ 90{
91 QListViewItem *item; 91 QListViewItem *item;
92 item = mAddressListView->selectedItem(); 92 item = mAddressListView->selectedItem();
93 if (!item) return; 93 if (!item) return;
94 mAddressListView->takeItem(item); 94 mAddressListView->takeItem(item);
95 item = mAddressListView->selectedItem(); 95 item = mAddressListView->selectedItem();
96 if (!item) { 96 if (!item) {
97 mNameLineEdit->setText(""); 97 mNameLineEdit->setText("");
98 mEmailLineEdit->setText(""); 98 mEmailLineEdit->setText("");
99 mNameLineEdit->setEnabled(false); 99 mNameLineEdit->setEnabled(false);
100 mEmailLineEdit->setEnabled(false); 100 mEmailLineEdit->setEnabled(false);
101 } 101 }
102 if (mAddressListView->childCount() == 0) { 102 if (mAddressListView->childCount() == 0) {
103 mNameLineEdit->setEnabled(false); 103 mNameLineEdit->setEnabled(false);
104 mEmailLineEdit->setEnabled(false); 104 mEmailLineEdit->setEnabled(false);
105 } 105 }
106} 106}
107 107
108void PublishDialog::openAddressbook() 108void PublishDialog::openAddressbook()
109{ 109{
110#ifndef KORG_NOKABC 110#ifndef KORG_NOKABC
111 KABC::Addressee::List addressList; 111 KABC::Addressee::List addressList;
112 addressList = KABC::AddresseeDialog::getAddressees(this); 112 addressList = KABC::AddresseeDialog::getAddressees(this);
113 //KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); 113 //KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
114 KABC::Addressee a = addressList.first(); 114 KABC::Addressee a = addressList.first();
115 if (!a.isEmpty()) { 115 if (!a.isEmpty()) {
116 uint i; 116 uint i;
117 for (i=0;i<addressList.count();i++) { 117 for (i=0;i<addressList.count();i++) {
118 a = addressList[i]; 118 a = addressList[i];
119 mNameLineEdit->setEnabled(true); 119 mNameLineEdit->setEnabled(true);
120 mEmailLineEdit->setEnabled(true); 120 mEmailLineEdit->setEnabled(true);
121 QListViewItem *item = new QListViewItem(mAddressListView); 121 QListViewItem *item = new QListViewItem(mAddressListView);
122 mAddressListView->setSelected(item,true); 122 mAddressListView->setSelected(item,true);
123 mNameLineEdit->setText(a.realName()); 123 mNameLineEdit->setText(a.realName());
124 mEmailLineEdit->setText(a.preferredEmail()); 124 mEmailLineEdit->setText(a.preferredEmail());
125 mAddressListView->insertItem(item); 125 mAddressListView->insertItem(item);
126 } 126 }
127 } 127 }
128#endif 128#endif
129} 129}
130 130
131void PublishDialog::updateItem() 131void PublishDialog::updateItem()
132{ 132{
133 QListViewItem *item; 133 QListViewItem *item;
134 item = mAddressListView->selectedItem(); 134 item = mAddressListView->selectedItem();
135 if (!item) return; 135 if (!item) return;
136 item->setText(0,mNameLineEdit->text()); 136 item->setText(0,mNameLineEdit->text());
137 item->setText(1,mEmailLineEdit->text()); 137 item->setText(1,mEmailLineEdit->text());
138} 138}
139 139
140void PublishDialog::updateInput() 140void PublishDialog::updateInput()
141{ 141{
142 QListViewItem *item; 142 QListViewItem *item;
143 item = mAddressListView->selectedItem(); 143 item = mAddressListView->selectedItem();
144 if (!item) return; 144 if (!item) return;
145 mNameLineEdit->setEnabled(true); 145 mNameLineEdit->setEnabled(true);
146 mEmailLineEdit->setEnabled(true); 146 mEmailLineEdit->setEnabled(true);
147 QString mail = item->text(1); 147 QString mail = item->text(1);
148 mNameLineEdit->setText(item->text(0)); 148 mNameLineEdit->setText(item->text(0));
149 mEmailLineEdit->setText(mail); 149 mEmailLineEdit->setText(mail);
150} 150}
151
152#include "publishdialog.moc"
diff --git a/korganizer/publishdialog_base.cpp b/korganizer/publishdialog_base.cpp
index 75e4746..683f7e9 100644
--- a/korganizer/publishdialog_base.cpp
+++ b/korganizer/publishdialog_base.cpp
@@ -1,162 +1,160 @@
1#include <klocale.h> 1#include <klocale.h>
2/**************************************************************************** 2/****************************************************************************
3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/publishdialog_base.ui' 3** Form implementation generated from reading ui file '/build/kde/cvs/korge/kdepim/korganizer/publishdialog_base.ui'
4** 4**
5** Created: Sat Mar 29 22:31:35 2003 5** Created: Sat Mar 29 22:31:35 2003
6** by: The User Interface Compiler () 6** by: The User Interface Compiler ()
7** 7**
8** WARNING! All changes made in this file will be lost! 8** WARNING! All changes made in this file will be lost!
9****************************************************************************/ 9****************************************************************************/
10 10
11#include "publishdialog_base.h" 11#include "publishdialog_base.h"
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qframe.h> 14#include <qframe.h>
15#include <qheader.h> 15#include <qheader.h>
16#include <qlabel.h> 16#include <qlabel.h>
17#include <qlineedit.h> 17#include <qlineedit.h>
18#include <qlistview.h> 18#include <qlistview.h>
19#include <qpushbutton.h> 19#include <qpushbutton.h>
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtooltip.h> 21#include <qtooltip.h>
22#include <qwhatsthis.h> 22#include <qwhatsthis.h>
23 23
24/* 24/*
25 * Constructs a PublishDialog_base as a child of 'parent', with the 25 * Constructs a PublishDialog_base as a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'. 26 * name 'name' and widget flags set to 'f'.
27 * 27 *
28 * The dialog will by default be modeless, unless you set 'modal' to 28 * The dialog will by default be modeless, unless you set 'modal' to
29 * TRUE to construct a modal dialog. 29 * TRUE to construct a modal dialog.
30 */ 30 */
31PublishDialog_base::PublishDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl ) 31PublishDialog_base::PublishDialog_base( QWidget* parent, const char* name, bool modal, WFlags fl )
32 : QDialog( parent, name, modal, fl ) 32 : QDialog( parent, name, modal, fl )
33 33
34{ 34{
35 if ( !name ) 35 if ( !name )
36 setName( "PublishDialog_base" ); 36 setName( "PublishDialog_base" );
37 PublishDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "PublishDialog_baseLayout"); 37 PublishDialog_baseLayout = new QGridLayout( this, 1, 1, 11, 6, "PublishDialog_baseLayout");
38 38
39 mAddressListView = new QListView( this, "mAddressListView" ); 39 mAddressListView = new QListView( this, "mAddressListView" );
40 mAddressListView->addColumn( tr2i18n( "Name" ) ); 40 mAddressListView->addColumn( tr2i18n( "Name" ) );
41 mAddressListView->addColumn( tr2i18n( "Email" ) ); 41 mAddressListView->addColumn( tr2i18n( "Email" ) );
42 42
43 PublishDialog_baseLayout->addMultiCellWidget( mAddressListView, 0, 3, 0, 1 ); 43 PublishDialog_baseLayout->addMultiCellWidget( mAddressListView, 0, 3, 0, 1 );
44 44
45 TextLabel1 = new QLabel( this, "TextLabel1" ); 45 TextLabel1 = new QLabel( this, "TextLabel1" );
46 46
47 PublishDialog_baseLayout->addWidget( TextLabel1, 4, 0 ); 47 PublishDialog_baseLayout->addWidget( TextLabel1, 4, 0 );
48 48
49 TextLabel2 = new QLabel( this, "TextLabel2" ); 49 TextLabel2 = new QLabel( this, "TextLabel2" );
50 50
51 PublishDialog_baseLayout->addWidget( TextLabel2, 5, 0 ); 51 PublishDialog_baseLayout->addWidget( TextLabel2, 5, 0 );
52 52
53 mEmailLineEdit = new QLineEdit( this, "mEmailLineEdit" ); 53 mEmailLineEdit = new QLineEdit( this, "mEmailLineEdit" );
54 54
55 PublishDialog_baseLayout->addWidget( mEmailLineEdit, 5, 1 ); 55 PublishDialog_baseLayout->addWidget( mEmailLineEdit, 5, 1 );
56 56
57 mNameLineEdit = new QLineEdit( this, "mNameLineEdit" ); 57 mNameLineEdit = new QLineEdit( this, "mNameLineEdit" );
58 58
59 PublishDialog_baseLayout->addWidget( mNameLineEdit, 4, 1 ); 59 PublishDialog_baseLayout->addWidget( mNameLineEdit, 4, 1 );
60 60
61 PushButton10 = new QPushButton( this, "PushButton10" ); 61 PushButton10 = new QPushButton( this, "PushButton10" );
62 62
63 PublishDialog_baseLayout->addWidget( PushButton10, 0, 2 ); 63 PublishDialog_baseLayout->addWidget( PushButton10, 0, 2 );
64 64
65 PushButton12 = new QPushButton( this, "PushButton12" ); 65 PushButton12 = new QPushButton( this, "PushButton12" );
66 66
67 PublishDialog_baseLayout->addWidget( PushButton12, 2, 2 ); 67 PublishDialog_baseLayout->addWidget( PushButton12, 2, 2 );
68 68
69 PushButton11 = new QPushButton( this, "PushButton11" ); 69 PushButton11 = new QPushButton( this, "PushButton11" );
70 70
71 PublishDialog_baseLayout->addWidget( PushButton11, 1, 2 ); 71 PublishDialog_baseLayout->addWidget( PushButton11, 1, 2 );
72 QSpacerItem* spacer = new QSpacerItem( 20, 241, QSizePolicy::Minimum, QSizePolicy::Expanding ); 72 QSpacerItem* spacer = new QSpacerItem( 20, 241, QSizePolicy::Minimum, QSizePolicy::Expanding );
73 PublishDialog_baseLayout->addMultiCell( spacer, 3, 5, 2, 2 ); 73 PublishDialog_baseLayout->addMultiCell( spacer, 3, 5, 2, 2 );
74 74
75 Line2 = new QFrame( this, "Line2" ); 75 Line2 = new QFrame( this, "Line2" );
76 Line2->setFrameShape( QFrame::HLine ); 76 Line2->setFrameShape( QFrame::HLine );
77 Line2->setFrameShadow( QFrame::Sunken ); 77 Line2->setFrameShadow( QFrame::Sunken );
78 Line2->setFrameShape( QFrame::HLine ); 78 Line2->setFrameShape( QFrame::HLine );
79 79
80 PublishDialog_baseLayout->addMultiCellWidget( Line2, 6, 6, 0, 2 ); 80 PublishDialog_baseLayout->addMultiCellWidget( Line2, 6, 6, 0, 2 );
81 81
82 layout95 = new QHBoxLayout( 0, 0, 6, "layout95"); 82 layout95 = new QHBoxLayout( 0, 0, 6, "layout95");
83 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); 83 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
84 layout95->addItem( spacer_2 ); 84 layout95->addItem( spacer_2 );
85 85
86 PushButton9 = new QPushButton( this, "PushButton9" ); 86 PushButton9 = new QPushButton( this, "PushButton9" );
87 PushButton9->setDefault( TRUE ); 87 PushButton9->setDefault( TRUE );
88 layout95->addWidget( PushButton9 ); 88 layout95->addWidget( PushButton9 );
89 89
90 PushButton8 = new QPushButton( this, "PushButton8" ); 90 PushButton8 = new QPushButton( this, "PushButton8" );
91 layout95->addWidget( PushButton8 ); 91 layout95->addWidget( PushButton8 );
92 92
93 PublishDialog_baseLayout->addMultiCellLayout( layout95, 7, 7, 0, 2 ); 93 PublishDialog_baseLayout->addMultiCellLayout( layout95, 7, 7, 0, 2 );
94 languageChange(); 94 languageChange();
95 resize( QSize(420, 379).expandedTo(minimumSizeHint()) ); 95 resize( QSize(420, 379).expandedTo(minimumSizeHint()) );
96 96
97 // signals and slots connections 97 // signals and slots connections
98 connect( PushButton10, SIGNAL( clicked() ), this, SLOT( addItem() ) ); 98 connect( PushButton10, SIGNAL( clicked() ), this, SLOT( addItem() ) );
99 connect( PushButton11, SIGNAL( clicked() ), this, SLOT( removeItem() ) ); 99 connect( PushButton11, SIGNAL( clicked() ), this, SLOT( removeItem() ) );
100 connect( PushButton12, SIGNAL( clicked() ), this, SLOT( openAddressbook() ) ); 100 connect( PushButton12, SIGNAL( clicked() ), this, SLOT( openAddressbook() ) );
101 connect( PushButton9, SIGNAL( clicked() ), this, SLOT( accept() ) ); 101 connect( PushButton9, SIGNAL( clicked() ), this, SLOT( accept() ) );
102 connect( mNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( updateItem() ) ); 102 connect( mNameLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( updateItem() ) );
103 connect( mEmailLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( updateItem() ) ); 103 connect( mEmailLineEdit, SIGNAL( textChanged(const QString&) ), this, SLOT( updateItem() ) );
104 connect( PushButton8, SIGNAL( clicked() ), this, SLOT( reject() ) ); 104 connect( PushButton8, SIGNAL( clicked() ), this, SLOT( reject() ) );
105 105
106 // tab order 106 // tab order
107 setTabOrder( mAddressListView, mNameLineEdit ); 107 setTabOrder( mAddressListView, mNameLineEdit );
108 setTabOrder( mNameLineEdit, mEmailLineEdit ); 108 setTabOrder( mNameLineEdit, mEmailLineEdit );
109 setTabOrder( mEmailLineEdit, PushButton10 ); 109 setTabOrder( mEmailLineEdit, PushButton10 );
110 setTabOrder( PushButton10, PushButton11 ); 110 setTabOrder( PushButton10, PushButton11 );
111 setTabOrder( PushButton11, PushButton12 ); 111 setTabOrder( PushButton11, PushButton12 );
112 setTabOrder( PushButton12, PushButton9 ); 112 setTabOrder( PushButton12, PushButton9 );
113 setTabOrder( PushButton9, PushButton8 ); 113 setTabOrder( PushButton9, PushButton8 );
114} 114}
115 115
116/* 116/*
117 * Destroys the object and frees any allocated resources 117 * Destroys the object and frees any allocated resources
118 */ 118 */
119PublishDialog_base::~PublishDialog_base() 119PublishDialog_base::~PublishDialog_base()
120{ 120{
121 // no need to delete child widgets, Qt does it all for us 121 // no need to delete child widgets, Qt does it all for us
122} 122}
123 123
124/* 124/*
125 * Sets the strings of the subwidgets using the current 125 * Sets the strings of the subwidgets using the current
126 * language. 126 * language.
127 */ 127 */
128void PublishDialog_base::languageChange() 128void PublishDialog_base::languageChange()
129{ 129{
130 setCaption( tr2i18n( "Form1" ) ); 130 setCaption( tr2i18n( "Form1" ) );
131 mAddressListView->header()->setLabel( 0, tr2i18n( "Name" ) ); 131 mAddressListView->header()->setLabel( 0, tr2i18n( "Name" ) );
132 mAddressListView->header()->setLabel( 1, tr2i18n( "Email" ) ); 132 mAddressListView->header()->setLabel( 1, tr2i18n( "Email" ) );
133 TextLabel1->setText( tr2i18n( "Name:" ) ); 133 TextLabel1->setText( tr2i18n( "Name:" ) );
134 TextLabel2->setText( tr2i18n( "Email:" ) ); 134 TextLabel2->setText( tr2i18n( "Email:" ) );
135 PushButton10->setText( tr2i18n( "&New" ) ); 135 PushButton10->setText( tr2i18n( "&New" ) );
136 PushButton12->setText( tr2i18n( "&Addressbook" ) ); 136 PushButton12->setText( tr2i18n( "&Addressbook" ) );
137 PushButton11->setText( tr2i18n( "&Remove" ) ); 137 PushButton11->setText( tr2i18n( "&Remove" ) );
138 PushButton9->setText( tr2i18n( "&OK" ) ); 138 PushButton9->setText( tr2i18n( "&OK" ) );
139 PushButton8->setText( tr2i18n( "&Cancel" ) ); 139 PushButton8->setText( tr2i18n( "&Cancel" ) );
140} 140}
141 141
142void PublishDialog_base::addItem() 142void PublishDialog_base::addItem()
143{ 143{
144 qWarning( "PublishDialog_base::addItem(): Not implemented yet" ); 144 qWarning( "PublishDialog_base::addItem(): Not implemented yet" );
145} 145}
146 146
147void PublishDialog_base::removeItem() 147void PublishDialog_base::removeItem()
148{ 148{
149 qWarning( "PublishDialog_base::removeItem(): Not implemented yet" ); 149 qWarning( "PublishDialog_base::removeItem(): Not implemented yet" );
150} 150}
151 151
152void PublishDialog_base::openAddressbook() 152void PublishDialog_base::openAddressbook()
153{ 153{
154 qWarning( "PublishDialog_base::openAddressbook(): Not implemented yet" ); 154 qWarning( "PublishDialog_base::openAddressbook(): Not implemented yet" );
155} 155}
156 156
157void PublishDialog_base::updateItem() 157void PublishDialog_base::updateItem()
158{ 158{
159 qWarning( "PublishDialog_base::updateItem(): Not implemented yet" ); 159 qWarning( "PublishDialog_base::updateItem(): Not implemented yet" );
160} 160}
161
162#include "publishdialog_base.moc"
diff --git a/korganizer/savetemplatedialog.cpp b/korganizer/savetemplatedialog.cpp
index 0da524f..3544081 100644
--- a/korganizer/savetemplatedialog.cpp
+++ b/korganizer/savetemplatedialog.cpp
@@ -1,76 +1,75 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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 25
26#include <keditlistbox.h> 26#include <keditlistbox.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "koprefs.h" 29#include "koprefs.h"
30 30
31#include "savetemplatedialog.h" 31#include "savetemplatedialog.h"
32#include "savetemplatedialog.moc"
33 32
34SaveTemplateDialog::SaveTemplateDialog( IncidenceType type, QWidget *parent ) 33SaveTemplateDialog::SaveTemplateDialog( IncidenceType type, QWidget *parent )
35 : KDialogBase( Plain, i18n("Save Template"), Ok | Cancel, Ok, parent, 0, 34 : KDialogBase( Plain, i18n("Save Template"), Ok | Cancel, Ok, parent, 0,
36 true, false ), 35 true, false ),
37 mType( type ) 36 mType( type )
38{ 37{
39 QFrame *topFrame = plainPage(); 38 QFrame *topFrame = plainPage();
40 QVBoxLayout *topLayout = new QVBoxLayout( topFrame, 0, spacingHint() ); 39 QVBoxLayout *topLayout = new QVBoxLayout( topFrame, 0, spacingHint() );
41 40
42 mEditListBox = new KEditListBox( i18n("Select Template Name"), topFrame, 41 mEditListBox = new KEditListBox( i18n("Select Template Name"), topFrame,
43 0, false, KEditListBox::Add | 42 0, false, KEditListBox::Add |
44 KEditListBox::Remove ); 43 KEditListBox::Remove );
45 topLayout->addWidget( mEditListBox ); 44 topLayout->addWidget( mEditListBox );
46 connect( mEditListBox, SIGNAL( changed() ), SLOT( slotChanged() ) ); 45 connect( mEditListBox, SIGNAL( changed() ), SLOT( slotChanged() ) );
47 46
48 QStringList templates; 47 QStringList templates;
49 48
50 if ( mType == EventType ) { 49 if ( mType == EventType ) {
51 templates = KOPrefs::instance()->mEventTemplates; 50 templates = KOPrefs::instance()->mEventTemplates;
52 } else if( mType == TodoType ) { 51 } else if( mType == TodoType ) {
53 templates = KOPrefs::instance()->mTodoTemplates; 52 templates = KOPrefs::instance()->mTodoTemplates;
54 } 53 }
55 54
56 mEditListBox->insertStringList( templates ); 55 mEditListBox->insertStringList( templates );
57} 56}
58 57
59SaveTemplateDialog::~SaveTemplateDialog() 58SaveTemplateDialog::~SaveTemplateDialog()
60{ 59{
61} 60}
62 61
63void SaveTemplateDialog::slotOk() 62void SaveTemplateDialog::slotOk()
64{ 63{
65 emit templateSelected( mEditListBox->currentText() ); 64 emit templateSelected( mEditListBox->currentText() );
66 accept(); 65 accept();
67} 66}
68 67
69void SaveTemplateDialog::slotChanged() 68void SaveTemplateDialog::slotChanged()
70{ 69{
71 if ( mType == EventType ) { 70 if ( mType == EventType ) {
72 KOPrefs::instance()->mEventTemplates = mEditListBox->items(); 71 KOPrefs::instance()->mEventTemplates = mEditListBox->items();
73 } else if( mType == TodoType ) { 72 } else if( mType == TodoType ) {
74 KOPrefs::instance()->mTodoTemplates = mEditListBox->items(); 73 KOPrefs::instance()->mTodoTemplates = mEditListBox->items();
75 } 74 }
76} 75}
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 74d48b9..5bd7c6f 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,396 +1,395 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 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 <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <klocale.h> 32#include <klocale.h>
33#include <kmessagebox.h> 33#include <kmessagebox.h>
34 34
35#include <libkdepim/kdateedit.h> 35#include <libkdepim/kdateedit.h>
36 36
37#include "koglobals.h" 37#include "koglobals.h"
38#include "koprefs.h" 38#include "koprefs.h"
39 39
40#include "calendarview.h" 40#include "calendarview.h"
41#include "koviewmanager.h" 41#include "koviewmanager.h"
42#include "searchdialog.h" 42#include "searchdialog.h"
43#include "searchdialog.moc"
44 43
45SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 44SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
46 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false, 45 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false,
47 i18n("&Find")) 46 i18n("&Find"))
48{ 47{
49 mCalendar = calendar; 48 mCalendar = calendar;
50 QFrame *topFrame = plainPage(); 49 QFrame *topFrame = plainPage();
51 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint()); 50 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint());
52 51
53 // Search expression 52 // Search expression
54 QHBoxLayout *subLayout = new QHBoxLayout(); 53 QHBoxLayout *subLayout = new QHBoxLayout();
55 layout->addLayout(subLayout); 54 layout->addLayout(subLayout);
56 55
57 searchLabel = new QLabel(topFrame); 56 searchLabel = new QLabel(topFrame);
58 searchLabel->setText(i18n("Search for:")); 57 searchLabel->setText(i18n("Search for:"));
59 subLayout->addWidget(searchLabel); 58 subLayout->addWidget(searchLabel);
60 59
61 searchEdit = new QLineEdit(topFrame); 60 searchEdit = new QLineEdit(topFrame);
62 subLayout->addWidget(searchEdit); 61 subLayout->addWidget(searchEdit);
63 searchEdit->setText("*"); // Find all events by default 62 searchEdit->setText("*"); // Find all events by default
64 searchEdit->setFocus(); 63 searchEdit->setFocus();
65 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 64 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
66 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 65 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
67 // Subjects to search 66 // Subjects to search
68 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 67 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
69 // topFrame); 68 // topFrame);
70 69
71 70
72 71
73 QHBox *incidenceGroup = new QHBox( topFrame ); 72 QHBox *incidenceGroup = new QHBox( topFrame );
74 layout->addWidget(incidenceGroup); 73 layout->addWidget(incidenceGroup);
75 74
76 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 75 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
77 mSearchEvent->setChecked(true); 76 mSearchEvent->setChecked(true);
78 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 77 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
79 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 78 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
80 79
81 QHBox *subjectGroup = new QHBox( topFrame ); 80 QHBox *subjectGroup = new QHBox( topFrame );
82 layout->addWidget(subjectGroup); 81 layout->addWidget(subjectGroup);
83 82
84 mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup); 83 mSummaryCheck = new QCheckBox(i18n("Summaries"),subjectGroup);
85 mSummaryCheck->setChecked(true); 84 mSummaryCheck->setChecked(true);
86 mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup); 85 mDescriptionCheck = new QCheckBox(i18n("Descriptions"),subjectGroup);
87 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 86 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
88 87
89 QHBox *attendeeGroup = new QHBox( topFrame ); 88 QHBox *attendeeGroup = new QHBox( topFrame );
90 layout->addWidget(attendeeGroup ); 89 layout->addWidget(attendeeGroup );
91 new QLabel( i18n("Attendee:"),attendeeGroup ); 90 new QLabel( i18n("Attendee:"),attendeeGroup );
92 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 91 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
93 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 92 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
94 // Date range 93 // Date range
95 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 94 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
96 // topFrame); 95 // topFrame);
97 // layout->addWidget(rangeGroup); 96 // layout->addWidget(rangeGroup);
98 97
99 QWidget *rangeWidget = new QWidget(topFrame); 98 QWidget *rangeWidget = new QWidget(topFrame);
100 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint()); 99 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint());
101 100
102 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 101 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
103 mStartDate = new KDateEdit(rangeWidget); 102 mStartDate = new KDateEdit(rangeWidget);
104 rangeLayout->addWidget(mStartDate); 103 rangeLayout->addWidget(mStartDate);
105 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
106 mEndDate = new KDateEdit(rangeWidget); 105 mEndDate = new KDateEdit(rangeWidget);
107 mEndDate->setDate(QDate::currentDate().addDays(365)); 106 mEndDate->setDate(QDate::currentDate().addDays(365));
108 rangeLayout->addWidget(mEndDate); 107 rangeLayout->addWidget(mEndDate);
109 108
110 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame); 109 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame);
111 //mInclusiveCheck->setChecked(false); 110 //mInclusiveCheck->setChecked(false);
112 layout->addWidget(rangeWidget); 111 layout->addWidget(rangeWidget);
113 //layout->addWidget(mInclusiveCheck); 112 //layout->addWidget(mInclusiveCheck);
114 // Subjects to search 113 // Subjects to search
115 114
116 115
117 // Results list view 116 // Results list view
118 listView = new KOListView(mCalendar,topFrame); 117 listView = new KOListView(mCalendar,topFrame);
119 //listView->showDates(); 118 //listView->showDates();
120 119
121 120
122 layout->addWidget(listView); 121 layout->addWidget(listView);
123 122
124 // if ( KOPrefs::instance()->mCompactDialogs ) { 123 // if ( KOPrefs::instance()->mCompactDialogs ) {
125 // KOGlobals::fitDialogToScreen( this, true ); 124 // KOGlobals::fitDialogToScreen( this, true );
126 // } 125 // }
127 126
128 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 127 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
129 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch())); 128 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch()));
130 QPushButton *CloseButton = findButton( Close ); 129 QPushButton *CloseButton = findButton( Close );
131 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear())); 130 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear()));
132 131
133#ifndef DESKTOP_VERSION 132#ifndef DESKTOP_VERSION
134 setCaption(i18n("Click OK to search ->")); 133 setCaption(i18n("Click OK to search ->"));
135 hideButtons(); 134 hideButtons();
136#endif 135#endif
137} 136}
138 137
139SearchDialog::~SearchDialog() 138SearchDialog::~SearchDialog()
140{ 139{
141 140
142} 141}
143void SearchDialog::accept() 142void SearchDialog::accept()
144{ 143{
145 doSearch(); 144 doSearch();
146} 145}
147void SearchDialog::updateList() 146void SearchDialog::updateList()
148{ 147{
149 //listView->updateList(); 148 //listView->updateList();
150 if ( isVisible() ) { 149 if ( isVisible() ) {
151 updateView(); 150 updateView();
152 //qDebug("SearchDialog::updated "); 151 //qDebug("SearchDialog::updated ");
153 } 152 }
154 else { 153 else {
155 listView->clear(); 154 listView->clear();
156 //qDebug("SearchDialog::cleared "); 155 //qDebug("SearchDialog::cleared ");
157 156
158 } 157 }
159} 158}
160void SearchDialog::searchTextChanged( const QString &_text ) 159void SearchDialog::searchTextChanged( const QString &_text )
161{ 160{
162 enableButton( KDialogBase::User1, !_text.isEmpty() ); 161 enableButton( KDialogBase::User1, !_text.isEmpty() );
163} 162}
164 163
165void SearchDialog::doSearch() 164void SearchDialog::doSearch()
166{ 165{
167 QRegExp re; 166 QRegExp re;
168 167
169 re.setWildcard(true); // most people understand these better. 168 re.setWildcard(true); // most people understand these better.
170 re.setCaseSensitive(false); 169 re.setCaseSensitive(false);
171 re.setPattern(searchEdit->text()); 170 re.setPattern(searchEdit->text());
172 if (!re.isValid() ) { 171 if (!re.isValid() ) {
173 KMessageBox::sorry(this, 172 KMessageBox::sorry(this,
174 i18n("Invalid search expression,\ncannot perform " 173 i18n("Invalid search expression,\ncannot perform "
175 "the search.\nPlease enter a search expression\n" 174 "the search.\nPlease enter a search expression\n"
176 "using the wildcard characters\n '*' and '?'" 175 "using the wildcard characters\n '*' and '?'"
177 "where needed.")); 176 "where needed."));
178 return; 177 return;
179 } 178 }
180 179
181 search(re); 180 search(re);
182 181
183 listView->setStartDate( mStartDate->date() ); 182 listView->setStartDate( mStartDate->date() );
184 listView->showEvents(mMatchedEvents); 183 listView->showEvents(mMatchedEvents);
185 listView->addTodos(mMatchedTodos); 184 listView->addTodos(mMatchedTodos);
186 listView->addJournals(mMatchedJournals); 185 listView->addJournals(mMatchedJournals);
187 186
188 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 187 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
189 KMessageBox::information(this, 188 KMessageBox::information(this,
190 i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed.")); 189 i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed."));
191#ifndef DESKTOP_VERSION 190#ifndef DESKTOP_VERSION
192 setCaption(i18n("Click OK to search ->")); 191 setCaption(i18n("Click OK to search ->"));
193#else 192#else
194 setCaption(i18n("KO/Pi Find ")); 193 setCaption(i18n("KO/Pi Find "));
195#endif 194#endif
196 } else { 195 } else {
197 QString mess; 196 QString mess;
198 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 197 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
199 setCaption( i18n("KO/Pi Find: ") + mess); 198 setCaption( i18n("KO/Pi Find: ") + mess);
200 199
201 } 200 }
202} 201}
203void SearchDialog::updateConfig() 202void SearchDialog::updateConfig()
204{ 203{
205 listView->updateConfig(); 204 listView->updateConfig();
206} 205}
207void SearchDialog::updateView() 206void SearchDialog::updateView()
208{ 207{
209 208
210 QRegExp re; 209 QRegExp re;
211 re.setWildcard(true); // most people understand these better. 210 re.setWildcard(true); // most people understand these better.
212 re.setCaseSensitive(false); 211 re.setCaseSensitive(false);
213 re.setPattern(searchEdit->text()); 212 re.setPattern(searchEdit->text());
214 if (re.isValid()) { 213 if (re.isValid()) {
215 search(re); 214 search(re);
216 } else { 215 } else {
217 mMatchedEvents.clear(); 216 mMatchedEvents.clear();
218 mMatchedTodos.clear(); 217 mMatchedTodos.clear();
219 mMatchedJournals.clear(); 218 mMatchedJournals.clear();
220 } 219 }
221 listView->setStartDate( mStartDate->date() ); 220 listView->setStartDate( mStartDate->date() );
222 listView->showEvents(mMatchedEvents); 221 listView->showEvents(mMatchedEvents);
223 listView->addTodos(mMatchedTodos); 222 listView->addTodos(mMatchedTodos);
224 listView->addJournals(mMatchedJournals); 223 listView->addJournals(mMatchedJournals);
225} 224}
226 225
227void SearchDialog::search(const QRegExp &re) 226void SearchDialog::search(const QRegExp &re)
228{ 227{
229 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 228 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
230 mEndDate->date(), 229 mEndDate->date(),
231 false /*mInclusiveCheck->isChecked()*/ ); 230 false /*mInclusiveCheck->isChecked()*/ );
232 231
233 mMatchedEvents.clear(); 232 mMatchedEvents.clear();
234 if ( mSearchEvent->isChecked() ) { 233 if ( mSearchEvent->isChecked() ) {
235 Event *ev; 234 Event *ev;
236 for(ev=events.first();ev;ev=events.next()) { 235 for(ev=events.first();ev;ev=events.next()) {
237 if (mSummaryCheck->isChecked()) { 236 if (mSummaryCheck->isChecked()) {
238#if QT_VERSION >= 300 237#if QT_VERSION >= 300
239 if (re.search(ev->summary()) != -1) 238 if (re.search(ev->summary()) != -1)
240#else 239#else
241 if (re.match(ev->summary()) != -1) 240 if (re.match(ev->summary()) != -1)
242#endif 241#endif
243 { 242 {
244 mMatchedEvents.append(ev); 243 mMatchedEvents.append(ev);
245 continue; 244 continue;
246 } 245 }
247 } 246 }
248 if (mDescriptionCheck->isChecked()) { 247 if (mDescriptionCheck->isChecked()) {
249#if QT_VERSION >= 300 248#if QT_VERSION >= 300
250 if (re.search(ev->description()) != -1) 249 if (re.search(ev->description()) != -1)
251#else 250#else
252 if (re.match(ev->description()) != -1) 251 if (re.match(ev->description()) != -1)
253#endif 252#endif
254 { 253 {
255 mMatchedEvents.append(ev); 254 mMatchedEvents.append(ev);
256 continue; 255 continue;
257 } 256 }
258 } 257 }
259 if (mCategoryCheck->isChecked()) { 258 if (mCategoryCheck->isChecked()) {
260#if QT_VERSION >= 300 259#if QT_VERSION >= 300
261 if (re.search(ev->categoriesStr()) != -1) 260 if (re.search(ev->categoriesStr()) != -1)
262#else 261#else
263 if (re.match(ev->categoriesStr()) != -1) 262 if (re.match(ev->categoriesStr()) != -1)
264#endif 263#endif
265 { 264 {
266 mMatchedEvents.append(ev); 265 mMatchedEvents.append(ev);
267 continue; 266 continue;
268 } 267 }
269 } 268 }
270 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 269 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
271 QPtrList<Attendee> tmpAList = ev->attendees(); 270 QPtrList<Attendee> tmpAList = ev->attendees();
272 Attendee *a; 271 Attendee *a;
273 for (a = tmpAList.first(); a; a = tmpAList.next()) { 272 for (a = tmpAList.first(); a; a = tmpAList.next()) {
274 if (mSearchAName->isChecked()) { 273 if (mSearchAName->isChecked()) {
275#if QT_VERSION >= 300 274#if QT_VERSION >= 300
276 if (re.search(a->name()) != -1) 275 if (re.search(a->name()) != -1)
277#else 276#else
278 if (re.match(a->name()) != -1) 277 if (re.match(a->name()) != -1)
279#endif 278#endif
280 { 279 {
281 mMatchedEvents.append(ev); 280 mMatchedEvents.append(ev);
282 break; 281 break;
283 } 282 }
284 } 283 }
285 if (mSearchAEmail->isChecked()) { 284 if (mSearchAEmail->isChecked()) {
286#if QT_VERSION >= 300 285#if QT_VERSION >= 300
287 if (re.search(a->email()) != -1) 286 if (re.search(a->email()) != -1)
288#else 287#else
289 if (re.match(a->email()) != -1) 288 if (re.match(a->email()) != -1)
290#endif 289#endif
291 { 290 {
292 mMatchedEvents.append(ev); 291 mMatchedEvents.append(ev);
293 break; 292 break;
294 } 293 }
295 } 294 }
296 } 295 }
297 } 296 }
298 } 297 }
299 } 298 }
300 QPtrList<Todo> todos = mCalendar->todos( ); 299 QPtrList<Todo> todos = mCalendar->todos( );
301 mMatchedTodos.clear(); 300 mMatchedTodos.clear();
302 if ( mSearchTodo->isChecked() ) { 301 if ( mSearchTodo->isChecked() ) {
303 Todo *tod; 302 Todo *tod;
304 for(tod=todos.first();tod;tod=todos.next()) { 303 for(tod=todos.first();tod;tod=todos.next()) {
305 if (mSummaryCheck->isChecked()) { 304 if (mSummaryCheck->isChecked()) {
306#if QT_VERSION >= 300 305#if QT_VERSION >= 300
307 if (re.search(tod->summary()) != -1) 306 if (re.search(tod->summary()) != -1)
308#else 307#else
309 if (re.match(tod->summary()) != -1) 308 if (re.match(tod->summary()) != -1)
310#endif 309#endif
311 { 310 {
312 mMatchedTodos.append(tod); 311 mMatchedTodos.append(tod);
313 continue; 312 continue;
314 } 313 }
315 } 314 }
316 if (mDescriptionCheck->isChecked()) { 315 if (mDescriptionCheck->isChecked()) {
317#if QT_VERSION >= 300 316#if QT_VERSION >= 300
318 if (re.search(tod->description()) != -1) 317 if (re.search(tod->description()) != -1)
319#else 318#else
320 if (re.match(tod->description()) != -1) 319 if (re.match(tod->description()) != -1)
321#endif 320#endif
322 { 321 {
323 mMatchedTodos.append(tod); 322 mMatchedTodos.append(tod);
324 continue; 323 continue;
325 } 324 }
326 } 325 }
327 if (mCategoryCheck->isChecked()) { 326 if (mCategoryCheck->isChecked()) {
328#if QT_VERSION >= 300 327#if QT_VERSION >= 300
329 if (re.search(tod->categoriesStr()) != -1) 328 if (re.search(tod->categoriesStr()) != -1)
330#else 329#else
331 if (re.match(tod->categoriesStr()) != -1) 330 if (re.match(tod->categoriesStr()) != -1)
332#endif 331#endif
333 { 332 {
334 mMatchedTodos.append(tod); 333 mMatchedTodos.append(tod);
335 continue; 334 continue;
336 } 335 }
337 } 336 }
338 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 337 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
339 QPtrList<Attendee> tmpAList = tod->attendees(); 338 QPtrList<Attendee> tmpAList = tod->attendees();
340 Attendee *a; 339 Attendee *a;
341 for (a = tmpAList.first(); a; a = tmpAList.next()) { 340 for (a = tmpAList.first(); a; a = tmpAList.next()) {
342 if (mSearchAName->isChecked()) { 341 if (mSearchAName->isChecked()) {
343#if QT_VERSION >= 300 342#if QT_VERSION >= 300
344 if (re.search(a->name()) != -1) 343 if (re.search(a->name()) != -1)
345#else 344#else
346 if (re.match(a->name()) != -1) 345 if (re.match(a->name()) != -1)
347#endif 346#endif
348 { 347 {
349 mMatchedTodos.append(tod); 348 mMatchedTodos.append(tod);
350 break; 349 break;
351 } 350 }
352 } 351 }
353 if (mSearchAEmail->isChecked()) { 352 if (mSearchAEmail->isChecked()) {
354#if QT_VERSION >= 300 353#if QT_VERSION >= 300
355 if (re.search(a->email()) != -1) 354 if (re.search(a->email()) != -1)
356#else 355#else
357 if (re.match(a->email()) != -1) 356 if (re.match(a->email()) != -1)
358#endif 357#endif
359 { 358 {
360 mMatchedTodos.append(tod); 359 mMatchedTodos.append(tod);
361 break; 360 break;
362 } 361 }
363 } 362 }
364 } 363 }
365 } 364 }
366 } 365 }
367 } 366 }
368 mMatchedJournals.clear(); 367 mMatchedJournals.clear();
369 if (mSearchJournal->isChecked() ) { 368 if (mSearchJournal->isChecked() ) {
370 QPtrList<Journal> journals = mCalendar->journals( ); 369 QPtrList<Journal> journals = mCalendar->journals( );
371 Journal* journ; 370 Journal* journ;
372 371
373 for(journ=journals.first();journ;journ=journals.next()) { 372 for(journ=journals.first();journ;journ=journals.next()) {
374 if ( journ->dtStart().date() <= mEndDate->date() 373 if ( journ->dtStart().date() <= mEndDate->date()
375 &&journ->dtStart().date() >= mStartDate->date()) { 374 &&journ->dtStart().date() >= mStartDate->date()) {
376#if QT_VERSION >= 300 375#if QT_VERSION >= 300
377 if (re.search(journ->description()) != -1) 376 if (re.search(journ->description()) != -1)
378#else 377#else
379 if (re.match(journ->description()) != -1) 378 if (re.match(journ->description()) != -1)
380#endif 379#endif
381 { 380 {
382 mMatchedJournals.append(journ); 381 mMatchedJournals.append(journ);
383 continue; 382 continue;
384 } 383 }
385 } 384 }
386 } 385 }
387 } 386 }
388 387
389} 388}
390void SearchDialog::keyPressEvent ( QKeyEvent *e) 389void SearchDialog::keyPressEvent ( QKeyEvent *e)
391{ 390{
392 391
393 e->ignore(); 392 e->ignore();
394 393
395} 394}
396//mMatchedJournals; 395//mMatchedJournals;
diff --git a/korganizer/statusdialog.cpp b/korganizer/statusdialog.cpp
index 78efeb0..7137c49 100644
--- a/korganizer/statusdialog.cpp
+++ b/korganizer/statusdialog.cpp
@@ -1,67 +1,66 @@
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 19
20#include <qlabel.h> 20#include <qlabel.h>
21#include <qpushbutton.h> 21#include <qpushbutton.h>
22#include <qstringlist.h> 22#include <qstringlist.h>
23#include <qlayout.h> 23#include <qlayout.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <klocale.h> 26#include <klocale.h>
27 27
28#include "statusdialog.h" 28#include "statusdialog.h"
29#include "statusdialog.moc"
30 29
31StatusDialog::StatusDialog(QWidget* parent, const char* name) : 30StatusDialog::StatusDialog(QWidget* parent, const char* name) :
32 KDialog(parent,name,true) 31 KDialog(parent,name,true)
33{ 32{
34 setCaption(i18n("Set Your Status")); 33 setCaption(i18n("Set Your Status"));
35 34
36 QBoxLayout *topLayout = new QVBoxLayout( this ); 35 QBoxLayout *topLayout = new QVBoxLayout( this );
37 topLayout->setSpacing( spacingHint() ); 36 topLayout->setSpacing( spacingHint() );
38 topLayout->setMargin( marginHint() ); 37 topLayout->setMargin( marginHint() );
39 38
40 QBoxLayout *statusLayout = new QHBoxLayout( topLayout ); 39 QBoxLayout *statusLayout = new QHBoxLayout( topLayout );
41 40
42 QLabel *text = new QLabel(i18n("Set your status"),this); 41 QLabel *text = new QLabel(i18n("Set your status"),this);
43 statusLayout->addWidget( text ); 42 statusLayout->addWidget( text );
44 43
45 mStatus = new QComboBox(false,this); 44 mStatus = new QComboBox(false,this);
46 mStatus->insertStringList(Attendee::statusList()); 45 mStatus->insertStringList(Attendee::statusList());
47 statusLayout->addWidget( mStatus ); 46 statusLayout->addWidget( mStatus );
48 47
49 QBoxLayout *buttonLayout = new QHBoxLayout( topLayout ); 48 QBoxLayout *buttonLayout = new QHBoxLayout( topLayout );
50 49
51 QPushButton *ok = new QPushButton(i18n("&OK"), this); 50 QPushButton *ok = new QPushButton(i18n("&OK"), this);
52 connect ( ok,SIGNAL(clicked()), this,SLOT(accept()) ); 51 connect ( ok,SIGNAL(clicked()), this,SLOT(accept()) );
53 buttonLayout->addWidget( ok ); 52 buttonLayout->addWidget( ok );
54 53
55 QPushButton *cancel = new QPushButton(i18n("&Cancel"), this); 54 QPushButton *cancel = new QPushButton(i18n("&Cancel"), this);
56 connect ( cancel,SIGNAL(clicked()), this,SLOT(reject()) ); 55 connect ( cancel,SIGNAL(clicked()), this,SLOT(reject()) );
57 buttonLayout->addWidget( cancel ); 56 buttonLayout->addWidget( cancel );
58} 57}
59 58
60StatusDialog::~StatusDialog() 59StatusDialog::~StatusDialog()
61{ 60{
62} 61}
63 62
64Attendee::PartStat StatusDialog::status() 63Attendee::PartStat StatusDialog::status()
65{ 64{
66 return Attendee::PartStat( mStatus->currentItem() ) ; 65 return Attendee::PartStat( mStatus->currentItem() ) ;
67} 66}
diff --git a/korganizer/timeline.cpp b/korganizer/timeline.cpp
index 6f9c8dd..11be432 100644
--- a/korganizer/timeline.cpp
+++ b/korganizer/timeline.cpp
@@ -1,63 +1,62 @@
1#include <qpainter.h> 1#include <qpainter.h>
2 2
3#include <kdebug.h> 3#include <kdebug.h>
4 4
5#include "timeline.h" 5#include "timeline.h"
6#include "timeline.moc"
7 6
8TimeLine::TimeLine( QWidget *parent, const char *name ) : 7TimeLine::TimeLine( QWidget *parent, const char *name ) :
9 QScrollView( parent, name ) 8 QScrollView( parent, name )
10{ 9{
11 mPixelWidth = 1000; 10 mPixelWidth = 1000;
12 11
13 resizeContents( mPixelWidth, 20 ); 12 resizeContents( mPixelWidth, 20 );
14 13
15 viewport()->setBackgroundMode( PaletteBackground ); 14 viewport()->setBackgroundMode( PaletteBackground );
16 15
17 setHScrollBarMode(AlwaysOff); 16 setHScrollBarMode(AlwaysOff);
18 setVScrollBarMode(AlwaysOff); 17 setVScrollBarMode(AlwaysOff);
19} 18}
20 19
21TimeLine::~TimeLine() 20TimeLine::~TimeLine()
22{ 21{
23} 22}
24 23
25void TimeLine::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 24void TimeLine::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
26{ 25{
27 int spacingX = mDaySpacing; 26 int spacingX = mDaySpacing;
28 int offsetX = mDayOffset; 27 int offsetX = mDayOffset;
29 28
30 // Draw vertical lines of grid 29 // Draw vertical lines of grid
31// kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl; 30// kdDebug() << "drawContents cx: " << cx << " cy: " << cy << " cw: " << cw << " ch: " << ch << endl;
32 int cell = int( (cx - ( spacingX - offsetX ) ) / spacingX ); 31 int cell = int( (cx - ( spacingX - offsetX ) ) / spacingX );
33 int x = cell * spacingX + ( spacingX - offsetX ); 32 int x = cell * spacingX + ( spacingX - offsetX );
34// kdDebug() << " x: " << x << endl; 33// kdDebug() << " x: " << x << endl;
35 while (x < cx + cw) { 34 while (x < cx + cw) {
36// kdDebug() << " x: " << x << endl; 35// kdDebug() << " x: " << x << endl;
37 p->drawLine(x,cy,x,cy+ch); 36 p->drawLine(x,cy,x,cy+ch);
38 p->drawText( x + 5, 15, QString::number( mStartDate.addDays( cell + 1 ).date().day() ) ); 37 p->drawText( x + 5, 15, QString::number( mStartDate.addDays( cell + 1 ).date().day() ) );
39 38
40 x += spacingX; 39 x += spacingX;
41 cell++; 40 cell++;
42 } 41 }
43} 42}
44 43
45void TimeLine::setDateRange( const QDateTime &start, const QDateTime &end ) 44void TimeLine::setDateRange( const QDateTime &start, const QDateTime &end )
46{ 45{
47 mStartDate = start; 46 mStartDate = start;
48 mEndDate = end; 47 mEndDate = end;
49 48
50 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mPixelWidth; 49 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mPixelWidth;
51 50
52 mDaySpacing = 60 * 60 * 24 / mSecsPerPixel; 51 mDaySpacing = 60 * 60 * 24 / mSecsPerPixel;
53 52
54 mDayOffset = QDateTime( mStartDate.date() ).secsTo( mStartDate ) / mSecsPerPixel; 53 mDayOffset = QDateTime( mStartDate.date() ).secsTo( mStartDate ) / mSecsPerPixel;
55 54
56 kdDebug() << "TimeLines::setDateRange(): mDaySpacing: " << mDaySpacing << " mDayOffset: " 55 kdDebug() << "TimeLines::setDateRange(): mDaySpacing: " << mDaySpacing << " mDayOffset: "
57 << mDayOffset << " mSecsPerPixel: " << mSecsPerPixel << endl; 56 << mDayOffset << " mSecsPerPixel: " << mSecsPerPixel << endl;
58} 57}
59 58
60void TimeLine::setContentsPos( int pos ) 59void TimeLine::setContentsPos( int pos )
61{ 60{
62 QScrollView::setContentsPos ( pos, 0 ); 61 QScrollView::setContentsPos ( pos, 0 );
63} 62}
diff --git a/korganizer/timespanview.cpp b/korganizer/timespanview.cpp
index f8314e7..67a3811 100644
--- a/korganizer/timespanview.cpp
+++ b/korganizer/timespanview.cpp
@@ -1,158 +1,157 @@
1 1
2#ifndef DESKTOP_VERSION 2#ifndef DESKTOP_VERSION
3#include <qksplitter.h> 3#include <qksplitter.h>
4#else 4#else
5#include <qsplitter.h> 5#include <qsplitter.h>
6#endif 6#endif
7#include <qlistview.h> 7#include <qlistview.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qheader.h> 9#include <qheader.h>
10#include <qpushbutton.h> 10#include <qpushbutton.h>
11 11
12#include <klocale.h> 12#include <klocale.h>
13#include <kdebug.h> 13#include <kdebug.h>
14 14
15#include "lineview.h" 15#include "lineview.h"
16#include "timeline.h" 16#include "timeline.h"
17 17
18#include "timespanview.h" 18#include "timespanview.h"
19#include "timespanview.moc"
20 19
21 20
22TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) : 21TimeSpanView::TimeSpanView( QWidget *parent, const char *name ) :
23 QWidget( parent, name ) 22 QWidget( parent, name )
24{ 23{
25 QBoxLayout *topLayout = new QVBoxLayout( this ); 24 QBoxLayout *topLayout = new QVBoxLayout( this );
26#ifndef DESKTOP_VERSION 25#ifndef DESKTOP_VERSION
27 mSplitter = new QKSplitter( this ); 26 mSplitter = new QKSplitter( this );
28#else 27#else
29 mSplitter = new QSplitter( this ); 28 mSplitter = new QSplitter( this );
30#endif 29#endif
31 topLayout->addWidget( mSplitter ); 30 topLayout->addWidget( mSplitter );
32 31
33 mList = new QListView( mSplitter ); 32 mList = new QListView( mSplitter );
34 mList->addColumn( i18n("Summary") ); 33 mList->addColumn( i18n("Summary") );
35 34
36 QWidget *rightPane = new QWidget( mSplitter ); 35 QWidget *rightPane = new QWidget( mSplitter );
37 QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane ); 36 QBoxLayout *rightPaneLayout = new QVBoxLayout( rightPane );
38 37
39 mTimeLine = new TimeLine( rightPane ); 38 mTimeLine = new TimeLine( rightPane );
40 mTimeLine->setFixedHeight( mList->header()->height() ); 39 mTimeLine->setFixedHeight( mList->header()->height() );
41 rightPaneLayout->addWidget( mTimeLine ); 40 rightPaneLayout->addWidget( mTimeLine );
42 41
43 mLineView = new LineView( rightPane ); 42 mLineView = new LineView( rightPane );
44 rightPaneLayout->addWidget( mLineView ); 43 rightPaneLayout->addWidget( mLineView );
45 44
46 QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout ); 45 QBoxLayout *buttonLayout = new QHBoxLayout( rightPaneLayout );
47 46
48 QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane ); 47 QPushButton *zoomInButton = new QPushButton( i18n("Zoom In"), rightPane );
49 connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) ); 48 connect( zoomInButton, SIGNAL( clicked() ), SLOT( zoomIn() ) );
50 buttonLayout->addWidget( zoomInButton ); 49 buttonLayout->addWidget( zoomInButton );
51 50
52 QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane ); 51 QPushButton *zoomOutButton = new QPushButton( i18n("Zoom Out"), rightPane );
53 connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) ); 52 connect( zoomOutButton, SIGNAL( clicked() ), SLOT( zoomOut() ) );
54 buttonLayout->addWidget( zoomOutButton ); 53 buttonLayout->addWidget( zoomOutButton );
55 54
56 QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane ); 55 QPushButton *centerButton = new QPushButton( i18n("Center View"), rightPane );
57 connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) ); 56 connect( centerButton, SIGNAL( clicked() ), SLOT( centerView() ) );
58 buttonLayout->addWidget( centerButton ); 57 buttonLayout->addWidget( centerButton );
59 58
60 connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)), 59 connect(mLineView->horizontalScrollBar(),SIGNAL(valueChanged(int)),
61 mTimeLine,SLOT(setContentsPos(int))); 60 mTimeLine,SLOT(setContentsPos(int)));
62} 61}
63 62
64TimeSpanView::~TimeSpanView() 63TimeSpanView::~TimeSpanView()
65{ 64{
66} 65}
67 66
68QValueList<int> TimeSpanView::splitterSizes() 67QValueList<int> TimeSpanView::splitterSizes()
69{ 68{
70 return mSplitter->sizes(); 69 return mSplitter->sizes();
71} 70}
72 71
73void TimeSpanView::setSplitterSizes( QValueList<int> sizes ) 72void TimeSpanView::setSplitterSizes( QValueList<int> sizes )
74{ 73{
75 mSplitter->setSizes( sizes ); 74 mSplitter->setSizes( sizes );
76} 75}
77 76
78void TimeSpanView::addItem( KCal::Event *event ) 77void TimeSpanView::addItem( KCal::Event *event )
79{ 78{
80 new QListViewItem( mList, event->summary() ); 79 new QListViewItem( mList, event->summary() );
81 80
82 QDateTime startDt = event->dtStart(); 81 QDateTime startDt = event->dtStart();
83 QDateTime endDt = event->dtEnd(); 82 QDateTime endDt = event->dtEnd();
84 83
85// kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString() 84// kdDebug() << "TimeSpanView::addItem(): start: " << startDt.toString()
86// << " end: " << endDt.toString() << endl; 85// << " end: " << endDt.toString() << endl;
87 86
88 int startSecs = mStartDate.secsTo( startDt ); 87 int startSecs = mStartDate.secsTo( startDt );
89 int durationSecs = startDt.secsTo( endDt ); 88 int durationSecs = startDt.secsTo( endDt );
90 89
91// kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl; 90// kdDebug() << "--- startSecs: " << startSecs << " dur: " << durationSecs << endl;
92 91
93 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel; 92 int startX = mStartDate.secsTo( startDt ) / mSecsPerPixel;
94 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel; 93 int endX = startX + startDt.secsTo( endDt ) / mSecsPerPixel;
95 94
96// kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl; 95// kdDebug() << "TimeSpanView::addItem(): s: " << startX << " e: " << endX << endl;
97 96
98 mLineView->addLine( startX, endX ); 97 mLineView->addLine( startX, endX );
99} 98}
100 99
101void TimeSpanView::clear() 100void TimeSpanView::clear()
102{ 101{
103 mList->clear(); 102 mList->clear();
104 mLineView->clear(); 103 mLineView->clear();
105} 104}
106 105
107void TimeSpanView::updateView() 106void TimeSpanView::updateView()
108{ 107{
109#if QT_VERSION >= 300 108#if QT_VERSION >= 300
110 mLineView->updateContents(); 109 mLineView->updateContents();
111 mTimeLine->updateContents(); 110 mTimeLine->updateContents();
112#else 111#else
113#endif 112#endif
114} 113}
115 114
116void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end ) 115void TimeSpanView::setDateRange( const QDateTime &start, const QDateTime &end )
117{ 116{
118 mStartDate = start; 117 mStartDate = start;
119 mEndDate = end; 118 mEndDate = end;
120 119
121 mTimeLine->setDateRange( start, end ); 120 mTimeLine->setDateRange( start, end );
122 121
123 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth(); 122 mSecsPerPixel = mStartDate.secsTo( mEndDate ) / mLineView->pixelWidth();
124} 123}
125 124
126QDateTime TimeSpanView::startDateTime() 125QDateTime TimeSpanView::startDateTime()
127{ 126{
128 return mStartDate; 127 return mStartDate;
129} 128}
130 129
131QDateTime TimeSpanView::endDateTime() 130QDateTime TimeSpanView::endDateTime()
132{ 131{
133 return mEndDate; 132 return mEndDate;
134} 133}
135 134
136void TimeSpanView::zoomIn() 135void TimeSpanView::zoomIn()
137{ 136{
138 int span = mStartDate.daysTo( mEndDate ); 137 int span = mStartDate.daysTo( mEndDate );
139 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) ); 138 setDateRange( mStartDate.addDays( span / 4 ), mEndDate.addDays( span / -4 ) );
140 139
141 emit dateRangeChanged(); 140 emit dateRangeChanged();
142} 141}
143 142
144void TimeSpanView::zoomOut() 143void TimeSpanView::zoomOut()
145{ 144{
146 int span = mStartDate.daysTo( mEndDate ); 145 int span = mStartDate.daysTo( mEndDate );
147 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) ); 146 setDateRange( mStartDate.addDays( span / -4 ), mEndDate.addDays( span / 4 ) );
148 147
149 emit dateRangeChanged(); 148 emit dateRangeChanged();
150} 149}
151 150
152void TimeSpanView::centerView() 151void TimeSpanView::centerView()
153{ 152{
154 QScrollBar *scrollBar = mLineView->horizontalScrollBar(); 153 QScrollBar *scrollBar = mLineView->horizontalScrollBar();
155 int min = scrollBar->minValue(); 154 int min = scrollBar->minValue();
156 int max = scrollBar->maxValue(); 155 int max = scrollBar->maxValue();
157 scrollBar->setValue( min + (max-min) / 2 ); 156 scrollBar->setValue( min + (max-min) / 2 );
158} 157}