-rw-r--r-- | korganizer/calendarview.cpp | 6 | ||||
-rw-r--r-- | korganizer/kosyncprefsdialog.cpp | 468 | ||||
-rw-r--r-- | korganizer/kosyncprefsdialog.h | 113 |
3 files changed, 3 insertions, 584 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index c75d10e..387b751 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2226 +1,2226 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include "kosyncprefsdialog.h" | 61 | #include <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 | 66 | ||
67 | #include <libkcal/vcaldrag.h> | 67 | #include <libkcal/vcaldrag.h> |
68 | #include <libkcal/icaldrag.h> | 68 | #include <libkcal/icaldrag.h> |
69 | #include <libkcal/icalformat.h> | 69 | #include <libkcal/icalformat.h> |
70 | #include <libkcal/vcalformat.h> | 70 | #include <libkcal/vcalformat.h> |
71 | #include <libkcal/scheduler.h> | 71 | #include <libkcal/scheduler.h> |
72 | #include <libkcal/calendarlocal.h> | 72 | #include <libkcal/calendarlocal.h> |
73 | #include <libkcal/journal.h> | 73 | #include <libkcal/journal.h> |
74 | #include <libkcal/calfilter.h> | 74 | #include <libkcal/calfilter.h> |
75 | #include <libkcal/attendee.h> | 75 | #include <libkcal/attendee.h> |
76 | #include <libkcal/dndfactory.h> | 76 | #include <libkcal/dndfactory.h> |
77 | #include <libkcal/freebusy.h> | 77 | #include <libkcal/freebusy.h> |
78 | #include <libkcal/filestorage.h> | 78 | #include <libkcal/filestorage.h> |
79 | #include <libkcal/calendarresources.h> | 79 | #include <libkcal/calendarresources.h> |
80 | #include <libkcal/qtopiaformat.h> | 80 | #include <libkcal/qtopiaformat.h> |
81 | #include "../kalarmd/alarmdialog.h" | 81 | #include "../kalarmd/alarmdialog.h" |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | #include <libkcal/sharpformat.h> | 84 | #include <libkcal/sharpformat.h> |
85 | #endif | 85 | #endif |
86 | #ifndef KORG_NOMAIL | 86 | #ifndef KORG_NOMAIL |
87 | #include "komailclient.h" | 87 | #include "komailclient.h" |
88 | #endif | 88 | #endif |
89 | #ifndef KORG_NOPRINTER | 89 | #ifndef KORG_NOPRINTER |
90 | #include "calprinter.h" | 90 | #include "calprinter.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPLUGINS | 92 | #ifndef KORG_NOPLUGINS |
93 | #include "kocore.h" | 93 | #include "kocore.h" |
94 | #endif | 94 | #endif |
95 | #include "koeventeditor.h" | 95 | #include "koeventeditor.h" |
96 | #include "kotodoeditor.h" | 96 | #include "kotodoeditor.h" |
97 | #include "koprefs.h" | 97 | #include "koprefs.h" |
98 | #include "koeventviewerdialog.h" | 98 | #include "koeventviewerdialog.h" |
99 | #include "publishdialog.h" | 99 | #include "publishdialog.h" |
100 | #include "kofilterview.h" | 100 | #include "kofilterview.h" |
101 | #include "koglobals.h" | 101 | #include "koglobals.h" |
102 | #include "koviewmanager.h" | 102 | #include "koviewmanager.h" |
103 | #include "koagendaview.h" | 103 | #include "koagendaview.h" |
104 | #include "kodialogmanager.h" | 104 | #include "kodialogmanager.h" |
105 | #include "outgoingdialog.h" | 105 | #include "outgoingdialog.h" |
106 | #include "incomingdialog.h" | 106 | #include "incomingdialog.h" |
107 | #include "statusdialog.h" | 107 | #include "statusdialog.h" |
108 | #include "kdatenavigator.h" | 108 | #include "kdatenavigator.h" |
109 | #include "kotodoview.h" | 109 | #include "kotodoview.h" |
110 | #include "datenavigator.h" | 110 | #include "datenavigator.h" |
111 | #include "resourceview.h" | 111 | #include "resourceview.h" |
112 | #include "navigatorbar.h" | 112 | #include "navigatorbar.h" |
113 | #include "searchdialog.h" | 113 | #include "searchdialog.h" |
114 | #include "mainwindow.h" | 114 | #include "mainwindow.h" |
115 | 115 | ||
116 | #include "calendarview.h" | 116 | #include "calendarview.h" |
117 | #ifndef DESKTOP_VERSION | 117 | #ifndef DESKTOP_VERSION |
118 | #include <qtopia/alarmserver.h> | 118 | #include <qtopia/alarmserver.h> |
119 | #endif | 119 | #endif |
120 | #ifndef _WIN32_ | 120 | #ifndef _WIN32_ |
121 | #include <stdlib.h> | 121 | #include <stdlib.h> |
122 | #include <stdio.h> | 122 | #include <stdio.h> |
123 | #include <unistd.h> | 123 | #include <unistd.h> |
124 | #else | 124 | #else |
125 | #include <qprocess.h> | 125 | #include <qprocess.h> |
126 | #endif | 126 | #endif |
127 | using namespace KOrg; | 127 | using namespace KOrg; |
128 | using namespace KCal; | 128 | using namespace KCal; |
129 | extern int globalFlagBlockAgenda; | 129 | extern int globalFlagBlockAgenda; |
130 | extern int globalFlagBlockStartup; | 130 | extern int globalFlagBlockStartup; |
131 | 131 | ||
132 | 132 | ||
133 | 133 | ||
134 | class KOBeamPrefs : public QDialog | 134 | class KOBeamPrefs : public QDialog |
135 | { | 135 | { |
136 | public: | 136 | public: |
137 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 137 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
138 | QDialog( parent, name, true ) | 138 | QDialog( parent, name, true ) |
139 | { | 139 | { |
140 | setCaption( i18n("Beam Options") ); | 140 | setCaption( i18n("Beam Options") ); |
141 | QVBoxLayout* lay = new QVBoxLayout( this ); | 141 | QVBoxLayout* lay = new QVBoxLayout( this ); |
142 | lay->setSpacing( 3 ); | 142 | lay->setSpacing( 3 ); |
143 | lay->setMargin( 3 ); | 143 | lay->setMargin( 3 ); |
144 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 144 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
145 | lay->addWidget( format ); | 145 | lay->addWidget( format ); |
146 | format->setExclusive ( true ) ; | 146 | format->setExclusive ( true ) ; |
147 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 147 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
148 | lay->addWidget( time ); time->setExclusive ( true ) ; | 148 | lay->addWidget( time ); time->setExclusive ( true ) ; |
149 | vcal = new QRadioButton(" vCalendar ", format ); | 149 | vcal = new QRadioButton(" vCalendar ", format ); |
150 | ical = new QRadioButton(" iCalendar ", format ); | 150 | ical = new QRadioButton(" iCalendar ", format ); |
151 | vcal->setChecked( true ); | 151 | vcal->setChecked( true ); |
152 | tz = new QRadioButton(i18n(" With timezone "), time ); | 152 | tz = new QRadioButton(i18n(" With timezone "), time ); |
153 | local = new QRadioButton(i18n(" Local time "), time ); | 153 | local = new QRadioButton(i18n(" Local time "), time ); |
154 | tz->setChecked( true ); | 154 | tz->setChecked( true ); |
155 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 155 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
156 | lay->addWidget( ok ); | 156 | lay->addWidget( ok ); |
157 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 157 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
158 | lay->addWidget( cancel ); | 158 | lay->addWidget( cancel ); |
159 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 159 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
160 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 160 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
161 | resize( 200, 200 ); | 161 | resize( 200, 200 ); |
162 | } | 162 | } |
163 | 163 | ||
164 | bool beamVcal() { return vcal->isChecked(); } | 164 | bool beamVcal() { return vcal->isChecked(); } |
165 | bool beamLocal() { return local->isChecked(); } | 165 | bool beamLocal() { return local->isChecked(); } |
166 | private: | 166 | private: |
167 | QRadioButton* vcal, *ical, *local, *tz; | 167 | QRadioButton* vcal, *ical, *local, *tz; |
168 | }; | 168 | }; |
169 | class KOCatPrefs : public QDialog | 169 | class KOCatPrefs : public QDialog |
170 | { | 170 | { |
171 | public: | 171 | public: |
172 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 172 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
173 | QDialog( parent, name, true ) | 173 | QDialog( parent, name, true ) |
174 | { | 174 | { |
175 | setCaption( i18n("Manage new Categories") ); | 175 | setCaption( i18n("Manage new Categories") ); |
176 | QVBoxLayout* lay = new QVBoxLayout( this ); | 176 | QVBoxLayout* lay = new QVBoxLayout( this ); |
177 | lay->setSpacing( 3 ); | 177 | lay->setSpacing( 3 ); |
178 | lay->setMargin( 3 ); | 178 | lay->setMargin( 3 ); |
179 | 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 ); | 179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
180 | lay->addWidget( lab ); | 180 | lay->addWidget( lab ); |
181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
182 | lay->addWidget( format ); | 182 | lay->addWidget( format ); |
183 | format->setExclusive ( true ) ; | 183 | format->setExclusive ( true ) ; |
184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
185 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 185 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
186 | addCatBut->setChecked( true ); | 186 | addCatBut->setChecked( true ); |
187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
188 | lay->addWidget( ok ); | 188 | lay->addWidget( ok ); |
189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
190 | lay->addWidget( cancel ); | 190 | lay->addWidget( cancel ); |
191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
193 | resize( 200, 200 ); | 193 | resize( 200, 200 ); |
194 | } | 194 | } |
195 | 195 | ||
196 | bool addCat() { return addCatBut->isChecked(); } | 196 | bool addCat() { return addCatBut->isChecked(); } |
197 | private: | 197 | private: |
198 | QRadioButton* addCatBut; | 198 | QRadioButton* addCatBut; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | 201 | ||
202 | 202 | ||
203 | CalendarView::CalendarView( CalendarResources *calendar, | 203 | CalendarView::CalendarView( CalendarResources *calendar, |
204 | QWidget *parent, const char *name ) | 204 | QWidget *parent, const char *name ) |
205 | : CalendarViewBase( parent, name ), | 205 | : CalendarViewBase( parent, name ), |
206 | mCalendar( calendar ), | 206 | mCalendar( calendar ), |
207 | mResourceManager( calendar->resourceManager() ) | 207 | mResourceManager( calendar->resourceManager() ) |
208 | { | 208 | { |
209 | 209 | ||
210 | mEventEditor = 0; | 210 | mEventEditor = 0; |
211 | mTodoEditor = 0; | 211 | mTodoEditor = 0; |
212 | 212 | ||
213 | init(); | 213 | init(); |
214 | } | 214 | } |
215 | 215 | ||
216 | CalendarView::CalendarView( Calendar *calendar, | 216 | CalendarView::CalendarView( Calendar *calendar, |
217 | QWidget *parent, const char *name ) | 217 | QWidget *parent, const char *name ) |
218 | : CalendarViewBase( parent, name ), | 218 | : CalendarViewBase( parent, name ), |
219 | mCalendar( calendar ), | 219 | mCalendar( calendar ), |
220 | mResourceManager( 0 ) | 220 | mResourceManager( 0 ) |
221 | { | 221 | { |
222 | 222 | ||
223 | mEventEditor = 0; | 223 | mEventEditor = 0; |
224 | mTodoEditor = 0; | 224 | mTodoEditor = 0; |
225 | init();} | 225 | init();} |
226 | 226 | ||
227 | void CalendarView::init() | 227 | void CalendarView::init() |
228 | { | 228 | { |
229 | beamDialog = new KOBeamPrefs(); | 229 | beamDialog = new KOBeamPrefs(); |
230 | mDatePickerMode = 0; | 230 | mDatePickerMode = 0; |
231 | mCurrentSyncDevice = ""; | 231 | mCurrentSyncDevice = ""; |
232 | writeLocale(); | 232 | writeLocale(); |
233 | mViewManager = new KOViewManager( this ); | 233 | mViewManager = new KOViewManager( this ); |
234 | mDialogManager = new KODialogManager( this ); | 234 | mDialogManager = new KODialogManager( this ); |
235 | mEventViewerDialog = 0; | 235 | mEventViewerDialog = 0; |
236 | mModified = false; | 236 | mModified = false; |
237 | mReadOnly = false; | 237 | mReadOnly = false; |
238 | mSelectedIncidence = 0; | 238 | mSelectedIncidence = 0; |
239 | mCalPrinter = 0; | 239 | mCalPrinter = 0; |
240 | mFilters.setAutoDelete(true); | 240 | mFilters.setAutoDelete(true); |
241 | 241 | ||
242 | mCalendar->registerObserver( this ); | 242 | mCalendar->registerObserver( this ); |
243 | // TODO: Make sure that view is updated, when calendar is changed. | 243 | // TODO: Make sure that view is updated, when calendar is changed. |
244 | 244 | ||
245 | mStorage = new FileStorage( mCalendar ); | 245 | mStorage = new FileStorage( mCalendar ); |
246 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 246 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
247 | 247 | ||
248 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 248 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
249 | #ifndef KORG_NOSPLITTER | 249 | #ifndef KORG_NOSPLITTER |
250 | // create the main layout frames. | 250 | // create the main layout frames. |
251 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 251 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
252 | topLayout->addWidget(mPanner); | 252 | topLayout->addWidget(mPanner); |
253 | 253 | ||
254 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 254 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
255 | "CalendarView::LeftFrame"); | 255 | "CalendarView::LeftFrame"); |
256 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 256 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
257 | 257 | ||
258 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 258 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
259 | "CalendarView::DateNavigator", QDate::currentDate() ); | 259 | "CalendarView::DateNavigator", QDate::currentDate() ); |
260 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 260 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
261 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 261 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
262 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 262 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
263 | 263 | ||
264 | #ifdef KORG_NORESOURCEVIEW | 264 | #ifdef KORG_NORESOURCEVIEW |
265 | mResourceView = 0; | 265 | mResourceView = 0; |
266 | #else | 266 | #else |
267 | if ( mResourceManager ) { | 267 | if ( mResourceManager ) { |
268 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 268 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
269 | mResourceView->updateView(); | 269 | mResourceView->updateView(); |
270 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 270 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
271 | SLOT( updateView() ) ); | 271 | SLOT( updateView() ) ); |
272 | } else { | 272 | } else { |
273 | mResourceView = 0; | 273 | mResourceView = 0; |
274 | } | 274 | } |
275 | #endif | 275 | #endif |
276 | QWidget *rightBox = new QWidget( mPanner ); | 276 | QWidget *rightBox = new QWidget( mPanner ); |
277 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 277 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
278 | 278 | ||
279 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 279 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
280 | rightLayout->addWidget( mNavigatorBar ); | 280 | rightLayout->addWidget( mNavigatorBar ); |
281 | 281 | ||
282 | mRightFrame = new QWidgetStack( rightBox ); | 282 | mRightFrame = new QWidgetStack( rightBox ); |
283 | rightLayout->addWidget( mRightFrame, 1 ); | 283 | rightLayout->addWidget( mRightFrame, 1 ); |
284 | 284 | ||
285 | mLeftFrame = mLeftSplitter; | 285 | mLeftFrame = mLeftSplitter; |
286 | #else | 286 | #else |
287 | QWidget *mainBox = new QWidget( this ); | 287 | QWidget *mainBox = new QWidget( this ); |
288 | QWidget *leftFrame = new QWidget( mainBox ); | 288 | QWidget *leftFrame = new QWidget( mainBox ); |
289 | 289 | ||
290 | QBoxLayout * mainBoxLayout; | 290 | QBoxLayout * mainBoxLayout; |
291 | QBoxLayout * leftFrameLayout; | 291 | QBoxLayout * leftFrameLayout; |
292 | if ( KOPrefs::instance()->mVerticalScreen ) { | 292 | if ( KOPrefs::instance()->mVerticalScreen ) { |
293 | mainBoxLayout = new QVBoxLayout(mainBox); | 293 | mainBoxLayout = new QVBoxLayout(mainBox); |
294 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 294 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
295 | } else { | 295 | } else { |
296 | mainBoxLayout = new QHBoxLayout(mainBox); | 296 | mainBoxLayout = new QHBoxLayout(mainBox); |
297 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 297 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
298 | } | 298 | } |
299 | topLayout->addWidget( mainBox ); | 299 | topLayout->addWidget( mainBox ); |
300 | mainBoxLayout->addWidget (leftFrame); | 300 | mainBoxLayout->addWidget (leftFrame); |
301 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 301 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
302 | "CalendarView::DateNavigator", QDate::currentDate()); | 302 | "CalendarView::DateNavigator", QDate::currentDate()); |
303 | // mDateNavigator->blockSignals( true ); | 303 | // mDateNavigator->blockSignals( true ); |
304 | leftFrameLayout->addWidget( mDateNavigator ); | 304 | leftFrameLayout->addWidget( mDateNavigator ); |
305 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 305 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
306 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 306 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
307 | 307 | ||
308 | if ( QApplication::desktop()->width() < 480 ) { | 308 | if ( QApplication::desktop()->width() < 480 ) { |
309 | leftFrameLayout->addWidget(mFilterView); | 309 | leftFrameLayout->addWidget(mFilterView); |
310 | leftFrameLayout->addWidget(mTodoList, 2 ); | 310 | leftFrameLayout->addWidget(mTodoList, 2 ); |
311 | 311 | ||
312 | } else { | 312 | } else { |
313 | leftFrameLayout->addWidget(mTodoList,2 ); | 313 | leftFrameLayout->addWidget(mTodoList,2 ); |
314 | leftFrameLayout->addWidget(mFilterView ); | 314 | leftFrameLayout->addWidget(mFilterView ); |
315 | } | 315 | } |
316 | mFilterView->hide(); | 316 | mFilterView->hide(); |
317 | QWidget *rightBox = new QWidget( mainBox ); | 317 | QWidget *rightBox = new QWidget( mainBox ); |
318 | mainBoxLayout->addWidget ( rightBox, 10 ); | 318 | mainBoxLayout->addWidget ( rightBox, 10 ); |
319 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 319 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
320 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 320 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
321 | mRightFrame = new QWidgetStack( rightBox ); | 321 | mRightFrame = new QWidgetStack( rightBox ); |
322 | rightLayout->addWidget( mNavigatorBar ); | 322 | rightLayout->addWidget( mNavigatorBar ); |
323 | rightLayout->addWidget( mRightFrame, 10 ); | 323 | rightLayout->addWidget( mRightFrame, 10 ); |
324 | 324 | ||
325 | mLeftFrame = leftFrame; | 325 | mLeftFrame = leftFrame; |
326 | if ( KOPrefs::instance()->mVerticalScreen ) { | 326 | if ( KOPrefs::instance()->mVerticalScreen ) { |
327 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 327 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
328 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 328 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
329 | } else { | 329 | } else { |
330 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 330 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
331 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 331 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
332 | } | 332 | } |
333 | 333 | ||
334 | //qDebug("Calendarview Size %d %d ", width(), height()); | 334 | //qDebug("Calendarview Size %d %d ", width(), height()); |
335 | #endif | 335 | #endif |
336 | 336 | ||
337 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 337 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
338 | SLOT( showDates( const KCal::DateList & ) ) ); | 338 | SLOT( showDates( const KCal::DateList & ) ) ); |
339 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 339 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
340 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 340 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
341 | 341 | ||
342 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 342 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
343 | mNavigator, SLOT( selectPreviousYear() ) ); | 343 | mNavigator, SLOT( selectPreviousYear() ) ); |
344 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 344 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
345 | mNavigator, SLOT( selectNextYear() ) ); | 345 | mNavigator, SLOT( selectNextYear() ) ); |
346 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 346 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
347 | mNavigator, SLOT( selectPreviousMonth() ) ); | 347 | mNavigator, SLOT( selectPreviousMonth() ) ); |
348 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 348 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
349 | mNavigator, SLOT( selectNextMonth() ) ); | 349 | mNavigator, SLOT( selectNextMonth() ) ); |
350 | 350 | ||
351 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 351 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
352 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 352 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
353 | 353 | ||
354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
356 | 356 | ||
357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
358 | mNavigator, SLOT( selectPreviousYear() ) ); | 358 | mNavigator, SLOT( selectPreviousYear() ) ); |
359 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 359 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
360 | mNavigator, SLOT( selectNextYear() ) ); | 360 | mNavigator, SLOT( selectNextYear() ) ); |
361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
362 | mNavigator, SLOT( selectPreviousMonth() ) ); | 362 | mNavigator, SLOT( selectPreviousMonth() ) ); |
363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
364 | mNavigator, SLOT( selectNextMonth() ) ); | 364 | mNavigator, SLOT( selectNextMonth() ) ); |
365 | 365 | ||
366 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 366 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
367 | mNavigator, SLOT( selectPrevious() ) ); | 367 | mNavigator, SLOT( selectPrevious() ) ); |
368 | connect( mDateNavigator, SIGNAL( goNext() ), | 368 | connect( mDateNavigator, SIGNAL( goNext() ), |
369 | mNavigator, SLOT( selectNext() ) ); | 369 | mNavigator, SLOT( selectNext() ) ); |
370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
372 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 372 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
373 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 373 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
374 | 374 | ||
375 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 375 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
376 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 376 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
377 | 377 | ||
378 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 378 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
379 | SLOT( eventAdded( Event *) ) ); | 379 | SLOT( eventAdded( Event *) ) ); |
380 | 380 | ||
381 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 381 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
382 | 382 | ||
383 | connect( this, SIGNAL( configChanged() ), | 383 | connect( this, SIGNAL( configChanged() ), |
384 | mDateNavigator, SLOT( updateConfig() ) ); | 384 | mDateNavigator, SLOT( updateConfig() ) ); |
385 | 385 | ||
386 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 386 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
387 | SLOT( newTodo() ) ); | 387 | SLOT( newTodo() ) ); |
388 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 388 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
389 | SLOT( newSubTodo( Todo * ) ) ); | 389 | SLOT( newSubTodo( Todo * ) ) ); |
390 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 390 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
391 | SLOT( editTodo( Todo * ) ) ); | 391 | SLOT( editTodo( Todo * ) ) ); |
392 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 392 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
393 | SLOT( showTodo( Todo *) ) ); | 393 | SLOT( showTodo( Todo *) ) ); |
394 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 394 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
395 | SLOT( deleteTodo( Todo *) ) ); | 395 | SLOT( deleteTodo( Todo *) ) ); |
396 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 396 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
397 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 397 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
398 | SLOT( purgeCompleted() ) ); | 398 | SLOT( purgeCompleted() ) ); |
399 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 399 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
400 | SIGNAL( todoModified( Todo *, int ) ) ); | 400 | SIGNAL( todoModified( Todo *, int ) ) ); |
401 | 401 | ||
402 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 402 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
403 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 403 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
404 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 404 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
405 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 405 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
406 | 406 | ||
407 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 407 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
408 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 408 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
409 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
410 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 410 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
411 | 411 | ||
412 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 412 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
413 | this, SLOT ( todo_unsub( Todo * ) ) ); | 413 | this, SLOT ( todo_unsub( Todo * ) ) ); |
414 | 414 | ||
415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
416 | SLOT( updateTodo( Todo *, int ) ) ); | 416 | SLOT( updateTodo( Todo *, int ) ) ); |
417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
419 | 419 | ||
420 | 420 | ||
421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
425 | 425 | ||
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
431 | SLOT(checkClipboard())); | 431 | SLOT(checkClipboard())); |
432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
433 | SLOT( processTodoListSelection( Incidence * ) ) ); | 433 | SLOT( processTodoListSelection( Incidence * ) ) ); |
434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
435 | 435 | ||
436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
437 | 437 | ||
438 | mDateFrame = new QVBox(0,0,WType_Popup); | 438 | mDateFrame = new QVBox(0,0,WType_Popup); |
439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
441 | mDateFrame->setLineWidth(3); | 441 | mDateFrame->setLineWidth(3); |
442 | mDateFrame->hide(); | 442 | mDateFrame->hide(); |
443 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 443 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
445 | 445 | ||
446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
447 | 447 | ||
448 | mEventEditor = mDialogManager->getEventEditor(); | 448 | mEventEditor = mDialogManager->getEventEditor(); |
449 | mTodoEditor = mDialogManager->getTodoEditor(); | 449 | mTodoEditor = mDialogManager->getTodoEditor(); |
450 | 450 | ||
451 | mFlagEditDescription = false; | 451 | mFlagEditDescription = false; |
452 | 452 | ||
453 | mSuspendTimer = new QTimer( this ); | 453 | mSuspendTimer = new QTimer( this ); |
454 | mAlarmTimer = new QTimer( this ); | 454 | mAlarmTimer = new QTimer( this ); |
455 | mRecheckAlarmTimer = new QTimer( this ); | 455 | mRecheckAlarmTimer = new QTimer( this ); |
456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
459 | mAlarmDialog = new AlarmDialog( this ); | 459 | mAlarmDialog = new AlarmDialog( this ); |
460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
461 | mAlarmDialog->setServerNotification( false ); | 461 | mAlarmDialog->setServerNotification( false ); |
462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
463 | } | 463 | } |
464 | 464 | ||
465 | 465 | ||
466 | CalendarView::~CalendarView() | 466 | CalendarView::~CalendarView() |
467 | { | 467 | { |
468 | // kdDebug() << "~CalendarView()" << endl; | 468 | // kdDebug() << "~CalendarView()" << endl; |
469 | //qDebug("CalendarView::~CalendarView() "); | 469 | //qDebug("CalendarView::~CalendarView() "); |
470 | delete mDialogManager; | 470 | delete mDialogManager; |
471 | delete mViewManager; | 471 | delete mViewManager; |
472 | delete mStorage; | 472 | delete mStorage; |
473 | delete mDateFrame ; | 473 | delete mDateFrame ; |
474 | delete beamDialog; | 474 | delete beamDialog; |
475 | //kdDebug() << "~CalendarView() done" << endl; | 475 | //kdDebug() << "~CalendarView() done" << endl; |
476 | } | 476 | } |
477 | void CalendarView::timerAlarm() | 477 | void CalendarView::timerAlarm() |
478 | { | 478 | { |
479 | //qDebug("CalendarView::timerAlarm() "); | 479 | //qDebug("CalendarView::timerAlarm() "); |
480 | computeAlarm(mAlarmNotification ); | 480 | computeAlarm(mAlarmNotification ); |
481 | } | 481 | } |
482 | 482 | ||
483 | void CalendarView::suspendAlarm() | 483 | void CalendarView::suspendAlarm() |
484 | { | 484 | { |
485 | //qDebug(" CalendarView::suspendAlarm() "); | 485 | //qDebug(" CalendarView::suspendAlarm() "); |
486 | computeAlarm(mSuspendAlarmNotification ); | 486 | computeAlarm(mSuspendAlarmNotification ); |
487 | 487 | ||
488 | } | 488 | } |
489 | 489 | ||
490 | void CalendarView::startAlarm( QString mess , QString filename) | 490 | void CalendarView::startAlarm( QString mess , QString filename) |
491 | { | 491 | { |
492 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 492 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
493 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 493 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
494 | 494 | ||
495 | } | 495 | } |
496 | 496 | ||
497 | void CalendarView::checkNextTimerAlarm() | 497 | void CalendarView::checkNextTimerAlarm() |
498 | { | 498 | { |
499 | mCalendar->checkAlarmForIncidence( 0, true ); | 499 | mCalendar->checkAlarmForIncidence( 0, true ); |
500 | } | 500 | } |
501 | 501 | ||
502 | void CalendarView::computeAlarm( QString msg ) | 502 | void CalendarView::computeAlarm( QString msg ) |
503 | { | 503 | { |
504 | 504 | ||
505 | QString mess = msg; | 505 | QString mess = msg; |
506 | QString mAlarmMessage = mess.mid( 9 ); | 506 | QString mAlarmMessage = mess.mid( 9 ); |
507 | QString filename = MainWindow::resourcePath(); | 507 | QString filename = MainWindow::resourcePath(); |
508 | filename += "koalarm.wav"; | 508 | filename += "koalarm.wav"; |
509 | QString tempfilename; | 509 | QString tempfilename; |
510 | if ( mess.left( 13 ) == "suspend_alarm") { | 510 | if ( mess.left( 13 ) == "suspend_alarm") { |
511 | bool error = false; | 511 | bool error = false; |
512 | int len = mess.mid( 13 ).find("+++"); | 512 | int len = mess.mid( 13 ).find("+++"); |
513 | if ( len < 2 ) | 513 | if ( len < 2 ) |
514 | error = true; | 514 | error = true; |
515 | else { | 515 | else { |
516 | tempfilename = mess.mid( 13, len ); | 516 | tempfilename = mess.mid( 13, len ); |
517 | if ( !QFile::exists( tempfilename ) ) | 517 | if ( !QFile::exists( tempfilename ) ) |
518 | error = true; | 518 | error = true; |
519 | } | 519 | } |
520 | if ( ! error ) { | 520 | if ( ! error ) { |
521 | filename = tempfilename; | 521 | filename = tempfilename; |
522 | } | 522 | } |
523 | mAlarmMessage = mess.mid( 13+len+3 ); | 523 | mAlarmMessage = mess.mid( 13+len+3 ); |
524 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 524 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
525 | startAlarm( mAlarmMessage, filename); | 525 | startAlarm( mAlarmMessage, filename); |
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | if ( mess.left( 11 ) == "timer_alarm") { | 528 | if ( mess.left( 11 ) == "timer_alarm") { |
529 | //mTimerTime = 0; | 529 | //mTimerTime = 0; |
530 | startAlarm( mess.mid( 11 ), filename ); | 530 | startAlarm( mess.mid( 11 ), filename ); |
531 | return; | 531 | return; |
532 | } | 532 | } |
533 | if ( mess.left( 10 ) == "proc_alarm") { | 533 | if ( mess.left( 10 ) == "proc_alarm") { |
534 | bool error = false; | 534 | bool error = false; |
535 | int len = mess.mid( 10 ).find("+++"); | 535 | int len = mess.mid( 10 ).find("+++"); |
536 | if ( len < 2 ) | 536 | if ( len < 2 ) |
537 | error = true; | 537 | error = true; |
538 | else { | 538 | else { |
539 | tempfilename = mess.mid( 10, len ); | 539 | tempfilename = mess.mid( 10, len ); |
540 | if ( !QFile::exists( tempfilename ) ) | 540 | if ( !QFile::exists( tempfilename ) ) |
541 | error = true; | 541 | error = true; |
542 | } | 542 | } |
543 | if ( error ) { | 543 | if ( error ) { |
544 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 544 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
545 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 545 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
546 | } else { | 546 | } else { |
547 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 547 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
548 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 548 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
549 | #ifndef _WIN32_ | 549 | #ifndef _WIN32_ |
550 | if ( vfork () == 0 ) { | 550 | if ( vfork () == 0 ) { |
551 | execl ( tempfilename.latin1(), 0 ); | 551 | execl ( tempfilename.latin1(), 0 ); |
552 | return; | 552 | return; |
553 | } | 553 | } |
554 | #else | 554 | #else |
555 | QProcess* p = new QProcess(); | 555 | QProcess* p = new QProcess(); |
556 | p->addArgument( tempfilename.latin1() ); | 556 | p->addArgument( tempfilename.latin1() ); |
557 | p->start(); | 557 | p->start(); |
558 | return; | 558 | return; |
559 | #endif | 559 | #endif |
560 | 560 | ||
561 | return; | 561 | return; |
562 | } | 562 | } |
563 | 563 | ||
564 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 564 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
565 | } | 565 | } |
566 | if ( mess.left( 11 ) == "audio_alarm") { | 566 | if ( mess.left( 11 ) == "audio_alarm") { |
567 | bool error = false; | 567 | bool error = false; |
568 | int len = mess.mid( 11 ).find("+++"); | 568 | int len = mess.mid( 11 ).find("+++"); |
569 | if ( len < 2 ) | 569 | if ( len < 2 ) |
570 | error = true; | 570 | error = true; |
571 | else { | 571 | else { |
572 | tempfilename = mess.mid( 11, len ); | 572 | tempfilename = mess.mid( 11, len ); |
573 | if ( !QFile::exists( tempfilename ) ) | 573 | if ( !QFile::exists( tempfilename ) ) |
574 | error = true; | 574 | error = true; |
575 | } | 575 | } |
576 | if ( ! error ) { | 576 | if ( ! error ) { |
577 | filename = tempfilename; | 577 | filename = tempfilename; |
578 | } | 578 | } |
579 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 579 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
580 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 580 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
581 | } | 581 | } |
582 | if ( mess.left( 9 ) == "cal_alarm") { | 582 | if ( mess.left( 9 ) == "cal_alarm") { |
583 | mAlarmMessage = mess.mid( 9 ) ; | 583 | mAlarmMessage = mess.mid( 9 ) ; |
584 | } | 584 | } |
585 | 585 | ||
586 | startAlarm( mAlarmMessage, filename ); | 586 | startAlarm( mAlarmMessage, filename ); |
587 | 587 | ||
588 | 588 | ||
589 | } | 589 | } |
590 | 590 | ||
591 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 591 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
592 | { | 592 | { |
593 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 593 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
594 | 594 | ||
595 | mSuspendAlarmNotification = noti; | 595 | mSuspendAlarmNotification = noti; |
596 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 596 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
597 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 597 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
598 | mSuspendTimer->start( ms , true ); | 598 | mSuspendTimer->start( ms , true ); |
599 | 599 | ||
600 | } | 600 | } |
601 | 601 | ||
602 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 602 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
603 | { | 603 | { |
604 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 604 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
605 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 605 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
606 | #ifndef DESKTOP_VERSION | 606 | #ifndef DESKTOP_VERSION |
607 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 607 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
608 | #endif | 608 | #endif |
609 | return; | 609 | return; |
610 | } | 610 | } |
611 | int maxSec; | 611 | int maxSec; |
612 | //maxSec = 5; //testing only | 612 | //maxSec = 5; //testing only |
613 | maxSec = 86400+3600; // one day+1hour | 613 | maxSec = 86400+3600; // one day+1hour |
614 | mAlarmNotification = noti; | 614 | mAlarmNotification = noti; |
615 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 615 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
616 | if ( sec > maxSec ) { | 616 | if ( sec > maxSec ) { |
617 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 617 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
618 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 618 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
619 | return; | 619 | return; |
620 | } else { | 620 | } else { |
621 | mRecheckAlarmTimer->stop(); | 621 | mRecheckAlarmTimer->stop(); |
622 | } | 622 | } |
623 | //qDebug("Alarm timer started with secs: %d ", sec); | 623 | //qDebug("Alarm timer started with secs: %d ", sec); |
624 | mAlarmTimer->start( sec *1000 , true ); | 624 | mAlarmTimer->start( sec *1000 , true ); |
625 | 625 | ||
626 | } | 626 | } |
627 | // called by mRecheckAlarmTimer to get next alarm | 627 | // called by mRecheckAlarmTimer to get next alarm |
628 | // we need this, because a QTimer has only a max range of 25 days | 628 | // we need this, because a QTimer has only a max range of 25 days |
629 | void CalendarView::recheckTimerAlarm() | 629 | void CalendarView::recheckTimerAlarm() |
630 | { | 630 | { |
631 | mAlarmTimer->stop(); | 631 | mAlarmTimer->stop(); |
632 | mRecheckAlarmTimer->stop(); | 632 | mRecheckAlarmTimer->stop(); |
633 | mCalendar->checkAlarmForIncidence( 0, true ); | 633 | mCalendar->checkAlarmForIncidence( 0, true ); |
634 | } | 634 | } |
635 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 635 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
636 | { | 636 | { |
637 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 637 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
638 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 638 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
639 | #ifndef DESKTOP_VERSION | 639 | #ifndef DESKTOP_VERSION |
640 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 640 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
641 | #endif | 641 | #endif |
642 | return; | 642 | return; |
643 | } | 643 | } |
644 | mAlarmTimer->stop(); | 644 | mAlarmTimer->stop(); |
645 | } | 645 | } |
646 | void CalendarView::selectWeekNum ( int num ) | 646 | void CalendarView::selectWeekNum ( int num ) |
647 | { | 647 | { |
648 | dateNavigator()->selectWeek( num ); | 648 | dateNavigator()->selectWeek( num ); |
649 | mViewManager->showWeekView(); | 649 | mViewManager->showWeekView(); |
650 | } | 650 | } |
651 | KOViewManager *CalendarView::viewManager() | 651 | KOViewManager *CalendarView::viewManager() |
652 | { | 652 | { |
653 | return mViewManager; | 653 | return mViewManager; |
654 | } | 654 | } |
655 | 655 | ||
656 | KODialogManager *CalendarView::dialogManager() | 656 | KODialogManager *CalendarView::dialogManager() |
657 | { | 657 | { |
658 | return mDialogManager; | 658 | return mDialogManager; |
659 | } | 659 | } |
660 | 660 | ||
661 | QDate CalendarView::startDate() | 661 | QDate CalendarView::startDate() |
662 | { | 662 | { |
663 | DateList dates = mNavigator->selectedDates(); | 663 | DateList dates = mNavigator->selectedDates(); |
664 | 664 | ||
665 | return dates.first(); | 665 | return dates.first(); |
666 | } | 666 | } |
667 | 667 | ||
668 | QDate CalendarView::endDate() | 668 | QDate CalendarView::endDate() |
669 | { | 669 | { |
670 | DateList dates = mNavigator->selectedDates(); | 670 | DateList dates = mNavigator->selectedDates(); |
671 | 671 | ||
672 | return dates.last(); | 672 | return dates.last(); |
673 | } | 673 | } |
674 | 674 | ||
675 | 675 | ||
676 | void CalendarView::createPrinter() | 676 | void CalendarView::createPrinter() |
677 | { | 677 | { |
678 | #ifndef KORG_NOPRINTER | 678 | #ifndef KORG_NOPRINTER |
679 | if (!mCalPrinter) { | 679 | if (!mCalPrinter) { |
680 | mCalPrinter = new CalPrinter(this, mCalendar); | 680 | mCalPrinter = new CalPrinter(this, mCalendar); |
681 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 681 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
682 | } | 682 | } |
683 | #endif | 683 | #endif |
684 | } | 684 | } |
685 | 685 | ||
686 | void CalendarView::confSync() | 686 | void CalendarView::confSync() |
687 | { | 687 | { |
688 | static KOSyncPrefsDialog* sp = 0; | 688 | static KSyncPrefsDialog* sp = 0; |
689 | if ( ! sp ) { | 689 | if ( ! sp ) { |
690 | sp = new KOSyncPrefsDialog( this, "syncprefs", true ); | 690 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
691 | } | 691 | } |
692 | sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName ); | 692 | sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName ); |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
702 | } | 702 | } |
703 | 703 | ||
704 | 704 | ||
705 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
706 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
707 | 707 | ||
708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
714 | 714 | ||
715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
716 | { | 716 | { |
717 | 717 | ||
718 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
719 | // int zaurusId() const; | 719 | // int zaurusId() const; |
720 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
721 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
722 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
723 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
724 | // 0 equal | 724 | // 0 equal |
725 | // 1 take local | 725 | // 1 take local |
726 | // 2 take remote | 726 | // 2 take remote |
727 | // 3 cancel | 727 | // 3 cancel |
728 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
730 | bool remCh, locCh; | 730 | bool remCh, locCh; |
731 | remCh = ( remote->zaurusUid() != local->zaurusUid() ); | 731 | remCh = ( remote->zaurusUid() != local->zaurusUid() ); |
732 | locCh = ( local->lastModified() > mLastCalendarSync ); | 732 | locCh = ( local->lastModified() > mLastCalendarSync ); |
733 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 733 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
734 | if ( !remCh && ! locCh ) { | 734 | if ( !remCh && ! locCh ) { |
735 | //qDebug("both not changed "); | 735 | //qDebug("both not changed "); |
736 | lastSync = local->lastModified().addDays(1); | 736 | lastSync = local->lastModified().addDays(1); |
737 | } else { | 737 | } else { |
738 | if ( locCh ) { | 738 | if ( locCh ) { |
739 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); | 739 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); |
740 | lastSync = local->lastModified().addDays( -1 ); | 740 | lastSync = local->lastModified().addDays( -1 ); |
741 | if ( !remCh ) | 741 | if ( !remCh ) |
742 | remote->setLastModified( lastSync.addDays( -1 ) ); | 742 | remote->setLastModified( lastSync.addDays( -1 ) ); |
743 | } else { | 743 | } else { |
744 | //qDebug(" not loc changed "); | 744 | //qDebug(" not loc changed "); |
745 | lastSync = local->lastModified().addDays( 1 ); | 745 | lastSync = local->lastModified().addDays( 1 ); |
746 | if ( remCh ) | 746 | if ( remCh ) |
747 | remote->setLastModified( lastSync.addDays( 1 ) ); | 747 | remote->setLastModified( lastSync.addDays( 1 ) ); |
748 | 748 | ||
749 | } | 749 | } |
750 | } | 750 | } |
751 | full = true; | 751 | full = true; |
752 | if ( mode < SYNC_PREF_ASK ) | 752 | if ( mode < SYNC_PREF_ASK ) |
753 | mode = SYNC_PREF_ASK; | 753 | mode = SYNC_PREF_ASK; |
754 | } else { | 754 | } else { |
755 | if ( local->lastModified() == remote->lastModified() ) | 755 | if ( local->lastModified() == remote->lastModified() ) |
756 | if ( local->revision() == remote->revision() ) | 756 | if ( local->revision() == remote->revision() ) |
757 | return 0; | 757 | return 0; |
758 | 758 | ||
759 | } | 759 | } |
760 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 760 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
761 | 761 | ||
762 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 762 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
763 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 763 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
764 | //full = true; //debug only | 764 | //full = true; //debug only |
765 | if ( full ) { | 765 | if ( full ) { |
766 | bool equ = false; | 766 | bool equ = false; |
767 | if ( local->type() == "Event" ) { | 767 | if ( local->type() == "Event" ) { |
768 | equ = (*((Event*) local) == *((Event*) remote)); | 768 | equ = (*((Event*) local) == *((Event*) remote)); |
769 | } | 769 | } |
770 | else if ( local->type() =="Todo" ) | 770 | else if ( local->type() =="Todo" ) |
771 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 771 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
772 | else if ( local->type() =="Journal" ) | 772 | else if ( local->type() =="Journal" ) |
773 | equ = (*((Journal*) local) == *((Journal*) remote)); | 773 | equ = (*((Journal*) local) == *((Journal*) remote)); |
774 | if ( equ ) { | 774 | if ( equ ) { |
775 | //qDebug("equal "); | 775 | //qDebug("equal "); |
776 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 776 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
777 | local->setZaurusUid( remote->zaurusUid() ); | 777 | local->setZaurusUid( remote->zaurusUid() ); |
778 | } | 778 | } |
779 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 779 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
780 | return 0; | 780 | return 0; |
781 | 781 | ||
782 | }//else //debug only | 782 | }//else //debug only |
783 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 783 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
784 | } | 784 | } |
785 | int result; | 785 | int result; |
786 | bool localIsNew; | 786 | bool localIsNew; |
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remote->lastModified() ) | 792 | if ( lastSync > remote->lastModified() ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > local->lastModified() ) | 794 | if ( lastSync > local->lastModified() ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remote->lastModified() ) | 799 | if ( lastSync > remote->lastModified() ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > local->lastModified() ) | 801 | if ( lastSync > local->lastModified() ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( local->lastModified() > remote->lastModified() ) | 806 | if ( local->lastModified() > remote->lastModified() ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
813 | if ( lastSync > remote->lastModified() ) | 813 | if ( lastSync > remote->lastModified() ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > local->lastModified() ) | 815 | if ( lastSync > local->lastModified() ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
818 | localIsNew = local->lastModified() > remote->lastModified(); | 818 | localIsNew = local->lastModified() > remote->lastModified(); |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); |
858 | lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); | 858 | lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); |
859 | lse->setDtStart( mLastCalendarSync ); | 859 | lse->setDtStart( mLastCalendarSync ); |
860 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 860 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
861 | lse->setCategories( i18n("SyncEvent") ); | 861 | lse->setCategories( i18n("SyncEvent") ); |
862 | lse->setReadOnly( true ); | 862 | lse->setReadOnly( true ); |
863 | mCalendar->addEvent( lse ); | 863 | mCalendar->addEvent( lse ); |
864 | } | 864 | } |
865 | 865 | ||
866 | return lse; | 866 | return lse; |
867 | 867 | ||
868 | } | 868 | } |
869 | void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) | 869 | void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) |
870 | { | 870 | { |
871 | if ( ! lastSync ) | 871 | if ( ! lastSync ) |
872 | return; | 872 | return; |
873 | if ( toDelete->zaurusId() < 0 ) | 873 | if ( toDelete->zaurusId() < 0 ) |
874 | return; | 874 | return; |
875 | if ( toDelete->type() == "Journal" ) | 875 | if ( toDelete->type() == "Journal" ) |
876 | return; | 876 | return; |
877 | QString des = lastSync->description(); | 877 | QString des = lastSync->description(); |
878 | QString pref = "e"; | 878 | QString pref = "e"; |
879 | if ( toDelete->type() == "Todo" ) | 879 | if ( toDelete->type() == "Todo" ) |
880 | pref = "t"; | 880 | pref = "t"; |
881 | des += pref+ QString::number ( toDelete->zaurusId() ) + ","; | 881 | des += pref+ QString::number ( toDelete->zaurusId() ) + ","; |
882 | lastSync->setReadOnly( false ); | 882 | lastSync->setReadOnly( false ); |
883 | lastSync->setDescription( des ); | 883 | lastSync->setDescription( des ); |
884 | lastSync->setReadOnly( true ); | 884 | lastSync->setReadOnly( true ); |
885 | 885 | ||
886 | } | 886 | } |
887 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 887 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
888 | { | 888 | { |
889 | bool syncOK = true; | 889 | bool syncOK = true; |
890 | int addedEvent = 0; | 890 | int addedEvent = 0; |
891 | int addedEventR = 0; | 891 | int addedEventR = 0; |
892 | int deletedEventR = 0; | 892 | int deletedEventR = 0; |
893 | int deletedEventL = 0; | 893 | int deletedEventL = 0; |
894 | int changedLocal = 0; | 894 | int changedLocal = 0; |
895 | int changedRemote = 0; | 895 | int changedRemote = 0; |
896 | //QPtrList<Event> el = local->rawEvents(); | 896 | //QPtrList<Event> el = local->rawEvents(); |
897 | Event* eventR; | 897 | Event* eventR; |
898 | QString uid; | 898 | QString uid; |
899 | int take; | 899 | int take; |
900 | Event* eventL; | 900 | Event* eventL; |
901 | Event* eventRSync; | 901 | Event* eventRSync; |
902 | Event* eventLSync; | 902 | Event* eventLSync; |
903 | Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); | 903 | Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); |
904 | Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); | 904 | Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); |
905 | bool fullDateRange = false; | 905 | bool fullDateRange = false; |
906 | mLastCalendarSync = QDateTime::currentDateTime(); | 906 | mLastCalendarSync = QDateTime::currentDateTime(); |
907 | QDateTime modifiedCalendar = mLastCalendarSync;; | 907 | QDateTime modifiedCalendar = mLastCalendarSync;; |
908 | eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); | 908 | eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); |
909 | if ( eventR ) { | 909 | if ( eventR ) { |
910 | eventRSync = (Event*) eventR->clone(); | 910 | eventRSync = (Event*) eventR->clone(); |
911 | remote->deleteEvent(eventR ); | 911 | remote->deleteEvent(eventR ); |
912 | 912 | ||
913 | } else { | 913 | } else { |
914 | fullDateRange = true; | 914 | fullDateRange = true; |
915 | eventRSync = new Event(); | 915 | eventRSync = new Event(); |
916 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 916 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
917 | eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); | 917 | eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); |
918 | eventRSync->setDtStart( mLastCalendarSync ); | 918 | eventRSync->setDtStart( mLastCalendarSync ); |
919 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 919 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
920 | eventRSync->setCategories( i18n("SyncEvent") ); | 920 | eventRSync->setCategories( i18n("SyncEvent") ); |
921 | } | 921 | } |
922 | eventLSync = getLastSyncEvent(); | 922 | eventLSync = getLastSyncEvent(); |
923 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 923 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
924 | fullDateRange = true; | 924 | fullDateRange = true; |
925 | 925 | ||
926 | if ( ! fullDateRange ) { | 926 | if ( ! fullDateRange ) { |
927 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 927 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
928 | 928 | ||
929 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 929 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
930 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 930 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
931 | fullDateRange = true; | 931 | fullDateRange = true; |
932 | } | 932 | } |
933 | } | 933 | } |
934 | if ( fullDateRange ) | 934 | if ( fullDateRange ) |
935 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 935 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
936 | else | 936 | else |
937 | mLastCalendarSync = eventLSync->dtStart(); | 937 | mLastCalendarSync = eventLSync->dtStart(); |
938 | // for resyncing if own file has changed | 938 | // for resyncing if own file has changed |
939 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 939 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
940 | mLastCalendarSync = loadedFileVersion; | 940 | mLastCalendarSync = loadedFileVersion; |
941 | qDebug("setting mLastCalendarSync "); | 941 | qDebug("setting mLastCalendarSync "); |
942 | } | 942 | } |
943 | //qDebug("*************************** "); | 943 | //qDebug("*************************** "); |
944 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 944 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
945 | QPtrList<Incidence> er = remote->rawIncidences(); | 945 | QPtrList<Incidence> er = remote->rawIncidences(); |
946 | Incidence* inR = er.first(); | 946 | Incidence* inR = er.first(); |
947 | Incidence* inL; | 947 | Incidence* inL; |
948 | QProgressBar bar( er.count(),0 ); | 948 | QProgressBar bar( er.count(),0 ); |
949 | bar.setCaption (i18n("Syncing - close to abort!") ); | 949 | bar.setCaption (i18n("Syncing - close to abort!") ); |
950 | 950 | ||
951 | int w = 300; | 951 | int w = 300; |
952 | if ( QApplication::desktop()->width() < 320 ) | 952 | if ( QApplication::desktop()->width() < 320 ) |
953 | w = 220; | 953 | w = 220; |
954 | int h = bar.sizeHint().height() ; | 954 | int h = bar.sizeHint().height() ; |
955 | int dw = QApplication::desktop()->width(); | 955 | int dw = QApplication::desktop()->width(); |
956 | int dh = QApplication::desktop()->height(); | 956 | int dh = QApplication::desktop()->height(); |
957 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 957 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
958 | bar.show(); | 958 | bar.show(); |
959 | int modulo = (er.count()/10)+1; | 959 | int modulo = (er.count()/10)+1; |
960 | int incCounter = 0; | 960 | int incCounter = 0; |
961 | while ( inR ) { | 961 | while ( inR ) { |
962 | if ( ! bar.isVisible() ) | 962 | if ( ! bar.isVisible() ) |
963 | return false; | 963 | return false; |
964 | if ( incCounter % modulo == 0 ) | 964 | if ( incCounter % modulo == 0 ) |
965 | bar.setProgress( incCounter ); | 965 | bar.setProgress( incCounter ); |
966 | ++incCounter; | 966 | ++incCounter; |
967 | uid = inR->uid(); | 967 | uid = inR->uid(); |
968 | bool skipIncidence = false; | 968 | bool skipIncidence = false; |
969 | if ( uid.left(21) == QString("last-syncEvent-device") ) | 969 | if ( uid.left(21) == QString("last-syncEvent-device") ) |
970 | skipIncidence = true; | 970 | skipIncidence = true; |
971 | 971 | ||
972 | qApp->processEvents(); | 972 | qApp->processEvents(); |
973 | if ( !skipIncidence ) { | 973 | if ( !skipIncidence ) { |
974 | inL = local->incidence( uid ); | 974 | inL = local->incidence( uid ); |
975 | if ( inL ) { // maybe conflict - same uid in both calendars | 975 | if ( inL ) { // maybe conflict - same uid in both calendars |
976 | int maxrev = inL->revision(); | 976 | int maxrev = inL->revision(); |
977 | if ( maxrev < inR->revision() ) | 977 | if ( maxrev < inR->revision() ) |
978 | maxrev = inR->revision(); | 978 | maxrev = inR->revision(); |
979 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 979 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
980 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 980 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
981 | if ( take == 3 ) | 981 | if ( take == 3 ) |
982 | return false; | 982 | return false; |
983 | if ( take == 1 ) {// take local | 983 | if ( take == 1 ) {// take local |
984 | inL->setZaurusUid( inR->zaurusUid() ); | 984 | inL->setZaurusUid( inR->zaurusUid() ); |
985 | remote->deleteIncidence( inR ); | 985 | remote->deleteIncidence( inR ); |
986 | if ( inL->revision() < maxrev ) | 986 | if ( inL->revision() < maxrev ) |
987 | inL->setRevision( maxrev ); | 987 | inL->setRevision( maxrev ); |
988 | remote->addIncidence( inL->clone() ); | 988 | remote->addIncidence( inL->clone() ); |
989 | ++changedRemote; | 989 | ++changedRemote; |
990 | } else { | 990 | } else { |
991 | if ( inR->revision() < maxrev ) | 991 | if ( inR->revision() < maxrev ) |
992 | inR->setRevision( maxrev ); | 992 | inR->setRevision( maxrev ); |
993 | local->deleteIncidence( inL ); | 993 | local->deleteIncidence( inL ); |
994 | local->addIncidence( inR->clone() ); | 994 | local->addIncidence( inR->clone() ); |
995 | ++changedLocal; | 995 | ++changedLocal; |
996 | } | 996 | } |
997 | } | 997 | } |
998 | } else { // no conflict | 998 | } else { // no conflict |
999 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 999 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1000 | QString des = eventLSync->description(); | 1000 | QString des = eventLSync->description(); |
1001 | QString pref = "e"; | 1001 | QString pref = "e"; |
1002 | if ( inR->type() == "Todo" ) | 1002 | if ( inR->type() == "Todo" ) |
1003 | pref = "t"; | 1003 | pref = "t"; |
1004 | if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it | 1004 | if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it |
1005 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1005 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1006 | //remote->deleteIncidence( inR ); | 1006 | //remote->deleteIncidence( inR ); |
1007 | ++deletedEventR; | 1007 | ++deletedEventR; |
1008 | } else { | 1008 | } else { |
1009 | inR->setLastModified( modifiedCalendar ); | 1009 | inR->setLastModified( modifiedCalendar ); |
1010 | local->addIncidence( inR->clone() ); | 1010 | local->addIncidence( inR->clone() ); |
1011 | ++addedEvent; | 1011 | ++addedEvent; |
1012 | } | 1012 | } |
1013 | } else { | 1013 | } else { |
1014 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1014 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1015 | inR->setLastModified( modifiedCalendar ); | 1015 | inR->setLastModified( modifiedCalendar ); |
1016 | local->addIncidence( inR->clone() ); | 1016 | local->addIncidence( inR->clone() ); |
1017 | ++addedEvent; | 1017 | ++addedEvent; |
1018 | } else { | 1018 | } else { |
1019 | checkSharpEvent(eventRSyncSharp, inR); | 1019 | checkSharpEvent(eventRSyncSharp, inR); |
1020 | remote->deleteIncidence( inR ); | 1020 | remote->deleteIncidence( inR ); |
1021 | ++deletedEventR; | 1021 | ++deletedEventR; |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | inR = er.next(); | 1026 | inR = er.next(); |
1027 | } | 1027 | } |
1028 | QPtrList<Incidence> el = local->rawIncidences(); | 1028 | QPtrList<Incidence> el = local->rawIncidences(); |
1029 | inL = el.first(); | 1029 | inL = el.first(); |
1030 | modulo = (el.count()/10)+1; | 1030 | modulo = (el.count()/10)+1; |
1031 | bar.setCaption (i18n("Add / remove events") ); | 1031 | bar.setCaption (i18n("Add / remove events") ); |
1032 | bar.setTotalSteps ( el.count() ) ; | 1032 | bar.setTotalSteps ( el.count() ) ; |
1033 | bar.show(); | 1033 | bar.show(); |
1034 | incCounter = 0; | 1034 | incCounter = 0; |
1035 | 1035 | ||
1036 | while ( inL ) { | 1036 | while ( inL ) { |
1037 | 1037 | ||
1038 | qApp->processEvents(); | 1038 | qApp->processEvents(); |
1039 | if ( ! bar.isVisible() ) | 1039 | if ( ! bar.isVisible() ) |
1040 | return false; | 1040 | return false; |
1041 | if ( incCounter % modulo == 0 ) | 1041 | if ( incCounter % modulo == 0 ) |
1042 | bar.setProgress( incCounter ); | 1042 | bar.setProgress( incCounter ); |
1043 | ++incCounter; | 1043 | ++incCounter; |
1044 | uid = inL->uid(); | 1044 | uid = inL->uid(); |
1045 | bool skipIncidence = false; | 1045 | bool skipIncidence = false; |
1046 | if ( uid.left(21) == QString("last-syncEvent-device") ) | 1046 | if ( uid.left(21) == QString("last-syncEvent-device") ) |
1047 | skipIncidence = true; | 1047 | skipIncidence = true; |
1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1048 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1049 | skipIncidence = true; | 1049 | skipIncidence = true; |
1050 | if ( !skipIncidence ) { | 1050 | if ( !skipIncidence ) { |
1051 | inR = remote->incidence( uid ); | 1051 | inR = remote->incidence( uid ); |
1052 | if ( ! inR ) { | 1052 | if ( ! inR ) { |
1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1054 | if ( inL->zaurusId() >= 0 && mode != 4 ) { | 1054 | if ( inL->zaurusId() >= 0 && mode != 4 ) { |
1055 | local->deleteIncidence( inL ); | 1055 | local->deleteIncidence( inL ); |
1056 | ++deletedEventL; | 1056 | ++deletedEventL; |
1057 | } else { | 1057 | } else { |
1058 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1058 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1059 | inL->setZaurusId( -1 ); | 1059 | inL->setZaurusId( -1 ); |
1060 | ++addedEventR; | 1060 | ++addedEventR; |
1061 | inL->setLastModified( modifiedCalendar ); | 1061 | inL->setLastModified( modifiedCalendar ); |
1062 | remote->addIncidence( inL->clone() ); | 1062 | remote->addIncidence( inL->clone() ); |
1063 | } | 1063 | } |
1064 | } | 1064 | } |
1065 | } else { | 1065 | } else { |
1066 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1066 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1067 | checkSharpEvent(eventLSyncSharp, inL); | 1067 | checkSharpEvent(eventLSyncSharp, inL); |
1068 | local->deleteIncidence( inL ); | 1068 | local->deleteIncidence( inL ); |
1069 | ++deletedEventL; | 1069 | ++deletedEventL; |
1070 | } else { | 1070 | } else { |
1071 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1071 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1072 | ++addedEventR; | 1072 | ++addedEventR; |
1073 | inL->setLastModified( modifiedCalendar ); | 1073 | inL->setLastModified( modifiedCalendar ); |
1074 | remote->addIncidence( inL->clone() ); | 1074 | remote->addIncidence( inL->clone() ); |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } | 1079 | } |
1080 | inL = el.next(); | 1080 | inL = el.next(); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | bar.hide(); | 1083 | bar.hide(); |
1084 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1084 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1085 | eventLSync->setReadOnly( false ); | 1085 | eventLSync->setReadOnly( false ); |
1086 | eventLSync->setDtStart( mLastCalendarSync ); | 1086 | eventLSync->setDtStart( mLastCalendarSync ); |
1087 | eventRSync->setDtStart( mLastCalendarSync ); | 1087 | eventRSync->setDtStart( mLastCalendarSync ); |
1088 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1088 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1089 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1089 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1090 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1090 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1091 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1091 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1092 | eventLSync->setReadOnly( true ); | 1092 | eventLSync->setReadOnly( true ); |
1093 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1093 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1094 | remote->addEvent( eventRSync ); | 1094 | remote->addEvent( eventRSync ); |
1095 | QString mes; | 1095 | QString mes; |
1096 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1096 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1097 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1097 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1098 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1098 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1099 | } | 1099 | } |
1100 | qDebug( mes ); | 1100 | qDebug( mes ); |
1101 | mCalendar->checkAlarmForIncidence( 0, true ); | 1101 | mCalendar->checkAlarmForIncidence( 0, true ); |
1102 | return syncOK; | 1102 | return syncOK; |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | void CalendarView::setSyncDevice( QString s ) | 1105 | void CalendarView::setSyncDevice( QString s ) |
1106 | { | 1106 | { |
1107 | mCurrentSyncDevice= s; | 1107 | mCurrentSyncDevice= s; |
1108 | } | 1108 | } |
1109 | void CalendarView::setSyncName( QString s ) | 1109 | void CalendarView::setSyncName( QString s ) |
1110 | { | 1110 | { |
1111 | mCurrentSyncName= s; | 1111 | mCurrentSyncName= s; |
1112 | } | 1112 | } |
1113 | bool CalendarView::syncCalendar(QString filename, int mode) | 1113 | bool CalendarView::syncCalendar(QString filename, int mode) |
1114 | { | 1114 | { |
1115 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1115 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1116 | CalendarLocal* calendar = new CalendarLocal(); | 1116 | CalendarLocal* calendar = new CalendarLocal(); |
1117 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1117 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1118 | FileStorage* storage = new FileStorage( calendar ); | 1118 | FileStorage* storage = new FileStorage( calendar ); |
1119 | bool syncOK = false; | 1119 | bool syncOK = false; |
1120 | storage->setFileName( filename ); | 1120 | storage->setFileName( filename ); |
1121 | // qDebug("loading ... "); | 1121 | // qDebug("loading ... "); |
1122 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1122 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1123 | getEventViewerDialog()->setSyncMode( true ); | 1123 | getEventViewerDialog()->setSyncMode( true ); |
1124 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1124 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1125 | getEventViewerDialog()->setSyncMode( false ); | 1125 | getEventViewerDialog()->setSyncMode( false ); |
1126 | if ( syncOK ) { | 1126 | if ( syncOK ) { |
1127 | if ( KOPrefs::instance()->mWriteBackFile ) | 1127 | if ( KOPrefs::instance()->mWriteBackFile ) |
1128 | { | 1128 | { |
1129 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1129 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1130 | storage->save(); | 1130 | storage->save(); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | setModified( true ); | 1133 | setModified( true ); |
1134 | } | 1134 | } |
1135 | delete storage; | 1135 | delete storage; |
1136 | delete calendar; | 1136 | delete calendar; |
1137 | if ( syncOK ) | 1137 | if ( syncOK ) |
1138 | updateView(); | 1138 | updateView(); |
1139 | return syncOK; | 1139 | return syncOK; |
1140 | } | 1140 | } |
1141 | void CalendarView::syncSharp() | 1141 | void CalendarView::syncSharp() |
1142 | { | 1142 | { |
1143 | #ifndef DESKTOP_VERSION | 1143 | #ifndef DESKTOP_VERSION |
1144 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1144 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1145 | //mCurrentSyncDevice = "sharp-DTM"; | 1145 | //mCurrentSyncDevice = "sharp-DTM"; |
1146 | if ( KOPrefs::instance()->mAskForPreferences ) | 1146 | if ( KOPrefs::instance()->mAskForPreferences ) |
1147 | edit_sync_options(); | 1147 | edit_sync_options(); |
1148 | qApp->processEvents(); | 1148 | qApp->processEvents(); |
1149 | CalendarLocal* calendar = new CalendarLocal(); | 1149 | CalendarLocal* calendar = new CalendarLocal(); |
1150 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1150 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1151 | bool syncOK = false; | 1151 | bool syncOK = false; |
1152 | SharpFormat sharpFormat; | 1152 | SharpFormat sharpFormat; |
1153 | if ( sharpFormat.load( calendar, mCalendar ) ) { | 1153 | if ( sharpFormat.load( calendar, mCalendar ) ) { |
1154 | getEventViewerDialog()->setSyncMode( true ); | 1154 | getEventViewerDialog()->setSyncMode( true ); |
1155 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1155 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1156 | getEventViewerDialog()->setSyncMode( false ); | 1156 | getEventViewerDialog()->setSyncMode( false ); |
1157 | qApp->processEvents(); | 1157 | qApp->processEvents(); |
1158 | if ( syncOK ) { | 1158 | if ( syncOK ) { |
1159 | if ( KOPrefs::instance()->mWriteBackFile ) | 1159 | if ( KOPrefs::instance()->mWriteBackFile ) |
1160 | { | 1160 | { |
1161 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1161 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1162 | Incidence* inc = iL.first(); | 1162 | Incidence* inc = iL.first(); |
1163 | /* obsolete | 1163 | /* obsolete |
1164 | while ( inc ) { | 1164 | while ( inc ) { |
1165 | inc->setZaurusStat( inc->revision () ); | 1165 | inc->setZaurusStat( inc->revision () ); |
1166 | inc = iL.next(); | 1166 | inc = iL.next(); |
1167 | } | 1167 | } |
1168 | */ | 1168 | */ |
1169 | // pending: clean last sync event description | 1169 | // pending: clean last sync event description |
1170 | sharpFormat.save(calendar); | 1170 | sharpFormat.save(calendar); |
1171 | iL = calendar->rawIncidences(); | 1171 | iL = calendar->rawIncidences(); |
1172 | inc = iL.first(); | 1172 | inc = iL.first(); |
1173 | Incidence* loc; | 1173 | Incidence* loc; |
1174 | while ( inc ) { | 1174 | while ( inc ) { |
1175 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1175 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1176 | loc = mCalendar->incidence(inc->uid() ); | 1176 | loc = mCalendar->incidence(inc->uid() ); |
1177 | if ( loc ) { | 1177 | if ( loc ) { |
1178 | loc->setZaurusId( inc->zaurusId() ); | 1178 | loc->setZaurusId( inc->zaurusId() ); |
1179 | loc->setZaurusUid( inc->zaurusUid() ); | 1179 | loc->setZaurusUid( inc->zaurusUid() ); |
1180 | } | 1180 | } |
1181 | } | 1181 | } |
1182 | inc = iL.next(); | 1182 | inc = iL.next(); |
1183 | } | 1183 | } |
1184 | Incidence* lse = getLastSyncEvent(); | 1184 | Incidence* lse = getLastSyncEvent(); |
1185 | if ( lse ) { | 1185 | if ( lse ) { |
1186 | lse->setReadOnly( false ); | 1186 | lse->setReadOnly( false ); |
1187 | lse->setDescription( "" ); | 1187 | lse->setDescription( "" ); |
1188 | lse->setReadOnly( true ); | 1188 | lse->setReadOnly( true ); |
1189 | } | 1189 | } |
1190 | } | 1190 | } |
1191 | } | 1191 | } |
1192 | setModified( true ); | 1192 | setModified( true ); |
1193 | } else { | 1193 | } else { |
1194 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1194 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1195 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1195 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1196 | question, i18n("Ok")) ; | 1196 | question, i18n("Ok")) ; |
1197 | 1197 | ||
1198 | } | 1198 | } |
1199 | delete calendar; | 1199 | delete calendar; |
1200 | updateView(); | 1200 | updateView(); |
1201 | return ;//syncOK; | 1201 | return ;//syncOK; |
1202 | #endif | 1202 | #endif |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | 1205 | ||
1206 | #include <kabc/stdaddressbook.h> | 1206 | #include <kabc/stdaddressbook.h> |
1207 | bool CalendarView::importBday() | 1207 | bool CalendarView::importBday() |
1208 | { | 1208 | { |
1209 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1209 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1210 | KABC::AddressBook::Iterator it; | 1210 | KABC::AddressBook::Iterator it; |
1211 | int count = 0; | 1211 | int count = 0; |
1212 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1212 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1213 | ++count; | 1213 | ++count; |
1214 | } | 1214 | } |
1215 | QProgressBar bar(count,0 ); | 1215 | QProgressBar bar(count,0 ); |
1216 | int w = 300; | 1216 | int w = 300; |
1217 | if ( QApplication::desktop()->width() < 320 ) | 1217 | if ( QApplication::desktop()->width() < 320 ) |
1218 | w = 220; | 1218 | w = 220; |
1219 | int h = bar.sizeHint().height() ; | 1219 | int h = bar.sizeHint().height() ; |
1220 | int dw = QApplication::desktop()->width(); | 1220 | int dw = QApplication::desktop()->width(); |
1221 | int dh = QApplication::desktop()->height(); | 1221 | int dh = QApplication::desktop()->height(); |
1222 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1222 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1223 | bar.show(); | 1223 | bar.show(); |
1224 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1224 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1225 | qApp->processEvents(); | 1225 | qApp->processEvents(); |
1226 | count = 0; | 1226 | count = 0; |
1227 | int addCount = 0; | 1227 | int addCount = 0; |
1228 | KCal::Attendee* a = 0; | 1228 | KCal::Attendee* a = 0; |
1229 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1229 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1230 | if ( ! bar.isVisible() ) | 1230 | if ( ! bar.isVisible() ) |
1231 | return false; | 1231 | return false; |
1232 | bar.setProgress( count++ ); | 1232 | bar.setProgress( count++ ); |
1233 | qApp->processEvents(); | 1233 | qApp->processEvents(); |
1234 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1234 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1235 | if ( (*it).birthday().date().isValid() ){ | 1235 | if ( (*it).birthday().date().isValid() ){ |
1236 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1236 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1237 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1237 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1238 | ++addCount; | 1238 | ++addCount; |
1239 | } | 1239 | } |
1240 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1240 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1241 | if ( anni.isValid() ){ | 1241 | if ( anni.isValid() ){ |
1242 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1242 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1243 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1243 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1244 | ++addCount; | 1244 | ++addCount; |
1245 | } | 1245 | } |
1246 | } | 1246 | } |
1247 | updateView(); | 1247 | updateView(); |
1248 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1248 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1249 | return true; | 1249 | return true; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1252 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1253 | { | 1253 | { |
1254 | //qDebug("addAnni "); | 1254 | //qDebug("addAnni "); |
1255 | Event * ev = new Event(); | 1255 | Event * ev = new Event(); |
1256 | if ( a ) { | 1256 | if ( a ) { |
1257 | ev->addAttendee( a ); | 1257 | ev->addAttendee( a ); |
1258 | } | 1258 | } |
1259 | QString kind; | 1259 | QString kind; |
1260 | if ( birthday ) | 1260 | if ( birthday ) |
1261 | kind = i18n( "Birthday" ); | 1261 | kind = i18n( "Birthday" ); |
1262 | else | 1262 | else |
1263 | kind = i18n( "Anniversary" ); | 1263 | kind = i18n( "Anniversary" ); |
1264 | ev->setSummary( name + " - " + kind ); | 1264 | ev->setSummary( name + " - " + kind ); |
1265 | ev->setOrganizer( "nobody@nowhere" ); | 1265 | ev->setOrganizer( "nobody@nowhere" ); |
1266 | ev->setCategories( kind ); | 1266 | ev->setCategories( kind ); |
1267 | ev->setDtStart( QDateTime(date) ); | 1267 | ev->setDtStart( QDateTime(date) ); |
1268 | ev->setDtEnd( QDateTime(date) ); | 1268 | ev->setDtEnd( QDateTime(date) ); |
1269 | ev->setFloats( true ); | 1269 | ev->setFloats( true ); |
1270 | Recurrence * rec = ev->recurrence(); | 1270 | Recurrence * rec = ev->recurrence(); |
1271 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1271 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1272 | rec->addYearlyNum( date.month() ); | 1272 | rec->addYearlyNum( date.month() ); |
1273 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1273 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1274 | delete ev; | 1274 | delete ev; |
1275 | return false; | 1275 | return false; |
1276 | } | 1276 | } |
1277 | return true; | 1277 | return true; |
1278 | 1278 | ||
1279 | } | 1279 | } |
1280 | bool CalendarView::importQtopia( const QString &categories, | 1280 | bool CalendarView::importQtopia( const QString &categories, |
1281 | const QString &datebook, | 1281 | const QString &datebook, |
1282 | const QString &todolist ) | 1282 | const QString &todolist ) |
1283 | { | 1283 | { |
1284 | 1284 | ||
1285 | QtopiaFormat qtopiaFormat; | 1285 | QtopiaFormat qtopiaFormat; |
1286 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1286 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1287 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1287 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1288 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1288 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1289 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1289 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1290 | 1290 | ||
1291 | updateView(); | 1291 | updateView(); |
1292 | return true; | 1292 | return true; |
1293 | 1293 | ||
1294 | #if 0 | 1294 | #if 0 |
1295 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1295 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1296 | mCurrentSyncDevice = "qtopia-XML"; | 1296 | mCurrentSyncDevice = "qtopia-XML"; |
1297 | if ( KOPrefs::instance()->mAskForPreferences ) | 1297 | if ( KOPrefs::instance()->mAskForPreferences ) |
1298 | edit_sync_options(); | 1298 | edit_sync_options(); |
1299 | qApp->processEvents(); | 1299 | qApp->processEvents(); |
1300 | CalendarLocal* calendar = new CalendarLocal(); | 1300 | CalendarLocal* calendar = new CalendarLocal(); |
1301 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1301 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1302 | bool syncOK = false; | 1302 | bool syncOK = false; |
1303 | QtopiaFormat qtopiaFormat; | 1303 | QtopiaFormat qtopiaFormat; |
1304 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1304 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1305 | bool loadOk = true; | 1305 | bool loadOk = true; |
1306 | if ( !categories.isEmpty() ) | 1306 | if ( !categories.isEmpty() ) |
1307 | loadOk = qtopiaFormat.load( calendar, categories ); | 1307 | loadOk = qtopiaFormat.load( calendar, categories ); |
1308 | if ( loadOk && !datebook.isEmpty() ) | 1308 | if ( loadOk && !datebook.isEmpty() ) |
1309 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1309 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1310 | if ( loadOk && !todolist.isEmpty() ) | 1310 | if ( loadOk && !todolist.isEmpty() ) |
1311 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1311 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1312 | 1312 | ||
1313 | if ( loadOk ) { | 1313 | if ( loadOk ) { |
1314 | getEventViewerDialog()->setSyncMode( true ); | 1314 | getEventViewerDialog()->setSyncMode( true ); |
1315 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1315 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1316 | getEventViewerDialog()->setSyncMode( false ); | 1316 | getEventViewerDialog()->setSyncMode( false ); |
1317 | qApp->processEvents(); | 1317 | qApp->processEvents(); |
1318 | if ( syncOK ) { | 1318 | if ( syncOK ) { |
1319 | if ( KOPrefs::instance()->mWriteBackFile ) | 1319 | if ( KOPrefs::instance()->mWriteBackFile ) |
1320 | { | 1320 | { |
1321 | // write back XML file | 1321 | // write back XML file |
1322 | 1322 | ||
1323 | } | 1323 | } |
1324 | setModified( true ); | 1324 | setModified( true ); |
1325 | } | 1325 | } |
1326 | } else { | 1326 | } else { |
1327 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1327 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1328 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1328 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1329 | question, i18n("Ok")) ; | 1329 | question, i18n("Ok")) ; |
1330 | } | 1330 | } |
1331 | delete calendar; | 1331 | delete calendar; |
1332 | updateView(); | 1332 | updateView(); |
1333 | return syncOK; | 1333 | return syncOK; |
1334 | 1334 | ||
1335 | 1335 | ||
1336 | #endif | 1336 | #endif |
1337 | 1337 | ||
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | void CalendarView::setSyncEventsReadOnly() | 1340 | void CalendarView::setSyncEventsReadOnly() |
1341 | { | 1341 | { |
1342 | Event * ev; | 1342 | Event * ev; |
1343 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1343 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1344 | ev = eL.first(); | 1344 | ev = eL.first(); |
1345 | while ( ev ) { | 1345 | while ( ev ) { |
1346 | if ( ev->uid().left(21) == QString("last-syncEvent-device") ) | 1346 | if ( ev->uid().left(21) == QString("last-syncEvent-device") ) |
1347 | ev->setReadOnly( true ); | 1347 | ev->setReadOnly( true ); |
1348 | ev = eL.next(); | 1348 | ev = eL.next(); |
1349 | } | 1349 | } |
1350 | } | 1350 | } |
1351 | bool CalendarView::openCalendar(QString filename, bool merge) | 1351 | bool CalendarView::openCalendar(QString filename, bool merge) |
1352 | { | 1352 | { |
1353 | 1353 | ||
1354 | if (filename.isEmpty()) { | 1354 | if (filename.isEmpty()) { |
1355 | return false; | 1355 | return false; |
1356 | } | 1356 | } |
1357 | 1357 | ||
1358 | if (!QFile::exists(filename)) { | 1358 | if (!QFile::exists(filename)) { |
1359 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1359 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1360 | return false; | 1360 | return false; |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | globalFlagBlockAgenda = 1; | 1363 | globalFlagBlockAgenda = 1; |
1364 | if (!merge) mCalendar->close(); | 1364 | if (!merge) mCalendar->close(); |
1365 | 1365 | ||
1366 | mStorage->setFileName( filename ); | 1366 | mStorage->setFileName( filename ); |
1367 | 1367 | ||
1368 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1368 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1369 | if ( merge ) ;//setModified( true ); | 1369 | if ( merge ) ;//setModified( true ); |
1370 | else { | 1370 | else { |
1371 | //setModified( true ); | 1371 | //setModified( true ); |
1372 | mViewManager->setDocumentId( filename ); | 1372 | mViewManager->setDocumentId( filename ); |
1373 | mDialogManager->setDocumentId( filename ); | 1373 | mDialogManager->setDocumentId( filename ); |
1374 | mTodoList->setDocumentId( filename ); | 1374 | mTodoList->setDocumentId( filename ); |
1375 | } | 1375 | } |
1376 | globalFlagBlockAgenda = 2; | 1376 | globalFlagBlockAgenda = 2; |
1377 | // if ( getLastSyncEvent() ) | 1377 | // if ( getLastSyncEvent() ) |
1378 | // getLastSyncEvent()->setReadOnly( true ); | 1378 | // getLastSyncEvent()->setReadOnly( true ); |
1379 | mCalendar->reInitAlarmSettings(); | 1379 | mCalendar->reInitAlarmSettings(); |
1380 | setSyncEventsReadOnly(); | 1380 | setSyncEventsReadOnly(); |
1381 | updateUnmanagedViews(); | 1381 | updateUnmanagedViews(); |
1382 | updateView(); | 1382 | updateView(); |
1383 | if ( filename != MainWindow::defaultFileName() ) | 1383 | if ( filename != MainWindow::defaultFileName() ) |
1384 | saveCalendar( MainWindow::defaultFileName() ); | 1384 | saveCalendar( MainWindow::defaultFileName() ); |
1385 | loadedFileVersion = QDateTime::currentDateTime(); | 1385 | loadedFileVersion = QDateTime::currentDateTime(); |
1386 | return true; | 1386 | return true; |
1387 | } else { | 1387 | } else { |
1388 | // while failing to load, the calendar object could | 1388 | // while failing to load, the calendar object could |
1389 | // have become partially populated. Clear it out. | 1389 | // have become partially populated. Clear it out. |
1390 | if ( !merge ) mCalendar->close(); | 1390 | if ( !merge ) mCalendar->close(); |
1391 | 1391 | ||
1392 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1392 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1393 | 1393 | ||
1394 | globalFlagBlockAgenda = 2; | 1394 | globalFlagBlockAgenda = 2; |
1395 | updateView(); | 1395 | updateView(); |
1396 | } | 1396 | } |
1397 | return false; | 1397 | return false; |
1398 | } | 1398 | } |
1399 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1399 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1400 | { | 1400 | { |
1401 | loadedFileVersion = dt; | 1401 | loadedFileVersion = dt; |
1402 | } | 1402 | } |
1403 | bool CalendarView::checkFileChanged(QString fn) | 1403 | bool CalendarView::checkFileChanged(QString fn) |
1404 | { | 1404 | { |
1405 | QFileInfo finf ( fn ); | 1405 | QFileInfo finf ( fn ); |
1406 | if ( !finf.exists() ) | 1406 | if ( !finf.exists() ) |
1407 | return true; | 1407 | return true; |
1408 | QDateTime dt = finf.lastModified (); | 1408 | QDateTime dt = finf.lastModified (); |
1409 | if ( dt <= loadedFileVersion ) | 1409 | if ( dt <= loadedFileVersion ) |
1410 | return false; | 1410 | return false; |
1411 | return true; | 1411 | return true; |
1412 | 1412 | ||
1413 | } | 1413 | } |
1414 | bool CalendarView::checkFileVersion(QString fn) | 1414 | bool CalendarView::checkFileVersion(QString fn) |
1415 | { | 1415 | { |
1416 | QFileInfo finf ( fn ); | 1416 | QFileInfo finf ( fn ); |
1417 | if ( !finf.exists() ) | 1417 | if ( !finf.exists() ) |
1418 | return true; | 1418 | return true; |
1419 | QDateTime dt = finf.lastModified (); | 1419 | QDateTime dt = finf.lastModified (); |
1420 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1420 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1421 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1421 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1422 | if ( dt <= loadedFileVersion ) | 1422 | if ( dt <= loadedFileVersion ) |
1423 | return true; | 1423 | return true; |
1424 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , | 1424 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , |
1425 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1425 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1426 | i18n("Sync+save")); | 1426 | i18n("Sync+save")); |
1427 | 1427 | ||
1428 | if ( km == KMessageBox::Cancel ) | 1428 | if ( km == KMessageBox::Cancel ) |
1429 | return false; | 1429 | return false; |
1430 | if ( km == KMessageBox::Yes ) | 1430 | if ( km == KMessageBox::Yes ) |
1431 | return true; | 1431 | return true; |
1432 | 1432 | ||
1433 | setSyncDevice("deleteaftersync" ); | 1433 | setSyncDevice("deleteaftersync" ); |
1434 | KOPrefs::instance()->mAskForPreferences = true; | 1434 | KOPrefs::instance()->mAskForPreferences = true; |
1435 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1435 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1436 | KOPrefs::instance()->mWriteBackFile = false; | 1436 | KOPrefs::instance()->mWriteBackFile = false; |
1437 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1437 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1438 | KOPrefs::instance()->mShowSyncSummary = false; | 1438 | KOPrefs::instance()->mShowSyncSummary = false; |
1439 | syncCalendar( fn, 3 ); | 1439 | syncCalendar( fn, 3 ); |
1440 | Event * e = getLastSyncEvent(); | 1440 | Event * e = getLastSyncEvent(); |
1441 | mCalendar->deleteEvent ( e ); | 1441 | mCalendar->deleteEvent ( e ); |
1442 | updateView(); | 1442 | updateView(); |
1443 | return true; | 1443 | return true; |
1444 | } | 1444 | } |
1445 | 1445 | ||
1446 | bool CalendarView::saveCalendar( QString filename ) | 1446 | bool CalendarView::saveCalendar( QString filename ) |
1447 | { | 1447 | { |
1448 | 1448 | ||
1449 | // Store back all unsaved data into calendar object | 1449 | // Store back all unsaved data into calendar object |
1450 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1450 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1451 | if ( mViewManager->currentView() ) | 1451 | if ( mViewManager->currentView() ) |
1452 | mViewManager->currentView()->flushView(); | 1452 | mViewManager->currentView()->flushView(); |
1453 | 1453 | ||
1454 | //mStorage->setFileName( filename ); | 1454 | //mStorage->setFileName( filename ); |
1455 | 1455 | ||
1456 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1456 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1457 | mStorage->setFileName( filename ); | 1457 | mStorage->setFileName( filename ); |
1458 | bool success; | 1458 | bool success; |
1459 | success = mStorage->save(); | 1459 | success = mStorage->save(); |
1460 | if ( !success ) { | 1460 | if ( !success ) { |
1461 | return false; | 1461 | return false; |
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | return true; | 1464 | return true; |
1465 | } | 1465 | } |
1466 | 1466 | ||
1467 | void CalendarView::closeCalendar() | 1467 | void CalendarView::closeCalendar() |
1468 | { | 1468 | { |
1469 | 1469 | ||
1470 | // child windows no longer valid | 1470 | // child windows no longer valid |
1471 | emit closingDown(); | 1471 | emit closingDown(); |
1472 | 1472 | ||
1473 | mCalendar->close(); | 1473 | mCalendar->close(); |
1474 | setModified(false); | 1474 | setModified(false); |
1475 | updateView(); | 1475 | updateView(); |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | void CalendarView::archiveCalendar() | 1478 | void CalendarView::archiveCalendar() |
1479 | { | 1479 | { |
1480 | mDialogManager->showArchiveDialog(); | 1480 | mDialogManager->showArchiveDialog(); |
1481 | } | 1481 | } |
1482 | 1482 | ||
1483 | 1483 | ||
1484 | void CalendarView::readSettings() | 1484 | void CalendarView::readSettings() |
1485 | { | 1485 | { |
1486 | 1486 | ||
1487 | 1487 | ||
1488 | // mViewManager->showAgendaView(); | 1488 | // mViewManager->showAgendaView(); |
1489 | QString str; | 1489 | QString str; |
1490 | //qDebug("CalendarView::readSettings() "); | 1490 | //qDebug("CalendarView::readSettings() "); |
1491 | // read settings from the KConfig, supplying reasonable | 1491 | // read settings from the KConfig, supplying reasonable |
1492 | // defaults where none are to be found | 1492 | // defaults where none are to be found |
1493 | KConfig *config = KOGlobals::config(); | 1493 | KConfig *config = KOGlobals::config(); |
1494 | #ifndef KORG_NOSPLITTER | 1494 | #ifndef KORG_NOSPLITTER |
1495 | config->setGroup("KOrganizer Geometry"); | 1495 | config->setGroup("KOrganizer Geometry"); |
1496 | 1496 | ||
1497 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1497 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1498 | if (sizes.count() != 2) { | 1498 | if (sizes.count() != 2) { |
1499 | sizes << mDateNavigator->minimumSizeHint().width(); | 1499 | sizes << mDateNavigator->minimumSizeHint().width(); |
1500 | sizes << 300; | 1500 | sizes << 300; |
1501 | } | 1501 | } |
1502 | mPanner->setSizes(sizes); | 1502 | mPanner->setSizes(sizes); |
1503 | 1503 | ||
1504 | sizes = config->readIntListEntry("Separator2"); | 1504 | sizes = config->readIntListEntry("Separator2"); |
1505 | if ( ( mResourceView && sizes.count() == 4 ) || | 1505 | if ( ( mResourceView && sizes.count() == 4 ) || |
1506 | ( !mResourceView && sizes.count() == 3 ) ) { | 1506 | ( !mResourceView && sizes.count() == 3 ) ) { |
1507 | mLeftSplitter->setSizes(sizes); | 1507 | mLeftSplitter->setSizes(sizes); |
1508 | } | 1508 | } |
1509 | #endif | 1509 | #endif |
1510 | globalFlagBlockAgenda = 1; | 1510 | globalFlagBlockAgenda = 1; |
1511 | mViewManager->showAgendaView(); | 1511 | mViewManager->showAgendaView(); |
1512 | //mViewManager->readSettings( config ); | 1512 | //mViewManager->readSettings( config ); |
1513 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1513 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1514 | readFilterSettings(config); | 1514 | readFilterSettings(config); |
1515 | config->setGroup( "Views" ); | 1515 | config->setGroup( "Views" ); |
1516 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1516 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1517 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1517 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1518 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1518 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1519 | else mNavigator->selectDates( dateCount ); | 1519 | else mNavigator->selectDates( dateCount ); |
1520 | // mViewManager->readSettings( config ); | 1520 | // mViewManager->readSettings( config ); |
1521 | updateConfig(); | 1521 | updateConfig(); |
1522 | globalFlagBlockAgenda = 2; | 1522 | globalFlagBlockAgenda = 2; |
1523 | mViewManager->readSettings( config ); | 1523 | mViewManager->readSettings( config ); |
1524 | #ifdef DESKTOP_VERSION | 1524 | #ifdef DESKTOP_VERSION |
1525 | config->setGroup("WidgetLayout"); | 1525 | config->setGroup("WidgetLayout"); |
1526 | QStringList list; | 1526 | QStringList list; |
1527 | list = config->readListEntry("MainLayout"); | 1527 | list = config->readListEntry("MainLayout"); |
1528 | int x,y,w,h; | 1528 | int x,y,w,h; |
1529 | if ( ! list.isEmpty() ) { | 1529 | if ( ! list.isEmpty() ) { |
1530 | x = list[0].toInt(); | 1530 | x = list[0].toInt(); |
1531 | y = list[1].toInt(); | 1531 | y = list[1].toInt(); |
1532 | w = list[2].toInt(); | 1532 | w = list[2].toInt(); |
1533 | h = list[3].toInt(); | 1533 | h = list[3].toInt(); |
1534 | topLevelWidget()->setGeometry(x,y,w,h); | 1534 | topLevelWidget()->setGeometry(x,y,w,h); |
1535 | 1535 | ||
1536 | } else { | 1536 | } else { |
1537 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1537 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1538 | } | 1538 | } |
1539 | list = config->readListEntry("EditEventLayout"); | 1539 | list = config->readListEntry("EditEventLayout"); |
1540 | if ( ! list.isEmpty() ) { | 1540 | if ( ! list.isEmpty() ) { |
1541 | x = list[0].toInt(); | 1541 | x = list[0].toInt(); |
1542 | y = list[1].toInt(); | 1542 | y = list[1].toInt(); |
1543 | w = list[2].toInt(); | 1543 | w = list[2].toInt(); |
1544 | h = list[3].toInt(); | 1544 | h = list[3].toInt(); |
1545 | mEventEditor->setGeometry(x,y,w,h); | 1545 | mEventEditor->setGeometry(x,y,w,h); |
1546 | 1546 | ||
1547 | } | 1547 | } |
1548 | list = config->readListEntry("EditTodoLayout"); | 1548 | list = config->readListEntry("EditTodoLayout"); |
1549 | if ( ! list.isEmpty() ) { | 1549 | if ( ! list.isEmpty() ) { |
1550 | x = list[0].toInt(); | 1550 | x = list[0].toInt(); |
1551 | y = list[1].toInt(); | 1551 | y = list[1].toInt(); |
1552 | w = list[2].toInt(); | 1552 | w = list[2].toInt(); |
1553 | h = list[3].toInt(); | 1553 | h = list[3].toInt(); |
1554 | mTodoEditor->setGeometry(x,y,w,h); | 1554 | mTodoEditor->setGeometry(x,y,w,h); |
1555 | 1555 | ||
1556 | } | 1556 | } |
1557 | list = config->readListEntry("ViewerLayout"); | 1557 | list = config->readListEntry("ViewerLayout"); |
1558 | if ( ! list.isEmpty() ) { | 1558 | if ( ! list.isEmpty() ) { |
1559 | x = list[0].toInt(); | 1559 | x = list[0].toInt(); |
1560 | y = list[1].toInt(); | 1560 | y = list[1].toInt(); |
1561 | w = list[2].toInt(); | 1561 | w = list[2].toInt(); |
1562 | h = list[3].toInt(); | 1562 | h = list[3].toInt(); |
1563 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1563 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1564 | } | 1564 | } |
1565 | #endif | 1565 | #endif |
1566 | 1566 | ||
1567 | } | 1567 | } |
1568 | 1568 | ||
1569 | 1569 | ||
1570 | void CalendarView::writeSettings() | 1570 | void CalendarView::writeSettings() |
1571 | { | 1571 | { |
1572 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1572 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1573 | 1573 | ||
1574 | KConfig *config = KOGlobals::config(); | 1574 | KConfig *config = KOGlobals::config(); |
1575 | 1575 | ||
1576 | #ifndef KORG_NOSPLITTER | 1576 | #ifndef KORG_NOSPLITTER |
1577 | config->setGroup("KOrganizer Geometry"); | 1577 | config->setGroup("KOrganizer Geometry"); |
1578 | 1578 | ||
1579 | QValueList<int> list = mPanner->sizes(); | 1579 | QValueList<int> list = mPanner->sizes(); |
1580 | config->writeEntry("Separator1",list); | 1580 | config->writeEntry("Separator1",list); |
1581 | 1581 | ||
1582 | list = mLeftSplitter->sizes(); | 1582 | list = mLeftSplitter->sizes(); |
1583 | config->writeEntry("Separator2",list); | 1583 | config->writeEntry("Separator2",list); |
1584 | #endif | 1584 | #endif |
1585 | 1585 | ||
1586 | mViewManager->writeSettings( config ); | 1586 | mViewManager->writeSettings( config ); |
1587 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1587 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1588 | mDialogManager->writeSettings( config ); | 1588 | mDialogManager->writeSettings( config ); |
1589 | //KOPrefs::instance()->usrWriteConfig(); | 1589 | //KOPrefs::instance()->usrWriteConfig(); |
1590 | KOPrefs::instance()->writeConfig(); | 1590 | KOPrefs::instance()->writeConfig(); |
1591 | 1591 | ||
1592 | writeFilterSettings(config); | 1592 | writeFilterSettings(config); |
1593 | 1593 | ||
1594 | config->setGroup( "Views" ); | 1594 | config->setGroup( "Views" ); |
1595 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1595 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1596 | 1596 | ||
1597 | #ifdef DESKTOP_VERSION | 1597 | #ifdef DESKTOP_VERSION |
1598 | config->setGroup("WidgetLayout"); | 1598 | config->setGroup("WidgetLayout"); |
1599 | QStringList list ;//= config->readListEntry("MainLayout"); | 1599 | QStringList list ;//= config->readListEntry("MainLayout"); |
1600 | int x,y,w,h; | 1600 | int x,y,w,h; |
1601 | QWidget* wid; | 1601 | QWidget* wid; |
1602 | wid = topLevelWidget(); | 1602 | wid = topLevelWidget(); |
1603 | x = wid->geometry().x(); | 1603 | x = wid->geometry().x(); |
1604 | y = wid->geometry().y(); | 1604 | y = wid->geometry().y(); |
1605 | w = wid->width(); | 1605 | w = wid->width(); |
1606 | h = wid->height(); | 1606 | h = wid->height(); |
1607 | list.clear(); | 1607 | list.clear(); |
1608 | list << QString::number( x ); | 1608 | list << QString::number( x ); |
1609 | list << QString::number( y ); | 1609 | list << QString::number( y ); |
1610 | list << QString::number( w ); | 1610 | list << QString::number( w ); |
1611 | list << QString::number( h ); | 1611 | list << QString::number( h ); |
1612 | config->writeEntry("MainLayout",list ); | 1612 | config->writeEntry("MainLayout",list ); |
1613 | 1613 | ||
1614 | wid = mEventEditor; | 1614 | wid = mEventEditor; |
1615 | x = wid->geometry().x(); | 1615 | x = wid->geometry().x(); |
1616 | y = wid->geometry().y(); | 1616 | y = wid->geometry().y(); |
1617 | w = wid->width(); | 1617 | w = wid->width(); |
1618 | h = wid->height(); | 1618 | h = wid->height(); |
1619 | list.clear(); | 1619 | list.clear(); |
1620 | list << QString::number( x ); | 1620 | list << QString::number( x ); |
1621 | list << QString::number( y ); | 1621 | list << QString::number( y ); |
1622 | list << QString::number( w ); | 1622 | list << QString::number( w ); |
1623 | list << QString::number( h ); | 1623 | list << QString::number( h ); |
1624 | config->writeEntry("EditEventLayout",list ); | 1624 | config->writeEntry("EditEventLayout",list ); |
1625 | 1625 | ||
1626 | wid = mTodoEditor; | 1626 | wid = mTodoEditor; |
1627 | x = wid->geometry().x(); | 1627 | x = wid->geometry().x(); |
1628 | y = wid->geometry().y(); | 1628 | y = wid->geometry().y(); |
1629 | w = wid->width(); | 1629 | w = wid->width(); |
1630 | h = wid->height(); | 1630 | h = wid->height(); |
1631 | list.clear(); | 1631 | list.clear(); |
1632 | list << QString::number( x ); | 1632 | list << QString::number( x ); |
1633 | list << QString::number( y ); | 1633 | list << QString::number( y ); |
1634 | list << QString::number( w ); | 1634 | list << QString::number( w ); |
1635 | list << QString::number( h ); | 1635 | list << QString::number( h ); |
1636 | config->writeEntry("EditTodoLayout",list ); | 1636 | config->writeEntry("EditTodoLayout",list ); |
1637 | wid = getEventViewerDialog(); | 1637 | wid = getEventViewerDialog(); |
1638 | x = wid->geometry().x(); | 1638 | x = wid->geometry().x(); |
1639 | y = wid->geometry().y(); | 1639 | y = wid->geometry().y(); |
1640 | w = wid->width(); | 1640 | w = wid->width(); |
1641 | h = wid->height(); | 1641 | h = wid->height(); |
1642 | list.clear(); | 1642 | list.clear(); |
1643 | list << QString::number( x ); | 1643 | list << QString::number( x ); |
1644 | list << QString::number( y ); | 1644 | list << QString::number( y ); |
1645 | list << QString::number( w ); | 1645 | list << QString::number( w ); |
1646 | list << QString::number( h ); | 1646 | list << QString::number( h ); |
1647 | config->writeEntry("ViewerLayout",list ); | 1647 | config->writeEntry("ViewerLayout",list ); |
1648 | wid = mDialogManager->getSearchDialog(); | 1648 | wid = mDialogManager->getSearchDialog(); |
1649 | if ( wid ) { | 1649 | if ( wid ) { |
1650 | x = wid->geometry().x(); | 1650 | x = wid->geometry().x(); |
1651 | y = wid->geometry().y(); | 1651 | y = wid->geometry().y(); |
1652 | w = wid->width(); | 1652 | w = wid->width(); |
1653 | h = wid->height(); | 1653 | h = wid->height(); |
1654 | list.clear(); | 1654 | list.clear(); |
1655 | list << QString::number( x ); | 1655 | list << QString::number( x ); |
1656 | list << QString::number( y ); | 1656 | list << QString::number( y ); |
1657 | list << QString::number( w ); | 1657 | list << QString::number( w ); |
1658 | list << QString::number( h ); | 1658 | list << QString::number( h ); |
1659 | config->writeEntry("SearchLayout",list ); | 1659 | config->writeEntry("SearchLayout",list ); |
1660 | } | 1660 | } |
1661 | #endif | 1661 | #endif |
1662 | 1662 | ||
1663 | 1663 | ||
1664 | config->sync(); | 1664 | config->sync(); |
1665 | } | 1665 | } |
1666 | 1666 | ||
1667 | void CalendarView::readFilterSettings(KConfig *config) | 1667 | void CalendarView::readFilterSettings(KConfig *config) |
1668 | { | 1668 | { |
1669 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1669 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1670 | 1670 | ||
1671 | mFilters.clear(); | 1671 | mFilters.clear(); |
1672 | 1672 | ||
1673 | config->setGroup("General"); | 1673 | config->setGroup("General"); |
1674 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1674 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1675 | 1675 | ||
1676 | QStringList::ConstIterator it = filterList.begin(); | 1676 | QStringList::ConstIterator it = filterList.begin(); |
1677 | QStringList::ConstIterator end = filterList.end(); | 1677 | QStringList::ConstIterator end = filterList.end(); |
1678 | while(it != end) { | 1678 | while(it != end) { |
1679 | // kdDebug() << " filter: " << (*it) << endl; | 1679 | // kdDebug() << " filter: " << (*it) << endl; |
1680 | 1680 | ||
1681 | CalFilter *filter; | 1681 | CalFilter *filter; |
1682 | filter = new CalFilter(*it); | 1682 | filter = new CalFilter(*it); |
1683 | config->setGroup("Filter_" + (*it)); | 1683 | config->setGroup("Filter_" + (*it)); |
1684 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1684 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1685 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1685 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1686 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1686 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1687 | mFilters.append(filter); | 1687 | mFilters.append(filter); |
1688 | 1688 | ||
1689 | ++it; | 1689 | ++it; |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | if (mFilters.count() == 0) { | 1692 | if (mFilters.count() == 0) { |
1693 | CalFilter *filter = new CalFilter(i18n("Default")); | 1693 | CalFilter *filter = new CalFilter(i18n("Default")); |
1694 | mFilters.append(filter); | 1694 | mFilters.append(filter); |
1695 | } | 1695 | } |
1696 | mFilterView->updateFilters(); | 1696 | mFilterView->updateFilters(); |
1697 | config->setGroup("FilterView"); | 1697 | config->setGroup("FilterView"); |
1698 | 1698 | ||
1699 | mFilterView->blockSignals(true); | 1699 | mFilterView->blockSignals(true); |
1700 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1700 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1701 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1701 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1702 | mFilterView->blockSignals(false); | 1702 | mFilterView->blockSignals(false); |
1703 | // We do it manually to avoid it being done twice by the above calls | 1703 | // We do it manually to avoid it being done twice by the above calls |
1704 | updateFilter(); | 1704 | updateFilter(); |
1705 | } | 1705 | } |
1706 | 1706 | ||
1707 | void CalendarView::writeFilterSettings(KConfig *config) | 1707 | void CalendarView::writeFilterSettings(KConfig *config) |
1708 | { | 1708 | { |
1709 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1709 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1710 | 1710 | ||
1711 | QStringList filterList; | 1711 | QStringList filterList; |
1712 | 1712 | ||
1713 | CalFilter *filter = mFilters.first(); | 1713 | CalFilter *filter = mFilters.first(); |
1714 | while(filter) { | 1714 | while(filter) { |
1715 | // kdDebug() << " fn: " << filter->name() << endl; | 1715 | // kdDebug() << " fn: " << filter->name() << endl; |
1716 | filterList << filter->name(); | 1716 | filterList << filter->name(); |
1717 | config->setGroup("Filter_" + filter->name()); | 1717 | config->setGroup("Filter_" + filter->name()); |
1718 | config->writeEntry("Criteria",filter->criteria()); | 1718 | config->writeEntry("Criteria",filter->criteria()); |
1719 | config->writeEntry("CategoryList",filter->categoryList()); | 1719 | config->writeEntry("CategoryList",filter->categoryList()); |
1720 | filter = mFilters.next(); | 1720 | filter = mFilters.next(); |
1721 | } | 1721 | } |
1722 | config->setGroup("General"); | 1722 | config->setGroup("General"); |
1723 | config->writeEntry("CalendarFilters",filterList); | 1723 | config->writeEntry("CalendarFilters",filterList); |
1724 | 1724 | ||
1725 | config->setGroup("FilterView"); | 1725 | config->setGroup("FilterView"); |
1726 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1726 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1727 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1727 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1728 | } | 1728 | } |
1729 | 1729 | ||
1730 | 1730 | ||
1731 | void CalendarView::goToday() | 1731 | void CalendarView::goToday() |
1732 | { | 1732 | { |
1733 | mNavigator->selectToday(); | 1733 | mNavigator->selectToday(); |
1734 | } | 1734 | } |
1735 | 1735 | ||
1736 | void CalendarView::goNext() | 1736 | void CalendarView::goNext() |
1737 | { | 1737 | { |
1738 | mNavigator->selectNext(); | 1738 | mNavigator->selectNext(); |
1739 | } | 1739 | } |
1740 | 1740 | ||
1741 | void CalendarView::goPrevious() | 1741 | void CalendarView::goPrevious() |
1742 | { | 1742 | { |
1743 | mNavigator->selectPrevious(); | 1743 | mNavigator->selectPrevious(); |
1744 | } | 1744 | } |
1745 | void CalendarView::goNextMonth() | 1745 | void CalendarView::goNextMonth() |
1746 | { | 1746 | { |
1747 | mNavigator->selectNextMonth(); | 1747 | mNavigator->selectNextMonth(); |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | void CalendarView::goPreviousMonth() | 1750 | void CalendarView::goPreviousMonth() |
1751 | { | 1751 | { |
1752 | mNavigator->selectPreviousMonth(); | 1752 | mNavigator->selectPreviousMonth(); |
1753 | } | 1753 | } |
1754 | void CalendarView::writeLocale() | 1754 | void CalendarView::writeLocale() |
1755 | { | 1755 | { |
1756 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1756 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1757 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1757 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1758 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1758 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1759 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1759 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1760 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1760 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1761 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1761 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1762 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1762 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1763 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1763 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1764 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1764 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1765 | KOPrefs::instance()->mDaylightsavingStart, | 1765 | KOPrefs::instance()->mDaylightsavingStart, |
1766 | KOPrefs::instance()->mDaylightsavingEnd ); | 1766 | KOPrefs::instance()->mDaylightsavingEnd ); |
1767 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1767 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1768 | } | 1768 | } |
1769 | void CalendarView::updateConfig() | 1769 | void CalendarView::updateConfig() |
1770 | { | 1770 | { |
1771 | writeLocale(); | 1771 | writeLocale(); |
1772 | if ( KOPrefs::instance()->mUseAppColors ) | 1772 | if ( KOPrefs::instance()->mUseAppColors ) |
1773 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1773 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1774 | emit configChanged(); | 1774 | emit configChanged(); |
1775 | mTodoList->updateConfig(); | 1775 | mTodoList->updateConfig(); |
1776 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1776 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1777 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1777 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1778 | // To make the "fill window" configurations work | 1778 | // To make the "fill window" configurations work |
1779 | //mViewManager->raiseCurrentView(); | 1779 | //mViewManager->raiseCurrentView(); |
1780 | } | 1780 | } |
1781 | 1781 | ||
1782 | 1782 | ||
1783 | void CalendarView::eventChanged(Event *event) | 1783 | void CalendarView::eventChanged(Event *event) |
1784 | { | 1784 | { |
1785 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1785 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1786 | //updateUnmanagedViews(); | 1786 | //updateUnmanagedViews(); |
1787 | } | 1787 | } |
1788 | 1788 | ||
1789 | void CalendarView::eventAdded(Event *event) | 1789 | void CalendarView::eventAdded(Event *event) |
1790 | { | 1790 | { |
1791 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1791 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1792 | } | 1792 | } |
1793 | 1793 | ||
1794 | void CalendarView::eventToBeDeleted(Event *) | 1794 | void CalendarView::eventToBeDeleted(Event *) |
1795 | { | 1795 | { |
1796 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1796 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1797 | } | 1797 | } |
1798 | 1798 | ||
1799 | void CalendarView::eventDeleted() | 1799 | void CalendarView::eventDeleted() |
1800 | { | 1800 | { |
1801 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1801 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1802 | } | 1802 | } |
1803 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1803 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1804 | { | 1804 | { |
1805 | changeIncidenceDisplay((Incidence *)which, action); | 1805 | changeIncidenceDisplay((Incidence *)which, action); |
1806 | } | 1806 | } |
1807 | void CalendarView::checkZaurusId( int id, bool todo ) | 1807 | void CalendarView::checkZaurusId( int id, bool todo ) |
1808 | { | 1808 | { |
1809 | if ( id >= 0 ) { | 1809 | if ( id >= 0 ) { |
1810 | Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); | 1810 | Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); |
1811 | if ( lse ) { | 1811 | if ( lse ) { |
1812 | QString des = lse->description(); | 1812 | QString des = lse->description(); |
1813 | QString pref = "e"; | 1813 | QString pref = "e"; |
1814 | if ( todo ) | 1814 | if ( todo ) |
1815 | pref = "t"; | 1815 | pref = "t"; |
1816 | des += pref+ QString::number ( id ) + ","; | 1816 | des += pref+ QString::number ( id ) + ","; |
1817 | lse->setReadOnly( false ); | 1817 | lse->setReadOnly( false ); |
1818 | lse->setDescription( des ); | 1818 | lse->setDescription( des ); |
1819 | lse->setReadOnly( true ); | 1819 | lse->setReadOnly( true ); |
1820 | } | 1820 | } |
1821 | } | 1821 | } |
1822 | } | 1822 | } |
1823 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1823 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1824 | { | 1824 | { |
1825 | updateUnmanagedViews(); | 1825 | updateUnmanagedViews(); |
1826 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1826 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1827 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1827 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1828 | mCalendar->checkAlarmForIncidence( 0, true ); | 1828 | mCalendar->checkAlarmForIncidence( 0, true ); |
1829 | if ( mEventViewerDialog ) | 1829 | if ( mEventViewerDialog ) |
1830 | mEventViewerDialog->hide(); | 1830 | mEventViewerDialog->hide(); |
1831 | } | 1831 | } |
1832 | else | 1832 | else |
1833 | mCalendar->checkAlarmForIncidence( which , false ); | 1833 | mCalendar->checkAlarmForIncidence( which , false ); |
1834 | } | 1834 | } |
1835 | 1835 | ||
1836 | // most of the changeEventDisplays() right now just call the view's | 1836 | // most of the changeEventDisplays() right now just call the view's |
1837 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1837 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1838 | void CalendarView::changeEventDisplay(Event *which, int action) | 1838 | void CalendarView::changeEventDisplay(Event *which, int action) |
1839 | { | 1839 | { |
1840 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1840 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1841 | changeIncidenceDisplay((Incidence *)which, action); | 1841 | changeIncidenceDisplay((Incidence *)which, action); |
1842 | mDateNavigator->updateView(); | 1842 | mDateNavigator->updateView(); |
1843 | //mDialogManager->updateSearchDialog(); | 1843 | //mDialogManager->updateSearchDialog(); |
1844 | 1844 | ||
1845 | if (which) { | 1845 | if (which) { |
1846 | // If there is an event view visible update the display | 1846 | // If there is an event view visible update the display |
1847 | mViewManager->currentView()->changeEventDisplay(which,action); | 1847 | mViewManager->currentView()->changeEventDisplay(which,action); |
1848 | // TODO: check, if update needed | 1848 | // TODO: check, if update needed |
1849 | // if (which->getTodoStatus()) { | 1849 | // if (which->getTodoStatus()) { |
1850 | mTodoList->updateView(); | 1850 | mTodoList->updateView(); |
1851 | // } | 1851 | // } |
1852 | } else { | 1852 | } else { |
1853 | mViewManager->currentView()->updateView(); | 1853 | mViewManager->currentView()->updateView(); |
1854 | } | 1854 | } |
1855 | } | 1855 | } |
1856 | 1856 | ||
1857 | 1857 | ||
1858 | void CalendarView::updateTodoViews() | 1858 | void CalendarView::updateTodoViews() |
1859 | { | 1859 | { |
1860 | 1860 | ||
1861 | mTodoList->updateView(); | 1861 | mTodoList->updateView(); |
1862 | mViewManager->currentView()->updateView(); | 1862 | mViewManager->currentView()->updateView(); |
1863 | 1863 | ||
1864 | } | 1864 | } |
1865 | 1865 | ||
1866 | 1866 | ||
1867 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1867 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1868 | { | 1868 | { |
1869 | mTodoList->updateView(); | 1869 | mTodoList->updateView(); |
1870 | mViewManager->updateView(start, end); | 1870 | mViewManager->updateView(start, end); |
1871 | //mDateNavigator->updateView(); | 1871 | //mDateNavigator->updateView(); |
1872 | } | 1872 | } |
1873 | 1873 | ||
1874 | void CalendarView::updateView() | 1874 | void CalendarView::updateView() |
1875 | { | 1875 | { |
1876 | DateList tmpList = mNavigator->selectedDates(); | 1876 | DateList tmpList = mNavigator->selectedDates(); |
1877 | 1877 | ||
1878 | // We assume that the navigator only selects consecutive days. | 1878 | // We assume that the navigator only selects consecutive days. |
1879 | updateView( tmpList.first(), tmpList.last() ); | 1879 | updateView( tmpList.first(), tmpList.last() ); |
1880 | } | 1880 | } |
1881 | 1881 | ||
1882 | void CalendarView::updateUnmanagedViews() | 1882 | void CalendarView::updateUnmanagedViews() |
1883 | { | 1883 | { |
1884 | mDateNavigator->updateDayMatrix(); | 1884 | mDateNavigator->updateDayMatrix(); |
1885 | } | 1885 | } |
1886 | 1886 | ||
1887 | int CalendarView::msgItemDelete() | 1887 | int CalendarView::msgItemDelete() |
1888 | { | 1888 | { |
1889 | return KMessageBox::warningContinueCancel(this, | 1889 | return KMessageBox::warningContinueCancel(this, |
1890 | i18n("This item will be\npermanently deleted."), | 1890 | i18n("This item will be\npermanently deleted."), |
1891 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 1891 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
1892 | } | 1892 | } |
1893 | 1893 | ||
1894 | 1894 | ||
1895 | void CalendarView::edit_cut() | 1895 | void CalendarView::edit_cut() |
1896 | { | 1896 | { |
1897 | Event *anEvent=0; | 1897 | Event *anEvent=0; |
1898 | 1898 | ||
1899 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1899 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1900 | 1900 | ||
1901 | if (mViewManager->currentView()->isEventView()) { | 1901 | if (mViewManager->currentView()->isEventView()) { |
1902 | if ( incidence && incidence->type() == "Event" ) { | 1902 | if ( incidence && incidence->type() == "Event" ) { |
1903 | anEvent = static_cast<Event *>(incidence); | 1903 | anEvent = static_cast<Event *>(incidence); |
1904 | } | 1904 | } |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | if (!anEvent) { | 1907 | if (!anEvent) { |
1908 | KNotifyClient::beep(); | 1908 | KNotifyClient::beep(); |
1909 | return; | 1909 | return; |
1910 | } | 1910 | } |
1911 | DndFactory factory( mCalendar ); | 1911 | DndFactory factory( mCalendar ); |
1912 | factory.cutEvent(anEvent); | 1912 | factory.cutEvent(anEvent); |
1913 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 1913 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | void CalendarView::edit_copy() | 1916 | void CalendarView::edit_copy() |
1917 | { | 1917 | { |
1918 | Event *anEvent=0; | 1918 | Event *anEvent=0; |
1919 | 1919 | ||
1920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1921 | 1921 | ||
1922 | if (mViewManager->currentView()->isEventView()) { | 1922 | if (mViewManager->currentView()->isEventView()) { |
1923 | if ( incidence && incidence->type() == "Event" ) { | 1923 | if ( incidence && incidence->type() == "Event" ) { |
1924 | anEvent = static_cast<Event *>(incidence); | 1924 | anEvent = static_cast<Event *>(incidence); |
1925 | } | 1925 | } |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | if (!anEvent) { | 1928 | if (!anEvent) { |
1929 | KNotifyClient::beep(); | 1929 | KNotifyClient::beep(); |
1930 | return; | 1930 | return; |
1931 | } | 1931 | } |
1932 | DndFactory factory( mCalendar ); | 1932 | DndFactory factory( mCalendar ); |
1933 | factory.copyEvent(anEvent); | 1933 | factory.copyEvent(anEvent); |
1934 | } | 1934 | } |
1935 | 1935 | ||
1936 | void CalendarView::edit_paste() | 1936 | void CalendarView::edit_paste() |
1937 | { | 1937 | { |
1938 | QDate date = mNavigator->selectedDates().first(); | 1938 | QDate date = mNavigator->selectedDates().first(); |
1939 | 1939 | ||
1940 | DndFactory factory( mCalendar ); | 1940 | DndFactory factory( mCalendar ); |
1941 | Event *pastedEvent = factory.pasteEvent( date ); | 1941 | Event *pastedEvent = factory.pasteEvent( date ); |
1942 | 1942 | ||
1943 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 1943 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
1944 | } | 1944 | } |
1945 | 1945 | ||
1946 | void CalendarView::edit_options() | 1946 | void CalendarView::edit_options() |
1947 | { | 1947 | { |
1948 | mDialogManager->showOptionsDialog(); | 1948 | mDialogManager->showOptionsDialog(); |
1949 | //writeSettings(); | 1949 | //writeSettings(); |
1950 | } | 1950 | } |
1951 | void CalendarView::edit_sync_options() | 1951 | void CalendarView::edit_sync_options() |
1952 | { | 1952 | { |
1953 | //mDialogManager->showSyncOptions(); | 1953 | //mDialogManager->showSyncOptions(); |
1954 | //KOPrefs::instance()->mSyncAlgoPrefs | 1954 | //KOPrefs::instance()->mSyncAlgoPrefs |
1955 | QDialog dia( this, "dia", true ); | 1955 | QDialog dia( this, "dia", true ); |
1956 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 1956 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
1957 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 1957 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
1958 | QVBoxLayout lay ( &dia ); | 1958 | QVBoxLayout lay ( &dia ); |
1959 | lay.setSpacing( 2 ); | 1959 | lay.setSpacing( 2 ); |
1960 | lay.setMargin( 3 ); | 1960 | lay.setMargin( 3 ); |
1961 | lay.addWidget(&gr); | 1961 | lay.addWidget(&gr); |
1962 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 1962 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
1963 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 1963 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
1964 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 1964 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
1965 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 1965 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
1966 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 1966 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
1967 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 1967 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
1968 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 1968 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
1969 | QPushButton pb ( "OK", &dia); | 1969 | QPushButton pb ( "OK", &dia); |
1970 | lay.addWidget( &pb ); | 1970 | lay.addWidget( &pb ); |
1971 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1971 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1972 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 1972 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
1973 | case 0: | 1973 | case 0: |
1974 | loc.setChecked( true); | 1974 | loc.setChecked( true); |
1975 | break; | 1975 | break; |
1976 | case 1: | 1976 | case 1: |
1977 | rem.setChecked( true ); | 1977 | rem.setChecked( true ); |
1978 | break; | 1978 | break; |
1979 | case 2: | 1979 | case 2: |
1980 | newest.setChecked( true); | 1980 | newest.setChecked( true); |
1981 | break; | 1981 | break; |
1982 | case 3: | 1982 | case 3: |
1983 | ask.setChecked( true); | 1983 | ask.setChecked( true); |
1984 | break; | 1984 | break; |
1985 | case 4: | 1985 | case 4: |
1986 | f_loc.setChecked( true); | 1986 | f_loc.setChecked( true); |
1987 | break; | 1987 | break; |
1988 | case 5: | 1988 | case 5: |
1989 | f_rem.setChecked( true); | 1989 | f_rem.setChecked( true); |
1990 | break; | 1990 | break; |
1991 | case 6: | 1991 | case 6: |
1992 | // both.setChecked( true); | 1992 | // both.setChecked( true); |
1993 | break; | 1993 | break; |
1994 | default: | 1994 | default: |
1995 | break; | 1995 | break; |
1996 | } | 1996 | } |
1997 | if ( dia.exec() ) { | 1997 | if ( dia.exec() ) { |
1998 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 1998 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | } | 2001 | } |
2002 | 2002 | ||
2003 | void CalendarView::slotSelectPickerDate( QDate d) | 2003 | void CalendarView::slotSelectPickerDate( QDate d) |
2004 | { | 2004 | { |
2005 | mDateFrame->hide(); | 2005 | mDateFrame->hide(); |
2006 | if ( mDatePickerMode == 1 ) { | 2006 | if ( mDatePickerMode == 1 ) { |
2007 | mNavigator->slotDaySelect( d ); | 2007 | mNavigator->slotDaySelect( d ); |
2008 | } else if ( mDatePickerMode == 2 ) { | 2008 | } else if ( mDatePickerMode == 2 ) { |
2009 | if ( mMoveIncidence->type() == "Todo" ) { | 2009 | if ( mMoveIncidence->type() == "Todo" ) { |
2010 | Todo * to = (Todo *) mMoveIncidence; | 2010 | Todo * to = (Todo *) mMoveIncidence; |
2011 | QTime tim; | 2011 | QTime tim; |
2012 | if ( to->hasDueDate() ) | 2012 | if ( to->hasDueDate() ) |
2013 | tim = to->dtDue().time(); | 2013 | tim = to->dtDue().time(); |
2014 | else { | 2014 | else { |
2015 | tim = QTime ( 0,0,0 ); | 2015 | tim = QTime ( 0,0,0 ); |
2016 | to->setFloats( true ); | 2016 | to->setFloats( true ); |
2017 | to->setHasDueDate( true ); | 2017 | to->setHasDueDate( true ); |
2018 | } | 2018 | } |
2019 | QDateTime dt ( d,tim ); | 2019 | QDateTime dt ( d,tim ); |
2020 | to->setDtDue( dt ); | 2020 | to->setDtDue( dt ); |
2021 | todoChanged( to ); | 2021 | todoChanged( to ); |
2022 | } else { | 2022 | } else { |
2023 | QTime tim = mMoveIncidence->dtStart().time(); | 2023 | QTime tim = mMoveIncidence->dtStart().time(); |
2024 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2024 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2025 | QDateTime dt ( d,tim ); | 2025 | QDateTime dt ( d,tim ); |
2026 | mMoveIncidence->setDtStart( dt ); | 2026 | mMoveIncidence->setDtStart( dt ); |
2027 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2027 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2028 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2028 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2029 | } | 2029 | } |
2030 | 2030 | ||
2031 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2031 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2032 | } | 2032 | } |
2033 | } | 2033 | } |
2034 | 2034 | ||
2035 | void CalendarView::removeCategories() | 2035 | void CalendarView::removeCategories() |
2036 | { | 2036 | { |
2037 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2037 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2038 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2038 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2039 | QStringList catIncList; | 2039 | QStringList catIncList; |
2040 | QStringList newCatList; | 2040 | QStringList newCatList; |
2041 | Incidence* inc = incList.first(); | 2041 | Incidence* inc = incList.first(); |
2042 | int i; | 2042 | int i; |
2043 | int count = 0; | 2043 | int count = 0; |
2044 | while ( inc ) { | 2044 | while ( inc ) { |
2045 | newCatList.clear(); | 2045 | newCatList.clear(); |
2046 | catIncList = inc->categories() ; | 2046 | catIncList = inc->categories() ; |
2047 | for( i = 0; i< catIncList.count(); ++i ) { | 2047 | for( i = 0; i< catIncList.count(); ++i ) { |
2048 | if ( catList.contains (catIncList[i])) | 2048 | if ( catList.contains (catIncList[i])) |
2049 | newCatList.append( catIncList[i] ); | 2049 | newCatList.append( catIncList[i] ); |
2050 | } | 2050 | } |
2051 | newCatList.sort(); | 2051 | newCatList.sort(); |
2052 | inc->setCategories( newCatList.join(",") ); | 2052 | inc->setCategories( newCatList.join(",") ); |
2053 | inc = incList.next(); | 2053 | inc = incList.next(); |
2054 | } | 2054 | } |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | int CalendarView::addCategories() | 2057 | int CalendarView::addCategories() |
2058 | { | 2058 | { |
2059 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2059 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2060 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2060 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2061 | QStringList catIncList; | 2061 | QStringList catIncList; |
2062 | Incidence* inc = incList.first(); | 2062 | Incidence* inc = incList.first(); |
2063 | int i; | 2063 | int i; |
2064 | int count = 0; | 2064 | int count = 0; |
2065 | while ( inc ) { | 2065 | while ( inc ) { |
2066 | catIncList = inc->categories() ; | 2066 | catIncList = inc->categories() ; |
2067 | for( i = 0; i< catIncList.count(); ++i ) { | 2067 | for( i = 0; i< catIncList.count(); ++i ) { |
2068 | if ( !catList.contains (catIncList[i])) { | 2068 | if ( !catList.contains (catIncList[i])) { |
2069 | catList.append( catIncList[i] ); | 2069 | catList.append( catIncList[i] ); |
2070 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2070 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2071 | ++count; | 2071 | ++count; |
2072 | } | 2072 | } |
2073 | } | 2073 | } |
2074 | inc = incList.next(); | 2074 | inc = incList.next(); |
2075 | } | 2075 | } |
2076 | catList.sort(); | 2076 | catList.sort(); |
2077 | KOPrefs::instance()->mCustomCategories = catList; | 2077 | KOPrefs::instance()->mCustomCategories = catList; |
2078 | return count; | 2078 | return count; |
2079 | } | 2079 | } |
2080 | 2080 | ||
2081 | void CalendarView::manageCategories() | 2081 | void CalendarView::manageCategories() |
2082 | { | 2082 | { |
2083 | KOCatPrefs* cp = new KOCatPrefs(); | 2083 | KOCatPrefs* cp = new KOCatPrefs(); |
2084 | cp->show(); | 2084 | cp->show(); |
2085 | int w =cp->sizeHint().width() ; | 2085 | int w =cp->sizeHint().width() ; |
2086 | int h = cp->sizeHint().height() ; | 2086 | int h = cp->sizeHint().height() ; |
2087 | int dw = QApplication::desktop()->width(); | 2087 | int dw = QApplication::desktop()->width(); |
2088 | int dh = QApplication::desktop()->height(); | 2088 | int dh = QApplication::desktop()->height(); |
2089 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2089 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2090 | if ( !cp->exec() ) { | 2090 | if ( !cp->exec() ) { |
2091 | delete cp; | 2091 | delete cp; |
2092 | return; | 2092 | return; |
2093 | } | 2093 | } |
2094 | int count = 0; | 2094 | int count = 0; |
2095 | if ( cp->addCat() ) { | 2095 | if ( cp->addCat() ) { |
2096 | count = addCategories(); | 2096 | count = addCategories(); |
2097 | if ( count ) { | 2097 | if ( count ) { |
2098 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2098 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2099 | writeSettings(); | 2099 | writeSettings(); |
2100 | } | 2100 | } |
2101 | } else { | 2101 | } else { |
2102 | removeCategories(); | 2102 | removeCategories(); |
2103 | updateView(); | 2103 | updateView(); |
2104 | } | 2104 | } |
2105 | delete cp; | 2105 | delete cp; |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | void CalendarView::beamIncidence(Incidence * Inc) | 2108 | void CalendarView::beamIncidence(Incidence * Inc) |
2109 | { | 2109 | { |
2110 | QPtrList<Incidence> delSel ; | 2110 | QPtrList<Incidence> delSel ; |
2111 | delSel.append(Inc); | 2111 | delSel.append(Inc); |
2112 | beamIncidenceList( delSel ); | 2112 | beamIncidenceList( delSel ); |
2113 | } | 2113 | } |
2114 | void CalendarView::beamCalendar() | 2114 | void CalendarView::beamCalendar() |
2115 | { | 2115 | { |
2116 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2116 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2117 | //qDebug("beamCalendar() "); | 2117 | //qDebug("beamCalendar() "); |
2118 | beamIncidenceList( delSel ); | 2118 | beamIncidenceList( delSel ); |
2119 | } | 2119 | } |
2120 | void CalendarView::beamFilteredCalendar() | 2120 | void CalendarView::beamFilteredCalendar() |
2121 | { | 2121 | { |
2122 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2122 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2123 | //qDebug("beamFilteredCalendar() "); | 2123 | //qDebug("beamFilteredCalendar() "); |
2124 | beamIncidenceList( delSel ); | 2124 | beamIncidenceList( delSel ); |
2125 | } | 2125 | } |
2126 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2126 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2127 | { | 2127 | { |
2128 | if ( beamDialog->exec () == QDialog::Rejected ) | 2128 | if ( beamDialog->exec () == QDialog::Rejected ) |
2129 | return; | 2129 | return; |
2130 | 2130 | ||
2131 | QString fn = "/tmp/kopibeamfile"; | 2131 | QString fn = "/tmp/kopibeamfile"; |
2132 | QString mes; | 2132 | QString mes; |
2133 | bool createbup = true; | 2133 | bool createbup = true; |
2134 | if ( createbup ) { | 2134 | if ( createbup ) { |
2135 | QString description = "\n"; | 2135 | QString description = "\n"; |
2136 | CalendarLocal* cal = new CalendarLocal(); | 2136 | CalendarLocal* cal = new CalendarLocal(); |
2137 | if ( beamDialog->beamLocal() ) | 2137 | if ( beamDialog->beamLocal() ) |
2138 | cal->setLocalTime(); | 2138 | cal->setLocalTime(); |
2139 | else | 2139 | else |
2140 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2140 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2141 | Incidence *incidence = delSel.first(); | 2141 | Incidence *incidence = delSel.first(); |
2142 | bool addText = false; | 2142 | bool addText = false; |
2143 | if ( delSel.count() < 10 ) | 2143 | if ( delSel.count() < 10 ) |
2144 | addText = true; | 2144 | addText = true; |
2145 | else { | 2145 | else { |
2146 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2146 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2147 | } | 2147 | } |
2148 | while ( incidence ) { | 2148 | while ( incidence ) { |
2149 | Incidence *in = incidence->clone(); | 2149 | Incidence *in = incidence->clone(); |
2150 | if ( addText ) | 2150 | if ( addText ) |
2151 | description += in->summary() + "\n"; | 2151 | description += in->summary() + "\n"; |
2152 | cal->addIncidence( in ); | 2152 | cal->addIncidence( in ); |
2153 | incidence = delSel.next(); | 2153 | incidence = delSel.next(); |
2154 | } | 2154 | } |
2155 | if ( beamDialog->beamVcal() ) { | 2155 | if ( beamDialog->beamVcal() ) { |
2156 | fn += ".vcs"; | 2156 | fn += ".vcs"; |
2157 | FileStorage storage( cal, fn, new VCalFormat ); | 2157 | FileStorage storage( cal, fn, new VCalFormat ); |
2158 | storage.save(); | 2158 | storage.save(); |
2159 | } else { | 2159 | } else { |
2160 | fn += ".ics"; | 2160 | fn += ".ics"; |
2161 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2161 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2162 | storage.save(); | 2162 | storage.save(); |
2163 | } | 2163 | } |
2164 | delete cal; | 2164 | delete cal; |
2165 | mes = i18n("KO/Pi: Ready for beaming"); | 2165 | mes = i18n("KO/Pi: Ready for beaming"); |
2166 | setCaption(mes); | 2166 | setCaption(mes); |
2167 | 2167 | ||
2168 | #ifndef DESKTOP_VERSION | 2168 | #ifndef DESKTOP_VERSION |
2169 | Ir *ir = new Ir( this ); | 2169 | Ir *ir = new Ir( this ); |
2170 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2170 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2171 | ir->send( fn, description, "text/x-vCalendar" ); | 2171 | ir->send( fn, description, "text/x-vCalendar" ); |
2172 | #endif | 2172 | #endif |
2173 | } | 2173 | } |
2174 | } | 2174 | } |
2175 | void CalendarView::beamDone( Ir *ir ) | 2175 | void CalendarView::beamDone( Ir *ir ) |
2176 | { | 2176 | { |
2177 | #ifndef DESKTOP_VERSION | 2177 | #ifndef DESKTOP_VERSION |
2178 | delete ir; | 2178 | delete ir; |
2179 | #endif | 2179 | #endif |
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | void CalendarView::moveIncidence(Incidence * inc ) | 2182 | void CalendarView::moveIncidence(Incidence * inc ) |
2183 | { | 2183 | { |
2184 | if ( !inc ) return; | 2184 | if ( !inc ) return; |
2185 | // qDebug("showDatePickerForIncidence( ) "); | 2185 | // qDebug("showDatePickerForIncidence( ) "); |
2186 | if ( mDateFrame->isVisible() ) | 2186 | if ( mDateFrame->isVisible() ) |
2187 | mDateFrame->hide(); | 2187 | mDateFrame->hide(); |
2188 | else { | 2188 | else { |
2189 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2189 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2190 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2190 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2191 | int dw = QApplication::desktop()->width(); | 2191 | int dw = QApplication::desktop()->width(); |
2192 | int dh = QApplication::desktop()->height(); | 2192 | int dh = QApplication::desktop()->height(); |
2193 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2193 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2194 | mDateFrame->show(); | 2194 | mDateFrame->show(); |
2195 | } | 2195 | } |
2196 | mDatePickerMode = 2; | 2196 | mDatePickerMode = 2; |
2197 | mMoveIncidence = inc ; | 2197 | mMoveIncidence = inc ; |
2198 | QDate da; | 2198 | QDate da; |
2199 | if ( mMoveIncidence->type() == "Todo" ) { | 2199 | if ( mMoveIncidence->type() == "Todo" ) { |
2200 | Todo * to = (Todo *) mMoveIncidence; | 2200 | Todo * to = (Todo *) mMoveIncidence; |
2201 | if ( to->hasDueDate() ) | 2201 | if ( to->hasDueDate() ) |
2202 | da = to->dtDue().date(); | 2202 | da = to->dtDue().date(); |
2203 | else | 2203 | else |
2204 | da = QDate::currentDate(); | 2204 | da = QDate::currentDate(); |
2205 | } else { | 2205 | } else { |
2206 | da = mMoveIncidence->dtStart().date(); | 2206 | da = mMoveIncidence->dtStart().date(); |
2207 | } | 2207 | } |
2208 | mDatePicker->setDate( da ); | 2208 | mDatePicker->setDate( da ); |
2209 | } | 2209 | } |
2210 | void CalendarView::showDatePicker( ) | 2210 | void CalendarView::showDatePicker( ) |
2211 | { | 2211 | { |
2212 | //qDebug("CalendarView::showDatePicker( ) "); | 2212 | //qDebug("CalendarView::showDatePicker( ) "); |
2213 | if ( mDateFrame->isVisible() ) | 2213 | if ( mDateFrame->isVisible() ) |
2214 | mDateFrame->hide(); | 2214 | mDateFrame->hide(); |
2215 | else { | 2215 | else { |
2216 | int w =mDatePicker->sizeHint().width() ; | 2216 | int w =mDatePicker->sizeHint().width() ; |
2217 | int h = mDatePicker->sizeHint().height() ; | 2217 | int h = mDatePicker->sizeHint().height() ; |
2218 | int dw = QApplication::desktop()->width(); | 2218 | int dw = QApplication::desktop()->width(); |
2219 | int dh = QApplication::desktop()->height(); | 2219 | int dh = QApplication::desktop()->height(); |
2220 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2220 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2221 | mDateFrame->show(); | 2221 | mDateFrame->show(); |
2222 | } | 2222 | } |
2223 | mDatePickerMode = 1; | 2223 | mDatePickerMode = 1; |
2224 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2224 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2225 | } | 2225 | } |
2226 | 2226 | ||
diff --git a/korganizer/kosyncprefsdialog.cpp b/korganizer/kosyncprefsdialog.cpp deleted file mode 100644 index 7c838f5..0000000 --- a/korganizer/kosyncprefsdialog.cpp +++ b/dev/null | |||
@@ -1,468 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qlayout.h> | ||
25 | #include <qlabel.h> | ||
26 | #include <qgroupbox.h> | ||
27 | #include <qbuttongroup.h> | ||
28 | #include <qlineedit.h> | ||
29 | #include <qfont.h> | ||
30 | #include <qslider.h> | ||
31 | #include <qfile.h> | ||
32 | #include <qdir.h> | ||
33 | #include <qtextstream.h> | ||
34 | #include <qcombobox.h> | ||
35 | #include <qvbox.h> | ||
36 | #include <qhbox.h> | ||
37 | #include <qspinbox.h> | ||
38 | #include <qdatetime.h> | ||
39 | #include <qcheckbox.h> | ||
40 | #include <qradiobutton.h> | ||
41 | #include <qpushbutton.h> | ||
42 | #include <qstrlist.h> | ||
43 | #include <qapplication.h> | ||
44 | |||
45 | #include <kcolorbutton.h> | ||
46 | #include <kdebug.h> | ||
47 | #include <klocale.h> | ||
48 | #include <kglobal.h> | ||
49 | #include <kfontdialog.h> | ||
50 | #include <kmessagebox.h> | ||
51 | #include <kcolordialog.h> | ||
52 | #include <kiconloader.h> | ||
53 | #include <kemailsettings.h> | ||
54 | #include <kstandarddirs.h> | ||
55 | #include <kfiledialog.h> | ||
56 | #include <kmessagebox.h> | ||
57 | |||
58 | #include <kurlrequester.h> | ||
59 | #include <klineedit.h> | ||
60 | #include <libkdepim/ksyncprofile.h> | ||
61 | |||
62 | |||
63 | //#include "koprefs.h" | ||
64 | |||
65 | #include "kosyncprefsdialog.h" | ||
66 | //#include "koglobals.h" | ||
67 | |||
68 | |||
69 | KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) : | ||
70 | KDialog(parent,name,true) | ||
71 | { | ||
72 | |||
73 | setCaption( i18n("Synchronization Preferences")); | ||
74 | |||
75 | mSyncProfiles.setAutoDelete( true ); | ||
76 | setupSyncAlgTab(); | ||
77 | } | ||
78 | |||
79 | |||
80 | KOSyncPrefsDialog::~KOSyncPrefsDialog() | ||
81 | { | ||
82 | } | ||
83 | |||
84 | #include <qlayout.h> | ||
85 | #include <qscrollview.h> | ||
86 | void KOSyncPrefsDialog::setupSyncAlgTab() | ||
87 | { | ||
88 | QLabel * lab; | ||
89 | //QFrame *page = addPage(i18n("Sync Prefs"),0,0); | ||
90 | QVBox * mainbox = new QVBox( this ); | ||
91 | QScrollView* sv = new QScrollView( mainbox ); | ||
92 | QHBoxLayout * lay = new QHBoxLayout( this ); | ||
93 | lay->addWidget( mainbox ); | ||
94 | QHBox * b_box = new QHBox( mainbox ); | ||
95 | |||
96 | QPushButton* button = new QPushButton( i18n("Ok"), b_box ); | ||
97 | connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); | ||
98 | button = new QPushButton( i18n("Cancel"), b_box ); | ||
99 | connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); | ||
100 | //QBoxLayout * sl = new QVBoxLayout(this ); | ||
101 | //sl->addWidget ( sv ); | ||
102 | sv->setResizePolicy ( QScrollView::AutoOneFit ); | ||
103 | QFrame *topFrame = new QFrame ( sv ); | ||
104 | sv->addChild( topFrame ); | ||
105 | mSetupSyncAlgTab = topFrame; | ||
106 | QGridLayout *topLayout = new QGridLayout(topFrame,6,2); | ||
107 | topLayout->setSpacing(spacingHint()); | ||
108 | topLayout->setMargin(marginHint()); | ||
109 | |||
110 | //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); | ||
111 | int iii = 0; | ||
112 | //topLayout->addMultiCellWidget(lab , iii,iii,0,1); | ||
113 | //++iii; | ||
114 | |||
115 | mMyMachineName = new QLineEdit(topFrame); | ||
116 | lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); | ||
117 | topLayout->addWidget(lab ,iii,0); | ||
118 | topLayout->addWidget(mMyMachineName,iii,1); | ||
119 | ++iii; | ||
120 | |||
121 | QHBox* buttonbox = new QHBox( topFrame); | ||
122 | topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); | ||
123 | ++iii; | ||
124 | button = new QPushButton( i18n("New profile"), buttonbox ); | ||
125 | connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); | ||
126 | |||
127 | button = new QPushButton( i18n("Clone profile"), buttonbox ); | ||
128 | connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); | ||
129 | |||
130 | button = new QPushButton( i18n("Delete profile"), buttonbox ); | ||
131 | connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); | ||
132 | |||
133 | mProfileBox = new QComboBox(topFrame); | ||
134 | mProfileBox->setEditable ( true ); | ||
135 | connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); | ||
136 | connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); | ||
137 | |||
138 | lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); | ||
139 | topLayout->addWidget(lab ,iii,0); | ||
140 | topLayout->addWidget(mProfileBox, iii,1); | ||
141 | ++iii; | ||
142 | |||
143 | mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame ); | ||
144 | topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); | ||
145 | ++iii; | ||
146 | |||
147 | mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); | ||
148 | topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); | ||
149 | ++iii; | ||
150 | QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); | ||
151 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | ||
152 | ++iii; | ||
153 | loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); | ||
154 | rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); | ||
155 | newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); | ||
156 | ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); | ||
157 | f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); | ||
158 | f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); | ||
159 | // both = new QRadioButton ( i18n("Take both on conflict"), gr ); | ||
160 | |||
161 | mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); | ||
162 | topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); | ||
163 | ++iii; | ||
164 | |||
165 | mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame ); | ||
166 | topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); | ||
167 | ++iii; | ||
168 | |||
169 | mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame ); | ||
170 | topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); | ||
171 | ++iii; | ||
172 | |||
173 | proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); | ||
174 | gr = proGr; | ||
175 | topLayout->addMultiCellWidget(gr, iii,iii,0,1); | ||
176 | ++iii; | ||
177 | mIsLocal = new QRadioButton ( i18n("Local file"), gr ); | ||
178 | mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); | ||
179 | connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); | ||
180 | |||
181 | localFileWidget = new QVBox( topFrame); | ||
182 | topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); | ||
183 | ++iii; | ||
184 | QHBox* temphb = new QHBox( localFileWidget ); | ||
185 | lab = new QLabel( i18n("Local file:"), temphb); | ||
186 | mRemoteFile = new QLineEdit(localFileWidget); | ||
187 | |||
188 | button = new QPushButton( i18n("Choose..."), temphb ); | ||
189 | connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); | ||
190 | |||
191 | |||
192 | remoteFileWidget = new QVBox( topFrame); | ||
193 | topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); | ||
194 | ++iii; | ||
195 | lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); | ||
196 | mRemotePrecommand = new QLineEdit(remoteFileWidget); | ||
197 | |||
198 | lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); | ||
199 | mLocalTempFile = new QLineEdit(remoteFileWidget); | ||
200 | |||
201 | |||
202 | lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); | ||
203 | mRemotePostcommand = new QLineEdit(remoteFileWidget); | ||
204 | |||
205 | lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); | ||
206 | temphb = new QHBox( remoteFileWidget ); | ||
207 | button = new QPushButton( i18n("ssh/scp"), temphb ); | ||
208 | connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); | ||
209 | button = new QPushButton( i18n("ftp"), temphb ); | ||
210 | connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); | ||
211 | lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); | ||
212 | |||
213 | |||
214 | } | ||
215 | void KOSyncPrefsDialog::slotOK() | ||
216 | { | ||
217 | if ( mMyMachineName->text() == "undefined" ) { | ||
218 | KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); | ||
219 | return; | ||
220 | } | ||
221 | int i; | ||
222 | for (i = 0; i < mSyncProfileNames.count(); ++ i) { | ||
223 | if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { | ||
224 | KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); | ||
225 | return; | ||
226 | } | ||
227 | } | ||
228 | usrWriteConfig(); | ||
229 | QDialog::accept(); | ||
230 | } | ||
231 | void KOSyncPrefsDialog::accept() | ||
232 | { | ||
233 | slotOK(); | ||
234 | } | ||
235 | void KOSyncPrefsDialog::chooseFile() | ||
236 | { | ||
237 | QString fn = QDir::homeDirPath(); | ||
238 | |||
239 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | ||
240 | if ( fn == "" ) | ||
241 | return; | ||
242 | mRemoteFile->setText( fn ); | ||
243 | } | ||
244 | |||
245 | void KOSyncPrefsDialog::textChanged( const QString & s ) | ||
246 | { | ||
247 | if ( mProfileBox->count() == 0 ) | ||
248 | return; | ||
249 | if ( currentSelection < 3 ) { | ||
250 | //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); | ||
251 | mProfileBox->blockSignals( true ); | ||
252 | mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); | ||
253 | mProfileBox->blockSignals( false ); | ||
254 | return; | ||
255 | } | ||
256 | //qDebug("cur i %d ",mProfileBox-> currentItem () ); | ||
257 | mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; | ||
258 | KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; | ||
259 | prof->setName( s ); | ||
260 | mSyncProfileNames[mProfileBox-> currentItem ()] = s; | ||
261 | } | ||
262 | void KOSyncPrefsDialog::profileChanged( int item ) | ||
263 | { | ||
264 | //qDebug("KOSyncPrefsDialog::profileChanged %d ", item ); | ||
265 | KSyncProfile* prof; | ||
266 | saveProfile(); | ||
267 | currentSelection = item; | ||
268 | prof = mSyncProfiles.at(item) ; | ||
269 | mRemotePrecommand->setText(prof->getPreSyncCommand()); | ||
270 | mRemotePostcommand->setText(prof->getPostSyncCommand()); | ||
271 | mLocalTempFile->setText(prof->getLocalTempFile()); | ||
272 | mRemoteFile->setText(prof->getRemoteFileName()) ; | ||
273 | mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); | ||
274 | mAskForPreferences->setChecked( prof->getAskForPreferences()); | ||
275 | mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); | ||
276 | mWriteBackFile->setChecked( prof->getWriteBackFile()); | ||
277 | mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); | ||
278 | |||
279 | switch ( prof->getSyncPrefs() ) { | ||
280 | case 0: | ||
281 | loc->setChecked( true); | ||
282 | break; | ||
283 | case 1: | ||
284 | rem->setChecked( true ); | ||
285 | break; | ||
286 | case 2: | ||
287 | newest->setChecked( true); | ||
288 | break; | ||
289 | case 3: | ||
290 | ask->setChecked( true); | ||
291 | break; | ||
292 | case 4: | ||
293 | f_loc->setChecked( true); | ||
294 | break; | ||
295 | case 5: | ||
296 | f_rem->setChecked( true); | ||
297 | break; | ||
298 | case 6: | ||
299 | //both->setChecked( true); | ||
300 | break; | ||
301 | default: | ||
302 | break; | ||
303 | } | ||
304 | mIsLocal->setChecked(prof->getIsLocalFileSync()) ; | ||
305 | mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); | ||
306 | proGr->setEnabled( item > 2 ); | ||
307 | if ( item < 3 ) { | ||
308 | localFileWidget->setEnabled(false); | ||
309 | remoteFileWidget->setEnabled(false); | ||
310 | |||
311 | } else | ||
312 | kindChanged( prof->getIsLocalFileSync() ); | ||
313 | } | ||
314 | |||
315 | void KOSyncPrefsDialog::fillSSH() | ||
316 | { | ||
317 | mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | ||
318 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | ||
319 | mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); | ||
320 | } | ||
321 | void KOSyncPrefsDialog::fillFTP() | ||
322 | { | ||
323 | mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); | ||
324 | mLocalTempFile->setText("/tmp/mycalendar.ics" ); | ||
325 | mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); | ||
326 | |||
327 | } | ||
328 | void KOSyncPrefsDialog::kindChanged( bool b ) | ||
329 | { | ||
330 | |||
331 | localFileWidget->setEnabled(b); | ||
332 | remoteFileWidget->setEnabled(!b); | ||
333 | |||
334 | } | ||
335 | void KOSyncPrefsDialog::deleteProfile() | ||
336 | { | ||
337 | //qDebug("KOSyncPrefsDialog::deleteProfile() "); | ||
338 | if ( currentSelection >= 0 ) { | ||
339 | if ( currentSelection < 3 ) { | ||
340 | KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); | ||
341 | return; | ||
342 | } | ||
343 | KSyncProfile* temp = mSyncProfiles.at(currentSelection); | ||
344 | mSyncProfiles.remove( temp ); | ||
345 | mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); | ||
346 | insertProfiles(); | ||
347 | } | ||
348 | } | ||
349 | |||
350 | void KOSyncPrefsDialog::saveProfile() | ||
351 | { | ||
352 | KSyncProfile* prof; | ||
353 | if ( currentSelection >= 0 ) { | ||
354 | prof = mSyncProfiles.at(currentSelection) ; | ||
355 | prof->setPreSyncCommand( mRemotePrecommand->text()); | ||
356 | prof->setPostSyncCommand( mRemotePostcommand->text() ); | ||
357 | prof->setLocalTempFile( mLocalTempFile->text()); | ||
358 | prof->setRemoteFileName( mRemoteFile->text() ); | ||
359 | prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); | ||
360 | prof->setAskForPreferences( mAskForPreferences->isChecked()); | ||
361 | prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); | ||
362 | prof->setWriteBackFile( mWriteBackFile->isChecked()); | ||
363 | prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); | ||
364 | int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; | ||
365 | prof->setSyncPrefs( syncprefs); | ||
366 | prof->setIsLocalFileSync( mIsLocal->isChecked() ); | ||
367 | } | ||
368 | |||
369 | } | ||
370 | |||
371 | void KOSyncPrefsDialog::insertProfiles() | ||
372 | { | ||
373 | int curItem = mProfileBox->currentItem(); | ||
374 | mProfileBox->blockSignals( true ); | ||
375 | mProfileBox->clear(); | ||
376 | mProfileBox->insertStringList (mSyncProfileNames ); | ||
377 | int item = mSyncProfileNames.count() -1; | ||
378 | if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) | ||
379 | mProfileBox->setCurrentItem( curItem ); | ||
380 | else if ( item >= 0 ) { | ||
381 | mProfileBox->setCurrentItem( item ); | ||
382 | } | ||
383 | currentSelection = -1; | ||
384 | if ( mSyncProfileNames.count() > 0 ) { | ||
385 | //qDebug(" profileChanged( mProfileBox->currentItem() "); | ||
386 | profileChanged( mProfileBox->currentItem() ); | ||
387 | currentSelection = mProfileBox->currentItem(); | ||
388 | } | ||
389 | mProfileBox->blockSignals( false ); | ||
390 | } | ||
391 | |||
392 | void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp ) | ||
393 | { | ||
394 | saveProfile(); | ||
395 | mSyncProfiles.append( temp ); | ||
396 | mSyncProfileNames << temp->getName(); | ||
397 | insertProfiles(); | ||
398 | int last = mProfileBox->count() -1; | ||
399 | mProfileBox->blockSignals( true ); | ||
400 | mProfileBox->setCurrentItem( last ); | ||
401 | mProfileBox->blockSignals( false ); | ||
402 | profileChanged(last); | ||
403 | } | ||
404 | void KOSyncPrefsDialog::newProfile() | ||
405 | { | ||
406 | addProfile ( new KSyncProfile () ); | ||
407 | } | ||
408 | |||
409 | void KOSyncPrefsDialog::cloneProfile() | ||
410 | { | ||
411 | if ( currentSelection >= 0 ) | ||
412 | addProfile (mSyncProfiles.at(currentSelection)->clone()) ; | ||
413 | else | ||
414 | newProfile(); | ||
415 | } | ||
416 | |||
417 | void KOSyncPrefsDialog::setLocalMachineName ( const QString& name ) | ||
418 | { | ||
419 | mMyMachineName->setText( name ); | ||
420 | |||
421 | } | ||
422 | QString KOSyncPrefsDialog::getLocalMachineName ( ) | ||
423 | { | ||
424 | return mMyMachineName->text(); | ||
425 | } | ||
426 | |||
427 | QStringList KOSyncPrefsDialog::getSyncProfileNames() | ||
428 | { | ||
429 | return mSyncProfileNames; | ||
430 | } | ||
431 | void KOSyncPrefsDialog::usrReadConfig() | ||
432 | { | ||
433 | //KConfig *config = KOGlobals::config(); | ||
434 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | ||
435 | config.setGroup("SyncProfiles"); | ||
436 | mSyncProfileNames =config.readListEntry("SyncProfileNames"); | ||
437 | int i; | ||
438 | KSyncProfile* temp ; | ||
439 | mSyncProfiles.clear(); | ||
440 | for ( i = 0; i < mSyncProfileNames.count();++i ) { | ||
441 | temp = new KSyncProfile (); | ||
442 | temp->setName( mSyncProfileNames[i] ); | ||
443 | temp->readConfig( &config ); | ||
444 | mSyncProfiles.append( temp ); | ||
445 | } | ||
446 | insertProfiles(); | ||
447 | //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); | ||
448 | } | ||
449 | |||
450 | |||
451 | void KOSyncPrefsDialog::usrWriteConfig() | ||
452 | { | ||
453 | saveProfile(); | ||
454 | if ( currentSelection >= 0 ) | ||
455 | profileChanged(currentSelection); | ||
456 | //KConfig *config = KOGlobals::config(); | ||
457 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | ||
458 | config.setGroup("SyncProfiles"); | ||
459 | KSyncProfile* prof = mSyncProfiles.first(); | ||
460 | while ( prof ) { | ||
461 | prof->writeConfig(&config); | ||
462 | prof = mSyncProfiles.next(); | ||
463 | } | ||
464 | //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; | ||
465 | //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); | ||
466 | config.writeEntry("SyncProfileNames",&mSyncProfileNames); | ||
467 | } | ||
468 | |||
diff --git a/korganizer/kosyncprefsdialog.h b/korganizer/kosyncprefsdialog.h deleted file mode 100644 index 541d18b..0000000 --- a/korganizer/kosyncprefsdialog.h +++ b/dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | #ifndef _KOPREFSDIALOG_H | ||
24 | #define _KOPREFSDIALOG_H | ||
25 | |||
26 | //#include <qframe.h> | ||
27 | //#include <qdict.h> | ||
28 | #include <qvbox.h> | ||
29 | #include <qhbox.h> | ||
30 | //#include <qcolor.h> | ||
31 | //#include <qlistview.h> | ||
32 | |||
33 | #include <kdialogbase.h> | ||
34 | |||
35 | #include <libkdepim/kprefsdialog.h> | ||
36 | |||
37 | class KColorButton; | ||
38 | class QSpinBox;; | ||
39 | class QRadioButton; | ||
40 | class QCheckBox; | ||
41 | class QSlider; | ||
42 | class KURLRequester; | ||
43 | class QComboBox; | ||
44 | class QLineEdit; | ||
45 | class QStringList; | ||
46 | class KSyncProfile; | ||
47 | |||
48 | /** Dialog to change the korganizer configuration. | ||
49 | */ | ||
50 | class KOSyncPrefsDialog : public KDialog | ||
51 | { | ||
52 | Q_OBJECT | ||
53 | public: | ||
54 | /** Initialize dialog and pages */ | ||
55 | KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); | ||
56 | ~KOSyncPrefsDialog(); | ||
57 | void usrReadConfig(); | ||
58 | void setLocalMachineName ( const QString& name ); | ||
59 | QString getLocalMachineName ( ); | ||
60 | |||
61 | QStringList getSyncProfileNames(); | ||
62 | |||
63 | public slots: | ||
64 | protected slots: | ||
65 | void accept(); | ||
66 | void deleteProfile(); | ||
67 | void newProfile(); | ||
68 | void cloneProfile(); | ||
69 | void kindChanged(bool); | ||
70 | void fillSSH(); | ||
71 | void fillFTP(); | ||
72 | void textChanged( const QString & ); | ||
73 | void profileChanged( int ); | ||
74 | void chooseFile(); | ||
75 | void slotOK(); | ||
76 | |||
77 | protected: | ||
78 | void usrWriteConfig(); | ||
79 | |||
80 | void setupSyncAlgTab(); | ||
81 | |||
82 | private: | ||
83 | int currentSelection; | ||
84 | QPtrList<KSyncProfile> mSyncProfiles; | ||
85 | QStringList mSyncProfileNames; | ||
86 | QLineEdit * mMyMachineName; | ||
87 | QComboBox * mProfileBox; | ||
88 | QRadioButton* mIsLocal; | ||
89 | QRadioButton* mIsNotLocal; | ||
90 | QCheckBox* mIncludeInRing; | ||
91 | void addProfile ( KSyncProfile* ); | ||
92 | void insertProfiles(); | ||
93 | void saveProfile(); | ||
94 | QButtonGroup* proGr; | ||
95 | |||
96 | QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; | ||
97 | |||
98 | |||
99 | QLineEdit * mRemotePostcommand; | ||
100 | QLineEdit * mRemotePrecommand; | ||
101 | QLineEdit * mRemoteFile; | ||
102 | QLineEdit * mLocalTempFile; | ||
103 | QWidget* mSetupSyncAlgTab; | ||
104 | |||
105 | QVBox* localFileWidget; | ||
106 | QVBox* remoteFileWidget; | ||
107 | QCheckBox* mWriteBackFile; | ||
108 | QCheckBox* mWriteBackExisting; | ||
109 | QCheckBox* mAskForPreferences; | ||
110 | QCheckBox* mShowSummaryAfterSync; | ||
111 | }; | ||
112 | |||
113 | #endif | ||