author | zautrix <zautrix> | 2004-10-06 12:40:40 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-06 12:40:40 (UTC) |
commit | 3e949ed97c7a65eeaddecb1048872cd8595b3caf (patch) (unidiff) | |
tree | a964f4f0ac4d0390655f72aec71185c3f26f04de | |
parent | 8ac1973bfa65844df80d74c482559470bc704041 (diff) | |
download | kdepimpi-3e949ed97c7a65eeaddecb1048872cd8595b3caf.zip kdepimpi-3e949ed97c7a65eeaddecb1048872cd8595b3caf.tar.gz kdepimpi-3e949ed97c7a65eeaddecb1048872cd8595b3caf.tar.bz2 |
added missing actions in kopi
-rw-r--r-- | korganizer/calendarview.cpp | 35 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 25 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 6 |
4 files changed, 69 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index b1da144..38b55f7 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3649 +1,3684 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #endif | 86 | #endif |
87 | #include <libkcal/phoneformat.h> | 87 | #include <libkcal/phoneformat.h> |
88 | #ifndef KORG_NOMAIL | 88 | #ifndef KORG_NOMAIL |
89 | #include "komailclient.h" | 89 | #include "komailclient.h" |
90 | #endif | 90 | #endif |
91 | #ifndef KORG_NOPRINTER | 91 | #ifndef KORG_NOPRINTER |
92 | #include "calprinter.h" | 92 | #include "calprinter.h" |
93 | #endif | 93 | #endif |
94 | #ifndef KORG_NOPLUGINS | 94 | #ifndef KORG_NOPLUGINS |
95 | #include "kocore.h" | 95 | #include "kocore.h" |
96 | #endif | 96 | #endif |
97 | #include "koeventeditor.h" | 97 | #include "koeventeditor.h" |
98 | #include "kotodoeditor.h" | 98 | #include "kotodoeditor.h" |
99 | #include "koprefs.h" | 99 | #include "koprefs.h" |
100 | #include "koeventviewerdialog.h" | 100 | #include "koeventviewerdialog.h" |
101 | #include "publishdialog.h" | 101 | #include "publishdialog.h" |
102 | #include "kofilterview.h" | 102 | #include "kofilterview.h" |
103 | #include "koglobals.h" | 103 | #include "koglobals.h" |
104 | #include "koviewmanager.h" | 104 | #include "koviewmanager.h" |
105 | #include "koagendaview.h" | 105 | #include "koagendaview.h" |
106 | #include "kodialogmanager.h" | 106 | #include "kodialogmanager.h" |
107 | #include "outgoingdialog.h" | 107 | #include "outgoingdialog.h" |
108 | #include "incomingdialog.h" | 108 | #include "incomingdialog.h" |
109 | #include "statusdialog.h" | 109 | #include "statusdialog.h" |
110 | #include "kdatenavigator.h" | 110 | #include "kdatenavigator.h" |
111 | #include "kotodoview.h" | 111 | #include "kotodoview.h" |
112 | #include "datenavigator.h" | 112 | #include "datenavigator.h" |
113 | #include "resourceview.h" | 113 | #include "resourceview.h" |
114 | #include "navigatorbar.h" | 114 | #include "navigatorbar.h" |
115 | #include "searchdialog.h" | 115 | #include "searchdialog.h" |
116 | #include "mainwindow.h" | 116 | #include "mainwindow.h" |
117 | 117 | ||
118 | #include "calendarview.h" | 118 | #include "calendarview.h" |
119 | #ifndef DESKTOP_VERSION | 119 | #ifndef DESKTOP_VERSION |
120 | #include <qtopia/alarmserver.h> | 120 | #include <qtopia/alarmserver.h> |
121 | #endif | 121 | #endif |
122 | #ifndef _WIN32_ | 122 | #ifndef _WIN32_ |
123 | #include <stdlib.h> | 123 | #include <stdlib.h> |
124 | #include <stdio.h> | 124 | #include <stdio.h> |
125 | #include <unistd.h> | 125 | #include <unistd.h> |
126 | #else | 126 | #else |
127 | #include <qprocess.h> | 127 | #include <qprocess.h> |
128 | #endif | 128 | #endif |
129 | using namespace KOrg; | 129 | using namespace KOrg; |
130 | using namespace KCal; | 130 | using namespace KCal; |
131 | extern int globalFlagBlockAgenda; | 131 | extern int globalFlagBlockAgenda; |
132 | extern int globalFlagBlockStartup; | 132 | extern int globalFlagBlockStartup; |
133 | 133 | ||
134 | 134 | ||
135 | 135 | ||
136 | class KOBeamPrefs : public QDialog | 136 | class KOBeamPrefs : public QDialog |
137 | { | 137 | { |
138 | public: | 138 | public: |
139 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 139 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
140 | QDialog( parent, name, true ) | 140 | QDialog( parent, name, true ) |
141 | { | 141 | { |
142 | setCaption( i18n("Beam Options") ); | 142 | setCaption( i18n("Beam Options") ); |
143 | QVBoxLayout* lay = new QVBoxLayout( this ); | 143 | QVBoxLayout* lay = new QVBoxLayout( this ); |
144 | lay->setSpacing( 3 ); | 144 | lay->setSpacing( 3 ); |
145 | lay->setMargin( 3 ); | 145 | lay->setMargin( 3 ); |
146 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 146 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
147 | lay->addWidget( format ); | 147 | lay->addWidget( format ); |
148 | format->setExclusive ( true ) ; | 148 | format->setExclusive ( true ) ; |
149 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 149 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
150 | lay->addWidget( time ); time->setExclusive ( true ) ; | 150 | lay->addWidget( time ); time->setExclusive ( true ) ; |
151 | vcal = new QRadioButton(" vCalendar ", format ); | 151 | vcal = new QRadioButton(" vCalendar ", format ); |
152 | ical = new QRadioButton(" iCalendar ", format ); | 152 | ical = new QRadioButton(" iCalendar ", format ); |
153 | vcal->setChecked( true ); | 153 | vcal->setChecked( true ); |
154 | tz = new QRadioButton(i18n(" With timezone "), time ); | 154 | tz = new QRadioButton(i18n(" With timezone "), time ); |
155 | local = new QRadioButton(i18n(" Local time "), time ); | 155 | local = new QRadioButton(i18n(" Local time "), time ); |
156 | tz->setChecked( true ); | 156 | tz->setChecked( true ); |
157 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 157 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
158 | lay->addWidget( ok ); | 158 | lay->addWidget( ok ); |
159 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 159 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
160 | lay->addWidget( cancel ); | 160 | lay->addWidget( cancel ); |
161 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 161 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
162 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 162 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
163 | resize( 200, 200 ); | 163 | resize( 200, 200 ); |
164 | } | 164 | } |
165 | 165 | ||
166 | bool beamVcal() { return vcal->isChecked(); } | 166 | bool beamVcal() { return vcal->isChecked(); } |
167 | bool beamLocal() { return local->isChecked(); } | 167 | bool beamLocal() { return local->isChecked(); } |
168 | private: | 168 | private: |
169 | QRadioButton* vcal, *ical, *local, *tz; | 169 | QRadioButton* vcal, *ical, *local, *tz; |
170 | }; | 170 | }; |
171 | class KOCatPrefs : public QDialog | 171 | class KOCatPrefs : public QDialog |
172 | { | 172 | { |
173 | public: | 173 | public: |
174 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 174 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
175 | QDialog( parent, name, true ) | 175 | QDialog( parent, name, true ) |
176 | { | 176 | { |
177 | setCaption( i18n("Manage new Categories") ); | 177 | setCaption( i18n("Manage new Categories") ); |
178 | QVBoxLayout* lay = new QVBoxLayout( this ); | 178 | QVBoxLayout* lay = new QVBoxLayout( this ); |
179 | lay->setSpacing( 3 ); | 179 | lay->setSpacing( 3 ); |
180 | lay->setMargin( 3 ); | 180 | lay->setMargin( 3 ); |
181 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 181 | 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 ); |
182 | lay->addWidget( lab ); | 182 | lay->addWidget( lab ); |
183 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 183 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
184 | lay->addWidget( format ); | 184 | lay->addWidget( format ); |
185 | format->setExclusive ( true ) ; | 185 | format->setExclusive ( true ) ; |
186 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 186 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
187 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 187 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
188 | addCatBut->setChecked( true ); | 188 | addCatBut->setChecked( true ); |
189 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 189 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
190 | lay->addWidget( ok ); | 190 | lay->addWidget( ok ); |
191 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 191 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
192 | lay->addWidget( cancel ); | 192 | lay->addWidget( cancel ); |
193 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 193 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
194 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 194 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
195 | resize( 200, 200 ); | 195 | resize( 200, 200 ); |
196 | } | 196 | } |
197 | 197 | ||
198 | bool addCat() { return addCatBut->isChecked(); } | 198 | bool addCat() { return addCatBut->isChecked(); } |
199 | private: | 199 | private: |
200 | QRadioButton* addCatBut; | 200 | QRadioButton* addCatBut; |
201 | }; | 201 | }; |
202 | 202 | ||
203 | 203 | ||
204 | 204 | ||
205 | CalendarView::CalendarView( CalendarResources *calendar, | 205 | CalendarView::CalendarView( CalendarResources *calendar, |
206 | QWidget *parent, const char *name ) | 206 | QWidget *parent, const char *name ) |
207 | : CalendarViewBase( parent, name ), | 207 | : CalendarViewBase( parent, name ), |
208 | mCalendar( calendar ), | 208 | mCalendar( calendar ), |
209 | mResourceManager( calendar->resourceManager() ) | 209 | mResourceManager( calendar->resourceManager() ) |
210 | { | 210 | { |
211 | 211 | ||
212 | mEventEditor = 0; | 212 | mEventEditor = 0; |
213 | mTodoEditor = 0; | 213 | mTodoEditor = 0; |
214 | 214 | ||
215 | init(); | 215 | init(); |
216 | } | 216 | } |
217 | 217 | ||
218 | CalendarView::CalendarView( Calendar *calendar, | 218 | CalendarView::CalendarView( Calendar *calendar, |
219 | QWidget *parent, const char *name ) | 219 | QWidget *parent, const char *name ) |
220 | : CalendarViewBase( parent, name ), | 220 | : CalendarViewBase( parent, name ), |
221 | mCalendar( calendar ), | 221 | mCalendar( calendar ), |
222 | mResourceManager( 0 ) | 222 | mResourceManager( 0 ) |
223 | { | 223 | { |
224 | 224 | ||
225 | mEventEditor = 0; | 225 | mEventEditor = 0; |
226 | mTodoEditor = 0; | 226 | mTodoEditor = 0; |
227 | init();} | 227 | init();} |
228 | 228 | ||
229 | void CalendarView::init() | 229 | void CalendarView::init() |
230 | { | 230 | { |
231 | beamDialog = new KOBeamPrefs(); | 231 | beamDialog = new KOBeamPrefs(); |
232 | mDatePickerMode = 0; | 232 | mDatePickerMode = 0; |
233 | mCurrentSyncDevice = ""; | 233 | mCurrentSyncDevice = ""; |
234 | writeLocale(); | 234 | writeLocale(); |
235 | mViewManager = new KOViewManager( this ); | 235 | mViewManager = new KOViewManager( this ); |
236 | mDialogManager = new KODialogManager( this ); | 236 | mDialogManager = new KODialogManager( this ); |
237 | mEventViewerDialog = 0; | 237 | mEventViewerDialog = 0; |
238 | mModified = false; | 238 | mModified = false; |
239 | mReadOnly = false; | 239 | mReadOnly = false; |
240 | mSelectedIncidence = 0; | 240 | mSelectedIncidence = 0; |
241 | mCalPrinter = 0; | 241 | mCalPrinter = 0; |
242 | mFilters.setAutoDelete(true); | 242 | mFilters.setAutoDelete(true); |
243 | 243 | ||
244 | mCalendar->registerObserver( this ); | 244 | mCalendar->registerObserver( this ); |
245 | // TODO: Make sure that view is updated, when calendar is changed. | 245 | // TODO: Make sure that view is updated, when calendar is changed. |
246 | 246 | ||
247 | mStorage = new FileStorage( mCalendar ); | 247 | mStorage = new FileStorage( mCalendar ); |
248 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 248 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
249 | 249 | ||
250 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 250 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
251 | #ifndef KORG_NOSPLITTER | 251 | #ifndef KORG_NOSPLITTER |
252 | // create the main layout frames. | 252 | // create the main layout frames. |
253 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 253 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
254 | topLayout->addWidget(mPanner); | 254 | topLayout->addWidget(mPanner); |
255 | 255 | ||
256 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 256 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
257 | "CalendarView::LeftFrame"); | 257 | "CalendarView::LeftFrame"); |
258 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 258 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
259 | 259 | ||
260 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 260 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
261 | "CalendarView::DateNavigator", QDate::currentDate() ); | 261 | "CalendarView::DateNavigator", QDate::currentDate() ); |
262 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 262 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
263 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 263 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
264 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 264 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
265 | 265 | ||
266 | #ifdef KORG_NORESOURCEVIEW | 266 | #ifdef KORG_NORESOURCEVIEW |
267 | mResourceView = 0; | 267 | mResourceView = 0; |
268 | #else | 268 | #else |
269 | if ( mResourceManager ) { | 269 | if ( mResourceManager ) { |
270 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 270 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
271 | mResourceView->updateView(); | 271 | mResourceView->updateView(); |
272 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 272 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
273 | SLOT( updateView() ) ); | 273 | SLOT( updateView() ) ); |
274 | } else { | 274 | } else { |
275 | mResourceView = 0; | 275 | mResourceView = 0; |
276 | } | 276 | } |
277 | #endif | 277 | #endif |
278 | QWidget *rightBox = new QWidget( mPanner ); | 278 | QWidget *rightBox = new QWidget( mPanner ); |
279 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 279 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
280 | 280 | ||
281 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 281 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
282 | rightLayout->addWidget( mNavigatorBar ); | 282 | rightLayout->addWidget( mNavigatorBar ); |
283 | 283 | ||
284 | mRightFrame = new QWidgetStack( rightBox ); | 284 | mRightFrame = new QWidgetStack( rightBox ); |
285 | rightLayout->addWidget( mRightFrame, 1 ); | 285 | rightLayout->addWidget( mRightFrame, 1 ); |
286 | 286 | ||
287 | mLeftFrame = mLeftSplitter; | 287 | mLeftFrame = mLeftSplitter; |
288 | #else | 288 | #else |
289 | QWidget *mainBox = new QWidget( this ); | 289 | QWidget *mainBox = new QWidget( this ); |
290 | QWidget *leftFrame = new QWidget( mainBox ); | 290 | QWidget *leftFrame = new QWidget( mainBox ); |
291 | 291 | ||
292 | QBoxLayout * mainBoxLayout; | 292 | QBoxLayout * mainBoxLayout; |
293 | QBoxLayout * leftFrameLayout; | 293 | QBoxLayout * leftFrameLayout; |
294 | if ( KOPrefs::instance()->mVerticalScreen ) { | 294 | if ( KOPrefs::instance()->mVerticalScreen ) { |
295 | mainBoxLayout = new QVBoxLayout(mainBox); | 295 | mainBoxLayout = new QVBoxLayout(mainBox); |
296 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 296 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
297 | } else { | 297 | } else { |
298 | mainBoxLayout = new QHBoxLayout(mainBox); | 298 | mainBoxLayout = new QHBoxLayout(mainBox); |
299 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 299 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
300 | } | 300 | } |
301 | topLayout->addWidget( mainBox ); | 301 | topLayout->addWidget( mainBox ); |
302 | mainBoxLayout->addWidget (leftFrame); | 302 | mainBoxLayout->addWidget (leftFrame); |
303 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 303 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
304 | "CalendarView::DateNavigator", QDate::currentDate()); | 304 | "CalendarView::DateNavigator", QDate::currentDate()); |
305 | // mDateNavigator->blockSignals( true ); | 305 | // mDateNavigator->blockSignals( true ); |
306 | leftFrameLayout->addWidget( mDateNavigator ); | 306 | leftFrameLayout->addWidget( mDateNavigator ); |
307 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 307 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
308 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 308 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
309 | 309 | ||
310 | if ( QApplication::desktop()->width() < 480 ) { | 310 | if ( QApplication::desktop()->width() < 480 ) { |
311 | leftFrameLayout->addWidget(mFilterView); | 311 | leftFrameLayout->addWidget(mFilterView); |
312 | leftFrameLayout->addWidget(mTodoList, 2 ); | 312 | leftFrameLayout->addWidget(mTodoList, 2 ); |
313 | 313 | ||
314 | } else { | 314 | } else { |
315 | leftFrameLayout->addWidget(mTodoList,2 ); | 315 | leftFrameLayout->addWidget(mTodoList,2 ); |
316 | leftFrameLayout->addWidget(mFilterView ); | 316 | leftFrameLayout->addWidget(mFilterView ); |
317 | } | 317 | } |
318 | mFilterView->hide(); | 318 | mFilterView->hide(); |
319 | QWidget *rightBox = new QWidget( mainBox ); | 319 | QWidget *rightBox = new QWidget( mainBox ); |
320 | mainBoxLayout->addWidget ( rightBox, 10 ); | 320 | mainBoxLayout->addWidget ( rightBox, 10 ); |
321 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 321 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
322 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 322 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
323 | mRightFrame = new QWidgetStack( rightBox ); | 323 | mRightFrame = new QWidgetStack( rightBox ); |
324 | rightLayout->addWidget( mNavigatorBar ); | 324 | rightLayout->addWidget( mNavigatorBar ); |
325 | rightLayout->addWidget( mRightFrame, 10 ); | 325 | rightLayout->addWidget( mRightFrame, 10 ); |
326 | 326 | ||
327 | mLeftFrame = leftFrame; | 327 | mLeftFrame = leftFrame; |
328 | if ( KOPrefs::instance()->mVerticalScreen ) { | 328 | if ( KOPrefs::instance()->mVerticalScreen ) { |
329 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 329 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
330 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 330 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
331 | } else { | 331 | } else { |
332 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 332 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
333 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 333 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
334 | } | 334 | } |
335 | 335 | ||
336 | //qDebug("Calendarview Size %d %d ", width(), height()); | 336 | //qDebug("Calendarview Size %d %d ", width(), height()); |
337 | #endif | 337 | #endif |
338 | 338 | ||
339 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 339 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
340 | SLOT( showDates( const KCal::DateList & ) ) ); | 340 | SLOT( showDates( const KCal::DateList & ) ) ); |
341 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 341 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
342 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 342 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
343 | 343 | ||
344 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 344 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
345 | mNavigator, SLOT( selectPreviousYear() ) ); | 345 | mNavigator, SLOT( selectPreviousYear() ) ); |
346 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 346 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
347 | mNavigator, SLOT( selectNextYear() ) ); | 347 | mNavigator, SLOT( selectNextYear() ) ); |
348 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 348 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
349 | mNavigator, SLOT( selectPreviousMonth() ) ); | 349 | mNavigator, SLOT( selectPreviousMonth() ) ); |
350 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 350 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
351 | mNavigator, SLOT( selectNextMonth() ) ); | 351 | mNavigator, SLOT( selectNextMonth() ) ); |
352 | 352 | ||
353 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 353 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
354 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 354 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
355 | 355 | ||
356 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 356 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
357 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 357 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
358 | 358 | ||
359 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 359 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
360 | mNavigator, SLOT( selectPreviousYear() ) ); | 360 | mNavigator, SLOT( selectPreviousYear() ) ); |
361 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 361 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
362 | mNavigator, SLOT( selectNextYear() ) ); | 362 | mNavigator, SLOT( selectNextYear() ) ); |
363 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 363 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
364 | mNavigator, SLOT( selectPreviousMonth() ) ); | 364 | mNavigator, SLOT( selectPreviousMonth() ) ); |
365 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 365 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
366 | mNavigator, SLOT( selectNextMonth() ) ); | 366 | mNavigator, SLOT( selectNextMonth() ) ); |
367 | 367 | ||
368 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 368 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
369 | mNavigator, SLOT( selectPrevious() ) ); | 369 | mNavigator, SLOT( selectPrevious() ) ); |
370 | connect( mDateNavigator, SIGNAL( goNext() ), | 370 | connect( mDateNavigator, SIGNAL( goNext() ), |
371 | mNavigator, SLOT( selectNext() ) ); | 371 | mNavigator, SLOT( selectNext() ) ); |
372 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 372 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
373 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 373 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
374 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 374 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
375 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 375 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
376 | 376 | ||
377 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 377 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
378 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 378 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
379 | 379 | ||
380 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 380 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
381 | SLOT( eventAdded( Event *) ) ); | 381 | SLOT( eventAdded( Event *) ) ); |
382 | 382 | ||
383 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 383 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
384 | 384 | ||
385 | connect( this, SIGNAL( configChanged() ), | 385 | connect( this, SIGNAL( configChanged() ), |
386 | mDateNavigator, SLOT( updateConfig() ) ); | 386 | mDateNavigator, SLOT( updateConfig() ) ); |
387 | 387 | ||
388 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 388 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
389 | SLOT( newTodo() ) ); | 389 | SLOT( newTodo() ) ); |
390 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 390 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
391 | SLOT( newSubTodo( Todo * ) ) ); | 391 | SLOT( newSubTodo( Todo * ) ) ); |
392 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 392 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
393 | SLOT( editTodo( Todo * ) ) ); | 393 | SLOT( editTodo( Todo * ) ) ); |
394 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 394 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
395 | SLOT( showTodo( Todo *) ) ); | 395 | SLOT( showTodo( Todo *) ) ); |
396 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 396 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
397 | SLOT( deleteTodo( Todo *) ) ); | 397 | SLOT( deleteTodo( Todo *) ) ); |
398 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 398 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
399 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 399 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
400 | SLOT( purgeCompleted() ) ); | 400 | SLOT( purgeCompleted() ) ); |
401 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 401 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
402 | SIGNAL( todoModified( Todo *, int ) ) ); | 402 | SIGNAL( todoModified( Todo *, int ) ) ); |
403 | 403 | ||
404 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 404 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
405 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 405 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
406 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 406 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
407 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 407 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 409 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
410 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 410 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
411 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 411 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
412 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 412 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 414 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
415 | this, SLOT ( todo_unsub( Todo * ) ) ); | 415 | this, SLOT ( todo_unsub( Todo * ) ) ); |
416 | 416 | ||
417 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 417 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
418 | SLOT( updateTodo( Todo *, int ) ) ); | 418 | SLOT( updateTodo( Todo *, int ) ) ); |
419 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 419 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
420 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 420 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
421 | 421 | ||
422 | 422 | ||
423 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 423 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
424 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 424 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
425 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 425 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
426 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 426 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | 431 | ||
432 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 432 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
433 | SLOT(checkClipboard())); | 433 | SLOT(checkClipboard())); |
434 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 434 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
435 | SLOT( processTodoListSelection( Incidence * ) ) ); | 435 | SLOT( processTodoListSelection( Incidence * ) ) ); |
436 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 436 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
437 | 437 | ||
438 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 438 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
439 | 439 | ||
440 | mDateFrame = new QVBox(0,0,WType_Popup); | 440 | mDateFrame = new QVBox(0,0,WType_Popup); |
441 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 441 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
442 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 442 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
443 | mDateFrame->setLineWidth(3); | 443 | mDateFrame->setLineWidth(3); |
444 | mDateFrame->hide(); | 444 | mDateFrame->hide(); |
445 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 445 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
446 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 446 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
447 | 447 | ||
448 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 448 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
449 | 449 | ||
450 | mEventEditor = mDialogManager->getEventEditor(); | 450 | mEventEditor = mDialogManager->getEventEditor(); |
451 | mTodoEditor = mDialogManager->getTodoEditor(); | 451 | mTodoEditor = mDialogManager->getTodoEditor(); |
452 | 452 | ||
453 | mFlagEditDescription = false; | 453 | mFlagEditDescription = false; |
454 | 454 | ||
455 | mSuspendTimer = new QTimer( this ); | 455 | mSuspendTimer = new QTimer( this ); |
456 | mAlarmTimer = new QTimer( this ); | 456 | mAlarmTimer = new QTimer( this ); |
457 | mRecheckAlarmTimer = new QTimer( this ); | 457 | mRecheckAlarmTimer = new QTimer( this ); |
458 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 458 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
459 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 459 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
460 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 460 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
461 | mAlarmDialog = new AlarmDialog( this ); | 461 | mAlarmDialog = new AlarmDialog( this ); |
462 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 462 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
463 | mAlarmDialog->setServerNotification( false ); | 463 | mAlarmDialog->setServerNotification( false ); |
464 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 464 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
465 | } | 465 | } |
466 | 466 | ||
467 | 467 | ||
468 | CalendarView::~CalendarView() | 468 | CalendarView::~CalendarView() |
469 | { | 469 | { |
470 | // kdDebug() << "~CalendarView()" << endl; | 470 | // kdDebug() << "~CalendarView()" << endl; |
471 | //qDebug("CalendarView::~CalendarView() "); | 471 | //qDebug("CalendarView::~CalendarView() "); |
472 | delete mDialogManager; | 472 | delete mDialogManager; |
473 | delete mViewManager; | 473 | delete mViewManager; |
474 | delete mStorage; | 474 | delete mStorage; |
475 | delete mDateFrame ; | 475 | delete mDateFrame ; |
476 | delete beamDialog; | 476 | delete beamDialog; |
477 | //kdDebug() << "~CalendarView() done" << endl; | 477 | //kdDebug() << "~CalendarView() done" << endl; |
478 | } | 478 | } |
479 | void CalendarView::timerAlarm() | 479 | void CalendarView::timerAlarm() |
480 | { | 480 | { |
481 | //qDebug("CalendarView::timerAlarm() "); | 481 | //qDebug("CalendarView::timerAlarm() "); |
482 | computeAlarm(mAlarmNotification ); | 482 | computeAlarm(mAlarmNotification ); |
483 | } | 483 | } |
484 | 484 | ||
485 | void CalendarView::suspendAlarm() | 485 | void CalendarView::suspendAlarm() |
486 | { | 486 | { |
487 | //qDebug(" CalendarView::suspendAlarm() "); | 487 | //qDebug(" CalendarView::suspendAlarm() "); |
488 | computeAlarm(mSuspendAlarmNotification ); | 488 | computeAlarm(mSuspendAlarmNotification ); |
489 | 489 | ||
490 | } | 490 | } |
491 | 491 | ||
492 | void CalendarView::startAlarm( QString mess , QString filename) | 492 | void CalendarView::startAlarm( QString mess , QString filename) |
493 | { | 493 | { |
494 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 494 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
495 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 495 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
496 | 496 | ||
497 | } | 497 | } |
498 | 498 | ||
499 | void CalendarView::checkNextTimerAlarm() | 499 | void CalendarView::checkNextTimerAlarm() |
500 | { | 500 | { |
501 | mCalendar->checkAlarmForIncidence( 0, true ); | 501 | mCalendar->checkAlarmForIncidence( 0, true ); |
502 | } | 502 | } |
503 | 503 | ||
504 | void CalendarView::computeAlarm( QString msg ) | 504 | void CalendarView::computeAlarm( QString msg ) |
505 | { | 505 | { |
506 | 506 | ||
507 | QString mess = msg; | 507 | QString mess = msg; |
508 | QString mAlarmMessage = mess.mid( 9 ); | 508 | QString mAlarmMessage = mess.mid( 9 ); |
509 | QString filename = MainWindow::resourcePath(); | 509 | QString filename = MainWindow::resourcePath(); |
510 | filename += "koalarm.wav"; | 510 | filename += "koalarm.wav"; |
511 | QString tempfilename; | 511 | QString tempfilename; |
512 | if ( mess.left( 13 ) == "suspend_alarm") { | 512 | if ( mess.left( 13 ) == "suspend_alarm") { |
513 | bool error = false; | 513 | bool error = false; |
514 | int len = mess.mid( 13 ).find("+++"); | 514 | int len = mess.mid( 13 ).find("+++"); |
515 | if ( len < 2 ) | 515 | if ( len < 2 ) |
516 | error = true; | 516 | error = true; |
517 | else { | 517 | else { |
518 | tempfilename = mess.mid( 13, len ); | 518 | tempfilename = mess.mid( 13, len ); |
519 | if ( !QFile::exists( tempfilename ) ) | 519 | if ( !QFile::exists( tempfilename ) ) |
520 | error = true; | 520 | error = true; |
521 | } | 521 | } |
522 | if ( ! error ) { | 522 | if ( ! error ) { |
523 | filename = tempfilename; | 523 | filename = tempfilename; |
524 | } | 524 | } |
525 | mAlarmMessage = mess.mid( 13+len+3 ); | 525 | mAlarmMessage = mess.mid( 13+len+3 ); |
526 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 526 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
527 | startAlarm( mAlarmMessage, filename); | 527 | startAlarm( mAlarmMessage, filename); |
528 | return; | 528 | return; |
529 | } | 529 | } |
530 | if ( mess.left( 11 ) == "timer_alarm") { | 530 | if ( mess.left( 11 ) == "timer_alarm") { |
531 | //mTimerTime = 0; | 531 | //mTimerTime = 0; |
532 | startAlarm( mess.mid( 11 ), filename ); | 532 | startAlarm( mess.mid( 11 ), filename ); |
533 | return; | 533 | return; |
534 | } | 534 | } |
535 | if ( mess.left( 10 ) == "proc_alarm") { | 535 | if ( mess.left( 10 ) == "proc_alarm") { |
536 | bool error = false; | 536 | bool error = false; |
537 | int len = mess.mid( 10 ).find("+++"); | 537 | int len = mess.mid( 10 ).find("+++"); |
538 | if ( len < 2 ) | 538 | if ( len < 2 ) |
539 | error = true; | 539 | error = true; |
540 | else { | 540 | else { |
541 | tempfilename = mess.mid( 10, len ); | 541 | tempfilename = mess.mid( 10, len ); |
542 | if ( !QFile::exists( tempfilename ) ) | 542 | if ( !QFile::exists( tempfilename ) ) |
543 | error = true; | 543 | error = true; |
544 | } | 544 | } |
545 | if ( error ) { | 545 | if ( error ) { |
546 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 546 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
547 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 547 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
548 | } else { | 548 | } else { |
549 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 549 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
550 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 550 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
551 | #ifndef _WIN32_ | 551 | #ifndef _WIN32_ |
552 | if ( vfork () == 0 ) { | 552 | if ( vfork () == 0 ) { |
553 | execl ( tempfilename.latin1(), 0 ); | 553 | execl ( tempfilename.latin1(), 0 ); |
554 | return; | 554 | return; |
555 | } | 555 | } |
556 | #else | 556 | #else |
557 | QProcess* p = new QProcess(); | 557 | QProcess* p = new QProcess(); |
558 | p->addArgument( tempfilename.latin1() ); | 558 | p->addArgument( tempfilename.latin1() ); |
559 | p->start(); | 559 | p->start(); |
560 | return; | 560 | return; |
561 | #endif | 561 | #endif |
562 | 562 | ||
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | 565 | ||
566 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 566 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
567 | } | 567 | } |
568 | if ( mess.left( 11 ) == "audio_alarm") { | 568 | if ( mess.left( 11 ) == "audio_alarm") { |
569 | bool error = false; | 569 | bool error = false; |
570 | int len = mess.mid( 11 ).find("+++"); | 570 | int len = mess.mid( 11 ).find("+++"); |
571 | if ( len < 2 ) | 571 | if ( len < 2 ) |
572 | error = true; | 572 | error = true; |
573 | else { | 573 | else { |
574 | tempfilename = mess.mid( 11, len ); | 574 | tempfilename = mess.mid( 11, len ); |
575 | if ( !QFile::exists( tempfilename ) ) | 575 | if ( !QFile::exists( tempfilename ) ) |
576 | error = true; | 576 | error = true; |
577 | } | 577 | } |
578 | if ( ! error ) { | 578 | if ( ! error ) { |
579 | filename = tempfilename; | 579 | filename = tempfilename; |
580 | } | 580 | } |
581 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 581 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
582 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 582 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
583 | } | 583 | } |
584 | if ( mess.left( 9 ) == "cal_alarm") { | 584 | if ( mess.left( 9 ) == "cal_alarm") { |
585 | mAlarmMessage = mess.mid( 9 ) ; | 585 | mAlarmMessage = mess.mid( 9 ) ; |
586 | } | 586 | } |
587 | 587 | ||
588 | startAlarm( mAlarmMessage, filename ); | 588 | startAlarm( mAlarmMessage, filename ); |
589 | 589 | ||
590 | 590 | ||
591 | } | 591 | } |
592 | 592 | ||
593 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 593 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
594 | { | 594 | { |
595 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 595 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
596 | 596 | ||
597 | mSuspendAlarmNotification = noti; | 597 | mSuspendAlarmNotification = noti; |
598 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 598 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
599 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 599 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
600 | mSuspendTimer->start( ms , true ); | 600 | mSuspendTimer->start( ms , true ); |
601 | 601 | ||
602 | } | 602 | } |
603 | 603 | ||
604 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 604 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
605 | { | 605 | { |
606 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 606 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
607 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 607 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
608 | #ifndef DESKTOP_VERSION | 608 | #ifndef DESKTOP_VERSION |
609 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 609 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
610 | #endif | 610 | #endif |
611 | return; | 611 | return; |
612 | } | 612 | } |
613 | int maxSec; | 613 | int maxSec; |
614 | //maxSec = 5; //testing only | 614 | //maxSec = 5; //testing only |
615 | maxSec = 86400+3600; // one day+1hour | 615 | maxSec = 86400+3600; // one day+1hour |
616 | mAlarmNotification = noti; | 616 | mAlarmNotification = noti; |
617 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 617 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
618 | if ( sec > maxSec ) { | 618 | if ( sec > maxSec ) { |
619 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 619 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
620 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 620 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
621 | return; | 621 | return; |
622 | } else { | 622 | } else { |
623 | mRecheckAlarmTimer->stop(); | 623 | mRecheckAlarmTimer->stop(); |
624 | } | 624 | } |
625 | //qDebug("Alarm timer started with secs: %d ", sec); | 625 | //qDebug("Alarm timer started with secs: %d ", sec); |
626 | mAlarmTimer->start( sec *1000 , true ); | 626 | mAlarmTimer->start( sec *1000 , true ); |
627 | 627 | ||
628 | } | 628 | } |
629 | // called by mRecheckAlarmTimer to get next alarm | 629 | // called by mRecheckAlarmTimer to get next alarm |
630 | // we need this, because a QTimer has only a max range of 25 days | 630 | // we need this, because a QTimer has only a max range of 25 days |
631 | void CalendarView::recheckTimerAlarm() | 631 | void CalendarView::recheckTimerAlarm() |
632 | { | 632 | { |
633 | mAlarmTimer->stop(); | 633 | mAlarmTimer->stop(); |
634 | mRecheckAlarmTimer->stop(); | 634 | mRecheckAlarmTimer->stop(); |
635 | mCalendar->checkAlarmForIncidence( 0, true ); | 635 | mCalendar->checkAlarmForIncidence( 0, true ); |
636 | } | 636 | } |
637 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 637 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
638 | { | 638 | { |
639 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 639 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
640 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 640 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
641 | #ifndef DESKTOP_VERSION | 641 | #ifndef DESKTOP_VERSION |
642 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 642 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
643 | #endif | 643 | #endif |
644 | return; | 644 | return; |
645 | } | 645 | } |
646 | mAlarmTimer->stop(); | 646 | mAlarmTimer->stop(); |
647 | } | 647 | } |
648 | void CalendarView::selectWeekNum ( int num ) | 648 | void CalendarView::selectWeekNum ( int num ) |
649 | { | 649 | { |
650 | dateNavigator()->selectWeek( num ); | 650 | dateNavigator()->selectWeek( num ); |
651 | mViewManager->showWeekView(); | 651 | mViewManager->showWeekView(); |
652 | } | 652 | } |
653 | KOViewManager *CalendarView::viewManager() | 653 | KOViewManager *CalendarView::viewManager() |
654 | { | 654 | { |
655 | return mViewManager; | 655 | return mViewManager; |
656 | } | 656 | } |
657 | 657 | ||
658 | KODialogManager *CalendarView::dialogManager() | 658 | KODialogManager *CalendarView::dialogManager() |
659 | { | 659 | { |
660 | return mDialogManager; | 660 | return mDialogManager; |
661 | } | 661 | } |
662 | 662 | ||
663 | QDate CalendarView::startDate() | 663 | QDate CalendarView::startDate() |
664 | { | 664 | { |
665 | DateList dates = mNavigator->selectedDates(); | 665 | DateList dates = mNavigator->selectedDates(); |
666 | 666 | ||
667 | return dates.first(); | 667 | return dates.first(); |
668 | } | 668 | } |
669 | 669 | ||
670 | QDate CalendarView::endDate() | 670 | QDate CalendarView::endDate() |
671 | { | 671 | { |
672 | DateList dates = mNavigator->selectedDates(); | 672 | DateList dates = mNavigator->selectedDates(); |
673 | 673 | ||
674 | return dates.last(); | 674 | return dates.last(); |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | void CalendarView::createPrinter() | 678 | void CalendarView::createPrinter() |
679 | { | 679 | { |
680 | #ifndef KORG_NOPRINTER | 680 | #ifndef KORG_NOPRINTER |
681 | if (!mCalPrinter) { | 681 | if (!mCalPrinter) { |
682 | mCalPrinter = new CalPrinter(this, mCalendar); | 682 | mCalPrinter = new CalPrinter(this, mCalendar); |
683 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 683 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
684 | } | 684 | } |
685 | #endif | 685 | #endif |
686 | } | 686 | } |
687 | 687 | ||
688 | void CalendarView::confSync() | 688 | void CalendarView::confSync() |
689 | { | 689 | { |
690 | static KSyncPrefsDialog* sp = 0; | 690 | static KSyncPrefsDialog* sp = 0; |
691 | if ( ! sp ) { | 691 | if ( ! sp ) { |
692 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 692 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
693 | } | 693 | } |
694 | sp->usrReadConfig(); | 694 | sp->usrReadConfig(); |
695 | #ifndef DESKTOP_VERSION | 695 | #ifndef DESKTOP_VERSION |
696 | sp->showMaximized(); | 696 | sp->showMaximized(); |
697 | #else | 697 | #else |
698 | sp->show(); | 698 | sp->show(); |
699 | #endif | 699 | #endif |
700 | sp->exec(); | 700 | sp->exec(); |
701 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 701 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
702 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 702 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
703 | } | 703 | } |
704 | 704 | ||
705 | 705 | ||
706 | //KOPrefs::instance()->mWriteBackFile | 706 | //KOPrefs::instance()->mWriteBackFile |
707 | //KOPrefs::instance()->mWriteBackExistingOnly | 707 | //KOPrefs::instance()->mWriteBackExistingOnly |
708 | 708 | ||
709 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 709 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
710 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 710 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
711 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 711 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
712 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 712 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
713 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 713 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
714 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 714 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
715 | 715 | ||
716 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 716 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
717 | { | 717 | { |
718 | 718 | ||
719 | //void setZaurusId(int id); | 719 | //void setZaurusId(int id); |
720 | // int zaurusId() const; | 720 | // int zaurusId() const; |
721 | // void setZaurusUid(int id); | 721 | // void setZaurusUid(int id); |
722 | // int zaurusUid() const; | 722 | // int zaurusUid() const; |
723 | // void setZaurusStat(int id); | 723 | // void setZaurusStat(int id); |
724 | // int zaurusStat() const; | 724 | // int zaurusStat() const; |
725 | // 0 equal | 725 | // 0 equal |
726 | // 1 take local | 726 | // 1 take local |
727 | // 2 take remote | 727 | // 2 take remote |
728 | // 3 cancel | 728 | // 3 cancel |
729 | QDateTime lastSync = mLastCalendarSync; | 729 | QDateTime lastSync = mLastCalendarSync; |
730 | QDateTime localMod = local->lastModified(); | 730 | QDateTime localMod = local->lastModified(); |
731 | QDateTime remoteMod = remote->lastModified(); | 731 | QDateTime remoteMod = remote->lastModified(); |
732 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 732 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
733 | bool remCh, locCh; | 733 | bool remCh, locCh; |
734 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 734 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
735 | //if ( remCh ) | 735 | //if ( remCh ) |
736 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 736 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
737 | locCh = ( localMod > mLastCalendarSync ); | 737 | locCh = ( localMod > mLastCalendarSync ); |
738 | if ( !remCh && ! locCh ) { | 738 | if ( !remCh && ! locCh ) { |
739 | //qDebug("both not changed "); | 739 | //qDebug("both not changed "); |
740 | lastSync = localMod.addDays(1); | 740 | lastSync = localMod.addDays(1); |
741 | if ( mode <= SYNC_PREF_ASK ) | 741 | if ( mode <= SYNC_PREF_ASK ) |
742 | return 0; | 742 | return 0; |
743 | } else { | 743 | } else { |
744 | if ( locCh ) { | 744 | if ( locCh ) { |
745 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 745 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
746 | lastSync = localMod.addDays( -1 ); | 746 | lastSync = localMod.addDays( -1 ); |
747 | if ( !remCh ) | 747 | if ( !remCh ) |
748 | remoteMod = ( lastSync.addDays( -1 ) ); | 748 | remoteMod = ( lastSync.addDays( -1 ) ); |
749 | } else { | 749 | } else { |
750 | //qDebug(" not loc changed "); | 750 | //qDebug(" not loc changed "); |
751 | lastSync = localMod.addDays( 1 ); | 751 | lastSync = localMod.addDays( 1 ); |
752 | if ( remCh ) | 752 | if ( remCh ) |
753 | remoteMod =( lastSync.addDays( 1 ) ); | 753 | remoteMod =( lastSync.addDays( 1 ) ); |
754 | 754 | ||
755 | } | 755 | } |
756 | } | 756 | } |
757 | full = true; | 757 | full = true; |
758 | if ( mode < SYNC_PREF_ASK ) | 758 | if ( mode < SYNC_PREF_ASK ) |
759 | mode = SYNC_PREF_ASK; | 759 | mode = SYNC_PREF_ASK; |
760 | } else { | 760 | } else { |
761 | if ( localMod == remoteMod ) | 761 | if ( localMod == remoteMod ) |
762 | if ( local->revision() == remote->revision() ) | 762 | if ( local->revision() == remote->revision() ) |
763 | return 0; | 763 | return 0; |
764 | 764 | ||
765 | } | 765 | } |
766 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 766 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
767 | 767 | ||
768 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 768 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
769 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 769 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
770 | //full = true; //debug only | 770 | //full = true; //debug only |
771 | if ( full ) { | 771 | if ( full ) { |
772 | bool equ = false; | 772 | bool equ = false; |
773 | if ( local->type() == "Event" ) { | 773 | if ( local->type() == "Event" ) { |
774 | equ = (*((Event*) local) == *((Event*) remote)); | 774 | equ = (*((Event*) local) == *((Event*) remote)); |
775 | } | 775 | } |
776 | else if ( local->type() =="Todo" ) | 776 | else if ( local->type() =="Todo" ) |
777 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 777 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
778 | else if ( local->type() =="Journal" ) | 778 | else if ( local->type() =="Journal" ) |
779 | equ = (*((Journal*) local) == *((Journal*) remote)); | 779 | equ = (*((Journal*) local) == *((Journal*) remote)); |
780 | if ( equ ) { | 780 | if ( equ ) { |
781 | //qDebug("equal "); | 781 | //qDebug("equal "); |
782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 782 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
783 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 783 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
784 | } | 784 | } |
785 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 785 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
786 | return 0; | 786 | return 0; |
787 | 787 | ||
788 | }//else //debug only | 788 | }//else //debug only |
789 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 789 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
790 | } | 790 | } |
791 | int result; | 791 | int result; |
792 | bool localIsNew; | 792 | bool localIsNew; |
793 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 793 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
794 | 794 | ||
795 | if ( full && mode < SYNC_PREF_NEWEST ) | 795 | if ( full && mode < SYNC_PREF_NEWEST ) |
796 | mode = SYNC_PREF_ASK; | 796 | mode = SYNC_PREF_ASK; |
797 | 797 | ||
798 | switch( mode ) { | 798 | switch( mode ) { |
799 | case SYNC_PREF_LOCAL: | 799 | case SYNC_PREF_LOCAL: |
800 | if ( lastSync > remoteMod ) | 800 | if ( lastSync > remoteMod ) |
801 | return 1; | 801 | return 1; |
802 | if ( lastSync > localMod ) | 802 | if ( lastSync > localMod ) |
803 | return 2; | 803 | return 2; |
804 | return 1; | 804 | return 1; |
805 | break; | 805 | break; |
806 | case SYNC_PREF_REMOTE: | 806 | case SYNC_PREF_REMOTE: |
807 | if ( lastSync > remoteMod ) | 807 | if ( lastSync > remoteMod ) |
808 | return 1; | 808 | return 1; |
809 | if ( lastSync > localMod ) | 809 | if ( lastSync > localMod ) |
810 | return 2; | 810 | return 2; |
811 | return 2; | 811 | return 2; |
812 | break; | 812 | break; |
813 | case SYNC_PREF_NEWEST: | 813 | case SYNC_PREF_NEWEST: |
814 | if ( localMod > remoteMod ) | 814 | if ( localMod > remoteMod ) |
815 | return 1; | 815 | return 1; |
816 | else | 816 | else |
817 | return 2; | 817 | return 2; |
818 | break; | 818 | break; |
819 | case SYNC_PREF_ASK: | 819 | case SYNC_PREF_ASK: |
820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
821 | if ( lastSync > remoteMod ) | 821 | if ( lastSync > remoteMod ) |
822 | return 1; | 822 | return 1; |
823 | if ( lastSync > localMod ) | 823 | if ( lastSync > localMod ) |
824 | return 2; | 824 | return 2; |
825 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 825 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
826 | localIsNew = localMod >= remoteMod; | 826 | localIsNew = localMod >= remoteMod; |
827 | if ( localIsNew ) | 827 | if ( localIsNew ) |
828 | getEventViewerDialog()->setColorMode( 1 ); | 828 | getEventViewerDialog()->setColorMode( 1 ); |
829 | else | 829 | else |
830 | getEventViewerDialog()->setColorMode( 2 ); | 830 | getEventViewerDialog()->setColorMode( 2 ); |
831 | getEventViewerDialog()->setIncidence(local); | 831 | getEventViewerDialog()->setIncidence(local); |
832 | if ( localIsNew ) | 832 | if ( localIsNew ) |
833 | getEventViewerDialog()->setColorMode( 2 ); | 833 | getEventViewerDialog()->setColorMode( 2 ); |
834 | else | 834 | else |
835 | getEventViewerDialog()->setColorMode( 1 ); | 835 | getEventViewerDialog()->setColorMode( 1 ); |
836 | getEventViewerDialog()->addIncidence(remote); | 836 | getEventViewerDialog()->addIncidence(remote); |
837 | getEventViewerDialog()->setColorMode( 0 ); | 837 | getEventViewerDialog()->setColorMode( 0 ); |
838 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 838 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
839 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 839 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
840 | getEventViewerDialog()->showMe(); | 840 | getEventViewerDialog()->showMe(); |
841 | result = getEventViewerDialog()->executeS( localIsNew ); | 841 | result = getEventViewerDialog()->executeS( localIsNew ); |
842 | return result; | 842 | return result; |
843 | 843 | ||
844 | break; | 844 | break; |
845 | case SYNC_PREF_FORCE_LOCAL: | 845 | case SYNC_PREF_FORCE_LOCAL: |
846 | return 1; | 846 | return 1; |
847 | break; | 847 | break; |
848 | case SYNC_PREF_FORCE_REMOTE: | 848 | case SYNC_PREF_FORCE_REMOTE: |
849 | return 2; | 849 | return 2; |
850 | break; | 850 | break; |
851 | 851 | ||
852 | default: | 852 | default: |
853 | // SYNC_PREF_TAKE_BOTH not implemented | 853 | // SYNC_PREF_TAKE_BOTH not implemented |
854 | break; | 854 | break; |
855 | } | 855 | } |
856 | return 0; | 856 | return 0; |
857 | } | 857 | } |
858 | Event* CalendarView::getLastSyncEvent() | 858 | Event* CalendarView::getLastSyncEvent() |
859 | { | 859 | { |
860 | Event* lse; | 860 | Event* lse; |
861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 861 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 862 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
863 | if (!lse) { | 863 | if (!lse) { |
864 | lse = new Event(); | 864 | lse = new Event(); |
865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 865 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
866 | QString sum = ""; | 866 | QString sum = ""; |
867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 867 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
868 | sum = "E: "; | 868 | sum = "E: "; |
869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 869 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
870 | lse->setDtStart( mLastCalendarSync ); | 870 | lse->setDtStart( mLastCalendarSync ); |
871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 871 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
872 | lse->setCategories( i18n("SyncEvent") ); | 872 | lse->setCategories( i18n("SyncEvent") ); |
873 | lse->setReadOnly( true ); | 873 | lse->setReadOnly( true ); |
874 | mCalendar->addEvent( lse ); | 874 | mCalendar->addEvent( lse ); |
875 | } | 875 | } |
876 | 876 | ||
877 | return lse; | 877 | return lse; |
878 | 878 | ||
879 | } | 879 | } |
880 | // probaly useless | 880 | // probaly useless |
881 | void CalendarView::setupExternSyncProfiles() | 881 | void CalendarView::setupExternSyncProfiles() |
882 | { | 882 | { |
883 | Event* lse; | 883 | Event* lse; |
884 | mExternLastSyncEvent.clear(); | 884 | mExternLastSyncEvent.clear(); |
885 | int i; | 885 | int i; |
886 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 886 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
887 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 887 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
888 | if ( lse ) | 888 | if ( lse ) |
889 | mExternLastSyncEvent.append( lse ); | 889 | mExternLastSyncEvent.append( lse ); |
890 | else | 890 | else |
891 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 891 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
892 | } | 892 | } |
893 | 893 | ||
894 | } | 894 | } |
895 | // we check, if the to delete event has a id for a profile | 895 | // we check, if the to delete event has a id for a profile |
896 | // if yes, we set this id in the profile to delete | 896 | // if yes, we set this id in the profile to delete |
897 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 897 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
898 | { | 898 | { |
899 | if ( lastSync.count() == 0 ) { | 899 | if ( lastSync.count() == 0 ) { |
900 | //qDebug(" lastSync.count() == 0"); | 900 | //qDebug(" lastSync.count() == 0"); |
901 | return; | 901 | return; |
902 | } | 902 | } |
903 | if ( toDelete->type() == "Journal" ) | 903 | if ( toDelete->type() == "Journal" ) |
904 | return; | 904 | return; |
905 | 905 | ||
906 | Event* eve = lastSync.first(); | 906 | Event* eve = lastSync.first(); |
907 | 907 | ||
908 | while ( eve ) { | 908 | while ( eve ) { |
909 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 909 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
910 | if ( !id.isEmpty() ) { | 910 | if ( !id.isEmpty() ) { |
911 | QString des = eve->description(); | 911 | QString des = eve->description(); |
912 | QString pref = "e"; | 912 | QString pref = "e"; |
913 | if ( toDelete->type() == "Todo" ) | 913 | if ( toDelete->type() == "Todo" ) |
914 | pref = "t"; | 914 | pref = "t"; |
915 | des += pref+ id + ","; | 915 | des += pref+ id + ","; |
916 | eve->setReadOnly( false ); | 916 | eve->setReadOnly( false ); |
917 | eve->setDescription( des ); | 917 | eve->setDescription( des ); |
918 | //qDebug("setdes %s ", des.latin1()); | 918 | //qDebug("setdes %s ", des.latin1()); |
919 | eve->setReadOnly( true ); | 919 | eve->setReadOnly( true ); |
920 | } | 920 | } |
921 | eve = lastSync.next(); | 921 | eve = lastSync.next(); |
922 | } | 922 | } |
923 | 923 | ||
924 | } | 924 | } |
925 | void CalendarView::checkExternalId( Incidence * inc ) | 925 | void CalendarView::checkExternalId( Incidence * inc ) |
926 | { | 926 | { |
927 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 927 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
928 | checkExternSyncEvent( lastSync, inc ); | 928 | checkExternSyncEvent( lastSync, inc ); |
929 | 929 | ||
930 | } | 930 | } |
931 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 931 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
932 | { | 932 | { |
933 | bool syncOK = true; | 933 | bool syncOK = true; |
934 | int addedEvent = 0; | 934 | int addedEvent = 0; |
935 | int addedEventR = 0; | 935 | int addedEventR = 0; |
936 | int deletedEventR = 0; | 936 | int deletedEventR = 0; |
937 | int deletedEventL = 0; | 937 | int deletedEventL = 0; |
938 | int changedLocal = 0; | 938 | int changedLocal = 0; |
939 | int changedRemote = 0; | 939 | int changedRemote = 0; |
940 | //QPtrList<Event> el = local->rawEvents(); | 940 | //QPtrList<Event> el = local->rawEvents(); |
941 | Event* eventR; | 941 | Event* eventR; |
942 | QString uid; | 942 | QString uid; |
943 | int take; | 943 | int take; |
944 | Event* eventL; | 944 | Event* eventL; |
945 | Event* eventRSync; | 945 | Event* eventRSync; |
946 | Event* eventLSync; | 946 | Event* eventLSync; |
947 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 947 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
948 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 948 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
949 | bool fullDateRange = false; | 949 | bool fullDateRange = false; |
950 | local->resetTempSyncStat(); | 950 | local->resetTempSyncStat(); |
951 | mLastCalendarSync = QDateTime::currentDateTime(); | 951 | mLastCalendarSync = QDateTime::currentDateTime(); |
952 | QDateTime modifiedCalendar = mLastCalendarSync;; | 952 | QDateTime modifiedCalendar = mLastCalendarSync;; |
953 | eventLSync = getLastSyncEvent(); | 953 | eventLSync = getLastSyncEvent(); |
954 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 954 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
955 | if ( eventR ) { | 955 | if ( eventR ) { |
956 | eventRSync = (Event*) eventR->clone(); | 956 | eventRSync = (Event*) eventR->clone(); |
957 | remote->deleteEvent(eventR ); | 957 | remote->deleteEvent(eventR ); |
958 | 958 | ||
959 | } else { | 959 | } else { |
960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 960 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
961 | eventRSync = (Event*)eventLSync->clone(); | 961 | eventRSync = (Event*)eventLSync->clone(); |
962 | } else { | 962 | } else { |
963 | fullDateRange = true; | 963 | fullDateRange = true; |
964 | eventRSync = new Event(); | 964 | eventRSync = new Event(); |
965 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 965 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
966 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 966 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
967 | eventRSync->setDtStart( mLastCalendarSync ); | 967 | eventRSync->setDtStart( mLastCalendarSync ); |
968 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 968 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
969 | eventRSync->setCategories( i18n("SyncEvent") ); | 969 | eventRSync->setCategories( i18n("SyncEvent") ); |
970 | } | 970 | } |
971 | } | 971 | } |
972 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 972 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
973 | fullDateRange = true; | 973 | fullDateRange = true; |
974 | 974 | ||
975 | if ( ! fullDateRange ) { | 975 | if ( ! fullDateRange ) { |
976 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 976 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
977 | 977 | ||
978 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 978 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
979 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 979 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
980 | fullDateRange = true; | 980 | fullDateRange = true; |
981 | } | 981 | } |
982 | } | 982 | } |
983 | if ( fullDateRange ) | 983 | if ( fullDateRange ) |
984 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 984 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
985 | else | 985 | else |
986 | mLastCalendarSync = eventLSync->dtStart(); | 986 | mLastCalendarSync = eventLSync->dtStart(); |
987 | // for resyncing if own file has changed | 987 | // for resyncing if own file has changed |
988 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 988 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
989 | mLastCalendarSync = loadedFileVersion; | 989 | mLastCalendarSync = loadedFileVersion; |
990 | qDebug("setting mLastCalendarSync "); | 990 | qDebug("setting mLastCalendarSync "); |
991 | } | 991 | } |
992 | //qDebug("*************************** "); | 992 | //qDebug("*************************** "); |
993 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 993 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
994 | QPtrList<Incidence> er = remote->rawIncidences(); | 994 | QPtrList<Incidence> er = remote->rawIncidences(); |
995 | Incidence* inR = er.first(); | 995 | Incidence* inR = er.first(); |
996 | Incidence* inL; | 996 | Incidence* inL; |
997 | QProgressBar bar( er.count(),0 ); | 997 | QProgressBar bar( er.count(),0 ); |
998 | bar.setCaption (i18n("Syncing - close to abort!") ); | 998 | bar.setCaption (i18n("Syncing - close to abort!") ); |
999 | 999 | ||
1000 | int w = 300; | 1000 | int w = 300; |
1001 | if ( QApplication::desktop()->width() < 320 ) | 1001 | if ( QApplication::desktop()->width() < 320 ) |
1002 | w = 220; | 1002 | w = 220; |
1003 | int h = bar.sizeHint().height() ; | 1003 | int h = bar.sizeHint().height() ; |
1004 | int dw = QApplication::desktop()->width(); | 1004 | int dw = QApplication::desktop()->width(); |
1005 | int dh = QApplication::desktop()->height(); | 1005 | int dh = QApplication::desktop()->height(); |
1006 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1006 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1007 | bar.show(); | 1007 | bar.show(); |
1008 | int modulo = (er.count()/10)+1; | 1008 | int modulo = (er.count()/10)+1; |
1009 | int incCounter = 0; | 1009 | int incCounter = 0; |
1010 | while ( inR ) { | 1010 | while ( inR ) { |
1011 | if ( ! bar.isVisible() ) | 1011 | if ( ! bar.isVisible() ) |
1012 | return false; | 1012 | return false; |
1013 | if ( incCounter % modulo == 0 ) | 1013 | if ( incCounter % modulo == 0 ) |
1014 | bar.setProgress( incCounter ); | 1014 | bar.setProgress( incCounter ); |
1015 | ++incCounter; | 1015 | ++incCounter; |
1016 | uid = inR->uid(); | 1016 | uid = inR->uid(); |
1017 | bool skipIncidence = false; | 1017 | bool skipIncidence = false; |
1018 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1018 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1019 | skipIncidence = true; | 1019 | skipIncidence = true; |
1020 | QString idS; | 1020 | QString idS; |
1021 | qApp->processEvents(); | 1021 | qApp->processEvents(); |
1022 | if ( !skipIncidence ) { | 1022 | if ( !skipIncidence ) { |
1023 | inL = local->incidence( uid ); | 1023 | inL = local->incidence( uid ); |
1024 | if ( inL ) { // maybe conflict - same uid in both calendars | 1024 | if ( inL ) { // maybe conflict - same uid in both calendars |
1025 | int maxrev = inL->revision(); | 1025 | int maxrev = inL->revision(); |
1026 | if ( maxrev < inR->revision() ) | 1026 | if ( maxrev < inR->revision() ) |
1027 | maxrev = inR->revision(); | 1027 | maxrev = inR->revision(); |
1028 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1028 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1029 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1029 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1030 | if ( take == 3 ) | 1030 | if ( take == 3 ) |
1031 | return false; | 1031 | return false; |
1032 | if ( take == 1 ) {// take local | 1032 | if ( take == 1 ) {// take local |
1033 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1033 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1034 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1034 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1035 | else | 1035 | else |
1036 | idS = inR->IDStr(); | 1036 | idS = inR->IDStr(); |
1037 | remote->deleteIncidence( inR ); | 1037 | remote->deleteIncidence( inR ); |
1038 | if ( inL->revision() < maxrev ) | 1038 | if ( inL->revision() < maxrev ) |
1039 | inL->setRevision( maxrev ); | 1039 | inL->setRevision( maxrev ); |
1040 | inR = inL->clone(); | 1040 | inR = inL->clone(); |
1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1042 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1042 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1043 | inR->setIDStr( idS ); | 1043 | inR->setIDStr( idS ); |
1044 | remote->addIncidence( inR ); | 1044 | remote->addIncidence( inR ); |
1045 | ++changedRemote; | 1045 | ++changedRemote; |
1046 | } else { | 1046 | } else { |
1047 | if ( inR->revision() < maxrev ) | 1047 | if ( inR->revision() < maxrev ) |
1048 | inR->setRevision( maxrev ); | 1048 | inR->setRevision( maxrev ); |
1049 | idS = inL->IDStr(); | 1049 | idS = inL->IDStr(); |
1050 | local->deleteIncidence( inL ); | 1050 | local->deleteIncidence( inL ); |
1051 | inL = inR->clone(); | 1051 | inL = inR->clone(); |
1052 | inL->setIDStr( idS ); | 1052 | inL->setIDStr( idS ); |
1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1054 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1054 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1055 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1055 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1056 | } | 1056 | } |
1057 | local->addIncidence( inL ); | 1057 | local->addIncidence( inL ); |
1058 | ++changedLocal; | 1058 | ++changedLocal; |
1059 | } | 1059 | } |
1060 | } | 1060 | } |
1061 | } else { // no conflict | 1061 | } else { // no conflict |
1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1063 | QString des = eventLSync->description(); | 1063 | QString des = eventLSync->description(); |
1064 | QString pref = "e"; | 1064 | QString pref = "e"; |
1065 | if ( inR->type() == "Todo" ) | 1065 | if ( inR->type() == "Todo" ) |
1066 | pref = "t"; | 1066 | pref = "t"; |
1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1069 | //remote->deleteIncidence( inR ); | 1069 | //remote->deleteIncidence( inR ); |
1070 | ++deletedEventR; | 1070 | ++deletedEventR; |
1071 | } else { | 1071 | } else { |
1072 | inR->setLastModified( modifiedCalendar ); | 1072 | inR->setLastModified( modifiedCalendar ); |
1073 | inL = inR->clone(); | 1073 | inL = inR->clone(); |
1074 | local->addIncidence( inL ); | 1074 | local->addIncidence( inL ); |
1075 | ++addedEvent; | 1075 | ++addedEvent; |
1076 | } | 1076 | } |
1077 | } else { | 1077 | } else { |
1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1078 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1079 | inR->setLastModified( modifiedCalendar ); | 1079 | inR->setLastModified( modifiedCalendar ); |
1080 | local->addIncidence( inR->clone() ); | 1080 | local->addIncidence( inR->clone() ); |
1081 | ++addedEvent; | 1081 | ++addedEvent; |
1082 | } else { | 1082 | } else { |
1083 | checkExternSyncEvent(eventRSyncSharp, inR); | 1083 | checkExternSyncEvent(eventRSyncSharp, inR); |
1084 | remote->deleteIncidence( inR ); | 1084 | remote->deleteIncidence( inR ); |
1085 | ++deletedEventR; | 1085 | ++deletedEventR; |
1086 | } | 1086 | } |
1087 | } | 1087 | } |
1088 | } | 1088 | } |
1089 | } | 1089 | } |
1090 | inR = er.next(); | 1090 | inR = er.next(); |
1091 | } | 1091 | } |
1092 | QPtrList<Incidence> el = local->rawIncidences(); | 1092 | QPtrList<Incidence> el = local->rawIncidences(); |
1093 | inL = el.first(); | 1093 | inL = el.first(); |
1094 | modulo = (el.count()/10)+1; | 1094 | modulo = (el.count()/10)+1; |
1095 | bar.setCaption (i18n("Add / remove events") ); | 1095 | bar.setCaption (i18n("Add / remove events") ); |
1096 | bar.setTotalSteps ( el.count() ) ; | 1096 | bar.setTotalSteps ( el.count() ) ; |
1097 | bar.show(); | 1097 | bar.show(); |
1098 | incCounter = 0; | 1098 | incCounter = 0; |
1099 | 1099 | ||
1100 | while ( inL ) { | 1100 | while ( inL ) { |
1101 | 1101 | ||
1102 | qApp->processEvents(); | 1102 | qApp->processEvents(); |
1103 | if ( ! bar.isVisible() ) | 1103 | if ( ! bar.isVisible() ) |
1104 | return false; | 1104 | return false; |
1105 | if ( incCounter % modulo == 0 ) | 1105 | if ( incCounter % modulo == 0 ) |
1106 | bar.setProgress( incCounter ); | 1106 | bar.setProgress( incCounter ); |
1107 | ++incCounter; | 1107 | ++incCounter; |
1108 | uid = inL->uid(); | 1108 | uid = inL->uid(); |
1109 | bool skipIncidence = false; | 1109 | bool skipIncidence = false; |
1110 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1110 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1111 | skipIncidence = true; | 1111 | skipIncidence = true; |
1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1112 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1113 | skipIncidence = true; | 1113 | skipIncidence = true; |
1114 | if ( !skipIncidence ) { | 1114 | if ( !skipIncidence ) { |
1115 | inR = remote->incidence( uid ); | 1115 | inR = remote->incidence( uid ); |
1116 | if ( ! inR ) { | 1116 | if ( ! inR ) { |
1117 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1117 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1118 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1118 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1119 | checkExternSyncEvent(eventLSyncSharp, inL); | 1119 | checkExternSyncEvent(eventLSyncSharp, inL); |
1120 | local->deleteIncidence( inL ); | 1120 | local->deleteIncidence( inL ); |
1121 | ++deletedEventL; | 1121 | ++deletedEventL; |
1122 | } else { | 1122 | } else { |
1123 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1123 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1124 | inL->removeID(mCurrentSyncDevice ); | 1124 | inL->removeID(mCurrentSyncDevice ); |
1125 | ++addedEventR; | 1125 | ++addedEventR; |
1126 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1126 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1127 | inL->setLastModified( modifiedCalendar ); | 1127 | inL->setLastModified( modifiedCalendar ); |
1128 | inR = inL->clone(); | 1128 | inR = inL->clone(); |
1129 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1129 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1130 | remote->addIncidence( inR ); | 1130 | remote->addIncidence( inR ); |
1131 | } | 1131 | } |
1132 | } | 1132 | } |
1133 | } else { | 1133 | } else { |
1134 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1134 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1135 | checkExternSyncEvent(eventLSyncSharp, inL); | 1135 | checkExternSyncEvent(eventLSyncSharp, inL); |
1136 | local->deleteIncidence( inL ); | 1136 | local->deleteIncidence( inL ); |
1137 | ++deletedEventL; | 1137 | ++deletedEventL; |
1138 | } else { | 1138 | } else { |
1139 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1139 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1140 | ++addedEventR; | 1140 | ++addedEventR; |
1141 | inL->setLastModified( modifiedCalendar ); | 1141 | inL->setLastModified( modifiedCalendar ); |
1142 | remote->addIncidence( inL->clone() ); | 1142 | remote->addIncidence( inL->clone() ); |
1143 | } | 1143 | } |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | inL = el.next(); | 1148 | inL = el.next(); |
1149 | } | 1149 | } |
1150 | int delFut = 0; | 1150 | int delFut = 0; |
1151 | if ( KOPrefs::instance()->mWriteBackInFuture ) { | 1151 | if ( KOPrefs::instance()->mWriteBackInFuture ) { |
1152 | er = remote->rawIncidences(); | 1152 | er = remote->rawIncidences(); |
1153 | inR = er.first(); | 1153 | inR = er.first(); |
1154 | QDateTime dt; | 1154 | QDateTime dt; |
1155 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1155 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1156 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); | 1156 | QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); |
1157 | while ( inR ) { | 1157 | while ( inR ) { |
1158 | if ( inR->type() == "Todo" ) { | 1158 | if ( inR->type() == "Todo" ) { |
1159 | Todo * t = (Todo*)inR; | 1159 | Todo * t = (Todo*)inR; |
1160 | if ( t->hasDueDate() ) | 1160 | if ( t->hasDueDate() ) |
1161 | dt = t->dtDue(); | 1161 | dt = t->dtDue(); |
1162 | else | 1162 | else |
1163 | dt = cur.addSecs( 62 ); | 1163 | dt = cur.addSecs( 62 ); |
1164 | } | 1164 | } |
1165 | else if (inR->type() == "Event" ) { | 1165 | else if (inR->type() == "Event" ) { |
1166 | bool ok; | 1166 | bool ok; |
1167 | dt = inR->getNextOccurence( cur, &ok ); | 1167 | dt = inR->getNextOccurence( cur, &ok ); |
1168 | if ( !ok ) | 1168 | if ( !ok ) |
1169 | dt = cur.addSecs( -62 ); | 1169 | dt = cur.addSecs( -62 ); |
1170 | } | 1170 | } |
1171 | else | 1171 | else |
1172 | dt = inR->dtStart(); | 1172 | dt = inR->dtStart(); |
1173 | if ( dt < cur || dt > end ) { | 1173 | if ( dt < cur || dt > end ) { |
1174 | remote->deleteIncidence( inR ); | 1174 | remote->deleteIncidence( inR ); |
1175 | ++delFut; | 1175 | ++delFut; |
1176 | } | 1176 | } |
1177 | inR = er.next(); | 1177 | inR = er.next(); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | bar.hide(); | 1180 | bar.hide(); |
1181 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1181 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1182 | eventLSync->setReadOnly( false ); | 1182 | eventLSync->setReadOnly( false ); |
1183 | eventLSync->setDtStart( mLastCalendarSync ); | 1183 | eventLSync->setDtStart( mLastCalendarSync ); |
1184 | eventRSync->setDtStart( mLastCalendarSync ); | 1184 | eventRSync->setDtStart( mLastCalendarSync ); |
1185 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1185 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1186 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1186 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1187 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1187 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1188 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1188 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1189 | eventLSync->setReadOnly( true ); | 1189 | eventLSync->setReadOnly( true ); |
1190 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1190 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1191 | remote->addEvent( eventRSync ); | 1191 | remote->addEvent( eventRSync ); |
1192 | QString mes; | 1192 | QString mes; |
1193 | 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 ); | 1193 | 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 ); |
1194 | QString delmess; | 1194 | QString delmess; |
1195 | if ( delFut ) { | 1195 | if ( delFut ) { |
1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); | 1196 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); |
1197 | mes += delmess; | 1197 | mes += delmess; |
1198 | } | 1198 | } |
1199 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1199 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1200 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1200 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1201 | } | 1201 | } |
1202 | qDebug( mes ); | 1202 | qDebug( mes ); |
1203 | mCalendar->checkAlarmForIncidence( 0, true ); | 1203 | mCalendar->checkAlarmForIncidence( 0, true ); |
1204 | return syncOK; | 1204 | return syncOK; |
1205 | } | 1205 | } |
1206 | 1206 | ||
1207 | void CalendarView::setSyncDevice( QString s ) | 1207 | void CalendarView::setSyncDevice( QString s ) |
1208 | { | 1208 | { |
1209 | mCurrentSyncDevice= s; | 1209 | mCurrentSyncDevice= s; |
1210 | } | 1210 | } |
1211 | void CalendarView::setSyncName( QString s ) | 1211 | void CalendarView::setSyncName( QString s ) |
1212 | { | 1212 | { |
1213 | mCurrentSyncName= s; | 1213 | mCurrentSyncName= s; |
1214 | } | 1214 | } |
1215 | bool CalendarView::syncCalendar(QString filename, int mode) | 1215 | bool CalendarView::syncCalendar(QString filename, int mode) |
1216 | { | 1216 | { |
1217 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1217 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1218 | CalendarLocal* calendar = new CalendarLocal(); | 1218 | CalendarLocal* calendar = new CalendarLocal(); |
1219 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1219 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1220 | FileStorage* storage = new FileStorage( calendar ); | 1220 | FileStorage* storage = new FileStorage( calendar ); |
1221 | bool syncOK = false; | 1221 | bool syncOK = false; |
1222 | storage->setFileName( filename ); | 1222 | storage->setFileName( filename ); |
1223 | // qDebug("loading ... "); | 1223 | // qDebug("loading ... "); |
1224 | if ( storage->load() ) { | 1224 | if ( storage->load() ) { |
1225 | getEventViewerDialog()->setSyncMode( true ); | 1225 | getEventViewerDialog()->setSyncMode( true ); |
1226 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1226 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1227 | getEventViewerDialog()->setSyncMode( false ); | 1227 | getEventViewerDialog()->setSyncMode( false ); |
1228 | if ( syncOK ) { | 1228 | if ( syncOK ) { |
1229 | if ( KOPrefs::instance()->mWriteBackFile ) | 1229 | if ( KOPrefs::instance()->mWriteBackFile ) |
1230 | { | 1230 | { |
1231 | storage->setSaveFormat( new ICalFormat() ); | 1231 | storage->setSaveFormat( new ICalFormat() ); |
1232 | storage->save(); | 1232 | storage->save(); |
1233 | } | 1233 | } |
1234 | } | 1234 | } |
1235 | setModified( true ); | 1235 | setModified( true ); |
1236 | } | 1236 | } |
1237 | delete storage; | 1237 | delete storage; |
1238 | delete calendar; | 1238 | delete calendar; |
1239 | if ( syncOK ) | 1239 | if ( syncOK ) |
1240 | updateView(); | 1240 | updateView(); |
1241 | return syncOK; | 1241 | return syncOK; |
1242 | } | 1242 | } |
1243 | void CalendarView::syncPhone() | 1243 | void CalendarView::syncPhone() |
1244 | { | 1244 | { |
1245 | syncExternal( 1 ); | 1245 | syncExternal( 1 ); |
1246 | } | 1246 | } |
1247 | void CalendarView::syncExternal( int mode ) | 1247 | void CalendarView::syncExternal( int mode ) |
1248 | { | 1248 | { |
1249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1249 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1250 | //mCurrentSyncDevice = "sharp-DTM"; | 1250 | //mCurrentSyncDevice = "sharp-DTM"; |
1251 | if ( KOPrefs::instance()->mAskForPreferences ) | 1251 | if ( KOPrefs::instance()->mAskForPreferences ) |
1252 | edit_sync_options(); | 1252 | edit_sync_options(); |
1253 | qApp->processEvents(); | 1253 | qApp->processEvents(); |
1254 | CalendarLocal* calendar = new CalendarLocal(); | 1254 | CalendarLocal* calendar = new CalendarLocal(); |
1255 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1255 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1256 | bool syncOK = false; | 1256 | bool syncOK = false; |
1257 | bool loadSuccess = false; | 1257 | bool loadSuccess = false; |
1258 | PhoneFormat* phoneFormat = 0; | 1258 | PhoneFormat* phoneFormat = 0; |
1259 | #ifndef DESKTOP_VERSION | 1259 | #ifndef DESKTOP_VERSION |
1260 | SharpFormat* sharpFormat = 0; | 1260 | SharpFormat* sharpFormat = 0; |
1261 | if ( mode == 0 ) { // sharp | 1261 | if ( mode == 0 ) { // sharp |
1262 | sharpFormat = new SharpFormat () ; | 1262 | sharpFormat = new SharpFormat () ; |
1263 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1263 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1264 | 1264 | ||
1265 | } else | 1265 | } else |
1266 | #endif | 1266 | #endif |
1267 | if ( mode == 1 ) { // phone | 1267 | if ( mode == 1 ) { // phone |
1268 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1268 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1269 | KOPrefs::instance()->mPhoneDevice, | 1269 | KOPrefs::instance()->mPhoneDevice, |
1270 | KOPrefs::instance()->mPhoneConnection, | 1270 | KOPrefs::instance()->mPhoneConnection, |
1271 | KOPrefs::instance()->mPhoneModel); | 1271 | KOPrefs::instance()->mPhoneModel); |
1272 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1272 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1273 | 1273 | ||
1274 | } else | 1274 | } else |
1275 | return; | 1275 | return; |
1276 | if ( loadSuccess ) { | 1276 | if ( loadSuccess ) { |
1277 | getEventViewerDialog()->setSyncMode( true ); | 1277 | getEventViewerDialog()->setSyncMode( true ); |
1278 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1278 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1279 | getEventViewerDialog()->setSyncMode( false ); | 1279 | getEventViewerDialog()->setSyncMode( false ); |
1280 | qApp->processEvents(); | 1280 | qApp->processEvents(); |
1281 | if ( syncOK ) { | 1281 | if ( syncOK ) { |
1282 | if ( KOPrefs::instance()->mWriteBackFile ) | 1282 | if ( KOPrefs::instance()->mWriteBackFile ) |
1283 | { | 1283 | { |
1284 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1284 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1285 | Incidence* inc = iL.first(); | 1285 | Incidence* inc = iL.first(); |
1286 | if ( phoneFormat ) { | 1286 | if ( phoneFormat ) { |
1287 | while ( inc ) { | 1287 | while ( inc ) { |
1288 | inc->removeID(mCurrentSyncDevice); | 1288 | inc->removeID(mCurrentSyncDevice); |
1289 | inc = iL.next(); | 1289 | inc = iL.next(); |
1290 | } | 1290 | } |
1291 | } | 1291 | } |
1292 | #ifndef DESKTOP_VERSION | 1292 | #ifndef DESKTOP_VERSION |
1293 | if ( sharpFormat ) | 1293 | if ( sharpFormat ) |
1294 | sharpFormat->save(calendar); | 1294 | sharpFormat->save(calendar); |
1295 | #endif | 1295 | #endif |
1296 | if ( phoneFormat ) | 1296 | if ( phoneFormat ) |
1297 | phoneFormat->save(calendar); | 1297 | phoneFormat->save(calendar); |
1298 | iL = calendar->rawIncidences(); | 1298 | iL = calendar->rawIncidences(); |
1299 | inc = iL.first(); | 1299 | inc = iL.first(); |
1300 | Incidence* loc; | 1300 | Incidence* loc; |
1301 | while ( inc ) { | 1301 | while ( inc ) { |
1302 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1302 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1303 | loc = mCalendar->incidence(inc->uid() ); | 1303 | loc = mCalendar->incidence(inc->uid() ); |
1304 | if ( loc ) { | 1304 | if ( loc ) { |
1305 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1305 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1306 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1306 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1307 | } | 1307 | } |
1308 | } | 1308 | } |
1309 | inc = iL.next(); | 1309 | inc = iL.next(); |
1310 | } | 1310 | } |
1311 | Incidence* lse = getLastSyncEvent(); | 1311 | Incidence* lse = getLastSyncEvent(); |
1312 | if ( lse ) { | 1312 | if ( lse ) { |
1313 | lse->setReadOnly( false ); | 1313 | lse->setReadOnly( false ); |
1314 | lse->setDescription( "" ); | 1314 | lse->setDescription( "" ); |
1315 | lse->setReadOnly( true ); | 1315 | lse->setReadOnly( true ); |
1316 | } | 1316 | } |
1317 | } | 1317 | } |
1318 | } | 1318 | } |
1319 | setModified( true ); | 1319 | setModified( true ); |
1320 | } else { | 1320 | } else { |
1321 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1321 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1322 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1322 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1323 | question, i18n("Ok")) ; | 1323 | question, i18n("Ok")) ; |
1324 | 1324 | ||
1325 | } | 1325 | } |
1326 | delete calendar; | 1326 | delete calendar; |
1327 | updateView(); | 1327 | updateView(); |
1328 | return ;//syncOK; | 1328 | return ;//syncOK; |
1329 | 1329 | ||
1330 | } | 1330 | } |
1331 | void CalendarView::syncSharp() | 1331 | void CalendarView::syncSharp() |
1332 | { | 1332 | { |
1333 | syncExternal( 0 ); | 1333 | syncExternal( 0 ); |
1334 | 1334 | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | 1337 | ||
1338 | //#include <kabc/stdaddressbook.h> | 1338 | //#include <kabc/stdaddressbook.h> |
1339 | bool CalendarView::importBday() | 1339 | bool CalendarView::importBday() |
1340 | { | 1340 | { |
1341 | #if 0 | 1341 | #if 0 |
1342 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1342 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1343 | KABC::AddressBook::Iterator it; | 1343 | KABC::AddressBook::Iterator it; |
1344 | int count = 0; | 1344 | int count = 0; |
1345 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1345 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1346 | ++count; | 1346 | ++count; |
1347 | } | 1347 | } |
1348 | QProgressBar bar(count,0 ); | 1348 | QProgressBar bar(count,0 ); |
1349 | int w = 300; | 1349 | int w = 300; |
1350 | if ( QApplication::desktop()->width() < 320 ) | 1350 | if ( QApplication::desktop()->width() < 320 ) |
1351 | w = 220; | 1351 | w = 220; |
1352 | int h = bar.sizeHint().height() ; | 1352 | int h = bar.sizeHint().height() ; |
1353 | int dw = QApplication::desktop()->width(); | 1353 | int dw = QApplication::desktop()->width(); |
1354 | int dh = QApplication::desktop()->height(); | 1354 | int dh = QApplication::desktop()->height(); |
1355 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1355 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1356 | bar.show(); | 1356 | bar.show(); |
1357 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1357 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1358 | qApp->processEvents(); | 1358 | qApp->processEvents(); |
1359 | count = 0; | 1359 | count = 0; |
1360 | int addCount = 0; | 1360 | int addCount = 0; |
1361 | KCal::Attendee* a = 0; | 1361 | KCal::Attendee* a = 0; |
1362 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1362 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1363 | if ( ! bar.isVisible() ) | 1363 | if ( ! bar.isVisible() ) |
1364 | return false; | 1364 | return false; |
1365 | bar.setProgress( count++ ); | 1365 | bar.setProgress( count++ ); |
1366 | qApp->processEvents(); | 1366 | qApp->processEvents(); |
1367 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1367 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1368 | if ( (*it).birthday().date().isValid() ){ | 1368 | if ( (*it).birthday().date().isValid() ){ |
1369 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1369 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1370 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1370 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1371 | ++addCount; | 1371 | ++addCount; |
1372 | } | 1372 | } |
1373 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1373 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1374 | if ( anni.isValid() ){ | 1374 | if ( anni.isValid() ){ |
1375 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1375 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1376 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1376 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1377 | ++addCount; | 1377 | ++addCount; |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | updateView(); | 1380 | updateView(); |
1381 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1381 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1382 | #endif | 1382 | #endif |
1383 | return true; | 1383 | return true; |
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1386 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1387 | { | 1387 | { |
1388 | //qDebug("addAnni "); | 1388 | //qDebug("addAnni "); |
1389 | Event * ev = new Event(); | 1389 | Event * ev = new Event(); |
1390 | if ( a ) { | 1390 | if ( a ) { |
1391 | ev->addAttendee( a ); | 1391 | ev->addAttendee( a ); |
1392 | } | 1392 | } |
1393 | QString kind; | 1393 | QString kind; |
1394 | if ( birthday ) | 1394 | if ( birthday ) |
1395 | kind = i18n( "Birthday" ); | 1395 | kind = i18n( "Birthday" ); |
1396 | else | 1396 | else |
1397 | kind = i18n( "Anniversary" ); | 1397 | kind = i18n( "Anniversary" ); |
1398 | ev->setSummary( name + " - " + kind ); | 1398 | ev->setSummary( name + " - " + kind ); |
1399 | ev->setOrganizer( "nobody@nowhere" ); | 1399 | ev->setOrganizer( "nobody@nowhere" ); |
1400 | ev->setCategories( kind ); | 1400 | ev->setCategories( kind ); |
1401 | ev->setDtStart( QDateTime(date) ); | 1401 | ev->setDtStart( QDateTime(date) ); |
1402 | ev->setDtEnd( QDateTime(date) ); | 1402 | ev->setDtEnd( QDateTime(date) ); |
1403 | ev->setFloats( true ); | 1403 | ev->setFloats( true ); |
1404 | Recurrence * rec = ev->recurrence(); | 1404 | Recurrence * rec = ev->recurrence(); |
1405 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1405 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1406 | rec->addYearlyNum( date.month() ); | 1406 | rec->addYearlyNum( date.month() ); |
1407 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1407 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1408 | delete ev; | 1408 | delete ev; |
1409 | return false; | 1409 | return false; |
1410 | } | 1410 | } |
1411 | return true; | 1411 | return true; |
1412 | 1412 | ||
1413 | } | 1413 | } |
1414 | bool CalendarView::importQtopia( const QString &categories, | 1414 | bool CalendarView::importQtopia( const QString &categories, |
1415 | const QString &datebook, | 1415 | const QString &datebook, |
1416 | const QString &todolist ) | 1416 | const QString &todolist ) |
1417 | { | 1417 | { |
1418 | 1418 | ||
1419 | QtopiaFormat qtopiaFormat; | 1419 | QtopiaFormat qtopiaFormat; |
1420 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1420 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1421 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1421 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1422 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1422 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1423 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1423 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1424 | 1424 | ||
1425 | updateView(); | 1425 | updateView(); |
1426 | return true; | 1426 | return true; |
1427 | 1427 | ||
1428 | #if 0 | 1428 | #if 0 |
1429 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1429 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1430 | mCurrentSyncDevice = "qtopia-XML"; | 1430 | mCurrentSyncDevice = "qtopia-XML"; |
1431 | if ( KOPrefs::instance()->mAskForPreferences ) | 1431 | if ( KOPrefs::instance()->mAskForPreferences ) |
1432 | edit_sync_options(); | 1432 | edit_sync_options(); |
1433 | qApp->processEvents(); | 1433 | qApp->processEvents(); |
1434 | CalendarLocal* calendar = new CalendarLocal(); | 1434 | CalendarLocal* calendar = new CalendarLocal(); |
1435 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1435 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1436 | bool syncOK = false; | 1436 | bool syncOK = false; |
1437 | QtopiaFormat qtopiaFormat; | 1437 | QtopiaFormat qtopiaFormat; |
1438 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1438 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1439 | bool loadOk = true; | 1439 | bool loadOk = true; |
1440 | if ( !categories.isEmpty() ) | 1440 | if ( !categories.isEmpty() ) |
1441 | loadOk = qtopiaFormat.load( calendar, categories ); | 1441 | loadOk = qtopiaFormat.load( calendar, categories ); |
1442 | if ( loadOk && !datebook.isEmpty() ) | 1442 | if ( loadOk && !datebook.isEmpty() ) |
1443 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1443 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1444 | if ( loadOk && !todolist.isEmpty() ) | 1444 | if ( loadOk && !todolist.isEmpty() ) |
1445 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1445 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1446 | 1446 | ||
1447 | if ( loadOk ) { | 1447 | if ( loadOk ) { |
1448 | getEventViewerDialog()->setSyncMode( true ); | 1448 | getEventViewerDialog()->setSyncMode( true ); |
1449 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1449 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1450 | getEventViewerDialog()->setSyncMode( false ); | 1450 | getEventViewerDialog()->setSyncMode( false ); |
1451 | qApp->processEvents(); | 1451 | qApp->processEvents(); |
1452 | if ( syncOK ) { | 1452 | if ( syncOK ) { |
1453 | if ( KOPrefs::instance()->mWriteBackFile ) | 1453 | if ( KOPrefs::instance()->mWriteBackFile ) |
1454 | { | 1454 | { |
1455 | // write back XML file | 1455 | // write back XML file |
1456 | 1456 | ||
1457 | } | 1457 | } |
1458 | setModified( true ); | 1458 | setModified( true ); |
1459 | } | 1459 | } |
1460 | } else { | 1460 | } else { |
1461 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1461 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1462 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1462 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1463 | question, i18n("Ok")) ; | 1463 | question, i18n("Ok")) ; |
1464 | } | 1464 | } |
1465 | delete calendar; | 1465 | delete calendar; |
1466 | updateView(); | 1466 | updateView(); |
1467 | return syncOK; | 1467 | return syncOK; |
1468 | 1468 | ||
1469 | 1469 | ||
1470 | #endif | 1470 | #endif |
1471 | 1471 | ||
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | void CalendarView::setSyncEventsReadOnly() | 1474 | void CalendarView::setSyncEventsReadOnly() |
1475 | { | 1475 | { |
1476 | Event * ev; | 1476 | Event * ev; |
1477 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1477 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1478 | ev = eL.first(); | 1478 | ev = eL.first(); |
1479 | while ( ev ) { | 1479 | while ( ev ) { |
1480 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1480 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1481 | ev->setReadOnly( true ); | 1481 | ev->setReadOnly( true ); |
1482 | ev = eL.next(); | 1482 | ev = eL.next(); |
1483 | } | 1483 | } |
1484 | } | 1484 | } |
1485 | bool CalendarView::openCalendar(QString filename, bool merge) | 1485 | bool CalendarView::openCalendar(QString filename, bool merge) |
1486 | { | 1486 | { |
1487 | 1487 | ||
1488 | if (filename.isEmpty()) { | 1488 | if (filename.isEmpty()) { |
1489 | return false; | 1489 | return false; |
1490 | } | 1490 | } |
1491 | 1491 | ||
1492 | if (!QFile::exists(filename)) { | 1492 | if (!QFile::exists(filename)) { |
1493 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1493 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1494 | return false; | 1494 | return false; |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | globalFlagBlockAgenda = 1; | 1497 | globalFlagBlockAgenda = 1; |
1498 | if (!merge) mCalendar->close(); | 1498 | if (!merge) mCalendar->close(); |
1499 | 1499 | ||
1500 | mStorage->setFileName( filename ); | 1500 | mStorage->setFileName( filename ); |
1501 | 1501 | ||
1502 | if ( mStorage->load() ) { | 1502 | if ( mStorage->load() ) { |
1503 | if ( merge ) ;//setModified( true ); | 1503 | if ( merge ) ;//setModified( true ); |
1504 | else { | 1504 | else { |
1505 | //setModified( true ); | 1505 | //setModified( true ); |
1506 | mViewManager->setDocumentId( filename ); | 1506 | mViewManager->setDocumentId( filename ); |
1507 | mDialogManager->setDocumentId( filename ); | 1507 | mDialogManager->setDocumentId( filename ); |
1508 | mTodoList->setDocumentId( filename ); | 1508 | mTodoList->setDocumentId( filename ); |
1509 | } | 1509 | } |
1510 | globalFlagBlockAgenda = 2; | 1510 | globalFlagBlockAgenda = 2; |
1511 | // if ( getLastSyncEvent() ) | 1511 | // if ( getLastSyncEvent() ) |
1512 | // getLastSyncEvent()->setReadOnly( true ); | 1512 | // getLastSyncEvent()->setReadOnly( true ); |
1513 | mCalendar->reInitAlarmSettings(); | 1513 | mCalendar->reInitAlarmSettings(); |
1514 | setSyncEventsReadOnly(); | 1514 | setSyncEventsReadOnly(); |
1515 | updateUnmanagedViews(); | 1515 | updateUnmanagedViews(); |
1516 | updateView(); | 1516 | updateView(); |
1517 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); | 1517 | setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 )); |
1518 | if ( filename != MainWindow::defaultFileName() ) { | 1518 | if ( filename != MainWindow::defaultFileName() ) { |
1519 | saveCalendar( MainWindow::defaultFileName() ); | 1519 | saveCalendar( MainWindow::defaultFileName() ); |
1520 | watchSavedFile(); | 1520 | watchSavedFile(); |
1521 | } | 1521 | } |
1522 | return true; | 1522 | return true; |
1523 | } else { | 1523 | } else { |
1524 | // while failing to load, the calendar object could | 1524 | // while failing to load, the calendar object could |
1525 | // have become partially populated. Clear it out. | 1525 | // have become partially populated. Clear it out. |
1526 | if ( !merge ) { | 1526 | if ( !merge ) { |
1527 | mCalendar->close(); | 1527 | mCalendar->close(); |
1528 | mViewManager->setDocumentId( filename ); | 1528 | mViewManager->setDocumentId( filename ); |
1529 | mDialogManager->setDocumentId( filename ); | 1529 | mDialogManager->setDocumentId( filename ); |
1530 | mTodoList->setDocumentId( filename ); | 1530 | mTodoList->setDocumentId( filename ); |
1531 | } | 1531 | } |
1532 | 1532 | ||
1533 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1533 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1534 | 1534 | ||
1535 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1535 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1536 | globalFlagBlockAgenda = 2; | 1536 | globalFlagBlockAgenda = 2; |
1537 | mCalendar->reInitAlarmSettings(); | 1537 | mCalendar->reInitAlarmSettings(); |
1538 | setSyncEventsReadOnly(); | 1538 | setSyncEventsReadOnly(); |
1539 | updateUnmanagedViews(); | 1539 | updateUnmanagedViews(); |
1540 | updateView(); | 1540 | updateView(); |
1541 | } | 1541 | } |
1542 | return false; | 1542 | return false; |
1543 | } | 1543 | } |
1544 | void CalendarView::showOpenError() | 1544 | void CalendarView::showOpenError() |
1545 | { | 1545 | { |
1546 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1546 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1547 | } | 1547 | } |
1548 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1548 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1549 | { | 1549 | { |
1550 | loadedFileVersion = dt; | 1550 | loadedFileVersion = dt; |
1551 | } | 1551 | } |
1552 | bool CalendarView::checkFileChanged(QString fn) | 1552 | bool CalendarView::checkFileChanged(QString fn) |
1553 | { | 1553 | { |
1554 | QFileInfo finf ( fn ); | 1554 | QFileInfo finf ( fn ); |
1555 | if ( !finf.exists() ) | 1555 | if ( !finf.exists() ) |
1556 | return true; | 1556 | return true; |
1557 | QDateTime dt = finf.lastModified (); | 1557 | QDateTime dt = finf.lastModified (); |
1558 | if ( dt <= loadedFileVersion ) | 1558 | if ( dt <= loadedFileVersion ) |
1559 | return false; | 1559 | return false; |
1560 | return true; | 1560 | return true; |
1561 | 1561 | ||
1562 | } | 1562 | } |
1563 | void CalendarView::watchSavedFile() | 1563 | void CalendarView::watchSavedFile() |
1564 | { | 1564 | { |
1565 | QFileInfo finf ( MainWindow::defaultFileName()); | 1565 | QFileInfo finf ( MainWindow::defaultFileName()); |
1566 | if ( !finf.exists() ) | 1566 | if ( !finf.exists() ) |
1567 | return; | 1567 | return; |
1568 | QDateTime dt = finf.lastModified (); | 1568 | QDateTime dt = finf.lastModified (); |
1569 | if ( dt < loadedFileVersion ) { | 1569 | if ( dt < loadedFileVersion ) { |
1570 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1570 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1571 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1571 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1572 | return; | 1572 | return; |
1573 | } | 1573 | } |
1574 | loadedFileVersion = dt; | 1574 | loadedFileVersion = dt; |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | bool CalendarView::checkFileVersion(QString fn) | 1577 | bool CalendarView::checkFileVersion(QString fn) |
1578 | { | 1578 | { |
1579 | QFileInfo finf ( fn ); | 1579 | QFileInfo finf ( fn ); |
1580 | if ( !finf.exists() ) | 1580 | if ( !finf.exists() ) |
1581 | return true; | 1581 | return true; |
1582 | QDateTime dt = finf.lastModified (); | 1582 | QDateTime dt = finf.lastModified (); |
1583 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1583 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1584 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1584 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1585 | if ( dt <= loadedFileVersion ) | 1585 | if ( dt <= loadedFileVersion ) |
1586 | return true; | 1586 | return true; |
1587 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1587 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1588 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1588 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1589 | i18n("Sync+save")); | 1589 | i18n("Sync+save")); |
1590 | 1590 | ||
1591 | if ( km == KMessageBox::Cancel ) | 1591 | if ( km == KMessageBox::Cancel ) |
1592 | return false; | 1592 | return false; |
1593 | if ( km == KMessageBox::Yes ) | 1593 | if ( km == KMessageBox::Yes ) |
1594 | return true; | 1594 | return true; |
1595 | 1595 | ||
1596 | setSyncDevice("deleteaftersync" ); | 1596 | setSyncDevice("deleteaftersync" ); |
1597 | KOPrefs::instance()->mAskForPreferences = true; | 1597 | KOPrefs::instance()->mAskForPreferences = true; |
1598 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1598 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1599 | KOPrefs::instance()->mWriteBackFile = false; | 1599 | KOPrefs::instance()->mWriteBackFile = false; |
1600 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1600 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1601 | KOPrefs::instance()->mShowSyncSummary = false; | 1601 | KOPrefs::instance()->mShowSyncSummary = false; |
1602 | syncCalendar( fn, 3 ); | 1602 | syncCalendar( fn, 3 ); |
1603 | Event * e = getLastSyncEvent(); | 1603 | Event * e = getLastSyncEvent(); |
1604 | mCalendar->deleteEvent ( e ); | 1604 | mCalendar->deleteEvent ( e ); |
1605 | updateView(); | 1605 | updateView(); |
1606 | return true; | 1606 | return true; |
1607 | } | 1607 | } |
1608 | 1608 | ||
1609 | bool CalendarView::saveCalendar( QString filename ) | 1609 | bool CalendarView::saveCalendar( QString filename ) |
1610 | { | 1610 | { |
1611 | 1611 | ||
1612 | // Store back all unsaved data into calendar object | 1612 | // Store back all unsaved data into calendar object |
1613 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1613 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1614 | if ( mViewManager->currentView() ) | 1614 | if ( mViewManager->currentView() ) |
1615 | mViewManager->currentView()->flushView(); | 1615 | mViewManager->currentView()->flushView(); |
1616 | 1616 | ||
1617 | //mStorage->setFileName( filename ); | 1617 | //mStorage->setFileName( filename ); |
1618 | 1618 | ||
1619 | mStorage->setSaveFormat( new ICalFormat() ); | 1619 | mStorage->setSaveFormat( new ICalFormat() ); |
1620 | mStorage->setFileName( filename ); | 1620 | mStorage->setFileName( filename ); |
1621 | bool success; | 1621 | bool success; |
1622 | success = mStorage->save(); | 1622 | success = mStorage->save(); |
1623 | if ( !success ) { | 1623 | if ( !success ) { |
1624 | return false; | 1624 | return false; |
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | return true; | 1627 | return true; |
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | void CalendarView::closeCalendar() | 1630 | void CalendarView::closeCalendar() |
1631 | { | 1631 | { |
1632 | 1632 | ||
1633 | // child windows no longer valid | 1633 | // child windows no longer valid |
1634 | emit closingDown(); | 1634 | emit closingDown(); |
1635 | 1635 | ||
1636 | mCalendar->close(); | 1636 | mCalendar->close(); |
1637 | setModified(false); | 1637 | setModified(false); |
1638 | updateView(); | 1638 | updateView(); |
1639 | } | 1639 | } |
1640 | 1640 | ||
1641 | void CalendarView::archiveCalendar() | 1641 | void CalendarView::archiveCalendar() |
1642 | { | 1642 | { |
1643 | mDialogManager->showArchiveDialog(); | 1643 | mDialogManager->showArchiveDialog(); |
1644 | } | 1644 | } |
1645 | 1645 | ||
1646 | 1646 | ||
1647 | void CalendarView::readSettings() | 1647 | void CalendarView::readSettings() |
1648 | { | 1648 | { |
1649 | 1649 | ||
1650 | 1650 | ||
1651 | // mViewManager->showAgendaView(); | 1651 | // mViewManager->showAgendaView(); |
1652 | QString str; | 1652 | QString str; |
1653 | //qDebug("CalendarView::readSettings() "); | 1653 | //qDebug("CalendarView::readSettings() "); |
1654 | // read settings from the KConfig, supplying reasonable | 1654 | // read settings from the KConfig, supplying reasonable |
1655 | // defaults where none are to be found | 1655 | // defaults where none are to be found |
1656 | KConfig *config = KOGlobals::config(); | 1656 | KConfig *config = KOGlobals::config(); |
1657 | #ifndef KORG_NOSPLITTER | 1657 | #ifndef KORG_NOSPLITTER |
1658 | config->setGroup("KOrganizer Geometry"); | 1658 | config->setGroup("KOrganizer Geometry"); |
1659 | 1659 | ||
1660 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1660 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1661 | if (sizes.count() != 2) { | 1661 | if (sizes.count() != 2) { |
1662 | sizes << mDateNavigator->minimumSizeHint().width(); | 1662 | sizes << mDateNavigator->minimumSizeHint().width(); |
1663 | sizes << 300; | 1663 | sizes << 300; |
1664 | } | 1664 | } |
1665 | mPanner->setSizes(sizes); | 1665 | mPanner->setSizes(sizes); |
1666 | 1666 | ||
1667 | sizes = config->readIntListEntry("Separator2"); | 1667 | sizes = config->readIntListEntry("Separator2"); |
1668 | if ( ( mResourceView && sizes.count() == 4 ) || | 1668 | if ( ( mResourceView && sizes.count() == 4 ) || |
1669 | ( !mResourceView && sizes.count() == 3 ) ) { | 1669 | ( !mResourceView && sizes.count() == 3 ) ) { |
1670 | mLeftSplitter->setSizes(sizes); | 1670 | mLeftSplitter->setSizes(sizes); |
1671 | } | 1671 | } |
1672 | #endif | 1672 | #endif |
1673 | globalFlagBlockAgenda = 1; | 1673 | globalFlagBlockAgenda = 1; |
1674 | mViewManager->showAgendaView(); | 1674 | mViewManager->showAgendaView(); |
1675 | //mViewManager->readSettings( config ); | 1675 | //mViewManager->readSettings( config ); |
1676 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1676 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1677 | readFilterSettings(config); | 1677 | readFilterSettings(config); |
1678 | config->setGroup( "Views" ); | 1678 | config->setGroup( "Views" ); |
1679 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1679 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1680 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1680 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1681 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1681 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1682 | else mNavigator->selectDates( dateCount ); | 1682 | else mNavigator->selectDates( dateCount ); |
1683 | // mViewManager->readSettings( config ); | 1683 | // mViewManager->readSettings( config ); |
1684 | updateConfig(); | 1684 | updateConfig(); |
1685 | globalFlagBlockAgenda = 2; | 1685 | globalFlagBlockAgenda = 2; |
1686 | mViewManager->readSettings( config ); | 1686 | mViewManager->readSettings( config ); |
1687 | #ifdef DESKTOP_VERSION | 1687 | #ifdef DESKTOP_VERSION |
1688 | config->setGroup("WidgetLayout"); | 1688 | config->setGroup("WidgetLayout"); |
1689 | QStringList list; | 1689 | QStringList list; |
1690 | list = config->readListEntry("MainLayout"); | 1690 | list = config->readListEntry("MainLayout"); |
1691 | int x,y,w,h; | 1691 | int x,y,w,h; |
1692 | if ( ! list.isEmpty() ) { | 1692 | if ( ! list.isEmpty() ) { |
1693 | x = list[0].toInt(); | 1693 | x = list[0].toInt(); |
1694 | y = list[1].toInt(); | 1694 | y = list[1].toInt(); |
1695 | w = list[2].toInt(); | 1695 | w = list[2].toInt(); |
1696 | h = list[3].toInt(); | 1696 | h = list[3].toInt(); |
1697 | topLevelWidget()->setGeometry(x,y,w,h); | 1697 | topLevelWidget()->setGeometry(x,y,w,h); |
1698 | 1698 | ||
1699 | } else { | 1699 | } else { |
1700 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1700 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1701 | } | 1701 | } |
1702 | list = config->readListEntry("EditEventLayout"); | 1702 | list = config->readListEntry("EditEventLayout"); |
1703 | if ( ! list.isEmpty() ) { | 1703 | if ( ! list.isEmpty() ) { |
1704 | x = list[0].toInt(); | 1704 | x = list[0].toInt(); |
1705 | y = list[1].toInt(); | 1705 | y = list[1].toInt(); |
1706 | w = list[2].toInt(); | 1706 | w = list[2].toInt(); |
1707 | h = list[3].toInt(); | 1707 | h = list[3].toInt(); |
1708 | mEventEditor->setGeometry(x,y,w,h); | 1708 | mEventEditor->setGeometry(x,y,w,h); |
1709 | 1709 | ||
1710 | } | 1710 | } |
1711 | list = config->readListEntry("EditTodoLayout"); | 1711 | list = config->readListEntry("EditTodoLayout"); |
1712 | if ( ! list.isEmpty() ) { | 1712 | if ( ! list.isEmpty() ) { |
1713 | x = list[0].toInt(); | 1713 | x = list[0].toInt(); |
1714 | y = list[1].toInt(); | 1714 | y = list[1].toInt(); |
1715 | w = list[2].toInt(); | 1715 | w = list[2].toInt(); |
1716 | h = list[3].toInt(); | 1716 | h = list[3].toInt(); |
1717 | mTodoEditor->setGeometry(x,y,w,h); | 1717 | mTodoEditor->setGeometry(x,y,w,h); |
1718 | 1718 | ||
1719 | } | 1719 | } |
1720 | list = config->readListEntry("ViewerLayout"); | 1720 | list = config->readListEntry("ViewerLayout"); |
1721 | if ( ! list.isEmpty() ) { | 1721 | if ( ! list.isEmpty() ) { |
1722 | x = list[0].toInt(); | 1722 | x = list[0].toInt(); |
1723 | y = list[1].toInt(); | 1723 | y = list[1].toInt(); |
1724 | w = list[2].toInt(); | 1724 | w = list[2].toInt(); |
1725 | h = list[3].toInt(); | 1725 | h = list[3].toInt(); |
1726 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1726 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1727 | } | 1727 | } |
1728 | #endif | 1728 | #endif |
1729 | 1729 | ||
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | 1732 | ||
1733 | void CalendarView::writeSettings() | 1733 | void CalendarView::writeSettings() |
1734 | { | 1734 | { |
1735 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1735 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1736 | 1736 | ||
1737 | KConfig *config = KOGlobals::config(); | 1737 | KConfig *config = KOGlobals::config(); |
1738 | 1738 | ||
1739 | #ifndef KORG_NOSPLITTER | 1739 | #ifndef KORG_NOSPLITTER |
1740 | config->setGroup("KOrganizer Geometry"); | 1740 | config->setGroup("KOrganizer Geometry"); |
1741 | 1741 | ||
1742 | QValueList<int> list = mPanner->sizes(); | 1742 | QValueList<int> list = mPanner->sizes(); |
1743 | config->writeEntry("Separator1",list); | 1743 | config->writeEntry("Separator1",list); |
1744 | 1744 | ||
1745 | list = mLeftSplitter->sizes(); | 1745 | list = mLeftSplitter->sizes(); |
1746 | config->writeEntry("Separator2",list); | 1746 | config->writeEntry("Separator2",list); |
1747 | #endif | 1747 | #endif |
1748 | 1748 | ||
1749 | mViewManager->writeSettings( config ); | 1749 | mViewManager->writeSettings( config ); |
1750 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1750 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1751 | mDialogManager->writeSettings( config ); | 1751 | mDialogManager->writeSettings( config ); |
1752 | //KOPrefs::instance()->usrWriteConfig(); | 1752 | //KOPrefs::instance()->usrWriteConfig(); |
1753 | KOPrefs::instance()->writeConfig(); | 1753 | KOPrefs::instance()->writeConfig(); |
1754 | 1754 | ||
1755 | writeFilterSettings(config); | 1755 | writeFilterSettings(config); |
1756 | 1756 | ||
1757 | config->setGroup( "Views" ); | 1757 | config->setGroup( "Views" ); |
1758 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1758 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1759 | 1759 | ||
1760 | #ifdef DESKTOP_VERSION | 1760 | #ifdef DESKTOP_VERSION |
1761 | config->setGroup("WidgetLayout"); | 1761 | config->setGroup("WidgetLayout"); |
1762 | QStringList list ;//= config->readListEntry("MainLayout"); | 1762 | QStringList list ;//= config->readListEntry("MainLayout"); |
1763 | int x,y,w,h; | 1763 | int x,y,w,h; |
1764 | QWidget* wid; | 1764 | QWidget* wid; |
1765 | wid = topLevelWidget(); | 1765 | wid = topLevelWidget(); |
1766 | x = wid->geometry().x(); | 1766 | x = wid->geometry().x(); |
1767 | y = wid->geometry().y(); | 1767 | y = wid->geometry().y(); |
1768 | w = wid->width(); | 1768 | w = wid->width(); |
1769 | h = wid->height(); | 1769 | h = wid->height(); |
1770 | list.clear(); | 1770 | list.clear(); |
1771 | list << QString::number( x ); | 1771 | list << QString::number( x ); |
1772 | list << QString::number( y ); | 1772 | list << QString::number( y ); |
1773 | list << QString::number( w ); | 1773 | list << QString::number( w ); |
1774 | list << QString::number( h ); | 1774 | list << QString::number( h ); |
1775 | config->writeEntry("MainLayout",list ); | 1775 | config->writeEntry("MainLayout",list ); |
1776 | 1776 | ||
1777 | wid = mEventEditor; | 1777 | wid = mEventEditor; |
1778 | x = wid->geometry().x(); | 1778 | x = wid->geometry().x(); |
1779 | y = wid->geometry().y(); | 1779 | y = wid->geometry().y(); |
1780 | w = wid->width(); | 1780 | w = wid->width(); |
1781 | h = wid->height(); | 1781 | h = wid->height(); |
1782 | list.clear(); | 1782 | list.clear(); |
1783 | list << QString::number( x ); | 1783 | list << QString::number( x ); |
1784 | list << QString::number( y ); | 1784 | list << QString::number( y ); |
1785 | list << QString::number( w ); | 1785 | list << QString::number( w ); |
1786 | list << QString::number( h ); | 1786 | list << QString::number( h ); |
1787 | config->writeEntry("EditEventLayout",list ); | 1787 | config->writeEntry("EditEventLayout",list ); |
1788 | 1788 | ||
1789 | wid = mTodoEditor; | 1789 | wid = mTodoEditor; |
1790 | x = wid->geometry().x(); | 1790 | x = wid->geometry().x(); |
1791 | y = wid->geometry().y(); | 1791 | y = wid->geometry().y(); |
1792 | w = wid->width(); | 1792 | w = wid->width(); |
1793 | h = wid->height(); | 1793 | h = wid->height(); |
1794 | list.clear(); | 1794 | list.clear(); |
1795 | list << QString::number( x ); | 1795 | list << QString::number( x ); |
1796 | list << QString::number( y ); | 1796 | list << QString::number( y ); |
1797 | list << QString::number( w ); | 1797 | list << QString::number( w ); |
1798 | list << QString::number( h ); | 1798 | list << QString::number( h ); |
1799 | config->writeEntry("EditTodoLayout",list ); | 1799 | config->writeEntry("EditTodoLayout",list ); |
1800 | wid = getEventViewerDialog(); | 1800 | wid = getEventViewerDialog(); |
1801 | x = wid->geometry().x(); | 1801 | x = wid->geometry().x(); |
1802 | y = wid->geometry().y(); | 1802 | y = wid->geometry().y(); |
1803 | w = wid->width(); | 1803 | w = wid->width(); |
1804 | h = wid->height(); | 1804 | h = wid->height(); |
1805 | list.clear(); | 1805 | list.clear(); |
1806 | list << QString::number( x ); | 1806 | list << QString::number( x ); |
1807 | list << QString::number( y ); | 1807 | list << QString::number( y ); |
1808 | list << QString::number( w ); | 1808 | list << QString::number( w ); |
1809 | list << QString::number( h ); | 1809 | list << QString::number( h ); |
1810 | config->writeEntry("ViewerLayout",list ); | 1810 | config->writeEntry("ViewerLayout",list ); |
1811 | wid = mDialogManager->getSearchDialog(); | 1811 | wid = mDialogManager->getSearchDialog(); |
1812 | if ( wid ) { | 1812 | if ( wid ) { |
1813 | x = wid->geometry().x(); | 1813 | x = wid->geometry().x(); |
1814 | y = wid->geometry().y(); | 1814 | y = wid->geometry().y(); |
1815 | w = wid->width(); | 1815 | w = wid->width(); |
1816 | h = wid->height(); | 1816 | h = wid->height(); |
1817 | list.clear(); | 1817 | list.clear(); |
1818 | list << QString::number( x ); | 1818 | list << QString::number( x ); |
1819 | list << QString::number( y ); | 1819 | list << QString::number( y ); |
1820 | list << QString::number( w ); | 1820 | list << QString::number( w ); |
1821 | list << QString::number( h ); | 1821 | list << QString::number( h ); |
1822 | config->writeEntry("SearchLayout",list ); | 1822 | config->writeEntry("SearchLayout",list ); |
1823 | } | 1823 | } |
1824 | #endif | 1824 | #endif |
1825 | 1825 | ||
1826 | 1826 | ||
1827 | config->sync(); | 1827 | config->sync(); |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | void CalendarView::readFilterSettings(KConfig *config) | 1830 | void CalendarView::readFilterSettings(KConfig *config) |
1831 | { | 1831 | { |
1832 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1832 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1833 | 1833 | ||
1834 | mFilters.clear(); | 1834 | mFilters.clear(); |
1835 | 1835 | ||
1836 | config->setGroup("General"); | 1836 | config->setGroup("General"); |
1837 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1837 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1838 | 1838 | ||
1839 | QStringList::ConstIterator it = filterList.begin(); | 1839 | QStringList::ConstIterator it = filterList.begin(); |
1840 | QStringList::ConstIterator end = filterList.end(); | 1840 | QStringList::ConstIterator end = filterList.end(); |
1841 | while(it != end) { | 1841 | while(it != end) { |
1842 | // kdDebug() << " filter: " << (*it) << endl; | 1842 | // kdDebug() << " filter: " << (*it) << endl; |
1843 | 1843 | ||
1844 | CalFilter *filter; | 1844 | CalFilter *filter; |
1845 | filter = new CalFilter(*it); | 1845 | filter = new CalFilter(*it); |
1846 | config->setGroup("Filter_" + (*it)); | 1846 | config->setGroup("Filter_" + (*it)); |
1847 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1847 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1848 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1848 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1849 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1849 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1850 | mFilters.append(filter); | 1850 | mFilters.append(filter); |
1851 | 1851 | ||
1852 | ++it; | 1852 | ++it; |
1853 | } | 1853 | } |
1854 | 1854 | ||
1855 | if (mFilters.count() == 0) { | 1855 | if (mFilters.count() == 0) { |
1856 | CalFilter *filter = new CalFilter(i18n("Default")); | 1856 | CalFilter *filter = new CalFilter(i18n("Default")); |
1857 | mFilters.append(filter); | 1857 | mFilters.append(filter); |
1858 | } | 1858 | } |
1859 | mFilterView->updateFilters(); | 1859 | mFilterView->updateFilters(); |
1860 | config->setGroup("FilterView"); | 1860 | config->setGroup("FilterView"); |
1861 | 1861 | ||
1862 | mFilterView->blockSignals(true); | 1862 | mFilterView->blockSignals(true); |
1863 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1863 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1864 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1864 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1865 | mFilterView->blockSignals(false); | 1865 | mFilterView->blockSignals(false); |
1866 | // We do it manually to avoid it being done twice by the above calls | 1866 | // We do it manually to avoid it being done twice by the above calls |
1867 | updateFilter(); | 1867 | updateFilter(); |
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | void CalendarView::writeFilterSettings(KConfig *config) | 1870 | void CalendarView::writeFilterSettings(KConfig *config) |
1871 | { | 1871 | { |
1872 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1872 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1873 | 1873 | ||
1874 | QStringList filterList; | 1874 | QStringList filterList; |
1875 | 1875 | ||
1876 | CalFilter *filter = mFilters.first(); | 1876 | CalFilter *filter = mFilters.first(); |
1877 | while(filter) { | 1877 | while(filter) { |
1878 | // kdDebug() << " fn: " << filter->name() << endl; | 1878 | // kdDebug() << " fn: " << filter->name() << endl; |
1879 | filterList << filter->name(); | 1879 | filterList << filter->name(); |
1880 | config->setGroup("Filter_" + filter->name()); | 1880 | config->setGroup("Filter_" + filter->name()); |
1881 | config->writeEntry("Criteria",filter->criteria()); | 1881 | config->writeEntry("Criteria",filter->criteria()); |
1882 | config->writeEntry("CategoryList",filter->categoryList()); | 1882 | config->writeEntry("CategoryList",filter->categoryList()); |
1883 | filter = mFilters.next(); | 1883 | filter = mFilters.next(); |
1884 | } | 1884 | } |
1885 | config->setGroup("General"); | 1885 | config->setGroup("General"); |
1886 | config->writeEntry("CalendarFilters",filterList); | 1886 | config->writeEntry("CalendarFilters",filterList); |
1887 | 1887 | ||
1888 | config->setGroup("FilterView"); | 1888 | config->setGroup("FilterView"); |
1889 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1889 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1890 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1890 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1891 | } | 1891 | } |
1892 | 1892 | ||
1893 | 1893 | ||
1894 | void CalendarView::goToday() | 1894 | void CalendarView::goToday() |
1895 | { | 1895 | { |
1896 | mNavigator->selectToday(); | 1896 | mNavigator->selectToday(); |
1897 | } | 1897 | } |
1898 | 1898 | ||
1899 | void CalendarView::goNext() | 1899 | void CalendarView::goNext() |
1900 | { | 1900 | { |
1901 | mNavigator->selectNext(); | 1901 | mNavigator->selectNext(); |
1902 | } | 1902 | } |
1903 | 1903 | ||
1904 | void CalendarView::goPrevious() | 1904 | void CalendarView::goPrevious() |
1905 | { | 1905 | { |
1906 | mNavigator->selectPrevious(); | 1906 | mNavigator->selectPrevious(); |
1907 | } | 1907 | } |
1908 | void CalendarView::goNextMonth() | 1908 | void CalendarView::goNextMonth() |
1909 | { | 1909 | { |
1910 | mNavigator->selectNextMonth(); | 1910 | mNavigator->selectNextMonth(); |
1911 | } | 1911 | } |
1912 | 1912 | ||
1913 | void CalendarView::goPreviousMonth() | 1913 | void CalendarView::goPreviousMonth() |
1914 | { | 1914 | { |
1915 | mNavigator->selectPreviousMonth(); | 1915 | mNavigator->selectPreviousMonth(); |
1916 | } | 1916 | } |
1917 | void CalendarView::writeLocale() | 1917 | void CalendarView::writeLocale() |
1918 | { | 1918 | { |
1919 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 1919 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
1920 | #if 0 | 1920 | #if 0 |
1921 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1921 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1922 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1922 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1923 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1923 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1924 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1924 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1925 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1925 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1926 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1926 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1927 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1927 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1928 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1928 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1929 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1929 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1930 | KOPrefs::instance()->mDaylightsavingStart, | 1930 | KOPrefs::instance()->mDaylightsavingStart, |
1931 | KOPrefs::instance()->mDaylightsavingEnd ); | 1931 | KOPrefs::instance()->mDaylightsavingEnd ); |
1932 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1932 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1933 | #endif | 1933 | #endif |
1934 | } | 1934 | } |
1935 | void CalendarView::updateConfig() | 1935 | void CalendarView::updateConfig() |
1936 | { | 1936 | { |
1937 | writeLocale(); | 1937 | writeLocale(); |
1938 | if ( KOPrefs::instance()->mUseAppColors ) | 1938 | if ( KOPrefs::instance()->mUseAppColors ) |
1939 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1939 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1940 | emit configChanged(); | 1940 | emit configChanged(); |
1941 | mTodoList->updateConfig(); | 1941 | mTodoList->updateConfig(); |
1942 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1942 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1943 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1943 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1944 | // To make the "fill window" configurations work | 1944 | // To make the "fill window" configurations work |
1945 | //mViewManager->raiseCurrentView(); | 1945 | //mViewManager->raiseCurrentView(); |
1946 | } | 1946 | } |
1947 | 1947 | ||
1948 | 1948 | ||
1949 | void CalendarView::eventChanged(Event *event) | 1949 | void CalendarView::eventChanged(Event *event) |
1950 | { | 1950 | { |
1951 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1951 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1952 | //updateUnmanagedViews(); | 1952 | //updateUnmanagedViews(); |
1953 | } | 1953 | } |
1954 | 1954 | ||
1955 | void CalendarView::eventAdded(Event *event) | 1955 | void CalendarView::eventAdded(Event *event) |
1956 | { | 1956 | { |
1957 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1957 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1958 | } | 1958 | } |
1959 | 1959 | ||
1960 | void CalendarView::eventToBeDeleted(Event *) | 1960 | void CalendarView::eventToBeDeleted(Event *) |
1961 | { | 1961 | { |
1962 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1962 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1963 | } | 1963 | } |
1964 | 1964 | ||
1965 | void CalendarView::eventDeleted() | 1965 | void CalendarView::eventDeleted() |
1966 | { | 1966 | { |
1967 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1967 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1968 | } | 1968 | } |
1969 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1969 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1970 | { | 1970 | { |
1971 | changeIncidenceDisplay((Incidence *)which, action); | 1971 | changeIncidenceDisplay((Incidence *)which, action); |
1972 | mDateNavigator->updateView(); //LR | 1972 | mDateNavigator->updateView(); //LR |
1973 | //mDialogManager->updateSearchDialog(); | 1973 | //mDialogManager->updateSearchDialog(); |
1974 | 1974 | ||
1975 | if (which) { | 1975 | if (which) { |
1976 | mViewManager->updateWNview(); | 1976 | mViewManager->updateWNview(); |
1977 | //mTodoList->updateView(); | 1977 | //mTodoList->updateView(); |
1978 | } | 1978 | } |
1979 | 1979 | ||
1980 | } | 1980 | } |
1981 | 1981 | ||
1982 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1982 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1983 | { | 1983 | { |
1984 | updateUnmanagedViews(); | 1984 | updateUnmanagedViews(); |
1985 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1985 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1986 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1986 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1987 | mCalendar->checkAlarmForIncidence( 0, true ); | 1987 | mCalendar->checkAlarmForIncidence( 0, true ); |
1988 | if ( mEventViewerDialog ) | 1988 | if ( mEventViewerDialog ) |
1989 | mEventViewerDialog->hide(); | 1989 | mEventViewerDialog->hide(); |
1990 | } | 1990 | } |
1991 | else | 1991 | else |
1992 | mCalendar->checkAlarmForIncidence( which , false ); | 1992 | mCalendar->checkAlarmForIncidence( which , false ); |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | // most of the changeEventDisplays() right now just call the view's | 1995 | // most of the changeEventDisplays() right now just call the view's |
1996 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1996 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1997 | void CalendarView::changeEventDisplay(Event *which, int action) | 1997 | void CalendarView::changeEventDisplay(Event *which, int action) |
1998 | { | 1998 | { |
1999 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1999 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2000 | changeIncidenceDisplay((Incidence *)which, action); | 2000 | changeIncidenceDisplay((Incidence *)which, action); |
2001 | mDateNavigator->updateView(); | 2001 | mDateNavigator->updateView(); |
2002 | //mDialogManager->updateSearchDialog(); | 2002 | //mDialogManager->updateSearchDialog(); |
2003 | 2003 | ||
2004 | if (which) { | 2004 | if (which) { |
2005 | // If there is an event view visible update the display | 2005 | // If there is an event view visible update the display |
2006 | mViewManager->currentView()->changeEventDisplay(which,action); | 2006 | mViewManager->currentView()->changeEventDisplay(which,action); |
2007 | // TODO: check, if update needed | 2007 | // TODO: check, if update needed |
2008 | // if (which->getTodoStatus()) { | 2008 | // if (which->getTodoStatus()) { |
2009 | mTodoList->updateView(); | 2009 | mTodoList->updateView(); |
2010 | // } | 2010 | // } |
2011 | } else { | 2011 | } else { |
2012 | mViewManager->currentView()->updateView(); | 2012 | mViewManager->currentView()->updateView(); |
2013 | } | 2013 | } |
2014 | } | 2014 | } |
2015 | 2015 | ||
2016 | 2016 | ||
2017 | void CalendarView::updateTodoViews() | 2017 | void CalendarView::updateTodoViews() |
2018 | { | 2018 | { |
2019 | 2019 | ||
2020 | mTodoList->updateView(); | 2020 | mTodoList->updateView(); |
2021 | mViewManager->currentView()->updateView(); | 2021 | mViewManager->currentView()->updateView(); |
2022 | 2022 | ||
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | 2025 | ||
2026 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2026 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2027 | { | 2027 | { |
2028 | mTodoList->updateView(); | 2028 | mTodoList->updateView(); |
2029 | mViewManager->updateView(start, end); | 2029 | mViewManager->updateView(start, end); |
2030 | //mDateNavigator->updateView(); | 2030 | //mDateNavigator->updateView(); |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | void CalendarView::updateView() | 2033 | void CalendarView::updateView() |
2034 | { | 2034 | { |
2035 | DateList tmpList = mNavigator->selectedDates(); | 2035 | DateList tmpList = mNavigator->selectedDates(); |
2036 | 2036 | ||
2037 | // We assume that the navigator only selects consecutive days. | 2037 | // We assume that the navigator only selects consecutive days. |
2038 | updateView( tmpList.first(), tmpList.last() ); | 2038 | updateView( tmpList.first(), tmpList.last() ); |
2039 | } | 2039 | } |
2040 | 2040 | ||
2041 | void CalendarView::updateUnmanagedViews() | 2041 | void CalendarView::updateUnmanagedViews() |
2042 | { | 2042 | { |
2043 | mDateNavigator->updateDayMatrix(); | 2043 | mDateNavigator->updateDayMatrix(); |
2044 | } | 2044 | } |
2045 | 2045 | ||
2046 | int CalendarView::msgItemDelete() | 2046 | int CalendarView::msgItemDelete() |
2047 | { | 2047 | { |
2048 | return KMessageBox::warningContinueCancel(this, | 2048 | return KMessageBox::warningContinueCancel(this, |
2049 | i18n("This item will be\npermanently deleted."), | 2049 | i18n("This item will be\npermanently deleted."), |
2050 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2050 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | 2053 | ||
2054 | void CalendarView::edit_cut() | 2054 | void CalendarView::edit_cut() |
2055 | { | 2055 | { |
2056 | Event *anEvent=0; | 2056 | Event *anEvent=0; |
2057 | 2057 | ||
2058 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2058 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2059 | 2059 | ||
2060 | if (mViewManager->currentView()->isEventView()) { | 2060 | if (mViewManager->currentView()->isEventView()) { |
2061 | if ( incidence && incidence->type() == "Event" ) { | 2061 | if ( incidence && incidence->type() == "Event" ) { |
2062 | anEvent = static_cast<Event *>(incidence); | 2062 | anEvent = static_cast<Event *>(incidence); |
2063 | } | 2063 | } |
2064 | } | 2064 | } |
2065 | 2065 | ||
2066 | if (!anEvent) { | 2066 | if (!anEvent) { |
2067 | KNotifyClient::beep(); | 2067 | KNotifyClient::beep(); |
2068 | return; | 2068 | return; |
2069 | } | 2069 | } |
2070 | DndFactory factory( mCalendar ); | 2070 | DndFactory factory( mCalendar ); |
2071 | factory.cutEvent(anEvent); | 2071 | factory.cutEvent(anEvent); |
2072 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2072 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2073 | } | 2073 | } |
2074 | 2074 | ||
2075 | void CalendarView::edit_copy() | 2075 | void CalendarView::edit_copy() |
2076 | { | 2076 | { |
2077 | Event *anEvent=0; | 2077 | Event *anEvent=0; |
2078 | 2078 | ||
2079 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2079 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2080 | 2080 | ||
2081 | if (mViewManager->currentView()->isEventView()) { | 2081 | if (mViewManager->currentView()->isEventView()) { |
2082 | if ( incidence && incidence->type() == "Event" ) { | 2082 | if ( incidence && incidence->type() == "Event" ) { |
2083 | anEvent = static_cast<Event *>(incidence); | 2083 | anEvent = static_cast<Event *>(incidence); |
2084 | } | 2084 | } |
2085 | } | 2085 | } |
2086 | 2086 | ||
2087 | if (!anEvent) { | 2087 | if (!anEvent) { |
2088 | KNotifyClient::beep(); | 2088 | KNotifyClient::beep(); |
2089 | return; | 2089 | return; |
2090 | } | 2090 | } |
2091 | DndFactory factory( mCalendar ); | 2091 | DndFactory factory( mCalendar ); |
2092 | factory.copyEvent(anEvent); | 2092 | factory.copyEvent(anEvent); |
2093 | } | 2093 | } |
2094 | 2094 | ||
2095 | void CalendarView::edit_paste() | 2095 | void CalendarView::edit_paste() |
2096 | { | 2096 | { |
2097 | QDate date = mNavigator->selectedDates().first(); | 2097 | QDate date = mNavigator->selectedDates().first(); |
2098 | 2098 | ||
2099 | DndFactory factory( mCalendar ); | 2099 | DndFactory factory( mCalendar ); |
2100 | Event *pastedEvent = factory.pasteEvent( date ); | 2100 | Event *pastedEvent = factory.pasteEvent( date ); |
2101 | 2101 | ||
2102 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2102 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2103 | } | 2103 | } |
2104 | 2104 | ||
2105 | void CalendarView::edit_options() | 2105 | void CalendarView::edit_options() |
2106 | { | 2106 | { |
2107 | mDialogManager->showOptionsDialog(); | 2107 | mDialogManager->showOptionsDialog(); |
2108 | //writeSettings(); | 2108 | //writeSettings(); |
2109 | } | 2109 | } |
2110 | void CalendarView::edit_sync_options() | 2110 | void CalendarView::edit_sync_options() |
2111 | { | 2111 | { |
2112 | //mDialogManager->showSyncOptions(); | 2112 | //mDialogManager->showSyncOptions(); |
2113 | //KOPrefs::instance()->mSyncAlgoPrefs | 2113 | //KOPrefs::instance()->mSyncAlgoPrefs |
2114 | QDialog dia( this, "dia", true ); | 2114 | QDialog dia( this, "dia", true ); |
2115 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2115 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
2116 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2116 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
2117 | QVBoxLayout lay ( &dia ); | 2117 | QVBoxLayout lay ( &dia ); |
2118 | lay.setSpacing( 2 ); | 2118 | lay.setSpacing( 2 ); |
2119 | lay.setMargin( 3 ); | 2119 | lay.setMargin( 3 ); |
2120 | lay.addWidget(&gr); | 2120 | lay.addWidget(&gr); |
2121 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2121 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
2122 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2122 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
2123 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2123 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
2124 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2124 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
2125 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2125 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
2126 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2126 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
2127 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2127 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
2128 | QPushButton pb ( "OK", &dia); | 2128 | QPushButton pb ( "OK", &dia); |
2129 | lay.addWidget( &pb ); | 2129 | lay.addWidget( &pb ); |
2130 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2130 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2131 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2131 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
2132 | case 0: | 2132 | case 0: |
2133 | loc.setChecked( true); | 2133 | loc.setChecked( true); |
2134 | break; | 2134 | break; |
2135 | case 1: | 2135 | case 1: |
2136 | rem.setChecked( true ); | 2136 | rem.setChecked( true ); |
2137 | break; | 2137 | break; |
2138 | case 2: | 2138 | case 2: |
2139 | newest.setChecked( true); | 2139 | newest.setChecked( true); |
2140 | break; | 2140 | break; |
2141 | case 3: | 2141 | case 3: |
2142 | ask.setChecked( true); | 2142 | ask.setChecked( true); |
2143 | break; | 2143 | break; |
2144 | case 4: | 2144 | case 4: |
2145 | f_loc.setChecked( true); | 2145 | f_loc.setChecked( true); |
2146 | break; | 2146 | break; |
2147 | case 5: | 2147 | case 5: |
2148 | f_rem.setChecked( true); | 2148 | f_rem.setChecked( true); |
2149 | break; | 2149 | break; |
2150 | case 6: | 2150 | case 6: |
2151 | // both.setChecked( true); | 2151 | // both.setChecked( true); |
2152 | break; | 2152 | break; |
2153 | default: | 2153 | default: |
2154 | break; | 2154 | break; |
2155 | } | 2155 | } |
2156 | if ( dia.exec() ) { | 2156 | if ( dia.exec() ) { |
2157 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2157 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | } | 2160 | } |
2161 | 2161 | ||
2162 | void CalendarView::slotSelectPickerDate( QDate d) | 2162 | void CalendarView::slotSelectPickerDate( QDate d) |
2163 | { | 2163 | { |
2164 | mDateFrame->hide(); | 2164 | mDateFrame->hide(); |
2165 | if ( mDatePickerMode == 1 ) { | 2165 | if ( mDatePickerMode == 1 ) { |
2166 | mNavigator->slotDaySelect( d ); | 2166 | mNavigator->slotDaySelect( d ); |
2167 | } else if ( mDatePickerMode == 2 ) { | 2167 | } else if ( mDatePickerMode == 2 ) { |
2168 | if ( mMoveIncidence->type() == "Todo" ) { | 2168 | if ( mMoveIncidence->type() == "Todo" ) { |
2169 | Todo * to = (Todo *) mMoveIncidence; | 2169 | Todo * to = (Todo *) mMoveIncidence; |
2170 | QTime tim; | 2170 | QTime tim; |
2171 | if ( to->hasDueDate() ) | 2171 | if ( to->hasDueDate() ) |
2172 | tim = to->dtDue().time(); | 2172 | tim = to->dtDue().time(); |
2173 | else { | 2173 | else { |
2174 | tim = QTime ( 0,0,0 ); | 2174 | tim = QTime ( 0,0,0 ); |
2175 | to->setFloats( true ); | 2175 | to->setFloats( true ); |
2176 | to->setHasDueDate( true ); | 2176 | to->setHasDueDate( true ); |
2177 | } | 2177 | } |
2178 | QDateTime dt ( d,tim ); | 2178 | QDateTime dt ( d,tim ); |
2179 | to->setDtDue( dt ); | 2179 | to->setDtDue( dt ); |
2180 | todoChanged( to ); | 2180 | todoChanged( to ); |
2181 | } else { | 2181 | } else { |
2182 | QTime tim = mMoveIncidence->dtStart().time(); | 2182 | QTime tim = mMoveIncidence->dtStart().time(); |
2183 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2183 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2184 | QDateTime dt ( d,tim ); | 2184 | QDateTime dt ( d,tim ); |
2185 | mMoveIncidence->setDtStart( dt ); | 2185 | mMoveIncidence->setDtStart( dt ); |
2186 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2186 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2187 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2187 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2188 | } | 2188 | } |
2189 | 2189 | ||
2190 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2190 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2191 | } | 2191 | } |
2192 | } | 2192 | } |
2193 | 2193 | ||
2194 | void CalendarView::removeCategories() | 2194 | void CalendarView::removeCategories() |
2195 | { | 2195 | { |
2196 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2196 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2197 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2197 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2198 | QStringList catIncList; | 2198 | QStringList catIncList; |
2199 | QStringList newCatList; | 2199 | QStringList newCatList; |
2200 | Incidence* inc = incList.first(); | 2200 | Incidence* inc = incList.first(); |
2201 | int i; | 2201 | int i; |
2202 | int count = 0; | 2202 | int count = 0; |
2203 | while ( inc ) { | 2203 | while ( inc ) { |
2204 | newCatList.clear(); | 2204 | newCatList.clear(); |
2205 | catIncList = inc->categories() ; | 2205 | catIncList = inc->categories() ; |
2206 | for( i = 0; i< catIncList.count(); ++i ) { | 2206 | for( i = 0; i< catIncList.count(); ++i ) { |
2207 | if ( catList.contains (catIncList[i])) | 2207 | if ( catList.contains (catIncList[i])) |
2208 | newCatList.append( catIncList[i] ); | 2208 | newCatList.append( catIncList[i] ); |
2209 | } | 2209 | } |
2210 | newCatList.sort(); | 2210 | newCatList.sort(); |
2211 | inc->setCategories( newCatList.join(",") ); | 2211 | inc->setCategories( newCatList.join(",") ); |
2212 | inc = incList.next(); | 2212 | inc = incList.next(); |
2213 | } | 2213 | } |
2214 | } | 2214 | } |
2215 | 2215 | ||
2216 | int CalendarView::addCategories() | 2216 | int CalendarView::addCategories() |
2217 | { | 2217 | { |
2218 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2218 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2219 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2219 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2220 | QStringList catIncList; | 2220 | QStringList catIncList; |
2221 | Incidence* inc = incList.first(); | 2221 | Incidence* inc = incList.first(); |
2222 | int i; | 2222 | int i; |
2223 | int count = 0; | 2223 | int count = 0; |
2224 | while ( inc ) { | 2224 | while ( inc ) { |
2225 | catIncList = inc->categories() ; | 2225 | catIncList = inc->categories() ; |
2226 | for( i = 0; i< catIncList.count(); ++i ) { | 2226 | for( i = 0; i< catIncList.count(); ++i ) { |
2227 | if ( !catList.contains (catIncList[i])) { | 2227 | if ( !catList.contains (catIncList[i])) { |
2228 | catList.append( catIncList[i] ); | 2228 | catList.append( catIncList[i] ); |
2229 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2229 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2230 | ++count; | 2230 | ++count; |
2231 | } | 2231 | } |
2232 | } | 2232 | } |
2233 | inc = incList.next(); | 2233 | inc = incList.next(); |
2234 | } | 2234 | } |
2235 | catList.sort(); | 2235 | catList.sort(); |
2236 | KOPrefs::instance()->mCustomCategories = catList; | 2236 | KOPrefs::instance()->mCustomCategories = catList; |
2237 | return count; | 2237 | return count; |
2238 | } | 2238 | } |
2239 | 2239 | ||
2240 | void CalendarView::manageCategories() | 2240 | void CalendarView::manageCategories() |
2241 | { | 2241 | { |
2242 | KOCatPrefs* cp = new KOCatPrefs(); | 2242 | KOCatPrefs* cp = new KOCatPrefs(); |
2243 | cp->show(); | 2243 | cp->show(); |
2244 | int w =cp->sizeHint().width() ; | 2244 | int w =cp->sizeHint().width() ; |
2245 | int h = cp->sizeHint().height() ; | 2245 | int h = cp->sizeHint().height() ; |
2246 | int dw = QApplication::desktop()->width(); | 2246 | int dw = QApplication::desktop()->width(); |
2247 | int dh = QApplication::desktop()->height(); | 2247 | int dh = QApplication::desktop()->height(); |
2248 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2248 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2249 | if ( !cp->exec() ) { | 2249 | if ( !cp->exec() ) { |
2250 | delete cp; | 2250 | delete cp; |
2251 | return; | 2251 | return; |
2252 | } | 2252 | } |
2253 | int count = 0; | 2253 | int count = 0; |
2254 | if ( cp->addCat() ) { | 2254 | if ( cp->addCat() ) { |
2255 | count = addCategories(); | 2255 | count = addCategories(); |
2256 | if ( count ) { | 2256 | if ( count ) { |
2257 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2257 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2258 | writeSettings(); | 2258 | writeSettings(); |
2259 | } | 2259 | } |
2260 | } else { | 2260 | } else { |
2261 | removeCategories(); | 2261 | removeCategories(); |
2262 | updateView(); | 2262 | updateView(); |
2263 | } | 2263 | } |
2264 | delete cp; | 2264 | delete cp; |
2265 | } | 2265 | } |
2266 | 2266 | ||
2267 | void CalendarView::beamIncidence(Incidence * Inc) | 2267 | void CalendarView::beamIncidence(Incidence * Inc) |
2268 | { | 2268 | { |
2269 | QPtrList<Incidence> delSel ; | 2269 | QPtrList<Incidence> delSel ; |
2270 | delSel.append(Inc); | 2270 | delSel.append(Inc); |
2271 | beamIncidenceList( delSel ); | 2271 | beamIncidenceList( delSel ); |
2272 | } | 2272 | } |
2273 | void CalendarView::beamCalendar() | 2273 | void CalendarView::beamCalendar() |
2274 | { | 2274 | { |
2275 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2275 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2276 | //qDebug("beamCalendar() "); | 2276 | //qDebug("beamCalendar() "); |
2277 | beamIncidenceList( delSel ); | 2277 | beamIncidenceList( delSel ); |
2278 | } | 2278 | } |
2279 | void CalendarView::beamFilteredCalendar() | 2279 | void CalendarView::beamFilteredCalendar() |
2280 | { | 2280 | { |
2281 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2281 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2282 | //qDebug("beamFilteredCalendar() "); | 2282 | //qDebug("beamFilteredCalendar() "); |
2283 | beamIncidenceList( delSel ); | 2283 | beamIncidenceList( delSel ); |
2284 | } | 2284 | } |
2285 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2285 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2286 | { | 2286 | { |
2287 | if ( beamDialog->exec () == QDialog::Rejected ) | 2287 | if ( beamDialog->exec () == QDialog::Rejected ) |
2288 | return; | 2288 | return; |
2289 | 2289 | ||
2290 | QString fn = "/tmp/kopibeamfile"; | 2290 | QString fn = "/tmp/kopibeamfile"; |
2291 | QString mes; | 2291 | QString mes; |
2292 | bool createbup = true; | 2292 | bool createbup = true; |
2293 | if ( createbup ) { | 2293 | if ( createbup ) { |
2294 | QString description = "\n"; | 2294 | QString description = "\n"; |
2295 | CalendarLocal* cal = new CalendarLocal(); | 2295 | CalendarLocal* cal = new CalendarLocal(); |
2296 | if ( beamDialog->beamLocal() ) | 2296 | if ( beamDialog->beamLocal() ) |
2297 | cal->setLocalTime(); | 2297 | cal->setLocalTime(); |
2298 | else | 2298 | else |
2299 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2299 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2300 | Incidence *incidence = delSel.first(); | 2300 | Incidence *incidence = delSel.first(); |
2301 | bool addText = false; | 2301 | bool addText = false; |
2302 | if ( delSel.count() < 10 ) | 2302 | if ( delSel.count() < 10 ) |
2303 | addText = true; | 2303 | addText = true; |
2304 | else { | 2304 | else { |
2305 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2305 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2306 | } | 2306 | } |
2307 | while ( incidence ) { | 2307 | while ( incidence ) { |
2308 | Incidence *in = incidence->clone(); | 2308 | Incidence *in = incidence->clone(); |
2309 | if ( addText ) | 2309 | if ( addText ) |
2310 | description += in->summary() + "\n"; | 2310 | description += in->summary() + "\n"; |
2311 | cal->addIncidence( in ); | 2311 | cal->addIncidence( in ); |
2312 | incidence = delSel.next(); | 2312 | incidence = delSel.next(); |
2313 | } | 2313 | } |
2314 | if ( beamDialog->beamVcal() ) { | 2314 | if ( beamDialog->beamVcal() ) { |
2315 | fn += ".vcs"; | 2315 | fn += ".vcs"; |
2316 | FileStorage storage( cal, fn, new VCalFormat ); | 2316 | FileStorage storage( cal, fn, new VCalFormat ); |
2317 | storage.save(); | 2317 | storage.save(); |
2318 | } else { | 2318 | } else { |
2319 | fn += ".ics"; | 2319 | fn += ".ics"; |
2320 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2320 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2321 | storage.save(); | 2321 | storage.save(); |
2322 | } | 2322 | } |
2323 | delete cal; | 2323 | delete cal; |
2324 | mes = i18n("KO/Pi: Ready for beaming"); | 2324 | mes = i18n("KO/Pi: Ready for beaming"); |
2325 | setCaption(mes); | 2325 | setCaption(mes); |
2326 | 2326 | ||
2327 | #ifndef DESKTOP_VERSION | 2327 | #ifndef DESKTOP_VERSION |
2328 | Ir *ir = new Ir( this ); | 2328 | Ir *ir = new Ir( this ); |
2329 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2329 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2330 | ir->send( fn, description, "text/x-vCalendar" ); | 2330 | ir->send( fn, description, "text/x-vCalendar" ); |
2331 | #endif | 2331 | #endif |
2332 | } | 2332 | } |
2333 | } | 2333 | } |
2334 | void CalendarView::beamDone( Ir *ir ) | 2334 | void CalendarView::beamDone( Ir *ir ) |
2335 | { | 2335 | { |
2336 | #ifndef DESKTOP_VERSION | 2336 | #ifndef DESKTOP_VERSION |
2337 | delete ir; | 2337 | delete ir; |
2338 | #endif | 2338 | #endif |
2339 | } | 2339 | } |
2340 | 2340 | ||
2341 | void CalendarView::moveIncidence(Incidence * inc ) | 2341 | void CalendarView::moveIncidence(Incidence * inc ) |
2342 | { | 2342 | { |
2343 | if ( !inc ) return; | 2343 | if ( !inc ) return; |
2344 | // qDebug("showDatePickerForIncidence( ) "); | 2344 | // qDebug("showDatePickerForIncidence( ) "); |
2345 | if ( mDateFrame->isVisible() ) | 2345 | if ( mDateFrame->isVisible() ) |
2346 | mDateFrame->hide(); | 2346 | mDateFrame->hide(); |
2347 | else { | 2347 | else { |
2348 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2348 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2349 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2349 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2350 | int dw = QApplication::desktop()->width(); | 2350 | int dw = QApplication::desktop()->width(); |
2351 | int dh = QApplication::desktop()->height(); | 2351 | int dh = QApplication::desktop()->height(); |
2352 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2352 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2353 | mDateFrame->show(); | 2353 | mDateFrame->show(); |
2354 | } | 2354 | } |
2355 | mDatePickerMode = 2; | 2355 | mDatePickerMode = 2; |
2356 | mMoveIncidence = inc ; | 2356 | mMoveIncidence = inc ; |
2357 | QDate da; | 2357 | QDate da; |
2358 | if ( mMoveIncidence->type() == "Todo" ) { | 2358 | if ( mMoveIncidence->type() == "Todo" ) { |
2359 | Todo * to = (Todo *) mMoveIncidence; | 2359 | Todo * to = (Todo *) mMoveIncidence; |
2360 | if ( to->hasDueDate() ) | 2360 | if ( to->hasDueDate() ) |
2361 | da = to->dtDue().date(); | 2361 | da = to->dtDue().date(); |
2362 | else | 2362 | else |
2363 | da = QDate::currentDate(); | 2363 | da = QDate::currentDate(); |
2364 | } else { | 2364 | } else { |
2365 | da = mMoveIncidence->dtStart().date(); | 2365 | da = mMoveIncidence->dtStart().date(); |
2366 | } | 2366 | } |
2367 | mDatePicker->setDate( da ); | 2367 | mDatePicker->setDate( da ); |
2368 | } | 2368 | } |
2369 | void CalendarView::showDatePicker( ) | 2369 | void CalendarView::showDatePicker( ) |
2370 | { | 2370 | { |
2371 | //qDebug("CalendarView::showDatePicker( ) "); | 2371 | //qDebug("CalendarView::showDatePicker( ) "); |
2372 | if ( mDateFrame->isVisible() ) | 2372 | if ( mDateFrame->isVisible() ) |
2373 | mDateFrame->hide(); | 2373 | mDateFrame->hide(); |
2374 | else { | 2374 | else { |
2375 | int w =mDatePicker->sizeHint().width() ; | 2375 | int w =mDatePicker->sizeHint().width() ; |
2376 | int h = mDatePicker->sizeHint().height() ; | 2376 | int h = mDatePicker->sizeHint().height() ; |
2377 | int dw = QApplication::desktop()->width(); | 2377 | int dw = QApplication::desktop()->width(); |
2378 | int dh = QApplication::desktop()->height(); | 2378 | int dh = QApplication::desktop()->height(); |
2379 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2379 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2380 | mDateFrame->show(); | 2380 | mDateFrame->show(); |
2381 | } | 2381 | } |
2382 | mDatePickerMode = 1; | 2382 | mDatePickerMode = 1; |
2383 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2383 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2384 | } | 2384 | } |
2385 | 2385 | ||
2386 | void CalendarView::showEventEditor() | 2386 | void CalendarView::showEventEditor() |
2387 | { | 2387 | { |
2388 | #ifdef DESKTOP_VERSION | 2388 | #ifdef DESKTOP_VERSION |
2389 | mEventEditor->show(); | 2389 | mEventEditor->show(); |
2390 | #else | 2390 | #else |
2391 | mEventEditor->showMaximized(); | 2391 | mEventEditor->showMaximized(); |
2392 | #endif | 2392 | #endif |
2393 | } | 2393 | } |
2394 | void CalendarView::showTodoEditor() | 2394 | void CalendarView::showTodoEditor() |
2395 | { | 2395 | { |
2396 | #ifdef DESKTOP_VERSION | 2396 | #ifdef DESKTOP_VERSION |
2397 | mTodoEditor->show(); | 2397 | mTodoEditor->show(); |
2398 | #else | 2398 | #else |
2399 | mTodoEditor->showMaximized(); | 2399 | mTodoEditor->showMaximized(); |
2400 | #endif | 2400 | #endif |
2401 | } | 2401 | } |
2402 | |||
2403 | void CalendarView::cloneIncidence() | ||
2404 | { | ||
2405 | Incidence *incidence = currentSelection(); | ||
2406 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | ||
2407 | if ( incidence ) { | ||
2408 | cloneIncidence(incidence); | ||
2409 | } | ||
2410 | } | ||
2411 | void CalendarView::moveIncidence() | ||
2412 | { | ||
2413 | Incidence *incidence = currentSelection(); | ||
2414 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | ||
2415 | if ( incidence ) { | ||
2416 | moveIncidence(incidence); | ||
2417 | } | ||
2418 | } | ||
2419 | void CalendarView::beamIncidence() | ||
2420 | { | ||
2421 | Incidence *incidence = currentSelection(); | ||
2422 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | ||
2423 | if ( incidence ) { | ||
2424 | beamIncidence(incidence); | ||
2425 | } | ||
2426 | } | ||
2427 | void CalendarView::toggleCancelIncidence() | ||
2428 | { | ||
2429 | Incidence *incidence = currentSelection(); | ||
2430 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | ||
2431 | if ( incidence ) { | ||
2432 | cancelIncidence(incidence); | ||
2433 | } | ||
2434 | } | ||
2435 | |||
2436 | |||
2402 | void CalendarView::cancelIncidence(Incidence * inc ) | 2437 | void CalendarView::cancelIncidence(Incidence * inc ) |
2403 | { | 2438 | { |
2404 | inc->setCancelled( ! inc->cancelled() ); | 2439 | inc->setCancelled( ! inc->cancelled() ); |
2405 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2440 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2406 | updateView(); | 2441 | updateView(); |
2407 | } | 2442 | } |
2408 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2443 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2409 | { | 2444 | { |
2410 | Incidence * newInc = orgInc->clone(); | 2445 | Incidence * newInc = orgInc->clone(); |
2411 | newInc->recreate(); | 2446 | newInc->recreate(); |
2412 | 2447 | ||
2413 | if ( newInc->type() == "Todo" ) { | 2448 | if ( newInc->type() == "Todo" ) { |
2414 | Todo* t = (Todo*) newInc; | 2449 | Todo* t = (Todo*) newInc; |
2415 | mTodoEditor->editTodo( t ); | 2450 | mTodoEditor->editTodo( t ); |
2416 | showTodoEditor(); | 2451 | showTodoEditor(); |
2417 | if ( mTodoEditor->exec() ) { | 2452 | if ( mTodoEditor->exec() ) { |
2418 | mCalendar->addTodo( t ); | 2453 | mCalendar->addTodo( t ); |
2419 | updateView(); | 2454 | updateView(); |
2420 | } else { | 2455 | } else { |
2421 | delete t; | 2456 | delete t; |
2422 | } | 2457 | } |
2423 | } | 2458 | } |
2424 | else { | 2459 | else { |
2425 | Event* e = (Event*) newInc; | 2460 | Event* e = (Event*) newInc; |
2426 | mEventEditor->editEvent( e ); | 2461 | mEventEditor->editEvent( e ); |
2427 | showEventEditor(); | 2462 | showEventEditor(); |
2428 | if ( mEventEditor->exec() ) { | 2463 | if ( mEventEditor->exec() ) { |
2429 | mCalendar->addEvent( e ); | 2464 | mCalendar->addEvent( e ); |
2430 | updateView(); | 2465 | updateView(); |
2431 | } else { | 2466 | } else { |
2432 | delete e; | 2467 | delete e; |
2433 | } | 2468 | } |
2434 | } | 2469 | } |
2435 | } | 2470 | } |
2436 | 2471 | ||
2437 | void CalendarView::newEvent() | 2472 | void CalendarView::newEvent() |
2438 | { | 2473 | { |
2439 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2474 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2440 | KOAgendaView *aView = mViewManager->agendaView(); | 2475 | KOAgendaView *aView = mViewManager->agendaView(); |
2441 | if (aView) { | 2476 | if (aView) { |
2442 | if (aView->selectionStart().isValid()) { | 2477 | if (aView->selectionStart().isValid()) { |
2443 | if (aView->selectedIsAllDay()) { | 2478 | if (aView->selectedIsAllDay()) { |
2444 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2479 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2445 | } else { | 2480 | } else { |
2446 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2481 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2447 | } | 2482 | } |
2448 | return; | 2483 | return; |
2449 | } | 2484 | } |
2450 | } | 2485 | } |
2451 | 2486 | ||
2452 | QDate date = mNavigator->selectedDates().first(); | 2487 | QDate date = mNavigator->selectedDates().first(); |
2453 | QDateTime current = QDateTime::currentDateTime(); | 2488 | QDateTime current = QDateTime::currentDateTime(); |
2454 | if ( date <= current.date() ) { | 2489 | if ( date <= current.date() ) { |
2455 | int hour = current.time().hour() +1; | 2490 | int hour = current.time().hour() +1; |
2456 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2491 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2457 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2492 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2458 | } else | 2493 | } else |
2459 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2494 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2460 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2495 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2461 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2496 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2462 | } | 2497 | } |
2463 | 2498 | ||
2464 | void CalendarView::newEvent(QDateTime fh) | 2499 | void CalendarView::newEvent(QDateTime fh) |
2465 | { | 2500 | { |
2466 | newEvent(fh, | 2501 | newEvent(fh, |
2467 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2502 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2468 | } | 2503 | } |
2469 | 2504 | ||
2470 | void CalendarView::newEvent(QDate dt) | 2505 | void CalendarView::newEvent(QDate dt) |
2471 | { | 2506 | { |
2472 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2507 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2473 | QDateTime(dt, QTime(0,0,0)), true); | 2508 | QDateTime(dt, QTime(0,0,0)), true); |
2474 | } | 2509 | } |
2475 | 2510 | ||
2476 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2511 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2477 | { | 2512 | { |
2478 | 2513 | ||
2479 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2514 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2480 | if ( mFilterView->filtersEnabled() ) { | 2515 | if ( mFilterView->filtersEnabled() ) { |
2481 | CalFilter *filter = mFilterView->selectedFilter(); | 2516 | CalFilter *filter = mFilterView->selectedFilter(); |
2482 | if (filter && filter->showCategories()) { | 2517 | if (filter && filter->showCategories()) { |
2483 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2518 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2484 | } | 2519 | } |
2485 | if ( filter ) | 2520 | if ( filter ) |
2486 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2521 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2487 | } | 2522 | } |
2488 | showEventEditor(); | 2523 | showEventEditor(); |
2489 | } | 2524 | } |
2490 | void CalendarView::todoAdded(Todo * t) | 2525 | void CalendarView::todoAdded(Todo * t) |
2491 | { | 2526 | { |
2492 | 2527 | ||
2493 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2528 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2494 | updateTodoViews(); | 2529 | updateTodoViews(); |
2495 | } | 2530 | } |
2496 | void CalendarView::todoChanged(Todo * t) | 2531 | void CalendarView::todoChanged(Todo * t) |
2497 | { | 2532 | { |
2498 | emit todoModified( t, 4 ); | 2533 | emit todoModified( t, 4 ); |
2499 | // updateTodoViews(); | 2534 | // updateTodoViews(); |
2500 | } | 2535 | } |
2501 | void CalendarView::todoToBeDeleted(Todo *) | 2536 | void CalendarView::todoToBeDeleted(Todo *) |
2502 | { | 2537 | { |
2503 | //qDebug("todoToBeDeleted(Todo *) "); | 2538 | //qDebug("todoToBeDeleted(Todo *) "); |
2504 | updateTodoViews(); | 2539 | updateTodoViews(); |
2505 | } | 2540 | } |
2506 | void CalendarView::todoDeleted() | 2541 | void CalendarView::todoDeleted() |
2507 | { | 2542 | { |
2508 | //qDebug(" todoDeleted()"); | 2543 | //qDebug(" todoDeleted()"); |
2509 | updateTodoViews(); | 2544 | updateTodoViews(); |
2510 | } | 2545 | } |
2511 | 2546 | ||
2512 | 2547 | ||
2513 | 2548 | ||
2514 | void CalendarView::newTodo() | 2549 | void CalendarView::newTodo() |
2515 | { | 2550 | { |
2516 | 2551 | ||
2517 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2552 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2518 | if ( mFilterView->filtersEnabled() ) { | 2553 | if ( mFilterView->filtersEnabled() ) { |
2519 | CalFilter *filter = mFilterView->selectedFilter(); | 2554 | CalFilter *filter = mFilterView->selectedFilter(); |
2520 | if (filter && filter->showCategories()) { | 2555 | if (filter && filter->showCategories()) { |
2521 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2556 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2522 | } | 2557 | } |
2523 | if ( filter ) | 2558 | if ( filter ) |
2524 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2559 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2525 | } | 2560 | } |
2526 | showTodoEditor(); | 2561 | showTodoEditor(); |
2527 | } | 2562 | } |
2528 | 2563 | ||
2529 | void CalendarView::newSubTodo() | 2564 | void CalendarView::newSubTodo() |
2530 | { | 2565 | { |
2531 | Todo *todo = selectedTodo(); | 2566 | Todo *todo = selectedTodo(); |
2532 | if ( todo ) newSubTodo( todo ); | 2567 | if ( todo ) newSubTodo( todo ); |
2533 | } | 2568 | } |
2534 | 2569 | ||
2535 | void CalendarView::newSubTodo(Todo *parentEvent) | 2570 | void CalendarView::newSubTodo(Todo *parentEvent) |
2536 | { | 2571 | { |
2537 | 2572 | ||
2538 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2573 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2539 | showTodoEditor(); | 2574 | showTodoEditor(); |
2540 | } | 2575 | } |
2541 | 2576 | ||
2542 | void CalendarView::newFloatingEvent() | 2577 | void CalendarView::newFloatingEvent() |
2543 | { | 2578 | { |
2544 | DateList tmpList = mNavigator->selectedDates(); | 2579 | DateList tmpList = mNavigator->selectedDates(); |
2545 | QDate date = tmpList.first(); | 2580 | QDate date = tmpList.first(); |
2546 | 2581 | ||
2547 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2582 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2548 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2583 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2549 | } | 2584 | } |
2550 | 2585 | ||
2551 | 2586 | ||
2552 | void CalendarView::editEvent( Event *event ) | 2587 | void CalendarView::editEvent( Event *event ) |
2553 | { | 2588 | { |
2554 | 2589 | ||
2555 | if ( !event ) return; | 2590 | if ( !event ) return; |
2556 | if ( event->isReadOnly() ) { | 2591 | if ( event->isReadOnly() ) { |
2557 | showEvent( event ); | 2592 | showEvent( event ); |
2558 | return; | 2593 | return; |
2559 | } | 2594 | } |
2560 | mEventEditor->editEvent( event , mFlagEditDescription); | 2595 | mEventEditor->editEvent( event , mFlagEditDescription); |
2561 | showEventEditor(); | 2596 | showEventEditor(); |
2562 | } | 2597 | } |
2563 | void CalendarView::editJournal( Journal *jour ) | 2598 | void CalendarView::editJournal( Journal *jour ) |
2564 | { | 2599 | { |
2565 | if ( !jour ) return; | 2600 | if ( !jour ) return; |
2566 | mDialogManager->hideSearchDialog(); | 2601 | mDialogManager->hideSearchDialog(); |
2567 | mViewManager->showJournalView(); | 2602 | mViewManager->showJournalView(); |
2568 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2603 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2569 | } | 2604 | } |
2570 | void CalendarView::editTodo( Todo *todo ) | 2605 | void CalendarView::editTodo( Todo *todo ) |
2571 | { | 2606 | { |
2572 | if ( !todo ) return; | 2607 | if ( !todo ) return; |
2573 | 2608 | ||
2574 | if ( todo->isReadOnly() ) { | 2609 | if ( todo->isReadOnly() ) { |
2575 | showTodo( todo ); | 2610 | showTodo( todo ); |
2576 | return; | 2611 | return; |
2577 | } | 2612 | } |
2578 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2613 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2579 | showTodoEditor(); | 2614 | showTodoEditor(); |
2580 | 2615 | ||
2581 | } | 2616 | } |
2582 | 2617 | ||
2583 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2618 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2584 | { | 2619 | { |
2585 | if ( !mEventViewerDialog ) { | 2620 | if ( !mEventViewerDialog ) { |
2586 | mEventViewerDialog = new KOEventViewerDialog(this); | 2621 | mEventViewerDialog = new KOEventViewerDialog(this); |
2587 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2622 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2588 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2623 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2589 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2624 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2590 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2625 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2591 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2626 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2592 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2627 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2593 | mEventViewerDialog->resize( 640, 480 ); | 2628 | mEventViewerDialog->resize( 640, 480 ); |
2594 | 2629 | ||
2595 | } | 2630 | } |
2596 | return mEventViewerDialog; | 2631 | return mEventViewerDialog; |
2597 | } | 2632 | } |
2598 | void CalendarView::showEvent(Event *event) | 2633 | void CalendarView::showEvent(Event *event) |
2599 | { | 2634 | { |
2600 | getEventViewerDialog()->setEvent(event); | 2635 | getEventViewerDialog()->setEvent(event); |
2601 | getEventViewerDialog()->showMe(); | 2636 | getEventViewerDialog()->showMe(); |
2602 | } | 2637 | } |
2603 | 2638 | ||
2604 | void CalendarView::showTodo(Todo *event) | 2639 | void CalendarView::showTodo(Todo *event) |
2605 | { | 2640 | { |
2606 | getEventViewerDialog()->setTodo(event); | 2641 | getEventViewerDialog()->setTodo(event); |
2607 | getEventViewerDialog()->showMe(); | 2642 | getEventViewerDialog()->showMe(); |
2608 | } | 2643 | } |
2609 | void CalendarView::showJournal( Journal *jour ) | 2644 | void CalendarView::showJournal( Journal *jour ) |
2610 | { | 2645 | { |
2611 | getEventViewerDialog()->setJournal(jour); | 2646 | getEventViewerDialog()->setJournal(jour); |
2612 | getEventViewerDialog()->showMe(); | 2647 | getEventViewerDialog()->showMe(); |
2613 | 2648 | ||
2614 | } | 2649 | } |
2615 | // void CalendarView::todoModified (Todo *event, int changed) | 2650 | // void CalendarView::todoModified (Todo *event, int changed) |
2616 | // { | 2651 | // { |
2617 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2652 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2618 | // // kdDebug() << "Todo modified and open" << endl; | 2653 | // // kdDebug() << "Todo modified and open" << endl; |
2619 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2654 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2620 | // // temp->modified (changed); | 2655 | // // temp->modified (changed); |
2621 | 2656 | ||
2622 | // // } | 2657 | // // } |
2623 | 2658 | ||
2624 | // mViewManager->updateView(); | 2659 | // mViewManager->updateView(); |
2625 | // } | 2660 | // } |
2626 | 2661 | ||
2627 | void CalendarView::appointment_show() | 2662 | void CalendarView::appointment_show() |
2628 | { | 2663 | { |
2629 | Event *anEvent = 0; | 2664 | Event *anEvent = 0; |
2630 | 2665 | ||
2631 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2666 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2632 | 2667 | ||
2633 | if (mViewManager->currentView()->isEventView()) { | 2668 | if (mViewManager->currentView()->isEventView()) { |
2634 | if ( incidence && incidence->type() == "Event" ) { | 2669 | if ( incidence && incidence->type() == "Event" ) { |
2635 | anEvent = static_cast<Event *>(incidence); | 2670 | anEvent = static_cast<Event *>(incidence); |
2636 | } | 2671 | } |
2637 | } | 2672 | } |
2638 | 2673 | ||
2639 | if (!anEvent) { | 2674 | if (!anEvent) { |
2640 | KNotifyClient::beep(); | 2675 | KNotifyClient::beep(); |
2641 | return; | 2676 | return; |
2642 | } | 2677 | } |
2643 | 2678 | ||
2644 | showEvent(anEvent); | 2679 | showEvent(anEvent); |
2645 | } | 2680 | } |
2646 | 2681 | ||
2647 | void CalendarView::appointment_edit() | 2682 | void CalendarView::appointment_edit() |
2648 | { | 2683 | { |
2649 | Event *anEvent = 0; | 2684 | Event *anEvent = 0; |
2650 | 2685 | ||
2651 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2686 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2652 | 2687 | ||
2653 | if (mViewManager->currentView()->isEventView()) { | 2688 | if (mViewManager->currentView()->isEventView()) { |
2654 | if ( incidence && incidence->type() == "Event" ) { | 2689 | if ( incidence && incidence->type() == "Event" ) { |
2655 | anEvent = static_cast<Event *>(incidence); | 2690 | anEvent = static_cast<Event *>(incidence); |
2656 | } | 2691 | } |
2657 | } | 2692 | } |
2658 | 2693 | ||
2659 | if (!anEvent) { | 2694 | if (!anEvent) { |
2660 | KNotifyClient::beep(); | 2695 | KNotifyClient::beep(); |
2661 | return; | 2696 | return; |
2662 | } | 2697 | } |
2663 | 2698 | ||
2664 | editEvent(anEvent); | 2699 | editEvent(anEvent); |
2665 | } | 2700 | } |
2666 | 2701 | ||
2667 | void CalendarView::appointment_delete() | 2702 | void CalendarView::appointment_delete() |
2668 | { | 2703 | { |
2669 | Event *anEvent = 0; | 2704 | Event *anEvent = 0; |
2670 | 2705 | ||
2671 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2706 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2672 | 2707 | ||
2673 | if (mViewManager->currentView()->isEventView()) { | 2708 | if (mViewManager->currentView()->isEventView()) { |
2674 | if ( incidence && incidence->type() == "Event" ) { | 2709 | if ( incidence && incidence->type() == "Event" ) { |
2675 | anEvent = static_cast<Event *>(incidence); | 2710 | anEvent = static_cast<Event *>(incidence); |
2676 | } | 2711 | } |
2677 | } | 2712 | } |
2678 | 2713 | ||
2679 | if (!anEvent) { | 2714 | if (!anEvent) { |
2680 | KNotifyClient::beep(); | 2715 | KNotifyClient::beep(); |
2681 | return; | 2716 | return; |
2682 | } | 2717 | } |
2683 | 2718 | ||
2684 | deleteEvent(anEvent); | 2719 | deleteEvent(anEvent); |
2685 | } | 2720 | } |
2686 | 2721 | ||
2687 | void CalendarView::todo_unsub(Todo *anTodo ) | 2722 | void CalendarView::todo_unsub(Todo *anTodo ) |
2688 | { | 2723 | { |
2689 | // Todo *anTodo = selectedTodo(); | 2724 | // Todo *anTodo = selectedTodo(); |
2690 | if (!anTodo) return; | 2725 | if (!anTodo) return; |
2691 | if (!anTodo->relatedTo()) return; | 2726 | if (!anTodo->relatedTo()) return; |
2692 | anTodo->relatedTo()->removeRelation(anTodo); | 2727 | anTodo->relatedTo()->removeRelation(anTodo); |
2693 | anTodo->setRelatedTo(0); | 2728 | anTodo->setRelatedTo(0); |
2694 | anTodo->updated(); | 2729 | anTodo->updated(); |
2695 | anTodo->setRelatedToUid(""); | 2730 | anTodo->setRelatedToUid(""); |
2696 | setModified(true); | 2731 | setModified(true); |
2697 | updateView(); | 2732 | updateView(); |
2698 | } | 2733 | } |
2699 | 2734 | ||
2700 | void CalendarView::deleteTodo(Todo *todo) | 2735 | void CalendarView::deleteTodo(Todo *todo) |
2701 | { | 2736 | { |
2702 | if (!todo) { | 2737 | if (!todo) { |
2703 | KNotifyClient::beep(); | 2738 | KNotifyClient::beep(); |
2704 | return; | 2739 | return; |
2705 | } | 2740 | } |
2706 | if (KOPrefs::instance()->mConfirm) { | 2741 | if (KOPrefs::instance()->mConfirm) { |
2707 | switch (msgItemDelete()) { | 2742 | switch (msgItemDelete()) { |
2708 | case KMessageBox::Continue: // OK | 2743 | case KMessageBox::Continue: // OK |
2709 | if (!todo->relations().isEmpty()) { | 2744 | if (!todo->relations().isEmpty()) { |
2710 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2745 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2711 | i18n("Delete To-Do")); | 2746 | i18n("Delete To-Do")); |
2712 | } else { | 2747 | } else { |
2713 | checkExternalId( todo ); | 2748 | checkExternalId( todo ); |
2714 | calendar()->deleteTodo(todo); | 2749 | calendar()->deleteTodo(todo); |
2715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2750 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2716 | updateView(); | 2751 | updateView(); |
2717 | } | 2752 | } |
2718 | break; | 2753 | break; |
2719 | } // switch | 2754 | } // switch |
2720 | } else { | 2755 | } else { |
2721 | if (!todo->relations().isEmpty()) { | 2756 | if (!todo->relations().isEmpty()) { |
2722 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2757 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2723 | i18n("Delete To-Do")); | 2758 | i18n("Delete To-Do")); |
2724 | } else { | 2759 | } else { |
2725 | checkExternalId( todo ); | 2760 | checkExternalId( todo ); |
2726 | mCalendar->deleteTodo(todo); | 2761 | mCalendar->deleteTodo(todo); |
2727 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2762 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2728 | updateView(); | 2763 | updateView(); |
2729 | } | 2764 | } |
2730 | } | 2765 | } |
2731 | emit updateSearchDialog(); | 2766 | emit updateSearchDialog(); |
2732 | } | 2767 | } |
2733 | void CalendarView::deleteJournal(Journal *jour) | 2768 | void CalendarView::deleteJournal(Journal *jour) |
2734 | { | 2769 | { |
2735 | if (!jour) { | 2770 | if (!jour) { |
2736 | KNotifyClient::beep(); | 2771 | KNotifyClient::beep(); |
2737 | return; | 2772 | return; |
2738 | } | 2773 | } |
2739 | if (KOPrefs::instance()->mConfirm) { | 2774 | if (KOPrefs::instance()->mConfirm) { |
2740 | switch (msgItemDelete()) { | 2775 | switch (msgItemDelete()) { |
2741 | case KMessageBox::Continue: // OK | 2776 | case KMessageBox::Continue: // OK |
2742 | calendar()->deleteJournal(jour); | 2777 | calendar()->deleteJournal(jour); |
2743 | updateView(); | 2778 | updateView(); |
2744 | break; | 2779 | break; |
2745 | } // switch | 2780 | } // switch |
2746 | } else { | 2781 | } else { |
2747 | calendar()->deleteJournal(jour);; | 2782 | calendar()->deleteJournal(jour);; |
2748 | updateView(); | 2783 | updateView(); |
2749 | } | 2784 | } |
2750 | emit updateSearchDialog(); | 2785 | emit updateSearchDialog(); |
2751 | } | 2786 | } |
2752 | 2787 | ||
2753 | void CalendarView::deleteEvent(Event *anEvent) | 2788 | void CalendarView::deleteEvent(Event *anEvent) |
2754 | { | 2789 | { |
2755 | if (!anEvent) { | 2790 | if (!anEvent) { |
2756 | KNotifyClient::beep(); | 2791 | KNotifyClient::beep(); |
2757 | return; | 2792 | return; |
2758 | } | 2793 | } |
2759 | 2794 | ||
2760 | if (anEvent->recurrence()->doesRecur()) { | 2795 | if (anEvent->recurrence()->doesRecur()) { |
2761 | QDate itemDate = mViewManager->currentSelectionDate(); | 2796 | QDate itemDate = mViewManager->currentSelectionDate(); |
2762 | int km; | 2797 | int km; |
2763 | if (!itemDate.isValid()) { | 2798 | if (!itemDate.isValid()) { |
2764 | //kdDebug() << "Date Not Valid" << endl; | 2799 | //kdDebug() << "Date Not Valid" << endl; |
2765 | if (KOPrefs::instance()->mConfirm) { | 2800 | if (KOPrefs::instance()->mConfirm) { |
2766 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2801 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2767 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2802 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2768 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2803 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2769 | if ( km == KMessageBox::Continue ) | 2804 | if ( km == KMessageBox::Continue ) |
2770 | km = KMessageBox::No; // No = all below | 2805 | km = KMessageBox::No; // No = all below |
2771 | } else | 2806 | } else |
2772 | km = KMessageBox::No; | 2807 | km = KMessageBox::No; |
2773 | } else { | 2808 | } else { |
2774 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2809 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2775 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2810 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2776 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2811 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2777 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2812 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2778 | i18n("All")); | 2813 | i18n("All")); |
2779 | } | 2814 | } |
2780 | switch(km) { | 2815 | switch(km) { |
2781 | 2816 | ||
2782 | case KMessageBox::No: // Continue // all | 2817 | case KMessageBox::No: // Continue // all |
2783 | //qDebug("KMessageBox::No "); | 2818 | //qDebug("KMessageBox::No "); |
2784 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2819 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2785 | schedule(Scheduler::Cancel,anEvent); | 2820 | schedule(Scheduler::Cancel,anEvent); |
2786 | 2821 | ||
2787 | checkExternalId( anEvent); | 2822 | checkExternalId( anEvent); |
2788 | mCalendar->deleteEvent(anEvent); | 2823 | mCalendar->deleteEvent(anEvent); |
2789 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2824 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2790 | break; | 2825 | break; |
2791 | 2826 | ||
2792 | // Disabled because it does not work | 2827 | // Disabled because it does not work |
2793 | //#if 0 | 2828 | //#if 0 |
2794 | case KMessageBox::Yes: // just this one | 2829 | case KMessageBox::Yes: // just this one |
2795 | //QDate qd = mNavigator->selectedDates().first(); | 2830 | //QDate qd = mNavigator->selectedDates().first(); |
2796 | //if (!qd.isValid()) { | 2831 | //if (!qd.isValid()) { |
2797 | // kdDebug() << "no date selected, or invalid date" << endl; | 2832 | // kdDebug() << "no date selected, or invalid date" << endl; |
2798 | // KNotifyClient::beep(); | 2833 | // KNotifyClient::beep(); |
2799 | // return; | 2834 | // return; |
2800 | //} | 2835 | //} |
2801 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2836 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2802 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2837 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2803 | anEvent->addExDate(itemDate); | 2838 | anEvent->addExDate(itemDate); |
2804 | int duration = anEvent->recurrence()->duration(); | 2839 | int duration = anEvent->recurrence()->duration(); |
2805 | if ( duration > 0 ) { | 2840 | if ( duration > 0 ) { |
2806 | anEvent->recurrence()->setDuration( duration - 1 ); | 2841 | anEvent->recurrence()->setDuration( duration - 1 ); |
2807 | } | 2842 | } |
2808 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2843 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2809 | } | 2844 | } |
2810 | break; | 2845 | break; |
2811 | //#endif | 2846 | //#endif |
2812 | } // switch | 2847 | } // switch |
2813 | } else { | 2848 | } else { |
2814 | if (KOPrefs::instance()->mConfirm) { | 2849 | if (KOPrefs::instance()->mConfirm) { |
2815 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2850 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2816 | i18n("\nAre you sure you want\nto delete this event?"), | 2851 | i18n("\nAre you sure you want\nto delete this event?"), |
2817 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2852 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2818 | case KMessageBox::Continue: // OK | 2853 | case KMessageBox::Continue: // OK |
2819 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2854 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2820 | schedule(Scheduler::Cancel,anEvent); | 2855 | schedule(Scheduler::Cancel,anEvent); |
2821 | checkExternalId( anEvent); | 2856 | checkExternalId( anEvent); |
2822 | mCalendar->deleteEvent(anEvent); | 2857 | mCalendar->deleteEvent(anEvent); |
2823 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2858 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2824 | break; | 2859 | break; |
2825 | } // switch | 2860 | } // switch |
2826 | } else { | 2861 | } else { |
2827 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2862 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2828 | schedule(Scheduler::Cancel,anEvent); | 2863 | schedule(Scheduler::Cancel,anEvent); |
2829 | checkExternalId( anEvent); | 2864 | checkExternalId( anEvent); |
2830 | mCalendar->deleteEvent(anEvent); | 2865 | mCalendar->deleteEvent(anEvent); |
2831 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2866 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2832 | } | 2867 | } |
2833 | } // if-else | 2868 | } // if-else |
2834 | emit updateSearchDialog(); | 2869 | emit updateSearchDialog(); |
2835 | } | 2870 | } |
2836 | 2871 | ||
2837 | bool CalendarView::deleteEvent(const QString &uid) | 2872 | bool CalendarView::deleteEvent(const QString &uid) |
2838 | { | 2873 | { |
2839 | Event *ev = mCalendar->event(uid); | 2874 | Event *ev = mCalendar->event(uid); |
2840 | if (ev) { | 2875 | if (ev) { |
2841 | deleteEvent(ev); | 2876 | deleteEvent(ev); |
2842 | return true; | 2877 | return true; |
2843 | } else { | 2878 | } else { |
2844 | return false; | 2879 | return false; |
2845 | } | 2880 | } |
2846 | } | 2881 | } |
2847 | 2882 | ||
2848 | /*****************************************************************************/ | 2883 | /*****************************************************************************/ |
2849 | 2884 | ||
2850 | void CalendarView::action_mail() | 2885 | void CalendarView::action_mail() |
2851 | { | 2886 | { |
2852 | #ifndef KORG_NOMAIL | 2887 | #ifndef KORG_NOMAIL |
2853 | KOMailClient mailClient; | 2888 | KOMailClient mailClient; |
2854 | 2889 | ||
2855 | Incidence *incidence = currentSelection(); | 2890 | Incidence *incidence = currentSelection(); |
2856 | 2891 | ||
2857 | if (!incidence) { | 2892 | if (!incidence) { |
2858 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2893 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2859 | return; | 2894 | return; |
2860 | } | 2895 | } |
2861 | if(incidence->attendeeCount() == 0 ) { | 2896 | if(incidence->attendeeCount() == 0 ) { |
2862 | KMessageBox::sorry(this, | 2897 | KMessageBox::sorry(this, |
2863 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2898 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2864 | return; | 2899 | return; |
2865 | } | 2900 | } |
2866 | 2901 | ||
2867 | CalendarLocal cal_tmp; | 2902 | CalendarLocal cal_tmp; |
2868 | Event *event = 0; | 2903 | Event *event = 0; |
2869 | Event *ev = 0; | 2904 | Event *ev = 0; |
2870 | if ( incidence && incidence->type() == "Event" ) { | 2905 | if ( incidence && incidence->type() == "Event" ) { |
2871 | event = static_cast<Event *>(incidence); | 2906 | event = static_cast<Event *>(incidence); |
2872 | ev = new Event(*event); | 2907 | ev = new Event(*event); |
2873 | cal_tmp.addEvent(ev); | 2908 | cal_tmp.addEvent(ev); |
2874 | } | 2909 | } |
2875 | ICalFormat mForm(); | 2910 | ICalFormat mForm(); |
2876 | QString attachment = mForm.toString( &cal_tmp ); | 2911 | QString attachment = mForm.toString( &cal_tmp ); |
2877 | if (ev) delete(ev); | 2912 | if (ev) delete(ev); |
2878 | 2913 | ||
2879 | mailClient.mailAttendees(currentSelection(), attachment); | 2914 | mailClient.mailAttendees(currentSelection(), attachment); |
2880 | 2915 | ||
2881 | #endif | 2916 | #endif |
2882 | 2917 | ||
2883 | #if 0 | 2918 | #if 0 |
2884 | Event *anEvent = 0; | 2919 | Event *anEvent = 0; |
2885 | if (mViewManager->currentView()->isEventView()) { | 2920 | if (mViewManager->currentView()->isEventView()) { |
2886 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2921 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2887 | } | 2922 | } |
2888 | 2923 | ||
2889 | if (!anEvent) { | 2924 | if (!anEvent) { |
2890 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2925 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2891 | return; | 2926 | return; |
2892 | } | 2927 | } |
2893 | if(anEvent->attendeeCount() == 0 ) { | 2928 | if(anEvent->attendeeCount() == 0 ) { |
2894 | KMessageBox::sorry(this, | 2929 | KMessageBox::sorry(this, |
2895 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2930 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2896 | return; | 2931 | return; |
2897 | } | 2932 | } |
2898 | 2933 | ||
2899 | mailobject.emailEvent(anEvent); | 2934 | mailobject.emailEvent(anEvent); |
2900 | #endif | 2935 | #endif |
2901 | } | 2936 | } |
2902 | 2937 | ||
2903 | 2938 | ||
2904 | void CalendarView::schedule_publish(Incidence *incidence) | 2939 | void CalendarView::schedule_publish(Incidence *incidence) |
2905 | { | 2940 | { |
2906 | Event *event = 0; | 2941 | Event *event = 0; |
2907 | Todo *todo = 0; | 2942 | Todo *todo = 0; |
2908 | 2943 | ||
2909 | if (incidence == 0) { | 2944 | if (incidence == 0) { |
2910 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2945 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2911 | if (incidence == 0) { | 2946 | if (incidence == 0) { |
2912 | incidence = mTodoList->selectedIncidences().first(); | 2947 | incidence = mTodoList->selectedIncidences().first(); |
2913 | } | 2948 | } |
2914 | } | 2949 | } |
2915 | if ( incidence && incidence->type() == "Event" ) { | 2950 | if ( incidence && incidence->type() == "Event" ) { |
2916 | event = static_cast<Event *>(incidence); | 2951 | event = static_cast<Event *>(incidence); |
2917 | } else { | 2952 | } else { |
2918 | if ( incidence && incidence->type() == "Todo" ) { | 2953 | if ( incidence && incidence->type() == "Todo" ) { |
2919 | todo = static_cast<Todo *>(incidence); | 2954 | todo = static_cast<Todo *>(incidence); |
2920 | } | 2955 | } |
2921 | } | 2956 | } |
2922 | 2957 | ||
2923 | if (!event && !todo) { | 2958 | if (!event && !todo) { |
2924 | KMessageBox::sorry(this,i18n("No event selected.")); | 2959 | KMessageBox::sorry(this,i18n("No event selected.")); |
2925 | return; | 2960 | return; |
2926 | } | 2961 | } |
2927 | 2962 | ||
2928 | PublishDialog *publishdlg = new PublishDialog(); | 2963 | PublishDialog *publishdlg = new PublishDialog(); |
2929 | if (incidence->attendeeCount()>0) { | 2964 | if (incidence->attendeeCount()>0) { |
2930 | QPtrList<Attendee> attendees = incidence->attendees(); | 2965 | QPtrList<Attendee> attendees = incidence->attendees(); |
2931 | attendees.first(); | 2966 | attendees.first(); |
2932 | while ( attendees.current()!=0 ) { | 2967 | while ( attendees.current()!=0 ) { |
2933 | publishdlg->addAttendee(attendees.current()); | 2968 | publishdlg->addAttendee(attendees.current()); |
2934 | attendees.next(); | 2969 | attendees.next(); |
2935 | } | 2970 | } |
2936 | } | 2971 | } |
2937 | bool send = true; | 2972 | bool send = true; |
2938 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 2973 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
2939 | if ( publishdlg->exec() != QDialog::Accepted ) | 2974 | if ( publishdlg->exec() != QDialog::Accepted ) |
2940 | send = false; | 2975 | send = false; |
2941 | } | 2976 | } |
2942 | if ( send ) { | 2977 | if ( send ) { |
2943 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 2978 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
2944 | if ( event ) { | 2979 | if ( event ) { |
2945 | Event *ev = new Event(*event); | 2980 | Event *ev = new Event(*event); |
2946 | ev->registerObserver(0); | 2981 | ev->registerObserver(0); |
2947 | ev->clearAttendees(); | 2982 | ev->clearAttendees(); |
2948 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 2983 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
2949 | delete(ev); | 2984 | delete(ev); |
2950 | } | 2985 | } |
2951 | } else { | 2986 | } else { |
2952 | if ( todo ) { | 2987 | if ( todo ) { |
2953 | Todo *ev = new Todo(*todo); | 2988 | Todo *ev = new Todo(*todo); |
2954 | ev->registerObserver(0); | 2989 | ev->registerObserver(0); |
2955 | ev->clearAttendees(); | 2990 | ev->clearAttendees(); |
2956 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 2991 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
2957 | delete(ev); | 2992 | delete(ev); |
2958 | } | 2993 | } |
2959 | } | 2994 | } |
2960 | } | 2995 | } |
2961 | } | 2996 | } |
2962 | delete publishdlg; | 2997 | delete publishdlg; |
2963 | } | 2998 | } |
2964 | 2999 | ||
2965 | void CalendarView::schedule_request(Incidence *incidence) | 3000 | void CalendarView::schedule_request(Incidence *incidence) |
2966 | { | 3001 | { |
2967 | schedule(Scheduler::Request,incidence); | 3002 | schedule(Scheduler::Request,incidence); |
2968 | } | 3003 | } |
2969 | 3004 | ||
2970 | void CalendarView::schedule_refresh(Incidence *incidence) | 3005 | void CalendarView::schedule_refresh(Incidence *incidence) |
2971 | { | 3006 | { |
2972 | schedule(Scheduler::Refresh,incidence); | 3007 | schedule(Scheduler::Refresh,incidence); |
2973 | } | 3008 | } |
2974 | 3009 | ||
2975 | void CalendarView::schedule_cancel(Incidence *incidence) | 3010 | void CalendarView::schedule_cancel(Incidence *incidence) |
2976 | { | 3011 | { |
2977 | schedule(Scheduler::Cancel,incidence); | 3012 | schedule(Scheduler::Cancel,incidence); |
2978 | } | 3013 | } |
2979 | 3014 | ||
2980 | void CalendarView::schedule_add(Incidence *incidence) | 3015 | void CalendarView::schedule_add(Incidence *incidence) |
2981 | { | 3016 | { |
2982 | schedule(Scheduler::Add,incidence); | 3017 | schedule(Scheduler::Add,incidence); |
2983 | } | 3018 | } |
2984 | 3019 | ||
2985 | void CalendarView::schedule_reply(Incidence *incidence) | 3020 | void CalendarView::schedule_reply(Incidence *incidence) |
2986 | { | 3021 | { |
2987 | schedule(Scheduler::Reply,incidence); | 3022 | schedule(Scheduler::Reply,incidence); |
2988 | } | 3023 | } |
2989 | 3024 | ||
2990 | void CalendarView::schedule_counter(Incidence *incidence) | 3025 | void CalendarView::schedule_counter(Incidence *incidence) |
2991 | { | 3026 | { |
2992 | schedule(Scheduler::Counter,incidence); | 3027 | schedule(Scheduler::Counter,incidence); |
2993 | } | 3028 | } |
2994 | 3029 | ||
2995 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3030 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
2996 | { | 3031 | { |
2997 | schedule(Scheduler::Declinecounter,incidence); | 3032 | schedule(Scheduler::Declinecounter,incidence); |
2998 | } | 3033 | } |
2999 | 3034 | ||
3000 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3035 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3001 | { | 3036 | { |
3002 | QDateTime start = QDateTime::currentDateTime(); | 3037 | QDateTime start = QDateTime::currentDateTime(); |
3003 | QDateTime end = start.addDays(daysToPublish); | 3038 | QDateTime end = start.addDays(daysToPublish); |
3004 | 3039 | ||
3005 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3040 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3006 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3041 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3007 | 3042 | ||
3008 | 3043 | ||
3009 | PublishDialog *publishdlg = new PublishDialog(); | 3044 | PublishDialog *publishdlg = new PublishDialog(); |
3010 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3045 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3011 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3046 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3012 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3047 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3013 | delete(freebusy); | 3048 | delete(freebusy); |
3014 | } | 3049 | } |
3015 | } | 3050 | } |
3016 | delete publishdlg; | 3051 | delete publishdlg; |
3017 | } | 3052 | } |
3018 | 3053 | ||
3019 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3054 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3020 | { | 3055 | { |
3021 | Event *event = 0; | 3056 | Event *event = 0; |
3022 | Todo *todo = 0; | 3057 | Todo *todo = 0; |
3023 | 3058 | ||
3024 | if (incidence == 0) { | 3059 | if (incidence == 0) { |
3025 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3060 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3026 | if (incidence == 0) { | 3061 | if (incidence == 0) { |
3027 | incidence = mTodoList->selectedIncidences().first(); | 3062 | incidence = mTodoList->selectedIncidences().first(); |
3028 | } | 3063 | } |
3029 | } | 3064 | } |
3030 | if ( incidence && incidence->type() == "Event" ) { | 3065 | if ( incidence && incidence->type() == "Event" ) { |
3031 | event = static_cast<Event *>(incidence); | 3066 | event = static_cast<Event *>(incidence); |
3032 | } | 3067 | } |
3033 | if ( incidence && incidence->type() == "Todo" ) { | 3068 | if ( incidence && incidence->type() == "Todo" ) { |
3034 | todo = static_cast<Todo *>(incidence); | 3069 | todo = static_cast<Todo *>(incidence); |
3035 | } | 3070 | } |
3036 | 3071 | ||
3037 | if (!event && !todo) { | 3072 | if (!event && !todo) { |
3038 | KMessageBox::sorry(this,i18n("No event selected.")); | 3073 | KMessageBox::sorry(this,i18n("No event selected.")); |
3039 | return; | 3074 | return; |
3040 | } | 3075 | } |
3041 | 3076 | ||
3042 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3077 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3043 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3078 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3044 | return; | 3079 | return; |
3045 | } | 3080 | } |
3046 | 3081 | ||
3047 | Event *ev = 0; | 3082 | Event *ev = 0; |
3048 | if (event) ev = new Event(*event); | 3083 | if (event) ev = new Event(*event); |
3049 | Todo *to = 0; | 3084 | Todo *to = 0; |
3050 | if (todo) to = new Todo(*todo); | 3085 | if (todo) to = new Todo(*todo); |
3051 | 3086 | ||
3052 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3087 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3053 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3088 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3054 | if (!me) { | 3089 | if (!me) { |
3055 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3090 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3056 | return; | 3091 | return; |
3057 | } | 3092 | } |
3058 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3093 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3059 | StatusDialog *statdlg = new StatusDialog(this); | 3094 | StatusDialog *statdlg = new StatusDialog(this); |
3060 | if (!statdlg->exec()==QDialog::Accepted) return; | 3095 | if (!statdlg->exec()==QDialog::Accepted) return; |
3061 | me->setStatus( statdlg->status() ); | 3096 | me->setStatus( statdlg->status() ); |
3062 | delete(statdlg); | 3097 | delete(statdlg); |
3063 | } | 3098 | } |
3064 | Attendee *menew = new Attendee(*me); | 3099 | Attendee *menew = new Attendee(*me); |
3065 | if (ev) { | 3100 | if (ev) { |
3066 | ev->clearAttendees(); | 3101 | ev->clearAttendees(); |
3067 | ev->addAttendee(menew,false); | 3102 | ev->addAttendee(menew,false); |
3068 | } else { | 3103 | } else { |
3069 | if (to) { | 3104 | if (to) { |
3070 | todo->clearAttendees(); | 3105 | todo->clearAttendees(); |
3071 | todo->addAttendee(menew,false); | 3106 | todo->addAttendee(menew,false); |
3072 | } | 3107 | } |
3073 | } | 3108 | } |
3074 | } | 3109 | } |
3075 | 3110 | ||
3076 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3111 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3077 | if (ev) { | 3112 | if (ev) { |
3078 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3113 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3079 | } else { | 3114 | } else { |
3080 | if (to) { | 3115 | if (to) { |
3081 | if ( !dlg->addMessage(to,method) ) delete(to); | 3116 | if ( !dlg->addMessage(to,method) ) delete(to); |
3082 | } | 3117 | } |
3083 | } | 3118 | } |
3084 | } | 3119 | } |
3085 | 3120 | ||
3086 | void CalendarView::openAddressbook() | 3121 | void CalendarView::openAddressbook() |
3087 | { | 3122 | { |
3088 | KRun::runCommand("kaddressbook"); | 3123 | KRun::runCommand("kaddressbook"); |
3089 | } | 3124 | } |
3090 | 3125 | ||
3091 | void CalendarView::setModified(bool modified) | 3126 | void CalendarView::setModified(bool modified) |
3092 | { | 3127 | { |
3093 | if ( modified ) | 3128 | if ( modified ) |
3094 | emit signalmodified(); | 3129 | emit signalmodified(); |
3095 | if (mModified != modified) { | 3130 | if (mModified != modified) { |
3096 | mModified = modified; | 3131 | mModified = modified; |
3097 | emit modifiedChanged(mModified); | 3132 | emit modifiedChanged(mModified); |
3098 | } | 3133 | } |
3099 | } | 3134 | } |
3100 | 3135 | ||
3101 | bool CalendarView::isReadOnly() | 3136 | bool CalendarView::isReadOnly() |
3102 | { | 3137 | { |
3103 | return mReadOnly; | 3138 | return mReadOnly; |
3104 | } | 3139 | } |
3105 | 3140 | ||
3106 | void CalendarView::setReadOnly(bool readOnly) | 3141 | void CalendarView::setReadOnly(bool readOnly) |
3107 | { | 3142 | { |
3108 | if (mReadOnly != readOnly) { | 3143 | if (mReadOnly != readOnly) { |
3109 | mReadOnly = readOnly; | 3144 | mReadOnly = readOnly; |
3110 | emit readOnlyChanged(mReadOnly); | 3145 | emit readOnlyChanged(mReadOnly); |
3111 | } | 3146 | } |
3112 | } | 3147 | } |
3113 | 3148 | ||
3114 | bool CalendarView::isModified() | 3149 | bool CalendarView::isModified() |
3115 | { | 3150 | { |
3116 | return mModified; | 3151 | return mModified; |
3117 | } | 3152 | } |
3118 | 3153 | ||
3119 | void CalendarView::printSetup() | 3154 | void CalendarView::printSetup() |
3120 | { | 3155 | { |
3121 | #ifndef KORG_NOPRINTER | 3156 | #ifndef KORG_NOPRINTER |
3122 | createPrinter(); | 3157 | createPrinter(); |
3123 | 3158 | ||
3124 | mCalPrinter->setupPrinter(); | 3159 | mCalPrinter->setupPrinter(); |
3125 | #endif | 3160 | #endif |
3126 | } | 3161 | } |
3127 | 3162 | ||
3128 | void CalendarView::print() | 3163 | void CalendarView::print() |
3129 | { | 3164 | { |
3130 | #ifndef KORG_NOPRINTER | 3165 | #ifndef KORG_NOPRINTER |
3131 | createPrinter(); | 3166 | createPrinter(); |
3132 | 3167 | ||
3133 | DateList tmpDateList = mNavigator->selectedDates(); | 3168 | DateList tmpDateList = mNavigator->selectedDates(); |
3134 | mCalPrinter->print(CalPrinter::Month, | 3169 | mCalPrinter->print(CalPrinter::Month, |
3135 | tmpDateList.first(), tmpDateList.last()); | 3170 | tmpDateList.first(), tmpDateList.last()); |
3136 | #endif | 3171 | #endif |
3137 | } | 3172 | } |
3138 | 3173 | ||
3139 | void CalendarView::printPreview() | 3174 | void CalendarView::printPreview() |
3140 | { | 3175 | { |
3141 | #ifndef KORG_NOPRINTER | 3176 | #ifndef KORG_NOPRINTER |
3142 | kdDebug() << "CalendarView::printPreview()" << endl; | 3177 | kdDebug() << "CalendarView::printPreview()" << endl; |
3143 | 3178 | ||
3144 | createPrinter(); | 3179 | createPrinter(); |
3145 | 3180 | ||
3146 | DateList tmpDateList = mNavigator->selectedDates(); | 3181 | DateList tmpDateList = mNavigator->selectedDates(); |
3147 | 3182 | ||
3148 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3183 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3149 | tmpDateList.last()); | 3184 | tmpDateList.last()); |
3150 | #endif | 3185 | #endif |
3151 | } | 3186 | } |
3152 | 3187 | ||
3153 | void CalendarView::exportICalendar() | 3188 | void CalendarView::exportICalendar() |
3154 | { | 3189 | { |
3155 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3190 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3156 | 3191 | ||
3157 | // Force correct extension | 3192 | // Force correct extension |
3158 | if (filename.right(4) != ".ics") filename += ".ics"; | 3193 | if (filename.right(4) != ".ics") filename += ".ics"; |
3159 | 3194 | ||
3160 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3195 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3161 | storage.save(); | 3196 | storage.save(); |
3162 | } | 3197 | } |
3163 | 3198 | ||
3164 | bool CalendarView::exportVCalendar( QString filename ) | 3199 | bool CalendarView::exportVCalendar( QString filename ) |
3165 | { | 3200 | { |
3166 | if (mCalendar->journals().count() > 0) { | 3201 | if (mCalendar->journals().count() > 0) { |
3167 | int result = KMessageBox::warningContinueCancel(this, | 3202 | int result = KMessageBox::warningContinueCancel(this, |
3168 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3203 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3169 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3204 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3170 | true); | 3205 | true); |
3171 | if (result != KMessageBox::Continue) return false; | 3206 | if (result != KMessageBox::Continue) return false; |
3172 | } | 3207 | } |
3173 | 3208 | ||
3174 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3209 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3175 | 3210 | ||
3176 | // Force correct extension | 3211 | // Force correct extension |
3177 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3212 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3178 | 3213 | ||
3179 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3214 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3180 | return storage.save(); | 3215 | return storage.save(); |
3181 | 3216 | ||
3182 | } | 3217 | } |
3183 | 3218 | ||
3184 | void CalendarView::eventUpdated(Incidence *) | 3219 | void CalendarView::eventUpdated(Incidence *) |
3185 | { | 3220 | { |
3186 | setModified(); | 3221 | setModified(); |
3187 | // Don't call updateView here. The code, which has caused the update of the | 3222 | // Don't call updateView here. The code, which has caused the update of the |
3188 | // event is responsible for updating the view. | 3223 | // event is responsible for updating the view. |
3189 | // updateView(); | 3224 | // updateView(); |
3190 | } | 3225 | } |
3191 | 3226 | ||
3192 | void CalendarView::adaptNavigationUnits() | 3227 | void CalendarView::adaptNavigationUnits() |
3193 | { | 3228 | { |
3194 | if (mViewManager->currentView()->isEventView()) { | 3229 | if (mViewManager->currentView()->isEventView()) { |
3195 | int days = mViewManager->currentView()->currentDateCount(); | 3230 | int days = mViewManager->currentView()->currentDateCount(); |
3196 | if (days == 1) { | 3231 | if (days == 1) { |
3197 | emit changeNavStringPrev(i18n("&Previous Day")); | 3232 | emit changeNavStringPrev(i18n("&Previous Day")); |
3198 | emit changeNavStringNext(i18n("&Next Day")); | 3233 | emit changeNavStringNext(i18n("&Next Day")); |
3199 | } else { | 3234 | } else { |
3200 | emit changeNavStringPrev(i18n("&Previous Week")); | 3235 | emit changeNavStringPrev(i18n("&Previous Week")); |
3201 | emit changeNavStringNext(i18n("&Next Week")); | 3236 | emit changeNavStringNext(i18n("&Next Week")); |
3202 | } | 3237 | } |
3203 | } | 3238 | } |
3204 | } | 3239 | } |
3205 | 3240 | ||
3206 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3241 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3207 | { | 3242 | { |
3208 | if ( incidence ) mTodoList->clearSelection(); | 3243 | if ( incidence ) mTodoList->clearSelection(); |
3209 | processIncidenceSelection( incidence ); | 3244 | processIncidenceSelection( incidence ); |
3210 | } | 3245 | } |
3211 | 3246 | ||
3212 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3247 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3213 | { | 3248 | { |
3214 | if ( incidence && mViewManager->currentView() ) { | 3249 | if ( incidence && mViewManager->currentView() ) { |
3215 | mViewManager->currentView()->clearSelection(); | 3250 | mViewManager->currentView()->clearSelection(); |
3216 | } | 3251 | } |
3217 | processIncidenceSelection( incidence ); | 3252 | processIncidenceSelection( incidence ); |
3218 | } | 3253 | } |
3219 | 3254 | ||
3220 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3255 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3221 | { | 3256 | { |
3222 | if ( incidence == mSelectedIncidence ) return; | 3257 | if ( incidence == mSelectedIncidence ) return; |
3223 | 3258 | ||
3224 | mSelectedIncidence = incidence; | 3259 | mSelectedIncidence = incidence; |
3225 | 3260 | ||
3226 | emit incidenceSelected( mSelectedIncidence ); | 3261 | emit incidenceSelected( mSelectedIncidence ); |
3227 | 3262 | ||
3228 | if ( incidence && incidence->type() == "Event" ) { | 3263 | if ( incidence && incidence->type() == "Event" ) { |
3229 | Event *event = static_cast<Event *>( incidence ); | 3264 | Event *event = static_cast<Event *>( incidence ); |
3230 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3265 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3231 | emit organizerEventsSelected( true ); | 3266 | emit organizerEventsSelected( true ); |
3232 | } else { | 3267 | } else { |
3233 | emit organizerEventsSelected(false); | 3268 | emit organizerEventsSelected(false); |
3234 | } | 3269 | } |
3235 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3270 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3236 | KOPrefs::instance()->email() ) ) { | 3271 | KOPrefs::instance()->email() ) ) { |
3237 | emit groupEventsSelected( true ); | 3272 | emit groupEventsSelected( true ); |
3238 | } else { | 3273 | } else { |
3239 | emit groupEventsSelected(false); | 3274 | emit groupEventsSelected(false); |
3240 | } | 3275 | } |
3241 | return; | 3276 | return; |
3242 | } else { | 3277 | } else { |
3243 | if ( incidence && incidence->type() == "Todo" ) { | 3278 | if ( incidence && incidence->type() == "Todo" ) { |
3244 | emit todoSelected( true ); | 3279 | emit todoSelected( true ); |
3245 | Todo *event = static_cast<Todo *>( incidence ); | 3280 | Todo *event = static_cast<Todo *>( incidence ); |
3246 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3281 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3247 | emit organizerEventsSelected( true ); | 3282 | emit organizerEventsSelected( true ); |
3248 | } else { | 3283 | } else { |
3249 | emit organizerEventsSelected(false); | 3284 | emit organizerEventsSelected(false); |
3250 | } | 3285 | } |
3251 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3286 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3252 | KOPrefs::instance()->email() ) ) { | 3287 | KOPrefs::instance()->email() ) ) { |
3253 | emit groupEventsSelected( true ); | 3288 | emit groupEventsSelected( true ); |
3254 | } else { | 3289 | } else { |
3255 | emit groupEventsSelected(false); | 3290 | emit groupEventsSelected(false); |
3256 | } | 3291 | } |
3257 | return; | 3292 | return; |
3258 | } else { | 3293 | } else { |
3259 | emit todoSelected( false ); | 3294 | emit todoSelected( false ); |
3260 | emit organizerEventsSelected(false); | 3295 | emit organizerEventsSelected(false); |
3261 | emit groupEventsSelected(false); | 3296 | emit groupEventsSelected(false); |
3262 | } | 3297 | } |
3263 | return; | 3298 | return; |
3264 | } | 3299 | } |
3265 | 3300 | ||
3266 | /* if ( incidence && incidence->type() == "Todo" ) { | 3301 | /* if ( incidence && incidence->type() == "Todo" ) { |
3267 | emit todoSelected( true ); | 3302 | emit todoSelected( true ); |
3268 | } else { | 3303 | } else { |
3269 | emit todoSelected( false ); | 3304 | emit todoSelected( false ); |
3270 | }*/ | 3305 | }*/ |
3271 | } | 3306 | } |
3272 | 3307 | ||
3273 | 3308 | ||
3274 | void CalendarView::checkClipboard() | 3309 | void CalendarView::checkClipboard() |
3275 | { | 3310 | { |
3276 | #ifndef KORG_NODND | 3311 | #ifndef KORG_NODND |
3277 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3312 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3278 | emit pasteEnabled(true); | 3313 | emit pasteEnabled(true); |
3279 | } else { | 3314 | } else { |
3280 | emit pasteEnabled(false); | 3315 | emit pasteEnabled(false); |
3281 | } | 3316 | } |
3282 | #endif | 3317 | #endif |
3283 | } | 3318 | } |
3284 | 3319 | ||
3285 | void CalendarView::showDates(const DateList &selectedDates) | 3320 | void CalendarView::showDates(const DateList &selectedDates) |
3286 | { | 3321 | { |
3287 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3322 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3288 | 3323 | ||
3289 | if ( mViewManager->currentView() ) { | 3324 | if ( mViewManager->currentView() ) { |
3290 | updateView( selectedDates.first(), selectedDates.last() ); | 3325 | updateView( selectedDates.first(), selectedDates.last() ); |
3291 | } else { | 3326 | } else { |
3292 | mViewManager->showAgendaView(); | 3327 | mViewManager->showAgendaView(); |
3293 | } | 3328 | } |
3294 | 3329 | ||
3295 | QString selDates; | 3330 | QString selDates; |
3296 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3331 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3297 | if (selectedDates.first() < selectedDates.last() ) | 3332 | if (selectedDates.first() < selectedDates.last() ) |
3298 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3333 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3299 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3334 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3300 | 3335 | ||
3301 | } | 3336 | } |
3302 | 3337 | ||
3303 | QPtrList<CalFilter> CalendarView::filters() | 3338 | QPtrList<CalFilter> CalendarView::filters() |
3304 | { | 3339 | { |
3305 | return mFilters; | 3340 | return mFilters; |
3306 | 3341 | ||
3307 | } | 3342 | } |
3308 | void CalendarView::editFilters() | 3343 | void CalendarView::editFilters() |
3309 | { | 3344 | { |
3310 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3345 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3311 | 3346 | ||
3312 | CalFilter *filter = mFilters.first(); | 3347 | CalFilter *filter = mFilters.first(); |
3313 | while(filter) { | 3348 | while(filter) { |
3314 | kdDebug() << " Filter: " << filter->name() << endl; | 3349 | kdDebug() << " Filter: " << filter->name() << endl; |
3315 | filter = mFilters.next(); | 3350 | filter = mFilters.next(); |
3316 | } | 3351 | } |
3317 | 3352 | ||
3318 | mDialogManager->showFilterEditDialog(&mFilters); | 3353 | mDialogManager->showFilterEditDialog(&mFilters); |
3319 | } | 3354 | } |
3320 | void CalendarView::toggleFilter() | 3355 | void CalendarView::toggleFilter() |
3321 | { | 3356 | { |
3322 | showFilter(! mFilterView->isVisible()); | 3357 | showFilter(! mFilterView->isVisible()); |
3323 | } | 3358 | } |
3324 | 3359 | ||
3325 | KOFilterView *CalendarView::filterView() | 3360 | KOFilterView *CalendarView::filterView() |
3326 | { | 3361 | { |
3327 | return mFilterView; | 3362 | return mFilterView; |
3328 | } | 3363 | } |
3329 | void CalendarView::selectFilter( int fil ) | 3364 | void CalendarView::selectFilter( int fil ) |
3330 | { | 3365 | { |
3331 | mFilterView->setSelectedFilter( fil ); | 3366 | mFilterView->setSelectedFilter( fil ); |
3332 | } | 3367 | } |
3333 | void CalendarView::showFilter(bool visible) | 3368 | void CalendarView::showFilter(bool visible) |
3334 | { | 3369 | { |
3335 | if (visible) mFilterView->show(); | 3370 | if (visible) mFilterView->show(); |
3336 | else mFilterView->hide(); | 3371 | else mFilterView->hide(); |
3337 | } | 3372 | } |
3338 | void CalendarView::toggleFilerEnabled( ) | 3373 | void CalendarView::toggleFilerEnabled( ) |
3339 | { | 3374 | { |
3340 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3375 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3341 | if ( !mFilterView->filtersEnabled() ) | 3376 | if ( !mFilterView->filtersEnabled() ) |
3342 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3377 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3343 | 3378 | ||
3344 | } | 3379 | } |
3345 | void CalendarView::updateFilter() | 3380 | void CalendarView::updateFilter() |
3346 | { | 3381 | { |
3347 | CalFilter *filter = mFilterView->selectedFilter(); | 3382 | CalFilter *filter = mFilterView->selectedFilter(); |
3348 | if (filter) { | 3383 | if (filter) { |
3349 | if (mFilterView->filtersEnabled()) { | 3384 | if (mFilterView->filtersEnabled()) { |
3350 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3385 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3351 | filter->setEnabled(true); | 3386 | filter->setEnabled(true); |
3352 | } | 3387 | } |
3353 | else filter->setEnabled(false); | 3388 | else filter->setEnabled(false); |
3354 | mCalendar->setFilter(filter); | 3389 | mCalendar->setFilter(filter); |
3355 | updateView(); | 3390 | updateView(); |
3356 | } | 3391 | } |
3357 | } | 3392 | } |
3358 | 3393 | ||
3359 | void CalendarView::filterEdited() | 3394 | void CalendarView::filterEdited() |
3360 | { | 3395 | { |
3361 | mFilterView->updateFilters(); | 3396 | mFilterView->updateFilters(); |
3362 | updateFilter(); | 3397 | updateFilter(); |
3363 | writeSettings(); | 3398 | writeSettings(); |
3364 | } | 3399 | } |
3365 | 3400 | ||
3366 | 3401 | ||
3367 | void CalendarView::takeOverEvent() | 3402 | void CalendarView::takeOverEvent() |
3368 | { | 3403 | { |
3369 | Incidence *incidence = currentSelection(); | 3404 | Incidence *incidence = currentSelection(); |
3370 | 3405 | ||
3371 | if (!incidence) return; | 3406 | if (!incidence) return; |
3372 | 3407 | ||
3373 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3408 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3374 | incidence->recreate(); | 3409 | incidence->recreate(); |
3375 | incidence->setReadOnly(false); | 3410 | incidence->setReadOnly(false); |
3376 | 3411 | ||
3377 | updateView(); | 3412 | updateView(); |
3378 | } | 3413 | } |
3379 | 3414 | ||
3380 | void CalendarView::takeOverCalendar() | 3415 | void CalendarView::takeOverCalendar() |
3381 | { | 3416 | { |
3382 | // TODO: Create Calendar::allIncidences() function and use it here | 3417 | // TODO: Create Calendar::allIncidences() function and use it here |
3383 | 3418 | ||
3384 | QPtrList<Event> events = mCalendar->events(); | 3419 | QPtrList<Event> events = mCalendar->events(); |
3385 | for(uint i=0; i<events.count(); ++i) { | 3420 | for(uint i=0; i<events.count(); ++i) { |
3386 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3421 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3387 | events.at(i)->recreate(); | 3422 | events.at(i)->recreate(); |
3388 | events.at(i)->setReadOnly(false); | 3423 | events.at(i)->setReadOnly(false); |
3389 | } | 3424 | } |
3390 | 3425 | ||
3391 | QPtrList<Todo> todos = mCalendar->todos(); | 3426 | QPtrList<Todo> todos = mCalendar->todos(); |
3392 | for(uint i=0; i<todos.count(); ++i) { | 3427 | for(uint i=0; i<todos.count(); ++i) { |
3393 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3428 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3394 | todos.at(i)->recreate(); | 3429 | todos.at(i)->recreate(); |
3395 | todos.at(i)->setReadOnly(false); | 3430 | todos.at(i)->setReadOnly(false); |
3396 | } | 3431 | } |
3397 | 3432 | ||
3398 | QPtrList<Journal> journals = mCalendar->journals(); | 3433 | QPtrList<Journal> journals = mCalendar->journals(); |
3399 | for(uint i=0; i<journals.count(); ++i) { | 3434 | for(uint i=0; i<journals.count(); ++i) { |
3400 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3435 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3401 | journals.at(i)->recreate(); | 3436 | journals.at(i)->recreate(); |
3402 | journals.at(i)->setReadOnly(false); | 3437 | journals.at(i)->setReadOnly(false); |
3403 | } | 3438 | } |
3404 | 3439 | ||
3405 | updateView(); | 3440 | updateView(); |
3406 | } | 3441 | } |
3407 | 3442 | ||
3408 | void CalendarView::showIntro() | 3443 | void CalendarView::showIntro() |
3409 | { | 3444 | { |
3410 | kdDebug() << "To be implemented." << endl; | 3445 | kdDebug() << "To be implemented." << endl; |
3411 | } | 3446 | } |
3412 | 3447 | ||
3413 | QWidgetStack *CalendarView::viewStack() | 3448 | QWidgetStack *CalendarView::viewStack() |
3414 | { | 3449 | { |
3415 | return mRightFrame; | 3450 | return mRightFrame; |
3416 | } | 3451 | } |
3417 | 3452 | ||
3418 | QWidget *CalendarView::leftFrame() | 3453 | QWidget *CalendarView::leftFrame() |
3419 | { | 3454 | { |
3420 | return mLeftFrame; | 3455 | return mLeftFrame; |
3421 | } | 3456 | } |
3422 | 3457 | ||
3423 | DateNavigator *CalendarView::dateNavigator() | 3458 | DateNavigator *CalendarView::dateNavigator() |
3424 | { | 3459 | { |
3425 | return mNavigator; | 3460 | return mNavigator; |
3426 | } | 3461 | } |
3427 | 3462 | ||
3428 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3463 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3429 | { | 3464 | { |
3430 | return mDateNavigator; | 3465 | return mDateNavigator; |
3431 | } | 3466 | } |
3432 | void CalendarView::toggleDateNavigatorWidget() | 3467 | void CalendarView::toggleDateNavigatorWidget() |
3433 | { | 3468 | { |
3434 | if (mDateNavigator->isVisible()) | 3469 | if (mDateNavigator->isVisible()) |
3435 | mDateNavigator->hide(); | 3470 | mDateNavigator->hide(); |
3436 | else | 3471 | else |
3437 | mDateNavigator->show(); | 3472 | mDateNavigator->show(); |
3438 | } | 3473 | } |
3439 | void CalendarView::addView(KOrg::BaseView *view) | 3474 | void CalendarView::addView(KOrg::BaseView *view) |
3440 | { | 3475 | { |
3441 | mViewManager->addView(view); | 3476 | mViewManager->addView(view); |
3442 | } | 3477 | } |
3443 | 3478 | ||
3444 | void CalendarView::showView(KOrg::BaseView *view) | 3479 | void CalendarView::showView(KOrg::BaseView *view) |
3445 | { | 3480 | { |
3446 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3481 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3447 | } | 3482 | } |
3448 | 3483 | ||
3449 | Incidence *CalendarView::currentSelection() | 3484 | Incidence *CalendarView::currentSelection() |
3450 | { | 3485 | { |
3451 | return mViewManager->currentSelection(); | 3486 | return mViewManager->currentSelection(); |
3452 | } | 3487 | } |
3453 | void CalendarView::toggleAllDaySize() | 3488 | void CalendarView::toggleAllDaySize() |
3454 | { | 3489 | { |
3455 | /* | 3490 | /* |
3456 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3491 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3457 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3492 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3458 | else | 3493 | else |
3459 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3494 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3460 | */ | 3495 | */ |
3461 | viewManager()->agendaView()->toggleAllDay(); | 3496 | viewManager()->agendaView()->toggleAllDay(); |
3462 | } | 3497 | } |
3463 | void CalendarView::toggleExpand() | 3498 | void CalendarView::toggleExpand() |
3464 | { | 3499 | { |
3465 | // if ( mLeftFrame->isHidden() ) { | 3500 | // if ( mLeftFrame->isHidden() ) { |
3466 | // mLeftFrame->show(); | 3501 | // mLeftFrame->show(); |
3467 | // emit calendarViewExpanded( false ); | 3502 | // emit calendarViewExpanded( false ); |
3468 | // } else { | 3503 | // } else { |
3469 | // mLeftFrame->hide(); | 3504 | // mLeftFrame->hide(); |
3470 | // emit calendarViewExpanded( true ); | 3505 | // emit calendarViewExpanded( true ); |
3471 | // } | 3506 | // } |
3472 | 3507 | ||
3473 | globalFlagBlockAgenda = 1; | 3508 | globalFlagBlockAgenda = 1; |
3474 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3509 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3475 | globalFlagBlockAgenda = 5; | 3510 | globalFlagBlockAgenda = 5; |
3476 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3511 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3477 | //mViewManager->showView( 0, true ); | 3512 | //mViewManager->showView( 0, true ); |
3478 | } | 3513 | } |
3479 | 3514 | ||
3480 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3515 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3481 | { | 3516 | { |
3482 | setModified( modified ); | 3517 | setModified( modified ); |
3483 | } | 3518 | } |
3484 | 3519 | ||
3485 | Todo *CalendarView::selectedTodo() | 3520 | Todo *CalendarView::selectedTodo() |
3486 | { | 3521 | { |
3487 | Incidence *incidence = currentSelection(); | 3522 | Incidence *incidence = currentSelection(); |
3488 | if ( incidence && incidence->type() == "Todo" ) { | 3523 | if ( incidence && incidence->type() == "Todo" ) { |
3489 | return static_cast<Todo *>( incidence ); | 3524 | return static_cast<Todo *>( incidence ); |
3490 | } | 3525 | } |
3491 | 3526 | ||
3492 | incidence = mTodoList->selectedIncidences().first(); | 3527 | incidence = mTodoList->selectedIncidences().first(); |
3493 | if ( incidence && incidence->type() == "Todo" ) { | 3528 | if ( incidence && incidence->type() == "Todo" ) { |
3494 | return static_cast<Todo *>( incidence ); | 3529 | return static_cast<Todo *>( incidence ); |
3495 | } | 3530 | } |
3496 | 3531 | ||
3497 | return 0; | 3532 | return 0; |
3498 | } | 3533 | } |
3499 | 3534 | ||
3500 | void CalendarView::dialogClosing(Incidence *in) | 3535 | void CalendarView::dialogClosing(Incidence *in) |
3501 | { | 3536 | { |
3502 | // mDialogList.remove(in); | 3537 | // mDialogList.remove(in); |
3503 | } | 3538 | } |
3504 | 3539 | ||
3505 | void CalendarView::showIncidence() | 3540 | void CalendarView::showIncidence() |
3506 | { | 3541 | { |
3507 | Incidence *incidence = currentSelection(); | 3542 | Incidence *incidence = currentSelection(); |
3508 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3543 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3509 | if ( incidence ) { | 3544 | if ( incidence ) { |
3510 | ShowIncidenceVisitor v; | 3545 | ShowIncidenceVisitor v; |
3511 | v.act( incidence, this ); | 3546 | v.act( incidence, this ); |
3512 | } | 3547 | } |
3513 | } | 3548 | } |
3514 | void CalendarView::editIncidenceDescription() | 3549 | void CalendarView::editIncidenceDescription() |
3515 | { | 3550 | { |
3516 | mFlagEditDescription = true; | 3551 | mFlagEditDescription = true; |
3517 | editIncidence(); | 3552 | editIncidence(); |
3518 | mFlagEditDescription = false; | 3553 | mFlagEditDescription = false; |
3519 | } | 3554 | } |
3520 | void CalendarView::editIncidence() | 3555 | void CalendarView::editIncidence() |
3521 | { | 3556 | { |
3522 | // qDebug("editIncidence() "); | 3557 | // qDebug("editIncidence() "); |
3523 | Incidence *incidence = currentSelection(); | 3558 | Incidence *incidence = currentSelection(); |
3524 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3559 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3525 | if ( incidence ) { | 3560 | if ( incidence ) { |
3526 | EditIncidenceVisitor v; | 3561 | EditIncidenceVisitor v; |
3527 | v.act( incidence, this ); | 3562 | v.act( incidence, this ); |
3528 | } | 3563 | } |
3529 | } | 3564 | } |
3530 | 3565 | ||
3531 | void CalendarView::deleteIncidence() | 3566 | void CalendarView::deleteIncidence() |
3532 | { | 3567 | { |
3533 | Incidence *incidence = currentSelection(); | 3568 | Incidence *incidence = currentSelection(); |
3534 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3569 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3535 | if ( incidence ) { | 3570 | if ( incidence ) { |
3536 | deleteIncidence(incidence); | 3571 | deleteIncidence(incidence); |
3537 | } | 3572 | } |
3538 | } | 3573 | } |
3539 | 3574 | ||
3540 | void CalendarView::showIncidence(Incidence *incidence) | 3575 | void CalendarView::showIncidence(Incidence *incidence) |
3541 | { | 3576 | { |
3542 | if ( incidence ) { | 3577 | if ( incidence ) { |
3543 | ShowIncidenceVisitor v; | 3578 | ShowIncidenceVisitor v; |
3544 | v.act( incidence, this ); | 3579 | v.act( incidence, this ); |
3545 | } | 3580 | } |
3546 | } | 3581 | } |
3547 | 3582 | ||
3548 | void CalendarView::editIncidence(Incidence *incidence) | 3583 | void CalendarView::editIncidence(Incidence *incidence) |
3549 | { | 3584 | { |
3550 | if ( incidence ) { | 3585 | if ( incidence ) { |
3551 | 3586 | ||
3552 | EditIncidenceVisitor v; | 3587 | EditIncidenceVisitor v; |
3553 | v.act( incidence, this ); | 3588 | v.act( incidence, this ); |
3554 | 3589 | ||
3555 | } | 3590 | } |
3556 | } | 3591 | } |
3557 | 3592 | ||
3558 | void CalendarView::deleteIncidence(Incidence *incidence) | 3593 | void CalendarView::deleteIncidence(Incidence *incidence) |
3559 | { | 3594 | { |
3560 | //qDebug(" CalendarView::deleteIncidence "); | 3595 | //qDebug(" CalendarView::deleteIncidence "); |
3561 | if ( incidence ) { | 3596 | if ( incidence ) { |
3562 | DeleteIncidenceVisitor v; | 3597 | DeleteIncidenceVisitor v; |
3563 | v.act( incidence, this ); | 3598 | v.act( incidence, this ); |
3564 | } | 3599 | } |
3565 | } | 3600 | } |
3566 | 3601 | ||
3567 | 3602 | ||
3568 | void CalendarView::lookForOutgoingMessages() | 3603 | void CalendarView::lookForOutgoingMessages() |
3569 | { | 3604 | { |
3570 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3605 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3571 | ogd->loadMessages(); | 3606 | ogd->loadMessages(); |
3572 | } | 3607 | } |
3573 | 3608 | ||
3574 | void CalendarView::lookForIncomingMessages() | 3609 | void CalendarView::lookForIncomingMessages() |
3575 | { | 3610 | { |
3576 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3611 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3577 | icd->retrieve(); | 3612 | icd->retrieve(); |
3578 | } | 3613 | } |
3579 | 3614 | ||
3580 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3615 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3581 | { | 3616 | { |
3582 | bool deleteTodo = true; | 3617 | bool deleteTodo = true; |
3583 | QPtrList<Incidence> subTodos; | 3618 | QPtrList<Incidence> subTodos; |
3584 | Incidence *aTodo; | 3619 | Incidence *aTodo; |
3585 | subTodos = t->relations(); | 3620 | subTodos = t->relations(); |
3586 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3621 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3587 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3622 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3588 | deleteTodo = false; | 3623 | deleteTodo = false; |
3589 | } | 3624 | } |
3590 | if ( deleteTodo ) { | 3625 | if ( deleteTodo ) { |
3591 | if ( t->isCompleted() ) { | 3626 | if ( t->isCompleted() ) { |
3592 | checkExternalId( t ); | 3627 | checkExternalId( t ); |
3593 | mCalendar->deleteTodo( t ); | 3628 | mCalendar->deleteTodo( t ); |
3594 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3629 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3595 | } | 3630 | } |
3596 | else | 3631 | else |
3597 | deleteTodo = false; | 3632 | deleteTodo = false; |
3598 | } | 3633 | } |
3599 | return deleteTodo; | 3634 | return deleteTodo; |
3600 | 3635 | ||
3601 | } | 3636 | } |
3602 | void CalendarView::purgeCompleted() | 3637 | void CalendarView::purgeCompleted() |
3603 | { | 3638 | { |
3604 | int result = KMessageBox::warningContinueCancel(this, | 3639 | int result = KMessageBox::warningContinueCancel(this, |
3605 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3640 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3606 | 3641 | ||
3607 | if (result == KMessageBox::Continue) { | 3642 | if (result == KMessageBox::Continue) { |
3608 | 3643 | ||
3609 | QPtrList<Todo> todoCal; | 3644 | QPtrList<Todo> todoCal; |
3610 | QPtrList<Todo> rootTodos; | 3645 | QPtrList<Todo> rootTodos; |
3611 | //QPtrList<Incidence> rel; | 3646 | //QPtrList<Incidence> rel; |
3612 | Todo *aTodo;//, *rTodo; | 3647 | Todo *aTodo;//, *rTodo; |
3613 | Incidence *rIncidence; | 3648 | Incidence *rIncidence; |
3614 | bool childDelete = false; | 3649 | bool childDelete = false; |
3615 | bool deletedOne = true; | 3650 | bool deletedOne = true; |
3616 | todoCal = calendar()->todos(); | 3651 | todoCal = calendar()->todos(); |
3617 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3652 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3618 | if ( !aTodo->relatedTo() ) | 3653 | if ( !aTodo->relatedTo() ) |
3619 | rootTodos.append( aTodo ); | 3654 | rootTodos.append( aTodo ); |
3620 | } | 3655 | } |
3621 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3656 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3622 | removeCompletedSubTodos( aTodo ); | 3657 | removeCompletedSubTodos( aTodo ); |
3623 | } | 3658 | } |
3624 | 3659 | ||
3625 | updateView(); | 3660 | updateView(); |
3626 | } | 3661 | } |
3627 | } | 3662 | } |
3628 | 3663 | ||
3629 | void CalendarView::slotCalendarChanged() | 3664 | void CalendarView::slotCalendarChanged() |
3630 | { | 3665 | { |
3631 | ; | 3666 | ; |
3632 | } | 3667 | } |
3633 | 3668 | ||
3634 | NavigatorBar *CalendarView::navigatorBar() | 3669 | NavigatorBar *CalendarView::navigatorBar() |
3635 | { | 3670 | { |
3636 | return mNavigatorBar; | 3671 | return mNavigatorBar; |
3637 | } | 3672 | } |
3638 | 3673 | ||
3639 | 3674 | ||
3640 | 3675 | ||
3641 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3676 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3642 | { | 3677 | { |
3643 | //qDebug(" alendarView::keyPressEvent "); | 3678 | //qDebug(" alendarView::keyPressEvent "); |
3644 | e->ignore(); | 3679 | e->ignore(); |
3645 | } | 3680 | } |
3646 | 3681 | ||
3647 | //#include "calendarview.moc" | 3682 | //#include "calendarview.moc" |
3648 | 3683 | ||
3649 | //#include "calendarviewbase.moc" | 3684 | //#include "calendarviewbase.moc" |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index cd54685..a713c91 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,592 +1,596 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | 42 | ||
43 | #include <korganizer/calendarviewbase.h> | 43 | #include <korganizer/calendarviewbase.h> |
44 | 44 | ||
45 | class QWidgetStack; | 45 | class QWidgetStack; |
46 | class QSplitter; | 46 | class QSplitter; |
47 | 47 | ||
48 | class CalPrinter; | 48 | class CalPrinter; |
49 | class KOFilterView; | 49 | class KOFilterView; |
50 | class KOViewManager; | 50 | class KOViewManager; |
51 | class KODialogManager; | 51 | class KODialogManager; |
52 | class KOTodoView; | 52 | class KOTodoView; |
53 | class KDateNavigator; | 53 | class KDateNavigator; |
54 | class DateNavigator; | 54 | class DateNavigator; |
55 | class KOIncidenceEditor; | 55 | class KOIncidenceEditor; |
56 | class KDatePicker; | 56 | class KDatePicker; |
57 | class ResourceView; | 57 | class ResourceView; |
58 | class NavigatorBar; | 58 | class NavigatorBar; |
59 | class KOEventEditor; | 59 | class KOEventEditor; |
60 | class KOTodoEditor ; | 60 | class KOTodoEditor ; |
61 | class KOEventViewerDialog; | 61 | class KOEventViewerDialog; |
62 | class KOBeamPrefs; | 62 | class KOBeamPrefs; |
63 | class KSyncProfile; | 63 | class KSyncProfile; |
64 | class AlarmDialog; | 64 | class AlarmDialog; |
65 | class KCal::Attendee; | 65 | class KCal::Attendee; |
66 | 66 | ||
67 | namespace KCal { class FileStorage; } | 67 | namespace KCal { class FileStorage; } |
68 | 68 | ||
69 | using namespace KCal; | 69 | using namespace KCal; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | This is the main calendar widget. It provides the different vies on t he | 72 | This is the main calendar widget. It provides the different vies on t he |
73 | calendar data as well as the date navigator. It also handles synchronisation | 73 | calendar data as well as the date navigator. It also handles synchronisation |
74 | of the different views and controls the different dialogs like preferences, | 74 | of the different views and controls the different dialogs like preferences, |
75 | event editor, search dialog etc. | 75 | event editor, search dialog etc. |
76 | 76 | ||
77 | @short main calendar view widget | 77 | @short main calendar view widget |
78 | @author Cornelius Schumacher | 78 | @author Cornelius Schumacher |
79 | */ | 79 | */ |
80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer | 80 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer |
81 | { | 81 | { |
82 | Q_OBJECT | 82 | Q_OBJECT |
83 | public: | 83 | public: |
84 | /** | 84 | /** |
85 | Constructs a new calendar view widget. | 85 | Constructs a new calendar view widget. |
86 | 86 | ||
87 | @param calendar calendar document | 87 | @param calendar calendar document |
88 | @param parent parent window | 88 | @param parent parent window |
89 | @param name Qt internal widget object name | 89 | @param name Qt internal widget object name |
90 | */ | 90 | */ |
91 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 91 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
92 | const char *name = 0 ); | 92 | const char *name = 0 ); |
93 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 93 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
94 | const char *name = 0 ); | 94 | const char *name = 0 ); |
95 | virtual ~CalendarView(); | 95 | virtual ~CalendarView(); |
96 | 96 | ||
97 | Calendar *calendar() { return mCalendar; } | 97 | Calendar *calendar() { return mCalendar; } |
98 | 98 | ||
99 | KOViewManager *viewManager(); | 99 | KOViewManager *viewManager(); |
100 | KODialogManager *dialogManager(); | 100 | KODialogManager *dialogManager(); |
101 | 101 | ||
102 | QDate startDate(); | 102 | QDate startDate(); |
103 | QDate endDate(); | 103 | QDate endDate(); |
104 | 104 | ||
105 | QWidgetStack *viewStack(); | 105 | QWidgetStack *viewStack(); |
106 | QWidget *leftFrame(); | 106 | QWidget *leftFrame(); |
107 | NavigatorBar *navigatorBar(); | 107 | NavigatorBar *navigatorBar(); |
108 | 108 | ||
109 | DateNavigator *dateNavigator(); | 109 | DateNavigator *dateNavigator(); |
110 | KDateNavigator *dateNavigatorWidget(); | 110 | KDateNavigator *dateNavigatorWidget(); |
111 | 111 | ||
112 | void addView(KOrg::BaseView *); | 112 | void addView(KOrg::BaseView *); |
113 | void showView(KOrg::BaseView *); | 113 | void showView(KOrg::BaseView *); |
114 | KOEventViewerDialog* getEventViewerDialog(); | 114 | KOEventViewerDialog* getEventViewerDialog(); |
115 | Incidence *currentSelection(); | 115 | Incidence *currentSelection(); |
116 | void setupExternSyncProfiles(); | 116 | void setupExternSyncProfiles(); |
117 | 117 | ||
118 | signals: | 118 | signals: |
119 | /** This todo has been modified */ | 119 | /** This todo has been modified */ |
120 | void todoModified(Todo *, int); | 120 | void todoModified(Todo *, int); |
121 | 121 | ||
122 | /** when change is made to options dialog, the topwidget will catch this | 122 | /** when change is made to options dialog, the topwidget will catch this |
123 | * and emit this signal which notifies all widgets which have registered | 123 | * and emit this signal which notifies all widgets which have registered |
124 | * for notification to update their settings. */ | 124 | * for notification to update their settings. */ |
125 | void configChanged(); | 125 | void configChanged(); |
126 | /** emitted when the topwidget is closing down, so that any attached | 126 | /** emitted when the topwidget is closing down, so that any attached |
127 | child windows can also close. */ | 127 | child windows can also close. */ |
128 | void closingDown(); | 128 | void closingDown(); |
129 | /** emitted right before we die */ | 129 | /** emitted right before we die */ |
130 | void closed(QWidget *); | 130 | void closed(QWidget *); |
131 | 131 | ||
132 | /** Emitted when state of modified flag changes */ | 132 | /** Emitted when state of modified flag changes */ |
133 | void modifiedChanged(bool); | 133 | void modifiedChanged(bool); |
134 | void signalmodified(); | 134 | void signalmodified(); |
135 | 135 | ||
136 | /** Emitted when state of read-only flag changes */ | 136 | /** Emitted when state of read-only flag changes */ |
137 | void readOnlyChanged(bool); | 137 | void readOnlyChanged(bool); |
138 | 138 | ||
139 | /** Emitted when the unit of navigation changes */ | 139 | /** Emitted when the unit of navigation changes */ |
140 | void changeNavStringPrev(const QString &); | 140 | void changeNavStringPrev(const QString &); |
141 | void changeNavStringNext(const QString &); | 141 | void changeNavStringNext(const QString &); |
142 | 142 | ||
143 | /** Emitted when state of events selection has changed and user is organizer*/ | 143 | /** Emitted when state of events selection has changed and user is organizer*/ |
144 | void organizerEventsSelected(bool); | 144 | void organizerEventsSelected(bool); |
145 | /** Emitted when state of events selection has changed and user is attendee*/ | 145 | /** Emitted when state of events selection has changed and user is attendee*/ |
146 | void groupEventsSelected(bool); | 146 | void groupEventsSelected(bool); |
147 | /** | 147 | /** |
148 | Emitted when an incidence gets selected. If the selection is cleared the | 148 | Emitted when an incidence gets selected. If the selection is cleared the |
149 | signal is emitted with 0 as argument. | 149 | signal is emitted with 0 as argument. |
150 | */ | 150 | */ |
151 | void incidenceSelected( Incidence * ); | 151 | void incidenceSelected( Incidence * ); |
152 | /** Emitted, when a todoitem is selected or deselected. */ | 152 | /** Emitted, when a todoitem is selected or deselected. */ |
153 | void todoSelected( bool ); | 153 | void todoSelected( bool ); |
154 | 154 | ||
155 | /** | 155 | /** |
156 | Emitted, when clipboard content changes. Parameter indicates if paste | 156 | Emitted, when clipboard content changes. Parameter indicates if paste |
157 | is possible or not. | 157 | is possible or not. |
158 | */ | 158 | */ |
159 | void pasteEnabled(bool); | 159 | void pasteEnabled(bool); |
160 | 160 | ||
161 | /** Emitted, when the number of incoming messages has changed. */ | 161 | /** Emitted, when the number of incoming messages has changed. */ |
162 | void numIncomingChanged(int); | 162 | void numIncomingChanged(int); |
163 | 163 | ||
164 | /** Emitted, when the number of outgoing messages has changed. */ | 164 | /** Emitted, when the number of outgoing messages has changed. */ |
165 | void numOutgoingChanged(int); | 165 | void numOutgoingChanged(int); |
166 | 166 | ||
167 | /** Send status message, which can e.g. be displayed in the status bar. */ | 167 | /** Send status message, which can e.g. be displayed in the status bar. */ |
168 | void statusMessage(const QString &); | 168 | void statusMessage(const QString &); |
169 | 169 | ||
170 | void calendarViewExpanded( bool ); | 170 | void calendarViewExpanded( bool ); |
171 | void updateSearchDialog(); | 171 | void updateSearchDialog(); |
172 | 172 | ||
173 | 173 | ||
174 | public slots: | 174 | public slots: |
175 | void showOpenError(); | 175 | void showOpenError(); |
176 | void watchSavedFile(); | 176 | void watchSavedFile(); |
177 | void recheckTimerAlarm(); | 177 | void recheckTimerAlarm(); |
178 | void checkNextTimerAlarm(); | 178 | void checkNextTimerAlarm(); |
179 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 179 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
180 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 180 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
181 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 181 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
182 | 182 | ||
183 | /** options dialog made a changed to the configuration. we catch this | 183 | /** options dialog made a changed to the configuration. we catch this |
184 | * and notify all widgets which need to update their configuration. */ | 184 | * and notify all widgets which need to update their configuration. */ |
185 | void updateConfig(); | 185 | void updateConfig(); |
186 | 186 | ||
187 | /** | 187 | /** |
188 | Load calendar from file \a filename. If \a merge is true, load | 188 | Load calendar from file \a filename. If \a merge is true, load |
189 | calendar into existing one, if it is false, clear calendar, before | 189 | calendar into existing one, if it is false, clear calendar, before |
190 | loading. Return true, if calendar could be successfully loaded. | 190 | loading. Return true, if calendar could be successfully loaded. |
191 | */ | 191 | */ |
192 | bool openCalendar(QString filename, bool merge=false); | 192 | bool openCalendar(QString filename, bool merge=false); |
193 | bool syncCalendar(QString filename,int mode = 0 ); | 193 | bool syncCalendar(QString filename,int mode = 0 ); |
194 | 194 | ||
195 | /** | 195 | /** |
196 | Save calendar data to file. Return true if calendar could be | 196 | Save calendar data to file. Return true if calendar could be |
197 | successfully saved. | 197 | successfully saved. |
198 | */ | 198 | */ |
199 | bool saveCalendar(QString filename); | 199 | bool saveCalendar(QString filename); |
200 | 200 | ||
201 | /** | 201 | /** |
202 | Close calendar. Clear calendar data and reset views to display an empty | 202 | Close calendar. Clear calendar data and reset views to display an empty |
203 | calendar. | 203 | calendar. |
204 | */ | 204 | */ |
205 | void closeCalendar(); | 205 | void closeCalendar(); |
206 | 206 | ||
207 | /** Archive old events of calendar */ | 207 | /** Archive old events of calendar */ |
208 | void archiveCalendar(); | 208 | void archiveCalendar(); |
209 | 209 | ||
210 | void showIncidence(); | 210 | void showIncidence(); |
211 | void editIncidence(); | 211 | void editIncidence(); |
212 | void editIncidenceDescription(); | 212 | void editIncidenceDescription(); |
213 | void deleteIncidence(); | 213 | void deleteIncidence(); |
214 | void cloneIncidence(); | ||
215 | void moveIncidence(); | ||
216 | void beamIncidence(); | ||
217 | void toggleCancelIncidence(); | ||
214 | 218 | ||
215 | /** create an editeventwin with supplied date/time, and if bool is true, | 219 | /** create an editeventwin with supplied date/time, and if bool is true, |
216 | * make the event take all day. */ | 220 | * make the event take all day. */ |
217 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 221 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
218 | void newEvent(QDateTime fh); | 222 | void newEvent(QDateTime fh); |
219 | void newEvent(QDate dt); | 223 | void newEvent(QDate dt); |
220 | /** create new event without having a date hint. Takes current date as | 224 | /** create new event without having a date hint. Takes current date as |
221 | default hint. */ | 225 | default hint. */ |
222 | void newEvent(); | 226 | void newEvent(); |
223 | void newFloatingEvent(); | 227 | void newFloatingEvent(); |
224 | 228 | ||
225 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 229 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
226 | void showIncidence(Incidence *); | 230 | void showIncidence(Incidence *); |
227 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 231 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
228 | void editIncidence(Incidence *); | 232 | void editIncidence(Incidence *); |
229 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 233 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
230 | void deleteIncidence(Incidence *); | 234 | void deleteIncidence(Incidence *); |
231 | void cloneIncidence(Incidence *); | 235 | void cloneIncidence(Incidence *); |
232 | void cancelIncidence(Incidence *); | 236 | void cancelIncidence(Incidence *); |
233 | /** Create an editor for the supplied event. */ | 237 | /** Create an editor for the supplied event. */ |
234 | void editEvent(Event *); | 238 | void editEvent(Event *); |
235 | /** Delete the supplied event. */ | 239 | /** Delete the supplied event. */ |
236 | void deleteEvent(Event *); | 240 | void deleteEvent(Event *); |
237 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 241 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
238 | found. */ | 242 | found. */ |
239 | bool deleteEvent(const QString &uid); | 243 | bool deleteEvent(const QString &uid); |
240 | /** Create a read-only viewer dialog for the supplied event. */ | 244 | /** Create a read-only viewer dialog for the supplied event. */ |
241 | void showEvent(Event *); | 245 | void showEvent(Event *); |
242 | 246 | ||
243 | void editJournal(Journal *); | 247 | void editJournal(Journal *); |
244 | void showJournal(Journal *); | 248 | void showJournal(Journal *); |
245 | void deleteJournal(Journal *); | 249 | void deleteJournal(Journal *); |
246 | /** Create an editor dialog for a todo */ | 250 | /** Create an editor dialog for a todo */ |
247 | void editTodo(Todo *); | 251 | void editTodo(Todo *); |
248 | /** Create a read-only viewer dialog for the supplied todo */ | 252 | /** Create a read-only viewer dialog for the supplied todo */ |
249 | void showTodo(Todo *); | 253 | void showTodo(Todo *); |
250 | /** create new todo */ | 254 | /** create new todo */ |
251 | void newTodo(); | 255 | void newTodo(); |
252 | /** create new todo with a parent todo */ | 256 | /** create new todo with a parent todo */ |
253 | void newSubTodo(); | 257 | void newSubTodo(); |
254 | /** create new todo with a parent todo */ | 258 | /** create new todo with a parent todo */ |
255 | void newSubTodo(Todo *); | 259 | void newSubTodo(Todo *); |
256 | /** Delete todo */ | 260 | /** Delete todo */ |
257 | void deleteTodo(Todo *); | 261 | void deleteTodo(Todo *); |
258 | 262 | ||
259 | 263 | ||
260 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 264 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
261 | * emitted as result. */ | 265 | * emitted as result. */ |
262 | void checkClipboard(); | 266 | void checkClipboard(); |
263 | 267 | ||
264 | /** using the KConfig associated with the kapp variable, read in the | 268 | /** using the KConfig associated with the kapp variable, read in the |
265 | * settings from the config file. | 269 | * settings from the config file. |
266 | */ | 270 | */ |
267 | void readSettings(); | 271 | void readSettings(); |
268 | 272 | ||
269 | /** write current state to config file. */ | 273 | /** write current state to config file. */ |
270 | void writeSettings(); | 274 | void writeSettings(); |
271 | 275 | ||
272 | /** read settings for calendar filters */ | 276 | /** read settings for calendar filters */ |
273 | void readFilterSettings(KConfig *config); | 277 | void readFilterSettings(KConfig *config); |
274 | 278 | ||
275 | /** write settings for calendar filters */ | 279 | /** write settings for calendar filters */ |
276 | void writeFilterSettings(KConfig *config); | 280 | void writeFilterSettings(KConfig *config); |
277 | 281 | ||
278 | /** passes on the message that an event has changed to the currently | 282 | /** passes on the message that an event has changed to the currently |
279 | * activated view so that it can make appropriate display changes. */ | 283 | * activated view so that it can make appropriate display changes. */ |
280 | void changeEventDisplay(Event *, int); | 284 | void changeEventDisplay(Event *, int); |
281 | void changeIncidenceDisplay(Incidence *, int); | 285 | void changeIncidenceDisplay(Incidence *, int); |
282 | void changeTodoDisplay(Todo *, int); | 286 | void changeTodoDisplay(Todo *, int); |
283 | 287 | ||
284 | void eventAdded(Event *); | 288 | void eventAdded(Event *); |
285 | void eventChanged(Event *); | 289 | void eventChanged(Event *); |
286 | void eventToBeDeleted(Event *); | 290 | void eventToBeDeleted(Event *); |
287 | void eventDeleted(); | 291 | void eventDeleted(); |
288 | 292 | ||
289 | void todoAdded(Todo *); | 293 | void todoAdded(Todo *); |
290 | void todoChanged(Todo *); | 294 | void todoChanged(Todo *); |
291 | void todoToBeDeleted(Todo *); | 295 | void todoToBeDeleted(Todo *); |
292 | void todoDeleted(); | 296 | void todoDeleted(); |
293 | 297 | ||
294 | void updateView(const QDate &start, const QDate &end); | 298 | void updateView(const QDate &start, const QDate &end); |
295 | void updateView(); | 299 | void updateView(); |
296 | 300 | ||
297 | /** Full update of visible todo views */ | 301 | /** Full update of visible todo views */ |
298 | void updateTodoViews(); | 302 | void updateTodoViews(); |
299 | 303 | ||
300 | void updateUnmanagedViews(); | 304 | void updateUnmanagedViews(); |
301 | 305 | ||
302 | /** cut the current appointment to the clipboard */ | 306 | /** cut the current appointment to the clipboard */ |
303 | void edit_cut(); | 307 | void edit_cut(); |
304 | 308 | ||
305 | /** copy the current appointment(s) to the clipboard */ | 309 | /** copy the current appointment(s) to the clipboard */ |
306 | void edit_copy(); | 310 | void edit_copy(); |
307 | 311 | ||
308 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 312 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
309 | void edit_paste(); | 313 | void edit_paste(); |
310 | 314 | ||
311 | /** edit viewing and configuration options. */ | 315 | /** edit viewing and configuration options. */ |
312 | void edit_options(); | 316 | void edit_options(); |
313 | void edit_sync_options(); | 317 | void edit_sync_options(); |
314 | /** | 318 | /** |
315 | Functions for printing, previewing a print, and setting up printing | 319 | Functions for printing, previewing a print, and setting up printing |
316 | parameters. | 320 | parameters. |
317 | */ | 321 | */ |
318 | void print(); | 322 | void print(); |
319 | void printSetup(); | 323 | void printSetup(); |
320 | void printPreview(); | 324 | void printPreview(); |
321 | 325 | ||
322 | /** Export as iCalendar file */ | 326 | /** Export as iCalendar file */ |
323 | void exportICalendar(); | 327 | void exportICalendar(); |
324 | 328 | ||
325 | /** Export as vCalendar file */ | 329 | /** Export as vCalendar file */ |
326 | bool exportVCalendar( QString fn); | 330 | bool exportVCalendar( QString fn); |
327 | 331 | ||
328 | /** pop up a dialog to show an existing appointment. */ | 332 | /** pop up a dialog to show an existing appointment. */ |
329 | void appointment_show(); | 333 | void appointment_show(); |
330 | /** | 334 | /** |
331 | * pop up an Appointment Dialog to edit an existing appointment.Get | 335 | * pop up an Appointment Dialog to edit an existing appointment.Get |
332 | * information on the appointment from the list of unique IDs that is | 336 | * information on the appointment from the list of unique IDs that is |
333 | * currently in the View, called currIds. | 337 | * currently in the View, called currIds. |
334 | */ | 338 | */ |
335 | void appointment_edit(); | 339 | void appointment_edit(); |
336 | /** | 340 | /** |
337 | * pop up dialog confirming deletion of currently selected event in the | 341 | * pop up dialog confirming deletion of currently selected event in the |
338 | * View. | 342 | * View. |
339 | */ | 343 | */ |
340 | void appointment_delete(); | 344 | void appointment_delete(); |
341 | 345 | ||
342 | /** mails the currently selected event to a particular user as a vCalendar | 346 | /** mails the currently selected event to a particular user as a vCalendar |
343 | attachment. */ | 347 | attachment. */ |
344 | void action_mail(); | 348 | void action_mail(); |
345 | 349 | ||
346 | /* frees a subtodo from it's relation */ | 350 | /* frees a subtodo from it's relation */ |
347 | void todo_unsub( Todo * ); | 351 | void todo_unsub( Todo * ); |
348 | 352 | ||
349 | /** Take ownership of selected event. */ | 353 | /** Take ownership of selected event. */ |
350 | void takeOverEvent(); | 354 | void takeOverEvent(); |
351 | 355 | ||
352 | /** Take ownership of all events in calendar. */ | 356 | /** Take ownership of all events in calendar. */ |
353 | void takeOverCalendar(); | 357 | void takeOverCalendar(); |
354 | 358 | ||
355 | /** query whether or not the calendar is "dirty". */ | 359 | /** query whether or not the calendar is "dirty". */ |
356 | bool isModified(); | 360 | bool isModified(); |
357 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 361 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
358 | void setModified(bool modified=true); | 362 | void setModified(bool modified=true); |
359 | 363 | ||
360 | /** query if the calendar is read-only. */ | 364 | /** query if the calendar is read-only. */ |
361 | bool isReadOnly(); | 365 | bool isReadOnly(); |
362 | /** set state of calendar to read-only */ | 366 | /** set state of calendar to read-only */ |
363 | void setReadOnly(bool readOnly=true); | 367 | void setReadOnly(bool readOnly=true); |
364 | 368 | ||
365 | void eventUpdated(Incidence *); | 369 | void eventUpdated(Incidence *); |
366 | 370 | ||
367 | /* iTIP scheduling actions */ | 371 | /* iTIP scheduling actions */ |
368 | void schedule_publish(Incidence *incidence = 0); | 372 | void schedule_publish(Incidence *incidence = 0); |
369 | void schedule_request(Incidence *incidence = 0); | 373 | void schedule_request(Incidence *incidence = 0); |
370 | void schedule_refresh(Incidence *incidence = 0); | 374 | void schedule_refresh(Incidence *incidence = 0); |
371 | void schedule_cancel(Incidence *incidence = 0); | 375 | void schedule_cancel(Incidence *incidence = 0); |
372 | void schedule_add(Incidence *incidence = 0); | 376 | void schedule_add(Incidence *incidence = 0); |
373 | void schedule_reply(Incidence *incidence = 0); | 377 | void schedule_reply(Incidence *incidence = 0); |
374 | void schedule_counter(Incidence *incidence = 0); | 378 | void schedule_counter(Incidence *incidence = 0); |
375 | void schedule_declinecounter(Incidence *incidence = 0); | 379 | void schedule_declinecounter(Incidence *incidence = 0); |
376 | void schedule_publish_freebusy(int daysToPublish = 30); | 380 | void schedule_publish_freebusy(int daysToPublish = 30); |
377 | 381 | ||
378 | void openAddressbook(); | 382 | void openAddressbook(); |
379 | 383 | ||
380 | void editFilters(); | 384 | void editFilters(); |
381 | void toggleFilerEnabled(); | 385 | void toggleFilerEnabled(); |
382 | QPtrList<CalFilter> filters(); | 386 | QPtrList<CalFilter> filters(); |
383 | void toggleFilter(); | 387 | void toggleFilter(); |
384 | void showFilter(bool visible); | 388 | void showFilter(bool visible); |
385 | void updateFilter(); | 389 | void updateFilter(); |
386 | void filterEdited(); | 390 | void filterEdited(); |
387 | void selectFilter( int ); | 391 | void selectFilter( int ); |
388 | KOFilterView *filterView(); | 392 | KOFilterView *filterView(); |
389 | 393 | ||
390 | void showIntro(); | 394 | void showIntro(); |
391 | 395 | ||
392 | /** Move the curdatepient view date to today */ | 396 | /** Move the curdatepient view date to today */ |
393 | void goToday(); | 397 | void goToday(); |
394 | 398 | ||
395 | /** Move to the next date(s) in the current view */ | 399 | /** Move to the next date(s) in the current view */ |
396 | void goNext(); | 400 | void goNext(); |
397 | 401 | ||
398 | /** Move to the previous date(s) in the current view */ | 402 | /** Move to the previous date(s) in the current view */ |
399 | void goPrevious(); | 403 | void goPrevious(); |
400 | /** Move to the next date(s) in the current view */ | 404 | /** Move to the next date(s) in the current view */ |
401 | void goNextMonth(); | 405 | void goNextMonth(); |
402 | 406 | ||
403 | /** Move to the previous date(s) in the current view */ | 407 | /** Move to the previous date(s) in the current view */ |
404 | void goPreviousMonth(); | 408 | void goPreviousMonth(); |
405 | 409 | ||
406 | void toggleExpand(); | 410 | void toggleExpand(); |
407 | void toggleDateNavigatorWidget(); | 411 | void toggleDateNavigatorWidget(); |
408 | void toggleAllDaySize(); | 412 | void toggleAllDaySize(); |
409 | void dialogClosing(Incidence *); | 413 | void dialogClosing(Incidence *); |
410 | 414 | ||
411 | /** Look for new messages in the inbox */ | 415 | /** Look for new messages in the inbox */ |
412 | void lookForIncomingMessages(); | 416 | void lookForIncomingMessages(); |
413 | /** Look for new messages in the outbox */ | 417 | /** Look for new messages in the outbox */ |
414 | void lookForOutgoingMessages(); | 418 | void lookForOutgoingMessages(); |
415 | 419 | ||
416 | void processMainViewSelection( Incidence * ); | 420 | void processMainViewSelection( Incidence * ); |
417 | void processTodoListSelection( Incidence * ); | 421 | void processTodoListSelection( Incidence * ); |
418 | 422 | ||
419 | void processIncidenceSelection( Incidence * ); | 423 | void processIncidenceSelection( Incidence * ); |
420 | 424 | ||
421 | void purgeCompleted(); | 425 | void purgeCompleted(); |
422 | bool removeCompletedSubTodos( Todo* ); | 426 | bool removeCompletedSubTodos( Todo* ); |
423 | void slotCalendarChanged(); | 427 | void slotCalendarChanged(); |
424 | bool importBday(); | 428 | bool importBday(); |
425 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 429 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
426 | bool importQtopia( const QString &categoriesFile, | 430 | bool importQtopia( const QString &categoriesFile, |
427 | const QString &datebookFile, | 431 | const QString &datebookFile, |
428 | const QString &tasklistFile ); | 432 | const QString &tasklistFile ); |
429 | void syncSharp( ); | 433 | void syncSharp( ); |
430 | void syncPhone( ); | 434 | void syncPhone( ); |
431 | void syncExternal( int mode ); | 435 | void syncExternal( int mode ); |
432 | void slotSelectPickerDate( QDate ) ; | 436 | void slotSelectPickerDate( QDate ) ; |
433 | void showDatePicker( ) ; | 437 | void showDatePicker( ) ; |
434 | void moveIncidence(Incidence *) ; | 438 | void moveIncidence(Incidence *) ; |
435 | void beamIncidence(Incidence *) ; | 439 | void beamIncidence(Incidence *) ; |
436 | void beamCalendar() ; | 440 | void beamCalendar() ; |
437 | void beamFilteredCalendar() ; | 441 | void beamFilteredCalendar() ; |
438 | void beamIncidenceList(QPtrList<Incidence>) ; | 442 | void beamIncidenceList(QPtrList<Incidence>) ; |
439 | void manageCategories(); | 443 | void manageCategories(); |
440 | int addCategories(); | 444 | int addCategories(); |
441 | void removeCategories(); | 445 | void removeCategories(); |
442 | void setSyncDevice( QString ); | 446 | void setSyncDevice( QString ); |
443 | void setSyncName( QString ); | 447 | void setSyncName( QString ); |
444 | protected slots: | 448 | protected slots: |
445 | void timerAlarm(); | 449 | void timerAlarm(); |
446 | void suspendAlarm(); | 450 | void suspendAlarm(); |
447 | void beamDone( Ir *ir ); | 451 | void beamDone( Ir *ir ); |
448 | /** Select a view or adapt the current view to display the specified dates. */ | 452 | /** Select a view or adapt the current view to display the specified dates. */ |
449 | void showDates( const KCal::DateList & ); | 453 | void showDates( const KCal::DateList & ); |
450 | void selectWeekNum ( int ); | 454 | void selectWeekNum ( int ); |
451 | 455 | ||
452 | public: | 456 | public: |
453 | // show a standard warning | 457 | // show a standard warning |
454 | // returns KMsgBox::yesNoCancel() | 458 | // returns KMsgBox::yesNoCancel() |
455 | int msgCalModified(); | 459 | int msgCalModified(); |
456 | void confSync(); | 460 | void confSync(); |
457 | void setLoadedFileVersion(QDateTime); | 461 | void setLoadedFileVersion(QDateTime); |
458 | bool checkFileVersion(QString fn); | 462 | bool checkFileVersion(QString fn); |
459 | bool checkFileChanged(QString fn); | 463 | bool checkFileChanged(QString fn); |
460 | Event* getLastSyncEvent(); | 464 | Event* getLastSyncEvent(); |
461 | /** Adapt navigation units correpsonding to step size of navigation of the | 465 | /** Adapt navigation units correpsonding to step size of navigation of the |
462 | * current view. | 466 | * current view. |
463 | */ | 467 | */ |
464 | void adaptNavigationUnits(); | 468 | void adaptNavigationUnits(); |
465 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 469 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
466 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 470 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
467 | //Attendee* getYourAttendee(Event *event); | 471 | //Attendee* getYourAttendee(Event *event); |
468 | protected: | 472 | protected: |
469 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 473 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
470 | 474 | ||
471 | // returns KMsgBox::OKCandel() | 475 | // returns KMsgBox::OKCandel() |
472 | int msgItemDelete(); | 476 | int msgItemDelete(); |
473 | void showEventEditor(); | 477 | void showEventEditor(); |
474 | void showTodoEditor(); | 478 | void showTodoEditor(); |
475 | void writeLocale(); | 479 | void writeLocale(); |
476 | Todo *selectedTodo(); | 480 | Todo *selectedTodo(); |
477 | 481 | ||
478 | private: | 482 | private: |
479 | AlarmDialog * mAlarmDialog; | 483 | AlarmDialog * mAlarmDialog; |
480 | QString mAlarmNotification; | 484 | QString mAlarmNotification; |
481 | QString mSuspendAlarmNotification; | 485 | QString mSuspendAlarmNotification; |
482 | QTimer* mSuspendTimer; | 486 | QTimer* mSuspendTimer; |
483 | QTimer* mAlarmTimer; | 487 | QTimer* mAlarmTimer; |
484 | QTimer* mRecheckAlarmTimer; | 488 | QTimer* mRecheckAlarmTimer; |
485 | void computeAlarm( QString ); | 489 | void computeAlarm( QString ); |
486 | void startAlarm( QString, QString ); | 490 | void startAlarm( QString, QString ); |
487 | void setSyncEventsReadOnly(); | 491 | void setSyncEventsReadOnly(); |
488 | 492 | ||
489 | QDateTime loadedFileVersion; | 493 | QDateTime loadedFileVersion; |
490 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 494 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
491 | void checkExternalId( Incidence * inc ); | 495 | void checkExternalId( Incidence * inc ); |
492 | int mGlobalSyncMode; | 496 | int mGlobalSyncMode; |
493 | QString mCurrentSyncDevice; | 497 | QString mCurrentSyncDevice; |
494 | QString mCurrentSyncName; | 498 | QString mCurrentSyncName; |
495 | KOBeamPrefs* beamDialog; | 499 | KOBeamPrefs* beamDialog; |
496 | void init(); | 500 | void init(); |
497 | int mDatePickerMode; | 501 | int mDatePickerMode; |
498 | bool mFlagEditDescription; | 502 | bool mFlagEditDescription; |
499 | QDateTime mLastCalendarSync; | 503 | QDateTime mLastCalendarSync; |
500 | void createPrinter(); | 504 | void createPrinter(); |
501 | 505 | ||
502 | void calendarModified( bool, Calendar * ); | 506 | void calendarModified( bool, Calendar * ); |
503 | 507 | ||
504 | CalPrinter *mCalPrinter; | 508 | CalPrinter *mCalPrinter; |
505 | 509 | ||
506 | QSplitter *mPanner; | 510 | QSplitter *mPanner; |
507 | QSplitter *mLeftSplitter; | 511 | QSplitter *mLeftSplitter; |
508 | QWidget *mLeftFrame; | 512 | QWidget *mLeftFrame; |
509 | QWidgetStack *mRightFrame; | 513 | QWidgetStack *mRightFrame; |
510 | 514 | ||
511 | KDatePicker* mDatePicker; | 515 | KDatePicker* mDatePicker; |
512 | QVBox* mDateFrame; | 516 | QVBox* mDateFrame; |
513 | NavigatorBar *mNavigatorBar; | 517 | NavigatorBar *mNavigatorBar; |
514 | 518 | ||
515 | KDateNavigator *mDateNavigator; // widget showing small month view. | 519 | KDateNavigator *mDateNavigator; // widget showing small month view. |
516 | 520 | ||
517 | KOFilterView *mFilterView; | 521 | KOFilterView *mFilterView; |
518 | 522 | ||
519 | ResourceView *mResourceView; | 523 | ResourceView *mResourceView; |
520 | 524 | ||
521 | // calendar object for this viewing instance | 525 | // calendar object for this viewing instance |
522 | Calendar *mCalendar; | 526 | Calendar *mCalendar; |
523 | 527 | ||
524 | CalendarResourceManager *mResourceManager; | 528 | CalendarResourceManager *mResourceManager; |
525 | 529 | ||
526 | FileStorage *mStorage; | 530 | FileStorage *mStorage; |
527 | 531 | ||
528 | DateNavigator *mNavigator; | 532 | DateNavigator *mNavigator; |
529 | 533 | ||
530 | KOViewManager *mViewManager; | 534 | KOViewManager *mViewManager; |
531 | KODialogManager *mDialogManager; | 535 | KODialogManager *mDialogManager; |
532 | 536 | ||
533 | // Calendar filters | 537 | // Calendar filters |
534 | QPtrList<CalFilter> mFilters; | 538 | QPtrList<CalFilter> mFilters; |
535 | 539 | ||
536 | // various housekeeping variables. | 540 | // various housekeeping variables. |
537 | bool mModified; // flag indicating if calendar is modified | 541 | bool mModified; // flag indicating if calendar is modified |
538 | bool mReadOnly; // flag indicating if calendar is read-only | 542 | bool mReadOnly; // flag indicating if calendar is read-only |
539 | QDate mSaveSingleDate; | 543 | QDate mSaveSingleDate; |
540 | 544 | ||
541 | Incidence *mSelectedIncidence; | 545 | Incidence *mSelectedIncidence; |
542 | Incidence *mMoveIncidence; | 546 | Incidence *mMoveIncidence; |
543 | QPtrList<Event> mExternLastSyncEvent; | 547 | QPtrList<Event> mExternLastSyncEvent; |
544 | KOTodoView *mTodoList; | 548 | KOTodoView *mTodoList; |
545 | KOEventEditor * mEventEditor; | 549 | KOEventEditor * mEventEditor; |
546 | KOTodoEditor * mTodoEditor; | 550 | KOTodoEditor * mTodoEditor; |
547 | KOEventViewerDialog * mEventViewerDialog; | 551 | KOEventViewerDialog * mEventViewerDialog; |
548 | void keyPressEvent ( QKeyEvent *e) ; | 552 | void keyPressEvent ( QKeyEvent *e) ; |
549 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 553 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
550 | }; | 554 | }; |
551 | 555 | ||
552 | 556 | ||
553 | class CalendarViewVisitor : public Incidence::Visitor | 557 | class CalendarViewVisitor : public Incidence::Visitor |
554 | { | 558 | { |
555 | public: | 559 | public: |
556 | CalendarViewVisitor() : mView( 0 ) {} | 560 | CalendarViewVisitor() : mView( 0 ) {} |
557 | 561 | ||
558 | bool act( Incidence *incidence, CalendarView *view ) | 562 | bool act( Incidence *incidence, CalendarView *view ) |
559 | { | 563 | { |
560 | mView = view; | 564 | mView = view; |
561 | return incidence->accept( *this ); | 565 | return incidence->accept( *this ); |
562 | } | 566 | } |
563 | 567 | ||
564 | protected: | 568 | protected: |
565 | CalendarView *mView; | 569 | CalendarView *mView; |
566 | }; | 570 | }; |
567 | 571 | ||
568 | class ShowIncidenceVisitor : public CalendarViewVisitor | 572 | class ShowIncidenceVisitor : public CalendarViewVisitor |
569 | { | 573 | { |
570 | protected: | 574 | protected: |
571 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 575 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
572 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 576 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
573 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 577 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
574 | }; | 578 | }; |
575 | 579 | ||
576 | class EditIncidenceVisitor : public CalendarViewVisitor | 580 | class EditIncidenceVisitor : public CalendarViewVisitor |
577 | { | 581 | { |
578 | protected: | 582 | protected: |
579 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 583 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
580 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 584 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
581 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 585 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
582 | }; | 586 | }; |
583 | 587 | ||
584 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 588 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
585 | { | 589 | { |
586 | protected: | 590 | protected: |
587 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 591 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
588 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 592 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
589 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 593 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
590 | }; | 594 | }; |
591 | 595 | ||
592 | #endif | 596 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 6a9a2f1..bd14fbf 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1,2645 +1,2668 @@ | |||
1 | #include <stdlib.h> | 1 | #include <stdlib.h> |
2 | 2 | ||
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qpainter.h> | 5 | #include <qpainter.h> |
6 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
9 | #include <qlineedit.h> | 9 | #include <qlineedit.h> |
10 | #include <qtextcodec.h> | 10 | #include <qtextcodec.h> |
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qdir.h> | 12 | #include <qdir.h> |
13 | #include <qapp.h> | 13 | #include <qapp.h> |
14 | #include <qfileinfo.h> | 14 | #include <qfileinfo.h> |
15 | #include <qlabel.h> | 15 | #include <qlabel.h> |
16 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
18 | #include <qmap.h> | 18 | #include <qmap.h> |
19 | #include <qwmatrix.h> | 19 | #include <qwmatrix.h> |
20 | #include <qtextbrowser.h> | 20 | #include <qtextbrowser.h> |
21 | #include <qtextstream.h> | 21 | #include <qtextstream.h> |
22 | #ifndef DESKTOP_VERSION | 22 | #ifndef DESKTOP_VERSION |
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
25 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qtopia/alarmserver.h> | 28 | #include <qtopia/alarmserver.h> |
29 | #include <qtopia/qcopenvelope_qws.h> | 29 | #include <qtopia/qcopenvelope_qws.h> |
30 | #include <unistd.h> // for sleep | 30 | #include <unistd.h> // for sleep |
31 | #else | 31 | #else |
32 | #include <qmenubar.h> | 32 | #include <qmenubar.h> |
33 | #include <qtoolbar.h> | 33 | #include <qtoolbar.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | //#include <resource.h> | 35 | //#include <resource.h> |
36 | 36 | ||
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendarlocal.h> | 38 | #include <libkcal/calendarlocal.h> |
39 | #include <libkcal/todo.h> | 39 | #include <libkcal/todo.h> |
40 | #include <libkcal/phoneformat.h> | 40 | #include <libkcal/phoneformat.h> |
41 | #include <libkdepim/ksyncprofile.h> | 41 | #include <libkdepim/ksyncprofile.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | #include <libkdepim/kpimglobalprefs.h> | 43 | #include <libkdepim/kpimglobalprefs.h> |
44 | 44 | ||
45 | #include "calendarview.h" | 45 | #include "calendarview.h" |
46 | #include "koviewmanager.h" | 46 | #include "koviewmanager.h" |
47 | #include "datenavigator.h" | 47 | #include "datenavigator.h" |
48 | #include "koagendaview.h" | 48 | #include "koagendaview.h" |
49 | #include "koagenda.h" | 49 | #include "koagenda.h" |
50 | #include "kodialogmanager.h" | 50 | #include "kodialogmanager.h" |
51 | #include "kdialogbase.h" | 51 | #include "kdialogbase.h" |
52 | #include "kapplication.h" | 52 | #include "kapplication.h" |
53 | #include "kofilterview.h" | 53 | #include "kofilterview.h" |
54 | #include "kstandarddirs.h" | 54 | #include "kstandarddirs.h" |
55 | #include "koprefs.h" | 55 | #include "koprefs.h" |
56 | #include "kfiledialog.h" | 56 | #include "kfiledialog.h" |
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #include "kglobal.h" | 58 | #include "kglobal.h" |
59 | #include "klocale.h" | 59 | #include "klocale.h" |
60 | #include "kconfig.h" | 60 | #include "kconfig.h" |
61 | #include "simplealarmclient.h" | 61 | #include "simplealarmclient.h" |
62 | #include "externalapphandler.h" | 62 | #include "externalapphandler.h" |
63 | 63 | ||
64 | using namespace KCal; | 64 | using namespace KCal; |
65 | #ifndef _WIN32_ | 65 | #ifndef _WIN32_ |
66 | #include <unistd.h> | 66 | #include <unistd.h> |
67 | #else | 67 | #else |
68 | #include "koimportoldialog.h" | 68 | #include "koimportoldialog.h" |
69 | #endif | 69 | #endif |
70 | #include "mainwindow.h" | 70 | #include "mainwindow.h" |
71 | 71 | ||
72 | class KOex2phonePrefs : public QDialog | 72 | class KOex2phonePrefs : public QDialog |
73 | { | 73 | { |
74 | public: | 74 | public: |
75 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : | 75 | KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : |
76 | QDialog( parent, name, true ) | 76 | QDialog( parent, name, true ) |
77 | { | 77 | { |
78 | setCaption( i18n("Export to phone options") ); | 78 | setCaption( i18n("Export to phone options") ); |
79 | QVBoxLayout* lay = new QVBoxLayout( this ); | 79 | QVBoxLayout* lay = new QVBoxLayout( this ); |
80 | lay->setSpacing( 3 ); | 80 | lay->setSpacing( 3 ); |
81 | lay->setMargin( 3 ); | 81 | lay->setMargin( 3 ); |
82 | QLabel *lab; | 82 | QLabel *lab; |
83 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); | 83 | lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); |
84 | lab->setAlignment (AlignHCenter ); | 84 | lab->setAlignment (AlignHCenter ); |
85 | QHBox* temphb; | 85 | QHBox* temphb; |
86 | temphb = new QHBox( this ); | 86 | temphb = new QHBox( this ); |
87 | new QLabel( i18n("I/O device: "), temphb ); | 87 | new QLabel( i18n("I/O device: "), temphb ); |
88 | mPhoneDevice = new QLineEdit( temphb); | 88 | mPhoneDevice = new QLineEdit( temphb); |
89 | lay->addWidget( temphb ); | 89 | lay->addWidget( temphb ); |
90 | temphb = new QHBox( this ); | 90 | temphb = new QHBox( this ); |
91 | new QLabel( i18n("Connection: "), temphb ); | 91 | new QLabel( i18n("Connection: "), temphb ); |
92 | mPhoneConnection = new QLineEdit( temphb); | 92 | mPhoneConnection = new QLineEdit( temphb); |
93 | lay->addWidget( temphb ); | 93 | lay->addWidget( temphb ); |
94 | temphb = new QHBox( this ); | 94 | temphb = new QHBox( this ); |
95 | new QLabel( i18n("Model(opt.): "), temphb ); | 95 | new QLabel( i18n("Model(opt.): "), temphb ); |
96 | mPhoneModel = new QLineEdit( temphb); | 96 | mPhoneModel = new QLineEdit( temphb); |
97 | lay->addWidget( temphb ); | 97 | lay->addWidget( temphb ); |
98 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); | 98 | mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); |
99 | mWriteBackFuture->setChecked( true ); | 99 | mWriteBackFuture->setChecked( true ); |
100 | lay->addWidget( mWriteBackFuture ); | 100 | lay->addWidget( mWriteBackFuture ); |
101 | temphb = new QHBox( this ); | 101 | temphb = new QHBox( this ); |
102 | new QLabel( i18n("Max. weeks in future: ") , temphb ); | 102 | new QLabel( i18n("Max. weeks in future: ") , temphb ); |
103 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); | 103 | mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); |
104 | mWriteBackFutureWeeks->setValue( 8 ); | 104 | mWriteBackFutureWeeks->setValue( 8 ); |
105 | lay->addWidget( temphb ); | 105 | lay->addWidget( temphb ); |
106 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\n todo/calendar data on phone!"), this ) ); | 106 | lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\n todo/calendar data on phone!"), this ) ); |
107 | lab->setAlignment (AlignHCenter ); | 107 | lab->setAlignment (AlignHCenter ); |
108 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); | 108 | QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); |
109 | lay->addWidget( ok ); | 109 | lay->addWidget( ok ); |
110 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 110 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
111 | lay->addWidget( cancel ); | 111 | lay->addWidget( cancel ); |
112 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 112 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
113 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 113 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
114 | resize( 220, 240 ); | 114 | resize( 220, 240 ); |
115 | 115 | ||
116 | } | 116 | } |
117 | 117 | ||
118 | public: | 118 | public: |
119 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; | 119 | QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; |
120 | QCheckBox* mWriteBackFuture; | 120 | QCheckBox* mWriteBackFuture; |
121 | QSpinBox* mWriteBackFutureWeeks; | 121 | QSpinBox* mWriteBackFutureWeeks; |
122 | }; | 122 | }; |
123 | 123 | ||
124 | int globalFlagBlockStartup; | 124 | int globalFlagBlockStartup; |
125 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : | 125 | MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : |
126 | QMainWindow( parent, name ) | 126 | QMainWindow( parent, name ) |
127 | { | 127 | { |
128 | mPassWordPiSync = "abc"; | 128 | mPassWordPiSync = "abc"; |
129 | #ifdef DESKTOP_VERSION | 129 | #ifdef DESKTOP_VERSION |
130 | setFont( QFont("Arial"), 14 ); | 130 | setFont( QFont("Arial"), 14 ); |
131 | #endif | 131 | #endif |
132 | mSyncActionDialog = 0; | 132 | mSyncActionDialog = 0; |
133 | mServerSocket = 0; | 133 | mServerSocket = 0; |
134 | mClosed = false; | 134 | mClosed = false; |
135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; | 135 | //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; |
136 | QString confFile = locateLocal("config","korganizerrc"); | 136 | QString confFile = locateLocal("config","korganizerrc"); |
137 | QFileInfo finf ( confFile ); | 137 | QFileInfo finf ( confFile ); |
138 | bool showWarning = !finf.exists(); | 138 | bool showWarning = !finf.exists(); |
139 | setIcon(SmallIcon( "ko24" ) ); | 139 | setIcon(SmallIcon( "ko24" ) ); |
140 | mBlockAtStartup = true; | 140 | mBlockAtStartup = true; |
141 | mFlagKeyPressed = false; | 141 | mFlagKeyPressed = false; |
142 | setCaption("KOrganizer/Pi"); | 142 | setCaption("KOrganizer/Pi"); |
143 | KOPrefs *p = KOPrefs::instance(); | 143 | KOPrefs *p = KOPrefs::instance(); |
144 | KPimGlobalPrefs::instance()->setGlobalConfig(); | 144 | KPimGlobalPrefs::instance()->setGlobalConfig(); |
145 | // if ( QApplication::desktop()->height() > 480 ) { | 145 | // if ( QApplication::desktop()->height() > 480 ) { |
146 | // if ( p->mHourSize == 4 ) | 146 | // if ( p->mHourSize == 4 ) |
147 | // p->mHourSize = 6; | 147 | // p->mHourSize = 6; |
148 | // } | 148 | // } |
149 | if ( p->mHourSize > 18 ) | 149 | if ( p->mHourSize > 18 ) |
150 | p->mHourSize = 18; | 150 | p->mHourSize = 18; |
151 | QMainWindow::ToolBarDock tbd; | 151 | QMainWindow::ToolBarDock tbd; |
152 | if ( p->mToolBarHor ) { | 152 | if ( p->mToolBarHor ) { |
153 | if ( p->mToolBarUp ) | 153 | if ( p->mToolBarUp ) |
154 | tbd = Bottom; | 154 | tbd = Bottom; |
155 | else | 155 | else |
156 | tbd = Top; | 156 | tbd = Top; |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | if ( p->mToolBarUp ) | 159 | if ( p->mToolBarUp ) |
160 | tbd = Right; | 160 | tbd = Right; |
161 | else | 161 | else |
162 | tbd = Left; | 162 | tbd = Left; |
163 | } | 163 | } |
164 | if ( KOPrefs::instance()->mUseAppColors ) | 164 | if ( KOPrefs::instance()->mUseAppColors ) |
165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 165 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
166 | globalFlagBlockStartup = 1; | 166 | globalFlagBlockStartup = 1; |
167 | iconToolBar = new QPEToolBar( this ); | 167 | iconToolBar = new QPEToolBar( this ); |
168 | addToolBar (iconToolBar , tbd ); | 168 | addToolBar (iconToolBar , tbd ); |
169 | mBlockSaveFlag = false; | 169 | mBlockSaveFlag = false; |
170 | mCalendarModifiedFlag = false; | 170 | mCalendarModifiedFlag = false; |
171 | 171 | ||
172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); | 172 | QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); |
173 | splash->setAlignment ( AlignCenter ); | 173 | splash->setAlignment ( AlignCenter ); |
174 | setCentralWidget( splash ); | 174 | setCentralWidget( splash ); |
175 | #ifndef DESKTOP_VERSION | 175 | #ifndef DESKTOP_VERSION |
176 | showMaximized(); | 176 | showMaximized(); |
177 | #endif | 177 | #endif |
178 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); | 178 | //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); |
179 | setDefaultPreferences(); | 179 | setDefaultPreferences(); |
180 | mCalendar = new CalendarLocal(); | 180 | mCalendar = new CalendarLocal(); |
181 | mView = new CalendarView( mCalendar, this,"mCalendar " ); | 181 | mView = new CalendarView( mCalendar, this,"mCalendar " ); |
182 | mView->hide(); | 182 | mView->hide(); |
183 | //mView->resize(splash->size() ); | 183 | //mView->resize(splash->size() ); |
184 | initActions(); | 184 | initActions(); |
185 | #ifndef DESKTOP_VERSION | 185 | #ifndef DESKTOP_VERSION |
186 | iconToolBar->show(); | 186 | iconToolBar->show(); |
187 | qApp->processEvents(); | 187 | qApp->processEvents(); |
188 | #endif | 188 | #endif |
189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); | 189 | //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); |
190 | int vh = height() ; | 190 | int vh = height() ; |
191 | int vw = width(); | 191 | int vw = width(); |
192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); | 192 | //qDebug("Toolbar hei %d ",iconToolBar->height() ); |
193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { | 193 | if ( iconToolBar->orientation () == Qt:: Horizontal ) { |
194 | vh -= iconToolBar->height(); | 194 | vh -= iconToolBar->height(); |
195 | } else { | 195 | } else { |
196 | vw -= iconToolBar->height(); | 196 | vw -= iconToolBar->height(); |
197 | } | 197 | } |
198 | //mView->setMaximumSize( splash->size() ); | 198 | //mView->setMaximumSize( splash->size() ); |
199 | //mView->resize( splash->size() ); | 199 | //mView->resize( splash->size() ); |
200 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 200 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
201 | mView->readSettings(); | 201 | mView->readSettings(); |
202 | bool newFile = false; | 202 | bool newFile = false; |
203 | if( !QFile::exists( defaultFileName() ) ) { | 203 | if( !QFile::exists( defaultFileName() ) ) { |
204 | QFileInfo finfo ( defaultFileName() ); | 204 | QFileInfo finfo ( defaultFileName() ); |
205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); | 205 | QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); |
206 | qDebug("oldfile %s ", oldFile.latin1()); | 206 | qDebug("oldfile %s ", oldFile.latin1()); |
207 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; | 207 | QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; |
208 | finfo.setFile( oldFile ); | 208 | finfo.setFile( oldFile ); |
209 | if (finfo.exists() ) { | 209 | if (finfo.exists() ) { |
210 | KMessageBox::information( this, message); | 210 | KMessageBox::information( this, message); |
211 | mView->openCalendar( oldFile ); | 211 | mView->openCalendar( oldFile ); |
212 | qApp->processEvents(); | 212 | qApp->processEvents(); |
213 | } else { | 213 | } else { |
214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); | 214 | oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); |
215 | finfo.setFile( oldFile ); | 215 | finfo.setFile( oldFile ); |
216 | if (finfo.exists() ) { | 216 | if (finfo.exists() ) { |
217 | KMessageBox::information( this, message); | 217 | KMessageBox::information( this, message); |
218 | mView->openCalendar( oldFile ); | 218 | mView->openCalendar( oldFile ); |
219 | qApp->processEvents(); | 219 | qApp->processEvents(); |
220 | } | 220 | } |
221 | } | 221 | } |
222 | mView->saveCalendar( defaultFileName() ); | 222 | mView->saveCalendar( defaultFileName() ); |
223 | newFile = true; | 223 | newFile = true; |
224 | } | 224 | } |
225 | 225 | ||
226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 226 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
227 | mView->openCalendar( defaultFileName() ); | 227 | mView->openCalendar( defaultFileName() ); |
228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 228 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); | 229 | qDebug("KO: Calendar loading time: %d ms",msNeeded ); |
230 | 230 | ||
231 | if ( KOPrefs::instance()->mLanguageChanged ) { | 231 | if ( KOPrefs::instance()->mLanguageChanged ) { |
232 | KOPrefs::instance()->setCategoryDefaults(); | 232 | KOPrefs::instance()->setCategoryDefaults(); |
233 | int count = mView->addCategories(); | 233 | int count = mView->addCategories(); |
234 | KOPrefs::instance()->mLanguageChanged = false; | 234 | KOPrefs::instance()->mLanguageChanged = false; |
235 | } | 235 | } |
236 | processIncidenceSelection( 0 ); | 236 | processIncidenceSelection( 0 ); |
237 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), | 237 | connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), |
238 | SLOT( processIncidenceSelection( Incidence * ) ) ); | 238 | SLOT( processIncidenceSelection( Incidence * ) ) ); |
239 | connect( mView, SIGNAL( modifiedChanged( bool ) ), | 239 | connect( mView, SIGNAL( modifiedChanged( bool ) ), |
240 | SLOT( slotModifiedChanged( bool ) ) ); | 240 | SLOT( slotModifiedChanged( bool ) ) ); |
241 | 241 | ||
242 | 242 | ||
243 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); | 243 | connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); |
244 | mView->setModified( false ); | 244 | mView->setModified( false ); |
245 | mBlockAtStartup = false; | 245 | mBlockAtStartup = false; |
246 | mView->setModified( false ); | 246 | mView->setModified( false ); |
247 | setCentralWidget( mView ); | 247 | setCentralWidget( mView ); |
248 | globalFlagBlockStartup = 0; | 248 | globalFlagBlockStartup = 0; |
249 | mView->show(); | 249 | mView->show(); |
250 | delete splash; | 250 | delete splash; |
251 | if ( newFile ) | 251 | if ( newFile ) |
252 | mView->updateConfig(); | 252 | mView->updateConfig(); |
253 | // qApp->processEvents(); | 253 | // qApp->processEvents(); |
254 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); | 254 | //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); |
255 | fillSyncMenu(); | 255 | fillSyncMenu(); |
256 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); | 256 | mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); |
257 | if ( showWarning ) { | 257 | if ( showWarning ) { |
258 | KMessageBox::information( this, | 258 | KMessageBox::information( this, |
259 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); | 259 | "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); |
260 | qApp->processEvents(); | 260 | qApp->processEvents(); |
261 | mView->dialogManager()->showSyncOptions(); | 261 | mView->dialogManager()->showSyncOptions(); |
262 | } | 262 | } |
263 | 263 | ||
264 | //US listen for result adressed from Ka/Pi | 264 | //US listen for result adressed from Ka/Pi |
265 | #ifndef DESKTOP_VERSION | 265 | #ifndef DESKTOP_VERSION |
266 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); | 266 | connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); |
267 | #endif | 267 | #endif |
268 | } | 268 | } |
269 | MainWindow::~MainWindow() | 269 | MainWindow::~MainWindow() |
270 | { | 270 | { |
271 | //qDebug("MainWindow::~MainWindow() "); | 271 | //qDebug("MainWindow::~MainWindow() "); |
272 | //save toolbar location | 272 | //save toolbar location |
273 | delete mServerSocket; | 273 | delete mServerSocket; |
274 | delete mCalendar; | 274 | delete mCalendar; |
275 | delete KOPrefs::instance(); | 275 | delete KOPrefs::instance(); |
276 | delete KIncidenceFormatter::instance(); | 276 | delete KIncidenceFormatter::instance(); |
277 | 277 | ||
278 | 278 | ||
279 | } | 279 | } |
280 | void MainWindow::showMaximized () | 280 | void MainWindow::showMaximized () |
281 | { | 281 | { |
282 | #ifndef DESKTOP_VERSION | 282 | #ifndef DESKTOP_VERSION |
283 | if ( ! globalFlagBlockStartup ) | 283 | if ( ! globalFlagBlockStartup ) |
284 | if ( mClosed ) | 284 | if ( mClosed ) |
285 | mView->goToday(); | 285 | mView->goToday(); |
286 | #endif | 286 | #endif |
287 | QWidget::showMaximized () ; | 287 | QWidget::showMaximized () ; |
288 | mClosed = false; | 288 | mClosed = false; |
289 | } | 289 | } |
290 | void MainWindow::closeEvent( QCloseEvent* ce ) | 290 | void MainWindow::closeEvent( QCloseEvent* ce ) |
291 | { | 291 | { |
292 | 292 | ||
293 | 293 | ||
294 | 294 | ||
295 | if ( ! KOPrefs::instance()->mAskForQuit ) { | 295 | if ( ! KOPrefs::instance()->mAskForQuit ) { |
296 | saveOnClose(); | 296 | saveOnClose(); |
297 | mClosed = true; | 297 | mClosed = true; |
298 | ce->accept(); | 298 | ce->accept(); |
299 | return; | 299 | return; |
300 | 300 | ||
301 | } | 301 | } |
302 | 302 | ||
303 | switch( QMessageBox::information( this, "KO/Pi", | 303 | switch( QMessageBox::information( this, "KO/Pi", |
304 | i18n("Do you really want\nto close KO/Pi?"), | 304 | i18n("Do you really want\nto close KO/Pi?"), |
305 | i18n("Close"), i18n("No"), | 305 | i18n("Close"), i18n("No"), |
306 | 0, 0 ) ) { | 306 | 0, 0 ) ) { |
307 | case 0: | 307 | case 0: |
308 | saveOnClose(); | 308 | saveOnClose(); |
309 | mClosed = true; | 309 | mClosed = true; |
310 | ce->accept(); | 310 | ce->accept(); |
311 | break; | 311 | break; |
312 | case 1: | 312 | case 1: |
313 | ce->ignore(); | 313 | ce->ignore(); |
314 | break; | 314 | break; |
315 | case 2: | 315 | case 2: |
316 | 316 | ||
317 | default: | 317 | default: |
318 | break; | 318 | break; |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | } | 322 | } |
323 | 323 | ||
324 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 324 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
325 | { | 325 | { |
326 | QDataStream stream( data, IO_ReadOnly ); | 326 | QDataStream stream( data, IO_ReadOnly ); |
327 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 327 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
328 | //QString datamess; | 328 | //QString datamess; |
329 | //qDebug("message "); | 329 | //qDebug("message "); |
330 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 330 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
331 | 331 | ||
332 | if ( cmsg == "-writeFile" ) { | 332 | if ( cmsg == "-writeFile" ) { |
333 | // I made from the "-writeFile" an "-writeAlarm" | 333 | // I made from the "-writeFile" an "-writeAlarm" |
334 | mView->viewManager()->showWhatsNextView(); | 334 | mView->viewManager()->showWhatsNextView(); |
335 | mCalendar->checkAlarmForIncidence( 0, true); | 335 | mCalendar->checkAlarmForIncidence( 0, true); |
336 | showMaximized(); | 336 | showMaximized(); |
337 | raise(); | 337 | raise(); |
338 | return; | 338 | return; |
339 | } | 339 | } |
340 | 340 | ||
341 | if ( cmsg == "-writeFile" ) { | 341 | if ( cmsg == "-writeFile" ) { |
342 | // I made from the "-writeFile" an "-writeAlarm" | 342 | // I made from the "-writeFile" an "-writeAlarm" |
343 | mView->viewManager()->showWhatsNextView(); | 343 | mView->viewManager()->showWhatsNextView(); |
344 | mCalendar->checkAlarmForIncidence( 0, true); | 344 | mCalendar->checkAlarmForIncidence( 0, true); |
345 | showMaximized(); | 345 | showMaximized(); |
346 | raise(); | 346 | raise(); |
347 | return; | 347 | return; |
348 | 348 | ||
349 | } | 349 | } |
350 | if ( cmsg == "-writeFileSilent" ) { | 350 | if ( cmsg == "-writeFileSilent" ) { |
351 | // I made from the "-writeFile" an "-writeAlarm" | 351 | // I made from the "-writeFile" an "-writeAlarm" |
352 | // mView->viewManager()->showWhatsNextView(); | 352 | // mView->viewManager()->showWhatsNextView(); |
353 | mCalendar->checkAlarmForIncidence( 0, true); | 353 | mCalendar->checkAlarmForIncidence( 0, true); |
354 | //showMaximized(); | 354 | //showMaximized(); |
355 | //raise(); | 355 | //raise(); |
356 | hide(); | 356 | hide(); |
357 | return; | 357 | return; |
358 | } | 358 | } |
359 | if ( cmsg == "-newCountdown" ) { | 359 | if ( cmsg == "-newCountdown" ) { |
360 | qDebug("newCountdown "); | 360 | qDebug("newCountdown "); |
361 | 361 | ||
362 | } | 362 | } |
363 | QString msg ; | 363 | QString msg ; |
364 | QString allmsg = cmsg; | 364 | QString allmsg = cmsg; |
365 | while ( allmsg.length() > 0 ) { | 365 | while ( allmsg.length() > 0 ) { |
366 | int nextC = allmsg.find( "-", 1 ); | 366 | int nextC = allmsg.find( "-", 1 ); |
367 | if ( nextC == -1 ) { | 367 | if ( nextC == -1 ) { |
368 | msg = allmsg; | 368 | msg = allmsg; |
369 | allmsg = ""; | 369 | allmsg = ""; |
370 | } else{ | 370 | } else{ |
371 | msg = allmsg.left( nextC ); | 371 | msg = allmsg.left( nextC ); |
372 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 372 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
373 | } | 373 | } |
374 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 374 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
375 | if ( msg == "-newEvent" ) { | 375 | if ( msg == "-newEvent" ) { |
376 | mView->newEvent(); | 376 | mView->newEvent(); |
377 | } | 377 | } |
378 | if ( msg == "-newTodo" ) { | 378 | if ( msg == "-newTodo" ) { |
379 | mView->newTodo(); | 379 | mView->newTodo(); |
380 | 380 | ||
381 | } | 381 | } |
382 | if ( msg == "-showWN" ) { | 382 | if ( msg == "-showWN" ) { |
383 | mView->viewManager()->showWhatsNextView(); | 383 | mView->viewManager()->showWhatsNextView(); |
384 | } | 384 | } |
385 | if ( msg == "-showTodo" ) { | 385 | if ( msg == "-showTodo" ) { |
386 | mView->viewManager()->showTodoView(); | 386 | mView->viewManager()->showTodoView(); |
387 | } | 387 | } |
388 | if ( msg == "-showList" ) { | 388 | if ( msg == "-showList" ) { |
389 | mView->viewManager()->showListView(); | 389 | mView->viewManager()->showListView(); |
390 | } | 390 | } |
391 | else if ( msg == "-showDay" ) { | 391 | else if ( msg == "-showDay" ) { |
392 | mView->viewManager()->showDayView(); | 392 | mView->viewManager()->showDayView(); |
393 | } | 393 | } |
394 | else if ( msg == "-showWWeek" ) { | 394 | else if ( msg == "-showWWeek" ) { |
395 | mView->viewManager()->showWorkWeekView(); | 395 | mView->viewManager()->showWorkWeekView(); |
396 | } | 396 | } |
397 | else if ( msg == "-ringSync" ) { | 397 | else if ( msg == "-ringSync" ) { |
398 | multiSync( false ); | 398 | multiSync( false ); |
399 | } | 399 | } |
400 | else if ( msg == "-showWeek" ) { | 400 | else if ( msg == "-showWeek" ) { |
401 | mView->viewManager()->showWeekView(); | 401 | mView->viewManager()->showWeekView(); |
402 | } | 402 | } |
403 | else if ( msg == "-showTodo" ) { | 403 | else if ( msg == "-showTodo" ) { |
404 | mView->viewManager()->showTodoView(); | 404 | mView->viewManager()->showTodoView(); |
405 | } | 405 | } |
406 | else if ( msg == "-showJournal" ) { | 406 | else if ( msg == "-showJournal" ) { |
407 | mView->dateNavigator()->selectDates( 1 ); | 407 | mView->dateNavigator()->selectDates( 1 ); |
408 | mView->dateNavigator()->selectToday(); | 408 | mView->dateNavigator()->selectToday(); |
409 | mView->viewManager()->showJournalView(); | 409 | mView->viewManager()->showJournalView(); |
410 | } | 410 | } |
411 | else if ( msg == "-showKO" ) { | 411 | else if ( msg == "-showKO" ) { |
412 | mView->viewManager()->showNextXView(); | 412 | mView->viewManager()->showNextXView(); |
413 | } | 413 | } |
414 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 414 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
415 | mView->viewManager()->showWhatsNextView(); | 415 | mView->viewManager()->showWhatsNextView(); |
416 | } | 416 | } |
417 | else if ( msg == "-showNextXView" ) { | 417 | else if ( msg == "-showNextXView" ) { |
418 | mView->viewManager()->showNextXView(); | 418 | mView->viewManager()->showNextXView(); |
419 | } | 419 | } |
420 | 420 | ||
421 | 421 | ||
422 | } | 422 | } |
423 | 423 | ||
424 | showMaximized(); | 424 | showMaximized(); |
425 | raise(); | 425 | raise(); |
426 | } | 426 | } |
427 | 427 | ||
428 | QPixmap MainWindow::loadPixmap( QString name ) | 428 | QPixmap MainWindow::loadPixmap( QString name ) |
429 | { | 429 | { |
430 | return SmallIcon( name ); | 430 | return SmallIcon( name ); |
431 | 431 | ||
432 | } | 432 | } |
433 | void MainWindow::initActions() | 433 | void MainWindow::initActions() |
434 | { | 434 | { |
435 | //KOPrefs::instance()->mShowFullMenu | 435 | //KOPrefs::instance()->mShowFullMenu |
436 | iconToolBar->clear(); | 436 | iconToolBar->clear(); |
437 | KOPrefs *p = KOPrefs::instance(); | 437 | KOPrefs *p = KOPrefs::instance(); |
438 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 438 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
439 | 439 | ||
440 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 440 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
441 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 441 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
442 | QPopupMenu *importMenu = new QPopupMenu( this ); | 442 | QPopupMenu *importMenu = new QPopupMenu( this ); |
443 | selectFilterMenu = new QPopupMenu( this ); | 443 | selectFilterMenu = new QPopupMenu( this ); |
444 | selectFilterMenu->setCheckable( true ); | 444 | selectFilterMenu->setCheckable( true ); |
445 | syncMenu = new QPopupMenu( this ); | 445 | syncMenu = new QPopupMenu( this ); |
446 | configureAgendaMenu = new QPopupMenu( this ); | 446 | configureAgendaMenu = new QPopupMenu( this ); |
447 | configureToolBarMenu = new QPopupMenu( this ); | 447 | configureToolBarMenu = new QPopupMenu( this ); |
448 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 448 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
449 | if ( KOPrefs::instance()->mShowFullMenu ) { | 449 | if ( KOPrefs::instance()->mShowFullMenu ) { |
450 | QMenuBar *menuBar1; | 450 | QMenuBar *menuBar1; |
451 | menuBar1 = menuBar(); | 451 | menuBar1 = menuBar(); |
452 | menuBar1->insertItem( i18n("File"), importMenu ); | 452 | menuBar1->insertItem( i18n("File"), importMenu ); |
453 | menuBar1->insertItem( i18n("View"), viewMenu ); | 453 | menuBar1->insertItem( i18n("View"), viewMenu ); |
454 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 454 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
455 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 455 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
456 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 456 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
457 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 457 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
458 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 458 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
459 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 459 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
460 | } else { | 460 | } else { |
461 | QPEMenuBar *menuBar1; | 461 | QPEMenuBar *menuBar1; |
462 | menuBar1 = new QPEMenuBar( iconToolBar ); | 462 | menuBar1 = new QPEMenuBar( iconToolBar ); |
463 | QPopupMenu *menuBar = new QPopupMenu( this ); | 463 | QPopupMenu *menuBar = new QPopupMenu( this ); |
464 | menuBar1->insertItem( i18n("ME"), menuBar); | 464 | menuBar1->insertItem( i18n("ME"), menuBar); |
465 | menuBar->insertItem( i18n("File"), importMenu ); | 465 | menuBar->insertItem( i18n("File"), importMenu ); |
466 | menuBar->insertItem( i18n("View"), viewMenu ); | 466 | menuBar->insertItem( i18n("View"), viewMenu ); |
467 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 467 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
468 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 468 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
469 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 469 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
470 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 470 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
471 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 471 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
472 | menuBar->insertItem( i18n("Help"), helpMenu ); | 472 | menuBar->insertItem( i18n("Help"), helpMenu ); |
473 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 473 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
474 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 474 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
475 | } | 475 | } |
476 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 476 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
477 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 477 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
478 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 478 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
479 | 479 | ||
480 | // ****************** | 480 | // ****************** |
481 | QAction *action; | 481 | QAction *action; |
482 | QIconSet icon; | 482 | QIconSet icon; |
483 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 483 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
484 | configureToolBarMenu->setCheckable( true ); | 484 | configureToolBarMenu->setCheckable( true ); |
485 | 485 | ||
486 | QString pathString = ""; | 486 | QString pathString = ""; |
487 | if ( !p->mToolBarMiniIcons ) { | 487 | if ( !p->mToolBarMiniIcons ) { |
488 | if ( QApplication::desktop()->width() < 480 ) | 488 | if ( QApplication::desktop()->width() < 480 ) |
489 | pathString += "icons16/"; | 489 | pathString += "icons16/"; |
490 | } else | 490 | } else |
491 | pathString += "iconsmini/"; | 491 | pathString += "iconsmini/"; |
492 | configureAgendaMenu->setCheckable( true ); | 492 | configureAgendaMenu->setCheckable( true ); |
493 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 493 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
494 | configureAgendaMenu->insertSeparator(); | 494 | configureAgendaMenu->insertSeparator(); |
495 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 495 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
496 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 496 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
497 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 497 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
498 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 498 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
499 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 499 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
500 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 500 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
501 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 501 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
502 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 502 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
503 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 503 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
504 | 504 | ||
505 | icon = loadPixmap( pathString + "configure" ); | 505 | icon = loadPixmap( pathString + "configure" ); |
506 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 506 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
507 | action->addTo( actionMenu ); | 507 | action->addTo( actionMenu ); |
508 | connect( action, SIGNAL( activated() ), | 508 | connect( action, SIGNAL( activated() ), |
509 | mView, SLOT( edit_options() ) ); | 509 | mView, SLOT( edit_options() ) ); |
510 | actionMenu->insertSeparator(); | 510 | actionMenu->insertSeparator(); |
511 | icon = loadPixmap( pathString + "newevent" ); | 511 | icon = loadPixmap( pathString + "newevent" ); |
512 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 512 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
513 | configureToolBarMenu->insertSeparator(); | 513 | configureToolBarMenu->insertSeparator(); |
514 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 514 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
515 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 515 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
516 | ne_action->addTo( actionMenu ); | 516 | ne_action->addTo( actionMenu ); |
517 | connect( ne_action, SIGNAL( activated() ), | 517 | connect( ne_action, SIGNAL( activated() ), |
518 | mView, SLOT( newEvent() ) ); | 518 | mView, SLOT( newEvent() ) ); |
519 | icon = loadPixmap( pathString + "newtodo" ); | 519 | icon = loadPixmap( pathString + "newtodo" ); |
520 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 520 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
521 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 521 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
522 | nt_action->addTo( actionMenu ); | 522 | nt_action->addTo( actionMenu ); |
523 | connect( nt_action, SIGNAL( activated() ), | 523 | connect( nt_action, SIGNAL( activated() ), |
524 | mView, SLOT( newTodo() ) ); | 524 | mView, SLOT( newTodo() ) ); |
525 | icon = loadPixmap( pathString + "navi" ); | 525 | icon = loadPixmap( pathString + "navi" ); |
526 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 526 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
527 | action->addTo( viewMenu ); | 527 | action->addTo( viewMenu ); |
528 | connect( action, SIGNAL( activated() ), | 528 | connect( action, SIGNAL( activated() ), |
529 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 529 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
530 | icon = loadPixmap( pathString + "filter" ); | 530 | icon = loadPixmap( pathString + "filter" ); |
531 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 531 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
532 | action->addTo( viewMenu ); | 532 | action->addTo( viewMenu ); |
533 | connect( action, SIGNAL( activated() ), | 533 | connect( action, SIGNAL( activated() ), |
534 | mView, SLOT( toggleFilter() ) ); | 534 | mView, SLOT( toggleFilter() ) ); |
535 | 535 | ||
536 | 536 | ||
537 | viewMenu->insertSeparator(); | 537 | viewMenu->insertSeparator(); |
538 | icon = loadPixmap( pathString + "picker" ); | 538 | icon = loadPixmap( pathString + "picker" ); |
539 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 539 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
540 | action->addTo( viewMenu ); | 540 | action->addTo( viewMenu ); |
541 | connect( action, SIGNAL( activated() ), | 541 | connect( action, SIGNAL( activated() ), |
542 | mView, SLOT( showDatePicker() ) ); | 542 | mView, SLOT( showDatePicker() ) ); |
543 | action->addTo( iconToolBar ); | 543 | action->addTo( iconToolBar ); |
544 | viewMenu->insertSeparator(); | 544 | viewMenu->insertSeparator(); |
545 | icon = loadPixmap( pathString + "list" ); | 545 | icon = loadPixmap( pathString + "list" ); |
546 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 546 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
547 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 547 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
548 | showlist_action->addTo( viewMenu ); | 548 | showlist_action->addTo( viewMenu ); |
549 | connect( showlist_action, SIGNAL( activated() ), | 549 | connect( showlist_action, SIGNAL( activated() ), |
550 | mView->viewManager(), SLOT( showListView() ) ); | 550 | mView->viewManager(), SLOT( showListView() ) ); |
551 | 551 | ||
552 | 552 | ||
553 | icon = loadPixmap( pathString + "day" ); | 553 | icon = loadPixmap( pathString + "day" ); |
554 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 554 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
555 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 555 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
556 | day1_action->addTo( viewMenu ); | 556 | day1_action->addTo( viewMenu ); |
557 | // action->addTo( toolBar ); | 557 | // action->addTo( toolBar ); |
558 | connect( day1_action, SIGNAL( activated() ), | 558 | connect( day1_action, SIGNAL( activated() ), |
559 | mView->viewManager(), SLOT( showDayView() ) ); | 559 | mView->viewManager(), SLOT( showDayView() ) ); |
560 | 560 | ||
561 | icon = loadPixmap( pathString + "workweek" ); | 561 | icon = loadPixmap( pathString + "workweek" ); |
562 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 562 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
563 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 563 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
564 | day5_action->addTo( viewMenu ); | 564 | day5_action->addTo( viewMenu ); |
565 | connect( day5_action, SIGNAL( activated() ), | 565 | connect( day5_action, SIGNAL( activated() ), |
566 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 566 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
567 | 567 | ||
568 | icon = loadPixmap( pathString + "week" ); | 568 | icon = loadPixmap( pathString + "week" ); |
569 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 569 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
570 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 570 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
571 | day7_action->addTo( viewMenu ); | 571 | day7_action->addTo( viewMenu ); |
572 | connect( day7_action, SIGNAL( activated() ), | 572 | connect( day7_action, SIGNAL( activated() ), |
573 | mView->viewManager(), SLOT( showWeekView() ) ); | 573 | mView->viewManager(), SLOT( showWeekView() ) ); |
574 | 574 | ||
575 | icon = loadPixmap( pathString + "month" ); | 575 | icon = loadPixmap( pathString + "month" ); |
576 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 576 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
577 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 577 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
578 | month_action->addTo( viewMenu ); | 578 | month_action->addTo( viewMenu ); |
579 | connect( month_action, SIGNAL( activated() ), | 579 | connect( month_action, SIGNAL( activated() ), |
580 | mView->viewManager(), SLOT( showMonthView() ) ); | 580 | mView->viewManager(), SLOT( showMonthView() ) ); |
581 | 581 | ||
582 | icon = loadPixmap( pathString + "todo" ); | 582 | icon = loadPixmap( pathString + "todo" ); |
583 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 583 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
584 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 584 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
585 | todoview_action->addTo( viewMenu ); | 585 | todoview_action->addTo( viewMenu ); |
586 | connect( todoview_action, SIGNAL( activated() ), | 586 | connect( todoview_action, SIGNAL( activated() ), |
587 | mView->viewManager(), SLOT( showTodoView() ) ); | 587 | mView->viewManager(), SLOT( showTodoView() ) ); |
588 | 588 | ||
589 | icon = loadPixmap( pathString + "journal" ); | 589 | icon = loadPixmap( pathString + "journal" ); |
590 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 590 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
591 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 591 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
592 | viewjournal_action->addTo( viewMenu ); | 592 | viewjournal_action->addTo( viewMenu ); |
593 | connect( viewjournal_action, SIGNAL( activated() ), | 593 | connect( viewjournal_action, SIGNAL( activated() ), |
594 | mView->viewManager(), SLOT( showJournalView() ) ); | 594 | mView->viewManager(), SLOT( showJournalView() ) ); |
595 | 595 | ||
596 | icon = loadPixmap( pathString + "xdays" ); | 596 | icon = loadPixmap( pathString + "xdays" ); |
597 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 597 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
598 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 598 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
599 | xdays_action->addTo( viewMenu ); | 599 | xdays_action->addTo( viewMenu ); |
600 | connect( xdays_action, SIGNAL( activated() ), | 600 | connect( xdays_action, SIGNAL( activated() ), |
601 | mView->viewManager(), SLOT( showNextXView() ) ); | 601 | mView->viewManager(), SLOT( showNextXView() ) ); |
602 | 602 | ||
603 | icon = loadPixmap( pathString + "whatsnext" ); | 603 | icon = loadPixmap( pathString + "whatsnext" ); |
604 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 604 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
605 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 605 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
606 | whatsnext_action->addTo( viewMenu ); | 606 | whatsnext_action->addTo( viewMenu ); |
607 | connect( whatsnext_action, SIGNAL( activated() ), | 607 | connect( whatsnext_action, SIGNAL( activated() ), |
608 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 608 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
609 | 609 | ||
610 | #if 0 | 610 | #if 0 |
611 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 611 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
612 | action->addTo( viewMenu ); | 612 | action->addTo( viewMenu ); |
613 | connect( action, SIGNAL( activated() ), | 613 | connect( action, SIGNAL( activated() ), |
614 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 614 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
615 | #endif | 615 | #endif |
616 | 616 | ||
617 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 617 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
618 | this ); | 618 | this ); |
619 | mNewSubTodoAction->addTo( actionMenu ); | 619 | mNewSubTodoAction->addTo( actionMenu ); |
620 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 620 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
621 | mView, SLOT( newSubTodo() ) ); | 621 | mView, SLOT( newSubTodo() ) ); |
622 | 622 | ||
623 | actionMenu->insertSeparator(); | 623 | actionMenu->insertSeparator(); |
624 | 624 | ||
625 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 625 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
626 | mShowAction->addTo( actionMenu ); | 626 | mShowAction->addTo( actionMenu ); |
627 | connect( mShowAction, SIGNAL( activated() ), | 627 | connect( mShowAction, SIGNAL( activated() ), |
628 | mView, SLOT( showIncidence() ) ); | 628 | mView, SLOT( showIncidence() ) ); |
629 | 629 | ||
630 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 630 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
631 | mEditAction->addTo( actionMenu ); | 631 | mEditAction->addTo( actionMenu ); |
632 | connect( mEditAction, SIGNAL( activated() ), | 632 | connect( mEditAction, SIGNAL( activated() ), |
633 | mView, SLOT( editIncidence() ) ); | 633 | mView, SLOT( editIncidence() ) ); |
634 | 634 | ||
635 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 635 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
636 | mDeleteAction->addTo( actionMenu ); | 636 | mDeleteAction->addTo( actionMenu ); |
637 | connect( mDeleteAction, SIGNAL( activated() ), | 637 | connect( mDeleteAction, SIGNAL( activated() ), |
638 | mView, SLOT( deleteIncidence() ) ); | 638 | mView, SLOT( deleteIncidence() ) ); |
639 | 639 | ||
640 | |||
641 | mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); | ||
642 | mCloneAction->addTo( actionMenu ); | ||
643 | connect( mCloneAction, SIGNAL( activated() ), | ||
644 | mView, SLOT( cloneIncidence() ) ); | ||
645 | mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); | ||
646 | mMoveAction->addTo( actionMenu ); | ||
647 | connect( mMoveAction, SIGNAL( activated() ), | ||
648 | mView, SLOT( moveIncidence() ) ); | ||
649 | mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); | ||
650 | mBeamAction->addTo( actionMenu ); | ||
651 | connect( mBeamAction, SIGNAL( activated() ), | ||
652 | mView, SLOT( beamIncidence() ) ); | ||
653 | mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); | ||
654 | mCancelAction->addTo( actionMenu ); | ||
655 | connect( mCancelAction, SIGNAL( activated() ), | ||
656 | mView, SLOT( toggleCancelIncidence() ) ); | ||
657 | |||
640 | actionMenu->insertSeparator(); | 658 | actionMenu->insertSeparator(); |
641 | 659 | ||
642 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 660 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
643 | this ); | 661 | this ); |
644 | action->addTo( actionMenu ); | 662 | action->addTo( actionMenu ); |
645 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 663 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
646 | 664 | ||
647 | icon = loadPixmap( pathString + "search" ); | 665 | icon = loadPixmap( pathString + "search" ); |
648 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 666 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
649 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 667 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
650 | search_action->addTo( actionMenu ); | 668 | search_action->addTo( actionMenu ); |
651 | connect( search_action, SIGNAL( activated() ), | 669 | connect( search_action, SIGNAL( activated() ), |
652 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 670 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
653 | 671 | ||
654 | icon = loadPixmap( pathString + "today" ); | 672 | icon = loadPixmap( pathString + "today" ); |
655 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 673 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
656 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 674 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
657 | today_action->addTo( actionMenu ); | 675 | today_action->addTo( actionMenu ); |
658 | connect( today_action, SIGNAL( activated() ), | 676 | connect( today_action, SIGNAL( activated() ), |
659 | mView, SLOT( goToday() ) ); | 677 | mView, SLOT( goToday() ) ); |
660 | 678 | ||
661 | if ( KOPrefs::instance()->mShowFullMenu ) { | 679 | if ( KOPrefs::instance()->mShowFullMenu ) { |
662 | actionMenu->insertSeparator(); | 680 | actionMenu->insertSeparator(); |
663 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 681 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
664 | 682 | ||
665 | } | 683 | } |
666 | // actionMenu->insertSeparator(); | 684 | // actionMenu->insertSeparator(); |
667 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 685 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
668 | this ); | 686 | this ); |
669 | action->addTo( importMenu ); | 687 | action->addTo( importMenu ); |
670 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 688 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
671 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 689 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
672 | this ); | 690 | this ); |
673 | action->addTo( importMenu ); | 691 | action->addTo( importMenu ); |
674 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 692 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
675 | importMenu->insertSeparator(); | 693 | importMenu->insertSeparator(); |
676 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 694 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
677 | this ); | 695 | this ); |
678 | action->addTo( importMenu ); | 696 | action->addTo( importMenu ); |
679 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 697 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
680 | #ifndef DESKTOP_VERSION | 698 | #ifndef DESKTOP_VERSION |
681 | importMenu->insertSeparator(); | 699 | importMenu->insertSeparator(); |
682 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 700 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
683 | this ); | 701 | this ); |
684 | action->addTo( importMenu ); | 702 | action->addTo( importMenu ); |
685 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 703 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
686 | #else | 704 | #else |
687 | #ifdef _WIN32_ | 705 | #ifdef _WIN32_ |
688 | importMenu->insertSeparator(); | 706 | importMenu->insertSeparator(); |
689 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 707 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
690 | this ); | 708 | this ); |
691 | action->addTo( importMenu ); | 709 | action->addTo( importMenu ); |
692 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 710 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
693 | #endif | 711 | #endif |
694 | #endif | 712 | #endif |
695 | 713 | ||
696 | importMenu->insertSeparator(); | 714 | importMenu->insertSeparator(); |
697 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 715 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
698 | this ); | 716 | this ); |
699 | action->addTo( importMenu ); | 717 | action->addTo( importMenu ); |
700 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 718 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
701 | 719 | ||
702 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 720 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
703 | this ); | 721 | this ); |
704 | action->addTo( importMenu ); | 722 | action->addTo( importMenu ); |
705 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 723 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
706 | 724 | ||
707 | importMenu->insertSeparator(); | 725 | importMenu->insertSeparator(); |
708 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 726 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
709 | this ); | 727 | this ); |
710 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 728 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
711 | 729 | ||
712 | 730 | ||
713 | //LR | 731 | //LR |
714 | QPopupMenu *ex2phone = new QPopupMenu( this ); | 732 | QPopupMenu *ex2phone = new QPopupMenu( this ); |
715 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 733 | ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
716 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 734 | ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
717 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); | 735 | connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); |
718 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); | 736 | importMenu->insertItem( i18n("Export to phone"), ex2phone ); |
719 | 737 | ||
720 | importMenu->insertSeparator(); | 738 | importMenu->insertSeparator(); |
721 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 739 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
722 | this ); | 740 | this ); |
723 | action->addTo( importMenu ); | 741 | action->addTo( importMenu ); |
724 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 742 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
725 | #ifndef DESKTOP_VERSION | 743 | #ifndef DESKTOP_VERSION |
726 | importMenu->insertSeparator(); | 744 | importMenu->insertSeparator(); |
727 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 745 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
728 | this ); | 746 | this ); |
729 | action->addTo( importMenu ); | 747 | action->addTo( importMenu ); |
730 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 748 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
731 | 749 | ||
732 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 750 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
733 | this ); | 751 | this ); |
734 | action->addTo( importMenu ); | 752 | action->addTo( importMenu ); |
735 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 753 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
736 | #else | 754 | #else |
737 | importMenu->insertSeparator(); | 755 | importMenu->insertSeparator(); |
738 | icon = loadPixmap( pathString + "print" ); | 756 | icon = loadPixmap( pathString + "print" ); |
739 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 757 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
740 | action->addTo( importMenu ); | 758 | action->addTo( importMenu ); |
741 | connect( action, SIGNAL( activated() ), | 759 | connect( action, SIGNAL( activated() ), |
742 | this, SLOT( printCal() ) ); | 760 | this, SLOT( printCal() ) ); |
743 | 761 | ||
744 | icon = loadPixmap( pathString + "print" ); | 762 | icon = loadPixmap( pathString + "print" ); |
745 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 763 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
746 | action->addTo( importMenu ); | 764 | action->addTo( importMenu ); |
747 | connect( action, SIGNAL( activated() ), | 765 | connect( action, SIGNAL( activated() ), |
748 | this, SLOT( printSel() ) ); | 766 | this, SLOT( printSel() ) ); |
749 | #endif | 767 | #endif |
750 | importMenu->insertSeparator(); | 768 | importMenu->insertSeparator(); |
751 | action = new QAction( "beam all", i18n("Save"), 0, | 769 | action = new QAction( "beam all", i18n("Save"), 0, |
752 | this ); | 770 | this ); |
753 | action->addTo( importMenu ); | 771 | action->addTo( importMenu ); |
754 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 772 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
755 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 773 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
756 | this ); | 774 | this ); |
757 | action->addTo( importMenu ); | 775 | action->addTo( importMenu ); |
758 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 776 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
759 | 777 | ||
760 | //menuBar->insertItem( "Configure",configureMenu ); | 778 | //menuBar->insertItem( "Configure",configureMenu ); |
761 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 779 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
762 | icon = loadPixmap( "korganizer/korganizer" ); | 780 | icon = loadPixmap( "korganizer/korganizer" ); |
763 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 781 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
764 | action->addTo( helpMenu ); | 782 | action->addTo( helpMenu ); |
765 | connect( action, SIGNAL( activated() ), | 783 | connect( action, SIGNAL( activated() ), |
766 | SLOT( keyBindings() ) ); | 784 | SLOT( keyBindings() ) ); |
767 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 785 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
768 | action->addTo( helpMenu ); | 786 | action->addTo( helpMenu ); |
769 | connect( action, SIGNAL( activated() ), | 787 | connect( action, SIGNAL( activated() ), |
770 | SLOT( features() ) ); | 788 | SLOT( features() ) ); |
771 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 789 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
772 | action->addTo( helpMenu ); | 790 | action->addTo( helpMenu ); |
773 | connect( action, SIGNAL( activated() ), | 791 | connect( action, SIGNAL( activated() ), |
774 | SLOT( aboutAutoSaving() ) ); | 792 | SLOT( aboutAutoSaving() ) ); |
775 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 793 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
776 | action->addTo( helpMenu ); | 794 | action->addTo( helpMenu ); |
777 | connect( action, SIGNAL( activated() ), | 795 | connect( action, SIGNAL( activated() ), |
778 | SLOT( aboutKnownBugs() ) ); | 796 | SLOT( aboutKnownBugs() ) ); |
779 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 797 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
780 | action->addTo( helpMenu ); | 798 | action->addTo( helpMenu ); |
781 | connect( action, SIGNAL( activated() ), | 799 | connect( action, SIGNAL( activated() ), |
782 | SLOT( usertrans() ) ); | 800 | SLOT( usertrans() ) ); |
783 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 801 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
784 | action->addTo( helpMenu ); | 802 | action->addTo( helpMenu ); |
785 | connect( action, SIGNAL( activated() ), | 803 | connect( action, SIGNAL( activated() ), |
786 | SLOT( synchowto() ) ); | 804 | SLOT( synchowto() ) ); |
787 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 805 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
788 | action->addTo( helpMenu ); | 806 | action->addTo( helpMenu ); |
789 | connect( action, SIGNAL( activated() ), | 807 | connect( action, SIGNAL( activated() ), |
790 | SLOT( whatsNew() ) ); | 808 | SLOT( whatsNew() ) ); |
791 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 809 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
792 | action->addTo( helpMenu ); | 810 | action->addTo( helpMenu ); |
793 | connect( action, SIGNAL( activated() ), | 811 | connect( action, SIGNAL( activated() ), |
794 | SLOT( faq() ) ); | 812 | SLOT( faq() ) ); |
795 | 813 | ||
796 | 814 | ||
797 | action = new QAction( "about", i18n("About..."), 0, this ); | 815 | action = new QAction( "about", i18n("About..."), 0, this ); |
798 | action->addTo( helpMenu ); | 816 | action->addTo( helpMenu ); |
799 | connect( action, SIGNAL( activated() ), | 817 | connect( action, SIGNAL( activated() ), |
800 | SLOT( about() ) ); | 818 | SLOT( about() ) ); |
801 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 819 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
802 | action->addTo( helpMenu ); | 820 | action->addTo( helpMenu ); |
803 | connect( action, SIGNAL( activated() ), | 821 | connect( action, SIGNAL( activated() ), |
804 | SLOT( licence() ) ); | 822 | SLOT( licence() ) ); |
805 | //menuBar->insertSeparator(); | 823 | //menuBar->insertSeparator(); |
806 | 824 | ||
807 | // ****************************************************** | 825 | // ****************************************************** |
808 | // menubar icons | 826 | // menubar icons |
809 | 827 | ||
810 | 828 | ||
811 | iconToolBar->setHorizontalStretchable (true ); | 829 | iconToolBar->setHorizontalStretchable (true ); |
812 | //menuBar->insertItem( iconToolBar ); | 830 | //menuBar->insertItem( iconToolBar ); |
813 | //xdays_action | 831 | //xdays_action |
814 | if (p-> mShowIconNewEvent) | 832 | if (p-> mShowIconNewEvent) |
815 | ne_action->addTo( iconToolBar ); | 833 | ne_action->addTo( iconToolBar ); |
816 | if (p->mShowIconNewTodo ) | 834 | if (p->mShowIconNewTodo ) |
817 | nt_action->addTo( iconToolBar ); | 835 | nt_action->addTo( iconToolBar ); |
818 | if (p-> mShowIconSearch) | 836 | if (p-> mShowIconSearch) |
819 | search_action->addTo( iconToolBar ); | 837 | search_action->addTo( iconToolBar ); |
820 | if (p-> mShowIconNext) | 838 | if (p-> mShowIconNext) |
821 | whatsnext_action->addTo( iconToolBar ); | 839 | whatsnext_action->addTo( iconToolBar ); |
822 | if (p-> mShowIconNextDays) | 840 | if (p-> mShowIconNextDays) |
823 | xdays_action->addTo( iconToolBar ); | 841 | xdays_action->addTo( iconToolBar ); |
824 | if (p-> mShowIconList) | 842 | if (p-> mShowIconList) |
825 | showlist_action->addTo( iconToolBar ); | 843 | showlist_action->addTo( iconToolBar ); |
826 | if (p-> mShowIconDay1) | 844 | if (p-> mShowIconDay1) |
827 | day1_action->addTo( iconToolBar ); | 845 | day1_action->addTo( iconToolBar ); |
828 | if (p-> mShowIconDay5) | 846 | if (p-> mShowIconDay5) |
829 | day5_action->addTo( iconToolBar ); | 847 | day5_action->addTo( iconToolBar ); |
830 | if (p-> mShowIconDay7) | 848 | if (p-> mShowIconDay7) |
831 | day7_action->addTo( iconToolBar ); | 849 | day7_action->addTo( iconToolBar ); |
832 | if (p-> mShowIconMonth) | 850 | if (p-> mShowIconMonth) |
833 | month_action->addTo( iconToolBar ); | 851 | month_action->addTo( iconToolBar ); |
834 | if (p-> mShowIconTodoview) | 852 | if (p-> mShowIconTodoview) |
835 | todoview_action->addTo( iconToolBar ); | 853 | todoview_action->addTo( iconToolBar ); |
836 | if (p-> mShowIconJournal) | 854 | if (p-> mShowIconJournal) |
837 | viewjournal_action->addTo( iconToolBar ); | 855 | viewjournal_action->addTo( iconToolBar ); |
838 | icon = loadPixmap( pathString + "2leftarrowB" ); | 856 | icon = loadPixmap( pathString + "2leftarrowB" ); |
839 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 857 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
840 | if (p-> mShowIconBackFast) { | 858 | if (p-> mShowIconBackFast) { |
841 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 859 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
842 | connect( action, SIGNAL( activated() ), | 860 | connect( action, SIGNAL( activated() ), |
843 | mView, SLOT( goPreviousMonth() ) ); | 861 | mView, SLOT( goPreviousMonth() ) ); |
844 | action->addTo( iconToolBar ); | 862 | action->addTo( iconToolBar ); |
845 | } | 863 | } |
846 | icon = loadPixmap( pathString + "1leftarrowB" ); | 864 | icon = loadPixmap( pathString + "1leftarrowB" ); |
847 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 865 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
848 | if (p-> mShowIconBack) { | 866 | if (p-> mShowIconBack) { |
849 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 867 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
850 | connect( action, SIGNAL( activated() ), | 868 | connect( action, SIGNAL( activated() ), |
851 | mView, SLOT( goPrevious() ) ); | 869 | mView, SLOT( goPrevious() ) ); |
852 | action->addTo( iconToolBar ); | 870 | action->addTo( iconToolBar ); |
853 | } | 871 | } |
854 | if (p-> mShowIconToday) | 872 | if (p-> mShowIconToday) |
855 | today_action->addTo( iconToolBar ); | 873 | today_action->addTo( iconToolBar ); |
856 | icon = loadPixmap( pathString + "1rightarrowB" ); | 874 | icon = loadPixmap( pathString + "1rightarrowB" ); |
857 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 875 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
858 | if (p-> mShowIconForward) { | 876 | if (p-> mShowIconForward) { |
859 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 877 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
860 | connect( action, SIGNAL( activated() ), | 878 | connect( action, SIGNAL( activated() ), |
861 | mView, SLOT( goNext() ) ); | 879 | mView, SLOT( goNext() ) ); |
862 | action->addTo( iconToolBar ); | 880 | action->addTo( iconToolBar ); |
863 | } | 881 | } |
864 | icon = loadPixmap( pathString + "2rightarrowB" ); | 882 | icon = loadPixmap( pathString + "2rightarrowB" ); |
865 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 883 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
866 | if (p-> mShowIconForwardFast) { | 884 | if (p-> mShowIconForwardFast) { |
867 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 885 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
868 | connect( action, SIGNAL( activated() ), | 886 | connect( action, SIGNAL( activated() ), |
869 | mView, SLOT( goNextMonth() ) ); | 887 | mView, SLOT( goNextMonth() ) ); |
870 | action->addTo( iconToolBar ); | 888 | action->addTo( iconToolBar ); |
871 | } | 889 | } |
872 | 890 | ||
873 | 891 | ||
874 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 892 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
875 | 893 | ||
876 | if (p-> mShowIconNewEvent) | 894 | if (p-> mShowIconNewEvent) |
877 | configureToolBarMenu->setItemChecked( 10, true ); | 895 | configureToolBarMenu->setItemChecked( 10, true ); |
878 | if (p->mShowIconNewTodo ) | 896 | if (p->mShowIconNewTodo ) |
879 | configureToolBarMenu->setItemChecked( 20, true ); | 897 | configureToolBarMenu->setItemChecked( 20, true ); |
880 | if (p-> mShowIconSearch) | 898 | if (p-> mShowIconSearch) |
881 | configureToolBarMenu->setItemChecked( 120, true ); | 899 | configureToolBarMenu->setItemChecked( 120, true ); |
882 | if (p-> mShowIconList) | 900 | if (p-> mShowIconList) |
883 | configureToolBarMenu->setItemChecked( 30, true ); | 901 | configureToolBarMenu->setItemChecked( 30, true ); |
884 | if (p-> mShowIconDay1) | 902 | if (p-> mShowIconDay1) |
885 | configureToolBarMenu->setItemChecked( 40, true ); | 903 | configureToolBarMenu->setItemChecked( 40, true ); |
886 | if (p-> mShowIconDay5) | 904 | if (p-> mShowIconDay5) |
887 | configureToolBarMenu->setItemChecked( 50, true ); | 905 | configureToolBarMenu->setItemChecked( 50, true ); |
888 | if (p-> mShowIconDay7) | 906 | if (p-> mShowIconDay7) |
889 | configureToolBarMenu->setItemChecked( 60, true ); | 907 | configureToolBarMenu->setItemChecked( 60, true ); |
890 | if (p-> mShowIconMonth) | 908 | if (p-> mShowIconMonth) |
891 | configureToolBarMenu->setItemChecked( 70, true ); | 909 | configureToolBarMenu->setItemChecked( 70, true ); |
892 | if (p-> mShowIconTodoview) | 910 | if (p-> mShowIconTodoview) |
893 | configureToolBarMenu->setItemChecked( 80, true ); | 911 | configureToolBarMenu->setItemChecked( 80, true ); |
894 | if (p-> mShowIconBackFast) | 912 | if (p-> mShowIconBackFast) |
895 | configureToolBarMenu->setItemChecked( 200, true ); | 913 | configureToolBarMenu->setItemChecked( 200, true ); |
896 | if (p-> mShowIconBack) | 914 | if (p-> mShowIconBack) |
897 | configureToolBarMenu->setItemChecked( 210, true ); | 915 | configureToolBarMenu->setItemChecked( 210, true ); |
898 | if (p-> mShowIconToday) | 916 | if (p-> mShowIconToday) |
899 | configureToolBarMenu->setItemChecked( 130, true ); | 917 | configureToolBarMenu->setItemChecked( 130, true ); |
900 | if (p-> mShowIconForward) | 918 | if (p-> mShowIconForward) |
901 | configureToolBarMenu->setItemChecked( 220, true ); | 919 | configureToolBarMenu->setItemChecked( 220, true ); |
902 | if (p-> mShowIconForwardFast) | 920 | if (p-> mShowIconForwardFast) |
903 | configureToolBarMenu->setItemChecked( 230, true ); | 921 | configureToolBarMenu->setItemChecked( 230, true ); |
904 | if (p-> mShowIconNextDays) | 922 | if (p-> mShowIconNextDays) |
905 | configureToolBarMenu->setItemChecked( 100, true ); | 923 | configureToolBarMenu->setItemChecked( 100, true ); |
906 | if (p-> mShowIconNext) | 924 | if (p-> mShowIconNext) |
907 | configureToolBarMenu->setItemChecked( 110, true ); | 925 | configureToolBarMenu->setItemChecked( 110, true ); |
908 | if (p-> mShowIconJournal) | 926 | if (p-> mShowIconJournal) |
909 | configureToolBarMenu->setItemChecked( 90, true ); | 927 | configureToolBarMenu->setItemChecked( 90, true ); |
910 | if (p-> mShowIconWhatsThis) | 928 | if (p-> mShowIconWhatsThis) |
911 | configureToolBarMenu->setItemChecked( 300, true ); | 929 | configureToolBarMenu->setItemChecked( 300, true ); |
912 | 930 | ||
913 | QLabel* dummy = new QLabel( iconToolBar ); | 931 | QLabel* dummy = new QLabel( iconToolBar ); |
914 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 932 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
915 | if (!p-> mShowIconStretch) | 933 | if (!p-> mShowIconStretch) |
916 | iconToolBar->setStretchableWidget ( dummy ) ; | 934 | iconToolBar->setStretchableWidget ( dummy ) ; |
917 | else | 935 | else |
918 | configureToolBarMenu->setItemChecked( 5, true ); | 936 | configureToolBarMenu->setItemChecked( 5, true ); |
919 | if (p-> mShowIconWhatsThis) | 937 | if (p-> mShowIconWhatsThis) |
920 | QWhatsThis::whatsThisButton ( iconToolBar ); | 938 | QWhatsThis::whatsThisButton ( iconToolBar ); |
921 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 939 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
922 | configureAgenda( p->mHourSize ); | 940 | configureAgenda( p->mHourSize ); |
923 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 941 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
924 | } | 942 | } |
925 | void MainWindow::fillSyncMenu() | 943 | void MainWindow::fillSyncMenu() |
926 | { | 944 | { |
927 | if ( syncMenu->count() ) | 945 | if ( syncMenu->count() ) |
928 | syncMenu->clear(); | 946 | syncMenu->clear(); |
929 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 947 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
930 | syncMenu->insertSeparator(); | 948 | syncMenu->insertSeparator(); |
931 | if ( mServerSocket == 0 ) { | 949 | if ( mServerSocket == 0 ) { |
932 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); | 950 | syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); |
933 | } else { | 951 | } else { |
934 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); | 952 | syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); |
935 | } | 953 | } |
936 | syncMenu->insertSeparator(); | 954 | syncMenu->insertSeparator(); |
937 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 955 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
938 | syncMenu->insertSeparator(); | 956 | syncMenu->insertSeparator(); |
939 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 957 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
940 | config.setGroup("General"); | 958 | config.setGroup("General"); |
941 | QStringList prof = config.readListEntry("SyncProfileNames"); | 959 | QStringList prof = config.readListEntry("SyncProfileNames"); |
942 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 960 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
943 | if ( prof.count() < 3 ) { | 961 | if ( prof.count() < 3 ) { |
944 | prof.clear(); | 962 | prof.clear(); |
945 | prof << i18n("Sharp_DTM"); | 963 | prof << i18n("Sharp_DTM"); |
946 | prof << i18n("Local_file"); | 964 | prof << i18n("Local_file"); |
947 | prof << i18n("Last_file"); | 965 | prof << i18n("Last_file"); |
948 | KSyncProfile* temp = new KSyncProfile (); | 966 | KSyncProfile* temp = new KSyncProfile (); |
949 | temp->setName( prof[0] ); | 967 | temp->setName( prof[0] ); |
950 | temp->writeConfig(&config); | 968 | temp->writeConfig(&config); |
951 | temp->setName( prof[1] ); | 969 | temp->setName( prof[1] ); |
952 | temp->writeConfig(&config); | 970 | temp->writeConfig(&config); |
953 | temp->setName( prof[2] ); | 971 | temp->setName( prof[2] ); |
954 | temp->writeConfig(&config); | 972 | temp->writeConfig(&config); |
955 | config.setGroup("General"); | 973 | config.setGroup("General"); |
956 | config.writeEntry("SyncProfileNames",prof); | 974 | config.writeEntry("SyncProfileNames",prof); |
957 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 975 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
958 | config.sync(); | 976 | config.sync(); |
959 | delete temp; | 977 | delete temp; |
960 | } | 978 | } |
961 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 979 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
962 | KOPrefs::instance()->mSyncProfileNames = prof; | 980 | KOPrefs::instance()->mSyncProfileNames = prof; |
963 | int i; | 981 | int i; |
964 | for ( i = 0; i < prof.count(); ++i ) { | 982 | for ( i = 0; i < prof.count(); ++i ) { |
965 | 983 | ||
966 | syncMenu->insertItem( prof[i], 1000+i ); | 984 | syncMenu->insertItem( prof[i], 1000+i ); |
967 | if ( i == 2 ) | 985 | if ( i == 2 ) |
968 | syncMenu->insertSeparator(); | 986 | syncMenu->insertSeparator(); |
969 | } | 987 | } |
970 | QDir app_dir; | 988 | QDir app_dir; |
971 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 989 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
972 | syncMenu->setItemEnabled( false , 1000 ); | 990 | syncMenu->setItemEnabled( false , 1000 ); |
973 | } | 991 | } |
974 | mView->setupExternSyncProfiles(); | 992 | mView->setupExternSyncProfiles(); |
975 | } | 993 | } |
976 | 994 | ||
977 | int MainWindow::ringSync() | 995 | int MainWindow::ringSync() |
978 | { | 996 | { |
979 | int syncedProfiles = 0; | 997 | int syncedProfiles = 0; |
980 | int i; | 998 | int i; |
981 | QTime timer; | 999 | QTime timer; |
982 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1000 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
983 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 1001 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
984 | KSyncProfile* temp = new KSyncProfile (); | 1002 | KSyncProfile* temp = new KSyncProfile (); |
985 | KOPrefs::instance()->mAskForPreferences = false; | 1003 | KOPrefs::instance()->mAskForPreferences = false; |
986 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 1004 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
987 | mCurrentSyncProfile = i; | 1005 | mCurrentSyncProfile = i; |
988 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 1006 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
989 | temp->readConfig(&config); | 1007 | temp->readConfig(&config); |
990 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 1008 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
991 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 1009 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
992 | ++syncedProfiles; | 1010 | ++syncedProfiles; |
993 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1011 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
994 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1012 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
995 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1013 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
996 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1014 | KOPrefs::instance()->mWriteBackInFuture = 0; |
997 | if ( temp->getWriteBackFuture() ) | 1015 | if ( temp->getWriteBackFuture() ) |
998 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1016 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
999 | KOPrefs::instance()->mShowSyncSummary = false; | 1017 | KOPrefs::instance()->mShowSyncSummary = false; |
1000 | mView->setSyncDevice(syncProfileNames[i] ); | 1018 | mView->setSyncDevice(syncProfileNames[i] ); |
1001 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1019 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1002 | if ( i == 0 ) { | 1020 | if ( i == 0 ) { |
1003 | syncSharp(); | 1021 | syncSharp(); |
1004 | } else { | 1022 | } else { |
1005 | if ( temp->getIsLocalFileSync() ) { | 1023 | if ( temp->getIsLocalFileSync() ) { |
1006 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 1024 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
1007 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1025 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1008 | } else { | 1026 | } else { |
1009 | if ( temp->getIsPhoneSync() ) { | 1027 | if ( temp->getIsPhoneSync() ) { |
1010 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1028 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1011 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1029 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1012 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1030 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1013 | syncPhone(); | 1031 | syncPhone(); |
1014 | } else if ( temp->getIsPiSync() ) { | 1032 | } else if ( temp->getIsPiSync() ) { |
1015 | mPassWordPiSync = temp->getRemotePw(); | 1033 | mPassWordPiSync = temp->getRemotePw(); |
1016 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1034 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1017 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1035 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1018 | syncPi(); | 1036 | syncPi(); |
1019 | } else | 1037 | } else |
1020 | syncRemote( temp, false ); | 1038 | syncRemote( temp, false ); |
1021 | 1039 | ||
1022 | } | 1040 | } |
1023 | } | 1041 | } |
1024 | timer.start(); | 1042 | timer.start(); |
1025 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 1043 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
1026 | while ( timer.elapsed () < 2000 ) { | 1044 | while ( timer.elapsed () < 2000 ) { |
1027 | qApp->processEvents(); | 1045 | qApp->processEvents(); |
1028 | #ifndef _WIN32_ | 1046 | #ifndef _WIN32_ |
1029 | sleep (1); | 1047 | sleep (1); |
1030 | #endif | 1048 | #endif |
1031 | } | 1049 | } |
1032 | 1050 | ||
1033 | } | 1051 | } |
1034 | 1052 | ||
1035 | } | 1053 | } |
1036 | delete temp; | 1054 | delete temp; |
1037 | return syncedProfiles; | 1055 | return syncedProfiles; |
1038 | } | 1056 | } |
1039 | 1057 | ||
1040 | void MainWindow::multiSync( bool askforPrefs ) | 1058 | void MainWindow::multiSync( bool askforPrefs ) |
1041 | { | 1059 | { |
1042 | if (mBlockSaveFlag) | 1060 | if (mBlockSaveFlag) |
1043 | return; | 1061 | return; |
1044 | mBlockSaveFlag = true; | 1062 | mBlockSaveFlag = true; |
1045 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 1063 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
1046 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 1064 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
1047 | question, | 1065 | question, |
1048 | i18n("Yes"), i18n("No"), | 1066 | i18n("Yes"), i18n("No"), |
1049 | 0, 0 ) != 0 ) { | 1067 | 0, 0 ) != 0 ) { |
1050 | mBlockSaveFlag = false; | 1068 | mBlockSaveFlag = false; |
1051 | setCaption(i18n("Aborted! Nothing synced!")); | 1069 | setCaption(i18n("Aborted! Nothing synced!")); |
1052 | return; | 1070 | return; |
1053 | } | 1071 | } |
1054 | mView->setSyncDevice(i18n("Multiple profiles") ); | 1072 | mView->setSyncDevice(i18n("Multiple profiles") ); |
1055 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 1073 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
1056 | if ( askforPrefs ) { | 1074 | if ( askforPrefs ) { |
1057 | mView->edit_sync_options(); | 1075 | mView->edit_sync_options(); |
1058 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 1076 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
1059 | } | 1077 | } |
1060 | setCaption(i18n("Multiple sync started.") ); | 1078 | setCaption(i18n("Multiple sync started.") ); |
1061 | qApp->processEvents(); | 1079 | qApp->processEvents(); |
1062 | int num = ringSync() ; | 1080 | int num = ringSync() ; |
1063 | if ( num > 1 ) | 1081 | if ( num > 1 ) |
1064 | ringSync(); | 1082 | ringSync(); |
1065 | mBlockSaveFlag = false; | 1083 | mBlockSaveFlag = false; |
1066 | if ( num ) | 1084 | if ( num ) |
1067 | save(); | 1085 | save(); |
1068 | if ( num ) | 1086 | if ( num ) |
1069 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 1087 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
1070 | else | 1088 | else |
1071 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 1089 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
1072 | return; | 1090 | return; |
1073 | } | 1091 | } |
1074 | void MainWindow::slotSyncMenu( int action ) | 1092 | void MainWindow::slotSyncMenu( int action ) |
1075 | { | 1093 | { |
1076 | qDebug("syncaction %d ", action); | 1094 | qDebug("syncaction %d ", action); |
1077 | if ( action == 0 ) { | 1095 | if ( action == 0 ) { |
1078 | 1096 | ||
1079 | // seems to be a Qt2 event handling bug | 1097 | // seems to be a Qt2 event handling bug |
1080 | // syncmenu.clear causes a segfault at first time | 1098 | // syncmenu.clear causes a segfault at first time |
1081 | // when we call it after the main event loop, it is ok | 1099 | // when we call it after the main event loop, it is ok |
1082 | // same behaviour when calling OM/Pi via QCOP for the first time | 1100 | // same behaviour when calling OM/Pi via QCOP for the first time |
1083 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); | 1101 | QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); |
1084 | //confSync(); | 1102 | //confSync(); |
1085 | 1103 | ||
1086 | return; | 1104 | return; |
1087 | } | 1105 | } |
1088 | if ( action == 1 ) { | 1106 | if ( action == 1 ) { |
1089 | multiSync( true ); | 1107 | multiSync( true ); |
1090 | return; | 1108 | return; |
1091 | } | 1109 | } |
1092 | if ( action == 2 ) { | 1110 | if ( action == 2 ) { |
1093 | enableQuick(); | 1111 | enableQuick(); |
1094 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1112 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1095 | return; | 1113 | return; |
1096 | } | 1114 | } |
1097 | if ( action == 3 ) { | 1115 | if ( action == 3 ) { |
1098 | delete mServerSocket; | 1116 | delete mServerSocket; |
1099 | mServerSocket = 0; | 1117 | mServerSocket = 0; |
1100 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); | 1118 | QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); |
1101 | return; | 1119 | return; |
1102 | } | 1120 | } |
1103 | 1121 | ||
1104 | if (mBlockSaveFlag) | 1122 | if (mBlockSaveFlag) |
1105 | return; | 1123 | return; |
1106 | mBlockSaveFlag = true; | 1124 | mBlockSaveFlag = true; |
1107 | mCurrentSyncProfile = action - 1000 ; | 1125 | mCurrentSyncProfile = action - 1000 ; |
1108 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 1126 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
1109 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 1127 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
1110 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); | 1128 | KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); |
1111 | KSyncProfile* temp = new KSyncProfile (); | 1129 | KSyncProfile* temp = new KSyncProfile (); |
1112 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 1130 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
1113 | temp->readConfig(&config); | 1131 | temp->readConfig(&config); |
1114 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 1132 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
1115 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 1133 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
1116 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 1134 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
1117 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 1135 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
1118 | KOPrefs::instance()->mWriteBackInFuture = 0; | 1136 | KOPrefs::instance()->mWriteBackInFuture = 0; |
1119 | if ( temp->getWriteBackFuture() ) | 1137 | if ( temp->getWriteBackFuture() ) |
1120 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); | 1138 | KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); |
1121 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 1139 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
1122 | if ( action == 1000 ) { | 1140 | if ( action == 1000 ) { |
1123 | syncSharp(); | 1141 | syncSharp(); |
1124 | 1142 | ||
1125 | } else if ( action == 1001 ) { | 1143 | } else if ( action == 1001 ) { |
1126 | syncLocalFile(); | 1144 | syncLocalFile(); |
1127 | 1145 | ||
1128 | } else if ( action == 1002 ) { | 1146 | } else if ( action == 1002 ) { |
1129 | quickSyncLocalFile(); | 1147 | quickSyncLocalFile(); |
1130 | 1148 | ||
1131 | } else if ( action >= 1003 ) { | 1149 | } else if ( action >= 1003 ) { |
1132 | if ( temp->getIsLocalFileSync() ) { | 1150 | if ( temp->getIsLocalFileSync() ) { |
1133 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1151 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1134 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1152 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1135 | } else { | 1153 | } else { |
1136 | if ( temp->getIsPhoneSync() ) { | 1154 | if ( temp->getIsPhoneSync() ) { |
1137 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 1155 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
1138 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 1156 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
1139 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 1157 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
1140 | syncPhone(); | 1158 | syncPhone(); |
1141 | } else if ( temp->getIsPiSync() ) { | 1159 | } else if ( temp->getIsPiSync() ) { |
1142 | mPassWordPiSync = temp->getRemotePw(); | 1160 | mPassWordPiSync = temp->getRemotePw(); |
1143 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); | 1161 | KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); |
1144 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); | 1162 | KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); |
1145 | syncPi(); | 1163 | syncPi(); |
1146 | } else | 1164 | } else |
1147 | syncRemote( temp ); | 1165 | syncRemote( temp ); |
1148 | 1166 | ||
1149 | } | 1167 | } |
1150 | } | 1168 | } |
1151 | delete temp; | 1169 | delete temp; |
1152 | mBlockSaveFlag = false; | 1170 | mBlockSaveFlag = false; |
1153 | } | 1171 | } |
1154 | void MainWindow::exportToPhone( int mode ) | 1172 | void MainWindow::exportToPhone( int mode ) |
1155 | { | 1173 | { |
1156 | 1174 | ||
1157 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); | 1175 | //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); |
1158 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); | 1176 | //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); |
1159 | KOex2phonePrefs ex2phone; | 1177 | KOex2phonePrefs ex2phone; |
1160 | ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection ); | 1178 | ex2phone.mPhoneConnection->setText( KOPrefs::instance()->mEx2PhoneConnection ); |
1161 | ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice ); | 1179 | ex2phone.mPhoneDevice->setText( KOPrefs::instance()->mEx2PhoneDevice ); |
1162 | ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel ); | 1180 | ex2phone.mPhoneModel->setText( KOPrefs::instance()->mEx2PhoneModel ); |
1163 | if ( mode == 1 ) | 1181 | if ( mode == 1 ) |
1164 | ex2phone.setCaption(i18n("Export complete calendar")); | 1182 | ex2phone.setCaption(i18n("Export complete calendar")); |
1165 | if ( mode == 2 ) | 1183 | if ( mode == 2 ) |
1166 | ex2phone.setCaption(i18n("Export filtered calendar")); | 1184 | ex2phone.setCaption(i18n("Export filtered calendar")); |
1167 | 1185 | ||
1168 | if ( !ex2phone.exec() ) { | 1186 | if ( !ex2phone.exec() ) { |
1169 | return; | 1187 | return; |
1170 | } | 1188 | } |
1171 | KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); | 1189 | KOPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); |
1172 | KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); | 1190 | KOPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); |
1173 | KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); | 1191 | KOPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); |
1174 | 1192 | ||
1175 | int inFuture = 0; | 1193 | int inFuture = 0; |
1176 | if ( ex2phone.mWriteBackFuture->isChecked() ) | 1194 | if ( ex2phone.mWriteBackFuture->isChecked() ) |
1177 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); | 1195 | inFuture = ex2phone.mWriteBackFutureWeeks->value(); |
1178 | QPtrList<Incidence> delSel; | 1196 | QPtrList<Incidence> delSel; |
1179 | if ( mode == 1 ) | 1197 | if ( mode == 1 ) |
1180 | delSel = mCalendar->rawIncidences(); | 1198 | delSel = mCalendar->rawIncidences(); |
1181 | if ( mode == 2 ) | 1199 | if ( mode == 2 ) |
1182 | delSel = mCalendar->incidences(); | 1200 | delSel = mCalendar->incidences(); |
1183 | CalendarLocal* cal = new CalendarLocal(); | 1201 | CalendarLocal* cal = new CalendarLocal(); |
1184 | cal->setLocalTime(); | 1202 | cal->setLocalTime(); |
1185 | Incidence *incidence = delSel.first(); | 1203 | Incidence *incidence = delSel.first(); |
1186 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1204 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1187 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); | 1205 | QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); |
1188 | while ( incidence ) { | 1206 | while ( incidence ) { |
1189 | if ( incidence->type() != "journal" ) { | 1207 | if ( incidence->type() != "Journal" ) { |
1190 | bool add = true; | 1208 | bool add = true; |
1191 | if ( inFuture ) { | 1209 | if ( inFuture ) { |
1192 | QDateTime dt; | 1210 | QDateTime dt; |
1193 | if ( incidence->type() == "Todo" ) { | 1211 | if ( incidence->type() == "Todo" ) { |
1194 | Todo * t = (Todo*)incidence; | 1212 | Todo * t = (Todo*)incidence; |
1195 | if ( t->hasDueDate() ) | 1213 | if ( t->hasDueDate() ) |
1196 | dt = t->dtDue(); | 1214 | dt = t->dtDue(); |
1197 | else | 1215 | else |
1198 | dt = cur.addSecs( 62 ); | 1216 | dt = cur.addSecs( 62 ); |
1199 | } | 1217 | } |
1200 | else { | 1218 | else { |
1201 | bool ok; | 1219 | bool ok; |
1202 | dt = incidence->getNextOccurence( cur, &ok ); | 1220 | dt = incidence->getNextOccurence( cur, &ok ); |
1203 | if ( !ok ) | 1221 | if ( !ok ) |
1204 | dt = cur.addSecs( -62 ); | 1222 | dt = cur.addSecs( -62 ); |
1205 | } | 1223 | } |
1206 | if ( dt < cur || dt > end ) { | 1224 | if ( dt < cur || dt > end ) { |
1207 | add = false; | 1225 | add = false; |
1208 | } | 1226 | } |
1209 | } | 1227 | } |
1210 | if ( add ) { | 1228 | if ( add ) { |
1211 | Incidence *in = incidence->clone(); | 1229 | Incidence *in = incidence->clone(); |
1212 | cal->addIncidence( in ); | 1230 | cal->addIncidence( in ); |
1213 | } | 1231 | } |
1214 | } | 1232 | } |
1215 | incidence = delSel.next(); | 1233 | incidence = delSel.next(); |
1216 | } | 1234 | } |
1217 | PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice, | 1235 | PhoneFormat::writeConfig( KOPrefs::instance()->mEx2PhoneDevice, |
1218 | KOPrefs::instance()->mEx2PhoneConnection, | 1236 | KOPrefs::instance()->mEx2PhoneConnection, |
1219 | KOPrefs::instance()->mEx2PhoneModel ); | 1237 | KOPrefs::instance()->mEx2PhoneModel ); |
1220 | 1238 | ||
1221 | setCaption( i18n("Writing to phone...")); | 1239 | setCaption( i18n("Writing to phone...")); |
1222 | if ( PhoneFormat::writeToPhone( cal ) ) | 1240 | if ( PhoneFormat::writeToPhone( cal ) ) |
1223 | setCaption( i18n("Export to phone successful!")); | 1241 | setCaption( i18n("Export to phone successful!")); |
1224 | else | 1242 | else |
1225 | setCaption( i18n("Error exporting to phone!")); | 1243 | setCaption( i18n("Error exporting to phone!")); |
1226 | delete cal; | 1244 | delete cal; |
1227 | } | 1245 | } |
1228 | 1246 | ||
1229 | 1247 | ||
1230 | void MainWindow::setDefaultPreferences() | 1248 | void MainWindow::setDefaultPreferences() |
1231 | { | 1249 | { |
1232 | KOPrefs *p = KOPrefs::instance(); | 1250 | KOPrefs *p = KOPrefs::instance(); |
1233 | 1251 | ||
1234 | p->mCompactDialogs = true; | 1252 | p->mCompactDialogs = true; |
1235 | p->mConfirm = true; | 1253 | p->mConfirm = true; |
1236 | // p->mEnableQuickTodo = false; | 1254 | // p->mEnableQuickTodo = false; |
1237 | 1255 | ||
1238 | } | 1256 | } |
1239 | 1257 | ||
1240 | QString MainWindow::resourcePath() | 1258 | QString MainWindow::resourcePath() |
1241 | { | 1259 | { |
1242 | return KGlobal::iconLoader()->iconPath(); | 1260 | return KGlobal::iconLoader()->iconPath(); |
1243 | } | 1261 | } |
1244 | 1262 | ||
1245 | void MainWindow::displayText( QString text ,QString cap ) | 1263 | void MainWindow::displayText( QString text ,QString cap ) |
1246 | { | 1264 | { |
1247 | QDialog dia( this, "name", true ); ; | 1265 | QDialog dia( this, "name", true ); ; |
1248 | dia.setCaption( cap ); | 1266 | dia.setCaption( cap ); |
1249 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1267 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1250 | lay->setSpacing( 3 ); | 1268 | lay->setSpacing( 3 ); |
1251 | lay->setMargin( 3 ); | 1269 | lay->setMargin( 3 ); |
1252 | QTextBrowser tb ( &dia ); | 1270 | QTextBrowser tb ( &dia ); |
1253 | lay->addWidget( &tb ); | 1271 | lay->addWidget( &tb ); |
1254 | tb.setText( text ); | 1272 | tb.setText( text ); |
1255 | #ifdef DESKTOP_VERSION | 1273 | #ifdef DESKTOP_VERSION |
1256 | dia.resize( 640, 480); | 1274 | dia.resize( 640, 480); |
1257 | #else | 1275 | #else |
1258 | dia.showMaximized(); | 1276 | dia.showMaximized(); |
1259 | #endif | 1277 | #endif |
1260 | dia.exec(); | 1278 | dia.exec(); |
1261 | } | 1279 | } |
1262 | void MainWindow::displayFile( QString fn, QString cap ) | 1280 | void MainWindow::displayFile( QString fn, QString cap ) |
1263 | { | 1281 | { |
1264 | QString fileName = resourcePath() + fn; | 1282 | QString fileName = resourcePath() + fn; |
1265 | QString text; | 1283 | QString text; |
1266 | QFile file( fileName ); | 1284 | QFile file( fileName ); |
1267 | if (!file.open( IO_ReadOnly ) ) { | 1285 | if (!file.open( IO_ReadOnly ) ) { |
1268 | return ; | 1286 | return ; |
1269 | 1287 | ||
1270 | } | 1288 | } |
1271 | QTextStream ts( &file ); | 1289 | QTextStream ts( &file ); |
1272 | text = ts.read(); | 1290 | text = ts.read(); |
1273 | file.close(); | 1291 | file.close(); |
1274 | displayText( text, cap); | 1292 | displayText( text, cap); |
1275 | } | 1293 | } |
1276 | void MainWindow::features() | 1294 | void MainWindow::features() |
1277 | { | 1295 | { |
1278 | 1296 | ||
1279 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1297 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1280 | } | 1298 | } |
1281 | 1299 | ||
1282 | void MainWindow::usertrans() | 1300 | void MainWindow::usertrans() |
1283 | { | 1301 | { |
1284 | 1302 | ||
1285 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1303 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1286 | } | 1304 | } |
1287 | 1305 | ||
1288 | void MainWindow::synchowto() | 1306 | void MainWindow::synchowto() |
1289 | { | 1307 | { |
1290 | #if 0 | 1308 | #if 0 |
1291 | QPtrList<Incidence> er = mCalendar->rawIncidences(); | 1309 | QPtrList<Incidence> er = mCalendar->rawIncidences(); |
1292 | Incidence* inR = er.first(); | 1310 | Incidence* inR = er.first(); |
1293 | VCalFormat vf; | 1311 | VCalFormat vf; |
1294 | QString strout; | 1312 | QString strout; |
1295 | while ( inR ) { | 1313 | while ( inR ) { |
1296 | if ( inR->type() == "Todo" ) | 1314 | if ( inR->type() == "Todo" ) |
1297 | strout = vf.todoToString( (Todo *) inR ); | 1315 | strout = vf.todoToString( (Todo *) inR ); |
1298 | if ( inR->type() == "Event" ) | 1316 | if ( inR->type() == "Event" ) |
1299 | strout = vf.eventToString( (Event *) inR ); | 1317 | strout = vf.eventToString( (Event *) inR ); |
1300 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); | 1318 | qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); |
1301 | inR = er.next(); | 1319 | inR = er.next(); |
1302 | } | 1320 | } |
1303 | #endif | 1321 | #endif |
1304 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1322 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1305 | } | 1323 | } |
1306 | void MainWindow::faq() | 1324 | void MainWindow::faq() |
1307 | { | 1325 | { |
1308 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1326 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1309 | 1327 | ||
1310 | } | 1328 | } |
1311 | void MainWindow::whatsNew() | 1329 | void MainWindow::whatsNew() |
1312 | { | 1330 | { |
1313 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1331 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1314 | 1332 | ||
1315 | } | 1333 | } |
1316 | void MainWindow::licence() | 1334 | void MainWindow::licence() |
1317 | { | 1335 | { |
1318 | KApplication::showLicence(); | 1336 | KApplication::showLicence(); |
1319 | 1337 | ||
1320 | } | 1338 | } |
1321 | void MainWindow::about() | 1339 | void MainWindow::about() |
1322 | { | 1340 | { |
1323 | QString version; | 1341 | QString version; |
1324 | #include <../version> | 1342 | #include <../version> |
1325 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1343 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1326 | i18n("KOrganizer/Platform-independent\n") + | 1344 | i18n("KOrganizer/Platform-independent\n") + |
1327 | "(KO/Pi) " + version + " - " + | 1345 | "(KO/Pi) " + version + " - " + |
1328 | 1346 | ||
1329 | #ifdef DESKTOP_VERSION | 1347 | #ifdef DESKTOP_VERSION |
1330 | i18n("Desktop Edition\n") + | 1348 | i18n("Desktop Edition\n") + |
1331 | #else | 1349 | #else |
1332 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1350 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1333 | #endif | 1351 | #endif |
1334 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); | 1352 | i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); |
1335 | } | 1353 | } |
1336 | void MainWindow::keyBindings() | 1354 | void MainWindow::keyBindings() |
1337 | { | 1355 | { |
1338 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1356 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1339 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1357 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1340 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1358 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1341 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1359 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1342 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1360 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1343 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1361 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1344 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1362 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1345 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1363 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1346 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1364 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1347 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1365 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1348 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1366 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1349 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1367 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1350 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1368 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1351 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1369 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1352 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1370 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1353 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1371 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1354 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1372 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1355 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1373 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1356 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1374 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1357 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1375 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1358 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1376 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1359 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1377 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1360 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1378 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1361 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1379 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1362 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1380 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1363 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1381 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1364 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1382 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1365 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1383 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1366 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1384 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1367 | i18n("<p><h3>In list view:</h3></p>\n") + | 1385 | i18n("<p><h3>In list view:</h3></p>\n") + |
1368 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1386 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1369 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1387 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1370 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1388 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1371 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1389 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1372 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1390 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1373 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1391 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1374 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1392 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1375 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1393 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1376 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1394 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1377 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1395 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1378 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1396 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1379 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1397 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1380 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1398 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1381 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1399 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1382 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1400 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1383 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1401 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1384 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1402 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1385 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1403 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1386 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1404 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1387 | displayText( text, cap); | 1405 | displayText( text, cap); |
1388 | 1406 | ||
1389 | } | 1407 | } |
1390 | void MainWindow::aboutAutoSaving() | 1408 | void MainWindow::aboutAutoSaving() |
1391 | { | 1409 | { |
1392 | QMessageBox* msg; | 1410 | QMessageBox* msg; |
1393 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1411 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1394 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, | 1412 | i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, |
1395 | QMessageBox::Ok, | 1413 | QMessageBox::Ok, |
1396 | QMessageBox::NoButton, | 1414 | QMessageBox::NoButton, |
1397 | QMessageBox::NoButton); | 1415 | QMessageBox::NoButton); |
1398 | msg->exec(); | 1416 | msg->exec(); |
1399 | delete msg; | 1417 | delete msg; |
1400 | 1418 | ||
1401 | 1419 | ||
1402 | } | 1420 | } |
1403 | void MainWindow::aboutKnownBugs() | 1421 | void MainWindow::aboutKnownBugs() |
1404 | { | 1422 | { |
1405 | QMessageBox* msg; | 1423 | QMessageBox* msg; |
1406 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1424 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1407 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1425 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1408 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1426 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1409 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1427 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1410 | i18n("\nor report them in the bugtracker on\n") + | 1428 | i18n("\nor report them in the bugtracker on\n") + |
1411 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1429 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1412 | QMessageBox::NoIcon, | 1430 | QMessageBox::NoIcon, |
1413 | QMessageBox::Ok, | 1431 | QMessageBox::Ok, |
1414 | QMessageBox::NoButton, | 1432 | QMessageBox::NoButton, |
1415 | QMessageBox::NoButton); | 1433 | QMessageBox::NoButton); |
1416 | msg->exec(); | 1434 | msg->exec(); |
1417 | delete msg; | 1435 | delete msg; |
1418 | 1436 | ||
1419 | } | 1437 | } |
1420 | 1438 | ||
1421 | QString MainWindow::defaultFileName() | 1439 | QString MainWindow::defaultFileName() |
1422 | { | 1440 | { |
1423 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1441 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1424 | } | 1442 | } |
1425 | QString MainWindow::syncFileName() | 1443 | QString MainWindow::syncFileName() |
1426 | { | 1444 | { |
1427 | #ifdef _WIN32_ | 1445 | #ifdef _WIN32_ |
1428 | return locateLocal( "tmp", "synccalendar.ics" ); | 1446 | return locateLocal( "tmp", "synccalendar.ics" ); |
1429 | #else | 1447 | #else |
1430 | return QString( "/tmp/kopitempfile.ics" ); | 1448 | return QString( "/tmp/kopitempfile.ics" ); |
1431 | #endif | 1449 | #endif |
1432 | } | 1450 | } |
1433 | 1451 | ||
1434 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1452 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1435 | { | 1453 | { |
1436 | if ( !incidence ) { | 1454 | if ( !incidence ) { |
1437 | enableIncidenceActions( false ); | 1455 | enableIncidenceActions( false ); |
1438 | 1456 | ||
1439 | mNewSubTodoAction->setEnabled( false ); | 1457 | mNewSubTodoAction->setEnabled( false ); |
1440 | setCaptionToDates(); | 1458 | setCaptionToDates(); |
1441 | return; | 1459 | return; |
1442 | 1460 | ||
1443 | } | 1461 | } |
1444 | 1462 | ||
1445 | //KGlobal::locale()->formatDateTime(nextA, true); | 1463 | //KGlobal::locale()->formatDateTime(nextA, true); |
1446 | QString startString = ""; | 1464 | QString startString = ""; |
1447 | if ( incidence->type() != "Todo" ) { | 1465 | if ( incidence->type() != "Todo" ) { |
1448 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1466 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1449 | if ( incidence->doesFloat() ) { | 1467 | if ( incidence->doesFloat() ) { |
1450 | startString += ": "+incidence->dtStartDateStr( true ); | 1468 | startString += ": "+incidence->dtStartDateStr( true ); |
1451 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1469 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1452 | 1470 | ||
1453 | } else { | 1471 | } else { |
1454 | startString = ": "+incidence->dtStartStr(true); | 1472 | startString = ": "+incidence->dtStartStr(true); |
1455 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1473 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1456 | 1474 | ||
1457 | } | 1475 | } |
1458 | 1476 | ||
1459 | } else { | 1477 | } else { |
1460 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1478 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1461 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1479 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1462 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1480 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1463 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1481 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1464 | } | 1482 | } |
1465 | 1483 | ||
1466 | } | 1484 | } |
1467 | else | 1485 | else |
1468 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1486 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1469 | if ( !incidence->location().isEmpty() ) | 1487 | if ( !incidence->location().isEmpty() ) |
1470 | startString += " (" +incidence->location()+")"; | 1488 | startString += " (" +incidence->location()+")"; |
1471 | setCaption( incidence->summary()+startString); | 1489 | setCaption( incidence->summary()+startString); |
1472 | 1490 | ||
1473 | enableIncidenceActions( true ); | 1491 | enableIncidenceActions( true ); |
1474 | 1492 | ||
1475 | if ( incidence->type() == "Event" ) { | 1493 | if ( incidence->type() == "Event" ) { |
1476 | mShowAction->setText( i18n("Show Event...") ); | 1494 | mShowAction->setText( i18n("Show Event...") ); |
1477 | mEditAction->setText( i18n("Edit Event...") ); | 1495 | mEditAction->setText( i18n("Edit Event...") ); |
1478 | mDeleteAction->setText( i18n("Delete Event...") ); | 1496 | mDeleteAction->setText( i18n("Delete Event...") ); |
1479 | 1497 | ||
1480 | mNewSubTodoAction->setEnabled( false ); | 1498 | mNewSubTodoAction->setEnabled( false ); |
1481 | } else if ( incidence->type() == "Todo" ) { | 1499 | } else if ( incidence->type() == "Todo" ) { |
1482 | mShowAction->setText( i18n("Show Todo...") ); | 1500 | mShowAction->setText( i18n("Show Todo...") ); |
1483 | mEditAction->setText( i18n("Edit Todo...") ); | 1501 | mEditAction->setText( i18n("Edit Todo...") ); |
1484 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1502 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1485 | 1503 | ||
1486 | mNewSubTodoAction->setEnabled( true ); | 1504 | mNewSubTodoAction->setEnabled( true ); |
1487 | } else { | 1505 | } else { |
1488 | mShowAction->setText( i18n("Show...") ); | 1506 | mShowAction->setText( i18n("Show...") ); |
1489 | mShowAction->setText( i18n("Edit...") ); | 1507 | mShowAction->setText( i18n("Edit...") ); |
1490 | mShowAction->setText( i18n("Delete...") ); | 1508 | mShowAction->setText( i18n("Delete...") ); |
1491 | 1509 | ||
1492 | mNewSubTodoAction->setEnabled( false ); | 1510 | mNewSubTodoAction->setEnabled( false ); |
1493 | } | 1511 | } |
1494 | } | 1512 | } |
1495 | 1513 | ||
1496 | void MainWindow::enableIncidenceActions( bool enabled ) | 1514 | void MainWindow::enableIncidenceActions( bool enabled ) |
1497 | { | 1515 | { |
1498 | mShowAction->setEnabled( enabled ); | 1516 | mShowAction->setEnabled( enabled ); |
1499 | mEditAction->setEnabled( enabled ); | 1517 | mEditAction->setEnabled( enabled ); |
1500 | mDeleteAction->setEnabled( enabled ); | 1518 | mDeleteAction->setEnabled( enabled ); |
1519 | |||
1520 | mCloneAction->setEnabled( enabled ); | ||
1521 | mMoveAction->setEnabled( enabled ); | ||
1522 | mBeamAction->setEnabled( enabled ); | ||
1523 | mCancelAction->setEnabled( enabled ); | ||
1501 | } | 1524 | } |
1502 | 1525 | ||
1503 | void MainWindow::importOL() | 1526 | void MainWindow::importOL() |
1504 | { | 1527 | { |
1505 | #ifdef _WIN32_ | 1528 | #ifdef _WIN32_ |
1506 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1529 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1507 | id->exec(); | 1530 | id->exec(); |
1508 | delete id; | 1531 | delete id; |
1509 | mView->updateView(); | 1532 | mView->updateView(); |
1510 | #endif | 1533 | #endif |
1511 | } | 1534 | } |
1512 | void MainWindow::importBday() | 1535 | void MainWindow::importBday() |
1513 | { | 1536 | { |
1514 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1537 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1515 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1538 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1516 | i18n("Import!"), i18n("Cancel"), 0, | 1539 | i18n("Import!"), i18n("Cancel"), 0, |
1517 | 0, 1 ); | 1540 | 0, 1 ); |
1518 | if ( result == 0 ) { | 1541 | if ( result == 0 ) { |
1519 | mView->importBday(); | 1542 | mView->importBday(); |
1520 | 1543 | ||
1521 | } | 1544 | } |
1522 | 1545 | ||
1523 | 1546 | ||
1524 | } | 1547 | } |
1525 | void MainWindow::importQtopia() | 1548 | void MainWindow::importQtopia() |
1526 | { | 1549 | { |
1527 | #ifndef DESKTOP_VERSION | 1550 | #ifndef DESKTOP_VERSION |
1528 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1551 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1529 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), | 1552 | i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), |
1530 | i18n("Import!"), i18n("Cancel"), 0, | 1553 | i18n("Import!"), i18n("Cancel"), 0, |
1531 | 0, 1 ); | 1554 | 0, 1 ); |
1532 | if ( result == 0 ) { | 1555 | if ( result == 0 ) { |
1533 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1556 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1534 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1557 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1535 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1558 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1536 | mView->importQtopia( categories, datebook, todolist ); | 1559 | mView->importQtopia( categories, datebook, todolist ); |
1537 | } | 1560 | } |
1538 | #else | 1561 | #else |
1539 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1562 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1540 | i18n("Not supported \non desktop!\n"), | 1563 | i18n("Not supported \non desktop!\n"), |
1541 | i18n("Ok"), i18n("Cancel"), 0, | 1564 | i18n("Ok"), i18n("Cancel"), 0, |
1542 | 0, 1 ); | 1565 | 0, 1 ); |
1543 | 1566 | ||
1544 | #endif | 1567 | #endif |
1545 | } | 1568 | } |
1546 | 1569 | ||
1547 | void MainWindow::saveOnClose() | 1570 | void MainWindow::saveOnClose() |
1548 | { | 1571 | { |
1549 | KOPrefs *p = KOPrefs::instance(); | 1572 | KOPrefs *p = KOPrefs::instance(); |
1550 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1573 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1551 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1574 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1552 | iconToolBar->y() > height()/2; | 1575 | iconToolBar->y() > height()/2; |
1553 | mView->writeSettings(); | 1576 | mView->writeSettings(); |
1554 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1577 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1555 | save(); | 1578 | save(); |
1556 | } | 1579 | } |
1557 | void MainWindow::slotModifiedChanged( bool changed ) | 1580 | void MainWindow::slotModifiedChanged( bool changed ) |
1558 | { | 1581 | { |
1559 | if ( mBlockAtStartup ) | 1582 | if ( mBlockAtStartup ) |
1560 | return; | 1583 | return; |
1561 | int msec; | 1584 | int msec; |
1562 | // we store the changes after 1 minute, | 1585 | // we store the changes after 1 minute, |
1563 | // and for safety reasons after 10 minutes again | 1586 | // and for safety reasons after 10 minutes again |
1564 | if ( !mBlockSaveFlag ) | 1587 | if ( !mBlockSaveFlag ) |
1565 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1588 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1566 | else | 1589 | else |
1567 | msec = 1000 * 600; | 1590 | msec = 1000 * 600; |
1568 | mSaveTimer.start( msec, true ); // 1 minute | 1591 | mSaveTimer.start( msec, true ); // 1 minute |
1569 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1592 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1570 | mCalendarModifiedFlag = true; | 1593 | mCalendarModifiedFlag = true; |
1571 | } | 1594 | } |
1572 | void MainWindow::save() | 1595 | void MainWindow::save() |
1573 | { | 1596 | { |
1574 | if ( mBlockSaveFlag ) | 1597 | if ( mBlockSaveFlag ) |
1575 | return; | 1598 | return; |
1576 | bool store = mBlockSaveFlag; | 1599 | bool store = mBlockSaveFlag; |
1577 | mBlockSaveFlag = true; | 1600 | mBlockSaveFlag = true; |
1578 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1601 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1579 | 1602 | ||
1580 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1603 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1581 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1604 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1582 | qDebug("KO: Start saving data to file!"); | 1605 | qDebug("KO: Start saving data to file!"); |
1583 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 1606 | mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
1584 | mView->saveCalendar( defaultFileName() ); | 1607 | mView->saveCalendar( defaultFileName() ); |
1585 | 1608 | ||
1586 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1609 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1587 | mView->watchSavedFile(); | 1610 | mView->watchSavedFile(); |
1588 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1611 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1589 | QString savemes; | 1612 | QString savemes; |
1590 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1613 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1591 | setCaption(savemes); | 1614 | setCaption(savemes); |
1592 | } else | 1615 | } else |
1593 | setCaption(i18n("Saving cancelled!")); | 1616 | setCaption(i18n("Saving cancelled!")); |
1594 | mCalendarModifiedFlag = false; | 1617 | mCalendarModifiedFlag = false; |
1595 | mBlockSaveFlag = store; | 1618 | mBlockSaveFlag = store; |
1596 | } | 1619 | } |
1597 | 1620 | ||
1598 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1621 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1599 | { | 1622 | { |
1600 | if ( !e->isAutoRepeat() ) { | 1623 | if ( !e->isAutoRepeat() ) { |
1601 | mFlagKeyPressed = false; | 1624 | mFlagKeyPressed = false; |
1602 | } | 1625 | } |
1603 | } | 1626 | } |
1604 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1627 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1605 | { | 1628 | { |
1606 | qApp->processEvents(); | 1629 | qApp->processEvents(); |
1607 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1630 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1608 | e->ignore(); | 1631 | e->ignore(); |
1609 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1632 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1610 | return; | 1633 | return; |
1611 | } | 1634 | } |
1612 | if (! e->isAutoRepeat() ) | 1635 | if (! e->isAutoRepeat() ) |
1613 | mFlagKeyPressed = true; | 1636 | mFlagKeyPressed = true; |
1614 | KOPrefs *p = KOPrefs::instance(); | 1637 | KOPrefs *p = KOPrefs::instance(); |
1615 | bool showSelectedDates = false; | 1638 | bool showSelectedDates = false; |
1616 | int size; | 1639 | int size; |
1617 | int pro = 0; | 1640 | int pro = 0; |
1618 | //qDebug("MainWindow::keyPressEvent "); | 1641 | //qDebug("MainWindow::keyPressEvent "); |
1619 | switch ( e->key() ) { | 1642 | switch ( e->key() ) { |
1620 | case Qt::Key_Right: | 1643 | case Qt::Key_Right: |
1621 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1644 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1622 | mView->goNextMonth(); | 1645 | mView->goNextMonth(); |
1623 | else | 1646 | else |
1624 | mView->goNext(); | 1647 | mView->goNext(); |
1625 | showSelectedDates = true; | 1648 | showSelectedDates = true; |
1626 | break; | 1649 | break; |
1627 | case Qt::Key_Left: | 1650 | case Qt::Key_Left: |
1628 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1651 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1629 | mView->goPreviousMonth(); | 1652 | mView->goPreviousMonth(); |
1630 | else | 1653 | else |
1631 | mView->goPrevious(); | 1654 | mView->goPrevious(); |
1632 | showSelectedDates = true; | 1655 | showSelectedDates = true; |
1633 | break; | 1656 | break; |
1634 | case Qt::Key_Down: | 1657 | case Qt::Key_Down: |
1635 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1658 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1636 | break; | 1659 | break; |
1637 | case Qt::Key_Up: | 1660 | case Qt::Key_Up: |
1638 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1661 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1639 | break; | 1662 | break; |
1640 | case Qt::Key_I: | 1663 | case Qt::Key_I: |
1641 | mView->showIncidence(); | 1664 | mView->showIncidence(); |
1642 | break; | 1665 | break; |
1643 | case Qt::Key_Delete: | 1666 | case Qt::Key_Delete: |
1644 | case Qt::Key_Backspace: | 1667 | case Qt::Key_Backspace: |
1645 | mView->deleteIncidence(); | 1668 | mView->deleteIncidence(); |
1646 | break; | 1669 | break; |
1647 | case Qt::Key_D: | 1670 | case Qt::Key_D: |
1648 | mView->viewManager()->showDayView(); | 1671 | mView->viewManager()->showDayView(); |
1649 | showSelectedDates = true; | 1672 | showSelectedDates = true; |
1650 | break; | 1673 | break; |
1651 | case Qt::Key_O: | 1674 | case Qt::Key_O: |
1652 | mView->toggleFilerEnabled( ); | 1675 | mView->toggleFilerEnabled( ); |
1653 | break; | 1676 | break; |
1654 | case Qt::Key_0: | 1677 | case Qt::Key_0: |
1655 | case Qt::Key_1: | 1678 | case Qt::Key_1: |
1656 | case Qt::Key_2: | 1679 | case Qt::Key_2: |
1657 | case Qt::Key_3: | 1680 | case Qt::Key_3: |
1658 | case Qt::Key_4: | 1681 | case Qt::Key_4: |
1659 | case Qt::Key_5: | 1682 | case Qt::Key_5: |
1660 | case Qt::Key_6: | 1683 | case Qt::Key_6: |
1661 | case Qt::Key_7: | 1684 | case Qt::Key_7: |
1662 | case Qt::Key_8: | 1685 | case Qt::Key_8: |
1663 | case Qt::Key_9: | 1686 | case Qt::Key_9: |
1664 | pro = e->key()-48; | 1687 | pro = e->key()-48; |
1665 | if ( pro == 0 ) | 1688 | if ( pro == 0 ) |
1666 | pro = 10; | 1689 | pro = 10; |
1667 | if ( e->state() == Qt::ControlButton) | 1690 | if ( e->state() == Qt::ControlButton) |
1668 | pro += 10; | 1691 | pro += 10; |
1669 | break; | 1692 | break; |
1670 | case Qt::Key_M: | 1693 | case Qt::Key_M: |
1671 | mView->viewManager()->showMonthView(); | 1694 | mView->viewManager()->showMonthView(); |
1672 | showSelectedDates = true; | 1695 | showSelectedDates = true; |
1673 | break; | 1696 | break; |
1674 | case Qt::Key_Insert: | 1697 | case Qt::Key_Insert: |
1675 | mView->newEvent(); | 1698 | mView->newEvent(); |
1676 | break; | 1699 | break; |
1677 | case Qt::Key_S : | 1700 | case Qt::Key_S : |
1678 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1701 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1679 | mView->newSubTodo(); | 1702 | mView->newSubTodo(); |
1680 | else | 1703 | else |
1681 | mView->dialogManager()->showSearchDialog(); | 1704 | mView->dialogManager()->showSearchDialog(); |
1682 | break; | 1705 | break; |
1683 | case Qt::Key_Y : | 1706 | case Qt::Key_Y : |
1684 | case Qt::Key_Z : | 1707 | case Qt::Key_Z : |
1685 | mView->viewManager()->showWorkWeekView(); | 1708 | mView->viewManager()->showWorkWeekView(); |
1686 | showSelectedDates = true; | 1709 | showSelectedDates = true; |
1687 | break; | 1710 | break; |
1688 | case Qt::Key_U : | 1711 | case Qt::Key_U : |
1689 | mView->viewManager()->showWeekView(); | 1712 | mView->viewManager()->showWeekView(); |
1690 | showSelectedDates = true; | 1713 | showSelectedDates = true; |
1691 | break; | 1714 | break; |
1692 | case Qt::Key_H : | 1715 | case Qt::Key_H : |
1693 | keyBindings(); | 1716 | keyBindings(); |
1694 | break; | 1717 | break; |
1695 | case Qt::Key_W: | 1718 | case Qt::Key_W: |
1696 | mView->viewManager()->showWhatsNextView(); | 1719 | mView->viewManager()->showWhatsNextView(); |
1697 | break; | 1720 | break; |
1698 | case Qt::Key_L: | 1721 | case Qt::Key_L: |
1699 | mView->viewManager()->showListView(); | 1722 | mView->viewManager()->showListView(); |
1700 | break; | 1723 | break; |
1701 | case Qt::Key_N: | 1724 | case Qt::Key_N: |
1702 | mView->viewManager()->showNextXView(); | 1725 | mView->viewManager()->showNextXView(); |
1703 | showSelectedDates = true; | 1726 | showSelectedDates = true; |
1704 | break; | 1727 | break; |
1705 | case Qt::Key_V: | 1728 | case Qt::Key_V: |
1706 | mView->viewManager()->showTodoView(); | 1729 | mView->viewManager()->showTodoView(); |
1707 | break; | 1730 | break; |
1708 | case Qt::Key_C: | 1731 | case Qt::Key_C: |
1709 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1732 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1710 | break; | 1733 | break; |
1711 | case Qt::Key_P: | 1734 | case Qt::Key_P: |
1712 | mView->showDatePicker( ); | 1735 | mView->showDatePicker( ); |
1713 | break; | 1736 | break; |
1714 | case Qt::Key_F: | 1737 | case Qt::Key_F: |
1715 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1738 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1716 | mView->editFilters(); | 1739 | mView->editFilters(); |
1717 | else | 1740 | else |
1718 | mView->toggleFilter(); | 1741 | mView->toggleFilter(); |
1719 | break; | 1742 | break; |
1720 | case Qt::Key_X: | 1743 | case Qt::Key_X: |
1721 | mView->toggleDateNavigatorWidget(); | 1744 | mView->toggleDateNavigatorWidget(); |
1722 | break; | 1745 | break; |
1723 | case Qt::Key_Space: | 1746 | case Qt::Key_Space: |
1724 | mView->toggleExpand(); | 1747 | mView->toggleExpand(); |
1725 | break; | 1748 | break; |
1726 | case Qt::Key_A: | 1749 | case Qt::Key_A: |
1727 | mView->toggleAllDaySize(); | 1750 | mView->toggleAllDaySize(); |
1728 | break; | 1751 | break; |
1729 | case Qt::Key_T: | 1752 | case Qt::Key_T: |
1730 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1753 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1731 | mView->newTodo(); | 1754 | mView->newTodo(); |
1732 | else { | 1755 | else { |
1733 | mView->goToday(); | 1756 | mView->goToday(); |
1734 | showSelectedDates = true; | 1757 | showSelectedDates = true; |
1735 | } | 1758 | } |
1736 | break; | 1759 | break; |
1737 | case Qt::Key_J: | 1760 | case Qt::Key_J: |
1738 | mView->viewManager()->showJournalView(); | 1761 | mView->viewManager()->showJournalView(); |
1739 | break; | 1762 | break; |
1740 | case Qt::Key_B: | 1763 | case Qt::Key_B: |
1741 | mView->editIncidenceDescription();; | 1764 | mView->editIncidenceDescription();; |
1742 | break; | 1765 | break; |
1743 | // case Qt::Key_Return: | 1766 | // case Qt::Key_Return: |
1744 | case Qt::Key_E: | 1767 | case Qt::Key_E: |
1745 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1768 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1746 | mView->newEvent(); | 1769 | mView->newEvent(); |
1747 | else | 1770 | else |
1748 | mView->editIncidence(); | 1771 | mView->editIncidence(); |
1749 | break; | 1772 | break; |
1750 | case Qt::Key_Plus: | 1773 | case Qt::Key_Plus: |
1751 | size = p->mHourSize +2; | 1774 | size = p->mHourSize +2; |
1752 | if ( size <= 18 ) | 1775 | if ( size <= 18 ) |
1753 | configureAgenda( size ); | 1776 | configureAgenda( size ); |
1754 | break; | 1777 | break; |
1755 | case Qt::Key_Minus: | 1778 | case Qt::Key_Minus: |
1756 | size = p->mHourSize - 2; | 1779 | size = p->mHourSize - 2; |
1757 | if ( size >= 4 ) | 1780 | if ( size >= 4 ) |
1758 | configureAgenda( size ); | 1781 | configureAgenda( size ); |
1759 | break; | 1782 | break; |
1760 | 1783 | ||
1761 | 1784 | ||
1762 | default: | 1785 | default: |
1763 | e->ignore(); | 1786 | e->ignore(); |
1764 | } | 1787 | } |
1765 | if ( pro > 0 ) { | 1788 | if ( pro > 0 ) { |
1766 | mView->selectFilter( pro-1 ); | 1789 | mView->selectFilter( pro-1 ); |
1767 | } | 1790 | } |
1768 | if ( showSelectedDates ) { | 1791 | if ( showSelectedDates ) { |
1769 | ;// setCaptionToDates(); | 1792 | ;// setCaptionToDates(); |
1770 | } | 1793 | } |
1771 | 1794 | ||
1772 | } | 1795 | } |
1773 | 1796 | ||
1774 | void MainWindow::fillFilterMenu() | 1797 | void MainWindow::fillFilterMenu() |
1775 | { | 1798 | { |
1776 | selectFilterMenu->clear(); | 1799 | selectFilterMenu->clear(); |
1777 | bool disable = false; | 1800 | bool disable = false; |
1778 | if ( mView->filterView()->filtersEnabled() ) { | 1801 | if ( mView->filterView()->filtersEnabled() ) { |
1779 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1802 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1780 | } | 1803 | } |
1781 | else { | 1804 | else { |
1782 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1805 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1783 | disable = true; | 1806 | disable = true; |
1784 | } | 1807 | } |
1785 | selectFilterMenu->insertSeparator(); | 1808 | selectFilterMenu->insertSeparator(); |
1786 | QPtrList<CalFilter> fili = mView->filters(); | 1809 | QPtrList<CalFilter> fili = mView->filters(); |
1787 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1810 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1788 | CalFilter *filter = fili.first(); | 1811 | CalFilter *filter = fili.first(); |
1789 | int iii = 1; | 1812 | int iii = 1; |
1790 | while(filter) { | 1813 | while(filter) { |
1791 | selectFilterMenu->insertItem( filter->name(), iii ); | 1814 | selectFilterMenu->insertItem( filter->name(), iii ); |
1792 | if ( filter == curfilter) | 1815 | if ( filter == curfilter) |
1793 | selectFilterMenu->setItemChecked( iii, true ); | 1816 | selectFilterMenu->setItemChecked( iii, true ); |
1794 | if ( disable ) | 1817 | if ( disable ) |
1795 | selectFilterMenu->setItemEnabled( iii, false ); | 1818 | selectFilterMenu->setItemEnabled( iii, false ); |
1796 | filter = fili.next(); | 1819 | filter = fili.next(); |
1797 | ++iii; | 1820 | ++iii; |
1798 | } | 1821 | } |
1799 | } | 1822 | } |
1800 | void MainWindow::selectFilter( int fil ) | 1823 | void MainWindow::selectFilter( int fil ) |
1801 | { | 1824 | { |
1802 | if ( fil == 0 ) { | 1825 | if ( fil == 0 ) { |
1803 | mView->toggleFilerEnabled( ); | 1826 | mView->toggleFilerEnabled( ); |
1804 | } else { | 1827 | } else { |
1805 | mView->selectFilter( fil-1 ); | 1828 | mView->selectFilter( fil-1 ); |
1806 | } | 1829 | } |
1807 | } | 1830 | } |
1808 | void MainWindow::configureToolBar( int item ) | 1831 | void MainWindow::configureToolBar( int item ) |
1809 | { | 1832 | { |
1810 | 1833 | ||
1811 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1834 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1812 | KOPrefs *p = KOPrefs::instance(); | 1835 | KOPrefs *p = KOPrefs::instance(); |
1813 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1836 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1814 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1837 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1815 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1838 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1816 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1839 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1817 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1840 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1818 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1841 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1819 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1842 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1820 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1843 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1821 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1844 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1822 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1845 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1823 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1846 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1824 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1847 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1825 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1848 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1826 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1849 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1827 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1850 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1828 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1851 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1829 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1852 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1830 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1853 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1831 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1854 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1832 | // initActions(); | 1855 | // initActions(); |
1833 | } | 1856 | } |
1834 | 1857 | ||
1835 | void MainWindow::setCaptionToDates() | 1858 | void MainWindow::setCaptionToDates() |
1836 | { | 1859 | { |
1837 | QString selDates; | 1860 | QString selDates; |
1838 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1861 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1839 | if (mView->startDate() < mView->endDate() ) | 1862 | if (mView->startDate() < mView->endDate() ) |
1840 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1863 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1841 | setCaption( i18n("Dates: ") + selDates ); | 1864 | setCaption( i18n("Dates: ") + selDates ); |
1842 | 1865 | ||
1843 | } | 1866 | } |
1844 | // parameter item == 0: reinit | 1867 | // parameter item == 0: reinit |
1845 | void MainWindow::configureAgenda( int item ) | 1868 | void MainWindow::configureAgenda( int item ) |
1846 | { | 1869 | { |
1847 | 1870 | ||
1848 | KOPrefs *p = KOPrefs::instance(); | 1871 | KOPrefs *p = KOPrefs::instance(); |
1849 | 1872 | ||
1850 | int i; | 1873 | int i; |
1851 | if ( item == 1 ) { | 1874 | if ( item == 1 ) { |
1852 | mView->toggleAllDaySize(); | 1875 | mView->toggleAllDaySize(); |
1853 | return; | 1876 | return; |
1854 | } | 1877 | } |
1855 | // do not allow 4 for widgets higher than 480 | 1878 | // do not allow 4 for widgets higher than 480 |
1856 | // if ( QApplication::desktop()->height() > 480 ) { | 1879 | // if ( QApplication::desktop()->height() > 480 ) { |
1857 | // if ( item == 4 ) | 1880 | // if ( item == 4 ) |
1858 | // item = 6; | 1881 | // item = 6; |
1859 | // } | 1882 | // } |
1860 | for ( i = 4; i <= 18; i= i+2 ) | 1883 | for ( i = 4; i <= 18; i= i+2 ) |
1861 | configureAgendaMenu->setItemChecked( i, false ); | 1884 | configureAgendaMenu->setItemChecked( i, false ); |
1862 | configureAgendaMenu->setItemChecked( item, true ); | 1885 | configureAgendaMenu->setItemChecked( item, true ); |
1863 | if ( p->mHourSize == item ) | 1886 | if ( p->mHourSize == item ) |
1864 | return; | 1887 | return; |
1865 | p->mHourSize=item; | 1888 | p->mHourSize=item; |
1866 | mView->viewManager()->agendaView()->updateConfig(); | 1889 | mView->viewManager()->agendaView()->updateConfig(); |
1867 | } | 1890 | } |
1868 | 1891 | ||
1869 | void MainWindow::saveCalendar() | 1892 | void MainWindow::saveCalendar() |
1870 | { | 1893 | { |
1871 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1894 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1872 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1895 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1873 | 1896 | ||
1874 | if ( fn == "" ) | 1897 | if ( fn == "" ) |
1875 | return; | 1898 | return; |
1876 | QFileInfo info; | 1899 | QFileInfo info; |
1877 | info.setFile( fn ); | 1900 | info.setFile( fn ); |
1878 | QString mes; | 1901 | QString mes; |
1879 | bool createbup = true; | 1902 | bool createbup = true; |
1880 | if ( info. exists() ) { | 1903 | if ( info. exists() ) { |
1881 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1904 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1882 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1905 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1883 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1906 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1884 | 0, 1 ); | 1907 | 0, 1 ); |
1885 | if ( result != 0 ) { | 1908 | if ( result != 0 ) { |
1886 | createbup = false; | 1909 | createbup = false; |
1887 | } | 1910 | } |
1888 | } | 1911 | } |
1889 | if ( createbup ) { | 1912 | if ( createbup ) { |
1890 | mView->saveCalendar( fn ); | 1913 | mView->saveCalendar( fn ); |
1891 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1914 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1892 | KOPrefs::instance()->mLastSaveFile = fn; | 1915 | KOPrefs::instance()->mLastSaveFile = fn; |
1893 | setCaption(mes); | 1916 | setCaption(mes); |
1894 | } | 1917 | } |
1895 | } | 1918 | } |
1896 | void MainWindow::loadCalendar() | 1919 | void MainWindow::loadCalendar() |
1897 | { | 1920 | { |
1898 | 1921 | ||
1899 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1922 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1900 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1923 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1901 | 1924 | ||
1902 | if ( fn == "" ) | 1925 | if ( fn == "" ) |
1903 | return; | 1926 | return; |
1904 | QFileInfo info; | 1927 | QFileInfo info; |
1905 | info.setFile( fn ); | 1928 | info.setFile( fn ); |
1906 | QString mess; | 1929 | QString mess; |
1907 | bool loadbup = true; | 1930 | bool loadbup = true; |
1908 | if ( info. exists() ) { | 1931 | if ( info. exists() ) { |
1909 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1932 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1910 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1933 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1911 | mess, | 1934 | mess, |
1912 | i18n("Load!"), i18n("Cancel"), 0, | 1935 | i18n("Load!"), i18n("Cancel"), 0, |
1913 | 0, 1 ); | 1936 | 0, 1 ); |
1914 | if ( result != 0 ) { | 1937 | if ( result != 0 ) { |
1915 | loadbup = false; | 1938 | loadbup = false; |
1916 | } | 1939 | } |
1917 | } else { | 1940 | } else { |
1918 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1941 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1919 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1942 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1920 | 0, 1 ); | 1943 | 0, 1 ); |
1921 | 1944 | ||
1922 | return; | 1945 | return; |
1923 | } | 1946 | } |
1924 | if ( loadbup ) { | 1947 | if ( loadbup ) { |
1925 | mView->openCalendar( fn ); | 1948 | mView->openCalendar( fn ); |
1926 | KOPrefs::instance()->mLastLoadFile = fn; | 1949 | KOPrefs::instance()->mLastLoadFile = fn; |
1927 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1950 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1928 | setCaption(mess); | 1951 | setCaption(mess); |
1929 | } | 1952 | } |
1930 | 1953 | ||
1931 | } | 1954 | } |
1932 | void MainWindow::quickImportIcal() | 1955 | void MainWindow::quickImportIcal() |
1933 | { | 1956 | { |
1934 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1957 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1935 | } | 1958 | } |
1936 | void MainWindow::importFile( QString fn, bool quick ) | 1959 | void MainWindow::importFile( QString fn, bool quick ) |
1937 | { | 1960 | { |
1938 | QFileInfo info; | 1961 | QFileInfo info; |
1939 | info.setFile( fn ); | 1962 | info.setFile( fn ); |
1940 | QString mess; | 1963 | QString mess; |
1941 | bool loadbup = true; | 1964 | bool loadbup = true; |
1942 | if ( !info. exists() ) { | 1965 | if ( !info. exists() ) { |
1943 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1966 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1944 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1967 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1945 | mess ); | 1968 | mess ); |
1946 | return; | 1969 | return; |
1947 | } | 1970 | } |
1948 | int result = 0; | 1971 | int result = 0; |
1949 | if ( !quick ) { | 1972 | if ( !quick ) { |
1950 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1973 | mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1951 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1974 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1952 | mess, | 1975 | mess, |
1953 | "Import", "Cancel", 0, | 1976 | "Import", "Cancel", 0, |
1954 | 0, 1 ); | 1977 | 0, 1 ); |
1955 | } | 1978 | } |
1956 | if ( result == 0 ) { | 1979 | if ( result == 0 ) { |
1957 | if ( mView->openCalendar( fn, true )) { | 1980 | if ( mView->openCalendar( fn, true )) { |
1958 | KOPrefs::instance()->mLastImportFile = fn; | 1981 | KOPrefs::instance()->mLastImportFile = fn; |
1959 | setCaption(i18n("Imported file successfully")); | 1982 | setCaption(i18n("Imported file successfully")); |
1960 | } else { | 1983 | } else { |
1961 | setCaption(i18n("Error importing file")); | 1984 | setCaption(i18n("Error importing file")); |
1962 | } | 1985 | } |
1963 | } | 1986 | } |
1964 | } | 1987 | } |
1965 | 1988 | ||
1966 | void MainWindow::importIcal() | 1989 | void MainWindow::importIcal() |
1967 | { | 1990 | { |
1968 | 1991 | ||
1969 | QString fn =KOPrefs::instance()->mLastImportFile; | 1992 | QString fn =KOPrefs::instance()->mLastImportFile; |
1970 | 1993 | ||
1971 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1994 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1972 | if ( fn == "" ) | 1995 | if ( fn == "" ) |
1973 | return; | 1996 | return; |
1974 | importFile( fn, true ); | 1997 | importFile( fn, true ); |
1975 | 1998 | ||
1976 | } | 1999 | } |
1977 | 2000 | ||
1978 | void MainWindow::exportVCalendar() | 2001 | void MainWindow::exportVCalendar() |
1979 | { | 2002 | { |
1980 | QString fn = KOPrefs::instance()->mLastVcalFile; | 2003 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1981 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 2004 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1982 | if ( fn == "" ) | 2005 | if ( fn == "" ) |
1983 | return; | 2006 | return; |
1984 | QFileInfo info; | 2007 | QFileInfo info; |
1985 | info.setFile( fn ); | 2008 | info.setFile( fn ); |
1986 | QString mes; | 2009 | QString mes; |
1987 | bool createbup = true; | 2010 | bool createbup = true; |
1988 | if ( info. exists() ) { | 2011 | if ( info. exists() ) { |
1989 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 2012 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1990 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 2013 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1991 | i18n("Overwrite!"), i18n("Cancel"), 0, | 2014 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1992 | 0, 1 ); | 2015 | 0, 1 ); |
1993 | if ( result != 0 ) { | 2016 | if ( result != 0 ) { |
1994 | createbup = false; | 2017 | createbup = false; |
1995 | } | 2018 | } |
1996 | } | 2019 | } |
1997 | if ( createbup ) { | 2020 | if ( createbup ) { |
1998 | if ( mView->exportVCalendar( fn ) ) { | 2021 | if ( mView->exportVCalendar( fn ) ) { |
1999 | KOPrefs::instance()->mLastVcalFile = fn; | 2022 | KOPrefs::instance()->mLastVcalFile = fn; |
2000 | if ( fn.length() > 20 ) | 2023 | if ( fn.length() > 20 ) |
2001 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 2024 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
2002 | else | 2025 | else |
2003 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 2026 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
2004 | setCaption(mes); | 2027 | setCaption(mes); |
2005 | } | 2028 | } |
2006 | } | 2029 | } |
2007 | 2030 | ||
2008 | } | 2031 | } |
2009 | QString MainWindow::getPassword( ) | 2032 | QString MainWindow::getPassword( ) |
2010 | { | 2033 | { |
2011 | QString retfile = ""; | 2034 | QString retfile = ""; |
2012 | QDialog dia ( this, "input-dialog", true ); | 2035 | QDialog dia ( this, "input-dialog", true ); |
2013 | QLineEdit lab ( &dia ); | 2036 | QLineEdit lab ( &dia ); |
2014 | lab.setEchoMode( QLineEdit::Password ); | 2037 | lab.setEchoMode( QLineEdit::Password ); |
2015 | QVBoxLayout lay( &dia ); | 2038 | QVBoxLayout lay( &dia ); |
2016 | lay.setMargin(7); | 2039 | lay.setMargin(7); |
2017 | lay.setSpacing(7); | 2040 | lay.setSpacing(7); |
2018 | lay.addWidget( &lab); | 2041 | lay.addWidget( &lab); |
2019 | dia.setFixedSize( 230,50 ); | 2042 | dia.setFixedSize( 230,50 ); |
2020 | dia.setCaption( i18n("Enter password") ); | 2043 | dia.setCaption( i18n("Enter password") ); |
2021 | QPushButton pb ( "OK", &dia); | 2044 | QPushButton pb ( "OK", &dia); |
2022 | lay.addWidget( &pb ); | 2045 | lay.addWidget( &pb ); |
2023 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2046 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2024 | dia.show(); | 2047 | dia.show(); |
2025 | int res = dia.exec(); | 2048 | int res = dia.exec(); |
2026 | if ( res ) | 2049 | if ( res ) |
2027 | retfile = lab.text(); | 2050 | retfile = lab.text(); |
2028 | dia.hide(); | 2051 | dia.hide(); |
2029 | qApp->processEvents(); | 2052 | qApp->processEvents(); |
2030 | return retfile; | 2053 | return retfile; |
2031 | 2054 | ||
2032 | } | 2055 | } |
2033 | 2056 | ||
2034 | void MainWindow::enableQuick() | 2057 | void MainWindow::enableQuick() |
2035 | { | 2058 | { |
2036 | QDialog dia ( this, "input-dialog", true ); | 2059 | QDialog dia ( this, "input-dialog", true ); |
2037 | QLineEdit lab ( &dia ); | 2060 | QLineEdit lab ( &dia ); |
2038 | QVBoxLayout lay( &dia ); | 2061 | QVBoxLayout lay( &dia ); |
2039 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); | 2062 | lab.setText( KOPrefs::instance()->mPassiveSyncPort ); |
2040 | lay.setMargin(7); | 2063 | lay.setMargin(7); |
2041 | lay.setSpacing(7); | 2064 | lay.setSpacing(7); |
2042 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); | 2065 | QLabel label ( i18n("Port number (Default: 9197)"), &dia ); |
2043 | lay.addWidget( &label); | 2066 | lay.addWidget( &label); |
2044 | lay.addWidget( &lab); | 2067 | lay.addWidget( &lab); |
2045 | 2068 | ||
2046 | QLineEdit lepw ( &dia ); | 2069 | QLineEdit lepw ( &dia ); |
2047 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); | 2070 | lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); |
2048 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); | 2071 | QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); |
2049 | lay.addWidget( &label2); | 2072 | lay.addWidget( &label2); |
2050 | lay.addWidget( &lepw); | 2073 | lay.addWidget( &lepw); |
2051 | dia.setFixedSize( 230,80 ); | 2074 | dia.setFixedSize( 230,80 ); |
2052 | dia.setCaption( i18n("Enter port for Pi-Sync") ); | 2075 | dia.setCaption( i18n("Enter port for Pi-Sync") ); |
2053 | QPushButton pb ( "OK", &dia); | 2076 | QPushButton pb ( "OK", &dia); |
2054 | lay.addWidget( &pb ); | 2077 | lay.addWidget( &pb ); |
2055 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2078 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
2056 | dia.show(); | 2079 | dia.show(); |
2057 | if ( ! dia.exec() ) | 2080 | if ( ! dia.exec() ) |
2058 | return; | 2081 | return; |
2059 | dia.hide(); | 2082 | dia.hide(); |
2060 | qApp->processEvents(); | 2083 | qApp->processEvents(); |
2061 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); | 2084 | KOPrefs::instance()->mPassiveSyncPw = lepw.text(); |
2062 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); | 2085 | KOPrefs::instance()->mPassiveSyncPort = lab.text(); |
2063 | bool ok; | 2086 | bool ok; |
2064 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); | 2087 | Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); |
2065 | if ( ! ok ) { | 2088 | if ( ! ok ) { |
2066 | KMessageBox::information( this, i18n("No valid port")); | 2089 | KMessageBox::information( this, i18n("No valid port")); |
2067 | return; | 2090 | return; |
2068 | } | 2091 | } |
2069 | //qDebug("port %d ", port); | 2092 | //qDebug("port %d ", port); |
2070 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); | 2093 | mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); |
2071 | mServerSocket->setFileName( defaultFileName() ); | 2094 | mServerSocket->setFileName( defaultFileName() ); |
2072 | //qDebug("connected "); | 2095 | //qDebug("connected "); |
2073 | if ( !mServerSocket->ok() ) { | 2096 | if ( !mServerSocket->ok() ) { |
2074 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); | 2097 | KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); |
2075 | delete mServerSocket; | 2098 | delete mServerSocket; |
2076 | mServerSocket = 0; | 2099 | mServerSocket = 0; |
2077 | return; | 2100 | return; |
2078 | } | 2101 | } |
2079 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); | 2102 | connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); |
2080 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); | 2103 | connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); |
2081 | } | 2104 | } |
2082 | 2105 | ||
2083 | void MainWindow::getFile( bool success ) | 2106 | void MainWindow::getFile( bool success ) |
2084 | { | 2107 | { |
2085 | if ( ! success ) { | 2108 | if ( ! success ) { |
2086 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2109 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2087 | return; | 2110 | return; |
2088 | } | 2111 | } |
2089 | mView->watchSavedFile(); | 2112 | mView->watchSavedFile(); |
2090 | mView->openCalendar( defaultFileName() ); | 2113 | mView->openCalendar( defaultFileName() ); |
2091 | setCaption( i18n("Pi-Sync successful!") ); | 2114 | setCaption( i18n("Pi-Sync successful!") ); |
2092 | 2115 | ||
2093 | } | 2116 | } |
2094 | 2117 | ||
2095 | 2118 | ||
2096 | void MainWindow::syncPi() | 2119 | void MainWindow::syncPi() |
2097 | { | 2120 | { |
2098 | qApp->processEvents(); | 2121 | qApp->processEvents(); |
2099 | bool ok; | 2122 | bool ok; |
2100 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); | 2123 | Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); |
2101 | if ( ! ok ) { | 2124 | if ( ! ok ) { |
2102 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); | 2125 | setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); |
2103 | return; | 2126 | return; |
2104 | } | 2127 | } |
2105 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); | 2128 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); |
2106 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); | 2129 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); |
2107 | setCaption( i18n("Sending request for remote file ...") ); | 2130 | setCaption( i18n("Sending request for remote file ...") ); |
2108 | commandSocket->readFile( syncFileName() ); | 2131 | commandSocket->readFile( syncFileName() ); |
2109 | } | 2132 | } |
2110 | 2133 | ||
2111 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) | 2134 | void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) |
2112 | { | 2135 | { |
2113 | qDebug("MainWindow::deleteCommandSocket %d", state); | 2136 | qDebug("MainWindow::deleteCommandSocket %d", state); |
2114 | 2137 | ||
2115 | //enum { success, errorW, errorR, quiet }; | 2138 | //enum { success, errorW, errorR, quiet }; |
2116 | if ( state == KCommandSocket::errorR ) { | 2139 | if ( state == KCommandSocket::errorR ) { |
2117 | setCaption( i18n("ERROR: Receiving remote file failed.") ); | 2140 | setCaption( i18n("ERROR: Receiving remote file failed.") ); |
2118 | delete s; | 2141 | delete s; |
2119 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2142 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2120 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2143 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2121 | commandSocket->sendStop(); | 2144 | commandSocket->sendStop(); |
2122 | return; | 2145 | return; |
2123 | 2146 | ||
2124 | } else if ( state == KCommandSocket::errorW ) { | 2147 | } else if ( state == KCommandSocket::errorW ) { |
2125 | setCaption( i18n("ERROR:Writing back file failed.") ); | 2148 | setCaption( i18n("ERROR:Writing back file failed.") ); |
2126 | 2149 | ||
2127 | } else if ( state == KCommandSocket::successR ) { | 2150 | } else if ( state == KCommandSocket::successR ) { |
2128 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); | 2151 | QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); |
2129 | 2152 | ||
2130 | } else if ( state == KCommandSocket::successW ) { | 2153 | } else if ( state == KCommandSocket::successW ) { |
2131 | setCaption( i18n("Pi-Sync succesful!") ); | 2154 | setCaption( i18n("Pi-Sync succesful!") ); |
2132 | } | 2155 | } |
2133 | 2156 | ||
2134 | delete s; | 2157 | delete s; |
2135 | } | 2158 | } |
2136 | 2159 | ||
2137 | void MainWindow::readFileFromSocket() | 2160 | void MainWindow::readFileFromSocket() |
2138 | { | 2161 | { |
2139 | QString fileName = syncFileName(); | 2162 | QString fileName = syncFileName(); |
2140 | setCaption( i18n("Remote file saved to temp file.") ); | 2163 | setCaption( i18n("Remote file saved to temp file.") ); |
2141 | if ( ! syncWithFile( fileName , true ) ) { | 2164 | if ( ! syncWithFile( fileName , true ) ) { |
2142 | setCaption( i18n("Syncing failed.") ); | 2165 | setCaption( i18n("Syncing failed.") ); |
2143 | qDebug("Syncing failed "); | 2166 | qDebug("Syncing failed "); |
2144 | return; | 2167 | return; |
2145 | } | 2168 | } |
2146 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); | 2169 | KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); |
2147 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); | 2170 | connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); |
2148 | if ( KOPrefs::instance()->mWriteBackFile ) | 2171 | if ( KOPrefs::instance()->mWriteBackFile ) |
2149 | commandSocket->writeFile( fileName ); | 2172 | commandSocket->writeFile( fileName ); |
2150 | else { | 2173 | else { |
2151 | commandSocket->sendStop(); | 2174 | commandSocket->sendStop(); |
2152 | setCaption( i18n("Pi-Sync succesful!") ); | 2175 | setCaption( i18n("Pi-Sync succesful!") ); |
2153 | } | 2176 | } |
2154 | } | 2177 | } |
2155 | 2178 | ||
2156 | void MainWindow::syncLocalFile() | 2179 | void MainWindow::syncLocalFile() |
2157 | { | 2180 | { |
2158 | 2181 | ||
2159 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; | 2182 | QString fn =KOPrefs::instance()->mLastSyncedLocalFile; |
2160 | 2183 | ||
2161 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); | 2184 | fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); |
2162 | if ( fn == "" ) | 2185 | if ( fn == "" ) |
2163 | return; | 2186 | return; |
2164 | //mView->setSyncDevice("local-file" ); | 2187 | //mView->setSyncDevice("local-file" ); |
2165 | if ( syncWithFile( fn, false ) ) { | 2188 | if ( syncWithFile( fn, false ) ) { |
2166 | // Event* e = mView->getLastSyncEvent(); | 2189 | // Event* e = mView->getLastSyncEvent(); |
2167 | // e->setReadOnly( false ); | 2190 | // e->setReadOnly( false ); |
2168 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2191 | // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2169 | // e->setReadOnly( true ); | 2192 | // e->setReadOnly( true ); |
2170 | } | 2193 | } |
2171 | 2194 | ||
2172 | } | 2195 | } |
2173 | 2196 | ||
2174 | bool MainWindow::syncWithFile( QString fn , bool quick ) | 2197 | bool MainWindow::syncWithFile( QString fn , bool quick ) |
2175 | { | 2198 | { |
2176 | bool ret = false; | 2199 | bool ret = false; |
2177 | QFileInfo info; | 2200 | QFileInfo info; |
2178 | info.setFile( fn ); | 2201 | info.setFile( fn ); |
2179 | QString mess; | 2202 | QString mess; |
2180 | bool loadbup = true; | 2203 | bool loadbup = true; |
2181 | if ( !info. exists() ) { | 2204 | if ( !info. exists() ) { |
2182 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); | 2205 | mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); |
2183 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2206 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2184 | mess ); | 2207 | mess ); |
2185 | return ret; | 2208 | return ret; |
2186 | } | 2209 | } |
2187 | int result = 0; | 2210 | int result = 0; |
2188 | if ( !quick ) { | 2211 | if ( !quick ) { |
2189 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 2212 | mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
2190 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2213 | result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2191 | mess, | 2214 | mess, |
2192 | i18n("Sync"), i18n("Cancel"), 0, | 2215 | i18n("Sync"), i18n("Cancel"), 0, |
2193 | 0, 1 ); | 2216 | 0, 1 ); |
2194 | if ( result ) | 2217 | if ( result ) |
2195 | return false; | 2218 | return false; |
2196 | } | 2219 | } |
2197 | if ( KOPrefs::instance()->mAskForPreferences ) | 2220 | if ( KOPrefs::instance()->mAskForPreferences ) |
2198 | mView->edit_sync_options(); | 2221 | mView->edit_sync_options(); |
2199 | if ( result == 0 ) { | 2222 | if ( result == 0 ) { |
2200 | //qDebug("Now sycing ... "); | 2223 | //qDebug("Now sycing ... "); |
2201 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) | 2224 | if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) |
2202 | setCaption( i18n("Synchronization successful") ); | 2225 | setCaption( i18n("Synchronization successful") ); |
2203 | else | 2226 | else |
2204 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); | 2227 | setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); |
2205 | if ( ! quick ) | 2228 | if ( ! quick ) |
2206 | KOPrefs::instance()->mLastSyncedLocalFile = fn; | 2229 | KOPrefs::instance()->mLastSyncedLocalFile = fn; |
2207 | slotModifiedChanged( true ); | 2230 | slotModifiedChanged( true ); |
2208 | } | 2231 | } |
2209 | return ret; | 2232 | return ret; |
2210 | } | 2233 | } |
2211 | void MainWindow::quickSyncLocalFile() | 2234 | void MainWindow::quickSyncLocalFile() |
2212 | { | 2235 | { |
2213 | //mView->setSyncDevice("local-file" ); | 2236 | //mView->setSyncDevice("local-file" ); |
2214 | //qDebug("quickSyncLocalFile() "); | 2237 | //qDebug("quickSyncLocalFile() "); |
2215 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { | 2238 | if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { |
2216 | // Event* e = mView->getLastSyncEvent(); | 2239 | // Event* e = mView->getLastSyncEvent(); |
2217 | // e->setReadOnly( false ); | 2240 | // e->setReadOnly( false ); |
2218 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); | 2241 | // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); |
2219 | // e->setReadOnly( true ); | 2242 | // e->setReadOnly( true ); |
2220 | 2243 | ||
2221 | } | 2244 | } |
2222 | } | 2245 | } |
2223 | 2246 | ||
2224 | void MainWindow::confSync() | 2247 | void MainWindow::confSync() |
2225 | { | 2248 | { |
2226 | mView->confSync(); | 2249 | mView->confSync(); |
2227 | fillSyncMenu(); | 2250 | fillSyncMenu(); |
2228 | } | 2251 | } |
2229 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) | 2252 | void MainWindow::syncRemote( KSyncProfile* prof, bool ask) |
2230 | { | 2253 | { |
2231 | QString question; | 2254 | QString question; |
2232 | if ( ask ) { | 2255 | if ( ask ) { |
2233 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; | 2256 | question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; |
2234 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 2257 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
2235 | question, | 2258 | question, |
2236 | i18n("Yes"), i18n("No"), | 2259 | i18n("Yes"), i18n("No"), |
2237 | 0, 0 ) != 0 ) | 2260 | 0, 0 ) != 0 ) |
2238 | return; | 2261 | return; |
2239 | } | 2262 | } |
2240 | QString command = prof->getPreSyncCommand(); | 2263 | QString command = prof->getPreSyncCommand(); |
2241 | int fi; | 2264 | int fi; |
2242 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2265 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2243 | QString pwd = getPassword(); | 2266 | QString pwd = getPassword(); |
2244 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2267 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2245 | 2268 | ||
2246 | } | 2269 | } |
2247 | int maxlen = 30; | 2270 | int maxlen = 30; |
2248 | if ( QApplication::desktop()->width() > 320 ) | 2271 | if ( QApplication::desktop()->width() > 320 ) |
2249 | maxlen += 25; | 2272 | maxlen += 25; |
2250 | setCaption ( i18n( "Copy remote file to local machine..." ) ); | 2273 | setCaption ( i18n( "Copy remote file to local machine..." ) ); |
2251 | int fileSize = 0; | 2274 | int fileSize = 0; |
2252 | int result = system ( command ); | 2275 | int result = system ( command ); |
2253 | // 0 : okay | 2276 | // 0 : okay |
2254 | // 256: no such file or dir | 2277 | // 256: no such file or dir |
2255 | // | 2278 | // |
2256 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); | 2279 | qDebug("KO: Remote copy result(0 = okay): %d ",result ); |
2257 | if ( result != 0 ) { | 2280 | if ( result != 0 ) { |
2258 | int len = maxlen; | 2281 | int len = maxlen; |
2259 | while ( len < command.length() ) { | 2282 | while ( len < command.length() ) { |
2260 | command.insert( len , "\n" ); | 2283 | command.insert( len , "\n" ); |
2261 | len += maxlen +2; | 2284 | len += maxlen +2; |
2262 | } | 2285 | } |
2263 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; | 2286 | question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; |
2264 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), | 2287 | QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), |
2265 | question, | 2288 | question, |
2266 | i18n("Okay!")) ; | 2289 | i18n("Okay!")) ; |
2267 | setCaption ("KO/Pi"); | 2290 | setCaption ("KO/Pi"); |
2268 | return; | 2291 | return; |
2269 | } | 2292 | } |
2270 | setCaption ( i18n( "Copying succeed." ) ); | 2293 | setCaption ( i18n( "Copying succeed." ) ); |
2271 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); | 2294 | //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); |
2272 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { | 2295 | if ( syncWithFile( prof->getLocalTempFile(), true ) ) { |
2273 | // Event* e = mView->getLastSyncEvent(); | 2296 | // Event* e = mView->getLastSyncEvent(); |
2274 | // e->setReadOnly( false ); | 2297 | // e->setReadOnly( false ); |
2275 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 2298 | // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
2276 | // e->setReadOnly( true ); | 2299 | // e->setReadOnly( true ); |
2277 | if ( KOPrefs::instance()->mWriteBackFile ) { | 2300 | if ( KOPrefs::instance()->mWriteBackFile ) { |
2278 | command = prof->getPostSyncCommand(); | 2301 | command = prof->getPostSyncCommand(); |
2279 | int fi; | 2302 | int fi; |
2280 | if ( (fi = command.find("$PWD$")) > 0 ) { | 2303 | if ( (fi = command.find("$PWD$")) > 0 ) { |
2281 | QString pwd = getPassword(); | 2304 | QString pwd = getPassword(); |
2282 | command = command.left( fi )+ pwd + command.mid( fi+5 ); | 2305 | command = command.left( fi )+ pwd + command.mid( fi+5 ); |
2283 | 2306 | ||
2284 | } | 2307 | } |
2285 | setCaption ( i18n( "Writing back file ..." ) ); | 2308 | setCaption ( i18n( "Writing back file ..." ) ); |
2286 | result = system ( command ); | 2309 | result = system ( command ); |
2287 | qDebug("KO: Writing back file result: %d ", result); | 2310 | qDebug("KO: Writing back file result: %d ", result); |
2288 | if ( result != 0 ) { | 2311 | if ( result != 0 ) { |
2289 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); | 2312 | setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); |
2290 | return; | 2313 | return; |
2291 | } else { | 2314 | } else { |
2292 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); | 2315 | setCaption ( i18n( "Syncronization sucessfully completed" ) ); |
2293 | } | 2316 | } |
2294 | } | 2317 | } |
2295 | } | 2318 | } |
2296 | return; | 2319 | return; |
2297 | } | 2320 | } |
2298 | 2321 | ||
2299 | void MainWindow::syncSharp() | 2322 | void MainWindow::syncSharp() |
2300 | { | 2323 | { |
2301 | if ( mCalendarModifiedFlag ) | 2324 | if ( mCalendarModifiedFlag ) |
2302 | save(); | 2325 | save(); |
2303 | mView->syncSharp(); | 2326 | mView->syncSharp(); |
2304 | slotModifiedChanged( true ); | 2327 | slotModifiedChanged( true ); |
2305 | 2328 | ||
2306 | } | 2329 | } |
2307 | void MainWindow::syncPhone() | 2330 | void MainWindow::syncPhone() |
2308 | { | 2331 | { |
2309 | if ( mCalendarModifiedFlag ) | 2332 | if ( mCalendarModifiedFlag ) |
2310 | save(); | 2333 | save(); |
2311 | mView->syncPhone(); | 2334 | mView->syncPhone(); |
2312 | slotModifiedChanged( true ); | 2335 | slotModifiedChanged( true ); |
2313 | 2336 | ||
2314 | } | 2337 | } |
2315 | 2338 | ||
2316 | void MainWindow::printSel( ) | 2339 | void MainWindow::printSel( ) |
2317 | { | 2340 | { |
2318 | mView->viewManager()->agendaView()->agenda()->printSelection(); | 2341 | mView->viewManager()->agendaView()->agenda()->printSelection(); |
2319 | } | 2342 | } |
2320 | 2343 | ||
2321 | void MainWindow::printCal() | 2344 | void MainWindow::printCal() |
2322 | { | 2345 | { |
2323 | mView->print();//mCp->showDialog(); | 2346 | mView->print();//mCp->showDialog(); |
2324 | } | 2347 | } |
2325 | 2348 | ||
2326 | 2349 | ||
2327 | 2350 | ||
2328 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) | 2351 | KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) |
2329 | { | 2352 | { |
2330 | mPassWord = pw; | 2353 | mPassWord = pw; |
2331 | mSocket = 0; | 2354 | mSocket = 0; |
2332 | mSyncActionDialog = 0; | 2355 | mSyncActionDialog = 0; |
2333 | blockRC = false; | 2356 | blockRC = false; |
2334 | }; | 2357 | }; |
2335 | 2358 | ||
2336 | void KServerSocket::newConnection ( int socket ) | 2359 | void KServerSocket::newConnection ( int socket ) |
2337 | { | 2360 | { |
2338 | // qDebug("KServerSocket:New connection %d ", socket); | 2361 | // qDebug("KServerSocket:New connection %d ", socket); |
2339 | if ( mSocket ) { | 2362 | if ( mSocket ) { |
2340 | qDebug("KServerSocket::newConnection Socket deleted! "); | 2363 | qDebug("KServerSocket::newConnection Socket deleted! "); |
2341 | delete mSocket; | 2364 | delete mSocket; |
2342 | mSocket = 0; | 2365 | mSocket = 0; |
2343 | } | 2366 | } |
2344 | mSocket = new QSocket( this ); | 2367 | mSocket = new QSocket( this ); |
2345 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); | 2368 | connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); |
2346 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); | 2369 | connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); |
2347 | mSocket->setSocket( socket ); | 2370 | mSocket->setSocket( socket ); |
2348 | } | 2371 | } |
2349 | 2372 | ||
2350 | void KServerSocket::discardClient() | 2373 | void KServerSocket::discardClient() |
2351 | { | 2374 | { |
2352 | //qDebug(" KServerSocket::discardClient()"); | 2375 | //qDebug(" KServerSocket::discardClient()"); |
2353 | if ( mSocket ) { | 2376 | if ( mSocket ) { |
2354 | delete mSocket; | 2377 | delete mSocket; |
2355 | mSocket = 0; | 2378 | mSocket = 0; |
2356 | } | 2379 | } |
2357 | //emit endConnect(); | 2380 | //emit endConnect(); |
2358 | } | 2381 | } |
2359 | void KServerSocket::readClient() | 2382 | void KServerSocket::readClient() |
2360 | { | 2383 | { |
2361 | if ( blockRC ) | 2384 | if ( blockRC ) |
2362 | return; | 2385 | return; |
2363 | if ( mSocket == 0 ) { | 2386 | if ( mSocket == 0 ) { |
2364 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); | 2387 | qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); |
2365 | return; | 2388 | return; |
2366 | } | 2389 | } |
2367 | qDebug("KServerSocket readClient()"); | 2390 | qDebug("KServerSocket readClient()"); |
2368 | if ( mSocket->canReadLine() ) { | 2391 | if ( mSocket->canReadLine() ) { |
2369 | QString line = mSocket->readLine(); | 2392 | QString line = mSocket->readLine(); |
2370 | qDebug("KServerSocket readline: %s ", line.latin1()); | 2393 | qDebug("KServerSocket readline: %s ", line.latin1()); |
2371 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); | 2394 | QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); |
2372 | if ( tokens[0] == "GET" ) { | 2395 | if ( tokens[0] == "GET" ) { |
2373 | if ( tokens[1] == mPassWord ) | 2396 | if ( tokens[1] == mPassWord ) |
2374 | //emit sendFile( mSocket ); | 2397 | //emit sendFile( mSocket ); |
2375 | send_file(); | 2398 | send_file(); |
2376 | else { | 2399 | else { |
2377 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); | 2400 | KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); |
2378 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2401 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2379 | } | 2402 | } |
2380 | } | 2403 | } |
2381 | if ( tokens[0] == "PUT" ) { | 2404 | if ( tokens[0] == "PUT" ) { |
2382 | if ( tokens[1] == mPassWord ) { | 2405 | if ( tokens[1] == mPassWord ) { |
2383 | //emit getFile( mSocket ); | 2406 | //emit getFile( mSocket ); |
2384 | blockRC = true; | 2407 | blockRC = true; |
2385 | get_file(); | 2408 | get_file(); |
2386 | } | 2409 | } |
2387 | else { | 2410 | else { |
2388 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); | 2411 | KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); |
2389 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); | 2412 | qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); |
2390 | } | 2413 | } |
2391 | } | 2414 | } |
2392 | if ( tokens[0] == "STOP" ) { | 2415 | if ( tokens[0] == "STOP" ) { |
2393 | //emit endConnect(); | 2416 | //emit endConnect(); |
2394 | end_connect(); | 2417 | end_connect(); |
2395 | } | 2418 | } |
2396 | } | 2419 | } |
2397 | } | 2420 | } |
2398 | void KServerSocket::end_connect() | 2421 | void KServerSocket::end_connect() |
2399 | { | 2422 | { |
2400 | delete mSyncActionDialog; | 2423 | delete mSyncActionDialog; |
2401 | mSyncActionDialog = 0; | 2424 | mSyncActionDialog = 0; |
2402 | } | 2425 | } |
2403 | void KServerSocket::send_file() | 2426 | void KServerSocket::send_file() |
2404 | { | 2427 | { |
2405 | //qDebug("MainWindow::sendFile(QSocket* s) "); | 2428 | //qDebug("MainWindow::sendFile(QSocket* s) "); |
2406 | if ( mSyncActionDialog ) | 2429 | if ( mSyncActionDialog ) |
2407 | delete mSyncActionDialog; | 2430 | delete mSyncActionDialog; |
2408 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); | 2431 | mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); |
2409 | mSyncActionDialog->setCaption(i18n("Received sync request")); | 2432 | mSyncActionDialog->setCaption(i18n("Received sync request")); |
2410 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); | 2433 | QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); |
2411 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); | 2434 | QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); |
2412 | lay->addWidget( label); | 2435 | lay->addWidget( label); |
2413 | lay->setMargin(7); | 2436 | lay->setMargin(7); |
2414 | lay->setSpacing(7); | 2437 | lay->setSpacing(7); |
2415 | mSyncActionDialog->setFixedSize( 230, 120); | 2438 | mSyncActionDialog->setFixedSize( 230, 120); |
2416 | mSyncActionDialog->show(); | 2439 | mSyncActionDialog->show(); |
2417 | qDebug("KSS::saving ... "); | 2440 | qDebug("KSS::saving ... "); |
2418 | emit saveFile(); | 2441 | emit saveFile(); |
2419 | qApp->processEvents(); | 2442 | qApp->processEvents(); |
2420 | QString fileName = mFileName; | 2443 | QString fileName = mFileName; |
2421 | QFile file( fileName ); | 2444 | QFile file( fileName ); |
2422 | if (!file.open( IO_ReadOnly ) ) { | 2445 | if (!file.open( IO_ReadOnly ) ) { |
2423 | delete mSyncActionDialog; | 2446 | delete mSyncActionDialog; |
2424 | mSyncActionDialog = 0; | 2447 | mSyncActionDialog = 0; |
2425 | qDebug("KSS::error open file "); | 2448 | qDebug("KSS::error open file "); |
2426 | mSocket->close(); | 2449 | mSocket->close(); |
2427 | if ( mSocket->state() == QSocket::Idle ) | 2450 | if ( mSocket->state() == QSocket::Idle ) |
2428 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2451 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2429 | return ; | 2452 | return ; |
2430 | 2453 | ||
2431 | } | 2454 | } |
2432 | mSyncActionDialog->setCaption( i18n("Sending file...") ); | 2455 | mSyncActionDialog->setCaption( i18n("Sending file...") ); |
2433 | QTextStream ts( &file ); | 2456 | QTextStream ts( &file ); |
2434 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2457 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2435 | QTextStream os( mSocket ); | 2458 | QTextStream os( mSocket ); |
2436 | os.setCodec( QTextCodec::codecForName("utf8") ); | 2459 | os.setCodec( QTextCodec::codecForName("utf8") ); |
2437 | //os.setEncoding( QTextStream::UnicodeUTF8 ); | 2460 | //os.setEncoding( QTextStream::UnicodeUTF8 ); |
2438 | while ( ! ts.atEnd() ) { | 2461 | while ( ! ts.atEnd() ) { |
2439 | os << ts.readLine() << "\n"; | 2462 | os << ts.readLine() << "\n"; |
2440 | } | 2463 | } |
2441 | //os << ts.read(); | 2464 | //os << ts.read(); |
2442 | file.close(); | 2465 | file.close(); |
2443 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); | 2466 | mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); |
2444 | mSocket->close(); | 2467 | mSocket->close(); |
2445 | if ( mSocket->state() == QSocket::Idle ) | 2468 | if ( mSocket->state() == QSocket::Idle ) |
2446 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2469 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2447 | } | 2470 | } |
2448 | void KServerSocket::get_file() | 2471 | void KServerSocket::get_file() |
2449 | { | 2472 | { |
2450 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); | 2473 | mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); |
2451 | 2474 | ||
2452 | piTime.start(); | 2475 | piTime.start(); |
2453 | piFileString = ""; | 2476 | piFileString = ""; |
2454 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); | 2477 | QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); |
2455 | } | 2478 | } |
2456 | 2479 | ||
2457 | 2480 | ||
2458 | void KServerSocket::readBackFileFromSocket() | 2481 | void KServerSocket::readBackFileFromSocket() |
2459 | { | 2482 | { |
2460 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); | 2483 | //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); |
2461 | while ( mSocket->canReadLine () ) { | 2484 | while ( mSocket->canReadLine () ) { |
2462 | piTime.restart(); | 2485 | piTime.restart(); |
2463 | QString line = mSocket->readLine (); | 2486 | QString line = mSocket->readLine (); |
2464 | piFileString += line; | 2487 | piFileString += line; |
2465 | //qDebug("readline: %s ", line.latin1()); | 2488 | //qDebug("readline: %s ", line.latin1()); |
2466 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); | 2489 | mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); |
2467 | 2490 | ||
2468 | } | 2491 | } |
2469 | if ( piTime.elapsed () < 3000 ) { | 2492 | if ( piTime.elapsed () < 3000 ) { |
2470 | // wait for more | 2493 | // wait for more |
2471 | //qDebug("waitformore "); | 2494 | //qDebug("waitformore "); |
2472 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); | 2495 | QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); |
2473 | return; | 2496 | return; |
2474 | } | 2497 | } |
2475 | QString fileName = mFileName; | 2498 | QString fileName = mFileName; |
2476 | QFile file ( fileName ); | 2499 | QFile file ( fileName ); |
2477 | if (!file.open( IO_WriteOnly ) ) { | 2500 | if (!file.open( IO_WriteOnly ) ) { |
2478 | delete mSyncActionDialog; | 2501 | delete mSyncActionDialog; |
2479 | mSyncActionDialog = 0; | 2502 | mSyncActionDialog = 0; |
2480 | qDebug("error open cal file "); | 2503 | qDebug("error open cal file "); |
2481 | piFileString = ""; | 2504 | piFileString = ""; |
2482 | emit file_received( false ); | 2505 | emit file_received( false ); |
2483 | blockRC = false; | 2506 | blockRC = false; |
2484 | return ; | 2507 | return ; |
2485 | 2508 | ||
2486 | } | 2509 | } |
2487 | 2510 | ||
2488 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2511 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2489 | QTextStream ts ( &file ); | 2512 | QTextStream ts ( &file ); |
2490 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2513 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2491 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); | 2514 | mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); |
2492 | ts << piFileString; | 2515 | ts << piFileString; |
2493 | mSocket->close(); | 2516 | mSocket->close(); |
2494 | if ( mSocket->state() == QSocket::Idle ) | 2517 | if ( mSocket->state() == QSocket::Idle ) |
2495 | QTimer::singleShot( 10, this , SLOT ( discardClient())); | 2518 | QTimer::singleShot( 10, this , SLOT ( discardClient())); |
2496 | file.close(); | 2519 | file.close(); |
2497 | delete mSyncActionDialog; | 2520 | delete mSyncActionDialog; |
2498 | mSyncActionDialog = 0; | 2521 | mSyncActionDialog = 0; |
2499 | piFileString = ""; | 2522 | piFileString = ""; |
2500 | blockRC = false; | 2523 | blockRC = false; |
2501 | emit file_received( true ); | 2524 | emit file_received( true ); |
2502 | 2525 | ||
2503 | } | 2526 | } |
2504 | 2527 | ||
2505 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) | 2528 | KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) |
2506 | { | 2529 | { |
2507 | mPassWord = password; | 2530 | mPassWord = password; |
2508 | mSocket = 0; | 2531 | mSocket = 0; |
2509 | mPort = port; | 2532 | mPort = port; |
2510 | mHost = host; | 2533 | mHost = host; |
2511 | 2534 | ||
2512 | mRetVal = quiet; | 2535 | mRetVal = quiet; |
2513 | mTimerSocket = new QTimer ( this ); | 2536 | mTimerSocket = new QTimer ( this ); |
2514 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); | 2537 | connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); |
2515 | } | 2538 | } |
2516 | void KCommandSocket::readFile( QString fn ) | 2539 | void KCommandSocket::readFile( QString fn ) |
2517 | { | 2540 | { |
2518 | if ( !mSocket ) { | 2541 | if ( !mSocket ) { |
2519 | mSocket = new QSocket( this ); | 2542 | mSocket = new QSocket( this ); |
2520 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); | 2543 | connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); |
2521 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2544 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2522 | } | 2545 | } |
2523 | mFileString = ""; | 2546 | mFileString = ""; |
2524 | mFileName = fn; | 2547 | mFileName = fn; |
2525 | mFirst = true; | 2548 | mFirst = true; |
2526 | mSocket->connectToHost( mHost, mPort ); | 2549 | mSocket->connectToHost( mHost, mPort ); |
2527 | QTextStream os( mSocket ); | 2550 | QTextStream os( mSocket ); |
2528 | os.setEncoding( QTextStream::UnicodeUTF8 ); | 2551 | os.setEncoding( QTextStream::UnicodeUTF8 ); |
2529 | os << "GET " << mPassWord << "\r\n"; | 2552 | os << "GET " << mPassWord << "\r\n"; |
2530 | mTimerSocket->start( 10000 ); | 2553 | mTimerSocket->start( 10000 ); |
2531 | } | 2554 | } |
2532 | 2555 | ||
2533 | void KCommandSocket::writeFile( QString fileName ) | 2556 | void KCommandSocket::writeFile( QString fileName ) |
2534 | { | 2557 | { |
2535 | if ( !mSocket ) { | 2558 | if ( !mSocket ) { |
2536 | mSocket = new QSocket( this ); | 2559 | mSocket = new QSocket( this ); |
2537 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2560 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2538 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); | 2561 | connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); |
2539 | } | 2562 | } |
2540 | mFileName = fileName ; | 2563 | mFileName = fileName ; |
2541 | mSocket->connectToHost( mHost, mPort ); | 2564 | mSocket->connectToHost( mHost, mPort ); |
2542 | } | 2565 | } |
2543 | void KCommandSocket::writeFileToSocket() | 2566 | void KCommandSocket::writeFileToSocket() |
2544 | { | 2567 | { |
2545 | QFile file2( mFileName ); | 2568 | QFile file2( mFileName ); |
2546 | if (!file2.open( IO_ReadOnly ) ) { | 2569 | if (!file2.open( IO_ReadOnly ) ) { |
2547 | mRetVal= errorW; | 2570 | mRetVal= errorW; |
2548 | mSocket->close(); | 2571 | mSocket->close(); |
2549 | if ( mSocket->state() == QSocket::Idle ) | 2572 | if ( mSocket->state() == QSocket::Idle ) |
2550 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2573 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2551 | return ; | 2574 | return ; |
2552 | } | 2575 | } |
2553 | QTextStream ts2( &file2 ); | 2576 | QTextStream ts2( &file2 ); |
2554 | ts2.setCodec( QTextCodec::codecForName("utf8") ); | 2577 | ts2.setCodec( QTextCodec::codecForName("utf8") ); |
2555 | QTextStream os2( mSocket ); | 2578 | QTextStream os2( mSocket ); |
2556 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2579 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2557 | os2 << "PUT " << mPassWord << "\r\n";; | 2580 | os2 << "PUT " << mPassWord << "\r\n";; |
2558 | while ( ! ts2.atEnd() ) { | 2581 | while ( ! ts2.atEnd() ) { |
2559 | os2 << ts2.readLine() << "\n"; | 2582 | os2 << ts2.readLine() << "\n"; |
2560 | } | 2583 | } |
2561 | mRetVal= successW; | 2584 | mRetVal= successW; |
2562 | file2.close(); | 2585 | file2.close(); |
2563 | mSocket->close(); | 2586 | mSocket->close(); |
2564 | if ( mSocket->state() == QSocket::Idle ) | 2587 | if ( mSocket->state() == QSocket::Idle ) |
2565 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2588 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2566 | } | 2589 | } |
2567 | void KCommandSocket::sendStop() | 2590 | void KCommandSocket::sendStop() |
2568 | { | 2591 | { |
2569 | if ( !mSocket ) { | 2592 | if ( !mSocket ) { |
2570 | mSocket = new QSocket( this ); | 2593 | mSocket = new QSocket( this ); |
2571 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2594 | connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2572 | } | 2595 | } |
2573 | mSocket->connectToHost( mHost, mPort ); | 2596 | mSocket->connectToHost( mHost, mPort ); |
2574 | QTextStream os2( mSocket ); | 2597 | QTextStream os2( mSocket ); |
2575 | os2.setCodec( QTextCodec::codecForName("utf8") ); | 2598 | os2.setCodec( QTextCodec::codecForName("utf8") ); |
2576 | os2 << "STOP\r\n"; | 2599 | os2 << "STOP\r\n"; |
2577 | mSocket->close(); | 2600 | mSocket->close(); |
2578 | if ( mSocket->state() == QSocket::Idle ) | 2601 | if ( mSocket->state() == QSocket::Idle ) |
2579 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); | 2602 | QTimer::singleShot( 10, this , SLOT ( deleteSocket())); |
2580 | } | 2603 | } |
2581 | 2604 | ||
2582 | void KCommandSocket::startReadFileFromSocket() | 2605 | void KCommandSocket::startReadFileFromSocket() |
2583 | { | 2606 | { |
2584 | if ( ! mFirst ) | 2607 | if ( ! mFirst ) |
2585 | return; | 2608 | return; |
2586 | mFirst = false; | 2609 | mFirst = false; |
2587 | mTimerSocket->stop(); | 2610 | mTimerSocket->stop(); |
2588 | mFileString = ""; | 2611 | mFileString = ""; |
2589 | mTime.start(); | 2612 | mTime.start(); |
2590 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); | 2613 | QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); |
2591 | 2614 | ||
2592 | } | 2615 | } |
2593 | void KCommandSocket::readFileFromSocket() | 2616 | void KCommandSocket::readFileFromSocket() |
2594 | { | 2617 | { |
2595 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); | 2618 | //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); |
2596 | while ( mSocket->canReadLine () ) { | 2619 | while ( mSocket->canReadLine () ) { |
2597 | mTime.restart(); | 2620 | mTime.restart(); |
2598 | QString line = mSocket->readLine (); | 2621 | QString line = mSocket->readLine (); |
2599 | mFileString += line; | 2622 | mFileString += line; |
2600 | //qDebug("readline: %s ", line.latin1()); | 2623 | //qDebug("readline: %s ", line.latin1()); |
2601 | } | 2624 | } |
2602 | if ( mTime.elapsed () < 3000 ) { | 2625 | if ( mTime.elapsed () < 3000 ) { |
2603 | // wait for more | 2626 | // wait for more |
2604 | //qDebug("waitformore "); | 2627 | //qDebug("waitformore "); |
2605 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); | 2628 | QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); |
2606 | return; | 2629 | return; |
2607 | } | 2630 | } |
2608 | QString fileName = mFileName; | 2631 | QString fileName = mFileName; |
2609 | QFile file ( fileName ); | 2632 | QFile file ( fileName ); |
2610 | if (!file.open( IO_WriteOnly ) ) { | 2633 | if (!file.open( IO_WriteOnly ) ) { |
2611 | mFileString = ""; | 2634 | mFileString = ""; |
2612 | mRetVal = errorR; | 2635 | mRetVal = errorR; |
2613 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); | 2636 | qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); |
2614 | deleteSocket(); | 2637 | deleteSocket(); |
2615 | return ; | 2638 | return ; |
2616 | 2639 | ||
2617 | } | 2640 | } |
2618 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); | 2641 | // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); |
2619 | QTextStream ts ( &file ); | 2642 | QTextStream ts ( &file ); |
2620 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 2643 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
2621 | ts << mFileString; | 2644 | ts << mFileString; |
2622 | file.close(); | 2645 | file.close(); |
2623 | mFileString = ""; | 2646 | mFileString = ""; |
2624 | mRetVal = successR; | 2647 | mRetVal = successR; |
2625 | mSocket->close(); | 2648 | mSocket->close(); |
2626 | // if state is not idle, deleteSocket(); is called via | 2649 | // if state is not idle, deleteSocket(); is called via |
2627 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); | 2650 | // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); |
2628 | if ( mSocket->state() == QSocket::Idle ) | 2651 | if ( mSocket->state() == QSocket::Idle ) |
2629 | deleteSocket(); | 2652 | deleteSocket(); |
2630 | } | 2653 | } |
2631 | 2654 | ||
2632 | void KCommandSocket::deleteSocket() | 2655 | void KCommandSocket::deleteSocket() |
2633 | { | 2656 | { |
2634 | if ( mTimerSocket->isActive () ) { | 2657 | if ( mTimerSocket->isActive () ) { |
2635 | mTimerSocket->stop(); | 2658 | mTimerSocket->stop(); |
2636 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); | 2659 | KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); |
2637 | mRetVal = errorR; | 2660 | mRetVal = errorR; |
2638 | } | 2661 | } |
2639 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); | 2662 | //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); |
2640 | if ( mSocket) | 2663 | if ( mSocket) |
2641 | delete mSocket; | 2664 | delete mSocket; |
2642 | mSocket = 0; | 2665 | mSocket = 0; |
2643 | emit commandFinished( this, mRetVal ); | 2666 | emit commandFinished( this, mRetVal ); |
2644 | } | 2667 | } |
2645 | 2668 | ||
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index 74c7f45..4f89e03 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -1,210 +1,216 @@ | |||
1 | #ifndef KORGE_MAINWINDOW_H | 1 | #ifndef KORGE_MAINWINDOW_H |
2 | #define KORGE_MAINWINDOW_H | 2 | #define KORGE_MAINWINDOW_H |
3 | 3 | ||
4 | #include <qmainwindow.h> | 4 | #include <qmainwindow.h> |
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | #include <qdict.h> | 6 | #include <qdict.h> |
7 | #include <qfile.h> | 7 | #include <qfile.h> |
8 | #include <qsocket.h> | 8 | #include <qsocket.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qregexp.h> | 10 | #include <qregexp.h> |
11 | 11 | ||
12 | #include <libkcal/incidence.h> | 12 | #include <libkcal/incidence.h> |
13 | #include "simplealarmclient.h" | 13 | #include "simplealarmclient.h" |
14 | 14 | ||
15 | class QAction; | 15 | class QAction; |
16 | class CalendarView; | 16 | class CalendarView; |
17 | class KSyncProfile; | 17 | class KSyncProfile; |
18 | #ifdef DESKTOP_VERSION | 18 | #ifdef DESKTOP_VERSION |
19 | 19 | ||
20 | #define QPEToolBar QToolBar | 20 | #define QPEToolBar QToolBar |
21 | #define QPEMenuBar QMenuBar | 21 | #define QPEMenuBar QMenuBar |
22 | #endif | 22 | #endif |
23 | class QPEToolBar; | 23 | class QPEToolBar; |
24 | #include <qserversocket.h> | 24 | #include <qserversocket.h> |
25 | #include <qsocket.h> | 25 | #include <qsocket.h> |
26 | #include <qnetworkprotocol.h> | 26 | #include <qnetworkprotocol.h> |
27 | 27 | ||
28 | class KServerSocket : public QServerSocket | 28 | class KServerSocket : public QServerSocket |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); | 33 | KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); |
34 | 34 | ||
35 | void newConnection ( int socket ) ; | 35 | void newConnection ( int socket ) ; |
36 | void setFileName( QString fn ) {mFileName = fn;}; | 36 | void setFileName( QString fn ) {mFileName = fn;}; |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | //void sendFile(QSocket*); | 39 | //void sendFile(QSocket*); |
40 | //void getFile(QSocket*); | 40 | //void getFile(QSocket*); |
41 | void file_received( bool ); | 41 | void file_received( bool ); |
42 | //void file_sent(); | 42 | //void file_sent(); |
43 | void saveFile(); | 43 | void saveFile(); |
44 | void endConnect(); | 44 | void endConnect(); |
45 | private slots: | 45 | private slots: |
46 | void discardClient(); | 46 | void discardClient(); |
47 | void readClient(); | 47 | void readClient(); |
48 | void readBackFileFromSocket(); | 48 | void readBackFileFromSocket(); |
49 | private : | 49 | private : |
50 | bool blockRC; | 50 | bool blockRC; |
51 | void send_file(); | 51 | void send_file(); |
52 | void get_file(); | 52 | void get_file(); |
53 | void end_connect(); | 53 | void end_connect(); |
54 | QDialog* mSyncActionDialog; | 54 | QDialog* mSyncActionDialog; |
55 | QSocket* mSocket; | 55 | QSocket* mSocket; |
56 | QString mPassWord; | 56 | QString mPassWord; |
57 | QString mFileName; | 57 | QString mFileName; |
58 | QTime piTime; | 58 | QTime piTime; |
59 | QString piFileString; | 59 | QString piFileString; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | class KCommandSocket : public QObject | 62 | class KCommandSocket : public QObject |
63 | { | 63 | { |
64 | Q_OBJECT | 64 | Q_OBJECT |
65 | public: | 65 | public: |
66 | enum state { successR, errorR, successW, errorW, quiet }; | 66 | enum state { successR, errorR, successW, errorW, quiet }; |
67 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); | 67 | KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); |
68 | void readFile( QString ); | 68 | void readFile( QString ); |
69 | void writeFile( QString ); | 69 | void writeFile( QString ); |
70 | void sendStop(); | 70 | void sendStop(); |
71 | 71 | ||
72 | 72 | ||
73 | signals: | 73 | signals: |
74 | void commandFinished( KCommandSocket*, int ); | 74 | void commandFinished( KCommandSocket*, int ); |
75 | private slots: | 75 | private slots: |
76 | void startReadFileFromSocket(); | 76 | void startReadFileFromSocket(); |
77 | void readFileFromSocket(); | 77 | void readFileFromSocket(); |
78 | void deleteSocket(); | 78 | void deleteSocket(); |
79 | void writeFileToSocket(); | 79 | void writeFileToSocket(); |
80 | private : | 80 | private : |
81 | QSocket* mSocket; | 81 | QSocket* mSocket; |
82 | QString mPassWord; | 82 | QString mPassWord; |
83 | Q_UINT16 mPort; | 83 | Q_UINT16 mPort; |
84 | QString mHost; | 84 | QString mHost; |
85 | QString mFileName; | 85 | QString mFileName; |
86 | QTimer* mTimerSocket; | 86 | QTimer* mTimerSocket; |
87 | int mRetVal; | 87 | int mRetVal; |
88 | QTime mTime; | 88 | QTime mTime; |
89 | QString mFileString; | 89 | QString mFileString; |
90 | bool mFirst; | 90 | bool mFirst; |
91 | }; | 91 | }; |
92 | 92 | ||
93 | namespace KCal { | 93 | namespace KCal { |
94 | class CalendarLocal; | 94 | class CalendarLocal; |
95 | } | 95 | } |
96 | 96 | ||
97 | using namespace KCal; | 97 | using namespace KCal; |
98 | 98 | ||
99 | class MainWindow : public QMainWindow | 99 | class MainWindow : public QMainWindow |
100 | { | 100 | { |
101 | Q_OBJECT | 101 | Q_OBJECT |
102 | public: | 102 | public: |
103 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); | 103 | MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); |
104 | ~MainWindow(); | 104 | ~MainWindow(); |
105 | public slots: | 105 | public slots: |
106 | virtual void showMaximized (); | 106 | virtual void showMaximized (); |
107 | void configureAgenda( int ); | 107 | void configureAgenda( int ); |
108 | void recieve( const QCString& msg, const QByteArray& data ); | 108 | void recieve( const QCString& msg, const QByteArray& data ); |
109 | static QString defaultFileName(); | 109 | static QString defaultFileName(); |
110 | static QString syncFileName(); | 110 | static QString syncFileName(); |
111 | static QString resourcePath(); | 111 | static QString resourcePath(); |
112 | protected slots: | 112 | protected slots: |
113 | void setCaptionToDates(); | 113 | void setCaptionToDates(); |
114 | int ringSync(); | 114 | int ringSync(); |
115 | void multiSync( bool askforPrefs = false ); | 115 | void multiSync( bool askforPrefs = false ); |
116 | void about(); | 116 | void about(); |
117 | void licence(); | 117 | void licence(); |
118 | void faq(); | 118 | void faq(); |
119 | void usertrans(); | 119 | void usertrans(); |
120 | void features(); | 120 | void features(); |
121 | void synchowto(); | 121 | void synchowto(); |
122 | void whatsNew(); | 122 | void whatsNew(); |
123 | void keyBindings(); | 123 | void keyBindings(); |
124 | void aboutAutoSaving();; | 124 | void aboutAutoSaving();; |
125 | void aboutKnownBugs(); | 125 | void aboutKnownBugs(); |
126 | 126 | ||
127 | void processIncidenceSelection( Incidence * ); | 127 | void processIncidenceSelection( Incidence * ); |
128 | 128 | ||
129 | void importQtopia(); | 129 | void importQtopia(); |
130 | void importBday(); | 130 | void importBday(); |
131 | void importOL(); | 131 | void importOL(); |
132 | void importIcal(); | 132 | void importIcal(); |
133 | void importFile( QString, bool ); | 133 | void importFile( QString, bool ); |
134 | void quickImportIcal(); | 134 | void quickImportIcal(); |
135 | 135 | ||
136 | void slotModifiedChanged( bool ); | 136 | void slotModifiedChanged( bool ); |
137 | 137 | ||
138 | void save(); | 138 | void save(); |
139 | void configureToolBar( int ); | 139 | void configureToolBar( int ); |
140 | void printSel(); | 140 | void printSel(); |
141 | void printCal(); | 141 | void printCal(); |
142 | void saveCalendar(); | 142 | void saveCalendar(); |
143 | void loadCalendar(); | 143 | void loadCalendar(); |
144 | void exportVCalendar(); | 144 | void exportVCalendar(); |
145 | void fillFilterMenu(); | 145 | void fillFilterMenu(); |
146 | void selectFilter( int ); | 146 | void selectFilter( int ); |
147 | void exportToPhone( int ); | 147 | void exportToPhone( int ); |
148 | 148 | ||
149 | void slotSyncMenu( int ); | 149 | void slotSyncMenu( int ); |
150 | void confSync(); | 150 | void confSync(); |
151 | void syncSharp(); | 151 | void syncSharp(); |
152 | void syncPhone(); | 152 | void syncPhone(); |
153 | void syncPi(); | 153 | void syncPi(); |
154 | void syncLocalFile(); | 154 | void syncLocalFile(); |
155 | bool syncWithFile( QString, bool ); | 155 | bool syncWithFile( QString, bool ); |
156 | void quickSyncLocalFile(); | 156 | void quickSyncLocalFile(); |
157 | 157 | ||
158 | 158 | ||
159 | protected: | 159 | protected: |
160 | void displayText( QString, QString); | 160 | void displayText( QString, QString); |
161 | void displayFile( QString, QString); | 161 | void displayFile( QString, QString); |
162 | 162 | ||
163 | void enableIncidenceActions( bool ); | 163 | void enableIncidenceActions( bool ); |
164 | 164 | ||
165 | private slots: | 165 | private slots: |
166 | QSocket* piSocket; | 166 | QSocket* piSocket; |
167 | QString piFileString; | 167 | QString piFileString; |
168 | QTime piTime; | 168 | QTime piTime; |
169 | void deleteCommandSocket(KCommandSocket* s, int state ); | 169 | void deleteCommandSocket(KCommandSocket* s, int state ); |
170 | void fillSyncMenu(); | 170 | void fillSyncMenu(); |
171 | void getFile( bool ); | 171 | void getFile( bool ); |
172 | void readFileFromSocket(); | 172 | void readFileFromSocket(); |
173 | private: | 173 | private: |
174 | //QTimer* mTimerCommandSocket; | 174 | //QTimer* mTimerCommandSocket; |
175 | QString mPassWordPiSync; | 175 | QString mPassWordPiSync; |
176 | KServerSocket * mServerSocket; | 176 | KServerSocket * mServerSocket; |
177 | bool mClosed; | 177 | bool mClosed; |
178 | void saveOnClose(); | 178 | void saveOnClose(); |
179 | int mCurrentSyncProfile; | 179 | int mCurrentSyncProfile; |
180 | void enableQuick(); | 180 | void enableQuick(); |
181 | void syncRemote( KSyncProfile* , bool ask = true); | 181 | void syncRemote( KSyncProfile* , bool ask = true); |
182 | bool mFlagKeyPressed; | 182 | bool mFlagKeyPressed; |
183 | bool mBlockAtStartup; | 183 | bool mBlockAtStartup; |
184 | QPEToolBar *iconToolBar; | 184 | QPEToolBar *iconToolBar; |
185 | void initActions(); | 185 | void initActions(); |
186 | void setDefaultPreferences(); | 186 | void setDefaultPreferences(); |
187 | void keyPressEvent ( QKeyEvent * ) ; | 187 | void keyPressEvent ( QKeyEvent * ) ; |
188 | void keyReleaseEvent ( QKeyEvent * ) ; | 188 | void keyReleaseEvent ( QKeyEvent * ) ; |
189 | QPopupMenu *configureToolBarMenu; | 189 | QPopupMenu *configureToolBarMenu; |
190 | QPopupMenu *selectFilterMenu; | 190 | QPopupMenu *selectFilterMenu; |
191 | QPopupMenu *configureAgendaMenu, *syncMenu; | 191 | QPopupMenu *configureAgendaMenu, *syncMenu; |
192 | CalendarLocal *mCalendar; | 192 | CalendarLocal *mCalendar; |
193 | CalendarView *mView; | 193 | CalendarView *mView; |
194 | QString getPassword(); | 194 | QString getPassword(); |
195 | QAction *mNewSubTodoAction; | 195 | QAction *mNewSubTodoAction; |
196 | 196 | ||
197 | QAction *mShowAction; | 197 | QAction *mShowAction; |
198 | QAction *mEditAction; | 198 | QAction *mEditAction; |
199 | QAction *mDeleteAction; | 199 | QAction *mDeleteAction; |
200 | QAction *mCloneAction; | ||
201 | QAction *mMoveAction; | ||
202 | QAction *mBeamAction; | ||
203 | QAction *mCancelAction; | ||
204 | |||
205 | |||
200 | void closeEvent( QCloseEvent* ce ); | 206 | void closeEvent( QCloseEvent* ce ); |
201 | SimpleAlarmClient mAlarmClient; | 207 | SimpleAlarmClient mAlarmClient; |
202 | QTimer mSaveTimer; | 208 | QTimer mSaveTimer; |
203 | bool mBlockSaveFlag; | 209 | bool mBlockSaveFlag; |
204 | bool mCalendarModifiedFlag; | 210 | bool mCalendarModifiedFlag; |
205 | QPixmap loadPixmap( QString ); | 211 | QPixmap loadPixmap( QString ); |
206 | QDialog * mSyncActionDialog; | 212 | QDialog * mSyncActionDialog; |
207 | }; | 213 | }; |
208 | 214 | ||
209 | 215 | ||
210 | #endif | 216 | #endif |