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