-rw-r--r-- | korganizer/calendarview.cpp | 42 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 8 | ||||
-rw-r--r-- | libkcal/libkcalE.pro | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 1359 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 65 |
6 files changed, 1467 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 689618d..a7f7010 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,2009 +1,2033 @@ | |||
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 | 66 | ||
67 | #include <libkcal/vcaldrag.h> | 67 | #include <libkcal/vcaldrag.h> |
68 | #include <libkcal/icaldrag.h> | 68 | #include <libkcal/icaldrag.h> |
69 | #include <libkcal/icalformat.h> | 69 | #include <libkcal/icalformat.h> |
70 | #include <libkcal/vcalformat.h> | 70 | #include <libkcal/vcalformat.h> |
71 | #include <libkcal/scheduler.h> | 71 | #include <libkcal/scheduler.h> |
72 | #include <libkcal/calendarlocal.h> | 72 | #include <libkcal/calendarlocal.h> |
73 | #include <libkcal/journal.h> | 73 | #include <libkcal/journal.h> |
74 | #include <libkcal/calfilter.h> | 74 | #include <libkcal/calfilter.h> |
75 | #include <libkcal/attendee.h> | 75 | #include <libkcal/attendee.h> |
76 | #include <libkcal/dndfactory.h> | 76 | #include <libkcal/dndfactory.h> |
77 | #include <libkcal/freebusy.h> | 77 | #include <libkcal/freebusy.h> |
78 | #include <libkcal/filestorage.h> | 78 | #include <libkcal/filestorage.h> |
79 | #include <libkcal/calendarresources.h> | 79 | #include <libkcal/calendarresources.h> |
80 | #include <libkcal/qtopiaformat.h> | 80 | #include <libkcal/qtopiaformat.h> |
81 | #include "../kalarmd/alarmdialog.h" | 81 | #include "../kalarmd/alarmdialog.h" |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | #include <libkcal/sharpformat.h> | 84 | #include <libkcal/sharpformat.h> |
85 | #endif | 85 | #endif |
86 | #include <libkcal/phoneformat.h> | ||
86 | #ifndef KORG_NOMAIL | 87 | #ifndef KORG_NOMAIL |
87 | #include "komailclient.h" | 88 | #include "komailclient.h" |
88 | #endif | 89 | #endif |
89 | #ifndef KORG_NOPRINTER | 90 | #ifndef KORG_NOPRINTER |
90 | #include "calprinter.h" | 91 | #include "calprinter.h" |
91 | #endif | 92 | #endif |
92 | #ifndef KORG_NOPLUGINS | 93 | #ifndef KORG_NOPLUGINS |
93 | #include "kocore.h" | 94 | #include "kocore.h" |
94 | #endif | 95 | #endif |
95 | #include "koeventeditor.h" | 96 | #include "koeventeditor.h" |
96 | #include "kotodoeditor.h" | 97 | #include "kotodoeditor.h" |
97 | #include "koprefs.h" | 98 | #include "koprefs.h" |
98 | #include "koeventviewerdialog.h" | 99 | #include "koeventviewerdialog.h" |
99 | #include "publishdialog.h" | 100 | #include "publishdialog.h" |
100 | #include "kofilterview.h" | 101 | #include "kofilterview.h" |
101 | #include "koglobals.h" | 102 | #include "koglobals.h" |
102 | #include "koviewmanager.h" | 103 | #include "koviewmanager.h" |
103 | #include "koagendaview.h" | 104 | #include "koagendaview.h" |
104 | #include "kodialogmanager.h" | 105 | #include "kodialogmanager.h" |
105 | #include "outgoingdialog.h" | 106 | #include "outgoingdialog.h" |
106 | #include "incomingdialog.h" | 107 | #include "incomingdialog.h" |
107 | #include "statusdialog.h" | 108 | #include "statusdialog.h" |
108 | #include "kdatenavigator.h" | 109 | #include "kdatenavigator.h" |
109 | #include "kotodoview.h" | 110 | #include "kotodoview.h" |
110 | #include "datenavigator.h" | 111 | #include "datenavigator.h" |
111 | #include "resourceview.h" | 112 | #include "resourceview.h" |
112 | #include "navigatorbar.h" | 113 | #include "navigatorbar.h" |
113 | #include "searchdialog.h" | 114 | #include "searchdialog.h" |
114 | #include "mainwindow.h" | 115 | #include "mainwindow.h" |
115 | 116 | ||
116 | #include "calendarview.h" | 117 | #include "calendarview.h" |
117 | #ifndef DESKTOP_VERSION | 118 | #ifndef DESKTOP_VERSION |
118 | #include <qtopia/alarmserver.h> | 119 | #include <qtopia/alarmserver.h> |
119 | #endif | 120 | #endif |
120 | #ifndef _WIN32_ | 121 | #ifndef _WIN32_ |
121 | #include <stdlib.h> | 122 | #include <stdlib.h> |
122 | #include <stdio.h> | 123 | #include <stdio.h> |
123 | #include <unistd.h> | 124 | #include <unistd.h> |
124 | #else | 125 | #else |
125 | #include <qprocess.h> | 126 | #include <qprocess.h> |
126 | #endif | 127 | #endif |
127 | using namespace KOrg; | 128 | using namespace KOrg; |
128 | using namespace KCal; | 129 | using namespace KCal; |
129 | extern int globalFlagBlockAgenda; | 130 | extern int globalFlagBlockAgenda; |
130 | extern int globalFlagBlockStartup; | 131 | extern int globalFlagBlockStartup; |
131 | 132 | ||
132 | 133 | ||
133 | 134 | ||
134 | class KOBeamPrefs : public QDialog | 135 | class KOBeamPrefs : public QDialog |
135 | { | 136 | { |
136 | public: | 137 | public: |
137 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 138 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
138 | QDialog( parent, name, true ) | 139 | QDialog( parent, name, true ) |
139 | { | 140 | { |
140 | setCaption( i18n("Beam Options") ); | 141 | setCaption( i18n("Beam Options") ); |
141 | QVBoxLayout* lay = new QVBoxLayout( this ); | 142 | QVBoxLayout* lay = new QVBoxLayout( this ); |
142 | lay->setSpacing( 3 ); | 143 | lay->setSpacing( 3 ); |
143 | lay->setMargin( 3 ); | 144 | lay->setMargin( 3 ); |
144 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 145 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
145 | lay->addWidget( format ); | 146 | lay->addWidget( format ); |
146 | format->setExclusive ( true ) ; | 147 | format->setExclusive ( true ) ; |
147 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 148 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
148 | lay->addWidget( time ); time->setExclusive ( true ) ; | 149 | lay->addWidget( time ); time->setExclusive ( true ) ; |
149 | vcal = new QRadioButton(" vCalendar ", format ); | 150 | vcal = new QRadioButton(" vCalendar ", format ); |
150 | ical = new QRadioButton(" iCalendar ", format ); | 151 | ical = new QRadioButton(" iCalendar ", format ); |
151 | vcal->setChecked( true ); | 152 | vcal->setChecked( true ); |
152 | tz = new QRadioButton(i18n(" With timezone "), time ); | 153 | tz = new QRadioButton(i18n(" With timezone "), time ); |
153 | local = new QRadioButton(i18n(" Local time "), time ); | 154 | local = new QRadioButton(i18n(" Local time "), time ); |
154 | tz->setChecked( true ); | 155 | tz->setChecked( true ); |
155 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 156 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
156 | lay->addWidget( ok ); | 157 | lay->addWidget( ok ); |
157 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 158 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
158 | lay->addWidget( cancel ); | 159 | lay->addWidget( cancel ); |
159 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 160 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
160 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 161 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
161 | resize( 200, 200 ); | 162 | resize( 200, 200 ); |
162 | } | 163 | } |
163 | 164 | ||
164 | bool beamVcal() { return vcal->isChecked(); } | 165 | bool beamVcal() { return vcal->isChecked(); } |
165 | bool beamLocal() { return local->isChecked(); } | 166 | bool beamLocal() { return local->isChecked(); } |
166 | private: | 167 | private: |
167 | QRadioButton* vcal, *ical, *local, *tz; | 168 | QRadioButton* vcal, *ical, *local, *tz; |
168 | }; | 169 | }; |
169 | class KOCatPrefs : public QDialog | 170 | class KOCatPrefs : public QDialog |
170 | { | 171 | { |
171 | public: | 172 | public: |
172 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 173 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
173 | QDialog( parent, name, true ) | 174 | QDialog( parent, name, true ) |
174 | { | 175 | { |
175 | setCaption( i18n("Manage new Categories") ); | 176 | setCaption( i18n("Manage new Categories") ); |
176 | QVBoxLayout* lay = new QVBoxLayout( this ); | 177 | QVBoxLayout* lay = new QVBoxLayout( this ); |
177 | lay->setSpacing( 3 ); | 178 | lay->setSpacing( 3 ); |
178 | lay->setMargin( 3 ); | 179 | lay->setMargin( 3 ); |
179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 180 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
180 | lay->addWidget( lab ); | 181 | lay->addWidget( lab ); |
181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 182 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
182 | lay->addWidget( format ); | 183 | lay->addWidget( format ); |
183 | format->setExclusive ( true ) ; | 184 | format->setExclusive ( true ) ; |
184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 185 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
185 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 186 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
186 | addCatBut->setChecked( true ); | 187 | addCatBut->setChecked( true ); |
187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 188 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
188 | lay->addWidget( ok ); | 189 | lay->addWidget( ok ); |
189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 190 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
190 | lay->addWidget( cancel ); | 191 | lay->addWidget( cancel ); |
191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 192 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 193 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
193 | resize( 200, 200 ); | 194 | resize( 200, 200 ); |
194 | } | 195 | } |
195 | 196 | ||
196 | bool addCat() { return addCatBut->isChecked(); } | 197 | bool addCat() { return addCatBut->isChecked(); } |
197 | private: | 198 | private: |
198 | QRadioButton* addCatBut; | 199 | QRadioButton* addCatBut; |
199 | }; | 200 | }; |
200 | 201 | ||
201 | 202 | ||
202 | 203 | ||
203 | CalendarView::CalendarView( CalendarResources *calendar, | 204 | CalendarView::CalendarView( CalendarResources *calendar, |
204 | QWidget *parent, const char *name ) | 205 | QWidget *parent, const char *name ) |
205 | : CalendarViewBase( parent, name ), | 206 | : CalendarViewBase( parent, name ), |
206 | mCalendar( calendar ), | 207 | mCalendar( calendar ), |
207 | mResourceManager( calendar->resourceManager() ) | 208 | mResourceManager( calendar->resourceManager() ) |
208 | { | 209 | { |
209 | 210 | ||
210 | mEventEditor = 0; | 211 | mEventEditor = 0; |
211 | mTodoEditor = 0; | 212 | mTodoEditor = 0; |
212 | 213 | ||
213 | init(); | 214 | init(); |
214 | } | 215 | } |
215 | 216 | ||
216 | CalendarView::CalendarView( Calendar *calendar, | 217 | CalendarView::CalendarView( Calendar *calendar, |
217 | QWidget *parent, const char *name ) | 218 | QWidget *parent, const char *name ) |
218 | : CalendarViewBase( parent, name ), | 219 | : CalendarViewBase( parent, name ), |
219 | mCalendar( calendar ), | 220 | mCalendar( calendar ), |
220 | mResourceManager( 0 ) | 221 | mResourceManager( 0 ) |
221 | { | 222 | { |
222 | 223 | ||
223 | mEventEditor = 0; | 224 | mEventEditor = 0; |
224 | mTodoEditor = 0; | 225 | mTodoEditor = 0; |
225 | init();} | 226 | init();} |
226 | 227 | ||
227 | void CalendarView::init() | 228 | void CalendarView::init() |
228 | { | 229 | { |
229 | beamDialog = new KOBeamPrefs(); | 230 | beamDialog = new KOBeamPrefs(); |
230 | mDatePickerMode = 0; | 231 | mDatePickerMode = 0; |
231 | mCurrentSyncDevice = ""; | 232 | mCurrentSyncDevice = ""; |
232 | writeLocale(); | 233 | writeLocale(); |
233 | mViewManager = new KOViewManager( this ); | 234 | mViewManager = new KOViewManager( this ); |
234 | mDialogManager = new KODialogManager( this ); | 235 | mDialogManager = new KODialogManager( this ); |
235 | mEventViewerDialog = 0; | 236 | mEventViewerDialog = 0; |
236 | mModified = false; | 237 | mModified = false; |
237 | mReadOnly = false; | 238 | mReadOnly = false; |
238 | mSelectedIncidence = 0; | 239 | mSelectedIncidence = 0; |
239 | mCalPrinter = 0; | 240 | mCalPrinter = 0; |
240 | mFilters.setAutoDelete(true); | 241 | mFilters.setAutoDelete(true); |
241 | 242 | ||
242 | mCalendar->registerObserver( this ); | 243 | mCalendar->registerObserver( this ); |
243 | // TODO: Make sure that view is updated, when calendar is changed. | 244 | // TODO: Make sure that view is updated, when calendar is changed. |
244 | 245 | ||
245 | mStorage = new FileStorage( mCalendar ); | 246 | mStorage = new FileStorage( mCalendar ); |
246 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
247 | 248 | ||
248 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
249 | #ifndef KORG_NOSPLITTER | 250 | #ifndef KORG_NOSPLITTER |
250 | // create the main layout frames. | 251 | // create the main layout frames. |
251 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
252 | topLayout->addWidget(mPanner); | 253 | topLayout->addWidget(mPanner); |
253 | 254 | ||
254 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
255 | "CalendarView::LeftFrame"); | 256 | "CalendarView::LeftFrame"); |
256 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
257 | 258 | ||
258 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
259 | "CalendarView::DateNavigator", QDate::currentDate() ); | 260 | "CalendarView::DateNavigator", QDate::currentDate() ); |
260 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
261 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
262 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
263 | 264 | ||
264 | #ifdef KORG_NORESOURCEVIEW | 265 | #ifdef KORG_NORESOURCEVIEW |
265 | mResourceView = 0; | 266 | mResourceView = 0; |
266 | #else | 267 | #else |
267 | if ( mResourceManager ) { | 268 | if ( mResourceManager ) { |
268 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
269 | mResourceView->updateView(); | 270 | mResourceView->updateView(); |
270 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 271 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
271 | SLOT( updateView() ) ); | 272 | SLOT( updateView() ) ); |
272 | } else { | 273 | } else { |
273 | mResourceView = 0; | 274 | mResourceView = 0; |
274 | } | 275 | } |
275 | #endif | 276 | #endif |
276 | QWidget *rightBox = new QWidget( mPanner ); | 277 | QWidget *rightBox = new QWidget( mPanner ); |
277 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
278 | 279 | ||
279 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
280 | rightLayout->addWidget( mNavigatorBar ); | 281 | rightLayout->addWidget( mNavigatorBar ); |
281 | 282 | ||
282 | mRightFrame = new QWidgetStack( rightBox ); | 283 | mRightFrame = new QWidgetStack( rightBox ); |
283 | rightLayout->addWidget( mRightFrame, 1 ); | 284 | rightLayout->addWidget( mRightFrame, 1 ); |
284 | 285 | ||
285 | mLeftFrame = mLeftSplitter; | 286 | mLeftFrame = mLeftSplitter; |
286 | #else | 287 | #else |
287 | QWidget *mainBox = new QWidget( this ); | 288 | QWidget *mainBox = new QWidget( this ); |
288 | QWidget *leftFrame = new QWidget( mainBox ); | 289 | QWidget *leftFrame = new QWidget( mainBox ); |
289 | 290 | ||
290 | QBoxLayout * mainBoxLayout; | 291 | QBoxLayout * mainBoxLayout; |
291 | QBoxLayout * leftFrameLayout; | 292 | QBoxLayout * leftFrameLayout; |
292 | if ( KOPrefs::instance()->mVerticalScreen ) { | 293 | if ( KOPrefs::instance()->mVerticalScreen ) { |
293 | mainBoxLayout = new QVBoxLayout(mainBox); | 294 | mainBoxLayout = new QVBoxLayout(mainBox); |
294 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 295 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
295 | } else { | 296 | } else { |
296 | mainBoxLayout = new QHBoxLayout(mainBox); | 297 | mainBoxLayout = new QHBoxLayout(mainBox); |
297 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 298 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
298 | } | 299 | } |
299 | topLayout->addWidget( mainBox ); | 300 | topLayout->addWidget( mainBox ); |
300 | mainBoxLayout->addWidget (leftFrame); | 301 | mainBoxLayout->addWidget (leftFrame); |
301 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
302 | "CalendarView::DateNavigator", QDate::currentDate()); | 303 | "CalendarView::DateNavigator", QDate::currentDate()); |
303 | // mDateNavigator->blockSignals( true ); | 304 | // mDateNavigator->blockSignals( true ); |
304 | leftFrameLayout->addWidget( mDateNavigator ); | 305 | leftFrameLayout->addWidget( mDateNavigator ); |
305 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
306 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
307 | 308 | ||
308 | if ( QApplication::desktop()->width() < 480 ) { | 309 | if ( QApplication::desktop()->width() < 480 ) { |
309 | leftFrameLayout->addWidget(mFilterView); | 310 | leftFrameLayout->addWidget(mFilterView); |
310 | leftFrameLayout->addWidget(mTodoList, 2 ); | 311 | leftFrameLayout->addWidget(mTodoList, 2 ); |
311 | 312 | ||
312 | } else { | 313 | } else { |
313 | leftFrameLayout->addWidget(mTodoList,2 ); | 314 | leftFrameLayout->addWidget(mTodoList,2 ); |
314 | leftFrameLayout->addWidget(mFilterView ); | 315 | leftFrameLayout->addWidget(mFilterView ); |
315 | } | 316 | } |
316 | mFilterView->hide(); | 317 | mFilterView->hide(); |
317 | QWidget *rightBox = new QWidget( mainBox ); | 318 | QWidget *rightBox = new QWidget( mainBox ); |
318 | mainBoxLayout->addWidget ( rightBox, 10 ); | 319 | mainBoxLayout->addWidget ( rightBox, 10 ); |
319 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
320 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
321 | mRightFrame = new QWidgetStack( rightBox ); | 322 | mRightFrame = new QWidgetStack( rightBox ); |
322 | rightLayout->addWidget( mNavigatorBar ); | 323 | rightLayout->addWidget( mNavigatorBar ); |
323 | rightLayout->addWidget( mRightFrame, 10 ); | 324 | rightLayout->addWidget( mRightFrame, 10 ); |
324 | 325 | ||
325 | mLeftFrame = leftFrame; | 326 | mLeftFrame = leftFrame; |
326 | if ( KOPrefs::instance()->mVerticalScreen ) { | 327 | if ( KOPrefs::instance()->mVerticalScreen ) { |
327 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
328 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
329 | } else { | 330 | } else { |
330 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
331 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
332 | } | 333 | } |
333 | 334 | ||
334 | //qDebug("Calendarview Size %d %d ", width(), height()); | 335 | //qDebug("Calendarview Size %d %d ", width(), height()); |
335 | #endif | 336 | #endif |
336 | 337 | ||
337 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
338 | SLOT( showDates( const KCal::DateList & ) ) ); | 339 | SLOT( showDates( const KCal::DateList & ) ) ); |
339 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
340 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
341 | 342 | ||
342 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
343 | mNavigator, SLOT( selectPreviousYear() ) ); | 344 | mNavigator, SLOT( selectPreviousYear() ) ); |
344 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
345 | mNavigator, SLOT( selectNextYear() ) ); | 346 | mNavigator, SLOT( selectNextYear() ) ); |
346 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
347 | mNavigator, SLOT( selectPreviousMonth() ) ); | 348 | mNavigator, SLOT( selectPreviousMonth() ) ); |
348 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
349 | mNavigator, SLOT( selectNextMonth() ) ); | 350 | mNavigator, SLOT( selectNextMonth() ) ); |
350 | 351 | ||
351 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
352 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
353 | 354 | ||
354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
356 | 357 | ||
357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
358 | mNavigator, SLOT( selectPreviousYear() ) ); | 359 | mNavigator, SLOT( selectPreviousYear() ) ); |
359 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 360 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
360 | mNavigator, SLOT( selectNextYear() ) ); | 361 | mNavigator, SLOT( selectNextYear() ) ); |
361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
362 | mNavigator, SLOT( selectPreviousMonth() ) ); | 363 | mNavigator, SLOT( selectPreviousMonth() ) ); |
363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
364 | mNavigator, SLOT( selectNextMonth() ) ); | 365 | mNavigator, SLOT( selectNextMonth() ) ); |
365 | 366 | ||
366 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 367 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
367 | mNavigator, SLOT( selectPrevious() ) ); | 368 | mNavigator, SLOT( selectPrevious() ) ); |
368 | connect( mDateNavigator, SIGNAL( goNext() ), | 369 | connect( mDateNavigator, SIGNAL( goNext() ), |
369 | mNavigator, SLOT( selectNext() ) ); | 370 | mNavigator, SLOT( selectNext() ) ); |
370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
372 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
373 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
374 | 375 | ||
375 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
376 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
377 | 378 | ||
378 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
379 | SLOT( eventAdded( Event *) ) ); | 380 | SLOT( eventAdded( Event *) ) ); |
380 | 381 | ||
381 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
382 | 383 | ||
383 | connect( this, SIGNAL( configChanged() ), | 384 | connect( this, SIGNAL( configChanged() ), |
384 | mDateNavigator, SLOT( updateConfig() ) ); | 385 | mDateNavigator, SLOT( updateConfig() ) ); |
385 | 386 | ||
386 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 387 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
387 | SLOT( newTodo() ) ); | 388 | SLOT( newTodo() ) ); |
388 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
389 | SLOT( newSubTodo( Todo * ) ) ); | 390 | SLOT( newSubTodo( Todo * ) ) ); |
390 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
391 | SLOT( editTodo( Todo * ) ) ); | 392 | SLOT( editTodo( Todo * ) ) ); |
392 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
393 | SLOT( showTodo( Todo *) ) ); | 394 | SLOT( showTodo( Todo *) ) ); |
394 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
395 | SLOT( deleteTodo( Todo *) ) ); | 396 | SLOT( deleteTodo( Todo *) ) ); |
396 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
397 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
398 | SLOT( purgeCompleted() ) ); | 399 | SLOT( purgeCompleted() ) ); |
399 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
400 | SIGNAL( todoModified( Todo *, int ) ) ); | 401 | SIGNAL( todoModified( Todo *, int ) ) ); |
401 | 402 | ||
402 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
403 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
404 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
405 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 406 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
406 | 407 | ||
407 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
408 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 409 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
409 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
410 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 411 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
411 | 412 | ||
412 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
413 | this, SLOT ( todo_unsub( Todo * ) ) ); | 414 | this, SLOT ( todo_unsub( Todo * ) ) ); |
414 | 415 | ||
415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
416 | SLOT( updateTodo( Todo *, int ) ) ); | 417 | SLOT( updateTodo( Todo *, int ) ) ); |
417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
419 | 420 | ||
420 | 421 | ||
421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
425 | 426 | ||
426 | 427 | ||
427 | 428 | ||
428 | 429 | ||
429 | 430 | ||
430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
431 | SLOT(checkClipboard())); | 432 | SLOT(checkClipboard())); |
432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
433 | SLOT( processTodoListSelection( Incidence * ) ) ); | 434 | SLOT( processTodoListSelection( Incidence * ) ) ); |
434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
435 | 436 | ||
436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
437 | 438 | ||
438 | mDateFrame = new QVBox(0,0,WType_Popup); | 439 | mDateFrame = new QVBox(0,0,WType_Popup); |
439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
441 | mDateFrame->setLineWidth(3); | 442 | mDateFrame->setLineWidth(3); |
442 | mDateFrame->hide(); | 443 | mDateFrame->hide(); |
443 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 444 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
445 | 446 | ||
446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
447 | 448 | ||
448 | mEventEditor = mDialogManager->getEventEditor(); | 449 | mEventEditor = mDialogManager->getEventEditor(); |
449 | mTodoEditor = mDialogManager->getTodoEditor(); | 450 | mTodoEditor = mDialogManager->getTodoEditor(); |
450 | 451 | ||
451 | mFlagEditDescription = false; | 452 | mFlagEditDescription = false; |
452 | 453 | ||
453 | mSuspendTimer = new QTimer( this ); | 454 | mSuspendTimer = new QTimer( this ); |
454 | mAlarmTimer = new QTimer( this ); | 455 | mAlarmTimer = new QTimer( this ); |
455 | mRecheckAlarmTimer = new QTimer( this ); | 456 | mRecheckAlarmTimer = new QTimer( this ); |
456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
459 | mAlarmDialog = new AlarmDialog( this ); | 460 | mAlarmDialog = new AlarmDialog( this ); |
460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
461 | mAlarmDialog->setServerNotification( false ); | 462 | mAlarmDialog->setServerNotification( false ); |
462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
463 | } | 464 | } |
464 | 465 | ||
465 | 466 | ||
466 | CalendarView::~CalendarView() | 467 | CalendarView::~CalendarView() |
467 | { | 468 | { |
468 | // kdDebug() << "~CalendarView()" << endl; | 469 | // kdDebug() << "~CalendarView()" << endl; |
469 | //qDebug("CalendarView::~CalendarView() "); | 470 | //qDebug("CalendarView::~CalendarView() "); |
470 | delete mDialogManager; | 471 | delete mDialogManager; |
471 | delete mViewManager; | 472 | delete mViewManager; |
472 | delete mStorage; | 473 | delete mStorage; |
473 | delete mDateFrame ; | 474 | delete mDateFrame ; |
474 | delete beamDialog; | 475 | delete beamDialog; |
475 | //kdDebug() << "~CalendarView() done" << endl; | 476 | //kdDebug() << "~CalendarView() done" << endl; |
476 | } | 477 | } |
477 | void CalendarView::timerAlarm() | 478 | void CalendarView::timerAlarm() |
478 | { | 479 | { |
479 | //qDebug("CalendarView::timerAlarm() "); | 480 | //qDebug("CalendarView::timerAlarm() "); |
480 | computeAlarm(mAlarmNotification ); | 481 | computeAlarm(mAlarmNotification ); |
481 | } | 482 | } |
482 | 483 | ||
483 | void CalendarView::suspendAlarm() | 484 | void CalendarView::suspendAlarm() |
484 | { | 485 | { |
485 | //qDebug(" CalendarView::suspendAlarm() "); | 486 | //qDebug(" CalendarView::suspendAlarm() "); |
486 | computeAlarm(mSuspendAlarmNotification ); | 487 | computeAlarm(mSuspendAlarmNotification ); |
487 | 488 | ||
488 | } | 489 | } |
489 | 490 | ||
490 | void CalendarView::startAlarm( QString mess , QString filename) | 491 | void CalendarView::startAlarm( QString mess , QString filename) |
491 | { | 492 | { |
492 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
493 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
494 | 495 | ||
495 | } | 496 | } |
496 | 497 | ||
497 | void CalendarView::checkNextTimerAlarm() | 498 | void CalendarView::checkNextTimerAlarm() |
498 | { | 499 | { |
499 | mCalendar->checkAlarmForIncidence( 0, true ); | 500 | mCalendar->checkAlarmForIncidence( 0, true ); |
500 | } | 501 | } |
501 | 502 | ||
502 | void CalendarView::computeAlarm( QString msg ) | 503 | void CalendarView::computeAlarm( QString msg ) |
503 | { | 504 | { |
504 | 505 | ||
505 | QString mess = msg; | 506 | QString mess = msg; |
506 | QString mAlarmMessage = mess.mid( 9 ); | 507 | QString mAlarmMessage = mess.mid( 9 ); |
507 | QString filename = MainWindow::resourcePath(); | 508 | QString filename = MainWindow::resourcePath(); |
508 | filename += "koalarm.wav"; | 509 | filename += "koalarm.wav"; |
509 | QString tempfilename; | 510 | QString tempfilename; |
510 | if ( mess.left( 13 ) == "suspend_alarm") { | 511 | if ( mess.left( 13 ) == "suspend_alarm") { |
511 | bool error = false; | 512 | bool error = false; |
512 | int len = mess.mid( 13 ).find("+++"); | 513 | int len = mess.mid( 13 ).find("+++"); |
513 | if ( len < 2 ) | 514 | if ( len < 2 ) |
514 | error = true; | 515 | error = true; |
515 | else { | 516 | else { |
516 | tempfilename = mess.mid( 13, len ); | 517 | tempfilename = mess.mid( 13, len ); |
517 | if ( !QFile::exists( tempfilename ) ) | 518 | if ( !QFile::exists( tempfilename ) ) |
518 | error = true; | 519 | error = true; |
519 | } | 520 | } |
520 | if ( ! error ) { | 521 | if ( ! error ) { |
521 | filename = tempfilename; | 522 | filename = tempfilename; |
522 | } | 523 | } |
523 | mAlarmMessage = mess.mid( 13+len+3 ); | 524 | mAlarmMessage = mess.mid( 13+len+3 ); |
524 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 525 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
525 | startAlarm( mAlarmMessage, filename); | 526 | startAlarm( mAlarmMessage, filename); |
526 | return; | 527 | return; |
527 | } | 528 | } |
528 | if ( mess.left( 11 ) == "timer_alarm") { | 529 | if ( mess.left( 11 ) == "timer_alarm") { |
529 | //mTimerTime = 0; | 530 | //mTimerTime = 0; |
530 | startAlarm( mess.mid( 11 ), filename ); | 531 | startAlarm( mess.mid( 11 ), filename ); |
531 | return; | 532 | return; |
532 | } | 533 | } |
533 | if ( mess.left( 10 ) == "proc_alarm") { | 534 | if ( mess.left( 10 ) == "proc_alarm") { |
534 | bool error = false; | 535 | bool error = false; |
535 | int len = mess.mid( 10 ).find("+++"); | 536 | int len = mess.mid( 10 ).find("+++"); |
536 | if ( len < 2 ) | 537 | if ( len < 2 ) |
537 | error = true; | 538 | error = true; |
538 | else { | 539 | else { |
539 | tempfilename = mess.mid( 10, len ); | 540 | tempfilename = mess.mid( 10, len ); |
540 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
541 | error = true; | 542 | error = true; |
542 | } | 543 | } |
543 | if ( error ) { | 544 | if ( error ) { |
544 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
545 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 546 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
546 | } else { | 547 | } else { |
547 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
548 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 549 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
549 | #ifndef _WIN32_ | 550 | #ifndef _WIN32_ |
550 | if ( vfork () == 0 ) { | 551 | if ( vfork () == 0 ) { |
551 | execl ( tempfilename.latin1(), 0 ); | 552 | execl ( tempfilename.latin1(), 0 ); |
552 | return; | 553 | return; |
553 | } | 554 | } |
554 | #else | 555 | #else |
555 | QProcess* p = new QProcess(); | 556 | QProcess* p = new QProcess(); |
556 | p->addArgument( tempfilename.latin1() ); | 557 | p->addArgument( tempfilename.latin1() ); |
557 | p->start(); | 558 | p->start(); |
558 | return; | 559 | return; |
559 | #endif | 560 | #endif |
560 | 561 | ||
561 | return; | 562 | return; |
562 | } | 563 | } |
563 | 564 | ||
564 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
565 | } | 566 | } |
566 | if ( mess.left( 11 ) == "audio_alarm") { | 567 | if ( mess.left( 11 ) == "audio_alarm") { |
567 | bool error = false; | 568 | bool error = false; |
568 | int len = mess.mid( 11 ).find("+++"); | 569 | int len = mess.mid( 11 ).find("+++"); |
569 | if ( len < 2 ) | 570 | if ( len < 2 ) |
570 | error = true; | 571 | error = true; |
571 | else { | 572 | else { |
572 | tempfilename = mess.mid( 11, len ); | 573 | tempfilename = mess.mid( 11, len ); |
573 | if ( !QFile::exists( tempfilename ) ) | 574 | if ( !QFile::exists( tempfilename ) ) |
574 | error = true; | 575 | error = true; |
575 | } | 576 | } |
576 | if ( ! error ) { | 577 | if ( ! error ) { |
577 | filename = tempfilename; | 578 | filename = tempfilename; |
578 | } | 579 | } |
579 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 580 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
580 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 581 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
581 | } | 582 | } |
582 | if ( mess.left( 9 ) == "cal_alarm") { | 583 | if ( mess.left( 9 ) == "cal_alarm") { |
583 | mAlarmMessage = mess.mid( 9 ) ; | 584 | mAlarmMessage = mess.mid( 9 ) ; |
584 | } | 585 | } |
585 | 586 | ||
586 | startAlarm( mAlarmMessage, filename ); | 587 | startAlarm( mAlarmMessage, filename ); |
587 | 588 | ||
588 | 589 | ||
589 | } | 590 | } |
590 | 591 | ||
591 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
592 | { | 593 | { |
593 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
594 | 595 | ||
595 | mSuspendAlarmNotification = noti; | 596 | mSuspendAlarmNotification = noti; |
596 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
597 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
598 | mSuspendTimer->start( ms , true ); | 599 | mSuspendTimer->start( ms , true ); |
599 | 600 | ||
600 | } | 601 | } |
601 | 602 | ||
602 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
603 | { | 604 | { |
604 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
605 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
606 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
607 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
608 | #endif | 609 | #endif |
609 | return; | 610 | return; |
610 | } | 611 | } |
611 | int maxSec; | 612 | int maxSec; |
612 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
613 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
614 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
615 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
616 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
617 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
618 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
619 | return; | 620 | return; |
620 | } else { | 621 | } else { |
621 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
622 | } | 623 | } |
623 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
624 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
625 | 626 | ||
626 | } | 627 | } |
627 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
628 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
629 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
630 | { | 631 | { |
631 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
632 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
633 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
634 | } | 635 | } |
635 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
636 | { | 637 | { |
637 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
638 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
639 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
640 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
641 | #endif | 642 | #endif |
642 | return; | 643 | return; |
643 | } | 644 | } |
644 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
645 | } | 646 | } |
646 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
647 | { | 648 | { |
648 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
649 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
650 | } | 651 | } |
651 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
652 | { | 653 | { |
653 | return mViewManager; | 654 | return mViewManager; |
654 | } | 655 | } |
655 | 656 | ||
656 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
657 | { | 658 | { |
658 | return mDialogManager; | 659 | return mDialogManager; |
659 | } | 660 | } |
660 | 661 | ||
661 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
662 | { | 663 | { |
663 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
664 | 665 | ||
665 | return dates.first(); | 666 | return dates.first(); |
666 | } | 667 | } |
667 | 668 | ||
668 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
669 | { | 670 | { |
670 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
671 | 672 | ||
672 | return dates.last(); | 673 | return dates.last(); |
673 | } | 674 | } |
674 | 675 | ||
675 | 676 | ||
676 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
677 | { | 678 | { |
678 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
679 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
680 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
681 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
682 | } | 683 | } |
683 | #endif | 684 | #endif |
684 | } | 685 | } |
685 | 686 | ||
686 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
687 | { | 688 | { |
688 | static KSyncPrefsDialog* sp = 0; | 689 | static KSyncPrefsDialog* sp = 0; |
689 | if ( ! sp ) { | 690 | if ( ! sp ) { |
690 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KSyncPrefsDialog( this, "syncprefs", true ); |
691 | } | 692 | } |
692 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
693 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
694 | sp->showMaximized(); | 695 | sp->showMaximized(); |
695 | #else | 696 | #else |
696 | sp->show(); | 697 | sp->show(); |
697 | #endif | 698 | #endif |
698 | sp->exec(); | 699 | sp->exec(); |
699 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); | 700 | KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); |
700 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); | 701 | KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); |
701 | } | 702 | } |
702 | 703 | ||
703 | 704 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 705 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 706 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 707 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 708 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 709 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 710 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 711 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 712 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 713 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 714 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 715 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 716 | { |
716 | 717 | ||
717 | //void setZaurusId(int id); | 718 | //void setZaurusId(int id); |
718 | // int zaurusId() const; | 719 | // int zaurusId() const; |
719 | // void setZaurusUid(int id); | 720 | // void setZaurusUid(int id); |
720 | // int zaurusUid() const; | 721 | // int zaurusUid() const; |
721 | // void setZaurusStat(int id); | 722 | // void setZaurusStat(int id); |
722 | // int zaurusStat() const; | 723 | // int zaurusStat() const; |
723 | // 0 equal | 724 | // 0 equal |
724 | // 1 take local | 725 | // 1 take local |
725 | // 2 take remote | 726 | // 2 take remote |
726 | // 3 cancel | 727 | // 3 cancel |
727 | QDateTime lastSync = mLastCalendarSync; | 728 | QDateTime lastSync = mLastCalendarSync; |
728 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 729 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
729 | bool remCh, locCh; | 730 | bool remCh, locCh; |
730 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 731 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
731 | locCh = ( local->lastModified() > mLastCalendarSync ); | 732 | locCh = ( local->lastModified() > mLastCalendarSync ); |
732 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 733 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
733 | if ( !remCh && ! locCh ) { | 734 | if ( !remCh && ! locCh ) { |
734 | //qDebug("both not changed "); | 735 | //qDebug("both not changed "); |
735 | lastSync = local->lastModified().addDays(1); | 736 | lastSync = local->lastModified().addDays(1); |
736 | } else { | 737 | } else { |
737 | if ( locCh ) { | 738 | if ( locCh ) { |
738 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); | 739 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); |
739 | lastSync = local->lastModified().addDays( -1 ); | 740 | lastSync = local->lastModified().addDays( -1 ); |
740 | if ( !remCh ) | 741 | if ( !remCh ) |
741 | remote->setLastModified( lastSync.addDays( -1 ) ); | 742 | remote->setLastModified( lastSync.addDays( -1 ) ); |
742 | } else { | 743 | } else { |
743 | //qDebug(" not loc changed "); | 744 | //qDebug(" not loc changed "); |
744 | lastSync = local->lastModified().addDays( 1 ); | 745 | lastSync = local->lastModified().addDays( 1 ); |
745 | if ( remCh ) | 746 | if ( remCh ) |
746 | remote->setLastModified( lastSync.addDays( 1 ) ); | 747 | remote->setLastModified( lastSync.addDays( 1 ) ); |
747 | 748 | ||
748 | } | 749 | } |
749 | } | 750 | } |
750 | full = true; | 751 | full = true; |
751 | if ( mode < SYNC_PREF_ASK ) | 752 | if ( mode < SYNC_PREF_ASK ) |
752 | mode = SYNC_PREF_ASK; | 753 | mode = SYNC_PREF_ASK; |
753 | } else { | 754 | } else { |
754 | if ( local->lastModified() == remote->lastModified() ) | 755 | if ( local->lastModified() == remote->lastModified() ) |
755 | if ( local->revision() == remote->revision() ) | 756 | if ( local->revision() == remote->revision() ) |
756 | return 0; | 757 | return 0; |
757 | 758 | ||
758 | } | 759 | } |
759 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 760 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
760 | 761 | ||
761 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 762 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
762 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 763 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
763 | //full = true; //debug only | 764 | //full = true; //debug only |
764 | if ( full ) { | 765 | if ( full ) { |
765 | bool equ = false; | 766 | bool equ = false; |
766 | if ( local->type() == "Event" ) { | 767 | if ( local->type() == "Event" ) { |
767 | equ = (*((Event*) local) == *((Event*) remote)); | 768 | equ = (*((Event*) local) == *((Event*) remote)); |
768 | } | 769 | } |
769 | else if ( local->type() =="Todo" ) | 770 | else if ( local->type() =="Todo" ) |
770 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 771 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
771 | else if ( local->type() =="Journal" ) | 772 | else if ( local->type() =="Journal" ) |
772 | equ = (*((Journal*) local) == *((Journal*) remote)); | 773 | equ = (*((Journal*) local) == *((Journal*) remote)); |
773 | if ( equ ) { | 774 | if ( equ ) { |
774 | //qDebug("equal "); | 775 | //qDebug("equal "); |
775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 776 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
776 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 777 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
777 | } | 778 | } |
778 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 779 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
779 | return 0; | 780 | return 0; |
780 | 781 | ||
781 | }//else //debug only | 782 | }//else //debug only |
782 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 783 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
783 | } | 784 | } |
784 | int result; | 785 | int result; |
785 | bool localIsNew; | 786 | bool localIsNew; |
786 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
787 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
788 | 789 | ||
789 | switch( mode ) { | 790 | switch( mode ) { |
790 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
791 | if ( lastSync > remote->lastModified() ) | 792 | if ( lastSync > remote->lastModified() ) |
792 | return 1; | 793 | return 1; |
793 | if ( lastSync > local->lastModified() ) | 794 | if ( lastSync > local->lastModified() ) |
794 | return 2; | 795 | return 2; |
795 | return 1; | 796 | return 1; |
796 | break; | 797 | break; |
797 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
798 | if ( lastSync > remote->lastModified() ) | 799 | if ( lastSync > remote->lastModified() ) |
799 | return 1; | 800 | return 1; |
800 | if ( lastSync > local->lastModified() ) | 801 | if ( lastSync > local->lastModified() ) |
801 | return 2; | 802 | return 2; |
802 | return 2; | 803 | return 2; |
803 | break; | 804 | break; |
804 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
805 | if ( local->lastModified() > remote->lastModified() ) | 806 | if ( local->lastModified() > remote->lastModified() ) |
806 | return 1; | 807 | return 1; |
807 | else | 808 | else |
808 | return 2; | 809 | return 2; |
809 | break; | 810 | break; |
810 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
811 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
812 | if ( lastSync > remote->lastModified() ) | 813 | if ( lastSync > remote->lastModified() ) |
813 | return 1; | 814 | return 1; |
814 | if ( lastSync > local->lastModified() ) | 815 | if ( lastSync > local->lastModified() ) |
815 | return 2; | 816 | return 2; |
816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
817 | localIsNew = local->lastModified() > remote->lastModified(); | 818 | localIsNew = local->lastModified() > remote->lastModified(); |
818 | if ( localIsNew ) | 819 | if ( localIsNew ) |
819 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
820 | else | 821 | else |
821 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
822 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
823 | if ( localIsNew ) | 824 | if ( localIsNew ) |
824 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
825 | else | 826 | else |
826 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
827 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
828 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
829 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
830 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
831 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
832 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
833 | return result; | 834 | return result; |
834 | 835 | ||
835 | break; | 836 | break; |
836 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
837 | return 1; | 838 | return 1; |
838 | break; | 839 | break; |
839 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
840 | return 2; | 841 | return 2; |
841 | break; | 842 | break; |
842 | 843 | ||
843 | default: | 844 | default: |
844 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
845 | break; | 846 | break; |
846 | } | 847 | } |
847 | return 0; | 848 | return 0; |
848 | } | 849 | } |
849 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
850 | { | 851 | { |
851 | Event* lse; | 852 | Event* lse; |
852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
853 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
854 | if (!lse) { | 855 | if (!lse) { |
855 | lse = new Event(); | 856 | lse = new Event(); |
856 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
857 | QString sum = ""; | 858 | QString sum = ""; |
858 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
859 | sum = "E: "; | 860 | sum = "E: "; |
860 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
861 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
862 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
863 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
864 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
865 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
866 | } | 867 | } |
867 | 868 | ||
868 | return lse; | 869 | return lse; |
869 | 870 | ||
870 | } | 871 | } |
871 | // probaly useless | 872 | // probaly useless |
872 | void CalendarView::setupExternSyncProfiles() | 873 | void CalendarView::setupExternSyncProfiles() |
873 | { | 874 | { |
874 | Event* lse; | 875 | Event* lse; |
875 | mExternLastSyncEvent.clear(); | 876 | mExternLastSyncEvent.clear(); |
876 | int i; | 877 | int i; |
877 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { | 878 | for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { |
878 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); | 879 | lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); |
879 | if ( lse ) | 880 | if ( lse ) |
880 | mExternLastSyncEvent.append( lse ); | 881 | mExternLastSyncEvent.append( lse ); |
881 | else | 882 | else |
882 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); | 883 | qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); |
883 | } | 884 | } |
884 | 885 | ||
885 | } | 886 | } |
886 | // we check, if the to delete event has a id for a profile | 887 | // we check, if the to delete event has a id for a profile |
887 | // if yes, we set this id in the profile to delete | 888 | // if yes, we set this id in the profile to delete |
888 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 889 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
889 | { | 890 | { |
890 | if ( lastSync.count() == 0 ) { | 891 | if ( lastSync.count() == 0 ) { |
891 | //qDebug(" lastSync.count() == 0"); | 892 | //qDebug(" lastSync.count() == 0"); |
892 | return; | 893 | return; |
893 | } | 894 | } |
894 | if ( toDelete->type() == "Journal" ) | 895 | if ( toDelete->type() == "Journal" ) |
895 | return; | 896 | return; |
896 | 897 | ||
897 | Event* eve = lastSync.first(); | 898 | Event* eve = lastSync.first(); |
898 | 899 | ||
899 | while ( eve ) { | 900 | while ( eve ) { |
900 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 901 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
901 | if ( !id.isEmpty() ) { | 902 | if ( !id.isEmpty() ) { |
902 | QString des = eve->description(); | 903 | QString des = eve->description(); |
903 | QString pref = "e"; | 904 | QString pref = "e"; |
904 | if ( toDelete->type() == "Todo" ) | 905 | if ( toDelete->type() == "Todo" ) |
905 | pref = "t"; | 906 | pref = "t"; |
906 | des += pref+ id + ","; | 907 | des += pref+ id + ","; |
907 | eve->setReadOnly( false ); | 908 | eve->setReadOnly( false ); |
908 | eve->setDescription( des ); | 909 | eve->setDescription( des ); |
909 | //qDebug("setdes %s ", des.latin1()); | 910 | //qDebug("setdes %s ", des.latin1()); |
910 | eve->setReadOnly( true ); | 911 | eve->setReadOnly( true ); |
911 | } | 912 | } |
912 | eve = lastSync.next(); | 913 | eve = lastSync.next(); |
913 | } | 914 | } |
914 | 915 | ||
915 | } | 916 | } |
916 | void CalendarView::checkExternalId( Incidence * inc ) | 917 | void CalendarView::checkExternalId( Incidence * inc ) |
917 | { | 918 | { |
918 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 919 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
919 | checkExternSyncEvent( lastSync, inc ); | 920 | checkExternSyncEvent( lastSync, inc ); |
920 | 921 | ||
921 | } | 922 | } |
922 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 923 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
923 | { | 924 | { |
924 | bool syncOK = true; | 925 | bool syncOK = true; |
925 | int addedEvent = 0; | 926 | int addedEvent = 0; |
926 | int addedEventR = 0; | 927 | int addedEventR = 0; |
927 | int deletedEventR = 0; | 928 | int deletedEventR = 0; |
928 | int deletedEventL = 0; | 929 | int deletedEventL = 0; |
929 | int changedLocal = 0; | 930 | int changedLocal = 0; |
930 | int changedRemote = 0; | 931 | int changedRemote = 0; |
931 | //QPtrList<Event> el = local->rawEvents(); | 932 | //QPtrList<Event> el = local->rawEvents(); |
932 | Event* eventR; | 933 | Event* eventR; |
933 | QString uid; | 934 | QString uid; |
934 | int take; | 935 | int take; |
935 | Event* eventL; | 936 | Event* eventL; |
936 | Event* eventRSync; | 937 | Event* eventRSync; |
937 | Event* eventLSync; | 938 | Event* eventLSync; |
938 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 939 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
939 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 940 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
940 | bool fullDateRange = false; | 941 | bool fullDateRange = false; |
941 | mLastCalendarSync = QDateTime::currentDateTime(); | 942 | mLastCalendarSync = QDateTime::currentDateTime(); |
942 | QDateTime modifiedCalendar = mLastCalendarSync;; | 943 | QDateTime modifiedCalendar = mLastCalendarSync;; |
943 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 944 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
944 | if ( eventR ) { | 945 | if ( eventR ) { |
945 | eventRSync = (Event*) eventR->clone(); | 946 | eventRSync = (Event*) eventR->clone(); |
946 | remote->deleteEvent(eventR ); | 947 | remote->deleteEvent(eventR ); |
947 | 948 | ||
948 | } else { | 949 | } else { |
949 | fullDateRange = true; | 950 | fullDateRange = true; |
950 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
951 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
952 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
953 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
954 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
955 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
956 | } | 957 | } |
957 | eventLSync = getLastSyncEvent(); | 958 | eventLSync = getLastSyncEvent(); |
958 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
959 | fullDateRange = true; | 960 | fullDateRange = true; |
960 | 961 | ||
961 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
962 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
963 | 964 | ||
964 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
965 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
966 | fullDateRange = true; | 967 | fullDateRange = true; |
967 | } | 968 | } |
968 | } | 969 | } |
969 | if ( fullDateRange ) | 970 | if ( fullDateRange ) |
970 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 971 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
971 | else | 972 | else |
972 | mLastCalendarSync = eventLSync->dtStart(); | 973 | mLastCalendarSync = eventLSync->dtStart(); |
973 | // for resyncing if own file has changed | 974 | // for resyncing if own file has changed |
974 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 975 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
975 | mLastCalendarSync = loadedFileVersion; | 976 | mLastCalendarSync = loadedFileVersion; |
976 | qDebug("setting mLastCalendarSync "); | 977 | qDebug("setting mLastCalendarSync "); |
977 | } | 978 | } |
978 | //qDebug("*************************** "); | 979 | //qDebug("*************************** "); |
979 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 980 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
980 | QPtrList<Incidence> er = remote->rawIncidences(); | 981 | QPtrList<Incidence> er = remote->rawIncidences(); |
981 | Incidence* inR = er.first(); | 982 | Incidence* inR = er.first(); |
982 | Incidence* inL; | 983 | Incidence* inL; |
983 | QProgressBar bar( er.count(),0 ); | 984 | QProgressBar bar( er.count(),0 ); |
984 | bar.setCaption (i18n("Syncing - close to abort!") ); | 985 | bar.setCaption (i18n("Syncing - close to abort!") ); |
985 | 986 | ||
986 | int w = 300; | 987 | int w = 300; |
987 | if ( QApplication::desktop()->width() < 320 ) | 988 | if ( QApplication::desktop()->width() < 320 ) |
988 | w = 220; | 989 | w = 220; |
989 | int h = bar.sizeHint().height() ; | 990 | int h = bar.sizeHint().height() ; |
990 | int dw = QApplication::desktop()->width(); | 991 | int dw = QApplication::desktop()->width(); |
991 | int dh = QApplication::desktop()->height(); | 992 | int dh = QApplication::desktop()->height(); |
992 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 993 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
993 | bar.show(); | 994 | bar.show(); |
994 | int modulo = (er.count()/10)+1; | 995 | int modulo = (er.count()/10)+1; |
995 | int incCounter = 0; | 996 | int incCounter = 0; |
996 | while ( inR ) { | 997 | while ( inR ) { |
997 | if ( ! bar.isVisible() ) | 998 | if ( ! bar.isVisible() ) |
998 | return false; | 999 | return false; |
999 | if ( incCounter % modulo == 0 ) | 1000 | if ( incCounter % modulo == 0 ) |
1000 | bar.setProgress( incCounter ); | 1001 | bar.setProgress( incCounter ); |
1001 | ++incCounter; | 1002 | ++incCounter; |
1002 | uid = inR->uid(); | 1003 | uid = inR->uid(); |
1003 | bool skipIncidence = false; | 1004 | bool skipIncidence = false; |
1004 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1005 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1005 | skipIncidence = true; | 1006 | skipIncidence = true; |
1006 | 1007 | ||
1007 | qApp->processEvents(); | 1008 | qApp->processEvents(); |
1008 | if ( !skipIncidence ) { | 1009 | if ( !skipIncidence ) { |
1009 | inL = local->incidence( uid ); | 1010 | inL = local->incidence( uid ); |
1010 | if ( inL ) { // maybe conflict - same uid in both calendars | 1011 | if ( inL ) { // maybe conflict - same uid in both calendars |
1011 | int maxrev = inL->revision(); | 1012 | int maxrev = inL->revision(); |
1012 | if ( maxrev < inR->revision() ) | 1013 | if ( maxrev < inR->revision() ) |
1013 | maxrev = inR->revision(); | 1014 | maxrev = inR->revision(); |
1014 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1015 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1016 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1017 | return false; | 1018 | return false; |
1018 | if ( take == 1 ) {// take local | 1019 | if ( take == 1 ) {// take local |
1019 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1020 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1020 | remote->deleteIncidence( inR ); | 1021 | remote->deleteIncidence( inR ); |
1021 | if ( inL->revision() < maxrev ) | 1022 | if ( inL->revision() < maxrev ) |
1022 | inL->setRevision( maxrev ); | 1023 | inL->setRevision( maxrev ); |
1023 | remote->addIncidence( inL->clone() ); | 1024 | remote->addIncidence( inL->clone() ); |
1024 | ++changedRemote; | 1025 | ++changedRemote; |
1025 | } else { | 1026 | } else { |
1026 | if ( inR->revision() < maxrev ) | 1027 | if ( inR->revision() < maxrev ) |
1027 | inR->setRevision( maxrev ); | 1028 | inR->setRevision( maxrev ); |
1028 | local->deleteIncidence( inL ); | 1029 | local->deleteIncidence( inL ); |
1029 | local->addIncidence( inR->clone() ); | 1030 | local->addIncidence( inR->clone() ); |
1030 | ++changedLocal; | 1031 | ++changedLocal; |
1031 | } | 1032 | } |
1032 | } | 1033 | } |
1033 | } else { // no conflict | 1034 | } else { // no conflict |
1034 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1035 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1035 | QString des = eventLSync->description(); | 1036 | QString des = eventLSync->description(); |
1036 | QString pref = "e"; | 1037 | QString pref = "e"; |
1037 | if ( inR->type() == "Todo" ) | 1038 | if ( inR->type() == "Todo" ) |
1038 | pref = "t"; | 1039 | pref = "t"; |
1039 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1040 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1040 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1041 | //remote->deleteIncidence( inR ); | 1042 | //remote->deleteIncidence( inR ); |
1042 | ++deletedEventR; | 1043 | ++deletedEventR; |
1043 | } else { | 1044 | } else { |
1044 | inR->setLastModified( modifiedCalendar ); | 1045 | inR->setLastModified( modifiedCalendar ); |
1045 | local->addIncidence( inR->clone() ); | 1046 | local->addIncidence( inR->clone() ); |
1046 | ++addedEvent; | 1047 | ++addedEvent; |
1047 | } | 1048 | } |
1048 | } else { | 1049 | } else { |
1049 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1050 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1050 | inR->setLastModified( modifiedCalendar ); | 1051 | inR->setLastModified( modifiedCalendar ); |
1051 | local->addIncidence( inR->clone() ); | 1052 | local->addIncidence( inR->clone() ); |
1052 | ++addedEvent; | 1053 | ++addedEvent; |
1053 | } else { | 1054 | } else { |
1054 | checkExternSyncEvent(eventRSyncSharp, inR); | 1055 | checkExternSyncEvent(eventRSyncSharp, inR); |
1055 | remote->deleteIncidence( inR ); | 1056 | remote->deleteIncidence( inR ); |
1056 | ++deletedEventR; | 1057 | ++deletedEventR; |
1057 | } | 1058 | } |
1058 | } | 1059 | } |
1059 | } | 1060 | } |
1060 | } | 1061 | } |
1061 | inR = er.next(); | 1062 | inR = er.next(); |
1062 | } | 1063 | } |
1063 | QPtrList<Incidence> el = local->rawIncidences(); | 1064 | QPtrList<Incidence> el = local->rawIncidences(); |
1064 | inL = el.first(); | 1065 | inL = el.first(); |
1065 | modulo = (el.count()/10)+1; | 1066 | modulo = (el.count()/10)+1; |
1066 | bar.setCaption (i18n("Add / remove events") ); | 1067 | bar.setCaption (i18n("Add / remove events") ); |
1067 | bar.setTotalSteps ( el.count() ) ; | 1068 | bar.setTotalSteps ( el.count() ) ; |
1068 | bar.show(); | 1069 | bar.show(); |
1069 | incCounter = 0; | 1070 | incCounter = 0; |
1070 | 1071 | ||
1071 | while ( inL ) { | 1072 | while ( inL ) { |
1072 | 1073 | ||
1073 | qApp->processEvents(); | 1074 | qApp->processEvents(); |
1074 | if ( ! bar.isVisible() ) | 1075 | if ( ! bar.isVisible() ) |
1075 | return false; | 1076 | return false; |
1076 | if ( incCounter % modulo == 0 ) | 1077 | if ( incCounter % modulo == 0 ) |
1077 | bar.setProgress( incCounter ); | 1078 | bar.setProgress( incCounter ); |
1078 | ++incCounter; | 1079 | ++incCounter; |
1079 | uid = inL->uid(); | 1080 | uid = inL->uid(); |
1080 | bool skipIncidence = false; | 1081 | bool skipIncidence = false; |
1081 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1082 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1082 | skipIncidence = true; | 1083 | skipIncidence = true; |
1083 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1084 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1084 | skipIncidence = true; | 1085 | skipIncidence = true; |
1085 | if ( !skipIncidence ) { | 1086 | if ( !skipIncidence ) { |
1086 | inR = remote->incidence( uid ); | 1087 | inR = remote->incidence( uid ); |
1087 | if ( ! inR ) { | 1088 | if ( ! inR ) { |
1088 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1089 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1089 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1090 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1090 | local->deleteIncidence( inL ); | 1091 | local->deleteIncidence( inL ); |
1091 | ++deletedEventL; | 1092 | ++deletedEventL; |
1092 | } else { | 1093 | } else { |
1093 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1094 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1094 | inL->removeID(mCurrentSyncDevice ); | 1095 | inL->removeID(mCurrentSyncDevice ); |
1095 | ++addedEventR; | 1096 | ++addedEventR; |
1096 | inL->setLastModified( modifiedCalendar ); | 1097 | inL->setLastModified( modifiedCalendar ); |
1097 | remote->addIncidence( inL->clone() ); | 1098 | remote->addIncidence( inL->clone() ); |
1098 | } | 1099 | } |
1099 | } | 1100 | } |
1100 | } else { | 1101 | } else { |
1101 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1102 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1102 | checkExternSyncEvent(eventLSyncSharp, inL); | 1103 | checkExternSyncEvent(eventLSyncSharp, inL); |
1103 | local->deleteIncidence( inL ); | 1104 | local->deleteIncidence( inL ); |
1104 | ++deletedEventL; | 1105 | ++deletedEventL; |
1105 | } else { | 1106 | } else { |
1106 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1107 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1107 | ++addedEventR; | 1108 | ++addedEventR; |
1108 | inL->setLastModified( modifiedCalendar ); | 1109 | inL->setLastModified( modifiedCalendar ); |
1109 | remote->addIncidence( inL->clone() ); | 1110 | remote->addIncidence( inL->clone() ); |
1110 | } | 1111 | } |
1111 | } | 1112 | } |
1112 | } | 1113 | } |
1113 | } | 1114 | } |
1114 | } | 1115 | } |
1115 | inL = el.next(); | 1116 | inL = el.next(); |
1116 | } | 1117 | } |
1117 | 1118 | ||
1118 | bar.hide(); | 1119 | bar.hide(); |
1119 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1120 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1120 | eventLSync->setReadOnly( false ); | 1121 | eventLSync->setReadOnly( false ); |
1121 | eventLSync->setDtStart( mLastCalendarSync ); | 1122 | eventLSync->setDtStart( mLastCalendarSync ); |
1122 | eventRSync->setDtStart( mLastCalendarSync ); | 1123 | eventRSync->setDtStart( mLastCalendarSync ); |
1123 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1124 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1124 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1125 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1125 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1126 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1126 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1127 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1127 | eventLSync->setReadOnly( true ); | 1128 | eventLSync->setReadOnly( true ); |
1128 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1129 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1129 | remote->addEvent( eventRSync ); | 1130 | remote->addEvent( eventRSync ); |
1130 | QString mes; | 1131 | QString mes; |
1131 | 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 ); | 1132 | 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 ); |
1132 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1133 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1133 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1134 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1134 | } | 1135 | } |
1135 | qDebug( mes ); | 1136 | qDebug( mes ); |
1136 | mCalendar->checkAlarmForIncidence( 0, true ); | 1137 | mCalendar->checkAlarmForIncidence( 0, true ); |
1137 | return syncOK; | 1138 | return syncOK; |
1138 | } | 1139 | } |
1139 | 1140 | ||
1140 | void CalendarView::setSyncDevice( QString s ) | 1141 | void CalendarView::setSyncDevice( QString s ) |
1141 | { | 1142 | { |
1142 | mCurrentSyncDevice= s; | 1143 | mCurrentSyncDevice= s; |
1143 | } | 1144 | } |
1144 | void CalendarView::setSyncName( QString s ) | 1145 | void CalendarView::setSyncName( QString s ) |
1145 | { | 1146 | { |
1146 | mCurrentSyncName= s; | 1147 | mCurrentSyncName= s; |
1147 | } | 1148 | } |
1148 | bool CalendarView::syncCalendar(QString filename, int mode) | 1149 | bool CalendarView::syncCalendar(QString filename, int mode) |
1149 | { | 1150 | { |
1150 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1151 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1151 | CalendarLocal* calendar = new CalendarLocal(); | 1152 | CalendarLocal* calendar = new CalendarLocal(); |
1152 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1153 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1153 | FileStorage* storage = new FileStorage( calendar ); | 1154 | FileStorage* storage = new FileStorage( calendar ); |
1154 | bool syncOK = false; | 1155 | bool syncOK = false; |
1155 | storage->setFileName( filename ); | 1156 | storage->setFileName( filename ); |
1156 | // qDebug("loading ... "); | 1157 | // qDebug("loading ... "); |
1157 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1158 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1158 | getEventViewerDialog()->setSyncMode( true ); | 1159 | getEventViewerDialog()->setSyncMode( true ); |
1159 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1160 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1160 | getEventViewerDialog()->setSyncMode( false ); | 1161 | getEventViewerDialog()->setSyncMode( false ); |
1161 | if ( syncOK ) { | 1162 | if ( syncOK ) { |
1162 | if ( KOPrefs::instance()->mWriteBackFile ) | 1163 | if ( KOPrefs::instance()->mWriteBackFile ) |
1163 | { | 1164 | { |
1164 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1165 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1165 | storage->save(); | 1166 | storage->save(); |
1166 | } | 1167 | } |
1167 | } | 1168 | } |
1168 | setModified( true ); | 1169 | setModified( true ); |
1169 | } | 1170 | } |
1170 | delete storage; | 1171 | delete storage; |
1171 | delete calendar; | 1172 | delete calendar; |
1172 | if ( syncOK ) | 1173 | if ( syncOK ) |
1173 | updateView(); | 1174 | updateView(); |
1174 | return syncOK; | 1175 | return syncOK; |
1175 | } | 1176 | } |
1176 | void CalendarView::syncPhone() | 1177 | void CalendarView::syncPhone() |
1177 | { | 1178 | { |
1178 | qDebug("CalendarView::syncPhone() "); | 1179 | syncExternal( 1 ); |
1179 | } | 1180 | } |
1180 | void CalendarView::syncSharp() | 1181 | void CalendarView::syncExternal( int mode ) |
1181 | { | 1182 | { |
1182 | #ifndef DESKTOP_VERSION | 1183 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1183 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | ||
1184 | //mCurrentSyncDevice = "sharp-DTM"; | 1184 | //mCurrentSyncDevice = "sharp-DTM"; |
1185 | if ( KOPrefs::instance()->mAskForPreferences ) | 1185 | if ( KOPrefs::instance()->mAskForPreferences ) |
1186 | edit_sync_options(); | 1186 | edit_sync_options(); |
1187 | qApp->processEvents(); | 1187 | qApp->processEvents(); |
1188 | CalendarLocal* calendar = new CalendarLocal(); | 1188 | CalendarLocal* calendar = new CalendarLocal(); |
1189 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1189 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1190 | bool syncOK = false; | 1190 | bool syncOK = false; |
1191 | SharpFormat sharpFormat; | 1191 | boo loadSuccess = false; |
1192 | if ( sharpFormat.load( calendar, mCalendar ) ) { | 1192 | PhoneFormat* phoneFormat = 0; |
1193 | #ifndef DESKTOP_VERSION | ||
1194 | SharpFormat* sharpFormat = 0; | ||
1195 | if ( mode == 0 ) { // sharp | ||
1196 | sharpFormat = new SharpFormat () ; | ||
1197 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | ||
1198 | |||
1199 | } else | ||
1200 | #endif | ||
1201 | if ( mode == 1 ) { // phone | ||
1202 | phoneFormat = new PhoneFormat (); | ||
1203 | loadSuccess = phoneFormat->load( calendar, mCalendar ); | ||
1204 | |||
1205 | } else | ||
1206 | return; | ||
1207 | if ( loadSuccess ) { | ||
1193 | getEventViewerDialog()->setSyncMode( true ); | 1208 | getEventViewerDialog()->setSyncMode( true ); |
1194 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1209 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1195 | getEventViewerDialog()->setSyncMode( false ); | 1210 | getEventViewerDialog()->setSyncMode( false ); |
1196 | qApp->processEvents(); | 1211 | qApp->processEvents(); |
1197 | if ( syncOK ) { | 1212 | if ( syncOK ) { |
1198 | if ( KOPrefs::instance()->mWriteBackFile ) | 1213 | if ( KOPrefs::instance()->mWriteBackFile ) |
1199 | { | 1214 | { |
1200 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1215 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1201 | Incidence* inc = iL.first(); | 1216 | Incidence* inc = iL.first(); |
1202 | /* obsolete | 1217 | /* obsolete |
1203 | while ( inc ) { | 1218 | while ( inc ) { |
1204 | inc->setZaurusStat( inc->revision () ); | 1219 | inc->setZaurusStat( inc->revision () ); |
1205 | inc = iL.next(); | 1220 | inc = iL.next(); |
1206 | } | 1221 | } |
1207 | */ | 1222 | */ |
1208 | // pending: clean last sync event description | 1223 | #ifndef DESKTOP_VERSION |
1209 | sharpFormat.save(calendar); | 1224 | if ( sharpFormat ) |
1225 | sharpFormat->save(calendar); | ||
1226 | #endif | ||
1227 | if ( phoneFormat ) | ||
1228 | phoneFormat->save(calendar); | ||
1210 | iL = calendar->rawIncidences(); | 1229 | iL = calendar->rawIncidences(); |
1211 | inc = iL.first(); | 1230 | inc = iL.first(); |
1212 | Incidence* loc; | 1231 | Incidence* loc; |
1213 | while ( inc ) { | 1232 | while ( inc ) { |
1214 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1233 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1215 | loc = mCalendar->incidence(inc->uid() ); | 1234 | loc = mCalendar->incidence(inc->uid() ); |
1216 | if ( loc ) { | 1235 | if ( loc ) { |
1217 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1236 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1218 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1237 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1219 | } | 1238 | } |
1220 | } | 1239 | } |
1221 | inc = iL.next(); | 1240 | inc = iL.next(); |
1222 | } | 1241 | } |
1223 | Incidence* lse = getLastSyncEvent(); | 1242 | Incidence* lse = getLastSyncEvent(); |
1224 | if ( lse ) { | 1243 | if ( lse ) { |
1225 | lse->setReadOnly( false ); | 1244 | lse->setReadOnly( false ); |
1226 | lse->setDescription( "" ); | 1245 | lse->setDescription( "" ); |
1227 | lse->setReadOnly( true ); | 1246 | lse->setReadOnly( true ); |
1228 | } | 1247 | } |
1229 | } | 1248 | } |
1230 | } | 1249 | } |
1231 | setModified( true ); | 1250 | setModified( true ); |
1232 | } else { | 1251 | } else { |
1233 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1252 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1234 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1253 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1235 | question, i18n("Ok")) ; | 1254 | question, i18n("Ok")) ; |
1236 | 1255 | ||
1237 | } | 1256 | } |
1238 | delete calendar; | 1257 | delete calendar; |
1239 | updateView(); | 1258 | updateView(); |
1240 | return ;//syncOK; | 1259 | return ;//syncOK; |
1241 | #endif | 1260 | |
1261 | } | ||
1262 | void CalendarView::syncSharp() | ||
1263 | { | ||
1264 | syncExternal( 0 ); | ||
1265 | |||
1242 | } | 1266 | } |
1243 | 1267 | ||
1244 | 1268 | ||
1245 | #include <kabc/stdaddressbook.h> | 1269 | #include <kabc/stdaddressbook.h> |
1246 | bool CalendarView::importBday() | 1270 | bool CalendarView::importBday() |
1247 | { | 1271 | { |
1248 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1272 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1249 | KABC::AddressBook::Iterator it; | 1273 | KABC::AddressBook::Iterator it; |
1250 | int count = 0; | 1274 | int count = 0; |
1251 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1275 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1252 | ++count; | 1276 | ++count; |
1253 | } | 1277 | } |
1254 | QProgressBar bar(count,0 ); | 1278 | QProgressBar bar(count,0 ); |
1255 | int w = 300; | 1279 | int w = 300; |
1256 | if ( QApplication::desktop()->width() < 320 ) | 1280 | if ( QApplication::desktop()->width() < 320 ) |
1257 | w = 220; | 1281 | w = 220; |
1258 | int h = bar.sizeHint().height() ; | 1282 | int h = bar.sizeHint().height() ; |
1259 | int dw = QApplication::desktop()->width(); | 1283 | int dw = QApplication::desktop()->width(); |
1260 | int dh = QApplication::desktop()->height(); | 1284 | int dh = QApplication::desktop()->height(); |
1261 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1285 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1262 | bar.show(); | 1286 | bar.show(); |
1263 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1287 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1264 | qApp->processEvents(); | 1288 | qApp->processEvents(); |
1265 | count = 0; | 1289 | count = 0; |
1266 | int addCount = 0; | 1290 | int addCount = 0; |
1267 | KCal::Attendee* a = 0; | 1291 | KCal::Attendee* a = 0; |
1268 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1292 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1269 | if ( ! bar.isVisible() ) | 1293 | if ( ! bar.isVisible() ) |
1270 | return false; | 1294 | return false; |
1271 | bar.setProgress( count++ ); | 1295 | bar.setProgress( count++ ); |
1272 | qApp->processEvents(); | 1296 | qApp->processEvents(); |
1273 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1297 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1274 | if ( (*it).birthday().date().isValid() ){ | 1298 | if ( (*it).birthday().date().isValid() ){ |
1275 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1299 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1276 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1300 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1277 | ++addCount; | 1301 | ++addCount; |
1278 | } | 1302 | } |
1279 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1303 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1280 | if ( anni.isValid() ){ | 1304 | if ( anni.isValid() ){ |
1281 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1305 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1282 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1306 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1283 | ++addCount; | 1307 | ++addCount; |
1284 | } | 1308 | } |
1285 | } | 1309 | } |
1286 | updateView(); | 1310 | updateView(); |
1287 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1311 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1288 | return true; | 1312 | return true; |
1289 | } | 1313 | } |
1290 | 1314 | ||
1291 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1315 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1292 | { | 1316 | { |
1293 | //qDebug("addAnni "); | 1317 | //qDebug("addAnni "); |
1294 | Event * ev = new Event(); | 1318 | Event * ev = new Event(); |
1295 | if ( a ) { | 1319 | if ( a ) { |
1296 | ev->addAttendee( a ); | 1320 | ev->addAttendee( a ); |
1297 | } | 1321 | } |
1298 | QString kind; | 1322 | QString kind; |
1299 | if ( birthday ) | 1323 | if ( birthday ) |
1300 | kind = i18n( "Birthday" ); | 1324 | kind = i18n( "Birthday" ); |
1301 | else | 1325 | else |
1302 | kind = i18n( "Anniversary" ); | 1326 | kind = i18n( "Anniversary" ); |
1303 | ev->setSummary( name + " - " + kind ); | 1327 | ev->setSummary( name + " - " + kind ); |
1304 | ev->setOrganizer( "nobody@nowhere" ); | 1328 | ev->setOrganizer( "nobody@nowhere" ); |
1305 | ev->setCategories( kind ); | 1329 | ev->setCategories( kind ); |
1306 | ev->setDtStart( QDateTime(date) ); | 1330 | ev->setDtStart( QDateTime(date) ); |
1307 | ev->setDtEnd( QDateTime(date) ); | 1331 | ev->setDtEnd( QDateTime(date) ); |
1308 | ev->setFloats( true ); | 1332 | ev->setFloats( true ); |
1309 | Recurrence * rec = ev->recurrence(); | 1333 | Recurrence * rec = ev->recurrence(); |
1310 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1334 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1311 | rec->addYearlyNum( date.month() ); | 1335 | rec->addYearlyNum( date.month() ); |
1312 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1336 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1313 | delete ev; | 1337 | delete ev; |
1314 | return false; | 1338 | return false; |
1315 | } | 1339 | } |
1316 | return true; | 1340 | return true; |
1317 | 1341 | ||
1318 | } | 1342 | } |
1319 | bool CalendarView::importQtopia( const QString &categories, | 1343 | bool CalendarView::importQtopia( const QString &categories, |
1320 | const QString &datebook, | 1344 | const QString &datebook, |
1321 | const QString &todolist ) | 1345 | const QString &todolist ) |
1322 | { | 1346 | { |
1323 | 1347 | ||
1324 | QtopiaFormat qtopiaFormat; | 1348 | QtopiaFormat qtopiaFormat; |
1325 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1349 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1326 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1350 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1327 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1351 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1328 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1352 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1329 | 1353 | ||
1330 | updateView(); | 1354 | updateView(); |
1331 | return true; | 1355 | return true; |
1332 | 1356 | ||
1333 | #if 0 | 1357 | #if 0 |
1334 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1358 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1335 | mCurrentSyncDevice = "qtopia-XML"; | 1359 | mCurrentSyncDevice = "qtopia-XML"; |
1336 | if ( KOPrefs::instance()->mAskForPreferences ) | 1360 | if ( KOPrefs::instance()->mAskForPreferences ) |
1337 | edit_sync_options(); | 1361 | edit_sync_options(); |
1338 | qApp->processEvents(); | 1362 | qApp->processEvents(); |
1339 | CalendarLocal* calendar = new CalendarLocal(); | 1363 | CalendarLocal* calendar = new CalendarLocal(); |
1340 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1364 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1341 | bool syncOK = false; | 1365 | bool syncOK = false; |
1342 | QtopiaFormat qtopiaFormat; | 1366 | QtopiaFormat qtopiaFormat; |
1343 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1367 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1344 | bool loadOk = true; | 1368 | bool loadOk = true; |
1345 | if ( !categories.isEmpty() ) | 1369 | if ( !categories.isEmpty() ) |
1346 | loadOk = qtopiaFormat.load( calendar, categories ); | 1370 | loadOk = qtopiaFormat.load( calendar, categories ); |
1347 | if ( loadOk && !datebook.isEmpty() ) | 1371 | if ( loadOk && !datebook.isEmpty() ) |
1348 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1372 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1349 | if ( loadOk && !todolist.isEmpty() ) | 1373 | if ( loadOk && !todolist.isEmpty() ) |
1350 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1374 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1351 | 1375 | ||
1352 | if ( loadOk ) { | 1376 | if ( loadOk ) { |
1353 | getEventViewerDialog()->setSyncMode( true ); | 1377 | getEventViewerDialog()->setSyncMode( true ); |
1354 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1378 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1355 | getEventViewerDialog()->setSyncMode( false ); | 1379 | getEventViewerDialog()->setSyncMode( false ); |
1356 | qApp->processEvents(); | 1380 | qApp->processEvents(); |
1357 | if ( syncOK ) { | 1381 | if ( syncOK ) { |
1358 | if ( KOPrefs::instance()->mWriteBackFile ) | 1382 | if ( KOPrefs::instance()->mWriteBackFile ) |
1359 | { | 1383 | { |
1360 | // write back XML file | 1384 | // write back XML file |
1361 | 1385 | ||
1362 | } | 1386 | } |
1363 | setModified( true ); | 1387 | setModified( true ); |
1364 | } | 1388 | } |
1365 | } else { | 1389 | } else { |
1366 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1390 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1367 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1391 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1368 | question, i18n("Ok")) ; | 1392 | question, i18n("Ok")) ; |
1369 | } | 1393 | } |
1370 | delete calendar; | 1394 | delete calendar; |
1371 | updateView(); | 1395 | updateView(); |
1372 | return syncOK; | 1396 | return syncOK; |
1373 | 1397 | ||
1374 | 1398 | ||
1375 | #endif | 1399 | #endif |
1376 | 1400 | ||
1377 | } | 1401 | } |
1378 | 1402 | ||
1379 | void CalendarView::setSyncEventsReadOnly() | 1403 | void CalendarView::setSyncEventsReadOnly() |
1380 | { | 1404 | { |
1381 | Event * ev; | 1405 | Event * ev; |
1382 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1406 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1383 | ev = eL.first(); | 1407 | ev = eL.first(); |
1384 | while ( ev ) { | 1408 | while ( ev ) { |
1385 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1409 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1386 | ev->setReadOnly( true ); | 1410 | ev->setReadOnly( true ); |
1387 | ev = eL.next(); | 1411 | ev = eL.next(); |
1388 | } | 1412 | } |
1389 | } | 1413 | } |
1390 | bool CalendarView::openCalendar(QString filename, bool merge) | 1414 | bool CalendarView::openCalendar(QString filename, bool merge) |
1391 | { | 1415 | { |
1392 | 1416 | ||
1393 | if (filename.isEmpty()) { | 1417 | if (filename.isEmpty()) { |
1394 | return false; | 1418 | return false; |
1395 | } | 1419 | } |
1396 | 1420 | ||
1397 | if (!QFile::exists(filename)) { | 1421 | if (!QFile::exists(filename)) { |
1398 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1422 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1399 | return false; | 1423 | return false; |
1400 | } | 1424 | } |
1401 | 1425 | ||
1402 | globalFlagBlockAgenda = 1; | 1426 | globalFlagBlockAgenda = 1; |
1403 | if (!merge) mCalendar->close(); | 1427 | if (!merge) mCalendar->close(); |
1404 | 1428 | ||
1405 | mStorage->setFileName( filename ); | 1429 | mStorage->setFileName( filename ); |
1406 | 1430 | ||
1407 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1431 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1408 | if ( merge ) ;//setModified( true ); | 1432 | if ( merge ) ;//setModified( true ); |
1409 | else { | 1433 | else { |
1410 | //setModified( true ); | 1434 | //setModified( true ); |
1411 | mViewManager->setDocumentId( filename ); | 1435 | mViewManager->setDocumentId( filename ); |
1412 | mDialogManager->setDocumentId( filename ); | 1436 | mDialogManager->setDocumentId( filename ); |
1413 | mTodoList->setDocumentId( filename ); | 1437 | mTodoList->setDocumentId( filename ); |
1414 | } | 1438 | } |
1415 | globalFlagBlockAgenda = 2; | 1439 | globalFlagBlockAgenda = 2; |
1416 | // if ( getLastSyncEvent() ) | 1440 | // if ( getLastSyncEvent() ) |
1417 | // getLastSyncEvent()->setReadOnly( true ); | 1441 | // getLastSyncEvent()->setReadOnly( true ); |
1418 | mCalendar->reInitAlarmSettings(); | 1442 | mCalendar->reInitAlarmSettings(); |
1419 | setSyncEventsReadOnly(); | 1443 | setSyncEventsReadOnly(); |
1420 | updateUnmanagedViews(); | 1444 | updateUnmanagedViews(); |
1421 | updateView(); | 1445 | updateView(); |
1422 | if ( filename != MainWindow::defaultFileName() ) | 1446 | if ( filename != MainWindow::defaultFileName() ) |
1423 | saveCalendar( MainWindow::defaultFileName() ); | 1447 | saveCalendar( MainWindow::defaultFileName() ); |
1424 | loadedFileVersion = QDateTime::currentDateTime(); | 1448 | loadedFileVersion = QDateTime::currentDateTime(); |
1425 | return true; | 1449 | return true; |
1426 | } else { | 1450 | } else { |
1427 | // while failing to load, the calendar object could | 1451 | // while failing to load, the calendar object could |
1428 | // have become partially populated. Clear it out. | 1452 | // have become partially populated. Clear it out. |
1429 | if ( !merge ) mCalendar->close(); | 1453 | if ( !merge ) mCalendar->close(); |
1430 | 1454 | ||
1431 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1455 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1432 | 1456 | ||
1433 | globalFlagBlockAgenda = 2; | 1457 | globalFlagBlockAgenda = 2; |
1434 | updateView(); | 1458 | updateView(); |
1435 | } | 1459 | } |
1436 | return false; | 1460 | return false; |
1437 | } | 1461 | } |
1438 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1462 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1439 | { | 1463 | { |
1440 | loadedFileVersion = dt; | 1464 | loadedFileVersion = dt; |
1441 | } | 1465 | } |
1442 | bool CalendarView::checkFileChanged(QString fn) | 1466 | bool CalendarView::checkFileChanged(QString fn) |
1443 | { | 1467 | { |
1444 | QFileInfo finf ( fn ); | 1468 | QFileInfo finf ( fn ); |
1445 | if ( !finf.exists() ) | 1469 | if ( !finf.exists() ) |
1446 | return true; | 1470 | return true; |
1447 | QDateTime dt = finf.lastModified (); | 1471 | QDateTime dt = finf.lastModified (); |
1448 | if ( dt <= loadedFileVersion ) | 1472 | if ( dt <= loadedFileVersion ) |
1449 | return false; | 1473 | return false; |
1450 | return true; | 1474 | return true; |
1451 | 1475 | ||
1452 | } | 1476 | } |
1453 | bool CalendarView::checkFileVersion(QString fn) | 1477 | bool CalendarView::checkFileVersion(QString fn) |
1454 | { | 1478 | { |
1455 | QFileInfo finf ( fn ); | 1479 | QFileInfo finf ( fn ); |
1456 | if ( !finf.exists() ) | 1480 | if ( !finf.exists() ) |
1457 | return true; | 1481 | return true; |
1458 | QDateTime dt = finf.lastModified (); | 1482 | QDateTime dt = finf.lastModified (); |
1459 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1483 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1460 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1484 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1461 | if ( dt <= loadedFileVersion ) | 1485 | if ( dt <= loadedFileVersion ) |
1462 | return true; | 1486 | return true; |
1463 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , | 1487 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , |
1464 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1488 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1465 | i18n("Sync+save")); | 1489 | i18n("Sync+save")); |
1466 | 1490 | ||
1467 | if ( km == KMessageBox::Cancel ) | 1491 | if ( km == KMessageBox::Cancel ) |
1468 | return false; | 1492 | return false; |
1469 | if ( km == KMessageBox::Yes ) | 1493 | if ( km == KMessageBox::Yes ) |
1470 | return true; | 1494 | return true; |
1471 | 1495 | ||
1472 | setSyncDevice("deleteaftersync" ); | 1496 | setSyncDevice("deleteaftersync" ); |
1473 | KOPrefs::instance()->mAskForPreferences = true; | 1497 | KOPrefs::instance()->mAskForPreferences = true; |
1474 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1498 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1475 | KOPrefs::instance()->mWriteBackFile = false; | 1499 | KOPrefs::instance()->mWriteBackFile = false; |
1476 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1500 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1477 | KOPrefs::instance()->mShowSyncSummary = false; | 1501 | KOPrefs::instance()->mShowSyncSummary = false; |
1478 | syncCalendar( fn, 3 ); | 1502 | syncCalendar( fn, 3 ); |
1479 | Event * e = getLastSyncEvent(); | 1503 | Event * e = getLastSyncEvent(); |
1480 | mCalendar->deleteEvent ( e ); | 1504 | mCalendar->deleteEvent ( e ); |
1481 | updateView(); | 1505 | updateView(); |
1482 | return true; | 1506 | return true; |
1483 | } | 1507 | } |
1484 | 1508 | ||
1485 | bool CalendarView::saveCalendar( QString filename ) | 1509 | bool CalendarView::saveCalendar( QString filename ) |
1486 | { | 1510 | { |
1487 | 1511 | ||
1488 | // Store back all unsaved data into calendar object | 1512 | // Store back all unsaved data into calendar object |
1489 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1513 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1490 | if ( mViewManager->currentView() ) | 1514 | if ( mViewManager->currentView() ) |
1491 | mViewManager->currentView()->flushView(); | 1515 | mViewManager->currentView()->flushView(); |
1492 | 1516 | ||
1493 | //mStorage->setFileName( filename ); | 1517 | //mStorage->setFileName( filename ); |
1494 | 1518 | ||
1495 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1519 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1496 | mStorage->setFileName( filename ); | 1520 | mStorage->setFileName( filename ); |
1497 | bool success; | 1521 | bool success; |
1498 | success = mStorage->save(); | 1522 | success = mStorage->save(); |
1499 | if ( !success ) { | 1523 | if ( !success ) { |
1500 | return false; | 1524 | return false; |
1501 | } | 1525 | } |
1502 | 1526 | ||
1503 | return true; | 1527 | return true; |
1504 | } | 1528 | } |
1505 | 1529 | ||
1506 | void CalendarView::closeCalendar() | 1530 | void CalendarView::closeCalendar() |
1507 | { | 1531 | { |
1508 | 1532 | ||
1509 | // child windows no longer valid | 1533 | // child windows no longer valid |
1510 | emit closingDown(); | 1534 | emit closingDown(); |
1511 | 1535 | ||
1512 | mCalendar->close(); | 1536 | mCalendar->close(); |
1513 | setModified(false); | 1537 | setModified(false); |
1514 | updateView(); | 1538 | updateView(); |
1515 | } | 1539 | } |
1516 | 1540 | ||
1517 | void CalendarView::archiveCalendar() | 1541 | void CalendarView::archiveCalendar() |
1518 | { | 1542 | { |
1519 | mDialogManager->showArchiveDialog(); | 1543 | mDialogManager->showArchiveDialog(); |
1520 | } | 1544 | } |
1521 | 1545 | ||
1522 | 1546 | ||
1523 | void CalendarView::readSettings() | 1547 | void CalendarView::readSettings() |
1524 | { | 1548 | { |
1525 | 1549 | ||
1526 | 1550 | ||
1527 | // mViewManager->showAgendaView(); | 1551 | // mViewManager->showAgendaView(); |
1528 | QString str; | 1552 | QString str; |
1529 | //qDebug("CalendarView::readSettings() "); | 1553 | //qDebug("CalendarView::readSettings() "); |
1530 | // read settings from the KConfig, supplying reasonable | 1554 | // read settings from the KConfig, supplying reasonable |
1531 | // defaults where none are to be found | 1555 | // defaults where none are to be found |
1532 | KConfig *config = KOGlobals::config(); | 1556 | KConfig *config = KOGlobals::config(); |
1533 | #ifndef KORG_NOSPLITTER | 1557 | #ifndef KORG_NOSPLITTER |
1534 | config->setGroup("KOrganizer Geometry"); | 1558 | config->setGroup("KOrganizer Geometry"); |
1535 | 1559 | ||
1536 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1560 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1537 | if (sizes.count() != 2) { | 1561 | if (sizes.count() != 2) { |
1538 | sizes << mDateNavigator->minimumSizeHint().width(); | 1562 | sizes << mDateNavigator->minimumSizeHint().width(); |
1539 | sizes << 300; | 1563 | sizes << 300; |
1540 | } | 1564 | } |
1541 | mPanner->setSizes(sizes); | 1565 | mPanner->setSizes(sizes); |
1542 | 1566 | ||
1543 | sizes = config->readIntListEntry("Separator2"); | 1567 | sizes = config->readIntListEntry("Separator2"); |
1544 | if ( ( mResourceView && sizes.count() == 4 ) || | 1568 | if ( ( mResourceView && sizes.count() == 4 ) || |
1545 | ( !mResourceView && sizes.count() == 3 ) ) { | 1569 | ( !mResourceView && sizes.count() == 3 ) ) { |
1546 | mLeftSplitter->setSizes(sizes); | 1570 | mLeftSplitter->setSizes(sizes); |
1547 | } | 1571 | } |
1548 | #endif | 1572 | #endif |
1549 | globalFlagBlockAgenda = 1; | 1573 | globalFlagBlockAgenda = 1; |
1550 | mViewManager->showAgendaView(); | 1574 | mViewManager->showAgendaView(); |
1551 | //mViewManager->readSettings( config ); | 1575 | //mViewManager->readSettings( config ); |
1552 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1576 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1553 | readFilterSettings(config); | 1577 | readFilterSettings(config); |
1554 | config->setGroup( "Views" ); | 1578 | config->setGroup( "Views" ); |
1555 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1579 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1556 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1580 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1557 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1581 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1558 | else mNavigator->selectDates( dateCount ); | 1582 | else mNavigator->selectDates( dateCount ); |
1559 | // mViewManager->readSettings( config ); | 1583 | // mViewManager->readSettings( config ); |
1560 | updateConfig(); | 1584 | updateConfig(); |
1561 | globalFlagBlockAgenda = 2; | 1585 | globalFlagBlockAgenda = 2; |
1562 | mViewManager->readSettings( config ); | 1586 | mViewManager->readSettings( config ); |
1563 | #ifdef DESKTOP_VERSION | 1587 | #ifdef DESKTOP_VERSION |
1564 | config->setGroup("WidgetLayout"); | 1588 | config->setGroup("WidgetLayout"); |
1565 | QStringList list; | 1589 | QStringList list; |
1566 | list = config->readListEntry("MainLayout"); | 1590 | list = config->readListEntry("MainLayout"); |
1567 | int x,y,w,h; | 1591 | int x,y,w,h; |
1568 | if ( ! list.isEmpty() ) { | 1592 | if ( ! list.isEmpty() ) { |
1569 | x = list[0].toInt(); | 1593 | x = list[0].toInt(); |
1570 | y = list[1].toInt(); | 1594 | y = list[1].toInt(); |
1571 | w = list[2].toInt(); | 1595 | w = list[2].toInt(); |
1572 | h = list[3].toInt(); | 1596 | h = list[3].toInt(); |
1573 | topLevelWidget()->setGeometry(x,y,w,h); | 1597 | topLevelWidget()->setGeometry(x,y,w,h); |
1574 | 1598 | ||
1575 | } else { | 1599 | } else { |
1576 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1600 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1577 | } | 1601 | } |
1578 | list = config->readListEntry("EditEventLayout"); | 1602 | list = config->readListEntry("EditEventLayout"); |
1579 | if ( ! list.isEmpty() ) { | 1603 | if ( ! list.isEmpty() ) { |
1580 | x = list[0].toInt(); | 1604 | x = list[0].toInt(); |
1581 | y = list[1].toInt(); | 1605 | y = list[1].toInt(); |
1582 | w = list[2].toInt(); | 1606 | w = list[2].toInt(); |
1583 | h = list[3].toInt(); | 1607 | h = list[3].toInt(); |
1584 | mEventEditor->setGeometry(x,y,w,h); | 1608 | mEventEditor->setGeometry(x,y,w,h); |
1585 | 1609 | ||
1586 | } | 1610 | } |
1587 | list = config->readListEntry("EditTodoLayout"); | 1611 | list = config->readListEntry("EditTodoLayout"); |
1588 | if ( ! list.isEmpty() ) { | 1612 | if ( ! list.isEmpty() ) { |
1589 | x = list[0].toInt(); | 1613 | x = list[0].toInt(); |
1590 | y = list[1].toInt(); | 1614 | y = list[1].toInt(); |
1591 | w = list[2].toInt(); | 1615 | w = list[2].toInt(); |
1592 | h = list[3].toInt(); | 1616 | h = list[3].toInt(); |
1593 | mTodoEditor->setGeometry(x,y,w,h); | 1617 | mTodoEditor->setGeometry(x,y,w,h); |
1594 | 1618 | ||
1595 | } | 1619 | } |
1596 | list = config->readListEntry("ViewerLayout"); | 1620 | list = config->readListEntry("ViewerLayout"); |
1597 | if ( ! list.isEmpty() ) { | 1621 | if ( ! list.isEmpty() ) { |
1598 | x = list[0].toInt(); | 1622 | x = list[0].toInt(); |
1599 | y = list[1].toInt(); | 1623 | y = list[1].toInt(); |
1600 | w = list[2].toInt(); | 1624 | w = list[2].toInt(); |
1601 | h = list[3].toInt(); | 1625 | h = list[3].toInt(); |
1602 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1626 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1603 | } | 1627 | } |
1604 | #endif | 1628 | #endif |
1605 | 1629 | ||
1606 | } | 1630 | } |
1607 | 1631 | ||
1608 | 1632 | ||
1609 | void CalendarView::writeSettings() | 1633 | void CalendarView::writeSettings() |
1610 | { | 1634 | { |
1611 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1635 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1612 | 1636 | ||
1613 | KConfig *config = KOGlobals::config(); | 1637 | KConfig *config = KOGlobals::config(); |
1614 | 1638 | ||
1615 | #ifndef KORG_NOSPLITTER | 1639 | #ifndef KORG_NOSPLITTER |
1616 | config->setGroup("KOrganizer Geometry"); | 1640 | config->setGroup("KOrganizer Geometry"); |
1617 | 1641 | ||
1618 | QValueList<int> list = mPanner->sizes(); | 1642 | QValueList<int> list = mPanner->sizes(); |
1619 | config->writeEntry("Separator1",list); | 1643 | config->writeEntry("Separator1",list); |
1620 | 1644 | ||
1621 | list = mLeftSplitter->sizes(); | 1645 | list = mLeftSplitter->sizes(); |
1622 | config->writeEntry("Separator2",list); | 1646 | config->writeEntry("Separator2",list); |
1623 | #endif | 1647 | #endif |
1624 | 1648 | ||
1625 | mViewManager->writeSettings( config ); | 1649 | mViewManager->writeSettings( config ); |
1626 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1650 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1627 | mDialogManager->writeSettings( config ); | 1651 | mDialogManager->writeSettings( config ); |
1628 | //KOPrefs::instance()->usrWriteConfig(); | 1652 | //KOPrefs::instance()->usrWriteConfig(); |
1629 | KOPrefs::instance()->writeConfig(); | 1653 | KOPrefs::instance()->writeConfig(); |
1630 | 1654 | ||
1631 | writeFilterSettings(config); | 1655 | writeFilterSettings(config); |
1632 | 1656 | ||
1633 | config->setGroup( "Views" ); | 1657 | config->setGroup( "Views" ); |
1634 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1658 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1635 | 1659 | ||
1636 | #ifdef DESKTOP_VERSION | 1660 | #ifdef DESKTOP_VERSION |
1637 | config->setGroup("WidgetLayout"); | 1661 | config->setGroup("WidgetLayout"); |
1638 | QStringList list ;//= config->readListEntry("MainLayout"); | 1662 | QStringList list ;//= config->readListEntry("MainLayout"); |
1639 | int x,y,w,h; | 1663 | int x,y,w,h; |
1640 | QWidget* wid; | 1664 | QWidget* wid; |
1641 | wid = topLevelWidget(); | 1665 | wid = topLevelWidget(); |
1642 | x = wid->geometry().x(); | 1666 | x = wid->geometry().x(); |
1643 | y = wid->geometry().y(); | 1667 | y = wid->geometry().y(); |
1644 | w = wid->width(); | 1668 | w = wid->width(); |
1645 | h = wid->height(); | 1669 | h = wid->height(); |
1646 | list.clear(); | 1670 | list.clear(); |
1647 | list << QString::number( x ); | 1671 | list << QString::number( x ); |
1648 | list << QString::number( y ); | 1672 | list << QString::number( y ); |
1649 | list << QString::number( w ); | 1673 | list << QString::number( w ); |
1650 | list << QString::number( h ); | 1674 | list << QString::number( h ); |
1651 | config->writeEntry("MainLayout",list ); | 1675 | config->writeEntry("MainLayout",list ); |
1652 | 1676 | ||
1653 | wid = mEventEditor; | 1677 | wid = mEventEditor; |
1654 | x = wid->geometry().x(); | 1678 | x = wid->geometry().x(); |
1655 | y = wid->geometry().y(); | 1679 | y = wid->geometry().y(); |
1656 | w = wid->width(); | 1680 | w = wid->width(); |
1657 | h = wid->height(); | 1681 | h = wid->height(); |
1658 | list.clear(); | 1682 | list.clear(); |
1659 | list << QString::number( x ); | 1683 | list << QString::number( x ); |
1660 | list << QString::number( y ); | 1684 | list << QString::number( y ); |
1661 | list << QString::number( w ); | 1685 | list << QString::number( w ); |
1662 | list << QString::number( h ); | 1686 | list << QString::number( h ); |
1663 | config->writeEntry("EditEventLayout",list ); | 1687 | config->writeEntry("EditEventLayout",list ); |
1664 | 1688 | ||
1665 | wid = mTodoEditor; | 1689 | wid = mTodoEditor; |
1666 | x = wid->geometry().x(); | 1690 | x = wid->geometry().x(); |
1667 | y = wid->geometry().y(); | 1691 | y = wid->geometry().y(); |
1668 | w = wid->width(); | 1692 | w = wid->width(); |
1669 | h = wid->height(); | 1693 | h = wid->height(); |
1670 | list.clear(); | 1694 | list.clear(); |
1671 | list << QString::number( x ); | 1695 | list << QString::number( x ); |
1672 | list << QString::number( y ); | 1696 | list << QString::number( y ); |
1673 | list << QString::number( w ); | 1697 | list << QString::number( w ); |
1674 | list << QString::number( h ); | 1698 | list << QString::number( h ); |
1675 | config->writeEntry("EditTodoLayout",list ); | 1699 | config->writeEntry("EditTodoLayout",list ); |
1676 | wid = getEventViewerDialog(); | 1700 | wid = getEventViewerDialog(); |
1677 | x = wid->geometry().x(); | 1701 | x = wid->geometry().x(); |
1678 | y = wid->geometry().y(); | 1702 | y = wid->geometry().y(); |
1679 | w = wid->width(); | 1703 | w = wid->width(); |
1680 | h = wid->height(); | 1704 | h = wid->height(); |
1681 | list.clear(); | 1705 | list.clear(); |
1682 | list << QString::number( x ); | 1706 | list << QString::number( x ); |
1683 | list << QString::number( y ); | 1707 | list << QString::number( y ); |
1684 | list << QString::number( w ); | 1708 | list << QString::number( w ); |
1685 | list << QString::number( h ); | 1709 | list << QString::number( h ); |
1686 | config->writeEntry("ViewerLayout",list ); | 1710 | config->writeEntry("ViewerLayout",list ); |
1687 | wid = mDialogManager->getSearchDialog(); | 1711 | wid = mDialogManager->getSearchDialog(); |
1688 | if ( wid ) { | 1712 | if ( wid ) { |
1689 | x = wid->geometry().x(); | 1713 | x = wid->geometry().x(); |
1690 | y = wid->geometry().y(); | 1714 | y = wid->geometry().y(); |
1691 | w = wid->width(); | 1715 | w = wid->width(); |
1692 | h = wid->height(); | 1716 | h = wid->height(); |
1693 | list.clear(); | 1717 | list.clear(); |
1694 | list << QString::number( x ); | 1718 | list << QString::number( x ); |
1695 | list << QString::number( y ); | 1719 | list << QString::number( y ); |
1696 | list << QString::number( w ); | 1720 | list << QString::number( w ); |
1697 | list << QString::number( h ); | 1721 | list << QString::number( h ); |
1698 | config->writeEntry("SearchLayout",list ); | 1722 | config->writeEntry("SearchLayout",list ); |
1699 | } | 1723 | } |
1700 | #endif | 1724 | #endif |
1701 | 1725 | ||
1702 | 1726 | ||
1703 | config->sync(); | 1727 | config->sync(); |
1704 | } | 1728 | } |
1705 | 1729 | ||
1706 | void CalendarView::readFilterSettings(KConfig *config) | 1730 | void CalendarView::readFilterSettings(KConfig *config) |
1707 | { | 1731 | { |
1708 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1732 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1709 | 1733 | ||
1710 | mFilters.clear(); | 1734 | mFilters.clear(); |
1711 | 1735 | ||
1712 | config->setGroup("General"); | 1736 | config->setGroup("General"); |
1713 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1737 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1714 | 1738 | ||
1715 | QStringList::ConstIterator it = filterList.begin(); | 1739 | QStringList::ConstIterator it = filterList.begin(); |
1716 | QStringList::ConstIterator end = filterList.end(); | 1740 | QStringList::ConstIterator end = filterList.end(); |
1717 | while(it != end) { | 1741 | while(it != end) { |
1718 | // kdDebug() << " filter: " << (*it) << endl; | 1742 | // kdDebug() << " filter: " << (*it) << endl; |
1719 | 1743 | ||
1720 | CalFilter *filter; | 1744 | CalFilter *filter; |
1721 | filter = new CalFilter(*it); | 1745 | filter = new CalFilter(*it); |
1722 | config->setGroup("Filter_" + (*it)); | 1746 | config->setGroup("Filter_" + (*it)); |
1723 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1747 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1724 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1748 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1725 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1749 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1726 | mFilters.append(filter); | 1750 | mFilters.append(filter); |
1727 | 1751 | ||
1728 | ++it; | 1752 | ++it; |
1729 | } | 1753 | } |
1730 | 1754 | ||
1731 | if (mFilters.count() == 0) { | 1755 | if (mFilters.count() == 0) { |
1732 | CalFilter *filter = new CalFilter(i18n("Default")); | 1756 | CalFilter *filter = new CalFilter(i18n("Default")); |
1733 | mFilters.append(filter); | 1757 | mFilters.append(filter); |
1734 | } | 1758 | } |
1735 | mFilterView->updateFilters(); | 1759 | mFilterView->updateFilters(); |
1736 | config->setGroup("FilterView"); | 1760 | config->setGroup("FilterView"); |
1737 | 1761 | ||
1738 | mFilterView->blockSignals(true); | 1762 | mFilterView->blockSignals(true); |
1739 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1763 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1740 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1764 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1741 | mFilterView->blockSignals(false); | 1765 | mFilterView->blockSignals(false); |
1742 | // We do it manually to avoid it being done twice by the above calls | 1766 | // We do it manually to avoid it being done twice by the above calls |
1743 | updateFilter(); | 1767 | updateFilter(); |
1744 | } | 1768 | } |
1745 | 1769 | ||
1746 | void CalendarView::writeFilterSettings(KConfig *config) | 1770 | void CalendarView::writeFilterSettings(KConfig *config) |
1747 | { | 1771 | { |
1748 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1772 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1749 | 1773 | ||
1750 | QStringList filterList; | 1774 | QStringList filterList; |
1751 | 1775 | ||
1752 | CalFilter *filter = mFilters.first(); | 1776 | CalFilter *filter = mFilters.first(); |
1753 | while(filter) { | 1777 | while(filter) { |
1754 | // kdDebug() << " fn: " << filter->name() << endl; | 1778 | // kdDebug() << " fn: " << filter->name() << endl; |
1755 | filterList << filter->name(); | 1779 | filterList << filter->name(); |
1756 | config->setGroup("Filter_" + filter->name()); | 1780 | config->setGroup("Filter_" + filter->name()); |
1757 | config->writeEntry("Criteria",filter->criteria()); | 1781 | config->writeEntry("Criteria",filter->criteria()); |
1758 | config->writeEntry("CategoryList",filter->categoryList()); | 1782 | config->writeEntry("CategoryList",filter->categoryList()); |
1759 | filter = mFilters.next(); | 1783 | filter = mFilters.next(); |
1760 | } | 1784 | } |
1761 | config->setGroup("General"); | 1785 | config->setGroup("General"); |
1762 | config->writeEntry("CalendarFilters",filterList); | 1786 | config->writeEntry("CalendarFilters",filterList); |
1763 | 1787 | ||
1764 | config->setGroup("FilterView"); | 1788 | config->setGroup("FilterView"); |
1765 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1789 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1766 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1790 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1767 | } | 1791 | } |
1768 | 1792 | ||
1769 | 1793 | ||
1770 | void CalendarView::goToday() | 1794 | void CalendarView::goToday() |
1771 | { | 1795 | { |
1772 | mNavigator->selectToday(); | 1796 | mNavigator->selectToday(); |
1773 | } | 1797 | } |
1774 | 1798 | ||
1775 | void CalendarView::goNext() | 1799 | void CalendarView::goNext() |
1776 | { | 1800 | { |
1777 | mNavigator->selectNext(); | 1801 | mNavigator->selectNext(); |
1778 | } | 1802 | } |
1779 | 1803 | ||
1780 | void CalendarView::goPrevious() | 1804 | void CalendarView::goPrevious() |
1781 | { | 1805 | { |
1782 | mNavigator->selectPrevious(); | 1806 | mNavigator->selectPrevious(); |
1783 | } | 1807 | } |
1784 | void CalendarView::goNextMonth() | 1808 | void CalendarView::goNextMonth() |
1785 | { | 1809 | { |
1786 | mNavigator->selectNextMonth(); | 1810 | mNavigator->selectNextMonth(); |
1787 | } | 1811 | } |
1788 | 1812 | ||
1789 | void CalendarView::goPreviousMonth() | 1813 | void CalendarView::goPreviousMonth() |
1790 | { | 1814 | { |
1791 | mNavigator->selectPreviousMonth(); | 1815 | mNavigator->selectPreviousMonth(); |
1792 | } | 1816 | } |
1793 | void CalendarView::writeLocale() | 1817 | void CalendarView::writeLocale() |
1794 | { | 1818 | { |
1795 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1819 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1796 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1820 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1797 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1821 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1798 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1822 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1799 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1823 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1800 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1824 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1801 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1825 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1802 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1826 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1803 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1827 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1804 | KOPrefs::instance()->mDaylightsavingStart, | 1828 | KOPrefs::instance()->mDaylightsavingStart, |
1805 | KOPrefs::instance()->mDaylightsavingEnd ); | 1829 | KOPrefs::instance()->mDaylightsavingEnd ); |
1806 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1830 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1807 | } | 1831 | } |
1808 | void CalendarView::updateConfig() | 1832 | void CalendarView::updateConfig() |
1809 | { | 1833 | { |
1810 | writeLocale(); | 1834 | writeLocale(); |
1811 | if ( KOPrefs::instance()->mUseAppColors ) | 1835 | if ( KOPrefs::instance()->mUseAppColors ) |
1812 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1836 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1813 | emit configChanged(); | 1837 | emit configChanged(); |
1814 | mTodoList->updateConfig(); | 1838 | mTodoList->updateConfig(); |
1815 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1839 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1816 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1840 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1817 | // To make the "fill window" configurations work | 1841 | // To make the "fill window" configurations work |
1818 | //mViewManager->raiseCurrentView(); | 1842 | //mViewManager->raiseCurrentView(); |
1819 | } | 1843 | } |
1820 | 1844 | ||
1821 | 1845 | ||
1822 | void CalendarView::eventChanged(Event *event) | 1846 | void CalendarView::eventChanged(Event *event) |
1823 | { | 1847 | { |
1824 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1848 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1825 | //updateUnmanagedViews(); | 1849 | //updateUnmanagedViews(); |
1826 | } | 1850 | } |
1827 | 1851 | ||
1828 | void CalendarView::eventAdded(Event *event) | 1852 | void CalendarView::eventAdded(Event *event) |
1829 | { | 1853 | { |
1830 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1854 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1831 | } | 1855 | } |
1832 | 1856 | ||
1833 | void CalendarView::eventToBeDeleted(Event *) | 1857 | void CalendarView::eventToBeDeleted(Event *) |
1834 | { | 1858 | { |
1835 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1859 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1836 | } | 1860 | } |
1837 | 1861 | ||
1838 | void CalendarView::eventDeleted() | 1862 | void CalendarView::eventDeleted() |
1839 | { | 1863 | { |
1840 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1864 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1841 | } | 1865 | } |
1842 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1866 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1843 | { | 1867 | { |
1844 | changeIncidenceDisplay((Incidence *)which, action); | 1868 | changeIncidenceDisplay((Incidence *)which, action); |
1845 | } | 1869 | } |
1846 | 1870 | ||
1847 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1871 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1848 | { | 1872 | { |
1849 | updateUnmanagedViews(); | 1873 | updateUnmanagedViews(); |
1850 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1874 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1851 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1875 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1852 | mCalendar->checkAlarmForIncidence( 0, true ); | 1876 | mCalendar->checkAlarmForIncidence( 0, true ); |
1853 | if ( mEventViewerDialog ) | 1877 | if ( mEventViewerDialog ) |
1854 | mEventViewerDialog->hide(); | 1878 | mEventViewerDialog->hide(); |
1855 | } | 1879 | } |
1856 | else | 1880 | else |
1857 | mCalendar->checkAlarmForIncidence( which , false ); | 1881 | mCalendar->checkAlarmForIncidence( which , false ); |
1858 | } | 1882 | } |
1859 | 1883 | ||
1860 | // most of the changeEventDisplays() right now just call the view's | 1884 | // most of the changeEventDisplays() right now just call the view's |
1861 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1885 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1862 | void CalendarView::changeEventDisplay(Event *which, int action) | 1886 | void CalendarView::changeEventDisplay(Event *which, int action) |
1863 | { | 1887 | { |
1864 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1888 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1865 | changeIncidenceDisplay((Incidence *)which, action); | 1889 | changeIncidenceDisplay((Incidence *)which, action); |
1866 | mDateNavigator->updateView(); | 1890 | mDateNavigator->updateView(); |
1867 | //mDialogManager->updateSearchDialog(); | 1891 | //mDialogManager->updateSearchDialog(); |
1868 | 1892 | ||
1869 | if (which) { | 1893 | if (which) { |
1870 | // If there is an event view visible update the display | 1894 | // If there is an event view visible update the display |
1871 | mViewManager->currentView()->changeEventDisplay(which,action); | 1895 | mViewManager->currentView()->changeEventDisplay(which,action); |
1872 | // TODO: check, if update needed | 1896 | // TODO: check, if update needed |
1873 | // if (which->getTodoStatus()) { | 1897 | // if (which->getTodoStatus()) { |
1874 | mTodoList->updateView(); | 1898 | mTodoList->updateView(); |
1875 | // } | 1899 | // } |
1876 | } else { | 1900 | } else { |
1877 | mViewManager->currentView()->updateView(); | 1901 | mViewManager->currentView()->updateView(); |
1878 | } | 1902 | } |
1879 | } | 1903 | } |
1880 | 1904 | ||
1881 | 1905 | ||
1882 | void CalendarView::updateTodoViews() | 1906 | void CalendarView::updateTodoViews() |
1883 | { | 1907 | { |
1884 | 1908 | ||
1885 | mTodoList->updateView(); | 1909 | mTodoList->updateView(); |
1886 | mViewManager->currentView()->updateView(); | 1910 | mViewManager->currentView()->updateView(); |
1887 | 1911 | ||
1888 | } | 1912 | } |
1889 | 1913 | ||
1890 | 1914 | ||
1891 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1915 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1892 | { | 1916 | { |
1893 | mTodoList->updateView(); | 1917 | mTodoList->updateView(); |
1894 | mViewManager->updateView(start, end); | 1918 | mViewManager->updateView(start, end); |
1895 | //mDateNavigator->updateView(); | 1919 | //mDateNavigator->updateView(); |
1896 | } | 1920 | } |
1897 | 1921 | ||
1898 | void CalendarView::updateView() | 1922 | void CalendarView::updateView() |
1899 | { | 1923 | { |
1900 | DateList tmpList = mNavigator->selectedDates(); | 1924 | DateList tmpList = mNavigator->selectedDates(); |
1901 | 1925 | ||
1902 | // We assume that the navigator only selects consecutive days. | 1926 | // We assume that the navigator only selects consecutive days. |
1903 | updateView( tmpList.first(), tmpList.last() ); | 1927 | updateView( tmpList.first(), tmpList.last() ); |
1904 | } | 1928 | } |
1905 | 1929 | ||
1906 | void CalendarView::updateUnmanagedViews() | 1930 | void CalendarView::updateUnmanagedViews() |
1907 | { | 1931 | { |
1908 | mDateNavigator->updateDayMatrix(); | 1932 | mDateNavigator->updateDayMatrix(); |
1909 | } | 1933 | } |
1910 | 1934 | ||
1911 | int CalendarView::msgItemDelete() | 1935 | int CalendarView::msgItemDelete() |
1912 | { | 1936 | { |
1913 | return KMessageBox::warningContinueCancel(this, | 1937 | return KMessageBox::warningContinueCancel(this, |
1914 | i18n("This item will be\npermanently deleted."), | 1938 | i18n("This item will be\npermanently deleted."), |
1915 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 1939 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
1916 | } | 1940 | } |
1917 | 1941 | ||
1918 | 1942 | ||
1919 | void CalendarView::edit_cut() | 1943 | void CalendarView::edit_cut() |
1920 | { | 1944 | { |
1921 | Event *anEvent=0; | 1945 | Event *anEvent=0; |
1922 | 1946 | ||
1923 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1947 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1924 | 1948 | ||
1925 | if (mViewManager->currentView()->isEventView()) { | 1949 | if (mViewManager->currentView()->isEventView()) { |
1926 | if ( incidence && incidence->type() == "Event" ) { | 1950 | if ( incidence && incidence->type() == "Event" ) { |
1927 | anEvent = static_cast<Event *>(incidence); | 1951 | anEvent = static_cast<Event *>(incidence); |
1928 | } | 1952 | } |
1929 | } | 1953 | } |
1930 | 1954 | ||
1931 | if (!anEvent) { | 1955 | if (!anEvent) { |
1932 | KNotifyClient::beep(); | 1956 | KNotifyClient::beep(); |
1933 | return; | 1957 | return; |
1934 | } | 1958 | } |
1935 | DndFactory factory( mCalendar ); | 1959 | DndFactory factory( mCalendar ); |
1936 | factory.cutEvent(anEvent); | 1960 | factory.cutEvent(anEvent); |
1937 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 1961 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
1938 | } | 1962 | } |
1939 | 1963 | ||
1940 | void CalendarView::edit_copy() | 1964 | void CalendarView::edit_copy() |
1941 | { | 1965 | { |
1942 | Event *anEvent=0; | 1966 | Event *anEvent=0; |
1943 | 1967 | ||
1944 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1968 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1945 | 1969 | ||
1946 | if (mViewManager->currentView()->isEventView()) { | 1970 | if (mViewManager->currentView()->isEventView()) { |
1947 | if ( incidence && incidence->type() == "Event" ) { | 1971 | if ( incidence && incidence->type() == "Event" ) { |
1948 | anEvent = static_cast<Event *>(incidence); | 1972 | anEvent = static_cast<Event *>(incidence); |
1949 | } | 1973 | } |
1950 | } | 1974 | } |
1951 | 1975 | ||
1952 | if (!anEvent) { | 1976 | if (!anEvent) { |
1953 | KNotifyClient::beep(); | 1977 | KNotifyClient::beep(); |
1954 | return; | 1978 | return; |
1955 | } | 1979 | } |
1956 | DndFactory factory( mCalendar ); | 1980 | DndFactory factory( mCalendar ); |
1957 | factory.copyEvent(anEvent); | 1981 | factory.copyEvent(anEvent); |
1958 | } | 1982 | } |
1959 | 1983 | ||
1960 | void CalendarView::edit_paste() | 1984 | void CalendarView::edit_paste() |
1961 | { | 1985 | { |
1962 | QDate date = mNavigator->selectedDates().first(); | 1986 | QDate date = mNavigator->selectedDates().first(); |
1963 | 1987 | ||
1964 | DndFactory factory( mCalendar ); | 1988 | DndFactory factory( mCalendar ); |
1965 | Event *pastedEvent = factory.pasteEvent( date ); | 1989 | Event *pastedEvent = factory.pasteEvent( date ); |
1966 | 1990 | ||
1967 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 1991 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
1968 | } | 1992 | } |
1969 | 1993 | ||
1970 | void CalendarView::edit_options() | 1994 | void CalendarView::edit_options() |
1971 | { | 1995 | { |
1972 | mDialogManager->showOptionsDialog(); | 1996 | mDialogManager->showOptionsDialog(); |
1973 | //writeSettings(); | 1997 | //writeSettings(); |
1974 | } | 1998 | } |
1975 | void CalendarView::edit_sync_options() | 1999 | void CalendarView::edit_sync_options() |
1976 | { | 2000 | { |
1977 | //mDialogManager->showSyncOptions(); | 2001 | //mDialogManager->showSyncOptions(); |
1978 | //KOPrefs::instance()->mSyncAlgoPrefs | 2002 | //KOPrefs::instance()->mSyncAlgoPrefs |
1979 | QDialog dia( this, "dia", true ); | 2003 | QDialog dia( this, "dia", true ); |
1980 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 2004 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
1981 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 2005 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
1982 | QVBoxLayout lay ( &dia ); | 2006 | QVBoxLayout lay ( &dia ); |
1983 | lay.setSpacing( 2 ); | 2007 | lay.setSpacing( 2 ); |
1984 | lay.setMargin( 3 ); | 2008 | lay.setMargin( 3 ); |
1985 | lay.addWidget(&gr); | 2009 | lay.addWidget(&gr); |
1986 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 2010 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
1987 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 2011 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
1988 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 2012 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
1989 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 2013 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
1990 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 2014 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
1991 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 2015 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
1992 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 2016 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
1993 | QPushButton pb ( "OK", &dia); | 2017 | QPushButton pb ( "OK", &dia); |
1994 | lay.addWidget( &pb ); | 2018 | lay.addWidget( &pb ); |
1995 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 2019 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1996 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 2020 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
1997 | case 0: | 2021 | case 0: |
1998 | loc.setChecked( true); | 2022 | loc.setChecked( true); |
1999 | break; | 2023 | break; |
2000 | case 1: | 2024 | case 1: |
2001 | rem.setChecked( true ); | 2025 | rem.setChecked( true ); |
2002 | break; | 2026 | break; |
2003 | case 2: | 2027 | case 2: |
2004 | newest.setChecked( true); | 2028 | newest.setChecked( true); |
2005 | break; | 2029 | break; |
2006 | case 3: | 2030 | case 3: |
2007 | ask.setChecked( true); | 2031 | ask.setChecked( true); |
2008 | break; | 2032 | break; |
2009 | case 4: | 2033 | case 4: |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index b2838db..a3315ad 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,589 +1,590 @@ | |||
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 recheckTimerAlarm(); | 175 | void recheckTimerAlarm(); |
176 | void checkNextTimerAlarm(); | 176 | void checkNextTimerAlarm(); |
177 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 177 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
178 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 178 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
179 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 179 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
180 | 180 | ||
181 | /** options dialog made a changed to the configuration. we catch this | 181 | /** options dialog made a changed to the configuration. we catch this |
182 | * and notify all widgets which need to update their configuration. */ | 182 | * and notify all widgets which need to update their configuration. */ |
183 | void updateConfig(); | 183 | void updateConfig(); |
184 | 184 | ||
185 | /** | 185 | /** |
186 | Load calendar from file \a filename. If \a merge is true, load | 186 | Load calendar from file \a filename. If \a merge is true, load |
187 | calendar into existing one, if it is false, clear calendar, before | 187 | calendar into existing one, if it is false, clear calendar, before |
188 | loading. Return true, if calendar could be successfully loaded. | 188 | loading. Return true, if calendar could be successfully loaded. |
189 | */ | 189 | */ |
190 | bool openCalendar(QString filename, bool merge=false); | 190 | bool openCalendar(QString filename, bool merge=false); |
191 | bool syncCalendar(QString filename,int mode = 0 ); | 191 | bool syncCalendar(QString filename,int mode = 0 ); |
192 | 192 | ||
193 | /** | 193 | /** |
194 | Save calendar data to file. Return true if calendar could be | 194 | Save calendar data to file. Return true if calendar could be |
195 | successfully saved. | 195 | successfully saved. |
196 | */ | 196 | */ |
197 | bool saveCalendar(QString filename); | 197 | bool saveCalendar(QString filename); |
198 | 198 | ||
199 | /** | 199 | /** |
200 | Close calendar. Clear calendar data and reset views to display an empty | 200 | Close calendar. Clear calendar data and reset views to display an empty |
201 | calendar. | 201 | calendar. |
202 | */ | 202 | */ |
203 | void closeCalendar(); | 203 | void closeCalendar(); |
204 | 204 | ||
205 | /** Archive old events of calendar */ | 205 | /** Archive old events of calendar */ |
206 | void archiveCalendar(); | 206 | void archiveCalendar(); |
207 | 207 | ||
208 | void showIncidence(); | 208 | void showIncidence(); |
209 | void editIncidence(); | 209 | void editIncidence(); |
210 | void editIncidenceDescription(); | 210 | void editIncidenceDescription(); |
211 | void deleteIncidence(); | 211 | void deleteIncidence(); |
212 | 212 | ||
213 | /** create an editeventwin with supplied date/time, and if bool is true, | 213 | /** create an editeventwin with supplied date/time, and if bool is true, |
214 | * make the event take all day. */ | 214 | * make the event take all day. */ |
215 | void newEvent(QDateTime, QDateTime, bool allDay = false); | 215 | void newEvent(QDateTime, QDateTime, bool allDay = false); |
216 | void newEvent(QDateTime fh); | 216 | void newEvent(QDateTime fh); |
217 | void newEvent(QDate dt); | 217 | void newEvent(QDate dt); |
218 | /** create new event without having a date hint. Takes current date as | 218 | /** create new event without having a date hint. Takes current date as |
219 | default hint. */ | 219 | default hint. */ |
220 | void newEvent(); | 220 | void newEvent(); |
221 | void newFloatingEvent(); | 221 | void newFloatingEvent(); |
222 | 222 | ||
223 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 223 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
224 | void showIncidence(Incidence *); | 224 | void showIncidence(Incidence *); |
225 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 225 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
226 | void editIncidence(Incidence *); | 226 | void editIncidence(Incidence *); |
227 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 227 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
228 | void deleteIncidence(Incidence *); | 228 | void deleteIncidence(Incidence *); |
229 | void cloneIncidence(Incidence *); | 229 | void cloneIncidence(Incidence *); |
230 | void cancelIncidence(Incidence *); | 230 | void cancelIncidence(Incidence *); |
231 | /** Create an editor for the supplied event. */ | 231 | /** Create an editor for the supplied event. */ |
232 | void editEvent(Event *); | 232 | void editEvent(Event *); |
233 | /** Delete the supplied event. */ | 233 | /** Delete the supplied event. */ |
234 | void deleteEvent(Event *); | 234 | void deleteEvent(Event *); |
235 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 235 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
236 | found. */ | 236 | found. */ |
237 | bool deleteEvent(const QString &uid); | 237 | bool deleteEvent(const QString &uid); |
238 | /** Create a read-only viewer dialog for the supplied event. */ | 238 | /** Create a read-only viewer dialog for the supplied event. */ |
239 | void showEvent(Event *); | 239 | void showEvent(Event *); |
240 | 240 | ||
241 | void editJournal(Journal *); | 241 | void editJournal(Journal *); |
242 | void showJournal(Journal *); | 242 | void showJournal(Journal *); |
243 | void deleteJournal(Journal *); | 243 | void deleteJournal(Journal *); |
244 | /** Create an editor dialog for a todo */ | 244 | /** Create an editor dialog for a todo */ |
245 | void editTodo(Todo *); | 245 | void editTodo(Todo *); |
246 | /** Create a read-only viewer dialog for the supplied todo */ | 246 | /** Create a read-only viewer dialog for the supplied todo */ |
247 | void showTodo(Todo *); | 247 | void showTodo(Todo *); |
248 | /** create new todo */ | 248 | /** create new todo */ |
249 | void newTodo(); | 249 | void newTodo(); |
250 | /** create new todo with a parent todo */ | 250 | /** create new todo with a parent todo */ |
251 | void newSubTodo(); | 251 | void newSubTodo(); |
252 | /** create new todo with a parent todo */ | 252 | /** create new todo with a parent todo */ |
253 | void newSubTodo(Todo *); | 253 | void newSubTodo(Todo *); |
254 | /** Delete todo */ | 254 | /** Delete todo */ |
255 | void deleteTodo(Todo *); | 255 | void deleteTodo(Todo *); |
256 | 256 | ||
257 | 257 | ||
258 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 258 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
259 | * emitted as result. */ | 259 | * emitted as result. */ |
260 | void checkClipboard(); | 260 | void checkClipboard(); |
261 | 261 | ||
262 | /** using the KConfig associated with the kapp variable, read in the | 262 | /** using the KConfig associated with the kapp variable, read in the |
263 | * settings from the config file. | 263 | * settings from the config file. |
264 | */ | 264 | */ |
265 | void readSettings(); | 265 | void readSettings(); |
266 | 266 | ||
267 | /** write current state to config file. */ | 267 | /** write current state to config file. */ |
268 | void writeSettings(); | 268 | void writeSettings(); |
269 | 269 | ||
270 | /** read settings for calendar filters */ | 270 | /** read settings for calendar filters */ |
271 | void readFilterSettings(KConfig *config); | 271 | void readFilterSettings(KConfig *config); |
272 | 272 | ||
273 | /** write settings for calendar filters */ | 273 | /** write settings for calendar filters */ |
274 | void writeFilterSettings(KConfig *config); | 274 | void writeFilterSettings(KConfig *config); |
275 | 275 | ||
276 | /** passes on the message that an event has changed to the currently | 276 | /** passes on the message that an event has changed to the currently |
277 | * activated view so that it can make appropriate display changes. */ | 277 | * activated view so that it can make appropriate display changes. */ |
278 | void changeEventDisplay(Event *, int); | 278 | void changeEventDisplay(Event *, int); |
279 | void changeIncidenceDisplay(Incidence *, int); | 279 | void changeIncidenceDisplay(Incidence *, int); |
280 | void changeTodoDisplay(Todo *, int); | 280 | void changeTodoDisplay(Todo *, int); |
281 | 281 | ||
282 | void eventAdded(Event *); | 282 | void eventAdded(Event *); |
283 | void eventChanged(Event *); | 283 | void eventChanged(Event *); |
284 | void eventToBeDeleted(Event *); | 284 | void eventToBeDeleted(Event *); |
285 | void eventDeleted(); | 285 | void eventDeleted(); |
286 | 286 | ||
287 | void todoAdded(Todo *); | 287 | void todoAdded(Todo *); |
288 | void todoChanged(Todo *); | 288 | void todoChanged(Todo *); |
289 | void todoToBeDeleted(Todo *); | 289 | void todoToBeDeleted(Todo *); |
290 | void todoDeleted(); | 290 | void todoDeleted(); |
291 | 291 | ||
292 | void updateView(const QDate &start, const QDate &end); | 292 | void updateView(const QDate &start, const QDate &end); |
293 | void updateView(); | 293 | void updateView(); |
294 | 294 | ||
295 | /** Full update of visible todo views */ | 295 | /** Full update of visible todo views */ |
296 | void updateTodoViews(); | 296 | void updateTodoViews(); |
297 | 297 | ||
298 | void updateUnmanagedViews(); | 298 | void updateUnmanagedViews(); |
299 | 299 | ||
300 | /** cut the current appointment to the clipboard */ | 300 | /** cut the current appointment to the clipboard */ |
301 | void edit_cut(); | 301 | void edit_cut(); |
302 | 302 | ||
303 | /** copy the current appointment(s) to the clipboard */ | 303 | /** copy the current appointment(s) to the clipboard */ |
304 | void edit_copy(); | 304 | void edit_copy(); |
305 | 305 | ||
306 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 306 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
307 | void edit_paste(); | 307 | void edit_paste(); |
308 | 308 | ||
309 | /** edit viewing and configuration options. */ | 309 | /** edit viewing and configuration options. */ |
310 | void edit_options(); | 310 | void edit_options(); |
311 | void edit_sync_options(); | 311 | void edit_sync_options(); |
312 | /** | 312 | /** |
313 | Functions for printing, previewing a print, and setting up printing | 313 | Functions for printing, previewing a print, and setting up printing |
314 | parameters. | 314 | parameters. |
315 | */ | 315 | */ |
316 | void print(); | 316 | void print(); |
317 | void printSetup(); | 317 | void printSetup(); |
318 | void printPreview(); | 318 | void printPreview(); |
319 | 319 | ||
320 | /** Export as iCalendar file */ | 320 | /** Export as iCalendar file */ |
321 | void exportICalendar(); | 321 | void exportICalendar(); |
322 | 322 | ||
323 | /** Export as vCalendar file */ | 323 | /** Export as vCalendar file */ |
324 | bool exportVCalendar( QString fn); | 324 | bool exportVCalendar( QString fn); |
325 | 325 | ||
326 | /** pop up a dialog to show an existing appointment. */ | 326 | /** pop up a dialog to show an existing appointment. */ |
327 | void appointment_show(); | 327 | void appointment_show(); |
328 | /** | 328 | /** |
329 | * pop up an Appointment Dialog to edit an existing appointment.Get | 329 | * pop up an Appointment Dialog to edit an existing appointment.Get |
330 | * information on the appointment from the list of unique IDs that is | 330 | * information on the appointment from the list of unique IDs that is |
331 | * currently in the View, called currIds. | 331 | * currently in the View, called currIds. |
332 | */ | 332 | */ |
333 | void appointment_edit(); | 333 | void appointment_edit(); |
334 | /** | 334 | /** |
335 | * pop up dialog confirming deletion of currently selected event in the | 335 | * pop up dialog confirming deletion of currently selected event in the |
336 | * View. | 336 | * View. |
337 | */ | 337 | */ |
338 | void appointment_delete(); | 338 | void appointment_delete(); |
339 | 339 | ||
340 | /** mails the currently selected event to a particular user as a vCalendar | 340 | /** mails the currently selected event to a particular user as a vCalendar |
341 | attachment. */ | 341 | attachment. */ |
342 | void action_mail(); | 342 | void action_mail(); |
343 | 343 | ||
344 | /* frees a subtodo from it's relation */ | 344 | /* frees a subtodo from it's relation */ |
345 | void todo_unsub( Todo * ); | 345 | void todo_unsub( Todo * ); |
346 | 346 | ||
347 | /** Take ownership of selected event. */ | 347 | /** Take ownership of selected event. */ |
348 | void takeOverEvent(); | 348 | void takeOverEvent(); |
349 | 349 | ||
350 | /** Take ownership of all events in calendar. */ | 350 | /** Take ownership of all events in calendar. */ |
351 | void takeOverCalendar(); | 351 | void takeOverCalendar(); |
352 | 352 | ||
353 | /** query whether or not the calendar is "dirty". */ | 353 | /** query whether or not the calendar is "dirty". */ |
354 | bool isModified(); | 354 | bool isModified(); |
355 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 355 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
356 | void setModified(bool modified=true); | 356 | void setModified(bool modified=true); |
357 | 357 | ||
358 | /** query if the calendar is read-only. */ | 358 | /** query if the calendar is read-only. */ |
359 | bool isReadOnly(); | 359 | bool isReadOnly(); |
360 | /** set state of calendar to read-only */ | 360 | /** set state of calendar to read-only */ |
361 | void setReadOnly(bool readOnly=true); | 361 | void setReadOnly(bool readOnly=true); |
362 | 362 | ||
363 | void eventUpdated(Incidence *); | 363 | void eventUpdated(Incidence *); |
364 | 364 | ||
365 | /* iTIP scheduling actions */ | 365 | /* iTIP scheduling actions */ |
366 | void schedule_publish(Incidence *incidence = 0); | 366 | void schedule_publish(Incidence *incidence = 0); |
367 | void schedule_request(Incidence *incidence = 0); | 367 | void schedule_request(Incidence *incidence = 0); |
368 | void schedule_refresh(Incidence *incidence = 0); | 368 | void schedule_refresh(Incidence *incidence = 0); |
369 | void schedule_cancel(Incidence *incidence = 0); | 369 | void schedule_cancel(Incidence *incidence = 0); |
370 | void schedule_add(Incidence *incidence = 0); | 370 | void schedule_add(Incidence *incidence = 0); |
371 | void schedule_reply(Incidence *incidence = 0); | 371 | void schedule_reply(Incidence *incidence = 0); |
372 | void schedule_counter(Incidence *incidence = 0); | 372 | void schedule_counter(Incidence *incidence = 0); |
373 | void schedule_declinecounter(Incidence *incidence = 0); | 373 | void schedule_declinecounter(Incidence *incidence = 0); |
374 | void schedule_publish_freebusy(int daysToPublish = 30); | 374 | void schedule_publish_freebusy(int daysToPublish = 30); |
375 | 375 | ||
376 | void openAddressbook(); | 376 | void openAddressbook(); |
377 | 377 | ||
378 | void editFilters(); | 378 | void editFilters(); |
379 | void toggleFilerEnabled(); | 379 | void toggleFilerEnabled(); |
380 | QPtrList<CalFilter> filters(); | 380 | QPtrList<CalFilter> filters(); |
381 | void toggleFilter(); | 381 | void toggleFilter(); |
382 | void showFilter(bool visible); | 382 | void showFilter(bool visible); |
383 | void updateFilter(); | 383 | void updateFilter(); |
384 | void filterEdited(); | 384 | void filterEdited(); |
385 | void selectFilter( int ); | 385 | void selectFilter( int ); |
386 | KOFilterView *filterView(); | 386 | KOFilterView *filterView(); |
387 | 387 | ||
388 | void showIntro(); | 388 | void showIntro(); |
389 | 389 | ||
390 | /** Move the curdatepient view date to today */ | 390 | /** Move the curdatepient view date to today */ |
391 | void goToday(); | 391 | void goToday(); |
392 | 392 | ||
393 | /** Move to the next date(s) in the current view */ | 393 | /** Move to the next date(s) in the current view */ |
394 | void goNext(); | 394 | void goNext(); |
395 | 395 | ||
396 | /** Move to the previous date(s) in the current view */ | 396 | /** Move to the previous date(s) in the current view */ |
397 | void goPrevious(); | 397 | void goPrevious(); |
398 | /** Move to the next date(s) in the current view */ | 398 | /** Move to the next date(s) in the current view */ |
399 | void goNextMonth(); | 399 | void goNextMonth(); |
400 | 400 | ||
401 | /** Move to the previous date(s) in the current view */ | 401 | /** Move to the previous date(s) in the current view */ |
402 | void goPreviousMonth(); | 402 | void goPreviousMonth(); |
403 | 403 | ||
404 | void toggleExpand(); | 404 | void toggleExpand(); |
405 | void toggleDateNavigatorWidget(); | 405 | void toggleDateNavigatorWidget(); |
406 | void toggleAllDaySize(); | 406 | void toggleAllDaySize(); |
407 | void dialogClosing(Incidence *); | 407 | void dialogClosing(Incidence *); |
408 | 408 | ||
409 | /** Look for new messages in the inbox */ | 409 | /** Look for new messages in the inbox */ |
410 | void lookForIncomingMessages(); | 410 | void lookForIncomingMessages(); |
411 | /** Look for new messages in the outbox */ | 411 | /** Look for new messages in the outbox */ |
412 | void lookForOutgoingMessages(); | 412 | void lookForOutgoingMessages(); |
413 | 413 | ||
414 | void processMainViewSelection( Incidence * ); | 414 | void processMainViewSelection( Incidence * ); |
415 | void processTodoListSelection( Incidence * ); | 415 | void processTodoListSelection( Incidence * ); |
416 | 416 | ||
417 | void processIncidenceSelection( Incidence * ); | 417 | void processIncidenceSelection( Incidence * ); |
418 | 418 | ||
419 | void purgeCompleted(); | 419 | void purgeCompleted(); |
420 | bool removeCompletedSubTodos( Todo* ); | 420 | bool removeCompletedSubTodos( Todo* ); |
421 | void slotCalendarChanged(); | 421 | void slotCalendarChanged(); |
422 | bool importBday(); | 422 | bool importBday(); |
423 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 423 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
424 | bool importQtopia( const QString &categoriesFile, | 424 | bool importQtopia( const QString &categoriesFile, |
425 | const QString &datebookFile, | 425 | const QString &datebookFile, |
426 | const QString &tasklistFile ); | 426 | const QString &tasklistFile ); |
427 | void syncSharp( ); | 427 | void syncSharp( ); |
428 | void syncPhone( ); | 428 | void syncPhone( ); |
429 | void syncExternal( int mode ); | ||
429 | void slotSelectPickerDate( QDate ) ; | 430 | void slotSelectPickerDate( QDate ) ; |
430 | void showDatePicker( ) ; | 431 | void showDatePicker( ) ; |
431 | void moveIncidence(Incidence *) ; | 432 | void moveIncidence(Incidence *) ; |
432 | void beamIncidence(Incidence *) ; | 433 | void beamIncidence(Incidence *) ; |
433 | void beamCalendar() ; | 434 | void beamCalendar() ; |
434 | void beamFilteredCalendar() ; | 435 | void beamFilteredCalendar() ; |
435 | void beamIncidenceList(QPtrList<Incidence>) ; | 436 | void beamIncidenceList(QPtrList<Incidence>) ; |
436 | void manageCategories(); | 437 | void manageCategories(); |
437 | int addCategories(); | 438 | int addCategories(); |
438 | void removeCategories(); | 439 | void removeCategories(); |
439 | void setSyncDevice( QString ); | 440 | void setSyncDevice( QString ); |
440 | void setSyncName( QString ); | 441 | void setSyncName( QString ); |
441 | protected slots: | 442 | protected slots: |
442 | void timerAlarm(); | 443 | void timerAlarm(); |
443 | void suspendAlarm(); | 444 | void suspendAlarm(); |
444 | void beamDone( Ir *ir ); | 445 | void beamDone( Ir *ir ); |
445 | /** Select a view or adapt the current view to display the specified dates. */ | 446 | /** Select a view or adapt the current view to display the specified dates. */ |
446 | void showDates( const KCal::DateList & ); | 447 | void showDates( const KCal::DateList & ); |
447 | void selectWeekNum ( int ); | 448 | void selectWeekNum ( int ); |
448 | 449 | ||
449 | public: | 450 | public: |
450 | // show a standard warning | 451 | // show a standard warning |
451 | // returns KMsgBox::yesNoCancel() | 452 | // returns KMsgBox::yesNoCancel() |
452 | int msgCalModified(); | 453 | int msgCalModified(); |
453 | void confSync(); | 454 | void confSync(); |
454 | void setLoadedFileVersion(QDateTime); | 455 | void setLoadedFileVersion(QDateTime); |
455 | bool checkFileVersion(QString fn); | 456 | bool checkFileVersion(QString fn); |
456 | bool checkFileChanged(QString fn); | 457 | bool checkFileChanged(QString fn); |
457 | Event* getLastSyncEvent(); | 458 | Event* getLastSyncEvent(); |
458 | /** Adapt navigation units correpsonding to step size of navigation of the | 459 | /** Adapt navigation units correpsonding to step size of navigation of the |
459 | * current view. | 460 | * current view. |
460 | */ | 461 | */ |
461 | void adaptNavigationUnits(); | 462 | void adaptNavigationUnits(); |
462 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 463 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
463 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 464 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
464 | //Attendee* getYourAttendee(Event *event); | 465 | //Attendee* getYourAttendee(Event *event); |
465 | protected: | 466 | protected: |
466 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 467 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
467 | 468 | ||
468 | // returns KMsgBox::OKCandel() | 469 | // returns KMsgBox::OKCandel() |
469 | int msgItemDelete(); | 470 | int msgItemDelete(); |
470 | void showEventEditor(); | 471 | void showEventEditor(); |
471 | void showTodoEditor(); | 472 | void showTodoEditor(); |
472 | void writeLocale(); | 473 | void writeLocale(); |
473 | Todo *selectedTodo(); | 474 | Todo *selectedTodo(); |
474 | 475 | ||
475 | private: | 476 | private: |
476 | AlarmDialog * mAlarmDialog; | 477 | AlarmDialog * mAlarmDialog; |
477 | QString mAlarmNotification; | 478 | QString mAlarmNotification; |
478 | QString mSuspendAlarmNotification; | 479 | QString mSuspendAlarmNotification; |
479 | QTimer* mSuspendTimer; | 480 | QTimer* mSuspendTimer; |
480 | QTimer* mAlarmTimer; | 481 | QTimer* mAlarmTimer; |
481 | QTimer* mRecheckAlarmTimer; | 482 | QTimer* mRecheckAlarmTimer; |
482 | void computeAlarm( QString ); | 483 | void computeAlarm( QString ); |
483 | void startAlarm( QString, QString ); | 484 | void startAlarm( QString, QString ); |
484 | void setSyncEventsReadOnly(); | 485 | void setSyncEventsReadOnly(); |
485 | 486 | ||
486 | QDateTime loadedFileVersion; | 487 | QDateTime loadedFileVersion; |
487 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 488 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
488 | void checkExternalId( Incidence * inc ); | 489 | void checkExternalId( Incidence * inc ); |
489 | int mGlobalSyncMode; | 490 | int mGlobalSyncMode; |
490 | QString mCurrentSyncDevice; | 491 | QString mCurrentSyncDevice; |
491 | QString mCurrentSyncName; | 492 | QString mCurrentSyncName; |
492 | KOBeamPrefs* beamDialog; | 493 | KOBeamPrefs* beamDialog; |
493 | void init(); | 494 | void init(); |
494 | int mDatePickerMode; | 495 | int mDatePickerMode; |
495 | bool mFlagEditDescription; | 496 | bool mFlagEditDescription; |
496 | QDateTime mLastCalendarSync; | 497 | QDateTime mLastCalendarSync; |
497 | void createPrinter(); | 498 | void createPrinter(); |
498 | 499 | ||
499 | void calendarModified( bool, Calendar * ); | 500 | void calendarModified( bool, Calendar * ); |
500 | 501 | ||
501 | CalPrinter *mCalPrinter; | 502 | CalPrinter *mCalPrinter; |
502 | 503 | ||
503 | QSplitter *mPanner; | 504 | QSplitter *mPanner; |
504 | QSplitter *mLeftSplitter; | 505 | QSplitter *mLeftSplitter; |
505 | QWidget *mLeftFrame; | 506 | QWidget *mLeftFrame; |
506 | QWidgetStack *mRightFrame; | 507 | QWidgetStack *mRightFrame; |
507 | 508 | ||
508 | KDatePicker* mDatePicker; | 509 | KDatePicker* mDatePicker; |
509 | QVBox* mDateFrame; | 510 | QVBox* mDateFrame; |
510 | NavigatorBar *mNavigatorBar; | 511 | NavigatorBar *mNavigatorBar; |
511 | 512 | ||
512 | KDateNavigator *mDateNavigator; // widget showing small month view. | 513 | KDateNavigator *mDateNavigator; // widget showing small month view. |
513 | 514 | ||
514 | KOFilterView *mFilterView; | 515 | KOFilterView *mFilterView; |
515 | 516 | ||
516 | ResourceView *mResourceView; | 517 | ResourceView *mResourceView; |
517 | 518 | ||
518 | // calendar object for this viewing instance | 519 | // calendar object for this viewing instance |
519 | Calendar *mCalendar; | 520 | Calendar *mCalendar; |
520 | 521 | ||
521 | CalendarResourceManager *mResourceManager; | 522 | CalendarResourceManager *mResourceManager; |
522 | 523 | ||
523 | FileStorage *mStorage; | 524 | FileStorage *mStorage; |
524 | 525 | ||
525 | DateNavigator *mNavigator; | 526 | DateNavigator *mNavigator; |
526 | 527 | ||
527 | KOViewManager *mViewManager; | 528 | KOViewManager *mViewManager; |
528 | KODialogManager *mDialogManager; | 529 | KODialogManager *mDialogManager; |
529 | 530 | ||
530 | // Calendar filters | 531 | // Calendar filters |
531 | QPtrList<CalFilter> mFilters; | 532 | QPtrList<CalFilter> mFilters; |
532 | 533 | ||
533 | // various housekeeping variables. | 534 | // various housekeeping variables. |
534 | bool mModified; // flag indicating if calendar is modified | 535 | bool mModified; // flag indicating if calendar is modified |
535 | bool mReadOnly; // flag indicating if calendar is read-only | 536 | bool mReadOnly; // flag indicating if calendar is read-only |
536 | QDate mSaveSingleDate; | 537 | QDate mSaveSingleDate; |
537 | 538 | ||
538 | Incidence *mSelectedIncidence; | 539 | Incidence *mSelectedIncidence; |
539 | Incidence *mMoveIncidence; | 540 | Incidence *mMoveIncidence; |
540 | QPtrList<Event> mExternLastSyncEvent; | 541 | QPtrList<Event> mExternLastSyncEvent; |
541 | KOTodoView *mTodoList; | 542 | KOTodoView *mTodoList; |
542 | KOEventEditor * mEventEditor; | 543 | KOEventEditor * mEventEditor; |
543 | KOTodoEditor * mTodoEditor; | 544 | KOTodoEditor * mTodoEditor; |
544 | KOEventViewerDialog * mEventViewerDialog; | 545 | KOEventViewerDialog * mEventViewerDialog; |
545 | void keyPressEvent ( QKeyEvent *e) ; | 546 | void keyPressEvent ( QKeyEvent *e) ; |
546 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 547 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
547 | }; | 548 | }; |
548 | 549 | ||
549 | 550 | ||
550 | class CalendarViewVisitor : public Incidence::Visitor | 551 | class CalendarViewVisitor : public Incidence::Visitor |
551 | { | 552 | { |
552 | public: | 553 | public: |
553 | CalendarViewVisitor() : mView( 0 ) {} | 554 | CalendarViewVisitor() : mView( 0 ) {} |
554 | 555 | ||
555 | bool act( Incidence *incidence, CalendarView *view ) | 556 | bool act( Incidence *incidence, CalendarView *view ) |
556 | { | 557 | { |
557 | mView = view; | 558 | mView = view; |
558 | return incidence->accept( *this ); | 559 | return incidence->accept( *this ); |
559 | } | 560 | } |
560 | 561 | ||
561 | protected: | 562 | protected: |
562 | CalendarView *mView; | 563 | CalendarView *mView; |
563 | }; | 564 | }; |
564 | 565 | ||
565 | class ShowIncidenceVisitor : public CalendarViewVisitor | 566 | class ShowIncidenceVisitor : public CalendarViewVisitor |
566 | { | 567 | { |
567 | protected: | 568 | protected: |
568 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 569 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
569 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 570 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
570 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 571 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
571 | }; | 572 | }; |
572 | 573 | ||
573 | class EditIncidenceVisitor : public CalendarViewVisitor | 574 | class EditIncidenceVisitor : public CalendarViewVisitor |
574 | { | 575 | { |
575 | protected: | 576 | protected: |
576 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 577 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
577 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 578 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
578 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 579 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
579 | }; | 580 | }; |
580 | 581 | ||
581 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 582 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
582 | { | 583 | { |
583 | protected: | 584 | protected: |
584 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 585 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
585 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 586 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
586 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 587 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
587 | }; | 588 | }; |
588 | 589 | ||
589 | #endif | 590 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 062c95f..cce182a 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -235,1537 +235,1543 @@ void MainWindow::closeEvent( QCloseEvent* ce ) | |||
235 | case 2: | 235 | case 2: |
236 | 236 | ||
237 | default: | 237 | default: |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | } | 242 | } |
243 | 243 | ||
244 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) | 244 | void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) |
245 | { | 245 | { |
246 | QDataStream stream( data, IO_ReadOnly ); | 246 | QDataStream stream( data, IO_ReadOnly ); |
247 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); | 247 | // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); |
248 | //QString datamess; | 248 | //QString datamess; |
249 | //qDebug("message "); | 249 | //qDebug("message "); |
250 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); | 250 | qDebug("KO: QCOP message received: %s ", cmsg.data() ); |
251 | if ( cmsg == "-writeFile" ) { | 251 | if ( cmsg == "-writeFile" ) { |
252 | // I made from the "-writeFile" an "-writeAlarm" | 252 | // I made from the "-writeFile" an "-writeAlarm" |
253 | mView->viewManager()->showWhatsNextView(); | 253 | mView->viewManager()->showWhatsNextView(); |
254 | mCalendar->checkAlarmForIncidence( 0, true); | 254 | mCalendar->checkAlarmForIncidence( 0, true); |
255 | showMaximized(); | 255 | showMaximized(); |
256 | raise(); | 256 | raise(); |
257 | return; | 257 | return; |
258 | 258 | ||
259 | } | 259 | } |
260 | if ( cmsg == "-writeFileSilent" ) { | 260 | if ( cmsg == "-writeFileSilent" ) { |
261 | // I made from the "-writeFile" an "-writeAlarm" | 261 | // I made from the "-writeFile" an "-writeAlarm" |
262 | // mView->viewManager()->showWhatsNextView(); | 262 | // mView->viewManager()->showWhatsNextView(); |
263 | mCalendar->checkAlarmForIncidence( 0, true); | 263 | mCalendar->checkAlarmForIncidence( 0, true); |
264 | //showMaximized(); | 264 | //showMaximized(); |
265 | //raise(); | 265 | //raise(); |
266 | hide(); | 266 | hide(); |
267 | return; | 267 | return; |
268 | } | 268 | } |
269 | if ( cmsg == "-newCountdown" ) { | 269 | if ( cmsg == "-newCountdown" ) { |
270 | qDebug("newCountdown "); | 270 | qDebug("newCountdown "); |
271 | 271 | ||
272 | } | 272 | } |
273 | QString msg ; | 273 | QString msg ; |
274 | QString allmsg = cmsg; | 274 | QString allmsg = cmsg; |
275 | while ( allmsg.length() > 0 ) { | 275 | while ( allmsg.length() > 0 ) { |
276 | int nextC = allmsg.find( "-", 1 ); | 276 | int nextC = allmsg.find( "-", 1 ); |
277 | if ( nextC == -1 ) { | 277 | if ( nextC == -1 ) { |
278 | msg = allmsg; | 278 | msg = allmsg; |
279 | allmsg = ""; | 279 | allmsg = ""; |
280 | } else{ | 280 | } else{ |
281 | msg = allmsg.left( nextC ); | 281 | msg = allmsg.left( nextC ); |
282 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); | 282 | allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); |
283 | } | 283 | } |
284 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); | 284 | //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); |
285 | if ( msg == "-newEvent" ) { | 285 | if ( msg == "-newEvent" ) { |
286 | mView->newEvent(); | 286 | mView->newEvent(); |
287 | } | 287 | } |
288 | if ( msg == "-newTodo" ) { | 288 | if ( msg == "-newTodo" ) { |
289 | mView->newTodo(); | 289 | mView->newTodo(); |
290 | 290 | ||
291 | } | 291 | } |
292 | if ( msg == "-showWN" ) { | 292 | if ( msg == "-showWN" ) { |
293 | mView->viewManager()->showWhatsNextView(); | 293 | mView->viewManager()->showWhatsNextView(); |
294 | } | 294 | } |
295 | if ( msg == "-showTodo" ) { | 295 | if ( msg == "-showTodo" ) { |
296 | mView->viewManager()->showTodoView(); | 296 | mView->viewManager()->showTodoView(); |
297 | } | 297 | } |
298 | if ( msg == "-showList" ) { | 298 | if ( msg == "-showList" ) { |
299 | mView->viewManager()->showListView(); | 299 | mView->viewManager()->showListView(); |
300 | } | 300 | } |
301 | else if ( msg == "-showDay" ) { | 301 | else if ( msg == "-showDay" ) { |
302 | mView->viewManager()->showDayView(); | 302 | mView->viewManager()->showDayView(); |
303 | } | 303 | } |
304 | else if ( msg == "-showWWeek" ) { | 304 | else if ( msg == "-showWWeek" ) { |
305 | mView->viewManager()->showWorkWeekView(); | 305 | mView->viewManager()->showWorkWeekView(); |
306 | } | 306 | } |
307 | else if ( msg == "-ringSync" ) { | 307 | else if ( msg == "-ringSync" ) { |
308 | multiSync( false ); | 308 | multiSync( false ); |
309 | } | 309 | } |
310 | else if ( msg == "-showWeek" ) { | 310 | else if ( msg == "-showWeek" ) { |
311 | mView->viewManager()->showWeekView(); | 311 | mView->viewManager()->showWeekView(); |
312 | } | 312 | } |
313 | else if ( msg == "-showTodo" ) { | 313 | else if ( msg == "-showTodo" ) { |
314 | mView->viewManager()->showTodoView(); | 314 | mView->viewManager()->showTodoView(); |
315 | } | 315 | } |
316 | else if ( msg == "-showJournal" ) { | 316 | else if ( msg == "-showJournal" ) { |
317 | mView->dateNavigator()->selectDates( 1 ); | 317 | mView->dateNavigator()->selectDates( 1 ); |
318 | mView->dateNavigator()->selectToday(); | 318 | mView->dateNavigator()->selectToday(); |
319 | mView->viewManager()->showJournalView(); | 319 | mView->viewManager()->showJournalView(); |
320 | } | 320 | } |
321 | else if ( msg == "-showKO" ) { | 321 | else if ( msg == "-showKO" ) { |
322 | mView->viewManager()->showNextXView(); | 322 | mView->viewManager()->showNextXView(); |
323 | } | 323 | } |
324 | else if ( msg == "-showWNext" || msg == "nextView()" ) { | 324 | else if ( msg == "-showWNext" || msg == "nextView()" ) { |
325 | mView->viewManager()->showWhatsNextView(); | 325 | mView->viewManager()->showWhatsNextView(); |
326 | } | 326 | } |
327 | else if ( msg == "-showNextXView" ) { | 327 | else if ( msg == "-showNextXView" ) { |
328 | mView->viewManager()->showNextXView(); | 328 | mView->viewManager()->showNextXView(); |
329 | } | 329 | } |
330 | 330 | ||
331 | 331 | ||
332 | } | 332 | } |
333 | 333 | ||
334 | showMaximized(); | 334 | showMaximized(); |
335 | raise(); | 335 | raise(); |
336 | } | 336 | } |
337 | 337 | ||
338 | QPixmap MainWindow::loadPixmap( QString name ) | 338 | QPixmap MainWindow::loadPixmap( QString name ) |
339 | { | 339 | { |
340 | return SmallIcon( name ); | 340 | return SmallIcon( name ); |
341 | 341 | ||
342 | } | 342 | } |
343 | void MainWindow::initActions() | 343 | void MainWindow::initActions() |
344 | { | 344 | { |
345 | //KOPrefs::instance()->mShowFullMenu | 345 | //KOPrefs::instance()->mShowFullMenu |
346 | iconToolBar->clear(); | 346 | iconToolBar->clear(); |
347 | KOPrefs *p = KOPrefs::instance(); | 347 | KOPrefs *p = KOPrefs::instance(); |
348 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); | 348 | //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); |
349 | 349 | ||
350 | QPopupMenu *viewMenu = new QPopupMenu( this ); | 350 | QPopupMenu *viewMenu = new QPopupMenu( this ); |
351 | QPopupMenu *actionMenu = new QPopupMenu( this ); | 351 | QPopupMenu *actionMenu = new QPopupMenu( this ); |
352 | QPopupMenu *importMenu = new QPopupMenu( this ); | 352 | QPopupMenu *importMenu = new QPopupMenu( this ); |
353 | selectFilterMenu = new QPopupMenu( this ); | 353 | selectFilterMenu = new QPopupMenu( this ); |
354 | selectFilterMenu->setCheckable( true ); | 354 | selectFilterMenu->setCheckable( true ); |
355 | syncMenu = new QPopupMenu( this ); | 355 | syncMenu = new QPopupMenu( this ); |
356 | configureAgendaMenu = new QPopupMenu( this ); | 356 | configureAgendaMenu = new QPopupMenu( this ); |
357 | configureToolBarMenu = new QPopupMenu( this ); | 357 | configureToolBarMenu = new QPopupMenu( this ); |
358 | QPopupMenu *helpMenu = new QPopupMenu( this ); | 358 | QPopupMenu *helpMenu = new QPopupMenu( this ); |
359 | if ( KOPrefs::instance()->mShowFullMenu ) { | 359 | if ( KOPrefs::instance()->mShowFullMenu ) { |
360 | QMenuBar *menuBar1; | 360 | QMenuBar *menuBar1; |
361 | menuBar1 = menuBar(); | 361 | menuBar1 = menuBar(); |
362 | menuBar1->insertItem( i18n("File"), importMenu ); | 362 | menuBar1->insertItem( i18n("File"), importMenu ); |
363 | menuBar1->insertItem( i18n("View"), viewMenu ); | 363 | menuBar1->insertItem( i18n("View"), viewMenu ); |
364 | menuBar1->insertItem( i18n("Actions"), actionMenu ); | 364 | menuBar1->insertItem( i18n("Actions"), actionMenu ); |
365 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); | 365 | menuBar1->insertItem( i18n("Synchronize"), syncMenu ); |
366 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 366 | menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
367 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 367 | //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
368 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); | 368 | menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); |
369 | menuBar1->insertItem( i18n("Help"), helpMenu ); | 369 | menuBar1->insertItem( i18n("Help"), helpMenu ); |
370 | } else { | 370 | } else { |
371 | QPEMenuBar *menuBar1; | 371 | QPEMenuBar *menuBar1; |
372 | menuBar1 = new QPEMenuBar( iconToolBar ); | 372 | menuBar1 = new QPEMenuBar( iconToolBar ); |
373 | QPopupMenu *menuBar = new QPopupMenu( this ); | 373 | QPopupMenu *menuBar = new QPopupMenu( this ); |
374 | menuBar1->insertItem( i18n("ME"), menuBar); | 374 | menuBar1->insertItem( i18n("ME"), menuBar); |
375 | menuBar->insertItem( i18n("File"), importMenu ); | 375 | menuBar->insertItem( i18n("File"), importMenu ); |
376 | menuBar->insertItem( i18n("View"), viewMenu ); | 376 | menuBar->insertItem( i18n("View"), viewMenu ); |
377 | menuBar->insertItem( i18n("Actions"), actionMenu ); | 377 | menuBar->insertItem( i18n("Actions"), actionMenu ); |
378 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); | 378 | menuBar->insertItem( i18n("Synchronize"), syncMenu ); |
379 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); | 379 | menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); |
380 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); | 380 | menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); |
381 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); | 381 | menuBar->insertItem( i18n("Filter"),selectFilterMenu ); |
382 | menuBar->insertItem( i18n("Help"), helpMenu ); | 382 | menuBar->insertItem( i18n("Help"), helpMenu ); |
383 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); | 383 | //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); |
384 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); | 384 | menuBar1->setMaximumSize( menuBar1->sizeHint( )); |
385 | } | 385 | } |
386 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); | 386 | connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); |
387 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); | 387 | connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); |
388 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); | 388 | connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); |
389 | 389 | ||
390 | // ****************** | 390 | // ****************** |
391 | QAction *action; | 391 | QAction *action; |
392 | QIconSet icon; | 392 | QIconSet icon; |
393 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); | 393 | // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); |
394 | configureToolBarMenu->setCheckable( true ); | 394 | configureToolBarMenu->setCheckable( true ); |
395 | 395 | ||
396 | QString pathString = ""; | 396 | QString pathString = ""; |
397 | if ( !p->mToolBarMiniIcons ) { | 397 | if ( !p->mToolBarMiniIcons ) { |
398 | if ( QApplication::desktop()->width() < 480 ) | 398 | if ( QApplication::desktop()->width() < 480 ) |
399 | pathString += "icons16/"; | 399 | pathString += "icons16/"; |
400 | } else | 400 | } else |
401 | pathString += "iconsmini/"; | 401 | pathString += "iconsmini/"; |
402 | configureAgendaMenu->setCheckable( true ); | 402 | configureAgendaMenu->setCheckable( true ); |
403 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); | 403 | configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); |
404 | configureAgendaMenu->insertSeparator(); | 404 | configureAgendaMenu->insertSeparator(); |
405 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); | 405 | configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); |
406 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); | 406 | configureAgendaMenu->insertItem(i18n("Small"), 6 ); |
407 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); | 407 | configureAgendaMenu->insertItem(i18n("Medium"), 8 ); |
408 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); | 408 | configureAgendaMenu->insertItem(i18n("Normal"), 10 ); |
409 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); | 409 | configureAgendaMenu->insertItem(i18n("Large"), 12 ); |
410 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); | 410 | configureAgendaMenu->insertItem(i18n("Big"), 14 ); |
411 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); | 411 | configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); |
412 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); | 412 | configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); |
413 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); | 413 | //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); |
414 | 414 | ||
415 | icon = loadPixmap( pathString + "configure" ); | 415 | icon = loadPixmap( pathString + "configure" ); |
416 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); | 416 | action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); |
417 | action->addTo( actionMenu ); | 417 | action->addTo( actionMenu ); |
418 | connect( action, SIGNAL( activated() ), | 418 | connect( action, SIGNAL( activated() ), |
419 | mView, SLOT( edit_options() ) ); | 419 | mView, SLOT( edit_options() ) ); |
420 | actionMenu->insertSeparator(); | 420 | actionMenu->insertSeparator(); |
421 | icon = loadPixmap( pathString + "newevent" ); | 421 | icon = loadPixmap( pathString + "newevent" ); |
422 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); | 422 | configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); |
423 | configureToolBarMenu->insertSeparator(); | 423 | configureToolBarMenu->insertSeparator(); |
424 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); | 424 | configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); |
425 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); | 425 | QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); |
426 | ne_action->addTo( actionMenu ); | 426 | ne_action->addTo( actionMenu ); |
427 | connect( ne_action, SIGNAL( activated() ), | 427 | connect( ne_action, SIGNAL( activated() ), |
428 | mView, SLOT( newEvent() ) ); | 428 | mView, SLOT( newEvent() ) ); |
429 | icon = loadPixmap( pathString + "newtodo" ); | 429 | icon = loadPixmap( pathString + "newtodo" ); |
430 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); | 430 | configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); |
431 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); | 431 | QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); |
432 | nt_action->addTo( actionMenu ); | 432 | nt_action->addTo( actionMenu ); |
433 | connect( nt_action, SIGNAL( activated() ), | 433 | connect( nt_action, SIGNAL( activated() ), |
434 | mView, SLOT( newTodo() ) ); | 434 | mView, SLOT( newTodo() ) ); |
435 | icon = loadPixmap( pathString + "navi" ); | 435 | icon = loadPixmap( pathString + "navi" ); |
436 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); | 436 | action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); |
437 | action->addTo( viewMenu ); | 437 | action->addTo( viewMenu ); |
438 | connect( action, SIGNAL( activated() ), | 438 | connect( action, SIGNAL( activated() ), |
439 | mView, SLOT( toggleDateNavigatorWidget() ) ); | 439 | mView, SLOT( toggleDateNavigatorWidget() ) ); |
440 | icon = loadPixmap( pathString + "filter" ); | 440 | icon = loadPixmap( pathString + "filter" ); |
441 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); | 441 | action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); |
442 | action->addTo( viewMenu ); | 442 | action->addTo( viewMenu ); |
443 | connect( action, SIGNAL( activated() ), | 443 | connect( action, SIGNAL( activated() ), |
444 | mView, SLOT( toggleFilter() ) ); | 444 | mView, SLOT( toggleFilter() ) ); |
445 | 445 | ||
446 | 446 | ||
447 | viewMenu->insertSeparator(); | 447 | viewMenu->insertSeparator(); |
448 | icon = loadPixmap( pathString + "picker" ); | 448 | icon = loadPixmap( pathString + "picker" ); |
449 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); | 449 | action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); |
450 | action->addTo( viewMenu ); | 450 | action->addTo( viewMenu ); |
451 | connect( action, SIGNAL( activated() ), | 451 | connect( action, SIGNAL( activated() ), |
452 | mView, SLOT( showDatePicker() ) ); | 452 | mView, SLOT( showDatePicker() ) ); |
453 | action->addTo( iconToolBar ); | 453 | action->addTo( iconToolBar ); |
454 | viewMenu->insertSeparator(); | 454 | viewMenu->insertSeparator(); |
455 | icon = loadPixmap( pathString + "list" ); | 455 | icon = loadPixmap( pathString + "list" ); |
456 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); | 456 | configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); |
457 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); | 457 | QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); |
458 | showlist_action->addTo( viewMenu ); | 458 | showlist_action->addTo( viewMenu ); |
459 | connect( showlist_action, SIGNAL( activated() ), | 459 | connect( showlist_action, SIGNAL( activated() ), |
460 | mView->viewManager(), SLOT( showListView() ) ); | 460 | mView->viewManager(), SLOT( showListView() ) ); |
461 | 461 | ||
462 | 462 | ||
463 | icon = loadPixmap( pathString + "day" ); | 463 | icon = loadPixmap( pathString + "day" ); |
464 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); | 464 | configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); |
465 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); | 465 | QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); |
466 | day1_action->addTo( viewMenu ); | 466 | day1_action->addTo( viewMenu ); |
467 | // action->addTo( toolBar ); | 467 | // action->addTo( toolBar ); |
468 | connect( day1_action, SIGNAL( activated() ), | 468 | connect( day1_action, SIGNAL( activated() ), |
469 | mView->viewManager(), SLOT( showDayView() ) ); | 469 | mView->viewManager(), SLOT( showDayView() ) ); |
470 | 470 | ||
471 | icon = loadPixmap( pathString + "workweek" ); | 471 | icon = loadPixmap( pathString + "workweek" ); |
472 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); | 472 | configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); |
473 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); | 473 | QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); |
474 | day5_action->addTo( viewMenu ); | 474 | day5_action->addTo( viewMenu ); |
475 | connect( day5_action, SIGNAL( activated() ), | 475 | connect( day5_action, SIGNAL( activated() ), |
476 | mView->viewManager(), SLOT( showWorkWeekView() ) ); | 476 | mView->viewManager(), SLOT( showWorkWeekView() ) ); |
477 | 477 | ||
478 | icon = loadPixmap( pathString + "week" ); | 478 | icon = loadPixmap( pathString + "week" ); |
479 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); | 479 | configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); |
480 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); | 480 | QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); |
481 | day7_action->addTo( viewMenu ); | 481 | day7_action->addTo( viewMenu ); |
482 | connect( day7_action, SIGNAL( activated() ), | 482 | connect( day7_action, SIGNAL( activated() ), |
483 | mView->viewManager(), SLOT( showWeekView() ) ); | 483 | mView->viewManager(), SLOT( showWeekView() ) ); |
484 | 484 | ||
485 | icon = loadPixmap( pathString + "month" ); | 485 | icon = loadPixmap( pathString + "month" ); |
486 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); | 486 | configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); |
487 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); | 487 | QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); |
488 | month_action->addTo( viewMenu ); | 488 | month_action->addTo( viewMenu ); |
489 | connect( month_action, SIGNAL( activated() ), | 489 | connect( month_action, SIGNAL( activated() ), |
490 | mView->viewManager(), SLOT( showMonthView() ) ); | 490 | mView->viewManager(), SLOT( showMonthView() ) ); |
491 | 491 | ||
492 | icon = loadPixmap( pathString + "todo" ); | 492 | icon = loadPixmap( pathString + "todo" ); |
493 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); | 493 | configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); |
494 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); | 494 | QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); |
495 | todoview_action->addTo( viewMenu ); | 495 | todoview_action->addTo( viewMenu ); |
496 | connect( todoview_action, SIGNAL( activated() ), | 496 | connect( todoview_action, SIGNAL( activated() ), |
497 | mView->viewManager(), SLOT( showTodoView() ) ); | 497 | mView->viewManager(), SLOT( showTodoView() ) ); |
498 | 498 | ||
499 | icon = loadPixmap( pathString + "journal" ); | 499 | icon = loadPixmap( pathString + "journal" ); |
500 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); | 500 | configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); |
501 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); | 501 | QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); |
502 | viewjournal_action->addTo( viewMenu ); | 502 | viewjournal_action->addTo( viewMenu ); |
503 | connect( viewjournal_action, SIGNAL( activated() ), | 503 | connect( viewjournal_action, SIGNAL( activated() ), |
504 | mView->viewManager(), SLOT( showJournalView() ) ); | 504 | mView->viewManager(), SLOT( showJournalView() ) ); |
505 | 505 | ||
506 | icon = loadPixmap( pathString + "xdays" ); | 506 | icon = loadPixmap( pathString + "xdays" ); |
507 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); | 507 | configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); |
508 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); | 508 | QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); |
509 | xdays_action->addTo( viewMenu ); | 509 | xdays_action->addTo( viewMenu ); |
510 | connect( xdays_action, SIGNAL( activated() ), | 510 | connect( xdays_action, SIGNAL( activated() ), |
511 | mView->viewManager(), SLOT( showNextXView() ) ); | 511 | mView->viewManager(), SLOT( showNextXView() ) ); |
512 | 512 | ||
513 | icon = loadPixmap( pathString + "whatsnext" ); | 513 | icon = loadPixmap( pathString + "whatsnext" ); |
514 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); | 514 | configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); |
515 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); | 515 | QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); |
516 | whatsnext_action->addTo( viewMenu ); | 516 | whatsnext_action->addTo( viewMenu ); |
517 | connect( whatsnext_action, SIGNAL( activated() ), | 517 | connect( whatsnext_action, SIGNAL( activated() ), |
518 | mView->viewManager(), SLOT( showWhatsNextView() ) ); | 518 | mView->viewManager(), SLOT( showWhatsNextView() ) ); |
519 | 519 | ||
520 | #if 0 | 520 | #if 0 |
521 | action = new QAction( "view_timespan", "Time Span", 0, this ); | 521 | action = new QAction( "view_timespan", "Time Span", 0, this ); |
522 | action->addTo( viewMenu ); | 522 | action->addTo( viewMenu ); |
523 | connect( action, SIGNAL( activated() ), | 523 | connect( action, SIGNAL( activated() ), |
524 | mView->viewManager(), SLOT( showTimeSpanView() ) ); | 524 | mView->viewManager(), SLOT( showTimeSpanView() ) ); |
525 | #endif | 525 | #endif |
526 | 526 | ||
527 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, | 527 | mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, |
528 | this ); | 528 | this ); |
529 | mNewSubTodoAction->addTo( actionMenu ); | 529 | mNewSubTodoAction->addTo( actionMenu ); |
530 | connect( mNewSubTodoAction, SIGNAL( activated() ), | 530 | connect( mNewSubTodoAction, SIGNAL( activated() ), |
531 | mView, SLOT( newSubTodo() ) ); | 531 | mView, SLOT( newSubTodo() ) ); |
532 | 532 | ||
533 | actionMenu->insertSeparator(); | 533 | actionMenu->insertSeparator(); |
534 | 534 | ||
535 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); | 535 | mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); |
536 | mShowAction->addTo( actionMenu ); | 536 | mShowAction->addTo( actionMenu ); |
537 | connect( mShowAction, SIGNAL( activated() ), | 537 | connect( mShowAction, SIGNAL( activated() ), |
538 | mView, SLOT( showIncidence() ) ); | 538 | mView, SLOT( showIncidence() ) ); |
539 | 539 | ||
540 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); | 540 | mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); |
541 | mEditAction->addTo( actionMenu ); | 541 | mEditAction->addTo( actionMenu ); |
542 | connect( mEditAction, SIGNAL( activated() ), | 542 | connect( mEditAction, SIGNAL( activated() ), |
543 | mView, SLOT( editIncidence() ) ); | 543 | mView, SLOT( editIncidence() ) ); |
544 | 544 | ||
545 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); | 545 | mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); |
546 | mDeleteAction->addTo( actionMenu ); | 546 | mDeleteAction->addTo( actionMenu ); |
547 | connect( mDeleteAction, SIGNAL( activated() ), | 547 | connect( mDeleteAction, SIGNAL( activated() ), |
548 | mView, SLOT( deleteIncidence() ) ); | 548 | mView, SLOT( deleteIncidence() ) ); |
549 | 549 | ||
550 | actionMenu->insertSeparator(); | 550 | actionMenu->insertSeparator(); |
551 | 551 | ||
552 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, | 552 | action = new QAction( "purge_completed", i18n("Purge Completed"), 0, |
553 | this ); | 553 | this ); |
554 | action->addTo( actionMenu ); | 554 | action->addTo( actionMenu ); |
555 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); | 555 | connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); |
556 | 556 | ||
557 | icon = loadPixmap( pathString + "search" ); | 557 | icon = loadPixmap( pathString + "search" ); |
558 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); | 558 | QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); |
559 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); | 559 | configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); |
560 | search_action->addTo( actionMenu ); | 560 | search_action->addTo( actionMenu ); |
561 | connect( search_action, SIGNAL( activated() ), | 561 | connect( search_action, SIGNAL( activated() ), |
562 | mView->dialogManager(), SLOT( showSearchDialog() ) ); | 562 | mView->dialogManager(), SLOT( showSearchDialog() ) ); |
563 | 563 | ||
564 | icon = loadPixmap( pathString + "today" ); | 564 | icon = loadPixmap( pathString + "today" ); |
565 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); | 565 | configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); |
566 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); | 566 | QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); |
567 | today_action->addTo( actionMenu ); | 567 | today_action->addTo( actionMenu ); |
568 | connect( today_action, SIGNAL( activated() ), | 568 | connect( today_action, SIGNAL( activated() ), |
569 | mView, SLOT( goToday() ) ); | 569 | mView, SLOT( goToday() ) ); |
570 | 570 | ||
571 | if ( KOPrefs::instance()->mShowFullMenu ) { | 571 | if ( KOPrefs::instance()->mShowFullMenu ) { |
572 | actionMenu->insertSeparator(); | 572 | actionMenu->insertSeparator(); |
573 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); | 573 | actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); |
574 | 574 | ||
575 | } | 575 | } |
576 | // actionMenu->insertSeparator(); | 576 | // actionMenu->insertSeparator(); |
577 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, | 577 | action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, |
578 | this ); | 578 | this ); |
579 | action->addTo( importMenu ); | 579 | action->addTo( importMenu ); |
580 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); | 580 | connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); |
581 | action = new QAction( "import_quick", i18n("Import last file"), 0, | 581 | action = new QAction( "import_quick", i18n("Import last file"), 0, |
582 | this ); | 582 | this ); |
583 | action->addTo( importMenu ); | 583 | action->addTo( importMenu ); |
584 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); | 584 | connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); |
585 | importMenu->insertSeparator(); | 585 | importMenu->insertSeparator(); |
586 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, | 586 | action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, |
587 | this ); | 587 | this ); |
588 | action->addTo( importMenu ); | 588 | action->addTo( importMenu ); |
589 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); | 589 | connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); |
590 | #ifndef DESKTOP_VERSION | 590 | #ifndef DESKTOP_VERSION |
591 | importMenu->insertSeparator(); | 591 | importMenu->insertSeparator(); |
592 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, | 592 | action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, |
593 | this ); | 593 | this ); |
594 | action->addTo( importMenu ); | 594 | action->addTo( importMenu ); |
595 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); | 595 | connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); |
596 | #else | 596 | #else |
597 | #ifdef _WIN32_ | 597 | #ifdef _WIN32_ |
598 | importMenu->insertSeparator(); | 598 | importMenu->insertSeparator(); |
599 | action = new QAction( "import_ol", i18n("Import from OL"), 0, | 599 | action = new QAction( "import_ol", i18n("Import from OL"), 0, |
600 | this ); | 600 | this ); |
601 | action->addTo( importMenu ); | 601 | action->addTo( importMenu ); |
602 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); | 602 | connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); |
603 | #endif | 603 | #endif |
604 | #endif | 604 | #endif |
605 | 605 | ||
606 | importMenu->insertSeparator(); | 606 | importMenu->insertSeparator(); |
607 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, | 607 | action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, |
608 | this ); | 608 | this ); |
609 | action->addTo( importMenu ); | 609 | action->addTo( importMenu ); |
610 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); | 610 | connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); |
611 | 611 | ||
612 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, | 612 | action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, |
613 | this ); | 613 | this ); |
614 | action->addTo( importMenu ); | 614 | action->addTo( importMenu ); |
615 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); | 615 | connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); |
616 | 616 | ||
617 | importMenu->insertSeparator(); | 617 | importMenu->insertSeparator(); |
618 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, | 618 | action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, |
619 | this ); | 619 | this ); |
620 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); | 620 | action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); |
621 | importMenu->insertSeparator(); | 621 | importMenu->insertSeparator(); |
622 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, | 622 | action = new QAction( "manage cat", i18n("Manage new categories..."), 0, |
623 | this ); | 623 | this ); |
624 | action->addTo( importMenu ); | 624 | action->addTo( importMenu ); |
625 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); | 625 | connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); |
626 | #ifndef DESKTOP_VERSION | 626 | #ifndef DESKTOP_VERSION |
627 | importMenu->insertSeparator(); | 627 | importMenu->insertSeparator(); |
628 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, | 628 | action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, |
629 | this ); | 629 | this ); |
630 | action->addTo( importMenu ); | 630 | action->addTo( importMenu ); |
631 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); | 631 | connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); |
632 | 632 | ||
633 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, | 633 | action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, |
634 | this ); | 634 | this ); |
635 | action->addTo( importMenu ); | 635 | action->addTo( importMenu ); |
636 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); | 636 | connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); |
637 | #else | 637 | #else |
638 | importMenu->insertSeparator(); | 638 | importMenu->insertSeparator(); |
639 | icon = loadPixmap( pathString + "print" ); | 639 | icon = loadPixmap( pathString + "print" ); |
640 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); | 640 | action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); |
641 | action->addTo( importMenu ); | 641 | action->addTo( importMenu ); |
642 | connect( action, SIGNAL( activated() ), | 642 | connect( action, SIGNAL( activated() ), |
643 | this, SLOT( printCal() ) ); | 643 | this, SLOT( printCal() ) ); |
644 | 644 | ||
645 | icon = loadPixmap( pathString + "print" ); | 645 | icon = loadPixmap( pathString + "print" ); |
646 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); | 646 | action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); |
647 | action->addTo( importMenu ); | 647 | action->addTo( importMenu ); |
648 | connect( action, SIGNAL( activated() ), | 648 | connect( action, SIGNAL( activated() ), |
649 | this, SLOT( printSel() ) ); | 649 | this, SLOT( printSel() ) ); |
650 | #endif | 650 | #endif |
651 | importMenu->insertSeparator(); | 651 | importMenu->insertSeparator(); |
652 | action = new QAction( "beam all", i18n("Save"), 0, | 652 | action = new QAction( "beam all", i18n("Save"), 0, |
653 | this ); | 653 | this ); |
654 | action->addTo( importMenu ); | 654 | action->addTo( importMenu ); |
655 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); | 655 | connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); |
656 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, | 656 | action = new QAction( "beam all", i18n("Exit (+save)"), 0, |
657 | this ); | 657 | this ); |
658 | action->addTo( importMenu ); | 658 | action->addTo( importMenu ); |
659 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); | 659 | connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); |
660 | 660 | ||
661 | //menuBar->insertItem( "Configure",configureMenu ); | 661 | //menuBar->insertItem( "Configure",configureMenu ); |
662 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); | 662 | //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); |
663 | icon = loadPixmap( "korganizer/korganizer" ); | 663 | icon = loadPixmap( "korganizer/korganizer" ); |
664 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); | 664 | action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); |
665 | action->addTo( helpMenu ); | 665 | action->addTo( helpMenu ); |
666 | connect( action, SIGNAL( activated() ), | 666 | connect( action, SIGNAL( activated() ), |
667 | SLOT( keyBindings() ) ); | 667 | SLOT( keyBindings() ) ); |
668 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); | 668 | action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); |
669 | action->addTo( helpMenu ); | 669 | action->addTo( helpMenu ); |
670 | connect( action, SIGNAL( activated() ), | 670 | connect( action, SIGNAL( activated() ), |
671 | SLOT( features() ) ); | 671 | SLOT( features() ) ); |
672 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); | 672 | action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); |
673 | action->addTo( helpMenu ); | 673 | action->addTo( helpMenu ); |
674 | connect( action, SIGNAL( activated() ), | 674 | connect( action, SIGNAL( activated() ), |
675 | SLOT( aboutAutoSaving() ) ); | 675 | SLOT( aboutAutoSaving() ) ); |
676 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); | 676 | action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); |
677 | action->addTo( helpMenu ); | 677 | action->addTo( helpMenu ); |
678 | connect( action, SIGNAL( activated() ), | 678 | connect( action, SIGNAL( activated() ), |
679 | SLOT( aboutKnownBugs() ) ); | 679 | SLOT( aboutKnownBugs() ) ); |
680 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); | 680 | action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); |
681 | action->addTo( helpMenu ); | 681 | action->addTo( helpMenu ); |
682 | connect( action, SIGNAL( activated() ), | 682 | connect( action, SIGNAL( activated() ), |
683 | SLOT( usertrans() ) ); | 683 | SLOT( usertrans() ) ); |
684 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); | 684 | action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); |
685 | action->addTo( helpMenu ); | 685 | action->addTo( helpMenu ); |
686 | connect( action, SIGNAL( activated() ), | 686 | connect( action, SIGNAL( activated() ), |
687 | SLOT( synchowto() ) ); | 687 | SLOT( synchowto() ) ); |
688 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); | 688 | action = new QAction( "Whats New", i18n("What's new?"), 0,this ); |
689 | action->addTo( helpMenu ); | 689 | action->addTo( helpMenu ); |
690 | connect( action, SIGNAL( activated() ), | 690 | connect( action, SIGNAL( activated() ), |
691 | SLOT( whatsNew() ) ); | 691 | SLOT( whatsNew() ) ); |
692 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); | 692 | action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); |
693 | action->addTo( helpMenu ); | 693 | action->addTo( helpMenu ); |
694 | connect( action, SIGNAL( activated() ), | 694 | connect( action, SIGNAL( activated() ), |
695 | SLOT( faq() ) ); | 695 | SLOT( faq() ) ); |
696 | 696 | ||
697 | 697 | ||
698 | action = new QAction( "about", i18n("About..."), 0, this ); | 698 | action = new QAction( "about", i18n("About..."), 0, this ); |
699 | action->addTo( helpMenu ); | 699 | action->addTo( helpMenu ); |
700 | connect( action, SIGNAL( activated() ), | 700 | connect( action, SIGNAL( activated() ), |
701 | SLOT( about() ) ); | 701 | SLOT( about() ) ); |
702 | action = new QAction( "licence", i18n("Licence..."), 0, this ); | 702 | action = new QAction( "licence", i18n("Licence..."), 0, this ); |
703 | action->addTo( helpMenu ); | 703 | action->addTo( helpMenu ); |
704 | connect( action, SIGNAL( activated() ), | 704 | connect( action, SIGNAL( activated() ), |
705 | SLOT( licence() ) ); | 705 | SLOT( licence() ) ); |
706 | //menuBar->insertSeparator(); | 706 | //menuBar->insertSeparator(); |
707 | 707 | ||
708 | // ****************************************************** | 708 | // ****************************************************** |
709 | // menubar icons | 709 | // menubar icons |
710 | 710 | ||
711 | 711 | ||
712 | iconToolBar->setHorizontalStretchable (true ); | 712 | iconToolBar->setHorizontalStretchable (true ); |
713 | //menuBar->insertItem( iconToolBar ); | 713 | //menuBar->insertItem( iconToolBar ); |
714 | //xdays_action | 714 | //xdays_action |
715 | if (p-> mShowIconNewEvent) | 715 | if (p-> mShowIconNewEvent) |
716 | ne_action->addTo( iconToolBar ); | 716 | ne_action->addTo( iconToolBar ); |
717 | if (p->mShowIconNewTodo ) | 717 | if (p->mShowIconNewTodo ) |
718 | nt_action->addTo( iconToolBar ); | 718 | nt_action->addTo( iconToolBar ); |
719 | if (p-> mShowIconSearch) | 719 | if (p-> mShowIconSearch) |
720 | search_action->addTo( iconToolBar ); | 720 | search_action->addTo( iconToolBar ); |
721 | if (p-> mShowIconNext) | 721 | if (p-> mShowIconNext) |
722 | whatsnext_action->addTo( iconToolBar ); | 722 | whatsnext_action->addTo( iconToolBar ); |
723 | if (p-> mShowIconNextDays) | 723 | if (p-> mShowIconNextDays) |
724 | xdays_action->addTo( iconToolBar ); | 724 | xdays_action->addTo( iconToolBar ); |
725 | if (p-> mShowIconList) | 725 | if (p-> mShowIconList) |
726 | showlist_action->addTo( iconToolBar ); | 726 | showlist_action->addTo( iconToolBar ); |
727 | if (p-> mShowIconDay1) | 727 | if (p-> mShowIconDay1) |
728 | day1_action->addTo( iconToolBar ); | 728 | day1_action->addTo( iconToolBar ); |
729 | if (p-> mShowIconDay5) | 729 | if (p-> mShowIconDay5) |
730 | day5_action->addTo( iconToolBar ); | 730 | day5_action->addTo( iconToolBar ); |
731 | if (p-> mShowIconDay7) | 731 | if (p-> mShowIconDay7) |
732 | day7_action->addTo( iconToolBar ); | 732 | day7_action->addTo( iconToolBar ); |
733 | if (p-> mShowIconMonth) | 733 | if (p-> mShowIconMonth) |
734 | month_action->addTo( iconToolBar ); | 734 | month_action->addTo( iconToolBar ); |
735 | if (p-> mShowIconTodoview) | 735 | if (p-> mShowIconTodoview) |
736 | todoview_action->addTo( iconToolBar ); | 736 | todoview_action->addTo( iconToolBar ); |
737 | if (p-> mShowIconJournal) | 737 | if (p-> mShowIconJournal) |
738 | viewjournal_action->addTo( iconToolBar ); | 738 | viewjournal_action->addTo( iconToolBar ); |
739 | icon = loadPixmap( pathString + "2leftarrowB" ); | 739 | icon = loadPixmap( pathString + "2leftarrowB" ); |
740 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); | 740 | configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); |
741 | if (p-> mShowIconBackFast) { | 741 | if (p-> mShowIconBackFast) { |
742 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); | 742 | action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); |
743 | connect( action, SIGNAL( activated() ), | 743 | connect( action, SIGNAL( activated() ), |
744 | mView, SLOT( goPreviousMonth() ) ); | 744 | mView, SLOT( goPreviousMonth() ) ); |
745 | action->addTo( iconToolBar ); | 745 | action->addTo( iconToolBar ); |
746 | } | 746 | } |
747 | icon = loadPixmap( pathString + "1leftarrowB" ); | 747 | icon = loadPixmap( pathString + "1leftarrowB" ); |
748 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); | 748 | configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); |
749 | if (p-> mShowIconBack) { | 749 | if (p-> mShowIconBack) { |
750 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); | 750 | action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); |
751 | connect( action, SIGNAL( activated() ), | 751 | connect( action, SIGNAL( activated() ), |
752 | mView, SLOT( goPrevious() ) ); | 752 | mView, SLOT( goPrevious() ) ); |
753 | action->addTo( iconToolBar ); | 753 | action->addTo( iconToolBar ); |
754 | } | 754 | } |
755 | if (p-> mShowIconToday) | 755 | if (p-> mShowIconToday) |
756 | today_action->addTo( iconToolBar ); | 756 | today_action->addTo( iconToolBar ); |
757 | icon = loadPixmap( pathString + "1rightarrowB" ); | 757 | icon = loadPixmap( pathString + "1rightarrowB" ); |
758 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); | 758 | configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); |
759 | if (p-> mShowIconForward) { | 759 | if (p-> mShowIconForward) { |
760 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); | 760 | action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); |
761 | connect( action, SIGNAL( activated() ), | 761 | connect( action, SIGNAL( activated() ), |
762 | mView, SLOT( goNext() ) ); | 762 | mView, SLOT( goNext() ) ); |
763 | action->addTo( iconToolBar ); | 763 | action->addTo( iconToolBar ); |
764 | } | 764 | } |
765 | icon = loadPixmap( pathString + "2rightarrowB" ); | 765 | icon = loadPixmap( pathString + "2rightarrowB" ); |
766 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); | 766 | configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); |
767 | if (p-> mShowIconForwardFast) { | 767 | if (p-> mShowIconForwardFast) { |
768 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); | 768 | action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); |
769 | connect( action, SIGNAL( activated() ), | 769 | connect( action, SIGNAL( activated() ), |
770 | mView, SLOT( goNextMonth() ) ); | 770 | mView, SLOT( goNextMonth() ) ); |
771 | action->addTo( iconToolBar ); | 771 | action->addTo( iconToolBar ); |
772 | } | 772 | } |
773 | 773 | ||
774 | 774 | ||
775 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); | 775 | configureToolBarMenu->insertItem(i18n("What's This?"), 300); |
776 | 776 | ||
777 | if (p-> mShowIconNewEvent) | 777 | if (p-> mShowIconNewEvent) |
778 | configureToolBarMenu->setItemChecked( 10, true ); | 778 | configureToolBarMenu->setItemChecked( 10, true ); |
779 | if (p->mShowIconNewTodo ) | 779 | if (p->mShowIconNewTodo ) |
780 | configureToolBarMenu->setItemChecked( 20, true ); | 780 | configureToolBarMenu->setItemChecked( 20, true ); |
781 | if (p-> mShowIconSearch) | 781 | if (p-> mShowIconSearch) |
782 | configureToolBarMenu->setItemChecked( 120, true ); | 782 | configureToolBarMenu->setItemChecked( 120, true ); |
783 | if (p-> mShowIconList) | 783 | if (p-> mShowIconList) |
784 | configureToolBarMenu->setItemChecked( 30, true ); | 784 | configureToolBarMenu->setItemChecked( 30, true ); |
785 | if (p-> mShowIconDay1) | 785 | if (p-> mShowIconDay1) |
786 | configureToolBarMenu->setItemChecked( 40, true ); | 786 | configureToolBarMenu->setItemChecked( 40, true ); |
787 | if (p-> mShowIconDay5) | 787 | if (p-> mShowIconDay5) |
788 | configureToolBarMenu->setItemChecked( 50, true ); | 788 | configureToolBarMenu->setItemChecked( 50, true ); |
789 | if (p-> mShowIconDay7) | 789 | if (p-> mShowIconDay7) |
790 | configureToolBarMenu->setItemChecked( 60, true ); | 790 | configureToolBarMenu->setItemChecked( 60, true ); |
791 | if (p-> mShowIconMonth) | 791 | if (p-> mShowIconMonth) |
792 | configureToolBarMenu->setItemChecked( 70, true ); | 792 | configureToolBarMenu->setItemChecked( 70, true ); |
793 | if (p-> mShowIconTodoview) | 793 | if (p-> mShowIconTodoview) |
794 | configureToolBarMenu->setItemChecked( 80, true ); | 794 | configureToolBarMenu->setItemChecked( 80, true ); |
795 | if (p-> mShowIconBackFast) | 795 | if (p-> mShowIconBackFast) |
796 | configureToolBarMenu->setItemChecked( 200, true ); | 796 | configureToolBarMenu->setItemChecked( 200, true ); |
797 | if (p-> mShowIconBack) | 797 | if (p-> mShowIconBack) |
798 | configureToolBarMenu->setItemChecked( 210, true ); | 798 | configureToolBarMenu->setItemChecked( 210, true ); |
799 | if (p-> mShowIconToday) | 799 | if (p-> mShowIconToday) |
800 | configureToolBarMenu->setItemChecked( 130, true ); | 800 | configureToolBarMenu->setItemChecked( 130, true ); |
801 | if (p-> mShowIconForward) | 801 | if (p-> mShowIconForward) |
802 | configureToolBarMenu->setItemChecked( 220, true ); | 802 | configureToolBarMenu->setItemChecked( 220, true ); |
803 | if (p-> mShowIconForwardFast) | 803 | if (p-> mShowIconForwardFast) |
804 | configureToolBarMenu->setItemChecked( 230, true ); | 804 | configureToolBarMenu->setItemChecked( 230, true ); |
805 | if (p-> mShowIconNextDays) | 805 | if (p-> mShowIconNextDays) |
806 | configureToolBarMenu->setItemChecked( 100, true ); | 806 | configureToolBarMenu->setItemChecked( 100, true ); |
807 | if (p-> mShowIconNext) | 807 | if (p-> mShowIconNext) |
808 | configureToolBarMenu->setItemChecked( 110, true ); | 808 | configureToolBarMenu->setItemChecked( 110, true ); |
809 | if (p-> mShowIconJournal) | 809 | if (p-> mShowIconJournal) |
810 | configureToolBarMenu->setItemChecked( 90, true ); | 810 | configureToolBarMenu->setItemChecked( 90, true ); |
811 | if (p-> mShowIconWhatsThis) | 811 | if (p-> mShowIconWhatsThis) |
812 | configureToolBarMenu->setItemChecked( 300, true ); | 812 | configureToolBarMenu->setItemChecked( 300, true ); |
813 | 813 | ||
814 | QLabel* dummy = new QLabel( iconToolBar ); | 814 | QLabel* dummy = new QLabel( iconToolBar ); |
815 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); | 815 | dummy->setBackgroundColor( iconToolBar->backgroundColor() ); |
816 | if (!p-> mShowIconStretch) | 816 | if (!p-> mShowIconStretch) |
817 | iconToolBar->setStretchableWidget ( dummy ) ; | 817 | iconToolBar->setStretchableWidget ( dummy ) ; |
818 | else | 818 | else |
819 | configureToolBarMenu->setItemChecked( 5, true ); | 819 | configureToolBarMenu->setItemChecked( 5, true ); |
820 | if (p-> mShowIconWhatsThis) | 820 | if (p-> mShowIconWhatsThis) |
821 | QWhatsThis::whatsThisButton ( iconToolBar ); | 821 | QWhatsThis::whatsThisButton ( iconToolBar ); |
822 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); | 822 | connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); |
823 | configureAgenda( p->mHourSize ); | 823 | configureAgenda( p->mHourSize ); |
824 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); | 824 | connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); |
825 | } | 825 | } |
826 | void MainWindow::fillSyncMenu() | 826 | void MainWindow::fillSyncMenu() |
827 | { | 827 | { |
828 | syncMenu->clear(); | 828 | syncMenu->clear(); |
829 | syncMenu->insertItem( i18n("Configure..."), 0 ); | 829 | syncMenu->insertItem( i18n("Configure..."), 0 ); |
830 | syncMenu->insertSeparator(); | 830 | syncMenu->insertSeparator(); |
831 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); | 831 | syncMenu->insertItem( i18n("Multiple sync"), 1 ); |
832 | syncMenu->insertSeparator(); | 832 | syncMenu->insertSeparator(); |
833 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 833 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
834 | config.setGroup("General"); | 834 | config.setGroup("General"); |
835 | QStringList prof = config.readListEntry("SyncProfileNames"); | 835 | QStringList prof = config.readListEntry("SyncProfileNames"); |
836 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); | 836 | KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); |
837 | if ( prof.count() < 3 ) { | 837 | if ( prof.count() < 3 ) { |
838 | prof.clear(); | 838 | prof.clear(); |
839 | prof << i18n("Sharp_DTM"); | 839 | prof << i18n("Sharp_DTM"); |
840 | prof << i18n("Local_file"); | 840 | prof << i18n("Local_file"); |
841 | prof << i18n("Last_file"); | 841 | prof << i18n("Last_file"); |
842 | KSyncProfile* temp = new KSyncProfile (); | 842 | KSyncProfile* temp = new KSyncProfile (); |
843 | temp->setName( prof[0] ); | 843 | temp->setName( prof[0] ); |
844 | temp->writeConfig(&config); | 844 | temp->writeConfig(&config); |
845 | temp->setName( prof[1] ); | 845 | temp->setName( prof[1] ); |
846 | temp->writeConfig(&config); | 846 | temp->writeConfig(&config); |
847 | temp->setName( prof[2] ); | 847 | temp->setName( prof[2] ); |
848 | temp->writeConfig(&config); | 848 | temp->writeConfig(&config); |
849 | config.setGroup("General"); | 849 | config.setGroup("General"); |
850 | config.writeEntry("SyncProfileNames",prof); | 850 | config.writeEntry("SyncProfileNames",prof); |
851 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); | 851 | config.writeEntry("ExternSyncProfiles","Sharp_DTM"); |
852 | config.sync(); | 852 | config.sync(); |
853 | delete temp; | 853 | delete temp; |
854 | } | 854 | } |
855 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); | 855 | KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); |
856 | KOPrefs::instance()->mSyncProfileNames = prof; | 856 | KOPrefs::instance()->mSyncProfileNames = prof; |
857 | int i; | 857 | int i; |
858 | for ( i = 0; i < prof.count(); ++i ) { | 858 | for ( i = 0; i < prof.count(); ++i ) { |
859 | 859 | ||
860 | syncMenu->insertItem( prof[i], 1000+i ); | 860 | syncMenu->insertItem( prof[i], 1000+i ); |
861 | if ( i == 2 ) | 861 | if ( i == 2 ) |
862 | syncMenu->insertSeparator(); | 862 | syncMenu->insertSeparator(); |
863 | } | 863 | } |
864 | QDir app_dir; | 864 | QDir app_dir; |
865 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { | 865 | if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { |
866 | syncMenu->setItemEnabled( false , 1000 ); | 866 | syncMenu->setItemEnabled( false , 1000 ); |
867 | } | 867 | } |
868 | mView->setupExternSyncProfiles(); | 868 | mView->setupExternSyncProfiles(); |
869 | } | 869 | } |
870 | 870 | ||
871 | int MainWindow::ringSync() | 871 | int MainWindow::ringSync() |
872 | { | 872 | { |
873 | int syncedProfiles = 0; | 873 | int syncedProfiles = 0; |
874 | int i; | 874 | int i; |
875 | QTime timer; | 875 | QTime timer; |
876 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 876 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
877 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; | 877 | QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; |
878 | KSyncProfile* temp = new KSyncProfile (); | 878 | KSyncProfile* temp = new KSyncProfile (); |
879 | KOPrefs::instance()->mAskForPreferences = false; | 879 | KOPrefs::instance()->mAskForPreferences = false; |
880 | for ( i = 0; i < syncProfileNames.count(); ++i ) { | 880 | for ( i = 0; i < syncProfileNames.count(); ++i ) { |
881 | mCurrentSyncProfile = i; | 881 | mCurrentSyncProfile = i; |
882 | temp->setName(syncProfileNames[mCurrentSyncProfile]); | 882 | temp->setName(syncProfileNames[mCurrentSyncProfile]); |
883 | temp->readConfig(&config); | 883 | temp->readConfig(&config); |
884 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { | 884 | if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { |
885 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); | 885 | setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); |
886 | ++syncedProfiles; | 886 | ++syncedProfiles; |
887 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 887 | // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
888 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 888 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
889 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 889 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
890 | KOPrefs::instance()->mShowSyncSummary = false; | 890 | KOPrefs::instance()->mShowSyncSummary = false; |
891 | mView->setSyncDevice(syncProfileNames[i] ); | 891 | mView->setSyncDevice(syncProfileNames[i] ); |
892 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 892 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
893 | if ( i == 0 ) { | 893 | if ( i == 0 ) { |
894 | syncSharp(); | 894 | syncSharp(); |
895 | } else { | 895 | } else { |
896 | if ( temp->getIsLocalFileSync() ) { | 896 | if ( temp->getIsLocalFileSync() ) { |
897 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) | 897 | if ( syncWithFile( temp->getRemoteFileName( ), true ) ) |
898 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 898 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
899 | } else { | 899 | } else { |
900 | if ( temp->getIsPhoneSync() ) { | 900 | if ( temp->getIsPhoneSync() ) { |
901 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | 901 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; |
902 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | 902 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); |
903 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | 903 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); |
904 | syncPhone(); | 904 | syncPhone(); |
905 | } else | 905 | } else |
906 | syncRemote( temp, false ); | 906 | syncRemote( temp, false ); |
907 | 907 | ||
908 | } | 908 | } |
909 | } | 909 | } |
910 | timer.start(); | 910 | timer.start(); |
911 | setCaption(i18n("Multiple sync in progress ... please wait!") ); | 911 | setCaption(i18n("Multiple sync in progress ... please wait!") ); |
912 | while ( timer.elapsed () < 2000 ) { | 912 | while ( timer.elapsed () < 2000 ) { |
913 | qApp->processEvents(); | 913 | qApp->processEvents(); |
914 | #ifndef _WIN32_ | 914 | #ifndef _WIN32_ |
915 | sleep (1); | 915 | sleep (1); |
916 | #endif | 916 | #endif |
917 | } | 917 | } |
918 | 918 | ||
919 | } | 919 | } |
920 | 920 | ||
921 | } | 921 | } |
922 | delete temp; | 922 | delete temp; |
923 | return syncedProfiles; | 923 | return syncedProfiles; |
924 | } | 924 | } |
925 | 925 | ||
926 | void MainWindow::multiSync( bool askforPrefs ) | 926 | void MainWindow::multiSync( bool askforPrefs ) |
927 | { | 927 | { |
928 | if (mBlockSaveFlag) | 928 | if (mBlockSaveFlag) |
929 | return; | 929 | return; |
930 | mBlockSaveFlag = true; | 930 | mBlockSaveFlag = true; |
931 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); | 931 | QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); |
932 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), | 932 | if ( QMessageBox::information( this, i18n("KO/Pi Sync"), |
933 | question, | 933 | question, |
934 | i18n("Yes"), i18n("No"), | 934 | i18n("Yes"), i18n("No"), |
935 | 0, 0 ) != 0 ) { | 935 | 0, 0 ) != 0 ) { |
936 | mBlockSaveFlag = false; | 936 | mBlockSaveFlag = false; |
937 | setCaption(i18n("Aborted! Nothing synced!")); | 937 | setCaption(i18n("Aborted! Nothing synced!")); |
938 | return; | 938 | return; |
939 | } | 939 | } |
940 | mView->setSyncDevice(i18n("Multiple profiles") ); | 940 | mView->setSyncDevice(i18n("Multiple profiles") ); |
941 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; | 941 | KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; |
942 | if ( askforPrefs ) { | 942 | if ( askforPrefs ) { |
943 | mView->edit_sync_options(); | 943 | mView->edit_sync_options(); |
944 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; | 944 | KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; |
945 | } | 945 | } |
946 | setCaption(i18n("Multiple sync started.") ); | 946 | setCaption(i18n("Multiple sync started.") ); |
947 | qApp->processEvents(); | 947 | qApp->processEvents(); |
948 | int num = ringSync() ; | 948 | int num = ringSync() ; |
949 | if ( num > 1 ) | 949 | if ( num > 1 ) |
950 | ringSync(); | 950 | ringSync(); |
951 | mBlockSaveFlag = false; | 951 | mBlockSaveFlag = false; |
952 | if ( num ) | 952 | if ( num ) |
953 | save(); | 953 | save(); |
954 | if ( num ) | 954 | if ( num ) |
955 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); | 955 | setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); |
956 | else | 956 | else |
957 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); | 957 | setCaption(i18n("Nothing synced! No profiles defined for multisync!")); |
958 | return; | 958 | return; |
959 | } | 959 | } |
960 | void MainWindow::slotSyncMenu( int action ) | 960 | void MainWindow::slotSyncMenu( int action ) |
961 | { | 961 | { |
962 | //qDebug("syncaction %d ", action); | 962 | //qDebug("syncaction %d ", action); |
963 | if ( action == 0 ) { | 963 | if ( action == 0 ) { |
964 | 964 | ||
965 | confSync(); | 965 | confSync(); |
966 | 966 | ||
967 | return; | 967 | return; |
968 | } | 968 | } |
969 | if ( action == 1 ) { | 969 | if ( action == 1 ) { |
970 | multiSync( true ); | 970 | multiSync( true ); |
971 | return; | 971 | return; |
972 | } | 972 | } |
973 | 973 | ||
974 | if (mBlockSaveFlag) | 974 | if (mBlockSaveFlag) |
975 | return; | 975 | return; |
976 | mBlockSaveFlag = true; | 976 | mBlockSaveFlag = true; |
977 | mCurrentSyncProfile = action - 1000 ; | 977 | mCurrentSyncProfile = action - 1000 ; |
978 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); | 978 | mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); |
979 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); | 979 | mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); |
980 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); | 980 | KConfig config ( locateLocal( "config","syncprofilesrc" ) ); |
981 | KSyncProfile* temp = new KSyncProfile (); | 981 | KSyncProfile* temp = new KSyncProfile (); |
982 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); | 982 | temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); |
983 | temp->readConfig(&config); | 983 | temp->readConfig(&config); |
984 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); | 984 | KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); |
985 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); | 985 | KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); |
986 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); | 986 | KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); |
987 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); | 987 | KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); |
988 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); | 988 | KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); |
989 | if ( action == 1000 ) { | 989 | if ( action == 1000 ) { |
990 | syncSharp(); | 990 | syncSharp(); |
991 | 991 | ||
992 | } else if ( action == 1001 ) { | 992 | } else if ( action == 1001 ) { |
993 | syncLocalFile(); | 993 | syncLocalFile(); |
994 | 994 | ||
995 | } else if ( action == 1002 ) { | 995 | } else if ( action == 1002 ) { |
996 | quickSyncLocalFile(); | 996 | quickSyncLocalFile(); |
997 | 997 | ||
998 | } else if ( action >= 1003 ) { | 998 | } else if ( action >= 1003 ) { |
999 | if ( temp->getIsLocalFileSync() ) { | 999 | if ( temp->getIsLocalFileSync() ) { |
1000 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) | 1000 | if ( syncWithFile( temp->getRemoteFileName( ), false ) ) |
1001 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); | 1001 | KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); |
1002 | } else { | 1002 | } else { |
1003 | syncRemote( temp ); | 1003 | if ( temp->getIsPhoneSync() ) { |
1004 | KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; | ||
1005 | KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); | ||
1006 | KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); | ||
1007 | syncPhone(); | ||
1008 | } else | ||
1009 | syncRemote( temp ); | ||
1004 | 1010 | ||
1005 | } | 1011 | } |
1006 | } | 1012 | } |
1007 | delete temp; | 1013 | delete temp; |
1008 | mBlockSaveFlag = false; | 1014 | mBlockSaveFlag = false; |
1009 | } | 1015 | } |
1010 | void MainWindow::setDefaultPreferences() | 1016 | void MainWindow::setDefaultPreferences() |
1011 | { | 1017 | { |
1012 | KOPrefs *p = KOPrefs::instance(); | 1018 | KOPrefs *p = KOPrefs::instance(); |
1013 | 1019 | ||
1014 | p->mCompactDialogs = true; | 1020 | p->mCompactDialogs = true; |
1015 | p->mConfirm = true; | 1021 | p->mConfirm = true; |
1016 | // p->mEnableQuickTodo = false; | 1022 | // p->mEnableQuickTodo = false; |
1017 | } | 1023 | } |
1018 | 1024 | ||
1019 | QString MainWindow::resourcePath() | 1025 | QString MainWindow::resourcePath() |
1020 | { | 1026 | { |
1021 | return KGlobal::iconLoader()->iconPath(); | 1027 | return KGlobal::iconLoader()->iconPath(); |
1022 | } | 1028 | } |
1023 | 1029 | ||
1024 | void MainWindow::displayText( QString text ,QString cap ) | 1030 | void MainWindow::displayText( QString text ,QString cap ) |
1025 | { | 1031 | { |
1026 | QDialog dia( this, "name", true ); ; | 1032 | QDialog dia( this, "name", true ); ; |
1027 | dia.setCaption( cap ); | 1033 | dia.setCaption( cap ); |
1028 | QVBoxLayout* lay = new QVBoxLayout( &dia ); | 1034 | QVBoxLayout* lay = new QVBoxLayout( &dia ); |
1029 | lay->setSpacing( 3 ); | 1035 | lay->setSpacing( 3 ); |
1030 | lay->setMargin( 3 ); | 1036 | lay->setMargin( 3 ); |
1031 | QTextBrowser tb ( &dia ); | 1037 | QTextBrowser tb ( &dia ); |
1032 | lay->addWidget( &tb ); | 1038 | lay->addWidget( &tb ); |
1033 | tb.setText( text ); | 1039 | tb.setText( text ); |
1034 | #ifdef DESKTOP_VERSION | 1040 | #ifdef DESKTOP_VERSION |
1035 | dia.resize( 640, 480); | 1041 | dia.resize( 640, 480); |
1036 | #else | 1042 | #else |
1037 | dia.showMaximized(); | 1043 | dia.showMaximized(); |
1038 | #endif | 1044 | #endif |
1039 | dia.exec(); | 1045 | dia.exec(); |
1040 | } | 1046 | } |
1041 | void MainWindow::displayFile( QString fn, QString cap ) | 1047 | void MainWindow::displayFile( QString fn, QString cap ) |
1042 | { | 1048 | { |
1043 | QString fileName = resourcePath() + fn; | 1049 | QString fileName = resourcePath() + fn; |
1044 | QString text; | 1050 | QString text; |
1045 | QFile file( fileName ); | 1051 | QFile file( fileName ); |
1046 | if (!file.open( IO_ReadOnly ) ) { | 1052 | if (!file.open( IO_ReadOnly ) ) { |
1047 | return ; | 1053 | return ; |
1048 | 1054 | ||
1049 | } | 1055 | } |
1050 | QTextStream ts( &file ); | 1056 | QTextStream ts( &file ); |
1051 | text = ts.read(); | 1057 | text = ts.read(); |
1052 | file.close(); | 1058 | file.close(); |
1053 | displayText( text, cap); | 1059 | displayText( text, cap); |
1054 | } | 1060 | } |
1055 | void MainWindow::features() | 1061 | void MainWindow::features() |
1056 | { | 1062 | { |
1057 | 1063 | ||
1058 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); | 1064 | displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); |
1059 | } | 1065 | } |
1060 | 1066 | ||
1061 | void MainWindow::usertrans() | 1067 | void MainWindow::usertrans() |
1062 | { | 1068 | { |
1063 | 1069 | ||
1064 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); | 1070 | displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); |
1065 | } | 1071 | } |
1066 | void MainWindow::synchowto() | 1072 | void MainWindow::synchowto() |
1067 | { | 1073 | { |
1068 | 1074 | ||
1069 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); | 1075 | displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); |
1070 | } | 1076 | } |
1071 | void MainWindow::faq() | 1077 | void MainWindow::faq() |
1072 | { | 1078 | { |
1073 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); | 1079 | displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); |
1074 | 1080 | ||
1075 | } | 1081 | } |
1076 | void MainWindow::whatsNew() | 1082 | void MainWindow::whatsNew() |
1077 | { | 1083 | { |
1078 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); | 1084 | displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); |
1079 | 1085 | ||
1080 | } | 1086 | } |
1081 | void MainWindow::licence() | 1087 | void MainWindow::licence() |
1082 | { | 1088 | { |
1083 | KApplication::showLicence(); | 1089 | KApplication::showLicence(); |
1084 | 1090 | ||
1085 | } | 1091 | } |
1086 | void MainWindow::about() | 1092 | void MainWindow::about() |
1087 | { | 1093 | { |
1088 | QString version; | 1094 | QString version; |
1089 | #include <../version> | 1095 | #include <../version> |
1090 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), | 1096 | QMessageBox::about( this, i18n("About KOrganizer/Pi"), |
1091 | i18n("KOrganizer/Platform-independent\n") + | 1097 | i18n("KOrganizer/Platform-independent\n") + |
1092 | "(KO/Pi) " + version + " - " + | 1098 | "(KO/Pi) " + version + " - " + |
1093 | 1099 | ||
1094 | #ifdef DESKTOP_VERSION | 1100 | #ifdef DESKTOP_VERSION |
1095 | i18n("Desktop Edition\n") + | 1101 | i18n("Desktop Edition\n") + |
1096 | #else | 1102 | #else |
1097 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + | 1103 | i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + |
1098 | #endif | 1104 | #endif |
1099 | 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") ); | 1105 | 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") ); |
1100 | } | 1106 | } |
1101 | void MainWindow::keyBindings() | 1107 | void MainWindow::keyBindings() |
1102 | { | 1108 | { |
1103 | QString cap = i18n("Key bindings KOrganizer/Pi"); | 1109 | QString cap = i18n("Key bindings KOrganizer/Pi"); |
1104 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + | 1110 | QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + |
1105 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ | 1111 | i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ |
1106 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + | 1112 | i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + |
1107 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ | 1113 | i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ |
1108 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ | 1114 | i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ |
1109 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ | 1115 | i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ |
1110 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ | 1116 | i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ |
1111 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ | 1117 | i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ |
1112 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ | 1118 | i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ |
1113 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ | 1119 | i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ |
1114 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ | 1120 | i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ |
1115 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ | 1121 | i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ |
1116 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ | 1122 | i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ |
1117 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ | 1123 | i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ |
1118 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ | 1124 | i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ |
1119 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ | 1125 | i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ |
1120 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ | 1126 | i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ |
1121 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ | 1127 | i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ |
1122 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ | 1128 | i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ |
1123 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ | 1129 | i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ |
1124 | i18n("<p><h3>In agenda view:</h3></p>\n") + | 1130 | i18n("<p><h3>In agenda view:</h3></p>\n") + |
1125 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ | 1131 | i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ |
1126 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ | 1132 | i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ |
1127 | i18n("<p><h3>In todo view:</h3></p>\n") + | 1133 | i18n("<p><h3>In todo view:</h3></p>\n") + |
1128 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ | 1134 | i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ |
1129 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1135 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1130 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ | 1136 | i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ |
1131 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ | 1137 | i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ |
1132 | i18n("<p><h3>In list view:</h3></p>\n") + | 1138 | i18n("<p><h3>In list view:</h3></p>\n") + |
1133 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ | 1139 | i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ |
1134 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ | 1140 | i18n("<p><b>return</b>: Select item+one step down</p>\n")+ |
1135 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ | 1141 | i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ |
1136 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ | 1142 | i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ |
1137 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ | 1143 | i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ |
1138 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ | 1144 | i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ |
1139 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + | 1145 | i18n("<p><h3>In event/todo viewer:</h3></p>\n") + |
1140 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ | 1146 | i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ |
1141 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ | 1147 | i18n("<p><b>A</b>: Show agenda view.</p>\n")+ |
1142 | i18n("<p><b>E</b>: Edit item</p>\n") + | 1148 | i18n("<p><b>E</b>: Edit item</p>\n") + |
1143 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1149 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1144 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1150 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1145 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1151 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1146 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1152 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1147 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1153 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1148 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1154 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1149 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1155 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1150 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1156 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1151 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1157 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1152 | displayText( text, cap); | 1158 | displayText( text, cap); |
1153 | 1159 | ||
1154 | } | 1160 | } |
1155 | void MainWindow::aboutAutoSaving() | 1161 | void MainWindow::aboutAutoSaving() |
1156 | { | 1162 | { |
1157 | QMessageBox* msg; | 1163 | QMessageBox* msg; |
1158 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), | 1164 | msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), |
1159 | 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, | 1165 | 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, |
1160 | QMessageBox::Ok, | 1166 | QMessageBox::Ok, |
1161 | QMessageBox::NoButton, | 1167 | QMessageBox::NoButton, |
1162 | QMessageBox::NoButton); | 1168 | QMessageBox::NoButton); |
1163 | msg->exec(); | 1169 | msg->exec(); |
1164 | delete msg; | 1170 | delete msg; |
1165 | 1171 | ||
1166 | 1172 | ||
1167 | } | 1173 | } |
1168 | void MainWindow::aboutKnownBugs() | 1174 | void MainWindow::aboutKnownBugs() |
1169 | { | 1175 | { |
1170 | QMessageBox* msg; | 1176 | QMessageBox* msg; |
1171 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1177 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1172 | 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")+ | 1178 | 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")+ |
1173 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1179 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1174 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + | 1180 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + |
1175 | i18n("\nor report them in the bugtracker on\n") + | 1181 | i18n("\nor report them in the bugtracker on\n") + |
1176 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1182 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1177 | QMessageBox::NoIcon, | 1183 | QMessageBox::NoIcon, |
1178 | QMessageBox::Ok, | 1184 | QMessageBox::Ok, |
1179 | QMessageBox::NoButton, | 1185 | QMessageBox::NoButton, |
1180 | QMessageBox::NoButton); | 1186 | QMessageBox::NoButton); |
1181 | msg->exec(); | 1187 | msg->exec(); |
1182 | delete msg; | 1188 | delete msg; |
1183 | 1189 | ||
1184 | } | 1190 | } |
1185 | 1191 | ||
1186 | QString MainWindow::defaultFileName() | 1192 | QString MainWindow::defaultFileName() |
1187 | { | 1193 | { |
1188 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1194 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1189 | } | 1195 | } |
1190 | 1196 | ||
1191 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1197 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1192 | { | 1198 | { |
1193 | if ( !incidence ) { | 1199 | if ( !incidence ) { |
1194 | enableIncidenceActions( false ); | 1200 | enableIncidenceActions( false ); |
1195 | 1201 | ||
1196 | mNewSubTodoAction->setEnabled( false ); | 1202 | mNewSubTodoAction->setEnabled( false ); |
1197 | setCaptionToDates(); | 1203 | setCaptionToDates(); |
1198 | return; | 1204 | return; |
1199 | 1205 | ||
1200 | } | 1206 | } |
1201 | 1207 | ||
1202 | //KGlobal::locale()->formatDateTime(nextA, true); | 1208 | //KGlobal::locale()->formatDateTime(nextA, true); |
1203 | QString startString = ""; | 1209 | QString startString = ""; |
1204 | if ( incidence->type() != "Todo" ) { | 1210 | if ( incidence->type() != "Todo" ) { |
1205 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1211 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1206 | if ( incidence->doesFloat() ) { | 1212 | if ( incidence->doesFloat() ) { |
1207 | startString += ": "+incidence->dtStartDateStr( true ); | 1213 | startString += ": "+incidence->dtStartDateStr( true ); |
1208 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1214 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1209 | 1215 | ||
1210 | } else { | 1216 | } else { |
1211 | startString = ": "+incidence->dtStartStr(true); | 1217 | startString = ": "+incidence->dtStartStr(true); |
1212 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1218 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1213 | 1219 | ||
1214 | } | 1220 | } |
1215 | 1221 | ||
1216 | } else { | 1222 | } else { |
1217 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1223 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1218 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1224 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1219 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1225 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1220 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); | 1226 | startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); |
1221 | } | 1227 | } |
1222 | 1228 | ||
1223 | } | 1229 | } |
1224 | else | 1230 | else |
1225 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); | 1231 | startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); |
1226 | if ( !incidence->location().isEmpty() ) | 1232 | if ( !incidence->location().isEmpty() ) |
1227 | startString += " (" +incidence->location()+")"; | 1233 | startString += " (" +incidence->location()+")"; |
1228 | setCaption( incidence->summary()+startString); | 1234 | setCaption( incidence->summary()+startString); |
1229 | 1235 | ||
1230 | enableIncidenceActions( true ); | 1236 | enableIncidenceActions( true ); |
1231 | 1237 | ||
1232 | if ( incidence->type() == "Event" ) { | 1238 | if ( incidence->type() == "Event" ) { |
1233 | mShowAction->setText( i18n("Show Event...") ); | 1239 | mShowAction->setText( i18n("Show Event...") ); |
1234 | mEditAction->setText( i18n("Edit Event...") ); | 1240 | mEditAction->setText( i18n("Edit Event...") ); |
1235 | mDeleteAction->setText( i18n("Delete Event...") ); | 1241 | mDeleteAction->setText( i18n("Delete Event...") ); |
1236 | 1242 | ||
1237 | mNewSubTodoAction->setEnabled( false ); | 1243 | mNewSubTodoAction->setEnabled( false ); |
1238 | } else if ( incidence->type() == "Todo" ) { | 1244 | } else if ( incidence->type() == "Todo" ) { |
1239 | mShowAction->setText( i18n("Show Todo...") ); | 1245 | mShowAction->setText( i18n("Show Todo...") ); |
1240 | mEditAction->setText( i18n("Edit Todo...") ); | 1246 | mEditAction->setText( i18n("Edit Todo...") ); |
1241 | mDeleteAction->setText( i18n("Delete Todo...") ); | 1247 | mDeleteAction->setText( i18n("Delete Todo...") ); |
1242 | 1248 | ||
1243 | mNewSubTodoAction->setEnabled( true ); | 1249 | mNewSubTodoAction->setEnabled( true ); |
1244 | } else { | 1250 | } else { |
1245 | mShowAction->setText( i18n("Show...") ); | 1251 | mShowAction->setText( i18n("Show...") ); |
1246 | mShowAction->setText( i18n("Edit...") ); | 1252 | mShowAction->setText( i18n("Edit...") ); |
1247 | mShowAction->setText( i18n("Delete...") ); | 1253 | mShowAction->setText( i18n("Delete...") ); |
1248 | 1254 | ||
1249 | mNewSubTodoAction->setEnabled( false ); | 1255 | mNewSubTodoAction->setEnabled( false ); |
1250 | } | 1256 | } |
1251 | } | 1257 | } |
1252 | 1258 | ||
1253 | void MainWindow::enableIncidenceActions( bool enabled ) | 1259 | void MainWindow::enableIncidenceActions( bool enabled ) |
1254 | { | 1260 | { |
1255 | mShowAction->setEnabled( enabled ); | 1261 | mShowAction->setEnabled( enabled ); |
1256 | mEditAction->setEnabled( enabled ); | 1262 | mEditAction->setEnabled( enabled ); |
1257 | mDeleteAction->setEnabled( enabled ); | 1263 | mDeleteAction->setEnabled( enabled ); |
1258 | } | 1264 | } |
1259 | 1265 | ||
1260 | void MainWindow::importOL() | 1266 | void MainWindow::importOL() |
1261 | { | 1267 | { |
1262 | #ifdef _WIN32_ | 1268 | #ifdef _WIN32_ |
1263 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); | 1269 | KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); |
1264 | id->exec(); | 1270 | id->exec(); |
1265 | delete id; | 1271 | delete id; |
1266 | mView->updateView(); | 1272 | mView->updateView(); |
1267 | #endif | 1273 | #endif |
1268 | } | 1274 | } |
1269 | void MainWindow::importBday() | 1275 | void MainWindow::importBday() |
1270 | { | 1276 | { |
1271 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1277 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1272 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), | 1278 | i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), |
1273 | i18n("Import!"), i18n("Cancel"), 0, | 1279 | i18n("Import!"), i18n("Cancel"), 0, |
1274 | 0, 1 ); | 1280 | 0, 1 ); |
1275 | if ( result == 0 ) { | 1281 | if ( result == 0 ) { |
1276 | mView->importBday(); | 1282 | mView->importBday(); |
1277 | 1283 | ||
1278 | } | 1284 | } |
1279 | 1285 | ||
1280 | 1286 | ||
1281 | } | 1287 | } |
1282 | void MainWindow::importQtopia() | 1288 | void MainWindow::importQtopia() |
1283 | { | 1289 | { |
1284 | #ifndef DESKTOP_VERSION | 1290 | #ifndef DESKTOP_VERSION |
1285 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1291 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1286 | 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"), | 1292 | 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"), |
1287 | i18n("Import!"), i18n("Cancel"), 0, | 1293 | i18n("Import!"), i18n("Cancel"), 0, |
1288 | 0, 1 ); | 1294 | 0, 1 ); |
1289 | if ( result == 0 ) { | 1295 | if ( result == 0 ) { |
1290 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); | 1296 | QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); |
1291 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); | 1297 | QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); |
1292 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; | 1298 | QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; |
1293 | mView->importQtopia( categories, datebook, todolist ); | 1299 | mView->importQtopia( categories, datebook, todolist ); |
1294 | } | 1300 | } |
1295 | #else | 1301 | #else |
1296 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1302 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1297 | i18n("Not supported \non desktop!\n"), | 1303 | i18n("Not supported \non desktop!\n"), |
1298 | i18n("Ok"), i18n("Cancel"), 0, | 1304 | i18n("Ok"), i18n("Cancel"), 0, |
1299 | 0, 1 ); | 1305 | 0, 1 ); |
1300 | 1306 | ||
1301 | #endif | 1307 | #endif |
1302 | } | 1308 | } |
1303 | 1309 | ||
1304 | void MainWindow::saveOnClose() | 1310 | void MainWindow::saveOnClose() |
1305 | { | 1311 | { |
1306 | KOPrefs *p = KOPrefs::instance(); | 1312 | KOPrefs *p = KOPrefs::instance(); |
1307 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); | 1313 | p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); |
1308 | p->mToolBarUp = iconToolBar->x() > width()/2 || | 1314 | p->mToolBarUp = iconToolBar->x() > width()/2 || |
1309 | iconToolBar->y() > height()/2; | 1315 | iconToolBar->y() > height()/2; |
1310 | mView->writeSettings(); | 1316 | mView->writeSettings(); |
1311 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) | 1317 | if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) |
1312 | save(); | 1318 | save(); |
1313 | } | 1319 | } |
1314 | void MainWindow::slotModifiedChanged( bool changed ) | 1320 | void MainWindow::slotModifiedChanged( bool changed ) |
1315 | { | 1321 | { |
1316 | if ( mBlockAtStartup ) | 1322 | if ( mBlockAtStartup ) |
1317 | return; | 1323 | return; |
1318 | int msec; | 1324 | int msec; |
1319 | // we store the changes after 1 minute, | 1325 | // we store the changes after 1 minute, |
1320 | // and for safety reasons after 10 minutes again | 1326 | // and for safety reasons after 10 minutes again |
1321 | if ( !mBlockSaveFlag ) | 1327 | if ( !mBlockSaveFlag ) |
1322 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; | 1328 | msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; |
1323 | else | 1329 | else |
1324 | msec = 1000 * 600; | 1330 | msec = 1000 * 600; |
1325 | mSaveTimer.start( msec, true ); // 1 minute | 1331 | mSaveTimer.start( msec, true ); // 1 minute |
1326 | qDebug("KO: Saving File in %d secs!", msec/1000); | 1332 | qDebug("KO: Saving File in %d secs!", msec/1000); |
1327 | mCalendarModifiedFlag = true; | 1333 | mCalendarModifiedFlag = true; |
1328 | } | 1334 | } |
1329 | #include <qfileinfo.h> | 1335 | #include <qfileinfo.h> |
1330 | void MainWindow::save() | 1336 | void MainWindow::save() |
1331 | { | 1337 | { |
1332 | if ( mBlockSaveFlag ) | 1338 | if ( mBlockSaveFlag ) |
1333 | return; | 1339 | return; |
1334 | bool store = mBlockSaveFlag; | 1340 | bool store = mBlockSaveFlag; |
1335 | mBlockSaveFlag = true; | 1341 | mBlockSaveFlag = true; |
1336 | if ( mView->checkFileVersion( defaultFileName()) ) { | 1342 | if ( mView->checkFileVersion( defaultFileName()) ) { |
1337 | 1343 | ||
1338 | QTime neededSaveTime = QDateTime::currentDateTime().time(); | 1344 | QTime neededSaveTime = QDateTime::currentDateTime().time(); |
1339 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); | 1345 | setCaption(i18n("KO/Pi:Saving Data to File ..." )); |
1340 | qDebug("KO: Start saving data to file!"); | 1346 | qDebug("KO: Start saving data to file!"); |
1341 | mView->saveCalendar( defaultFileName() ); | 1347 | mView->saveCalendar( defaultFileName() ); |
1342 | 1348 | ||
1343 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); | 1349 | int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); |
1344 | mView->setLoadedFileVersion(QDateTime::currentDateTime()); | 1350 | mView->setLoadedFileVersion(QDateTime::currentDateTime()); |
1345 | qDebug("KO: Needed %d ms for saving.",msNeeded ); | 1351 | qDebug("KO: Needed %d ms for saving.",msNeeded ); |
1346 | QString savemes; | 1352 | QString savemes; |
1347 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); | 1353 | savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); |
1348 | setCaption(savemes); | 1354 | setCaption(savemes); |
1349 | } else | 1355 | } else |
1350 | setCaption(i18n("Saving cancelled!")); | 1356 | setCaption(i18n("Saving cancelled!")); |
1351 | mCalendarModifiedFlag = false; | 1357 | mCalendarModifiedFlag = false; |
1352 | mBlockSaveFlag = store; | 1358 | mBlockSaveFlag = store; |
1353 | } | 1359 | } |
1354 | 1360 | ||
1355 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) | 1361 | void MainWindow::keyReleaseEvent ( QKeyEvent * e) |
1356 | { | 1362 | { |
1357 | if ( !e->isAutoRepeat() ) { | 1363 | if ( !e->isAutoRepeat() ) { |
1358 | mFlagKeyPressed = false; | 1364 | mFlagKeyPressed = false; |
1359 | } | 1365 | } |
1360 | } | 1366 | } |
1361 | void MainWindow::keyPressEvent ( QKeyEvent * e ) | 1367 | void MainWindow::keyPressEvent ( QKeyEvent * e ) |
1362 | { | 1368 | { |
1363 | qApp->processEvents(); | 1369 | qApp->processEvents(); |
1364 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 1370 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
1365 | e->ignore(); | 1371 | e->ignore(); |
1366 | // qDebug(" ignore %d",e->isAutoRepeat() ); | 1372 | // qDebug(" ignore %d",e->isAutoRepeat() ); |
1367 | return; | 1373 | return; |
1368 | } | 1374 | } |
1369 | if (! e->isAutoRepeat() ) | 1375 | if (! e->isAutoRepeat() ) |
1370 | mFlagKeyPressed = true; | 1376 | mFlagKeyPressed = true; |
1371 | KOPrefs *p = KOPrefs::instance(); | 1377 | KOPrefs *p = KOPrefs::instance(); |
1372 | bool showSelectedDates = false; | 1378 | bool showSelectedDates = false; |
1373 | int size; | 1379 | int size; |
1374 | int pro = 0; | 1380 | int pro = 0; |
1375 | //qDebug("MainWindow::keyPressEvent "); | 1381 | //qDebug("MainWindow::keyPressEvent "); |
1376 | switch ( e->key() ) { | 1382 | switch ( e->key() ) { |
1377 | case Qt::Key_Right: | 1383 | case Qt::Key_Right: |
1378 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1384 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1379 | mView->goNextMonth(); | 1385 | mView->goNextMonth(); |
1380 | else | 1386 | else |
1381 | mView->goNext(); | 1387 | mView->goNext(); |
1382 | showSelectedDates = true; | 1388 | showSelectedDates = true; |
1383 | break; | 1389 | break; |
1384 | case Qt::Key_Left: | 1390 | case Qt::Key_Left: |
1385 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1391 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1386 | mView->goPreviousMonth(); | 1392 | mView->goPreviousMonth(); |
1387 | else | 1393 | else |
1388 | mView->goPrevious(); | 1394 | mView->goPrevious(); |
1389 | showSelectedDates = true; | 1395 | showSelectedDates = true; |
1390 | break; | 1396 | break; |
1391 | case Qt::Key_Down: | 1397 | case Qt::Key_Down: |
1392 | mView->viewManager()->agendaView()->scrollOneHourDown(); | 1398 | mView->viewManager()->agendaView()->scrollOneHourDown(); |
1393 | break; | 1399 | break; |
1394 | case Qt::Key_Up: | 1400 | case Qt::Key_Up: |
1395 | mView->viewManager()->agendaView()->scrollOneHourUp(); | 1401 | mView->viewManager()->agendaView()->scrollOneHourUp(); |
1396 | break; | 1402 | break; |
1397 | case Qt::Key_I: | 1403 | case Qt::Key_I: |
1398 | mView->showIncidence(); | 1404 | mView->showIncidence(); |
1399 | break; | 1405 | break; |
1400 | case Qt::Key_Delete: | 1406 | case Qt::Key_Delete: |
1401 | case Qt::Key_Backspace: | 1407 | case Qt::Key_Backspace: |
1402 | mView->deleteIncidence(); | 1408 | mView->deleteIncidence(); |
1403 | break; | 1409 | break; |
1404 | case Qt::Key_D: | 1410 | case Qt::Key_D: |
1405 | mView->viewManager()->showDayView(); | 1411 | mView->viewManager()->showDayView(); |
1406 | showSelectedDates = true; | 1412 | showSelectedDates = true; |
1407 | break; | 1413 | break; |
1408 | case Qt::Key_O: | 1414 | case Qt::Key_O: |
1409 | mView->toggleFilerEnabled( ); | 1415 | mView->toggleFilerEnabled( ); |
1410 | break; | 1416 | break; |
1411 | case Qt::Key_0: | 1417 | case Qt::Key_0: |
1412 | case Qt::Key_1: | 1418 | case Qt::Key_1: |
1413 | case Qt::Key_2: | 1419 | case Qt::Key_2: |
1414 | case Qt::Key_3: | 1420 | case Qt::Key_3: |
1415 | case Qt::Key_4: | 1421 | case Qt::Key_4: |
1416 | case Qt::Key_5: | 1422 | case Qt::Key_5: |
1417 | case Qt::Key_6: | 1423 | case Qt::Key_6: |
1418 | case Qt::Key_7: | 1424 | case Qt::Key_7: |
1419 | case Qt::Key_8: | 1425 | case Qt::Key_8: |
1420 | case Qt::Key_9: | 1426 | case Qt::Key_9: |
1421 | pro = e->key()-48; | 1427 | pro = e->key()-48; |
1422 | if ( pro == 0 ) | 1428 | if ( pro == 0 ) |
1423 | pro = 10; | 1429 | pro = 10; |
1424 | if ( e->state() == Qt::ControlButton) | 1430 | if ( e->state() == Qt::ControlButton) |
1425 | pro += 10; | 1431 | pro += 10; |
1426 | break; | 1432 | break; |
1427 | case Qt::Key_M: | 1433 | case Qt::Key_M: |
1428 | mView->viewManager()->showMonthView(); | 1434 | mView->viewManager()->showMonthView(); |
1429 | showSelectedDates = true; | 1435 | showSelectedDates = true; |
1430 | break; | 1436 | break; |
1431 | case Qt::Key_Insert: | 1437 | case Qt::Key_Insert: |
1432 | mView->newEvent(); | 1438 | mView->newEvent(); |
1433 | break; | 1439 | break; |
1434 | case Qt::Key_S : | 1440 | case Qt::Key_S : |
1435 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) | 1441 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) |
1436 | mView->newSubTodo(); | 1442 | mView->newSubTodo(); |
1437 | else | 1443 | else |
1438 | mView->dialogManager()->showSearchDialog(); | 1444 | mView->dialogManager()->showSearchDialog(); |
1439 | break; | 1445 | break; |
1440 | case Qt::Key_Y : | 1446 | case Qt::Key_Y : |
1441 | case Qt::Key_Z : | 1447 | case Qt::Key_Z : |
1442 | mView->viewManager()->showWorkWeekView(); | 1448 | mView->viewManager()->showWorkWeekView(); |
1443 | showSelectedDates = true; | 1449 | showSelectedDates = true; |
1444 | break; | 1450 | break; |
1445 | case Qt::Key_U : | 1451 | case Qt::Key_U : |
1446 | mView->viewManager()->showWeekView(); | 1452 | mView->viewManager()->showWeekView(); |
1447 | showSelectedDates = true; | 1453 | showSelectedDates = true; |
1448 | break; | 1454 | break; |
1449 | case Qt::Key_H : | 1455 | case Qt::Key_H : |
1450 | keyBindings(); | 1456 | keyBindings(); |
1451 | break; | 1457 | break; |
1452 | case Qt::Key_W: | 1458 | case Qt::Key_W: |
1453 | mView->viewManager()->showWhatsNextView(); | 1459 | mView->viewManager()->showWhatsNextView(); |
1454 | break; | 1460 | break; |
1455 | case Qt::Key_L: | 1461 | case Qt::Key_L: |
1456 | mView->viewManager()->showListView(); | 1462 | mView->viewManager()->showListView(); |
1457 | break; | 1463 | break; |
1458 | case Qt::Key_N: | 1464 | case Qt::Key_N: |
1459 | mView->viewManager()->showNextXView(); | 1465 | mView->viewManager()->showNextXView(); |
1460 | showSelectedDates = true; | 1466 | showSelectedDates = true; |
1461 | break; | 1467 | break; |
1462 | case Qt::Key_V: | 1468 | case Qt::Key_V: |
1463 | mView->viewManager()->showTodoView(); | 1469 | mView->viewManager()->showTodoView(); |
1464 | break; | 1470 | break; |
1465 | case Qt::Key_C: | 1471 | case Qt::Key_C: |
1466 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); | 1472 | mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); |
1467 | break; | 1473 | break; |
1468 | case Qt::Key_P: | 1474 | case Qt::Key_P: |
1469 | mView->showDatePicker( ); | 1475 | mView->showDatePicker( ); |
1470 | break; | 1476 | break; |
1471 | case Qt::Key_F: | 1477 | case Qt::Key_F: |
1472 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1478 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1473 | mView->editFilters(); | 1479 | mView->editFilters(); |
1474 | else | 1480 | else |
1475 | mView->toggleFilter(); | 1481 | mView->toggleFilter(); |
1476 | break; | 1482 | break; |
1477 | case Qt::Key_X: | 1483 | case Qt::Key_X: |
1478 | mView->toggleDateNavigatorWidget(); | 1484 | mView->toggleDateNavigatorWidget(); |
1479 | break; | 1485 | break; |
1480 | case Qt::Key_Space: | 1486 | case Qt::Key_Space: |
1481 | mView->toggleExpand(); | 1487 | mView->toggleExpand(); |
1482 | break; | 1488 | break; |
1483 | case Qt::Key_A: | 1489 | case Qt::Key_A: |
1484 | mView->toggleAllDaySize(); | 1490 | mView->toggleAllDaySize(); |
1485 | break; | 1491 | break; |
1486 | case Qt::Key_T: | 1492 | case Qt::Key_T: |
1487 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1493 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1488 | mView->newTodo(); | 1494 | mView->newTodo(); |
1489 | else { | 1495 | else { |
1490 | mView->goToday(); | 1496 | mView->goToday(); |
1491 | showSelectedDates = true; | 1497 | showSelectedDates = true; |
1492 | } | 1498 | } |
1493 | break; | 1499 | break; |
1494 | case Qt::Key_J: | 1500 | case Qt::Key_J: |
1495 | mView->viewManager()->showJournalView(); | 1501 | mView->viewManager()->showJournalView(); |
1496 | break; | 1502 | break; |
1497 | case Qt::Key_B: | 1503 | case Qt::Key_B: |
1498 | mView->editIncidenceDescription();; | 1504 | mView->editIncidenceDescription();; |
1499 | break; | 1505 | break; |
1500 | // case Qt::Key_Return: | 1506 | // case Qt::Key_Return: |
1501 | case Qt::Key_E: | 1507 | case Qt::Key_E: |
1502 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 1508 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
1503 | mView->newEvent(); | 1509 | mView->newEvent(); |
1504 | else | 1510 | else |
1505 | mView->editIncidence(); | 1511 | mView->editIncidence(); |
1506 | break; | 1512 | break; |
1507 | case Qt::Key_Plus: | 1513 | case Qt::Key_Plus: |
1508 | size = p->mHourSize +2; | 1514 | size = p->mHourSize +2; |
1509 | if ( size <= 18 ) | 1515 | if ( size <= 18 ) |
1510 | configureAgenda( size ); | 1516 | configureAgenda( size ); |
1511 | break; | 1517 | break; |
1512 | case Qt::Key_Minus: | 1518 | case Qt::Key_Minus: |
1513 | size = p->mHourSize - 2; | 1519 | size = p->mHourSize - 2; |
1514 | if ( size >= 4 ) | 1520 | if ( size >= 4 ) |
1515 | configureAgenda( size ); | 1521 | configureAgenda( size ); |
1516 | break; | 1522 | break; |
1517 | 1523 | ||
1518 | 1524 | ||
1519 | default: | 1525 | default: |
1520 | e->ignore(); | 1526 | e->ignore(); |
1521 | } | 1527 | } |
1522 | if ( pro > 0 ) { | 1528 | if ( pro > 0 ) { |
1523 | mView->selectFilter( pro-1 ); | 1529 | mView->selectFilter( pro-1 ); |
1524 | } | 1530 | } |
1525 | if ( showSelectedDates ) { | 1531 | if ( showSelectedDates ) { |
1526 | ;// setCaptionToDates(); | 1532 | ;// setCaptionToDates(); |
1527 | } | 1533 | } |
1528 | 1534 | ||
1529 | } | 1535 | } |
1530 | 1536 | ||
1531 | void MainWindow::fillFilterMenu() | 1537 | void MainWindow::fillFilterMenu() |
1532 | { | 1538 | { |
1533 | selectFilterMenu->clear(); | 1539 | selectFilterMenu->clear(); |
1534 | bool disable = false; | 1540 | bool disable = false; |
1535 | if ( mView->filterView()->filtersEnabled() ) { | 1541 | if ( mView->filterView()->filtersEnabled() ) { |
1536 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); | 1542 | selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); |
1537 | } | 1543 | } |
1538 | else { | 1544 | else { |
1539 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); | 1545 | selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); |
1540 | disable = true; | 1546 | disable = true; |
1541 | } | 1547 | } |
1542 | selectFilterMenu->insertSeparator(); | 1548 | selectFilterMenu->insertSeparator(); |
1543 | QPtrList<CalFilter> fili = mView->filters(); | 1549 | QPtrList<CalFilter> fili = mView->filters(); |
1544 | CalFilter *curfilter = mView->filterView()->selectedFilter(); | 1550 | CalFilter *curfilter = mView->filterView()->selectedFilter(); |
1545 | CalFilter *filter = fili.first(); | 1551 | CalFilter *filter = fili.first(); |
1546 | int iii = 1; | 1552 | int iii = 1; |
1547 | while(filter) { | 1553 | while(filter) { |
1548 | selectFilterMenu->insertItem( filter->name(), iii ); | 1554 | selectFilterMenu->insertItem( filter->name(), iii ); |
1549 | if ( filter == curfilter) | 1555 | if ( filter == curfilter) |
1550 | selectFilterMenu->setItemChecked( iii, true ); | 1556 | selectFilterMenu->setItemChecked( iii, true ); |
1551 | if ( disable ) | 1557 | if ( disable ) |
1552 | selectFilterMenu->setItemEnabled( iii, false ); | 1558 | selectFilterMenu->setItemEnabled( iii, false ); |
1553 | filter = fili.next(); | 1559 | filter = fili.next(); |
1554 | ++iii; | 1560 | ++iii; |
1555 | } | 1561 | } |
1556 | } | 1562 | } |
1557 | void MainWindow::selectFilter( int fil ) | 1563 | void MainWindow::selectFilter( int fil ) |
1558 | { | 1564 | { |
1559 | if ( fil == 0 ) { | 1565 | if ( fil == 0 ) { |
1560 | mView->toggleFilerEnabled( ); | 1566 | mView->toggleFilerEnabled( ); |
1561 | } else { | 1567 | } else { |
1562 | mView->selectFilter( fil-1 ); | 1568 | mView->selectFilter( fil-1 ); |
1563 | } | 1569 | } |
1564 | } | 1570 | } |
1565 | void MainWindow::configureToolBar( int item ) | 1571 | void MainWindow::configureToolBar( int item ) |
1566 | { | 1572 | { |
1567 | 1573 | ||
1568 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); | 1574 | configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); |
1569 | KOPrefs *p = KOPrefs::instance(); | 1575 | KOPrefs *p = KOPrefs::instance(); |
1570 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); | 1576 | p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); |
1571 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); | 1577 | p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); |
1572 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); | 1578 | p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); |
1573 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); | 1579 | p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); |
1574 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); | 1580 | p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); |
1575 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); | 1581 | p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); |
1576 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); | 1582 | p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); |
1577 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); | 1583 | p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); |
1578 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); | 1584 | p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); |
1579 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); | 1585 | p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); |
1580 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); | 1586 | p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); |
1581 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); | 1587 | p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); |
1582 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); | 1588 | p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); |
1583 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); | 1589 | p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); |
1584 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); | 1590 | p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); |
1585 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); | 1591 | p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); |
1586 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); | 1592 | p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); |
1587 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); | 1593 | p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); |
1588 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); | 1594 | p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); |
1589 | // initActions(); | 1595 | // initActions(); |
1590 | } | 1596 | } |
1591 | 1597 | ||
1592 | void MainWindow::setCaptionToDates() | 1598 | void MainWindow::setCaptionToDates() |
1593 | { | 1599 | { |
1594 | QString selDates; | 1600 | QString selDates; |
1595 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); | 1601 | selDates = KGlobal::locale()->formatDate(mView->startDate(), true); |
1596 | if (mView->startDate() < mView->endDate() ) | 1602 | if (mView->startDate() < mView->endDate() ) |
1597 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); | 1603 | selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); |
1598 | setCaption( i18n("Dates: ") + selDates ); | 1604 | setCaption( i18n("Dates: ") + selDates ); |
1599 | 1605 | ||
1600 | } | 1606 | } |
1601 | // parameter item == 0: reinit | 1607 | // parameter item == 0: reinit |
1602 | void MainWindow::configureAgenda( int item ) | 1608 | void MainWindow::configureAgenda( int item ) |
1603 | { | 1609 | { |
1604 | 1610 | ||
1605 | KOPrefs *p = KOPrefs::instance(); | 1611 | KOPrefs *p = KOPrefs::instance(); |
1606 | 1612 | ||
1607 | int i; | 1613 | int i; |
1608 | if ( item == 1 ) { | 1614 | if ( item == 1 ) { |
1609 | mView->toggleAllDaySize(); | 1615 | mView->toggleAllDaySize(); |
1610 | return; | 1616 | return; |
1611 | } | 1617 | } |
1612 | // do not allow 4 for widgets higher than 480 | 1618 | // do not allow 4 for widgets higher than 480 |
1613 | // if ( QApplication::desktop()->height() > 480 ) { | 1619 | // if ( QApplication::desktop()->height() > 480 ) { |
1614 | // if ( item == 4 ) | 1620 | // if ( item == 4 ) |
1615 | // item = 6; | 1621 | // item = 6; |
1616 | // } | 1622 | // } |
1617 | for ( i = 4; i <= 18; i= i+2 ) | 1623 | for ( i = 4; i <= 18; i= i+2 ) |
1618 | configureAgendaMenu->setItemChecked( i, false ); | 1624 | configureAgendaMenu->setItemChecked( i, false ); |
1619 | configureAgendaMenu->setItemChecked( item, true ); | 1625 | configureAgendaMenu->setItemChecked( item, true ); |
1620 | if ( p->mHourSize == item ) | 1626 | if ( p->mHourSize == item ) |
1621 | return; | 1627 | return; |
1622 | p->mHourSize=item; | 1628 | p->mHourSize=item; |
1623 | mView->viewManager()->agendaView()->updateConfig(); | 1629 | mView->viewManager()->agendaView()->updateConfig(); |
1624 | } | 1630 | } |
1625 | 1631 | ||
1626 | void MainWindow::saveCalendar() | 1632 | void MainWindow::saveCalendar() |
1627 | { | 1633 | { |
1628 | QString fn = KOPrefs::instance()->mLastSaveFile; | 1634 | QString fn = KOPrefs::instance()->mLastSaveFile; |
1629 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); | 1635 | fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); |
1630 | 1636 | ||
1631 | if ( fn == "" ) | 1637 | if ( fn == "" ) |
1632 | return; | 1638 | return; |
1633 | QFileInfo info; | 1639 | QFileInfo info; |
1634 | info.setFile( fn ); | 1640 | info.setFile( fn ); |
1635 | QString mes; | 1641 | QString mes; |
1636 | bool createbup = true; | 1642 | bool createbup = true; |
1637 | if ( info. exists() ) { | 1643 | if ( info. exists() ) { |
1638 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; | 1644 | mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; |
1639 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1645 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1640 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1646 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1641 | 0, 1 ); | 1647 | 0, 1 ); |
1642 | if ( result != 0 ) { | 1648 | if ( result != 0 ) { |
1643 | createbup = false; | 1649 | createbup = false; |
1644 | } | 1650 | } |
1645 | } | 1651 | } |
1646 | if ( createbup ) { | 1652 | if ( createbup ) { |
1647 | mView->saveCalendar( fn ); | 1653 | mView->saveCalendar( fn ); |
1648 | mes = i18n("KO/Pi:Saved %1").arg(fn); | 1654 | mes = i18n("KO/Pi:Saved %1").arg(fn); |
1649 | KOPrefs::instance()->mLastSaveFile = fn; | 1655 | KOPrefs::instance()->mLastSaveFile = fn; |
1650 | setCaption(mes); | 1656 | setCaption(mes); |
1651 | } | 1657 | } |
1652 | } | 1658 | } |
1653 | void MainWindow::loadCalendar() | 1659 | void MainWindow::loadCalendar() |
1654 | { | 1660 | { |
1655 | 1661 | ||
1656 | QString fn = KOPrefs::instance()->mLastLoadFile; | 1662 | QString fn = KOPrefs::instance()->mLastLoadFile; |
1657 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); | 1663 | fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); |
1658 | 1664 | ||
1659 | if ( fn == "" ) | 1665 | if ( fn == "" ) |
1660 | return; | 1666 | return; |
1661 | QFileInfo info; | 1667 | QFileInfo info; |
1662 | info.setFile( fn ); | 1668 | info.setFile( fn ); |
1663 | QString mess; | 1669 | QString mess; |
1664 | bool loadbup = true; | 1670 | bool loadbup = true; |
1665 | if ( info. exists() ) { | 1671 | if ( info. exists() ) { |
1666 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); | 1672 | mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); |
1667 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1673 | int result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1668 | mess, | 1674 | mess, |
1669 | i18n("Load!"), i18n("Cancel"), 0, | 1675 | i18n("Load!"), i18n("Cancel"), 0, |
1670 | 0, 1 ); | 1676 | 0, 1 ); |
1671 | if ( result != 0 ) { | 1677 | if ( result != 0 ) { |
1672 | loadbup = false; | 1678 | loadbup = false; |
1673 | } | 1679 | } |
1674 | } else { | 1680 | } else { |
1675 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1681 | QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1676 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, | 1682 | i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, |
1677 | 0, 1 ); | 1683 | 0, 1 ); |
1678 | 1684 | ||
1679 | return; | 1685 | return; |
1680 | } | 1686 | } |
1681 | if ( loadbup ) { | 1687 | if ( loadbup ) { |
1682 | mView->openCalendar( fn ); | 1688 | mView->openCalendar( fn ); |
1683 | KOPrefs::instance()->mLastLoadFile = fn; | 1689 | KOPrefs::instance()->mLastLoadFile = fn; |
1684 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; | 1690 | mess = i18n("KO/Pi:Loaded %1").arg(fn) ; |
1685 | setCaption(mess); | 1691 | setCaption(mess); |
1686 | } | 1692 | } |
1687 | 1693 | ||
1688 | } | 1694 | } |
1689 | void MainWindow::quickImportIcal() | 1695 | void MainWindow::quickImportIcal() |
1690 | { | 1696 | { |
1691 | importFile( KOPrefs::instance()->mLastImportFile, false ); | 1697 | importFile( KOPrefs::instance()->mLastImportFile, false ); |
1692 | } | 1698 | } |
1693 | void MainWindow::importFile( QString fn, bool quick ) | 1699 | void MainWindow::importFile( QString fn, bool quick ) |
1694 | { | 1700 | { |
1695 | QFileInfo info; | 1701 | QFileInfo info; |
1696 | info.setFile( fn ); | 1702 | info.setFile( fn ); |
1697 | QString mess; | 1703 | QString mess; |
1698 | bool loadbup = true; | 1704 | bool loadbup = true; |
1699 | if ( !info. exists() ) { | 1705 | if ( !info. exists() ) { |
1700 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); | 1706 | mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); |
1701 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1707 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1702 | mess ); | 1708 | mess ); |
1703 | return; | 1709 | return; |
1704 | } | 1710 | } |
1705 | int result = 0; | 1711 | int result = 0; |
1706 | if ( !quick ) { | 1712 | if ( !quick ) { |
1707 | 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 )); | 1713 | 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 )); |
1708 | result = QMessageBox::warning( this, "KO/Pi: Warning!", | 1714 | result = QMessageBox::warning( this, "KO/Pi: Warning!", |
1709 | mess, | 1715 | mess, |
1710 | "Import", "Cancel", 0, | 1716 | "Import", "Cancel", 0, |
1711 | 0, 1 ); | 1717 | 0, 1 ); |
1712 | } | 1718 | } |
1713 | if ( result == 0 ) { | 1719 | if ( result == 0 ) { |
1714 | if ( mView->openCalendar( fn, true )) { | 1720 | if ( mView->openCalendar( fn, true )) { |
1715 | KOPrefs::instance()->mLastImportFile = fn; | 1721 | KOPrefs::instance()->mLastImportFile = fn; |
1716 | setCaption(i18n("Imported file successfully")); | 1722 | setCaption(i18n("Imported file successfully")); |
1717 | } else { | 1723 | } else { |
1718 | setCaption(i18n("Error importing file")); | 1724 | setCaption(i18n("Error importing file")); |
1719 | } | 1725 | } |
1720 | } | 1726 | } |
1721 | } | 1727 | } |
1722 | 1728 | ||
1723 | void MainWindow::importIcal() | 1729 | void MainWindow::importIcal() |
1724 | { | 1730 | { |
1725 | 1731 | ||
1726 | QString fn =KOPrefs::instance()->mLastImportFile; | 1732 | QString fn =KOPrefs::instance()->mLastImportFile; |
1727 | 1733 | ||
1728 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); | 1734 | fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); |
1729 | if ( fn == "" ) | 1735 | if ( fn == "" ) |
1730 | return; | 1736 | return; |
1731 | importFile( fn, true ); | 1737 | importFile( fn, true ); |
1732 | 1738 | ||
1733 | } | 1739 | } |
1734 | 1740 | ||
1735 | void MainWindow::exportVCalendar() | 1741 | void MainWindow::exportVCalendar() |
1736 | { | 1742 | { |
1737 | QString fn = KOPrefs::instance()->mLastVcalFile; | 1743 | QString fn = KOPrefs::instance()->mLastVcalFile; |
1738 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); | 1744 | fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); |
1739 | if ( fn == "" ) | 1745 | if ( fn == "" ) |
1740 | return; | 1746 | return; |
1741 | QFileInfo info; | 1747 | QFileInfo info; |
1742 | info.setFile( fn ); | 1748 | info.setFile( fn ); |
1743 | QString mes; | 1749 | QString mes; |
1744 | bool createbup = true; | 1750 | bool createbup = true; |
1745 | if ( info. exists() ) { | 1751 | if ( info. exists() ) { |
1746 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 1752 | mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
1747 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 1753 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
1748 | i18n("Overwrite!"), i18n("Cancel"), 0, | 1754 | i18n("Overwrite!"), i18n("Cancel"), 0, |
1749 | 0, 1 ); | 1755 | 0, 1 ); |
1750 | if ( result != 0 ) { | 1756 | if ( result != 0 ) { |
1751 | createbup = false; | 1757 | createbup = false; |
1752 | } | 1758 | } |
1753 | } | 1759 | } |
1754 | if ( createbup ) { | 1760 | if ( createbup ) { |
1755 | if ( mView->exportVCalendar( fn ) ) { | 1761 | if ( mView->exportVCalendar( fn ) ) { |
1756 | KOPrefs::instance()->mLastVcalFile = fn; | 1762 | KOPrefs::instance()->mLastVcalFile = fn; |
1757 | if ( fn.length() > 20 ) | 1763 | if ( fn.length() > 20 ) |
1758 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; | 1764 | mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; |
1759 | else | 1765 | else |
1760 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); | 1766 | mes = i18n("KO/Pi:Exported to %1").arg(fn ); |
1761 | setCaption(mes); | 1767 | setCaption(mes); |
1762 | } | 1768 | } |
1763 | } | 1769 | } |
1764 | 1770 | ||
1765 | } | 1771 | } |
1766 | #include <qpushbutton.h> | 1772 | #include <qpushbutton.h> |
1767 | QString MainWindow::getPassword( ) | 1773 | QString MainWindow::getPassword( ) |
1768 | { | 1774 | { |
1769 | QString retfile = ""; | 1775 | QString retfile = ""; |
1770 | QDialog dia ( this, "input-dialog", true ); | 1776 | QDialog dia ( this, "input-dialog", true ); |
1771 | QLineEdit lab ( &dia ); | 1777 | QLineEdit lab ( &dia ); |
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro index 283a22d..f5be980 100644 --- a/libkcal/libkcalE.pro +++ b/libkcal/libkcalE.pro | |||
@@ -1,87 +1,89 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on | 2 | CONFIG += qt warn_on |
3 | TARGET = microkcal | 3 | TARGET = microkcal |
4 | 4 | ||
5 | INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include | 5 | INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include |
6 | INCLUDEPATH += ../libical/src/libical | 6 | INCLUDEPATH += ../libical/src/libical |
7 | INCLUDEPATH += ../libical/src/libicalss | 7 | INCLUDEPATH += ../libical/src/libicalss |
8 | OBJECTS_DIR = obj/$(PLATFORM) | 8 | OBJECTS_DIR = obj/$(PLATFORM) |
9 | MOC_DIR = moc/$(PLATFORM) | 9 | MOC_DIR = moc/$(PLATFORM) |
10 | DESTDIR = $(QPEDIR)/lib | 10 | DESTDIR = $(QPEDIR)/lib |
11 | LIBS += ../libical/lib/$(PLATFORM)/libical.a | 11 | LIBS += ../libical/lib/$(PLATFORM)/libical.a |
12 | LIBS += ../libical/lib/$(PLATFORM)/libicalss.a | 12 | LIBS += ../libical/lib/$(PLATFORM)/libicalss.a |
13 | 13 | ||
14 | INTERFACES = \ | 14 | INTERFACES = \ |
15 | 15 | ||
16 | HEADERS = \ | 16 | HEADERS = \ |
17 | alarm.h \ | 17 | alarm.h \ |
18 | attachment.h \ | 18 | attachment.h \ |
19 | attendee.h \ | 19 | attendee.h \ |
20 | calendar.h \ | 20 | calendar.h \ |
21 | calendarlocal.h \ | 21 | calendarlocal.h \ |
22 | calfilter.h \ | 22 | calfilter.h \ |
23 | calformat.h \ | 23 | calformat.h \ |
24 | calstorage.h \ | 24 | calstorage.h \ |
25 | compat.h \ | 25 | compat.h \ |
26 | customproperties.h \ | 26 | customproperties.h \ |
27 | dummyscheduler.h \ | 27 | dummyscheduler.h \ |
28 | duration.h \ | 28 | duration.h \ |
29 | event.h \ | 29 | event.h \ |
30 | exceptions.h \ | 30 | exceptions.h \ |
31 | filestorage.h \ | 31 | filestorage.h \ |
32 | freebusy.h \ | 32 | freebusy.h \ |
33 | icaldrag.h \ | 33 | icaldrag.h \ |
34 | icalformat.h \ | 34 | icalformat.h \ |
35 | icalformatimpl.h \ | 35 | icalformatimpl.h \ |
36 | imipscheduler.h \ | 36 | imipscheduler.h \ |
37 | incidence.h \ | 37 | incidence.h \ |
38 | incidencebase.h \ | 38 | incidencebase.h \ |
39 | journal.h \ | 39 | journal.h \ |
40 | period.h \ | 40 | period.h \ |
41 | person.h \ | 41 | person.h \ |
42 | qtopiaformat.h \ | 42 | qtopiaformat.h \ |
43 | sharpformat.h \ | 43 | sharpformat.h \ |
44 | phoneformat.h \ | ||
44 | recurrence.h \ | 45 | recurrence.h \ |
45 | scheduler.h \ | 46 | scheduler.h \ |
46 | todo.h \ | 47 | todo.h \ |
47 | vcaldrag.h \ | 48 | vcaldrag.h \ |
48 | vcalformat.h \ | 49 | vcalformat.h \ |
49 | versit/port.h \ | 50 | versit/port.h \ |
50 | versit/vcc.h \ | 51 | versit/vcc.h \ |
51 | versit/vobject.h \ | 52 | versit/vobject.h \ |
52 | 53 | ||
53 | SOURCES = \ | 54 | SOURCES = \ |
54 | alarm.cpp \ | 55 | alarm.cpp \ |
55 | attachment.cpp \ | 56 | attachment.cpp \ |
56 | attendee.cpp \ | 57 | attendee.cpp \ |
57 | calendar.cpp \ | 58 | calendar.cpp \ |
58 | calendarlocal.cpp \ | 59 | calendarlocal.cpp \ |
59 | calfilter.cpp \ | 60 | calfilter.cpp \ |
60 | calformat.cpp \ | 61 | calformat.cpp \ |
61 | compat.cpp \ | 62 | compat.cpp \ |
62 | customproperties.cpp \ | 63 | customproperties.cpp \ |
63 | dummyscheduler.cpp \ | 64 | dummyscheduler.cpp \ |
64 | duration.cpp \ | 65 | duration.cpp \ |
65 | event.cpp \ | 66 | event.cpp \ |
66 | exceptions.cpp \ | 67 | exceptions.cpp \ |
67 | filestorage.cpp \ | 68 | filestorage.cpp \ |
68 | freebusy.cpp \ | 69 | freebusy.cpp \ |
69 | icaldrag.cpp \ | 70 | icaldrag.cpp \ |
70 | icalformat.cpp \ | 71 | icalformat.cpp \ |
71 | icalformatimpl.cpp \ | 72 | icalformatimpl.cpp \ |
72 | imipscheduler.cpp \ | 73 | imipscheduler.cpp \ |
73 | incidence.cpp \ | 74 | incidence.cpp \ |
74 | incidencebase.cpp \ | 75 | incidencebase.cpp \ |
75 | journal.cpp \ | 76 | journal.cpp \ |
76 | period.cpp \ | 77 | period.cpp \ |
77 | person.cpp \ | 78 | person.cpp \ |
78 | qtopiaformat.cpp \ | 79 | qtopiaformat.cpp \ |
79 | sharpformat.cpp \ | 80 | sharpformat.cpp \ |
81 | phoneformat.cpp \ | ||
80 | recurrence.cpp \ | 82 | recurrence.cpp \ |
81 | scheduler.cpp \ | 83 | scheduler.cpp \ |
82 | todo.cpp \ | 84 | todo.cpp \ |
83 | vcaldrag.cpp \ | 85 | vcaldrag.cpp \ |
84 | vcalformat.cpp \ | 86 | vcalformat.cpp \ |
85 | versit/vcc.c \ | 87 | versit/vcc.c \ |
86 | versit/vobject.c \ | 88 | versit/vobject.c \ |
87 | 89 | ||
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp new file mode 100644 index 0000000..f78730d --- a/dev/null +++ b/libkcal/phoneformat.cpp | |||
@@ -0,0 +1,1359 @@ | |||
1 | /* | ||
2 | This file is part of libkcal. | ||
3 | |||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | ||
5 | |||
6 | This library is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU Library General Public | ||
8 | License as published by the Free Software Foundation; either | ||
9 | version 2 of the License, or (at your option) any later version. | ||
10 | |||
11 | This library is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | Library General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU Library General Public License | ||
17 | along with this library; see the file COPYING.LIB. If not, write to | ||
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | #include <qdatetime.h> | ||
23 | #include <qstring.h> | ||
24 | #include <qapplication.h> | ||
25 | #include <qptrlist.h> | ||
26 | #include <qregexp.h> | ||
27 | #include <qmessagebox.h> | ||
28 | #include <qclipboard.h> | ||
29 | #include <qfile.h> | ||
30 | #include <qtextstream.h> | ||
31 | #include <qtextcodec.h> | ||
32 | #include <qxml.h> | ||
33 | #include <qlabel.h> | ||
34 | |||
35 | #include <kdebug.h> | ||
36 | #include <klocale.h> | ||
37 | #include <kglobal.h> | ||
38 | |||
39 | #include "calendar.h" | ||
40 | #include "alarm.h" | ||
41 | #include "recurrence.h" | ||
42 | #include "calendarlocal.h" | ||
43 | |||
44 | #include "phoneformat.h" | ||
45 | |||
46 | using namespace KCal; | ||
47 | |||
48 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | ||
49 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ||
50 | |||
51 | //ARSD silentalarm = 0 | ||
52 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | ||
53 | // 12 RFRQ | ||
54 | // 13 RPOS pos = 4. monday in month | ||
55 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | ||
56 | // 15 REND 0 = no end/ 1 = end | ||
57 | // 16 REDT rec end dt | ||
58 | //ALSD | ||
59 | //ALED | ||
60 | //MDAY | ||
61 | |||
62 | class SharpParser : public QObject | ||
63 | { | ||
64 | public: | ||
65 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { | ||
66 | oldCategories = 0; | ||
67 | } | ||
68 | |||
69 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) | ||
70 | { | ||
71 | int i = 1; | ||
72 | bool skip = true; | ||
73 | int max = attList.count() -2; | ||
74 | while ( i < max ) { | ||
75 | if ( !attList[i].isEmpty() ) { | ||
76 | skip = false; | ||
77 | break; | ||
78 | } | ||
79 | ++i ; | ||
80 | } | ||
81 | if ( skip ) | ||
82 | return false; | ||
83 | ulong cSum = SharpFormat::getCsum(attList ); | ||
84 | |||
85 | if ( qName == "Event" ) { | ||
86 | Event *event; | ||
87 | event = existingCalendar->event( attList[0].toInt() ); | ||
88 | if ( event ) | ||
89 | event = (Event*)event->clone(); | ||
90 | else | ||
91 | event = new Event; | ||
92 | event->setZaurusId( attList[0].toInt() ); | ||
93 | event->setZaurusUid( cSum ); | ||
94 | event->setZaurusStat( -2 ); | ||
95 | |||
96 | event->setSummary( attList[2] ); | ||
97 | event->setLocation( attList[3] ); | ||
98 | event->setDescription( attList[4] ); | ||
99 | if ( attList[7] == "1" ) { | ||
100 | event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); | ||
101 | event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); | ||
102 | event->setFloats( true ); | ||
103 | } else { | ||
104 | event->setFloats( false ); | ||
105 | event->setDtStart( fromString( attList[5] ) ); | ||
106 | event->setDtEnd( fromString( attList[6] )); | ||
107 | } | ||
108 | |||
109 | QString rtype = attList[11]; | ||
110 | if ( rtype != "255" ) { | ||
111 | // qDebug("recurs "); | ||
112 | QDate startDate = event->dtStart().date(); | ||
113 | |||
114 | QString freqStr = attList[12]; | ||
115 | int freq = freqStr.toInt(); | ||
116 | |||
117 | QString hasEndDateStr = attList[15] ; | ||
118 | bool hasEndDate = hasEndDateStr == "1"; | ||
119 | |||
120 | QString endDateStr = attList[16]; | ||
121 | QDate endDate = fromString( endDateStr ).date(); | ||
122 | |||
123 | QString weekDaysStr = attList[14]; | ||
124 | uint weekDaysNum = weekDaysStr.toInt(); | ||
125 | |||
126 | QBitArray weekDays( 7 ); | ||
127 | int i; | ||
128 | int bb = 1; | ||
129 | for( i = 1; i <= 7; ++i ) { | ||
130 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | ||
131 | bb = 2 << (i-1); | ||
132 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | ||
133 | } | ||
134 | // qDebug("next "); | ||
135 | QString posStr = attList[13]; | ||
136 | int pos = posStr.toInt(); | ||
137 | Recurrence *r = event->recurrence(); | ||
138 | |||
139 | if ( rtype == "0" ) { | ||
140 | if ( hasEndDate ) r->setDaily( freq, endDate ); | ||
141 | else r->setDaily( freq, -1 ); | ||
142 | } else if ( rtype == "1" ) { | ||
143 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | ||
144 | else r->setWeekly( freq, weekDays, -1 ); | ||
145 | } else if ( rtype == "3" ) { | ||
146 | if ( hasEndDate ) | ||
147 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | ||
148 | else | ||
149 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | ||
150 | r->addMonthlyDay( startDate.day() ); | ||
151 | } else if ( rtype == "2" ) { | ||
152 | if ( hasEndDate ) | ||
153 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | ||
154 | else | ||
155 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | ||
156 | QBitArray days( 7 ); | ||
157 | days.fill( false ); | ||
158 | days.setBit( startDate.dayOfWeek() - 1 ); | ||
159 | r->addMonthlyPos( pos, days ); | ||
160 | } else if ( rtype == "4" ) { | ||
161 | if ( hasEndDate ) | ||
162 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | ||
163 | else | ||
164 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | ||
165 | r->addYearlyNum( startDate.month() ); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | QString categoryList = attList[1] ; | ||
170 | event->setCategories( lookupCategories( categoryList ) ); | ||
171 | |||
172 | // strange 0 semms to mean: alarm enabled | ||
173 | if ( attList[8] == "0" ) { | ||
174 | Alarm *alarm; | ||
175 | if ( event->alarms().count() > 0 ) | ||
176 | alarm = event->alarms().first(); | ||
177 | else { | ||
178 | alarm = new Alarm( event ); | ||
179 | event->addAlarm( alarm ); | ||
180 | } | ||
181 | alarm->setType( Alarm::Audio ); | ||
182 | alarm->setEnabled( true ); | ||
183 | int alarmOffset = attList[9].toInt(); | ||
184 | alarm->setStartOffset( alarmOffset * -60 ); | ||
185 | } | ||
186 | |||
187 | mCalendar->addEvent( event); | ||
188 | } else if ( qName == "Todo" ) { | ||
189 | Todo *todo; | ||
190 | |||
191 | todo = existingCalendar->todo( attList[0].toInt() ); | ||
192 | if (todo ) | ||
193 | todo = (Todo*)todo->clone(); | ||
194 | else | ||
195 | todo = new Todo; | ||
196 | |||
197 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | ||
198 | // 0 1 2 3 4 5 6 7 8 | ||
199 | //1,,,,,1,4,Loch zumachen,"" | ||
200 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | ||
201 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | ||
202 | |||
203 | todo->setZaurusId( attList[0].toInt() ); | ||
204 | todo->setZaurusUid( cSum ); | ||
205 | todo->setZaurusStat( -2 ); | ||
206 | |||
207 | todo->setSummary( attList[7] ); | ||
208 | todo->setDescription( attList[8]); | ||
209 | |||
210 | int priority = attList[6].toInt(); | ||
211 | if ( priority == 0 ) priority = 3; | ||
212 | todo->setPriority( priority ); | ||
213 | |||
214 | QString categoryList = attList[1]; | ||
215 | todo->setCategories( lookupCategories( categoryList ) ); | ||
216 | |||
217 | |||
218 | |||
219 | QString hasDateStr = attList[3]; // due | ||
220 | if ( !hasDateStr.isEmpty() ) { | ||
221 | if ( hasDateStr.right(6) == "000000" ) { | ||
222 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | ||
223 | todo->setFloats( true ); | ||
224 | } | ||
225 | else { | ||
226 | todo->setDtDue( fromString( hasDateStr ) ); | ||
227 | todo->setFloats( false ); | ||
228 | } | ||
229 | |||
230 | todo->setHasDueDate( true ); | ||
231 | } | ||
232 | hasDateStr = attList[2];//start | ||
233 | if ( !hasDateStr.isEmpty() ) { | ||
234 | |||
235 | todo->setDtStart( fromString( hasDateStr ) ); | ||
236 | todo->setHasStartDate( true); | ||
237 | } else | ||
238 | todo->setHasStartDate( false ); | ||
239 | hasDateStr = attList[4];//completed | ||
240 | if ( !hasDateStr.isEmpty() ) { | ||
241 | todo->setCompleted(fromString( hasDateStr ) ); | ||
242 | } | ||
243 | QString completedStr = attList[5]; | ||
244 | if ( completedStr == "0" ) | ||
245 | todo->setCompleted( true ); | ||
246 | else | ||
247 | todo->setCompleted( false ); | ||
248 | mCalendar->addTodo( todo ); | ||
249 | |||
250 | } else if ( qName == "Category" ) { | ||
251 | /* | ||
252 | QString id = attributes.value( "id" ); | ||
253 | QString name = attributes.value( "name" ); | ||
254 | setCategory( id, name ); | ||
255 | */ | ||
256 | } | ||
257 | //qDebug("end "); | ||
258 | return true; | ||
259 | } | ||
260 | |||
261 | |||
262 | void setCategoriesList ( QStringList * c ) | ||
263 | { | ||
264 | oldCategories = c; | ||
265 | } | ||
266 | |||
267 | QDateTime fromString ( QString s, bool useTz = true ) { | ||
268 | QDateTime dt; | ||
269 | int y,m,t,h,min,sec; | ||
270 | y = s.mid(0,4).toInt(); | ||
271 | m = s.mid(4,2).toInt(); | ||
272 | t = s.mid(6,2).toInt(); | ||
273 | h = s.mid(9,2).toInt(); | ||
274 | min = s.mid(11,2).toInt(); | ||
275 | sec = s.mid(13,2).toInt(); | ||
276 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | ||
277 | int offset = KGlobal::locale()->localTimeOffset( dt ); | ||
278 | if ( useTz ) | ||
279 | dt = dt.addSecs ( offset*60); | ||
280 | return dt; | ||
281 | |||
282 | } | ||
283 | protected: | ||
284 | QDateTime toDateTime( const QString &value ) | ||
285 | { | ||
286 | QDateTime dt; | ||
287 | dt.setTime_t( value.toUInt() ); | ||
288 | |||
289 | return dt; | ||
290 | } | ||
291 | |||
292 | QStringList lookupCategories( const QString &categoryList ) | ||
293 | { | ||
294 | QStringList categoryIds = QStringList::split( ";", categoryList ); | ||
295 | QStringList categories; | ||
296 | QStringList::ConstIterator it; | ||
297 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { | ||
298 | QString cate = category( *it ); | ||
299 | if ( oldCategories ) { | ||
300 | if ( ! oldCategories->contains( cate ) ) | ||
301 | oldCategories->append( cate ); | ||
302 | } | ||
303 | categories.append(cate ); | ||
304 | } | ||
305 | return categories; | ||
306 | } | ||
307 | |||
308 | private: | ||
309 | Calendar *mCalendar; | ||
310 | QStringList * oldCategories; | ||
311 | static QString category( const QString &id ) | ||
312 | { | ||
313 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); | ||
314 | if ( it == mCategoriesMap.end() ) return id; | ||
315 | else return *it; | ||
316 | } | ||
317 | |||
318 | static void setCategory( const QString &id, const QString &name ) | ||
319 | { | ||
320 | mCategoriesMap.insert( id, name ); | ||
321 | } | ||
322 | |||
323 | static QMap<QString,QString> mCategoriesMap; | ||
324 | }; | ||
325 | |||
326 | QMap<QString,QString> SharpParser::mCategoriesMap; | ||
327 | |||
328 | SharpFormat::SharpFormat() | ||
329 | { | ||
330 | mCategories = 0; | ||
331 | } | ||
332 | |||
333 | SharpFormat::~SharpFormat() | ||
334 | { | ||
335 | } | ||
336 | ulong SharpFormat::getCsum( const QStringList & attList) | ||
337 | { | ||
338 | int max = attList.count() -1; | ||
339 | ulong cSum = 0; | ||
340 | int j,k,i; | ||
341 | int add; | ||
342 | for ( i = 1; i < max ; ++i ) { | ||
343 | QString s = attList[i]; | ||
344 | if ( ! s.isEmpty() ){ | ||
345 | j = s.length(); | ||
346 | for ( k = 0; k < j; ++k ) { | ||
347 | int mul = k +1; | ||
348 | add = s[k].unicode (); | ||
349 | if ( k < 16 ) | ||
350 | mul = mul * mul; | ||
351 | add = add * mul *i*i*i; | ||
352 | cSum += add; | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | return cSum; | ||
357 | |||
358 | } | ||
359 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | ||
360 | #include <stdlib.h> | ||
361 | #define DEBUGMODE false | ||
362 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | ||
363 | { | ||
364 | |||
365 | GSM_StateMachines; | ||
366 | qDebug(" load "); | ||
367 | s.opened = false; | ||
368 | s.msg = NULL; | ||
369 | s.ConfigNum = 0; | ||
370 | static char*cp; | ||
371 | static INI_Section *cfg = NULL; | ||
372 | cfg=GSM_FindGammuRC(); | ||
373 | int i; | ||
374 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | ||
375 | if (cfg!=NULL) { | ||
376 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); | ||
377 | if (cp) di.coding = cp; | ||
378 | |||
379 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); | ||
380 | if (s.Config[i].Localize) { | ||
381 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | ||
382 | } else { | ||
383 | #if !defined(WIN32) && defined(LOCALE_PATH) | ||
384 | locale = setlocale(LC_MESSAGES, NULL); | ||
385 | if (locale != NULL) { | ||
386 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", | ||
387 | LOCALE_PATH, | ||
388 | tolower(locale[0]), | ||
389 | tolower(locale[1])); | ||
390 | s.msg = INI_ReadFile(locale_file, true); | ||
391 | } | ||
392 | #endif | ||
393 | } | ||
394 | } | ||
395 | |||
396 | /* Wanted user specific configuration? */ | ||
397 | |||
398 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; | ||
399 | |||
400 | s.ConfigNum++; | ||
401 | |||
402 | /* We want to use only one file descriptor for global and state machine debug output */ | ||
403 | s.Config[i].UseGlobalDebugFile = true; | ||
404 | |||
405 | |||
406 | |||
407 | /* We wanted to read just user specified configuration. */ | ||
408 | {break;} | ||
409 | } | ||
410 | |||
411 | |||
412 | |||
413 | |||
414 | int error=GSM_InitConnection(&s,3); | ||
415 | |||
416 | |||
417 | qDebug(" init %d %d", error, ERR_NONE); | ||
418 | if ( error != ERR_NONE ) | ||
419 | return false; | ||
420 | fromString2Cal( calendar, existngCal, &s, "Event" ); | ||
421 | |||
422 | |||
423 | error=GSM_TerminateConnection(&s); | ||
424 | |||
425 | |||
426 | #if 0 | ||
427 | |||
428 | bool debug = DEBUGMODE; | ||
429 | //debug = true; | ||
430 | QString text; | ||
431 | QString codec = "utf8"; | ||
432 | QLabel status ( i18n("Reading events ..."), 0 ); | ||
433 | |||
434 | int w = status.sizeHint().width()+20 ; | ||
435 | if ( w < 200 ) w = 200; | ||
436 | int h = status.sizeHint().height()+20 ; | ||
437 | int dw = QApplication::desktop()->width(); | ||
438 | int dh = QApplication::desktop()->height(); | ||
439 | status.setCaption(i18n("Reading DTM Data") ); | ||
440 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
441 | status.show(); | ||
442 | status.raise(); | ||
443 | qApp->processEvents(); | ||
444 | QString fileName; | ||
445 | if ( ! debug ) { | ||
446 | fileName = "/tmp/kopitempout"; | ||
447 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | ||
448 | system ( command.latin1() ); | ||
449 | } else { | ||
450 | fileName = "/tmp/events.txt"; | ||
451 | |||
452 | } | ||
453 | QFile file( fileName ); | ||
454 | if (!file.open( IO_ReadOnly ) ) { | ||
455 | return false; | ||
456 | |||
457 | } | ||
458 | QTextStream ts( &file ); | ||
459 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
460 | text = ts.read(); | ||
461 | file.close(); | ||
462 | status.setText( i18n("Processing events ...") ); | ||
463 | status.raise(); | ||
464 | qApp->processEvents(); | ||
465 | fromString2Cal( calendar, existngCal, text, "Event" ); | ||
466 | status.setText( i18n("Reading todos ...") ); | ||
467 | qApp->processEvents(); | ||
468 | if ( ! debug ) { | ||
469 | fileName = "/tmp/kopitempout"; | ||
470 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | ||
471 | system ( command.latin1() ); | ||
472 | } else { | ||
473 | fileName = "/tmp/todo.txt"; | ||
474 | } | ||
475 | file.setName( fileName ); | ||
476 | if (!file.open( IO_ReadOnly ) ) { | ||
477 | return false; | ||
478 | |||
479 | } | ||
480 | ts.setDevice( &file ); | ||
481 | text = ts.read(); | ||
482 | file.close(); | ||
483 | |||
484 | status.setText( i18n("Processing todos ...") ); | ||
485 | status.raise(); | ||
486 | qApp->processEvents(); | ||
487 | fromString2Cal( calendar, existngCal, text, "Todo" ); | ||
488 | #endif | ||
489 | return true; | ||
490 | } | ||
491 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | ||
492 | { | ||
493 | int retval = -1; | ||
494 | QStringList templist; | ||
495 | QString tempString; | ||
496 | int start = 0; | ||
497 | int len = answer.length(); | ||
498 | int end = answer.find ("\n",start)+1; | ||
499 | bool ok = true; | ||
500 | start = end; | ||
501 | int ccc = 0; | ||
502 | while ( start > 0 ) { | ||
503 | templist.clear(); | ||
504 | ok = true; | ||
505 | int loopCount = 0; | ||
506 | while ( ok ) { | ||
507 | ++loopCount; | ||
508 | if ( loopCount > 25 ) { | ||
509 | qDebug("KO: Error in while loop"); | ||
510 | ok = false; | ||
511 | start = 0; | ||
512 | break; | ||
513 | } | ||
514 | if ( ok ) | ||
515 | tempString = getPart( answer, ok, start ); | ||
516 | if ( start >= len || start == 0 ) { | ||
517 | start = 0; | ||
518 | ok = false; | ||
519 | } | ||
520 | if ( tempString.right(1) =="\n" ) | ||
521 | tempString = tempString.left( tempString.length()-1); | ||
522 | |||
523 | templist.append( tempString ); | ||
524 | } | ||
525 | ++ccc; | ||
526 | if ( ccc == 2 && loopCount < 25 ) { | ||
527 | start = 0; | ||
528 | bool ok; | ||
529 | int newnum = templist[0].toInt( &ok ); | ||
530 | if ( ok && newnum > 0) { | ||
531 | retval = newnum; | ||
532 | inc->setZaurusId( newnum ); | ||
533 | inc->setZaurusUid( getCsum( templist ) ); | ||
534 | inc->setZaurusStat( -4 ); | ||
535 | } | ||
536 | } | ||
537 | } | ||
538 | //qDebug("getNumFromRecord returning : %d ", retval); | ||
539 | return retval; | ||
540 | } | ||
541 | bool SharpFormat::save( Calendar *calendar) | ||
542 | { | ||
543 | |||
544 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | ||
545 | int w = status.sizeHint().width()+20 ; | ||
546 | if ( w < 200 ) w = 200; | ||
547 | int h = status.sizeHint().height()+20 ; | ||
548 | int dw = QApplication::desktop()->width(); | ||
549 | int dh = QApplication::desktop()->height(); | ||
550 | status.setCaption(i18n("Writing DTM Data") ); | ||
551 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | ||
552 | status.show(); | ||
553 | status.raise(); | ||
554 | qApp->processEvents(); | ||
555 | bool debug = DEBUGMODE; | ||
556 | QString codec = "utf8"; | ||
557 | QString answer; | ||
558 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | ||
559 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | ||
560 | QString command; | ||
561 | QPtrList<Event> er = calendar->rawEvents(); | ||
562 | Event* ev = er.first(); | ||
563 | QString fileName = "/tmp/kopitempout"; | ||
564 | int i = 0; | ||
565 | QString changeString = ePrefix; | ||
566 | QString deleteString = ePrefix; | ||
567 | bool deleteEnt = false; | ||
568 | bool changeEnt = false; | ||
569 | QString message = i18n("Processing event # "); | ||
570 | int procCount = 0; | ||
571 | while ( ev ) { | ||
572 | //qDebug("i %d ", ++i); | ||
573 | if ( ev->zaurusStat() != -2 ) { | ||
574 | status.setText ( message + QString::number ( ++procCount ) ); | ||
575 | qApp->processEvents(); | ||
576 | QString eString = getEventString( ev ); | ||
577 | if ( ev->zaurusStat() == -3 ) { // delete | ||
578 | // deleting empty strings does not work. | ||
579 | // we write first and x and then delete the record with the x | ||
580 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | ||
581 | changeString += eString + "\n"; | ||
582 | deleteString += eString + "\n"; | ||
583 | deleteEnt = true; | ||
584 | changeEnt = true; | ||
585 | } | ||
586 | else if ( ev->zaurusId() == -1 ) { // add new | ||
587 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | ||
588 | system ( command.utf8() ); | ||
589 | QFile file( fileName ); | ||
590 | if (!file.open( IO_ReadOnly ) ) { | ||
591 | return false; | ||
592 | |||
593 | } | ||
594 | QTextStream ts( &file ); | ||
595 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
596 | answer = ts.read(); | ||
597 | file.close(); | ||
598 | //qDebug("answer \n%s ", answer.latin1()); | ||
599 | getNumFromRecord( answer, ev ) ; | ||
600 | |||
601 | } | ||
602 | else { // change existing | ||
603 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | ||
604 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | ||
605 | changeString += eString + "\n"; | ||
606 | changeEnt = true; | ||
607 | |||
608 | } | ||
609 | } | ||
610 | ev = er.next(); | ||
611 | } | ||
612 | status.setText ( i18n("Changing events ...") ); | ||
613 | qApp->processEvents(); | ||
614 | //qDebug("changing... "); | ||
615 | if ( changeEnt ) { | ||
616 | QFile file( fileName ); | ||
617 | if (!file.open( IO_WriteOnly ) ) { | ||
618 | return false; | ||
619 | |||
620 | } | ||
621 | QTextStream ts( &file ); | ||
622 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
623 | ts << changeString ; | ||
624 | file.close(); | ||
625 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; | ||
626 | system ( command.latin1() ); | ||
627 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | ||
628 | |||
629 | } | ||
630 | status.setText ( i18n("Deleting events ...") ); | ||
631 | qApp->processEvents(); | ||
632 | //qDebug("deleting... "); | ||
633 | if ( deleteEnt ) { | ||
634 | QFile file( fileName ); | ||
635 | if (!file.open( IO_WriteOnly ) ) { | ||
636 | return false; | ||
637 | |||
638 | } | ||
639 | QTextStream ts( &file ); | ||
640 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
641 | ts << deleteString; | ||
642 | file.close(); | ||
643 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; | ||
644 | system ( command.latin1() ); | ||
645 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | ||
646 | } | ||
647 | |||
648 | |||
649 | changeString = tPrefix; | ||
650 | deleteString = tPrefix; | ||
651 | status.setText ( i18n("Processing todos ...") ); | ||
652 | qApp->processEvents(); | ||
653 | QPtrList<Todo> tl = calendar->rawTodos(); | ||
654 | Todo* to = tl.first(); | ||
655 | i = 0; | ||
656 | message = i18n("Processing todo # "); | ||
657 | procCount = 0; | ||
658 | while ( to ) { | ||
659 | if ( to->zaurusStat() != -2 ) { | ||
660 | status.setText ( message + QString::number ( ++procCount ) ); | ||
661 | qApp->processEvents(); | ||
662 | QString eString = getTodoString( to ); | ||
663 | if ( to->zaurusStat() == -3 ) { // delete | ||
664 | // deleting empty strings does not work. | ||
665 | // we write first and x and then delete the record with the x | ||
666 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | ||
667 | changeString += eString + "\n"; | ||
668 | deleteString += eString + "\n"; | ||
669 | deleteEnt = true; | ||
670 | changeEnt = true; | ||
671 | } | ||
672 | else if ( to->zaurusId() == -1 ) { // add new | ||
673 | command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; | ||
674 | system ( command.utf8() ); | ||
675 | QFile file( fileName ); | ||
676 | if (!file.open( IO_ReadOnly ) ) { | ||
677 | return false; | ||
678 | |||
679 | } | ||
680 | QTextStream ts( &file ); | ||
681 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
682 | answer = ts.read(); | ||
683 | file.close(); | ||
684 | //qDebug("answer \n%s ", answer.latin1()); | ||
685 | getNumFromRecord( answer, to ) ; | ||
686 | |||
687 | } | ||
688 | else { // change existing | ||
689 | //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); | ||
690 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | ||
691 | changeString += eString + "\n"; | ||
692 | changeEnt = true; | ||
693 | |||
694 | } | ||
695 | } | ||
696 | |||
697 | to = tl.next(); | ||
698 | } | ||
699 | status.setText ( i18n("Changing todos ...") ); | ||
700 | qApp->processEvents(); | ||
701 | //qDebug("changing... "); | ||
702 | if ( changeEnt ) { | ||
703 | QFile file( fileName ); | ||
704 | if (!file.open( IO_WriteOnly ) ) { | ||
705 | return false; | ||
706 | |||
707 | } | ||
708 | QTextStream ts( &file ); | ||
709 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
710 | ts << changeString ; | ||
711 | file.close(); | ||
712 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; | ||
713 | system ( command.latin1() ); | ||
714 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | ||
715 | |||
716 | } | ||
717 | status.setText ( i18n("Deleting todos ...") ); | ||
718 | qApp->processEvents(); | ||
719 | //qDebug("deleting... "); | ||
720 | if ( deleteEnt ) { | ||
721 | QFile file( fileName ); | ||
722 | if (!file.open( IO_WriteOnly ) ) { | ||
723 | return false; | ||
724 | |||
725 | } | ||
726 | QTextStream ts( &file ); | ||
727 | ts.setCodec( QTextCodec::codecForName("utf8") ); | ||
728 | ts << deleteString; | ||
729 | file.close(); | ||
730 | command = "db2file todo -d -c " + codec+ " < "+ fileName; | ||
731 | system ( command.latin1() ); | ||
732 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | ||
733 | } | ||
734 | |||
735 | return true; | ||
736 | } | ||
737 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) | ||
738 | { | ||
739 | QString datestr; | ||
740 | QString timestr; | ||
741 | int offset = KGlobal::locale()->localTimeOffset( dti ); | ||
742 | QDateTime dt; | ||
743 | if (useTZ) | ||
744 | dt = dti.addSecs ( -(offset*60)); | ||
745 | else | ||
746 | dt = dti; | ||
747 | if(dt.date().isValid()){ | ||
748 | const QDate& date = dt.date(); | ||
749 | datestr.sprintf("%04d%02d%02d", | ||
750 | date.year(), date.month(), date.day()); | ||
751 | } | ||
752 | if(dt.time().isValid()){ | ||
753 | const QTime& time = dt.time(); | ||
754 | timestr.sprintf("T%02d%02d%02d", | ||
755 | time.hour(), time.minute(), time.second()); | ||
756 | } | ||
757 | return datestr + timestr; | ||
758 | } | ||
759 | QString SharpFormat::getEventString( Event* event ) | ||
760 | { | ||
761 | QStringList list; | ||
762 | list.append( QString::number(event->zaurusId() ) ); | ||
763 | list.append( event->categories().join(",") ); | ||
764 | if ( !event->summary().isEmpty() ) | ||
765 | list.append( event->summary() ); | ||
766 | else | ||
767 | list.append("" ); | ||
768 | if ( !event->location().isEmpty() ) | ||
769 | list.append( event->location() ); | ||
770 | else | ||
771 | list.append("" ); | ||
772 | if ( !event->description().isEmpty() ) | ||
773 | list.append( event->description() ); | ||
774 | else | ||
775 | list.append( "" ); | ||
776 | if ( event->doesFloat () ) { | ||
777 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); | ||
778 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 | ||
779 | list.append( "1" ); | ||
780 | |||
781 | } | ||
782 | else { | ||
783 | list.append( dtToString( event->dtStart()) ); | ||
784 | list.append( dtToString( event->dtEnd()) ); //6 | ||
785 | list.append( "0" ); | ||
786 | } | ||
787 | bool noAlarm = true; | ||
788 | if ( event->alarms().count() > 0 ) { | ||
789 | Alarm * al = event->alarms().first(); | ||
790 | if ( al->enabled() ) { | ||
791 | noAlarm = false; | ||
792 | list.append( "0" ); // yes, 0 == alarm | ||
793 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); | ||
794 | if ( al->type() == Alarm::Audio ) | ||
795 | list.append( "1" ); // type audio | ||
796 | else | ||
797 | list.append( "0" ); // type silent | ||
798 | } | ||
799 | } | ||
800 | if ( noAlarm ) { | ||
801 | list.append( "1" ); // yes, 1 == no alarm | ||
802 | list.append( "0" ); // no alarm offset | ||
803 | list.append( "1" ); // type | ||
804 | } | ||
805 | // next is: 11 | ||
806 | // next is: 11-16 are recurrence | ||
807 | Recurrence* rec = event->recurrence(); | ||
808 | |||
809 | bool writeEndDate = false; | ||
810 | switch ( rec->doesRecur() ) | ||
811 | { | ||
812 | case Recurrence::rDaily: // 0 | ||
813 | list.append( "0" ); | ||
814 | list.append( QString::number( rec->frequency() ));//12 | ||
815 | list.append( "0" ); | ||
816 | list.append( "0" ); | ||
817 | writeEndDate = true; | ||
818 | break; | ||
819 | case Recurrence::rWeekly:// 1 | ||
820 | list.append( "1" ); | ||
821 | list.append( QString::number( rec->frequency()) );//12 | ||
822 | list.append( "0" ); | ||
823 | { | ||
824 | int days = 0; | ||
825 | QBitArray weekDays = rec->days(); | ||
826 | int i; | ||
827 | for( i = 1; i <= 7; ++i ) { | ||
828 | if ( weekDays[i-1] ) { | ||
829 | days += 1 << (i-1); | ||
830 | } | ||
831 | } | ||
832 | list.append( QString::number( days ) ); | ||
833 | } | ||
834 | //pending weekdays | ||
835 | writeEndDate = true; | ||
836 | |||
837 | break; | ||
838 | case Recurrence::rMonthlyPos:// 2 | ||
839 | list.append( "2" ); | ||
840 | list.append( QString::number( rec->frequency()) );//12 | ||
841 | |||
842 | writeEndDate = true; | ||
843 | { | ||
844 | int count = 1; | ||
845 | QPtrList<Recurrence::rMonthPos> rmp; | ||
846 | rmp = rec->monthPositions(); | ||
847 | if ( rmp.first()->negative ) | ||
848 | count = 5 - rmp.first()->rPos - 1; | ||
849 | else | ||
850 | count = rmp.first()->rPos - 1; | ||
851 | list.append( QString::number( count ) ); | ||
852 | |||
853 | } | ||
854 | |||
855 | list.append( "0" ); | ||
856 | break; | ||
857 | case Recurrence::rMonthlyDay:// 3 | ||
858 | list.append( "3" ); | ||
859 | list.append( QString::number( rec->frequency()) );//12 | ||
860 | list.append( "0" ); | ||
861 | list.append( "0" ); | ||
862 | writeEndDate = true; | ||
863 | break; | ||
864 | case Recurrence::rYearlyMonth://4 | ||
865 | list.append( "4" ); | ||
866 | list.append( QString::number( rec->frequency()) );//12 | ||
867 | list.append( "0" ); | ||
868 | list.append( "0" ); | ||
869 | writeEndDate = true; | ||
870 | break; | ||
871 | |||
872 | default: | ||
873 | list.append( "255" ); | ||
874 | list.append( QString() ); | ||
875 | list.append( "0" ); | ||
876 | list.append( QString() ); | ||
877 | list.append( "0" ); | ||
878 | list.append( "20991231T000000" ); | ||
879 | break; | ||
880 | } | ||
881 | if ( writeEndDate ) { | ||
882 | |||
883 | if ( rec->endDate().isValid() ) { // 15 + 16 | ||
884 | list.append( "1" ); | ||
885 | list.append( dtToString( rec->endDate()) ); | ||
886 | } else { | ||
887 | list.append( "0" ); | ||
888 | list.append( "20991231T000000" ); | ||
889 | } | ||
890 | |||
891 | } | ||
892 | if ( event->doesFloat () ) { | ||
893 | list.append( dtToString( event->dtStart(), false ).left( 8 )); | ||
894 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 | ||
895 | |||
896 | } | ||
897 | else { | ||
898 | list.append( QString() ); | ||
899 | list.append( QString() ); | ||
900 | |||
901 | } | ||
902 | if (event->dtStart().date() == event->dtEnd().date() ) | ||
903 | list.append( "0" ); | ||
904 | else | ||
905 | list.append( "1" ); | ||
906 | |||
907 | |||
908 | for(QStringList::Iterator it=list.begin(); | ||
909 | it!=list.end(); ++it){ | ||
910 | QString& s = (*it); | ||
911 | s.replace(QRegExp("\""), "\"\""); | ||
912 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | ||
913 | s.prepend('\"'); | ||
914 | s.append('\"'); | ||
915 | } else if(s.isEmpty() && !s.isNull()){ | ||
916 | s = "\"\""; | ||
917 | } | ||
918 | } | ||
919 | return list.join(","); | ||
920 | |||
921 | |||
922 | } | ||
923 | QString SharpFormat::getTodoString( Todo* todo ) | ||
924 | { | ||
925 | QStringList list; | ||
926 | list.append( QString::number( todo->zaurusId() ) ); | ||
927 | list.append( todo->categories().join(",") ); | ||
928 | |||
929 | if ( todo->hasStartDate() ) { | ||
930 | list.append( dtToString( todo->dtStart()) ); | ||
931 | } else | ||
932 | list.append( QString() ); | ||
933 | |||
934 | if ( todo->hasDueDate() ) { | ||
935 | QTime tim; | ||
936 | if ( todo->doesFloat()) { | ||
937 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | ||
938 | } else { | ||
939 | list.append( dtToString(todo->dtDue() ) ); | ||
940 | } | ||
941 | } else | ||
942 | list.append( QString() ); | ||
943 | |||
944 | if ( todo->isCompleted() ) { | ||
945 | list.append( dtToString( todo->completed()) ); | ||
946 | list.append( "0" ); // yes 0 == completed | ||
947 | } else { | ||
948 | list.append( dtToString( todo->completed()) ); | ||
949 | list.append( "1" ); | ||
950 | } | ||
951 | list.append( QString::number( todo->priority() )); | ||
952 | if( ! todo->summary().isEmpty() ) | ||
953 | list.append( todo->summary() ); | ||
954 | else | ||
955 | list.append( "" ); | ||
956 | if (! todo->description().isEmpty() ) | ||
957 | list.append( todo->description() ); | ||
958 | else | ||
959 | list.append( "" ); | ||
960 | for(QStringList::Iterator it=list.begin(); | ||
961 | it!=list.end(); ++it){ | ||
962 | QString& s = (*it); | ||
963 | s.replace(QRegExp("\""), "\"\""); | ||
964 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | ||
965 | s.prepend('\"'); | ||
966 | s.append('\"'); | ||
967 | } else if(s.isEmpty() && !s.isNull()){ | ||
968 | s = "\"\""; | ||
969 | } | ||
970 | } | ||
971 | return list.join(","); | ||
972 | } | ||
973 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) | ||
974 | { | ||
975 | //qDebug("start %d ", start); | ||
976 | |||
977 | QString retval =""; | ||
978 | if ( text.at(start) == '"' ) { | ||
979 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { | ||
980 | start = start +2; | ||
981 | if ( text.mid( start,1) == "," ) { | ||
982 | start += 1; | ||
983 | } | ||
984 | retval = ""; | ||
985 | if ( text.mid( start,1) == "\n" ) { | ||
986 | start += 1; | ||
987 | ok = false; | ||
988 | } | ||
989 | return retval; | ||
990 | } | ||
991 | int hk = start+1; | ||
992 | hk = text.find ('"',hk); | ||
993 | while ( text.at(hk+1) == '"' ) | ||
994 | hk = text.find ('"',hk+2); | ||
995 | retval = text.mid( start+1, hk-start-1); | ||
996 | start = hk+1; | ||
997 | retval.replace( QRegExp("\"\""), "\""); | ||
998 | if ( text.mid( start,1) == "," ) { | ||
999 | start += 1; | ||
1000 | } | ||
1001 | if ( text.mid( start,1) == "\n" ) { | ||
1002 | start += 1; | ||
1003 | ok = false; | ||
1004 | } | ||
1005 | //qDebug("retval***%s*** ",retval.latin1() ); | ||
1006 | return retval; | ||
1007 | |||
1008 | } else { | ||
1009 | int nl = text.find ("\n",start); | ||
1010 | int kom = text.find (',',start); | ||
1011 | if ( kom < nl ) { | ||
1012 | // qDebug("kom < nl %d ", kom); | ||
1013 | retval = text.mid(start, kom-start); | ||
1014 | start = kom+1; | ||
1015 | return retval; | ||
1016 | } else { | ||
1017 | if ( nl == kom ) { | ||
1018 | // qDebug(" nl == kom "); | ||
1019 | start = 0; | ||
1020 | ok = false; | ||
1021 | return "0"; | ||
1022 | } | ||
1023 | // qDebug(" nl < kom ", nl); | ||
1024 | retval = text.mid( start, nl-start); | ||
1025 | ok = false; | ||
1026 | start = nl+1; | ||
1027 | return retval; | ||
1028 | } | ||
1029 | } | ||
1030 | } | ||
1031 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) | ||
1032 | { | ||
1033 | return false; | ||
1034 | } | ||
1035 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type) | ||
1036 | { | ||
1037 | GSM_Phone_Functions*Phone; | ||
1038 | |||
1039 | GSM_CalendarEntrynote; | ||
1040 | GSM_CalendarEntry*Note; | ||
1041 | bool refresh= true; | ||
1042 | |||
1043 | Phone=s->Phone.Functions; | ||
1044 | bool gshutdown = false; | ||
1045 | SharpParser handler( calendar ); | ||
1046 | //handler.setCategoriesList( mCategories ); | ||
1047 | QStringList templist; | ||
1048 | QString tempString; | ||
1049 | int start = 0; | ||
1050 | int error; | ||
1051 | int ccc = 0; | ||
1052 | while (!gshutdown && ccc++ < 10 ) { | ||
1053 | QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY; | ||
1054 | templist.clear(); | ||
1055 | qDebug("count %d ", ccc); | ||
1056 | error=Phone->GetNextCalendar(s,¬e,refresh); | ||
1057 | if (error == ERR_EMPTY) break; | ||
1058 | |||
1059 | Note = ¬e; | ||
1060 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | ||
1061 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ||
1062 | |||
1063 | //ARSD silentalarm = 0 | ||
1064 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | ||
1065 | // 12 RFRQ | ||
1066 | // 13 RPOS pos = 4. monday in month | ||
1067 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | ||
1068 | // 15 REND 0 = no end/ 1 = end | ||
1069 | // 16 REDT rec end dt | ||
1070 | //ALSD | ||
1071 | //ALED | ||
1072 | //MDAY | ||
1073 | |||
1074 | CARDID = QString::number( Note->Location ); // 0 | ||
1075 | |||
1076 | |||
1077 | int i_age = 0,i; | ||
1078 | GSM_DateTime Alarm,DateTime; | ||
1079 | GSM_DateTime* dtp; | ||
1080 | GSM_MemoryEntry entry; | ||
1081 | unsigned char *name; | ||
1082 | |||
1083 | bool repeating = false; | ||
1084 | int repeat_dayofweek = -1; | ||
1085 | int repeat_day = -1; | ||
1086 | int repeat_weekofmonth = -1; | ||
1087 | int repeat_month = -1; | ||
1088 | int repeat_frequency = -1; | ||
1089 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | ||
1090 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | ||
1091 | |||
1092 | Alarm.Year = 0; | ||
1093 | |||
1094 | repeating = false; | ||
1095 | repeat_dayofweek = -1; | ||
1096 | repeat_day = -1; | ||
1097 | repeat_weekofmonth = -1; | ||
1098 | repeat_month = -1; | ||
1099 | repeat_frequency = -1; | ||
1100 | repeat_startdate.Day= 0; | ||
1101 | repeat_stopdate.Day = 0; | ||
1102 | |||
1103 | |||
1104 | switch (Note->Type) { | ||
1105 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; | ||
1106 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; | ||
1107 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; | ||
1108 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; | ||
1109 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; | ||
1110 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; | ||
1111 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; | ||
1112 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; | ||
1113 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; | ||
1114 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; | ||
1115 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; | ||
1116 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; | ||
1117 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; | ||
1118 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; | ||
1119 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; | ||
1120 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; | ||
1121 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; | ||
1122 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; | ||
1123 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; | ||
1124 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; | ||
1125 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; | ||
1126 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; | ||
1127 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; | ||
1128 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; | ||
1129 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; | ||
1130 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; | ||
1131 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; | ||
1132 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; | ||
1133 | default : CATEGORY = QString(""); | ||
1134 | } | ||
1135 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | ||
1136 | // 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19? | ||
1137 | |||
1138 | MEM1 = ""; | ||
1139 | |||
1140 | #if 0 | ||
1141 | |||
1142 | if ( attList[7] == "1" ) { | ||
1143 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); | ||
1144 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); | ||
1145 | event->setFloats( true ); | ||
1146 | } else { | ||
1147 | event->setFloats( false ); | ||
1148 | event->setDtStart( fromString( attList[5] ) ); | ||
1149 | event->setDtEnd( fromString( attList[6] )); | ||
1150 | } | ||
1151 | |||
1152 | |||
1153 | |||
1154 | typedef struct { | ||
1155 | /** | ||
1156 | * The difference between local time and GMT in hours | ||
1157 | */ | ||
1158 | int Timezone; | ||
1159 | |||
1160 | unsigned int Second; | ||
1161 | unsigned int Minute; | ||
1162 | unsigned int Hour; | ||
1163 | |||
1164 | unsigned int Day; | ||
1165 | /** | ||
1166 | * January = 1, February = 2, etc. | ||
1167 | */ | ||
1168 | unsigned int Month; | ||
1169 | /** | ||
1170 | * Complete year number. Not 03, but 2003 | ||
1171 | */ | ||
1172 | unsigned int Year; | ||
1173 | } GSM_DateTime; | ||
1174 | |||
1175 | if(dt.date().isValid()){ | ||
1176 | const QDate& date = dt.date(); | ||
1177 | datestr.sprintf("%04d%02d%02d", | ||
1178 | date.year(), date.month(), date.day()); | ||
1179 | } | ||
1180 | if(dt.time().isValid()){ | ||
1181 | const QTime& time = dt.time(); | ||
1182 | timestr.sprintf("T%02d%02d%02d", | ||
1183 | time.hour(), time.minute(), time.second()); | ||
1184 | } | ||
1185 | return datestr + timestr; | ||
1186 | |||
1187 | |||
1188 | |||
1189 | |||
1190 | #endif | ||
1191 | |||
1192 | |||
1193 | ADAY = "0"; | ||
1194 | ARON = "1"; // 1 == disabled | ||
1195 | ARMN = "0"; //alarm offset in minutes | ||
1196 | |||
1197 | for (i=0;i<Note->EntriesNum;i++) { | ||
1198 | |||
1199 | qDebug(" for "); | ||
1200 | switch (Note->Entries[i].EntryType) { | ||
1201 | case CAL_START_DATETIME: | ||
1202 | dtp = &Note->Entries[i].Date ; | ||
1203 | |||
1204 | qDebug("hour: %d ", dtp->Hour); | ||
1205 | if ( dtp->Hour == -1 ) { | ||
1206 | ADAY = "1"; | ||
1207 | ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); | ||
1208 | TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); | ||
1209 | } else { | ||
1210 | TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1211 | |||
1212 | } | ||
1213 | ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1214 | //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1215 | break; | ||
1216 | case CAL_END_DATETIME: | ||
1217 | dtp = &Note->Entries[i].Date ; | ||
1218 | qDebug("hour2: %d ", dtp->Hour); | ||
1219 | if ( dtp->Hour == -1 ) { | ||
1220 | ADAY = "1"; | ||
1221 | ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day ); | ||
1222 | TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day ); | ||
1223 | } else { | ||
1224 | TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1225 | |||
1226 | } | ||
1227 | //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1228 | //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1229 | break; | ||
1230 | case CAL_ALARM_DATETIME: | ||
1231 | ARON = "0"; | ||
1232 | dtp = &Note->Entries[i].Date ; | ||
1233 | ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1234 | //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1235 | memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1236 | break; | ||
1237 | case CAL_SILENT_ALARM_DATETIME: | ||
1238 | ARON = "0"; | ||
1239 | dtp = &Note->Entries[i].Date ; | ||
1240 | ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second ); | ||
1241 | //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false)); | ||
1242 | //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime)); | ||
1243 | break; | ||
1244 | case CAL_RECURRANCE: | ||
1245 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); | ||
1246 | break; | ||
1247 | case CAL_TEXT: | ||
1248 | DSRP = QString ( (const char*) Note->Entries[i].Text ); | ||
1249 | break; | ||
1250 | case CAL_LOCATION: | ||
1251 | PLCE = QString ((const char*) Note->Entries[i].Text ); | ||
1252 | break; | ||
1253 | case CAL_PHONE: | ||
1254 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | ||
1255 | break; | ||
1256 | case CAL_PRIVATE: | ||
1257 | //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No"); | ||
1258 | break; | ||
1259 | case CAL_CONTACTID: | ||
1260 | #if 0 | ||
1261 | entry.Location = Note->Entries[i].Number; | ||
1262 | entry.MemoryType = MEM_ME; | ||
1263 | error=Phone->GetMemory(&s, &entry); | ||
1264 | if (error == ERR_NONE) { | ||
1265 | name = GSM_PhonebookGetEntryName(&entry); | ||
1266 | if (name != NULL) { | ||
1267 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); | ||
1268 | } else { | ||
1269 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | ||
1270 | } | ||
1271 | } else { | ||
1272 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | ||
1273 | } | ||
1274 | #endif | ||
1275 | break; | ||
1276 | case CAL_REPEAT_DAYOFWEEK: | ||
1277 | repeat_dayofweek = Note->Entries[i].Number; | ||
1278 | repeating = true; | ||
1279 | break; | ||
1280 | case CAL_REPEAT_DAY: | ||
1281 | repeat_day = Note->Entries[i].Number; | ||
1282 | repeating = true; | ||
1283 | break; | ||
1284 | case CAL_REPEAT_WEEKOFMONTH: | ||
1285 | repeat_weekofmonth = Note->Entries[i].Number; | ||
1286 | repeating = true; | ||
1287 | break; | ||
1288 | case CAL_REPEAT_MONTH: | ||
1289 | repeat_month = Note->Entries[i].Number; | ||
1290 | repeating = true; | ||
1291 | break; | ||
1292 | case CAL_REPEAT_FREQUENCY: | ||
1293 | repeat_frequency = Note->Entries[i].Number; | ||
1294 | repeating = true; | ||
1295 | break; | ||
1296 | case CAL_REPEAT_STARTDATE: | ||
1297 | repeat_startdate = Note->Entries[i].Date; | ||
1298 | repeating = true; | ||
1299 | break; | ||
1300 | case CAL_REPEAT_STOPDATE: | ||
1301 | repeat_stopdate = Note->Entries[i].Date; | ||
1302 | repeating = true; | ||
1303 | break; | ||
1304 | } | ||
1305 | } | ||
1306 | |||
1307 | |||
1308 | |||
1309 | if ( ARON == "0" ) { | ||
1310 | QDateTime start,alarm; | ||
1311 | start = handler.fromString( TIM1 ); | ||
1312 | alarm = handler.fromString( ARMN ); | ||
1313 | int min = alarm.secsTo ( start )/60; | ||
1314 | ARMN = QString::number ( min ); | ||
1315 | } | ||
1316 | |||
1317 | templist.clear(); | ||
1318 | templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY; | ||
1319 | handler.startElement( existingCalendar, templist, type ); | ||
1320 | } | ||
1321 | |||
1322 | |||
1323 | |||
1324 | #if 0 | ||
1325 | // qDebug("test %s ", text.latin1()); | ||
1326 | QStringList templist; | ||
1327 | QString tempString; | ||
1328 | int start = 0; | ||
1329 | int len = text.length(); | ||
1330 | int end = text.find ("\n",start)+1; | ||
1331 | bool ok = true; | ||
1332 | start = end; | ||
1333 | SharpParser handler( calendar ); | ||
1334 | handler.setCategoriesList( mCategories ); | ||
1335 | while ( start > 0 ) { | ||
1336 | templist.clear(); | ||
1337 | ok = true; | ||
1338 | while ( ok ) { | ||
1339 | tempString = getPart( text, ok, start ); | ||
1340 | if ( start >= len || start == 0 ) { | ||
1341 | start = 0; | ||
1342 | ok = false; | ||
1343 | } | ||
1344 | if ( tempString.right(1) =="\n" ) | ||
1345 | tempString = tempString.left( tempString.length()-1); | ||
1346 | //if ( ok ) | ||
1347 | templist.append( tempString ); | ||
1348 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); | ||
1349 | } | ||
1350 | handler.startElement( existingCalendar, templist, type ); | ||
1351 | } | ||
1352 | #endif | ||
1353 | return false; | ||
1354 | } | ||
1355 | |||
1356 | QString SharpFormat::toString( Calendar * ) | ||
1357 | { | ||
1358 | return QString::null; | ||
1359 | } | ||
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h new file mode 100644 index 0000000..f4cb52c --- a/dev/null +++ b/libkcal/phoneformat.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | This file is part of libkcal. | ||
3 | |||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | ||
5 | |||
6 | This library is free software; you can redistribute it and/or | ||
7 | modify it under the terms of the GNU Library General Public | ||
8 | License as published by the Free Software Foundation; either | ||
9 | version 2 of the License, or (at your option) any later version. | ||
10 | |||
11 | This library is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | Library General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU Library General Public License | ||
17 | along with this library; see the file COPYING.LIB. If not, write to | ||
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | #ifndef SHARPFORMAT_H | ||
22 | #define SHARPAFORMAT_H | ||
23 | |||
24 | #include <qstring.h> | ||
25 | |||
26 | #include "scheduler.h" | ||
27 | |||
28 | #include "calformat.h" | ||
29 | extern "C" { | ||
30 | #include "gammu.h" | ||
31 | } | ||
32 | |||
33 | namespace KCal { | ||
34 | |||
35 | /** | ||
36 | This class implements the calendar format used by Sharp. | ||
37 | */ | ||
38 | |||
39 | class SharpFormat : public QObject { | ||
40 | public: | ||
41 | /** Create new iCalendar format. */ | ||
42 | SharpFormat(); | ||
43 | virtual ~SharpFormat(); | ||
44 | |||
45 | bool load( Calendar * ,Calendar *); | ||
46 | bool save( Calendar * ); | ||
47 | void setCategoriesList ( QStringList * cat ){ mCategories = cat; } | ||
48 | bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & ); | ||
49 | bool fromString( Calendar *, const QString & ); | ||
50 | QString toString( Calendar * ); | ||
51 | static ulong getCsum( const QStringList & ); | ||
52 | |||
53 | private: | ||
54 | QString getEventString( Event* ); | ||
55 | QString getTodoString( Todo* ); | ||
56 | QString dtToString( const QDateTime& dt, bool useTZ = true ); | ||
57 | |||
58 | QStringList *mCategories; | ||
59 | int getNumFromRecord( QString answer,Incidence* inc ) ; | ||
60 | QString getPart( const QString & text, bool &ok, int &start ); | ||
61 | }; | ||
62 | |||
63 | } | ||
64 | |||
65 | #endif | ||