summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-01 09:50:16 (UTC)
committer zautrix <zautrix>2005-04-01 09:50:16 (UTC)
commitf8e027db1d950ec27a3c47fc2a5ea2fe49ae9772 (patch) (unidiff)
tree15edcb7a2b053eae5c5391191f71ba5c5c015211
parentb76ad1e7e329051a47e28c9d132ce3fcd0b25c5c (diff)
downloadkdepimpi-f8e027db1d950ec27a3c47fc2a5ea2fe49ae9772.zip
kdepimpi-f8e027db1d950ec27a3c47fc2a5ea2fe49ae9772.tar.gz
kdepimpi-f8e027db1d950ec27a3c47fc2a5ea2fe49ae9772.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp6
-rw-r--r--korganizer/kodialogmanager.cpp4
-rw-r--r--korganizer/koprefs.h11
-rw-r--r--korganizer/koviewmanager.cpp20
-rw-r--r--korganizer/mainwindow.cpp1
-rw-r--r--korganizer/searchdialog.cpp47
-rw-r--r--korganizer/searchdialog.h1
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp7
-rw-r--r--microkde/kapplication.cpp15
-rw-r--r--microkde/kapplication.h1
-rw-r--r--microkde/kresources/factory.cpp6
11 files changed, 100 insertions, 19 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1e83236..beb19d9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3919 +1,3923 @@
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 <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.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#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141 141
142class KOBeamPrefs : public QDialog 142class KOBeamPrefs : public QDialog
143{ 143{
144 public: 144 public:
145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
146 QDialog( parent, name, true ) 146 QDialog( parent, name, true )
147 { 147 {
148 setCaption( i18n("Beam Options") ); 148 setCaption( i18n("Beam Options") );
149 QVBoxLayout* lay = new QVBoxLayout( this ); 149 QVBoxLayout* lay = new QVBoxLayout( this );
150 lay->setSpacing( 3 ); 150 lay->setSpacing( 3 );
151 lay->setMargin( 3 ); 151 lay->setMargin( 3 );
152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
153 lay->addWidget( format ); 153 lay->addWidget( format );
154 format->setExclusive ( true ) ; 154 format->setExclusive ( true ) ;
155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
156 lay->addWidget( time ); time->setExclusive ( true ) ; 156 lay->addWidget( time ); time->setExclusive ( true ) ;
157 vcal = new QRadioButton(" vCalendar ", format ); 157 vcal = new QRadioButton(" vCalendar ", format );
158 ical = new QRadioButton(" iCalendar ", format ); 158 ical = new QRadioButton(" iCalendar ", format );
159 vcal->setChecked( true ); 159 vcal->setChecked( true );
160 tz = new QRadioButton(i18n(" With timezone "), time ); 160 tz = new QRadioButton(i18n(" With timezone "), time );
161 local = new QRadioButton(i18n(" Local time "), time ); 161 local = new QRadioButton(i18n(" Local time "), time );
162 tz->setChecked( true ); 162 tz->setChecked( true );
163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
164 lay->addWidget( ok ); 164 lay->addWidget( ok );
165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
166 lay->addWidget( cancel ); 166 lay->addWidget( cancel );
167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
169 resize( 200, 200 ); 169 resize( 200, 200 );
170 } 170 }
171 171
172 bool beamVcal() { return vcal->isChecked(); } 172 bool beamVcal() { return vcal->isChecked(); }
173 bool beamLocal() { return local->isChecked(); } 173 bool beamLocal() { return local->isChecked(); }
174private: 174private:
175 QRadioButton* vcal, *ical, *local, *tz; 175 QRadioButton* vcal, *ical, *local, *tz;
176}; 176};
177class KOCatPrefs : public QDialog 177class KOCatPrefs : public QDialog
178{ 178{
179 public: 179 public:
180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
181 QDialog( parent, name, true ) 181 QDialog( parent, name, true )
182 { 182 {
183 setCaption( i18n("Manage new Categories") ); 183 setCaption( i18n("Manage new Categories") );
184 QVBoxLayout* lay = new QVBoxLayout( this ); 184 QVBoxLayout* lay = new QVBoxLayout( this );
185 lay->setSpacing( 3 ); 185 lay->setSpacing( 3 );
186 lay->setMargin( 3 ); 186 lay->setMargin( 3 );
187 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 ); 187 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 );
188 lay->addWidget( lab ); 188 lay->addWidget( lab );
189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
190 lay->addWidget( format ); 190 lay->addWidget( format );
191 format->setExclusive ( true ) ; 191 format->setExclusive ( true ) ;
192 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 192 addCatBut = new QRadioButton(i18n("Add to category list"), format );
193 new QRadioButton(i18n("Remove from Events/Todos"), format ); 193 new QRadioButton(i18n("Remove from Events/Todos"), format );
194 addCatBut->setChecked( true ); 194 addCatBut->setChecked( true );
195 QPushButton * ok = new QPushButton( i18n("OK"), this ); 195 QPushButton * ok = new QPushButton( i18n("OK"), this );
196 lay->addWidget( ok ); 196 lay->addWidget( ok );
197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
198 lay->addWidget( cancel ); 198 lay->addWidget( cancel );
199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
201 resize( 200, 200 ); 201 resize( 200, 200 );
202 } 202 }
203 203
204 bool addCat() { return addCatBut->isChecked(); } 204 bool addCat() { return addCatBut->isChecked(); }
205private: 205private:
206 QRadioButton* addCatBut; 206 QRadioButton* addCatBut;
207}; 207};
208 208
209 209
210 210
211CalendarView::CalendarView( CalendarResources *calendar, 211CalendarView::CalendarView( CalendarResources *calendar,
212 QWidget *parent, const char *name ) 212 QWidget *parent, const char *name )
213 : CalendarViewBase( parent, name ), 213 : CalendarViewBase( parent, name ),
214 mCalendar( calendar ), 214 mCalendar( calendar ),
215 mResourceManager( calendar->resourceManager() ) 215 mResourceManager( calendar->resourceManager() )
216{ 216{
217 217
218 mEventEditor = 0; 218 mEventEditor = 0;
219 mTodoEditor = 0; 219 mTodoEditor = 0;
220 220
221 init(); 221 init();
222} 222}
223 223
224CalendarView::CalendarView( Calendar *calendar, 224CalendarView::CalendarView( Calendar *calendar,
225 QWidget *parent, const char *name ) 225 QWidget *parent, const char *name )
226 : CalendarViewBase( parent, name ), 226 : CalendarViewBase( parent, name ),
227 mCalendar( calendar ), 227 mCalendar( calendar ),
228 mResourceManager( 0 ) 228 mResourceManager( 0 )
229{ 229{
230 230
231 mEventEditor = 0; 231 mEventEditor = 0;
232 mTodoEditor = 0; 232 mTodoEditor = 0;
233 init(); 233 init();
234} 234}
235 235
236void CalendarView::init() 236void CalendarView::init()
237{ 237{
238 mNextAlarmDateTime = QDateTime::currentDateTime(); 238 mNextAlarmDateTime = QDateTime::currentDateTime();
239 setFocusPolicy ( WheelFocus ); 239 setFocusPolicy ( WheelFocus );
240 mViewerCallerIsSearchDialog = false; 240 mViewerCallerIsSearchDialog = false;
241 mBlockShowDates = false; 241 mBlockShowDates = false;
242 beamDialog = new KOBeamPrefs(); 242 beamDialog = new KOBeamPrefs();
243 mDatePickerMode = 0; 243 mDatePickerMode = 0;
244 mCurrentSyncDevice = ""; 244 mCurrentSyncDevice = "";
245 writeLocale(); 245 writeLocale();
246 mViewManager = new KOViewManager( this ); 246 mViewManager = new KOViewManager( this );
247 mDialogManager = new KODialogManager( this ); 247 mDialogManager = new KODialogManager( this );
248 mEventViewerDialog = 0; 248 mEventViewerDialog = 0;
249 mModified = false; 249 mModified = false;
250 mReadOnly = false; 250 mReadOnly = false;
251 mSelectedIncidence = 0; 251 mSelectedIncidence = 0;
252 mCalPrinter = 0; 252 mCalPrinter = 0;
253 mFilters.setAutoDelete(true); 253 mFilters.setAutoDelete(true);
254 254
255 mCalendar->registerObserver( this ); 255 mCalendar->registerObserver( this );
256 // TODO: Make sure that view is updated, when calendar is changed. 256 // TODO: Make sure that view is updated, when calendar is changed.
257 257
258 mStorage = new FileStorage( mCalendar ); 258 mStorage = new FileStorage( mCalendar );
259 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 259 mNavigator = new DateNavigator( this, "datevav", mViewManager );
260 260
261 QBoxLayout *topLayout = (QBoxLayout*)layout(); 261 QBoxLayout *topLayout = (QBoxLayout*)layout();
262#ifndef KORG_NOSPLITTER 262#ifndef KORG_NOSPLITTER
263 // create the main layout frames. 263 // create the main layout frames.
264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
265 topLayout->addWidget(mPanner); 265 topLayout->addWidget(mPanner);
266 266
267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
268 "CalendarView::LeftFrame"); 268 "CalendarView::LeftFrame");
269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
270 270
271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
272 "CalendarView::DateNavigator" ); 272 "CalendarView::DateNavigator" );
273 273
274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
276 mTodoList->setNavigator( mNavigator ); 276 mTodoList->setNavigator( mNavigator );
277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
278 278
279#ifdef KORG_NORESOURCEVIEW 279#ifdef KORG_NORESOURCEVIEW
280 mResourceView = 0; 280 mResourceView = 0;
281#else 281#else
282 if ( mResourceManager ) { 282 if ( mResourceManager ) {
283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
284 mResourceView->updateView(); 284 mResourceView->updateView();
285 connect( mResourceView, SIGNAL( resourcesChanged() ), 285 connect( mResourceView, SIGNAL( resourcesChanged() ),
286 SLOT( updateView() ) ); 286 SLOT( updateView() ) );
287 } else { 287 } else {
288 mResourceView = 0; 288 mResourceView = 0;
289 } 289 }
290#endif 290#endif
291 QWidget *rightBox = new QWidget( mPanner ); 291 QWidget *rightBox = new QWidget( mPanner );
292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
293 293
294 mRightFrame = new QWidgetStack( rightBox ); 294 mRightFrame = new QWidgetStack( rightBox );
295 rightLayout->addWidget( mRightFrame, 1 ); 295 rightLayout->addWidget( mRightFrame, 1 );
296 296
297 mLeftFrame = mLeftSplitter; 297 mLeftFrame = mLeftSplitter;
298#else 298#else
299 //QWidget *mainBox = new QWidget( this ); 299 //QWidget *mainBox = new QWidget( this );
300 //QWidget *leftFrame = new QWidget( mainBox ); 300 //QWidget *leftFrame = new QWidget( mainBox );
301 //QBoxLayout * mainBoxLayout; 301 //QBoxLayout * mainBoxLayout;
302 if ( KOPrefs::instance()->mVerticalScreen ) { 302 if ( KOPrefs::instance()->mVerticalScreen ) {
303 //mainBoxLayout = new QVBoxLayout(mainBox); 303 //mainBoxLayout = new QVBoxLayout(mainBox);
304 //leftFrameLayout = new QHBoxLayout(leftFrame ); 304 //leftFrameLayout = new QHBoxLayout(leftFrame );
305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
309 } else { 309 } else {
310 //mainBoxLayout = new QHBoxLayout(mainBox); 310 //mainBoxLayout = new QHBoxLayout(mainBox);
311 //leftFrameLayout = new QVBoxLayout(leftFrame ); 311 //leftFrameLayout = new QVBoxLayout(leftFrame );
312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
316 } 316 }
317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
318 //QBoxLayout * leftFrameLayout; 318 //QBoxLayout * leftFrameLayout;
319 topLayout->addWidget( mMainFrame ); 319 topLayout->addWidget( mMainFrame );
320 //mainBoxLayout->addWidget (mLeftFrame); 320 //mainBoxLayout->addWidget (mLeftFrame);
321 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 321 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
322 "CalendarView::DateNavigator" ); 322 "CalendarView::DateNavigator" );
323#if 0 323#if 0
324 // FIXME 324 // FIXME
325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
326 "CalendarView::DateNavigator", QDate::currentDate()); 326 "CalendarView::DateNavigator", QDate::currentDate());
327#endif 327#endif
328 // mDateNavigator->blockSignals( true ); 328 // mDateNavigator->blockSignals( true );
329 //leftFrameLayout->addWidget( mDateNavigator ); 329 //leftFrameLayout->addWidget( mDateNavigator );
330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
332 mTodoList->setNavigator( mNavigator ); 332 mTodoList->setNavigator( mNavigator );
333#if 0 333#if 0
334 if ( QApplication::desktop()->width() < 480 ) { 334 if ( QApplication::desktop()->width() < 480 ) {
335 leftFrameLayout->addWidget(mFilterView); 335 leftFrameLayout->addWidget(mFilterView);
336 leftFrameLayout->addWidget(mTodoList, 2 ); 336 leftFrameLayout->addWidget(mTodoList, 2 );
337 337
338 } else { 338 } else {
339 leftFrameLayout->addWidget(mTodoList,2 ); 339 leftFrameLayout->addWidget(mTodoList,2 );
340 leftFrameLayout->addWidget(mFilterView ); 340 leftFrameLayout->addWidget(mFilterView );
341 } 341 }
342#endif 342#endif
343 mFilterView->hide(); 343 mFilterView->hide();
344 QWidget *rightBox = new QWidget( mMainFrame ); 344 QWidget *rightBox = new QWidget( mMainFrame );
345 //mainBoxLayout->addWidget ( rightBox, 10 ); 345 //mainBoxLayout->addWidget ( rightBox, 10 );
346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
347 mRightFrame = new QWidgetStack( rightBox ); 347 mRightFrame = new QWidgetStack( rightBox );
348 rightLayout->addWidget( mRightFrame, 10 ); 348 rightLayout->addWidget( mRightFrame, 10 );
349 349
350 //mLeftFrame = (QWidget *)leftFrame; 350 //mLeftFrame = (QWidget *)leftFrame;
351 if ( KOPrefs::instance()->mVerticalScreen ) { 351 if ( KOPrefs::instance()->mVerticalScreen ) {
352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
356 } else { 356 } else {
357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
360 } 360 }
361 if ( !KOPrefs::instance()->mShowDateNavigator) 361 if ( !KOPrefs::instance()->mShowDateNavigator)
362 mDateNavigator->hide(); 362 mDateNavigator->hide();
363 //qDebug("Calendarview Size %d %d ", width(), height()); 363 //qDebug("Calendarview Size %d %d ", width(), height());
364#endif 364#endif
365 365
366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
367 SLOT( showDates( const KCal::DateList & ) ) ); 367 SLOT( showDates( const KCal::DateList & ) ) );
368 368
369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 371
372 372
373 373
374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
375 mViewManager, SLOT( showMonth( const QDate & ) ) ); 375 mViewManager, SLOT( showMonth( const QDate & ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
378 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 378 mNavigator, SLOT( selectWeek( const QDate & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( goPrevYear() ), 380 connect( mDateNavigator, SIGNAL( goPrevYear() ),
381 mNavigator, SLOT( selectPreviousYear() ) ); 381 mNavigator, SLOT( selectPreviousYear() ) );
382 connect( mDateNavigator, SIGNAL( goNextYear() ), 382 connect( mDateNavigator, SIGNAL( goNextYear() ),
383 mNavigator, SLOT( selectNextYear() ) ); 383 mNavigator, SLOT( selectNextYear() ) );
384 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 384 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
385 mNavigator, SLOT( selectPreviousMonth() ) ); 385 mNavigator, SLOT( selectPreviousMonth() ) );
386 connect( mDateNavigator, SIGNAL( goNextMonth() ), 386 connect( mDateNavigator, SIGNAL( goNextMonth() ),
387 mNavigator, SLOT( selectNextMonth() ) ); 387 mNavigator, SLOT( selectNextMonth() ) );
388 388
389 connect( mDateNavigator, SIGNAL( goPrevious() ), 389 connect( mDateNavigator, SIGNAL( goPrevious() ),
390 mNavigator, SLOT( selectPrevious() ) ); 390 mNavigator, SLOT( selectPrevious() ) );
391 connect( mDateNavigator, SIGNAL( goNext() ), 391 connect( mDateNavigator, SIGNAL( goNext() ),
392 mNavigator, SLOT( selectNext() ) ); 392 mNavigator, SLOT( selectNext() ) );
393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
394 mNavigator, SLOT( slotMonthSelect( int ) ) ); 394 mNavigator, SLOT( slotMonthSelect( int ) ) );
395 395
396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
398#if 0 398#if 0
399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
400 SLOT( incidenceAdded( Incidence *) ) ); 400 SLOT( incidenceAdded( Incidence *) ) );
401#endif 401#endif
402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
403 403
404 connect( this, SIGNAL( configChanged() ), 404 connect( this, SIGNAL( configChanged() ),
405 mDateNavigator, SLOT( updateConfig() ) ); 405 mDateNavigator, SLOT( updateConfig() ) );
406 406
407 connect( mTodoList, SIGNAL( newTodoSignal() ), 407 connect( mTodoList, SIGNAL( newTodoSignal() ),
408 SLOT( newTodo() ) ); 408 SLOT( newTodo() ) );
409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
410 SLOT( newSubTodo( Todo * ) ) ); 410 SLOT( newSubTodo( Todo * ) ) );
411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
412 SLOT( editTodo( Todo * ) ) ); 412 SLOT( editTodo( Todo * ) ) );
413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
414 SLOT( showTodo( Todo *) ) ); 414 SLOT( showTodo( Todo *) ) );
415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
416 SLOT( deleteTodo( Todo *) ) ); 416 SLOT( deleteTodo( Todo *) ) );
417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
419 SLOT( purgeCompleted() ) ); 419 SLOT( purgeCompleted() ) );
420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
421 SIGNAL( todoModified( Todo *, int ) ) ); 421 SIGNAL( todoModified( Todo *, int ) ) );
422 422
423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
424 this, SLOT ( cloneIncidence( Incidence * ) ) ); 424 this, SLOT ( cloneIncidence( Incidence * ) ) );
425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
426 this, SLOT (cancelIncidence( Incidence * ) ) ); 426 this, SLOT (cancelIncidence( Incidence * ) ) );
427 427
428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
429 this, SLOT ( moveIncidence( Incidence * ) ) ); 429 this, SLOT ( moveIncidence( Incidence * ) ) );
430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
431 this, SLOT ( beamIncidence( Incidence * ) ) ); 431 this, SLOT ( beamIncidence( Incidence * ) ) );
432 432
433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
434 this, SLOT ( todo_unsub( Todo * ) ) ); 434 this, SLOT ( todo_unsub( Todo * ) ) );
435 435
436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
437 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 437 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
439 SLOT( updateTodo( Todo *, int ) ) ); 439 SLOT( updateTodo( Todo *, int ) ) );
440 connect( this, SIGNAL( todoModified( Todo *, int )), this, 440 connect( this, SIGNAL( todoModified( Todo *, int )), this,
441 SLOT( changeTodoDisplay( Todo *, int ) ) ); 441 SLOT( changeTodoDisplay( Todo *, int ) ) );
442 442
443 443
444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
448 448
449 449
450 450
451 451
452 452
453 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 453 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
454 SLOT(checkClipboard())); 454 SLOT(checkClipboard()));
455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
456 SLOT( processTodoListSelection( Incidence * ) ) ); 456 SLOT( processTodoListSelection( Incidence * ) ) );
457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
458 458
459 // kdDebug() << "CalendarView::CalendarView() done" << endl; 459 // kdDebug() << "CalendarView::CalendarView() done" << endl;
460 460
461 mDateFrame = new QVBox(0,0,WType_Popup); 461 mDateFrame = new QVBox(0,0,WType_Popup);
462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
464 mDateFrame->setLineWidth(3); 464 mDateFrame->setLineWidth(3);
465 mDateFrame->hide(); 465 mDateFrame->hide();
466 mDateFrame->setCaption( i18n( "Pick a date to display")); 466 mDateFrame->setCaption( i18n( "Pick a date to display"));
467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
468 468
469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
470 470
471 mEventEditor = mDialogManager->getEventEditor(); 471 mEventEditor = mDialogManager->getEventEditor();
472 mTodoEditor = mDialogManager->getTodoEditor(); 472 mTodoEditor = mDialogManager->getTodoEditor();
473 473
474 mFlagEditDescription = false; 474 mFlagEditDescription = false;
475 475
476 mSuspendTimer = new QTimer( this ); 476 mSuspendTimer = new QTimer( this );
477 mAlarmTimer = new QTimer( this ); 477 mAlarmTimer = new QTimer( this );
478 mRecheckAlarmTimer = new QTimer( this ); 478 mRecheckAlarmTimer = new QTimer( this );
479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
482 mAlarmDialog = new AlarmDialog( this ); 482 mAlarmDialog = new AlarmDialog( this );
483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
484 mAlarmDialog->setServerNotification( false ); 484 mAlarmDialog->setServerNotification( false );
485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
486 486
487 487
488#ifndef DESKTOP_VERSION 488#ifndef DESKTOP_VERSION
489//US listen for arriving address resultsets 489//US listen for arriving address resultsets
490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
492#endif 492#endif
493 mDateNavigator->setCalendar( mCalendar ); 493 mDateNavigator->setCalendar( mCalendar );
494} 494}
495 495
496 496
497CalendarView::~CalendarView() 497CalendarView::~CalendarView()
498{ 498{
499 // kdDebug() << "~CalendarView()" << endl; 499 // kdDebug() << "~CalendarView()" << endl;
500 //qDebug("CalendarView::~CalendarView() "); 500 //qDebug("CalendarView::~CalendarView() ");
501 delete mDialogManager; 501 delete mDialogManager;
502 delete mViewManager; 502 delete mViewManager;
503 delete mStorage; 503 delete mStorage;
504 delete mDateFrame ; 504 delete mDateFrame ;
505 delete beamDialog; 505 delete beamDialog;
506 delete mEventViewerDialog; 506 delete mEventViewerDialog;
507 //kdDebug() << "~CalendarView() done" << endl; 507 //kdDebug() << "~CalendarView() done" << endl;
508} 508}
509 509
510void CalendarView::showDay( QDate d ) 510void CalendarView::showDay( QDate d )
511{ 511{
512 dateNavigator()->blockSignals( true ); 512 dateNavigator()->blockSignals( true );
513 dateNavigator()->selectDate( d ); 513 dateNavigator()->selectDate( d );
514 dateNavigator()->blockSignals( false ); 514 dateNavigator()->blockSignals( false );
515 mViewManager->showDayView(); 515 mViewManager->showDayView();
516 //dateNavigator()->selectDate( d ); 516 //dateNavigator()->selectDate( d );
517} 517}
518void CalendarView::timerAlarm() 518void CalendarView::timerAlarm()
519{ 519{
520 //qDebug("CalendarView::timerAlarm() "); 520 //qDebug("CalendarView::timerAlarm() ");
521 computeAlarm(mAlarmNotification ); 521 computeAlarm(mAlarmNotification );
522} 522}
523 523
524void CalendarView::suspendAlarm() 524void CalendarView::suspendAlarm()
525{ 525{
526 //qDebug(" CalendarView::suspendAlarm() "); 526 //qDebug(" CalendarView::suspendAlarm() ");
527 computeAlarm(mSuspendAlarmNotification ); 527 computeAlarm(mSuspendAlarmNotification );
528 528
529} 529}
530 530
531void CalendarView::startAlarm( QString mess , QString filename) 531void CalendarView::startAlarm( QString mess , QString filename)
532{ 532{
533 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 533 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
534 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 534 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
535 535
536} 536}
537 537
538void CalendarView::checkNextTimerAlarm() 538void CalendarView::checkNextTimerAlarm()
539{ 539{
540 mCalendar->checkAlarmForIncidence( 0, true ); 540 mCalendar->checkAlarmForIncidence( 0, true );
541} 541}
542 542
543void CalendarView::computeAlarm( QString msg ) 543void CalendarView::computeAlarm( QString msg )
544{ 544{
545 545
546 QString mess = msg; 546 QString mess = msg;
547 QString mAlarmMessage = mess.mid( 9 ); 547 QString mAlarmMessage = mess.mid( 9 );
548 QString filename = MainWindow::resourcePath(); 548 QString filename = MainWindow::resourcePath();
549 filename += "koalarm.wav"; 549 filename += "koalarm.wav";
550 QString tempfilename; 550 QString tempfilename;
551 if ( mess.left( 13 ) == "suspend_alarm") { 551 if ( mess.left( 13 ) == "suspend_alarm") {
552 bool error = false; 552 bool error = false;
553 int len = mess.mid( 13 ).find("+++"); 553 int len = mess.mid( 13 ).find("+++");
554 if ( len < 2 ) 554 if ( len < 2 )
555 error = true; 555 error = true;
556 else { 556 else {
557 tempfilename = mess.mid( 13, len ); 557 tempfilename = mess.mid( 13, len );
558 if ( !QFile::exists( tempfilename ) ) 558 if ( !QFile::exists( tempfilename ) )
559 error = true; 559 error = true;
560 } 560 }
561 if ( ! error ) { 561 if ( ! error ) {
562 filename = tempfilename; 562 filename = tempfilename;
563 } 563 }
564 mAlarmMessage = mess.mid( 13+len+3 ); 564 mAlarmMessage = mess.mid( 13+len+3 );
565 //qDebug("suspend file %s ",tempfilename.latin1() ); 565 //qDebug("suspend file %s ",tempfilename.latin1() );
566 startAlarm( mAlarmMessage, filename); 566 startAlarm( mAlarmMessage, filename);
567 return; 567 return;
568 } 568 }
569 if ( mess.left( 11 ) == "timer_alarm") { 569 if ( mess.left( 11 ) == "timer_alarm") {
570 //mTimerTime = 0; 570 //mTimerTime = 0;
571 startAlarm( mess.mid( 11 ), filename ); 571 startAlarm( mess.mid( 11 ), filename );
572 return; 572 return;
573 } 573 }
574 if ( mess.left( 10 ) == "proc_alarm") { 574 if ( mess.left( 10 ) == "proc_alarm") {
575 bool error = false; 575 bool error = false;
576 int len = mess.mid( 10 ).find("+++"); 576 int len = mess.mid( 10 ).find("+++");
577 if ( len < 2 ) 577 if ( len < 2 )
578 error = true; 578 error = true;
579 else { 579 else {
580 tempfilename = mess.mid( 10, len ); 580 tempfilename = mess.mid( 10, len );
581 if ( !QFile::exists( tempfilename ) ) 581 if ( !QFile::exists( tempfilename ) )
582 error = true; 582 error = true;
583 } 583 }
584 if ( error ) { 584 if ( error ) {
585 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 585 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
586 mAlarmMessage += mess.mid( 10+len+3+9 ); 586 mAlarmMessage += mess.mid( 10+len+3+9 );
587 } else { 587 } else {
588 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 588 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
589 //qDebug("-----system command %s ",tempfilename.latin1() ); 589 //qDebug("-----system command %s ",tempfilename.latin1() );
590#ifndef _WIN32_ 590#ifndef _WIN32_
591 if ( vfork () == 0 ) { 591 if ( vfork () == 0 ) {
592 execl ( tempfilename.latin1(), 0 ); 592 execl ( tempfilename.latin1(), 0 );
593 return; 593 return;
594 } 594 }
595#else 595#else
596 QProcess* p = new QProcess(); 596 QProcess* p = new QProcess();
597 p->addArgument( tempfilename.latin1() ); 597 p->addArgument( tempfilename.latin1() );
598 p->start(); 598 p->start();
599 return; 599 return;
600#endif 600#endif
601 601
602 return; 602 return;
603 } 603 }
604 604
605 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 605 //qDebug("+++++++system command %s ",tempfilename.latin1() );
606 } 606 }
607 if ( mess.left( 11 ) == "audio_alarm") { 607 if ( mess.left( 11 ) == "audio_alarm") {
608 bool error = false; 608 bool error = false;
609 int len = mess.mid( 11 ).find("+++"); 609 int len = mess.mid( 11 ).find("+++");
610 if ( len < 2 ) 610 if ( len < 2 )
611 error = true; 611 error = true;
612 else { 612 else {
613 tempfilename = mess.mid( 11, len ); 613 tempfilename = mess.mid( 11, len );
614 if ( !QFile::exists( tempfilename ) ) 614 if ( !QFile::exists( tempfilename ) )
615 error = true; 615 error = true;
616 } 616 }
617 if ( ! error ) { 617 if ( ! error ) {
618 filename = tempfilename; 618 filename = tempfilename;
619 } 619 }
620 mAlarmMessage = mess.mid( 11+len+3+9 ); 620 mAlarmMessage = mess.mid( 11+len+3+9 );
621 //qDebug("audio file command %s ",tempfilename.latin1() ); 621 //qDebug("audio file command %s ",tempfilename.latin1() );
622 } 622 }
623 if ( mess.left( 9 ) == "cal_alarm") { 623 if ( mess.left( 9 ) == "cal_alarm") {
624 mAlarmMessage = mess.mid( 9 ) ; 624 mAlarmMessage = mess.mid( 9 ) ;
625 } 625 }
626 626
627 startAlarm( mAlarmMessage, filename ); 627 startAlarm( mAlarmMessage, filename );
628 628
629 629
630} 630}
631 631
632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
633{ 633{
634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 635
636 mSuspendAlarmNotification = noti; 636 mSuspendAlarmNotification = noti;
637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
639 mSuspendTimer->start( ms , true ); 639 mSuspendTimer->start( ms , true );
640 640
641} 641}
642 642
643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
644{ 644{
645 mNextAlarmDateTime = qdt; 645 mNextAlarmDateTime = qdt;
646 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 646 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
647 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 647 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
648#ifndef DESKTOP_VERSION 648#ifndef DESKTOP_VERSION
649 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 649 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
650#endif 650#endif
651 return; 651 return;
652 } 652 }
653 int maxSec; 653 int maxSec;
654 //maxSec = 5; //testing only 654 //maxSec = 5; //testing only
655 maxSec = 86400+3600; // one day+1hour 655 maxSec = 86400+3600; // one day+1hour
656 mAlarmNotification = noti; 656 mAlarmNotification = noti;
657 int sec = QDateTime::currentDateTime().secsTo( qdt ); 657 int sec = QDateTime::currentDateTime().secsTo( qdt );
658 if ( sec > maxSec ) { 658 if ( sec > maxSec ) {
659 mRecheckAlarmTimer->start( maxSec * 1000 ); 659 mRecheckAlarmTimer->start( maxSec * 1000 );
660 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 660 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
661 return; 661 return;
662 } else { 662 } else {
663 mRecheckAlarmTimer->stop(); 663 mRecheckAlarmTimer->stop();
664 } 664 }
665 //qDebug("Alarm timer started with secs: %d ", sec); 665 //qDebug("Alarm timer started with secs: %d ", sec);
666 mAlarmTimer->start( sec *1000 , true ); 666 mAlarmTimer->start( sec *1000 , true );
667 667
668} 668}
669// called by mRecheckAlarmTimer to get next alarm 669// called by mRecheckAlarmTimer to get next alarm
670// we need this, because a QTimer has only a max range of 25 days 670// we need this, because a QTimer has only a max range of 25 days
671void CalendarView::recheckTimerAlarm() 671void CalendarView::recheckTimerAlarm()
672{ 672{
673 mAlarmTimer->stop(); 673 mAlarmTimer->stop();
674 mRecheckAlarmTimer->stop(); 674 mRecheckAlarmTimer->stop();
675 mCalendar->checkAlarmForIncidence( 0, true ); 675 mCalendar->checkAlarmForIncidence( 0, true );
676} 676}
677void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 677void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
678{ 678{
679 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 679 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
680 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 680 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
681#ifndef DESKTOP_VERSION 681#ifndef DESKTOP_VERSION
682 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 682 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
683#endif 683#endif
684 return; 684 return;
685 } 685 }
686 mAlarmTimer->stop(); 686 mAlarmTimer->stop();
687} 687}
688void CalendarView::selectWeekNum ( int num ) 688void CalendarView::selectWeekNum ( int num )
689{ 689{
690 dateNavigator()->blockSignals( true ); 690 dateNavigator()->blockSignals( true );
691 dateNavigator()->selectWeek( num ); 691 dateNavigator()->selectWeek( num );
692 dateNavigator()->blockSignals( false ); 692 dateNavigator()->blockSignals( false );
693 mViewManager->showWeekView(); 693 mViewManager->showWeekView();
694} 694}
695KOViewManager *CalendarView::viewManager() 695KOViewManager *CalendarView::viewManager()
696{ 696{
697 return mViewManager; 697 return mViewManager;
698} 698}
699 699
700KODialogManager *CalendarView::dialogManager() 700KODialogManager *CalendarView::dialogManager()
701{ 701{
702 return mDialogManager; 702 return mDialogManager;
703} 703}
704 704
705QDate CalendarView::startDate() 705QDate CalendarView::startDate()
706{ 706{
707 DateList dates = mNavigator->selectedDates(); 707 DateList dates = mNavigator->selectedDates();
708 708
709 return dates.first(); 709 return dates.first();
710} 710}
711 711
712QDate CalendarView::endDate() 712QDate CalendarView::endDate()
713{ 713{
714 DateList dates = mNavigator->selectedDates(); 714 DateList dates = mNavigator->selectedDates();
715 715
716 return dates.last(); 716 return dates.last();
717} 717}
718 718
719 719
720void CalendarView::createPrinter() 720void CalendarView::createPrinter()
721{ 721{
722#ifndef KORG_NOPRINTER 722#ifndef KORG_NOPRINTER
723 if (!mCalPrinter) { 723 if (!mCalPrinter) {
724 mCalPrinter = new CalPrinter(this, mCalendar); 724 mCalPrinter = new CalPrinter(this, mCalendar);
725 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 725 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
726 } 726 }
727#endif 727#endif
728} 728}
729 729
730 730
731//KOPrefs::instance()->mWriteBackFile 731//KOPrefs::instance()->mWriteBackFile
732//KOPrefs::instance()->mWriteBackExistingOnly 732//KOPrefs::instance()->mWriteBackExistingOnly
733 733
734// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 734// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
735// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 735// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
736// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 736// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
737// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 737// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
738// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 738// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
739// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 739// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
740 740
741int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 741int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
742{ 742{
743 743
744 // 0 equal 744 // 0 equal
745 // 1 take local 745 // 1 take local
746 // 2 take remote 746 // 2 take remote
747 // 3 cancel 747 // 3 cancel
748 QDateTime lastSync = mLastCalendarSync; 748 QDateTime lastSync = mLastCalendarSync;
749 QDateTime localMod = local->lastModified(); 749 QDateTime localMod = local->lastModified();
750 QDateTime remoteMod = remote->lastModified(); 750 QDateTime remoteMod = remote->lastModified();
751 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 751 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
752 bool remCh, locCh; 752 bool remCh, locCh;
753 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 753 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
754 //if ( remCh ) 754 //if ( remCh )
755 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 755 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
756 locCh = ( localMod > mLastCalendarSync ); 756 locCh = ( localMod > mLastCalendarSync );
757 if ( !remCh && ! locCh ) { 757 if ( !remCh && ! locCh ) {
758 //qDebug("both not changed "); 758 //qDebug("both not changed ");
759 lastSync = localMod.addDays(1); 759 lastSync = localMod.addDays(1);
760 if ( mode <= SYNC_PREF_ASK ) 760 if ( mode <= SYNC_PREF_ASK )
761 return 0; 761 return 0;
762 } else { 762 } else {
763 if ( locCh ) { 763 if ( locCh ) {
764 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 764 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
765 lastSync = localMod.addDays( -1 ); 765 lastSync = localMod.addDays( -1 );
766 if ( !remCh ) 766 if ( !remCh )
767 remoteMod = ( lastSync.addDays( -1 ) ); 767 remoteMod = ( lastSync.addDays( -1 ) );
768 } else { 768 } else {
769 //qDebug(" not loc changed "); 769 //qDebug(" not loc changed ");
770 lastSync = localMod.addDays( 1 ); 770 lastSync = localMod.addDays( 1 );
771 if ( remCh ) 771 if ( remCh )
772 remoteMod =( lastSync.addDays( 1 ) ); 772 remoteMod =( lastSync.addDays( 1 ) );
773 773
774 } 774 }
775 } 775 }
776 full = true; 776 full = true;
777 if ( mode < SYNC_PREF_ASK ) 777 if ( mode < SYNC_PREF_ASK )
778 mode = SYNC_PREF_ASK; 778 mode = SYNC_PREF_ASK;
779 } else { 779 } else {
780 if ( localMod == remoteMod ) 780 if ( localMod == remoteMod )
781 // if ( local->revision() == remote->revision() ) 781 // if ( local->revision() == remote->revision() )
782 return 0; 782 return 0;
783 783
784 } 784 }
785 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 785 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
786 786
787 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 787 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
788 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 788 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
789 //full = true; //debug only 789 //full = true; //debug only
790 if ( full ) { 790 if ( full ) {
791 bool equ = false; 791 bool equ = false;
792 if ( local->type() == "Event" ) { 792 if ( local->type() == "Event" ) {
793 equ = (*((Event*) local) == *((Event*) remote)); 793 equ = (*((Event*) local) == *((Event*) remote));
794 } 794 }
795 else if ( local->type() =="Todo" ) 795 else if ( local->type() =="Todo" )
796 equ = (*((Todo*) local) == (*(Todo*) remote)); 796 equ = (*((Todo*) local) == (*(Todo*) remote));
797 else if ( local->type() =="Journal" ) 797 else if ( local->type() =="Journal" )
798 equ = (*((Journal*) local) == *((Journal*) remote)); 798 equ = (*((Journal*) local) == *((Journal*) remote));
799 if ( equ ) { 799 if ( equ ) {
800 //qDebug("equal "); 800 //qDebug("equal ");
801 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 801 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
802 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 802 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
803 } 803 }
804 if ( mode < SYNC_PREF_FORCE_LOCAL ) 804 if ( mode < SYNC_PREF_FORCE_LOCAL )
805 return 0; 805 return 0;
806 806
807 }//else //debug only 807 }//else //debug only
808 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 808 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
809 } 809 }
810 int result; 810 int result;
811 bool localIsNew; 811 bool localIsNew;
812 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 812 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
813 813
814 if ( full && mode < SYNC_PREF_NEWEST ) 814 if ( full && mode < SYNC_PREF_NEWEST )
815 mode = SYNC_PREF_ASK; 815 mode = SYNC_PREF_ASK;
816 816
817 switch( mode ) { 817 switch( mode ) {
818 case SYNC_PREF_LOCAL: 818 case SYNC_PREF_LOCAL:
819 if ( lastSync > remoteMod ) 819 if ( lastSync > remoteMod )
820 return 1; 820 return 1;
821 if ( lastSync > localMod ) 821 if ( lastSync > localMod )
822 return 2; 822 return 2;
823 return 1; 823 return 1;
824 break; 824 break;
825 case SYNC_PREF_REMOTE: 825 case SYNC_PREF_REMOTE:
826 if ( lastSync > remoteMod ) 826 if ( lastSync > remoteMod )
827 return 1; 827 return 1;
828 if ( lastSync > localMod ) 828 if ( lastSync > localMod )
829 return 2; 829 return 2;
830 return 2; 830 return 2;
831 break; 831 break;
832 case SYNC_PREF_NEWEST: 832 case SYNC_PREF_NEWEST:
833 if ( localMod > remoteMod ) 833 if ( localMod > remoteMod )
834 return 1; 834 return 1;
835 else 835 else
836 return 2; 836 return 2;
837 break; 837 break;
838 case SYNC_PREF_ASK: 838 case SYNC_PREF_ASK:
839 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 839 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
840 if ( lastSync > remoteMod ) 840 if ( lastSync > remoteMod )
841 return 1; 841 return 1;
842 if ( lastSync > localMod ) 842 if ( lastSync > localMod )
843 return 2; 843 return 2;
844 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 844 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
845 localIsNew = localMod >= remoteMod; 845 localIsNew = localMod >= remoteMod;
846 if ( localIsNew ) 846 if ( localIsNew )
847 getEventViewerDialog()->setColorMode( 1 ); 847 getEventViewerDialog()->setColorMode( 1 );
848 else 848 else
849 getEventViewerDialog()->setColorMode( 2 ); 849 getEventViewerDialog()->setColorMode( 2 );
850 getEventViewerDialog()->setIncidence(local); 850 getEventViewerDialog()->setIncidence(local);
851 if ( localIsNew ) 851 if ( localIsNew )
852 getEventViewerDialog()->setColorMode( 2 ); 852 getEventViewerDialog()->setColorMode( 2 );
853 else 853 else
854 getEventViewerDialog()->setColorMode( 1 ); 854 getEventViewerDialog()->setColorMode( 1 );
855 getEventViewerDialog()->addIncidence(remote); 855 getEventViewerDialog()->addIncidence(remote);
856 getEventViewerDialog()->setColorMode( 0 ); 856 getEventViewerDialog()->setColorMode( 0 );
857 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 857 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
858 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 858 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
859 getEventViewerDialog()->showMe(); 859 getEventViewerDialog()->showMe();
860 result = getEventViewerDialog()->executeS( localIsNew ); 860 result = getEventViewerDialog()->executeS( localIsNew );
861 return result; 861 return result;
862 862
863 break; 863 break;
864 case SYNC_PREF_FORCE_LOCAL: 864 case SYNC_PREF_FORCE_LOCAL:
865 return 1; 865 return 1;
866 break; 866 break;
867 case SYNC_PREF_FORCE_REMOTE: 867 case SYNC_PREF_FORCE_REMOTE:
868 return 2; 868 return 2;
869 break; 869 break;
870 870
871 default: 871 default:
872 // SYNC_PREF_TAKE_BOTH not implemented 872 // SYNC_PREF_TAKE_BOTH not implemented
873 break; 873 break;
874 } 874 }
875 return 0; 875 return 0;
876} 876}
877Event* CalendarView::getLastSyncEvent() 877Event* CalendarView::getLastSyncEvent()
878{ 878{
879 Event* lse; 879 Event* lse;
880 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 880 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
881 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 881 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
882 if (!lse) { 882 if (!lse) {
883 lse = new Event(); 883 lse = new Event();
884 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 884 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
885 QString sum = ""; 885 QString sum = "";
886 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 886 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
887 sum = "E: "; 887 sum = "E: ";
888 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 888 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
889 lse->setDtStart( mLastCalendarSync ); 889 lse->setDtStart( mLastCalendarSync );
890 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 890 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
891 lse->setCategories( i18n("SyncEvent") ); 891 lse->setCategories( i18n("SyncEvent") );
892 lse->setReadOnly( true ); 892 lse->setReadOnly( true );
893 mCalendar->addEvent( lse ); 893 mCalendar->addEvent( lse );
894 } 894 }
895 895
896 return lse; 896 return lse;
897 897
898} 898}
899 899
900// we check, if the to delete event has a id for a profile 900// we check, if the to delete event has a id for a profile
901// if yes, we set this id in the profile to delete 901// if yes, we set this id in the profile to delete
902void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 902void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
903{ 903{
904 if ( lastSync.count() == 0 ) { 904 if ( lastSync.count() == 0 ) {
905 //qDebug(" lastSync.count() == 0"); 905 //qDebug(" lastSync.count() == 0");
906 return; 906 return;
907 } 907 }
908 if ( toDelete->type() == "Journal" ) 908 if ( toDelete->type() == "Journal" )
909 return; 909 return;
910 910
911 Event* eve = lastSync.first(); 911 Event* eve = lastSync.first();
912 912
913 while ( eve ) { 913 while ( eve ) {
914 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 914 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
915 if ( !id.isEmpty() ) { 915 if ( !id.isEmpty() ) {
916 QString des = eve->description(); 916 QString des = eve->description();
917 QString pref = "e"; 917 QString pref = "e";
918 if ( toDelete->type() == "Todo" ) 918 if ( toDelete->type() == "Todo" )
919 pref = "t"; 919 pref = "t";
920 des += pref+ id + ","; 920 des += pref+ id + ",";
921 eve->setReadOnly( false ); 921 eve->setReadOnly( false );
922 eve->setDescription( des ); 922 eve->setDescription( des );
923 //qDebug("setdes %s ", des.latin1()); 923 //qDebug("setdes %s ", des.latin1());
924 eve->setReadOnly( true ); 924 eve->setReadOnly( true );
925 } 925 }
926 eve = lastSync.next(); 926 eve = lastSync.next();
927 } 927 }
928 928
929} 929}
930void CalendarView::checkExternalId( Incidence * inc ) 930void CalendarView::checkExternalId( Incidence * inc )
931{ 931{
932 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 932 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
933 checkExternSyncEvent( lastSync, inc ); 933 checkExternSyncEvent( lastSync, inc );
934 934
935} 935}
936bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 936bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
937{ 937{
938 bool syncOK = true; 938 bool syncOK = true;
939 int addedEvent = 0; 939 int addedEvent = 0;
940 int addedEventR = 0; 940 int addedEventR = 0;
941 int deletedEventR = 0; 941 int deletedEventR = 0;
942 int deletedEventL = 0; 942 int deletedEventL = 0;
943 int changedLocal = 0; 943 int changedLocal = 0;
944 int changedRemote = 0; 944 int changedRemote = 0;
945 int filteredIN = 0; 945 int filteredIN = 0;
946 int filteredOUT = 0; 946 int filteredOUT = 0;
947 //QPtrList<Event> el = local->rawEvents(); 947 //QPtrList<Event> el = local->rawEvents();
948 Event* eventR; 948 Event* eventR;
949 QString uid; 949 QString uid;
950 int take; 950 int take;
951 Event* eventL; 951 Event* eventL;
952 Event* eventRSync; 952 Event* eventRSync;
953 Event* eventLSync; 953 Event* eventLSync;
954 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 954 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
955 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 955 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
956 bool fullDateRange = false; 956 bool fullDateRange = false;
957 local->resetTempSyncStat(); 957 local->resetTempSyncStat();
958 mLastCalendarSync = QDateTime::currentDateTime(); 958 mLastCalendarSync = QDateTime::currentDateTime();
959 if ( mSyncManager->syncWithDesktop() ) { 959 if ( mSyncManager->syncWithDesktop() ) {
960 remote->resetPilotStat(1); 960 remote->resetPilotStat(1);
961 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 961 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
962 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 962 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
963 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 963 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
964 } else { 964 } else {
965 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 965 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
966 } 966 }
967 } 967 }
968 QDateTime modifiedCalendar = mLastCalendarSync; 968 QDateTime modifiedCalendar = mLastCalendarSync;
969 eventLSync = getLastSyncEvent(); 969 eventLSync = getLastSyncEvent();
970 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 970 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
971 if ( eventR ) { 971 if ( eventR ) {
972 eventRSync = (Event*) eventR->clone(); 972 eventRSync = (Event*) eventR->clone();
973 remote->deleteEvent(eventR ); 973 remote->deleteEvent(eventR );
974 974
975 } else { 975 } else {
976 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 976 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
977 eventRSync = (Event*)eventLSync->clone(); 977 eventRSync = (Event*)eventLSync->clone();
978 } else { 978 } else {
979 fullDateRange = true; 979 fullDateRange = true;
980 eventRSync = new Event(); 980 eventRSync = new Event();
981 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 981 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
982 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 982 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
983 eventRSync->setDtStart( mLastCalendarSync ); 983 eventRSync->setDtStart( mLastCalendarSync );
984 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 984 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
985 eventRSync->setCategories( i18n("SyncEvent") ); 985 eventRSync->setCategories( i18n("SyncEvent") );
986 } 986 }
987 } 987 }
988 if ( eventLSync->dtStart() == mLastCalendarSync ) 988 if ( eventLSync->dtStart() == mLastCalendarSync )
989 fullDateRange = true; 989 fullDateRange = true;
990 990
991 if ( ! fullDateRange ) { 991 if ( ! fullDateRange ) {
992 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 992 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
993 993
994 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 994 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
995 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 995 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
996 fullDateRange = true; 996 fullDateRange = true;
997 } 997 }
998 } 998 }
999 if ( mSyncManager->syncWithDesktop() ) { 999 if ( mSyncManager->syncWithDesktop() ) {
1000 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1000 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1001 } 1001 }
1002 if ( fullDateRange ) 1002 if ( fullDateRange )
1003 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1003 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1004 else 1004 else
1005 mLastCalendarSync = eventLSync->dtStart(); 1005 mLastCalendarSync = eventLSync->dtStart();
1006 // for resyncing if own file has changed 1006 // for resyncing if own file has changed
1007 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1007 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1008 mLastCalendarSync = loadedFileVersion; 1008 mLastCalendarSync = loadedFileVersion;
1009 //qDebug("setting mLastCalendarSync "); 1009 //qDebug("setting mLastCalendarSync ");
1010 } 1010 }
1011 //qDebug("*************************** "); 1011 //qDebug("*************************** ");
1012 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1012 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1013 QPtrList<Incidence> er = remote->rawIncidences(); 1013 QPtrList<Incidence> er = remote->rawIncidences();
1014 Incidence* inR = er.first(); 1014 Incidence* inR = er.first();
1015 Incidence* inL; 1015 Incidence* inL;
1016 QProgressBar bar( er.count(),0 ); 1016 QProgressBar bar( er.count(),0 );
1017 bar.setCaption (i18n("Syncing - close to abort!") ); 1017 bar.setCaption (i18n("Syncing - close to abort!") );
1018 1018
1019 // ************** setting up filter ************* 1019 // ************** setting up filter *************
1020 CalFilter *filterIN = 0; 1020 CalFilter *filterIN = 0;
1021 CalFilter *filterOUT = 0; 1021 CalFilter *filterOUT = 0;
1022 CalFilter *filter = mFilters.first(); 1022 CalFilter *filter = mFilters.first();
1023 while(filter) { 1023 while(filter) {
1024 if ( filter->name() == mSyncManager->mFilterInCal ) 1024 if ( filter->name() == mSyncManager->mFilterInCal )
1025 filterIN = filter; 1025 filterIN = filter;
1026 if ( filter->name() == mSyncManager->mFilterOutCal ) 1026 if ( filter->name() == mSyncManager->mFilterOutCal )
1027 filterOUT = filter; 1027 filterOUT = filter;
1028 filter = mFilters.next(); 1028 filter = mFilters.next();
1029 } 1029 }
1030 int w = 300; 1030 int w = 300;
1031 if ( QApplication::desktop()->width() < 320 ) 1031 if ( QApplication::desktop()->width() < 320 )
1032 w = 220; 1032 w = 220;
1033 int h = bar.sizeHint().height() ; 1033 int h = bar.sizeHint().height() ;
1034 int dw = QApplication::desktop()->width(); 1034 int dw = QApplication::desktop()->width();
1035 int dh = QApplication::desktop()->height(); 1035 int dh = QApplication::desktop()->height();
1036 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1036 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1037 bar.show(); 1037 bar.show();
1038 int modulo = (er.count()/10)+1; 1038 int modulo = (er.count()/10)+1;
1039 int incCounter = 0; 1039 int incCounter = 0;
1040 while ( inR ) { 1040 while ( inR ) {
1041 if ( ! bar.isVisible() ) 1041 if ( ! bar.isVisible() )
1042 return false; 1042 return false;
1043 if ( incCounter % modulo == 0 ) 1043 if ( incCounter % modulo == 0 )
1044 bar.setProgress( incCounter ); 1044 bar.setProgress( incCounter );
1045 ++incCounter; 1045 ++incCounter;
1046 uid = inR->uid(); 1046 uid = inR->uid();
1047 bool skipIncidence = false; 1047 bool skipIncidence = false;
1048 if ( uid.left(15) == QString("last-syncEvent-") ) 1048 if ( uid.left(15) == QString("last-syncEvent-") )
1049 skipIncidence = true; 1049 skipIncidence = true;
1050 QString idS; 1050 QString idS;
1051 qApp->processEvents(); 1051 qApp->processEvents();
1052 if ( !skipIncidence ) { 1052 if ( !skipIncidence ) {
1053 inL = local->incidence( uid ); 1053 inL = local->incidence( uid );
1054 if ( inL ) { // maybe conflict - same uid in both calendars 1054 if ( inL ) { // maybe conflict - same uid in both calendars
1055 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1055 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1056 //qDebug("take %d %s ", take, inL->summary().latin1()); 1056 //qDebug("take %d %s ", take, inL->summary().latin1());
1057 if ( take == 3 ) 1057 if ( take == 3 )
1058 return false; 1058 return false;
1059 if ( take == 1 ) {// take local ********************** 1059 if ( take == 1 ) {// take local **********************
1060 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1060 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1061 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1061 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1062 else 1062 else
1063 idS = inR->IDStr(); 1063 idS = inR->IDStr();
1064 remote->deleteIncidence( inR ); 1064 remote->deleteIncidence( inR );
1065 inR = inL->clone(); 1065 inR = inL->clone();
1066 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1066 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1067 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1067 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1068 inR->setIDStr( idS ); 1068 inR->setIDStr( idS );
1069 remote->addIncidence( inR ); 1069 remote->addIncidence( inR );
1070 if ( mSyncManager->syncWithDesktop() ) 1070 if ( mSyncManager->syncWithDesktop() )
1071 inR->setPilotId( 2 ); 1071 inR->setPilotId( 2 );
1072 ++changedRemote; 1072 ++changedRemote;
1073 } else {// take remote ********************** 1073 } else {// take remote **********************
1074 idS = inL->IDStr(); 1074 idS = inL->IDStr();
1075 int pid = inL->pilotId(); 1075 int pid = inL->pilotId();
1076 local->deleteIncidence( inL ); 1076 local->deleteIncidence( inL );
1077 inL = inR->clone(); 1077 inL = inR->clone();
1078 if ( mSyncManager->syncWithDesktop() ) 1078 if ( mSyncManager->syncWithDesktop() )
1079 inL->setPilotId( pid ); 1079 inL->setPilotId( pid );
1080 inL->setIDStr( idS ); 1080 inL->setIDStr( idS );
1081 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1081 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1082 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1082 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1083 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1083 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1084 } 1084 }
1085 local->addIncidence( inL ); 1085 local->addIncidence( inL );
1086 ++changedLocal; 1086 ++changedLocal;
1087 } 1087 }
1088 } 1088 }
1089 } else { // no conflict ********** add or delete remote 1089 } else { // no conflict ********** add or delete remote
1090 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1090 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1091 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1091 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1092 QString des = eventLSync->description(); 1092 QString des = eventLSync->description();
1093 QString pref = "e"; 1093 QString pref = "e";
1094 if ( inR->type() == "Todo" ) 1094 if ( inR->type() == "Todo" )
1095 pref = "t"; 1095 pref = "t";
1096 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1096 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1097 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1097 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1098 //remote->deleteIncidence( inR ); 1098 //remote->deleteIncidence( inR );
1099 ++deletedEventR; 1099 ++deletedEventR;
1100 } else { 1100 } else {
1101 inR->setLastModified( modifiedCalendar ); 1101 inR->setLastModified( modifiedCalendar );
1102 inL = inR->clone(); 1102 inL = inR->clone();
1103 inL->setIDStr( ":" ); 1103 inL->setIDStr( ":" );
1104 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1104 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1105 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1105 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1106 local->addIncidence( inL ); 1106 local->addIncidence( inL );
1107 ++addedEvent; 1107 ++addedEvent;
1108 1108
1109 } 1109 }
1110 } else { 1110 } else {
1111 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1111 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1112 inR->setLastModified( modifiedCalendar ); 1112 inR->setLastModified( modifiedCalendar );
1113 inL = inR->clone(); 1113 inL = inR->clone();
1114 inL->setIDStr( ":" ); 1114 inL->setIDStr( ":" );
1115 local->addIncidence( inL ); 1115 local->addIncidence( inL );
1116 ++addedEvent; 1116 ++addedEvent;
1117 1117
1118 } else { 1118 } else {
1119 checkExternSyncEvent(eventRSyncSharp, inR); 1119 checkExternSyncEvent(eventRSyncSharp, inR);
1120 remote->deleteIncidence( inR ); 1120 remote->deleteIncidence( inR );
1121 ++deletedEventR; 1121 ++deletedEventR;
1122 } 1122 }
1123 } 1123 }
1124 } else { 1124 } else {
1125 ++filteredIN; 1125 ++filteredIN;
1126 } 1126 }
1127 } 1127 }
1128 } 1128 }
1129 inR = er.next(); 1129 inR = er.next();
1130 } 1130 }
1131 QPtrList<Incidence> el = local->rawIncidences(); 1131 QPtrList<Incidence> el = local->rawIncidences();
1132 inL = el.first(); 1132 inL = el.first();
1133 modulo = (el.count()/10)+1; 1133 modulo = (el.count()/10)+1;
1134 bar.setCaption (i18n("Add / remove events") ); 1134 bar.setCaption (i18n("Add / remove events") );
1135 bar.setTotalSteps ( el.count() ) ; 1135 bar.setTotalSteps ( el.count() ) ;
1136 bar.show(); 1136 bar.show();
1137 incCounter = 0; 1137 incCounter = 0;
1138 1138
1139 while ( inL ) { 1139 while ( inL ) {
1140 1140
1141 qApp->processEvents(); 1141 qApp->processEvents();
1142 if ( ! bar.isVisible() ) 1142 if ( ! bar.isVisible() )
1143 return false; 1143 return false;
1144 if ( incCounter % modulo == 0 ) 1144 if ( incCounter % modulo == 0 )
1145 bar.setProgress( incCounter ); 1145 bar.setProgress( incCounter );
1146 ++incCounter; 1146 ++incCounter;
1147 uid = inL->uid(); 1147 uid = inL->uid();
1148 bool skipIncidence = false; 1148 bool skipIncidence = false;
1149 if ( uid.left(15) == QString("last-syncEvent-") ) 1149 if ( uid.left(15) == QString("last-syncEvent-") )
1150 skipIncidence = true; 1150 skipIncidence = true;
1151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1152 skipIncidence = true; 1152 skipIncidence = true;
1153 if ( !skipIncidence ) { 1153 if ( !skipIncidence ) {
1154 inR = remote->incidence( uid ); 1154 inR = remote->incidence( uid );
1155 if ( ! inR ) { 1155 if ( ! inR ) {
1156 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1156 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1157 // no conflict ********** add or delete local 1157 // no conflict ********** add or delete local
1158 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1158 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1159 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1159 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1160 checkExternSyncEvent(eventLSyncSharp, inL); 1160 checkExternSyncEvent(eventLSyncSharp, inL);
1161 local->deleteIncidence( inL ); 1161 local->deleteIncidence( inL );
1162 ++deletedEventL; 1162 ++deletedEventL;
1163 } else { 1163 } else {
1164 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1164 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1165 inL->removeID(mCurrentSyncDevice ); 1165 inL->removeID(mCurrentSyncDevice );
1166 ++addedEventR; 1166 ++addedEventR;
1167 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1167 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1168 inL->setLastModified( modifiedCalendar ); 1168 inL->setLastModified( modifiedCalendar );
1169 inR = inL->clone(); 1169 inR = inL->clone();
1170 inR->setIDStr( ":" ); 1170 inR->setIDStr( ":" );
1171 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1171 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1172 remote->addIncidence( inR ); 1172 remote->addIncidence( inR );
1173 } 1173 }
1174 } 1174 }
1175 } else { 1175 } else {
1176 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1176 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1177 checkExternSyncEvent(eventLSyncSharp, inL); 1177 checkExternSyncEvent(eventLSyncSharp, inL);
1178 local->deleteIncidence( inL ); 1178 local->deleteIncidence( inL );
1179 ++deletedEventL; 1179 ++deletedEventL;
1180 } else { 1180 } else {
1181 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1181 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1182 ++addedEventR; 1182 ++addedEventR;
1183 inL->setLastModified( modifiedCalendar ); 1183 inL->setLastModified( modifiedCalendar );
1184 inR = inL->clone(); 1184 inR = inL->clone();
1185 inR->setIDStr( ":" ); 1185 inR->setIDStr( ":" );
1186 remote->addIncidence( inR ); 1186 remote->addIncidence( inR );
1187 } 1187 }
1188 } 1188 }
1189 } 1189 }
1190 } else { 1190 } else {
1191 ++filteredOUT; 1191 ++filteredOUT;
1192 } 1192 }
1193 } 1193 }
1194 } 1194 }
1195 inL = el.next(); 1195 inL = el.next();
1196 } 1196 }
1197 int delFut = 0; 1197 int delFut = 0;
1198 int remRem = 0; 1198 int remRem = 0;
1199 if ( mSyncManager->mWriteBackInFuture ) { 1199 if ( mSyncManager->mWriteBackInFuture ) {
1200 er = remote->rawIncidences(); 1200 er = remote->rawIncidences();
1201 remRem = er.count(); 1201 remRem = er.count();
1202 inR = er.first(); 1202 inR = er.first();
1203 QDateTime dt; 1203 QDateTime dt;
1204 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1204 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1205 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1205 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1206 while ( inR ) { 1206 while ( inR ) {
1207 if ( inR->type() == "Todo" ) { 1207 if ( inR->type() == "Todo" ) {
1208 Todo * t = (Todo*)inR; 1208 Todo * t = (Todo*)inR;
1209 if ( t->hasDueDate() ) 1209 if ( t->hasDueDate() )
1210 dt = t->dtDue(); 1210 dt = t->dtDue();
1211 else 1211 else
1212 dt = cur.addSecs( 62 ); 1212 dt = cur.addSecs( 62 );
1213 } 1213 }
1214 else if (inR->type() == "Event" ) { 1214 else if (inR->type() == "Event" ) {
1215 bool ok; 1215 bool ok;
1216 dt = inR->getNextOccurence( cur, &ok ); 1216 dt = inR->getNextOccurence( cur, &ok );
1217 if ( !ok ) 1217 if ( !ok )
1218 dt = cur.addSecs( -62 ); 1218 dt = cur.addSecs( -62 );
1219 } 1219 }
1220 else 1220 else
1221 dt = inR->dtStart(); 1221 dt = inR->dtStart();
1222 if ( dt < cur || dt > end ) { 1222 if ( dt < cur || dt > end ) {
1223 remote->deleteIncidence( inR ); 1223 remote->deleteIncidence( inR );
1224 ++delFut; 1224 ++delFut;
1225 } 1225 }
1226 inR = er.next(); 1226 inR = er.next();
1227 } 1227 }
1228 } 1228 }
1229 bar.hide(); 1229 bar.hide();
1230 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1230 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1231 eventLSync->setReadOnly( false ); 1231 eventLSync->setReadOnly( false );
1232 eventLSync->setDtStart( mLastCalendarSync ); 1232 eventLSync->setDtStart( mLastCalendarSync );
1233 eventRSync->setDtStart( mLastCalendarSync ); 1233 eventRSync->setDtStart( mLastCalendarSync );
1234 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1234 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1235 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1235 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1236 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1236 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1237 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1237 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1238 eventLSync->setReadOnly( true ); 1238 eventLSync->setReadOnly( true );
1239 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1239 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1240 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1240 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1241 remote->addEvent( eventRSync ); 1241 remote->addEvent( eventRSync );
1242 else 1242 else
1243 delete eventRSync; 1243 delete eventRSync;
1244 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1244 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1245 QString mes; 1245 QString mes;
1246 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1246 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1247 QString delmess; 1247 QString delmess;
1248 if ( delFut ) { 1248 if ( delFut ) {
1249 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1249 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1250 mes += delmess; 1250 mes += delmess;
1251 } 1251 }
1252 mes = i18n("Local calendar changed!\n") +mes; 1252 mes = i18n("Local calendar changed!\n") +mes;
1253 mCalendar->checkAlarmForIncidence( 0, true ); 1253 mCalendar->checkAlarmForIncidence( 0, true );
1254 qDebug( mes ); 1254 qDebug( mes );
1255 if ( mSyncManager->mShowSyncSummary ) { 1255 if ( mSyncManager->mShowSyncSummary ) {
1256 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1256 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1257 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1257 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1258 qDebug("KO: WB cancelled "); 1258 qDebug("KO: WB cancelled ");
1259 mSyncManager->mWriteBackFile = false; 1259 mSyncManager->mWriteBackFile = false;
1260 return syncOK; 1260 return syncOK;
1261 } 1261 }
1262 } 1262 }
1263 return syncOK; 1263 return syncOK;
1264} 1264}
1265 1265
1266void CalendarView::setSyncDevice( QString s ) 1266void CalendarView::setSyncDevice( QString s )
1267{ 1267{
1268 mCurrentSyncDevice= s; 1268 mCurrentSyncDevice= s;
1269} 1269}
1270void CalendarView::setSyncName( QString s ) 1270void CalendarView::setSyncName( QString s )
1271{ 1271{
1272 mCurrentSyncName= s; 1272 mCurrentSyncName= s;
1273} 1273}
1274bool CalendarView::syncCalendar(QString filename, int mode) 1274bool CalendarView::syncCalendar(QString filename, int mode)
1275{ 1275{
1276 //qDebug("syncCalendar %s ", filename.latin1()); 1276 //qDebug("syncCalendar %s ", filename.latin1());
1277 mGlobalSyncMode = SYNC_MODE_NORMAL; 1277 mGlobalSyncMode = SYNC_MODE_NORMAL;
1278 CalendarLocal* calendar = new CalendarLocal(); 1278 CalendarLocal* calendar = new CalendarLocal();
1279 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1279 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1280 FileStorage* storage = new FileStorage( calendar ); 1280 FileStorage* storage = new FileStorage( calendar );
1281 bool syncOK = false; 1281 bool syncOK = false;
1282 storage->setFileName( filename ); 1282 storage->setFileName( filename );
1283 // qDebug("loading ... "); 1283 // qDebug("loading ... ");
1284 if ( storage->load() ) { 1284 if ( storage->load() ) {
1285 getEventViewerDialog()->setSyncMode( true ); 1285 getEventViewerDialog()->setSyncMode( true );
1286 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1286 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1287 getEventViewerDialog()->setSyncMode( false ); 1287 getEventViewerDialog()->setSyncMode( false );
1288 if ( syncOK ) { 1288 if ( syncOK ) {
1289 if ( mSyncManager->mWriteBackFile ) 1289 if ( mSyncManager->mWriteBackFile )
1290 { 1290 {
1291 storage->setSaveFormat( new ICalFormat() ); 1291 storage->setSaveFormat( new ICalFormat() );
1292 storage->save(); 1292 storage->save();
1293 } 1293 }
1294 } 1294 }
1295 setModified( true ); 1295 setModified( true );
1296 } 1296 }
1297 delete storage; 1297 delete storage;
1298 delete calendar; 1298 delete calendar;
1299 if ( syncOK ) 1299 if ( syncOK )
1300 updateView(); 1300 updateView();
1301 return syncOK; 1301 return syncOK;
1302} 1302}
1303 1303
1304void CalendarView::syncExternal( int mode ) 1304void CalendarView::syncExternal( int mode )
1305{ 1305{
1306 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1306 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1307 1307
1308 qApp->processEvents(); 1308 qApp->processEvents();
1309 CalendarLocal* calendar = new CalendarLocal(); 1309 CalendarLocal* calendar = new CalendarLocal();
1310 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1310 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1311 bool syncOK = false; 1311 bool syncOK = false;
1312 bool loadSuccess = false; 1312 bool loadSuccess = false;
1313 PhoneFormat* phoneFormat = 0; 1313 PhoneFormat* phoneFormat = 0;
1314 emit tempDisableBR(true); 1314 emit tempDisableBR(true);
1315#ifndef DESKTOP_VERSION 1315#ifndef DESKTOP_VERSION
1316 SharpFormat* sharpFormat = 0; 1316 SharpFormat* sharpFormat = 0;
1317 if ( mode == 0 ) { // sharp 1317 if ( mode == 0 ) { // sharp
1318 sharpFormat = new SharpFormat () ; 1318 sharpFormat = new SharpFormat () ;
1319 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1319 loadSuccess = sharpFormat->load( calendar, mCalendar );
1320 1320
1321 } else 1321 } else
1322#endif 1322#endif
1323 if ( mode == 1 ) { // phone 1323 if ( mode == 1 ) { // phone
1324 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1324 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1325 mSyncManager->mPhoneDevice, 1325 mSyncManager->mPhoneDevice,
1326 mSyncManager->mPhoneConnection, 1326 mSyncManager->mPhoneConnection,
1327 mSyncManager->mPhoneModel); 1327 mSyncManager->mPhoneModel);
1328 loadSuccess = phoneFormat->load( calendar,mCalendar); 1328 loadSuccess = phoneFormat->load( calendar,mCalendar);
1329 1329
1330 } else { 1330 } else {
1331 emit tempDisableBR(false); 1331 emit tempDisableBR(false);
1332 return; 1332 return;
1333 } 1333 }
1334 if ( loadSuccess ) { 1334 if ( loadSuccess ) {
1335 getEventViewerDialog()->setSyncMode( true ); 1335 getEventViewerDialog()->setSyncMode( true );
1336 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1336 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1337 getEventViewerDialog()->setSyncMode( false ); 1337 getEventViewerDialog()->setSyncMode( false );
1338 qApp->processEvents(); 1338 qApp->processEvents();
1339 if ( syncOK ) { 1339 if ( syncOK ) {
1340 if ( mSyncManager->mWriteBackFile ) 1340 if ( mSyncManager->mWriteBackFile )
1341 { 1341 {
1342 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1342 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1343 Incidence* inc = iL.first(); 1343 Incidence* inc = iL.first();
1344 if ( phoneFormat ) { 1344 if ( phoneFormat ) {
1345 while ( inc ) { 1345 while ( inc ) {
1346 inc->removeID(mCurrentSyncDevice); 1346 inc->removeID(mCurrentSyncDevice);
1347 inc = iL.next(); 1347 inc = iL.next();
1348 } 1348 }
1349 } 1349 }
1350#ifndef DESKTOP_VERSION 1350#ifndef DESKTOP_VERSION
1351 if ( sharpFormat ) 1351 if ( sharpFormat )
1352 sharpFormat->save(calendar); 1352 sharpFormat->save(calendar);
1353#endif 1353#endif
1354 if ( phoneFormat ) 1354 if ( phoneFormat )
1355 phoneFormat->save(calendar); 1355 phoneFormat->save(calendar);
1356 iL = calendar->rawIncidences(); 1356 iL = calendar->rawIncidences();
1357 inc = iL.first(); 1357 inc = iL.first();
1358 Incidence* loc; 1358 Incidence* loc;
1359 while ( inc ) { 1359 while ( inc ) {
1360 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1360 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1361 loc = mCalendar->incidence(inc->uid() ); 1361 loc = mCalendar->incidence(inc->uid() );
1362 if ( loc ) { 1362 if ( loc ) {
1363 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1363 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1364 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1364 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1365 } 1365 }
1366 } 1366 }
1367 inc = iL.next(); 1367 inc = iL.next();
1368 } 1368 }
1369 Incidence* lse = getLastSyncEvent(); 1369 Incidence* lse = getLastSyncEvent();
1370 if ( lse ) { 1370 if ( lse ) {
1371 lse->setReadOnly( false ); 1371 lse->setReadOnly( false );
1372 lse->setDescription( "" ); 1372 lse->setDescription( "" );
1373 lse->setReadOnly( true ); 1373 lse->setReadOnly( true );
1374 } 1374 }
1375 } 1375 }
1376 } else { 1376 } else {
1377 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1377 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1378 } 1378 }
1379 setModified( true ); 1379 setModified( true );
1380 } else { 1380 } else {
1381 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1381 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1382 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1382 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1383 question, i18n("Ok")) ; 1383 question, i18n("Ok")) ;
1384 1384
1385 } 1385 }
1386 delete calendar; 1386 delete calendar;
1387 updateView(); 1387 updateView();
1388 emit tempDisableBR(false); 1388 emit tempDisableBR(false);
1389 return ;//syncOK; 1389 return ;//syncOK;
1390 1390
1391} 1391}
1392 1392
1393bool CalendarView::importBday() 1393bool CalendarView::importBday()
1394{ 1394{
1395#ifndef KORG_NOKABC 1395#ifndef KORG_NOKABC
1396 1396
1397#ifdef DESKTOP_VERSION 1397#ifdef DESKTOP_VERSION
1398 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1398 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1399 KABC::AddressBook::Iterator it; 1399 KABC::AddressBook::Iterator it;
1400 int count = 0; 1400 int count = 0;
1401 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1401 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1402 ++count; 1402 ++count;
1403 } 1403 }
1404 QProgressBar bar(count,0 ); 1404 QProgressBar bar(count,0 );
1405 int w = 300; 1405 int w = 300;
1406 if ( QApplication::desktop()->width() < 320 ) 1406 if ( QApplication::desktop()->width() < 320 )
1407 w = 220; 1407 w = 220;
1408 int h = bar.sizeHint().height() ; 1408 int h = bar.sizeHint().height() ;
1409 int dw = QApplication::desktop()->width(); 1409 int dw = QApplication::desktop()->width();
1410 int dh = QApplication::desktop()->height(); 1410 int dh = QApplication::desktop()->height();
1411 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1411 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1412 bar.show(); 1412 bar.show();
1413 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1413 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1414 qApp->processEvents(); 1414 qApp->processEvents();
1415 count = 0; 1415 count = 0;
1416 int addCount = 0; 1416 int addCount = 0;
1417 KCal::Attendee* a = 0; 1417 KCal::Attendee* a = 0;
1418 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1418 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1419 if ( ! bar.isVisible() ) 1419 if ( ! bar.isVisible() )
1420 return false; 1420 return false;
1421 bar.setProgress( count++ ); 1421 bar.setProgress( count++ );
1422 qApp->processEvents(); 1422 qApp->processEvents();
1423 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1423 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1424 if ( (*it).birthday().date().isValid() ){ 1424 if ( (*it).birthday().date().isValid() ){
1425 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1425 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1426 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1426 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1427 ++addCount; 1427 ++addCount;
1428 } 1428 }
1429 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1429 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1430 if ( anni.isValid() ){ 1430 if ( anni.isValid() ){
1431 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1431 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1432 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1432 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1433 ++addCount; 1433 ++addCount;
1434 } 1434 }
1435 } 1435 }
1436 updateView(); 1436 updateView();
1437 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1437 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1438#else //DESKTOP_VERSION 1438#else //DESKTOP_VERSION
1439 1439
1440 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1440 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1441 // the result should now arrive through method insertBirthdays 1441 // the result should now arrive through method insertBirthdays
1442 1442
1443#endif //DESKTOP_VERSION 1443#endif //DESKTOP_VERSION
1444 1444
1445#endif //KORG_NOKABC 1445#endif //KORG_NOKABC
1446 1446
1447 1447
1448 return true; 1448 return true;
1449} 1449}
1450 1450
1451// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1451// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1452void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1452void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1453 const QStringList& anniversaryList, const QStringList& realNameList, 1453 const QStringList& anniversaryList, const QStringList& realNameList,
1454 const QStringList& emailList, const QStringList& assembledNameList, 1454 const QStringList& emailList, const QStringList& assembledNameList,
1455 const QStringList& uidList) 1455 const QStringList& uidList)
1456{ 1456{
1457 //qDebug("KO::CalendarView::insertBirthdays"); 1457 //qDebug("KO::CalendarView::insertBirthdays");
1458 if (uid == this->name()) 1458 if (uid == this->name())
1459 { 1459 {
1460 int count = birthdayList.count(); 1460 int count = birthdayList.count();
1461 int addCount = 0; 1461 int addCount = 0;
1462 KCal::Attendee* a = 0; 1462 KCal::Attendee* a = 0;
1463 1463
1464 //qDebug("CalView 1 %i", count); 1464 //qDebug("CalView 1 %i", count);
1465 1465
1466 QProgressBar bar(count,0 ); 1466 QProgressBar bar(count,0 );
1467 int w = 300; 1467 int w = 300;
1468 if ( QApplication::desktop()->width() < 320 ) 1468 if ( QApplication::desktop()->width() < 320 )
1469 w = 220; 1469 w = 220;
1470 int h = bar.sizeHint().height() ; 1470 int h = bar.sizeHint().height() ;
1471 int dw = QApplication::desktop()->width(); 1471 int dw = QApplication::desktop()->width();
1472 int dh = QApplication::desktop()->height(); 1472 int dh = QApplication::desktop()->height();
1473 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1473 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1474 bar.show(); 1474 bar.show();
1475 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1475 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1476 qApp->processEvents(); 1476 qApp->processEvents();
1477 1477
1478 QDate birthday; 1478 QDate birthday;
1479 QDate anniversary; 1479 QDate anniversary;
1480 QString realName; 1480 QString realName;
1481 QString email; 1481 QString email;
1482 QString assembledName; 1482 QString assembledName;
1483 QString uid; 1483 QString uid;
1484 bool ok = true; 1484 bool ok = true;
1485 for ( int i = 0; i < count; i++) 1485 for ( int i = 0; i < count; i++)
1486 { 1486 {
1487 if ( ! bar.isVisible() ) 1487 if ( ! bar.isVisible() )
1488 return; 1488 return;
1489 bar.setProgress( i ); 1489 bar.setProgress( i );
1490 qApp->processEvents(); 1490 qApp->processEvents();
1491 1491
1492 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1492 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1493 if (!ok) { 1493 if (!ok) {
1494 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1494 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1495 } 1495 }
1496 1496
1497 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1497 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1498 if (!ok) { 1498 if (!ok) {
1499 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1499 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1500 } 1500 }
1501 realName = realNameList[i]; 1501 realName = realNameList[i];
1502 email = emailList[i]; 1502 email = emailList[i];
1503 assembledName = assembledNameList[i]; 1503 assembledName = assembledNameList[i];
1504 uid = uidList[i]; 1504 uid = uidList[i];
1505 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1505 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1506 1506
1507 if ( birthday.isValid() ){ 1507 if ( birthday.isValid() ){
1508 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1508 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1509 KCal::Attendee::ReqParticipant,uid) ; 1509 KCal::Attendee::ReqParticipant,uid) ;
1510 if ( addAnniversary( birthday, assembledName, a, true ) ) 1510 if ( addAnniversary( birthday, assembledName, a, true ) )
1511 ++addCount; 1511 ++addCount;
1512 } 1512 }
1513 1513
1514 if ( anniversary.isValid() ){ 1514 if ( anniversary.isValid() ){
1515 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1515 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1516 KCal::Attendee::ReqParticipant,uid) ; 1516 KCal::Attendee::ReqParticipant,uid) ;
1517 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1517 if ( addAnniversary( anniversary, assembledName, a, false ) )
1518 ++addCount; 1518 ++addCount;
1519 } 1519 }
1520 } 1520 }
1521 1521
1522 updateView(); 1522 updateView();
1523 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1523 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1524 1524
1525 } 1525 }
1526 1526
1527} 1527}
1528 1528
1529 1529
1530 1530
1531bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1531bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1532{ 1532{
1533 //qDebug("addAnni "); 1533 //qDebug("addAnni ");
1534 Event * ev = new Event(); 1534 Event * ev = new Event();
1535 ev->setOrganizer(KOPrefs::instance()->email()); 1535 ev->setOrganizer(KOPrefs::instance()->email());
1536 if ( a ) { 1536 if ( a ) {
1537 ev->addAttendee( a ); 1537 ev->addAttendee( a );
1538 } 1538 }
1539 QString kind; 1539 QString kind;
1540 if ( birthday ) { 1540 if ( birthday ) {
1541 kind = i18n( "Birthday" ); 1541 kind = i18n( "Birthday" );
1542 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1542 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1543 } 1543 }
1544 else { 1544 else {
1545 kind = i18n( "Anniversary" ); 1545 kind = i18n( "Anniversary" );
1546 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1546 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1547 } 1547 }
1548 ev->setCategories( kind ); 1548 ev->setCategories( kind );
1549 ev->setDtStart( QDateTime(date) ); 1549 ev->setDtStart( QDateTime(date) );
1550 ev->setDtEnd( QDateTime(date) ); 1550 ev->setDtEnd( QDateTime(date) );
1551 ev->setFloats( true ); 1551 ev->setFloats( true );
1552 Recurrence * rec = ev->recurrence(); 1552 Recurrence * rec = ev->recurrence();
1553 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1553 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1554 rec->addYearlyNum( date.month() ); 1554 rec->addYearlyNum( date.month() );
1555 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1555 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1556 delete ev; 1556 delete ev;
1557 return false; 1557 return false;
1558 } 1558 }
1559 return true; 1559 return true;
1560 1560
1561} 1561}
1562bool CalendarView::importQtopia( const QString &categories, 1562bool CalendarView::importQtopia( const QString &categories,
1563 const QString &datebook, 1563 const QString &datebook,
1564 const QString &todolist ) 1564 const QString &todolist )
1565{ 1565{
1566 1566
1567 QtopiaFormat qtopiaFormat; 1567 QtopiaFormat qtopiaFormat;
1568 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1568 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1569 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1569 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1570 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1570 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1571 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1571 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1572 1572
1573 updateView(); 1573 updateView();
1574 return true; 1574 return true;
1575 1575
1576#if 0 1576#if 0
1577 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1577 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1578 mCurrentSyncDevice = "qtopia-XML"; 1578 mCurrentSyncDevice = "qtopia-XML";
1579 if ( mSyncManager->mAskForPreferences ) 1579 if ( mSyncManager->mAskForPreferences )
1580 edit_sync_options(); 1580 edit_sync_options();
1581 qApp->processEvents(); 1581 qApp->processEvents();
1582 CalendarLocal* calendar = new CalendarLocal(); 1582 CalendarLocal* calendar = new CalendarLocal();
1583 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1583 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1584 bool syncOK = false; 1584 bool syncOK = false;
1585 QtopiaFormat qtopiaFormat; 1585 QtopiaFormat qtopiaFormat;
1586 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1586 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1587 bool loadOk = true; 1587 bool loadOk = true;
1588 if ( !categories.isEmpty() ) 1588 if ( !categories.isEmpty() )
1589 loadOk = qtopiaFormat.load( calendar, categories ); 1589 loadOk = qtopiaFormat.load( calendar, categories );
1590 if ( loadOk && !datebook.isEmpty() ) 1590 if ( loadOk && !datebook.isEmpty() )
1591 loadOk = qtopiaFormat.load( calendar, datebook ); 1591 loadOk = qtopiaFormat.load( calendar, datebook );
1592 if ( loadOk && !todolist.isEmpty() ) 1592 if ( loadOk && !todolist.isEmpty() )
1593 loadOk = qtopiaFormat.load( calendar, todolist ); 1593 loadOk = qtopiaFormat.load( calendar, todolist );
1594 1594
1595 if ( loadOk ) { 1595 if ( loadOk ) {
1596 getEventViewerDialog()->setSyncMode( true ); 1596 getEventViewerDialog()->setSyncMode( true );
1597 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1597 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1598 getEventViewerDialog()->setSyncMode( false ); 1598 getEventViewerDialog()->setSyncMode( false );
1599 qApp->processEvents(); 1599 qApp->processEvents();
1600 if ( syncOK ) { 1600 if ( syncOK ) {
1601 if ( mSyncManager->mWriteBackFile ) 1601 if ( mSyncManager->mWriteBackFile )
1602 { 1602 {
1603 // write back XML file 1603 // write back XML file
1604 1604
1605 } 1605 }
1606 setModified( true ); 1606 setModified( true );
1607 } 1607 }
1608 } else { 1608 } else {
1609 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1609 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1610 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1610 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1611 question, i18n("Ok")) ; 1611 question, i18n("Ok")) ;
1612 } 1612 }
1613 delete calendar; 1613 delete calendar;
1614 updateView(); 1614 updateView();
1615 return syncOK; 1615 return syncOK;
1616 1616
1617 1617
1618#endif 1618#endif
1619 1619
1620} 1620}
1621 1621
1622void CalendarView::setSyncEventsReadOnly() 1622void CalendarView::setSyncEventsReadOnly()
1623{ 1623{
1624 Event * ev; 1624 Event * ev;
1625 QPtrList<Event> eL = mCalendar->rawEvents(); 1625 QPtrList<Event> eL = mCalendar->rawEvents();
1626 ev = eL.first(); 1626 ev = eL.first();
1627 while ( ev ) { 1627 while ( ev ) {
1628 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1628 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1629 ev->setReadOnly( true ); 1629 ev->setReadOnly( true );
1630 ev = eL.next(); 1630 ev = eL.next();
1631 } 1631 }
1632} 1632}
1633bool CalendarView::openCalendar(QString filename, bool merge) 1633bool CalendarView::openCalendar(QString filename, bool merge)
1634{ 1634{
1635 1635
1636 if (filename.isEmpty()) { 1636 if (filename.isEmpty()) {
1637 return false; 1637 return false;
1638 } 1638 }
1639 1639
1640 if (!QFile::exists(filename)) { 1640 if (!QFile::exists(filename)) {
1641 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1641 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1642 return false; 1642 return false;
1643 } 1643 }
1644 1644
1645 globalFlagBlockAgenda = 1; 1645 globalFlagBlockAgenda = 1;
1646 if (!merge) mCalendar->close(); 1646 if (!merge) mCalendar->close();
1647 1647
1648 mStorage->setFileName( filename ); 1648 mStorage->setFileName( filename );
1649 1649
1650 if ( mStorage->load() ) { 1650 if ( mStorage->load() ) {
1651 if ( merge ) ;//setModified( true ); 1651 if ( merge ) ;//setModified( true );
1652 else { 1652 else {
1653 //setModified( true ); 1653 //setModified( true );
1654 mViewManager->setDocumentId( filename ); 1654 mViewManager->setDocumentId( filename );
1655 mDialogManager->setDocumentId( filename ); 1655 mDialogManager->setDocumentId( filename );
1656 mTodoList->setDocumentId( filename ); 1656 mTodoList->setDocumentId( filename );
1657 } 1657 }
1658 globalFlagBlockAgenda = 2; 1658 globalFlagBlockAgenda = 2;
1659 // if ( getLastSyncEvent() ) 1659 // if ( getLastSyncEvent() )
1660 // getLastSyncEvent()->setReadOnly( true ); 1660 // getLastSyncEvent()->setReadOnly( true );
1661 mCalendar->reInitAlarmSettings(); 1661 mCalendar->reInitAlarmSettings();
1662 setSyncEventsReadOnly(); 1662 setSyncEventsReadOnly();
1663 updateUnmanagedViews(); 1663 updateUnmanagedViews();
1664 updateView(); 1664 updateView();
1665 if ( filename != MainWindow::defaultFileName() ) { 1665 if ( filename != MainWindow::defaultFileName() ) {
1666 saveCalendar( MainWindow::defaultFileName() ); 1666 saveCalendar( MainWindow::defaultFileName() );
1667 } else { 1667 } else {
1668 QFileInfo finf ( MainWindow::defaultFileName()); 1668 QFileInfo finf ( MainWindow::defaultFileName());
1669 if ( finf.exists() ) { 1669 if ( finf.exists() ) {
1670 setLoadedFileVersion( finf.lastModified () ); 1670 setLoadedFileVersion( finf.lastModified () );
1671 } 1671 }
1672 } 1672 }
1673 return true; 1673 return true;
1674 } else { 1674 } else {
1675 // while failing to load, the calendar object could 1675 // while failing to load, the calendar object could
1676 // have become partially populated. Clear it out. 1676 // have become partially populated. Clear it out.
1677 if ( !merge ) { 1677 if ( !merge ) {
1678 mCalendar->close(); 1678 mCalendar->close();
1679 mViewManager->setDocumentId( filename ); 1679 mViewManager->setDocumentId( filename );
1680 mDialogManager->setDocumentId( filename ); 1680 mDialogManager->setDocumentId( filename );
1681 mTodoList->setDocumentId( filename ); 1681 mTodoList->setDocumentId( filename );
1682 } 1682 }
1683 1683
1684 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1684 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1685 1685
1686 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1686 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1687 globalFlagBlockAgenda = 2; 1687 globalFlagBlockAgenda = 2;
1688 mCalendar->reInitAlarmSettings(); 1688 mCalendar->reInitAlarmSettings();
1689 setSyncEventsReadOnly(); 1689 setSyncEventsReadOnly();
1690 updateUnmanagedViews(); 1690 updateUnmanagedViews();
1691 updateView(); 1691 updateView();
1692 } 1692 }
1693 return false; 1693 return false;
1694} 1694}
1695void CalendarView::showOpenError() 1695void CalendarView::showOpenError()
1696{ 1696{
1697 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1697 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1698} 1698}
1699void CalendarView::setLoadedFileVersion(QDateTime dt) 1699void CalendarView::setLoadedFileVersion(QDateTime dt)
1700{ 1700{
1701 loadedFileVersion = dt; 1701 loadedFileVersion = dt;
1702} 1702}
1703bool CalendarView::checkFileChanged(QString fn) 1703bool CalendarView::checkFileChanged(QString fn)
1704{ 1704{
1705 QFileInfo finf ( fn ); 1705 QFileInfo finf ( fn );
1706 if ( !finf.exists() ) 1706 if ( !finf.exists() )
1707 return true; 1707 return true;
1708 QDateTime dt = finf.lastModified (); 1708 QDateTime dt = finf.lastModified ();
1709 if ( dt <= loadedFileVersion ) 1709 if ( dt <= loadedFileVersion )
1710 return false; 1710 return false;
1711 return true; 1711 return true;
1712 1712
1713} 1713}
1714void CalendarView::watchSavedFile() 1714void CalendarView::watchSavedFile()
1715{ 1715{
1716 QFileInfo finf ( MainWindow::defaultFileName()); 1716 QFileInfo finf ( MainWindow::defaultFileName());
1717 if ( !finf.exists() ) 1717 if ( !finf.exists() )
1718 return; 1718 return;
1719 QDateTime dt = finf.lastModified (); 1719 QDateTime dt = finf.lastModified ();
1720 if ( dt < loadedFileVersion ) { 1720 if ( dt < loadedFileVersion ) {
1721 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1721 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1722 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1722 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1723 return; 1723 return;
1724 } 1724 }
1725 loadedFileVersion = dt; 1725 loadedFileVersion = dt;
1726} 1726}
1727 1727
1728bool CalendarView::checkFileVersion(QString fn) 1728bool CalendarView::checkFileVersion(QString fn)
1729{ 1729{
1730 QFileInfo finf ( fn ); 1730 QFileInfo finf ( fn );
1731 if ( !finf.exists() ) 1731 if ( !finf.exists() )
1732 return true; 1732 return true;
1733 QDateTime dt = finf.lastModified (); 1733 QDateTime dt = finf.lastModified ();
1734 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1734 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1735 //qDebug("file on disk version %s",dt.toString().latin1()); 1735 //qDebug("file on disk version %s",dt.toString().latin1());
1736 if ( dt <= loadedFileVersion ) 1736 if ( dt <= loadedFileVersion )
1737 return true; 1737 return true;
1738 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, true)) , 1738 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, true)) ,
1739 i18n("KO/Pi Warning"),i18n("Overwrite"), 1739 i18n("KO/Pi Warning"),i18n("Overwrite"),
1740 i18n("Sync+save")); 1740 i18n("Sync+save"));
1741 1741
1742 if ( km == KMessageBox::Cancel ) 1742 if ( km == KMessageBox::Cancel )
1743 return false; 1743 return false;
1744 if ( km == KMessageBox::Yes ) 1744 if ( km == KMessageBox::Yes )
1745 return true; 1745 return true;
1746 1746
1747 setSyncDevice("deleteaftersync" ); 1747 setSyncDevice("deleteaftersync" );
1748 mSyncManager->mAskForPreferences = true; 1748 mSyncManager->mAskForPreferences = true;
1749 mSyncManager->mSyncAlgoPrefs = 3; 1749 mSyncManager->mSyncAlgoPrefs = 3;
1750 mSyncManager->mWriteBackFile = false; 1750 mSyncManager->mWriteBackFile = false;
1751 mSyncManager->mWriteBackExistingOnly = false; 1751 mSyncManager->mWriteBackExistingOnly = false;
1752 mSyncManager->mShowSyncSummary = false; 1752 mSyncManager->mShowSyncSummary = false;
1753 syncCalendar( fn, 3 ); 1753 syncCalendar( fn, 3 );
1754 Event * e = getLastSyncEvent(); 1754 Event * e = getLastSyncEvent();
1755 mCalendar->deleteEvent ( e ); 1755 mCalendar->deleteEvent ( e );
1756 updateView(); 1756 updateView();
1757 return true; 1757 return true;
1758} 1758}
1759 1759
1760bool CalendarView::saveCalendar( QString filename ) 1760bool CalendarView::saveCalendar( QString filename )
1761{ 1761{
1762 1762
1763 // Store back all unsaved data into calendar object 1763 // Store back all unsaved data into calendar object
1764 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1764 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1765 if ( mViewManager->currentView() ) 1765 if ( mViewManager->currentView() )
1766 mViewManager->currentView()->flushView(); 1766 mViewManager->currentView()->flushView();
1767 1767
1768 1768
1769 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1769 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1770 mStorage->setSaveFormat( new ICalFormat() ); 1770 mStorage->setSaveFormat( new ICalFormat() );
1771 mStorage->setFileName( filename ); 1771 mStorage->setFileName( filename );
1772 bool success; 1772 bool success;
1773 success = mStorage->save(); 1773 success = mStorage->save();
1774 if ( !success ) { 1774 if ( !success ) {
1775 return false; 1775 return false;
1776 } 1776 }
1777 if ( filename == MainWindow::defaultFileName() ) { 1777 if ( filename == MainWindow::defaultFileName() ) {
1778 setLoadedFileVersion( lfv ); 1778 setLoadedFileVersion( lfv );
1779 watchSavedFile(); 1779 watchSavedFile();
1780 } 1780 }
1781 return true; 1781 return true;
1782} 1782}
1783 1783
1784void CalendarView::closeCalendar() 1784void CalendarView::closeCalendar()
1785{ 1785{
1786 1786
1787 // child windows no longer valid 1787 // child windows no longer valid
1788 emit closingDown(); 1788 emit closingDown();
1789 1789
1790 mCalendar->close(); 1790 mCalendar->close();
1791 setModified(false); 1791 setModified(false);
1792 updateView(); 1792 updateView();
1793} 1793}
1794 1794
1795void CalendarView::archiveCalendar() 1795void CalendarView::archiveCalendar()
1796{ 1796{
1797 mDialogManager->showArchiveDialog(); 1797 mDialogManager->showArchiveDialog();
1798} 1798}
1799 1799
1800 1800
1801void CalendarView::readSettings() 1801void CalendarView::readSettings()
1802{ 1802{
1803 1803
1804 1804
1805 // mViewManager->showAgendaView(); 1805 // mViewManager->showAgendaView();
1806 QString str; 1806 QString str;
1807 //qDebug("CalendarView::readSettings() "); 1807 //qDebug("CalendarView::readSettings() ");
1808 // read settings from the KConfig, supplying reasonable 1808 // read settings from the KConfig, supplying reasonable
1809 // defaults where none are to be found 1809 // defaults where none are to be found
1810 KConfig *config = KOGlobals::config(); 1810 KConfig *config = KOGlobals::config();
1811#ifndef KORG_NOSPLITTER 1811#ifndef KORG_NOSPLITTER
1812 config->setGroup("KOrganizer Geometry"); 1812 config->setGroup("KOrganizer Geometry");
1813 1813
1814 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1814 QValueList<int> sizes = config->readIntListEntry("Separator1");
1815 if (sizes.count() != 2) { 1815 if (sizes.count() != 2) {
1816 sizes << mDateNavigator->minimumSizeHint().width(); 1816 sizes << mDateNavigator->minimumSizeHint().width();
1817 sizes << 300; 1817 sizes << 300;
1818 } 1818 }
1819 mPanner->setSizes(sizes); 1819 mPanner->setSizes(sizes);
1820 1820
1821 sizes = config->readIntListEntry("Separator2"); 1821 sizes = config->readIntListEntry("Separator2");
1822 if ( ( mResourceView && sizes.count() == 4 ) || 1822 if ( ( mResourceView && sizes.count() == 4 ) ||
1823 ( !mResourceView && sizes.count() == 3 ) ) { 1823 ( !mResourceView && sizes.count() == 3 ) ) {
1824 mLeftSplitter->setSizes(sizes); 1824 mLeftSplitter->setSizes(sizes);
1825 } 1825 }
1826#endif 1826#endif
1827 globalFlagBlockAgenda = 1; 1827 globalFlagBlockAgenda = 1;
1828 mViewManager->showAgendaView(); 1828 mViewManager->showAgendaView();
1829 //mViewManager->readSettings( config ); 1829 //mViewManager->readSettings( config );
1830 mTodoList->restoreLayout(config,QString("Todo Layout")); 1830 mTodoList->restoreLayout(config,QString("Todo Layout"));
1831 readFilterSettings(config); 1831 readFilterSettings(config);
1832 1832
1833#ifdef DESKTOP_VERSION 1833#ifdef DESKTOP_VERSION
1834 config->setGroup("WidgetLayout"); 1834 config->setGroup("WidgetLayout");
1835 QStringList list; 1835 QStringList list;
1836 list = config->readListEntry("MainLayout"); 1836 list = config->readListEntry("MainLayout");
1837 int x,y,w,h; 1837 int x,y,w,h;
1838 if ( ! list.isEmpty() ) { 1838 if ( ! list.isEmpty() ) {
1839 x = list[0].toInt(); 1839 x = list[0].toInt();
1840 y = list[1].toInt(); 1840 y = list[1].toInt();
1841 w = list[2].toInt(); 1841 w = list[2].toInt();
1842 h = list[3].toInt(); 1842 h = list[3].toInt();
1843 KApplication::testCoords( &x,&y,&w,&h );
1843 topLevelWidget()->setGeometry(x,y,w,h); 1844 topLevelWidget()->setGeometry(x,y,w,h);
1844 1845
1845 } else { 1846 } else {
1846 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1847 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1847 } 1848 }
1848 list = config->readListEntry("EditEventLayout"); 1849 list = config->readListEntry("EditEventLayout");
1849 if ( ! list.isEmpty() ) { 1850 if ( ! list.isEmpty() ) {
1850 x = list[0].toInt(); 1851 x = list[0].toInt();
1851 y = list[1].toInt(); 1852 y = list[1].toInt();
1852 w = list[2].toInt(); 1853 w = list[2].toInt();
1853 h = list[3].toInt(); 1854 h = list[3].toInt();
1855 KApplication::testCoords( &x,&y,&w,&h );
1854 mEventEditor->setGeometry(x,y,w,h); 1856 mEventEditor->setGeometry(x,y,w,h);
1855 1857
1856 } 1858 }
1857 list = config->readListEntry("EditTodoLayout"); 1859 list = config->readListEntry("EditTodoLayout");
1858 if ( ! list.isEmpty() ) { 1860 if ( ! list.isEmpty() ) {
1859 x = list[0].toInt(); 1861 x = list[0].toInt();
1860 y = list[1].toInt(); 1862 y = list[1].toInt();
1861 w = list[2].toInt(); 1863 w = list[2].toInt();
1862 h = list[3].toInt(); 1864 h = list[3].toInt();
1865 KApplication::testCoords( &x,&y,&w,&h );
1863 mTodoEditor->setGeometry(x,y,w,h); 1866 mTodoEditor->setGeometry(x,y,w,h);
1864 1867
1865 } 1868 }
1866 list = config->readListEntry("ViewerLayout"); 1869 list = config->readListEntry("ViewerLayout");
1867 if ( ! list.isEmpty() ) { 1870 if ( ! list.isEmpty() ) {
1868 x = list[0].toInt(); 1871 x = list[0].toInt();
1869 y = list[1].toInt(); 1872 y = list[1].toInt();
1870 w = list[2].toInt(); 1873 w = list[2].toInt();
1871 h = list[3].toInt(); 1874 h = list[3].toInt();
1875 KApplication::testCoords( &x,&y,&w,&h );
1872 getEventViewerDialog()->setGeometry(x,y,w,h); 1876 getEventViewerDialog()->setGeometry(x,y,w,h);
1873 } 1877 }
1874#endif 1878#endif
1875 config->setGroup( "Views" ); 1879 config->setGroup( "Views" );
1876 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1880 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1877 1881
1878 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1882 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1879 1883
1880 int resetval = 0; 1884 int resetval = 0;
1881 int maxVal = 0; 1885 int maxVal = 0;
1882 if (sizes.count() != 3) { 1886 if (sizes.count() != 3) {
1883 if ( KOPrefs::instance()->mVerticalScreen ) { 1887 if ( KOPrefs::instance()->mVerticalScreen ) {
1884 resetval = mDateNavigator->sizeHint().width()+2; 1888 resetval = mDateNavigator->sizeHint().width()+2;
1885 } else { 1889 } else {
1886 resetval = mDateNavigator->sizeHint().height()+2; 1890 resetval = mDateNavigator->sizeHint().height()+2;
1887 } 1891 }
1888 } 1892 }
1889 if ( resetval ) { 1893 if ( resetval ) {
1890 sizes.clear(); 1894 sizes.clear();
1891 if ( KOPrefs::instance()->mVerticalScreen ) { 1895 if ( KOPrefs::instance()->mVerticalScreen ) {
1892 maxVal = QApplication::desktop()->width() -10; 1896 maxVal = QApplication::desktop()->width() -10;
1893 } else { 1897 } else {
1894 maxVal = QApplication::desktop()->height()-10; 1898 maxVal = QApplication::desktop()->height()-10;
1895 } 1899 }
1896 sizes << resetval; 1900 sizes << resetval;
1897 if ( maxVal < resetval + resetval) 1901 if ( maxVal < resetval + resetval)
1898 resetval = maxVal - resetval; 1902 resetval = maxVal - resetval;
1899 sizes << resetval; 1903 sizes << resetval;
1900 sizes << 100; 1904 sizes << 100;
1901 } 1905 }
1902 mLeftFrame->setSizes(sizes); 1906 mLeftFrame->setSizes(sizes);
1903 sizes = config->readIntListEntry("Main Splitter Frame"); 1907 sizes = config->readIntListEntry("Main Splitter Frame");
1904 resetval = 0; 1908 resetval = 0;
1905 maxVal = 0; 1909 maxVal = 0;
1906 if (sizes.count() != 2) { 1910 if (sizes.count() != 2) {
1907 if ( !KOPrefs::instance()->mVerticalScreen ) { 1911 if ( !KOPrefs::instance()->mVerticalScreen ) {
1908 resetval = mDateNavigator->sizeHint().width()+2; 1912 resetval = mDateNavigator->sizeHint().width()+2;
1909 } else { 1913 } else {
1910 resetval = mDateNavigator->sizeHint().height()+2; 1914 resetval = mDateNavigator->sizeHint().height()+2;
1911 } 1915 }
1912 } 1916 }
1913 if ( resetval ) { 1917 if ( resetval ) {
1914 sizes.clear(); 1918 sizes.clear();
1915 if ( !KOPrefs::instance()->mVerticalScreen ) { 1919 if ( !KOPrefs::instance()->mVerticalScreen ) {
1916 maxVal = QApplication::desktop()->width() -10; 1920 maxVal = QApplication::desktop()->width() -10;
1917 } else { 1921 } else {
1918 maxVal = QApplication::desktop()->height()-10; 1922 maxVal = QApplication::desktop()->height()-10;
1919 } 1923 }
1920 sizes << resetval; 1924 sizes << resetval;
1921 if ( maxVal < resetval + resetval) 1925 if ( maxVal < resetval + resetval)
1922 resetval = maxVal - resetval; 1926 resetval = maxVal - resetval;
1923 sizes << resetval; 1927 sizes << resetval;
1924 } 1928 }
1925 mMainFrame->setSizes(sizes); 1929 mMainFrame->setSizes(sizes);
1926 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1930 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1927 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1931 else if ( dateCount == 7 ) mNavigator->selectWeek();
1928 else mNavigator->selectDates( dateCount ); 1932 else mNavigator->selectDates( dateCount );
1929 // mViewManager->readSettings( config ); 1933 // mViewManager->readSettings( config );
1930 updateConfig(); 1934 updateConfig();
1931 globalFlagBlockAgenda = 2; 1935 globalFlagBlockAgenda = 2;
1932 mViewManager->readSettings( config ); 1936 mViewManager->readSettings( config );
1933 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 1937 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1934} 1938}
1935 1939
1936 1940
1937void CalendarView::writeSettings() 1941void CalendarView::writeSettings()
1938{ 1942{
1939 // kdDebug() << "CalendarView::writeSettings" << endl; 1943 // kdDebug() << "CalendarView::writeSettings" << endl;
1940 1944
1941 KConfig *config = KOGlobals::config(); 1945 KConfig *config = KOGlobals::config();
1942 1946
1943 mViewManager->writeSettings( config ); 1947 mViewManager->writeSettings( config );
1944 mTodoList->saveLayout(config,QString("Todo Layout")); 1948 mTodoList->saveLayout(config,QString("Todo Layout"));
1945 mDialogManager->writeSettings( config ); 1949 mDialogManager->writeSettings( config );
1946 //KOPrefs::instance()->usrWriteConfig(); 1950 //KOPrefs::instance()->usrWriteConfig();
1947 KOPrefs::instance()->writeConfig(); 1951 KOPrefs::instance()->writeConfig();
1948 1952
1949 writeFilterSettings(config); 1953 writeFilterSettings(config);
1950 1954
1951 config->setGroup( "Views" ); 1955 config->setGroup( "Views" );
1952 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1956 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1953 1957
1954 QValueList<int> listINT = mLeftFrame->sizes(); 1958 QValueList<int> listINT = mLeftFrame->sizes();
1955 config->writeEntry("Left Splitter Frame",listINT); 1959 config->writeEntry("Left Splitter Frame",listINT);
1956 QValueList<int> listINT2 = mMainFrame->sizes(); 1960 QValueList<int> listINT2 = mMainFrame->sizes();
1957 config->writeEntry("Main Splitter Frame",listINT2); 1961 config->writeEntry("Main Splitter Frame",listINT2);
1958#ifdef DESKTOP_VERSION 1962#ifdef DESKTOP_VERSION
1959 config->setGroup("WidgetLayout"); 1963 config->setGroup("WidgetLayout");
1960 QStringList list ;//= config->readListEntry("MainLayout"); 1964 QStringList list ;//= config->readListEntry("MainLayout");
1961 int x,y,w,h; 1965 int x,y,w,h;
1962 QWidget* wid; 1966 QWidget* wid;
1963 wid = topLevelWidget(); 1967 wid = topLevelWidget();
1964 x = wid->geometry().x(); 1968 x = wid->geometry().x();
1965 y = wid->geometry().y(); 1969 y = wid->geometry().y();
1966 w = wid->width(); 1970 w = wid->width();
1967 h = wid->height(); 1971 h = wid->height();
1968 list.clear(); 1972 list.clear();
1969 list << QString::number( x ); 1973 list << QString::number( x );
1970 list << QString::number( y ); 1974 list << QString::number( y );
1971 list << QString::number( w ); 1975 list << QString::number( w );
1972 list << QString::number( h ); 1976 list << QString::number( h );
1973 config->writeEntry("MainLayout",list ); 1977 config->writeEntry("MainLayout",list );
1974 1978
1975 wid = mEventEditor; 1979 wid = mEventEditor;
1976 x = wid->geometry().x(); 1980 x = wid->geometry().x();
1977 y = wid->geometry().y(); 1981 y = wid->geometry().y();
1978 w = wid->width(); 1982 w = wid->width();
1979 h = wid->height(); 1983 h = wid->height();
1980 list.clear(); 1984 list.clear();
1981 list << QString::number( x ); 1985 list << QString::number( x );
1982 list << QString::number( y ); 1986 list << QString::number( y );
1983 list << QString::number( w ); 1987 list << QString::number( w );
1984 list << QString::number( h ); 1988 list << QString::number( h );
1985 config->writeEntry("EditEventLayout",list ); 1989 config->writeEntry("EditEventLayout",list );
1986 1990
1987 wid = mTodoEditor; 1991 wid = mTodoEditor;
1988 x = wid->geometry().x(); 1992 x = wid->geometry().x();
1989 y = wid->geometry().y(); 1993 y = wid->geometry().y();
1990 w = wid->width(); 1994 w = wid->width();
1991 h = wid->height(); 1995 h = wid->height();
1992 list.clear(); 1996 list.clear();
1993 list << QString::number( x ); 1997 list << QString::number( x );
1994 list << QString::number( y ); 1998 list << QString::number( y );
1995 list << QString::number( w ); 1999 list << QString::number( w );
1996 list << QString::number( h ); 2000 list << QString::number( h );
1997 config->writeEntry("EditTodoLayout",list ); 2001 config->writeEntry("EditTodoLayout",list );
1998 wid = getEventViewerDialog(); 2002 wid = getEventViewerDialog();
1999 x = wid->geometry().x(); 2003 x = wid->geometry().x();
2000 y = wid->geometry().y(); 2004 y = wid->geometry().y();
2001 w = wid->width(); 2005 w = wid->width();
2002 h = wid->height(); 2006 h = wid->height();
2003 list.clear(); 2007 list.clear();
2004 list << QString::number( x ); 2008 list << QString::number( x );
2005 list << QString::number( y ); 2009 list << QString::number( y );
2006 list << QString::number( w ); 2010 list << QString::number( w );
2007 list << QString::number( h ); 2011 list << QString::number( h );
2008 config->writeEntry("ViewerLayout",list ); 2012 config->writeEntry("ViewerLayout",list );
2009 wid = mDialogManager->getSearchDialog(); 2013 wid = mDialogManager->getSearchDialog();
2010 if ( wid ) { 2014 if ( wid ) {
2011 x = wid->geometry().x(); 2015 x = wid->geometry().x();
2012 y = wid->geometry().y(); 2016 y = wid->geometry().y();
2013 w = wid->width(); 2017 w = wid->width();
2014 h = wid->height(); 2018 h = wid->height();
2015 list.clear(); 2019 list.clear();
2016 list << QString::number( x ); 2020 list << QString::number( x );
2017 list << QString::number( y ); 2021 list << QString::number( y );
2018 list << QString::number( w ); 2022 list << QString::number( w );
2019 list << QString::number( h ); 2023 list << QString::number( h );
2020 config->writeEntry("SearchLayout",list ); 2024 config->writeEntry("SearchLayout",list );
2021 } 2025 }
2022#endif 2026#endif
2023 2027
2024 2028
2025 config->sync(); 2029 config->sync();
2026} 2030}
2027 2031
2028void CalendarView::readFilterSettings(KConfig *config) 2032void CalendarView::readFilterSettings(KConfig *config)
2029{ 2033{
2030 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2034 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2031 2035
2032 mFilters.clear(); 2036 mFilters.clear();
2033 2037
2034 config->setGroup("General"); 2038 config->setGroup("General");
2035 QStringList filterList = config->readListEntry("CalendarFilters"); 2039 QStringList filterList = config->readListEntry("CalendarFilters");
2036 2040
2037 QStringList::ConstIterator it = filterList.begin(); 2041 QStringList::ConstIterator it = filterList.begin();
2038 QStringList::ConstIterator end = filterList.end(); 2042 QStringList::ConstIterator end = filterList.end();
2039 while(it != end) { 2043 while(it != end) {
2040 // kdDebug() << " filter: " << (*it) << endl; 2044 // kdDebug() << " filter: " << (*it) << endl;
2041 2045
2042 CalFilter *filter; 2046 CalFilter *filter;
2043 filter = new CalFilter(*it); 2047 filter = new CalFilter(*it);
2044 config->setGroup("Filter_" + (*it).utf8()); 2048 config->setGroup("Filter_" + (*it).utf8());
2045 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2049 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2046 filter->setCriteria(config->readNumEntry("Criteria",0)); 2050 filter->setCriteria(config->readNumEntry("Criteria",0));
2047 filter->setCategoryList(config->readListEntry("CategoryList")); 2051 filter->setCategoryList(config->readListEntry("CategoryList"));
2048 mFilters.append(filter); 2052 mFilters.append(filter);
2049 2053
2050 ++it; 2054 ++it;
2051 } 2055 }
2052 2056
2053 if (mFilters.count() == 0) { 2057 if (mFilters.count() == 0) {
2054 CalFilter *filter = new CalFilter(i18n("Default")); 2058 CalFilter *filter = new CalFilter(i18n("Default"));
2055 mFilters.append(filter); 2059 mFilters.append(filter);
2056 } 2060 }
2057 mFilterView->updateFilters(); 2061 mFilterView->updateFilters();
2058 config->setGroup("FilterView"); 2062 config->setGroup("FilterView");
2059 2063
2060 mFilterView->blockSignals(true); 2064 mFilterView->blockSignals(true);
2061 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2065 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2062 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2066 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2063 mFilterView->blockSignals(false); 2067 mFilterView->blockSignals(false);
2064 // We do it manually to avoid it being done twice by the above calls 2068 // We do it manually to avoid it being done twice by the above calls
2065 updateFilter(); 2069 updateFilter();
2066} 2070}
2067 2071
2068void CalendarView::writeFilterSettings(KConfig *config) 2072void CalendarView::writeFilterSettings(KConfig *config)
2069{ 2073{
2070 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2074 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2071 2075
2072 QStringList filterList; 2076 QStringList filterList;
2073 2077
2074 CalFilter *filter = mFilters.first(); 2078 CalFilter *filter = mFilters.first();
2075 while(filter) { 2079 while(filter) {
2076 // kdDebug() << " fn: " << filter->name() << endl; 2080 // kdDebug() << " fn: " << filter->name() << endl;
2077 filterList << filter->name(); 2081 filterList << filter->name();
2078 config->setGroup("Filter_" + filter->name().utf8()); 2082 config->setGroup("Filter_" + filter->name().utf8());
2079 config->writeEntry("Criteria",filter->criteria()); 2083 config->writeEntry("Criteria",filter->criteria());
2080 config->writeEntry("CategoryList",filter->categoryList()); 2084 config->writeEntry("CategoryList",filter->categoryList());
2081 filter = mFilters.next(); 2085 filter = mFilters.next();
2082 } 2086 }
2083 config->setGroup("General"); 2087 config->setGroup("General");
2084 config->writeEntry("CalendarFilters",filterList); 2088 config->writeEntry("CalendarFilters",filterList);
2085 2089
2086 config->setGroup("FilterView"); 2090 config->setGroup("FilterView");
2087 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2091 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2088 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2092 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2089} 2093}
2090 2094
2091 2095
2092void CalendarView::goToday() 2096void CalendarView::goToday()
2093{ 2097{
2094 if ( mViewManager->currentView()->isMonthView() ) 2098 if ( mViewManager->currentView()->isMonthView() )
2095 mNavigator->selectTodayMonth(); 2099 mNavigator->selectTodayMonth();
2096 else 2100 else
2097 mNavigator->selectToday(); 2101 mNavigator->selectToday();
2098} 2102}
2099 2103
2100void CalendarView::goNext() 2104void CalendarView::goNext()
2101{ 2105{
2102 mNavigator->selectNext(); 2106 mNavigator->selectNext();
2103} 2107}
2104 2108
2105void CalendarView::goPrevious() 2109void CalendarView::goPrevious()
2106{ 2110{
2107 mNavigator->selectPrevious(); 2111 mNavigator->selectPrevious();
2108} 2112}
2109void CalendarView::goNextMonth() 2113void CalendarView::goNextMonth()
2110{ 2114{
2111 mNavigator->selectNextMonth(); 2115 mNavigator->selectNextMonth();
2112} 2116}
2113 2117
2114void CalendarView::goPreviousMonth() 2118void CalendarView::goPreviousMonth()
2115{ 2119{
2116 mNavigator->selectPreviousMonth(); 2120 mNavigator->selectPreviousMonth();
2117} 2121}
2118void CalendarView::writeLocale() 2122void CalendarView::writeLocale()
2119{ 2123{
2120 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2124 //KPimGlobalPrefs::instance()->setGlobalConfig();
2121#if 0 2125#if 0
2122 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2126 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2123 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2127 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2124 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2128 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2125 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2129 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2126 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2130 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2127 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2131 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2128 dummy = KOPrefs::instance()->mUserDateFormatShort; 2132 dummy = KOPrefs::instance()->mUserDateFormatShort;
2129 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2133 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2130 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2134 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2131 KOPrefs::instance()->mDaylightsavingStart, 2135 KOPrefs::instance()->mDaylightsavingStart,
2132 KOPrefs::instance()->mDaylightsavingEnd ); 2136 KOPrefs::instance()->mDaylightsavingEnd );
2133 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2137 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2134#endif 2138#endif
2135} 2139}
2136void CalendarView::updateConfig() 2140void CalendarView::updateConfig()
2137{ 2141{
2138 writeLocale(); 2142 writeLocale();
2139 if ( KOPrefs::instance()->mUseAppColors ) 2143 if ( KOPrefs::instance()->mUseAppColors )
2140 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2144 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2141 emit configChanged(); 2145 emit configChanged();
2142 mTodoList->updateConfig(); 2146 mTodoList->updateConfig();
2143 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2147 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2144 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2148 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2145 // To make the "fill window" configurations work 2149 // To make the "fill window" configurations work
2146 //mViewManager->raiseCurrentView(); 2150 //mViewManager->raiseCurrentView();
2147} 2151}
2148 2152
2149 2153
2150void CalendarView::eventChanged(Event *event) 2154void CalendarView::eventChanged(Event *event)
2151{ 2155{
2152 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2156 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2153 //updateUnmanagedViews(); 2157 //updateUnmanagedViews();
2154} 2158}
2155 2159
2156void CalendarView::eventAdded(Event *event) 2160void CalendarView::eventAdded(Event *event)
2157{ 2161{
2158 changeEventDisplay(event,KOGlobals::EVENTADDED); 2162 changeEventDisplay(event,KOGlobals::EVENTADDED);
2159} 2163}
2160 2164
2161void CalendarView::eventToBeDeleted(Event *) 2165void CalendarView::eventToBeDeleted(Event *)
2162{ 2166{
2163 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2167 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2164} 2168}
2165 2169
2166void CalendarView::eventDeleted() 2170void CalendarView::eventDeleted()
2167{ 2171{
2168 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2172 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2169} 2173}
2170void CalendarView::changeTodoDisplay(Todo *which, int action) 2174void CalendarView::changeTodoDisplay(Todo *which, int action)
2171{ 2175{
2172 changeIncidenceDisplay((Incidence *)which, action); 2176 changeIncidenceDisplay((Incidence *)which, action);
2173 mDateNavigator->updateView(); //LR 2177 mDateNavigator->updateView(); //LR
2174 //mDialogManager->updateSearchDialog(); 2178 //mDialogManager->updateSearchDialog();
2175 2179
2176 if (which) { 2180 if (which) {
2177 mViewManager->updateWNview(); 2181 mViewManager->updateWNview();
2178 //mTodoList->updateView(); 2182 //mTodoList->updateView();
2179 } 2183 }
2180 2184
2181} 2185}
2182 2186
2183void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2187void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2184{ 2188{
2185 updateUnmanagedViews(); 2189 updateUnmanagedViews();
2186 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2190 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2187 if ( action == KOGlobals::EVENTDELETED ) { //delete 2191 if ( action == KOGlobals::EVENTDELETED ) { //delete
2188 mCalendar->checkAlarmForIncidence( 0, true ); 2192 mCalendar->checkAlarmForIncidence( 0, true );
2189 if ( mEventViewerDialog ) 2193 if ( mEventViewerDialog )
2190 mEventViewerDialog->hide(); 2194 mEventViewerDialog->hide();
2191 } 2195 }
2192 else 2196 else
2193 mCalendar->checkAlarmForIncidence( which , false ); 2197 mCalendar->checkAlarmForIncidence( which , false );
2194} 2198}
2195 2199
2196// most of the changeEventDisplays() right now just call the view's 2200// most of the changeEventDisplays() right now just call the view's
2197// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2201// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2198void CalendarView::changeEventDisplay(Event *which, int action) 2202void CalendarView::changeEventDisplay(Event *which, int action)
2199{ 2203{
2200 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2204 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2201 changeIncidenceDisplay((Incidence *)which, action); 2205 changeIncidenceDisplay((Incidence *)which, action);
2202 mDateNavigator->updateView(); 2206 mDateNavigator->updateView();
2203 //mDialogManager->updateSearchDialog(); 2207 //mDialogManager->updateSearchDialog();
2204 2208
2205 if (which) { 2209 if (which) {
2206 // If there is an event view visible update the display 2210 // If there is an event view visible update the display
2207 mViewManager->currentView()->changeEventDisplay(which,action); 2211 mViewManager->currentView()->changeEventDisplay(which,action);
2208 // TODO: check, if update needed 2212 // TODO: check, if update needed
2209 // if (which->getTodoStatus()) { 2213 // if (which->getTodoStatus()) {
2210 mTodoList->updateView(); 2214 mTodoList->updateView();
2211 // } 2215 // }
2212 } else { 2216 } else {
2213 mViewManager->currentView()->updateView(); 2217 mViewManager->currentView()->updateView();
2214 } 2218 }
2215} 2219}
2216 2220
2217 2221
2218void CalendarView::updateTodoViews() 2222void CalendarView::updateTodoViews()
2219{ 2223{
2220 mTodoList->updateView(); 2224 mTodoList->updateView();
2221 mViewManager->currentView()->updateView(); 2225 mViewManager->currentView()->updateView();
2222 2226
2223} 2227}
2224 2228
2225 2229
2226void CalendarView::updateView(const QDate &start, const QDate &end) 2230void CalendarView::updateView(const QDate &start, const QDate &end)
2227{ 2231{
2228 mTodoList->updateView(); 2232 mTodoList->updateView();
2229 mViewManager->updateView(start, end); 2233 mViewManager->updateView(start, end);
2230 //mDateNavigator->updateView(); 2234 //mDateNavigator->updateView();
2231} 2235}
2232 2236
2233void CalendarView::updateView() 2237void CalendarView::updateView()
2234{ 2238{
2235 DateList tmpList = mNavigator->selectedDates(); 2239 DateList tmpList = mNavigator->selectedDates();
2236 2240
2237 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2241 if ( KOPrefs::instance()->mHideNonStartedTodos )
2238 mTodoList->updateView(); 2242 mTodoList->updateView();
2239 // We assume that the navigator only selects consecutive days. 2243 // We assume that the navigator only selects consecutive days.
2240 updateView( tmpList.first(), tmpList.last() ); 2244 updateView( tmpList.first(), tmpList.last() );
2241} 2245}
2242 2246
2243void CalendarView::updateUnmanagedViews() 2247void CalendarView::updateUnmanagedViews()
2244{ 2248{
2245 mDateNavigator->updateDayMatrix(); 2249 mDateNavigator->updateDayMatrix();
2246} 2250}
2247 2251
2248int CalendarView::msgItemDelete(const QString name) 2252int CalendarView::msgItemDelete(const QString name)
2249{ 2253{
2250 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2254 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2251 i18n("This item will be\npermanently deleted."), 2255 i18n("This item will be\npermanently deleted."),
2252 i18n("KO/Pi Confirmation"),i18n("Delete")); 2256 i18n("KO/Pi Confirmation"),i18n("Delete"));
2253} 2257}
2254 2258
2255 2259
2256void CalendarView::edit_cut() 2260void CalendarView::edit_cut()
2257{ 2261{
2258 Event *anEvent=0; 2262 Event *anEvent=0;
2259 2263
2260 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2264 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2261 2265
2262 if (mViewManager->currentView()->isEventView()) { 2266 if (mViewManager->currentView()->isEventView()) {
2263 if ( incidence && incidence->type() == "Event" ) { 2267 if ( incidence && incidence->type() == "Event" ) {
2264 anEvent = static_cast<Event *>(incidence); 2268 anEvent = static_cast<Event *>(incidence);
2265 } 2269 }
2266 } 2270 }
2267 2271
2268 if (!anEvent) { 2272 if (!anEvent) {
2269 KNotifyClient::beep(); 2273 KNotifyClient::beep();
2270 return; 2274 return;
2271 } 2275 }
2272 DndFactory factory( mCalendar ); 2276 DndFactory factory( mCalendar );
2273 factory.cutIncidence(anEvent); 2277 factory.cutIncidence(anEvent);
2274 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2278 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2275} 2279}
2276 2280
2277void CalendarView::edit_copy() 2281void CalendarView::edit_copy()
2278{ 2282{
2279 Event *anEvent=0; 2283 Event *anEvent=0;
2280 2284
2281 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2285 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2282 2286
2283 if (mViewManager->currentView()->isEventView()) { 2287 if (mViewManager->currentView()->isEventView()) {
2284 if ( incidence && incidence->type() == "Event" ) { 2288 if ( incidence && incidence->type() == "Event" ) {
2285 anEvent = static_cast<Event *>(incidence); 2289 anEvent = static_cast<Event *>(incidence);
2286 } 2290 }
2287 } 2291 }
2288 2292
2289 if (!anEvent) { 2293 if (!anEvent) {
2290 KNotifyClient::beep(); 2294 KNotifyClient::beep();
2291 return; 2295 return;
2292 } 2296 }
2293 DndFactory factory( mCalendar ); 2297 DndFactory factory( mCalendar );
2294 factory.copyIncidence(anEvent); 2298 factory.copyIncidence(anEvent);
2295} 2299}
2296 2300
2297void CalendarView::edit_paste() 2301void CalendarView::edit_paste()
2298{ 2302{
2299 QDate date = mNavigator->selectedDates().first(); 2303 QDate date = mNavigator->selectedDates().first();
2300 2304
2301 DndFactory factory( mCalendar ); 2305 DndFactory factory( mCalendar );
2302 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2306 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2303 2307
2304 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2308 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2305} 2309}
2306 2310
2307void CalendarView::edit_options() 2311void CalendarView::edit_options()
2308{ 2312{
2309 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2313 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2310 emit save(); 2314 emit save();
2311 emit saveStopTimer(); 2315 emit saveStopTimer();
2312 mDialogManager->showOptionsDialog(); 2316 mDialogManager->showOptionsDialog();
2313 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2317 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2314 emit saveStopTimer(); 2318 emit saveStopTimer();
2315 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2319 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2316 i18n("Timezone settings"),i18n("Reload"))) { 2320 i18n("Timezone settings"),i18n("Reload"))) {
2317 qDebug("KO: TZ reload cancelled "); 2321 qDebug("KO: TZ reload cancelled ");
2318 return; 2322 return;
2319 } 2323 }
2320 qDebug("KO: Timezone change "); 2324 qDebug("KO: Timezone change ");
2321 openCalendar( MainWindow::defaultFileName() ); 2325 openCalendar( MainWindow::defaultFileName() );
2322 setModified(true); 2326 setModified(true);
2323 } 2327 }
2324 else 2328 else
2325 qDebug("KO: No tz change "); 2329 qDebug("KO: No tz change ");
2326 2330
2327} 2331}
2328 2332
2329 2333
2330void CalendarView::slotSelectPickerDate( QDate d) 2334void CalendarView::slotSelectPickerDate( QDate d)
2331{ 2335{
2332 mDateFrame->hide(); 2336 mDateFrame->hide();
2333 if ( mDatePickerMode == 1 ) { 2337 if ( mDatePickerMode == 1 ) {
2334 mNavigator->slotDaySelect( d ); 2338 mNavigator->slotDaySelect( d );
2335 } else if ( mDatePickerMode == 2 ) { 2339 } else if ( mDatePickerMode == 2 ) {
2336 if ( mMoveIncidence->type() == "Todo" ) { 2340 if ( mMoveIncidence->type() == "Todo" ) {
2337 Todo * to = (Todo *) mMoveIncidence; 2341 Todo * to = (Todo *) mMoveIncidence;
2338 QTime tim; 2342 QTime tim;
2339 int len = 0; 2343 int len = 0;
2340 if ( to->hasStartDate() && to->hasDueDate() ) 2344 if ( to->hasStartDate() && to->hasDueDate() )
2341 len = to->dtStart().secsTo( to->dtDue()); 2345 len = to->dtStart().secsTo( to->dtDue());
2342 if ( to->hasDueDate() ) 2346 if ( to->hasDueDate() )
2343 tim = to->dtDue().time(); 2347 tim = to->dtDue().time();
2344 else { 2348 else {
2345 tim = QTime ( 0,0,0 ); 2349 tim = QTime ( 0,0,0 );
2346 to->setFloats( true ); 2350 to->setFloats( true );
2347 to->setHasDueDate( true ); 2351 to->setHasDueDate( true );
2348 } 2352 }
2349 QDateTime dt ( d,tim ); 2353 QDateTime dt ( d,tim );
2350 to->setDtDue( dt ); 2354 to->setDtDue( dt );
2351 2355
2352 if ( to->hasStartDate() ) { 2356 if ( to->hasStartDate() ) {
2353 if ( len>0 ) 2357 if ( len>0 )
2354 to->setDtStart(to->dtDue().addSecs( -len )); 2358 to->setDtStart(to->dtDue().addSecs( -len ));
2355 else 2359 else
2356 if (to->dtStart() > to->dtDue() ) 2360 if (to->dtStart() > to->dtDue() )
2357 to->setDtStart(to->dtDue().addDays( -3 )); 2361 to->setDtStart(to->dtDue().addDays( -3 ));
2358 } 2362 }
2359 2363
2360 todoChanged( to ); 2364 todoChanged( to );
2361 } else { 2365 } else {
2362 if ( mMoveIncidence->doesRecur() ) { 2366 if ( mMoveIncidence->doesRecur() ) {
2363#if 0 2367#if 0
2364 // PENDING implement this 2368 // PENDING implement this
2365 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2369 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2366 mCalendar()->addIncidence( newInc ); 2370 mCalendar()->addIncidence( newInc );
2367 if ( mMoveIncidence->type() == "Todo" ) 2371 if ( mMoveIncidence->type() == "Todo" )
2368 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2372 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2369 else 2373 else
2370 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2374 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2371 mMoveIncidence = newInc; 2375 mMoveIncidence = newInc;
2372 2376
2373#endif 2377#endif
2374 } 2378 }
2375 QTime tim = mMoveIncidence->dtStart().time(); 2379 QTime tim = mMoveIncidence->dtStart().time();
2376 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2380 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2377 QDateTime dt ( d,tim ); 2381 QDateTime dt ( d,tim );
2378 mMoveIncidence->setDtStart( dt ); 2382 mMoveIncidence->setDtStart( dt );
2379 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2383 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2380 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2384 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2381 } 2385 }
2382 2386
2383 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2387 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2384 } 2388 }
2385} 2389}
2386 2390
2387void CalendarView::removeCategories() 2391void CalendarView::removeCategories()
2388{ 2392{
2389 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2393 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2390 QStringList catList = KOPrefs::instance()->mCustomCategories; 2394 QStringList catList = KOPrefs::instance()->mCustomCategories;
2391 QStringList catIncList; 2395 QStringList catIncList;
2392 QStringList newCatList; 2396 QStringList newCatList;
2393 Incidence* inc = incList.first(); 2397 Incidence* inc = incList.first();
2394 int i; 2398 int i;
2395 int count = 0; 2399 int count = 0;
2396 while ( inc ) { 2400 while ( inc ) {
2397 newCatList.clear(); 2401 newCatList.clear();
2398 catIncList = inc->categories() ; 2402 catIncList = inc->categories() ;
2399 for( i = 0; i< catIncList.count(); ++i ) { 2403 for( i = 0; i< catIncList.count(); ++i ) {
2400 if ( catList.contains (catIncList[i])) 2404 if ( catList.contains (catIncList[i]))
2401 newCatList.append( catIncList[i] ); 2405 newCatList.append( catIncList[i] );
2402 } 2406 }
2403 newCatList.sort(); 2407 newCatList.sort();
2404 inc->setCategories( newCatList.join(",") ); 2408 inc->setCategories( newCatList.join(",") );
2405 inc = incList.next(); 2409 inc = incList.next();
2406 } 2410 }
2407} 2411}
2408 2412
2409int CalendarView::addCategories() 2413int CalendarView::addCategories()
2410{ 2414{
2411 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2415 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2412 QStringList catList = KOPrefs::instance()->mCustomCategories; 2416 QStringList catList = KOPrefs::instance()->mCustomCategories;
2413 QStringList catIncList; 2417 QStringList catIncList;
2414 Incidence* inc = incList.first(); 2418 Incidence* inc = incList.first();
2415 int i; 2419 int i;
2416 int count = 0; 2420 int count = 0;
2417 while ( inc ) { 2421 while ( inc ) {
2418 catIncList = inc->categories() ; 2422 catIncList = inc->categories() ;
2419 for( i = 0; i< catIncList.count(); ++i ) { 2423 for( i = 0; i< catIncList.count(); ++i ) {
2420 if ( !catList.contains (catIncList[i])) { 2424 if ( !catList.contains (catIncList[i])) {
2421 catList.append( catIncList[i] ); 2425 catList.append( catIncList[i] );
2422 //qDebug("add cat %s ", catIncList[i].latin1()); 2426 //qDebug("add cat %s ", catIncList[i].latin1());
2423 ++count; 2427 ++count;
2424 } 2428 }
2425 } 2429 }
2426 inc = incList.next(); 2430 inc = incList.next();
2427 } 2431 }
2428 catList.sort(); 2432 catList.sort();
2429 KOPrefs::instance()->mCustomCategories = catList; 2433 KOPrefs::instance()->mCustomCategories = catList;
2430 return count; 2434 return count;
2431} 2435}
2432 2436
2433void CalendarView::manageCategories() 2437void CalendarView::manageCategories()
2434{ 2438{
2435 KOCatPrefs* cp = new KOCatPrefs(); 2439 KOCatPrefs* cp = new KOCatPrefs();
2436 cp->show(); 2440 cp->show();
2437 int w =cp->sizeHint().width() ; 2441 int w =cp->sizeHint().width() ;
2438 int h = cp->sizeHint().height() ; 2442 int h = cp->sizeHint().height() ;
2439 int dw = QApplication::desktop()->width(); 2443 int dw = QApplication::desktop()->width();
2440 int dh = QApplication::desktop()->height(); 2444 int dh = QApplication::desktop()->height();
2441 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2445 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2442 if ( !cp->exec() ) { 2446 if ( !cp->exec() ) {
2443 delete cp; 2447 delete cp;
2444 return; 2448 return;
2445 } 2449 }
2446 int count = 0; 2450 int count = 0;
2447 if ( cp->addCat() ) { 2451 if ( cp->addCat() ) {
2448 count = addCategories(); 2452 count = addCategories();
2449 if ( count ) { 2453 if ( count ) {
2450 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2454 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2451 writeSettings(); 2455 writeSettings();
2452 } else 2456 } else
2453 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2457 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2454 } else { 2458 } else {
2455 removeCategories(); 2459 removeCategories();
2456 updateView(); 2460 updateView();
2457 } 2461 }
2458 delete cp; 2462 delete cp;
2459} 2463}
2460 2464
2461void CalendarView::beamIncidence(Incidence * Inc) 2465void CalendarView::beamIncidence(Incidence * Inc)
2462{ 2466{
2463 QPtrList<Incidence> delSel ; 2467 QPtrList<Incidence> delSel ;
2464 delSel.append(Inc); 2468 delSel.append(Inc);
2465 beamIncidenceList( delSel ); 2469 beamIncidenceList( delSel );
2466} 2470}
2467void CalendarView::beamCalendar() 2471void CalendarView::beamCalendar()
2468{ 2472{
2469 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2473 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2470 //qDebug("beamCalendar() "); 2474 //qDebug("beamCalendar() ");
2471 beamIncidenceList( delSel ); 2475 beamIncidenceList( delSel );
2472} 2476}
2473void CalendarView::beamFilteredCalendar() 2477void CalendarView::beamFilteredCalendar()
2474{ 2478{
2475 QPtrList<Incidence> delSel = mCalendar->incidences(); 2479 QPtrList<Incidence> delSel = mCalendar->incidences();
2476 //qDebug("beamFilteredCalendar() "); 2480 //qDebug("beamFilteredCalendar() ");
2477 beamIncidenceList( delSel ); 2481 beamIncidenceList( delSel );
2478} 2482}
2479void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2483void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2480{ 2484{
2481 if ( beamDialog->exec () == QDialog::Rejected ) 2485 if ( beamDialog->exec () == QDialog::Rejected )
2482 return; 2486 return;
2483#ifdef DESKTOP_VERSION 2487#ifdef DESKTOP_VERSION
2484 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2488 QString fn = locateLocal( "tmp", "kopibeamfile" );
2485#else 2489#else
2486 QString fn = "/tmp/kopibeamfile"; 2490 QString fn = "/tmp/kopibeamfile";
2487#endif 2491#endif
2488 QString mes; 2492 QString mes;
2489 bool createbup = true; 2493 bool createbup = true;
2490 if ( createbup ) { 2494 if ( createbup ) {
2491 QString description = "\n"; 2495 QString description = "\n";
2492 CalendarLocal* cal = new CalendarLocal(); 2496 CalendarLocal* cal = new CalendarLocal();
2493 if ( beamDialog->beamLocal() ) 2497 if ( beamDialog->beamLocal() )
2494 cal->setLocalTime(); 2498 cal->setLocalTime();
2495 else 2499 else
2496 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2500 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2497 Incidence *incidence = delSel.first(); 2501 Incidence *incidence = delSel.first();
2498 bool addText = false; 2502 bool addText = false;
2499 if ( delSel.count() < 10 ) 2503 if ( delSel.count() < 10 )
2500 addText = true; 2504 addText = true;
2501 else { 2505 else {
2502 description.sprintf(i18n(" %d items?"),delSel.count() ); 2506 description.sprintf(i18n(" %d items?"),delSel.count() );
2503 } 2507 }
2504 while ( incidence ) { 2508 while ( incidence ) {
2505 Incidence *in = incidence->clone(); 2509 Incidence *in = incidence->clone();
2506 if ( ! in->summary().isEmpty() ) { 2510 if ( ! in->summary().isEmpty() ) {
2507 in->setDescription(""); 2511 in->setDescription("");
2508 } else { 2512 } else {
2509 in->setSummary( in->description().left(20)); 2513 in->setSummary( in->description().left(20));
2510 in->setDescription(""); 2514 in->setDescription("");
2511 } 2515 }
2512 if ( addText ) 2516 if ( addText )
2513 description += in->summary() + "\n"; 2517 description += in->summary() + "\n";
2514 cal->addIncidence( in ); 2518 cal->addIncidence( in );
2515 incidence = delSel.next(); 2519 incidence = delSel.next();
2516 } 2520 }
2517 if ( beamDialog->beamVcal() ) { 2521 if ( beamDialog->beamVcal() ) {
2518 fn += ".vcs"; 2522 fn += ".vcs";
2519 FileStorage storage( cal, fn, new VCalFormat ); 2523 FileStorage storage( cal, fn, new VCalFormat );
2520 storage.save(); 2524 storage.save();
2521 } else { 2525 } else {
2522 fn += ".ics"; 2526 fn += ".ics";
2523 FileStorage storage( cal, fn, new ICalFormat( ) ); 2527 FileStorage storage( cal, fn, new ICalFormat( ) );
2524 storage.save(); 2528 storage.save();
2525 } 2529 }
2526 delete cal; 2530 delete cal;
2527 mes = i18n("KO/Pi: Ready for beaming"); 2531 mes = i18n("KO/Pi: Ready for beaming");
2528 topLevelWidget()->setCaption(mes); 2532 topLevelWidget()->setCaption(mes);
2529 KApplication::convert2latin1( fn ); 2533 KApplication::convert2latin1( fn );
2530#ifndef DESKTOP_VERSION 2534#ifndef DESKTOP_VERSION
2531 Ir *ir = new Ir( this ); 2535 Ir *ir = new Ir( this );
2532 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2536 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2533 ir->send( fn, description, "text/x-vCalendar" ); 2537 ir->send( fn, description, "text/x-vCalendar" );
2534#endif 2538#endif
2535 } 2539 }
2536} 2540}
2537void CalendarView::beamDone( Ir *ir ) 2541void CalendarView::beamDone( Ir *ir )
2538{ 2542{
2539#ifndef DESKTOP_VERSION 2543#ifndef DESKTOP_VERSION
2540 delete ir; 2544 delete ir;
2541#endif 2545#endif
2542 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2546 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2543 topLevelWidget()->raise(); 2547 topLevelWidget()->raise();
2544} 2548}
2545 2549
2546void CalendarView::moveIncidence(Incidence * inc ) 2550void CalendarView::moveIncidence(Incidence * inc )
2547{ 2551{
2548 if ( !inc ) return; 2552 if ( !inc ) return;
2549 showDatePickerPopup(); 2553 showDatePickerPopup();
2550 mDatePickerMode = 2; 2554 mDatePickerMode = 2;
2551 mMoveIncidence = inc ; 2555 mMoveIncidence = inc ;
2552 QDate da; 2556 QDate da;
2553 if ( mMoveIncidence->type() == "Todo" ) { 2557 if ( mMoveIncidence->type() == "Todo" ) {
2554 Todo * to = (Todo *) mMoveIncidence; 2558 Todo * to = (Todo *) mMoveIncidence;
2555 if ( to->hasDueDate() ) 2559 if ( to->hasDueDate() )
2556 da = to->dtDue().date(); 2560 da = to->dtDue().date();
2557 else 2561 else
2558 da = QDate::currentDate(); 2562 da = QDate::currentDate();
2559 } else { 2563 } else {
2560 da = mMoveIncidence->dtStart().date(); 2564 da = mMoveIncidence->dtStart().date();
2561 } 2565 }
2562 //PENDING set date for recurring incidence to date of recurrence 2566 //PENDING set date for recurring incidence to date of recurrence
2563 //mMoveIncidenceOldDate; 2567 //mMoveIncidenceOldDate;
2564 mDatePicker->setDate( da ); 2568 mDatePicker->setDate( da );
2565} 2569}
2566void CalendarView::showDatePickerPopup() 2570void CalendarView::showDatePickerPopup()
2567{ 2571{
2568 if ( mDateFrame->isVisible() ) 2572 if ( mDateFrame->isVisible() )
2569 mDateFrame->hide(); 2573 mDateFrame->hide();
2570 else { 2574 else {
2571 int offX = 0, offY = 0; 2575 int offX = 0, offY = 0;
2572#ifdef DESKTOP_VERSION 2576#ifdef DESKTOP_VERSION
2573 int w =mDatePicker->sizeHint().width() ; 2577 int w =mDatePicker->sizeHint().width() ;
2574 int h = mDatePicker->sizeHint().height() ; 2578 int h = mDatePicker->sizeHint().height() ;
2575 int dw = topLevelWidget()->width(); 2579 int dw = topLevelWidget()->width();
2576 int dh = topLevelWidget()->height(); 2580 int dh = topLevelWidget()->height();
2577 offX = topLevelWidget()->x(); 2581 offX = topLevelWidget()->x();
2578 offY = topLevelWidget()->y(); 2582 offY = topLevelWidget()->y();
2579#else 2583#else
2580 int w =mDatePicker->sizeHint().width() ; 2584 int w =mDatePicker->sizeHint().width() ;
2581 int h = mDatePicker->sizeHint().height() ; 2585 int h = mDatePicker->sizeHint().height() ;
2582 int dw = QApplication::desktop()->width(); 2586 int dw = QApplication::desktop()->width();
2583 int dh = QApplication::desktop()->height(); 2587 int dh = QApplication::desktop()->height();
2584#endif 2588#endif
2585 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2589 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2586 mDateFrame->show(); 2590 mDateFrame->show();
2587 } 2591 }
2588} 2592}
2589void CalendarView::showDatePicker( ) 2593void CalendarView::showDatePicker( )
2590{ 2594{
2591 showDatePickerPopup(); 2595 showDatePickerPopup();
2592 mDatePickerMode = 1; 2596 mDatePickerMode = 1;
2593 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2597 mDatePicker->setDate( mNavigator->selectedDates().first() );
2594} 2598}
2595 2599
2596void CalendarView::showEventEditor() 2600void CalendarView::showEventEditor()
2597{ 2601{
2598#ifdef DESKTOP_VERSION 2602#ifdef DESKTOP_VERSION
2599 int x,y,w,h; 2603 int x,y,w,h;
2600 x = mEventEditor->geometry().x(); 2604 x = mEventEditor->geometry().x();
2601 y = mEventEditor->geometry().y(); 2605 y = mEventEditor->geometry().y();
2602 w = mEventEditor->width(); 2606 w = mEventEditor->width();
2603 h = mEventEditor->height(); 2607 h = mEventEditor->height();
2604 mEventEditor->show(); 2608 mEventEditor->show();
2605 mEventEditor->setGeometry(x,y,w,h); 2609 mEventEditor->setGeometry(x,y,w,h);
2606#else 2610#else
2607 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2611 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2608 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2612 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2609 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2613 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2610 qApp->processEvents(); 2614 qApp->processEvents();
2611 delete mEventEditor; 2615 delete mEventEditor;
2612 mEventEditor = mDialogManager->getEventEditor(); 2616 mEventEditor = mDialogManager->getEventEditor();
2613 topLevelWidget()->setCaption( i18n("") ); 2617 topLevelWidget()->setCaption( i18n("") );
2614 } 2618 }
2615 mEventEditor->showMaximized(); 2619 mEventEditor->showMaximized();
2616#endif 2620#endif
2617} 2621}
2618void CalendarView::showTodoEditor() 2622void CalendarView::showTodoEditor()
2619{ 2623{
2620#ifdef DESKTOP_VERSION 2624#ifdef DESKTOP_VERSION
2621 int x,y,w,h; 2625 int x,y,w,h;
2622 x = mTodoEditor->geometry().x(); 2626 x = mTodoEditor->geometry().x();
2623 y = mTodoEditor->geometry().y(); 2627 y = mTodoEditor->geometry().y();
2624 w = mTodoEditor->width(); 2628 w = mTodoEditor->width();
2625 h = mTodoEditor->height(); 2629 h = mTodoEditor->height();
2626 mTodoEditor->show(); 2630 mTodoEditor->show();
2627 mTodoEditor->setGeometry(x,y,w,h); 2631 mTodoEditor->setGeometry(x,y,w,h);
2628#else 2632#else
2629 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2633 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2630 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2634 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2631 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2635 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2632 qApp->processEvents(); 2636 qApp->processEvents();
2633 delete mTodoEditor; 2637 delete mTodoEditor;
2634 mTodoEditor = mDialogManager->getTodoEditor(); 2638 mTodoEditor = mDialogManager->getTodoEditor();
2635 topLevelWidget()->setCaption( i18n("") ); 2639 topLevelWidget()->setCaption( i18n("") );
2636 } 2640 }
2637 mTodoEditor->showMaximized(); 2641 mTodoEditor->showMaximized();
2638#endif 2642#endif
2639} 2643}
2640 2644
2641void CalendarView::cloneIncidence() 2645void CalendarView::cloneIncidence()
2642{ 2646{
2643 Incidence *incidence = currentSelection(); 2647 Incidence *incidence = currentSelection();
2644 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2648 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2645 if ( incidence ) { 2649 if ( incidence ) {
2646 cloneIncidence(incidence); 2650 cloneIncidence(incidence);
2647 } 2651 }
2648} 2652}
2649void CalendarView::moveIncidence() 2653void CalendarView::moveIncidence()
2650{ 2654{
2651 Incidence *incidence = currentSelection(); 2655 Incidence *incidence = currentSelection();
2652 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2656 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2653 if ( incidence ) { 2657 if ( incidence ) {
2654 moveIncidence(incidence); 2658 moveIncidence(incidence);
2655 } 2659 }
2656} 2660}
2657void CalendarView::beamIncidence() 2661void CalendarView::beamIncidence()
2658{ 2662{
2659 Incidence *incidence = currentSelection(); 2663 Incidence *incidence = currentSelection();
2660 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2664 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2661 if ( incidence ) { 2665 if ( incidence ) {
2662 beamIncidence(incidence); 2666 beamIncidence(incidence);
2663 } 2667 }
2664} 2668}
2665void CalendarView::toggleCancelIncidence() 2669void CalendarView::toggleCancelIncidence()
2666{ 2670{
2667 Incidence *incidence = currentSelection(); 2671 Incidence *incidence = currentSelection();
2668 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2672 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2669 if ( incidence ) { 2673 if ( incidence ) {
2670 cancelIncidence(incidence); 2674 cancelIncidence(incidence);
2671 } 2675 }
2672} 2676}
2673 2677
2674 2678
2675void CalendarView::cancelIncidence(Incidence * inc ) 2679void CalendarView::cancelIncidence(Incidence * inc )
2676{ 2680{
2677 inc->setCancelled( ! inc->cancelled() ); 2681 inc->setCancelled( ! inc->cancelled() );
2678 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2682 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2679 updateView(); 2683 updateView();
2680} 2684}
2681void CalendarView::cloneIncidence(Incidence * orgInc ) 2685void CalendarView::cloneIncidence(Incidence * orgInc )
2682{ 2686{
2683 Incidence * newInc = orgInc->clone(); 2687 Incidence * newInc = orgInc->clone();
2684 newInc->recreate(); 2688 newInc->recreate();
2685 2689
2686 if ( newInc->type() == "Todo" ) { 2690 if ( newInc->type() == "Todo" ) {
2687 Todo* t = (Todo*) newInc; 2691 Todo* t = (Todo*) newInc;
2688 showTodoEditor(); 2692 showTodoEditor();
2689 mTodoEditor->editTodo( t ); 2693 mTodoEditor->editTodo( t );
2690 if ( mTodoEditor->exec() ) { 2694 if ( mTodoEditor->exec() ) {
2691 mCalendar->addTodo( t ); 2695 mCalendar->addTodo( t );
2692 updateView(); 2696 updateView();
2693 } else { 2697 } else {
2694 delete t; 2698 delete t;
2695 } 2699 }
2696 } 2700 }
2697 else { 2701 else {
2698 Event* e = (Event*) newInc; 2702 Event* e = (Event*) newInc;
2699 showEventEditor(); 2703 showEventEditor();
2700 mEventEditor->editEvent( e ); 2704 mEventEditor->editEvent( e );
2701 if ( mEventEditor->exec() ) { 2705 if ( mEventEditor->exec() ) {
2702 mCalendar->addEvent( e ); 2706 mCalendar->addEvent( e );
2703 updateView(); 2707 updateView();
2704 } else { 2708 } else {
2705 delete e; 2709 delete e;
2706 } 2710 }
2707 } 2711 }
2708 setActiveWindow(); 2712 setActiveWindow();
2709} 2713}
2710 2714
2711void CalendarView::newEvent() 2715void CalendarView::newEvent()
2712{ 2716{
2713 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2717 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2714 KOAgendaView *aView = mViewManager->agendaView(); 2718 KOAgendaView *aView = mViewManager->agendaView();
2715 if (aView) { 2719 if (aView) {
2716 if (aView->selectionStart().isValid()) { 2720 if (aView->selectionStart().isValid()) {
2717 if (aView->selectedIsAllDay()) { 2721 if (aView->selectedIsAllDay()) {
2718 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2722 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2719 } else { 2723 } else {
2720 newEvent(aView->selectionStart(),aView->selectionEnd()); 2724 newEvent(aView->selectionStart(),aView->selectionEnd());
2721 } 2725 }
2722 return; 2726 return;
2723 } 2727 }
2724 } 2728 }
2725 2729
2726 QDate date = mNavigator->selectedDates().first(); 2730 QDate date = mNavigator->selectedDates().first();
2727 QDateTime current = QDateTime::currentDateTime(); 2731 QDateTime current = QDateTime::currentDateTime();
2728 if ( date <= current.date() ) { 2732 if ( date <= current.date() ) {
2729 int hour = current.time().hour() +1; 2733 int hour = current.time().hour() +1;
2730 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2734 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2731 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2735 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2732 } else 2736 } else
2733 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2737 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2734 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2738 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2735 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2739 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2736} 2740}
2737 2741
2738void CalendarView::newEvent(QDateTime fh) 2742void CalendarView::newEvent(QDateTime fh)
2739{ 2743{
2740 newEvent(fh, 2744 newEvent(fh,
2741 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2745 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2742} 2746}
2743 2747
2744void CalendarView::newEvent(QDate dt) 2748void CalendarView::newEvent(QDate dt)
2745{ 2749{
2746 newEvent(QDateTime(dt, QTime(0,0,0)), 2750 newEvent(QDateTime(dt, QTime(0,0,0)),
2747 QDateTime(dt, QTime(0,0,0)), true); 2751 QDateTime(dt, QTime(0,0,0)), true);
2748} 2752}
2749void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2753void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2750{ 2754{
2751 newEvent(fromHint, toHint, false); 2755 newEvent(fromHint, toHint, false);
2752} 2756}
2753void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2757void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2754{ 2758{
2755 2759
2756 showEventEditor(); 2760 showEventEditor();
2757 mEventEditor->newEvent(fromHint,toHint,allDay); 2761 mEventEditor->newEvent(fromHint,toHint,allDay);
2758 if ( mFilterView->filtersEnabled() ) { 2762 if ( mFilterView->filtersEnabled() ) {
2759 CalFilter *filter = mFilterView->selectedFilter(); 2763 CalFilter *filter = mFilterView->selectedFilter();
2760 if (filter && filter->showCategories()) { 2764 if (filter && filter->showCategories()) {
2761 mEventEditor->setCategories(filter->categoryList().join(",") ); 2765 mEventEditor->setCategories(filter->categoryList().join(",") );
2762 } 2766 }
2763 if ( filter ) 2767 if ( filter )
2764 mEventEditor->setSecrecy( filter->getSecrecy() ); 2768 mEventEditor->setSecrecy( filter->getSecrecy() );
2765 } 2769 }
2766 mEventEditor->exec(); 2770 mEventEditor->exec();
2767 setActiveWindow(); 2771 setActiveWindow();
2768} 2772}
2769void CalendarView::todoAdded(Todo * t) 2773void CalendarView::todoAdded(Todo * t)
2770{ 2774{
2771 2775
2772 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2776 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2773 updateTodoViews(); 2777 updateTodoViews();
2774} 2778}
2775void CalendarView::todoChanged(Todo * t) 2779void CalendarView::todoChanged(Todo * t)
2776{ 2780{
2777 emit todoModified( t, 4 ); 2781 emit todoModified( t, 4 );
2778 // updateTodoViews(); 2782 // updateTodoViews();
2779} 2783}
2780void CalendarView::todoToBeDeleted(Todo *) 2784void CalendarView::todoToBeDeleted(Todo *)
2781{ 2785{
2782 //qDebug("todoToBeDeleted(Todo *) "); 2786 //qDebug("todoToBeDeleted(Todo *) ");
2783 updateTodoViews(); 2787 updateTodoViews();
2784} 2788}
2785void CalendarView::todoDeleted() 2789void CalendarView::todoDeleted()
2786{ 2790{
2787 //qDebug(" todoDeleted()"); 2791 //qDebug(" todoDeleted()");
2788 updateTodoViews(); 2792 updateTodoViews();
2789} 2793}
2790 2794
2791 2795
2792void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2796void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2793{ 2797{
2794 showTodoEditor(); 2798 showTodoEditor();
2795 mTodoEditor->newTodo(dt,0,allday); 2799 mTodoEditor->newTodo(dt,0,allday);
2796 if ( mFilterView->filtersEnabled() ) { 2800 if ( mFilterView->filtersEnabled() ) {
2797 CalFilter *filter = mFilterView->selectedFilter(); 2801 CalFilter *filter = mFilterView->selectedFilter();
2798 if (filter && filter->showCategories()) { 2802 if (filter && filter->showCategories()) {
2799 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2803 mTodoEditor->setCategories(filter->categoryList().join(",") );
2800 } 2804 }
2801 if ( filter ) 2805 if ( filter )
2802 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2806 mTodoEditor->setSecrecy( filter->getSecrecy() );
2803 } 2807 }
2804 mTodoEditor->exec(); 2808 mTodoEditor->exec();
2805 setActiveWindow(); 2809 setActiveWindow();
2806} 2810}
2807 2811
2808void CalendarView::newTodo() 2812void CalendarView::newTodo()
2809{ 2813{
2810 newTodoDateTime( QDateTime(),true ); 2814 newTodoDateTime( QDateTime(),true );
2811} 2815}
2812 2816
2813void CalendarView::newSubTodo() 2817void CalendarView::newSubTodo()
2814{ 2818{
2815 Todo *todo = selectedTodo(); 2819 Todo *todo = selectedTodo();
2816 if ( todo ) newSubTodo( todo ); 2820 if ( todo ) newSubTodo( todo );
2817} 2821}
2818 2822
2819void CalendarView::newSubTodo(Todo *parentEvent) 2823void CalendarView::newSubTodo(Todo *parentEvent)
2820{ 2824{
2821 2825
2822 showTodoEditor(); 2826 showTodoEditor();
2823 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2827 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2824 mTodoEditor->exec(); 2828 mTodoEditor->exec();
2825 setActiveWindow(); 2829 setActiveWindow();
2826} 2830}
2827 2831
2828void CalendarView::newFloatingEvent() 2832void CalendarView::newFloatingEvent()
2829{ 2833{
2830 DateList tmpList = mNavigator->selectedDates(); 2834 DateList tmpList = mNavigator->selectedDates();
2831 QDate date = tmpList.first(); 2835 QDate date = tmpList.first();
2832 2836
2833 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2837 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2834 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2838 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2835} 2839}
2836 2840
2837 2841
2838void CalendarView::editEvent( Event *event ) 2842void CalendarView::editEvent( Event *event )
2839{ 2843{
2840 2844
2841 if ( !event ) return; 2845 if ( !event ) return;
2842 if ( event->isReadOnly() ) { 2846 if ( event->isReadOnly() ) {
2843 showEvent( event ); 2847 showEvent( event );
2844 return; 2848 return;
2845 } 2849 }
2846 showEventEditor(); 2850 showEventEditor();
2847 mEventEditor->editEvent( event , mFlagEditDescription); 2851 mEventEditor->editEvent( event , mFlagEditDescription);
2848 mEventEditor->exec(); 2852 mEventEditor->exec();
2849 setActiveWindow(); 2853 setActiveWindow();
2850 2854
2851} 2855}
2852void CalendarView::editJournal( Journal *jour ) 2856void CalendarView::editJournal( Journal *jour )
2853{ 2857{
2854 if ( !jour ) return; 2858 if ( !jour ) return;
2855 mDialogManager->hideSearchDialog(); 2859 mDialogManager->hideSearchDialog();
2856 mViewManager->showJournalView(); 2860 mViewManager->showJournalView();
2857 mNavigator->slotDaySelect( jour->dtStart().date() ); 2861 mNavigator->slotDaySelect( jour->dtStart().date() );
2858} 2862}
2859void CalendarView::editTodo( Todo *todo ) 2863void CalendarView::editTodo( Todo *todo )
2860{ 2864{
2861 if ( !todo ) return; 2865 if ( !todo ) return;
2862 2866
2863 if ( todo->isReadOnly() ) { 2867 if ( todo->isReadOnly() ) {
2864 showTodo( todo ); 2868 showTodo( todo );
2865 return; 2869 return;
2866 } 2870 }
2867 showTodoEditor(); 2871 showTodoEditor();
2868 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2872 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2869 mTodoEditor->exec(); 2873 mTodoEditor->exec();
2870 setActiveWindow(); 2874 setActiveWindow();
2871 2875
2872} 2876}
2873 2877
2874KOEventViewerDialog* CalendarView::getEventViewerDialog() 2878KOEventViewerDialog* CalendarView::getEventViewerDialog()
2875{ 2879{
2876 if ( !mEventViewerDialog ) { 2880 if ( !mEventViewerDialog ) {
2877 mEventViewerDialog = new KOEventViewerDialog(0); 2881 mEventViewerDialog = new KOEventViewerDialog(0);
2878 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2882 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2879 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2883 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2880 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2884 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2881 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2885 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2882 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2886 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2883 viewManager(), SLOT( showAgendaView( bool ) ) ); 2887 viewManager(), SLOT( showAgendaView( bool ) ) );
2884 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2888 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2885 this, SLOT( slotViewerClosed() ) ); 2889 this, SLOT( slotViewerClosed() ) );
2886 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2890 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2887 this, SLOT( todoChanged(Todo *) ) ); 2891 this, SLOT( todoChanged(Todo *) ) );
2888 mEventViewerDialog->resize( 640, 480 ); 2892 mEventViewerDialog->resize( 640, 480 );
2889 2893
2890 } 2894 }
2891 return mEventViewerDialog; 2895 return mEventViewerDialog;
2892} 2896}
2893void CalendarView::showEvent(Event *event) 2897void CalendarView::showEvent(Event *event)
2894{ 2898{
2895 getEventViewerDialog()->setEvent(event); 2899 getEventViewerDialog()->setEvent(event);
2896 getEventViewerDialog()->showMe(); 2900 getEventViewerDialog()->showMe();
2897} 2901}
2898 2902
2899void CalendarView::showTodo(Todo *event) 2903void CalendarView::showTodo(Todo *event)
2900{ 2904{
2901 getEventViewerDialog()->setTodo(event); 2905 getEventViewerDialog()->setTodo(event);
2902 getEventViewerDialog()->showMe(); 2906 getEventViewerDialog()->showMe();
2903} 2907}
2904void CalendarView::showJournal( Journal *jour ) 2908void CalendarView::showJournal( Journal *jour )
2905{ 2909{
2906 getEventViewerDialog()->setJournal(jour); 2910 getEventViewerDialog()->setJournal(jour);
2907 getEventViewerDialog()->showMe(); 2911 getEventViewerDialog()->showMe();
2908 2912
2909} 2913}
2910// void CalendarView::todoModified (Todo *event, int changed) 2914// void CalendarView::todoModified (Todo *event, int changed)
2911// { 2915// {
2912// // if (mDialogList.find (event) != mDialogList.end ()) { 2916// // if (mDialogList.find (event) != mDialogList.end ()) {
2913// // kdDebug() << "Todo modified and open" << endl; 2917// // kdDebug() << "Todo modified and open" << endl;
2914// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2918// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2915// // temp->modified (changed); 2919// // temp->modified (changed);
2916 2920
2917// // } 2921// // }
2918 2922
2919// mViewManager->updateView(); 2923// mViewManager->updateView();
2920// } 2924// }
2921 2925
2922void CalendarView::appointment_show() 2926void CalendarView::appointment_show()
2923{ 2927{
2924 Event *anEvent = 0; 2928 Event *anEvent = 0;
2925 2929
2926 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2930 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2927 2931
2928 if (mViewManager->currentView()->isEventView()) { 2932 if (mViewManager->currentView()->isEventView()) {
2929 if ( incidence && incidence->type() == "Event" ) { 2933 if ( incidence && incidence->type() == "Event" ) {
2930 anEvent = static_cast<Event *>(incidence); 2934 anEvent = static_cast<Event *>(incidence);
2931 } 2935 }
2932 } 2936 }
2933 2937
2934 if (!anEvent) { 2938 if (!anEvent) {
2935 KNotifyClient::beep(); 2939 KNotifyClient::beep();
2936 return; 2940 return;
2937 } 2941 }
2938 2942
2939 showEvent(anEvent); 2943 showEvent(anEvent);
2940} 2944}
2941 2945
2942void CalendarView::appointment_edit() 2946void CalendarView::appointment_edit()
2943{ 2947{
2944 Event *anEvent = 0; 2948 Event *anEvent = 0;
2945 2949
2946 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2950 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2947 2951
2948 if (mViewManager->currentView()->isEventView()) { 2952 if (mViewManager->currentView()->isEventView()) {
2949 if ( incidence && incidence->type() == "Event" ) { 2953 if ( incidence && incidence->type() == "Event" ) {
2950 anEvent = static_cast<Event *>(incidence); 2954 anEvent = static_cast<Event *>(incidence);
2951 } 2955 }
2952 } 2956 }
2953 2957
2954 if (!anEvent) { 2958 if (!anEvent) {
2955 KNotifyClient::beep(); 2959 KNotifyClient::beep();
2956 return; 2960 return;
2957 } 2961 }
2958 2962
2959 editEvent(anEvent); 2963 editEvent(anEvent);
2960} 2964}
2961 2965
2962void CalendarView::appointment_delete() 2966void CalendarView::appointment_delete()
2963{ 2967{
2964 Event *anEvent = 0; 2968 Event *anEvent = 0;
2965 2969
2966 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2970 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2967 2971
2968 if (mViewManager->currentView()->isEventView()) { 2972 if (mViewManager->currentView()->isEventView()) {
2969 if ( incidence && incidence->type() == "Event" ) { 2973 if ( incidence && incidence->type() == "Event" ) {
2970 anEvent = static_cast<Event *>(incidence); 2974 anEvent = static_cast<Event *>(incidence);
2971 } 2975 }
2972 } 2976 }
2973 2977
2974 if (!anEvent) { 2978 if (!anEvent) {
2975 KNotifyClient::beep(); 2979 KNotifyClient::beep();
2976 return; 2980 return;
2977 } 2981 }
2978 2982
2979 deleteEvent(anEvent); 2983 deleteEvent(anEvent);
2980} 2984}
2981 2985
2982void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2986void CalendarView::todo_resub( Todo * parent, Todo * sub )
2983{ 2987{
2984 if (!sub) return; 2988 if (!sub) return;
2985 if (!parent) return; 2989 if (!parent) return;
2986 if ( sub->relatedTo() ) 2990 if ( sub->relatedTo() )
2987 sub->relatedTo()->removeRelation(sub); 2991 sub->relatedTo()->removeRelation(sub);
2988 sub->setRelatedTo(parent); 2992 sub->setRelatedTo(parent);
2989 sub->setRelatedToUid(parent->uid()); 2993 sub->setRelatedToUid(parent->uid());
2990 parent->addRelation(sub); 2994 parent->addRelation(sub);
2991 sub->updated(); 2995 sub->updated();
2992 parent->updated(); 2996 parent->updated();
2993 setModified(true); 2997 setModified(true);
2994 updateView(); 2998 updateView();
2995} 2999}
2996void CalendarView::todo_unsub(Todo *anTodo ) 3000void CalendarView::todo_unsub(Todo *anTodo )
2997{ 3001{
2998 // Todo *anTodo = selectedTodo(); 3002 // Todo *anTodo = selectedTodo();
2999 if (!anTodo) return; 3003 if (!anTodo) return;
3000 if (!anTodo->relatedTo()) return; 3004 if (!anTodo->relatedTo()) return;
3001 anTodo->relatedTo()->removeRelation(anTodo); 3005 anTodo->relatedTo()->removeRelation(anTodo);
3002 anTodo->setRelatedTo(0); 3006 anTodo->setRelatedTo(0);
3003 anTodo->updated(); 3007 anTodo->updated();
3004 anTodo->setRelatedToUid(""); 3008 anTodo->setRelatedToUid("");
3005 setModified(true); 3009 setModified(true);
3006 updateView(); 3010 updateView();
3007} 3011}
3008 3012
3009void CalendarView::deleteTodo(Todo *todo) 3013void CalendarView::deleteTodo(Todo *todo)
3010{ 3014{
3011 if (!todo) { 3015 if (!todo) {
3012 KNotifyClient::beep(); 3016 KNotifyClient::beep();
3013 return; 3017 return;
3014 } 3018 }
3015 if (KOPrefs::instance()->mConfirm) { 3019 if (KOPrefs::instance()->mConfirm) {
3016 QString text = todo->summary().left(20); 3020 QString text = todo->summary().left(20);
3017 if (!todo->relations().isEmpty()) { 3021 if (!todo->relations().isEmpty()) {
3018 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3022 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3019 3023
3020 } 3024 }
3021 switch (msgItemDelete(text)) { 3025 switch (msgItemDelete(text)) {
3022 case KMessageBox::Continue: // OK 3026 case KMessageBox::Continue: // OK
3023 bool deleteT = false; 3027 bool deleteT = false;
3024 if (!todo->relations().isEmpty()) { 3028 if (!todo->relations().isEmpty()) {
3025 deleteT = removeCompletedSubTodos( todo ); 3029 deleteT = removeCompletedSubTodos( todo );
3026 } 3030 }
3027 // deleteT == true: todo already deleted in removeCompletedSubTodos 3031 // deleteT == true: todo already deleted in removeCompletedSubTodos
3028 if ( !deleteT ) { 3032 if ( !deleteT ) {
3029 checkExternalId( todo ); 3033 checkExternalId( todo );
3030 calendar()->deleteTodo(todo); 3034 calendar()->deleteTodo(todo);
3031 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3035 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3032 updateView(); 3036 updateView();
3033 } 3037 }
3034 break; 3038 break;
3035 } // switch 3039 } // switch
3036 } else { 3040 } else {
3037 checkExternalId( todo ); 3041 checkExternalId( todo );
3038 mCalendar->deleteTodo(todo); 3042 mCalendar->deleteTodo(todo);
3039 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3043 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3040 updateView(); 3044 updateView();
3041 } 3045 }
3042 3046
3043 emit updateSearchDialog(); 3047 emit updateSearchDialog();
3044} 3048}
3045void CalendarView::deleteJournal(Journal *jour) 3049void CalendarView::deleteJournal(Journal *jour)
3046{ 3050{
3047 if (!jour) { 3051 if (!jour) {
3048 KNotifyClient::beep(); 3052 KNotifyClient::beep();
3049 return; 3053 return;
3050 } 3054 }
3051 if (KOPrefs::instance()->mConfirm) { 3055 if (KOPrefs::instance()->mConfirm) {
3052 switch (msgItemDelete( jour->description().left(20))) { 3056 switch (msgItemDelete( jour->description().left(20))) {
3053 case KMessageBox::Continue: // OK 3057 case KMessageBox::Continue: // OK
3054 calendar()->deleteJournal(jour); 3058 calendar()->deleteJournal(jour);
3055 updateView(); 3059 updateView();
3056 break; 3060 break;
3057 } // switch 3061 } // switch
3058 } else { 3062 } else {
3059 calendar()->deleteJournal(jour);; 3063 calendar()->deleteJournal(jour);;
3060 updateView(); 3064 updateView();
3061 } 3065 }
3062 emit updateSearchDialog(); 3066 emit updateSearchDialog();
3063} 3067}
3064 3068
3065void CalendarView::deleteEvent(Event *anEvent) 3069void CalendarView::deleteEvent(Event *anEvent)
3066{ 3070{
3067 if (!anEvent) { 3071 if (!anEvent) {
3068 KNotifyClient::beep(); 3072 KNotifyClient::beep();
3069 return; 3073 return;
3070 } 3074 }
3071 3075
3072 if (anEvent->recurrence()->doesRecur()) { 3076 if (anEvent->recurrence()->doesRecur()) {
3073 QDate itemDate = mViewManager->currentSelectionDate(); 3077 QDate itemDate = mViewManager->currentSelectionDate();
3074 int km; 3078 int km;
3075 if (!itemDate.isValid()) { 3079 if (!itemDate.isValid()) {
3076 //kdDebug() << "Date Not Valid" << endl; 3080 //kdDebug() << "Date Not Valid" << endl;
3077 if (KOPrefs::instance()->mConfirm) { 3081 if (KOPrefs::instance()->mConfirm) {
3078 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3082 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3079 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3083 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3080 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3084 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3081 if ( km == KMessageBox::Continue ) 3085 if ( km == KMessageBox::Continue )
3082 km = KMessageBox::No; // No = all below 3086 km = KMessageBox::No; // No = all below
3083 } else 3087 } else
3084 km = KMessageBox::No; 3088 km = KMessageBox::No;
3085 } else { 3089 } else {
3086 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3090 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3087 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3091 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3088 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3092 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3089 i18n("KO/Pi Confirmation"),i18n("Current"), 3093 i18n("KO/Pi Confirmation"),i18n("Current"),
3090 i18n("All")); 3094 i18n("All"));
3091 } 3095 }
3092 switch(km) { 3096 switch(km) {
3093 3097
3094 case KMessageBox::No: // Continue // all 3098 case KMessageBox::No: // Continue // all
3095 //qDebug("KMessageBox::No "); 3099 //qDebug("KMessageBox::No ");
3096 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3100 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3097 schedule(Scheduler::Cancel,anEvent); 3101 schedule(Scheduler::Cancel,anEvent);
3098 3102
3099 checkExternalId( anEvent); 3103 checkExternalId( anEvent);
3100 mCalendar->deleteEvent(anEvent); 3104 mCalendar->deleteEvent(anEvent);
3101 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3105 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3102 break; 3106 break;
3103 3107
3104 // Disabled because it does not work 3108 // Disabled because it does not work
3105 //#if 0 3109 //#if 0
3106 case KMessageBox::Yes: // just this one 3110 case KMessageBox::Yes: // just this one
3107 //QDate qd = mNavigator->selectedDates().first(); 3111 //QDate qd = mNavigator->selectedDates().first();
3108 //if (!qd.isValid()) { 3112 //if (!qd.isValid()) {
3109 // kdDebug() << "no date selected, or invalid date" << endl; 3113 // kdDebug() << "no date selected, or invalid date" << endl;
3110 // KNotifyClient::beep(); 3114 // KNotifyClient::beep();
3111 // return; 3115 // return;
3112 //} 3116 //}
3113 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3117 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3114 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3118 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3115 anEvent->addExDate(itemDate); 3119 anEvent->addExDate(itemDate);
3116 int duration = anEvent->recurrence()->duration(); 3120 int duration = anEvent->recurrence()->duration();
3117 if ( duration > 0 ) { 3121 if ( duration > 0 ) {
3118 anEvent->recurrence()->setDuration( duration - 1 ); 3122 anEvent->recurrence()->setDuration( duration - 1 );
3119 } 3123 }
3120 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3124 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3121 } 3125 }
3122 break; 3126 break;
3123 //#endif 3127 //#endif
3124 } // switch 3128 } // switch
3125 } else { 3129 } else {
3126 if (KOPrefs::instance()->mConfirm) { 3130 if (KOPrefs::instance()->mConfirm) {
3127 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3131 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3128 i18n("\nAre you sure you want\nto delete this event?"), 3132 i18n("\nAre you sure you want\nto delete this event?"),
3129 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3133 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3130 case KMessageBox::Continue: // OK 3134 case KMessageBox::Continue: // OK
3131 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3135 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3132 schedule(Scheduler::Cancel,anEvent); 3136 schedule(Scheduler::Cancel,anEvent);
3133 checkExternalId( anEvent); 3137 checkExternalId( anEvent);
3134 mCalendar->deleteEvent(anEvent); 3138 mCalendar->deleteEvent(anEvent);
3135 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3139 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3136 break; 3140 break;
3137 } // switch 3141 } // switch
3138 } else { 3142 } else {
3139 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3143 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3140 schedule(Scheduler::Cancel,anEvent); 3144 schedule(Scheduler::Cancel,anEvent);
3141 checkExternalId( anEvent); 3145 checkExternalId( anEvent);
3142 mCalendar->deleteEvent(anEvent); 3146 mCalendar->deleteEvent(anEvent);
3143 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3147 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3144 } 3148 }
3145 } // if-else 3149 } // if-else
3146 emit updateSearchDialog(); 3150 emit updateSearchDialog();
3147} 3151}
3148 3152
3149bool CalendarView::deleteEvent(const QString &uid) 3153bool CalendarView::deleteEvent(const QString &uid)
3150{ 3154{
3151 Event *ev = mCalendar->event(uid); 3155 Event *ev = mCalendar->event(uid);
3152 if (ev) { 3156 if (ev) {
3153 deleteEvent(ev); 3157 deleteEvent(ev);
3154 return true; 3158 return true;
3155 } else { 3159 } else {
3156 return false; 3160 return false;
3157 } 3161 }
3158} 3162}
3159 3163
3160/*****************************************************************************/ 3164/*****************************************************************************/
3161 3165
3162void CalendarView::action_mail() 3166void CalendarView::action_mail()
3163{ 3167{
3164#ifndef KORG_NOMAIL 3168#ifndef KORG_NOMAIL
3165 KOMailClient mailClient; 3169 KOMailClient mailClient;
3166 3170
3167 Incidence *incidence = currentSelection(); 3171 Incidence *incidence = currentSelection();
3168 3172
3169 if (!incidence) { 3173 if (!incidence) {
3170 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3174 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3171 return; 3175 return;
3172 } 3176 }
3173 if(incidence->attendeeCount() == 0 ) { 3177 if(incidence->attendeeCount() == 0 ) {
3174 KMessageBox::sorry(this, 3178 KMessageBox::sorry(this,
3175 i18n("Can't generate mail:\nNo attendees defined.\n")); 3179 i18n("Can't generate mail:\nNo attendees defined.\n"));
3176 return; 3180 return;
3177 } 3181 }
3178 3182
3179 CalendarLocal cal_tmp; 3183 CalendarLocal cal_tmp;
3180 Event *event = 0; 3184 Event *event = 0;
3181 Event *ev = 0; 3185 Event *ev = 0;
3182 if ( incidence && incidence->type() == "Event" ) { 3186 if ( incidence && incidence->type() == "Event" ) {
3183 event = static_cast<Event *>(incidence); 3187 event = static_cast<Event *>(incidence);
3184 ev = new Event(*event); 3188 ev = new Event(*event);
3185 cal_tmp.addEvent(ev); 3189 cal_tmp.addEvent(ev);
3186 } 3190 }
3187 ICalFormat mForm(); 3191 ICalFormat mForm();
3188 QString attachment = mForm.toString( &cal_tmp ); 3192 QString attachment = mForm.toString( &cal_tmp );
3189 if (ev) delete(ev); 3193 if (ev) delete(ev);
3190 3194
3191 mailClient.mailAttendees(currentSelection(), attachment); 3195 mailClient.mailAttendees(currentSelection(), attachment);
3192 3196
3193#endif 3197#endif
3194 3198
3195#if 0 3199#if 0
3196 Event *anEvent = 0; 3200 Event *anEvent = 0;
3197 if (mViewManager->currentView()->isEventView()) { 3201 if (mViewManager->currentView()->isEventView()) {
3198 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3202 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3199 } 3203 }
3200 3204
3201 if (!anEvent) { 3205 if (!anEvent) {
3202 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3206 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3203 return; 3207 return;
3204 } 3208 }
3205 if(anEvent->attendeeCount() == 0 ) { 3209 if(anEvent->attendeeCount() == 0 ) {
3206 KMessageBox::sorry(this, 3210 KMessageBox::sorry(this,
3207 i18n("Can't generate mail:\nNo attendees defined.\n")); 3211 i18n("Can't generate mail:\nNo attendees defined.\n"));
3208 return; 3212 return;
3209 } 3213 }
3210 3214
3211 mailobject.emailEvent(anEvent); 3215 mailobject.emailEvent(anEvent);
3212#endif 3216#endif
3213} 3217}
3214 3218
3215 3219
3216void CalendarView::schedule_publish(Incidence *incidence) 3220void CalendarView::schedule_publish(Incidence *incidence)
3217{ 3221{
3218 Event *event = 0; 3222 Event *event = 0;
3219 Todo *todo = 0; 3223 Todo *todo = 0;
3220 3224
3221 if (incidence == 0) { 3225 if (incidence == 0) {
3222 incidence = mViewManager->currentView()->selectedIncidences().first(); 3226 incidence = mViewManager->currentView()->selectedIncidences().first();
3223 if (incidence == 0) { 3227 if (incidence == 0) {
3224 incidence = mTodoList->selectedIncidences().first(); 3228 incidence = mTodoList->selectedIncidences().first();
3225 } 3229 }
3226 } 3230 }
3227 if ( incidence && incidence->type() == "Event" ) { 3231 if ( incidence && incidence->type() == "Event" ) {
3228 event = static_cast<Event *>(incidence); 3232 event = static_cast<Event *>(incidence);
3229 } else { 3233 } else {
3230 if ( incidence && incidence->type() == "Todo" ) { 3234 if ( incidence && incidence->type() == "Todo" ) {
3231 todo = static_cast<Todo *>(incidence); 3235 todo = static_cast<Todo *>(incidence);
3232 } 3236 }
3233 } 3237 }
3234 3238
3235 if (!event && !todo) { 3239 if (!event && !todo) {
3236 KMessageBox::sorry(this,i18n("No event selected.")); 3240 KMessageBox::sorry(this,i18n("No event selected."));
3237 return; 3241 return;
3238 } 3242 }
3239 3243
3240 PublishDialog *publishdlg = new PublishDialog(); 3244 PublishDialog *publishdlg = new PublishDialog();
3241 if (incidence->attendeeCount()>0) { 3245 if (incidence->attendeeCount()>0) {
3242 QPtrList<Attendee> attendees = incidence->attendees(); 3246 QPtrList<Attendee> attendees = incidence->attendees();
3243 attendees.first(); 3247 attendees.first();
3244 while ( attendees.current()!=0 ) { 3248 while ( attendees.current()!=0 ) {
3245 publishdlg->addAttendee(attendees.current()); 3249 publishdlg->addAttendee(attendees.current());
3246 attendees.next(); 3250 attendees.next();
3247 } 3251 }
3248 } 3252 }
3249 bool send = true; 3253 bool send = true;
3250 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3254 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3251 if ( publishdlg->exec() != QDialog::Accepted ) 3255 if ( publishdlg->exec() != QDialog::Accepted )
3252 send = false; 3256 send = false;
3253 } 3257 }
3254 if ( send ) { 3258 if ( send ) {
3255 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3259 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3256 if ( event ) { 3260 if ( event ) {
3257 Event *ev = new Event(*event); 3261 Event *ev = new Event(*event);
3258 ev->registerObserver(0); 3262 ev->registerObserver(0);
3259 ev->clearAttendees(); 3263 ev->clearAttendees();
3260 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3264 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3261 delete(ev); 3265 delete(ev);
3262 } 3266 }
3263 } else { 3267 } else {
3264 if ( todo ) { 3268 if ( todo ) {
3265 Todo *ev = new Todo(*todo); 3269 Todo *ev = new Todo(*todo);
3266 ev->registerObserver(0); 3270 ev->registerObserver(0);
3267 ev->clearAttendees(); 3271 ev->clearAttendees();
3268 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3272 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3269 delete(ev); 3273 delete(ev);
3270 } 3274 }
3271 } 3275 }
3272 } 3276 }
3273 } 3277 }
3274 delete publishdlg; 3278 delete publishdlg;
3275} 3279}
3276 3280
3277void CalendarView::schedule_request(Incidence *incidence) 3281void CalendarView::schedule_request(Incidence *incidence)
3278{ 3282{
3279 schedule(Scheduler::Request,incidence); 3283 schedule(Scheduler::Request,incidence);
3280} 3284}
3281 3285
3282void CalendarView::schedule_refresh(Incidence *incidence) 3286void CalendarView::schedule_refresh(Incidence *incidence)
3283{ 3287{
3284 schedule(Scheduler::Refresh,incidence); 3288 schedule(Scheduler::Refresh,incidence);
3285} 3289}
3286 3290
3287void CalendarView::schedule_cancel(Incidence *incidence) 3291void CalendarView::schedule_cancel(Incidence *incidence)
3288{ 3292{
3289 schedule(Scheduler::Cancel,incidence); 3293 schedule(Scheduler::Cancel,incidence);
3290} 3294}
3291 3295
3292void CalendarView::schedule_add(Incidence *incidence) 3296void CalendarView::schedule_add(Incidence *incidence)
3293{ 3297{
3294 schedule(Scheduler::Add,incidence); 3298 schedule(Scheduler::Add,incidence);
3295} 3299}
3296 3300
3297void CalendarView::schedule_reply(Incidence *incidence) 3301void CalendarView::schedule_reply(Incidence *incidence)
3298{ 3302{
3299 schedule(Scheduler::Reply,incidence); 3303 schedule(Scheduler::Reply,incidence);
3300} 3304}
3301 3305
3302void CalendarView::schedule_counter(Incidence *incidence) 3306void CalendarView::schedule_counter(Incidence *incidence)
3303{ 3307{
3304 schedule(Scheduler::Counter,incidence); 3308 schedule(Scheduler::Counter,incidence);
3305} 3309}
3306 3310
3307void CalendarView::schedule_declinecounter(Incidence *incidence) 3311void CalendarView::schedule_declinecounter(Incidence *incidence)
3308{ 3312{
3309 schedule(Scheduler::Declinecounter,incidence); 3313 schedule(Scheduler::Declinecounter,incidence);
3310} 3314}
3311 3315
3312void CalendarView::schedule_publish_freebusy(int daysToPublish) 3316void CalendarView::schedule_publish_freebusy(int daysToPublish)
3313{ 3317{
3314 QDateTime start = QDateTime::currentDateTime(); 3318 QDateTime start = QDateTime::currentDateTime();
3315 QDateTime end = start.addDays(daysToPublish); 3319 QDateTime end = start.addDays(daysToPublish);
3316 3320
3317 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3321 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3318 freebusy->setOrganizer(KOPrefs::instance()->email()); 3322 freebusy->setOrganizer(KOPrefs::instance()->email());
3319 3323
3320 3324
3321 PublishDialog *publishdlg = new PublishDialog(); 3325 PublishDialog *publishdlg = new PublishDialog();
3322 if ( publishdlg->exec() == QDialog::Accepted ) { 3326 if ( publishdlg->exec() == QDialog::Accepted ) {
3323 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3327 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3324 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3328 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3325 delete(freebusy); 3329 delete(freebusy);
3326 } 3330 }
3327 } 3331 }
3328 delete publishdlg; 3332 delete publishdlg;
3329} 3333}
3330 3334
3331void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3335void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3332{ 3336{
3333 Event *event = 0; 3337 Event *event = 0;
3334 Todo *todo = 0; 3338 Todo *todo = 0;
3335 3339
3336 if (incidence == 0) { 3340 if (incidence == 0) {
3337 incidence = mViewManager->currentView()->selectedIncidences().first(); 3341 incidence = mViewManager->currentView()->selectedIncidences().first();
3338 if (incidence == 0) { 3342 if (incidence == 0) {
3339 incidence = mTodoList->selectedIncidences().first(); 3343 incidence = mTodoList->selectedIncidences().first();
3340 } 3344 }
3341 } 3345 }
3342 if ( incidence && incidence->type() == "Event" ) { 3346 if ( incidence && incidence->type() == "Event" ) {
3343 event = static_cast<Event *>(incidence); 3347 event = static_cast<Event *>(incidence);
3344 } 3348 }
3345 if ( incidence && incidence->type() == "Todo" ) { 3349 if ( incidence && incidence->type() == "Todo" ) {
3346 todo = static_cast<Todo *>(incidence); 3350 todo = static_cast<Todo *>(incidence);
3347 } 3351 }
3348 3352
3349 if (!event && !todo) { 3353 if (!event && !todo) {
3350 KMessageBox::sorry(this,i18n("No event selected.")); 3354 KMessageBox::sorry(this,i18n("No event selected."));
3351 return; 3355 return;
3352 } 3356 }
3353 3357
3354 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3358 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3355 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3359 KMessageBox::sorry(this,i18n("The event has no attendees."));
3356 return; 3360 return;
3357 } 3361 }
3358 3362
3359 Event *ev = 0; 3363 Event *ev = 0;
3360 if (event) ev = new Event(*event); 3364 if (event) ev = new Event(*event);
3361 Todo *to = 0; 3365 Todo *to = 0;
3362 if (todo) to = new Todo(*todo); 3366 if (todo) to = new Todo(*todo);
3363 3367
3364 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3368 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3365 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3369 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3366 if (!me) { 3370 if (!me) {
3367 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3371 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3368 return; 3372 return;
3369 } 3373 }
3370 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3374 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3371 StatusDialog *statdlg = new StatusDialog(this); 3375 StatusDialog *statdlg = new StatusDialog(this);
3372 if (!statdlg->exec()==QDialog::Accepted) return; 3376 if (!statdlg->exec()==QDialog::Accepted) return;
3373 me->setStatus( statdlg->status() ); 3377 me->setStatus( statdlg->status() );
3374 delete(statdlg); 3378 delete(statdlg);
3375 } 3379 }
3376 Attendee *menew = new Attendee(*me); 3380 Attendee *menew = new Attendee(*me);
3377 if (ev) { 3381 if (ev) {
3378 ev->clearAttendees(); 3382 ev->clearAttendees();
3379 ev->addAttendee(menew,false); 3383 ev->addAttendee(menew,false);
3380 } else { 3384 } else {
3381 if (to) { 3385 if (to) {
3382 todo->clearAttendees(); 3386 todo->clearAttendees();
3383 todo->addAttendee(menew,false); 3387 todo->addAttendee(menew,false);
3384 } 3388 }
3385 } 3389 }
3386 } 3390 }
3387 3391
3388 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3392 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3389 if (ev) { 3393 if (ev) {
3390 if ( !dlg->addMessage(ev,method) ) delete(ev); 3394 if ( !dlg->addMessage(ev,method) ) delete(ev);
3391 } else { 3395 } else {
3392 if (to) { 3396 if (to) {
3393 if ( !dlg->addMessage(to,method) ) delete(to); 3397 if ( !dlg->addMessage(to,method) ) delete(to);
3394 } 3398 }
3395 } 3399 }
3396} 3400}
3397 3401
3398void CalendarView::openAddressbook() 3402void CalendarView::openAddressbook()
3399{ 3403{
3400 KRun::runCommand("kaddressbook"); 3404 KRun::runCommand("kaddressbook");
3401} 3405}
3402 3406
3403void CalendarView::setModified(bool modified) 3407void CalendarView::setModified(bool modified)
3404{ 3408{
3405 if ( modified ) 3409 if ( modified )
3406 emit signalmodified(); 3410 emit signalmodified();
3407 if (mModified != modified) { 3411 if (mModified != modified) {
3408 mModified = modified; 3412 mModified = modified;
3409 emit modifiedChanged(mModified); 3413 emit modifiedChanged(mModified);
3410 } 3414 }
3411} 3415}
3412 3416
3413bool CalendarView::isReadOnly() 3417bool CalendarView::isReadOnly()
3414{ 3418{
3415 return mReadOnly; 3419 return mReadOnly;
3416} 3420}
3417 3421
3418void CalendarView::setReadOnly(bool readOnly) 3422void CalendarView::setReadOnly(bool readOnly)
3419{ 3423{
3420 if (mReadOnly != readOnly) { 3424 if (mReadOnly != readOnly) {
3421 mReadOnly = readOnly; 3425 mReadOnly = readOnly;
3422 emit readOnlyChanged(mReadOnly); 3426 emit readOnlyChanged(mReadOnly);
3423 } 3427 }
3424} 3428}
3425 3429
3426bool CalendarView::isModified() 3430bool CalendarView::isModified()
3427{ 3431{
3428 return mModified; 3432 return mModified;
3429} 3433}
3430void CalendarView::slotprintSelInc() 3434void CalendarView::slotprintSelInc()
3431{ 3435{
3432 if ( currentSelection() == 0 ) { 3436 if ( currentSelection() == 0 ) {
3433 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3437 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3434 return; 3438 return;
3435 } 3439 }
3436 showIncidence(); 3440 showIncidence();
3437 getEventViewerDialog()->print(); 3441 getEventViewerDialog()->print();
3438 3442
3439} 3443}
3440void CalendarView::printSetup() 3444void CalendarView::printSetup()
3441{ 3445{
3442#ifndef KORG_NOPRINTER 3446#ifndef KORG_NOPRINTER
3443 createPrinter(); 3447 createPrinter();
3444 3448
3445 mCalPrinter->setupPrinter(); 3449 mCalPrinter->setupPrinter();
3446#endif 3450#endif
3447} 3451}
3448 3452
3449void CalendarView::print() 3453void CalendarView::print()
3450{ 3454{
3451#ifndef KORG_NOPRINTER 3455#ifndef KORG_NOPRINTER
3452 createPrinter(); 3456 createPrinter();
3453 3457
3454 DateList tmpDateList = mNavigator->selectedDates(); 3458 DateList tmpDateList = mNavigator->selectedDates();
3455 mCalPrinter->print(CalPrinter::Month, 3459 mCalPrinter->print(CalPrinter::Month,
3456 tmpDateList.first(), tmpDateList.last()); 3460 tmpDateList.first(), tmpDateList.last());
3457#endif 3461#endif
3458} 3462}
3459 3463
3460void CalendarView::printPreview() 3464void CalendarView::printPreview()
3461{ 3465{
3462#ifndef KORG_NOPRINTER 3466#ifndef KORG_NOPRINTER
3463 kdDebug() << "CalendarView::printPreview()" << endl; 3467 kdDebug() << "CalendarView::printPreview()" << endl;
3464 3468
3465 createPrinter(); 3469 createPrinter();
3466 3470
3467 DateList tmpDateList = mNavigator->selectedDates(); 3471 DateList tmpDateList = mNavigator->selectedDates();
3468 3472
3469 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3473 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3470 tmpDateList.last()); 3474 tmpDateList.last());
3471#endif 3475#endif
3472} 3476}
3473 3477
3474void CalendarView::exportICalendar() 3478void CalendarView::exportICalendar()
3475{ 3479{
3476 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3480 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3477 3481
3478 // Force correct extension 3482 // Force correct extension
3479 if (filename.right(4) != ".ics") filename += ".ics"; 3483 if (filename.right(4) != ".ics") filename += ".ics";
3480 3484
3481 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3485 FileStorage storage( mCalendar, filename, new ICalFormat() );
3482 storage.save(); 3486 storage.save();
3483} 3487}
3484 3488
3485bool CalendarView::exportVCalendar( QString filename ) 3489bool CalendarView::exportVCalendar( QString filename )
3486{ 3490{
3487 if (mCalendar->journals().count() > 0) { 3491 if (mCalendar->journals().count() > 0) {
3488 int result = KMessageBox::warningContinueCancel(this, 3492 int result = KMessageBox::warningContinueCancel(this,
3489 i18n("The journal entries can not be\nexported to a vCalendar file."), 3493 i18n("The journal entries can not be\nexported to a vCalendar file."),
3490 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3494 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3491 true); 3495 true);
3492 if (result != KMessageBox::Continue) return false; 3496 if (result != KMessageBox::Continue) return false;
3493 } 3497 }
3494 3498
3495 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3499 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3496 3500
3497 // Force correct extension 3501 // Force correct extension
3498 if (filename.right(4) != ".vcs") filename += ".vcs"; 3502 if (filename.right(4) != ".vcs") filename += ".vcs";
3499 3503
3500 FileStorage storage( mCalendar, filename, new VCalFormat ); 3504 FileStorage storage( mCalendar, filename, new VCalFormat );
3501 return storage.save(); 3505 return storage.save();
3502 3506
3503} 3507}
3504 3508
3505void CalendarView::eventUpdated(Incidence *) 3509void CalendarView::eventUpdated(Incidence *)
3506{ 3510{
3507 setModified(); 3511 setModified();
3508 // Don't call updateView here. The code, which has caused the update of the 3512 // Don't call updateView here. The code, which has caused the update of the
3509 // event is responsible for updating the view. 3513 // event is responsible for updating the view.
3510 // updateView(); 3514 // updateView();
3511} 3515}
3512 3516
3513void CalendarView::adaptNavigationUnits() 3517void CalendarView::adaptNavigationUnits()
3514{ 3518{
3515 if (mViewManager->currentView()->isEventView()) { 3519 if (mViewManager->currentView()->isEventView()) {
3516 int days = mViewManager->currentView()->currentDateCount(); 3520 int days = mViewManager->currentView()->currentDateCount();
3517 if (days == 1) { 3521 if (days == 1) {
3518 emit changeNavStringPrev(i18n("&Previous Day")); 3522 emit changeNavStringPrev(i18n("&Previous Day"));
3519 emit changeNavStringNext(i18n("&Next Day")); 3523 emit changeNavStringNext(i18n("&Next Day"));
3520 } else { 3524 } else {
3521 emit changeNavStringPrev(i18n("&Previous Week")); 3525 emit changeNavStringPrev(i18n("&Previous Week"));
3522 emit changeNavStringNext(i18n("&Next Week")); 3526 emit changeNavStringNext(i18n("&Next Week"));
3523 } 3527 }
3524 } 3528 }
3525} 3529}
3526 3530
3527void CalendarView::processMainViewSelection( Incidence *incidence ) 3531void CalendarView::processMainViewSelection( Incidence *incidence )
3528{ 3532{
3529 if ( incidence ) mTodoList->clearSelection(); 3533 if ( incidence ) mTodoList->clearSelection();
3530 processIncidenceSelection( incidence ); 3534 processIncidenceSelection( incidence );
3531} 3535}
3532 3536
3533void CalendarView::processTodoListSelection( Incidence *incidence ) 3537void CalendarView::processTodoListSelection( Incidence *incidence )
3534{ 3538{
3535 if ( incidence && mViewManager->currentView() ) { 3539 if ( incidence && mViewManager->currentView() ) {
3536 mViewManager->currentView()->clearSelection(); 3540 mViewManager->currentView()->clearSelection();
3537 } 3541 }
3538 processIncidenceSelection( incidence ); 3542 processIncidenceSelection( incidence );
3539} 3543}
3540 3544
3541void CalendarView::processIncidenceSelection( Incidence *incidence ) 3545void CalendarView::processIncidenceSelection( Incidence *incidence )
3542{ 3546{
3543 if ( incidence == mSelectedIncidence ) return; 3547 if ( incidence == mSelectedIncidence ) return;
3544 3548
3545 mSelectedIncidence = incidence; 3549 mSelectedIncidence = incidence;
3546 3550
3547 emit incidenceSelected( mSelectedIncidence ); 3551 emit incidenceSelected( mSelectedIncidence );
3548 3552
3549 if ( incidence && incidence->type() == "Event" ) { 3553 if ( incidence && incidence->type() == "Event" ) {
3550 Event *event = static_cast<Event *>( incidence ); 3554 Event *event = static_cast<Event *>( incidence );
3551 if ( event->organizer() == KOPrefs::instance()->email() ) { 3555 if ( event->organizer() == KOPrefs::instance()->email() ) {
3552 emit organizerEventsSelected( true ); 3556 emit organizerEventsSelected( true );
3553 } else { 3557 } else {
3554 emit organizerEventsSelected(false); 3558 emit organizerEventsSelected(false);
3555 } 3559 }
3556 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3560 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3557 KOPrefs::instance()->email() ) ) { 3561 KOPrefs::instance()->email() ) ) {
3558 emit groupEventsSelected( true ); 3562 emit groupEventsSelected( true );
3559 } else { 3563 } else {
3560 emit groupEventsSelected(false); 3564 emit groupEventsSelected(false);
3561 } 3565 }
3562 return; 3566 return;
3563 } else { 3567 } else {
3564 if ( incidence && incidence->type() == "Todo" ) { 3568 if ( incidence && incidence->type() == "Todo" ) {
3565 emit todoSelected( true ); 3569 emit todoSelected( true );
3566 Todo *event = static_cast<Todo *>( incidence ); 3570 Todo *event = static_cast<Todo *>( incidence );
3567 if ( event->organizer() == KOPrefs::instance()->email() ) { 3571 if ( event->organizer() == KOPrefs::instance()->email() ) {
3568 emit organizerEventsSelected( true ); 3572 emit organizerEventsSelected( true );
3569 } else { 3573 } else {
3570 emit organizerEventsSelected(false); 3574 emit organizerEventsSelected(false);
3571 } 3575 }
3572 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3576 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3573 KOPrefs::instance()->email() ) ) { 3577 KOPrefs::instance()->email() ) ) {
3574 emit groupEventsSelected( true ); 3578 emit groupEventsSelected( true );
3575 } else { 3579 } else {
3576 emit groupEventsSelected(false); 3580 emit groupEventsSelected(false);
3577 } 3581 }
3578 return; 3582 return;
3579 } else { 3583 } else {
3580 emit todoSelected( false ); 3584 emit todoSelected( false );
3581 emit organizerEventsSelected(false); 3585 emit organizerEventsSelected(false);
3582 emit groupEventsSelected(false); 3586 emit groupEventsSelected(false);
3583 } 3587 }
3584 return; 3588 return;
3585 } 3589 }
3586 3590
3587 /* if ( incidence && incidence->type() == "Todo" ) { 3591 /* if ( incidence && incidence->type() == "Todo" ) {
3588 emit todoSelected( true ); 3592 emit todoSelected( true );
3589 } else { 3593 } else {
3590 emit todoSelected( false ); 3594 emit todoSelected( false );
3591 }*/ 3595 }*/
3592} 3596}
3593 3597
3594 3598
3595void CalendarView::checkClipboard() 3599void CalendarView::checkClipboard()
3596{ 3600{
3597#ifndef KORG_NODND 3601#ifndef KORG_NODND
3598 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3602 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3599 emit pasteEnabled(true); 3603 emit pasteEnabled(true);
3600 } else { 3604 } else {
3601 emit pasteEnabled(false); 3605 emit pasteEnabled(false);
3602 } 3606 }
3603#endif 3607#endif
3604} 3608}
3605 3609
3606void CalendarView::showDates(const DateList &selectedDates) 3610void CalendarView::showDates(const DateList &selectedDates)
3607{ 3611{
3608 // kdDebug() << "CalendarView::selectDates()" << endl; 3612 // kdDebug() << "CalendarView::selectDates()" << endl;
3609 3613
3610 3614
3611 if ( !mBlockShowDates ) { 3615 if ( !mBlockShowDates ) {
3612 if ( mViewManager->currentView() ) { 3616 if ( mViewManager->currentView() ) {
3613 updateView( selectedDates.first(), selectedDates.last() ); 3617 updateView( selectedDates.first(), selectedDates.last() );
3614 } else { 3618 } else {
3615 mViewManager->showAgendaView(); 3619 mViewManager->showAgendaView();
3616 } 3620 }
3617 } 3621 }
3618 3622
3619 QDate date = selectedDates.first(); 3623 QDate date = selectedDates.first();
3620 if ( ! date.isValid() ) { 3624 if ( ! date.isValid() ) {
3621 topLevelWidget()->setCaption(""); 3625 topLevelWidget()->setCaption("");
3622 return; 3626 return;
3623 } 3627 }
3624 3628
3625 QString selDates; 3629 QString selDates;
3626 selDates = KGlobal::locale()->formatDate( date, true); 3630 selDates = KGlobal::locale()->formatDate( date, true);
3627 if (selectedDates.first() < selectedDates.last() ) 3631 if (selectedDates.first() < selectedDates.last() )
3628 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3632 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3629 else { 3633 else {
3630 QString addString; 3634 QString addString;
3631 if ( date == QDateTime::currentDateTime().date() ) 3635 if ( date == QDateTime::currentDateTime().date() )
3632 addString = i18n("Today"); 3636 addString = i18n("Today");
3633 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3637 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3634 addString = i18n("Tomorrow"); 3638 addString = i18n("Tomorrow");
3635 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3639 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3636 addString = i18n("Yesterday"); 3640 addString = i18n("Yesterday");
3637 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3641 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3638 addString = i18n("Day before yesterday"); 3642 addString = i18n("Day before yesterday");
3639 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3643 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3640 addString = i18n("Day after tomorrow"); 3644 addString = i18n("Day after tomorrow");
3641 if ( !addString.isEmpty() ) { 3645 if ( !addString.isEmpty() ) {
3642 topLevelWidget()->setCaption( addString+", " + selDates ); 3646 topLevelWidget()->setCaption( addString+", " + selDates );
3643 return; 3647 return;
3644 } 3648 }
3645 } 3649 }
3646 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3650 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3647 3651
3648} 3652}
3649 3653
3650QPtrList<CalFilter> CalendarView::filters() 3654QPtrList<CalFilter> CalendarView::filters()
3651{ 3655{
3652 return mFilters; 3656 return mFilters;
3653 3657
3654} 3658}
3655void CalendarView::editFilters() 3659void CalendarView::editFilters()
3656{ 3660{
3657 // kdDebug() << "CalendarView::editFilters()" << endl; 3661 // kdDebug() << "CalendarView::editFilters()" << endl;
3658 3662
3659 CalFilter *filter = mFilters.first(); 3663 CalFilter *filter = mFilters.first();
3660 while(filter) { 3664 while(filter) {
3661 kdDebug() << " Filter: " << filter->name() << endl; 3665 kdDebug() << " Filter: " << filter->name() << endl;
3662 filter = mFilters.next(); 3666 filter = mFilters.next();
3663 } 3667 }
3664 3668
3665 mDialogManager->showFilterEditDialog(&mFilters); 3669 mDialogManager->showFilterEditDialog(&mFilters);
3666} 3670}
3667void CalendarView::toggleFilter() 3671void CalendarView::toggleFilter()
3668{ 3672{
3669 showFilter(! mFilterView->isVisible()); 3673 showFilter(! mFilterView->isVisible());
3670} 3674}
3671 3675
3672KOFilterView *CalendarView::filterView() 3676KOFilterView *CalendarView::filterView()
3673{ 3677{
3674 return mFilterView; 3678 return mFilterView;
3675} 3679}
3676void CalendarView::selectFilter( int fil ) 3680void CalendarView::selectFilter( int fil )
3677{ 3681{
3678 mFilterView->setSelectedFilter( fil ); 3682 mFilterView->setSelectedFilter( fil );
3679} 3683}
3680void CalendarView::showFilter(bool visible) 3684void CalendarView::showFilter(bool visible)
3681{ 3685{
3682 if (visible) mFilterView->show(); 3686 if (visible) mFilterView->show();
3683 else mFilterView->hide(); 3687 else mFilterView->hide();
3684} 3688}
3685void CalendarView::toggleFilerEnabled( ) 3689void CalendarView::toggleFilerEnabled( )
3686{ 3690{
3687 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3691 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3688 if ( !mFilterView->filtersEnabled() ) 3692 if ( !mFilterView->filtersEnabled() )
3689 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3693 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3690 3694
3691} 3695}
3692void CalendarView::updateFilter() 3696void CalendarView::updateFilter()
3693{ 3697{
3694 CalFilter *filter = mFilterView->selectedFilter(); 3698 CalFilter *filter = mFilterView->selectedFilter();
3695 if (filter) { 3699 if (filter) {
3696 QString mess; 3700 QString mess;
3697 if (mFilterView->filtersEnabled()) { 3701 if (mFilterView->filtersEnabled()) {
3698 mess = i18n("Filter selected: ")+filter->name(); 3702 mess = i18n("Filter selected: ")+filter->name();
3699 filter->setEnabled(true); 3703 filter->setEnabled(true);
3700 } 3704 }
3701 else filter->setEnabled(false); 3705 else filter->setEnabled(false);
3702 mCalendar->setFilter(filter); 3706 mCalendar->setFilter(filter);
3703 updateView(); 3707 updateView();
3704 if ( !mess.isEmpty() ) 3708 if ( !mess.isEmpty() )
3705 topLevelWidget()->setCaption( mess ); 3709 topLevelWidget()->setCaption( mess );
3706 3710
3707 } 3711 }
3708} 3712}
3709 3713
3710void CalendarView::filterEdited() 3714void CalendarView::filterEdited()
3711{ 3715{
3712 mFilterView->updateFilters(); 3716 mFilterView->updateFilters();
3713 updateFilter(); 3717 updateFilter();
3714 writeSettings(); 3718 writeSettings();
3715} 3719}
3716 3720
3717 3721
3718void CalendarView::takeOverEvent() 3722void CalendarView::takeOverEvent()
3719{ 3723{
3720 Incidence *incidence = currentSelection(); 3724 Incidence *incidence = currentSelection();
3721 3725
3722 if (!incidence) return; 3726 if (!incidence) return;
3723 3727
3724 incidence->setOrganizer(KOPrefs::instance()->email()); 3728 incidence->setOrganizer(KOPrefs::instance()->email());
3725 incidence->recreate(); 3729 incidence->recreate();
3726 incidence->setReadOnly(false); 3730 incidence->setReadOnly(false);
3727 3731
3728 updateView(); 3732 updateView();
3729} 3733}
3730 3734
3731void CalendarView::takeOverCalendar() 3735void CalendarView::takeOverCalendar()
3732{ 3736{
3733 // TODO: Create Calendar::allIncidences() function and use it here 3737 // TODO: Create Calendar::allIncidences() function and use it here
3734 3738
3735 QPtrList<Event> events = mCalendar->events(); 3739 QPtrList<Event> events = mCalendar->events();
3736 for(uint i=0; i<events.count(); ++i) { 3740 for(uint i=0; i<events.count(); ++i) {
3737 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3741 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3738 events.at(i)->recreate(); 3742 events.at(i)->recreate();
3739 events.at(i)->setReadOnly(false); 3743 events.at(i)->setReadOnly(false);
3740 } 3744 }
3741 3745
3742 QPtrList<Todo> todos = mCalendar->todos(); 3746 QPtrList<Todo> todos = mCalendar->todos();
3743 for(uint i=0; i<todos.count(); ++i) { 3747 for(uint i=0; i<todos.count(); ++i) {
3744 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3748 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3745 todos.at(i)->recreate(); 3749 todos.at(i)->recreate();
3746 todos.at(i)->setReadOnly(false); 3750 todos.at(i)->setReadOnly(false);
3747 } 3751 }
3748 3752
3749 QPtrList<Journal> journals = mCalendar->journals(); 3753 QPtrList<Journal> journals = mCalendar->journals();
3750 for(uint i=0; i<journals.count(); ++i) { 3754 for(uint i=0; i<journals.count(); ++i) {
3751 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3755 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3752 journals.at(i)->recreate(); 3756 journals.at(i)->recreate();
3753 journals.at(i)->setReadOnly(false); 3757 journals.at(i)->setReadOnly(false);
3754 } 3758 }
3755 3759
3756 updateView(); 3760 updateView();
3757} 3761}
3758 3762
3759void CalendarView::showIntro() 3763void CalendarView::showIntro()
3760{ 3764{
3761 kdDebug() << "To be implemented." << endl; 3765 kdDebug() << "To be implemented." << endl;
3762} 3766}
3763 3767
3764QWidgetStack *CalendarView::viewStack() 3768QWidgetStack *CalendarView::viewStack()
3765{ 3769{
3766 return mRightFrame; 3770 return mRightFrame;
3767} 3771}
3768 3772
3769QWidget *CalendarView::leftFrame() 3773QWidget *CalendarView::leftFrame()
3770{ 3774{
3771 return ( QWidget *)mLeftFrame; 3775 return ( QWidget *)mLeftFrame;
3772} 3776}
3773 3777
3774DateNavigator *CalendarView::dateNavigator() 3778DateNavigator *CalendarView::dateNavigator()
3775{ 3779{
3776 return mNavigator; 3780 return mNavigator;
3777} 3781}
3778 3782
3779KDateNavigator* CalendarView::dateNavigatorWidget() 3783KDateNavigator* CalendarView::dateNavigatorWidget()
3780{ 3784{
3781 return mDateNavigator->navigatorView(); 3785 return mDateNavigator->navigatorView();
3782} 3786}
3783void CalendarView::toggleDateNavigatorWidget() 3787void CalendarView::toggleDateNavigatorWidget()
3784{ 3788{
3785 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3789 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3786 3790
3787 if (!KOPrefs::instance()->mShowDateNavigator ) 3791 if (!KOPrefs::instance()->mShowDateNavigator )
3788 mDateNavigator->hide(); 3792 mDateNavigator->hide();
3789 else 3793 else
3790 mDateNavigator->show(); 3794 mDateNavigator->show();
3791} 3795}
3792void CalendarView::addView(KOrg::BaseView *view) 3796void CalendarView::addView(KOrg::BaseView *view)
3793{ 3797{
3794 mViewManager->addView(view); 3798 mViewManager->addView(view);
3795} 3799}
3796 3800
3797void CalendarView::showView(KOrg::BaseView *view) 3801void CalendarView::showView(KOrg::BaseView *view)
3798{ 3802{
3799 mViewManager->showView(view, mLeftFrame->isVisible()); 3803 mViewManager->showView(view, mLeftFrame->isVisible());
3800} 3804}
3801 3805
3802Incidence *CalendarView::currentSelection() 3806Incidence *CalendarView::currentSelection()
3803{ 3807{
3804 return mViewManager->currentSelection(); 3808 return mViewManager->currentSelection();
3805} 3809}
3806void CalendarView::toggleAllDaySize() 3810void CalendarView::toggleAllDaySize()
3807{ 3811{
3808 /* 3812 /*
3809 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3813 if ( KOPrefs::instance()->mAllDaySize > 47 )
3810 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3814 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3811 else 3815 else
3812 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3816 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3813 */ 3817 */
3814 viewManager()->agendaView()->toggleAllDay(); 3818 viewManager()->agendaView()->toggleAllDay();
3815} 3819}
3816void CalendarView::toggleExpand() 3820void CalendarView::toggleExpand()
3817{ 3821{
3818 // if ( mLeftFrame->isHidden() ) { 3822 // if ( mLeftFrame->isHidden() ) {
3819 // mLeftFrame->show(); 3823 // mLeftFrame->show();
3820 // emit calendarViewExpanded( false ); 3824 // emit calendarViewExpanded( false );
3821 // } else { 3825 // } else {
3822 // mLeftFrame->hide(); 3826 // mLeftFrame->hide();
3823 // emit calendarViewExpanded( true ); 3827 // emit calendarViewExpanded( true );
3824 // } 3828 // }
3825 //qDebug(" CalendarView::toggleExpand()"); 3829 //qDebug(" CalendarView::toggleExpand()");
3826 globalFlagBlockAgenda = 1; 3830 globalFlagBlockAgenda = 1;
3827 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3831 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3828 globalFlagBlockAgenda = 5; 3832 globalFlagBlockAgenda = 5;
3829 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3833 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3830 //mViewManager->showView( 0, true ); 3834 //mViewManager->showView( 0, true );
3831} 3835}
3832 3836
3833void CalendarView::calendarModified( bool modified, Calendar * ) 3837void CalendarView::calendarModified( bool modified, Calendar * )
3834{ 3838{
3835 setModified( modified ); 3839 setModified( modified );
3836} 3840}
3837 3841
3838Todo *CalendarView::selectedTodo() 3842Todo *CalendarView::selectedTodo()
3839{ 3843{
3840 Incidence *incidence = currentSelection(); 3844 Incidence *incidence = currentSelection();
3841 if ( incidence && incidence->type() == "Todo" ) { 3845 if ( incidence && incidence->type() == "Todo" ) {
3842 return static_cast<Todo *>( incidence ); 3846 return static_cast<Todo *>( incidence );
3843 } 3847 }
3844 3848
3845 incidence = mTodoList->selectedIncidences().first(); 3849 incidence = mTodoList->selectedIncidences().first();
3846 if ( incidence && incidence->type() == "Todo" ) { 3850 if ( incidence && incidence->type() == "Todo" ) {
3847 return static_cast<Todo *>( incidence ); 3851 return static_cast<Todo *>( incidence );
3848 } 3852 }
3849 3853
3850 return 0; 3854 return 0;
3851} 3855}
3852 3856
3853void CalendarView::dialogClosing(Incidence *in) 3857void CalendarView::dialogClosing(Incidence *in)
3854{ 3858{
3855 // mDialogList.remove(in); 3859 // mDialogList.remove(in);
3856} 3860}
3857 3861
3858void CalendarView::showIncidence() 3862void CalendarView::showIncidence()
3859{ 3863{
3860 mViewerCallerIsSearchDialog = false; 3864 mViewerCallerIsSearchDialog = false;
3861 Incidence *incidence = currentSelection(); 3865 Incidence *incidence = currentSelection();
3862 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3866 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3863 if ( incidence ) { 3867 if ( incidence ) {
3864 ShowIncidenceVisitor v; 3868 ShowIncidenceVisitor v;
3865 v.act( incidence, this ); 3869 v.act( incidence, this );
3866 } 3870 }
3867} 3871}
3868void CalendarView::editIncidenceDescription() 3872void CalendarView::editIncidenceDescription()
3869{ 3873{
3870 mFlagEditDescription = true; 3874 mFlagEditDescription = true;
3871 editIncidence(); 3875 editIncidence();
3872 mFlagEditDescription = false; 3876 mFlagEditDescription = false;
3873} 3877}
3874void CalendarView::editIncidence() 3878void CalendarView::editIncidence()
3875{ 3879{
3876 // qDebug("editIncidence() "); 3880 // qDebug("editIncidence() ");
3877 Incidence *incidence = currentSelection(); 3881 Incidence *incidence = currentSelection();
3878 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3882 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3879 if ( incidence ) { 3883 if ( incidence ) {
3880 EditIncidenceVisitor v; 3884 EditIncidenceVisitor v;
3881 v.act( incidence, this ); 3885 v.act( incidence, this );
3882 } 3886 }
3883} 3887}
3884 3888
3885void CalendarView::deleteIncidence() 3889void CalendarView::deleteIncidence()
3886{ 3890{
3887 Incidence *incidence = currentSelection(); 3891 Incidence *incidence = currentSelection();
3888 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3892 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3889 if ( incidence ) { 3893 if ( incidence ) {
3890 deleteIncidence(incidence); 3894 deleteIncidence(incidence);
3891 } 3895 }
3892} 3896}
3893 3897
3894void CalendarView::showIncidence(Incidence *incidence) 3898void CalendarView::showIncidence(Incidence *incidence)
3895{ 3899{
3896 mViewerCallerIsSearchDialog = false; 3900 mViewerCallerIsSearchDialog = false;
3897 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3901 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3898 if ( sender() && mDialogManager->getSearchDialog() ) { 3902 if ( sender() && mDialogManager->getSearchDialog() ) {
3899 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3903 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3900 mViewerCallerIsSearchDialog = true; 3904 mViewerCallerIsSearchDialog = true;
3901 } 3905 }
3902 } 3906 }
3903 if ( incidence ) { 3907 if ( incidence ) {
3904 ShowIncidenceVisitor v; 3908 ShowIncidenceVisitor v;
3905 v.act( incidence, this ); 3909 v.act( incidence, this );
3906 } 3910 }
3907} 3911}
3908 3912
3909void CalendarView::editIncidence(Incidence *incidence) 3913void CalendarView::editIncidence(Incidence *incidence)
3910{ 3914{
3911 if ( incidence ) { 3915 if ( incidence ) {
3912 3916
3913 EditIncidenceVisitor v; 3917 EditIncidenceVisitor v;
3914 v.act( incidence, this ); 3918 v.act( incidence, this );
3915 3919
3916 } 3920 }
3917} 3921}
3918 3922
3919void CalendarView::deleteIncidence(Incidence *incidence) 3923void CalendarView::deleteIncidence(Incidence *incidence)
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
index a8652ea..c927b37 100644
--- a/korganizer/kodialogmanager.cpp
+++ b/korganizer/kodialogmanager.cpp
@@ -1,350 +1,352 @@
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 <kapplication.h>
43 44
44KODialogManager::KODialogManager( CalendarView *mainView ) : 45KODialogManager::KODialogManager( CalendarView *mainView ) :
45 QObject(), mMainView( mainView ) 46 QObject(), mMainView( mainView )
46{ 47{
47 mOutgoingDialog = 0; 48 mOutgoingDialog = 0;
48 mIncomingDialog = 0; 49 mIncomingDialog = 0;
49 mOptionsDialog = 0; 50 mOptionsDialog = 0;
50 mSearchDialog = 0; 51 mSearchDialog = 0;
51 mArchiveDialog = 0; 52 mArchiveDialog = 0;
52 mFilterEditDialog = 0; 53 mFilterEditDialog = 0;
53 mPluginDialog = 0; 54 mPluginDialog = 0;
54 55
55 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView); 56 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView);
56 //KOGlobals::fitDialogToScreen( mCategoryEditDialog ); 57 //KOGlobals::fitDialogToScreen( mCategoryEditDialog );
57} 58}
58 59
59KODialogManager::~KODialogManager() 60KODialogManager::~KODialogManager()
60{ 61{
61 delete mOutgoingDialog; 62 delete mOutgoingDialog;
62 delete mIncomingDialog; 63 delete mIncomingDialog;
63 delete mOptionsDialog; 64 delete mOptionsDialog;
64 delete mSearchDialog; 65 delete mSearchDialog;
65#ifndef KORG_NOARCHIVE 66#ifndef KORG_NOARCHIVE
66 delete mArchiveDialog; 67 delete mArchiveDialog;
67#endif 68#endif
68 delete mFilterEditDialog; 69 delete mFilterEditDialog;
69#ifndef KORG_NOPLUGINS 70#ifndef KORG_NOPLUGINS
70 delete mPluginDialog; 71 delete mPluginDialog;
71#endif 72#endif
72} 73}
73 74
74OutgoingDialog *KODialogManager::outgoingDialog() 75OutgoingDialog *KODialogManager::outgoingDialog()
75{ 76{
76 createOutgoingDialog(); 77 createOutgoingDialog();
77 return mOutgoingDialog; 78 return mOutgoingDialog;
78} 79}
79 80
80void KODialogManager::createOutgoingDialog() 81void KODialogManager::createOutgoingDialog()
81{ 82{
82 if (!mOutgoingDialog) { 83 if (!mOutgoingDialog) {
83 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView); 84 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView);
84 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog); 85 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog);
85 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)), 86 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)),
86 mMainView,SIGNAL(numOutgoingChanged(int))); 87 mMainView,SIGNAL(numOutgoingChanged(int)));
87 } 88 }
88} 89}
89 90
90void KODialogManager::showOptionsDialog( bool showSync ) 91void KODialogManager::showOptionsDialog( bool showSync )
91{ 92{
92 93
93 if (!mOptionsDialog) { 94 if (!mOptionsDialog) {
94 mOptionsDialog = new KOPrefsDialog(mMainView); 95 mOptionsDialog = new KOPrefsDialog(mMainView);
95 //mOptionsDialog->readConfig(); 96 //mOptionsDialog->readConfig();
96 connect(mOptionsDialog,SIGNAL(configChanged()), 97 connect(mOptionsDialog,SIGNAL(configChanged()),
97 mMainView,SLOT(updateConfig())); 98 mMainView,SLOT(updateConfig()));
98 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 99 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
99 // mOptionsDialog,SLOT(updateCategories())); 100 // mOptionsDialog,SLOT(updateCategories()));
100 101
101 } 102 }
102 mOptionsDialog->readConfig(); 103 mOptionsDialog->readConfig();
103#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
104 mOptionsDialog->showMaximized(); 105 mOptionsDialog->showMaximized();
105#else 106#else
106 mOptionsDialog->show(); 107 mOptionsDialog->show();
107#endif 108#endif
108 if ( showSync ) 109 if ( showSync )
109 mOptionsDialog->showSyncPage(); 110 mOptionsDialog->showSyncPage();
110 mOptionsDialog->exec(); 111 mOptionsDialog->exec();
111 112
112} 113}
113void KODialogManager::showSyncOptions() 114void KODialogManager::showSyncOptions()
114{ 115{
115 showOptionsDialog( true ); 116 showOptionsDialog( true );
116 117
117} 118}
118void KODialogManager::showOutgoingDialog() 119void KODialogManager::showOutgoingDialog()
119{ 120{
120 createOutgoingDialog(); 121 createOutgoingDialog();
121 mOutgoingDialog->show(); 122 mOutgoingDialog->show();
122 mOutgoingDialog->raise(); 123 mOutgoingDialog->raise();
123} 124}
124 125
125IncomingDialog *KODialogManager::incomingDialog() 126IncomingDialog *KODialogManager::incomingDialog()
126{ 127{
127 createOutgoingDialog(); 128 createOutgoingDialog();
128 if (!mIncomingDialog) { 129 if (!mIncomingDialog) {
129 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 130 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
130 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 131 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
131 mMainView,SIGNAL(numIncomingChanged(int))); 132 mMainView,SIGNAL(numIncomingChanged(int)));
132 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 133 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
133 mMainView,SLOT(updateView())); 134 mMainView,SLOT(updateView()));
134 } 135 }
135 return mIncomingDialog; 136 return mIncomingDialog;
136} 137}
137 138
138void KODialogManager::createIncomingDialog() 139void KODialogManager::createIncomingDialog()
139{ 140{
140 createOutgoingDialog(); 141 createOutgoingDialog();
141 if (!mIncomingDialog) { 142 if (!mIncomingDialog) {
142 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 143 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
143 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 144 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
144 mMainView,SIGNAL(numIncomingChanged(int))); 145 mMainView,SIGNAL(numIncomingChanged(int)));
145 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 146 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
146 mMainView,SLOT(updateView())); 147 mMainView,SLOT(updateView()));
147 } 148 }
148} 149}
149 150
150void KODialogManager::showIncomingDialog() 151void KODialogManager::showIncomingDialog()
151{ 152{
152 createIncomingDialog(); 153 createIncomingDialog();
153 mIncomingDialog->show(); 154 mIncomingDialog->show();
154 mIncomingDialog->raise(); 155 mIncomingDialog->raise();
155} 156}
156/* 157/*
157void KODialogManager::showCategoryEditDialog() 158void KODialogManager::showCategoryEditDialog()
158{ 159{
159 mCategoryEditDialog->show(); 160 mCategoryEditDialog->show();
160} 161}
161*/ 162*/
162void KODialogManager::hideSearchDialog() 163void KODialogManager::hideSearchDialog()
163{ 164{
164 if (mSearchDialog) 165 if (mSearchDialog)
165 mSearchDialog->hide(); 166 mSearchDialog->hide();
166} 167}
167 168
168void KODialogManager::showSearchDialog() 169void KODialogManager::showSearchDialog()
169{ 170{
170 if (!mSearchDialog) { 171 if (!mSearchDialog) {
171 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView); 172 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView);
172 KOListView * lview = mSearchDialog->listview(); 173 KOListView * lview = mSearchDialog->listview();
173 174
174 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)), 175 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)),
175 mMainView, SLOT(showIncidence(Incidence *))); 176 mMainView, SLOT(showIncidence(Incidence *)));
176 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)), 177 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)),
177 mMainView, SLOT(editIncidence(Incidence *))); 178 mMainView, SLOT(editIncidence(Incidence *)));
178 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)), 179 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)),
179 mMainView, SLOT(deleteIncidence(Incidence *))); 180 mMainView, SLOT(deleteIncidence(Incidence *)));
180 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)), 181 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)),
181 mMainView, SLOT(cloneIncidence(Incidence *))); 182 mMainView, SLOT(cloneIncidence(Incidence *)));
182 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)), 183 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)),
183 mMainView, SLOT(beamIncidence(Incidence *))); 184 mMainView, SLOT(beamIncidence(Incidence *)));
184 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)), 185 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)),
185 mMainView, SLOT(moveIncidence(Incidence *))); 186 mMainView, SLOT(moveIncidence(Incidence *)));
186 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )), 187 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )),
187 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> ))); 188 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> )));
188 189
189 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig())); 190 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig()));
190 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList())); 191 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList()));
191 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ), 192 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ),
192 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 193 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
193#ifndef DESKTOP_VERSION 194#ifndef DESKTOP_VERSION
194 mSearchDialog->setMaximumSize( QApplication::desktop()->size()); 195 mSearchDialog->setMaximumSize( QApplication::desktop()->size());
195 mSearchDialog->showMaximized(); 196 mSearchDialog->showMaximized();
196#else 197#else
197 KConfig *config = KOGlobals::config(); 198 KConfig *config = KOGlobals::config();
198 config->setGroup("WidgetLayout"); 199 config->setGroup("WidgetLayout");
199 QStringList list; 200 QStringList list;
200 list = config->readListEntry("SearchLayout"); 201 list = config->readListEntry("SearchLayout");
201 int x,y,w,h; 202 int x,y,w,h;
202 if ( ! list.isEmpty() ) { 203 if ( ! list.isEmpty() ) {
203 x = list[0].toInt(); 204 x = list[0].toInt();
204 y = list[1].toInt(); 205 y = list[1].toInt();
205 w = list[2].toInt(); 206 w = list[2].toInt();
206 h = list[3].toInt(); 207 h = list[3].toInt();
208 KApplication::testCoords( &x,&y,&w,&h );
207 mSearchDialog->setGeometry(x,y,w,h); 209 mSearchDialog->setGeometry(x,y,w,h);
208 210
209 } 211 }
210 212
211#endif 213#endif
212 } 214 }
213 // make sure the widget is on top again 215 // make sure the widget is on top again
214#ifdef DESKTOP_VERSION 216#ifdef DESKTOP_VERSION
215 mSearchDialog->show(); 217 mSearchDialog->show();
216#else 218#else
217 mSearchDialog->setMaximumSize( QApplication::desktop()->size()); 219 mSearchDialog->setMaximumSize( QApplication::desktop()->size());
218 mSearchDialog->showMaximized(); 220 mSearchDialog->showMaximized();
219#endif 221#endif
220 mSearchDialog->raise(); 222 mSearchDialog->raiseAndSelect();
221} 223}
222 224
223SearchDialog * KODialogManager::getSearchDialog() 225SearchDialog * KODialogManager::getSearchDialog()
224{ 226{
225 return mSearchDialog; 227 return mSearchDialog;
226} 228}
227void KODialogManager::showArchiveDialog() 229void KODialogManager::showArchiveDialog()
228{ 230{
229#ifndef KORG_NOARCHIVE 231#ifndef KORG_NOARCHIVE
230 if (!mArchiveDialog) { 232 if (!mArchiveDialog) {
231 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView); 233 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView);
232 connect(mArchiveDialog,SIGNAL(eventsDeleted()), 234 connect(mArchiveDialog,SIGNAL(eventsDeleted()),
233 mMainView,SLOT(updateView())); 235 mMainView,SLOT(updateView()));
234 } 236 }
235 mArchiveDialog->show(); 237 mArchiveDialog->show();
236 mArchiveDialog->raise(); 238 mArchiveDialog->raise();
237 239
238 // Workaround. 240 // Workaround.
239 QApplication::restoreOverrideCursor(); 241 QApplication::restoreOverrideCursor();
240#endif 242#endif
241} 243}
242 244
243void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters) 245void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters)
244{ 246{
245 if (!mFilterEditDialog) { 247 if (!mFilterEditDialog) {
246 mFilterEditDialog = new FilterEditDialog(filters,mMainView); 248 mFilterEditDialog = new FilterEditDialog(filters,mMainView);
247 connect(mFilterEditDialog,SIGNAL(filterChanged()), 249 connect(mFilterEditDialog,SIGNAL(filterChanged()),
248 mMainView,SLOT(filterEdited())); 250 mMainView,SLOT(filterEdited()));
249 251
250 } 252 }
251 253
252#ifndef DESKTOP_VERSION 254#ifndef DESKTOP_VERSION
253 mFilterEditDialog->showMaximized(); 255 mFilterEditDialog->showMaximized();
254#else 256#else
255 mFilterEditDialog->show(); 257 mFilterEditDialog->show();
256#endif 258#endif
257 mFilterEditDialog->raise(); 259 mFilterEditDialog->raise();
258} 260}
259 261
260void KODialogManager::showPluginDialog() 262void KODialogManager::showPluginDialog()
261{ 263{
262#ifndef KORG_NOPLUGINS 264#ifndef KORG_NOPLUGINS
263 if (!mPluginDialog) { 265 if (!mPluginDialog) {
264 mPluginDialog = new PluginDialog(mMainView); 266 mPluginDialog = new PluginDialog(mMainView);
265 connect(mPluginDialog,SIGNAL(configChanged()), 267 connect(mPluginDialog,SIGNAL(configChanged()),
266 mMainView,SLOT(updateConfig())); 268 mMainView,SLOT(updateConfig()));
267 } 269 }
268 mPluginDialog->show(); 270 mPluginDialog->show();
269 mPluginDialog->raise(); 271 mPluginDialog->raise();
270#endif 272#endif
271} 273}
272 274
273KOEventEditor *KODialogManager::getEventEditor() 275KOEventEditor *KODialogManager::getEventEditor()
274{ 276{
275 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(), 277 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(),
276 mMainView ); 278 mMainView );
277 279
278 connect(eventEditor,SIGNAL(eventAdded(Event *)), 280 connect(eventEditor,SIGNAL(eventAdded(Event *)),
279 mMainView,SLOT(eventAdded(Event *))); 281 mMainView,SLOT(eventAdded(Event *)));
280 connect(eventEditor,SIGNAL(eventChanged(Event *)), 282 connect(eventEditor,SIGNAL(eventChanged(Event *)),
281 mMainView,SLOT(eventChanged(Event *))); 283 mMainView,SLOT(eventChanged(Event *)));
282 connect(eventEditor,SIGNAL(eventDeleted()), 284 connect(eventEditor,SIGNAL(eventDeleted()),
283 mMainView,SLOT(eventDeleted())); 285 mMainView,SLOT(eventDeleted()));
284 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)), 286 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)),
285 mMainView,SLOT(schedule_cancel(Incidence *))); 287 mMainView,SLOT(schedule_cancel(Incidence *)));
286 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)), 288 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)),
287 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 289 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
288 connect( eventEditor, SIGNAL( showAgendaView( bool)), 290 connect( eventEditor, SIGNAL( showAgendaView( bool)),
289 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 291 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
290 292
291 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 293 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
292 // eventEditor,SLOT(updateCategoryConfig())); 294 // eventEditor,SLOT(updateCategoryConfig()));
293 // connect(eventEditor,SIGNAL(editCategories()), 295 // connect(eventEditor,SIGNAL(editCategories()),
294 // mCategoryEditDialog,SLOT(show())); 296 // mCategoryEditDialog,SLOT(show()));
295 connect(eventEditor,SIGNAL(dialogClose(Incidence*)), 297 connect(eventEditor,SIGNAL(dialogClose(Incidence*)),
296 mMainView,SLOT(dialogClosing(Incidence*))); 298 mMainView,SLOT(dialogClosing(Incidence*)));
297 299
298 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject())); 300 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject()));
299 301
300#ifndef DESKTOP_VERSION 302#ifndef DESKTOP_VERSION
301 eventEditor->resize( QApplication::desktop()->width() -20, 100 ); 303 eventEditor->resize( QApplication::desktop()->width() -20, 100 );
302#endif 304#endif
303 return eventEditor; 305 return eventEditor;
304} 306}
305 307
306KOTodoEditor *KODialogManager::getTodoEditor() 308KOTodoEditor *KODialogManager::getTodoEditor()
307{ 309{
308 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(), 310 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(),
309 mMainView ); 311 mMainView );
310 312
311 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 313 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
312 // todoEditor,SLOT(updateCategoryConfig())); 314 // todoEditor,SLOT(updateCategoryConfig()));
313 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show())); 315 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show()));
314 316
315 connect(todoEditor,SIGNAL(todoAdded(Todo *)), 317 connect(todoEditor,SIGNAL(todoAdded(Todo *)),
316 mMainView,SLOT(todoAdded(Todo *))); 318 mMainView,SLOT(todoAdded(Todo *)));
317 connect(todoEditor,SIGNAL(todoChanged(Todo *)), 319 connect(todoEditor,SIGNAL(todoChanged(Todo *)),
318 mMainView,SLOT(todoChanged(Todo *))); 320 mMainView,SLOT(todoChanged(Todo *)));
319 connect(todoEditor,SIGNAL(todoDeleted()), 321 connect(todoEditor,SIGNAL(todoDeleted()),
320 mMainView,SLOT(todoDeleted())); 322 mMainView,SLOT(todoDeleted()));
321 connect(todoEditor,SIGNAL(dialogClose(Incidence*)), 323 connect(todoEditor,SIGNAL(dialogClose(Incidence*)),
322 mMainView,SLOT(dialogClosing(Incidence*))); 324 mMainView,SLOT(dialogClosing(Incidence*)));
323 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)), 325 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)),
324 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 326 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
325 connect( todoEditor, SIGNAL( showAgendaView( bool)), 327 connect( todoEditor, SIGNAL( showAgendaView( bool)),
326 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 328 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
327 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)), 329 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)),
328 // mMainView,SLOT(schedule_cancel(Incidence *))); 330 // mMainView,SLOT(schedule_cancel(Incidence *)));
329 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject())); 331 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject()));
330#ifndef DESKTOP_VERSION 332#ifndef DESKTOP_VERSION
331 todoEditor->resize( QApplication::desktop()->width() -20, 100 ); 333 todoEditor->resize( QApplication::desktop()->width() -20, 100 );
332#endif 334#endif
333 return todoEditor; 335 return todoEditor;
334} 336}
335 337
336void KODialogManager::updateSearchDialog() 338void KODialogManager::updateSearchDialog()
337{ 339{
338 if (mSearchDialog) mSearchDialog->updateView(); 340 if (mSearchDialog) mSearchDialog->updateView();
339} 341}
340 342
341void KODialogManager::setDocumentId( const QString &id ) 343void KODialogManager::setDocumentId( const QString &id )
342{ 344{
343 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id ); 345 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id );
344} 346}
345 347
346void KODialogManager::writeSettings( KConfig *config ) 348void KODialogManager::writeSettings( KConfig *config )
347{ 349{
348 if (mSearchDialog) 350 if (mSearchDialog)
349 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout"); 351 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout");
350} 352}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 3a07348..cf8dae6 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,305 +1,316 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
32class QColor; 32class QColor;
33class QStringList; 33class QStringList;
34 34
35#define VIEW_WN_VIEW 1
36#define VIEW_NX_VIEW 2
37#define VIEW_J_VIEW 3
38#define VIEW_A_VIEW 4
39#define VIEW_ML_VIEW 5
40#define VIEW_M_VIEW 6
41#define VIEW_L_VIEW 7
42#define VIEW_T_VIEW 8
43
35class KOPrefs : public KPimPrefs 44class KOPrefs : public KPimPrefs
36{ 45{
37 public: 46 public:
38 enum { FormatVCalendar, FormatICalendar }; 47 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail }; 48 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail }; 49 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend }; 50 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto }; 51 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination }; 52 enum { standardDestination, askDestination };
44 53
45 virtual ~KOPrefs(); 54 virtual ~KOPrefs();
46 55
47 /** Get instance of KOPrefs. It is made sure that there is only one 56 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */ 57 instance. */
49 static KOPrefs *instance(); 58 static KOPrefs *instance();
50 59
51 /** Set preferences to default values */ 60 /** Set preferences to default values */
52 void usrSetDefaults(); 61 void usrSetDefaults();
53 62
54 /** Read preferences from config file */ 63 /** Read preferences from config file */
55 void usrReadConfig(); 64 void usrReadConfig();
56 65
57 /** Write preferences to config file */ 66 /** Write preferences to config file */
58 void usrWriteConfig(); 67 void usrWriteConfig();
59 void setCategoryDefaults(); 68 void setCategoryDefaults();
60 void setAllDefaults(); 69 void setAllDefaults();
61 70
62 protected: 71 protected:
63 void setTimeZoneIdDefault(); 72 void setTimeZoneIdDefault();
64 73
65 /** Fill empty mail fields with default values. */ 74 /** Fill empty mail fields with default values. */
66 void fillMailDefaults(); 75 void fillMailDefaults();
67 76
68 private: 77 private:
69 /** Constructor disabled for public. Use instance() to create a KOPrefs 78 /** Constructor disabled for public. Use instance() to create a KOPrefs
70 object. */ 79 object. */
71 KOPrefs(); 80 KOPrefs();
72 81
73 static KOPrefs *mInstance; 82 static KOPrefs *mInstance;
74 QStringList getDefaultList(); 83 QStringList getDefaultList();
75 QStringList getLocationDefaultList(); 84 QStringList getLocationDefaultList();
76 public: 85 public:
77 // preferences data 86 // preferences data
78 KConfig* getConfig(); 87 KConfig* getConfig();
79 void setFullName(const QString &); 88 void setFullName(const QString &);
80 QString fullName(); 89 QString fullName();
81 void setEmail(const QString &); 90 void setEmail(const QString &);
82 QString email(); 91 QString email();
83 92
84 QString mAdditional; 93 QString mAdditional;
85 94
86 bool mEmailControlCenter; 95 bool mEmailControlCenter;
87 96
88 bool mBcc; 97 bool mBcc;
89 bool mAutoSave; 98 bool mAutoSave;
90 int mAutoSaveInterval; 99 int mAutoSaveInterval;
91 bool mConfirm; 100 bool mConfirm;
92 101
93 bool mEnableGroupScheduling; 102 bool mEnableGroupScheduling;
94 bool mEnableProjectView; 103 bool mEnableProjectView;
95 104
96 int mDefaultFormat; 105 int mDefaultFormat;
97 int mMailClient; 106 int mMailClient;
98 107
99 int mStartTime; 108 int mStartTime;
100 int mDefaultDuration; 109 int mDefaultDuration;
101 int mAlarmTime; 110 int mAlarmTime;
102 111
103 int mWorkingHoursStart; 112 int mWorkingHoursStart;
104 int mWorkingHoursEnd; 113 int mWorkingHoursEnd;
105 bool mExcludeHolidays; 114 bool mExcludeHolidays;
106 bool mExcludeSaturdays; 115 bool mExcludeSaturdays;
107 bool mMarcusBainsShowSeconds; 116 bool mMarcusBainsShowSeconds;
108 117
109 QFont mTimeBarFont; 118 QFont mTimeBarFont;
110 QFont mMonthViewFont; 119 QFont mMonthViewFont;
111 QFont mAgendaViewFont; 120 QFont mAgendaViewFont;
112 QFont mMarcusBainsFont; 121 QFont mMarcusBainsFont;
113 QFont mTimeLabelsFont; 122 QFont mTimeLabelsFont;
114 QFont mTodoViewFont; 123 QFont mTodoViewFont;
115 QFont mListViewFont; 124 QFont mListViewFont;
116 QFont mDateNavigatorFont; 125 QFont mDateNavigatorFont;
117 QFont mEditBoxFont; 126 QFont mEditBoxFont;
118 QFont mJornalViewFont; 127 QFont mJornalViewFont;
119 QFont mWhatsNextFont; 128 QFont mWhatsNextFont;
120 QFont mEventViewFont; 129 QFont mEventViewFont;
121 130
122 131
123 132
124 133
125 QColor mHolidayColor; 134 QColor mHolidayColor;
126 QColor mHighlightColor; 135 QColor mHighlightColor;
127 QColor mEventColor; 136 QColor mEventColor;
128 QColor mTodoDoneColor; 137 QColor mTodoDoneColor;
129 QColor mAgendaBgColor; 138 QColor mAgendaBgColor;
130 QColor mWorkingHoursColor; 139 QColor mWorkingHoursColor;
131 QColor mTodoDueTodayColor; 140 QColor mTodoDueTodayColor;
132 QColor mTodoOverdueColor; 141 QColor mTodoOverdueColor;
133 QColor mMonthViewEvenColor; 142 QColor mMonthViewEvenColor;
134 QColor mMonthViewOddColor; 143 QColor mMonthViewOddColor;
135 QColor mMonthViewHolidayColor; 144 QColor mMonthViewHolidayColor;
136 bool mMonthViewUsesDayColors; 145 bool mMonthViewUsesDayColors;
137 bool mMonthViewSatSunTog; 146 bool mMonthViewSatSunTog;
138 bool mMonthViewWeek; 147 bool mMonthViewWeek;
139 QColor mAppColor1; 148 QColor mAppColor1;
140 QColor mAppColor2; 149 QColor mAppColor2;
141 bool mUseAppColors; 150 bool mUseAppColors;
142 151
143 int mDayBegins; 152 int mDayBegins;
144 int mHourSize; 153 int mHourSize;
145 int mAllDaySize; 154 int mAllDaySize;
146 bool mShowFullMenu; 155 bool mShowFullMenu;
147 bool mDailyRecur; 156 bool mDailyRecur;
148 bool mWeeklyRecur; 157 bool mWeeklyRecur;
149 bool mMonthDailyRecur; 158 bool mMonthDailyRecur;
150 bool mMonthWeeklyRecur; 159 bool mMonthWeeklyRecur;
151 bool mMonthShowIcons; 160 bool mMonthShowIcons;
152 bool mMonthShowShort; 161 bool mMonthShowShort;
153 bool mEnableToolTips; 162 bool mEnableToolTips;
154 bool mEnableMonthScroll; 163 bool mEnableMonthScroll;
155 bool mFullViewMonth; 164 bool mFullViewMonth;
156 bool mMonthViewUsesCategoryColor; 165 bool mMonthViewUsesCategoryColor;
157 bool mFullViewTodo; 166 bool mFullViewTodo;
158 bool mShowCompletedTodo; 167 bool mShowCompletedTodo;
159 bool mMarcusBainsEnabled; 168 bool mMarcusBainsEnabled;
160 int mNextXDays; 169 int mNextXDays;
161 int mWhatsNextDays; 170 int mWhatsNextDays;
162 int mWhatsNextPrios; 171 int mWhatsNextPrios;
163 bool mEnableQuickTodo; 172 bool mEnableQuickTodo;
164 173
165 bool mCompactDialogs; 174 bool mCompactDialogs;
166 bool mVerticalScreen; 175 bool mVerticalScreen;
167 176
168 bool mShowIconNewTodo; 177 bool mShowIconNewTodo;
169 bool mShowIconNewEvent; 178 bool mShowIconNewEvent;
170 bool mShowIconSearch; 179 bool mShowIconSearch;
171 bool mShowIconList; 180 bool mShowIconList;
172 bool mShowIconDay1; 181 bool mShowIconDay1;
173 bool mShowIconDay5; 182 bool mShowIconDay5;
174 bool mShowIconDay6; 183 bool mShowIconDay6;
175 bool mShowIconDay7; 184 bool mShowIconDay7;
176 bool mShowIconMonth; 185 bool mShowIconMonth;
177 bool mShowIconTodoview; 186 bool mShowIconTodoview;
178 bool mShowIconBackFast; 187 bool mShowIconBackFast;
179 bool mShowIconBack; 188 bool mShowIconBack;
180 bool mShowIconToday; 189 bool mShowIconToday;
181 bool mShowIconForward; 190 bool mShowIconForward;
182 bool mShowIconForwardFast; 191 bool mShowIconForwardFast;
183 bool mShowIconWhatsThis; 192 bool mShowIconWhatsThis;
184 bool mShowIconWeekNum; 193 bool mShowIconWeekNum;
185 bool mShowIconNextDays; 194 bool mShowIconNextDays;
186 bool mShowIconNext; 195 bool mShowIconNext;
187 bool mShowIconJournal; 196 bool mShowIconJournal;
188 bool mShowIconFilter; 197 bool mShowIconFilter;
189 bool mShowIconOnetoolbar; 198 bool mShowIconOnetoolbar;
190 bool mShowIconNavigator; 199 bool mShowIconNavigator;
191 bool mShowIconAllday; 200 bool mShowIconAllday;
192 bool mShowIconFilterview; 201 bool mShowIconFilterview;
193 bool mShowIconToggleFull; 202 bool mShowIconToggleFull;
194 203
195 bool mShowIconStretch; 204 bool mShowIconStretch;
196 205
197 bool mToolBarHor; 206 bool mToolBarHor;
198 bool mToolBarUp; 207 bool mToolBarUp;
199 bool mToolBarHorV; 208 bool mToolBarHorV;
200 bool mToolBarUpV; 209 bool mToolBarUpV;
201 bool mToolBarHorN; 210 bool mToolBarHorN;
202 bool mToolBarUpN; 211 bool mToolBarUpN;
203 bool mToolBarHorF; 212 bool mToolBarHorF;
204 bool mToolBarUpF; 213 bool mToolBarUpF;
205 bool mToolBarMiniIcons; 214 bool mToolBarMiniIcons;
206 215
207 bool mAskForQuit; 216 bool mAskForQuit;
208 bool mUsePassWd; 217 bool mUsePassWd;
209 bool mShowSyncEvents; 218 bool mShowSyncEvents;
210 bool mShowTodoInAgenda; 219 bool mShowTodoInAgenda;
211 bool mShowTimeInAgenda; 220 bool mShowTimeInAgenda;
212 bool mHideNonStartedTodos; 221 bool mHideNonStartedTodos;
213 222
214 int mLastSyncTime; 223 int mLastSyncTime;
215 void setCategoryColor(QString cat,const QColor & color); 224 void setCategoryColor(QString cat,const QColor & color);
216 QColor *categoryColor(QString cat); 225 QColor *categoryColor(QString cat);
217 226
218 QString mArchiveFile; 227 QString mArchiveFile;
219 QString mHtmlExportFile; 228 QString mHtmlExportFile;
220 bool mHtmlWithSave; 229 bool mHtmlWithSave;
221 230
222 QStringList mSelectedPlugins; 231 QStringList mSelectedPlugins;
223 232
224 QString mLastImportFile; 233 QString mLastImportFile;
225 QString mLastVcalFile; 234 QString mLastVcalFile;
226 QString mLastSaveFile; 235 QString mLastSaveFile;
227 QString mLastLoadFile; 236 QString mLastLoadFile;
228 237
229 238
230 QString mDefaultAlarmFile; 239 QString mDefaultAlarmFile;
231 int mIMIPScheduler; 240 int mIMIPScheduler;
232 int mIMIPSend; 241 int mIMIPSend;
233 QStringList mAdditionalMails; 242 QStringList mAdditionalMails;
234 int mIMIPAutoRefresh; 243 int mIMIPAutoRefresh;
235 int mIMIPAutoInsertReply; 244 int mIMIPAutoInsertReply;
236 int mIMIPAutoInsertRequest; 245 int mIMIPAutoInsertRequest;
237 int mIMIPAutoFreeBusy; 246 int mIMIPAutoFreeBusy;
238 int mIMIPAutoFreeBusyReply; 247 int mIMIPAutoFreeBusyReply;
239 248
240 QStringList mTodoTemplates; 249 QStringList mTodoTemplates;
241 QStringList mEventTemplates; 250 QStringList mEventTemplates;
242 251
243 int mDestination; 252 int mDestination;
244 253
245 254
246 bool mEditOnDoubleClick; 255 bool mEditOnDoubleClick;
247 bool mViewChangeHoldFullscreen; 256 bool mViewChangeHoldFullscreen;
248 bool mViewChangeHoldNonFullscreen; 257 bool mViewChangeHoldNonFullscreen;
249 bool mCenterOnCurrentTime; 258 bool mCenterOnCurrentTime;
250 bool mSetTimeToDayStartAt; 259 bool mSetTimeToDayStartAt;
251 bool mHighlightCurrentDay; 260 bool mHighlightCurrentDay;
252 bool mUseHighlightLightColor; 261 bool mUseHighlightLightColor;
253 bool mListViewMonthTimespan; 262 bool mListViewMonthTimespan;
254 bool mWNViewShowsParents; 263 bool mWNViewShowsParents;
255 bool mWNViewShowsPast; 264 bool mWNViewShowsPast;
256 bool mWNViewShowLocation; 265 bool mWNViewShowLocation;
257 bool mTodoViewShowsPercentage; 266 bool mTodoViewShowsPercentage;
258 bool mTodoViewUsesCatColors; 267 bool mTodoViewUsesCatColors;
259 bool mMonthViewUsesBigFont; 268 bool mMonthViewUsesBigFont;
260 bool mTodoViewUsesSmallFont; 269 bool mTodoViewUsesSmallFont;
261 bool mTodoViewUsesForegroundColor; 270 bool mTodoViewUsesForegroundColor;
262 bool mMonthViewUsesForegroundColor; 271 bool mMonthViewUsesForegroundColor;
263 272
264 bool mHightlightDateTimeEdit; 273 bool mHightlightDateTimeEdit;
265 bool mShortDateInViewer; 274 bool mShortDateInViewer;
266 275
267 bool mShowDateNavigator; 276 bool mShowDateNavigator;
268 277
269 QStringList mLocationDefaults; 278 QStringList mLocationDefaults;
270 QStringList mEventSummaryUser; 279 QStringList mEventSummaryUser;
271 QStringList mTodoSummaryUser; 280 QStringList mTodoSummaryUser;
272 281
273 bool mUseInternalAlarmNotification; 282 bool mUseInternalAlarmNotification;
274 int mAlarmPlayBeeps; 283 int mAlarmPlayBeeps;
275 int mAlarmSuspendTime; 284 int mAlarmSuspendTime;
276 int mAlarmSuspendCount; 285 int mAlarmSuspendCount;
277 int mAlarmBeepInterval; 286 int mAlarmBeepInterval;
278 int mOldLanguage; 287 int mOldLanguage;
279 int mOldLoadedLanguage; 288 int mOldLoadedLanguage;
280 289
281 290
282 QString mActiveSyncPort; 291 QString mActiveSyncPort;
283 QString mActiveSyncIP; 292 QString mActiveSyncIP;
284 293
285 // settings for eventviewer 294 // settings for eventviewer
286 bool mEVshowDetails; 295 bool mEVshowDetails;
287 bool mEVshowCreated; 296 bool mEVshowCreated;
288 bool mEVshowChanged; 297 bool mEVshowChanged;
289 bool mWTshowDetails; 298 bool mWTshowDetails;
290 bool mWTshowCreated; 299 bool mWTshowCreated;
291 bool mWTshowChanged; 300 bool mWTshowChanged;
292 301
302 int mCurrentDisplayedView;
303
293 private: 304 private:
294 QDict<QColor> mCategoryColors; 305 QDict<QColor> mCategoryColors;
295 QColor mDefaultCategoryColor; 306 QColor mDefaultCategoryColor;
296 307
297 QFont mDefaultTimeBarFont; 308 QFont mDefaultTimeBarFont;
298 QFont mDefaultViewFont; 309 QFont mDefaultViewFont;
299 QFont mDefaultMonthViewFont; 310 QFont mDefaultMonthViewFont;
300 311
301 QString mName; 312 QString mName;
302 QString mEmail; 313 QString mEmail;
303}; 314};
304 315
305#endif 316#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index c442d0b..406e741 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,829 +1,827 @@
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 <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 flagResetViewChangeDate = 0; 64 flagResetViewChangeDate = 0;
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->dateNavigator()->selectDate( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ; 133 mCurrentAgendaView = 1 ;
134 } else if (view == 4 ) { 134 } else if (view == 4 ) {
135 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
136 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
137 } else if (view == 5 ) { 137 } else if (view == 5 ) {
138 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
139 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
140 } else if (view == 6 ) { 140 } else if (view == 6 ) {
141 resetDateSilent( date,1); 141 resetDateSilent( date,1);
142 showMonthView(); 142 showMonthView();
143 } else if (view == 7 ) { 143 } else if (view == 7 ) {
144 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
145 showJournalView(); 145 showJournalView();
146 } else if (view == 8 ) { 146 } else if (view == 8 ) {
147 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
148 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
149 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
150 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
151 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
152 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
153 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
154 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
155 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
157 if ( lastMode ) { 157 if ( lastMode ) {
158 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
159 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
160 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
161 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
162 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
163 } 163 }
164 } else 164 } else
165 showWeekView(); 165 showWeekView();
166 } else if (view == 10) { 166 } else if (view == 10) {
167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
168 } 168 }
169} 169}
170 170
171 171
172 172
173void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
174{ 174{
175 config->setGroup("General"); 175 config->setGroup("General");
176 176
177 QString view; 177 QString view;
178 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
179 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
180 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
181 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
183 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
184 else view = "Agenda"; 184 else view = "Agenda";
185 185
186 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
187 187
188 if (mAgendaView) { 188 if (mAgendaView) {
189 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
190 } 190 }
191 if (mTimeSpanView) { 191 if (mTimeSpanView) {
192 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
193 } 193 }
194 if (mListView) { 194 if (mListView) {
195 mListView->writeSettings(config); 195 mListView->writeSettings(config);
196 } 196 }
197 if (mTodoView) { 197 if (mTodoView) {
198 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
199 } 199 }
200} 200}
201void KOViewManager::showNextView() 201void KOViewManager::showNextView()
202{ 202{
203 static int selecteddatescount = 0; 203 static int selecteddatescount = 0;
204 static QDate selecteddate = QDate ( 2000, 1, 1 ); 204 static QDate selecteddate = QDate ( 2000, 1, 1 );
205 static QDate baseCycleDate = QDate ( 2000, 1, 1 ); 205 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
206 int newCount = mMainView->dateNavigator()->selectedDates().count(); 206 int newCount = mMainView->dateNavigator()->selectedDates().count();
207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
208 flagResetViewChangeDate = 1; 208 flagResetViewChangeDate = 1;
209 } 209 }
210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
211 flagResetViewChangeDate = 1; 211 flagResetViewChangeDate = 1;
212 if ( flagResetViewChangeDate > 0 ) { 212 if ( flagResetViewChangeDate > 0 ) {
213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
214 //qDebug("newCycle "); 214 //qDebug("newCycle ");
215 } 215 }
216 if (mCurrentView == mWhatsNextView) goto NEXT_X; 216 if (mCurrentView == mWhatsNextView) goto NEXT_X;
217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
218 if (mCurrentView == mJournalView ) goto DAY_1; 218 if (mCurrentView == mJournalView ) goto DAY_1;
219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
221 if (mCurrentView == mAgendaView ) goto DAY_6; 221 if (mCurrentView == mAgendaView ) goto DAY_6;
222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
223 if (mCurrentView == mMonthView ) goto LIST; 223 if (mCurrentView == mMonthView ) goto LIST;
224 if (mCurrentView == mListView ) goto TODO; 224 if (mCurrentView == mListView ) goto TODO;
225 // if (mCurrentView == mTodoView ) goto NEXT; 225 // if (mCurrentView == mTodoView ) goto NEXT;
226 NEXT: 226 NEXT:
227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
228 NEXT_X: 228 NEXT_X:
229 if ( KOPrefs::instance()->mShowIconNextDays ) { 229 if ( KOPrefs::instance()->mShowIconNextDays ) {
230 globalFlagBlockAgenda = 1; 230 showNextXView();
231 if ( mCurrentAgendaView != 3 )
232 mCurrentAgendaView = -1;
233 showAgendaView(KOPrefs::instance()->mFullViewMonth);
234 globalFlagBlockAgenda = 2;
235 mMainView->dateNavigator()->selectDates( baseCycleDate ,
236 KOPrefs::instance()->mNextXDays );
237 mFlagShowNextxDays = true;
238 mCurrentAgendaView = 3 ;
239 goto ENTE ; 231 goto ENTE ;
240 } 232 }
241 JOURNAL: 233 JOURNAL:
242 if ( KOPrefs::instance()->mShowIconJournal ) { 234 if ( KOPrefs::instance()->mShowIconJournal ) {
243 resetDateSilent( baseCycleDate , 1 ); 235 resetDateSilent( baseCycleDate , 1 );
244 showJournalView() ;goto ENTE ;} 236 showJournalView() ;goto ENTE ;}
245 DAY_1: 237 DAY_1:
246 if ( KOPrefs::instance()->mShowIconDay1 ) { 238 if ( KOPrefs::instance()->mShowIconDay1 ) {
247 resetDateSilent( baseCycleDate , 2 ); 239 resetDateSilent( baseCycleDate , 2 );
248 showDayView() ;goto ENTE ;} 240 showDayView() ;goto ENTE ;}
249 DAY_5: 241 DAY_5:
250 if ( KOPrefs::instance()->mShowIconDay5 ) { 242 if ( KOPrefs::instance()->mShowIconDay5 ) {
251 resetDateSilent( baseCycleDate , 2 ); 243 resetDateSilent( baseCycleDate , 2 );
252 showWorkWeekView() ;goto ENTE ;} 244 showWorkWeekView() ;goto ENTE ;}
253 DAY_7: 245 DAY_7:
254 if ( KOPrefs::instance()->mShowIconDay7 ) { 246 if ( KOPrefs::instance()->mShowIconDay7 ) {
255 resetDateSilent( baseCycleDate , 2 ); 247 resetDateSilent( baseCycleDate , 2 );
256 showWeekView();goto ENTE ;} 248 showWeekView();goto ENTE ;}
257 DAY_6: 249 DAY_6:
258 if ( KOPrefs::instance()->mShowIconDay6 ) { 250 if ( KOPrefs::instance()->mShowIconDay6 ) {
259 resetDateSilent( baseCycleDate , 2 ); 251 resetDateSilent( baseCycleDate , 2 );
260 showMonthViewWeek();goto ENTE ;} 252 showMonthViewWeek();goto ENTE ;}
261 MONTH: 253 MONTH:
262 if ( KOPrefs::instance()->mShowIconMonth ) { 254 if ( KOPrefs::instance()->mShowIconMonth ) {
263 resetDateSilent( baseCycleDate , 2 ); 255 resetDateSilent( baseCycleDate , 2 );
264 showMonthView();goto ENTE ;} 256 showMonthView();goto ENTE ;}
265 LIST: 257 LIST:
266 if ( KOPrefs::instance()->mShowIconList ) { 258 if ( KOPrefs::instance()->mShowIconList ) {
267 resetDateSilent( baseCycleDate , 2 ); 259 resetDateSilent( baseCycleDate , 2 );
268 showListView() ;goto ENTE ;} 260 showListView() ;goto ENTE ;}
269 TODO: 261 TODO:
270 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
271 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
272 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
273 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
274 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
275 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
276 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
277 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
278 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
279 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
280 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
281 ENTE: 273 ENTE:
282 flagResetViewChangeDate = 0; 274 flagResetViewChangeDate = 0;
283 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
284 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 276 selecteddate = mMainView->dateNavigator()->selectedDates().first();
285 277
286} 278}
287void KOViewManager::resetDateSilent( QDate date , int days ) 279void KOViewManager::resetDateSilent( QDate date , int days )
288{ 280{
289 mMainView->dateNavigator()->blockSignals( true ); 281 mMainView->dateNavigator()->blockSignals( true );
290 mMainView->dateNavigator()->selectDates( date , days ); 282 mMainView->dateNavigator()->selectDates( date , days );
291 mMainView->dateNavigator()->blockSignals( false ); 283 mMainView->dateNavigator()->blockSignals( false );
292} 284}
293void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
294{ 286{
295 if ( flagResetViewChangeDate < 10 ) 287 if ( flagResetViewChangeDate < 10 )
296 ++flagResetViewChangeDate; 288 ++flagResetViewChangeDate;
297 //mFlagShowNextxDays = false; 289 //mFlagShowNextxDays = false;
298 //if(view == mCurrentView) return; 290 //if(view == mCurrentView) return;
299 if ( view == 0 ) { 291 if ( view == 0 ) {
300 view = mCurrentView; 292 view = mCurrentView;
301 if ( view == 0 ) 293 if ( view == 0 )
302 return; 294 return;
303 } 295 }
304 bool callupdate = !(view == mCurrentView); 296 bool callupdate = !(view == mCurrentView);
305 bool full = fullScreen; 297 bool full = fullScreen;
306 if(view == mCurrentView && view != mWhatsNextView ) { 298 if(view == mCurrentView && view != mWhatsNextView ) {
307 if ( mCurrentAgendaView < 0 ) 299 if ( mCurrentAgendaView < 0 )
308 return; 300 return;
309 if ( view != mMonthView ) 301 if ( view != mMonthView )
310 full = mMainView->leftFrame()->isVisible(); 302 full = mMainView->leftFrame()->isVisible();
311 } else { 303 } else {
312 if ( view == mMonthView && mMonthView) 304 if ( view == mMonthView && mMonthView)
313 ;//mMonthView->skipResize = true ; 305 ;//mMonthView->skipResize = true ;
314 mCurrentView = view; 306 mCurrentView = view;
315 // bool full = fullScreen; 307 // bool full = fullScreen;
316 bool isFull = !mMainView->leftFrame()->isVisible(); 308 bool isFull = !mMainView->leftFrame()->isVisible();
317 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
318 full = true; 310 full = true;
319 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
320 full = false; 312 full = false;
321 } 313 }
322 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
323 //raiseCurrentView( full ); 315 //raiseCurrentView( full );
324 mMainView->processIncidenceSelection( 0 ); 316 mMainView->processIncidenceSelection( 0 );
325 //mMainView->updateView(); 317 //mMainView->updateView();
326 raiseCurrentView( full, callupdate ); 318 raiseCurrentView( full, callupdate );
327 mMainView->adaptNavigationUnits(); 319 mMainView->adaptNavigationUnits();
328} 320}
329 321
330void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 322void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
331{ 323{
332 mCurrentAgendaView = 0; 324 mCurrentAgendaView = 0;
333 if ( fullScreen ) { 325 if ( fullScreen ) {
334 mMainView->leftFrame()->hide(); 326 mMainView->leftFrame()->hide();
335 } else { 327 } else {
336 mMainView->leftFrame()->show(); 328 mMainView->leftFrame()->show();
337 } 329 }
338 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 330 //if ( mCurrentView == mMonthView ) qApp->processEvents();
339 emit signalFullScreen( !fullScreen ); 331 emit signalFullScreen( !fullScreen );
340 if ( callUpdateView ) 332 if ( callUpdateView )
341 mMainView->updateView(); 333 mMainView->updateView();
342 334
343 if ( globalFlagBlockAgenda == 5 ) { 335 if ( globalFlagBlockAgenda == 5 ) {
344 globalFlagBlockAgenda = 4; 336 globalFlagBlockAgenda = 4;
345 globalFlagBlockAgendaItemPaint = 1; 337 globalFlagBlockAgendaItemPaint = 1;
346 } 338 }
347 mMainView->viewStack()->raiseWidget(mCurrentView); 339 mMainView->viewStack()->raiseWidget(mCurrentView);
348 if ( globalFlagBlockAgenda == 4 ) { 340 if ( globalFlagBlockAgenda == 4 ) {
349 if ( mCurrentView == mAgendaView ) { 341 if ( mCurrentView == mAgendaView ) {
350 //globalFlagBlockAgenda =1 ; 342 //globalFlagBlockAgenda =1 ;
351 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 343 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
352 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 344 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
353 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 345 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
354 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 346 mAgendaView->setStartHour( QTime::currentTime ().hour() );
355 qApp->processEvents(); 347 qApp->processEvents();
356 //qDebug("qApp->processEvents() "); 348 //qDebug("qApp->processEvents() ");
357 globalFlagBlockAgenda = 0; 349 globalFlagBlockAgenda = 0;
358 mAgendaView->repaintAgenda(); 350 mAgendaView->repaintAgenda();
359 351
360 } 352 }
361 globalFlagBlockAgenda = 0; 353 globalFlagBlockAgenda = 0;
362 } 354 }
363 emit signalAgendaView( mCurrentView == mAgendaView ); 355 emit signalAgendaView( mCurrentView == mAgendaView );
364 //qDebug("raiseCurrentView ende "); 356 //qDebug("raiseCurrentView ende ");
365 357
366} 358}
367 359
368void KOViewManager::updateView() 360void KOViewManager::updateView()
369{ 361{
370 // qDebug("KOViewManager::updateView() "); 362 // qDebug("KOViewManager::updateView() ");
371 // if we are updating mTodoView, we get endless recursion 363 // if we are updating mTodoView, we get endless recursion
372 if ( mTodoView == mCurrentView ) 364 if ( mTodoView == mCurrentView )
373 return; 365 return;
374 if ( mCurrentView ) mCurrentView->updateView(); 366 if ( mCurrentView ) mCurrentView->updateView();
375 367
376} 368}
377 369
378void KOViewManager::updateView(const QDate &start, const QDate &end) 370void KOViewManager::updateView(const QDate &start, const QDate &end)
379{ 371{
380 // kdDebug() << "KOViewManager::updateView()" << endl; 372 // kdDebug() << "KOViewManager::updateView()" << endl;
381 373
382 if (mCurrentView) mCurrentView->showDates(start, end); 374 if (mCurrentView) mCurrentView->showDates(start, end);
383 375
384 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 376 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
385} 377}
386 378
387 379
388void KOViewManager::updateWNview() 380void KOViewManager::updateWNview()
389{ 381{
390 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 382 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
391 mWhatsNextView->updateView(); 383 mWhatsNextView->updateView();
392 if ( mCurrentView == mMonthView && mMonthView ) 384 if ( mCurrentView == mMonthView && mMonthView )
393 mMonthView->updateView(); 385 mMonthView->updateView();
394 386
395} 387}
396void KOViewManager::showWhatsNextView() 388void KOViewManager::showWhatsNextView()
397{ 389{
398 if (!mWhatsNextView) { 390 if (!mWhatsNextView) {
399 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 391 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
400 "KOViewManager::WhatsNextView"); 392 "KOViewManager::WhatsNextView");
401 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 393 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
402 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 394 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
403 addView(mWhatsNextView); 395 addView(mWhatsNextView);
404 connect(this, SIGNAL( printWNV() ), 396 connect(this, SIGNAL( printWNV() ),
405 mWhatsNextView, SLOT( printMe() ) ); 397 mWhatsNextView, SLOT( printMe() ) );
406 } 398 }
407 globalFlagBlockAgenda = 1; 399 globalFlagBlockAgenda = 1;
408 showView(mWhatsNextView, true ); 400 showView(mWhatsNextView, true );
409 //mWhatsNextView->updateView(); 401 //mWhatsNextView->updateView();
410 402 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
411} 403}
412 404
413void KOViewManager::slotprintWNV() 405void KOViewManager::slotprintWNV()
414{ 406{
415 if (!mWhatsNextView) 407 if (!mWhatsNextView)
416 showWhatsNextView(); 408 showWhatsNextView();
417 emit printWNV(); 409 emit printWNV();
418 410
419} 411}
420void KOViewManager::showListView() 412void KOViewManager::showListView()
421{ 413{
422 if (!mListView) { 414 if (!mListView) {
423 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 415 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
424 addView(mListView); 416 addView(mListView);
425 417
426 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 418 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
427 mMainView, SLOT(showIncidence(Incidence *))); 419 mMainView, SLOT(showIncidence(Incidence *)));
428 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 420 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
429 mMainView, SLOT(editIncidence(Incidence *))); 421 mMainView, SLOT(editIncidence(Incidence *)));
430 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 422 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
431 mMainView, SLOT(deleteIncidence(Incidence *))); 423 mMainView, SLOT(deleteIncidence(Incidence *)));
432 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 424 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
433 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 425 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
434 connect( mListView, SIGNAL( signalNewEvent() ), 426 connect( mListView, SIGNAL( signalNewEvent() ),
435 mMainView, SLOT( newEvent() ) ); 427 mMainView, SLOT( newEvent() ) );
436 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 428 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
437 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 429 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
438 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 430 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
439 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 431 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
440 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 432 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
441 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 433 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
442 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 434 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
443 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 435 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
444 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 436 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
445 } 437 }
446 // bool temp = mFlagShowNextxDays; 438 // bool temp = mFlagShowNextxDays;
447 //globalFlagBlockPainting = true; 439 //globalFlagBlockPainting = true;
448 globalFlagBlockAgenda = 1; 440 globalFlagBlockAgenda = 1;
449 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 441 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
450 mMainView->setBlockShowDates( true ); 442 mMainView->setBlockShowDates( true );
451 mMainView->dateNavigator()->selectMonth(); 443 mMainView->dateNavigator()->selectMonth();
452 mMainView->setBlockShowDates( false ); 444 mMainView->setBlockShowDates( false );
453 } 445 }
454 showView(mListView, KOPrefs::instance()->mFullViewTodo); 446 showView(mListView, KOPrefs::instance()->mFullViewTodo);
455 //mFlagShowNextxDays = temp; 447 //mFlagShowNextxDays = temp;
448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
456} 449}
457 450
458void KOViewManager::showAgendaView( bool fullScreen ) 451void KOViewManager::showAgendaView( bool fullScreen )
459{ 452{
460 453
461 mMainView->dialogManager()->hideSearchDialog(); 454 mMainView->dialogManager()->hideSearchDialog();
462 // qDebug("KOViewManager::showAgendaView "); 455 // qDebug("KOViewManager::showAgendaView ");
463 bool full; 456 bool full;
464 full = fullScreen; 457 full = fullScreen;
465 if (!mAgendaView) { 458 if (!mAgendaView) {
466 full = false; 459 full = false;
467 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 460 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
468 addView(mAgendaView); 461 addView(mAgendaView);
469#ifndef DESKTOP_VERSION 462#ifndef DESKTOP_VERSION
470 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 463 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
471#endif 464#endif
472 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 465 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
473 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 466 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
474 467
475 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 468 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
476 469
477 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 470 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
478 471
479 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 472 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
480 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 473 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
481 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 474 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
482 mMainView, SLOT(newEvent(QDateTime))); 475 mMainView, SLOT(newEvent(QDateTime)));
483 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 476 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
484 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 477 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
485 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 478 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
486 mMainView, SLOT(newEvent(QDate))); 479 mMainView, SLOT(newEvent(QDate)));
487 480
488 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 481 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
489 mMainView, SLOT(editIncidence(Incidence *))); 482 mMainView, SLOT(editIncidence(Incidence *)));
490 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 483 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
491 mMainView, SLOT(showIncidence(Incidence *))); 484 mMainView, SLOT(showIncidence(Incidence *)));
492 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 485 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
493 mMainView, SLOT(deleteIncidence(Incidence *))); 486 mMainView, SLOT(deleteIncidence(Incidence *)));
494 487
495 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 488 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
496 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 489 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
497 490
498 connect(mAgendaView, SIGNAL( toggleExpand() ), 491 connect(mAgendaView, SIGNAL( toggleExpand() ),
499 mMainView, SLOT( toggleExpand() ) ); 492 mMainView, SLOT( toggleExpand() ) );
500 493
501 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 494 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
502 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 495 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
503 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 496 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
504 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 497 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
505 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 498 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
506 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 499 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
507 SLOT( updateTodo( Todo *, int ) ) ); 500 SLOT( updateTodo( Todo *, int ) ) );
508 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 501 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
509 mMainView, SIGNAL( todoModified( Todo *, int ))); 502 mMainView, SIGNAL( todoModified( Todo *, int )));
510 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 503 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
511 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 504 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
512 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 505 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
513 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 506 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
514 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 507 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
515 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 508 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
516 mAgendaView->readSettings(); 509 mAgendaView->readSettings();
517 mAgendaView->updateConfig(); 510 mAgendaView->updateConfig();
518 } 511 }
519 512
520 showView( mAgendaView, full); 513 showView( mAgendaView, full);
521 514 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
522} 515}
523 516
524void KOViewManager::showDayView() 517void KOViewManager::showDayView()
525{ 518{
526 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 519 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
527 mFlagShowNextxDays = false; 520 mFlagShowNextxDays = false;
528 globalFlagBlockLabel = 1; 521 globalFlagBlockLabel = 1;
529 globalFlagBlockAgenda = 1; 522 globalFlagBlockAgenda = 1;
530 if ( mCurrentAgendaView != 1 ) 523 if ( mCurrentAgendaView != 1 )
531 mCurrentAgendaView = -1; 524 mCurrentAgendaView = -1;
532 showAgendaView(); 525 showAgendaView();
533 qApp->processEvents(); 526 qApp->processEvents();
534 globalFlagBlockAgenda = 2; 527 globalFlagBlockAgenda = 2;
535 globalFlagBlockLabel = 0; 528 globalFlagBlockLabel = 0;
536 mMainView->dateNavigator()->selectDates( 1 ); 529 mMainView->dateNavigator()->selectDates( 1 );
537 mCurrentAgendaView = 1 ; 530 mCurrentAgendaView = 1 ;
538 531
539} 532}
540 533
541void KOViewManager::showWorkWeekView() 534void KOViewManager::showWorkWeekView()
542{ 535{
543 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 536 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
544 mFlagShowNextxDays = false; 537 mFlagShowNextxDays = false;
545 globalFlagBlockAgenda = 1; 538 globalFlagBlockAgenda = 1;
546 globalFlagBlockLabel = 1; 539 globalFlagBlockLabel = 1;
547 if ( mCurrentAgendaView != 5 ) 540 if ( mCurrentAgendaView != 5 )
548 mCurrentAgendaView = -1; 541 mCurrentAgendaView = -1;
549 showAgendaView(); 542 showAgendaView();
550 qApp->processEvents(); 543 qApp->processEvents();
551 globalFlagBlockAgenda = 2; 544 globalFlagBlockAgenda = 2;
552 globalFlagBlockLabel = 0; 545 globalFlagBlockLabel = 0;
553 mMainView->dateNavigator()->selectWorkWeek(); 546 mMainView->dateNavigator()->selectWorkWeek();
554 mCurrentAgendaView = 5 ; 547 mCurrentAgendaView = 5 ;
555 548
556} 549}
557 550
558void KOViewManager::showWeekView() 551void KOViewManager::showWeekView()
559{ 552{
560 /* 553 /*
561 globalFlagBlockAgenda = 2; 554 globalFlagBlockAgenda = 2;
562 qDebug("4globalFlagBlockAgenda = 2; "); 555 qDebug("4globalFlagBlockAgenda = 2; ");
563 //globalFlagBlockPainting = true; 556 //globalFlagBlockPainting = true;
564 mMainView->dateNavigator()->selectWeek(); 557 mMainView->dateNavigator()->selectWeek();
565 showAgendaView(); 558 showAgendaView();
566 */ 559 */
567 560
568 561
569 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 562 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
570 mFlagShowNextxDays = false; 563 mFlagShowNextxDays = false;
571 globalFlagBlockAgenda = 1; 564 globalFlagBlockAgenda = 1;
572 globalFlagBlockLabel = 1; 565 globalFlagBlockLabel = 1;
573 if ( mCurrentAgendaView != 7 ) 566 if ( mCurrentAgendaView != 7 )
574 mCurrentAgendaView = -1; 567 mCurrentAgendaView = -1;
575 showAgendaView(); 568 showAgendaView();
576 qApp->processEvents(); 569 qApp->processEvents();
577 globalFlagBlockAgenda = 2; 570 globalFlagBlockAgenda = 2;
578 globalFlagBlockLabel = 0; 571 globalFlagBlockLabel = 0;
579 mMainView->dateNavigator()->selectWeek(); 572 mMainView->dateNavigator()->selectWeek();
580 mCurrentAgendaView = 7 ; 573 mCurrentAgendaView = 7 ;
581} 574}
582 575
583void KOViewManager::showNextXView() 576void KOViewManager::showNextXView()
584{ 577{
585 578
586 globalFlagBlockAgenda = 1; 579 globalFlagBlockAgenda = 1;
587 if ( mCurrentAgendaView != 3 ) 580 if ( mCurrentAgendaView != 3 )
588 mCurrentAgendaView = -1; 581 mCurrentAgendaView = -1;
589 showAgendaView(KOPrefs::instance()->mFullViewMonth); 582 showAgendaView(KOPrefs::instance()->mFullViewMonth);
590 globalFlagBlockAgenda = 2; 583 globalFlagBlockAgenda = 2;
591 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 584 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
592 KOPrefs::instance()->mNextXDays ); 585 KOPrefs::instance()->mNextXDays );
593 mFlagShowNextxDays = true; 586 mFlagShowNextxDays = true;
594 mCurrentAgendaView = 3 ; 587 mCurrentAgendaView = 3 ;
588 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
595} 589}
596bool KOViewManager::showsNextDays() 590bool KOViewManager::showsNextDays()
597{ 591{
598 return mFlagShowNextxDays; 592 return mFlagShowNextxDays;
599} 593}
600void KOViewManager::createMonthView() 594void KOViewManager::createMonthView()
601{ 595{
602if (!mMonthView) { 596if (!mMonthView) {
603 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 597 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
604 598
605 addView(mMonthView); 599 addView(mMonthView);
606 // mMonthView->show(); 600 // mMonthView->show();
607 // SIGNALS/SLOTS FOR MONTH VIEW 601 // SIGNALS/SLOTS FOR MONTH VIEW
608 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 602 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
609 mMainView, SLOT(newEvent(QDateTime))); 603 mMainView, SLOT(newEvent(QDateTime)));
610 604
611 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 605 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
612 mMainView, SLOT(showIncidence(Incidence *))); 606 mMainView, SLOT(showIncidence(Incidence *)));
613 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 607 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
614 mMainView, SLOT(editIncidence(Incidence *))); 608 mMainView, SLOT(editIncidence(Incidence *)));
615 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 609 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
616 mMainView, SLOT(deleteIncidence(Incidence *))); 610 mMainView, SLOT(deleteIncidence(Incidence *)));
617 611
618 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 612 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
619 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 613 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
620 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 614 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
621 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 615 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
622 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 616 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
623 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 617 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
624 618
625 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 619 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
626 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 620 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
627 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 621 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
628 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 622 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
629 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 623 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
630 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 624 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
631 connect( mMonthView, SIGNAL( selectMonth() ), 625 connect( mMonthView, SIGNAL( selectMonth() ),
632 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 626 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
633 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 627 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
634 mMainView, SLOT ( showDay( QDate ) ) ); 628 mMainView, SLOT ( showDay( QDate ) ) );
635 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 629 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
636 connect( mMonthView, SIGNAL(nextMonth() ), 630 connect( mMonthView, SIGNAL(nextMonth() ),
637 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 631 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
638 connect( mMonthView, SIGNAL(prevMonth() ), 632 connect( mMonthView, SIGNAL(prevMonth() ),
639 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 633 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
640 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 634 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
641 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 635 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
642 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 636 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
643 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 637 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
644 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 638 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
645 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 639 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
646 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 640 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
647 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 641 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
648 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 642 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
649 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 643 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
650 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 644 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
651 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 645 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
652 646
653 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 647 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
654 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 648 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
655 649
656 650
657 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 651 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
658 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 652 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
659 653
660 } 654 }
661} 655}
662void KOViewManager::showMonthViewWeek() 656void KOViewManager::showMonthViewWeek()
663{ 657{
664 createMonthView(); 658 createMonthView();
665 globalFlagBlockAgenda = 1; 659 globalFlagBlockAgenda = 1;
666 bool full = true; 660 bool full = true;
667 if ( mCurrentView == mMonthView) 661 if ( mCurrentView == mMonthView)
668 full = mMainView->leftFrame()->isVisible(); 662 full = mMainView->leftFrame()->isVisible();
669 if ( !KOPrefs::instance()->mMonthViewWeek ) { 663 if ( !KOPrefs::instance()->mMonthViewWeek ) {
670 mMonthView->switchView(); 664 mMonthView->switchView();
671 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 665 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
672 full = false; 666 full = false;
673 else 667 else
674 full = true; 668 full = true;
675 } 669 }
676 mMainView->dateNavigator()->selectWeek(); 670 mMainView->dateNavigator()->selectWeek();
677 showView(mMonthView, full ); 671 showView(mMonthView, full );
678 mMonthView->setKeyBFocus(); 672 mMonthView->setKeyBFocus();
673 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
679} 674}
680 675
681void KOViewManager::showMonth( const QDate & date ) 676void KOViewManager::showMonth( const QDate & date )
682{ 677{
683 mMainView->dateNavigator()->blockSignals( true ); 678 mMainView->dateNavigator()->blockSignals( true );
684 mMainView->dateNavigator()->selectDate( date ); 679 mMainView->dateNavigator()->selectDate( date );
685 mMainView->dateNavigator()->blockSignals( false ); 680 mMainView->dateNavigator()->blockSignals( false );
686 showMonthView(); 681 showMonthView();
687} 682}
688void KOViewManager::showMonthView() 683void KOViewManager::showMonthView()
689 { 684 {
690 685
691 createMonthView(); 686 createMonthView();
692 globalFlagBlockAgenda = 1; 687 globalFlagBlockAgenda = 1;
693 //mFlagShowNextxDays = false; 688 //mFlagShowNextxDays = false;
694 bool full = true; 689 bool full = true;
695 if ( mCurrentView == mMonthView) 690 if ( mCurrentView == mMonthView)
696 full = mMainView->leftFrame()->isVisible(); 691 full = mMainView->leftFrame()->isVisible();
697 // if(mMonthView == mCurrentView) return; 692 // if(mMonthView == mCurrentView) return;
698 if ( KOPrefs::instance()->mMonthViewWeek ) { 693 if ( KOPrefs::instance()->mMonthViewWeek ) {
699 mMonthView->switchView(); 694 mMonthView->switchView();
700 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 695 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
701 full = false; 696 full = false;
702 else 697 else
703 full = true; 698 full = true;
704 } 699 }
705 mMainView->dateNavigator()->selectMonth(); 700 mMainView->dateNavigator()->selectMonth();
706 701
707 showView(mMonthView, full ); 702 showView(mMonthView, full );
708 mMonthView->setKeyBFocus(); 703 mMonthView->setKeyBFocus();
704 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
709 705
710} 706}
711 707
712void KOViewManager::showTodoView() 708void KOViewManager::showTodoView()
713{ 709{
714 //mFlagShowNextxDays = false; 710 //mFlagShowNextxDays = false;
715 if ( !mTodoView ) { 711 if ( !mTodoView ) {
716 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 712 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
717 "KOViewManager::TodoView" ); 713 "KOViewManager::TodoView" );
718 714
719 addView( mTodoView ); 715 addView( mTodoView );
720 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 716 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
721 717
722 // SIGNALS/SLOTS FOR TODO VIEW 718 // SIGNALS/SLOTS FOR TODO VIEW
723 connect( mTodoView, SIGNAL( newTodoSignal() ), 719 connect( mTodoView, SIGNAL( newTodoSignal() ),
724 mMainView, SLOT( newTodo() ) ); 720 mMainView, SLOT( newTodo() ) );
725 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 721 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
726 mMainView, SLOT( newSubTodo( Todo *) ) ); 722 mMainView, SLOT( newSubTodo( Todo *) ) );
727 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 723 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
728 mMainView, SLOT( showTodo( Todo * ) ) ); 724 mMainView, SLOT( showTodo( Todo * ) ) );
729 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 725 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
730 mMainView, SLOT( editTodo( Todo * ) ) ); 726 mMainView, SLOT( editTodo( Todo * ) ) );
731 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 727 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
732 mMainView, SLOT( deleteTodo( Todo * ) ) ); 728 mMainView, SLOT( deleteTodo( Todo * ) ) );
733 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 729 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
734 mMainView, SLOT( purgeCompleted() ) ); 730 mMainView, SLOT( purgeCompleted() ) );
735 731
736 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 732 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
737 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 733 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
738 734
739 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 735 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
740 SLOT( updateConfig() ) ); 736 SLOT( updateConfig() ) );
741 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 737 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
742 SLOT( updateTodo( Todo *, int ) ) ); 738 SLOT( updateTodo( Todo *, int ) ) );
743 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 739 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
744 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 740 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
745 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 741 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
746 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 742 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
747 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 743 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
748 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 744 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
749 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 745 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
750 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 746 mMainView, SLOT ( todo_unsub( Todo * ) ) );
751 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 747 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
752 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 748 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
753 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 749 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
754 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 750 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
755 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 751 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
756 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 752 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
757 KConfig *config = KOGlobals::config(); 753 KConfig *config = KOGlobals::config();
758 mTodoView->restoreLayout(config,"Todo View"); 754 mTodoView->restoreLayout(config,"Todo View");
759 mTodoView->setNavigator( mMainView->dateNavigator() ); 755 mTodoView->setNavigator( mMainView->dateNavigator() );
760 } 756 }
761 757
762 globalFlagBlockAgenda = 1; 758 globalFlagBlockAgenda = 1;
763 showView( mTodoView, true ); 759 showView( mTodoView, true );
760 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
764 761
765} 762}
766 763
767void KOViewManager::showJournalView() 764void KOViewManager::showJournalView()
768{ 765{
769 //mFlagShowNextxDays = false; 766 //mFlagShowNextxDays = false;
770 if (!mJournalView) { 767 if (!mJournalView) {
771 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 768 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
772 "KOViewManager::JournalView"); 769 "KOViewManager::JournalView");
773 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 770 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
774 SLOT( updateConfig() ) ); 771 SLOT( updateConfig() ) );
775 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 772 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
776 addView(mJournalView); 773 addView(mJournalView);
777 } 774 }
778 775
779 showView(mJournalView); 776 showView(mJournalView);
780 mMainView->dateNavigator()->selectDates( 1 ); 777 mMainView->dateNavigator()->selectDates( 1 );
778 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
781} 779}
782 780
783void KOViewManager::showTimeSpanView() 781void KOViewManager::showTimeSpanView()
784{ 782{
785 //mFlagShowNextxDays = false; 783 //mFlagShowNextxDays = false;
786 if (!mTimeSpanView) { 784 if (!mTimeSpanView) {
787 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 785 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
788 "KOViewManager::TimeSpanView"); 786 "KOViewManager::TimeSpanView");
789 addView(mTimeSpanView); 787 addView(mTimeSpanView);
790 788
791 mTimeSpanView->readSettings(); 789 mTimeSpanView->readSettings();
792 } 790 }
793 791
794 showView(mTimeSpanView); 792 showView(mTimeSpanView);
795} 793}
796 794
797Incidence *KOViewManager::currentSelection() 795Incidence *KOViewManager::currentSelection()
798{ 796{
799 if (!mCurrentView) return 0; 797 if (!mCurrentView) return 0;
800 if ( mCurrentView == mListView ) { 798 if ( mCurrentView == mListView ) {
801 if ( mListView->currentItem() ) 799 if ( mListView->currentItem() )
802 return mListView->currentItem(); 800 return mListView->currentItem();
803 } 801 }
804 return mCurrentView->selectedIncidences().first(); 802 return mCurrentView->selectedIncidences().first();
805} 803}
806 804
807QDate KOViewManager::currentSelectionDate() 805QDate KOViewManager::currentSelectionDate()
808{ 806{
809 QDate qd; 807 QDate qd;
810 if (mCurrentView) { 808 if (mCurrentView) {
811 DateList qvl = mCurrentView->selectedDates(); 809 DateList qvl = mCurrentView->selectedDates();
812 if (!qvl.isEmpty()) qd = qvl.first(); 810 if (!qvl.isEmpty()) qd = qvl.first();
813 } 811 }
814 return qd; 812 return qd;
815} 813}
816 814
817void KOViewManager::addView(KOrg::BaseView *view) 815void KOViewManager::addView(KOrg::BaseView *view)
818{ 816{
819#if QT_VERSION >= 0x030000 817#if QT_VERSION >= 0x030000
820 mMainView->viewStack()->addWidget( view ); 818 mMainView->viewStack()->addWidget( view );
821#else 819#else
822 mMainView->viewStack()->addWidget( view, 1 ); 820 mMainView->viewStack()->addWidget( view, 1 );
823#endif 821#endif
824} 822}
825 823
826void KOViewManager::setDocumentId( const QString &id ) 824void KOViewManager::setDocumentId( const QString &id )
827{ 825{
828 if (mTodoView) mTodoView->setDocumentId( id ); 826 if (mTodoView) mTodoView->setDocumentId( id );
829} 827}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d98915b..357154e 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2195 +1,2196 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "simplealarmclient.h" 63#include "simplealarmclient.h"
64#include "externalapphandler.h" 64#include "externalapphandler.h"
65 65
66using namespace KCal; 66using namespace KCal;
67#ifndef _WIN32_ 67#ifndef _WIN32_
68#include <unistd.h> 68#include <unistd.h>
69#else 69#else
70#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 71#include "koimportoldialog.h"
72#endif 72#endif
73#endif 73#endif
74#include "mainwindow.h" 74#include "mainwindow.h"
75 75
76 76
77class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
78{ 78{
79 public: 79 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
82 { 82 {
83 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
87 QLabel *lab; 87 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 90 QHBox* temphb;
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 p->mCurrentDisplayedView = 0;
148 if ( p->mHourSize > 22 ) 149 if ( p->mHourSize > 22 )
149 p->mHourSize = 22; 150 p->mHourSize = 22;
150 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
151 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
152 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
153 tbd = Bottom; 154 tbd = Bottom;
154 else 155 else
155 tbd = Top; 156 tbd = Top;
156 } 157 }
157 else { 158 else {
158 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
159 tbd = Right; 160 tbd = Right;
160 else 161 else
161 tbd = Left; 162 tbd = Left;
162 } 163 }
163 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
164 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
165 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
166 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
167 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
168 169
169#ifdef DESKTOP_VERSION 170#ifdef DESKTOP_VERSION
170 if ( KOPrefs::instance()->mShowIconFilter ) 171 if ( KOPrefs::instance()->mShowIconFilter )
171#else 172#else
172 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
173#endif 174#endif
174 175
175{ 176{
176 if ( p->mToolBarHorF ) { 177 if ( p->mToolBarHorF ) {
177 if ( p->mToolBarUpF ) 178 if ( p->mToolBarUpF )
178 tbd = Bottom; 179 tbd = Bottom;
179 else 180 else
180 tbd = Top; 181 tbd = Top;
181 } 182 }
182 else { 183 else {
183 if ( p->mToolBarUpF ) 184 if ( p->mToolBarUpF )
184 tbd = Right; 185 tbd = Right;
185 else 186 else
186 tbd = Left; 187 tbd = Left;
187 } 188 }
188 filterToolBar = new QPEToolBar ( this ); 189 filterToolBar = new QPEToolBar ( this );
189 filterMenubar = new QPEMenuBar( filterToolBar ); 190 filterMenubar = new QPEMenuBar( filterToolBar );
190 QFontMetrics fm ( filterMenubar->font() ); 191 QFontMetrics fm ( filterMenubar->font() );
191 192
192 filterPopupMenu = new QPopupMenu( this ); 193 filterPopupMenu = new QPopupMenu( this );
193 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
194 QString addTest = "Ax"; 195 QString addTest = "Ax";
195#ifdef DESKTOP_VERSION 196#ifdef DESKTOP_VERSION
196 addTest = "AAAx"; 197 addTest = "AAAx";
197#endif 198#endif
198 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) ); 199 filterMenubar->setFixedWidth( fm.width( i18n("No Filter")+addTest ) );
199 addToolBar (filterToolBar , tbd ); 200 addToolBar (filterToolBar , tbd );
200 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 201 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
201 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 202 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
202 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 203 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
203 filterToolBar->hide(); 204 filterToolBar->hide();
204 } else { 205 } else {
205 filterToolBar = 0; 206 filterToolBar = 0;
206 filterMenubar = 0; 207 filterMenubar = 0;
207 filterPopupMenu = 0; 208 filterPopupMenu = 0;
208 } 209 }
209 if ( p->mShowIconOnetoolbar ) { 210 if ( p->mShowIconOnetoolbar ) {
210 viewToolBar = iconToolBar ; 211 viewToolBar = iconToolBar ;
211 navigatorToolBar = iconToolBar ; 212 navigatorToolBar = iconToolBar ;
212 } else { 213 } else {
213#ifndef DESKTOP_VERSION 214#ifndef DESKTOP_VERSION
214 setToolBarsMovable( false ); 215 setToolBarsMovable( false );
215#endif 216#endif
216 if ( p->mToolBarHorV ) { 217 if ( p->mToolBarHorV ) {
217 if ( p->mToolBarUpV ) 218 if ( p->mToolBarUpV )
218 tbd = Bottom; 219 tbd = Bottom;
219 else 220 else
220 tbd = Top; 221 tbd = Top;
221 } 222 }
222 else { 223 else {
223 if ( p->mToolBarUpV ) 224 if ( p->mToolBarUpV )
224 tbd = Right; 225 tbd = Right;
225 else 226 else
226 tbd = Left; 227 tbd = Left;
227 } 228 }
228 viewToolBar = new QPEToolBar( this ); 229 viewToolBar = new QPEToolBar( this );
229 addToolBar (viewToolBar , tbd ); 230 addToolBar (viewToolBar , tbd );
230 if ( p->mToolBarHorN ) { 231 if ( p->mToolBarHorN ) {
231 if ( p->mToolBarUpN ) 232 if ( p->mToolBarUpN )
232 tbd = Bottom; 233 tbd = Bottom;
233 else 234 else
234 tbd = Top; 235 tbd = Top;
235 } 236 }
236 else { 237 else {
237 if ( p->mToolBarUpN ) 238 if ( p->mToolBarUpN )
238 tbd = Right; 239 tbd = Right;
239 else 240 else
240 tbd = Left; 241 tbd = Left;
241 } 242 }
242 navigatorToolBar = new QPEToolBar( this ); 243 navigatorToolBar = new QPEToolBar( this );
243 addToolBar (navigatorToolBar , tbd ); 244 addToolBar (navigatorToolBar , tbd );
244 } 245 }
245 246
246 247
247 248
248 mCalendarModifiedFlag = false; 249 mCalendarModifiedFlag = false;
249 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 250 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
250 splash->setAlignment ( AlignCenter ); 251 splash->setAlignment ( AlignCenter );
251 setCentralWidget( splash ); 252 setCentralWidget( splash );
252#ifndef DESKTOP_VERSION 253#ifndef DESKTOP_VERSION
253 showMaximized(); 254 showMaximized();
254#endif 255#endif
255 256
256 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 257 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
257 setDefaultPreferences(); 258 setDefaultPreferences();
258 mCalendar = new CalendarLocal(); 259 mCalendar = new CalendarLocal();
259 mView = new CalendarView( mCalendar, this,"mCalendar " ); 260 mView = new CalendarView( mCalendar, this,"mCalendar " );
260 mView->hide(); 261 mView->hide();
261 //mView->resize(splash->size() ); 262 //mView->resize(splash->size() );
262 initActions(); 263 initActions();
263 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 264 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
264 mSyncManager->setBlockSave(false); 265 mSyncManager->setBlockSave(false);
265 mView->setSyncManager(mSyncManager); 266 mView->setSyncManager(mSyncManager);
266#ifndef DESKTOP_VERSION 267#ifndef DESKTOP_VERSION
267 iconToolBar->show(); 268 iconToolBar->show();
268 qApp->processEvents(); 269 qApp->processEvents();
269#endif 270#endif
270 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 271 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
271 int vh = height() ; 272 int vh = height() ;
272 int vw = width(); 273 int vw = width();
273 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 274 //qDebug("Toolbar hei %d ",iconToolBar->height() );
274 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 275 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
275 vh -= iconToolBar->height(); 276 vh -= iconToolBar->height();
276 } else { 277 } else {
277 vw -= iconToolBar->height(); 278 vw -= iconToolBar->height();
278 } 279 }
279 //mView->setMaximumSize( splash->size() ); 280 //mView->setMaximumSize( splash->size() );
280 //mView->resize( splash->size() ); 281 //mView->resize( splash->size() );
281 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 282 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
282 mView->readSettings(); 283 mView->readSettings();
283 bool newFile = false; 284 bool newFile = false;
284 if( !QFile::exists( defaultFileName() ) ) { 285 if( !QFile::exists( defaultFileName() ) ) {
285 QFileInfo finfo ( defaultFileName() ); 286 QFileInfo finfo ( defaultFileName() );
286 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 287 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
287 qDebug("oldfile %s ", oldFile.latin1()); 288 qDebug("oldfile %s ", oldFile.latin1());
288 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 289 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
289 finfo.setFile( oldFile ); 290 finfo.setFile( oldFile );
290 if (finfo.exists() ) { 291 if (finfo.exists() ) {
291 KMessageBox::information( this, message); 292 KMessageBox::information( this, message);
292 mView->openCalendar( oldFile ); 293 mView->openCalendar( oldFile );
293 qApp->processEvents(); 294 qApp->processEvents();
294 } else { 295 } else {
295 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 296 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
296 finfo.setFile( oldFile ); 297 finfo.setFile( oldFile );
297 if (finfo.exists() ) { 298 if (finfo.exists() ) {
298 KMessageBox::information( this, message); 299 KMessageBox::information( this, message);
299 mView->openCalendar( oldFile ); 300 mView->openCalendar( oldFile );
300 qApp->processEvents(); 301 qApp->processEvents();
301 } 302 }
302 } 303 }
303 mView->saveCalendar( defaultFileName() ); 304 mView->saveCalendar( defaultFileName() );
304 newFile = true; 305 newFile = true;
305 } 306 }
306 307
307 QTime neededSaveTime = QDateTime::currentDateTime().time(); 308 QTime neededSaveTime = QDateTime::currentDateTime().time();
308 mView->openCalendar( defaultFileName() ); 309 mView->openCalendar( defaultFileName() );
309 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 310 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
310 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 311 qDebug("KO: Calendar loading time: %d ms",msNeeded );
311 312
312 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 313 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
313 KOPrefs::instance()->setAllDefaults(); 314 KOPrefs::instance()->setAllDefaults();
314 int count = mView->addCategories(); 315 int count = mView->addCategories();
315 } 316 }
316 processIncidenceSelection( 0 ); 317 processIncidenceSelection( 0 );
317 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 318 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
318 SLOT( processIncidenceSelection( Incidence * ) ) ); 319 SLOT( processIncidenceSelection( Incidence * ) ) );
319 connect( mView, SIGNAL( modifiedChanged( bool ) ), 320 connect( mView, SIGNAL( modifiedChanged( bool ) ),
320 SLOT( slotModifiedChanged( bool ) ) ); 321 SLOT( slotModifiedChanged( bool ) ) );
321 322
322 323
323 connect( mView, SIGNAL( tempDisableBR(bool) ), 324 connect( mView, SIGNAL( tempDisableBR(bool) ),
324 SLOT( disableBR(bool) ) ); 325 SLOT( disableBR(bool) ) );
325 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 326 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
326 mView->setModified( false ); 327 mView->setModified( false );
327 mBlockAtStartup = false; 328 mBlockAtStartup = false;
328 mView->setModified( false ); 329 mView->setModified( false );
329 setCentralWidget( mView ); 330 setCentralWidget( mView );
330 globalFlagBlockStartup = 0; 331 globalFlagBlockStartup = 0;
331 mView->show(); 332 mView->show();
332 delete splash; 333 delete splash;
333 if ( newFile ) 334 if ( newFile )
334 mView->updateConfig(); 335 mView->updateConfig();
335 // qApp->processEvents(); 336 // qApp->processEvents();
336 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 337 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
337 //fillSyncMenu(); 338 //fillSyncMenu();
338 339
339 340
340 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 341 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
341 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 342 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
342 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 343 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
343 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 344 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
344 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 345 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
345 mSyncManager->setDefaultFileName( sentSyncFile()); 346 mSyncManager->setDefaultFileName( sentSyncFile());
346 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 347 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
347 mSyncManager->fillSyncMenu(); 348 mSyncManager->fillSyncMenu();
348 349
349 350
350 351
351 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 352 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
352 if ( showWarning ) { 353 if ( showWarning ) {
353 KMessageBox::information( this, 354 KMessageBox::information( this,
354 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 355 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
355 qApp->processEvents(); 356 qApp->processEvents();
356 mView->dialogManager()->showSyncOptions(); 357 mView->dialogManager()->showSyncOptions();
357 } 358 }
358 359
359 //US listen for result adressed from Ka/Pi 360 //US listen for result adressed from Ka/Pi
360#ifndef DESKTOP_VERSION 361#ifndef DESKTOP_VERSION
361 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 362 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
362#endif 363#endif
363#ifndef DESKTOP_VERSION 364#ifndef DESKTOP_VERSION
364 infrared = 0; 365 infrared = 0;
365#endif 366#endif
366 updateFilterToolbar(); 367 updateFilterToolbar();
367 updateWeek( mView->startDate() ); 368 updateWeek( mView->startDate() );
368 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
369 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 370 SLOT( updateWeekNum( const KCal::DateList & ) ) );
370 mBRdisabled = false; 371 mBRdisabled = false;
371 //toggleBeamReceive(); 372 //toggleBeamReceive();
372} 373}
373MainWindow::~MainWindow() 374MainWindow::~MainWindow()
374{ 375{
375 //qDebug("MainWindow::~MainWindow() "); 376 //qDebug("MainWindow::~MainWindow() ");
376 //save toolbar location 377 //save toolbar location
377 delete mCalendar; 378 delete mCalendar;
378 delete mSyncManager; 379 delete mSyncManager;
379#ifndef DESKTOP_VERSION 380#ifndef DESKTOP_VERSION
380 if ( infrared ) 381 if ( infrared )
381 delete infrared; 382 delete infrared;
382#endif 383#endif
383 384
384 385
385} 386}
386 387
387void MainWindow::disableBR(bool b) 388void MainWindow::disableBR(bool b)
388{ 389{
389#ifndef DESKTOP_VERSION 390#ifndef DESKTOP_VERSION
390 if ( b ) { 391 if ( b ) {
391 if ( infrared ) { 392 if ( infrared ) {
392 toggleBeamReceive(); 393 toggleBeamReceive();
393 mBRdisabled = true; 394 mBRdisabled = true;
394 } 395 }
395 mBRdisabled = true; 396 mBRdisabled = true;
396 } else { 397 } else {
397 if ( mBRdisabled ) { 398 if ( mBRdisabled ) {
398 mBRdisabled = false; 399 mBRdisabled = false;
399 //makes no sense,because other cal ap is probably running 400 //makes no sense,because other cal ap is probably running
400 // toggleBeamReceive(); 401 // toggleBeamReceive();
401 } 402 }
402 } 403 }
403#endif 404#endif
404 405
405} 406}
406bool MainWindow::beamReceiveEnabled() 407bool MainWindow::beamReceiveEnabled()
407{ 408{
408#ifndef DESKTOP_VERSION 409#ifndef DESKTOP_VERSION
409 return ( infrared != 0 ); 410 return ( infrared != 0 );
410#endif 411#endif
411 return false; 412 return false;
412} 413}
413 414
414void MainWindow::toggleBeamReceive() 415void MainWindow::toggleBeamReceive()
415{ 416{
416 if ( mBRdisabled ) 417 if ( mBRdisabled )
417 return; 418 return;
418#ifndef DESKTOP_VERSION 419#ifndef DESKTOP_VERSION
419 if ( infrared ) { 420 if ( infrared ) {
420 qDebug("disable BeamReceive "); 421 qDebug("disable BeamReceive ");
421 delete infrared; 422 delete infrared;
422 infrared = 0; 423 infrared = 0;
423 brAction->setOn(false); 424 brAction->setOn(false);
424 return; 425 return;
425 } 426 }
426 qDebug("enable BeamReceive "); 427 qDebug("enable BeamReceive ");
427 brAction->setOn(true); 428 brAction->setOn(true);
428 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 429 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
429 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 430 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
430#endif 431#endif
431} 432}
432void MainWindow::showMaximized () 433void MainWindow::showMaximized ()
433{ 434{
434#ifndef DESKTOP_VERSION 435#ifndef DESKTOP_VERSION
435 if ( ! globalFlagBlockStartup ) 436 if ( ! globalFlagBlockStartup )
436 if ( mClosed ) 437 if ( mClosed )
437 mView->goToday(); 438 mView->goToday();
438#endif 439#endif
439 QWidget::showMaximized () ; 440 QWidget::showMaximized () ;
440 mClosed = false; 441 mClosed = false;
441} 442}
442void MainWindow::closeEvent( QCloseEvent* ce ) 443void MainWindow::closeEvent( QCloseEvent* ce )
443{ 444{
444 445
445 446
446 447
447 if ( ! KOPrefs::instance()->mAskForQuit ) { 448 if ( ! KOPrefs::instance()->mAskForQuit ) {
448 saveOnClose(); 449 saveOnClose();
449 mClosed = true; 450 mClosed = true;
450 ce->accept(); 451 ce->accept();
451 return; 452 return;
452 453
453 } 454 }
454 455
455 switch( QMessageBox::information( this, "KO/Pi", 456 switch( QMessageBox::information( this, "KO/Pi",
456 i18n("Do you really want\nto close KO/Pi?"), 457 i18n("Do you really want\nto close KO/Pi?"),
457 i18n("Close"), i18n("No"), 458 i18n("Close"), i18n("No"),
458 0, 0 ) ) { 459 0, 0 ) ) {
459 case 0: 460 case 0:
460 saveOnClose(); 461 saveOnClose();
461 mClosed = true; 462 mClosed = true;
462 ce->accept(); 463 ce->accept();
463 break; 464 break;
464 case 1: 465 case 1:
465 ce->ignore(); 466 ce->ignore();
466 break; 467 break;
467 case 2: 468 case 2:
468 469
469 default: 470 default:
470 break; 471 break;
471 } 472 }
472 473
473 474
474} 475}
475 476
476void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 477void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
477{ 478{
478 QDataStream stream( data, IO_ReadOnly ); 479 QDataStream stream( data, IO_ReadOnly );
479 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 480 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
480 //QString datamess; 481 //QString datamess;
481 //qDebug("message "); 482 //qDebug("message ");
482 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 483 qDebug("KO: QCOP message received: %s ", cmsg.data() );
483 484
484 if ( cmsg == "setDocument(QString)" ) { 485 if ( cmsg == "setDocument(QString)" ) {
485 QDataStream stream( data, IO_ReadOnly ); 486 QDataStream stream( data, IO_ReadOnly );
486 QString fileName; 487 QString fileName;
487 stream >> fileName; 488 stream >> fileName;
488 //qDebug("filename %s ", fileName.latin1()); 489 //qDebug("filename %s ", fileName.latin1());
489 showMaximized(); 490 showMaximized();
490 raise(); 491 raise();
491 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 492 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
492 mSyncManager->slotSyncMenu( 1002 ); 493 mSyncManager->slotSyncMenu( 1002 );
493 return; 494 return;
494 } 495 }
495 496
496 if ( cmsg == "-writeFile" ) { 497 if ( cmsg == "-writeFile" ) {
497 // I made from the "-writeFile" an "-writeAlarm" 498 // I made from the "-writeFile" an "-writeAlarm"
498 mView->viewManager()->showWhatsNextView(); 499 mView->viewManager()->showWhatsNextView();
499 mCalendar->checkAlarmForIncidence( 0, true); 500 mCalendar->checkAlarmForIncidence( 0, true);
500 showMaximized(); 501 showMaximized();
501 raise(); 502 raise();
502 return; 503 return;
503 504
504 } 505 }
505 if ( cmsg == "-writeFileSilent" ) { 506 if ( cmsg == "-writeFileSilent" ) {
506 // I made from the "-writeFile" an "-writeAlarm" 507 // I made from the "-writeFile" an "-writeAlarm"
507 // mView->viewManager()->showWhatsNextView(); 508 // mView->viewManager()->showWhatsNextView();
508 mCalendar->checkAlarmForIncidence( 0, true); 509 mCalendar->checkAlarmForIncidence( 0, true);
509 //showMaximized(); 510 //showMaximized();
510 //raise(); 511 //raise();
511 hide(); 512 hide();
512 return; 513 return;
513 } 514 }
514 if ( cmsg == "-newCountdown" ) { 515 if ( cmsg == "-newCountdown" ) {
515 qDebug("newCountdown "); 516 qDebug("newCountdown ");
516 517
517 } 518 }
518 QString msg ; 519 QString msg ;
519 QString allmsg = cmsg; 520 QString allmsg = cmsg;
520 while ( allmsg.length() > 0 ) { 521 while ( allmsg.length() > 0 ) {
521 int nextC = allmsg.find( "-", 1 ); 522 int nextC = allmsg.find( "-", 1 );
522 if ( nextC == -1 ) { 523 if ( nextC == -1 ) {
523 msg = allmsg; 524 msg = allmsg;
524 allmsg = ""; 525 allmsg = "";
525 } else{ 526 } else{
526 msg = allmsg.left( nextC ); 527 msg = allmsg.left( nextC );
527 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 528 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
528 } 529 }
529 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 530 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
530 if ( msg == "-newEvent" ) { 531 if ( msg == "-newEvent" ) {
531 mView->newEvent(); 532 mView->newEvent();
532 } 533 }
533 if ( msg == "-newTodo" ) { 534 if ( msg == "-newTodo" ) {
534 mView->newTodo(); 535 mView->newTodo();
535 536
536 } 537 }
537 if ( msg == "-showWN" ) { 538 if ( msg == "-showWN" ) {
538 mView->viewManager()->showWhatsNextView(); 539 mView->viewManager()->showWhatsNextView();
539 } 540 }
540 if ( msg == "-showTodo" ) { 541 if ( msg == "-showTodo" ) {
541 mView->viewManager()->showTodoView(); 542 mView->viewManager()->showTodoView();
542 } 543 }
543 if ( msg == "-showList" ) { 544 if ( msg == "-showList" ) {
544 mView->viewManager()->showListView(); 545 mView->viewManager()->showListView();
545 } 546 }
546 else if ( msg == "-showDay" ) { 547 else if ( msg == "-showDay" ) {
547 mView->viewManager()->showDayView(); 548 mView->viewManager()->showDayView();
548 } 549 }
549 else if ( msg == "-showWWeek" ) { 550 else if ( msg == "-showWWeek" ) {
550 mView->viewManager()->showWorkWeekView(); 551 mView->viewManager()->showWorkWeekView();
551 } 552 }
552 else if ( msg == "-ringSync" ) { 553 else if ( msg == "-ringSync" ) {
553 mSyncManager->multiSync( false ); 554 mSyncManager->multiSync( false );
554 } 555 }
555 else if ( msg == "-showWeek" ) { 556 else if ( msg == "-showWeek" ) {
556 mView->viewManager()->showWeekView(); 557 mView->viewManager()->showWeekView();
557 } 558 }
558 else if ( msg == "-showTodo" ) { 559 else if ( msg == "-showTodo" ) {
559 mView->viewManager()->showTodoView(); 560 mView->viewManager()->showTodoView();
560 } 561 }
561 else if ( msg == "-showJournal" ) { 562 else if ( msg == "-showJournal" ) {
562 mView->dateNavigator()->selectDates( 1 ); 563 mView->dateNavigator()->selectDates( 1 );
563 mView->dateNavigator()->selectToday(); 564 mView->dateNavigator()->selectToday();
564 mView->viewManager()->showJournalView(); 565 mView->viewManager()->showJournalView();
565 } 566 }
566 else if ( msg == "-showKO" ) { 567 else if ( msg == "-showKO" ) {
567 mView->viewManager()->showNextXView(); 568 mView->viewManager()->showNextXView();
568 } 569 }
569 else if ( msg == "-showWNext" ) { 570 else if ( msg == "-showWNext" ) {
570 mView->viewManager()->showWhatsNextView(); 571 mView->viewManager()->showWhatsNextView();
571 } 572 }
572 else if ( msg == "nextView()" ) { 573 else if ( msg == "nextView()" ) {
573 mView->viewManager()->showNextView(); 574 mView->viewManager()->showNextView();
574 } 575 }
575 else if ( msg == "-showNextXView" ) { 576 else if ( msg == "-showNextXView" ) {
576 mView->viewManager()->showNextXView(); 577 mView->viewManager()->showNextXView();
577 } 578 }
578 579
579 580
580 } 581 }
581 582
582 showMaximized(); 583 showMaximized();
583 raise(); 584 raise();
584} 585}
585 586
586QPixmap MainWindow::loadPixmap( QString name ) 587QPixmap MainWindow::loadPixmap( QString name )
587{ 588{
588 return SmallIcon( name ); 589 return SmallIcon( name );
589 590
590} 591}
591void MainWindow::initActions() 592void MainWindow::initActions()
592{ 593{
593 //KOPrefs::instance()->mShowFullMenu 594 //KOPrefs::instance()->mShowFullMenu
594 iconToolBar->clear(); 595 iconToolBar->clear();
595 KOPrefs *p = KOPrefs::instance(); 596 KOPrefs *p = KOPrefs::instance();
596 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 597 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
597 598
598 QPopupMenu *viewMenu = new QPopupMenu( this ); 599 QPopupMenu *viewMenu = new QPopupMenu( this );
599 QPopupMenu *actionMenu = new QPopupMenu( this ); 600 QPopupMenu *actionMenu = new QPopupMenu( this );
600 QPopupMenu *importMenu = new QPopupMenu( this ); 601 QPopupMenu *importMenu = new QPopupMenu( this );
601 QPopupMenu *importMenu_X = new QPopupMenu( this ); 602 QPopupMenu *importMenu_X = new QPopupMenu( this );
602 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 603 QPopupMenu *exportMenu_X = new QPopupMenu( this );
603 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 604 QPopupMenu *beamMenu_X = new QPopupMenu( this );
604 selectFilterMenu = new QPopupMenu( this ); 605 selectFilterMenu = new QPopupMenu( this );
605 selectFilterMenu->setCheckable( true ); 606 selectFilterMenu->setCheckable( true );
606 syncMenu = new QPopupMenu( this ); 607 syncMenu = new QPopupMenu( this );
607 configureAgendaMenu = new QPopupMenu( this ); 608 configureAgendaMenu = new QPopupMenu( this );
608 configureToolBarMenu = new QPopupMenu( this ); 609 configureToolBarMenu = new QPopupMenu( this );
609 QPopupMenu *helpMenu = new QPopupMenu( this ); 610 QPopupMenu *helpMenu = new QPopupMenu( this );
610 QIconSet icon; 611 QIconSet icon;
611 int pixWid = 22, pixHei = 22; 612 int pixWid = 22, pixHei = 22;
612 QString pathString = ""; 613 QString pathString = "";
613 if ( !p->mToolBarMiniIcons ) { 614 if ( !p->mToolBarMiniIcons ) {
614 if ( QApplication::desktop()->width() < 480 ) { 615 if ( QApplication::desktop()->width() < 480 ) {
615 pathString += "icons16/"; 616 pathString += "icons16/";
616 pixWid = 18; pixHei = 16; 617 pixWid = 18; pixHei = 16;
617 } 618 }
618 } else { 619 } else {
619 pathString += "iconsmini/"; 620 pathString += "iconsmini/";
620 pixWid = 18; pixHei = 16; 621 pixWid = 18; pixHei = 16;
621 } 622 }
622 if ( KOPrefs::instance()->mShowFullMenu ) { 623 if ( KOPrefs::instance()->mShowFullMenu ) {
623 QMenuBar *menuBar1; 624 QMenuBar *menuBar1;
624 menuBar1 = menuBar(); 625 menuBar1 = menuBar();
625 menuBar1->insertItem( i18n("File"), importMenu ); 626 menuBar1->insertItem( i18n("File"), importMenu );
626 menuBar1->insertItem( i18n("View"), viewMenu ); 627 menuBar1->insertItem( i18n("View"), viewMenu );
627 menuBar1->insertItem( i18n("Actions"), actionMenu ); 628 menuBar1->insertItem( i18n("Actions"), actionMenu );
628#ifdef DESKTOP_VERSION 629#ifdef DESKTOP_VERSION
629 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 630 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
630 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 631 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
631#else 632#else
632 menuBar1->insertItem( i18n("Sync"), syncMenu ); 633 menuBar1->insertItem( i18n("Sync"), syncMenu );
633 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 634 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
634#endif 635#endif
635 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 636 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
636 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 637 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
637 menuBar1->insertItem( i18n("Help"), helpMenu ); 638 menuBar1->insertItem( i18n("Help"), helpMenu );
638 } else { 639 } else {
639 QPEMenuBar *menuBar1; 640 QPEMenuBar *menuBar1;
640 menuBar1 = new QPEMenuBar( iconToolBar ); 641 menuBar1 = new QPEMenuBar( iconToolBar );
641 QPopupMenu *menuBar = new QPopupMenu( this ); 642 QPopupMenu *menuBar = new QPopupMenu( this );
642 icon = loadPixmap( pathString + "z_menu" ); 643 icon = loadPixmap( pathString + "z_menu" );
643 menuBar1->insertItem( icon.pixmap(), menuBar); 644 menuBar1->insertItem( icon.pixmap(), menuBar);
644 //menuBar1->insertItem( i18n("ME"), menuBar); 645 //menuBar1->insertItem( i18n("ME"), menuBar);
645 menuBar->insertItem( i18n("File"), importMenu ); 646 menuBar->insertItem( i18n("File"), importMenu );
646 menuBar->insertItem( i18n("View"), viewMenu ); 647 menuBar->insertItem( i18n("View"), viewMenu );
647 menuBar->insertItem( i18n("Actions"), actionMenu ); 648 menuBar->insertItem( i18n("Actions"), actionMenu );
648 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 649 menuBar->insertItem( i18n("Synchronize"), syncMenu );
649 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 650 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
650 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 651 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
651 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 652 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
652 menuBar->insertItem( i18n("Help"), helpMenu ); 653 menuBar->insertItem( i18n("Help"), helpMenu );
653 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 654 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
654 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 655 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
655 } 656 }
656 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 657 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
657 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 658 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
658 659
659 660
660 mWeekBgColor = iconToolBar->backgroundColor(); 661 mWeekBgColor = iconToolBar->backgroundColor();
661 mWeekPixmap.resize( pixWid , pixHei ); 662 mWeekPixmap.resize( pixWid , pixHei );
662 mWeekPixmap.fill( mWeekBgColor ); 663 mWeekPixmap.fill( mWeekBgColor );
663 icon = mWeekPixmap; 664 icon = mWeekPixmap;
664 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 665 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
665 if ( p-> mShowIconWeekNum ) 666 if ( p-> mShowIconWeekNum )
666 mWeekAction->addTo( iconToolBar ); 667 mWeekAction->addTo( iconToolBar );
667 mWeekFont = font(); 668 mWeekFont = font();
668 669
669 int fontPoint = mWeekFont.pointSize(); 670 int fontPoint = mWeekFont.pointSize();
670 QFontMetrics f( mWeekFont ); 671 QFontMetrics f( mWeekFont );
671 int fontWid = f.width( "30" ); 672 int fontWid = f.width( "30" );
672 while ( fontWid > pixWid ) { 673 while ( fontWid > pixWid ) {
673 --fontPoint; 674 --fontPoint;
674 mWeekFont.setPointSize( fontPoint ); 675 mWeekFont.setPointSize( fontPoint );
675 QFontMetrics f( mWeekFont ); 676 QFontMetrics f( mWeekFont );
676 fontWid = f.width( "30" ); 677 fontWid = f.width( "30" );
677 //qDebug("dec-- "); 678 //qDebug("dec-- ");
678 } 679 }
679 680
680 connect( mWeekAction, SIGNAL( activated() ), 681 connect( mWeekAction, SIGNAL( activated() ),
681 this, SLOT( weekAction() ) ); 682 this, SLOT( weekAction() ) );
682 683
683 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 684 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
684 if ( p->mShowIconFilterview ) { 685 if ( p->mShowIconFilterview ) {
685 icon = loadPixmap( pathString + "filter" ); 686 icon = loadPixmap( pathString + "filter" );
686 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 687 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
687 connect( actionFilterMenuTB, SIGNAL( activated() ), 688 connect( actionFilterMenuTB, SIGNAL( activated() ),
688 this, SLOT( fillFilterMenuTB() ) ); 689 this, SLOT( fillFilterMenuTB() ) );
689 actionFilterMenuTB->addTo( iconToolBar ); 690 actionFilterMenuTB->addTo( iconToolBar );
690 selectFilterMenuTB = new QPopupMenu( this ); 691 selectFilterMenuTB = new QPopupMenu( this );
691 selectFilterMenuTB->setCheckable( true ); 692 selectFilterMenuTB->setCheckable( true );
692 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 693 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
693 } 694 }
694 695
695 //#endif 696 //#endif
696 // ****************** 697 // ******************
697 QAction *action; 698 QAction *action;
698 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 699 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
699 configureToolBarMenu->setCheckable( true ); 700 configureToolBarMenu->setCheckable( true );
700 701
701 702
702 configureAgendaMenu->setCheckable( true ); 703 configureAgendaMenu->setCheckable( true );
703 int iii ; 704 int iii ;
704 for ( iii = 1;iii<= 10 ;++iii ){ 705 for ( iii = 1;iii<= 10 ;++iii ){
705 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 706 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
706 } 707 }
707 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 708 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
708 709
709 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 710 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
710 this, SLOT( showConfigureAgenda( ) ) ); 711 this, SLOT( showConfigureAgenda( ) ) );
711 712
712 icon = loadPixmap( pathString + "configure" ); 713 icon = loadPixmap( pathString + "configure" );
713 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 714 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
714 action->addTo( actionMenu ); 715 action->addTo( actionMenu );
715 connect( action, SIGNAL( activated() ), 716 connect( action, SIGNAL( activated() ),
716 mView, SLOT( edit_options() ) ); 717 mView, SLOT( edit_options() ) );
717 actionMenu->insertSeparator(); 718 actionMenu->insertSeparator();
718 719
719 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 720 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
720 action->addTo( actionMenu ); 721 action->addTo( actionMenu );
721 connect( action, SIGNAL( activated() ), 722 connect( action, SIGNAL( activated() ),
722 mView, SLOT( undo_delete() ) ); 723 mView, SLOT( undo_delete() ) );
723 actionMenu->insertSeparator(); 724 actionMenu->insertSeparator();
724 725
725 icon = loadPixmap( pathString + "newevent" ); 726 icon = loadPixmap( pathString + "newevent" );
726 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 727 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
727 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 728 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
728 configureToolBarMenu->insertSeparator(); 729 configureToolBarMenu->insertSeparator();
729 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 730 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
730 configureToolBarMenu->insertSeparator(); 731 configureToolBarMenu->insertSeparator();
731 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 732 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
732 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 733 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
733 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 734 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
734 ne_action->addTo( actionMenu ); 735 ne_action->addTo( actionMenu );
735 connect( ne_action, SIGNAL( activated() ), 736 connect( ne_action, SIGNAL( activated() ),
736 mView, SLOT( newEvent() ) ); 737 mView, SLOT( newEvent() ) );
737 icon = loadPixmap( pathString + "newtodo" ); 738 icon = loadPixmap( pathString + "newtodo" );
738 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 739 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
739 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 740 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
740 nt_action->addTo( actionMenu ); 741 nt_action->addTo( actionMenu );
741 connect( nt_action, SIGNAL( activated() ), 742 connect( nt_action, SIGNAL( activated() ),
742 mView, SLOT( newTodo() ) ); 743 mView, SLOT( newTodo() ) );
743 744
744 icon = loadPixmap( pathString + "today" ); 745 icon = loadPixmap( pathString + "today" );
745 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 746 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
746 today_action->addTo( viewMenu ); 747 today_action->addTo( viewMenu );
747 connect( today_action, SIGNAL( activated() ), 748 connect( today_action, SIGNAL( activated() ),
748 mView, SLOT( goToday() ) ); 749 mView, SLOT( goToday() ) );
749 viewMenu->insertSeparator(); 750 viewMenu->insertSeparator();
750 751
751 // *********************** 752 // ***********************
752 if ( KOPrefs::instance()->mVerticalScreen ) { 753 if ( KOPrefs::instance()->mVerticalScreen ) {
753 icon = SmallIcon( "1updownarrow" ); 754 icon = SmallIcon( "1updownarrow" );
754 } else { 755 } else {
755 icon = SmallIcon("1leftrightarrow" ); 756 icon = SmallIcon("1leftrightarrow" );
756 } 757 }
757 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 758 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
758 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 759 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
759 FSaction->addTo( viewMenu ); 760 FSaction->addTo( viewMenu );
760 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 761 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
761 762
762 icon = loadPixmap( pathString + "navi" ); 763 icon = loadPixmap( pathString + "navi" );
763 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 764 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
764 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 765 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
765 action->addTo( viewMenu ); 766 action->addTo( viewMenu );
766 connect( action, SIGNAL( activated() ), 767 connect( action, SIGNAL( activated() ),
767 mView, SLOT( toggleDateNavigatorWidget() ) ); 768 mView, SLOT( toggleDateNavigatorWidget() ) );
768 mToggleNav = action ; 769 mToggleNav = action ;
769 icon = loadPixmap( pathString + "filter" ); 770 icon = loadPixmap( pathString + "filter" );
770 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 771 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
771 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 772 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
772 action->addTo( viewMenu ); 773 action->addTo( viewMenu );
773 connect( action, SIGNAL( activated() ), 774 connect( action, SIGNAL( activated() ),
774 mView, SLOT( toggleFilter() ) ); 775 mView, SLOT( toggleFilter() ) );
775 mToggleFilter = action; 776 mToggleFilter = action;
776 icon = loadPixmap( pathString + "allday" ); 777 icon = loadPixmap( pathString + "allday" );
777 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 778 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
778 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 779 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
779 action->addTo( viewMenu ); 780 action->addTo( viewMenu );
780 connect( action, SIGNAL( activated() ), 781 connect( action, SIGNAL( activated() ),
781 mView, SLOT( toggleAllDaySize() ) ); 782 mView, SLOT( toggleAllDaySize() ) );
782 mToggleAllday = action; 783 mToggleAllday = action;
783 784
784 785
785 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 786 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
786 mToggleNav, SLOT( setEnabled ( bool ) ) ); 787 mToggleNav, SLOT( setEnabled ( bool ) ) );
787 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 788 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
788 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 789 mToggleFilter, SLOT( setEnabled ( bool ) ) );
789 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 790 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
790 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 791 mToggleAllday, SLOT( setEnabled ( bool ) ) );
791 792
792 viewMenu->insertSeparator(); 793 viewMenu->insertSeparator();
793 icon = loadPixmap( pathString + "picker" ); 794 icon = loadPixmap( pathString + "picker" );
794 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 795 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
795 action->addTo( viewMenu ); 796 action->addTo( viewMenu );
796 connect( action, SIGNAL( activated() ), 797 connect( action, SIGNAL( activated() ),
797 mView, SLOT( showDatePicker() ) ); 798 mView, SLOT( showDatePicker() ) );
798 action->addTo( iconToolBar ); 799 action->addTo( iconToolBar );
799 viewMenu->insertSeparator(); 800 viewMenu->insertSeparator();
800 801
801 if ( p-> mShowIconToggleFull ) 802 if ( p-> mShowIconToggleFull )
802 FSaction->addTo( iconToolBar ); 803 FSaction->addTo( iconToolBar );
803 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 804 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
804 805
805 //******************** 806 //********************
806 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 807 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
807 808
808 809
809 icon = loadPixmap( pathString + "whatsnext" ); 810 icon = loadPixmap( pathString + "whatsnext" );
810 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 811 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
811 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 812 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
812 whatsnext_action->addTo( viewMenu ); 813 whatsnext_action->addTo( viewMenu );
813 connect( whatsnext_action, SIGNAL( activated() ), 814 connect( whatsnext_action, SIGNAL( activated() ),
814 mView->viewManager(), SLOT( showWhatsNextView() ) ); 815 mView->viewManager(), SLOT( showWhatsNextView() ) );
815 816
816 icon = loadPixmap( pathString + "xdays" ); 817 icon = loadPixmap( pathString + "xdays" );
817 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 818 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
818 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 819 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
819 xdays_action->addTo( viewMenu ); 820 xdays_action->addTo( viewMenu );
820 connect( xdays_action, SIGNAL( activated() ), 821 connect( xdays_action, SIGNAL( activated() ),
821 mView->viewManager(), SLOT( showNextXView() ) ); 822 mView->viewManager(), SLOT( showNextXView() ) );
822 823
823 824
824 icon = loadPixmap( pathString + "journal" ); 825 icon = loadPixmap( pathString + "journal" );
825 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 826 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
826 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 827 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
827 viewjournal_action->addTo( viewMenu ); 828 viewjournal_action->addTo( viewMenu );
828 connect( viewjournal_action, SIGNAL( activated() ), 829 connect( viewjournal_action, SIGNAL( activated() ),
829 mView->viewManager(), SLOT( showJournalView() ) ); 830 mView->viewManager(), SLOT( showJournalView() ) );
830 831
831 832
832 icon = loadPixmap( pathString + "day" ); 833 icon = loadPixmap( pathString + "day" );
833 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 834 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
834 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 835 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
835 day1_action->addTo( viewMenu ); 836 day1_action->addTo( viewMenu );
836 // action->addTo( toolBar ); 837 // action->addTo( toolBar );
837 connect( day1_action, SIGNAL( activated() ), 838 connect( day1_action, SIGNAL( activated() ),
838 mView->viewManager(), SLOT( showDayView() ) ); 839 mView->viewManager(), SLOT( showDayView() ) );
839 840
840 icon = loadPixmap( pathString + "workweek" ); 841 icon = loadPixmap( pathString + "workweek" );
841 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 842 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
842 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 843 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
843 day5_action->addTo( viewMenu ); 844 day5_action->addTo( viewMenu );
844 connect( day5_action, SIGNAL( activated() ), 845 connect( day5_action, SIGNAL( activated() ),
845 mView->viewManager(), SLOT( showWorkWeekView() ) ); 846 mView->viewManager(), SLOT( showWorkWeekView() ) );
846 847
847 icon = loadPixmap( pathString + "week" ); 848 icon = loadPixmap( pathString + "week" );
848 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 849 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
849 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 850 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
850 day7_action->addTo( viewMenu ); 851 day7_action->addTo( viewMenu );
851 connect( day7_action, SIGNAL( activated() ), 852 connect( day7_action, SIGNAL( activated() ),
852 mView->viewManager(), SLOT( showWeekView() ) ); 853 mView->viewManager(), SLOT( showWeekView() ) );
853 854
854 icon = loadPixmap( pathString + "workweek2" ); 855 icon = loadPixmap( pathString + "workweek2" );
855 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 856 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
856 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 857 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
857 day6_action->addTo( viewMenu ); 858 day6_action->addTo( viewMenu );
858 connect( day6_action, SIGNAL( activated() ), 859 connect( day6_action, SIGNAL( activated() ),
859 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 860 mView->viewManager(), SLOT( showMonthViewWeek() ) );
860 861
861 icon = loadPixmap( pathString + "month" ); 862 icon = loadPixmap( pathString + "month" );
862 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 863 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
863 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 864 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
864 month_action->addTo( viewMenu ); 865 month_action->addTo( viewMenu );
865 connect( month_action, SIGNAL( activated() ), 866 connect( month_action, SIGNAL( activated() ),
866 mView->viewManager(), SLOT( showMonthView() ) ); 867 mView->viewManager(), SLOT( showMonthView() ) );
867 868
868 icon = loadPixmap( pathString + "list" ); 869 icon = loadPixmap( pathString + "list" );
869 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 870 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
870 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 871 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
871 showlist_action->addTo( viewMenu ); 872 showlist_action->addTo( viewMenu );
872 connect( showlist_action, SIGNAL( activated() ), 873 connect( showlist_action, SIGNAL( activated() ),
873 mView->viewManager(), SLOT( showListView() ) ); 874 mView->viewManager(), SLOT( showListView() ) );
874 875
875 icon = loadPixmap( pathString + "todo" ); 876 icon = loadPixmap( pathString + "todo" );
876 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 877 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
877 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 878 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
878 todoview_action->addTo( viewMenu ); 879 todoview_action->addTo( viewMenu );
879 connect( todoview_action, SIGNAL( activated() ), 880 connect( todoview_action, SIGNAL( activated() ),
880 mView->viewManager(), SLOT( showTodoView() ) ); 881 mView->viewManager(), SLOT( showTodoView() ) );
881 882
882 883
883 884
884#if 0 885#if 0
885 action = new QAction( "view_timespan", "Time Span", 0, this ); 886 action = new QAction( "view_timespan", "Time Span", 0, this );
886 action->addTo( viewMenu ); 887 action->addTo( viewMenu );
887 connect( action, SIGNAL( activated() ), 888 connect( action, SIGNAL( activated() ),
888 mView->viewManager(), SLOT( showTimeSpanView() ) ); 889 mView->viewManager(), SLOT( showTimeSpanView() ) );
889#endif 890#endif
890 891
891 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 892 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
892 this ); 893 this );
893 mNewSubTodoAction->addTo( actionMenu ); 894 mNewSubTodoAction->addTo( actionMenu );
894 connect( mNewSubTodoAction, SIGNAL( activated() ), 895 connect( mNewSubTodoAction, SIGNAL( activated() ),
895 mView, SLOT( newSubTodo() ) ); 896 mView, SLOT( newSubTodo() ) );
896 897
897 actionMenu->insertSeparator(); 898 actionMenu->insertSeparator();
898 899
899 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 900 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
900 mShowAction->addTo( actionMenu ); 901 mShowAction->addTo( actionMenu );
901 connect( mShowAction, SIGNAL( activated() ), 902 connect( mShowAction, SIGNAL( activated() ),
902 mView, SLOT( showIncidence() ) ); 903 mView, SLOT( showIncidence() ) );
903 904
904 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 905 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
905 mEditAction->addTo( actionMenu ); 906 mEditAction->addTo( actionMenu );
906 connect( mEditAction, SIGNAL( activated() ), 907 connect( mEditAction, SIGNAL( activated() ),
907 mView, SLOT( editIncidence() ) ); 908 mView, SLOT( editIncidence() ) );
908 909
909 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 910 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
910 mDeleteAction->addTo( actionMenu ); 911 mDeleteAction->addTo( actionMenu );
911 connect( mDeleteAction, SIGNAL( activated() ), 912 connect( mDeleteAction, SIGNAL( activated() ),
912 mView, SLOT( deleteIncidence() ) ); 913 mView, SLOT( deleteIncidence() ) );
913 914
914 915
915 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 916 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
916 mCloneAction->addTo( actionMenu ); 917 mCloneAction->addTo( actionMenu );
917 connect( mCloneAction, SIGNAL( activated() ), 918 connect( mCloneAction, SIGNAL( activated() ),
918 mView, SLOT( cloneIncidence() ) ); 919 mView, SLOT( cloneIncidence() ) );
919 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 920 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
920 mMoveAction->addTo( actionMenu ); 921 mMoveAction->addTo( actionMenu );
921 connect( mMoveAction, SIGNAL( activated() ), 922 connect( mMoveAction, SIGNAL( activated() ),
922 mView, SLOT( moveIncidence() ) ); 923 mView, SLOT( moveIncidence() ) );
923 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 924 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
924 mBeamAction->addTo( actionMenu ); 925 mBeamAction->addTo( actionMenu );
925 connect( mBeamAction, SIGNAL( activated() ), 926 connect( mBeamAction, SIGNAL( activated() ),
926 mView, SLOT( beamIncidence() ) ); 927 mView, SLOT( beamIncidence() ) );
927 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 928 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
928 mCancelAction->addTo( actionMenu ); 929 mCancelAction->addTo( actionMenu );
929 connect( mCancelAction, SIGNAL( activated() ), 930 connect( mCancelAction, SIGNAL( activated() ),
930 mView, SLOT( toggleCancelIncidence() ) ); 931 mView, SLOT( toggleCancelIncidence() ) );
931 932
932 actionMenu->insertSeparator(); 933 actionMenu->insertSeparator();
933 934
934 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 935 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
935 this ); 936 this );
936 action->addTo( actionMenu ); 937 action->addTo( actionMenu );
937 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 938 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
938 939
939 icon = loadPixmap( pathString + "search" ); 940 icon = loadPixmap( pathString + "search" );
940 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 941 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
941 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 942 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
942 search_action->addTo( actionMenu ); 943 search_action->addTo( actionMenu );
943 connect( search_action, SIGNAL( activated() ), 944 connect( search_action, SIGNAL( activated() ),
944 mView->dialogManager(), SLOT( showSearchDialog() ) ); 945 mView->dialogManager(), SLOT( showSearchDialog() ) );
945 946
946 947
947 948
948 if ( KOPrefs::instance()->mShowFullMenu ) { 949 if ( KOPrefs::instance()->mShowFullMenu ) {
949 actionMenu->insertSeparator(); 950 actionMenu->insertSeparator();
950 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 951 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
951 952
952 } 953 }
953 // actionMenu->insertSeparator(); 954 // actionMenu->insertSeparator();
954 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 955 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
955 this ); 956 this );
956 action->addTo( importMenu_X ); 957 action->addTo( importMenu_X );
957 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 958 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
958 action = new QAction( "import_quick", i18n("Import last file"), 0, 959 action = new QAction( "import_quick", i18n("Import last file"), 0,
959 this ); 960 this );
960 action->addTo( importMenu_X ); 961 action->addTo( importMenu_X );
961 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 962 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
962 importMenu_X->insertSeparator(); 963 importMenu_X->insertSeparator();
963 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 964 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
964 this ); 965 this );
965 action->addTo( importMenu_X ); 966 action->addTo( importMenu_X );
966 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 967 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
967 //#ifndef DESKTOP_VERSION 968 //#ifndef DESKTOP_VERSION
968 importMenu_X->insertSeparator(); 969 importMenu_X->insertSeparator();
969 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 970 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
970 this ); 971 this );
971 action->addTo( importMenu_X ); 972 action->addTo( importMenu_X );
972 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 973 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
973 //#else 974 //#else
974#ifdef _OL_IMPORT_ 975#ifdef _OL_IMPORT_
975 importMenu_X->insertSeparator(); 976 importMenu_X->insertSeparator();
976 action = new QAction( "import_ol", i18n("Import from OL"), 0, 977 action = new QAction( "import_ol", i18n("Import from OL"), 0,
977 this ); 978 this );
978 action->addTo( importMenu_X ); 979 action->addTo( importMenu_X );
979 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 980 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
980#endif 981#endif
981 //#endif 982 //#endif
982 983
983 //importMenu->insertSeparator(); 984 //importMenu->insertSeparator();
984 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 985 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
985 this ); 986 this );
986 action->addTo( importMenu ); 987 action->addTo( importMenu );
987 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 988 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
988 989
989 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 990 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
990 this ); 991 this );
991 action->addTo( importMenu ); 992 action->addTo( importMenu );
992 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 993 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
993 importMenu->insertSeparator(); 994 importMenu->insertSeparator();
994 importMenu->insertItem( i18n("Import"), importMenu_X ); 995 importMenu->insertItem( i18n("Import"), importMenu_X );
995 //importMenu->insertSeparator(); 996 //importMenu->insertSeparator();
996 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 997 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
997 this ); 998 this );
998 action->addTo( exportMenu_X ); 999 action->addTo( exportMenu_X );
999 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1000 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1000 1001
1001 1002
1002 //LR 1003 //LR
1003 QPopupMenu *ex2phone = new QPopupMenu( this ); 1004 QPopupMenu *ex2phone = new QPopupMenu( this );
1004 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1005 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1005 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1006 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1006 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1007 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1007 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1008 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1008 1009
1009 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1010 importMenu->insertItem( i18n("Export"), exportMenu_X );
1010#ifndef DESKTOP_VERSION 1011#ifndef DESKTOP_VERSION
1011 //importMenu->insertSeparator(); 1012 //importMenu->insertSeparator();
1012 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1013 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1013 this ); 1014 this );
1014 brAction->addTo( beamMenu_X ); 1015 brAction->addTo( beamMenu_X );
1015 brAction->setToggleAction (true ) ; 1016 brAction->setToggleAction (true ) ;
1016 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1017 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1017 1018
1018 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1019 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1019 this ); 1020 this );
1020 action->addTo( beamMenu_X ); 1021 action->addTo( beamMenu_X );
1021 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1022 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1022 1023
1023 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1024 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1024 this ); 1025 this );
1025 action->addTo( beamMenu_X ); 1026 action->addTo( beamMenu_X );
1026 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1027 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1027 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1028 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1028#else 1029#else
1029 //importMenu->insertSeparator(); 1030 //importMenu->insertSeparator();
1030 icon = loadPixmap( pathString + "print" ); 1031 icon = loadPixmap( pathString + "print" );
1031 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1032 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1032 action->addTo( beamMenu_X ); 1033 action->addTo( beamMenu_X );
1033 connect( action, SIGNAL( activated() ), 1034 connect( action, SIGNAL( activated() ),
1034 this, SLOT( printCal() ) ); 1035 this, SLOT( printCal() ) );
1035 1036
1036 icon = loadPixmap( pathString + "print" ); 1037 icon = loadPixmap( pathString + "print" );
1037 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1038 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1038 action->addTo( beamMenu_X ); 1039 action->addTo( beamMenu_X );
1039 connect( action, SIGNAL( activated() ), 1040 connect( action, SIGNAL( activated() ),
1040 this, SLOT( printSel() ) ); 1041 this, SLOT( printSel() ) );
1041 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1042 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1042 action->addTo( beamMenu_X ); 1043 action->addTo( beamMenu_X );
1043 connect( action, SIGNAL( activated() ), 1044 connect( action, SIGNAL( activated() ),
1044 mView->viewManager(), SLOT( slotprintWNV() ) ); 1045 mView->viewManager(), SLOT( slotprintWNV() ) );
1045 1046
1046 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1047 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1047 action->addTo( beamMenu_X ); 1048 action->addTo( beamMenu_X );
1048 connect( action, SIGNAL( activated() ), 1049 connect( action, SIGNAL( activated() ),
1049 mView, SLOT( slotprintSelInc() ) ); 1050 mView, SLOT( slotprintSelInc() ) );
1050 1051
1051 1052
1052 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1053 importMenu->insertItem( i18n("Print"), beamMenu_X );
1053#endif 1054#endif
1054 importMenu->insertSeparator(); 1055 importMenu->insertSeparator();
1055 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1056 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1056 this ); 1057 this );
1057 action->addTo( importMenu ); 1058 action->addTo( importMenu );
1058 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1059 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1059 importMenu->insertSeparator(); 1060 importMenu->insertSeparator();
1060 action = new QAction( "beam all", i18n("Save"), 0, 1061 action = new QAction( "beam all", i18n("Save"), 0,
1061 this ); 1062 this );
1062 action->addTo( importMenu ); 1063 action->addTo( importMenu );
1063 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1064 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1064 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1065 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1065 this ); 1066 this );
1066 action->addTo( importMenu ); 1067 action->addTo( importMenu );
1067 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1068 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1068 1069
1069 //menuBar->insertItem( "Configure",configureMenu ); 1070 //menuBar->insertItem( "Configure",configureMenu );
1070 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1071 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1071 icon = loadPixmap( "korganizer/korganizer" ); 1072 icon = loadPixmap( "korganizer/korganizer" );
1072 1073
1073 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1074 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1074 action->addTo( helpMenu ); 1075 action->addTo( helpMenu );
1075 connect( action, SIGNAL( activated() ), 1076 connect( action, SIGNAL( activated() ),
1076 SLOT( whatsNew() ) ); 1077 SLOT( whatsNew() ) );
1077 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1078 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1078 action->addTo( helpMenu ); 1079 action->addTo( helpMenu );
1079 connect( action, SIGNAL( activated() ), 1080 connect( action, SIGNAL( activated() ),
1080 SLOT( features() ) ); 1081 SLOT( features() ) );
1081 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1082 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1082 action->addTo( helpMenu ); 1083 action->addTo( helpMenu );
1083 connect( action, SIGNAL( activated() ), 1084 connect( action, SIGNAL( activated() ),
1084 SLOT( keyBindings() ) ); 1085 SLOT( keyBindings() ) );
1085 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1086 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1086 action->addTo( helpMenu ); 1087 action->addTo( helpMenu );
1087 connect( action, SIGNAL( activated() ), 1088 connect( action, SIGNAL( activated() ),
1088 SLOT( synchowto() ) ); 1089 SLOT( synchowto() ) );
1089 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1090 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1090 action->addTo( helpMenu ); 1091 action->addTo( helpMenu );
1091 connect( action, SIGNAL( activated() ), 1092 connect( action, SIGNAL( activated() ),
1092 SLOT( kdesynchowto() ) ); 1093 SLOT( kdesynchowto() ) );
1093 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1094 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1094 action->addTo( helpMenu ); 1095 action->addTo( helpMenu );
1095 connect( action, SIGNAL( activated() ), 1096 connect( action, SIGNAL( activated() ),
1096 SLOT( multisynchowto() ) ); 1097 SLOT( multisynchowto() ) );
1097 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1098 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1098 action->addTo( helpMenu ); 1099 action->addTo( helpMenu );
1099 connect( action, SIGNAL( activated() ), 1100 connect( action, SIGNAL( activated() ),
1100 SLOT( aboutAutoSaving() ) ); 1101 SLOT( aboutAutoSaving() ) );
1101 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1102 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1102 action->addTo( helpMenu ); 1103 action->addTo( helpMenu );
1103 connect( action, SIGNAL( activated() ), 1104 connect( action, SIGNAL( activated() ),
1104 SLOT( aboutKnownBugs() ) ); 1105 SLOT( aboutKnownBugs() ) );
1105 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1106 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1106 action->addTo( helpMenu ); 1107 action->addTo( helpMenu );
1107 connect( action, SIGNAL( activated() ), 1108 connect( action, SIGNAL( activated() ),
1108 SLOT( usertrans() ) ); 1109 SLOT( usertrans() ) );
1109 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1110 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1110 action->addTo( helpMenu ); 1111 action->addTo( helpMenu );
1111 connect( action, SIGNAL( activated() ), 1112 connect( action, SIGNAL( activated() ),
1112 SLOT( faq() ) ); 1113 SLOT( faq() ) );
1113 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1114 action = new QAction( "licence", i18n("Licence..."), 0, this );
1114 action->addTo( helpMenu ); 1115 action->addTo( helpMenu );
1115 connect( action, SIGNAL( activated() ), 1116 connect( action, SIGNAL( activated() ),
1116 SLOT( licence() ) ); 1117 SLOT( licence() ) );
1117 action = new QAction( "about", i18n("About..."), 0, this ); 1118 action = new QAction( "about", i18n("About..."), 0, this );
1118 action->addTo( helpMenu ); 1119 action->addTo( helpMenu );
1119 connect( action, SIGNAL( activated() ), 1120 connect( action, SIGNAL( activated() ),
1120 SLOT( about() ) ); 1121 SLOT( about() ) );
1121 //menuBar->insertSeparator(); 1122 //menuBar->insertSeparator();
1122 1123
1123 // ****************************************************** 1124 // ******************************************************
1124 // menubar icons 1125 // menubar icons
1125 1126
1126 1127
1127 1128
1128 //menuBar->insertItem( iconToolBar ); 1129 //menuBar->insertItem( iconToolBar );
1129 //xdays_action 1130 //xdays_action
1130 if (p-> mShowIconNewEvent) 1131 if (p-> mShowIconNewEvent)
1131 ne_action->addTo( iconToolBar ); 1132 ne_action->addTo( iconToolBar );
1132 if (p->mShowIconNewTodo ) 1133 if (p->mShowIconNewTodo )
1133 nt_action->addTo( iconToolBar ); 1134 nt_action->addTo( iconToolBar );
1134 if (p-> mShowIconSearch) 1135 if (p-> mShowIconSearch)
1135 search_action->addTo( iconToolBar ); 1136 search_action->addTo( iconToolBar );
1136 if (p-> mShowIconWhatsThis) 1137 if (p-> mShowIconWhatsThis)
1137 QWhatsThis::whatsThisButton ( iconToolBar ); 1138 QWhatsThis::whatsThisButton ( iconToolBar );
1138 if (p-> mShowIconNext) 1139 if (p-> mShowIconNext)
1139 whatsnext_action->addTo( viewToolBar ); 1140 whatsnext_action->addTo( viewToolBar );
1140 if (p-> mShowIconNextDays) 1141 if (p-> mShowIconNextDays)
1141 xdays_action->addTo( viewToolBar ); 1142 xdays_action->addTo( viewToolBar );
1142 if (p-> mShowIconJournal) 1143 if (p-> mShowIconJournal)
1143 viewjournal_action->addTo( viewToolBar ); 1144 viewjournal_action->addTo( viewToolBar );
1144 if (p-> mShowIconDay1) 1145 if (p-> mShowIconDay1)
1145 day1_action->addTo( viewToolBar ); 1146 day1_action->addTo( viewToolBar );
1146 if (p-> mShowIconDay5) 1147 if (p-> mShowIconDay5)
1147 day5_action->addTo( viewToolBar ); 1148 day5_action->addTo( viewToolBar );
1148 if (p-> mShowIconDay7) 1149 if (p-> mShowIconDay7)
1149 day7_action->addTo( viewToolBar ); 1150 day7_action->addTo( viewToolBar );
1150 if (p-> mShowIconDay6) 1151 if (p-> mShowIconDay6)
1151 day6_action->addTo( viewToolBar ); 1152 day6_action->addTo( viewToolBar );
1152 if (p-> mShowIconMonth) 1153 if (p-> mShowIconMonth)
1153 month_action->addTo( viewToolBar ); 1154 month_action->addTo( viewToolBar );
1154 if (p-> mShowIconList) 1155 if (p-> mShowIconList)
1155 showlist_action->addTo( viewToolBar ); 1156 showlist_action->addTo( viewToolBar );
1156 if (p-> mShowIconTodoview) 1157 if (p-> mShowIconTodoview)
1157 todoview_action->addTo( viewToolBar ); 1158 todoview_action->addTo( viewToolBar );
1158 1159
1159 icon = loadPixmap( pathString + "2leftarrowB" ); 1160 icon = loadPixmap( pathString + "2leftarrowB" );
1160 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1161 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1161 if (p-> mShowIconBackFast) { 1162 if (p-> mShowIconBackFast) {
1162 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1163 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1163 connect( action, SIGNAL( activated() ), 1164 connect( action, SIGNAL( activated() ),
1164 mView, SLOT( goPreviousMonth() ) ); 1165 mView, SLOT( goPreviousMonth() ) );
1165 action->addTo( navigatorToolBar ); 1166 action->addTo( navigatorToolBar );
1166 } 1167 }
1167 icon = loadPixmap( pathString + "1leftarrowB" ); 1168 icon = loadPixmap( pathString + "1leftarrowB" );
1168 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1169 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1169 if (p-> mShowIconBack) { 1170 if (p-> mShowIconBack) {
1170 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1171 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1171 connect( action, SIGNAL( activated() ), 1172 connect( action, SIGNAL( activated() ),
1172 mView, SLOT( goPrevious() ) ); 1173 mView, SLOT( goPrevious() ) );
1173 action->addTo( navigatorToolBar ); 1174 action->addTo( navigatorToolBar );
1174 } 1175 }
1175 icon = loadPixmap( pathString + "today" ); 1176 icon = loadPixmap( pathString + "today" );
1176 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1177 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1177 if (p-> mShowIconToday) 1178 if (p-> mShowIconToday)
1178 today_action->addTo( navigatorToolBar ); 1179 today_action->addTo( navigatorToolBar );
1179 icon = loadPixmap( pathString + "1rightarrowB" ); 1180 icon = loadPixmap( pathString + "1rightarrowB" );
1180 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1181 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1181 if (p-> mShowIconForward) { 1182 if (p-> mShowIconForward) {
1182 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1183 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1183 connect( action, SIGNAL( activated() ), 1184 connect( action, SIGNAL( activated() ),
1184 mView, SLOT( goNext() ) ); 1185 mView, SLOT( goNext() ) );
1185 action->addTo( navigatorToolBar ); 1186 action->addTo( navigatorToolBar );
1186 } 1187 }
1187 icon = loadPixmap( pathString + "2rightarrowB" ); 1188 icon = loadPixmap( pathString + "2rightarrowB" );
1188 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1189 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1189 if (p-> mShowIconForwardFast) { 1190 if (p-> mShowIconForwardFast) {
1190 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1191 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1191 connect( action, SIGNAL( activated() ), 1192 connect( action, SIGNAL( activated() ),
1192 mView, SLOT( goNextMonth() ) ); 1193 mView, SLOT( goNextMonth() ) );
1193 action->addTo( navigatorToolBar ); 1194 action->addTo( navigatorToolBar );
1194 } 1195 }
1195 1196
1196 1197
1197 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1198 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1198 1199
1199 1200
1200 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1201 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1201 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1202 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1202 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1203 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1203 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1204 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1204 1205
1205 if (p-> mShowIconNewEvent) 1206 if (p-> mShowIconNewEvent)
1206 configureToolBarMenu->setItemChecked( 10, true ); 1207 configureToolBarMenu->setItemChecked( 10, true );
1207 if (p->mShowIconNewTodo ) 1208 if (p->mShowIconNewTodo )
1208 configureToolBarMenu->setItemChecked( 20, true ); 1209 configureToolBarMenu->setItemChecked( 20, true );
1209 if (p-> mShowIconSearch) 1210 if (p-> mShowIconSearch)
1210 configureToolBarMenu->setItemChecked( 120, true ); 1211 configureToolBarMenu->setItemChecked( 120, true );
1211 if (p-> mShowIconList) 1212 if (p-> mShowIconList)
1212 configureToolBarMenu->setItemChecked( 30, true ); 1213 configureToolBarMenu->setItemChecked( 30, true );
1213 if (p-> mShowIconDay1) 1214 if (p-> mShowIconDay1)
1214 configureToolBarMenu->setItemChecked( 40, true ); 1215 configureToolBarMenu->setItemChecked( 40, true );
1215 if (p-> mShowIconDay5) 1216 if (p-> mShowIconDay5)
1216 configureToolBarMenu->setItemChecked( 50, true ); 1217 configureToolBarMenu->setItemChecked( 50, true );
1217 if (p-> mShowIconDay6) 1218 if (p-> mShowIconDay6)
1218 configureToolBarMenu->setItemChecked( 75, true ); 1219 configureToolBarMenu->setItemChecked( 75, true );
1219 if (p-> mShowIconDay7) 1220 if (p-> mShowIconDay7)
1220 configureToolBarMenu->setItemChecked( 60, true ); 1221 configureToolBarMenu->setItemChecked( 60, true );
1221 if (p-> mShowIconMonth) 1222 if (p-> mShowIconMonth)
1222 configureToolBarMenu->setItemChecked( 70, true ); 1223 configureToolBarMenu->setItemChecked( 70, true );
1223 if (p-> mShowIconTodoview) 1224 if (p-> mShowIconTodoview)
1224 configureToolBarMenu->setItemChecked( 80, true ); 1225 configureToolBarMenu->setItemChecked( 80, true );
1225 if (p-> mShowIconBackFast) 1226 if (p-> mShowIconBackFast)
1226 configureToolBarMenu->setItemChecked( 200, true ); 1227 configureToolBarMenu->setItemChecked( 200, true );
1227 if (p-> mShowIconBack) 1228 if (p-> mShowIconBack)
1228 configureToolBarMenu->setItemChecked( 210, true ); 1229 configureToolBarMenu->setItemChecked( 210, true );
1229 if (p-> mShowIconToday) 1230 if (p-> mShowIconToday)
1230 configureToolBarMenu->setItemChecked( 130, true ); 1231 configureToolBarMenu->setItemChecked( 130, true );
1231 if (p-> mShowIconForward) 1232 if (p-> mShowIconForward)
1232 configureToolBarMenu->setItemChecked( 220, true ); 1233 configureToolBarMenu->setItemChecked( 220, true );
1233 if (p-> mShowIconForwardFast) 1234 if (p-> mShowIconForwardFast)
1234 configureToolBarMenu->setItemChecked( 230, true ); 1235 configureToolBarMenu->setItemChecked( 230, true );
1235 if (p-> mShowIconNextDays) 1236 if (p-> mShowIconNextDays)
1236 configureToolBarMenu->setItemChecked( 100, true ); 1237 configureToolBarMenu->setItemChecked( 100, true );
1237 if (p-> mShowIconNext) 1238 if (p-> mShowIconNext)
1238 configureToolBarMenu->setItemChecked( 110, true ); 1239 configureToolBarMenu->setItemChecked( 110, true );
1239 if (p-> mShowIconJournal) 1240 if (p-> mShowIconJournal)
1240 configureToolBarMenu->setItemChecked( 90, true ); 1241 configureToolBarMenu->setItemChecked( 90, true );
1241 if (p-> mShowIconWhatsThis) 1242 if (p-> mShowIconWhatsThis)
1242 configureToolBarMenu->setItemChecked( 300, true ); 1243 configureToolBarMenu->setItemChecked( 300, true );
1243 if (p-> mShowIconWeekNum) 1244 if (p-> mShowIconWeekNum)
1244 configureToolBarMenu->setItemChecked( 400, true ); 1245 configureToolBarMenu->setItemChecked( 400, true );
1245 if (!p-> mShowIconStretch) { 1246 if (!p-> mShowIconStretch) {
1246 QLabel* dummy = new QLabel( iconToolBar ); 1247 QLabel* dummy = new QLabel( iconToolBar );
1247 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1248 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1248 dummy->setMinimumWidth( 0 ); 1249 dummy->setMinimumWidth( 0 );
1249 iconToolBar->setStretchableWidget ( dummy ) ; 1250 iconToolBar->setStretchableWidget ( dummy ) ;
1250 } 1251 }
1251 else { 1252 else {
1252 iconToolBar->setHorizontalStretchable (true ); 1253 iconToolBar->setHorizontalStretchable (true );
1253 viewToolBar->setHorizontalStretchable (true ); 1254 viewToolBar->setHorizontalStretchable (true );
1254 navigatorToolBar->setHorizontalStretchable (true ); 1255 navigatorToolBar->setHorizontalStretchable (true );
1255 iconToolBar->setVerticalStretchable (true ); 1256 iconToolBar->setVerticalStretchable (true );
1256 viewToolBar->setVerticalStretchable (true ); 1257 viewToolBar->setVerticalStretchable (true );
1257 navigatorToolBar->setVerticalStretchable (true ); 1258 navigatorToolBar->setVerticalStretchable (true );
1258 configureToolBarMenu->setItemChecked( 5, true ); 1259 configureToolBarMenu->setItemChecked( 5, true );
1259 } 1260 }
1260 if (p-> mShowIconFilter) 1261 if (p-> mShowIconFilter)
1261 configureToolBarMenu->setItemChecked( 7, true ); 1262 configureToolBarMenu->setItemChecked( 7, true );
1262 if (p-> mShowIconOnetoolbar) 1263 if (p-> mShowIconOnetoolbar)
1263 configureToolBarMenu->setItemChecked( 6, true ); 1264 configureToolBarMenu->setItemChecked( 6, true );
1264 1265
1265 1266
1266 if ( filterMenubar ) 1267 if ( filterMenubar )
1267 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1268 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1268 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1269 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1269 configureAgenda( p->mHourSize ); 1270 configureAgenda( p->mHourSize );
1270 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1271 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1271} 1272}
1272 1273
1273void MainWindow::exportToPhone( int mode ) 1274void MainWindow::exportToPhone( int mode )
1274{ 1275{
1275 1276
1276 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1277 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1277 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1278 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1278 KOex2phonePrefs ex2phone; 1279 KOex2phonePrefs ex2phone;
1279 1280
1280 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1281 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1281 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1282 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1282 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1283 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1283 if ( mode == 1 ) 1284 if ( mode == 1 )
1284 ex2phone.setCaption(i18n("Export complete calendar")); 1285 ex2phone.setCaption(i18n("Export complete calendar"));
1285 if ( mode == 2 ) 1286 if ( mode == 2 )
1286 ex2phone.setCaption(i18n("Export filtered calendar")); 1287 ex2phone.setCaption(i18n("Export filtered calendar"));
1287 1288
1288 if ( !ex2phone.exec() ) { 1289 if ( !ex2phone.exec() ) {
1289 return; 1290 return;
1290 } 1291 }
1291 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1292 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1292 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1293 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1293 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1294 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1294 1295
1295 int inFuture = 0; 1296 int inFuture = 0;
1296 if ( ex2phone.mWriteBackFuture->isChecked() ) 1297 if ( ex2phone.mWriteBackFuture->isChecked() )
1297 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1298 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1298 QPtrList<Incidence> delSel; 1299 QPtrList<Incidence> delSel;
1299 if ( mode == 1 ) 1300 if ( mode == 1 )
1300 delSel = mCalendar->rawIncidences(); 1301 delSel = mCalendar->rawIncidences();
1301 if ( mode == 2 ) 1302 if ( mode == 2 )
1302 delSel = mCalendar->incidences(); 1303 delSel = mCalendar->incidences();
1303 CalendarLocal* cal = new CalendarLocal(); 1304 CalendarLocal* cal = new CalendarLocal();
1304 cal->setLocalTime(); 1305 cal->setLocalTime();
1305 Incidence *incidence = delSel.first(); 1306 Incidence *incidence = delSel.first();
1306 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1307 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1307 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1308 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1308 while ( incidence ) { 1309 while ( incidence ) {
1309 if ( incidence->type() != "Journal" ) { 1310 if ( incidence->type() != "Journal" ) {
1310 bool add = true; 1311 bool add = true;
1311 if ( inFuture ) { 1312 if ( inFuture ) {
1312 QDateTime dt; 1313 QDateTime dt;
1313 if ( incidence->type() == "Todo" ) { 1314 if ( incidence->type() == "Todo" ) {
1314 Todo * t = (Todo*)incidence; 1315 Todo * t = (Todo*)incidence;
1315 if ( t->hasDueDate() ) 1316 if ( t->hasDueDate() )
1316 dt = t->dtDue(); 1317 dt = t->dtDue();
1317 else 1318 else
1318 dt = cur.addSecs( 62 ); 1319 dt = cur.addSecs( 62 );
1319 } 1320 }
1320 else { 1321 else {
1321 bool ok; 1322 bool ok;
1322 dt = incidence->getNextOccurence( cur, &ok ); 1323 dt = incidence->getNextOccurence( cur, &ok );
1323 if ( !ok ) 1324 if ( !ok )
1324 dt = cur.addSecs( -62 ); 1325 dt = cur.addSecs( -62 );
1325 } 1326 }
1326 if ( dt < cur || dt > end ) { 1327 if ( dt < cur || dt > end ) {
1327 add = false; 1328 add = false;
1328 } 1329 }
1329 } 1330 }
1330 if ( add ) { 1331 if ( add ) {
1331 Incidence *in = incidence->clone(); 1332 Incidence *in = incidence->clone();
1332 cal->addIncidence( in ); 1333 cal->addIncidence( in );
1333 } 1334 }
1334 } 1335 }
1335 incidence = delSel.next(); 1336 incidence = delSel.next();
1336 } 1337 }
1337 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1338 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1338 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1339 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1339 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1340 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1340 1341
1341 setCaption( i18n("Writing to phone...")); 1342 setCaption( i18n("Writing to phone..."));
1342 if ( PhoneFormat::writeToPhone( cal ) ) 1343 if ( PhoneFormat::writeToPhone( cal ) )
1343 setCaption( i18n("Export to phone successful!")); 1344 setCaption( i18n("Export to phone successful!"));
1344 else 1345 else
1345 setCaption( i18n("Error exporting to phone!")); 1346 setCaption( i18n("Error exporting to phone!"));
1346 delete cal; 1347 delete cal;
1347} 1348}
1348 1349
1349 1350
1350void MainWindow::setDefaultPreferences() 1351void MainWindow::setDefaultPreferences()
1351{ 1352{
1352 KOPrefs *p = KOPrefs::instance(); 1353 KOPrefs *p = KOPrefs::instance();
1353 1354
1354 p->mCompactDialogs = true; 1355 p->mCompactDialogs = true;
1355 p->mConfirm = true; 1356 p->mConfirm = true;
1356 // p->mEnableQuickTodo = false; 1357 // p->mEnableQuickTodo = false;
1357 1358
1358} 1359}
1359 1360
1360QString MainWindow::resourcePath() 1361QString MainWindow::resourcePath()
1361{ 1362{
1362 return KGlobal::iconLoader()->iconPath(); 1363 return KGlobal::iconLoader()->iconPath();
1363} 1364}
1364 1365
1365void MainWindow::displayText( QString text ,QString cap ) 1366void MainWindow::displayText( QString text ,QString cap )
1366{ 1367{
1367 QDialog dia( this, "name", true ); ; 1368 QDialog dia( this, "name", true ); ;
1368 dia.setCaption( cap ); 1369 dia.setCaption( cap );
1369 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1370 QVBoxLayout* lay = new QVBoxLayout( &dia );
1370 lay->setSpacing( 3 ); 1371 lay->setSpacing( 3 );
1371 lay->setMargin( 3 ); 1372 lay->setMargin( 3 );
1372 QTextBrowser tb ( &dia ); 1373 QTextBrowser tb ( &dia );
1373 lay->addWidget( &tb ); 1374 lay->addWidget( &tb );
1374 tb.setText( text ); 1375 tb.setText( text );
1375#ifdef DESKTOP_VERSION 1376#ifdef DESKTOP_VERSION
1376 dia.resize( 640, 480); 1377 dia.resize( 640, 480);
1377#else 1378#else
1378 dia.showMaximized(); 1379 dia.showMaximized();
1379#endif 1380#endif
1380 dia.exec(); 1381 dia.exec();
1381} 1382}
1382 1383
1383void MainWindow::features() 1384void MainWindow::features()
1384{ 1385{
1385 1386
1386 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1387 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1387} 1388}
1388 1389
1389void MainWindow::usertrans() 1390void MainWindow::usertrans()
1390{ 1391{
1391 1392
1392 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1393 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1393} 1394}
1394 1395
1395void MainWindow::kdesynchowto() 1396void MainWindow::kdesynchowto()
1396{ 1397{
1397 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1398 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1398} 1399}
1399void MainWindow::multisynchowto() 1400void MainWindow::multisynchowto()
1400{ 1401{
1401 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1402 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1402} 1403}
1403void MainWindow::synchowto() 1404void MainWindow::synchowto()
1404{ 1405{
1405 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1406 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1406} 1407}
1407void MainWindow::faq() 1408void MainWindow::faq()
1408{ 1409{
1409 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1410 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1410 1411
1411} 1412}
1412void MainWindow::whatsNew() 1413void MainWindow::whatsNew()
1413{ 1414{
1414 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1415 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1415 1416
1416} 1417}
1417void MainWindow::licence() 1418void MainWindow::licence()
1418{ 1419{
1419 KApplication::showLicence(); 1420 KApplication::showLicence();
1420 1421
1421} 1422}
1422void MainWindow::about() 1423void MainWindow::about()
1423{ 1424{
1424 QString version; 1425 QString version;
1425#include <../version> 1426#include <../version>
1426 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1427 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1427 i18n("KOrganizer/Platform-independent\n") + 1428 i18n("KOrganizer/Platform-independent\n") +
1428 "(KO/Pi) " + version + " - " + 1429 "(KO/Pi) " + version + " - " +
1429 1430
1430#ifdef DESKTOP_VERSION 1431#ifdef DESKTOP_VERSION
1431 i18n("Desktop Edition\n") + 1432 i18n("Desktop Edition\n") +
1432#else 1433#else
1433 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1434 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1434#endif 1435#endif
1435 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1436 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1436} 1437}
1437void MainWindow::keyBindings() 1438void MainWindow::keyBindings()
1438{ 1439{
1439 QString cap = i18n("KO/Pi Keys + Colors"); 1440 QString cap = i18n("KO/Pi Keys + Colors");
1440 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1441 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1441 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1442 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1442 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1443 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1443 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1444 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1444 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1445 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1445 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1446 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1446 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1447 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1447 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1448 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1448 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1449 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1449 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1450 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1450 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1451 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1451 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1452 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1452 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1453 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1453 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1454 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1454 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1455 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1455 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1456 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1456 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1457 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1457 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1458 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1458 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1459 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1459 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1460 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1460 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1461 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1461 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1462 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1462 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1463 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1463 i18n("<p><h3>In agenda view:</h3></p>\n") + 1464 i18n("<p><h3>In agenda view:</h3></p>\n") +
1464 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1465 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1465 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1466 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1466 i18n("<p><h3>In todo view:</h3></p>\n") + 1467 i18n("<p><h3>In todo view:</h3></p>\n") +
1467 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1468 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1468 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1469 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1469 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1470 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1470 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1471 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1471 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1472 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1472 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1473 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1473 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1474 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1474 i18n("<p><h3>In list view:</h3></p>\n") + 1475 i18n("<p><h3>In list view:</h3></p>\n") +
1475 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1476 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1476 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1477 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1477 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1478 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1478 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1479 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1479 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1480 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1480 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1481 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1481 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1482 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1482 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1483 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1483 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1484 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1484 i18n("<p><b>E</b>: Edit item</p>\n") + 1485 i18n("<p><b>E</b>: Edit item</p>\n") +
1485 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1486 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1486 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1487 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1487 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1488 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1488 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1489 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1489 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1490 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1490 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1491 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1491 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1492 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1492 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1493 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1493 i18n("<p><b>White</b>: Item readonly</p>\n"); 1494 i18n("<p><b>White</b>: Item readonly</p>\n");
1494 displayText( text, cap); 1495 displayText( text, cap);
1495} 1496}
1496void MainWindow::aboutAutoSaving() 1497void MainWindow::aboutAutoSaving()
1497{ 1498{
1498 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1499 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1499 1500
1500 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1501 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1501 1502
1502} 1503}
1503void MainWindow::aboutKnownBugs() 1504void MainWindow::aboutKnownBugs()
1504{ 1505{
1505 QMessageBox* msg; 1506 QMessageBox* msg;
1506 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1507 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1507 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1508 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1508 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1509 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1509 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1510 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1510 i18n("\nor report them in the bugtracker on\n") + 1511 i18n("\nor report them in the bugtracker on\n") +
1511 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1512 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1512 QMessageBox::NoIcon, 1513 QMessageBox::NoIcon,
1513 QMessageBox::Ok, 1514 QMessageBox::Ok,
1514 QMessageBox::NoButton, 1515 QMessageBox::NoButton,
1515 QMessageBox::NoButton); 1516 QMessageBox::NoButton);
1516 msg->exec(); 1517 msg->exec();
1517 delete msg; 1518 delete msg;
1518 1519
1519} 1520}
1520 1521
1521QString MainWindow::defaultFileName() 1522QString MainWindow::defaultFileName()
1522{ 1523{
1523 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1524 return locateLocal( "data", "korganizer/mycalendar.ics" );
1524} 1525}
1525QString MainWindow::syncFileName() 1526QString MainWindow::syncFileName()
1526{ 1527{
1527#ifdef DESKTOP_VERSION 1528#ifdef DESKTOP_VERSION
1528 return locateLocal( "tmp", "synccalendar.ics" ); 1529 return locateLocal( "tmp", "synccalendar.ics" );
1529#else 1530#else
1530 return QString( "/tmp/synccalendar.ics" ); 1531 return QString( "/tmp/synccalendar.ics" );
1531#endif 1532#endif
1532} 1533}
1533#include "koglobals.h" 1534#include "koglobals.h"
1534#include <kcalendarsystem.h> 1535#include <kcalendarsystem.h>
1535void MainWindow::updateWeek(QDate seda) 1536void MainWindow::updateWeek(QDate seda)
1536{ 1537{
1537 int weekNum = KGlobal::locale()->weekNum ( seda ); 1538 int weekNum = KGlobal::locale()->weekNum ( seda );
1538 mWeekPixmap.fill( mWeekBgColor ); 1539 mWeekPixmap.fill( mWeekBgColor );
1539 QPainter p ( &mWeekPixmap ); 1540 QPainter p ( &mWeekPixmap );
1540 p.setFont( mWeekFont ); 1541 p.setFont( mWeekFont );
1541 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1542 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1542 p.end(); 1543 p.end();
1543 QIconSet icon3 ( mWeekPixmap ); 1544 QIconSet icon3 ( mWeekPixmap );
1544 mWeekAction->setIconSet ( icon3 ); 1545 mWeekAction->setIconSet ( icon3 );
1545 1546
1546} 1547}
1547void MainWindow::updateWeekNum(const DateList &selectedDates) 1548void MainWindow::updateWeekNum(const DateList &selectedDates)
1548{ 1549{
1549 updateWeek( selectedDates.first() ); 1550 updateWeek( selectedDates.first() );
1550} 1551}
1551void MainWindow::processIncidenceSelection( Incidence *incidence ) 1552void MainWindow::processIncidenceSelection( Incidence *incidence )
1552{ 1553{
1553 1554
1554 if ( !incidence ) { 1555 if ( !incidence ) {
1555 enableIncidenceActions( false ); 1556 enableIncidenceActions( false );
1556 1557
1557 mNewSubTodoAction->setEnabled( false ); 1558 mNewSubTodoAction->setEnabled( false );
1558 setCaptionToDates(); 1559 setCaptionToDates();
1559 return; 1560 return;
1560 1561
1561 } 1562 }
1562 1563
1563 //KGlobal::locale()->formatDateTime(nextA, true); 1564 //KGlobal::locale()->formatDateTime(nextA, true);
1564 QString startString = ""; 1565 QString startString = "";
1565 if ( incidence->type() != "Todo" ) { 1566 if ( incidence->type() != "Todo" ) {
1566 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1567 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1567 if ( incidence->doesFloat() ) { 1568 if ( incidence->doesFloat() ) {
1568 startString += ": "+incidence->dtStartDateStr( true ); 1569 startString += ": "+incidence->dtStartDateStr( true );
1569 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1570 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1570 1571
1571 } else { 1572 } else {
1572 startString = ": "+incidence->dtStartStr(true); 1573 startString = ": "+incidence->dtStartStr(true);
1573 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1574 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1574 1575
1575 } 1576 }
1576 1577
1577 } else { 1578 } else {
1578 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1579 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1579 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1580 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1580 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1581 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1581 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1582 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1582 bool ok; 1583 bool ok;
1583 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1584 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1584 if ( ok ) { 1585 if ( ok ) {
1585 int years = noc.date().year() - incidence->dtStart().date().year(); 1586 int years = noc.date().year() - incidence->dtStart().date().year();
1586 startString += i18n(" (%1 y.)"). arg( years ); 1587 startString += i18n(" (%1 y.)"). arg( years );
1587 } 1588 }
1588 } 1589 }
1589 else 1590 else
1590 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1591 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1591 } 1592 }
1592 1593
1593 } 1594 }
1594 else 1595 else
1595 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1596 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1596 if ( !incidence->location().isEmpty() ) 1597 if ( !incidence->location().isEmpty() )
1597 startString += " (" +incidence->location()+")"; 1598 startString += " (" +incidence->location()+")";
1598 setCaption( incidence->summary()+startString); 1599 setCaption( incidence->summary()+startString);
1599 1600
1600 enableIncidenceActions( true ); 1601 enableIncidenceActions( true );
1601 1602
1602 if ( incidence->type() == "Event" ) { 1603 if ( incidence->type() == "Event" ) {
1603 mShowAction->setText( i18n("Show Event...") ); 1604 mShowAction->setText( i18n("Show Event...") );
1604 mEditAction->setText( i18n("Edit Event...") ); 1605 mEditAction->setText( i18n("Edit Event...") );
1605 mDeleteAction->setText( i18n("Delete Event...") ); 1606 mDeleteAction->setText( i18n("Delete Event...") );
1606 1607
1607 mNewSubTodoAction->setEnabled( false ); 1608 mNewSubTodoAction->setEnabled( false );
1608 } else if ( incidence->type() == "Todo" ) { 1609 } else if ( incidence->type() == "Todo" ) {
1609 mShowAction->setText( i18n("Show Todo...") ); 1610 mShowAction->setText( i18n("Show Todo...") );
1610 mEditAction->setText( i18n("Edit Todo...") ); 1611 mEditAction->setText( i18n("Edit Todo...") );
1611 mDeleteAction->setText( i18n("Delete Todo...") ); 1612 mDeleteAction->setText( i18n("Delete Todo...") );
1612 1613
1613 mNewSubTodoAction->setEnabled( true ); 1614 mNewSubTodoAction->setEnabled( true );
1614 } else { 1615 } else {
1615 mShowAction->setText( i18n("Show...") ); 1616 mShowAction->setText( i18n("Show...") );
1616 mShowAction->setText( i18n("Edit...") ); 1617 mShowAction->setText( i18n("Edit...") );
1617 mShowAction->setText( i18n("Delete...") ); 1618 mShowAction->setText( i18n("Delete...") );
1618 1619
1619 mNewSubTodoAction->setEnabled( false ); 1620 mNewSubTodoAction->setEnabled( false );
1620 } 1621 }
1621} 1622}
1622 1623
1623void MainWindow::enableIncidenceActions( bool enabled ) 1624void MainWindow::enableIncidenceActions( bool enabled )
1624{ 1625{
1625 mShowAction->setEnabled( enabled ); 1626 mShowAction->setEnabled( enabled );
1626 mEditAction->setEnabled( enabled ); 1627 mEditAction->setEnabled( enabled );
1627 mDeleteAction->setEnabled( enabled ); 1628 mDeleteAction->setEnabled( enabled );
1628 1629
1629 mCloneAction->setEnabled( enabled ); 1630 mCloneAction->setEnabled( enabled );
1630 mMoveAction->setEnabled( enabled ); 1631 mMoveAction->setEnabled( enabled );
1631 mBeamAction->setEnabled( enabled ); 1632 mBeamAction->setEnabled( enabled );
1632 mCancelAction->setEnabled( enabled ); 1633 mCancelAction->setEnabled( enabled );
1633} 1634}
1634 1635
1635void MainWindow::importOL() 1636void MainWindow::importOL()
1636{ 1637{
1637#ifdef _OL_IMPORT_ 1638#ifdef _OL_IMPORT_
1638 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1639 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1639 id->exec(); 1640 id->exec();
1640 delete id; 1641 delete id;
1641 mView->updateView(); 1642 mView->updateView();
1642#endif 1643#endif
1643} 1644}
1644void MainWindow::importBday() 1645void MainWindow::importBday()
1645{ 1646{
1646 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1647 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1647 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1648 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1648 i18n("Import!"), i18n("Cancel"), 0, 1649 i18n("Import!"), i18n("Cancel"), 0,
1649 0, 1 ); 1650 0, 1 );
1650 if ( result == 0 ) { 1651 if ( result == 0 ) {
1651 mView->importBday(); 1652 mView->importBday();
1652 1653
1653 } 1654 }
1654 1655
1655 1656
1656} 1657}
1657void MainWindow::importQtopia() 1658void MainWindow::importQtopia()
1658{ 1659{
1659 //#ifndef DESKTOP_VERSION 1660 //#ifndef DESKTOP_VERSION
1660 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1661 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1661#ifdef DESKTOP_VERSION 1662#ifdef DESKTOP_VERSION
1662 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1663 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1663#endif 1664#endif
1664 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1665 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1665 i18n("Import!"), i18n("Cancel"), 0, 1666 i18n("Import!"), i18n("Cancel"), 0,
1666 0, 1 ); 1667 0, 1 );
1667 if ( result == 0 ) { 1668 if ( result == 0 ) {
1668#ifndef DESKTOP_VERSION 1669#ifndef DESKTOP_VERSION
1669 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1670 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1670 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1671 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1671 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1672 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1672#else 1673#else
1673 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1674 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1674 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1675 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1675 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1676 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1676#endif 1677#endif
1677 mView->importQtopia( categories, datebook, todolist ); 1678 mView->importQtopia( categories, datebook, todolist );
1678 } 1679 }
1679#if 0 1680#if 0
1680 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1681 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1681 i18n("Not supported \non desktop!\n"), 1682 i18n("Not supported \non desktop!\n"),
1682 i18n("Ok"), i18n("Cancel"), 0, 1683 i18n("Ok"), i18n("Cancel"), 0,
1683 0, 1 ); 1684 0, 1 );
1684 1685
1685#endif 1686#endif
1686} 1687}
1687 1688
1688void MainWindow::saveOnClose() 1689void MainWindow::saveOnClose()
1689{ 1690{
1690 KOPrefs *p = KOPrefs::instance(); 1691 KOPrefs *p = KOPrefs::instance();
1691 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1692 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1692 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1693 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1693 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1694 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1694 if ( filterToolBar ) { 1695 if ( filterToolBar ) {
1695 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1696 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1696 } 1697 }
1697#ifdef DESKTOP_VERSION 1698#ifdef DESKTOP_VERSION
1698 1699
1699 QPoint myP; 1700 QPoint myP;
1700 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1701 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1701 if ( p->mToolBarHor ) 1702 if ( p->mToolBarHor )
1702 p->mToolBarUp = myP.y() > height()/2; 1703 p->mToolBarUp = myP.y() > height()/2;
1703 else 1704 else
1704 p->mToolBarUp = myP.x() > width()/2; 1705 p->mToolBarUp = myP.x() > width()/2;
1705 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1706 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1706 if ( p->mToolBarHorV ) 1707 if ( p->mToolBarHorV )
1707 p->mToolBarUpV = myP.y() > height()/2; 1708 p->mToolBarUpV = myP.y() > height()/2;
1708 else 1709 else
1709 p->mToolBarUpV = myP.x() > width()/2 ; 1710 p->mToolBarUpV = myP.x() > width()/2 ;
1710 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1711 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1711 if ( p->mToolBarHorN ) 1712 if ( p->mToolBarHorN )
1712 p->mToolBarUpN = myP.y() > height()/2; 1713 p->mToolBarUpN = myP.y() > height()/2;
1713 else 1714 else
1714 p->mToolBarUpN = myP.x() > width()/2 ; 1715 p->mToolBarUpN = myP.x() > width()/2 ;
1715 if ( filterToolBar ) { 1716 if ( filterToolBar ) {
1716 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1717 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1717 if ( p->mToolBarHorF ) 1718 if ( p->mToolBarHorF )
1718 p->mToolBarUpF = myP.y() > height()/2; 1719 p->mToolBarUpF = myP.y() > height()/2;
1719 else 1720 else
1720 p->mToolBarUpF = myP.x() > width()/2 ; 1721 p->mToolBarUpF = myP.x() > width()/2 ;
1721 } 1722 }
1722#else 1723#else
1723 if ( p->mToolBarHor ) 1724 if ( p->mToolBarHor )
1724 p->mToolBarUp = iconToolBar->y() > height()/2; 1725 p->mToolBarUp = iconToolBar->y() > height()/2;
1725 else 1726 else
1726 p->mToolBarUp = iconToolBar->x() > width()/2; 1727 p->mToolBarUp = iconToolBar->x() > width()/2;
1727 if ( p->mToolBarHorV ) 1728 if ( p->mToolBarHorV )
1728 p->mToolBarUpV = viewToolBar->y() > height()/2; 1729 p->mToolBarUpV = viewToolBar->y() > height()/2;
1729 else 1730 else
1730 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1731 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1731 1732
1732 if ( p->mToolBarHorN ) 1733 if ( p->mToolBarHorN )
1733 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1734 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1734 else 1735 else
1735 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1736 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1736 if ( filterToolBar ) { 1737 if ( filterToolBar ) {
1737 if ( p->mToolBarHorF ) 1738 if ( p->mToolBarHorF )
1738 p->mToolBarUpF = filterToolBar->y() > height()/2; 1739 p->mToolBarUpF = filterToolBar->y() > height()/2;
1739 else 1740 else
1740 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1741 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1741 } 1742 }
1742#endif 1743#endif
1743 1744
1744 1745
1745 mView->writeSettings(); 1746 mView->writeSettings();
1746 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1747 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1747 save(); 1748 save();
1748} 1749}
1749void MainWindow::slotModifiedChanged( bool changed ) 1750void MainWindow::slotModifiedChanged( bool changed )
1750{ 1751{
1751 if ( mBlockAtStartup ) 1752 if ( mBlockAtStartup )
1752 return; 1753 return;
1753 1754
1754 int msec; 1755 int msec;
1755 // we store the changes after 1 minute, 1756 // we store the changes after 1 minute,
1756 // and for safety reasons after 10 minutes again 1757 // and for safety reasons after 10 minutes again
1757 if ( !mSyncManager->blockSave() ) 1758 if ( !mSyncManager->blockSave() )
1758 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1759 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1759 else 1760 else
1760 msec = 1000 * 600; 1761 msec = 1000 * 600;
1761 mSaveTimer.start( msec, true ); // 1 minute 1762 mSaveTimer.start( msec, true ); // 1 minute
1762 qDebug("KO: Saving File in %d secs!", msec/1000); 1763 qDebug("KO: Saving File in %d secs!", msec/1000);
1763 mCalendarModifiedFlag = true; 1764 mCalendarModifiedFlag = true;
1764} 1765}
1765void MainWindow::saveStopTimer() 1766void MainWindow::saveStopTimer()
1766{ 1767{
1767 mSaveTimer.stop(); 1768 mSaveTimer.stop();
1768 if (mSaveTimer.isActive() ) 1769 if (mSaveTimer.isActive() )
1769 qDebug("ti active "); 1770 qDebug("ti active ");
1770 else 1771 else
1771 qDebug("KO: Save timer stopped"); 1772 qDebug("KO: Save timer stopped");
1772} 1773}
1773void MainWindow::save() 1774void MainWindow::save()
1774{ 1775{
1775 if ( !mCalendarModifiedFlag ) { 1776 if ( !mCalendarModifiedFlag ) {
1776 qDebug("KO: Calendar not modified. Nothing saved."); 1777 qDebug("KO: Calendar not modified. Nothing saved.");
1777 return; 1778 return;
1778 } 1779 }
1779 if ( mSyncManager->blockSave() ) 1780 if ( mSyncManager->blockSave() )
1780 return; 1781 return;
1781 mSyncManager->setBlockSave(true); 1782 mSyncManager->setBlockSave(true);
1782 if ( mView->checkFileVersion( defaultFileName()) ) { 1783 if ( mView->checkFileVersion( defaultFileName()) ) {
1783 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1784 QTime neededSaveTime = QDateTime::currentDateTime().time();
1784 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1785 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1785 qDebug("KO: Start saving data to file!"); 1786 qDebug("KO: Start saving data to file!");
1786 mView->saveCalendar( defaultFileName() ); 1787 mView->saveCalendar( defaultFileName() );
1787 mCalendarModifiedFlag = false; 1788 mCalendarModifiedFlag = false;
1788 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1789 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1789 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1790 qDebug("KO: Needed %d ms for saving.",msNeeded );
1790 QString savemes; 1791 QString savemes;
1791 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1792 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1792 setCaption(savemes); 1793 setCaption(savemes);
1793 } else 1794 } else
1794 setCaption(i18n("Saving cancelled!")); 1795 setCaption(i18n("Saving cancelled!"));
1795 mSyncManager->setBlockSave( false ); 1796 mSyncManager->setBlockSave( false );
1796} 1797}
1797 1798
1798void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1799void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1799{ 1800{
1800 if ( !e->isAutoRepeat() ) { 1801 if ( !e->isAutoRepeat() ) {
1801 mFlagKeyPressed = false; 1802 mFlagKeyPressed = false;
1802 } 1803 }
1803} 1804}
1804void MainWindow::keyPressEvent ( QKeyEvent * e ) 1805void MainWindow::keyPressEvent ( QKeyEvent * e )
1805{ 1806{
1806 qApp->processEvents(); 1807 qApp->processEvents();
1807 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1808 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1808 e->ignore(); 1809 e->ignore();
1809 // qDebug(" ignore %d",e->isAutoRepeat() ); 1810 // qDebug(" ignore %d",e->isAutoRepeat() );
1810 return; 1811 return;
1811 } 1812 }
1812 if (! e->isAutoRepeat() ) 1813 if (! e->isAutoRepeat() )
1813 mFlagKeyPressed = true; 1814 mFlagKeyPressed = true;
1814 KOPrefs *p = KOPrefs::instance(); 1815 KOPrefs *p = KOPrefs::instance();
1815 bool showSelectedDates = false; 1816 bool showSelectedDates = false;
1816 int size; 1817 int size;
1817 int pro = 0; 1818 int pro = 0;
1818 //qDebug("MainWindow::keyPressEvent "); 1819 //qDebug("MainWindow::keyPressEvent ");
1819 switch ( e->key() ) { 1820 switch ( e->key() ) {
1820 case Qt::Key_Right: 1821 case Qt::Key_Right:
1821 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1822 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1822 mView->goNextMonth(); 1823 mView->goNextMonth();
1823 else 1824 else
1824 mView->goNext(); 1825 mView->goNext();
1825 showSelectedDates = true; 1826 showSelectedDates = true;
1826 break; 1827 break;
1827 case Qt::Key_Left: 1828 case Qt::Key_Left:
1828 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1829 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1829 mView->goPreviousMonth(); 1830 mView->goPreviousMonth();
1830 else 1831 else
1831 mView->goPrevious(); 1832 mView->goPrevious();
1832 showSelectedDates = true; 1833 showSelectedDates = true;
1833 break; 1834 break;
1834 case Qt::Key_Down: 1835 case Qt::Key_Down:
1835 mView->viewManager()->agendaView()->scrollOneHourDown(); 1836 mView->viewManager()->agendaView()->scrollOneHourDown();
1836 break; 1837 break;
1837 case Qt::Key_Up: 1838 case Qt::Key_Up:
1838 mView->viewManager()->agendaView()->scrollOneHourUp(); 1839 mView->viewManager()->agendaView()->scrollOneHourUp();
1839 break; 1840 break;
1840 case Qt::Key_K: 1841 case Qt::Key_K:
1841 mView->viewManager()->showMonthViewWeek(); 1842 mView->viewManager()->showMonthViewWeek();
1842 break; 1843 break;
1843 case Qt::Key_I: 1844 case Qt::Key_I:
1844 mView->showIncidence(); 1845 mView->showIncidence();
1845 break; 1846 break;
1846 case Qt::Key_Delete: 1847 case Qt::Key_Delete:
1847 case Qt::Key_Backspace: 1848 case Qt::Key_Backspace:
1848 mView->deleteIncidence(); 1849 mView->deleteIncidence();
1849 break; 1850 break;
1850 case Qt::Key_D: 1851 case Qt::Key_D:
1851 mView->viewManager()->showDayView(); 1852 mView->viewManager()->showDayView();
1852 showSelectedDates = true; 1853 showSelectedDates = true;
1853 break; 1854 break;
1854 case Qt::Key_O: 1855 case Qt::Key_O:
1855 mView->toggleFilerEnabled( ); 1856 mView->toggleFilerEnabled( );
1856 break; 1857 break;
1857 case Qt::Key_0: 1858 case Qt::Key_0:
1858 case Qt::Key_1: 1859 case Qt::Key_1:
1859 case Qt::Key_2: 1860 case Qt::Key_2:
1860 case Qt::Key_3: 1861 case Qt::Key_3:
1861 case Qt::Key_4: 1862 case Qt::Key_4:
1862 case Qt::Key_5: 1863 case Qt::Key_5:
1863 case Qt::Key_6: 1864 case Qt::Key_6:
1864 case Qt::Key_7: 1865 case Qt::Key_7:
1865 case Qt::Key_8: 1866 case Qt::Key_8:
1866 case Qt::Key_9: 1867 case Qt::Key_9:
1867 pro = e->key()-48; 1868 pro = e->key()-48;
1868 if ( pro == 0 ) 1869 if ( pro == 0 )
1869 pro = 10; 1870 pro = 10;
1870 if ( e->state() == Qt::ControlButton) 1871 if ( e->state() == Qt::ControlButton)
1871 pro += 10; 1872 pro += 10;
1872 break; 1873 break;
1873 case Qt::Key_M: 1874 case Qt::Key_M:
1874 mView->viewManager()->showMonthView(); 1875 mView->viewManager()->showMonthView();
1875 showSelectedDates = true; 1876 showSelectedDates = true;
1876 break; 1877 break;
1877 case Qt::Key_Insert: 1878 case Qt::Key_Insert:
1878 mView->newEvent(); 1879 mView->newEvent();
1879 break; 1880 break;
1880 case Qt::Key_S : 1881 case Qt::Key_S :
1881 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1882 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1882 mView->newSubTodo(); 1883 mView->newSubTodo();
1883 else 1884 else
1884 mView->dialogManager()->showSearchDialog(); 1885 mView->dialogManager()->showSearchDialog();
1885 break; 1886 break;
1886 case Qt::Key_Y : 1887 case Qt::Key_Y :
1887 case Qt::Key_Z : 1888 case Qt::Key_Z :
1888 mView->viewManager()->showWorkWeekView(); 1889 mView->viewManager()->showWorkWeekView();
1889 showSelectedDates = true; 1890 showSelectedDates = true;
1890 break; 1891 break;
1891 case Qt::Key_U : 1892 case Qt::Key_U :
1892 mView->viewManager()->showWeekView(); 1893 mView->viewManager()->showWeekView();
1893 showSelectedDates = true; 1894 showSelectedDates = true;
1894 break; 1895 break;
1895 case Qt::Key_H : 1896 case Qt::Key_H :
1896 keyBindings(); 1897 keyBindings();
1897 break; 1898 break;
1898 case Qt::Key_W: 1899 case Qt::Key_W:
1899 mView->viewManager()->showWhatsNextView(); 1900 mView->viewManager()->showWhatsNextView();
1900 break; 1901 break;
1901 case Qt::Key_L: 1902 case Qt::Key_L:
1902 mView->viewManager()->showListView(); 1903 mView->viewManager()->showListView();
1903 break; 1904 break;
1904 case Qt::Key_N: 1905 case Qt::Key_N:
1905 mView->viewManager()->showNextView(); 1906 mView->viewManager()->showNextView();
1906 break; 1907 break;
1907 case Qt::Key_V: 1908 case Qt::Key_V:
1908 mView->viewManager()->showTodoView(); 1909 mView->viewManager()->showTodoView();
1909 break; 1910 break;
1910 case Qt::Key_C: 1911 case Qt::Key_C:
1911 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1912 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1912 break; 1913 break;
1913 case Qt::Key_P: 1914 case Qt::Key_P:
1914 mView->showDatePicker( ); 1915 mView->showDatePicker( );
1915 break; 1916 break;
1916 case Qt::Key_F: 1917 case Qt::Key_F:
1917 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1918 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1918 mView->editFilters(); 1919 mView->editFilters();
1919 else 1920 else
1920 mView->toggleFilter(); 1921 mView->toggleFilter();
1921 break; 1922 break;
1922 case Qt::Key_X: 1923 case Qt::Key_X:
1923 if ( e->state() == Qt::ControlButton ) 1924 if ( e->state() == Qt::ControlButton )
1924 mView->toggleDateNavigatorWidget(); 1925 mView->toggleDateNavigatorWidget();
1925 else { 1926 else {
1926 mView->viewManager()->showNextXView(); 1927 mView->viewManager()->showNextXView();
1927 showSelectedDates = true; 1928 showSelectedDates = true;
1928 } 1929 }
1929 break; 1930 break;
1930 case Qt::Key_Space: 1931 case Qt::Key_Space:
1931 mView->toggleExpand(); 1932 mView->toggleExpand();
1932 break; 1933 break;
1933 case Qt::Key_A: 1934 case Qt::Key_A:
1934 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1935 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1935 mView->showNextAlarms(); 1936 mView->showNextAlarms();
1936 else 1937 else
1937 mView->toggleAllDaySize(); 1938 mView->toggleAllDaySize();
1938 break; 1939 break;
1939 case Qt::Key_T: 1940 case Qt::Key_T:
1940 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1941 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1941 mView->newTodo(); 1942 mView->newTodo();
1942 else { 1943 else {
1943 mView->goToday(); 1944 mView->goToday();
1944 showSelectedDates = true; 1945 showSelectedDates = true;
1945 } 1946 }
1946 break; 1947 break;
1947 case Qt::Key_J: 1948 case Qt::Key_J:
1948 mView->viewManager()->showJournalView(); 1949 mView->viewManager()->showJournalView();
1949 break; 1950 break;
1950 case Qt::Key_B: 1951 case Qt::Key_B:
1951 mView->editIncidenceDescription();; 1952 mView->editIncidenceDescription();;
1952 break; 1953 break;
1953 // case Qt::Key_Return: 1954 // case Qt::Key_Return:
1954 case Qt::Key_E: 1955 case Qt::Key_E:
1955 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1956 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1956 mView->newEvent(); 1957 mView->newEvent();
1957 else 1958 else
1958 mView->editIncidence(); 1959 mView->editIncidence();
1959 break; 1960 break;
1960 case Qt::Key_Plus: 1961 case Qt::Key_Plus:
1961 size = p->mHourSize +2; 1962 size = p->mHourSize +2;
1962 if ( size <= 22 ) 1963 if ( size <= 22 )
1963 configureAgenda( size ); 1964 configureAgenda( size );
1964 break; 1965 break;
1965 case Qt::Key_Minus: 1966 case Qt::Key_Minus:
1966 size = p->mHourSize - 2; 1967 size = p->mHourSize - 2;
1967 if ( size >= 4 ) 1968 if ( size >= 4 )
1968 configureAgenda( size ); 1969 configureAgenda( size );
1969 break; 1970 break;
1970 1971
1971 1972
1972 default: 1973 default:
1973 e->ignore(); 1974 e->ignore();
1974 } 1975 }
1975 if ( pro > 0 ) { 1976 if ( pro > 0 ) {
1976 mView->selectFilter( pro-1 ); 1977 mView->selectFilter( pro-1 );
1977 } 1978 }
1978 if ( showSelectedDates ) { 1979 if ( showSelectedDates ) {
1979 ;// setCaptionToDates(); 1980 ;// setCaptionToDates();
1980 } 1981 }
1981 1982
1982} 1983}
1983void MainWindow::fillFilterMenuTB() 1984void MainWindow::fillFilterMenuTB()
1984{ 1985{
1985 selectFilterMenuTB->clear(); 1986 selectFilterMenuTB->clear();
1986 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 1987 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
1987 selectFilterMenuTB->insertSeparator(); 1988 selectFilterMenuTB->insertSeparator();
1988 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 1989 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
1989 1990
1990 selectFilterMenuTB->insertSeparator(); 1991 selectFilterMenuTB->insertSeparator();
1991 QPtrList<CalFilter> fili = mView->filters(); 1992 QPtrList<CalFilter> fili = mView->filters();
1992 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1993 CalFilter *curfilter = mView->filterView()->selectedFilter();
1993 CalFilter *filter = fili.first(); 1994 CalFilter *filter = fili.first();
1994 int iii = 2; 1995 int iii = 2;
1995 bool checkitem = mView->filterView()->filtersEnabled(); 1996 bool checkitem = mView->filterView()->filtersEnabled();
1996 while(filter) { 1997 while(filter) {
1997 selectFilterMenuTB->insertItem( filter->name(), iii ); 1998 selectFilterMenuTB->insertItem( filter->name(), iii );
1998 if ( filter == curfilter) 1999 if ( filter == curfilter)
1999 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2000 selectFilterMenuTB->setItemChecked( iii, checkitem );
2000 filter = fili.next(); 2001 filter = fili.next();
2001 ++iii; 2002 ++iii;
2002 } 2003 }
2003 if ( !checkitem ) 2004 if ( !checkitem )
2004 selectFilterMenuTB->setItemChecked( 1, true ); 2005 selectFilterMenuTB->setItemChecked( 1, true );
2005 2006
2006 int x = 0; 2007 int x = 0;
2007 int y = iconToolBar->height(); 2008 int y = iconToolBar->height();
2008 int dX = 0; 2009 int dX = 0;
2009 int dY = 0; 2010 int dY = 0;
2010 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2011 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2011 if ( iconToolBar->y() > height()/2 ) { 2012 if ( iconToolBar->y() > height()/2 ) {
2012 dY = selectFilterMenuTB->sizeHint().height()+8; 2013 dY = selectFilterMenuTB->sizeHint().height()+8;
2013 y = 0; 2014 y = 0;
2014 } 2015 }
2015 } else { 2016 } else {
2016 if ( iconToolBar->x() > width()/2 ) { // right side 2017 if ( iconToolBar->x() > width()/2 ) { // right side
2017 x=0; 2018 x=0;
2018 dX= selectFilterMenuTB->sizeHint().width()+8; 2019 dX= selectFilterMenuTB->sizeHint().width()+8;
2019 y = 0; 2020 y = 0;
2020 } else { 2021 } else {
2021 x= iconToolBar->width(); 2022 x= iconToolBar->width();
2022 y = 0; 2023 y = 0;
2023 } 2024 }
2024 } 2025 }
2025 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2026 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2026 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2027 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2027} 2028}
2028void MainWindow::fillFilterMenu() 2029void MainWindow::fillFilterMenu()
2029{ 2030{
2030 selectFilterMenu->clear(); 2031 selectFilterMenu->clear();
2031 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2032 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2032 selectFilterMenu->insertSeparator(); 2033 selectFilterMenu->insertSeparator();
2033 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2034 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2034 2035
2035 selectFilterMenu->insertSeparator(); 2036 selectFilterMenu->insertSeparator();
2036 QPtrList<CalFilter> fili = mView->filters(); 2037 QPtrList<CalFilter> fili = mView->filters();
2037 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2038 CalFilter *curfilter = mView->filterView()->selectedFilter();
2038 CalFilter *filter = fili.first(); 2039 CalFilter *filter = fili.first();
2039 int iii = 2; 2040 int iii = 2;
2040 bool checkitem = mView->filterView()->filtersEnabled(); 2041 bool checkitem = mView->filterView()->filtersEnabled();
2041 while(filter) { 2042 while(filter) {
2042 selectFilterMenu->insertItem( filter->name(), iii ); 2043 selectFilterMenu->insertItem( filter->name(), iii );
2043 if ( filter == curfilter) 2044 if ( filter == curfilter)
2044 selectFilterMenu->setItemChecked( iii, checkitem ); 2045 selectFilterMenu->setItemChecked( iii, checkitem );
2045 filter = fili.next(); 2046 filter = fili.next();
2046 ++iii; 2047 ++iii;
2047 } 2048 }
2048 if ( !checkitem ) 2049 if ( !checkitem )
2049 selectFilterMenu->setItemChecked( 1, true ); 2050 selectFilterMenu->setItemChecked( 1, true );
2050} 2051}
2051void MainWindow::fillFilterMenuPopup() 2052void MainWindow::fillFilterMenuPopup()
2052{ 2053{
2053 filterPopupMenu->clear(); 2054 filterPopupMenu->clear();
2054 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2055 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2055 2056
2056 filterPopupMenu->insertSeparator(); 2057 filterPopupMenu->insertSeparator();
2057 QPtrList<CalFilter> fili = mView->filters(); 2058 QPtrList<CalFilter> fili = mView->filters();
2058 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2059 CalFilter *curfilter = mView->filterView()->selectedFilter();
2059 CalFilter *filter = fili.first(); 2060 CalFilter *filter = fili.first();
2060 int iii = 1; 2061 int iii = 1;
2061 bool checkitem = mView->filterView()->filtersEnabled(); 2062 bool checkitem = mView->filterView()->filtersEnabled();
2062 while(filter) { 2063 while(filter) {
2063 filterPopupMenu->insertItem( filter->name(), iii ); 2064 filterPopupMenu->insertItem( filter->name(), iii );
2064 if ( filter == curfilter) 2065 if ( filter == curfilter)
2065 filterPopupMenu->setItemChecked( iii, checkitem ); 2066 filterPopupMenu->setItemChecked( iii, checkitem );
2066 filter = fili.next(); 2067 filter = fili.next();
2067 ++iii; 2068 ++iii;
2068 } 2069 }
2069 if ( !checkitem ) 2070 if ( !checkitem )
2070 filterPopupMenu->setItemChecked( 0, true ); 2071 filterPopupMenu->setItemChecked( 0, true );
2071} 2072}
2072void MainWindow::selectFilter( int fil ) 2073void MainWindow::selectFilter( int fil )
2073{ 2074{
2074 2075
2075 if ( fil == 0 ) { 2076 if ( fil == 0 ) {
2076 mView->editFilters( ); 2077 mView->editFilters( );
2077 } else if ( fil == 1 ){ 2078 } else if ( fil == 1 ){
2078 if ( mView->filterView()->filtersEnabled() ) 2079 if ( mView->filterView()->filtersEnabled() )
2079 mView->toggleFilerEnabled( ); 2080 mView->toggleFilerEnabled( );
2080 } else { 2081 } else {
2081 if ( !mView->filterView()->filtersEnabled() ) { 2082 if ( !mView->filterView()->filtersEnabled() ) {
2082 mView->filterView()->blockSignals( true ); 2083 mView->filterView()->blockSignals( true );
2083 mView->toggleFilerEnabled( ); 2084 mView->toggleFilerEnabled( );
2084 mView->filterView()->blockSignals( false ); 2085 mView->filterView()->blockSignals( false );
2085 } 2086 }
2086 mView->selectFilter( fil-2 ); 2087 mView->selectFilter( fil-2 );
2087 } 2088 }
2088} 2089}
2089void MainWindow::updateFilterToolbar() 2090void MainWindow::updateFilterToolbar()
2090{ 2091{
2091 if ( filterMenubar ) { 2092 if ( filterMenubar ) {
2092 if ( !mView->filterView()->filtersEnabled() ) { 2093 if ( !mView->filterView()->filtersEnabled() ) {
2093 filterMenubar->changeItem( 0, i18n("No Filter") ); 2094 filterMenubar->changeItem( 0, i18n("No Filter") );
2094 } else { 2095 } else {
2095 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2096 CalFilter *curfilter = mView->filterView()->selectedFilter();
2096 if ( curfilter ) { 2097 if ( curfilter ) {
2097 filterMenubar->changeItem( 0, curfilter->name() ); 2098 filterMenubar->changeItem( 0, curfilter->name() );
2098 } 2099 }
2099 } 2100 }
2100 } 2101 }
2101} 2102}
2102void MainWindow::selectFilterPopup( int fil ) 2103void MainWindow::selectFilterPopup( int fil )
2103{ 2104{
2104 selectFilter( fil + 1 ); 2105 selectFilter( fil + 1 );
2105 2106
2106} 2107}
2107void MainWindow::configureToolBar( int item ) 2108void MainWindow::configureToolBar( int item )
2108{ 2109{
2109 2110
2110 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2111 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2111 KOPrefs *p = KOPrefs::instance(); 2112 KOPrefs *p = KOPrefs::instance();
2112 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2113 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2113 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2114 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2114 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2115 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2115 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2116 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2116 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2117 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2117 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2118 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2118 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2119 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2119 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2120 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2120 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2121 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2121 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2122 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2122 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2123 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2123 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2124 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2124 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2125 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2125 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2126 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2126 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2127 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2127 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2128 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2128 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2129 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2129 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2130 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2130 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2131 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2131 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2132 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2132 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2133 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2133 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2134 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2134 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2135 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2135 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2136 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2136 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2137 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2137 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2138 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2138 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2139 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2139 // initActions(); 2140 // initActions();
2140} 2141}
2141void MainWindow::setCaption ( const QString & c ) 2142void MainWindow::setCaption ( const QString & c )
2142{ 2143{
2143 QString cap = c; 2144 QString cap = c;
2144 cap.replace( QRegExp("\n"), " " ); 2145 cap.replace( QRegExp("\n"), " " );
2145 cap = cap.stripWhiteSpace(); 2146 cap = cap.stripWhiteSpace();
2146 if ( cap.isEmpty() ) 2147 if ( cap.isEmpty() )
2147 cap = "KO/Pi"; 2148 cap = "KO/Pi";
2148 QWidget::setCaption( cap ); 2149 QWidget::setCaption( cap );
2149} 2150}
2150void MainWindow::setCaptionToDates() 2151void MainWindow::setCaptionToDates()
2151{ 2152{
2152 QString selDates; 2153 QString selDates;
2153 QDate date = mView->startDate(); 2154 QDate date = mView->startDate();
2154 if ( ! date.isValid() ) { 2155 if ( ! date.isValid() ) {
2155 setCaption(""); 2156 setCaption("");
2156 return; 2157 return;
2157 } 2158 }
2158 selDates = KGlobal::locale()->formatDate( date, true); 2159 selDates = KGlobal::locale()->formatDate( date, true);
2159 if (mView->startDate() < mView->endDate() ) 2160 if (mView->startDate() < mView->endDate() )
2160 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2161 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2161 else { 2162 else {
2162 QString addString; 2163 QString addString;
2163 if ( date == QDateTime::currentDateTime().date() ) 2164 if ( date == QDateTime::currentDateTime().date() )
2164 addString = i18n("Today"); 2165 addString = i18n("Today");
2165 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2166 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2166 addString = i18n("Tomorrow"); 2167 addString = i18n("Tomorrow");
2167 if ( !addString.isEmpty() ) 2168 if ( !addString.isEmpty() )
2168 selDates = addString+", "+selDates ; 2169 selDates = addString+", "+selDates ;
2169 } 2170 }
2170 setCaption( i18n("Dates: ") + selDates ); 2171 setCaption( i18n("Dates: ") + selDates );
2171 2172
2172} 2173}
2173void MainWindow::showConfigureAgenda( ) 2174void MainWindow::showConfigureAgenda( )
2174{ 2175{
2175 int iii; 2176 int iii;
2176 for ( iii = 1;iii<= 10 ;++iii ){ 2177 for ( iii = 1;iii<= 10 ;++iii ){
2177 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2178 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2178 } 2179 }
2179 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2180 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2180} 2181}
2181void MainWindow::configureAgenda( int item ) 2182void MainWindow::configureAgenda( int item )
2182{ 2183{
2183 if ( KOPrefs::instance()->mHourSize == item ) 2184 if ( KOPrefs::instance()->mHourSize == item )
2184 return; 2185 return;
2185 KOPrefs::instance()->mHourSize=item; 2186 KOPrefs::instance()->mHourSize=item;
2186 mView->viewManager()->agendaView()->updateConfig(); 2187 mView->viewManager()->agendaView()->updateConfig();
2187} 2188}
2188 2189
2189void MainWindow::saveCalendar() 2190void MainWindow::saveCalendar()
2190{ 2191{
2191 QString fn = KOPrefs::instance()->mLastSaveFile; 2192 QString fn = KOPrefs::instance()->mLastSaveFile;
2192 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 2193 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
2193 2194
2194 if ( fn == "" ) 2195 if ( fn == "" )
2195 return; 2196 return;
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 341a839..db60383 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,417 +1,460 @@
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 <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 searchLabel = new QLabel(topFrame); 58 searchLabel = new QLabel(topFrame);
59 searchLabel->setText(i18n("Search for:")); 59 searchLabel->setText(i18n("Search for:"));
60 subLayout->addWidget(searchLabel); 60 subLayout->addWidget(searchLabel);
61 61
62 searchEdit = new KLineEdit(topFrame); 62 searchEdit = new KLineEdit(topFrame);
63 subLayout->addWidget(searchEdit); 63 subLayout->addWidget(searchEdit);
64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); 64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
65 //OkButton->setDefault( true ); 65 //OkButton->setDefault( true );
66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
67 subLayout->addWidget(OkButton); 67 subLayout->addWidget(OkButton);
68 searchEdit->setText("*"); // Find all events by default 68 searchEdit->setText("*"); // Find all events by default
69 searchEdit->setFocus(); 69 searchEdit->setFocus();
70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
72 // Subjects to search 72 // Subjects to search
73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
74 // topFrame); 74 // topFrame);
75 75
76 QHBox *incidenceGroup = new QHBox( topFrame ); 76 QHBox *incidenceGroup = new QHBox( topFrame );
77 layout->addWidget(incidenceGroup); 77 layout->addWidget(incidenceGroup);
78 78
79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
80 mSearchEvent->setChecked(true); 80 //mSearchEvent->setChecked(true);
81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
83 83
84 QHBox *subjectGroup = new QHBox( topFrame ); 84 QHBox *subjectGroup = new QHBox( topFrame );
85 layout->addWidget(subjectGroup); 85 layout->addWidget(subjectGroup);
86 86
87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
88 mSummaryCheck->setChecked(true); 88 mSummaryCheck->setChecked(true);
89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
91 91
92 QHBox *attendeeGroup = new QHBox( topFrame ); 92 QHBox *attendeeGroup = new QHBox( topFrame );
93 layout->addWidget(attendeeGroup ); 93 layout->addWidget(attendeeGroup );
94 new QLabel( i18n("Attendee:"),attendeeGroup ); 94 new QLabel( i18n("Attendee:"),attendeeGroup );
95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
97 // Date range 97 // Date range
98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
99 // topFrame); 99 // topFrame);
100 // layout->addWidget(rangeGroup); 100 // layout->addWidget(rangeGroup);
101 101
102 QWidget *rangeWidget = new QWidget(topFrame); 102 QWidget *rangeWidget = new QWidget(topFrame);
103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); 103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
105 mStartDate = new KDateEdit(rangeWidget); 105 mStartDate = new KDateEdit(rangeWidget);
106 rangeLayout->addWidget(mStartDate); 106 rangeLayout->addWidget(mStartDate);
107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
108 mEndDate = new KDateEdit(rangeWidget); 108 mEndDate = new KDateEdit(rangeWidget);
109 mEndDate->setDate(QDate::currentDate().addDays(365)); 109 mEndDate->setDate(QDate::currentDate().addDays(365));
110 rangeLayout->addWidget(mEndDate); 110 rangeLayout->addWidget(mEndDate);
111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
112 rangeLayout->addWidget( (QWidget*)wt ); 112 rangeLayout->addWidget( (QWidget*)wt );
113 layout->addWidget(rangeWidget); 113 layout->addWidget(rangeWidget);
114 // Results list view 114 // Results list view
115 listView = new KOListView(mCalendar,topFrame); 115 listView = new KOListView(mCalendar,topFrame);
116 layout->addWidget(listView); 116 layout->addWidget(listView);
117 117
118 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 118 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
120 120
121 setCaption( i18n("KO/Pi Find: ")); 121 setCaption( i18n("KO/Pi Find: "));
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 OkButton = new QPushButton( i18n("Close"), this ); 123 OkButton = new QPushButton( i18n("Close"), this );
124 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 124 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
125#endif 125#endif
126} 126}
127 127
128SearchDialog::~SearchDialog() 128SearchDialog::~SearchDialog()
129{ 129{
130 130
131} 131}
132void SearchDialog::raiseAndSelect()
133{
134
135 static int currentState = 0;
136
137 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
138 currentState = 0;
139 int newState = 0;
140 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
141 newState = VIEW_J_VIEW;
142 }
143 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
144 newState = VIEW_T_VIEW;
145 }
146 else {
147 newState = VIEW_A_VIEW;
148 }
149 if ( newState != currentState ) {
150 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
151 if ( ! mSearchJournal->isChecked() ) {
152 mSearchJournal->setChecked( true );
153 mSearchTodo->setChecked( false );
154 mSearchEvent->setChecked( false );
155 }
156 }
157 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
158 if ( ! mSearchTodo->isChecked() ) {
159 mSearchTodo->setChecked( true );
160 mSearchJournal->setChecked( false );
161 mSearchEvent->setChecked( false );
162 }
163 }
164 else {
165 if ( ! mSearchEvent->isChecked() ) {
166 mSearchEvent->setChecked( true );
167 mSearchJournal->setChecked( false );
168 mSearchTodo->setChecked( false );
169 }
170 }
171 }
172 currentState = newState;
173 raise();
174}
132void SearchDialog::setFocusToList() 175void SearchDialog::setFocusToList()
133{ 176{
134 listView->resetFocus(); 177 listView->resetFocus();
135} 178}
136void SearchDialog::accept() 179void SearchDialog::accept()
137{ 180{
138 doSearch(); 181 doSearch();
139} 182}
140void SearchDialog::updateList() 183void SearchDialog::updateList()
141{ 184{
142 //listView->updateList(); 185 //listView->updateList();
143 if ( isVisible() ) { 186 if ( isVisible() ) {
144 updateView(); 187 updateView();
145 //qDebug("SearchDialog::updated "); 188 //qDebug("SearchDialog::updated ");
146 } 189 }
147 else { 190 else {
148 listView->clear(); 191 listView->clear();
149 //qDebug("SearchDialog::cleared "); 192 //qDebug("SearchDialog::cleared ");
150 193
151 } 194 }
152} 195}
153void SearchDialog::searchTextChanged( const QString &_text ) 196void SearchDialog::searchTextChanged( const QString &_text )
154{ 197{
155#if 0 198#if 0
156 enableButton( KDialogBase::User1, !_text.isEmpty() ); 199 enableButton( KDialogBase::User1, !_text.isEmpty() );
157#endif 200#endif
158} 201}
159 202
160void SearchDialog::doSearch() 203void SearchDialog::doSearch()
161{ 204{
162 QRegExp re; 205 QRegExp re;
163 206
164 re.setWildcard(true); // most people understand these better. 207 re.setWildcard(true); // most people understand these better.
165 re.setCaseSensitive(false); 208 re.setCaseSensitive(false);
166 re.setPattern(searchEdit->text()); 209 re.setPattern(searchEdit->text());
167 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 210 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
168 KMessageBox::sorry(this, 211 KMessageBox::sorry(this,
169 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 212 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
170 return; 213 return;
171 } 214 }
172 if (!re.isValid() ) { 215 if (!re.isValid() ) {
173 KMessageBox::sorry(this, 216 KMessageBox::sorry(this,
174 i18n("Invalid search expression,\ncannot perform " 217 i18n("Invalid search expression,\ncannot perform "
175 "the search.\nPlease enter a search expression\n" 218 "the search.\nPlease enter a search expression\n"
176 "using the wildcard characters\n '*' and '?'" 219 "using the wildcard characters\n '*' and '?'"
177 "where needed.")); 220 "where needed."));
178 return; 221 return;
179 } 222 }
180 223
181 search(re); 224 search(re);
182 225
183 listView->setStartDate( mStartDate->date() ); 226 listView->setStartDate( mStartDate->date() );
184 listView->showEvents(mMatchedEvents); 227 listView->showEvents(mMatchedEvents);
185 listView->addTodos(mMatchedTodos); 228 listView->addTodos(mMatchedTodos);
186 listView->addJournals(mMatchedJournals); 229 listView->addJournals(mMatchedJournals);
187 230
188 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 231 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
189 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 232 setCaption(i18n("No items found. Use '*' and '?' where needed."));
190 } else { 233 } else {
191 QString mess; 234 QString mess;
192 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 235 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
193 setCaption( i18n("KO/Pi Find: ") + mess); 236 setCaption( i18n("KO/Pi Find: ") + mess);
194 237
195 } 238 }
196 searchEdit->setFocus(); 239 searchEdit->setFocus();
197} 240}
198void SearchDialog::updateConfig() 241void SearchDialog::updateConfig()
199{ 242{
200 listView->updateConfig(); 243 listView->updateConfig();
201} 244}
202void SearchDialog::updateView() 245void SearchDialog::updateView()
203{ 246{
204 247 //qDebug("SearchDialog::updateView() %d ", isVisible());
205 QRegExp re; 248 QRegExp re;
206 re.setWildcard(true); // most people understand these better. 249 re.setWildcard(true); // most people understand these better.
207 re.setCaseSensitive(false); 250 re.setCaseSensitive(false);
208 re.setPattern(searchEdit->text()); 251 re.setPattern(searchEdit->text());
209 if (re.isValid()) { 252 if (re.isValid()) {
210 search(re); 253 search(re);
211 } else { 254 } else {
212 mMatchedEvents.clear(); 255 mMatchedEvents.clear();
213 mMatchedTodos.clear(); 256 mMatchedTodos.clear();
214 mMatchedJournals.clear(); 257 mMatchedJournals.clear();
215 } 258 }
216 listView->setStartDate( mStartDate->date() ); 259 listView->setStartDate( mStartDate->date() );
217 listView->showEvents(mMatchedEvents); 260 listView->showEvents(mMatchedEvents);
218 listView->addTodos(mMatchedTodos); 261 listView->addTodos(mMatchedTodos);
219 listView->addJournals(mMatchedJournals); 262 listView->addJournals(mMatchedJournals);
220} 263}
221 264
222void SearchDialog::search(const QRegExp &re) 265void SearchDialog::search(const QRegExp &re)
223{ 266{
224 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 267 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
225 mEndDate->date(), 268 mEndDate->date(),
226 false /*mInclusiveCheck->isChecked()*/ ); 269 false /*mInclusiveCheck->isChecked()*/ );
227 270
228 mMatchedEvents.clear(); 271 mMatchedEvents.clear();
229 if ( mSearchEvent->isChecked() ) { 272 if ( mSearchEvent->isChecked() ) {
230 Event *ev; 273 Event *ev;
231 for(ev=events.first();ev;ev=events.next()) { 274 for(ev=events.first();ev;ev=events.next()) {
232 if (mSummaryCheck->isChecked()) { 275 if (mSummaryCheck->isChecked()) {
233#if QT_VERSION >= 0x030000 276#if QT_VERSION >= 0x030000
234 if (re.search(ev->summary()) != -1) 277 if (re.search(ev->summary()) != -1)
235#else 278#else
236 if (re.match(ev->summary()) != -1) 279 if (re.match(ev->summary()) != -1)
237#endif 280#endif
238 { 281 {
239 mMatchedEvents.append(ev); 282 mMatchedEvents.append(ev);
240 continue; 283 continue;
241 } 284 }
242#if QT_VERSION >= 0x030000 285#if QT_VERSION >= 0x030000
243 if (re.search(ev->location()) != -1) 286 if (re.search(ev->location()) != -1)
244#else 287#else
245 if (re.match(ev->location()) != -1) 288 if (re.match(ev->location()) != -1)
246#endif 289#endif
247 { 290 {
248 mMatchedEvents.append(ev); 291 mMatchedEvents.append(ev);
249 continue; 292 continue;
250 } 293 }
251 } 294 }
252 if (mDescriptionCheck->isChecked()) { 295 if (mDescriptionCheck->isChecked()) {
253#if QT_VERSION >= 0x030000 296#if QT_VERSION >= 0x030000
254 if (re.search(ev->description()) != -1) 297 if (re.search(ev->description()) != -1)
255#else 298#else
256 if (re.match(ev->description()) != -1) 299 if (re.match(ev->description()) != -1)
257#endif 300#endif
258 { 301 {
259 mMatchedEvents.append(ev); 302 mMatchedEvents.append(ev);
260 continue; 303 continue;
261 } 304 }
262 } 305 }
263 if (mCategoryCheck->isChecked()) { 306 if (mCategoryCheck->isChecked()) {
264#if QT_VERSION >= 0x030000 307#if QT_VERSION >= 0x030000
265 if (re.search(ev->categoriesStr()) != -1) 308 if (re.search(ev->categoriesStr()) != -1)
266#else 309#else
267 if (re.match(ev->categoriesStr()) != -1) 310 if (re.match(ev->categoriesStr()) != -1)
268#endif 311#endif
269 { 312 {
270 mMatchedEvents.append(ev); 313 mMatchedEvents.append(ev);
271 continue; 314 continue;
272 } 315 }
273 } 316 }
274 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 317 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
275 QPtrList<Attendee> tmpAList = ev->attendees(); 318 QPtrList<Attendee> tmpAList = ev->attendees();
276 Attendee *a; 319 Attendee *a;
277 for (a = tmpAList.first(); a; a = tmpAList.next()) { 320 for (a = tmpAList.first(); a; a = tmpAList.next()) {
278 if (mSearchAName->isChecked()) { 321 if (mSearchAName->isChecked()) {
279#if QT_VERSION >= 0x030000 322#if QT_VERSION >= 0x030000
280 if (re.search(a->name()) != -1) 323 if (re.search(a->name()) != -1)
281#else 324#else
282 if (re.match(a->name()) != -1) 325 if (re.match(a->name()) != -1)
283#endif 326#endif
284 { 327 {
285 mMatchedEvents.append(ev); 328 mMatchedEvents.append(ev);
286 break; 329 break;
287 } 330 }
288 } 331 }
289 if (mSearchAEmail->isChecked()) { 332 if (mSearchAEmail->isChecked()) {
290#if QT_VERSION >= 0x030000 333#if QT_VERSION >= 0x030000
291 if (re.search(a->email()) != -1) 334 if (re.search(a->email()) != -1)
292#else 335#else
293 if (re.match(a->email()) != -1) 336 if (re.match(a->email()) != -1)
294#endif 337#endif
295 { 338 {
296 mMatchedEvents.append(ev); 339 mMatchedEvents.append(ev);
297 break; 340 break;
298 } 341 }
299 } 342 }
300 } 343 }
301 } 344 }
302 } 345 }
303 } 346 }
304 QPtrList<Todo> todos = mCalendar->todos( ); 347 QPtrList<Todo> todos = mCalendar->todos( );
305 mMatchedTodos.clear(); 348 mMatchedTodos.clear();
306 if ( mSearchTodo->isChecked() ) { 349 if ( mSearchTodo->isChecked() ) {
307 Todo *tod; 350 Todo *tod;
308 for(tod=todos.first();tod;tod=todos.next()) { 351 for(tod=todos.first();tod;tod=todos.next()) {
309 if (mSummaryCheck->isChecked()) { 352 if (mSummaryCheck->isChecked()) {
310#if QT_VERSION >= 0x030000 353#if QT_VERSION >= 0x030000
311 if (re.search(tod->summary()) != -1) 354 if (re.search(tod->summary()) != -1)
312#else 355#else
313 if (re.match(tod->summary()) != -1) 356 if (re.match(tod->summary()) != -1)
314#endif 357#endif
315 { 358 {
316 mMatchedTodos.append(tod); 359 mMatchedTodos.append(tod);
317 continue; 360 continue;
318 } 361 }
319 } 362 }
320 if (mDescriptionCheck->isChecked()) { 363 if (mDescriptionCheck->isChecked()) {
321#if QT_VERSION >= 0x030000 364#if QT_VERSION >= 0x030000
322 if (re.search(tod->description()) != -1) 365 if (re.search(tod->description()) != -1)
323#else 366#else
324 if (re.match(tod->description()) != -1) 367 if (re.match(tod->description()) != -1)
325#endif 368#endif
326 { 369 {
327 mMatchedTodos.append(tod); 370 mMatchedTodos.append(tod);
328 continue; 371 continue;
329 } 372 }
330 } 373 }
331 if (mCategoryCheck->isChecked()) { 374 if (mCategoryCheck->isChecked()) {
332#if QT_VERSION >= 0x030000 375#if QT_VERSION >= 0x030000
333 if (re.search(tod->categoriesStr()) != -1) 376 if (re.search(tod->categoriesStr()) != -1)
334#else 377#else
335 if (re.match(tod->categoriesStr()) != -1) 378 if (re.match(tod->categoriesStr()) != -1)
336#endif 379#endif
337 { 380 {
338 mMatchedTodos.append(tod); 381 mMatchedTodos.append(tod);
339 continue; 382 continue;
340 } 383 }
341 } 384 }
342 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 385 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
343 QPtrList<Attendee> tmpAList = tod->attendees(); 386 QPtrList<Attendee> tmpAList = tod->attendees();
344 Attendee *a; 387 Attendee *a;
345 for (a = tmpAList.first(); a; a = tmpAList.next()) { 388 for (a = tmpAList.first(); a; a = tmpAList.next()) {
346 if (mSearchAName->isChecked()) { 389 if (mSearchAName->isChecked()) {
347#if QT_VERSION >= 0x030000 390#if QT_VERSION >= 0x030000
348 if (re.search(a->name()) != -1) 391 if (re.search(a->name()) != -1)
349#else 392#else
350 if (re.match(a->name()) != -1) 393 if (re.match(a->name()) != -1)
351#endif 394#endif
352 { 395 {
353 mMatchedTodos.append(tod); 396 mMatchedTodos.append(tod);
354 break; 397 break;
355 } 398 }
356 } 399 }
357 if (mSearchAEmail->isChecked()) { 400 if (mSearchAEmail->isChecked()) {
358#if QT_VERSION >= 0x030000 401#if QT_VERSION >= 0x030000
359 if (re.search(a->email()) != -1) 402 if (re.search(a->email()) != -1)
360#else 403#else
361 if (re.match(a->email()) != -1) 404 if (re.match(a->email()) != -1)
362#endif 405#endif
363 { 406 {
364 mMatchedTodos.append(tod); 407 mMatchedTodos.append(tod);
365 break; 408 break;
366 } 409 }
367 } 410 }
368 } 411 }
369 } 412 }
370 } 413 }
371 } 414 }
372 mMatchedJournals.clear(); 415 mMatchedJournals.clear();
373 if (mSearchJournal->isChecked() ) { 416 if (mSearchJournal->isChecked() ) {
374 QPtrList<Journal> journals = mCalendar->journals( ); 417 QPtrList<Journal> journals = mCalendar->journals( );
375 Journal* journ; 418 Journal* journ;
376 419
377 for(journ=journals.first();journ;journ=journals.next()) { 420 for(journ=journals.first();journ;journ=journals.next()) {
378 if ( journ->dtStart().date() <= mEndDate->date() 421 if ( journ->dtStart().date() <= mEndDate->date()
379 &&journ->dtStart().date() >= mStartDate->date()) { 422 &&journ->dtStart().date() >= mStartDate->date()) {
380#if QT_VERSION >= 0x030000 423#if QT_VERSION >= 0x030000
381 if (re.search(journ->description()) != -1) 424 if (re.search(journ->description()) != -1)
382#else 425#else
383 if (re.match(journ->description()) != -1) 426 if (re.match(journ->description()) != -1)
384#endif 427#endif
385 { 428 {
386 mMatchedJournals.append(journ); 429 mMatchedJournals.append(journ);
387 continue; 430 continue;
388 } 431 }
389 } 432 }
390 } 433 }
391 } 434 }
392 435
393} 436}
394 437
395void SearchDialog::keyPressEvent ( QKeyEvent *e) 438void SearchDialog::keyPressEvent ( QKeyEvent *e)
396{ 439{
397 switch ( e->key() ) { 440 switch ( e->key() ) {
398 case Qt::Key_Escape: 441 case Qt::Key_Escape:
399 hide(); 442 hide();
400 break; 443 break;
401 case Qt::Key_F: 444 case Qt::Key_F:
402 if ( e->state() == Qt::ControlButton ) { 445 if ( e->state() == Qt::ControlButton ) {
403 qDebug("full "); 446 qDebug("full ");
404 447
405 } 448 }
406 break; 449 break;
407 case Qt::Key_Return: 450 case Qt::Key_Return:
408 case Qt::Key_Enter: 451 case Qt::Key_Enter:
409 doSearch(); 452 doSearch();
410 break; 453 break;
411 454
412 default: 455 default:
413 e->ignore(); 456 e->ignore();
414 } 457 }
415} 458}
416 459
417//mMatchedJournals; 460//mMatchedJournals;
diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h
index b730ed5..4559d20 100644
--- a/korganizer/searchdialog.h
+++ b/korganizer/searchdialog.h
@@ -1,94 +1,95 @@
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#ifndef SEARCHDIALOG_H 24#ifndef SEARCHDIALOG_H
25#define SEARCHDIALOG_H 25#define SEARCHDIALOG_H
26 26
27#include <qregexp.h> 27#include <qregexp.h>
28 28
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30#include <qvbox.h> 30#include <qvbox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33 33
34#include "kolistview.h" 34#include "kolistview.h"
35 35
36class KDateEdit; 36class KDateEdit;
37class QCheckBox; 37class QCheckBox;
38class QLineEdit; 38class QLineEdit;
39class KLineEdit; 39class KLineEdit;
40class QLabel; 40class QLabel;
41class CalendarView; 41class CalendarView;
42 42
43using namespace KCal; 43using namespace KCal;
44class SearchDialog : public QVBox 44class SearchDialog : public QVBox
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 SearchDialog(Calendar *calendar,CalendarView *parent=0); 48 SearchDialog(Calendar *calendar,CalendarView *parent=0);
49 virtual ~SearchDialog(); 49 virtual ~SearchDialog();
50 KOListView *listview(){ return listView;} 50 KOListView *listview(){ return listView;}
51 void updateView(); 51 void updateView();
52 void raiseAndSelect();
52 53
53 public slots: 54 public slots:
54 void changeEventDisplay(Event *, int) { updateView(); } 55 void changeEventDisplay(Event *, int) { updateView(); }
55 void updateConfig(); 56 void updateConfig();
56 void updateList(); 57 void updateList();
57 protected slots: 58 protected slots:
58 void setFocusToList(); 59 void setFocusToList();
59 void accept(); 60 void accept();
60 void doSearch(); 61 void doSearch();
61 void searchTextChanged( const QString &_text ); 62 void searchTextChanged( const QString &_text );
62 63
63 signals: 64 signals:
64 void showEventSignal(Event *); 65 void showEventSignal(Event *);
65 void editEventSignal(Event *); 66 void editEventSignal(Event *);
66 void deleteEventSignal(Event *); 67 void deleteEventSignal(Event *);
67 68
68 private: 69 private:
69 void search(const QRegExp &); 70 void search(const QRegExp &);
70 71
71 Calendar *mCalendar; 72 Calendar *mCalendar;
72 73
73 QPtrList<Event> mMatchedEvents; 74 QPtrList<Event> mMatchedEvents;
74 QPtrList<Todo> mMatchedTodos; 75 QPtrList<Todo> mMatchedTodos;
75 QPtrList<Journal> mMatchedJournals; 76 QPtrList<Journal> mMatchedJournals;
76 77
77 QLabel *searchLabel; 78 QLabel *searchLabel;
78 KLineEdit *searchEdit; 79 KLineEdit *searchEdit;
79 KOListView *listView; 80 KOListView *listView;
80 81
81 KDateEdit *mStartDate; 82 KDateEdit *mStartDate;
82 KDateEdit *mEndDate; 83 KDateEdit *mEndDate;
83 QCheckBox *mSummaryCheck; 84 QCheckBox *mSummaryCheck;
84 QCheckBox *mDescriptionCheck; 85 QCheckBox *mDescriptionCheck;
85 QCheckBox *mCategoryCheck; 86 QCheckBox *mCategoryCheck;
86 QCheckBox *mSearchEvent; 87 QCheckBox *mSearchEvent;
87 QCheckBox *mSearchTodo; 88 QCheckBox *mSearchTodo;
88 QCheckBox *mSearchJournal; 89 QCheckBox *mSearchJournal;
89 QCheckBox *mSearchAName; 90 QCheckBox *mSearchAName;
90 QCheckBox *mSearchAEmail; 91 QCheckBox *mSearchAEmail;
91 void keyPressEvent ( QKeyEvent *e) ; 92 void keyPressEvent ( QKeyEvent *e) ;
92}; 93};
93 94
94#endif 95#endif
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index c60b566..029f14b 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -1,1652 +1,1657 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 0x030000 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "qptrlist.h"
42#include "qmemarray.h" 42#include "qmemarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define QPtrList QList
47#define QMemArray QArray 47#define QMemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobjectlist.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#ifndef KDGANTT_MASTER_CVS 55#ifndef KDGANTT_MASTER_CVS
56//#include "KDGanttMinimizeSplitter.moc" 56//#include "KDGanttMinimizeSplitter.moc"
57#endif 57#endif
58 58
59 59
60 60
61#ifndef DOXYGEN_SKIP_INTERNAL 61#ifndef DOXYGEN_SKIP_INTERNAL
62 62
63#if QT_VERSION >= 232 63#if QT_VERSION >= 232
64static int mouseOffset; 64static int mouseOffset;
65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
66 66
67 67
68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
69 KDGanttMinimizeSplitter *parent, const char * name ) 69 KDGanttMinimizeSplitter *parent, const char * name )
70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) 70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
71{ 71{
72 72
73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { 73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
74 mSizeHint = QSize(7,7); 74 mSizeHint = QSize(7,7);
75 mUseOffset = true; 75 mUseOffset = true;
76 } else { 76 } else {
77 mSizeHint = QSize(6,6); 77 mSizeHint = QSize(6,6);
78 mUseOffset = false; 78 mUseOffset = false;
79 } 79 }
80 s = parent; 80 s = parent;
81 setOrientation(o); 81 setOrientation(o);
82 setMouseTracking( true ); 82 setMouseTracking( true );
83 mMouseDown = false; 83 mMouseDown = false;
84 //setMaximumHeight( 5 ); // test only 84 //setMaximumHeight( 5 ); // test only
85} 85}
86 86
87QSize KDGanttSplitterHandle::sizeHint() const 87QSize KDGanttSplitterHandle::sizeHint() const
88{ 88{
89 return mSizeHint; 89 return mSizeHint;
90} 90}
91 91
92void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 92void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
93{ 93{
94 orient = o; 94 orient = o;
95#ifndef QT_NO_CURSOR 95#ifndef QT_NO_CURSOR
96 if ( o == KDGanttMinimizeSplitter::Horizontal ) 96 if ( o == KDGanttMinimizeSplitter::Horizontal )
97 setCursor( splitHCursor ); 97 setCursor( splitHCursor );
98 else 98 else
99 setCursor( splitVCursor ); 99 setCursor( splitVCursor );
100#endif 100#endif
101} 101}
102 102
103 103
104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
105{ 105{
106 updateCursor( e->pos() ); 106 updateCursor( e->pos() );
107 if ( !(e->state()&LeftButton) ) 107 if ( !(e->state()&LeftButton) )
108 return; 108 return;
109 109
110 if ( _activeButton != 0) 110 if ( _activeButton != 0)
111 return; 111 return;
112 112
113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
114 - mouseOffset; 114 - mouseOffset;
115 if ( true /*opaque()*/ ) { 115 if ( opaque() ) {
116 s->moveSplitter( pos, id() ); 116 s->moveSplitter( pos, id() );
117 } else { 117 } else {
118 int min = pos; int max = pos; 118 int min = pos; int max = pos;
119 s->getRange( id(), &min, &max ); 119 s->getRange( id(), &min, &max );
120 s->setRubberband( QMAX( min, QMIN(max, pos ))); 120 s->setRubberband( QMAX( min, QMIN(max, pos )));
121 } 121 }
122 _collapsed = false; 122 _collapsed = false;
123} 123}
124 124
125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
126{ 126{
127 if ( e->button() == LeftButton ) { 127 if ( e->button() == LeftButton ) {
128 _activeButton = onButton( e->pos() ); 128 _activeButton = onButton( e->pos() );
129 mouseOffset = s->pick(e->pos()); 129 mouseOffset = s->pick(e->pos());
130 mMouseDown = true; 130 mMouseDown = true;
131 repaint(); 131 repaint();
132 updateCursor( e->pos() ); 132 updateCursor( e->pos() );
133 } 133 }
134} 134}
135 135
136void KDGanttSplitterHandle::updateCursor( const QPoint& p) 136void KDGanttSplitterHandle::updateCursor( const QPoint& p)
137{ 137{
138 if ( onButton( p ) != 0 ) { 138 if ( onButton( p ) != 0 ) {
139 setCursor( arrowCursor ); 139 setCursor( arrowCursor );
140 } 140 }
141 else { 141 else {
142 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 142 if ( orient == KDGanttMinimizeSplitter::Horizontal )
143 setCursor( splitHCursor ); 143 setCursor( splitHCursor );
144 else 144 else
145 setCursor( splitVCursor ); 145 setCursor( splitVCursor );
146 } 146 }
147} 147}
148void KDGanttSplitterHandle::toggle() 148void KDGanttSplitterHandle::toggle()
149{ 149{
150 int pos; 150 int pos;
151 int min, max; 151 int min, max;
152 if ( !_collapsed ) { 152 if ( !_collapsed ) {
153 s->expandPos( id(), &min, &max ); 153 s->expandPos( id(), &min, &max );
154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
156 pos = min; 156 pos = min;
157 } 157 }
158 else { 158 else {
159 pos = max; 159 pos = max;
160 } 160 }
161 161
162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
163 s->moveSplitter( pos, id() ); 163 s->moveSplitter( pos, id() );
164 _collapsed = true; 164 _collapsed = true;
165 } 165 }
166 else { 166 else {
167 s->moveSplitter( _origPos, id() ); 167 s->moveSplitter( _origPos, id() );
168 _collapsed = false; 168 _collapsed = false;
169 } 169 }
170 repaint(); 170 repaint();
171} 171}
172 172
173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
174{ 174{
175 mMouseDown = false; 175 mMouseDown = false;
176 if ( _activeButton != 0 ) { 176 if ( _activeButton != 0 ) {
177 if ( onButton( e->pos() ) == _activeButton ) 177 if ( onButton( e->pos() ) == _activeButton )
178 { 178 {
179 toggle(); 179 toggle();
180 } 180 }
181 _activeButton = 0; 181 _activeButton = 0;
182 updateCursor( e->pos() ); 182 updateCursor( e->pos() );
183 } 183 }
184 else { 184 else {
185 if ( !opaque() && e->button() == LeftButton ) { 185 if ( !opaque() && e->button() == LeftButton ) {
186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
187 - mouseOffset; 187 - mouseOffset;
188 s->setRubberband( -1 ); 188 s->setRubberband( -1 );
189 s->moveSplitter( pos, id() ); 189 s->moveSplitter( pos, id() );
190 } 190 }
191 } 191 }
192 repaint(); 192 repaint();
193} 193}
194 194
195int KDGanttSplitterHandle::onButton( const QPoint& p ) 195int KDGanttSplitterHandle::onButton( const QPoint& p )
196{ 196{
197 QValueList<QPointArray> list = buttonRegions(); 197 QValueList<QPointArray> list = buttonRegions();
198 int index = 1; 198 int index = 1;
199 int add = 12; 199 int add = 12;
200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
201 QRect rect = (*it).boundingRect(); 201 QRect rect = (*it).boundingRect();
202 rect.setLeft( rect.left()- add ); 202 rect.setLeft( rect.left()- add );
203 rect.setRight( rect.right() + add); 203 rect.setRight( rect.right() + add);
204 rect.setTop( rect.top()- add ); 204 rect.setTop( rect.top()- add );
205 rect.setBottom( rect.bottom() + add); 205 rect.setBottom( rect.bottom() + add);
206 if ( rect.contains( p ) ) { 206 if ( rect.contains( p ) ) {
207 return index; 207 return index;
208 } 208 }
209 index++; 209 index++;
210 } 210 }
211 return 0; 211 return 0;
212} 212}
213 213
214 214
215QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 215QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions()
216{ 216{
217 QValueList<QPointArray> list; 217 QValueList<QPointArray> list;
218 218
219 int sw = 8; 219 int sw = 8;
220 int yyy = 1; 220 int yyy = 1;
221 int xxx = 1; 221 int xxx = 1;
222 int voffset[] = { (int) -sw*3, (int) sw*3 }; 222 int voffset[] = { (int) -sw*3, (int) sw*3 };
223 for ( int i = 0; i < 2; i++ ) { 223 for ( int i = 0; i < 2; i++ ) {
224 QPointArray arr; 224 QPointArray arr;
225 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 225 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
226 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 226 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
227 int mid = height()/2 + voffset[i]; 227 int mid = height()/2 + voffset[i];
228 arr.setPoints( 3, 228 arr.setPoints( 3,
229 1-xxx, mid - sw + 4, 229 1-xxx, mid - sw + 4,
230 sw-3-xxx, mid, 230 sw-3-xxx, mid,
231 1-xxx, mid + sw -4); 231 1-xxx, mid + sw -4);
232 } 232 }
233 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 233 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
234 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 234 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
235 int mid = height()/2 + voffset[i]; 235 int mid = height()/2 + voffset[i];
236 arr.setPoints( 3, 236 arr.setPoints( 3,
237 sw-4, mid - sw + 4, 237 sw-4, mid - sw + 4,
238 0, mid, 238 0, mid,
239 sw-4, mid + sw - 4); 239 sw-4, mid + sw - 4);
240 } 240 }
241 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 241 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
242 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { 242 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
243 int mid = width()/2 + voffset[i]; 243 int mid = width()/2 + voffset[i];
244 arr.setPoints( 3, 244 arr.setPoints( 3,
245 mid - sw + 4, sw-4, 245 mid - sw + 4, sw-4,
246 mid, 0, 246 mid, 0,
247 mid + sw - 4, sw-4 ); 247 mid + sw - 4, sw-4 );
248 } 248 }
249 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || 249 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
250 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 250 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
251 int mid = width()/2 + voffset[i]; 251 int mid = width()/2 + voffset[i];
252 arr.setPoints( 3, 252 arr.setPoints( 3,
253 mid - sw + 4, 1-yyy, 253 mid - sw + 4, 1-yyy,
254 mid, sw-3-yyy, 254 mid, sw-3-yyy,
255 mid + sw -4, 1-yyy); 255 mid + sw -4, 1-yyy);
256 } 256 }
257 list.append( arr ); 257 list.append( arr );
258 } 258 }
259 return list; 259 return list;
260} 260}
261 261
262void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) 262void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
263{ 263{
264 QPixmap buffer( size() ); 264 QPixmap buffer( size() );
265 QPainter p( &buffer ); 265 QPainter p( &buffer );
266 266
267 //LR 267 //LR
268 // Draw the splitter rectangle 268 // Draw the splitter rectangle
269 p.setBrush( colorGroup().background() ); 269 p.setBrush( colorGroup().background() );
270 p.setPen( colorGroup().foreground() ); 270 p.setPen( colorGroup().foreground() );
271 //p.drawRect( rect() ); 271 //p.drawRect( rect() );
272 buffer.fill( colorGroup().background() ); 272 buffer.fill( colorGroup().background() );
273 //buffer.fill( backgroundColor() ); 273 //buffer.fill( backgroundColor() );
274 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); 274 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
275 275
276 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size 276 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
277 277
278 // arrow color 278 // arrow color
279 QColor col; 279 QColor col;
280 if ( _activeButton ) 280 if ( _activeButton )
281 col = colorGroup().background().dark( 250 ); 281 col = colorGroup().background().dark( 250 );
282 else { 282 else {
283 if ( mMouseDown ) 283 if ( mMouseDown )
284 col = Qt::white; 284 col = Qt::white;
285 else 285 else
286 col = colorGroup().background().dark( 150 ); 286 col = colorGroup().background().dark( 150 );
287 } 287 }
288 //QColor col = backgroundColor().dark( 130 ); 288 //QColor col = backgroundColor().dark( 130 );
289 p.setBrush( col ); 289 p.setBrush( col );
290 p.setPen( col ); 290 p.setPen( col );
291 291
292 QValueList<QPointArray> list = buttonRegions(); 292 QValueList<QPointArray> list = buttonRegions();
293 int index = 1; 293 int index = 1;
294 if ( mUseOffset ) 294 if ( mUseOffset )
295 p.translate( 0, 1 ); 295 p.translate( 0, 1 );
296 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 296 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
297 if ( index == _activeButton ) { 297 if ( index == _activeButton ) {
298 298
299 /* 299 /*
300 if ( ! _collapsed ) { 300 if ( ! _collapsed ) {
301 p.save(); 301 p.save();
302 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), 302 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
303 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); 303 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
304 p.translate( -1, 0 ); 304 p.translate( -1, 0 );
305 p.drawPolygon( *it, true ); 305 p.drawPolygon( *it, true );
306 p.restore(); } else 306 p.restore(); } else
307 */ 307 */
308 p.drawPolygon( *it, true ); 308 p.drawPolygon( *it, true );
309 309
310 } 310 }
311 else { 311 else {
312 /* 312 /*
313 if ( ! _collapsed ) { 313 if ( ! _collapsed ) {
314 p.save(); 314 p.save();
315 p.translate( -1, 0 ); 315 p.translate( -1, 0 );
316 p.drawPolygon( *it, true ); 316 p.drawPolygon( *it, true );
317 p.restore(); 317 p.restore();
318 } else 318 } else
319 */ 319 */
320 p.drawPolygon( *it, true ); 320 p.drawPolygon( *it, true );
321 321
322 } 322 }
323 index++; 323 index++;
324 } 324 }
325 325
326 // Draw the lines between the arrows 326 // Draw the lines between the arrows
327 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 327 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
328 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 328 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
329 int mid = height()/2; 329 int mid = height()/2;
330 p.drawLine ( 1, mid - sw, 1, mid + sw ); 330 p.drawLine ( 1, mid - sw, 1, mid + sw );
331 p.drawLine ( 3, mid - sw, 3, mid + sw ); 331 p.drawLine ( 3, mid - sw, 3, mid + sw );
332 } 332 }
333 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 333 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
334 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { 334 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
335 int mid = width()/2; 335 int mid = width()/2;
336 p.drawLine( mid -sw, 1, mid +sw, 1 ); 336 p.drawLine( mid -sw, 1, mid +sw, 1 );
337 p.drawLine( mid -sw, 3, mid +sw, 3 ); 337 p.drawLine( mid -sw, 3, mid +sw, 3 );
338 } 338 }
339 bitBlt( this, 0, 0, &buffer ); 339 bitBlt( this, 0, 0, &buffer );
340 340
341} 341}
342#endif 342#endif
343 343
344class QSplitterLayoutStruct 344class QSplitterLayoutStruct
345{ 345{
346public: 346public:
347 KDGanttMinimizeSplitter::ResizeMode mode; 347 KDGanttMinimizeSplitter::ResizeMode mode;
348 QCOORD sizer; 348 QCOORD sizer;
349 bool isSplitter; 349 bool isSplitter;
350 QWidget *wid; 350 QWidget *wid;
351}; 351};
352 352
353class QSplitterData 353class QSplitterData
354{ 354{
355public: 355public:
356 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 356 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
357 357
358 QPtrList<QSplitterLayoutStruct> list; 358 QPtrList<QSplitterLayoutStruct> list;
359 bool opaque; 359 bool opaque;
360 bool firstShow; 360 bool firstShow;
361}; 361};
362 362
363void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 363void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
364 int space, int spacer ); 364 int space, int spacer );
365#endif // DOXYGEN_SKIP_INTERNAL 365#endif // DOXYGEN_SKIP_INTERNAL
366 366
367 367
368/*! 368/*!
369 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 369 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
370 \brief The KDGanttMinimizeSplitter class implements a splitter 370 \brief The KDGanttMinimizeSplitter class implements a splitter
371 widget with minimize buttons. 371 widget with minimize buttons.
372 372
373 This class (and its documentation) is largely a copy of Qt's 373 This class (and its documentation) is largely a copy of Qt's
374 QSplitter; the copying was necessary because QSplitter is not 374 QSplitter; the copying was necessary because QSplitter is not
375 extensible at all. QSplitter and its documentation are licensed 375 extensible at all. QSplitter and its documentation are licensed
376 according to the GPL and the Qt Professional License (if you hold 376 according to the GPL and the Qt Professional License (if you hold
377 such a license) and are (C) Trolltech AS. 377 such a license) and are (C) Trolltech AS.
378 378
379 A splitter lets the user control the size of child widgets by 379 A splitter lets the user control the size of child widgets by
380 dragging the boundary between the children. Any number of widgets 380 dragging the boundary between the children. Any number of widgets
381 may be controlled. 381 may be controlled.
382 382
383 To show a QListBox, a QListView and a QTextEdit side by side: 383 To show a QListBox, a QListView and a QTextEdit side by side:
384 384
385 \code 385 \code
386 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 386 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
387 QListBox *lb = new QListBox( split ); 387 QListBox *lb = new QListBox( split );
388 QListView *lv = new QListView( split ); 388 QListView *lv = new QListView( split );
389 QTextEdit *ed = new QTextEdit( split ); 389 QTextEdit *ed = new QTextEdit( split );
390 \endcode 390 \endcode
391 391
392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
393 vertical. The default is horizontal (the children are side by side) 393 vertical. The default is horizontal (the children are side by side)
394 but you can use setOrientation( QSplitter::Vertical ) to set it to 394 but you can use setOrientation( QSplitter::Vertical ) to set it to
395 vertical. 395 vertical.
396 396
397 Use setResizeMode() to specify 397 Use setResizeMode() to specify
398 that a widget should keep its size when the splitter is resized. 398 that a widget should keep its size when the splitter is resized.
399 399
400 Although KDGanttMinimizeSplitter normally resizes the children only 400 Although KDGanttMinimizeSplitter normally resizes the children only
401 at the end of a resize operation, if you call setOpaqueResize( TRUE 401 at the end of a resize operation, if you call setOpaqueResize( TRUE
402 ) the widgets are resized as often as possible. 402 ) the widgets are resized as often as possible.
403 403
404 The initial distribution of size between the widgets is determined 404 The initial distribution of size between the widgets is determined
405 by the initial size of each widget. You can also use setSizes() to 405 by the initial size of each widget. You can also use setSizes() to
406 set the sizes of all the widgets. The function sizes() returns the 406 set the sizes of all the widgets. The function sizes() returns the
407 sizes set by the user. 407 sizes set by the user.
408 408
409 If you hide() a child, its space will be distributed among the other 409 If you hide() a child, its space will be distributed among the other
410 children. It will be reinstated when you show() it again. It is also 410 children. It will be reinstated when you show() it again. It is also
411 possible to reorder the widgets within the splitter using 411 possible to reorder the widgets within the splitter using
412 moveToFirst() and moveToLast(). 412 moveToFirst() and moveToLast().
413*/ 413*/
414 414
415 415
416 416
417static QSize minSize( const QWidget* /*w*/ ) 417static QSize minSize( const QWidget* /*w*/ )
418{ 418{
419 return QSize(0,0); 419 return QSize(0,0);
420} 420}
421 421
422// This is the original version of minSize 422// This is the original version of minSize
423static QSize minSizeHint( const QWidget* w ) 423static QSize minSizeHint( const QWidget* w )
424{ 424{
425 QSize min = w->minimumSize(); 425 QSize min = w->minimumSize();
426 QSize s; 426 QSize s;
427 if ( min.height() <= 0 || min.width() <= 0 ) 427 if ( min.height() <= 0 || min.width() <= 0 )
428 s = w->minimumSizeHint(); 428 s = w->minimumSizeHint();
429 if ( min.height() > 0 ) 429 if ( min.height() > 0 )
430 s.setHeight( min.height() ); 430 s.setHeight( min.height() );
431 if ( min.width() > 0 ) 431 if ( min.width() > 0 )
432 s.setWidth( min.width() ); 432 s.setWidth( min.width() );
433 return s.expandedTo(QSize(0,0)); 433 return s.expandedTo(QSize(0,0));
434} 434}
435 435
436 436
437 437
438/*! 438/*!
439 Constructs a horizontal splitter with the \a parent and \a 439 Constructs a horizontal splitter with the \a parent and \a
440 name arguments being passed on to the QFrame constructor. 440 name arguments being passed on to the QFrame constructor.
441*/ 441*/
442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
443 :QFrame(parent,name,WPaintUnclipped) 443 :QFrame(parent,name,WPaintUnclipped)
444{ 444{
445 mFirstHandle = 0; 445 mFirstHandle = 0;
446#if QT_VERSION >= 232 446#if QT_VERSION >= 232
447 orient = Horizontal; 447 orient = Horizontal;
448 init(); 448 init();
449#endif 449#endif
450} 450}
451 451
452/*! 452/*!
453 Constructs a splitter with orientation \a o with the \a parent 453 Constructs a splitter with orientation \a o with the \a parent
454 and \a name arguments being passed on to the QFrame constructor. 454 and \a name arguments being passed on to the QFrame constructor.
455*/ 455*/
456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
457 :QFrame(parent,name,WPaintUnclipped) 457 :QFrame(parent,name,WPaintUnclipped)
458{ 458{
459 mFirstHandle = 0; 459 mFirstHandle = 0;
460#if QT_VERSION >= 232 460#if QT_VERSION >= 232
461 orient = o; 461 orient = o;
462 init(); 462 init();
463#endif 463#endif
464} 464}
465 465
466/*! 466/*!
467 Destroys the splitter and any children. 467 Destroys the splitter and any children.
468*/ 468*/
469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
470{ 470{
471#if QT_VERSION >= 232 471#if QT_VERSION >= 232
472 data->list.setAutoDelete( TRUE ); 472 data->list.setAutoDelete( TRUE );
473 delete data; 473 delete data;
474#endif 474#endif
475} 475}
476 476
477 477
478#if QT_VERSION >= 232 478#if QT_VERSION >= 232
479void KDGanttMinimizeSplitter::init() 479void KDGanttMinimizeSplitter::init()
480{ 480{
481 data = new QSplitterData; 481 data = new QSplitterData;
482 if ( orient == Horizontal ) 482 if ( orient == Horizontal )
483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
484 else 484 else
485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
486#ifndef DESKTOP_VERSION
487 setOpaqueResize( false );
488#else
489 setOpaqueResize( true );
490#endif
486} 491}
487#endif 492#endif
488 493
489 494
490void KDGanttMinimizeSplitter::toggle() 495void KDGanttMinimizeSplitter::toggle()
491{ 496{
492 if ( mFirstHandle ) 497 if ( mFirstHandle )
493 mFirstHandle->toggle(); 498 mFirstHandle->toggle();
494 else 499 else
495 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); 500 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
496 501
497} 502}
498 503
499 504
500/*! 505/*!
501 \brief the orientation of the splitter 506 \brief the orientation of the splitter
502 507
503 By default the orientation is horizontal (the widgets are side by side). 508 By default the orientation is horizontal (the widgets are side by side).
504 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 509 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
505*/ 510*/
506void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 511void KDGanttMinimizeSplitter::setOrientation( Orientation o )
507{ 512{
508#if QT_VERSION >= 232 513#if QT_VERSION >= 232
509 if ( orient == o ) 514 if ( orient == o )
510 return; 515 return;
511 orient = o; 516 orient = o;
512 517
513 if ( orient == Horizontal ) 518 if ( orient == Horizontal )
514 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 519 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
515 else 520 else
516 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 521 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
517 522
518 QSplitterLayoutStruct *s = data->list.first(); 523 QSplitterLayoutStruct *s = data->list.first();
519 while ( s ) { 524 while ( s ) {
520 if ( s->isSplitter ) 525 if ( s->isSplitter )
521 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 526 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
522 s = data->list.next(); // ### next at end of loop, no iterator 527 s = data->list.next(); // ### next at end of loop, no iterator
523 } 528 }
524 recalc( isVisible() ); 529 recalc( isVisible() );
525#endif 530#endif
526} 531}
527 532
528 533
529#if QT_VERSION >= 232 534#if QT_VERSION >= 232
530/*! 535/*!
531 \reimp 536 \reimp
532*/ 537*/
533void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 538void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
534{ 539{
535 doResize(); 540 doResize();
536} 541}
537 542
538 543
539/* 544/*
540 Inserts the widget \a w at the end (or at the beginning if \a first 545 Inserts the widget \a w at the end (or at the beginning if \a first
541 is TRUE) of the splitter's list of widgets. 546 is TRUE) of the splitter's list of widgets.
542 547
543 It is the responsibility of the caller of this function to make sure 548 It is the responsibility of the caller of this function to make sure
544 that \a w is not already in the splitter and to call recalcId if 549 that \a w is not already in the splitter and to call recalcId if
545 needed. (If \a first is TRUE, then recalcId is very probably 550 needed. (If \a first is TRUE, then recalcId is very probably
546 needed.) 551 needed.)
547*/ 552*/
548QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 553QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
549{ 554{
550 QSplitterLayoutStruct *s; 555 QSplitterLayoutStruct *s;
551 KDGanttSplitterHandle *newHandle = 0; 556 KDGanttSplitterHandle *newHandle = 0;
552 if ( data->list.count() > 0 ) { 557 if ( data->list.count() > 0 ) {
553 s = new QSplitterLayoutStruct; 558 s = new QSplitterLayoutStruct;
554 s->mode = KeepSize; 559 s->mode = KeepSize;
555 QString tmp = "qt_splithandle_"; 560 QString tmp = "qt_splithandle_";
556 tmp += w->name(); 561 tmp += w->name();
557 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 562 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
558 if ( ! mFirstHandle ) 563 if ( ! mFirstHandle )
559 mFirstHandle = newHandle; 564 mFirstHandle = newHandle;
560 s->wid = newHandle; 565 s->wid = newHandle;
561 newHandle->setId(data->list.count()); 566 newHandle->setId(data->list.count());
562 s->isSplitter = TRUE; 567 s->isSplitter = TRUE;
563 s->sizer = pick( newHandle->sizeHint() ); 568 s->sizer = pick( newHandle->sizeHint() );
564 if ( first ) 569 if ( first )
565 data->list.insert( 0, s ); 570 data->list.insert( 0, s );
566 else 571 else
567 data->list.append( s ); 572 data->list.append( s );
568 } 573 }
569 s = new QSplitterLayoutStruct; 574 s = new QSplitterLayoutStruct;
570 s->mode = Stretch; 575 s->mode = Stretch;
571 s->wid = w; 576 s->wid = w;
572 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 577 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
573 s->sizer = pick( w->sizeHint() ); 578 s->sizer = pick( w->sizeHint() );
574 else 579 else
575 s->sizer = pick( w->size() ); 580 s->sizer = pick( w->size() );
576 s->isSplitter = FALSE; 581 s->isSplitter = FALSE;
577 if ( first ) 582 if ( first )
578 data->list.insert( 0, s ); 583 data->list.insert( 0, s );
579 else 584 else
580 data->list.append( s ); 585 data->list.append( s );
581 if ( newHandle && isVisible() ) 586 if ( newHandle && isVisible() )
582 newHandle->show(); //will trigger sending of post events 587 newHandle->show(); //will trigger sending of post events
583 return s; 588 return s;
584} 589}
585 590
586 591
587/*! 592/*!
588 Tells the splitter that a child widget has been inserted or removed. 593 Tells the splitter that a child widget has been inserted or removed.
589 The event is passed in \a c. 594 The event is passed in \a c.
590*/ 595*/
591void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 596void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
592{ 597{
593 if ( c->type() == QEvent::ChildInserted ) { 598 if ( c->type() == QEvent::ChildInserted ) {
594 if ( !c->child()->isWidgetType() ) 599 if ( !c->child()->isWidgetType() )
595 return; 600 return;
596 601
597 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 602 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
598 return; 603 return;
599 604
600 QSplitterLayoutStruct *s = data->list.first(); 605 QSplitterLayoutStruct *s = data->list.first();
601 while ( s ) { 606 while ( s ) {
602 if ( s->wid == c->child() ) 607 if ( s->wid == c->child() )
603 return; 608 return;
604 s = data->list.next(); 609 s = data->list.next();
605 } 610 }
606 addWidget( (QWidget*)c->child() ); 611 addWidget( (QWidget*)c->child() );
607 recalc( isVisible() ); 612 recalc( isVisible() );
608 613
609 } else if ( c->type() == QEvent::ChildRemoved ) { 614 } else if ( c->type() == QEvent::ChildRemoved ) {
610 QSplitterLayoutStruct *p = 0; 615 QSplitterLayoutStruct *p = 0;
611 if ( data->list.count() > 1 ) 616 if ( data->list.count() > 1 )
612 p = data->list.at(1); //remove handle _after_ first widget. 617 p = data->list.at(1); //remove handle _after_ first widget.
613 QSplitterLayoutStruct *s = data->list.first(); 618 QSplitterLayoutStruct *s = data->list.first();
614 while ( s ) { 619 while ( s ) {
615 if ( s->wid == c->child() ) { 620 if ( s->wid == c->child() ) {
616 data->list.removeRef( s ); 621 data->list.removeRef( s );
617 delete s; 622 delete s;
618 if ( p && p->isSplitter ) { 623 if ( p && p->isSplitter ) {
619 data->list.removeRef( p ); 624 data->list.removeRef( p );
620 delete p->wid; //will call childEvent 625 delete p->wid; //will call childEvent
621 delete p; 626 delete p;
622 } 627 }
623 recalcId(); 628 recalcId();
624 doResize(); 629 doResize();
625 return; 630 return;
626 } 631 }
627 p = s; 632 p = s;
628 s = data->list.next(); 633 s = data->list.next();
629 } 634 }
630 } 635 }
631} 636}
632 637
633 638
634/*! 639/*!
635 Shows a rubber band at position \a p. If \a p is negative, the 640 Shows a rubber band at position \a p. If \a p is negative, the
636 rubber band is removed. 641 rubber band is removed.
637*/ 642*/
638void KDGanttMinimizeSplitter::setRubberband( int p ) 643void KDGanttMinimizeSplitter::setRubberband( int p )
639{ 644{
640 QPainter paint( this ); 645 QPainter paint( this );
641 paint.setPen( gray ); 646 paint.setPen( gray );
642 paint.setBrush( gray ); 647 paint.setBrush( gray );
643 paint.setRasterOp( XorROP ); 648 paint.setRasterOp( XorROP );
644 QRect r = contentsRect(); 649 QRect r = contentsRect();
645 const int rBord = 3; //Themable???? 650 const int rBord = 3; //Themable????
646#if QT_VERSION >= 0x030000 651#if QT_VERSION >= 0x030000
647 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 652 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
648#else 653#else
649 int sw = style().splitterWidth(); 654 int sw = style().splitterWidth();
650#endif 655#endif
651 if ( orient == Horizontal ) { 656 if ( orient == Horizontal ) {
652 if ( opaqueOldPos >= 0 ) 657 if ( opaqueOldPos >= 0 )
653 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 658 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
654 2*rBord, r.height() ); 659 2*rBord, r.height() );
655 if ( p >= 0 ) 660 if ( p >= 0 )
656 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 661 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
657 } else { 662 } else {
658 if ( opaqueOldPos >= 0 ) 663 if ( opaqueOldPos >= 0 )
659 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 664 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
660 r.width(), 2*rBord ); 665 r.width(), 2*rBord );
661 if ( p >= 0 ) 666 if ( p >= 0 )
662 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 667 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
663 } 668 }
664 opaqueOldPos = p; 669 opaqueOldPos = p;
665} 670}
666 671
667 672
668/*! \reimp */ 673/*! \reimp */
669bool KDGanttMinimizeSplitter::event( QEvent *e ) 674bool KDGanttMinimizeSplitter::event( QEvent *e )
670{ 675{
671 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 676 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
672 recalc( isVisible() ); 677 recalc( isVisible() );
673 if ( e->type() == QEvent::Show ) 678 if ( e->type() == QEvent::Show )
674 data->firstShow = FALSE; 679 data->firstShow = FALSE;
675 } 680 }
676 return QWidget::event( e ); 681 return QWidget::event( e );
677} 682}
678 683
679 684
680/*! 685/*!
681 \obsolete 686 \obsolete
682 687
683 Draws the splitter handle in the rectangle described by \a x, \a y, 688 Draws the splitter handle in the rectangle described by \a x, \a y,
684 \a w, \a h using painter \a p. 689 \a w, \a h using painter \a p.
685 \sa QStyle::drawPrimitive() 690 \sa QStyle::drawPrimitive()
686*/ 691*/
687void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 692void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
688 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 693 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
689{ 694{
690#if 0 695#if 0
691 // LR 696 // LR
692 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 697 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
693 (orientation() == Qt::Horizontal ? 698 (orientation() == Qt::Horizontal ?
694 QStyle::Style_Horizontal : 0)); 699 QStyle::Style_Horizontal : 0));
695#endif 700#endif
696} 701}
697 702
698 703
699/*! 704/*!
700 Returns the id of the splitter to the right of or below the widget \a w, 705 Returns the id of the splitter to the right of or below the widget \a w,
701 or 0 if there is no such splitter 706 or 0 if there is no such splitter
702 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 707 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
703*/ 708*/
704int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 709int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
705{ 710{
706 QSplitterLayoutStruct *s = data->list.first(); 711 QSplitterLayoutStruct *s = data->list.first();
707 bool seen_w = FALSE; 712 bool seen_w = FALSE;
708 while ( s ) { 713 while ( s ) {
709 if ( s->isSplitter && seen_w ) 714 if ( s->isSplitter && seen_w )
710 return data->list.at(); 715 return data->list.at();
711 if ( !s->isSplitter && s->wid == w ) 716 if ( !s->isSplitter && s->wid == w )
712 seen_w = TRUE; 717 seen_w = TRUE;
713 s = data->list.next(); 718 s = data->list.next();
714 } 719 }
715 return 0; 720 return 0;
716} 721}
717 722
718 723
719/*! 724/*!
720 Moves the left/top edge of the splitter handle with id \a id as 725 Moves the left/top edge of the splitter handle with id \a id as
721 close as possible to position \a p, which is the distance from the 726 close as possible to position \a p, which is the distance from the
722 left (or top) edge of the widget. 727 left (or top) edge of the widget.
723 728
724 For Arabic and Hebrew the layout is reversed, and using this 729 For Arabic and Hebrew the layout is reversed, and using this
725 function to set the position of the splitter might lead to 730 function to set the position of the splitter might lead to
726 unexpected results, since in Arabic and Hebrew the position of 731 unexpected results, since in Arabic and Hebrew the position of
727 splitter one is to the left of the position of splitter zero. 732 splitter one is to the left of the position of splitter zero.
728 733
729 \sa idAfter() 734 \sa idAfter()
730*/ 735*/
731void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 736void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
732{ 737{
733 p = adjustPos( p, id ); 738 p = adjustPos( p, id );
734 QSplitterLayoutStruct *s = data->list.at(id); 739 QSplitterLayoutStruct *s = data->list.at(id);
735 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 740 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y();
736 bool upLeft; 741 bool upLeft;
737 if ( false && orient == Horizontal ) { 742 if ( false && orient == Horizontal ) {
738 p += s->wid->width(); 743 p += s->wid->width();
739 upLeft = p > oldP; 744 upLeft = p > oldP;
740 } else 745 } else
741 upLeft = p < oldP; 746 upLeft = p < oldP;
742 747
743 moveAfter( p, id, upLeft ); 748 moveAfter( p, id, upLeft );
744 moveBefore( p-1, id-1, upLeft ); 749 moveBefore( p-1, id-1, upLeft );
745 750
746 storeSizes(); 751 storeSizes();
747} 752}
748 753
749 754
750void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 755void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
751{ 756{
752 if ( orient == Horizontal ) { 757 if ( orient == Horizontal ) {
753 if ( false && orient == Horizontal && !isSplitter ) 758 if ( false && orient == Horizontal && !isSplitter )
754 p = contentsRect().width() - p - s; 759 p = contentsRect().width() - p - s;
755 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 760 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
756 } else 761 } else
757 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 762 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
758} 763}
759 764
760 765
761/* 766/*
762 Places the right/bottom edge of the widget at \a id at position \a pos. 767 Places the right/bottom edge of the widget at \a id at position \a pos.
763 768
764 \sa idAfter() 769 \sa idAfter()
765*/ 770*/
766void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) 771void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft )
767{ 772{
768 if( id < 0 ) 773 if( id < 0 )
769 return; 774 return;
770 QSplitterLayoutStruct *s = data->list.at(id); 775 QSplitterLayoutStruct *s = data->list.at(id);
771 if ( !s ) 776 if ( !s )
772 return; 777 return;
773 QWidget *w = s->wid; 778 QWidget *w = s->wid;
774 if ( w->isHidden() ) { 779 if ( w->isHidden() ) {
775 moveBefore( pos, id-1, upLeft ); 780 moveBefore( pos, id-1, upLeft );
776 } else if ( s->isSplitter ) { 781 } else if ( s->isSplitter ) {
777 int pos1, pos2; 782 int pos1, pos2;
778 int dd = s->sizer; 783 int dd = s->sizer;
779 if( false && orient == Horizontal ) { 784 if( false && orient == Horizontal ) {
780 pos1 = pos; 785 pos1 = pos;
781 pos2 = pos + dd; 786 pos2 = pos + dd;
782 } else { 787 } else {
783 pos2 = pos - dd; 788 pos2 = pos - dd;
784 pos1 = pos2 + 1; 789 pos1 = pos2 + 1;
785 } 790 }
786 if ( upLeft ) { 791 if ( upLeft ) {
787 setG( w, pos1, dd, TRUE ); 792 setG( w, pos1, dd, TRUE );
788 moveBefore( pos2, id-1, upLeft ); 793 moveBefore( pos2, id-1, upLeft );
789 } else { 794 } else {
790 moveBefore( pos2, id-1, upLeft ); 795 moveBefore( pos2, id-1, upLeft );
791 setG( w, pos1, dd, TRUE ); 796 setG( w, pos1, dd, TRUE );
792 } 797 }
793 } else { 798 } else {
794 int dd, newLeft, nextPos; 799 int dd, newLeft, nextPos;
795 if( false && orient == Horizontal ) { 800 if( false && orient == Horizontal ) {
796 dd = w->geometry().right() - pos; 801 dd = w->geometry().right() - pos;
797 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 802 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
798 newLeft = pos+1; 803 newLeft = pos+1;
799 nextPos = newLeft + dd; 804 nextPos = newLeft + dd;
800 } else { 805 } else {
801 dd = pos - pick( w->pos() ) + 1; 806 dd = pos - pick( w->pos() ) + 1;
802 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 807 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
803 newLeft = pos-dd+1; 808 newLeft = pos-dd+1;
804 nextPos = newLeft - 1; 809 nextPos = newLeft - 1;
805 } 810 }
806 setG( w, newLeft, dd, TRUE ); 811 setG( w, newLeft, dd, TRUE );
807 moveBefore( nextPos, id-1, upLeft ); 812 moveBefore( nextPos, id-1, upLeft );
808 } 813 }
809} 814}
810 815
811 816
812/* 817/*
813 Places the left/top edge of the widget at \a id at position \a pos. 818 Places the left/top edge of the widget at \a id at position \a pos.
814 819
815 \sa idAfter() 820 \sa idAfter()
816*/ 821*/
817void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) 822void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft )
818{ 823{
819 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 824 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
820 data->list.at(id) : 0; 825 data->list.at(id) : 0;
821 if ( !s ) 826 if ( !s )
822 return; 827 return;
823 QWidget *w = s->wid; 828 QWidget *w = s->wid;
824 if ( w->isHidden() ) { 829 if ( w->isHidden() ) {
825 moveAfter( pos, id+1, upLeft ); 830 moveAfter( pos, id+1, upLeft );
826 } else if ( pick( w->pos() ) == pos ) { 831 } else if ( pick( w->pos() ) == pos ) {
827 //No need to do anything if it's already there. 832 //No need to do anything if it's already there.
828 return; 833 return;
829 } else if ( s->isSplitter ) { 834 } else if ( s->isSplitter ) {
830 int dd = s->sizer; 835 int dd = s->sizer;
831 int pos1, pos2; 836 int pos1, pos2;
832 if( false && orient == Horizontal ) { 837 if( false && orient == Horizontal ) {
833 pos2 = pos - dd; 838 pos2 = pos - dd;
834 pos1 = pos2 + 1; 839 pos1 = pos2 + 1;
835 } else { 840 } else {
836 pos1 = pos; 841 pos1 = pos;
837 pos2 = pos + dd; 842 pos2 = pos + dd;
838 } 843 }
839 if ( upLeft ) { 844 if ( upLeft ) {
840 setG( w, pos1, dd, TRUE ); 845 setG( w, pos1, dd, TRUE );
841 moveAfter( pos2, id+1, upLeft ); 846 moveAfter( pos2, id+1, upLeft );
842 } else { 847 } else {
843 moveAfter( pos2, id+1, upLeft ); 848 moveAfter( pos2, id+1, upLeft );
844 setG( w, pos1, dd, TRUE ); 849 setG( w, pos1, dd, TRUE );
845 } 850 }
846 } else { 851 } else {
847 int left = pick( w->pos() ); 852 int left = pick( w->pos() );
848 int right, dd,/* newRight,*/ newLeft, nextPos; 853 int right, dd,/* newRight,*/ newLeft, nextPos;
849 if ( false && orient == Horizontal ) { 854 if ( false && orient == Horizontal ) {
850 dd = pos - left + 1; 855 dd = pos - left + 1;
851 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 856 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
852 newLeft = pos-dd+1; 857 newLeft = pos-dd+1;
853 nextPos = newLeft - 1; 858 nextPos = newLeft - 1;
854 } else { 859 } else {
855 right = pick( w->geometry().bottomRight() ); 860 right = pick( w->geometry().bottomRight() );
856 dd = right - pos + 1; 861 dd = right - pos + 1;
857 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 862 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
858 /*newRight = pos+dd-1;*/ 863 /*newRight = pos+dd-1;*/
859 newLeft = pos; 864 newLeft = pos;
860 nextPos = newLeft + dd; 865 nextPos = newLeft + dd;
861 } 866 }
862 setG( w, newLeft, dd, TRUE ); 867 setG( w, newLeft, dd, TRUE );
863 /*if( right != newRight )*/ 868 /*if( right != newRight )*/
864 moveAfter( nextPos, id+1, upLeft ); 869 moveAfter( nextPos, id+1, upLeft );
865 } 870 }
866} 871}
867 872
868 873
869void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) 874void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max )
870{ 875{
871 QSplitterLayoutStruct *s = data->list.at(id-1); 876 QSplitterLayoutStruct *s = data->list.at(id-1);
872 QWidget* w = s->wid; 877 QWidget* w = s->wid;
873 *min = pick( w->mapToParent( QPoint(0,0) ) ); 878 *min = pick( w->mapToParent( QPoint(0,0) ) );
874 879
875 if ( (uint) id == data->list.count() ) { 880 if ( (uint) id == data->list.count() ) {
876 pick( size() ); 881 pick( size() );
877 } 882 }
878 else { 883 else {
879 QSplitterLayoutStruct *s = data->list.at(id+1); 884 QSplitterLayoutStruct *s = data->list.at(id+1);
880 QWidget* w = s->wid; 885 QWidget* w = s->wid;
881 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; 886 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8;
882 } 887 }
883} 888}
884 889
885 890
886/*! 891/*!
887 Returns the valid range of the splitter with id \a id in \a *min and \a *max. 892 Returns the valid range of the splitter with id \a id in \a *min and \a *max.
888 893
889 \sa idAfter() 894 \sa idAfter()
890*/ 895*/
891 896
892void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) 897void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
893{ 898{
894 int minB = 0;//before 899 int minB = 0;//before
895 int maxB = 0; 900 int maxB = 0;
896 int minA = 0; 901 int minA = 0;
897 int maxA = 0;//after 902 int maxA = 0;//after
898 int n = data->list.count(); 903 int n = data->list.count();
899 if ( id < 0 || id >= n ) 904 if ( id < 0 || id >= n )
900 return; 905 return;
901 int i; 906 int i;
902 for ( i = 0; i < id; i++ ) { 907 for ( i = 0; i < id; i++ ) {
903 QSplitterLayoutStruct *s = data->list.at(i); 908 QSplitterLayoutStruct *s = data->list.at(i);
904 if ( s->wid->isHidden() ) { 909 if ( s->wid->isHidden() ) {
905 //ignore 910 //ignore
906 } else if ( s->isSplitter ) { 911 } else if ( s->isSplitter ) {
907 minB += s->sizer; 912 minB += s->sizer;
908 maxB += s->sizer; 913 maxB += s->sizer;
909 } else { 914 } else {
910 minB += pick( minSize(s->wid) ); 915 minB += pick( minSize(s->wid) );
911 maxB += pick( s->wid->maximumSize() ); 916 maxB += pick( s->wid->maximumSize() );
912 } 917 }
913 } 918 }
914 for ( i = id; i < n; i++ ) { 919 for ( i = id; i < n; i++ ) {
915 QSplitterLayoutStruct *s = data->list.at(i); 920 QSplitterLayoutStruct *s = data->list.at(i);
916 if ( s->wid->isHidden() ) { 921 if ( s->wid->isHidden() ) {
917 //ignore 922 //ignore
918 } else if ( s->isSplitter ) { 923 } else if ( s->isSplitter ) {
919 minA += s->sizer; 924 minA += s->sizer;
920 maxA += s->sizer; 925 maxA += s->sizer;
921 } else { 926 } else {
922 minA += pick( minSize(s->wid) ); 927 minA += pick( minSize(s->wid) );
923 maxA += pick( s->wid->maximumSize() ); 928 maxA += pick( s->wid->maximumSize() );
924 } 929 }
925 } 930 }
926 QRect r = contentsRect(); 931 QRect r = contentsRect();
927 if ( orient == Horizontal && false ) { 932 if ( orient == Horizontal && false ) {
928#if QT_VERSION >= 0x030000 933#if QT_VERSION >= 0x030000
929 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 934 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this);
930#else 935#else
931 int splitterWidth = style().splitterWidth(); 936 int splitterWidth = style().splitterWidth();
932#endif 937#endif
933 938
934 if ( min ) 939 if ( min )
935 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 940 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
936 if ( max ) 941 if ( max )
937 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 942 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
938 } else { 943 } else {
939 if ( min ) 944 if ( min )
940 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 945 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
941 if ( max ) 946 if ( max )
942 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 947 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
943 } 948 }
944} 949}
945 950
946 951
947/*! 952/*!
948 Returns the closest legal position to \a p of the splitter with id \a id. 953 Returns the closest legal position to \a p of the splitter with id \a id.
949 954
950 \sa idAfter() 955 \sa idAfter()
951*/ 956*/
952 957
953int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 958int KDGanttMinimizeSplitter::adjustPos( int p, int id )
954{ 959{
955 int min = 0; 960 int min = 0;
956 int max = 0; 961 int max = 0;
957 getRange( id, &min, &max ); 962 getRange( id, &min, &max );
958 p = QMAX( min, QMIN( p, max ) ); 963 p = QMAX( min, QMIN( p, max ) );
959 964
960 return p; 965 return p;
961} 966}
962 967
963 968
964void KDGanttMinimizeSplitter::doResize() 969void KDGanttMinimizeSplitter::doResize()
965{ 970{
966 QRect r = contentsRect(); 971 QRect r = contentsRect();
967 int i; 972 int i;
968 int n = data->list.count(); 973 int n = data->list.count();
969 QMemArray<QLayoutStruct> a( n ); 974 QMemArray<QLayoutStruct> a( n );
970 for ( i = 0; i< n; i++ ) { 975 for ( i = 0; i< n; i++ ) {
971 a[i].init(); 976 a[i].init();
972 QSplitterLayoutStruct *s = data->list.at(i); 977 QSplitterLayoutStruct *s = data->list.at(i);
973 if ( s->wid->isHidden() ) { 978 if ( s->wid->isHidden() ) {
974 a[i].stretch = 0; 979 a[i].stretch = 0;
975 a[i].sizeHint = a[i].minimumSize = 0; 980 a[i].sizeHint = a[i].minimumSize = 0;
976 a[i].maximumSize = 0; 981 a[i].maximumSize = 0;
977 } else if ( s->isSplitter ) { 982 } else if ( s->isSplitter ) {
978 a[i].stretch = 0; 983 a[i].stretch = 0;
979 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 984 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
980 a[i].empty = FALSE; 985 a[i].empty = FALSE;
981 } else if ( s->mode == KeepSize ) { 986 } else if ( s->mode == KeepSize ) {
982 a[i].stretch = 0; 987 a[i].stretch = 0;
983 a[i].minimumSize = pick( minSize(s->wid) ); 988 a[i].minimumSize = pick( minSize(s->wid) );
984 a[i].sizeHint = s->sizer; 989 a[i].sizeHint = s->sizer;
985 a[i].maximumSize = pick( s->wid->maximumSize() ); 990 a[i].maximumSize = pick( s->wid->maximumSize() );
986 a[i].empty = FALSE; 991 a[i].empty = FALSE;
987 } else if ( s->mode == FollowSizeHint ) { 992 } else if ( s->mode == FollowSizeHint ) {
988 a[i].stretch = 0; 993 a[i].stretch = 0;
989 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 994 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
990 a[i].maximumSize = pick( s->wid->maximumSize() ); 995 a[i].maximumSize = pick( s->wid->maximumSize() );
991 a[i].empty = FALSE; 996 a[i].empty = FALSE;
992 } else { //proportional 997 } else { //proportional
993 a[i].stretch = s->sizer; 998 a[i].stretch = s->sizer;
994 a[i].maximumSize = pick( s->wid->maximumSize() ); 999 a[i].maximumSize = pick( s->wid->maximumSize() );
995 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 1000 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
996 a[i].empty = FALSE; 1001 a[i].empty = FALSE;
997 } 1002 }
998 } 1003 }
999 1004
1000 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 1005 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
1001 1006
1002 for ( i = 0; i< n; i++ ) { 1007 for ( i = 0; i< n; i++ ) {
1003 QSplitterLayoutStruct *s = data->list.at(i); 1008 QSplitterLayoutStruct *s = data->list.at(i);
1004 setG( s->wid, a[i].pos, a[i].size ); 1009 setG( s->wid, a[i].pos, a[i].size );
1005 } 1010 }
1006 1011
1007} 1012}
1008 1013
1009 1014
1010void KDGanttMinimizeSplitter::recalc( bool update ) 1015void KDGanttMinimizeSplitter::recalc( bool update )
1011{ 1016{
1012 int fi = 2*frameWidth(); 1017 int fi = 2*frameWidth();
1013 int maxl = fi; 1018 int maxl = fi;
1014 int minl = fi; 1019 int minl = fi;
1015 int maxt = QWIDGETSIZE_MAX; 1020 int maxt = QWIDGETSIZE_MAX;
1016 int mint = fi; 1021 int mint = fi;
1017 int n = data->list.count(); 1022 int n = data->list.count();
1018 bool first = TRUE; 1023 bool first = TRUE;
1019 /* 1024 /*
1020 The splitter before a hidden widget is always hidden. 1025 The splitter before a hidden widget is always hidden.
1021 The splitter before the first visible widget is hidden. 1026 The splitter before the first visible widget is hidden.
1022 The splitter before any other visible widget is visible. 1027 The splitter before any other visible widget is visible.
1023 */ 1028 */
1024 for ( int i = 0; i< n; i++ ) { 1029 for ( int i = 0; i< n; i++ ) {
1025 QSplitterLayoutStruct *s = data->list.at(i); 1030 QSplitterLayoutStruct *s = data->list.at(i);
1026 if ( !s->isSplitter ) { 1031 if ( !s->isSplitter ) {
1027 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 1032 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
1028 if ( p && p->isSplitter ) 1033 if ( p && p->isSplitter )
1029 if ( first || s->wid->isHidden() ) 1034 if ( first || s->wid->isHidden() )
1030 p->wid->hide(); //may trigger new recalc 1035 p->wid->hide(); //may trigger new recalc
1031 else 1036 else
1032 p->wid->show(); //may trigger new recalc 1037 p->wid->show(); //may trigger new recalc
1033 if ( !s->wid->isHidden() ) 1038 if ( !s->wid->isHidden() )
1034 first = FALSE; 1039 first = FALSE;
1035 } 1040 }
1036 } 1041 }
1037 1042
1038 bool empty=TRUE; 1043 bool empty=TRUE;
1039 for ( int j = 0; j< n; j++ ) { 1044 for ( int j = 0; j< n; j++ ) {
1040 QSplitterLayoutStruct *s = data->list.at(j); 1045 QSplitterLayoutStruct *s = data->list.at(j);
1041 if ( !s->wid->isHidden() ) { 1046 if ( !s->wid->isHidden() ) {
1042 empty = FALSE; 1047 empty = FALSE;
1043 if ( s->isSplitter ) { 1048 if ( s->isSplitter ) {
1044 minl += s->sizer; 1049 minl += s->sizer;
1045 maxl += s->sizer; 1050 maxl += s->sizer;
1046 } else { 1051 } else {
1047 QSize minS = minSize(s->wid); 1052 QSize minS = minSize(s->wid);
1048 minl += pick( minS ); 1053 minl += pick( minS );
1049 maxl += pick( s->wid->maximumSize() ); 1054 maxl += pick( s->wid->maximumSize() );
1050 mint = QMAX( mint, trans( minS )); 1055 mint = QMAX( mint, trans( minS ));
1051 int tm = trans( s->wid->maximumSize() ); 1056 int tm = trans( s->wid->maximumSize() );
1052 if ( tm > 0 ) 1057 if ( tm > 0 )
1053 maxt = QMIN( maxt, tm ); 1058 maxt = QMIN( maxt, tm );
1054 } 1059 }
1055 } 1060 }
1056 } 1061 }
1057 if ( empty ) { 1062 if ( empty ) {
1058 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { 1063 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) {
1059 // nested splitters; be nice 1064 // nested splitters; be nice
1060 maxl = maxt = 0; 1065 maxl = maxt = 0;
1061 } else { 1066 } else {
1062 // KDGanttMinimizeSplitter with no children yet 1067 // KDGanttMinimizeSplitter with no children yet
1063 maxl = QWIDGETSIZE_MAX; 1068 maxl = QWIDGETSIZE_MAX;
1064 } 1069 }
1065 } else { 1070 } else {
1066 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 1071 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
1067 } 1072 }
1068 if ( maxt < mint ) 1073 if ( maxt < mint )
1069 maxt = mint; 1074 maxt = mint;
1070 1075
1071 if ( orient == Horizontal ) { 1076 if ( orient == Horizontal ) {
1072 setMaximumSize( maxl, maxt ); 1077 setMaximumSize( maxl, maxt );
1073 setMinimumSize( minl, mint ); 1078 setMinimumSize( minl, mint );
1074 } else { 1079 } else {
1075 setMaximumSize( maxt, maxl ); 1080 setMaximumSize( maxt, maxl );
1076 setMinimumSize( mint, minl ); 1081 setMinimumSize( mint, minl );
1077 } 1082 }
1078 if ( update ) 1083 if ( update )
1079 doResize(); 1084 doResize();
1080} 1085}
1081 1086
1082/*! 1087/*!
1083 Sets resize mode of \a w to \a mode. 1088 Sets resize mode of \a w to \a mode.
1084 1089
1085 \sa ResizeMode 1090 \sa ResizeMode
1086*/ 1091*/
1087 1092
1088void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 1093void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode )
1089{ 1094{
1090 processChildEvents(); 1095 processChildEvents();
1091 QSplitterLayoutStruct *s = data->list.first(); 1096 QSplitterLayoutStruct *s = data->list.first();
1092 while ( s ) { 1097 while ( s ) {
1093 if ( s->wid == w ) { 1098 if ( s->wid == w ) {
1094 s->mode = mode; 1099 s->mode = mode;
1095 return; 1100 return;
1096 } 1101 }
1097 s = data->list.next(); 1102 s = data->list.next();
1098 } 1103 }
1099 s = addWidget( w, TRUE ); 1104 s = addWidget( w, TRUE );
1100 s->mode = mode; 1105 s->mode = mode;
1101} 1106}
1102 1107
1103 1108
1104/*! 1109/*!
1105 Returns TRUE if opaque resize is on; otherwise returns FALSE. 1110 Returns TRUE if opaque resize is on; otherwise returns FALSE.
1106 1111
1107 \sa setOpaqueResize() 1112 \sa setOpaqueResize()
1108*/ 1113*/
1109 1114
1110bool KDGanttMinimizeSplitter::opaqueResize() const 1115bool KDGanttMinimizeSplitter::opaqueResize() const
1111{ 1116{
1112 return data->opaque; 1117 return data->opaque;
1113} 1118}
1114 1119
1115 1120
1116/*! 1121/*!
1117 If \a on is TRUE then opaque resizing is turned on; otherwise 1122 If \a on is TRUE then opaque resizing is turned on; otherwise
1118 opaque resizing is turned off. 1123 opaque resizing is turned off.
1119 Opaque resizing is initially turned off. 1124 Opaque resizing is initially turned off.
1120 1125
1121 \sa opaqueResize() 1126 \sa opaqueResize()
1122*/ 1127*/
1123 1128
1124void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) 1129void KDGanttMinimizeSplitter::setOpaqueResize( bool on )
1125{ 1130{
1126 data->opaque = on; 1131 data->opaque = on;
1127} 1132}
1128 1133
1129 1134
1130/*! 1135/*!
1131 Moves widget \a w to the leftmost/top position. 1136 Moves widget \a w to the leftmost/top position.
1132*/ 1137*/
1133 1138
1134void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) 1139void KDGanttMinimizeSplitter::moveToFirst( QWidget *w )
1135{ 1140{
1136 processChildEvents(); 1141 processChildEvents();
1137 bool found = FALSE; 1142 bool found = FALSE;
1138 QSplitterLayoutStruct *s = data->list.first(); 1143 QSplitterLayoutStruct *s = data->list.first();
1139 while ( s ) { 1144 while ( s ) {
1140 if ( s->wid == w ) { 1145 if ( s->wid == w ) {
1141 found = TRUE; 1146 found = TRUE;
1142 QSplitterLayoutStruct *p = data->list.prev(); 1147 QSplitterLayoutStruct *p = data->list.prev();
1143 if ( p ) { // not already at first place 1148 if ( p ) { // not already at first place
1144 data->list.take(); //take p 1149 data->list.take(); //take p
1145 data->list.take(); // take s 1150 data->list.take(); // take s
1146 data->list.insert( 0, p ); 1151 data->list.insert( 0, p );
1147 data->list.insert( 0, s ); 1152 data->list.insert( 0, s );
1148 } 1153 }
1149 break; 1154 break;
1150 } 1155 }
1151 s = data->list.next(); 1156 s = data->list.next();
1152 } 1157 }
1153 if ( !found ) 1158 if ( !found )
1154 addWidget( w, TRUE ); 1159 addWidget( w, TRUE );
1155 recalcId(); 1160 recalcId();
1156} 1161}
1157 1162
1158 1163
1159/*! 1164/*!
1160 Moves widget \a w to the rightmost/bottom position. 1165 Moves widget \a w to the rightmost/bottom position.
1161*/ 1166*/
1162 1167
1163void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) 1168void KDGanttMinimizeSplitter::moveToLast( QWidget *w )
1164{ 1169{
1165 processChildEvents(); 1170 processChildEvents();
1166 bool found = FALSE; 1171 bool found = FALSE;
1167 QSplitterLayoutStruct *s = data->list.first(); 1172 QSplitterLayoutStruct *s = data->list.first();
1168 while ( s ) { 1173 while ( s ) {
1169 if ( s->wid == w ) { 1174 if ( s->wid == w ) {
1170 found = TRUE; 1175 found = TRUE;
1171 data->list.take(); // take s 1176 data->list.take(); // take s
1172 QSplitterLayoutStruct *p = data->list.current(); 1177 QSplitterLayoutStruct *p = data->list.current();
1173 if ( p ) { // the splitter handle after s 1178 if ( p ) { // the splitter handle after s
1174 data->list.take(); //take p 1179 data->list.take(); //take p
1175 data->list.append( p ); 1180 data->list.append( p );
1176 } 1181 }
1177 data->list.append( s ); 1182 data->list.append( s );
1178 break; 1183 break;
1179 } 1184 }
1180 s = data->list.next(); 1185 s = data->list.next();
1181 } 1186 }
1182 if ( !found ) 1187 if ( !found )
1183 addWidget( w); 1188 addWidget( w);
1184 recalcId(); 1189 recalcId();
1185} 1190}
1186 1191
1187 1192
1188void KDGanttMinimizeSplitter::recalcId() 1193void KDGanttMinimizeSplitter::recalcId()
1189{ 1194{
1190 int n = data->list.count(); 1195 int n = data->list.count();
1191 for ( int i = 0; i < n; i++ ) { 1196 for ( int i = 0; i < n; i++ ) {
1192 QSplitterLayoutStruct *s = data->list.at(i); 1197 QSplitterLayoutStruct *s = data->list.at(i);
1193 if ( s->isSplitter ) 1198 if ( s->isSplitter )
1194 ((KDGanttSplitterHandle*)s->wid)->setId(i); 1199 ((KDGanttSplitterHandle*)s->wid)->setId(i);
1195 } 1200 }
1196} 1201}
1197 1202
1198 1203
1199/*!\reimp 1204/*!\reimp
1200*/ 1205*/
1201QSize KDGanttMinimizeSplitter::sizeHint() const 1206QSize KDGanttMinimizeSplitter::sizeHint() const
1202{ 1207{
1203 constPolish(); 1208 constPolish();
1204 int l = 0; 1209 int l = 0;
1205 int t = 0; 1210 int t = 0;
1206 if ( children() ) { 1211 if ( children() ) {
1207 const QObjectList * c = children(); 1212 const QObjectList * c = children();
1208 QObjectListIt it( *c ); 1213 QObjectListIt it( *c );
1209 QObject * o; 1214 QObject * o;
1210 1215
1211 while( (o=it.current()) != 0 ) { 1216 while( (o=it.current()) != 0 ) {
1212 ++it; 1217 ++it;
1213 if ( o->isWidgetType() && 1218 if ( o->isWidgetType() &&
1214 !((QWidget*)o)->isHidden() ) { 1219 !((QWidget*)o)->isHidden() ) {
1215 QSize s = ((QWidget*)o)->sizeHint(); 1220 QSize s = ((QWidget*)o)->sizeHint();
1216 if ( s.isValid() ) { 1221 if ( s.isValid() ) {
1217 l += pick( s ); 1222 l += pick( s );
1218 t = QMAX( t, trans( s ) ); 1223 t = QMAX( t, trans( s ) );
1219 } 1224 }
1220 } 1225 }
1221 } 1226 }
1222 } 1227 }
1223 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1228 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1224} 1229}
1225 1230
1226 1231
1227/*! 1232/*!
1228\reimp 1233\reimp
1229*/ 1234*/
1230 1235
1231QSize KDGanttMinimizeSplitter::minimumSizeHint() const 1236QSize KDGanttMinimizeSplitter::minimumSizeHint() const
1232{ 1237{
1233 constPolish(); 1238 constPolish();
1234 int l = 0; 1239 int l = 0;
1235 int t = 0; 1240 int t = 0;
1236 if ( children() ) { 1241 if ( children() ) {
1237 const QObjectList * c = children(); 1242 const QObjectList * c = children();
1238 QObjectListIt it( *c ); 1243 QObjectListIt it( *c );
1239 QObject * o; 1244 QObject * o;
1240 1245
1241 while( (o=it.current()) != 0 ) { 1246 while( (o=it.current()) != 0 ) {
1242 ++it; 1247 ++it;
1243 if ( o->isWidgetType() && 1248 if ( o->isWidgetType() &&
1244 !((QWidget*)o)->isHidden() ) { 1249 !((QWidget*)o)->isHidden() ) {
1245 QSize s = minSizeHint((QWidget*)o); 1250 QSize s = minSizeHint((QWidget*)o);
1246 if ( s.isValid() ) { 1251 if ( s.isValid() ) {
1247 l += pick( s ); 1252 l += pick( s );
1248 t = QMAX( t, trans( s ) ); 1253 t = QMAX( t, trans( s ) );
1249 } 1254 }
1250 } 1255 }
1251 } 1256 }
1252 } 1257 }
1253 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1258 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
1254} 1259}
1255 1260
1256 1261
1257/* 1262/*
1258 Calculates stretch parameters from current sizes 1263 Calculates stretch parameters from current sizes
1259*/ 1264*/
1260 1265
1261void KDGanttMinimizeSplitter::storeSizes() 1266void KDGanttMinimizeSplitter::storeSizes()
1262{ 1267{
1263 QSplitterLayoutStruct *s = data->list.first(); 1268 QSplitterLayoutStruct *s = data->list.first();
1264 while ( s ) { 1269 while ( s ) {
1265 if ( !s->isSplitter ) 1270 if ( !s->isSplitter )
1266 s->sizer = pick( s->wid->size() ); 1271 s->sizer = pick( s->wid->size() );
1267 s = data->list.next(); 1272 s = data->list.next();
1268 } 1273 }
1269} 1274}
1270 1275
1271 1276
1272#if 0 // ### remove this code ASAP 1277#if 0 // ### remove this code ASAP
1273 1278
1274/*! 1279/*!
1275 Hides \a w if \a hide is TRUE and updates the splitter. 1280 Hides \a w if \a hide is TRUE and updates the splitter.
1276 1281
1277 \warning Due to a limitation in the current implementation, 1282 \warning Due to a limitation in the current implementation,
1278 calling QWidget::hide() will not work. 1283 calling QWidget::hide() will not work.
1279*/ 1284*/
1280 1285
1281void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) 1286void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide )
1282{ 1287{
1283 if ( w == w1 ) { 1288 if ( w == w1 ) {
1284 w1show = !hide; 1289 w1show = !hide;
1285 } else if ( w == w2 ) { 1290 } else if ( w == w2 ) {
1286 w2show = !hide; 1291 w2show = !hide;
1287 } else { 1292 } else {
1288#ifdef QT_CHECK_RANGE 1293#ifdef QT_CHECK_RANGE
1289 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); 1294 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" );
1290#endif 1295#endif
1291 return; 1296 return;
1292 } 1297 }
1293 if ( hide ) 1298 if ( hide )
1294 w->hide(); 1299 w->hide();
1295 else 1300 else
1296 w->show(); 1301 w->show();
1297 recalc( TRUE ); 1302 recalc( TRUE );
1298} 1303}
1299 1304
1300 1305
1301/*! 1306/*!
1302 Returns the hidden status of \a w 1307 Returns the hidden status of \a w
1303*/ 1308*/
1304 1309
1305bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const 1310bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const
1306{ 1311{
1307 if ( w == w1 ) 1312 if ( w == w1 )
1308 return !w1show; 1313 return !w1show;
1309 else if ( w == w2 ) 1314 else if ( w == w2 )
1310 return !w2show; 1315 return !w2show;
1311#ifdef QT_CHECK_RANGE 1316#ifdef QT_CHECK_RANGE
1312 else 1317 else
1313 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); 1318 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" );
1314#endif 1319#endif
1315 return FALSE; 1320 return FALSE;
1316} 1321}
1317#endif 1322#endif
1318 1323
1319 1324
1320/*! 1325/*!
1321 Returns a list of the size parameters of all the widgets in this 1326 Returns a list of the size parameters of all the widgets in this
1322 splitter. 1327 splitter.
1323 1328
1324 Giving the values to another splitter's setSizes() function will 1329 Giving the values to another splitter's setSizes() function will
1325 produce a splitter with the same layout as this one. 1330 produce a splitter with the same layout as this one.
1326 1331
1327 Note that if you want to iterate over the list, you should 1332 Note that if you want to iterate over the list, you should
1328 iterate over a copy, e.g. 1333 iterate over a copy, e.g.
1329 \code 1334 \code
1330 QValueList<int> list = mySplitter.sizes(); 1335 QValueList<int> list = mySplitter.sizes();
1331 QValueList<int>::Iterator it = list.begin(); 1336 QValueList<int>::Iterator it = list.begin();
1332 while( it != list.end() ) { 1337 while( it != list.end() ) {
1333 myProcessing( *it ); 1338 myProcessing( *it );
1334 ++it; 1339 ++it;
1335 } 1340 }
1336 \endcode 1341 \endcode
1337 1342
1338 \sa setSizes() 1343 \sa setSizes()
1339*/ 1344*/
1340 1345
1341QValueList<int> KDGanttMinimizeSplitter::sizes() const 1346QValueList<int> KDGanttMinimizeSplitter::sizes() const
1342{ 1347{
1343 if ( !testWState(WState_Polished) ) { 1348 if ( !testWState(WState_Polished) ) {
1344 QWidget* that = (QWidget*) this; 1349 QWidget* that = (QWidget*) this;
1345 that->polish(); 1350 that->polish();
1346 } 1351 }
1347 QValueList<int> list; 1352 QValueList<int> list;
1348 QSplitterLayoutStruct *s = data->list.first(); 1353 QSplitterLayoutStruct *s = data->list.first();
1349 while ( s ) { 1354 while ( s ) {
1350 if ( !s->isSplitter ) 1355 if ( !s->isSplitter )
1351 list.append( s->sizer ); 1356 list.append( s->sizer );
1352 s = data->list.next(); 1357 s = data->list.next();
1353 } 1358 }
1354 return list; 1359 return list;
1355} 1360}
1356 1361
1357 1362
1358 1363
1359/*! 1364/*!
1360 Sets the size parameters to the values given in \a list. 1365 Sets the size parameters to the values given in \a list.
1361 If the splitter is horizontal, the values set the sizes from 1366 If the splitter is horizontal, the values set the sizes from
1362 left to right. If it is vertical, the sizes are applied from 1367 left to right. If it is vertical, the sizes are applied from
1363 top to bottom. 1368 top to bottom.
1364 Extra values in \a list are ignored. 1369 Extra values in \a list are ignored.
1365 1370
1366 If \a list contains too few values, the result is undefined 1371 If \a list contains too few values, the result is undefined
1367 but the program will still be well-behaved. 1372 but the program will still be well-behaved.
1368 1373
1369 \sa sizes() 1374 \sa sizes()
1370*/ 1375*/
1371 1376
1372void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) 1377void KDGanttMinimizeSplitter::setSizes( QValueList<int> list )
1373{ 1378{
1374 processChildEvents(); 1379 processChildEvents();
1375 QValueList<int>::Iterator it = list.begin(); 1380 QValueList<int>::Iterator it = list.begin();
1376 QSplitterLayoutStruct *s = data->list.first(); 1381 QSplitterLayoutStruct *s = data->list.first();
1377 while ( s && it != list.end() ) { 1382 while ( s && it != list.end() ) {
1378 if ( !s->isSplitter ) { 1383 if ( !s->isSplitter ) {
1379 s->sizer = *it; 1384 s->sizer = *it;
1380 ++it; 1385 ++it;
1381 } 1386 }
1382 s = data->list.next(); 1387 s = data->list.next();
1383 } 1388 }
1384 doResize(); 1389 doResize();
1385} 1390}
1386 1391
1387 1392
1388/*! 1393/*!
1389 Gets all posted child events, ensuring that the internal state of 1394 Gets all posted child events, ensuring that the internal state of
1390 the splitter is consistent. 1395 the splitter is consistent.
1391*/ 1396*/
1392 1397
1393void KDGanttMinimizeSplitter::processChildEvents() 1398void KDGanttMinimizeSplitter::processChildEvents()
1394{ 1399{
1395 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1400 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1396} 1401}
1397 1402
1398 1403
1399/*! 1404/*!
1400 \reimp 1405 \reimp
1401*/ 1406*/
1402 1407
1403void KDGanttMinimizeSplitter::styleChange( QStyle& old ) 1408void KDGanttMinimizeSplitter::styleChange( QStyle& old )
1404{ 1409{
1405 1410
1406#if QT_VERSION >= 0x030000 1411#if QT_VERSION >= 0x030000
1407 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1412 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this);
1408#else 1413#else
1409 int sw = style().splitterWidth(); 1414 int sw = style().splitterWidth();
1410#endif 1415#endif
1411 QSplitterLayoutStruct *s = data->list.first(); 1416 QSplitterLayoutStruct *s = data->list.first();
1412 while ( s ) { 1417 while ( s ) {
1413 if ( s->isSplitter ) 1418 if ( s->isSplitter )
1414 s->sizer = sw; 1419 s->sizer = sw;
1415 s = data->list.next(); 1420 s = data->list.next();
1416 } 1421 }
1417 doResize(); 1422 doResize();
1418 QFrame::styleChange( old ); 1423 QFrame::styleChange( old );
1419} 1424}
1420 1425
1421#endif 1426#endif
1422 1427
1423/*! 1428/*!
1424 Specifies the direction of the minimize buttons. 1429 Specifies the direction of the minimize buttons.
1425 If the orientation of the splitter is horizontal then with 1430 If the orientation of the splitter is horizontal then with
1426 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, 1431 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used,
1427 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down 1432 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down
1428 should be used. 1433 should be used.
1429*/ 1434*/
1430void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) 1435void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction )
1431{ 1436{
1432 _direction = direction; 1437 _direction = direction;
1433} 1438}
1434 1439
1435/*! 1440/*!
1436 Returns the direction of the minimize buttons. 1441 Returns the direction of the minimize buttons.
1437*/ 1442*/
1438KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const 1443KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const
1439{ 1444{
1440 return _direction; 1445 return _direction;
1441} 1446}
1442 1447
1443/* 1448/*
1444 This is a copy of qGeomCalc() in qlayoutengine.cpp which 1449 This is a copy of qGeomCalc() in qlayoutengine.cpp which
1445 unfortunately isn't exported. 1450 unfortunately isn't exported.
1446*/ 1451*/
1447static inline int toFixed( int i ) { return i * 256; } 1452static inline int toFixed( int i ) { return i * 256; }
1448static inline int fRound( int i ) { 1453static inline int fRound( int i ) {
1449 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; 1454 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256;
1450} 1455}
1451void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 1456void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos,
1452 int space, int spacer ) 1457 int space, int spacer )
1453{ 1458{
1454 typedef int fixed; 1459 typedef int fixed;
1455 int cHint = 0; 1460 int cHint = 0;
1456 int cMin = 0; 1461 int cMin = 0;
1457 int cMax = 0; 1462 int cMax = 0;
1458 int sumStretch = 0; 1463 int sumStretch = 0;
1459 int spacerCount = 0; 1464 int spacerCount = 0;
1460 1465
1461 bool wannaGrow = FALSE; // anyone who really wants to grow? 1466 bool wannaGrow = FALSE; // anyone who really wants to grow?
1462 // bool canShrink = FALSE; // anyone who could be persuaded to shrink? 1467 // bool canShrink = FALSE; // anyone who could be persuaded to shrink?
1463 1468
1464 int i; 1469 int i;
1465 for ( i = start; i < start + count; i++ ) { 1470 for ( i = start; i < start + count; i++ ) {
1466 chain[i].done = FALSE; 1471 chain[i].done = FALSE;
1467 cHint += chain[i].sizeHint; 1472 cHint += chain[i].sizeHint;
1468 cMin += chain[i].minimumSize; 1473 cMin += chain[i].minimumSize;
1469 cMax += chain[i].maximumSize; 1474 cMax += chain[i].maximumSize;
1470 sumStretch += chain[i].stretch; 1475 sumStretch += chain[i].stretch;
1471 if ( !chain[i].empty ) 1476 if ( !chain[i].empty )
1472 spacerCount++; 1477 spacerCount++;
1473 wannaGrow = wannaGrow || chain[i].expansive; 1478 wannaGrow = wannaGrow || chain[i].expansive;
1474 } 1479 }
1475 1480
1476 int extraspace = 0; 1481 int extraspace = 0;
1477 if ( spacerCount ) 1482 if ( spacerCount )
1478 spacerCount--; // only spacers between things 1483 spacerCount--; // only spacers between things
1479 if ( space < cMin + spacerCount * spacer ) { 1484 if ( space < cMin + spacerCount * spacer ) {
1480 //qDebug("not enough space"); 1485 //qDebug("not enough space");
1481 for ( i = start; i < start+count; i++ ) { 1486 for ( i = start; i < start+count; i++ ) {
1482 chain[i].size = chain[i].minimumSize; 1487 chain[i].size = chain[i].minimumSize;
1483 chain[i].done = TRUE; 1488 chain[i].done = TRUE;
1484 } 1489 }
1485 } else if ( space < cHint + spacerCount*spacer ) { 1490 } else if ( space < cHint + spacerCount*spacer ) {
1486 // Less space than sizeHint, but more than minimum. 1491 // Less space than sizeHint, but more than minimum.
1487 // Currently take space equally from each, like in Qt 2.x. 1492 // Currently take space equally from each, like in Qt 2.x.
1488 // Commented-out lines will give more space to stretchier items. 1493 // Commented-out lines will give more space to stretchier items.
1489 int n = count; 1494 int n = count;
1490 int space_left = space - spacerCount*spacer; 1495 int space_left = space - spacerCount*spacer;
1491 int overdraft = cHint - space_left; 1496 int overdraft = cHint - space_left;
1492 //first give to the fixed ones: 1497 //first give to the fixed ones:
1493 for ( i = start; i < start+count; i++ ) { 1498 for ( i = start; i < start+count; i++ ) {
1494 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { 1499 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) {
1495 chain[i].size = chain[i].sizeHint; 1500 chain[i].size = chain[i].sizeHint;
1496 chain[i].done = TRUE; 1501 chain[i].done = TRUE;
1497 space_left -= chain[i].sizeHint; 1502 space_left -= chain[i].sizeHint;
1498 // sumStretch -= chain[i].stretch; 1503 // sumStretch -= chain[i].stretch;
1499 n--; 1504 n--;
1500 } 1505 }
1501 } 1506 }
1502 bool finished = n == 0; 1507 bool finished = n == 0;
1503 while ( !finished ) { 1508 while ( !finished ) {
1504 finished = TRUE; 1509 finished = TRUE;
1505 fixed fp_over = toFixed( overdraft ); 1510 fixed fp_over = toFixed( overdraft );
1506 fixed fp_w = 0; 1511 fixed fp_w = 0;
1507 1512
1508 for ( i = start; i < start+count; i++ ) { 1513 for ( i = start; i < start+count; i++ ) {
1509 if ( chain[i].done ) 1514 if ( chain[i].done )
1510 continue; 1515 continue;
1511 // if ( sumStretch <= 0 ) 1516 // if ( sumStretch <= 0 )
1512 fp_w += fp_over / n; 1517 fp_w += fp_over / n;
1513 // else 1518 // else
1514 // fp_w += (fp_over * chain[i].stretch) / sumStretch; 1519 // fp_w += (fp_over * chain[i].stretch) / sumStretch;
1515 int w = fRound( fp_w ); 1520 int w = fRound( fp_w );
1516 chain[i].size = chain[i].sizeHint - w; 1521 chain[i].size = chain[i].sizeHint - w;
1517 fp_w -= toFixed( w ); //give the difference to the next 1522 fp_w -= toFixed( w ); //give the difference to the next
1518 if ( chain[i].size < chain[i].minimumSize ) { 1523 if ( chain[i].size < chain[i].minimumSize ) {
1519 chain[i].done = TRUE; 1524 chain[i].done = TRUE;
1520 chain[i].size = chain[i].minimumSize; 1525 chain[i].size = chain[i].minimumSize;
1521 finished = FALSE; 1526 finished = FALSE;
1522 overdraft -= chain[i].sizeHint - chain[i].minimumSize; 1527 overdraft -= chain[i].sizeHint - chain[i].minimumSize;
1523 // sumStretch -= chain[i].stretch; 1528 // sumStretch -= chain[i].stretch;
1524 n--; 1529 n--;
1525 break; 1530 break;
1526 } 1531 }
1527 } 1532 }
1528 } 1533 }
1529 } else { //extra space 1534 } else { //extra space
1530 int n = count; 1535 int n = count;
1531 int space_left = space - spacerCount*spacer; 1536 int space_left = space - spacerCount*spacer;
1532 // first give to the fixed ones, and handle non-expansiveness 1537 // first give to the fixed ones, and handle non-expansiveness
1533 for ( i = start; i < start + count; i++ ) { 1538 for ( i = start; i < start + count; i++ ) {
1534 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint 1539 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint
1535 || wannaGrow && !chain[i].expansive) ) { 1540 || wannaGrow && !chain[i].expansive) ) {
1536 chain[i].size = chain[i].sizeHint; 1541 chain[i].size = chain[i].sizeHint;
1537 chain[i].done = TRUE; 1542 chain[i].done = TRUE;
1538 space_left -= chain[i].sizeHint; 1543 space_left -= chain[i].sizeHint;
1539 sumStretch -= chain[i].stretch; 1544 sumStretch -= chain[i].stretch;
1540 n--; 1545 n--;
1541 } 1546 }
1542 } 1547 }
1543 extraspace = space_left; 1548 extraspace = space_left;
1544 /* 1549 /*
1545 Do a trial distribution and calculate how much it is off. 1550 Do a trial distribution and calculate how much it is off.
1546 If there are more deficit pixels than surplus pixels, give 1551 If there are more deficit pixels than surplus pixels, give
1547 the minimum size items what they need, and repeat. 1552 the minimum size items what they need, and repeat.
1548 Otherwise give to the maximum size items, and repeat. 1553 Otherwise give to the maximum size items, and repeat.
1549 1554
1550 I have a wonderful mathematical proof for the correctness 1555 I have a wonderful mathematical proof for the correctness
1551 of this principle, but unfortunately this comment is too 1556 of this principle, but unfortunately this comment is too
1552 small to contain it. 1557 small to contain it.
1553 */ 1558 */
1554 int surplus, deficit; 1559 int surplus, deficit;
1555 do { 1560 do {
1556 surplus = deficit = 0; 1561 surplus = deficit = 0;
1557 fixed fp_space = toFixed( space_left ); 1562 fixed fp_space = toFixed( space_left );
1558 fixed fp_w = 0; 1563 fixed fp_w = 0;
1559 for ( i = start; i < start+count; i++ ) { 1564 for ( i = start; i < start+count; i++ ) {
1560 if ( chain[i].done ) 1565 if ( chain[i].done )
1561 continue; 1566 continue;
1562 extraspace = 0; 1567 extraspace = 0;
1563 if ( sumStretch <= 0 ) 1568 if ( sumStretch <= 0 )
1564 fp_w += fp_space / n; 1569 fp_w += fp_space / n;
1565 else 1570 else
1566 fp_w += (fp_space * chain[i].stretch) / sumStretch; 1571 fp_w += (fp_space * chain[i].stretch) / sumStretch;
1567 int w = fRound( fp_w ); 1572 int w = fRound( fp_w );
1568 chain[i].size = w; 1573 chain[i].size = w;
1569 fp_w -= toFixed( w ); // give the difference to the next 1574 fp_w -= toFixed( w ); // give the difference to the next
1570 if ( w < chain[i].sizeHint ) { 1575 if ( w < chain[i].sizeHint ) {
1571 deficit += chain[i].sizeHint - w; 1576 deficit += chain[i].sizeHint - w;
1572 } else if ( w > chain[i].maximumSize ) { 1577 } else if ( w > chain[i].maximumSize ) {
1573 surplus += w - chain[i].maximumSize; 1578 surplus += w - chain[i].maximumSize;
1574 } 1579 }
1575 } 1580 }
1576 if ( deficit > 0 && surplus <= deficit ) { 1581 if ( deficit > 0 && surplus <= deficit ) {
1577 // give to the ones that have too little 1582 // give to the ones that have too little
1578 for ( i = start; i < start+count; i++ ) { 1583 for ( i = start; i < start+count; i++ ) {
1579 if ( !chain[i].done && 1584 if ( !chain[i].done &&
1580 chain[i].size < chain[i].sizeHint ) { 1585 chain[i].size < chain[i].sizeHint ) {
1581 chain[i].size = chain[i].sizeHint; 1586 chain[i].size = chain[i].sizeHint;
1582 chain[i].done = TRUE; 1587 chain[i].done = TRUE;
1583 space_left -= chain[i].sizeHint; 1588 space_left -= chain[i].sizeHint;
1584 sumStretch -= chain[i].stretch; 1589 sumStretch -= chain[i].stretch;
1585 n--; 1590 n--;
1586 } 1591 }
1587 } 1592 }
1588 } 1593 }
1589 if ( surplus > 0 && surplus >= deficit ) { 1594 if ( surplus > 0 && surplus >= deficit ) {
1590 // take from the ones that have too much 1595 // take from the ones that have too much
1591 for ( i = start; i < start+count; i++ ) { 1596 for ( i = start; i < start+count; i++ ) {
1592 if ( !chain[i].done && 1597 if ( !chain[i].done &&
1593 chain[i].size > chain[i].maximumSize ) { 1598 chain[i].size > chain[i].maximumSize ) {
1594 chain[i].size = chain[i].maximumSize; 1599 chain[i].size = chain[i].maximumSize;
1595 chain[i].done = TRUE; 1600 chain[i].done = TRUE;
1596 space_left -= chain[i].maximumSize; 1601 space_left -= chain[i].maximumSize;
1597 sumStretch -= chain[i].stretch; 1602 sumStretch -= chain[i].stretch;
1598 n--; 1603 n--;
1599 } 1604 }
1600 } 1605 }
1601 } 1606 }
1602 } while ( n > 0 && surplus != deficit ); 1607 } while ( n > 0 && surplus != deficit );
1603 if ( n == 0 ) 1608 if ( n == 0 )
1604 extraspace = space_left; 1609 extraspace = space_left;
1605 } 1610 }
1606 1611
1607 // as a last resort, we distribute the unwanted space equally 1612 // as a last resort, we distribute the unwanted space equally
1608 // among the spacers (counting the start and end of the chain). 1613 // among the spacers (counting the start and end of the chain).
1609 1614
1610 //### should do a sub-pixel allocation of extra space 1615 //### should do a sub-pixel allocation of extra space
1611 int extra = extraspace / ( spacerCount + 2 ); 1616 int extra = extraspace / ( spacerCount + 2 );
1612 int p = pos + extra; 1617 int p = pos + extra;
1613 for ( i = start; i < start+count; i++ ) { 1618 for ( i = start; i < start+count; i++ ) {
1614 chain[i].pos = p; 1619 chain[i].pos = p;
1615 p = p + chain[i].size; 1620 p = p + chain[i].size;
1616 if ( !chain[i].empty ) 1621 if ( !chain[i].empty )
1617 p += spacer+extra; 1622 p += spacer+extra;
1618 } 1623 }
1619} 1624}
1620 1625
1621#endif 1626#endif
1622 1627
1623/*! 1628/*!
1624 \enum KDGanttMinimizeSplitter::Direction 1629 \enum KDGanttMinimizeSplitter::Direction
1625 1630
1626 The values of this enumeration describe into which direction the 1631 The values of this enumeration describe into which direction the
1627 splitter will collapse its child widgets. By extension, it also 1632 splitter will collapse its child widgets. By extension, it also
1628 specifies the orientation of the splitter; collapsing to the left or 1633 specifies the orientation of the splitter; collapsing to the left or
1629 to the right results in a horizontal splitter, collapsing to the top 1634 to the right results in a horizontal splitter, collapsing to the top
1630 or bottom in a vertical splitter. 1635 or bottom in a vertical splitter.
1631*/ 1636*/
1632 1637
1633/*! 1638/*!
1634 \fn Orientation KDGanttMinimizeSplitter::orientation() const 1639 \fn Orientation KDGanttMinimizeSplitter::orientation() const
1635 1640
1636 Returns the orientation of the splitter. 1641 Returns the orientation of the splitter.
1637*/ 1642*/
1638 1643
1639/*! \enum KDGanttMinimizeSplitter::ResizeMode 1644/*! \enum KDGanttMinimizeSplitter::ResizeMode
1640 1645
1641 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are: 1646 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are:
1642 1647
1643 Stretch: the widget will be resized when the splitter 1648 Stretch: the widget will be resized when the splitter
1644 itself is resized. 1649 itself is resized.
1645 1650
1646 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size 1651 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size
1647 unchanged. 1652 unchanged.
1648 1653
1649 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the 1654 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the
1650 widget's size hint changes. 1655 widget's size hint changes.
1651*/ 1656*/
1652 1657
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index f05b91b..80a83e0 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,111 +1,126 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "kapplication.h" 4#include "kapplication.h"
5#include "ktextedit.h" 5#include "ktextedit.h"
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qtextbrowser.h> 12#include <qtextbrowser.h>
13 13
14int KApplication::random() 14int KApplication::random()
15{ 15{
16 return rand(); 16 return rand();
17} 17}
18 18
19//US 19//US
20QString KApplication::randomString(int length) 20QString KApplication::randomString(int length)
21{ 21{
22 if (length <=0 ) return QString::null; 22 if (length <=0 ) return QString::null;
23 23
24 QString str; 24 QString str;
25 while (length--) 25 while (length--)
26 { 26 {
27 int r=random() % 62; 27 int r=random() % 62;
28 r+=48; 28 r+=48;
29 if (r>57) r+=7; 29 if (r>57) r+=7;
30 if (r>90) r+=6; 30 if (r>90) r+=6;
31 str += char(r); 31 str += char(r);
32 // so what if I work backwards? 32 // so what if I work backwards?
33 } 33 }
34 return str; 34 return str;
35} 35}
36int KApplication::execDialog( QDialog* d ) 36int KApplication::execDialog( QDialog* d )
37{ 37{
38 if (QApplication::desktop()->width() <= 640 ) 38 if (QApplication::desktop()->width() <= 640 )
39 d->showMaximized(); 39 d->showMaximized();
40 else 40 else
41 ;//d->resize( 800, 600 ); 41 ;//d->resize( 800, 600 );
42 return d->exec(); 42 return d->exec();
43} 43}
44void KApplication::showLicence() 44void KApplication::showLicence()
45{ 45{
46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); 46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" );
47} 47}
48 48
49void KApplication::testCoords( int* x, int* y, int* wid, int * hei )
50{
51 int dWid = QApplication::desktop()->width() ;
52 int dHei = QApplication::desktop()->height();
53 if ( *x + *wid > dWid ) {
54 *x = 0;
55 if ( *wid > dWid )
56 *wid = dWid;
57 }
58 if ( *y + *hei > dHei ) {
59 *y = 0;
60 if ( *hei > dHei )
61 *hei = dHei;
62 }
63}
49void KApplication::showFile(QString caption, QString fn) 64void KApplication::showFile(QString caption, QString fn)
50{ 65{
51 QString text; 66 QString text;
52 QString fileName; 67 QString fileName;
53#ifndef DESKTOP_VERSION 68#ifndef DESKTOP_VERSION
54 fileName = getenv("QPEDIR"); 69 fileName = getenv("QPEDIR");
55 fileName += "/pics/" + fn ; 70 fileName += "/pics/" + fn ;
56#else 71#else
57 fileName = qApp->applicationDirPath () + "/" + fn; 72 fileName = qApp->applicationDirPath () + "/" + fn;
58#endif 73#endif
59 QFile file( fileName ); 74 QFile file( fileName );
60 if (!file.open( IO_ReadOnly ) ) { 75 if (!file.open( IO_ReadOnly ) ) {
61 return ; 76 return ;
62 } 77 }
63 QTextStream ts( &file ); 78 QTextStream ts( &file );
64 text = ts.read(); 79 text = ts.read();
65 file.close(); 80 file.close();
66 KApplication::showText( caption, text ); 81 KApplication::showText( caption, text );
67 82
68} 83}
69 84
70bool KApplication::convert2latin1(QString fileName) 85bool KApplication::convert2latin1(QString fileName)
71{ 86{
72 QString text; 87 QString text;
73 QFile file( fileName ); 88 QFile file( fileName );
74 if (!file.open( IO_ReadOnly ) ) { 89 if (!file.open( IO_ReadOnly ) ) {
75 return false; 90 return false;
76 91
77 } 92 }
78 QTextStream ts( &file ); 93 QTextStream ts( &file );
79 ts.setEncoding( QTextStream::UnicodeUTF8 ); 94 ts.setEncoding( QTextStream::UnicodeUTF8 );
80 text = ts.read(); 95 text = ts.read();
81 file.close(); 96 file.close();
82 if (!file.open( IO_WriteOnly ) ) { 97 if (!file.open( IO_WriteOnly ) ) {
83 return false; 98 return false;
84 } 99 }
85 QTextStream tsIn( &file ); 100 QTextStream tsIn( &file );
86 tsIn.setEncoding( QTextStream::Latin1 ); 101 tsIn.setEncoding( QTextStream::Latin1 );
87 tsIn << text.latin1(); 102 tsIn << text.latin1();
88 file.close(); 103 file.close();
89 return true; 104 return true;
90 105
91 106
92} 107}
93void KApplication::showText(QString caption, QString text) 108void KApplication::showText(QString caption, QString text)
94{ 109{
95 QDialog dia( 0, "name", true ); ; 110 QDialog dia( 0, "name", true ); ;
96 dia.setCaption( caption ); 111 dia.setCaption( caption );
97 QVBoxLayout* lay = new QVBoxLayout( &dia ); 112 QVBoxLayout* lay = new QVBoxLayout( &dia );
98 lay->setSpacing( 3 ); 113 lay->setSpacing( 3 );
99 lay->setMargin( 3 ); 114 lay->setMargin( 3 );
100 KTextEdit tb ( &dia ); 115 KTextEdit tb ( &dia );
101 tb.setWordWrap( QMultiLineEdit::WidgetWidth ); 116 tb.setWordWrap( QMultiLineEdit::WidgetWidth );
102 lay->addWidget( &tb ); 117 lay->addWidget( &tb );
103 tb.setText( text ); 118 tb.setText( text );
104#ifdef DESKTOP_VERSION 119#ifdef DESKTOP_VERSION
105 dia.resize( 640, 480); 120 dia.resize( 640, 480);
106#else 121#else
107 dia.showMaximized(); 122 dia.showMaximized();
108#endif 123#endif
109 dia.exec(); 124 dia.exec();
110 125
111} 126}
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index 497ec2f..f7eb1ef 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -1,30 +1,31 @@
1#ifndef MINIKDE_KAPPLICATION_H 1#ifndef MINIKDE_KAPPLICATION_H
2#define MINIKDE_KAPPLICATION_H 2#define MINIKDE_KAPPLICATION_H
3 3
4#include "qstring.h" 4#include "qstring.h"
5#include <qdialog.h> 5#include <qdialog.h>
6#ifdef QDialog 6#ifdef QDialog
7#undef QDialog 7#undef QDialog
8#endif 8#endif
9 9
10class KApplication 10class KApplication
11{ 11{
12 public: 12 public:
13 static int random(); 13 static int random();
14 14
15//US 15//US
16 /** 16 /**
17 * Generates a random string. It operates in the range [A-Za-z0-9] 17 * Generates a random string. It operates in the range [A-Za-z0-9]
18 * @param length Generate a string of this length. 18 * @param length Generate a string of this length.
19 * @return the random string 19 * @return the random string
20 */ 20 */
21 static QString randomString(int length); 21 static QString randomString(int length);
22 static int execDialog( QDialog* ); 22 static int execDialog( QDialog* );
23 static void showLicence(); 23 static void showLicence();
24 static void testCoords( int* x, int* y, int* wid, int * hei );
24 static void showFile(QString caption, QString file); 25 static void showFile(QString caption, QString file);
25 static void showText(QString caption, QString text); 26 static void showText(QString caption, QString text);
26 static bool convert2latin1(QString file); 27 static bool convert2latin1(QString file);
27}; 28};
28 29
29 30
30#endif 31#endif
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 3d1889f..a3b7fff 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -1,256 +1,256 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library 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 GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <klocale.h> 25#include <klocale.h>
26#include <ksimpleconfig.h> 26#include <ksimpleconfig.h>
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <kstaticdeleter.h> 28#include <kstaticdeleter.h>
29//#ifndef DESKTOP_VERSION 29//#ifndef DESKTOP_VERSION
30#include <klibloader.h> 30#include <klibloader.h>
31//#endif 31//#endif
32#include <qfile.h> 32#include <qfile.h>
33 33
34#include "resource.h" 34#include "resource.h"
35#include "factory.h" 35#include "factory.h"
36 36
37using namespace KRES; 37using namespace KRES;
38 38
39QDict<Factory> *Factory::mSelves = 0; 39QDict<Factory> *Factory::mSelves = 0;
40static KStaticDeleter< QDict<Factory> > staticDeleter; 40static KStaticDeleter< QDict<Factory> > staticDeleter;
41 41
42Factory *Factory::self( const QString& resourceFamily) 42Factory *Factory::self( const QString& resourceFamily)
43{ 43{
44 44
45 45
46 Factory *factory = 0; 46 Factory *factory = 0;
47 if ( !mSelves ) 47 if ( !mSelves )
48 { 48 {
49 mSelves = staticDeleter.setObject( new QDict<Factory> ); 49 mSelves = staticDeleter.setObject( new QDict<Factory> );
50 } 50 }
51 51
52 factory = mSelves->find( resourceFamily ); 52 factory = mSelves->find( resourceFamily );
53 53
54 if ( !factory ) { 54 if ( !factory ) {
55 factory = new Factory( resourceFamily); 55 factory = new Factory( resourceFamily);
56 mSelves->insert( resourceFamily, factory ); 56 mSelves->insert( resourceFamily, factory );
57 } 57 }
58 58
59 return factory; 59 return factory;
60} 60}
61 61
62Factory::Factory( const QString& resourceFamily) : 62Factory::Factory( const QString& resourceFamily) :
63 mResourceFamily( resourceFamily ) 63 mResourceFamily( resourceFamily )
64{ 64{
65//US so far we have three types available for resourceFamily "contact" 65//US so far we have three types available for resourceFamily "contact"
66// and that are "file", "dir", "ldap" 66// and that are "file", "dir", "ldap"
67/*US 67/*US
68 68
69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
70 .arg( resourceFamily ) ); 70 .arg( resourceFamily ) );
71 KTrader::OfferList::ConstIterator it; 71 KTrader::OfferList::ConstIterator it;
72 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 72 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
73 QVariant type = (*it)->property( "X-KDE-ResourceType" ); 73 QVariant type = (*it)->property( "X-KDE-ResourceType" );
74 if ( !type.toString().isEmpty() ) 74 if ( !type.toString().isEmpty() )
75 mTypeMap.insert( type.toString(), *it ); 75 mTypeMap.insert( type.toString(), *it );
76 } 76 }
77*/ 77*/
78 78
79//US new 79//US new
80 PluginInfo* info = new PluginInfo; 80 PluginInfo* info = new PluginInfo;
81 info->library = "microkabc_file"; 81 info->library = "microkabc_file";
82 info->nameLabel = i18n( "file" ); 82 info->nameLabel = i18n( "file" );
83 info->descriptionLabel = i18n( "Choose one file" ); 83 info->descriptionLabel = i18n( "One file" );
84 mTypeMap.insert( "file", info ); 84 mTypeMap.insert( "file", info );
85 85
86 info = new PluginInfo; 86 info = new PluginInfo;
87 info->library = "microkabc_dir"; 87 info->library = "microkabc_dir";
88 info->nameLabel = i18n( "dir" ); 88 info->nameLabel = i18n( "dir" );
89 info->descriptionLabel = i18n( "Choose a directory with may files" ); 89 info->descriptionLabel = i18n( "A directory with many files" );
90 mTypeMap.insert( "dir", info ); 90 mTypeMap.insert( "dir", info );
91 91
92 info = new PluginInfo; 92 info = new PluginInfo;
93 info->library = "microkabc_ldap"; 93 info->library = "microkabc_ldap";
94 info->nameLabel = i18n( "ldap" ); 94 info->nameLabel = i18n( "ldap" );
95 info->descriptionLabel = i18n( "No description available" ); 95 info->descriptionLabel = i18n( "Connect to a directory server" );
96 mTypeMap.insert( "ldap", info ); 96 mTypeMap.insert( "ldap", info );
97 97
98 //US add opie plugin only, if the library exists. 98 //US add opie plugin only, if the library exists.
99 /*US 99 /*US
100 QString libname = "microkabc_opie"; 100 QString libname = "microkabc_opie";
101 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 101 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
102 if ( !path.isEmpty() ) 102 if ( !path.isEmpty() )
103 { 103 {
104 info = new PluginInfo; 104 info = new PluginInfo;
105 info->library = libname; 105 info->library = libname;
106 info->nameLabel = i18n( "opie" ); 106 info->nameLabel = i18n( "opie" );
107 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 107 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
108 mTypeMap.insert( "opie", info ); 108 mTypeMap.insert( "opie", info );
109 } 109 }
110 */ 110 */
111 //US add qtopia plugin only, if the library exists. 111 //US add qtopia plugin only, if the library exists.
112 QString libname = "microkabc_qtopia"; 112 QString libname = "microkabc_qtopia";
113 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 113 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
114 if ( !path.isEmpty() ) 114 if ( !path.isEmpty() )
115 { 115 {
116 info = new PluginInfo; 116 info = new PluginInfo;
117 info->library = libname; 117 info->library = libname;
118 info->nameLabel = i18n( "qtopia" ); 118 info->nameLabel = i18n( "qtopia" );
119 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 119 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
120 mTypeMap.insert( "qtopia", info ); 120 mTypeMap.insert( "qtopia", info );
121 } 121 }
122 122
123 //US add sharp plugin only, if the library exists. 123 //US add sharp plugin only, if the library exists.
124 libname = "microkabc_sharpdtm"; 124 libname = "microkabc_sharpdtm";
125 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 125 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
126 if ( !path.isEmpty() ) 126 if ( !path.isEmpty() )
127 { 127 {
128 info = new PluginInfo; 128 info = new PluginInfo;
129 info->library = libname; 129 info->library = libname;
130 info->nameLabel = i18n( "sharp" ); 130 info->nameLabel = i18n( "sharp" );
131 info->descriptionLabel = i18n( "Sharp DTM Addressbook." ); 131 info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
132 mTypeMap.insert( "sharp", info ); 132 mTypeMap.insert( "sharp", info );
133 } 133 }
134 134
135 135
136} 136}
137 137
138Factory::~Factory() 138Factory::~Factory()
139{ 139{
140} 140}
141 141
142QStringList Factory::typeNames() const 142QStringList Factory::typeNames() const
143{ 143{
144//US method QMap::keys() not available yet. SO collect the data manually 144//US method QMap::keys() not available yet. SO collect the data manually
145//US return mTypeMap.keys(); 145//US return mTypeMap.keys();
146 146
147 QStringList result; 147 QStringList result;
148 148
149 QMap<QString, PluginInfo*>::ConstIterator it; 149 QMap<QString, PluginInfo*>::ConstIterator it;
150 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 150 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
151 result << it.key().latin1(); 151 result << it.key().latin1();
152// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 152// qDebug("Factory::typeNames() : %s ", it.key().latin1());
153 153
154 } 154 }
155 return result; 155 return result;
156} 156}
157 157
158ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 158ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
159{ 159{
160 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 160 if ( type.isEmpty() || !mTypeMap.contains( type ) )
161 return 0; 161 return 0;
162 162
163//US KService::Ptr ptr = mTypeMap[ type ]; 163//US KService::Ptr ptr = mTypeMap[ type ];
164//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 164//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
165 PluginInfo* pi = mTypeMap[ type ]; 165 PluginInfo* pi = mTypeMap[ type ];
166 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 166 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
167 if ( !factory ) { 167 if ( !factory ) {
168 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 168 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
169 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 169 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
170 return 0; 170 return 0;
171 } 171 }
172 172
173 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 173 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
174 174
175 if ( !pluginFactory ) { 175 if ( !pluginFactory ) {
176 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 176 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
177 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 177 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
178 return 0; 178 return 0;
179 } 179 }
180 180
181 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 181 ConfigWidget *wdg = pluginFactory->configWidget( parent );
182 if ( !wdg ) { 182 if ( !wdg ) {
183//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 183//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
184 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 184 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
185 return 0; 185 return 0;
186 } 186 }
187 return wdg; 187 return wdg;
188 188
189} 189}
190 190
191QString Factory::typeName( const QString &type ) const 191QString Factory::typeName( const QString &type ) const
192{ 192{
193 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 193 if ( type.isEmpty() || !mTypeMap.contains( type ) )
194 return QString(); 194 return QString();
195 195
196 196
197//US KService::Ptr ptr = mTypeMap[ type ]; 197//US KService::Ptr ptr = mTypeMap[ type ];
198//US return ptr->name(); 198//US return ptr->name();
199 PluginInfo* pi = mTypeMap[ type ]; 199 PluginInfo* pi = mTypeMap[ type ];
200 return pi->nameLabel; 200 return pi->nameLabel;
201 201
202} 202}
203 203
204QString Factory::typeDescription( const QString &type ) const 204QString Factory::typeDescription( const QString &type ) const
205{ 205{
206 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 206 if ( type.isEmpty() || !mTypeMap.contains( type ) )
207 return QString(); 207 return QString();
208 208
209//US KService::Ptr ptr = mTypeMap[ type ]; 209//US KService::Ptr ptr = mTypeMap[ type ];
210//US return ptr->comment(); 210//US return ptr->comment();
211 PluginInfo* pi = mTypeMap[ type ]; 211 PluginInfo* pi = mTypeMap[ type ];
212 return pi->descriptionLabel; 212 return pi->descriptionLabel;
213} 213}
214 214
215Resource *Factory::resource( const QString& type, const KConfig *config ) 215Resource *Factory::resource( const QString& type, const KConfig *config )
216{ 216{
217 217
218 218
219 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 219 if ( type.isEmpty() || !mTypeMap.contains( type ) )
220 return 0; 220 return 0;
221 221
222/*US load the lib not dynamicly. !! 222/*US load the lib not dynamicly. !!
223 KService::Ptr ptr = mTypeMap[ type ]; 223 KService::Ptr ptr = mTypeMap[ type ];
224 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 224 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
225 if ( !factory ) { 225 if ( !factory ) {
226 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 226 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
227 return 0; 227 return 0;
228 } 228 }
229*/ 229*/
230 PluginInfo* pi = mTypeMap[ type ]; 230 PluginInfo* pi = mTypeMap[ type ];
231 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 231 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
232 if ( !factory ) { 232 if ( !factory ) {
233 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 233 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
234 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 234 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
235 return 0; 235 return 0;
236 } 236 }
237 237
238 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 238 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
239 239
240 if ( !pluginFactory ) { 240 if ( !pluginFactory ) {
241 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 241 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
242 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 242 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
243 return 0; 243 return 0;
244 } 244 }
245 245
246 Resource *resource = pluginFactory->resource( config ); 246 Resource *resource = pluginFactory->resource( config );
247 if ( !resource ) { 247 if ( !resource ) {
248//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 248//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
249 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 249 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
250 return 0; 250 return 0;
251 } 251 }
252 252
253 resource->setType( type ); 253 resource->setType( type );
254 254
255 return resource; 255 return resource;
256} 256}