author | zautrix <zautrix> | 2004-12-04 04:53:22 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-04 04:53:22 (UTC) |
commit | 7828f46413766ee5db72dc9bd457eac0868f0646 (patch) (unidiff) | |
tree | d3da09120bdef2b498f836c5b1b97a5b2aa2da99 /korganizer | |
parent | 967f7c879d06961dd7a25d019380c521f7a84792 (diff) | |
download | kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.zip kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.tar.gz kdepimpi-7828f46413766ee5db72dc9bd457eac0868f0646.tar.bz2 |
fixed some bugs
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2321087..3908dbb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3788 +1,3792 @@ | |||
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, "todolistsmall"); | 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( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 422 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 423 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 424 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
425 | SLOT( updateTodo( Todo *, int ) ) ); | 425 | SLOT( updateTodo( Todo *, int ) ) ); |
426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 426 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 427 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
428 | 428 | ||
429 | 429 | ||
430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 430 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 431 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 432 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 433 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
434 | 434 | ||
435 | 435 | ||
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 439 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
440 | SLOT(checkClipboard())); | 440 | SLOT(checkClipboard())); |
441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 441 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
442 | SLOT( processTodoListSelection( Incidence * ) ) ); | 442 | SLOT( processTodoListSelection( Incidence * ) ) ); |
443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 443 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
444 | 444 | ||
445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 445 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
446 | 446 | ||
447 | mDateFrame = new QVBox(0,0,WType_Popup); | 447 | mDateFrame = new QVBox(0,0,WType_Popup); |
448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 448 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 449 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
450 | mDateFrame->setLineWidth(3); | 450 | mDateFrame->setLineWidth(3); |
451 | mDateFrame->hide(); | 451 | mDateFrame->hide(); |
452 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 452 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 453 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
454 | 454 | ||
455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 455 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
456 | 456 | ||
457 | mEventEditor = mDialogManager->getEventEditor(); | 457 | mEventEditor = mDialogManager->getEventEditor(); |
458 | mTodoEditor = mDialogManager->getTodoEditor(); | 458 | mTodoEditor = mDialogManager->getTodoEditor(); |
459 | 459 | ||
460 | mFlagEditDescription = false; | 460 | mFlagEditDescription = false; |
461 | 461 | ||
462 | mSuspendTimer = new QTimer( this ); | 462 | mSuspendTimer = new QTimer( this ); |
463 | mAlarmTimer = new QTimer( this ); | 463 | mAlarmTimer = new QTimer( this ); |
464 | mRecheckAlarmTimer = new QTimer( this ); | 464 | mRecheckAlarmTimer = new QTimer( this ); |
465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 465 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 466 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 467 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
468 | mAlarmDialog = new AlarmDialog( this ); | 468 | mAlarmDialog = new AlarmDialog( this ); |
469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 469 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
470 | mAlarmDialog->setServerNotification( false ); | 470 | mAlarmDialog->setServerNotification( false ); |
471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 471 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
472 | 472 | ||
473 | 473 | ||
474 | #ifndef DESKTOP_VERSION | 474 | #ifndef DESKTOP_VERSION |
475 | //US listen for arriving address resultsets | 475 | //US listen for arriving address resultsets |
476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 476 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 477 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
478 | #endif | 478 | #endif |
479 | 479 | ||
480 | } | 480 | } |
481 | 481 | ||
482 | 482 | ||
483 | CalendarView::~CalendarView() | 483 | CalendarView::~CalendarView() |
484 | { | 484 | { |
485 | // kdDebug() << "~CalendarView()" << endl; | 485 | // kdDebug() << "~CalendarView()" << endl; |
486 | //qDebug("CalendarView::~CalendarView() "); | 486 | //qDebug("CalendarView::~CalendarView() "); |
487 | delete mDialogManager; | 487 | delete mDialogManager; |
488 | delete mViewManager; | 488 | delete mViewManager; |
489 | delete mStorage; | 489 | delete mStorage; |
490 | delete mDateFrame ; | 490 | delete mDateFrame ; |
491 | delete beamDialog; | 491 | delete beamDialog; |
492 | //kdDebug() << "~CalendarView() done" << endl; | 492 | //kdDebug() << "~CalendarView() done" << endl; |
493 | } | 493 | } |
494 | void CalendarView::timerAlarm() | 494 | void CalendarView::timerAlarm() |
495 | { | 495 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 496 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 497 | computeAlarm(mAlarmNotification ); |
498 | } | 498 | } |
499 | 499 | ||
500 | void CalendarView::suspendAlarm() | 500 | void CalendarView::suspendAlarm() |
501 | { | 501 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 502 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 503 | computeAlarm(mSuspendAlarmNotification ); |
504 | 504 | ||
505 | } | 505 | } |
506 | 506 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 507 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 508 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 511 | ||
512 | } | 512 | } |
513 | 513 | ||
514 | void CalendarView::checkNextTimerAlarm() | 514 | void CalendarView::checkNextTimerAlarm() |
515 | { | 515 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 516 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 517 | } |
518 | 518 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 519 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 520 | { |
521 | 521 | ||
522 | QString mess = msg; | 522 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 523 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 524 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 525 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 526 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 527 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 528 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 529 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 530 | if ( len < 2 ) |
531 | error = true; | 531 | error = true; |
532 | else { | 532 | else { |
533 | tempfilename = mess.mid( 13, len ); | 533 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 534 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 535 | error = true; |
536 | } | 536 | } |
537 | if ( ! error ) { | 537 | if ( ! error ) { |
538 | filename = tempfilename; | 538 | filename = tempfilename; |
539 | } | 539 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 540 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 541 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 542 | startAlarm( mAlarmMessage, filename); |
543 | return; | 543 | return; |
544 | } | 544 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 545 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 546 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 547 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 548 | return; |
549 | } | 549 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 550 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 551 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 552 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 553 | if ( len < 2 ) |
554 | error = true; | 554 | error = true; |
555 | else { | 555 | else { |
556 | tempfilename = mess.mid( 10, len ); | 556 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 557 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 558 | error = true; |
559 | } | 559 | } |
560 | if ( error ) { | 560 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 562 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 563 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 565 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 566 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 567 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | // 0 equal | 717 | // 0 equal |
718 | // 1 take local | 718 | // 1 take local |
719 | // 2 take remote | 719 | // 2 take remote |
720 | // 3 cancel | 720 | // 3 cancel |
721 | QDateTime lastSync = mLastCalendarSync; | 721 | QDateTime lastSync = mLastCalendarSync; |
722 | QDateTime localMod = local->lastModified(); | 722 | QDateTime localMod = local->lastModified(); |
723 | QDateTime remoteMod = remote->lastModified(); | 723 | QDateTime remoteMod = remote->lastModified(); |
724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 724 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
725 | bool remCh, locCh; | 725 | bool remCh, locCh; |
726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 726 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
727 | //if ( remCh ) | 727 | //if ( remCh ) |
728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 728 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
729 | locCh = ( localMod > mLastCalendarSync ); | 729 | locCh = ( localMod > mLastCalendarSync ); |
730 | if ( !remCh && ! locCh ) { | 730 | if ( !remCh && ! locCh ) { |
731 | //qDebug("both not changed "); | 731 | //qDebug("both not changed "); |
732 | lastSync = localMod.addDays(1); | 732 | lastSync = localMod.addDays(1); |
733 | if ( mode <= SYNC_PREF_ASK ) | 733 | if ( mode <= SYNC_PREF_ASK ) |
734 | return 0; | 734 | return 0; |
735 | } else { | 735 | } else { |
736 | if ( locCh ) { | 736 | if ( locCh ) { |
737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 737 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
738 | lastSync = localMod.addDays( -1 ); | 738 | lastSync = localMod.addDays( -1 ); |
739 | if ( !remCh ) | 739 | if ( !remCh ) |
740 | remoteMod = ( lastSync.addDays( -1 ) ); | 740 | remoteMod = ( lastSync.addDays( -1 ) ); |
741 | } else { | 741 | } else { |
742 | //qDebug(" not loc changed "); | 742 | //qDebug(" not loc changed "); |
743 | lastSync = localMod.addDays( 1 ); | 743 | lastSync = localMod.addDays( 1 ); |
744 | if ( remCh ) | 744 | if ( remCh ) |
745 | remoteMod =( lastSync.addDays( 1 ) ); | 745 | remoteMod =( lastSync.addDays( 1 ) ); |
746 | 746 | ||
747 | } | 747 | } |
748 | } | 748 | } |
749 | full = true; | 749 | full = true; |
750 | if ( mode < SYNC_PREF_ASK ) | 750 | if ( mode < SYNC_PREF_ASK ) |
751 | mode = SYNC_PREF_ASK; | 751 | mode = SYNC_PREF_ASK; |
752 | } else { | 752 | } else { |
753 | if ( localMod == remoteMod ) | 753 | if ( localMod == remoteMod ) |
754 | // if ( local->revision() == remote->revision() ) | 754 | // if ( local->revision() == remote->revision() ) |
755 | return 0; | 755 | return 0; |
756 | 756 | ||
757 | } | 757 | } |
758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 758 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
759 | 759 | ||
760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 760 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 761 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
762 | //full = true; //debug only | 762 | //full = true; //debug only |
763 | if ( full ) { | 763 | if ( full ) { |
764 | bool equ = false; | 764 | bool equ = false; |
765 | if ( local->type() == "Event" ) { | 765 | if ( local->type() == "Event" ) { |
766 | equ = (*((Event*) local) == *((Event*) remote)); | 766 | equ = (*((Event*) local) == *((Event*) remote)); |
767 | } | 767 | } |
768 | else if ( local->type() =="Todo" ) | 768 | else if ( local->type() =="Todo" ) |
769 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 769 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
770 | else if ( local->type() =="Journal" ) | 770 | else if ( local->type() =="Journal" ) |
771 | equ = (*((Journal*) local) == *((Journal*) remote)); | 771 | equ = (*((Journal*) local) == *((Journal*) remote)); |
772 | if ( equ ) { | 772 | if ( equ ) { |
773 | //qDebug("equal "); | 773 | //qDebug("equal "); |
774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 774 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 775 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
776 | } | 776 | } |
777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 777 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
778 | return 0; | 778 | return 0; |
779 | 779 | ||
780 | }//else //debug only | 780 | }//else //debug only |
781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 781 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
782 | } | 782 | } |
783 | int result; | 783 | int result; |
784 | bool localIsNew; | 784 | bool localIsNew; |
785 | //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() ); | 785 | //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() ); |
786 | 786 | ||
787 | if ( full && mode < SYNC_PREF_NEWEST ) | 787 | if ( full && mode < SYNC_PREF_NEWEST ) |
788 | mode = SYNC_PREF_ASK; | 788 | mode = SYNC_PREF_ASK; |
789 | 789 | ||
790 | switch( mode ) { | 790 | switch( mode ) { |
791 | case SYNC_PREF_LOCAL: | 791 | case SYNC_PREF_LOCAL: |
792 | if ( lastSync > remoteMod ) | 792 | if ( lastSync > remoteMod ) |
793 | return 1; | 793 | return 1; |
794 | if ( lastSync > localMod ) | 794 | if ( lastSync > localMod ) |
795 | return 2; | 795 | return 2; |
796 | return 1; | 796 | return 1; |
797 | break; | 797 | break; |
798 | case SYNC_PREF_REMOTE: | 798 | case SYNC_PREF_REMOTE: |
799 | if ( lastSync > remoteMod ) | 799 | if ( lastSync > remoteMod ) |
800 | return 1; | 800 | return 1; |
801 | if ( lastSync > localMod ) | 801 | if ( lastSync > localMod ) |
802 | return 2; | 802 | return 2; |
803 | return 2; | 803 | return 2; |
804 | break; | 804 | break; |
805 | case SYNC_PREF_NEWEST: | 805 | case SYNC_PREF_NEWEST: |
806 | if ( localMod > remoteMod ) | 806 | if ( localMod > remoteMod ) |
807 | return 1; | 807 | return 1; |
808 | else | 808 | else |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_ASK: | 811 | case SYNC_PREF_ASK: |
812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 812 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
813 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
814 | return 1; | 814 | return 1; |
815 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
816 | return 2; | 816 | return 2; |
817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 817 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
818 | localIsNew = localMod >= remoteMod; | 818 | localIsNew = localMod >= remoteMod; |
819 | if ( localIsNew ) | 819 | if ( localIsNew ) |
820 | getEventViewerDialog()->setColorMode( 1 ); | 820 | getEventViewerDialog()->setColorMode( 1 ); |
821 | else | 821 | else |
822 | getEventViewerDialog()->setColorMode( 2 ); | 822 | getEventViewerDialog()->setColorMode( 2 ); |
823 | getEventViewerDialog()->setIncidence(local); | 823 | getEventViewerDialog()->setIncidence(local); |
824 | if ( localIsNew ) | 824 | if ( localIsNew ) |
825 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
826 | else | 826 | else |
827 | getEventViewerDialog()->setColorMode( 1 ); | 827 | getEventViewerDialog()->setColorMode( 1 ); |
828 | getEventViewerDialog()->addIncidence(remote); | 828 | getEventViewerDialog()->addIncidence(remote); |
829 | getEventViewerDialog()->setColorMode( 0 ); | 829 | getEventViewerDialog()->setColorMode( 0 ); |
830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 830 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 831 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
832 | getEventViewerDialog()->showMe(); | 832 | getEventViewerDialog()->showMe(); |
833 | result = getEventViewerDialog()->executeS( localIsNew ); | 833 | result = getEventViewerDialog()->executeS( localIsNew ); |
834 | return result; | 834 | return result; |
835 | 835 | ||
836 | break; | 836 | break; |
837 | case SYNC_PREF_FORCE_LOCAL: | 837 | case SYNC_PREF_FORCE_LOCAL: |
838 | return 1; | 838 | return 1; |
839 | break; | 839 | break; |
840 | case SYNC_PREF_FORCE_REMOTE: | 840 | case SYNC_PREF_FORCE_REMOTE: |
841 | return 2; | 841 | return 2; |
842 | break; | 842 | break; |
843 | 843 | ||
844 | default: | 844 | default: |
845 | // SYNC_PREF_TAKE_BOTH not implemented | 845 | // SYNC_PREF_TAKE_BOTH not implemented |
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | return 0; | 848 | return 0; |
849 | } | 849 | } |
850 | Event* CalendarView::getLastSyncEvent() | 850 | Event* CalendarView::getLastSyncEvent() |
851 | { | 851 | { |
852 | Event* lse; | 852 | Event* lse; |
853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 853 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 854 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
855 | if (!lse) { | 855 | if (!lse) { |
856 | lse = new Event(); | 856 | lse = new Event(); |
857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
858 | QString sum = ""; | 858 | QString sum = ""; |
859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 859 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
860 | sum = "E: "; | 860 | sum = "E: "; |
861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 861 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
862 | lse->setDtStart( mLastCalendarSync ); | 862 | lse->setDtStart( mLastCalendarSync ); |
863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 863 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
864 | lse->setCategories( i18n("SyncEvent") ); | 864 | lse->setCategories( i18n("SyncEvent") ); |
865 | lse->setReadOnly( true ); | 865 | lse->setReadOnly( true ); |
866 | mCalendar->addEvent( lse ); | 866 | mCalendar->addEvent( lse ); |
867 | } | 867 | } |
868 | 868 | ||
869 | return lse; | 869 | return lse; |
870 | 870 | ||
871 | } | 871 | } |
872 | 872 | ||
873 | // we check, if the to delete event has a id for a profile | 873 | // we check, if the to delete event has a id for a profile |
874 | // if yes, we set this id in the profile to delete | 874 | // if yes, we set this id in the profile to delete |
875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 875 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
876 | { | 876 | { |
877 | if ( lastSync.count() == 0 ) { | 877 | if ( lastSync.count() == 0 ) { |
878 | //qDebug(" lastSync.count() == 0"); | 878 | //qDebug(" lastSync.count() == 0"); |
879 | return; | 879 | return; |
880 | } | 880 | } |
881 | if ( toDelete->type() == "Journal" ) | 881 | if ( toDelete->type() == "Journal" ) |
882 | return; | 882 | return; |
883 | 883 | ||
884 | Event* eve = lastSync.first(); | 884 | Event* eve = lastSync.first(); |
885 | 885 | ||
886 | while ( eve ) { | 886 | while ( eve ) { |
887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 887 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
888 | if ( !id.isEmpty() ) { | 888 | if ( !id.isEmpty() ) { |
889 | QString des = eve->description(); | 889 | QString des = eve->description(); |
890 | QString pref = "e"; | 890 | QString pref = "e"; |
891 | if ( toDelete->type() == "Todo" ) | 891 | if ( toDelete->type() == "Todo" ) |
892 | pref = "t"; | 892 | pref = "t"; |
893 | des += pref+ id + ","; | 893 | des += pref+ id + ","; |
894 | eve->setReadOnly( false ); | 894 | eve->setReadOnly( false ); |
895 | eve->setDescription( des ); | 895 | eve->setDescription( des ); |
896 | //qDebug("setdes %s ", des.latin1()); | 896 | //qDebug("setdes %s ", des.latin1()); |
897 | eve->setReadOnly( true ); | 897 | eve->setReadOnly( true ); |
898 | } | 898 | } |
899 | eve = lastSync.next(); | 899 | eve = lastSync.next(); |
900 | } | 900 | } |
901 | 901 | ||
902 | } | 902 | } |
903 | void CalendarView::checkExternalId( Incidence * inc ) | 903 | void CalendarView::checkExternalId( Incidence * inc ) |
904 | { | 904 | { |
905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 905 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
906 | checkExternSyncEvent( lastSync, inc ); | 906 | checkExternSyncEvent( lastSync, inc ); |
907 | 907 | ||
908 | } | 908 | } |
909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 909 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
910 | { | 910 | { |
911 | bool syncOK = true; | 911 | bool syncOK = true; |
912 | int addedEvent = 0; | 912 | int addedEvent = 0; |
913 | int addedEventR = 0; | 913 | int addedEventR = 0; |
914 | int deletedEventR = 0; | 914 | int deletedEventR = 0; |
915 | int deletedEventL = 0; | 915 | int deletedEventL = 0; |
916 | int changedLocal = 0; | 916 | int changedLocal = 0; |
917 | int changedRemote = 0; | 917 | int changedRemote = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncManager->syncWithDesktop() ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync; | 939 | QDateTime modifiedCalendar = mLastCalendarSync; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | int w = 300; | 990 | int w = 300; |
991 | if ( QApplication::desktop()->width() < 320 ) | 991 | if ( QApplication::desktop()->width() < 320 ) |
992 | w = 220; | 992 | w = 220; |
993 | int h = bar.sizeHint().height() ; | 993 | int h = bar.sizeHint().height() ; |
994 | int dw = QApplication::desktop()->width(); | 994 | int dw = QApplication::desktop()->width(); |
995 | int dh = QApplication::desktop()->height(); | 995 | int dh = QApplication::desktop()->height(); |
996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 996 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
997 | bar.show(); | 997 | bar.show(); |
998 | int modulo = (er.count()/10)+1; | 998 | int modulo = (er.count()/10)+1; |
999 | int incCounter = 0; | 999 | int incCounter = 0; |
1000 | while ( inR ) { | 1000 | while ( inR ) { |
1001 | if ( ! bar.isVisible() ) | 1001 | if ( ! bar.isVisible() ) |
1002 | return false; | 1002 | return false; |
1003 | if ( incCounter % modulo == 0 ) | 1003 | if ( incCounter % modulo == 0 ) |
1004 | bar.setProgress( incCounter ); | 1004 | bar.setProgress( incCounter ); |
1005 | ++incCounter; | 1005 | ++incCounter; |
1006 | uid = inR->uid(); | 1006 | uid = inR->uid(); |
1007 | bool skipIncidence = false; | 1007 | bool skipIncidence = false; |
1008 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1008 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1009 | skipIncidence = true; | 1009 | skipIncidence = true; |
1010 | QString idS; | 1010 | QString idS; |
1011 | qApp->processEvents(); | 1011 | qApp->processEvents(); |
1012 | if ( !skipIncidence ) { | 1012 | if ( !skipIncidence ) { |
1013 | inL = local->incidence( uid ); | 1013 | inL = local->incidence( uid ); |
1014 | if ( inL ) { // maybe conflict - same uid in both calendars | 1014 | if ( inL ) { // maybe conflict - same uid in both calendars |
1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1015 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1016 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1017 | if ( take == 3 ) | 1017 | if ( take == 3 ) |
1018 | return false; | 1018 | return false; |
1019 | if ( take == 1 ) {// take local ********************** | 1019 | if ( take == 1 ) {// take local ********************** |
1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1020 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1021 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1022 | else | 1022 | else |
1023 | idS = inR->IDStr(); | 1023 | idS = inR->IDStr(); |
1024 | remote->deleteIncidence( inR ); | 1024 | remote->deleteIncidence( inR ); |
1025 | inR = inL->clone(); | 1025 | inR = inL->clone(); |
1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1026 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1027 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1028 | inR->setIDStr( idS ); | 1028 | inR->setIDStr( idS ); |
1029 | remote->addIncidence( inR ); | 1029 | remote->addIncidence( inR ); |
1030 | if ( mSyncManager->syncWithDesktop() ) | 1030 | if ( mSyncManager->syncWithDesktop() ) |
1031 | inR->setPilotId( 2 ); | 1031 | inR->setPilotId( 2 ); |
1032 | ++changedRemote; | 1032 | ++changedRemote; |
1033 | } else {// take remote ********************** | 1033 | } else {// take remote ********************** |
1034 | idS = inL->IDStr(); | 1034 | idS = inL->IDStr(); |
1035 | int pid = inL->pilotId(); | 1035 | int pid = inL->pilotId(); |
1036 | local->deleteIncidence( inL ); | 1036 | local->deleteIncidence( inL ); |
1037 | inL = inR->clone(); | 1037 | inL = inR->clone(); |
1038 | if ( mSyncManager->syncWithDesktop() ) | 1038 | if ( mSyncManager->syncWithDesktop() ) |
1039 | inL->setPilotId( pid ); | 1039 | inL->setPilotId( pid ); |
1040 | inL->setIDStr( idS ); | 1040 | inL->setIDStr( idS ); |
1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1041 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1042 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1043 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1044 | } | 1044 | } |
1045 | local->addIncidence( inL ); | 1045 | local->addIncidence( inL ); |
1046 | ++changedLocal; | 1046 | ++changedLocal; |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | } else { // no conflict ********** add or delete remote | 1049 | } else { // no conflict ********** add or delete remote |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1051 | QString des = eventLSync->description(); | 1051 | QString des = eventLSync->description(); |
1052 | QString pref = "e"; | 1052 | QString pref = "e"; |
1053 | if ( inR->type() == "Todo" ) | 1053 | if ( inR->type() == "Todo" ) |
1054 | pref = "t"; | 1054 | pref = "t"; |
1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1055 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1057 | //remote->deleteIncidence( inR ); | 1057 | //remote->deleteIncidence( inR ); |
1058 | ++deletedEventR; | 1058 | ++deletedEventR; |
1059 | } else { | 1059 | } else { |
1060 | inR->setLastModified( modifiedCalendar ); | 1060 | inR->setLastModified( modifiedCalendar ); |
1061 | inL = inR->clone(); | 1061 | inL = inR->clone(); |
1062 | inL->setIDStr( ":" ); | 1062 | inL->setIDStr( ":" ); |
1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1063 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1064 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1065 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1066 | ++addedEvent; | 1066 | ++addedEvent; |
1067 | } | 1067 | } |
1068 | } else { | 1068 | } else { |
1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1070 | inR->setLastModified( modifiedCalendar ); | 1070 | inR->setLastModified( modifiedCalendar ); |
1071 | inL = inR->clone(); | 1071 | inL = inR->clone(); |
1072 | inL->setIDStr( ":" ); | 1072 | inL->setIDStr( ":" ); |
1073 | local->addIncidence( inL ); | 1073 | local->addIncidence( inL ); |
1074 | ++addedEvent; | 1074 | ++addedEvent; |
1075 | } else { | 1075 | } else { |
1076 | checkExternSyncEvent(eventRSyncSharp, inR); | 1076 | checkExternSyncEvent(eventRSyncSharp, inR); |
1077 | remote->deleteIncidence( inR ); | 1077 | remote->deleteIncidence( inR ); |
1078 | ++deletedEventR; | 1078 | ++deletedEventR; |
1079 | } | 1079 | } |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | inR = er.next(); | 1083 | inR = er.next(); |
1084 | } | 1084 | } |
1085 | QPtrList<Incidence> el = local->rawIncidences(); | 1085 | QPtrList<Incidence> el = local->rawIncidences(); |
1086 | inL = el.first(); | 1086 | inL = el.first(); |
1087 | modulo = (el.count()/10)+1; | 1087 | modulo = (el.count()/10)+1; |
1088 | bar.setCaption (i18n("Add / remove events") ); | 1088 | bar.setCaption (i18n("Add / remove events") ); |
1089 | bar.setTotalSteps ( el.count() ) ; | 1089 | bar.setTotalSteps ( el.count() ) ; |
1090 | bar.show(); | 1090 | bar.show(); |
1091 | incCounter = 0; | 1091 | incCounter = 0; |
1092 | 1092 | ||
1093 | while ( inL ) { | 1093 | while ( inL ) { |
1094 | 1094 | ||
1095 | qApp->processEvents(); | 1095 | qApp->processEvents(); |
1096 | if ( ! bar.isVisible() ) | 1096 | if ( ! bar.isVisible() ) |
1097 | return false; | 1097 | return false; |
1098 | if ( incCounter % modulo == 0 ) | 1098 | if ( incCounter % modulo == 0 ) |
1099 | bar.setProgress( incCounter ); | 1099 | bar.setProgress( incCounter ); |
1100 | ++incCounter; | 1100 | ++incCounter; |
1101 | uid = inL->uid(); | 1101 | uid = inL->uid(); |
1102 | bool skipIncidence = false; | 1102 | bool skipIncidence = false; |
1103 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1103 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1104 | skipIncidence = true; | 1104 | skipIncidence = true; |
1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1105 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1106 | skipIncidence = true; | 1106 | skipIncidence = true; |
1107 | if ( !skipIncidence ) { | 1107 | if ( !skipIncidence ) { |
1108 | inR = remote->incidence( uid ); | 1108 | inR = remote->incidence( uid ); |
1109 | if ( ! inR ) { // no conflict ********** add or delete local | 1109 | if ( ! inR ) { // no conflict ********** add or delete local |
1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1110 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1111 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1112 | checkExternSyncEvent(eventLSyncSharp, inL); | 1112 | checkExternSyncEvent(eventLSyncSharp, inL); |
1113 | local->deleteIncidence( inL ); | 1113 | local->deleteIncidence( inL ); |
1114 | ++deletedEventL; | 1114 | ++deletedEventL; |
1115 | } else { | 1115 | } else { |
1116 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1116 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1117 | inL->removeID(mCurrentSyncDevice ); | 1117 | inL->removeID(mCurrentSyncDevice ); |
1118 | ++addedEventR; | 1118 | ++addedEventR; |
1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1119 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1120 | inL->setLastModified( modifiedCalendar ); | 1120 | inL->setLastModified( modifiedCalendar ); |
1121 | inR = inL->clone(); | 1121 | inR = inL->clone(); |
1122 | inR->setIDStr( ":" ); | 1122 | inR->setIDStr( ":" ); |
1123 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1123 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1124 | remote->addIncidence( inR ); | 1124 | remote->addIncidence( inR ); |
1125 | } | 1125 | } |
1126 | } | 1126 | } |
1127 | } else { | 1127 | } else { |
1128 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1128 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1129 | checkExternSyncEvent(eventLSyncSharp, inL); | 1129 | checkExternSyncEvent(eventLSyncSharp, inL); |
1130 | local->deleteIncidence( inL ); | 1130 | local->deleteIncidence( inL ); |
1131 | ++deletedEventL; | 1131 | ++deletedEventL; |
1132 | } else { | 1132 | } else { |
1133 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1133 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1134 | ++addedEventR; | 1134 | ++addedEventR; |
1135 | inL->setLastModified( modifiedCalendar ); | 1135 | inL->setLastModified( modifiedCalendar ); |
1136 | inR = inL->clone(); | 1136 | inR = inL->clone(); |
1137 | inR->setIDStr( ":" ); | 1137 | inR->setIDStr( ":" ); |
1138 | remote->addIncidence( inR ); | 1138 | remote->addIncidence( inR ); |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | } | 1142 | } |
1143 | } | 1143 | } |
1144 | inL = el.next(); | 1144 | inL = el.next(); |
1145 | } | 1145 | } |
1146 | int delFut = 0; | 1146 | int delFut = 0; |
1147 | int remRem = 0; | 1147 | int remRem = 0; |
1148 | if ( mSyncManager->mWriteBackInFuture ) { | 1148 | if ( mSyncManager->mWriteBackInFuture ) { |
1149 | er = remote->rawIncidences(); | 1149 | er = remote->rawIncidences(); |
1150 | remRem = er.count(); | 1150 | remRem = er.count(); |
1151 | inR = er.first(); | 1151 | inR = er.first(); |
1152 | QDateTime dt; | 1152 | QDateTime dt; |
1153 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1153 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1154 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1154 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1155 | while ( inR ) { | 1155 | while ( inR ) { |
1156 | if ( inR->type() == "Todo" ) { | 1156 | if ( inR->type() == "Todo" ) { |
1157 | Todo * t = (Todo*)inR; | 1157 | Todo * t = (Todo*)inR; |
1158 | if ( t->hasDueDate() ) | 1158 | if ( t->hasDueDate() ) |
1159 | dt = t->dtDue(); | 1159 | dt = t->dtDue(); |
1160 | else | 1160 | else |
1161 | dt = cur.addSecs( 62 ); | 1161 | dt = cur.addSecs( 62 ); |
1162 | } | 1162 | } |
1163 | else if (inR->type() == "Event" ) { | 1163 | else if (inR->type() == "Event" ) { |
1164 | bool ok; | 1164 | bool ok; |
1165 | dt = inR->getNextOccurence( cur, &ok ); | 1165 | dt = inR->getNextOccurence( cur, &ok ); |
1166 | if ( !ok ) | 1166 | if ( !ok ) |
1167 | dt = cur.addSecs( -62 ); | 1167 | dt = cur.addSecs( -62 ); |
1168 | } | 1168 | } |
1169 | else | 1169 | else |
1170 | dt = inR->dtStart(); | 1170 | dt = inR->dtStart(); |
1171 | if ( dt < cur || dt > end ) { | 1171 | if ( dt < cur || dt > end ) { |
1172 | remote->deleteIncidence( inR ); | 1172 | remote->deleteIncidence( inR ); |
1173 | ++delFut; | 1173 | ++delFut; |
1174 | } | 1174 | } |
1175 | inR = er.next(); | 1175 | inR = er.next(); |
1176 | } | 1176 | } |
1177 | } | 1177 | } |
1178 | bar.hide(); | 1178 | bar.hide(); |
1179 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1179 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1180 | eventLSync->setReadOnly( false ); | 1180 | eventLSync->setReadOnly( false ); |
1181 | eventLSync->setDtStart( mLastCalendarSync ); | 1181 | eventLSync->setDtStart( mLastCalendarSync ); |
1182 | eventRSync->setDtStart( mLastCalendarSync ); | 1182 | eventRSync->setDtStart( mLastCalendarSync ); |
1183 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1183 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1184 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1184 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1185 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1185 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1186 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1186 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1187 | eventLSync->setReadOnly( true ); | 1187 | eventLSync->setReadOnly( true ); |
1188 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); | 1188 | qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); |
1189 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1189 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1190 | remote->addEvent( eventRSync ); | 1190 | remote->addEvent( eventRSync ); |
1191 | else | 1191 | else |
1192 | delete eventRSync; | 1192 | delete eventRSync; |
1193 | QString mes; | 1193 | QString mes; |
1194 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1194 | 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 ); |
1195 | QString delmess; | 1195 | QString delmess; |
1196 | if ( delFut ) { | 1196 | if ( delFut ) { |
1197 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1197 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1198 | mes += delmess; | 1198 | mes += delmess; |
1199 | } | 1199 | } |
1200 | mes = i18n("Local calendar changed!\n") +mes; | 1200 | mes = i18n("Local calendar changed!\n") +mes; |
1201 | mCalendar->checkAlarmForIncidence( 0, true ); | 1201 | mCalendar->checkAlarmForIncidence( 0, true ); |
1202 | qDebug( mes ); | 1202 | qDebug( mes ); |
1203 | if ( mSyncManager->mShowSyncSummary ) { | 1203 | if ( mSyncManager->mShowSyncSummary ) { |
1204 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1204 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1205 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1205 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1206 | qDebug("cancelled "); | 1206 | qDebug("cancelled "); |
1207 | return false; | 1207 | return false; |
1208 | } | 1208 | } |
1209 | } | 1209 | } |
1210 | return syncOK; | 1210 | return syncOK; |
1211 | } | 1211 | } |
1212 | 1212 | ||
1213 | void CalendarView::setSyncDevice( QString s ) | 1213 | void CalendarView::setSyncDevice( QString s ) |
1214 | { | 1214 | { |
1215 | mCurrentSyncDevice= s; | 1215 | mCurrentSyncDevice= s; |
1216 | } | 1216 | } |
1217 | void CalendarView::setSyncName( QString s ) | 1217 | void CalendarView::setSyncName( QString s ) |
1218 | { | 1218 | { |
1219 | mCurrentSyncName= s; | 1219 | mCurrentSyncName= s; |
1220 | } | 1220 | } |
1221 | bool CalendarView::syncCalendar(QString filename, int mode) | 1221 | bool CalendarView::syncCalendar(QString filename, int mode) |
1222 | { | 1222 | { |
1223 | //qDebug("syncCalendar %s ", filename.latin1()); | 1223 | //qDebug("syncCalendar %s ", filename.latin1()); |
1224 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1224 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1225 | CalendarLocal* calendar = new CalendarLocal(); | 1225 | CalendarLocal* calendar = new CalendarLocal(); |
1226 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1226 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1227 | FileStorage* storage = new FileStorage( calendar ); | 1227 | FileStorage* storage = new FileStorage( calendar ); |
1228 | bool syncOK = false; | 1228 | bool syncOK = false; |
1229 | storage->setFileName( filename ); | 1229 | storage->setFileName( filename ); |
1230 | // qDebug("loading ... "); | 1230 | // qDebug("loading ... "); |
1231 | if ( storage->load() ) { | 1231 | if ( storage->load() ) { |
1232 | getEventViewerDialog()->setSyncMode( true ); | 1232 | getEventViewerDialog()->setSyncMode( true ); |
1233 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1233 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1234 | getEventViewerDialog()->setSyncMode( false ); | 1234 | getEventViewerDialog()->setSyncMode( false ); |
1235 | if ( syncOK ) { | 1235 | if ( syncOK ) { |
1236 | if ( mSyncManager->mWriteBackFile ) | 1236 | if ( mSyncManager->mWriteBackFile ) |
1237 | { | 1237 | { |
1238 | storage->setSaveFormat( new ICalFormat() ); | 1238 | storage->setSaveFormat( new ICalFormat() ); |
1239 | storage->save(); | 1239 | storage->save(); |
1240 | } | 1240 | } |
1241 | } | 1241 | } |
1242 | setModified( true ); | 1242 | setModified( true ); |
1243 | } | 1243 | } |
1244 | delete storage; | 1244 | delete storage; |
1245 | delete calendar; | 1245 | delete calendar; |
1246 | if ( syncOK ) | 1246 | if ( syncOK ) |
1247 | updateView(); | 1247 | updateView(); |
1248 | return syncOK; | 1248 | return syncOK; |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | void CalendarView::syncExternal( int mode ) | 1251 | void CalendarView::syncExternal( int mode ) |
1252 | { | 1252 | { |
1253 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1253 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1254 | 1254 | ||
1255 | qApp->processEvents(); | 1255 | qApp->processEvents(); |
1256 | CalendarLocal* calendar = new CalendarLocal(); | 1256 | CalendarLocal* calendar = new CalendarLocal(); |
1257 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1257 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1258 | bool syncOK = false; | 1258 | bool syncOK = false; |
1259 | bool loadSuccess = false; | 1259 | bool loadSuccess = false; |
1260 | PhoneFormat* phoneFormat = 0; | 1260 | PhoneFormat* phoneFormat = 0; |
1261 | emit tempDisableBR(true); | 1261 | emit tempDisableBR(true); |
1262 | #ifndef DESKTOP_VERSION | 1262 | #ifndef DESKTOP_VERSION |
1263 | SharpFormat* sharpFormat = 0; | 1263 | SharpFormat* sharpFormat = 0; |
1264 | if ( mode == 0 ) { // sharp | 1264 | if ( mode == 0 ) { // sharp |
1265 | sharpFormat = new SharpFormat () ; | 1265 | sharpFormat = new SharpFormat () ; |
1266 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1266 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1267 | 1267 | ||
1268 | } else | 1268 | } else |
1269 | #endif | 1269 | #endif |
1270 | if ( mode == 1 ) { // phone | 1270 | if ( mode == 1 ) { // phone |
1271 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1271 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1272 | mSyncManager->mPhoneDevice, | 1272 | mSyncManager->mPhoneDevice, |
1273 | mSyncManager->mPhoneConnection, | 1273 | mSyncManager->mPhoneConnection, |
1274 | mSyncManager->mPhoneModel); | 1274 | mSyncManager->mPhoneModel); |
1275 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1275 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1276 | 1276 | ||
1277 | } else { | 1277 | } else { |
1278 | emit tempDisableBR(false); | 1278 | emit tempDisableBR(false); |
1279 | return; | 1279 | return; |
1280 | } | 1280 | } |
1281 | if ( loadSuccess ) { | 1281 | if ( loadSuccess ) { |
1282 | getEventViewerDialog()->setSyncMode( true ); | 1282 | getEventViewerDialog()->setSyncMode( true ); |
1283 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1283 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1284 | getEventViewerDialog()->setSyncMode( false ); | 1284 | getEventViewerDialog()->setSyncMode( false ); |
1285 | qApp->processEvents(); | 1285 | qApp->processEvents(); |
1286 | if ( syncOK ) { | 1286 | if ( syncOK ) { |
1287 | if ( mSyncManager->mWriteBackFile ) | 1287 | if ( mSyncManager->mWriteBackFile ) |
1288 | { | 1288 | { |
1289 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1289 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1290 | Incidence* inc = iL.first(); | 1290 | Incidence* inc = iL.first(); |
1291 | if ( phoneFormat ) { | 1291 | if ( phoneFormat ) { |
1292 | while ( inc ) { | 1292 | while ( inc ) { |
1293 | inc->removeID(mCurrentSyncDevice); | 1293 | inc->removeID(mCurrentSyncDevice); |
1294 | inc = iL.next(); | 1294 | inc = iL.next(); |
1295 | } | 1295 | } |
1296 | } | 1296 | } |
1297 | #ifndef DESKTOP_VERSION | 1297 | #ifndef DESKTOP_VERSION |
1298 | if ( sharpFormat ) | 1298 | if ( sharpFormat ) |
1299 | sharpFormat->save(calendar); | 1299 | sharpFormat->save(calendar); |
1300 | #endif | 1300 | #endif |
1301 | if ( phoneFormat ) | 1301 | if ( phoneFormat ) |
1302 | phoneFormat->save(calendar); | 1302 | phoneFormat->save(calendar); |
1303 | iL = calendar->rawIncidences(); | 1303 | iL = calendar->rawIncidences(); |
1304 | inc = iL.first(); | 1304 | inc = iL.first(); |
1305 | Incidence* loc; | 1305 | Incidence* loc; |
1306 | while ( inc ) { | 1306 | while ( inc ) { |
1307 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1307 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1308 | loc = mCalendar->incidence(inc->uid() ); | 1308 | loc = mCalendar->incidence(inc->uid() ); |
1309 | if ( loc ) { | 1309 | if ( loc ) { |
1310 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1310 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1311 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1311 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | inc = iL.next(); | 1314 | inc = iL.next(); |
1315 | } | 1315 | } |
1316 | Incidence* lse = getLastSyncEvent(); | 1316 | Incidence* lse = getLastSyncEvent(); |
1317 | if ( lse ) { | 1317 | if ( lse ) { |
1318 | lse->setReadOnly( false ); | 1318 | lse->setReadOnly( false ); |
1319 | lse->setDescription( "" ); | 1319 | lse->setDescription( "" ); |
1320 | lse->setReadOnly( true ); | 1320 | lse->setReadOnly( true ); |
1321 | } | 1321 | } |
1322 | } | 1322 | } |
1323 | } else { | 1323 | } else { |
1324 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1324 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1325 | } | 1325 | } |
1326 | setModified( true ); | 1326 | setModified( true ); |
1327 | } else { | 1327 | } else { |
1328 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1328 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1329 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1329 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1330 | question, i18n("Ok")) ; | 1330 | question, i18n("Ok")) ; |
1331 | 1331 | ||
1332 | } | 1332 | } |
1333 | delete calendar; | 1333 | delete calendar; |
1334 | updateView(); | 1334 | updateView(); |
1335 | emit tempDisableBR(false); | 1335 | emit tempDisableBR(false); |
1336 | return ;//syncOK; | 1336 | return ;//syncOK; |
1337 | 1337 | ||
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | bool CalendarView::importBday() | 1340 | bool CalendarView::importBday() |
1341 | { | 1341 | { |
1342 | #ifndef KORG_NOKABC | 1342 | #ifndef KORG_NOKABC |
1343 | 1343 | ||
1344 | #ifdef DESKTOP_VERSION | 1344 | #ifdef DESKTOP_VERSION |
1345 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1345 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1346 | KABC::AddressBook::Iterator it; | 1346 | KABC::AddressBook::Iterator it; |
1347 | int count = 0; | 1347 | int count = 0; |
1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1349 | ++count; | 1349 | ++count; |
1350 | } | 1350 | } |
1351 | QProgressBar bar(count,0 ); | 1351 | QProgressBar bar(count,0 ); |
1352 | int w = 300; | 1352 | int w = 300; |
1353 | if ( QApplication::desktop()->width() < 320 ) | 1353 | if ( QApplication::desktop()->width() < 320 ) |
1354 | w = 220; | 1354 | w = 220; |
1355 | int h = bar.sizeHint().height() ; | 1355 | int h = bar.sizeHint().height() ; |
1356 | int dw = QApplication::desktop()->width(); | 1356 | int dw = QApplication::desktop()->width(); |
1357 | int dh = QApplication::desktop()->height(); | 1357 | int dh = QApplication::desktop()->height(); |
1358 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1358 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1359 | bar.show(); | 1359 | bar.show(); |
1360 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1360 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1361 | qApp->processEvents(); | 1361 | qApp->processEvents(); |
1362 | count = 0; | 1362 | count = 0; |
1363 | int addCount = 0; | 1363 | int addCount = 0; |
1364 | KCal::Attendee* a = 0; | 1364 | KCal::Attendee* a = 0; |
1365 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1365 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1366 | if ( ! bar.isVisible() ) | 1366 | if ( ! bar.isVisible() ) |
1367 | return false; | 1367 | return false; |
1368 | bar.setProgress( count++ ); | 1368 | bar.setProgress( count++ ); |
1369 | qApp->processEvents(); | 1369 | qApp->processEvents(); |
1370 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1370 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1371 | if ( (*it).birthday().date().isValid() ){ | 1371 | if ( (*it).birthday().date().isValid() ){ |
1372 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1372 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1373 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1373 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1374 | ++addCount; | 1374 | ++addCount; |
1375 | } | 1375 | } |
1376 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1376 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1377 | if ( anni.isValid() ){ | 1377 | if ( anni.isValid() ){ |
1378 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1378 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1379 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1379 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1380 | ++addCount; | 1380 | ++addCount; |
1381 | } | 1381 | } |
1382 | } | 1382 | } |
1383 | updateView(); | 1383 | updateView(); |
1384 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1384 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1385 | #else //DESKTOP_VERSION | 1385 | #else //DESKTOP_VERSION |
1386 | 1386 | ||
1387 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1387 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1388 | // the result should now arrive through method insertBirthdays | 1388 | // the result should now arrive through method insertBirthdays |
1389 | 1389 | ||
1390 | #endif //DESKTOP_VERSION | 1390 | #endif //DESKTOP_VERSION |
1391 | 1391 | ||
1392 | #endif //KORG_NOKABC | 1392 | #endif //KORG_NOKABC |
1393 | 1393 | ||
1394 | 1394 | ||
1395 | return true; | 1395 | return true; |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1398 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1399 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1399 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1400 | const QStringList& anniversaryList, const QStringList& realNameList, | 1400 | const QStringList& anniversaryList, const QStringList& realNameList, |
1401 | const QStringList& emailList, const QStringList& assembledNameList, | 1401 | const QStringList& emailList, const QStringList& assembledNameList, |
1402 | const QStringList& uidList) | 1402 | const QStringList& uidList) |
1403 | { | 1403 | { |
1404 | qDebug("CalendarView::insertBirthdays"); | 1404 | qDebug("CalendarView::insertBirthdays"); |
1405 | if (uid == this->name()) | 1405 | if (uid == this->name()) |
1406 | { | 1406 | { |
1407 | int count = birthdayList.count(); | 1407 | int count = birthdayList.count(); |
1408 | int addCount = 0; | 1408 | int addCount = 0; |
1409 | KCal::Attendee* a = 0; | 1409 | KCal::Attendee* a = 0; |
1410 | 1410 | ||
1411 | qDebug("CalView 1 %i", count); | 1411 | qDebug("CalView 1 %i", count); |
1412 | 1412 | ||
1413 | QProgressBar bar(count,0 ); | 1413 | QProgressBar bar(count,0 ); |
1414 | int w = 300; | 1414 | int w = 300; |
1415 | if ( QApplication::desktop()->width() < 320 ) | 1415 | if ( QApplication::desktop()->width() < 320 ) |
1416 | w = 220; | 1416 | w = 220; |
1417 | int h = bar.sizeHint().height() ; | 1417 | int h = bar.sizeHint().height() ; |
1418 | int dw = QApplication::desktop()->width(); | 1418 | int dw = QApplication::desktop()->width(); |
1419 | int dh = QApplication::desktop()->height(); | 1419 | int dh = QApplication::desktop()->height(); |
1420 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1420 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1421 | bar.show(); | 1421 | bar.show(); |
1422 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1422 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1423 | qApp->processEvents(); | 1423 | qApp->processEvents(); |
1424 | 1424 | ||
1425 | QDate birthday; | 1425 | QDate birthday; |
1426 | QDate anniversary; | 1426 | QDate anniversary; |
1427 | QString realName; | 1427 | QString realName; |
1428 | QString email; | 1428 | QString email; |
1429 | QString assembledName; | 1429 | QString assembledName; |
1430 | QString uid; | 1430 | QString uid; |
1431 | bool ok = true; | 1431 | bool ok = true; |
1432 | for ( int i = 0; i < count; i++) | 1432 | for ( int i = 0; i < count; i++) |
1433 | { | 1433 | { |
1434 | if ( ! bar.isVisible() ) | 1434 | if ( ! bar.isVisible() ) |
1435 | return; | 1435 | return; |
1436 | bar.setProgress( i ); | 1436 | bar.setProgress( i ); |
1437 | qApp->processEvents(); | 1437 | qApp->processEvents(); |
1438 | 1438 | ||
1439 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1439 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1440 | if (!ok) { | 1440 | if (!ok) { |
1441 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1441 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1444 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1445 | if (!ok) { | 1445 | if (!ok) { |
1446 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1446 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1447 | } | 1447 | } |
1448 | realName = realNameList[i]; | 1448 | realName = realNameList[i]; |
1449 | email = emailList[i]; | 1449 | email = emailList[i]; |
1450 | assembledName = assembledNameList[i]; | 1450 | assembledName = assembledNameList[i]; |
1451 | uid = uidList[i]; | 1451 | uid = uidList[i]; |
1452 | //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() ); | 1452 | //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() ); |
1453 | 1453 | ||
1454 | if ( birthday.isValid() ){ | 1454 | if ( birthday.isValid() ){ |
1455 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1455 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1456 | KCal::Attendee::ReqParticipant,uid) ; | 1456 | KCal::Attendee::ReqParticipant,uid) ; |
1457 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1457 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1458 | ++addCount; | 1458 | ++addCount; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | if ( anniversary.isValid() ){ | 1461 | if ( anniversary.isValid() ){ |
1462 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1462 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1463 | KCal::Attendee::ReqParticipant,uid) ; | 1463 | KCal::Attendee::ReqParticipant,uid) ; |
1464 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1464 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1465 | ++addCount; | 1465 | ++addCount; |
1466 | } | 1466 | } |
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | updateView(); | 1469 | updateView(); |
1470 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1470 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1471 | 1471 | ||
1472 | } | 1472 | } |
1473 | 1473 | ||
1474 | } | 1474 | } |
1475 | 1475 | ||
1476 | 1476 | ||
1477 | 1477 | ||
1478 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1478 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1479 | { | 1479 | { |
1480 | //qDebug("addAnni "); | 1480 | //qDebug("addAnni "); |
1481 | Event * ev = new Event(); | 1481 | Event * ev = new Event(); |
1482 | if ( a ) { | 1482 | if ( a ) { |
1483 | ev->addAttendee( a ); | 1483 | ev->addAttendee( a ); |
1484 | } | 1484 | } |
1485 | QString kind; | 1485 | QString kind; |
1486 | if ( birthday ) | 1486 | if ( birthday ) |
1487 | kind = i18n( "Birthday" ); | 1487 | kind = i18n( "Birthday" ); |
1488 | else | 1488 | else |
1489 | kind = i18n( "Anniversary" ); | 1489 | kind = i18n( "Anniversary" ); |
1490 | ev->setSummary( name + " - " + kind ); | 1490 | ev->setSummary( name + " - " + kind ); |
1491 | ev->setOrganizer(a->email()); | 1491 | ev->setOrganizer(a->email()); |
1492 | ev->setCategories( kind ); | 1492 | ev->setCategories( kind ); |
1493 | ev->setDtStart( QDateTime(date) ); | 1493 | ev->setDtStart( QDateTime(date) ); |
1494 | ev->setDtEnd( QDateTime(date) ); | 1494 | ev->setDtEnd( QDateTime(date) ); |
1495 | ev->setFloats( true ); | 1495 | ev->setFloats( true ); |
1496 | Recurrence * rec = ev->recurrence(); | 1496 | Recurrence * rec = ev->recurrence(); |
1497 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1497 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1498 | rec->addYearlyNum( date.month() ); | 1498 | rec->addYearlyNum( date.month() ); |
1499 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1499 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1500 | delete ev; | 1500 | delete ev; |
1501 | return false; | 1501 | return false; |
1502 | } | 1502 | } |
1503 | return true; | 1503 | return true; |
1504 | 1504 | ||
1505 | } | 1505 | } |
1506 | bool CalendarView::importQtopia( const QString &categories, | 1506 | bool CalendarView::importQtopia( const QString &categories, |
1507 | const QString &datebook, | 1507 | const QString &datebook, |
1508 | const QString &todolist ) | 1508 | const QString &todolist ) |
1509 | { | 1509 | { |
1510 | 1510 | ||
1511 | QtopiaFormat qtopiaFormat; | 1511 | QtopiaFormat qtopiaFormat; |
1512 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1512 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1513 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1513 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1514 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1514 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1515 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1515 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1516 | 1516 | ||
1517 | updateView(); | 1517 | updateView(); |
1518 | return true; | 1518 | return true; |
1519 | 1519 | ||
1520 | #if 0 | 1520 | #if 0 |
1521 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1521 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1522 | mCurrentSyncDevice = "qtopia-XML"; | 1522 | mCurrentSyncDevice = "qtopia-XML"; |
1523 | if ( mSyncManager->mAskForPreferences ) | 1523 | if ( mSyncManager->mAskForPreferences ) |
1524 | edit_sync_options(); | 1524 | edit_sync_options(); |
1525 | qApp->processEvents(); | 1525 | qApp->processEvents(); |
1526 | CalendarLocal* calendar = new CalendarLocal(); | 1526 | CalendarLocal* calendar = new CalendarLocal(); |
1527 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1527 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1528 | bool syncOK = false; | 1528 | bool syncOK = false; |
1529 | QtopiaFormat qtopiaFormat; | 1529 | QtopiaFormat qtopiaFormat; |
1530 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1530 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1531 | bool loadOk = true; | 1531 | bool loadOk = true; |
1532 | if ( !categories.isEmpty() ) | 1532 | if ( !categories.isEmpty() ) |
1533 | loadOk = qtopiaFormat.load( calendar, categories ); | 1533 | loadOk = qtopiaFormat.load( calendar, categories ); |
1534 | if ( loadOk && !datebook.isEmpty() ) | 1534 | if ( loadOk && !datebook.isEmpty() ) |
1535 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1535 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1536 | if ( loadOk && !todolist.isEmpty() ) | 1536 | if ( loadOk && !todolist.isEmpty() ) |
1537 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1537 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1538 | 1538 | ||
1539 | if ( loadOk ) { | 1539 | if ( loadOk ) { |
1540 | getEventViewerDialog()->setSyncMode( true ); | 1540 | getEventViewerDialog()->setSyncMode( true ); |
1541 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1541 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1542 | getEventViewerDialog()->setSyncMode( false ); | 1542 | getEventViewerDialog()->setSyncMode( false ); |
1543 | qApp->processEvents(); | 1543 | qApp->processEvents(); |
1544 | if ( syncOK ) { | 1544 | if ( syncOK ) { |
1545 | if ( mSyncManager->mWriteBackFile ) | 1545 | if ( mSyncManager->mWriteBackFile ) |
1546 | { | 1546 | { |
1547 | // write back XML file | 1547 | // write back XML file |
1548 | 1548 | ||
1549 | } | 1549 | } |
1550 | setModified( true ); | 1550 | setModified( true ); |
1551 | } | 1551 | } |
1552 | } else { | 1552 | } else { |
1553 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1553 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1554 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1554 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1555 | question, i18n("Ok")) ; | 1555 | question, i18n("Ok")) ; |
1556 | } | 1556 | } |
1557 | delete calendar; | 1557 | delete calendar; |
1558 | updateView(); | 1558 | updateView(); |
1559 | return syncOK; | 1559 | return syncOK; |
1560 | 1560 | ||
1561 | 1561 | ||
1562 | #endif | 1562 | #endif |
1563 | 1563 | ||
1564 | } | 1564 | } |
1565 | 1565 | ||
1566 | void CalendarView::setSyncEventsReadOnly() | 1566 | void CalendarView::setSyncEventsReadOnly() |
1567 | { | 1567 | { |
1568 | Event * ev; | 1568 | Event * ev; |
1569 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1569 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1570 | ev = eL.first(); | 1570 | ev = eL.first(); |
1571 | while ( ev ) { | 1571 | while ( ev ) { |
1572 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1572 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1573 | ev->setReadOnly( true ); | 1573 | ev->setReadOnly( true ); |
1574 | ev = eL.next(); | 1574 | ev = eL.next(); |
1575 | } | 1575 | } |
1576 | } | 1576 | } |
1577 | bool CalendarView::openCalendar(QString filename, bool merge) | 1577 | bool CalendarView::openCalendar(QString filename, bool merge) |
1578 | { | 1578 | { |
1579 | 1579 | ||
1580 | if (filename.isEmpty()) { | 1580 | if (filename.isEmpty()) { |
1581 | return false; | 1581 | return false; |
1582 | } | 1582 | } |
1583 | 1583 | ||
1584 | if (!QFile::exists(filename)) { | 1584 | if (!QFile::exists(filename)) { |
1585 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1585 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1586 | return false; | 1586 | return false; |
1587 | } | 1587 | } |
1588 | 1588 | ||
1589 | globalFlagBlockAgenda = 1; | 1589 | globalFlagBlockAgenda = 1; |
1590 | if (!merge) mCalendar->close(); | 1590 | if (!merge) mCalendar->close(); |
1591 | 1591 | ||
1592 | mStorage->setFileName( filename ); | 1592 | mStorage->setFileName( filename ); |
1593 | 1593 | ||
1594 | if ( mStorage->load() ) { | 1594 | if ( mStorage->load() ) { |
1595 | if ( merge ) ;//setModified( true ); | 1595 | if ( merge ) ;//setModified( true ); |
1596 | else { | 1596 | else { |
1597 | //setModified( true ); | 1597 | //setModified( true ); |
1598 | mViewManager->setDocumentId( filename ); | 1598 | mViewManager->setDocumentId( filename ); |
1599 | mDialogManager->setDocumentId( filename ); | 1599 | mDialogManager->setDocumentId( filename ); |
1600 | mTodoList->setDocumentId( filename ); | 1600 | mTodoList->setDocumentId( filename ); |
1601 | } | 1601 | } |
1602 | globalFlagBlockAgenda = 2; | 1602 | globalFlagBlockAgenda = 2; |
1603 | // if ( getLastSyncEvent() ) | 1603 | // if ( getLastSyncEvent() ) |
1604 | // getLastSyncEvent()->setReadOnly( true ); | 1604 | // getLastSyncEvent()->setReadOnly( true ); |
1605 | mCalendar->reInitAlarmSettings(); | 1605 | mCalendar->reInitAlarmSettings(); |
1606 | setSyncEventsReadOnly(); | 1606 | setSyncEventsReadOnly(); |
1607 | updateUnmanagedViews(); | 1607 | updateUnmanagedViews(); |
1608 | updateView(); | 1608 | updateView(); |
1609 | if ( filename != MainWindow::defaultFileName() ) { | 1609 | if ( filename != MainWindow::defaultFileName() ) { |
1610 | saveCalendar( MainWindow::defaultFileName() ); | 1610 | saveCalendar( MainWindow::defaultFileName() ); |
1611 | } else { | 1611 | } else { |
1612 | QFileInfo finf ( MainWindow::defaultFileName()); | 1612 | QFileInfo finf ( MainWindow::defaultFileName()); |
1613 | if ( finf.exists() ) { | 1613 | if ( finf.exists() ) { |
1614 | setLoadedFileVersion( finf.lastModified () ); | 1614 | setLoadedFileVersion( finf.lastModified () ); |
1615 | } | 1615 | } |
1616 | } | 1616 | } |
1617 | return true; | 1617 | return true; |
1618 | } else { | 1618 | } else { |
1619 | // while failing to load, the calendar object could | 1619 | // while failing to load, the calendar object could |
1620 | // have become partially populated. Clear it out. | 1620 | // have become partially populated. Clear it out. |
1621 | if ( !merge ) { | 1621 | if ( !merge ) { |
1622 | mCalendar->close(); | 1622 | mCalendar->close(); |
1623 | mViewManager->setDocumentId( filename ); | 1623 | mViewManager->setDocumentId( filename ); |
1624 | mDialogManager->setDocumentId( filename ); | 1624 | mDialogManager->setDocumentId( filename ); |
1625 | mTodoList->setDocumentId( filename ); | 1625 | mTodoList->setDocumentId( filename ); |
1626 | } | 1626 | } |
1627 | 1627 | ||
1628 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1628 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1629 | 1629 | ||
1630 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1630 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1631 | globalFlagBlockAgenda = 2; | 1631 | globalFlagBlockAgenda = 2; |
1632 | mCalendar->reInitAlarmSettings(); | 1632 | mCalendar->reInitAlarmSettings(); |
1633 | setSyncEventsReadOnly(); | 1633 | setSyncEventsReadOnly(); |
1634 | updateUnmanagedViews(); | 1634 | updateUnmanagedViews(); |
1635 | updateView(); | 1635 | updateView(); |
1636 | } | 1636 | } |
1637 | return false; | 1637 | return false; |
1638 | } | 1638 | } |
1639 | void CalendarView::showOpenError() | 1639 | void CalendarView::showOpenError() |
1640 | { | 1640 | { |
1641 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1641 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1642 | } | 1642 | } |
1643 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1643 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1644 | { | 1644 | { |
1645 | loadedFileVersion = dt; | 1645 | loadedFileVersion = dt; |
1646 | } | 1646 | } |
1647 | bool CalendarView::checkFileChanged(QString fn) | 1647 | bool CalendarView::checkFileChanged(QString fn) |
1648 | { | 1648 | { |
1649 | QFileInfo finf ( fn ); | 1649 | QFileInfo finf ( fn ); |
1650 | if ( !finf.exists() ) | 1650 | if ( !finf.exists() ) |
1651 | return true; | 1651 | return true; |
1652 | QDateTime dt = finf.lastModified (); | 1652 | QDateTime dt = finf.lastModified (); |
1653 | if ( dt <= loadedFileVersion ) | 1653 | if ( dt <= loadedFileVersion ) |
1654 | return false; | 1654 | return false; |
1655 | return true; | 1655 | return true; |
1656 | 1656 | ||
1657 | } | 1657 | } |
1658 | void CalendarView::watchSavedFile() | 1658 | void CalendarView::watchSavedFile() |
1659 | { | 1659 | { |
1660 | QFileInfo finf ( MainWindow::defaultFileName()); | 1660 | QFileInfo finf ( MainWindow::defaultFileName()); |
1661 | if ( !finf.exists() ) | 1661 | if ( !finf.exists() ) |
1662 | return; | 1662 | return; |
1663 | QDateTime dt = finf.lastModified (); | 1663 | QDateTime dt = finf.lastModified (); |
1664 | if ( dt < loadedFileVersion ) { | 1664 | if ( dt < loadedFileVersion ) { |
1665 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1665 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1666 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1666 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1667 | return; | 1667 | return; |
1668 | } | 1668 | } |
1669 | loadedFileVersion = dt; | 1669 | loadedFileVersion = dt; |
1670 | } | 1670 | } |
1671 | 1671 | ||
1672 | bool CalendarView::checkFileVersion(QString fn) | 1672 | bool CalendarView::checkFileVersion(QString fn) |
1673 | { | 1673 | { |
1674 | QFileInfo finf ( fn ); | 1674 | QFileInfo finf ( fn ); |
1675 | if ( !finf.exists() ) | 1675 | if ( !finf.exists() ) |
1676 | return true; | 1676 | return true; |
1677 | QDateTime dt = finf.lastModified (); | 1677 | QDateTime dt = finf.lastModified (); |
1678 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1678 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1679 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1679 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1680 | if ( dt <= loadedFileVersion ) | 1680 | if ( dt <= loadedFileVersion ) |
1681 | return true; | 1681 | return true; |
1682 | 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)) , | 1682 | 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)) , |
1683 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1683 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1684 | i18n("Sync+save")); | 1684 | i18n("Sync+save")); |
1685 | 1685 | ||
1686 | if ( km == KMessageBox::Cancel ) | 1686 | if ( km == KMessageBox::Cancel ) |
1687 | return false; | 1687 | return false; |
1688 | if ( km == KMessageBox::Yes ) | 1688 | if ( km == KMessageBox::Yes ) |
1689 | return true; | 1689 | return true; |
1690 | 1690 | ||
1691 | setSyncDevice("deleteaftersync" ); | 1691 | setSyncDevice("deleteaftersync" ); |
1692 | mSyncManager->mAskForPreferences = true; | 1692 | mSyncManager->mAskForPreferences = true; |
1693 | mSyncManager->mSyncAlgoPrefs = 3; | 1693 | mSyncManager->mSyncAlgoPrefs = 3; |
1694 | mSyncManager->mWriteBackFile = false; | 1694 | mSyncManager->mWriteBackFile = false; |
1695 | mSyncManager->mWriteBackExistingOnly = false; | 1695 | mSyncManager->mWriteBackExistingOnly = false; |
1696 | mSyncManager->mShowSyncSummary = false; | 1696 | mSyncManager->mShowSyncSummary = false; |
1697 | syncCalendar( fn, 3 ); | 1697 | syncCalendar( fn, 3 ); |
1698 | Event * e = getLastSyncEvent(); | 1698 | Event * e = getLastSyncEvent(); |
1699 | mCalendar->deleteEvent ( e ); | 1699 | mCalendar->deleteEvent ( e ); |
1700 | updateView(); | 1700 | updateView(); |
1701 | return true; | 1701 | return true; |
1702 | } | 1702 | } |
1703 | 1703 | ||
1704 | bool CalendarView::saveCalendar( QString filename ) | 1704 | bool CalendarView::saveCalendar( QString filename ) |
1705 | { | 1705 | { |
1706 | 1706 | ||
1707 | // Store back all unsaved data into calendar object | 1707 | // Store back all unsaved data into calendar object |
1708 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1708 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1709 | if ( mViewManager->currentView() ) | 1709 | if ( mViewManager->currentView() ) |
1710 | mViewManager->currentView()->flushView(); | 1710 | mViewManager->currentView()->flushView(); |
1711 | 1711 | ||
1712 | 1712 | ||
1713 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1713 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1714 | mStorage->setSaveFormat( new ICalFormat() ); | 1714 | mStorage->setSaveFormat( new ICalFormat() ); |
1715 | mStorage->setFileName( filename ); | 1715 | mStorage->setFileName( filename ); |
1716 | bool success; | 1716 | bool success; |
1717 | success = mStorage->save(); | 1717 | success = mStorage->save(); |
1718 | if ( !success ) { | 1718 | if ( !success ) { |
1719 | return false; | 1719 | return false; |
1720 | } | 1720 | } |
1721 | if ( filename == MainWindow::defaultFileName() ) { | 1721 | if ( filename == MainWindow::defaultFileName() ) { |
1722 | setLoadedFileVersion( lfv ); | 1722 | setLoadedFileVersion( lfv ); |
1723 | watchSavedFile(); | 1723 | watchSavedFile(); |
1724 | } | 1724 | } |
1725 | return true; | 1725 | return true; |
1726 | } | 1726 | } |
1727 | 1727 | ||
1728 | void CalendarView::closeCalendar() | 1728 | void CalendarView::closeCalendar() |
1729 | { | 1729 | { |
1730 | 1730 | ||
1731 | // child windows no longer valid | 1731 | // child windows no longer valid |
1732 | emit closingDown(); | 1732 | emit closingDown(); |
1733 | 1733 | ||
1734 | mCalendar->close(); | 1734 | mCalendar->close(); |
1735 | setModified(false); | 1735 | setModified(false); |
1736 | updateView(); | 1736 | updateView(); |
1737 | } | 1737 | } |
1738 | 1738 | ||
1739 | void CalendarView::archiveCalendar() | 1739 | void CalendarView::archiveCalendar() |
1740 | { | 1740 | { |
1741 | mDialogManager->showArchiveDialog(); | 1741 | mDialogManager->showArchiveDialog(); |
1742 | } | 1742 | } |
1743 | 1743 | ||
1744 | 1744 | ||
1745 | void CalendarView::readSettings() | 1745 | void CalendarView::readSettings() |
1746 | { | 1746 | { |
1747 | 1747 | ||
1748 | 1748 | ||
1749 | // mViewManager->showAgendaView(); | 1749 | // mViewManager->showAgendaView(); |
1750 | QString str; | 1750 | QString str; |
1751 | //qDebug("CalendarView::readSettings() "); | 1751 | //qDebug("CalendarView::readSettings() "); |
1752 | // read settings from the KConfig, supplying reasonable | 1752 | // read settings from the KConfig, supplying reasonable |
1753 | // defaults where none are to be found | 1753 | // defaults where none are to be found |
1754 | KConfig *config = KOGlobals::config(); | 1754 | KConfig *config = KOGlobals::config(); |
1755 | #ifndef KORG_NOSPLITTER | 1755 | #ifndef KORG_NOSPLITTER |
1756 | config->setGroup("KOrganizer Geometry"); | 1756 | config->setGroup("KOrganizer Geometry"); |
1757 | 1757 | ||
1758 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1758 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1759 | if (sizes.count() != 2) { | 1759 | if (sizes.count() != 2) { |
1760 | sizes << mDateNavigator->minimumSizeHint().width(); | 1760 | sizes << mDateNavigator->minimumSizeHint().width(); |
1761 | sizes << 300; | 1761 | sizes << 300; |
1762 | } | 1762 | } |
1763 | mPanner->setSizes(sizes); | 1763 | mPanner->setSizes(sizes); |
1764 | 1764 | ||
1765 | sizes = config->readIntListEntry("Separator2"); | 1765 | sizes = config->readIntListEntry("Separator2"); |
1766 | if ( ( mResourceView && sizes.count() == 4 ) || | 1766 | if ( ( mResourceView && sizes.count() == 4 ) || |
1767 | ( !mResourceView && sizes.count() == 3 ) ) { | 1767 | ( !mResourceView && sizes.count() == 3 ) ) { |
1768 | mLeftSplitter->setSizes(sizes); | 1768 | mLeftSplitter->setSizes(sizes); |
1769 | } | 1769 | } |
1770 | #endif | 1770 | #endif |
1771 | globalFlagBlockAgenda = 1; | 1771 | globalFlagBlockAgenda = 1; |
1772 | mViewManager->showAgendaView(); | 1772 | mViewManager->showAgendaView(); |
1773 | //mViewManager->readSettings( config ); | 1773 | //mViewManager->readSettings( config ); |
1774 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1774 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1775 | readFilterSettings(config); | 1775 | readFilterSettings(config); |
1776 | config->setGroup( "Views" ); | 1776 | config->setGroup( "Views" ); |
1777 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1777 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1778 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1778 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1779 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1779 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1780 | else mNavigator->selectDates( dateCount ); | 1780 | else mNavigator->selectDates( dateCount ); |
1781 | // mViewManager->readSettings( config ); | 1781 | // mViewManager->readSettings( config ); |
1782 | updateConfig(); | 1782 | updateConfig(); |
1783 | globalFlagBlockAgenda = 2; | 1783 | globalFlagBlockAgenda = 2; |
1784 | mViewManager->readSettings( config ); | 1784 | mViewManager->readSettings( config ); |
1785 | #ifdef DESKTOP_VERSION | 1785 | #ifdef DESKTOP_VERSION |
1786 | config->setGroup("WidgetLayout"); | 1786 | config->setGroup("WidgetLayout"); |
1787 | QStringList list; | 1787 | QStringList list; |
1788 | list = config->readListEntry("MainLayout"); | 1788 | list = config->readListEntry("MainLayout"); |
1789 | int x,y,w,h; | 1789 | int x,y,w,h; |
1790 | if ( ! list.isEmpty() ) { | 1790 | if ( ! list.isEmpty() ) { |
1791 | x = list[0].toInt(); | 1791 | x = list[0].toInt(); |
1792 | y = list[1].toInt(); | 1792 | y = list[1].toInt(); |
1793 | w = list[2].toInt(); | 1793 | w = list[2].toInt(); |
1794 | h = list[3].toInt(); | 1794 | h = list[3].toInt(); |
1795 | topLevelWidget()->setGeometry(x,y,w,h); | 1795 | topLevelWidget()->setGeometry(x,y,w,h); |
1796 | 1796 | ||
1797 | } else { | 1797 | } else { |
1798 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1798 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1799 | } | 1799 | } |
1800 | list = config->readListEntry("EditEventLayout"); | 1800 | list = config->readListEntry("EditEventLayout"); |
1801 | if ( ! list.isEmpty() ) { | 1801 | if ( ! list.isEmpty() ) { |
1802 | x = list[0].toInt(); | 1802 | x = list[0].toInt(); |
1803 | y = list[1].toInt(); | 1803 | y = list[1].toInt(); |
1804 | w = list[2].toInt(); | 1804 | w = list[2].toInt(); |
1805 | h = list[3].toInt(); | 1805 | h = list[3].toInt(); |
1806 | mEventEditor->setGeometry(x,y,w,h); | 1806 | mEventEditor->setGeometry(x,y,w,h); |
1807 | 1807 | ||
1808 | } | 1808 | } |
1809 | list = config->readListEntry("EditTodoLayout"); | 1809 | list = config->readListEntry("EditTodoLayout"); |
1810 | if ( ! list.isEmpty() ) { | 1810 | if ( ! list.isEmpty() ) { |
1811 | x = list[0].toInt(); | 1811 | x = list[0].toInt(); |
1812 | y = list[1].toInt(); | 1812 | y = list[1].toInt(); |
1813 | w = list[2].toInt(); | 1813 | w = list[2].toInt(); |
1814 | h = list[3].toInt(); | 1814 | h = list[3].toInt(); |
1815 | mTodoEditor->setGeometry(x,y,w,h); | 1815 | mTodoEditor->setGeometry(x,y,w,h); |
1816 | 1816 | ||
1817 | } | 1817 | } |
1818 | list = config->readListEntry("ViewerLayout"); | 1818 | list = config->readListEntry("ViewerLayout"); |
1819 | if ( ! list.isEmpty() ) { | 1819 | if ( ! list.isEmpty() ) { |
1820 | x = list[0].toInt(); | 1820 | x = list[0].toInt(); |
1821 | y = list[1].toInt(); | 1821 | y = list[1].toInt(); |
1822 | w = list[2].toInt(); | 1822 | w = list[2].toInt(); |
1823 | h = list[3].toInt(); | 1823 | h = list[3].toInt(); |
1824 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1824 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1825 | } | 1825 | } |
1826 | #endif | 1826 | #endif |
1827 | 1827 | ||
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | 1830 | ||
1831 | void CalendarView::writeSettings() | 1831 | void CalendarView::writeSettings() |
1832 | { | 1832 | { |
1833 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1833 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1834 | 1834 | ||
1835 | KConfig *config = KOGlobals::config(); | 1835 | KConfig *config = KOGlobals::config(); |
1836 | 1836 | ||
1837 | #ifndef KORG_NOSPLITTER | 1837 | #ifndef KORG_NOSPLITTER |
1838 | config->setGroup("KOrganizer Geometry"); | 1838 | config->setGroup("KOrganizer Geometry"); |
1839 | 1839 | ||
1840 | QValueList<int> list = mPanner->sizes(); | 1840 | QValueList<int> list = mPanner->sizes(); |
1841 | config->writeEntry("Separator1",list); | 1841 | config->writeEntry("Separator1",list); |
1842 | 1842 | ||
1843 | list = mLeftSplitter->sizes(); | 1843 | list = mLeftSplitter->sizes(); |
1844 | config->writeEntry("Separator2",list); | 1844 | config->writeEntry("Separator2",list); |
1845 | #endif | 1845 | #endif |
1846 | 1846 | ||
1847 | mViewManager->writeSettings( config ); | 1847 | mViewManager->writeSettings( config ); |
1848 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1848 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1849 | mDialogManager->writeSettings( config ); | 1849 | mDialogManager->writeSettings( config ); |
1850 | //KOPrefs::instance()->usrWriteConfig(); | 1850 | //KOPrefs::instance()->usrWriteConfig(); |
1851 | KOPrefs::instance()->writeConfig(); | 1851 | KOPrefs::instance()->writeConfig(); |
1852 | 1852 | ||
1853 | writeFilterSettings(config); | 1853 | writeFilterSettings(config); |
1854 | 1854 | ||
1855 | config->setGroup( "Views" ); | 1855 | config->setGroup( "Views" ); |
1856 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1856 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1857 | 1857 | ||
1858 | #ifdef DESKTOP_VERSION | 1858 | #ifdef DESKTOP_VERSION |
1859 | config->setGroup("WidgetLayout"); | 1859 | config->setGroup("WidgetLayout"); |
1860 | QStringList list ;//= config->readListEntry("MainLayout"); | 1860 | QStringList list ;//= config->readListEntry("MainLayout"); |
1861 | int x,y,w,h; | 1861 | int x,y,w,h; |
1862 | QWidget* wid; | 1862 | QWidget* wid; |
1863 | wid = topLevelWidget(); | 1863 | wid = topLevelWidget(); |
1864 | x = wid->geometry().x(); | 1864 | x = wid->geometry().x(); |
1865 | y = wid->geometry().y(); | 1865 | y = wid->geometry().y(); |
1866 | w = wid->width(); | 1866 | w = wid->width(); |
1867 | h = wid->height(); | 1867 | h = wid->height(); |
1868 | list.clear(); | 1868 | list.clear(); |
1869 | list << QString::number( x ); | 1869 | list << QString::number( x ); |
1870 | list << QString::number( y ); | 1870 | list << QString::number( y ); |
1871 | list << QString::number( w ); | 1871 | list << QString::number( w ); |
1872 | list << QString::number( h ); | 1872 | list << QString::number( h ); |
1873 | config->writeEntry("MainLayout",list ); | 1873 | config->writeEntry("MainLayout",list ); |
1874 | 1874 | ||
1875 | wid = mEventEditor; | 1875 | wid = mEventEditor; |
1876 | x = wid->geometry().x(); | 1876 | x = wid->geometry().x(); |
1877 | y = wid->geometry().y(); | 1877 | y = wid->geometry().y(); |
1878 | w = wid->width(); | 1878 | w = wid->width(); |
1879 | h = wid->height(); | 1879 | h = wid->height(); |
1880 | list.clear(); | 1880 | list.clear(); |
1881 | list << QString::number( x ); | 1881 | list << QString::number( x ); |
1882 | list << QString::number( y ); | 1882 | list << QString::number( y ); |
1883 | list << QString::number( w ); | 1883 | list << QString::number( w ); |
1884 | list << QString::number( h ); | 1884 | list << QString::number( h ); |
1885 | config->writeEntry("EditEventLayout",list ); | 1885 | config->writeEntry("EditEventLayout",list ); |
1886 | 1886 | ||
1887 | wid = mTodoEditor; | 1887 | wid = mTodoEditor; |
1888 | x = wid->geometry().x(); | 1888 | x = wid->geometry().x(); |
1889 | y = wid->geometry().y(); | 1889 | y = wid->geometry().y(); |
1890 | w = wid->width(); | 1890 | w = wid->width(); |
1891 | h = wid->height(); | 1891 | h = wid->height(); |
1892 | list.clear(); | 1892 | list.clear(); |
1893 | list << QString::number( x ); | 1893 | list << QString::number( x ); |
1894 | list << QString::number( y ); | 1894 | list << QString::number( y ); |
1895 | list << QString::number( w ); | 1895 | list << QString::number( w ); |
1896 | list << QString::number( h ); | 1896 | list << QString::number( h ); |
1897 | config->writeEntry("EditTodoLayout",list ); | 1897 | config->writeEntry("EditTodoLayout",list ); |
1898 | wid = getEventViewerDialog(); | 1898 | wid = getEventViewerDialog(); |
1899 | x = wid->geometry().x(); | 1899 | x = wid->geometry().x(); |
1900 | y = wid->geometry().y(); | 1900 | y = wid->geometry().y(); |
1901 | w = wid->width(); | 1901 | w = wid->width(); |
1902 | h = wid->height(); | 1902 | h = wid->height(); |
1903 | list.clear(); | 1903 | list.clear(); |
1904 | list << QString::number( x ); | 1904 | list << QString::number( x ); |
1905 | list << QString::number( y ); | 1905 | list << QString::number( y ); |
1906 | list << QString::number( w ); | 1906 | list << QString::number( w ); |
1907 | list << QString::number( h ); | 1907 | list << QString::number( h ); |
1908 | config->writeEntry("ViewerLayout",list ); | 1908 | config->writeEntry("ViewerLayout",list ); |
1909 | wid = mDialogManager->getSearchDialog(); | 1909 | wid = mDialogManager->getSearchDialog(); |
1910 | if ( wid ) { | 1910 | if ( wid ) { |
1911 | x = wid->geometry().x(); | 1911 | x = wid->geometry().x(); |
1912 | y = wid->geometry().y(); | 1912 | y = wid->geometry().y(); |
1913 | w = wid->width(); | 1913 | w = wid->width(); |
1914 | h = wid->height(); | 1914 | h = wid->height(); |
1915 | list.clear(); | 1915 | list.clear(); |
1916 | list << QString::number( x ); | 1916 | list << QString::number( x ); |
1917 | list << QString::number( y ); | 1917 | list << QString::number( y ); |
1918 | list << QString::number( w ); | 1918 | list << QString::number( w ); |
1919 | list << QString::number( h ); | 1919 | list << QString::number( h ); |
1920 | config->writeEntry("SearchLayout",list ); | 1920 | config->writeEntry("SearchLayout",list ); |
1921 | } | 1921 | } |
1922 | #endif | 1922 | #endif |
1923 | 1923 | ||
1924 | 1924 | ||
1925 | config->sync(); | 1925 | config->sync(); |
1926 | } | 1926 | } |
1927 | 1927 | ||
1928 | void CalendarView::readFilterSettings(KConfig *config) | 1928 | void CalendarView::readFilterSettings(KConfig *config) |
1929 | { | 1929 | { |
1930 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1930 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1931 | 1931 | ||
1932 | mFilters.clear(); | 1932 | mFilters.clear(); |
1933 | 1933 | ||
1934 | config->setGroup("General"); | 1934 | config->setGroup("General"); |
1935 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1935 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1936 | 1936 | ||
1937 | QStringList::ConstIterator it = filterList.begin(); | 1937 | QStringList::ConstIterator it = filterList.begin(); |
1938 | QStringList::ConstIterator end = filterList.end(); | 1938 | QStringList::ConstIterator end = filterList.end(); |
1939 | while(it != end) { | 1939 | while(it != end) { |
1940 | // kdDebug() << " filter: " << (*it) << endl; | 1940 | // kdDebug() << " filter: " << (*it) << endl; |
1941 | 1941 | ||
1942 | CalFilter *filter; | 1942 | CalFilter *filter; |
1943 | filter = new CalFilter(*it); | 1943 | filter = new CalFilter(*it); |
1944 | config->setGroup("Filter_" + (*it)); | 1944 | config->setGroup("Filter_" + (*it)); |
1945 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1945 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1946 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1946 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1947 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1947 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1948 | mFilters.append(filter); | 1948 | mFilters.append(filter); |
1949 | 1949 | ||
1950 | ++it; | 1950 | ++it; |
1951 | } | 1951 | } |
1952 | 1952 | ||
1953 | if (mFilters.count() == 0) { | 1953 | if (mFilters.count() == 0) { |
1954 | CalFilter *filter = new CalFilter(i18n("Default")); | 1954 | CalFilter *filter = new CalFilter(i18n("Default")); |
1955 | mFilters.append(filter); | 1955 | mFilters.append(filter); |
1956 | } | 1956 | } |
1957 | mFilterView->updateFilters(); | 1957 | mFilterView->updateFilters(); |
1958 | config->setGroup("FilterView"); | 1958 | config->setGroup("FilterView"); |
1959 | 1959 | ||
1960 | mFilterView->blockSignals(true); | 1960 | mFilterView->blockSignals(true); |
1961 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1961 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1962 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1962 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1963 | mFilterView->blockSignals(false); | 1963 | mFilterView->blockSignals(false); |
1964 | // We do it manually to avoid it being done twice by the above calls | 1964 | // We do it manually to avoid it being done twice by the above calls |
1965 | updateFilter(); | 1965 | updateFilter(); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void CalendarView::writeFilterSettings(KConfig *config) | 1968 | void CalendarView::writeFilterSettings(KConfig *config) |
1969 | { | 1969 | { |
1970 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1970 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1971 | 1971 | ||
1972 | QStringList filterList; | 1972 | QStringList filterList; |
1973 | 1973 | ||
1974 | CalFilter *filter = mFilters.first(); | 1974 | CalFilter *filter = mFilters.first(); |
1975 | while(filter) { | 1975 | while(filter) { |
1976 | // kdDebug() << " fn: " << filter->name() << endl; | 1976 | // kdDebug() << " fn: " << filter->name() << endl; |
1977 | filterList << filter->name(); | 1977 | filterList << filter->name(); |
1978 | config->setGroup("Filter_" + filter->name()); | 1978 | config->setGroup("Filter_" + filter->name()); |
1979 | config->writeEntry("Criteria",filter->criteria()); | 1979 | config->writeEntry("Criteria",filter->criteria()); |
1980 | config->writeEntry("CategoryList",filter->categoryList()); | 1980 | config->writeEntry("CategoryList",filter->categoryList()); |
1981 | filter = mFilters.next(); | 1981 | filter = mFilters.next(); |
1982 | } | 1982 | } |
1983 | config->setGroup("General"); | 1983 | config->setGroup("General"); |
1984 | config->writeEntry("CalendarFilters",filterList); | 1984 | config->writeEntry("CalendarFilters",filterList); |
1985 | 1985 | ||
1986 | config->setGroup("FilterView"); | 1986 | config->setGroup("FilterView"); |
1987 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1987 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1988 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1988 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1989 | } | 1989 | } |
1990 | 1990 | ||
1991 | 1991 | ||
1992 | void CalendarView::goToday() | 1992 | void CalendarView::goToday() |
1993 | { | 1993 | { |
1994 | mNavigator->selectToday(); | 1994 | mNavigator->selectToday(); |
1995 | } | 1995 | } |
1996 | 1996 | ||
1997 | void CalendarView::goNext() | 1997 | void CalendarView::goNext() |
1998 | { | 1998 | { |
1999 | mNavigator->selectNext(); | 1999 | mNavigator->selectNext(); |
2000 | } | 2000 | } |
2001 | 2001 | ||
2002 | void CalendarView::goPrevious() | 2002 | void CalendarView::goPrevious() |
2003 | { | 2003 | { |
2004 | mNavigator->selectPrevious(); | 2004 | mNavigator->selectPrevious(); |
2005 | } | 2005 | } |
2006 | void CalendarView::goNextMonth() | 2006 | void CalendarView::goNextMonth() |
2007 | { | 2007 | { |
2008 | mNavigator->selectNextMonth(); | 2008 | mNavigator->selectNextMonth(); |
2009 | } | 2009 | } |
2010 | 2010 | ||
2011 | void CalendarView::goPreviousMonth() | 2011 | void CalendarView::goPreviousMonth() |
2012 | { | 2012 | { |
2013 | mNavigator->selectPreviousMonth(); | 2013 | mNavigator->selectPreviousMonth(); |
2014 | } | 2014 | } |
2015 | void CalendarView::writeLocale() | 2015 | void CalendarView::writeLocale() |
2016 | { | 2016 | { |
2017 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2017 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2018 | #if 0 | 2018 | #if 0 |
2019 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2019 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2020 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2020 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2021 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2021 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2022 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2022 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2023 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2023 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2024 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2024 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2025 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2025 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2026 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2026 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2027 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2027 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2028 | KOPrefs::instance()->mDaylightsavingStart, | 2028 | KOPrefs::instance()->mDaylightsavingStart, |
2029 | KOPrefs::instance()->mDaylightsavingEnd ); | 2029 | KOPrefs::instance()->mDaylightsavingEnd ); |
2030 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2030 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2031 | #endif | 2031 | #endif |
2032 | } | 2032 | } |
2033 | void CalendarView::updateConfig() | 2033 | void CalendarView::updateConfig() |
2034 | { | 2034 | { |
2035 | writeLocale(); | 2035 | writeLocale(); |
2036 | if ( KOPrefs::instance()->mUseAppColors ) | 2036 | if ( KOPrefs::instance()->mUseAppColors ) |
2037 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2037 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2038 | emit configChanged(); | 2038 | emit configChanged(); |
2039 | mTodoList->updateConfig(); | 2039 | mTodoList->updateConfig(); |
2040 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2040 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2041 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2041 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2042 | // To make the "fill window" configurations work | 2042 | // To make the "fill window" configurations work |
2043 | //mViewManager->raiseCurrentView(); | 2043 | //mViewManager->raiseCurrentView(); |
2044 | } | 2044 | } |
2045 | 2045 | ||
2046 | 2046 | ||
2047 | void CalendarView::eventChanged(Event *event) | 2047 | void CalendarView::eventChanged(Event *event) |
2048 | { | 2048 | { |
2049 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2049 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2050 | //updateUnmanagedViews(); | 2050 | //updateUnmanagedViews(); |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | void CalendarView::eventAdded(Event *event) | 2053 | void CalendarView::eventAdded(Event *event) |
2054 | { | 2054 | { |
2055 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2055 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2056 | } | 2056 | } |
2057 | 2057 | ||
2058 | void CalendarView::eventToBeDeleted(Event *) | 2058 | void CalendarView::eventToBeDeleted(Event *) |
2059 | { | 2059 | { |
2060 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2060 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2061 | } | 2061 | } |
2062 | 2062 | ||
2063 | void CalendarView::eventDeleted() | 2063 | void CalendarView::eventDeleted() |
2064 | { | 2064 | { |
2065 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2065 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2066 | } | 2066 | } |
2067 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2067 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2068 | { | 2068 | { |
2069 | changeIncidenceDisplay((Incidence *)which, action); | 2069 | changeIncidenceDisplay((Incidence *)which, action); |
2070 | mDateNavigator->updateView(); //LR | 2070 | mDateNavigator->updateView(); //LR |
2071 | //mDialogManager->updateSearchDialog(); | 2071 | //mDialogManager->updateSearchDialog(); |
2072 | 2072 | ||
2073 | if (which) { | 2073 | if (which) { |
2074 | mViewManager->updateWNview(); | 2074 | mViewManager->updateWNview(); |
2075 | //mTodoList->updateView(); | 2075 | //mTodoList->updateView(); |
2076 | } | 2076 | } |
2077 | 2077 | ||
2078 | } | 2078 | } |
2079 | 2079 | ||
2080 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2080 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2081 | { | 2081 | { |
2082 | updateUnmanagedViews(); | 2082 | updateUnmanagedViews(); |
2083 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2083 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2084 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2084 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2085 | mCalendar->checkAlarmForIncidence( 0, true ); | 2085 | mCalendar->checkAlarmForIncidence( 0, true ); |
2086 | if ( mEventViewerDialog ) | 2086 | if ( mEventViewerDialog ) |
2087 | mEventViewerDialog->hide(); | 2087 | mEventViewerDialog->hide(); |
2088 | } | 2088 | } |
2089 | else | 2089 | else |
2090 | mCalendar->checkAlarmForIncidence( which , false ); | 2090 | mCalendar->checkAlarmForIncidence( which , false ); |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | // most of the changeEventDisplays() right now just call the view's | 2093 | // most of the changeEventDisplays() right now just call the view's |
2094 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2094 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2095 | void CalendarView::changeEventDisplay(Event *which, int action) | 2095 | void CalendarView::changeEventDisplay(Event *which, int action) |
2096 | { | 2096 | { |
2097 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2097 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2098 | changeIncidenceDisplay((Incidence *)which, action); | 2098 | changeIncidenceDisplay((Incidence *)which, action); |
2099 | mDateNavigator->updateView(); | 2099 | mDateNavigator->updateView(); |
2100 | //mDialogManager->updateSearchDialog(); | 2100 | //mDialogManager->updateSearchDialog(); |
2101 | 2101 | ||
2102 | if (which) { | 2102 | if (which) { |
2103 | // If there is an event view visible update the display | 2103 | // If there is an event view visible update the display |
2104 | mViewManager->currentView()->changeEventDisplay(which,action); | 2104 | mViewManager->currentView()->changeEventDisplay(which,action); |
2105 | // TODO: check, if update needed | 2105 | // TODO: check, if update needed |
2106 | // if (which->getTodoStatus()) { | 2106 | // if (which->getTodoStatus()) { |
2107 | mTodoList->updateView(); | 2107 | mTodoList->updateView(); |
2108 | // } | 2108 | // } |
2109 | } else { | 2109 | } else { |
2110 | mViewManager->currentView()->updateView(); | 2110 | mViewManager->currentView()->updateView(); |
2111 | } | 2111 | } |
2112 | } | 2112 | } |
2113 | 2113 | ||
2114 | 2114 | ||
2115 | void CalendarView::updateTodoViews() | 2115 | void CalendarView::updateTodoViews() |
2116 | { | 2116 | { |
2117 | 2117 | ||
2118 | mTodoList->updateView(); | 2118 | mTodoList->updateView(); |
2119 | mViewManager->currentView()->updateView(); | 2119 | mViewManager->currentView()->updateView(); |
2120 | 2120 | ||
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | 2123 | ||
2124 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2124 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2125 | { | 2125 | { |
2126 | mTodoList->updateView(); | 2126 | mTodoList->updateView(); |
2127 | mViewManager->updateView(start, end); | 2127 | mViewManager->updateView(start, end); |
2128 | //mDateNavigator->updateView(); | 2128 | //mDateNavigator->updateView(); |
2129 | } | 2129 | } |
2130 | 2130 | ||
2131 | void CalendarView::updateView() | 2131 | void CalendarView::updateView() |
2132 | { | 2132 | { |
2133 | DateList tmpList = mNavigator->selectedDates(); | 2133 | DateList tmpList = mNavigator->selectedDates(); |
2134 | 2134 | ||
2135 | // We assume that the navigator only selects consecutive days. | 2135 | // We assume that the navigator only selects consecutive days. |
2136 | updateView( tmpList.first(), tmpList.last() ); | 2136 | updateView( tmpList.first(), tmpList.last() ); |
2137 | } | 2137 | } |
2138 | 2138 | ||
2139 | void CalendarView::updateUnmanagedViews() | 2139 | void CalendarView::updateUnmanagedViews() |
2140 | { | 2140 | { |
2141 | mDateNavigator->updateDayMatrix(); | 2141 | mDateNavigator->updateDayMatrix(); |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | int CalendarView::msgItemDelete() | 2144 | int CalendarView::msgItemDelete() |
2145 | { | 2145 | { |
2146 | return KMessageBox::warningContinueCancel(this, | 2146 | return KMessageBox::warningContinueCancel(this, |
2147 | i18n("This item will be\npermanently deleted."), | 2147 | i18n("This item will be\npermanently deleted."), |
2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2148 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2149 | } | 2149 | } |
2150 | 2150 | ||
2151 | 2151 | ||
2152 | void CalendarView::edit_cut() | 2152 | void CalendarView::edit_cut() |
2153 | { | 2153 | { |
2154 | Event *anEvent=0; | 2154 | Event *anEvent=0; |
2155 | 2155 | ||
2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2156 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2157 | 2157 | ||
2158 | if (mViewManager->currentView()->isEventView()) { | 2158 | if (mViewManager->currentView()->isEventView()) { |
2159 | if ( incidence && incidence->type() == "Event" ) { | 2159 | if ( incidence && incidence->type() == "Event" ) { |
2160 | anEvent = static_cast<Event *>(incidence); | 2160 | anEvent = static_cast<Event *>(incidence); |
2161 | } | 2161 | } |
2162 | } | 2162 | } |
2163 | 2163 | ||
2164 | if (!anEvent) { | 2164 | if (!anEvent) { |
2165 | KNotifyClient::beep(); | 2165 | KNotifyClient::beep(); |
2166 | return; | 2166 | return; |
2167 | } | 2167 | } |
2168 | DndFactory factory( mCalendar ); | 2168 | DndFactory factory( mCalendar ); |
2169 | factory.cutEvent(anEvent); | 2169 | factory.cutEvent(anEvent); |
2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2170 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | void CalendarView::edit_copy() | 2173 | void CalendarView::edit_copy() |
2174 | { | 2174 | { |
2175 | Event *anEvent=0; | 2175 | Event *anEvent=0; |
2176 | 2176 | ||
2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2177 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2178 | 2178 | ||
2179 | if (mViewManager->currentView()->isEventView()) { | 2179 | if (mViewManager->currentView()->isEventView()) { |
2180 | if ( incidence && incidence->type() == "Event" ) { | 2180 | if ( incidence && incidence->type() == "Event" ) { |
2181 | anEvent = static_cast<Event *>(incidence); | 2181 | anEvent = static_cast<Event *>(incidence); |
2182 | } | 2182 | } |
2183 | } | 2183 | } |
2184 | 2184 | ||
2185 | if (!anEvent) { | 2185 | if (!anEvent) { |
2186 | KNotifyClient::beep(); | 2186 | KNotifyClient::beep(); |
2187 | return; | 2187 | return; |
2188 | } | 2188 | } |
2189 | DndFactory factory( mCalendar ); | 2189 | DndFactory factory( mCalendar ); |
2190 | factory.copyEvent(anEvent); | 2190 | factory.copyEvent(anEvent); |
2191 | } | 2191 | } |
2192 | 2192 | ||
2193 | void CalendarView::edit_paste() | 2193 | void CalendarView::edit_paste() |
2194 | { | 2194 | { |
2195 | QDate date = mNavigator->selectedDates().first(); | 2195 | QDate date = mNavigator->selectedDates().first(); |
2196 | 2196 | ||
2197 | DndFactory factory( mCalendar ); | 2197 | DndFactory factory( mCalendar ); |
2198 | Event *pastedEvent = factory.pasteEvent( date ); | 2198 | Event *pastedEvent = factory.pasteEvent( date ); |
2199 | 2199 | ||
2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2200 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2201 | } | 2201 | } |
2202 | 2202 | ||
2203 | void CalendarView::edit_options() | 2203 | void CalendarView::edit_options() |
2204 | { | 2204 | { |
2205 | mDialogManager->showOptionsDialog(); | 2205 | mDialogManager->showOptionsDialog(); |
2206 | //writeSettings(); | 2206 | //writeSettings(); |
2207 | } | 2207 | } |
2208 | 2208 | ||
2209 | void CalendarView::slotSelectPickerDate( QDate d) | 2209 | void CalendarView::slotSelectPickerDate( QDate d) |
2210 | { | 2210 | { |
2211 | mDateFrame->hide(); | 2211 | mDateFrame->hide(); |
2212 | if ( mDatePickerMode == 1 ) { | 2212 | if ( mDatePickerMode == 1 ) { |
2213 | mNavigator->slotDaySelect( d ); | 2213 | mNavigator->slotDaySelect( d ); |
2214 | } else if ( mDatePickerMode == 2 ) { | 2214 | } else if ( mDatePickerMode == 2 ) { |
2215 | if ( mMoveIncidence->type() == "Todo" ) { | 2215 | if ( mMoveIncidence->type() == "Todo" ) { |
2216 | Todo * to = (Todo *) mMoveIncidence; | 2216 | Todo * to = (Todo *) mMoveIncidence; |
2217 | QTime tim; | 2217 | QTime tim; |
2218 | if ( to->hasDueDate() ) | 2218 | if ( to->hasDueDate() ) |
2219 | tim = to->dtDue().time(); | 2219 | tim = to->dtDue().time(); |
2220 | else { | 2220 | else { |
2221 | tim = QTime ( 0,0,0 ); | 2221 | tim = QTime ( 0,0,0 ); |
2222 | to->setFloats( true ); | 2222 | to->setFloats( true ); |
2223 | to->setHasDueDate( true ); | 2223 | to->setHasDueDate( true ); |
2224 | } | 2224 | } |
2225 | QDateTime dt ( d,tim ); | 2225 | QDateTime dt ( d,tim ); |
2226 | to->setDtDue( dt ); | 2226 | to->setDtDue( dt ); |
2227 | todoChanged( to ); | 2227 | todoChanged( to ); |
2228 | } else { | 2228 | } else { |
2229 | QTime tim = mMoveIncidence->dtStart().time(); | 2229 | QTime tim = mMoveIncidence->dtStart().time(); |
2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2230 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2231 | QDateTime dt ( d,tim ); | 2231 | QDateTime dt ( d,tim ); |
2232 | mMoveIncidence->setDtStart( dt ); | 2232 | mMoveIncidence->setDtStart( dt ); |
2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2233 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2234 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2235 | } | 2235 | } |
2236 | 2236 | ||
2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2237 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2238 | } | 2238 | } |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::removeCategories() | 2241 | void CalendarView::removeCategories() |
2242 | { | 2242 | { |
2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2243 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2244 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2245 | QStringList catIncList; | 2245 | QStringList catIncList; |
2246 | QStringList newCatList; | 2246 | QStringList newCatList; |
2247 | Incidence* inc = incList.first(); | 2247 | Incidence* inc = incList.first(); |
2248 | int i; | 2248 | int i; |
2249 | int count = 0; | 2249 | int count = 0; |
2250 | while ( inc ) { | 2250 | while ( inc ) { |
2251 | newCatList.clear(); | 2251 | newCatList.clear(); |
2252 | catIncList = inc->categories() ; | 2252 | catIncList = inc->categories() ; |
2253 | for( i = 0; i< catIncList.count(); ++i ) { | 2253 | for( i = 0; i< catIncList.count(); ++i ) { |
2254 | if ( catList.contains (catIncList[i])) | 2254 | if ( catList.contains (catIncList[i])) |
2255 | newCatList.append( catIncList[i] ); | 2255 | newCatList.append( catIncList[i] ); |
2256 | } | 2256 | } |
2257 | newCatList.sort(); | 2257 | newCatList.sort(); |
2258 | inc->setCategories( newCatList.join(",") ); | 2258 | inc->setCategories( newCatList.join(",") ); |
2259 | inc = incList.next(); | 2259 | inc = incList.next(); |
2260 | } | 2260 | } |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | int CalendarView::addCategories() | 2263 | int CalendarView::addCategories() |
2264 | { | 2264 | { |
2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2267 | QStringList catIncList; | 2267 | QStringList catIncList; |
2268 | Incidence* inc = incList.first(); | 2268 | Incidence* inc = incList.first(); |
2269 | int i; | 2269 | int i; |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | while ( inc ) { | 2271 | while ( inc ) { |
2272 | catIncList = inc->categories() ; | 2272 | catIncList = inc->categories() ; |
2273 | for( i = 0; i< catIncList.count(); ++i ) { | 2273 | for( i = 0; i< catIncList.count(); ++i ) { |
2274 | if ( !catList.contains (catIncList[i])) { | 2274 | if ( !catList.contains (catIncList[i])) { |
2275 | catList.append( catIncList[i] ); | 2275 | catList.append( catIncList[i] ); |
2276 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2276 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2277 | ++count; | 2277 | ++count; |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | inc = incList.next(); | 2280 | inc = incList.next(); |
2281 | } | 2281 | } |
2282 | catList.sort(); | 2282 | catList.sort(); |
2283 | KOPrefs::instance()->mCustomCategories = catList; | 2283 | KOPrefs::instance()->mCustomCategories = catList; |
2284 | return count; | 2284 | return count; |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | void CalendarView::manageCategories() | 2287 | void CalendarView::manageCategories() |
2288 | { | 2288 | { |
2289 | KOCatPrefs* cp = new KOCatPrefs(); | 2289 | KOCatPrefs* cp = new KOCatPrefs(); |
2290 | cp->show(); | 2290 | cp->show(); |
2291 | int w =cp->sizeHint().width() ; | 2291 | int w =cp->sizeHint().width() ; |
2292 | int h = cp->sizeHint().height() ; | 2292 | int h = cp->sizeHint().height() ; |
2293 | int dw = QApplication::desktop()->width(); | 2293 | int dw = QApplication::desktop()->width(); |
2294 | int dh = QApplication::desktop()->height(); | 2294 | int dh = QApplication::desktop()->height(); |
2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2296 | if ( !cp->exec() ) { | 2296 | if ( !cp->exec() ) { |
2297 | delete cp; | 2297 | delete cp; |
2298 | return; | 2298 | return; |
2299 | } | 2299 | } |
2300 | int count = 0; | 2300 | int count = 0; |
2301 | if ( cp->addCat() ) { | 2301 | if ( cp->addCat() ) { |
2302 | count = addCategories(); | 2302 | count = addCategories(); |
2303 | if ( count ) { | 2303 | if ( count ) { |
2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2305 | writeSettings(); | 2305 | writeSettings(); |
2306 | } else | 2306 | } else |
2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2308 | } else { | 2308 | } else { |
2309 | removeCategories(); | 2309 | removeCategories(); |
2310 | updateView(); | 2310 | updateView(); |
2311 | } | 2311 | } |
2312 | delete cp; | 2312 | delete cp; |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | void CalendarView::beamIncidence(Incidence * Inc) | 2315 | void CalendarView::beamIncidence(Incidence * Inc) |
2316 | { | 2316 | { |
2317 | QPtrList<Incidence> delSel ; | 2317 | QPtrList<Incidence> delSel ; |
2318 | delSel.append(Inc); | 2318 | delSel.append(Inc); |
2319 | beamIncidenceList( delSel ); | 2319 | beamIncidenceList( delSel ); |
2320 | } | 2320 | } |
2321 | void CalendarView::beamCalendar() | 2321 | void CalendarView::beamCalendar() |
2322 | { | 2322 | { |
2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2324 | //qDebug("beamCalendar() "); | 2324 | //qDebug("beamCalendar() "); |
2325 | beamIncidenceList( delSel ); | 2325 | beamIncidenceList( delSel ); |
2326 | } | 2326 | } |
2327 | void CalendarView::beamFilteredCalendar() | 2327 | void CalendarView::beamFilteredCalendar() |
2328 | { | 2328 | { |
2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2330 | //qDebug("beamFilteredCalendar() "); | 2330 | //qDebug("beamFilteredCalendar() "); |
2331 | beamIncidenceList( delSel ); | 2331 | beamIncidenceList( delSel ); |
2332 | } | 2332 | } |
2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2334 | { | 2334 | { |
2335 | if ( beamDialog->exec () == QDialog::Rejected ) | 2335 | if ( beamDialog->exec () == QDialog::Rejected ) |
2336 | return; | 2336 | return; |
2337 | #ifdef DESKTOP_VERSION | 2337 | #ifdef DESKTOP_VERSION |
2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2339 | #else | 2339 | #else |
2340 | QString fn = "/tmp/kopibeamfile"; | 2340 | QString fn = "/tmp/kopibeamfile"; |
2341 | #endif | 2341 | #endif |
2342 | QString mes; | 2342 | QString mes; |
2343 | bool createbup = true; | 2343 | bool createbup = true; |
2344 | if ( createbup ) { | 2344 | if ( createbup ) { |
2345 | QString description = "\n"; | 2345 | QString description = "\n"; |
2346 | CalendarLocal* cal = new CalendarLocal(); | 2346 | CalendarLocal* cal = new CalendarLocal(); |
2347 | if ( beamDialog->beamLocal() ) | 2347 | if ( beamDialog->beamLocal() ) |
2348 | cal->setLocalTime(); | 2348 | cal->setLocalTime(); |
2349 | else | 2349 | else |
2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2351 | Incidence *incidence = delSel.first(); | 2351 | Incidence *incidence = delSel.first(); |
2352 | bool addText = false; | 2352 | bool addText = false; |
2353 | if ( delSel.count() < 10 ) | 2353 | if ( delSel.count() < 10 ) |
2354 | addText = true; | 2354 | addText = true; |
2355 | else { | 2355 | else { |
2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2357 | } | 2357 | } |
2358 | while ( incidence ) { | 2358 | while ( incidence ) { |
2359 | Incidence *in = incidence->clone(); | 2359 | Incidence *in = incidence->clone(); |
2360 | if ( ! in->summary().isEmpty() ) { | 2360 | if ( ! in->summary().isEmpty() ) { |
2361 | in->setDescription(""); | 2361 | in->setDescription(""); |
2362 | } else { | 2362 | } else { |
2363 | in->setSummary( in->description().left(20)); | 2363 | in->setSummary( in->description().left(20)); |
2364 | in->setDescription(""); | 2364 | in->setDescription(""); |
2365 | } | 2365 | } |
2366 | if ( addText ) | 2366 | if ( addText ) |
2367 | description += in->summary() + "\n"; | 2367 | description += in->summary() + "\n"; |
2368 | cal->addIncidence( in ); | 2368 | cal->addIncidence( in ); |
2369 | incidence = delSel.next(); | 2369 | incidence = delSel.next(); |
2370 | } | 2370 | } |
2371 | if ( beamDialog->beamVcal() ) { | 2371 | if ( beamDialog->beamVcal() ) { |
2372 | fn += ".vcs"; | 2372 | fn += ".vcs"; |
2373 | FileStorage storage( cal, fn, new VCalFormat ); | 2373 | FileStorage storage( cal, fn, new VCalFormat ); |
2374 | storage.save(); | 2374 | storage.save(); |
2375 | } else { | 2375 | } else { |
2376 | fn += ".ics"; | 2376 | fn += ".ics"; |
2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2378 | storage.save(); | 2378 | storage.save(); |
2379 | } | 2379 | } |
2380 | delete cal; | 2380 | delete cal; |
2381 | mes = i18n("KO/Pi: Ready for beaming"); | 2381 | mes = i18n("KO/Pi: Ready for beaming"); |
2382 | topLevelWidget()->setCaption(mes); | 2382 | topLevelWidget()->setCaption(mes); |
2383 | KApplication::convert2latin1( fn ); | 2383 | KApplication::convert2latin1( fn ); |
2384 | #ifndef DESKTOP_VERSION | 2384 | #ifndef DESKTOP_VERSION |
2385 | Ir *ir = new Ir( this ); | 2385 | Ir *ir = new Ir( this ); |
2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2387 | ir->send( fn, description, "text/x-vCalendar" ); | 2387 | ir->send( fn, description, "text/x-vCalendar" ); |
2388 | #endif | 2388 | #endif |
2389 | } | 2389 | } |
2390 | } | 2390 | } |
2391 | void CalendarView::beamDone( Ir *ir ) | 2391 | void CalendarView::beamDone( Ir *ir ) |
2392 | { | 2392 | { |
2393 | #ifndef DESKTOP_VERSION | 2393 | #ifndef DESKTOP_VERSION |
2394 | delete ir; | 2394 | delete ir; |
2395 | #endif | 2395 | #endif |
2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2397 | topLevelWidget()->raise(); | 2397 | topLevelWidget()->raise(); |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | void CalendarView::moveIncidence(Incidence * inc ) | 2400 | void CalendarView::moveIncidence(Incidence * inc ) |
2401 | { | 2401 | { |
2402 | if ( !inc ) return; | 2402 | if ( !inc ) return; |
2403 | // qDebug("showDatePickerForIncidence( ) "); | 2403 | // qDebug("showDatePickerForIncidence( ) "); |
2404 | if ( mDateFrame->isVisible() ) | 2404 | if ( mDateFrame->isVisible() ) |
2405 | mDateFrame->hide(); | 2405 | mDateFrame->hide(); |
2406 | else { | 2406 | else { |
2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2409 | int dw = QApplication::desktop()->width(); | 2409 | int dw = QApplication::desktop()->width(); |
2410 | int dh = QApplication::desktop()->height(); | 2410 | int dh = QApplication::desktop()->height(); |
2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2412 | mDateFrame->show(); | 2412 | mDateFrame->show(); |
2413 | } | 2413 | } |
2414 | mDatePickerMode = 2; | 2414 | mDatePickerMode = 2; |
2415 | mMoveIncidence = inc ; | 2415 | mMoveIncidence = inc ; |
2416 | QDate da; | 2416 | QDate da; |
2417 | if ( mMoveIncidence->type() == "Todo" ) { | 2417 | if ( mMoveIncidence->type() == "Todo" ) { |
2418 | Todo * to = (Todo *) mMoveIncidence; | 2418 | Todo * to = (Todo *) mMoveIncidence; |
2419 | if ( to->hasDueDate() ) | 2419 | if ( to->hasDueDate() ) |
2420 | da = to->dtDue().date(); | 2420 | da = to->dtDue().date(); |
2421 | else | 2421 | else |
2422 | da = QDate::currentDate(); | 2422 | da = QDate::currentDate(); |
2423 | } else { | 2423 | } else { |
2424 | da = mMoveIncidence->dtStart().date(); | 2424 | da = mMoveIncidence->dtStart().date(); |
2425 | } | 2425 | } |
2426 | mDatePicker->setDate( da ); | 2426 | mDatePicker->setDate( da ); |
2427 | } | 2427 | } |
2428 | void CalendarView::showDatePicker( ) | 2428 | void CalendarView::showDatePicker( ) |
2429 | { | 2429 | { |
2430 | //qDebug("CalendarView::showDatePicker( ) "); | 2430 | //qDebug("CalendarView::showDatePicker( ) "); |
2431 | if ( mDateFrame->isVisible() ) | 2431 | if ( mDateFrame->isVisible() ) |
2432 | mDateFrame->hide(); | 2432 | mDateFrame->hide(); |
2433 | else { | 2433 | else { |
2434 | int w =mDatePicker->sizeHint().width() ; | 2434 | int w =mDatePicker->sizeHint().width() ; |
2435 | int h = mDatePicker->sizeHint().height() ; | 2435 | int h = mDatePicker->sizeHint().height() ; |
2436 | int dw = QApplication::desktop()->width(); | 2436 | int dw = QApplication::desktop()->width(); |
2437 | int dh = QApplication::desktop()->height(); | 2437 | int dh = QApplication::desktop()->height(); |
2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2439 | mDateFrame->show(); | 2439 | mDateFrame->show(); |
2440 | } | 2440 | } |
2441 | mDatePickerMode = 1; | 2441 | mDatePickerMode = 1; |
2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2443 | } | 2443 | } |
2444 | 2444 | ||
2445 | void CalendarView::showEventEditor() | 2445 | void CalendarView::showEventEditor() |
2446 | { | 2446 | { |
2447 | #ifdef DESKTOP_VERSION | 2447 | #ifdef DESKTOP_VERSION |
2448 | mEventEditor->show(); | 2448 | mEventEditor->show(); |
2449 | #else | 2449 | #else |
2450 | if ( mEventEditor->width() != QApplication::desktop()->width() ) | ||
2451 | mEventEditor->hide(); | ||
2450 | mEventEditor->showMaximized(); | 2452 | mEventEditor->showMaximized(); |
2451 | #endif | 2453 | #endif |
2452 | } | 2454 | } |
2453 | void CalendarView::showTodoEditor() | 2455 | void CalendarView::showTodoEditor() |
2454 | { | 2456 | { |
2455 | #ifdef DESKTOP_VERSION | 2457 | #ifdef DESKTOP_VERSION |
2456 | mTodoEditor->show(); | 2458 | mTodoEditor->show(); |
2457 | #else | 2459 | #else |
2460 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) | ||
2461 | mTodoEditor->hide(); | ||
2458 | mTodoEditor->showMaximized(); | 2462 | mTodoEditor->showMaximized(); |
2459 | #endif | 2463 | #endif |
2460 | } | 2464 | } |
2461 | 2465 | ||
2462 | void CalendarView::cloneIncidence() | 2466 | void CalendarView::cloneIncidence() |
2463 | { | 2467 | { |
2464 | Incidence *incidence = currentSelection(); | 2468 | Incidence *incidence = currentSelection(); |
2465 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2469 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2466 | if ( incidence ) { | 2470 | if ( incidence ) { |
2467 | cloneIncidence(incidence); | 2471 | cloneIncidence(incidence); |
2468 | } | 2472 | } |
2469 | } | 2473 | } |
2470 | void CalendarView::moveIncidence() | 2474 | void CalendarView::moveIncidence() |
2471 | { | 2475 | { |
2472 | Incidence *incidence = currentSelection(); | 2476 | Incidence *incidence = currentSelection(); |
2473 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2477 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2474 | if ( incidence ) { | 2478 | if ( incidence ) { |
2475 | moveIncidence(incidence); | 2479 | moveIncidence(incidence); |
2476 | } | 2480 | } |
2477 | } | 2481 | } |
2478 | void CalendarView::beamIncidence() | 2482 | void CalendarView::beamIncidence() |
2479 | { | 2483 | { |
2480 | Incidence *incidence = currentSelection(); | 2484 | Incidence *incidence = currentSelection(); |
2481 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2485 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2482 | if ( incidence ) { | 2486 | if ( incidence ) { |
2483 | beamIncidence(incidence); | 2487 | beamIncidence(incidence); |
2484 | } | 2488 | } |
2485 | } | 2489 | } |
2486 | void CalendarView::toggleCancelIncidence() | 2490 | void CalendarView::toggleCancelIncidence() |
2487 | { | 2491 | { |
2488 | Incidence *incidence = currentSelection(); | 2492 | Incidence *incidence = currentSelection(); |
2489 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2493 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2490 | if ( incidence ) { | 2494 | if ( incidence ) { |
2491 | cancelIncidence(incidence); | 2495 | cancelIncidence(incidence); |
2492 | } | 2496 | } |
2493 | } | 2497 | } |
2494 | 2498 | ||
2495 | 2499 | ||
2496 | void CalendarView::cancelIncidence(Incidence * inc ) | 2500 | void CalendarView::cancelIncidence(Incidence * inc ) |
2497 | { | 2501 | { |
2498 | inc->setCancelled( ! inc->cancelled() ); | 2502 | inc->setCancelled( ! inc->cancelled() ); |
2499 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2503 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2500 | updateView(); | 2504 | updateView(); |
2501 | } | 2505 | } |
2502 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2506 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2503 | { | 2507 | { |
2504 | Incidence * newInc = orgInc->clone(); | 2508 | Incidence * newInc = orgInc->clone(); |
2505 | newInc->recreate(); | 2509 | newInc->recreate(); |
2506 | 2510 | ||
2507 | if ( newInc->type() == "Todo" ) { | 2511 | if ( newInc->type() == "Todo" ) { |
2508 | Todo* t = (Todo*) newInc; | 2512 | Todo* t = (Todo*) newInc; |
2509 | mTodoEditor->editTodo( t ); | 2513 | mTodoEditor->editTodo( t ); |
2510 | showTodoEditor(); | 2514 | showTodoEditor(); |
2511 | if ( mTodoEditor->exec() ) { | 2515 | if ( mTodoEditor->exec() ) { |
2512 | mCalendar->addTodo( t ); | 2516 | mCalendar->addTodo( t ); |
2513 | updateView(); | 2517 | updateView(); |
2514 | } else { | 2518 | } else { |
2515 | delete t; | 2519 | delete t; |
2516 | } | 2520 | } |
2517 | } | 2521 | } |
2518 | else { | 2522 | else { |
2519 | Event* e = (Event*) newInc; | 2523 | Event* e = (Event*) newInc; |
2520 | mEventEditor->editEvent( e ); | 2524 | mEventEditor->editEvent( e ); |
2521 | showEventEditor(); | 2525 | showEventEditor(); |
2522 | if ( mEventEditor->exec() ) { | 2526 | if ( mEventEditor->exec() ) { |
2523 | mCalendar->addEvent( e ); | 2527 | mCalendar->addEvent( e ); |
2524 | updateView(); | 2528 | updateView(); |
2525 | } else { | 2529 | } else { |
2526 | delete e; | 2530 | delete e; |
2527 | } | 2531 | } |
2528 | } | 2532 | } |
2529 | } | 2533 | } |
2530 | 2534 | ||
2531 | void CalendarView::newEvent() | 2535 | void CalendarView::newEvent() |
2532 | { | 2536 | { |
2533 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2537 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2534 | KOAgendaView *aView = mViewManager->agendaView(); | 2538 | KOAgendaView *aView = mViewManager->agendaView(); |
2535 | if (aView) { | 2539 | if (aView) { |
2536 | if (aView->selectionStart().isValid()) { | 2540 | if (aView->selectionStart().isValid()) { |
2537 | if (aView->selectedIsAllDay()) { | 2541 | if (aView->selectedIsAllDay()) { |
2538 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2542 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2539 | } else { | 2543 | } else { |
2540 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2544 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2541 | } | 2545 | } |
2542 | return; | 2546 | return; |
2543 | } | 2547 | } |
2544 | } | 2548 | } |
2545 | 2549 | ||
2546 | QDate date = mNavigator->selectedDates().first(); | 2550 | QDate date = mNavigator->selectedDates().first(); |
2547 | QDateTime current = QDateTime::currentDateTime(); | 2551 | QDateTime current = QDateTime::currentDateTime(); |
2548 | if ( date <= current.date() ) { | 2552 | if ( date <= current.date() ) { |
2549 | int hour = current.time().hour() +1; | 2553 | int hour = current.time().hour() +1; |
2550 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2554 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2551 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2555 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2552 | } else | 2556 | } else |
2553 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2557 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2554 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2558 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2555 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2559 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2556 | } | 2560 | } |
2557 | 2561 | ||
2558 | void CalendarView::newEvent(QDateTime fh) | 2562 | void CalendarView::newEvent(QDateTime fh) |
2559 | { | 2563 | { |
2560 | newEvent(fh, | 2564 | newEvent(fh, |
2561 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2565 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2562 | } | 2566 | } |
2563 | 2567 | ||
2564 | void CalendarView::newEvent(QDate dt) | 2568 | void CalendarView::newEvent(QDate dt) |
2565 | { | 2569 | { |
2566 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2570 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2567 | QDateTime(dt, QTime(0,0,0)), true); | 2571 | QDateTime(dt, QTime(0,0,0)), true); |
2568 | } | 2572 | } |
2569 | 2573 | ||
2570 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2574 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2571 | { | 2575 | { |
2572 | 2576 | ||
2573 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2577 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2574 | if ( mFilterView->filtersEnabled() ) { | 2578 | if ( mFilterView->filtersEnabled() ) { |
2575 | CalFilter *filter = mFilterView->selectedFilter(); | 2579 | CalFilter *filter = mFilterView->selectedFilter(); |
2576 | if (filter && filter->showCategories()) { | 2580 | if (filter && filter->showCategories()) { |
2577 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2581 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2578 | } | 2582 | } |
2579 | if ( filter ) | 2583 | if ( filter ) |
2580 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2584 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2581 | } | 2585 | } |
2582 | showEventEditor(); | 2586 | showEventEditor(); |
2583 | } | 2587 | } |
2584 | void CalendarView::todoAdded(Todo * t) | 2588 | void CalendarView::todoAdded(Todo * t) |
2585 | { | 2589 | { |
2586 | 2590 | ||
2587 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2591 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2588 | updateTodoViews(); | 2592 | updateTodoViews(); |
2589 | } | 2593 | } |
2590 | void CalendarView::todoChanged(Todo * t) | 2594 | void CalendarView::todoChanged(Todo * t) |
2591 | { | 2595 | { |
2592 | emit todoModified( t, 4 ); | 2596 | emit todoModified( t, 4 ); |
2593 | // updateTodoViews(); | 2597 | // updateTodoViews(); |
2594 | } | 2598 | } |
2595 | void CalendarView::todoToBeDeleted(Todo *) | 2599 | void CalendarView::todoToBeDeleted(Todo *) |
2596 | { | 2600 | { |
2597 | //qDebug("todoToBeDeleted(Todo *) "); | 2601 | //qDebug("todoToBeDeleted(Todo *) "); |
2598 | updateTodoViews(); | 2602 | updateTodoViews(); |
2599 | } | 2603 | } |
2600 | void CalendarView::todoDeleted() | 2604 | void CalendarView::todoDeleted() |
2601 | { | 2605 | { |
2602 | //qDebug(" todoDeleted()"); | 2606 | //qDebug(" todoDeleted()"); |
2603 | updateTodoViews(); | 2607 | updateTodoViews(); |
2604 | } | 2608 | } |
2605 | 2609 | ||
2606 | 2610 | ||
2607 | 2611 | ||
2608 | void CalendarView::newTodo() | 2612 | void CalendarView::newTodo() |
2609 | { | 2613 | { |
2610 | 2614 | ||
2611 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2615 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2612 | if ( mFilterView->filtersEnabled() ) { | 2616 | if ( mFilterView->filtersEnabled() ) { |
2613 | CalFilter *filter = mFilterView->selectedFilter(); | 2617 | CalFilter *filter = mFilterView->selectedFilter(); |
2614 | if (filter && filter->showCategories()) { | 2618 | if (filter && filter->showCategories()) { |
2615 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2619 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2616 | } | 2620 | } |
2617 | if ( filter ) | 2621 | if ( filter ) |
2618 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2622 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2619 | } | 2623 | } |
2620 | showTodoEditor(); | 2624 | showTodoEditor(); |
2621 | } | 2625 | } |
2622 | 2626 | ||
2623 | void CalendarView::newSubTodo() | 2627 | void CalendarView::newSubTodo() |
2624 | { | 2628 | { |
2625 | Todo *todo = selectedTodo(); | 2629 | Todo *todo = selectedTodo(); |
2626 | if ( todo ) newSubTodo( todo ); | 2630 | if ( todo ) newSubTodo( todo ); |
2627 | } | 2631 | } |
2628 | 2632 | ||
2629 | void CalendarView::newSubTodo(Todo *parentEvent) | 2633 | void CalendarView::newSubTodo(Todo *parentEvent) |
2630 | { | 2634 | { |
2631 | 2635 | ||
2632 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2636 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2633 | showTodoEditor(); | 2637 | showTodoEditor(); |
2634 | } | 2638 | } |
2635 | 2639 | ||
2636 | void CalendarView::newFloatingEvent() | 2640 | void CalendarView::newFloatingEvent() |
2637 | { | 2641 | { |
2638 | DateList tmpList = mNavigator->selectedDates(); | 2642 | DateList tmpList = mNavigator->selectedDates(); |
2639 | QDate date = tmpList.first(); | 2643 | QDate date = tmpList.first(); |
2640 | 2644 | ||
2641 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2645 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2642 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2646 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2643 | } | 2647 | } |
2644 | 2648 | ||
2645 | 2649 | ||
2646 | void CalendarView::editEvent( Event *event ) | 2650 | void CalendarView::editEvent( Event *event ) |
2647 | { | 2651 | { |
2648 | 2652 | ||
2649 | if ( !event ) return; | 2653 | if ( !event ) return; |
2650 | if ( event->isReadOnly() ) { | 2654 | if ( event->isReadOnly() ) { |
2651 | showEvent( event ); | 2655 | showEvent( event ); |
2652 | return; | 2656 | return; |
2653 | } | 2657 | } |
2654 | mEventEditor->editEvent( event , mFlagEditDescription); | 2658 | mEventEditor->editEvent( event , mFlagEditDescription); |
2655 | showEventEditor(); | 2659 | showEventEditor(); |
2656 | } | 2660 | } |
2657 | void CalendarView::editJournal( Journal *jour ) | 2661 | void CalendarView::editJournal( Journal *jour ) |
2658 | { | 2662 | { |
2659 | if ( !jour ) return; | 2663 | if ( !jour ) return; |
2660 | mDialogManager->hideSearchDialog(); | 2664 | mDialogManager->hideSearchDialog(); |
2661 | mViewManager->showJournalView(); | 2665 | mViewManager->showJournalView(); |
2662 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2666 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2663 | } | 2667 | } |
2664 | void CalendarView::editTodo( Todo *todo ) | 2668 | void CalendarView::editTodo( Todo *todo ) |
2665 | { | 2669 | { |
2666 | if ( !todo ) return; | 2670 | if ( !todo ) return; |
2667 | 2671 | ||
2668 | if ( todo->isReadOnly() ) { | 2672 | if ( todo->isReadOnly() ) { |
2669 | showTodo( todo ); | 2673 | showTodo( todo ); |
2670 | return; | 2674 | return; |
2671 | } | 2675 | } |
2672 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2676 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2673 | showTodoEditor(); | 2677 | showTodoEditor(); |
2674 | 2678 | ||
2675 | } | 2679 | } |
2676 | 2680 | ||
2677 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2681 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2678 | { | 2682 | { |
2679 | if ( !mEventViewerDialog ) { | 2683 | if ( !mEventViewerDialog ) { |
2680 | mEventViewerDialog = new KOEventViewerDialog(this); | 2684 | mEventViewerDialog = new KOEventViewerDialog(this); |
2681 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2685 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2682 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2686 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2683 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2687 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2684 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2688 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2685 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2689 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2686 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2690 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2687 | mEventViewerDialog->resize( 640, 480 ); | 2691 | mEventViewerDialog->resize( 640, 480 ); |
2688 | 2692 | ||
2689 | } | 2693 | } |
2690 | return mEventViewerDialog; | 2694 | return mEventViewerDialog; |
2691 | } | 2695 | } |
2692 | void CalendarView::showEvent(Event *event) | 2696 | void CalendarView::showEvent(Event *event) |
2693 | { | 2697 | { |
2694 | getEventViewerDialog()->setEvent(event); | 2698 | getEventViewerDialog()->setEvent(event); |
2695 | getEventViewerDialog()->showMe(); | 2699 | getEventViewerDialog()->showMe(); |
2696 | } | 2700 | } |
2697 | 2701 | ||
2698 | void CalendarView::showTodo(Todo *event) | 2702 | void CalendarView::showTodo(Todo *event) |
2699 | { | 2703 | { |
2700 | getEventViewerDialog()->setTodo(event); | 2704 | getEventViewerDialog()->setTodo(event); |
2701 | getEventViewerDialog()->showMe(); | 2705 | getEventViewerDialog()->showMe(); |
2702 | } | 2706 | } |
2703 | void CalendarView::showJournal( Journal *jour ) | 2707 | void CalendarView::showJournal( Journal *jour ) |
2704 | { | 2708 | { |
2705 | getEventViewerDialog()->setJournal(jour); | 2709 | getEventViewerDialog()->setJournal(jour); |
2706 | getEventViewerDialog()->showMe(); | 2710 | getEventViewerDialog()->showMe(); |
2707 | 2711 | ||
2708 | } | 2712 | } |
2709 | // void CalendarView::todoModified (Todo *event, int changed) | 2713 | // void CalendarView::todoModified (Todo *event, int changed) |
2710 | // { | 2714 | // { |
2711 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2715 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2712 | // // kdDebug() << "Todo modified and open" << endl; | 2716 | // // kdDebug() << "Todo modified and open" << endl; |
2713 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2717 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2714 | // // temp->modified (changed); | 2718 | // // temp->modified (changed); |
2715 | 2719 | ||
2716 | // // } | 2720 | // // } |
2717 | 2721 | ||
2718 | // mViewManager->updateView(); | 2722 | // mViewManager->updateView(); |
2719 | // } | 2723 | // } |
2720 | 2724 | ||
2721 | void CalendarView::appointment_show() | 2725 | void CalendarView::appointment_show() |
2722 | { | 2726 | { |
2723 | Event *anEvent = 0; | 2727 | Event *anEvent = 0; |
2724 | 2728 | ||
2725 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2729 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2726 | 2730 | ||
2727 | if (mViewManager->currentView()->isEventView()) { | 2731 | if (mViewManager->currentView()->isEventView()) { |
2728 | if ( incidence && incidence->type() == "Event" ) { | 2732 | if ( incidence && incidence->type() == "Event" ) { |
2729 | anEvent = static_cast<Event *>(incidence); | 2733 | anEvent = static_cast<Event *>(incidence); |
2730 | } | 2734 | } |
2731 | } | 2735 | } |
2732 | 2736 | ||
2733 | if (!anEvent) { | 2737 | if (!anEvent) { |
2734 | KNotifyClient::beep(); | 2738 | KNotifyClient::beep(); |
2735 | return; | 2739 | return; |
2736 | } | 2740 | } |
2737 | 2741 | ||
2738 | showEvent(anEvent); | 2742 | showEvent(anEvent); |
2739 | } | 2743 | } |
2740 | 2744 | ||
2741 | void CalendarView::appointment_edit() | 2745 | void CalendarView::appointment_edit() |
2742 | { | 2746 | { |
2743 | Event *anEvent = 0; | 2747 | Event *anEvent = 0; |
2744 | 2748 | ||
2745 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2749 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2746 | 2750 | ||
2747 | if (mViewManager->currentView()->isEventView()) { | 2751 | if (mViewManager->currentView()->isEventView()) { |
2748 | if ( incidence && incidence->type() == "Event" ) { | 2752 | if ( incidence && incidence->type() == "Event" ) { |
2749 | anEvent = static_cast<Event *>(incidence); | 2753 | anEvent = static_cast<Event *>(incidence); |
2750 | } | 2754 | } |
2751 | } | 2755 | } |
2752 | 2756 | ||
2753 | if (!anEvent) { | 2757 | if (!anEvent) { |
2754 | KNotifyClient::beep(); | 2758 | KNotifyClient::beep(); |
2755 | return; | 2759 | return; |
2756 | } | 2760 | } |
2757 | 2761 | ||
2758 | editEvent(anEvent); | 2762 | editEvent(anEvent); |
2759 | } | 2763 | } |
2760 | 2764 | ||
2761 | void CalendarView::appointment_delete() | 2765 | void CalendarView::appointment_delete() |
2762 | { | 2766 | { |
2763 | Event *anEvent = 0; | 2767 | Event *anEvent = 0; |
2764 | 2768 | ||
2765 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2769 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2766 | 2770 | ||
2767 | if (mViewManager->currentView()->isEventView()) { | 2771 | if (mViewManager->currentView()->isEventView()) { |
2768 | if ( incidence && incidence->type() == "Event" ) { | 2772 | if ( incidence && incidence->type() == "Event" ) { |
2769 | anEvent = static_cast<Event *>(incidence); | 2773 | anEvent = static_cast<Event *>(incidence); |
2770 | } | 2774 | } |
2771 | } | 2775 | } |
2772 | 2776 | ||
2773 | if (!anEvent) { | 2777 | if (!anEvent) { |
2774 | KNotifyClient::beep(); | 2778 | KNotifyClient::beep(); |
2775 | return; | 2779 | return; |
2776 | } | 2780 | } |
2777 | 2781 | ||
2778 | deleteEvent(anEvent); | 2782 | deleteEvent(anEvent); |
2779 | } | 2783 | } |
2780 | 2784 | ||
2781 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2785 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2782 | { | 2786 | { |
2783 | if (!sub) return; | 2787 | if (!sub) return; |
2784 | if (!parent) return; | 2788 | if (!parent) return; |
2785 | if ( sub->relatedTo() ) | 2789 | if ( sub->relatedTo() ) |
2786 | sub->relatedTo()->removeRelation(sub); | 2790 | sub->relatedTo()->removeRelation(sub); |
2787 | sub->setRelatedTo(parent); | 2791 | sub->setRelatedTo(parent); |
2788 | sub->setRelatedToUid(parent->uid()); | 2792 | sub->setRelatedToUid(parent->uid()); |
2789 | parent->addRelation(sub); | 2793 | parent->addRelation(sub); |
2790 | sub->updated(); | 2794 | sub->updated(); |
2791 | parent->updated(); | 2795 | parent->updated(); |
2792 | setModified(true); | 2796 | setModified(true); |
2793 | updateView(); | 2797 | updateView(); |
2794 | } | 2798 | } |
2795 | void CalendarView::todo_unsub(Todo *anTodo ) | 2799 | void CalendarView::todo_unsub(Todo *anTodo ) |
2796 | { | 2800 | { |
2797 | // Todo *anTodo = selectedTodo(); | 2801 | // Todo *anTodo = selectedTodo(); |
2798 | if (!anTodo) return; | 2802 | if (!anTodo) return; |
2799 | if (!anTodo->relatedTo()) return; | 2803 | if (!anTodo->relatedTo()) return; |
2800 | anTodo->relatedTo()->removeRelation(anTodo); | 2804 | anTodo->relatedTo()->removeRelation(anTodo); |
2801 | anTodo->setRelatedTo(0); | 2805 | anTodo->setRelatedTo(0); |
2802 | anTodo->updated(); | 2806 | anTodo->updated(); |
2803 | anTodo->setRelatedToUid(""); | 2807 | anTodo->setRelatedToUid(""); |
2804 | setModified(true); | 2808 | setModified(true); |
2805 | updateView(); | 2809 | updateView(); |
2806 | } | 2810 | } |
2807 | 2811 | ||
2808 | void CalendarView::deleteTodo(Todo *todo) | 2812 | void CalendarView::deleteTodo(Todo *todo) |
2809 | { | 2813 | { |
2810 | if (!todo) { | 2814 | if (!todo) { |
2811 | KNotifyClient::beep(); | 2815 | KNotifyClient::beep(); |
2812 | return; | 2816 | return; |
2813 | } | 2817 | } |
2814 | if (KOPrefs::instance()->mConfirm) { | 2818 | if (KOPrefs::instance()->mConfirm) { |
2815 | switch (msgItemDelete()) { | 2819 | switch (msgItemDelete()) { |
2816 | case KMessageBox::Continue: // OK | 2820 | case KMessageBox::Continue: // OK |
2817 | if (!todo->relations().isEmpty()) { | 2821 | if (!todo->relations().isEmpty()) { |
2818 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2822 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2819 | i18n("Delete To-Do")); | 2823 | i18n("Delete To-Do")); |
2820 | } else { | 2824 | } else { |
2821 | checkExternalId( todo ); | 2825 | checkExternalId( todo ); |
2822 | calendar()->deleteTodo(todo); | 2826 | calendar()->deleteTodo(todo); |
2823 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2827 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2824 | updateView(); | 2828 | updateView(); |
2825 | } | 2829 | } |
2826 | break; | 2830 | break; |
2827 | } // switch | 2831 | } // switch |
2828 | } else { | 2832 | } else { |
2829 | if (!todo->relations().isEmpty()) { | 2833 | if (!todo->relations().isEmpty()) { |
2830 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2834 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2831 | i18n("Delete To-Do")); | 2835 | i18n("Delete To-Do")); |
2832 | } else { | 2836 | } else { |
2833 | checkExternalId( todo ); | 2837 | checkExternalId( todo ); |
2834 | mCalendar->deleteTodo(todo); | 2838 | mCalendar->deleteTodo(todo); |
2835 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2839 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2836 | updateView(); | 2840 | updateView(); |
2837 | } | 2841 | } |
2838 | } | 2842 | } |
2839 | emit updateSearchDialog(); | 2843 | emit updateSearchDialog(); |
2840 | } | 2844 | } |
2841 | void CalendarView::deleteJournal(Journal *jour) | 2845 | void CalendarView::deleteJournal(Journal *jour) |
2842 | { | 2846 | { |
2843 | if (!jour) { | 2847 | if (!jour) { |
2844 | KNotifyClient::beep(); | 2848 | KNotifyClient::beep(); |
2845 | return; | 2849 | return; |
2846 | } | 2850 | } |
2847 | if (KOPrefs::instance()->mConfirm) { | 2851 | if (KOPrefs::instance()->mConfirm) { |
2848 | switch (msgItemDelete()) { | 2852 | switch (msgItemDelete()) { |
2849 | case KMessageBox::Continue: // OK | 2853 | case KMessageBox::Continue: // OK |
2850 | calendar()->deleteJournal(jour); | 2854 | calendar()->deleteJournal(jour); |
2851 | updateView(); | 2855 | updateView(); |
2852 | break; | 2856 | break; |
2853 | } // switch | 2857 | } // switch |
2854 | } else { | 2858 | } else { |
2855 | calendar()->deleteJournal(jour);; | 2859 | calendar()->deleteJournal(jour);; |
2856 | updateView(); | 2860 | updateView(); |
2857 | } | 2861 | } |
2858 | emit updateSearchDialog(); | 2862 | emit updateSearchDialog(); |
2859 | } | 2863 | } |
2860 | 2864 | ||
2861 | void CalendarView::deleteEvent(Event *anEvent) | 2865 | void CalendarView::deleteEvent(Event *anEvent) |
2862 | { | 2866 | { |
2863 | if (!anEvent) { | 2867 | if (!anEvent) { |
2864 | KNotifyClient::beep(); | 2868 | KNotifyClient::beep(); |
2865 | return; | 2869 | return; |
2866 | } | 2870 | } |
2867 | 2871 | ||
2868 | if (anEvent->recurrence()->doesRecur()) { | 2872 | if (anEvent->recurrence()->doesRecur()) { |
2869 | QDate itemDate = mViewManager->currentSelectionDate(); | 2873 | QDate itemDate = mViewManager->currentSelectionDate(); |
2870 | int km; | 2874 | int km; |
2871 | if (!itemDate.isValid()) { | 2875 | if (!itemDate.isValid()) { |
2872 | //kdDebug() << "Date Not Valid" << endl; | 2876 | //kdDebug() << "Date Not Valid" << endl; |
2873 | if (KOPrefs::instance()->mConfirm) { | 2877 | if (KOPrefs::instance()->mConfirm) { |
2874 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2878 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2875 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2879 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2876 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2880 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2877 | if ( km == KMessageBox::Continue ) | 2881 | if ( km == KMessageBox::Continue ) |
2878 | km = KMessageBox::No; // No = all below | 2882 | km = KMessageBox::No; // No = all below |
2879 | } else | 2883 | } else |
2880 | km = KMessageBox::No; | 2884 | km = KMessageBox::No; |
2881 | } else { | 2885 | } else { |
2882 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2886 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2883 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2887 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2884 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2888 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2885 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2889 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2886 | i18n("All")); | 2890 | i18n("All")); |
2887 | } | 2891 | } |
2888 | switch(km) { | 2892 | switch(km) { |
2889 | 2893 | ||
2890 | case KMessageBox::No: // Continue // all | 2894 | case KMessageBox::No: // Continue // all |
2891 | //qDebug("KMessageBox::No "); | 2895 | //qDebug("KMessageBox::No "); |
2892 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2896 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2893 | schedule(Scheduler::Cancel,anEvent); | 2897 | schedule(Scheduler::Cancel,anEvent); |
2894 | 2898 | ||
2895 | checkExternalId( anEvent); | 2899 | checkExternalId( anEvent); |
2896 | mCalendar->deleteEvent(anEvent); | 2900 | mCalendar->deleteEvent(anEvent); |
2897 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2901 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2898 | break; | 2902 | break; |
2899 | 2903 | ||
2900 | // Disabled because it does not work | 2904 | // Disabled because it does not work |
2901 | //#if 0 | 2905 | //#if 0 |
2902 | case KMessageBox::Yes: // just this one | 2906 | case KMessageBox::Yes: // just this one |
2903 | //QDate qd = mNavigator->selectedDates().first(); | 2907 | //QDate qd = mNavigator->selectedDates().first(); |
2904 | //if (!qd.isValid()) { | 2908 | //if (!qd.isValid()) { |
2905 | // kdDebug() << "no date selected, or invalid date" << endl; | 2909 | // kdDebug() << "no date selected, or invalid date" << endl; |
2906 | // KNotifyClient::beep(); | 2910 | // KNotifyClient::beep(); |
2907 | // return; | 2911 | // return; |
2908 | //} | 2912 | //} |
2909 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2913 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2910 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2914 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2911 | anEvent->addExDate(itemDate); | 2915 | anEvent->addExDate(itemDate); |
2912 | int duration = anEvent->recurrence()->duration(); | 2916 | int duration = anEvent->recurrence()->duration(); |
2913 | if ( duration > 0 ) { | 2917 | if ( duration > 0 ) { |
2914 | anEvent->recurrence()->setDuration( duration - 1 ); | 2918 | anEvent->recurrence()->setDuration( duration - 1 ); |
2915 | } | 2919 | } |
2916 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2920 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2917 | } | 2921 | } |
2918 | break; | 2922 | break; |
2919 | //#endif | 2923 | //#endif |
2920 | } // switch | 2924 | } // switch |
2921 | } else { | 2925 | } else { |
2922 | if (KOPrefs::instance()->mConfirm) { | 2926 | if (KOPrefs::instance()->mConfirm) { |
2923 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2927 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2924 | i18n("\nAre you sure you want\nto delete this event?"), | 2928 | i18n("\nAre you sure you want\nto delete this event?"), |
2925 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2929 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2926 | case KMessageBox::Continue: // OK | 2930 | case KMessageBox::Continue: // OK |
2927 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2931 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2928 | schedule(Scheduler::Cancel,anEvent); | 2932 | schedule(Scheduler::Cancel,anEvent); |
2929 | checkExternalId( anEvent); | 2933 | checkExternalId( anEvent); |
2930 | mCalendar->deleteEvent(anEvent); | 2934 | mCalendar->deleteEvent(anEvent); |
2931 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2935 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2932 | break; | 2936 | break; |
2933 | } // switch | 2937 | } // switch |
2934 | } else { | 2938 | } else { |
2935 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2939 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2936 | schedule(Scheduler::Cancel,anEvent); | 2940 | schedule(Scheduler::Cancel,anEvent); |
2937 | checkExternalId( anEvent); | 2941 | checkExternalId( anEvent); |
2938 | mCalendar->deleteEvent(anEvent); | 2942 | mCalendar->deleteEvent(anEvent); |
2939 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2943 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2940 | } | 2944 | } |
2941 | } // if-else | 2945 | } // if-else |
2942 | emit updateSearchDialog(); | 2946 | emit updateSearchDialog(); |
2943 | } | 2947 | } |
2944 | 2948 | ||
2945 | bool CalendarView::deleteEvent(const QString &uid) | 2949 | bool CalendarView::deleteEvent(const QString &uid) |
2946 | { | 2950 | { |
2947 | Event *ev = mCalendar->event(uid); | 2951 | Event *ev = mCalendar->event(uid); |
2948 | if (ev) { | 2952 | if (ev) { |
2949 | deleteEvent(ev); | 2953 | deleteEvent(ev); |
2950 | return true; | 2954 | return true; |
2951 | } else { | 2955 | } else { |
2952 | return false; | 2956 | return false; |
2953 | } | 2957 | } |
2954 | } | 2958 | } |
2955 | 2959 | ||
2956 | /*****************************************************************************/ | 2960 | /*****************************************************************************/ |
2957 | 2961 | ||
2958 | void CalendarView::action_mail() | 2962 | void CalendarView::action_mail() |
2959 | { | 2963 | { |
2960 | #ifndef KORG_NOMAIL | 2964 | #ifndef KORG_NOMAIL |
2961 | KOMailClient mailClient; | 2965 | KOMailClient mailClient; |
2962 | 2966 | ||
2963 | Incidence *incidence = currentSelection(); | 2967 | Incidence *incidence = currentSelection(); |
2964 | 2968 | ||
2965 | if (!incidence) { | 2969 | if (!incidence) { |
2966 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2970 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2967 | return; | 2971 | return; |
2968 | } | 2972 | } |
2969 | if(incidence->attendeeCount() == 0 ) { | 2973 | if(incidence->attendeeCount() == 0 ) { |
2970 | KMessageBox::sorry(this, | 2974 | KMessageBox::sorry(this, |
2971 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2975 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2972 | return; | 2976 | return; |
2973 | } | 2977 | } |
2974 | 2978 | ||
2975 | CalendarLocal cal_tmp; | 2979 | CalendarLocal cal_tmp; |
2976 | Event *event = 0; | 2980 | Event *event = 0; |
2977 | Event *ev = 0; | 2981 | Event *ev = 0; |
2978 | if ( incidence && incidence->type() == "Event" ) { | 2982 | if ( incidence && incidence->type() == "Event" ) { |
2979 | event = static_cast<Event *>(incidence); | 2983 | event = static_cast<Event *>(incidence); |
2980 | ev = new Event(*event); | 2984 | ev = new Event(*event); |
2981 | cal_tmp.addEvent(ev); | 2985 | cal_tmp.addEvent(ev); |
2982 | } | 2986 | } |
2983 | ICalFormat mForm(); | 2987 | ICalFormat mForm(); |
2984 | QString attachment = mForm.toString( &cal_tmp ); | 2988 | QString attachment = mForm.toString( &cal_tmp ); |
2985 | if (ev) delete(ev); | 2989 | if (ev) delete(ev); |
2986 | 2990 | ||
2987 | mailClient.mailAttendees(currentSelection(), attachment); | 2991 | mailClient.mailAttendees(currentSelection(), attachment); |
2988 | 2992 | ||
2989 | #endif | 2993 | #endif |
2990 | 2994 | ||
2991 | #if 0 | 2995 | #if 0 |
2992 | Event *anEvent = 0; | 2996 | Event *anEvent = 0; |
2993 | if (mViewManager->currentView()->isEventView()) { | 2997 | if (mViewManager->currentView()->isEventView()) { |
2994 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2998 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2995 | } | 2999 | } |
2996 | 3000 | ||
2997 | if (!anEvent) { | 3001 | if (!anEvent) { |
2998 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3002 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2999 | return; | 3003 | return; |
3000 | } | 3004 | } |
3001 | if(anEvent->attendeeCount() == 0 ) { | 3005 | if(anEvent->attendeeCount() == 0 ) { |
3002 | KMessageBox::sorry(this, | 3006 | KMessageBox::sorry(this, |
3003 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3007 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3004 | return; | 3008 | return; |
3005 | } | 3009 | } |
3006 | 3010 | ||
3007 | mailobject.emailEvent(anEvent); | 3011 | mailobject.emailEvent(anEvent); |
3008 | #endif | 3012 | #endif |
3009 | } | 3013 | } |
3010 | 3014 | ||
3011 | 3015 | ||
3012 | void CalendarView::schedule_publish(Incidence *incidence) | 3016 | void CalendarView::schedule_publish(Incidence *incidence) |
3013 | { | 3017 | { |
3014 | Event *event = 0; | 3018 | Event *event = 0; |
3015 | Todo *todo = 0; | 3019 | Todo *todo = 0; |
3016 | 3020 | ||
3017 | if (incidence == 0) { | 3021 | if (incidence == 0) { |
3018 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3022 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3019 | if (incidence == 0) { | 3023 | if (incidence == 0) { |
3020 | incidence = mTodoList->selectedIncidences().first(); | 3024 | incidence = mTodoList->selectedIncidences().first(); |
3021 | } | 3025 | } |
3022 | } | 3026 | } |
3023 | if ( incidence && incidence->type() == "Event" ) { | 3027 | if ( incidence && incidence->type() == "Event" ) { |
3024 | event = static_cast<Event *>(incidence); | 3028 | event = static_cast<Event *>(incidence); |
3025 | } else { | 3029 | } else { |
3026 | if ( incidence && incidence->type() == "Todo" ) { | 3030 | if ( incidence && incidence->type() == "Todo" ) { |
3027 | todo = static_cast<Todo *>(incidence); | 3031 | todo = static_cast<Todo *>(incidence); |
3028 | } | 3032 | } |
3029 | } | 3033 | } |
3030 | 3034 | ||
3031 | if (!event && !todo) { | 3035 | if (!event && !todo) { |
3032 | KMessageBox::sorry(this,i18n("No event selected.")); | 3036 | KMessageBox::sorry(this,i18n("No event selected.")); |
3033 | return; | 3037 | return; |
3034 | } | 3038 | } |
3035 | 3039 | ||
3036 | PublishDialog *publishdlg = new PublishDialog(); | 3040 | PublishDialog *publishdlg = new PublishDialog(); |
3037 | if (incidence->attendeeCount()>0) { | 3041 | if (incidence->attendeeCount()>0) { |
3038 | QPtrList<Attendee> attendees = incidence->attendees(); | 3042 | QPtrList<Attendee> attendees = incidence->attendees(); |
3039 | attendees.first(); | 3043 | attendees.first(); |
3040 | while ( attendees.current()!=0 ) { | 3044 | while ( attendees.current()!=0 ) { |
3041 | publishdlg->addAttendee(attendees.current()); | 3045 | publishdlg->addAttendee(attendees.current()); |
3042 | attendees.next(); | 3046 | attendees.next(); |
3043 | } | 3047 | } |
3044 | } | 3048 | } |
3045 | bool send = true; | 3049 | bool send = true; |
3046 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3050 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3047 | if ( publishdlg->exec() != QDialog::Accepted ) | 3051 | if ( publishdlg->exec() != QDialog::Accepted ) |
3048 | send = false; | 3052 | send = false; |
3049 | } | 3053 | } |
3050 | if ( send ) { | 3054 | if ( send ) { |
3051 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3055 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3052 | if ( event ) { | 3056 | if ( event ) { |
3053 | Event *ev = new Event(*event); | 3057 | Event *ev = new Event(*event); |
3054 | ev->registerObserver(0); | 3058 | ev->registerObserver(0); |
3055 | ev->clearAttendees(); | 3059 | ev->clearAttendees(); |
3056 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3060 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3057 | delete(ev); | 3061 | delete(ev); |
3058 | } | 3062 | } |
3059 | } else { | 3063 | } else { |
3060 | if ( todo ) { | 3064 | if ( todo ) { |
3061 | Todo *ev = new Todo(*todo); | 3065 | Todo *ev = new Todo(*todo); |
3062 | ev->registerObserver(0); | 3066 | ev->registerObserver(0); |
3063 | ev->clearAttendees(); | 3067 | ev->clearAttendees(); |
3064 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3068 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3065 | delete(ev); | 3069 | delete(ev); |
3066 | } | 3070 | } |
3067 | } | 3071 | } |
3068 | } | 3072 | } |
3069 | } | 3073 | } |
3070 | delete publishdlg; | 3074 | delete publishdlg; |
3071 | } | 3075 | } |
3072 | 3076 | ||
3073 | void CalendarView::schedule_request(Incidence *incidence) | 3077 | void CalendarView::schedule_request(Incidence *incidence) |
3074 | { | 3078 | { |
3075 | schedule(Scheduler::Request,incidence); | 3079 | schedule(Scheduler::Request,incidence); |
3076 | } | 3080 | } |
3077 | 3081 | ||
3078 | void CalendarView::schedule_refresh(Incidence *incidence) | 3082 | void CalendarView::schedule_refresh(Incidence *incidence) |
3079 | { | 3083 | { |
3080 | schedule(Scheduler::Refresh,incidence); | 3084 | schedule(Scheduler::Refresh,incidence); |
3081 | } | 3085 | } |
3082 | 3086 | ||
3083 | void CalendarView::schedule_cancel(Incidence *incidence) | 3087 | void CalendarView::schedule_cancel(Incidence *incidence) |
3084 | { | 3088 | { |
3085 | schedule(Scheduler::Cancel,incidence); | 3089 | schedule(Scheduler::Cancel,incidence); |
3086 | } | 3090 | } |
3087 | 3091 | ||
3088 | void CalendarView::schedule_add(Incidence *incidence) | 3092 | void CalendarView::schedule_add(Incidence *incidence) |
3089 | { | 3093 | { |
3090 | schedule(Scheduler::Add,incidence); | 3094 | schedule(Scheduler::Add,incidence); |
3091 | } | 3095 | } |
3092 | 3096 | ||
3093 | void CalendarView::schedule_reply(Incidence *incidence) | 3097 | void CalendarView::schedule_reply(Incidence *incidence) |
3094 | { | 3098 | { |
3095 | schedule(Scheduler::Reply,incidence); | 3099 | schedule(Scheduler::Reply,incidence); |
3096 | } | 3100 | } |
3097 | 3101 | ||
3098 | void CalendarView::schedule_counter(Incidence *incidence) | 3102 | void CalendarView::schedule_counter(Incidence *incidence) |
3099 | { | 3103 | { |
3100 | schedule(Scheduler::Counter,incidence); | 3104 | schedule(Scheduler::Counter,incidence); |
3101 | } | 3105 | } |
3102 | 3106 | ||
3103 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3107 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3104 | { | 3108 | { |
3105 | schedule(Scheduler::Declinecounter,incidence); | 3109 | schedule(Scheduler::Declinecounter,incidence); |
3106 | } | 3110 | } |
3107 | 3111 | ||
3108 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3112 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3109 | { | 3113 | { |
3110 | QDateTime start = QDateTime::currentDateTime(); | 3114 | QDateTime start = QDateTime::currentDateTime(); |
3111 | QDateTime end = start.addDays(daysToPublish); | 3115 | QDateTime end = start.addDays(daysToPublish); |
3112 | 3116 | ||
3113 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3117 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3114 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3118 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3115 | 3119 | ||
3116 | 3120 | ||
3117 | PublishDialog *publishdlg = new PublishDialog(); | 3121 | PublishDialog *publishdlg = new PublishDialog(); |
3118 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3122 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3119 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3123 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3120 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3124 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3121 | delete(freebusy); | 3125 | delete(freebusy); |
3122 | } | 3126 | } |
3123 | } | 3127 | } |
3124 | delete publishdlg; | 3128 | delete publishdlg; |
3125 | } | 3129 | } |
3126 | 3130 | ||
3127 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3131 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3128 | { | 3132 | { |
3129 | Event *event = 0; | 3133 | Event *event = 0; |
3130 | Todo *todo = 0; | 3134 | Todo *todo = 0; |
3131 | 3135 | ||
3132 | if (incidence == 0) { | 3136 | if (incidence == 0) { |
3133 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3137 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3134 | if (incidence == 0) { | 3138 | if (incidence == 0) { |
3135 | incidence = mTodoList->selectedIncidences().first(); | 3139 | incidence = mTodoList->selectedIncidences().first(); |
3136 | } | 3140 | } |
3137 | } | 3141 | } |
3138 | if ( incidence && incidence->type() == "Event" ) { | 3142 | if ( incidence && incidence->type() == "Event" ) { |
3139 | event = static_cast<Event *>(incidence); | 3143 | event = static_cast<Event *>(incidence); |
3140 | } | 3144 | } |
3141 | if ( incidence && incidence->type() == "Todo" ) { | 3145 | if ( incidence && incidence->type() == "Todo" ) { |
3142 | todo = static_cast<Todo *>(incidence); | 3146 | todo = static_cast<Todo *>(incidence); |
3143 | } | 3147 | } |
3144 | 3148 | ||
3145 | if (!event && !todo) { | 3149 | if (!event && !todo) { |
3146 | KMessageBox::sorry(this,i18n("No event selected.")); | 3150 | KMessageBox::sorry(this,i18n("No event selected.")); |
3147 | return; | 3151 | return; |
3148 | } | 3152 | } |
3149 | 3153 | ||
3150 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3154 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3151 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3155 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3152 | return; | 3156 | return; |
3153 | } | 3157 | } |
3154 | 3158 | ||
3155 | Event *ev = 0; | 3159 | Event *ev = 0; |
3156 | if (event) ev = new Event(*event); | 3160 | if (event) ev = new Event(*event); |
3157 | Todo *to = 0; | 3161 | Todo *to = 0; |
3158 | if (todo) to = new Todo(*todo); | 3162 | if (todo) to = new Todo(*todo); |
3159 | 3163 | ||
3160 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3164 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3161 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3165 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3162 | if (!me) { | 3166 | if (!me) { |
3163 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3167 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3164 | return; | 3168 | return; |
3165 | } | 3169 | } |
3166 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3170 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3167 | StatusDialog *statdlg = new StatusDialog(this); | 3171 | StatusDialog *statdlg = new StatusDialog(this); |
3168 | if (!statdlg->exec()==QDialog::Accepted) return; | 3172 | if (!statdlg->exec()==QDialog::Accepted) return; |
3169 | me->setStatus( statdlg->status() ); | 3173 | me->setStatus( statdlg->status() ); |
3170 | delete(statdlg); | 3174 | delete(statdlg); |
3171 | } | 3175 | } |
3172 | Attendee *menew = new Attendee(*me); | 3176 | Attendee *menew = new Attendee(*me); |
3173 | if (ev) { | 3177 | if (ev) { |
3174 | ev->clearAttendees(); | 3178 | ev->clearAttendees(); |
3175 | ev->addAttendee(menew,false); | 3179 | ev->addAttendee(menew,false); |
3176 | } else { | 3180 | } else { |
3177 | if (to) { | 3181 | if (to) { |
3178 | todo->clearAttendees(); | 3182 | todo->clearAttendees(); |
3179 | todo->addAttendee(menew,false); | 3183 | todo->addAttendee(menew,false); |
3180 | } | 3184 | } |
3181 | } | 3185 | } |
3182 | } | 3186 | } |
3183 | 3187 | ||
3184 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3188 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3185 | if (ev) { | 3189 | if (ev) { |
3186 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3190 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3187 | } else { | 3191 | } else { |
3188 | if (to) { | 3192 | if (to) { |
3189 | if ( !dlg->addMessage(to,method) ) delete(to); | 3193 | if ( !dlg->addMessage(to,method) ) delete(to); |
3190 | } | 3194 | } |
3191 | } | 3195 | } |
3192 | } | 3196 | } |
3193 | 3197 | ||
3194 | void CalendarView::openAddressbook() | 3198 | void CalendarView::openAddressbook() |
3195 | { | 3199 | { |
3196 | KRun::runCommand("kaddressbook"); | 3200 | KRun::runCommand("kaddressbook"); |
3197 | } | 3201 | } |
3198 | 3202 | ||
3199 | void CalendarView::setModified(bool modified) | 3203 | void CalendarView::setModified(bool modified) |
3200 | { | 3204 | { |
3201 | if ( modified ) | 3205 | if ( modified ) |
3202 | emit signalmodified(); | 3206 | emit signalmodified(); |
3203 | if (mModified != modified) { | 3207 | if (mModified != modified) { |
3204 | mModified = modified; | 3208 | mModified = modified; |
3205 | emit modifiedChanged(mModified); | 3209 | emit modifiedChanged(mModified); |
3206 | } | 3210 | } |
3207 | } | 3211 | } |
3208 | 3212 | ||
3209 | bool CalendarView::isReadOnly() | 3213 | bool CalendarView::isReadOnly() |
3210 | { | 3214 | { |
3211 | return mReadOnly; | 3215 | return mReadOnly; |
3212 | } | 3216 | } |
3213 | 3217 | ||
3214 | void CalendarView::setReadOnly(bool readOnly) | 3218 | void CalendarView::setReadOnly(bool readOnly) |
3215 | { | 3219 | { |
3216 | if (mReadOnly != readOnly) { | 3220 | if (mReadOnly != readOnly) { |
3217 | mReadOnly = readOnly; | 3221 | mReadOnly = readOnly; |
3218 | emit readOnlyChanged(mReadOnly); | 3222 | emit readOnlyChanged(mReadOnly); |
3219 | } | 3223 | } |
3220 | } | 3224 | } |
3221 | 3225 | ||
3222 | bool CalendarView::isModified() | 3226 | bool CalendarView::isModified() |
3223 | { | 3227 | { |
3224 | return mModified; | 3228 | return mModified; |
3225 | } | 3229 | } |
3226 | 3230 | ||
3227 | void CalendarView::printSetup() | 3231 | void CalendarView::printSetup() |
3228 | { | 3232 | { |
3229 | #ifndef KORG_NOPRINTER | 3233 | #ifndef KORG_NOPRINTER |
3230 | createPrinter(); | 3234 | createPrinter(); |
3231 | 3235 | ||
3232 | mCalPrinter->setupPrinter(); | 3236 | mCalPrinter->setupPrinter(); |
3233 | #endif | 3237 | #endif |
3234 | } | 3238 | } |
3235 | 3239 | ||
3236 | void CalendarView::print() | 3240 | void CalendarView::print() |
3237 | { | 3241 | { |
3238 | #ifndef KORG_NOPRINTER | 3242 | #ifndef KORG_NOPRINTER |
3239 | createPrinter(); | 3243 | createPrinter(); |
3240 | 3244 | ||
3241 | DateList tmpDateList = mNavigator->selectedDates(); | 3245 | DateList tmpDateList = mNavigator->selectedDates(); |
3242 | mCalPrinter->print(CalPrinter::Month, | 3246 | mCalPrinter->print(CalPrinter::Month, |
3243 | tmpDateList.first(), tmpDateList.last()); | 3247 | tmpDateList.first(), tmpDateList.last()); |
3244 | #endif | 3248 | #endif |
3245 | } | 3249 | } |
3246 | 3250 | ||
3247 | void CalendarView::printPreview() | 3251 | void CalendarView::printPreview() |
3248 | { | 3252 | { |
3249 | #ifndef KORG_NOPRINTER | 3253 | #ifndef KORG_NOPRINTER |
3250 | kdDebug() << "CalendarView::printPreview()" << endl; | 3254 | kdDebug() << "CalendarView::printPreview()" << endl; |
3251 | 3255 | ||
3252 | createPrinter(); | 3256 | createPrinter(); |
3253 | 3257 | ||
3254 | DateList tmpDateList = mNavigator->selectedDates(); | 3258 | DateList tmpDateList = mNavigator->selectedDates(); |
3255 | 3259 | ||
3256 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3260 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3257 | tmpDateList.last()); | 3261 | tmpDateList.last()); |
3258 | #endif | 3262 | #endif |
3259 | } | 3263 | } |
3260 | 3264 | ||
3261 | void CalendarView::exportICalendar() | 3265 | void CalendarView::exportICalendar() |
3262 | { | 3266 | { |
3263 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3267 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3264 | 3268 | ||
3265 | // Force correct extension | 3269 | // Force correct extension |
3266 | if (filename.right(4) != ".ics") filename += ".ics"; | 3270 | if (filename.right(4) != ".ics") filename += ".ics"; |
3267 | 3271 | ||
3268 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3272 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3269 | storage.save(); | 3273 | storage.save(); |
3270 | } | 3274 | } |
3271 | 3275 | ||
3272 | bool CalendarView::exportVCalendar( QString filename ) | 3276 | bool CalendarView::exportVCalendar( QString filename ) |
3273 | { | 3277 | { |
3274 | if (mCalendar->journals().count() > 0) { | 3278 | if (mCalendar->journals().count() > 0) { |
3275 | int result = KMessageBox::warningContinueCancel(this, | 3279 | int result = KMessageBox::warningContinueCancel(this, |
3276 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3280 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3277 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3281 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3278 | true); | 3282 | true); |
3279 | if (result != KMessageBox::Continue) return false; | 3283 | if (result != KMessageBox::Continue) return false; |
3280 | } | 3284 | } |
3281 | 3285 | ||
3282 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3286 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3283 | 3287 | ||
3284 | // Force correct extension | 3288 | // Force correct extension |
3285 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3289 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3286 | 3290 | ||
3287 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3291 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3288 | return storage.save(); | 3292 | return storage.save(); |
3289 | 3293 | ||
3290 | } | 3294 | } |
3291 | 3295 | ||
3292 | void CalendarView::eventUpdated(Incidence *) | 3296 | void CalendarView::eventUpdated(Incidence *) |
3293 | { | 3297 | { |
3294 | setModified(); | 3298 | setModified(); |
3295 | // Don't call updateView here. The code, which has caused the update of the | 3299 | // Don't call updateView here. The code, which has caused the update of the |
3296 | // event is responsible for updating the view. | 3300 | // event is responsible for updating the view. |
3297 | // updateView(); | 3301 | // updateView(); |
3298 | } | 3302 | } |
3299 | 3303 | ||
3300 | void CalendarView::adaptNavigationUnits() | 3304 | void CalendarView::adaptNavigationUnits() |
3301 | { | 3305 | { |
3302 | if (mViewManager->currentView()->isEventView()) { | 3306 | if (mViewManager->currentView()->isEventView()) { |
3303 | int days = mViewManager->currentView()->currentDateCount(); | 3307 | int days = mViewManager->currentView()->currentDateCount(); |
3304 | if (days == 1) { | 3308 | if (days == 1) { |
3305 | emit changeNavStringPrev(i18n("&Previous Day")); | 3309 | emit changeNavStringPrev(i18n("&Previous Day")); |
3306 | emit changeNavStringNext(i18n("&Next Day")); | 3310 | emit changeNavStringNext(i18n("&Next Day")); |
3307 | } else { | 3311 | } else { |
3308 | emit changeNavStringPrev(i18n("&Previous Week")); | 3312 | emit changeNavStringPrev(i18n("&Previous Week")); |
3309 | emit changeNavStringNext(i18n("&Next Week")); | 3313 | emit changeNavStringNext(i18n("&Next Week")); |
3310 | } | 3314 | } |
3311 | } | 3315 | } |
3312 | } | 3316 | } |
3313 | 3317 | ||
3314 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3318 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3315 | { | 3319 | { |
3316 | if ( incidence ) mTodoList->clearSelection(); | 3320 | if ( incidence ) mTodoList->clearSelection(); |
3317 | processIncidenceSelection( incidence ); | 3321 | processIncidenceSelection( incidence ); |
3318 | } | 3322 | } |
3319 | 3323 | ||
3320 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3324 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3321 | { | 3325 | { |
3322 | if ( incidence && mViewManager->currentView() ) { | 3326 | if ( incidence && mViewManager->currentView() ) { |
3323 | mViewManager->currentView()->clearSelection(); | 3327 | mViewManager->currentView()->clearSelection(); |
3324 | } | 3328 | } |
3325 | processIncidenceSelection( incidence ); | 3329 | processIncidenceSelection( incidence ); |
3326 | } | 3330 | } |
3327 | 3331 | ||
3328 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3332 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3329 | { | 3333 | { |
3330 | if ( incidence == mSelectedIncidence ) return; | 3334 | if ( incidence == mSelectedIncidence ) return; |
3331 | 3335 | ||
3332 | mSelectedIncidence = incidence; | 3336 | mSelectedIncidence = incidence; |
3333 | 3337 | ||
3334 | emit incidenceSelected( mSelectedIncidence ); | 3338 | emit incidenceSelected( mSelectedIncidence ); |
3335 | 3339 | ||
3336 | if ( incidence && incidence->type() == "Event" ) { | 3340 | if ( incidence && incidence->type() == "Event" ) { |
3337 | Event *event = static_cast<Event *>( incidence ); | 3341 | Event *event = static_cast<Event *>( incidence ); |
3338 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3342 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3339 | emit organizerEventsSelected( true ); | 3343 | emit organizerEventsSelected( true ); |
3340 | } else { | 3344 | } else { |
3341 | emit organizerEventsSelected(false); | 3345 | emit organizerEventsSelected(false); |
3342 | } | 3346 | } |
3343 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3347 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3344 | KOPrefs::instance()->email() ) ) { | 3348 | KOPrefs::instance()->email() ) ) { |
3345 | emit groupEventsSelected( true ); | 3349 | emit groupEventsSelected( true ); |
3346 | } else { | 3350 | } else { |
3347 | emit groupEventsSelected(false); | 3351 | emit groupEventsSelected(false); |
3348 | } | 3352 | } |
3349 | return; | 3353 | return; |
3350 | } else { | 3354 | } else { |
3351 | if ( incidence && incidence->type() == "Todo" ) { | 3355 | if ( incidence && incidence->type() == "Todo" ) { |
3352 | emit todoSelected( true ); | 3356 | emit todoSelected( true ); |
3353 | Todo *event = static_cast<Todo *>( incidence ); | 3357 | Todo *event = static_cast<Todo *>( incidence ); |
3354 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3358 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3355 | emit organizerEventsSelected( true ); | 3359 | emit organizerEventsSelected( true ); |
3356 | } else { | 3360 | } else { |
3357 | emit organizerEventsSelected(false); | 3361 | emit organizerEventsSelected(false); |
3358 | } | 3362 | } |
3359 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3363 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3360 | KOPrefs::instance()->email() ) ) { | 3364 | KOPrefs::instance()->email() ) ) { |
3361 | emit groupEventsSelected( true ); | 3365 | emit groupEventsSelected( true ); |
3362 | } else { | 3366 | } else { |
3363 | emit groupEventsSelected(false); | 3367 | emit groupEventsSelected(false); |
3364 | } | 3368 | } |
3365 | return; | 3369 | return; |
3366 | } else { | 3370 | } else { |
3367 | emit todoSelected( false ); | 3371 | emit todoSelected( false ); |
3368 | emit organizerEventsSelected(false); | 3372 | emit organizerEventsSelected(false); |
3369 | emit groupEventsSelected(false); | 3373 | emit groupEventsSelected(false); |
3370 | } | 3374 | } |
3371 | return; | 3375 | return; |
3372 | } | 3376 | } |
3373 | 3377 | ||
3374 | /* if ( incidence && incidence->type() == "Todo" ) { | 3378 | /* if ( incidence && incidence->type() == "Todo" ) { |
3375 | emit todoSelected( true ); | 3379 | emit todoSelected( true ); |
3376 | } else { | 3380 | } else { |
3377 | emit todoSelected( false ); | 3381 | emit todoSelected( false ); |
3378 | }*/ | 3382 | }*/ |
3379 | } | 3383 | } |
3380 | 3384 | ||
3381 | 3385 | ||
3382 | void CalendarView::checkClipboard() | 3386 | void CalendarView::checkClipboard() |
3383 | { | 3387 | { |
3384 | #ifndef KORG_NODND | 3388 | #ifndef KORG_NODND |
3385 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3389 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3386 | emit pasteEnabled(true); | 3390 | emit pasteEnabled(true); |
3387 | } else { | 3391 | } else { |
3388 | emit pasteEnabled(false); | 3392 | emit pasteEnabled(false); |
3389 | } | 3393 | } |
3390 | #endif | 3394 | #endif |
3391 | } | 3395 | } |
3392 | 3396 | ||
3393 | void CalendarView::showDates(const DateList &selectedDates) | 3397 | void CalendarView::showDates(const DateList &selectedDates) |
3394 | { | 3398 | { |
3395 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3399 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3396 | 3400 | ||
3397 | if ( mViewManager->currentView() ) { | 3401 | if ( mViewManager->currentView() ) { |
3398 | updateView( selectedDates.first(), selectedDates.last() ); | 3402 | updateView( selectedDates.first(), selectedDates.last() ); |
3399 | } else { | 3403 | } else { |
3400 | mViewManager->showAgendaView(); | 3404 | mViewManager->showAgendaView(); |
3401 | } | 3405 | } |
3402 | 3406 | ||
3403 | QString selDates; | 3407 | QString selDates; |
3404 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3408 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3405 | if (selectedDates.first() < selectedDates.last() ) | 3409 | if (selectedDates.first() < selectedDates.last() ) |
3406 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3410 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3407 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3411 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3408 | 3412 | ||
3409 | } | 3413 | } |
3410 | 3414 | ||
3411 | QPtrList<CalFilter> CalendarView::filters() | 3415 | QPtrList<CalFilter> CalendarView::filters() |
3412 | { | 3416 | { |
3413 | return mFilters; | 3417 | return mFilters; |
3414 | 3418 | ||
3415 | } | 3419 | } |
3416 | void CalendarView::editFilters() | 3420 | void CalendarView::editFilters() |
3417 | { | 3421 | { |
3418 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3422 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3419 | 3423 | ||
3420 | CalFilter *filter = mFilters.first(); | 3424 | CalFilter *filter = mFilters.first(); |
3421 | while(filter) { | 3425 | while(filter) { |
3422 | kdDebug() << " Filter: " << filter->name() << endl; | 3426 | kdDebug() << " Filter: " << filter->name() << endl; |
3423 | filter = mFilters.next(); | 3427 | filter = mFilters.next(); |
3424 | } | 3428 | } |
3425 | 3429 | ||
3426 | mDialogManager->showFilterEditDialog(&mFilters); | 3430 | mDialogManager->showFilterEditDialog(&mFilters); |
3427 | } | 3431 | } |
3428 | void CalendarView::toggleFilter() | 3432 | void CalendarView::toggleFilter() |
3429 | { | 3433 | { |
3430 | showFilter(! mFilterView->isVisible()); | 3434 | showFilter(! mFilterView->isVisible()); |
3431 | } | 3435 | } |
3432 | 3436 | ||
3433 | KOFilterView *CalendarView::filterView() | 3437 | KOFilterView *CalendarView::filterView() |
3434 | { | 3438 | { |
3435 | return mFilterView; | 3439 | return mFilterView; |
3436 | } | 3440 | } |
3437 | void CalendarView::selectFilter( int fil ) | 3441 | void CalendarView::selectFilter( int fil ) |
3438 | { | 3442 | { |
3439 | mFilterView->setSelectedFilter( fil ); | 3443 | mFilterView->setSelectedFilter( fil ); |
3440 | } | 3444 | } |
3441 | void CalendarView::showFilter(bool visible) | 3445 | void CalendarView::showFilter(bool visible) |
3442 | { | 3446 | { |
3443 | if (visible) mFilterView->show(); | 3447 | if (visible) mFilterView->show(); |
3444 | else mFilterView->hide(); | 3448 | else mFilterView->hide(); |
3445 | } | 3449 | } |
3446 | void CalendarView::toggleFilerEnabled( ) | 3450 | void CalendarView::toggleFilerEnabled( ) |
3447 | { | 3451 | { |
3448 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3452 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3449 | if ( !mFilterView->filtersEnabled() ) | 3453 | if ( !mFilterView->filtersEnabled() ) |
3450 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3454 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3451 | 3455 | ||
3452 | } | 3456 | } |
3453 | void CalendarView::updateFilter() | 3457 | void CalendarView::updateFilter() |
3454 | { | 3458 | { |
3455 | CalFilter *filter = mFilterView->selectedFilter(); | 3459 | CalFilter *filter = mFilterView->selectedFilter(); |
3456 | if (filter) { | 3460 | if (filter) { |
3457 | if (mFilterView->filtersEnabled()) { | 3461 | if (mFilterView->filtersEnabled()) { |
3458 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3462 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3459 | filter->setEnabled(true); | 3463 | filter->setEnabled(true); |
3460 | } | 3464 | } |
3461 | else filter->setEnabled(false); | 3465 | else filter->setEnabled(false); |
3462 | mCalendar->setFilter(filter); | 3466 | mCalendar->setFilter(filter); |
3463 | updateView(); | 3467 | updateView(); |
3464 | } | 3468 | } |
3465 | } | 3469 | } |
3466 | 3470 | ||
3467 | void CalendarView::filterEdited() | 3471 | void CalendarView::filterEdited() |
3468 | { | 3472 | { |
3469 | mFilterView->updateFilters(); | 3473 | mFilterView->updateFilters(); |
3470 | updateFilter(); | 3474 | updateFilter(); |
3471 | writeSettings(); | 3475 | writeSettings(); |
3472 | } | 3476 | } |
3473 | 3477 | ||
3474 | 3478 | ||
3475 | void CalendarView::takeOverEvent() | 3479 | void CalendarView::takeOverEvent() |
3476 | { | 3480 | { |
3477 | Incidence *incidence = currentSelection(); | 3481 | Incidence *incidence = currentSelection(); |
3478 | 3482 | ||
3479 | if (!incidence) return; | 3483 | if (!incidence) return; |
3480 | 3484 | ||
3481 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3485 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3482 | incidence->recreate(); | 3486 | incidence->recreate(); |
3483 | incidence->setReadOnly(false); | 3487 | incidence->setReadOnly(false); |
3484 | 3488 | ||
3485 | updateView(); | 3489 | updateView(); |
3486 | } | 3490 | } |
3487 | 3491 | ||
3488 | void CalendarView::takeOverCalendar() | 3492 | void CalendarView::takeOverCalendar() |
3489 | { | 3493 | { |
3490 | // TODO: Create Calendar::allIncidences() function and use it here | 3494 | // TODO: Create Calendar::allIncidences() function and use it here |
3491 | 3495 | ||
3492 | QPtrList<Event> events = mCalendar->events(); | 3496 | QPtrList<Event> events = mCalendar->events(); |
3493 | for(uint i=0; i<events.count(); ++i) { | 3497 | for(uint i=0; i<events.count(); ++i) { |
3494 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3498 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3495 | events.at(i)->recreate(); | 3499 | events.at(i)->recreate(); |
3496 | events.at(i)->setReadOnly(false); | 3500 | events.at(i)->setReadOnly(false); |
3497 | } | 3501 | } |
3498 | 3502 | ||
3499 | QPtrList<Todo> todos = mCalendar->todos(); | 3503 | QPtrList<Todo> todos = mCalendar->todos(); |
3500 | for(uint i=0; i<todos.count(); ++i) { | 3504 | for(uint i=0; i<todos.count(); ++i) { |
3501 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3505 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3502 | todos.at(i)->recreate(); | 3506 | todos.at(i)->recreate(); |
3503 | todos.at(i)->setReadOnly(false); | 3507 | todos.at(i)->setReadOnly(false); |
3504 | } | 3508 | } |
3505 | 3509 | ||
3506 | QPtrList<Journal> journals = mCalendar->journals(); | 3510 | QPtrList<Journal> journals = mCalendar->journals(); |
3507 | for(uint i=0; i<journals.count(); ++i) { | 3511 | for(uint i=0; i<journals.count(); ++i) { |
3508 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3512 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3509 | journals.at(i)->recreate(); | 3513 | journals.at(i)->recreate(); |
3510 | journals.at(i)->setReadOnly(false); | 3514 | journals.at(i)->setReadOnly(false); |
3511 | } | 3515 | } |
3512 | 3516 | ||
3513 | updateView(); | 3517 | updateView(); |
3514 | } | 3518 | } |
3515 | 3519 | ||
3516 | void CalendarView::showIntro() | 3520 | void CalendarView::showIntro() |
3517 | { | 3521 | { |
3518 | kdDebug() << "To be implemented." << endl; | 3522 | kdDebug() << "To be implemented." << endl; |
3519 | } | 3523 | } |
3520 | 3524 | ||
3521 | QWidgetStack *CalendarView::viewStack() | 3525 | QWidgetStack *CalendarView::viewStack() |
3522 | { | 3526 | { |
3523 | return mRightFrame; | 3527 | return mRightFrame; |
3524 | } | 3528 | } |
3525 | 3529 | ||
3526 | QWidget *CalendarView::leftFrame() | 3530 | QWidget *CalendarView::leftFrame() |
3527 | { | 3531 | { |
3528 | return mLeftFrame; | 3532 | return mLeftFrame; |
3529 | } | 3533 | } |
3530 | 3534 | ||
3531 | DateNavigator *CalendarView::dateNavigator() | 3535 | DateNavigator *CalendarView::dateNavigator() |
3532 | { | 3536 | { |
3533 | return mNavigator; | 3537 | return mNavigator; |
3534 | } | 3538 | } |
3535 | 3539 | ||
3536 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3540 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3537 | { | 3541 | { |
3538 | return mDateNavigator; | 3542 | return mDateNavigator; |
3539 | } | 3543 | } |
3540 | void CalendarView::toggleDateNavigatorWidget() | 3544 | void CalendarView::toggleDateNavigatorWidget() |
3541 | { | 3545 | { |
3542 | if (mDateNavigator->isVisible()) | 3546 | if (mDateNavigator->isVisible()) |
3543 | mDateNavigator->hide(); | 3547 | mDateNavigator->hide(); |
3544 | else | 3548 | else |
3545 | mDateNavigator->show(); | 3549 | mDateNavigator->show(); |
3546 | } | 3550 | } |
3547 | void CalendarView::addView(KOrg::BaseView *view) | 3551 | void CalendarView::addView(KOrg::BaseView *view) |
3548 | { | 3552 | { |
3549 | mViewManager->addView(view); | 3553 | mViewManager->addView(view); |
3550 | } | 3554 | } |
3551 | 3555 | ||
3552 | void CalendarView::showView(KOrg::BaseView *view) | 3556 | void CalendarView::showView(KOrg::BaseView *view) |
3553 | { | 3557 | { |
3554 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3558 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3555 | } | 3559 | } |
3556 | 3560 | ||
3557 | Incidence *CalendarView::currentSelection() | 3561 | Incidence *CalendarView::currentSelection() |
3558 | { | 3562 | { |
3559 | return mViewManager->currentSelection(); | 3563 | return mViewManager->currentSelection(); |
3560 | } | 3564 | } |
3561 | void CalendarView::toggleAllDaySize() | 3565 | void CalendarView::toggleAllDaySize() |
3562 | { | 3566 | { |
3563 | /* | 3567 | /* |
3564 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3568 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3565 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3569 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3566 | else | 3570 | else |
3567 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3571 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3568 | */ | 3572 | */ |
3569 | viewManager()->agendaView()->toggleAllDay(); | 3573 | viewManager()->agendaView()->toggleAllDay(); |
3570 | } | 3574 | } |
3571 | void CalendarView::toggleExpand() | 3575 | void CalendarView::toggleExpand() |
3572 | { | 3576 | { |
3573 | // if ( mLeftFrame->isHidden() ) { | 3577 | // if ( mLeftFrame->isHidden() ) { |
3574 | // mLeftFrame->show(); | 3578 | // mLeftFrame->show(); |
3575 | // emit calendarViewExpanded( false ); | 3579 | // emit calendarViewExpanded( false ); |
3576 | // } else { | 3580 | // } else { |
3577 | // mLeftFrame->hide(); | 3581 | // mLeftFrame->hide(); |
3578 | // emit calendarViewExpanded( true ); | 3582 | // emit calendarViewExpanded( true ); |
3579 | // } | 3583 | // } |
3580 | 3584 | ||
3581 | globalFlagBlockAgenda = 1; | 3585 | globalFlagBlockAgenda = 1; |
3582 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3586 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3583 | globalFlagBlockAgenda = 5; | 3587 | globalFlagBlockAgenda = 5; |
3584 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3588 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3585 | //mViewManager->showView( 0, true ); | 3589 | //mViewManager->showView( 0, true ); |
3586 | } | 3590 | } |
3587 | 3591 | ||
3588 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3592 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3589 | { | 3593 | { |
3590 | setModified( modified ); | 3594 | setModified( modified ); |
3591 | } | 3595 | } |
3592 | 3596 | ||
3593 | Todo *CalendarView::selectedTodo() | 3597 | Todo *CalendarView::selectedTodo() |
3594 | { | 3598 | { |
3595 | Incidence *incidence = currentSelection(); | 3599 | Incidence *incidence = currentSelection(); |
3596 | if ( incidence && incidence->type() == "Todo" ) { | 3600 | if ( incidence && incidence->type() == "Todo" ) { |
3597 | return static_cast<Todo *>( incidence ); | 3601 | return static_cast<Todo *>( incidence ); |
3598 | } | 3602 | } |
3599 | 3603 | ||
3600 | incidence = mTodoList->selectedIncidences().first(); | 3604 | incidence = mTodoList->selectedIncidences().first(); |
3601 | if ( incidence && incidence->type() == "Todo" ) { | 3605 | if ( incidence && incidence->type() == "Todo" ) { |
3602 | return static_cast<Todo *>( incidence ); | 3606 | return static_cast<Todo *>( incidence ); |
3603 | } | 3607 | } |
3604 | 3608 | ||
3605 | return 0; | 3609 | return 0; |
3606 | } | 3610 | } |
3607 | 3611 | ||
3608 | void CalendarView::dialogClosing(Incidence *in) | 3612 | void CalendarView::dialogClosing(Incidence *in) |
3609 | { | 3613 | { |
3610 | // mDialogList.remove(in); | 3614 | // mDialogList.remove(in); |
3611 | } | 3615 | } |
3612 | 3616 | ||
3613 | void CalendarView::showIncidence() | 3617 | void CalendarView::showIncidence() |
3614 | { | 3618 | { |
3615 | Incidence *incidence = currentSelection(); | 3619 | Incidence *incidence = currentSelection(); |
3616 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3620 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3617 | if ( incidence ) { | 3621 | if ( incidence ) { |
3618 | ShowIncidenceVisitor v; | 3622 | ShowIncidenceVisitor v; |
3619 | v.act( incidence, this ); | 3623 | v.act( incidence, this ); |
3620 | } | 3624 | } |
3621 | } | 3625 | } |
3622 | void CalendarView::editIncidenceDescription() | 3626 | void CalendarView::editIncidenceDescription() |
3623 | { | 3627 | { |
3624 | mFlagEditDescription = true; | 3628 | mFlagEditDescription = true; |
3625 | editIncidence(); | 3629 | editIncidence(); |
3626 | mFlagEditDescription = false; | 3630 | mFlagEditDescription = false; |
3627 | } | 3631 | } |
3628 | void CalendarView::editIncidence() | 3632 | void CalendarView::editIncidence() |
3629 | { | 3633 | { |
3630 | // qDebug("editIncidence() "); | 3634 | // qDebug("editIncidence() "); |
3631 | Incidence *incidence = currentSelection(); | 3635 | Incidence *incidence = currentSelection(); |
3632 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3636 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3633 | if ( incidence ) { | 3637 | if ( incidence ) { |
3634 | EditIncidenceVisitor v; | 3638 | EditIncidenceVisitor v; |
3635 | v.act( incidence, this ); | 3639 | v.act( incidence, this ); |
3636 | } | 3640 | } |
3637 | } | 3641 | } |
3638 | 3642 | ||
3639 | void CalendarView::deleteIncidence() | 3643 | void CalendarView::deleteIncidence() |
3640 | { | 3644 | { |
3641 | Incidence *incidence = currentSelection(); | 3645 | Incidence *incidence = currentSelection(); |
3642 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3646 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3643 | if ( incidence ) { | 3647 | if ( incidence ) { |
3644 | deleteIncidence(incidence); | 3648 | deleteIncidence(incidence); |
3645 | } | 3649 | } |
3646 | } | 3650 | } |
3647 | 3651 | ||
3648 | void CalendarView::showIncidence(Incidence *incidence) | 3652 | void CalendarView::showIncidence(Incidence *incidence) |
3649 | { | 3653 | { |
3650 | if ( incidence ) { | 3654 | if ( incidence ) { |
3651 | ShowIncidenceVisitor v; | 3655 | ShowIncidenceVisitor v; |
3652 | v.act( incidence, this ); | 3656 | v.act( incidence, this ); |
3653 | } | 3657 | } |
3654 | } | 3658 | } |
3655 | 3659 | ||
3656 | void CalendarView::editIncidence(Incidence *incidence) | 3660 | void CalendarView::editIncidence(Incidence *incidence) |
3657 | { | 3661 | { |
3658 | if ( incidence ) { | 3662 | if ( incidence ) { |
3659 | 3663 | ||
3660 | EditIncidenceVisitor v; | 3664 | EditIncidenceVisitor v; |
3661 | v.act( incidence, this ); | 3665 | v.act( incidence, this ); |
3662 | 3666 | ||
3663 | } | 3667 | } |
3664 | } | 3668 | } |
3665 | 3669 | ||
3666 | void CalendarView::deleteIncidence(Incidence *incidence) | 3670 | void CalendarView::deleteIncidence(Incidence *incidence) |
3667 | { | 3671 | { |
3668 | //qDebug(" CalendarView::deleteIncidence "); | 3672 | //qDebug(" CalendarView::deleteIncidence "); |
3669 | if ( incidence ) { | 3673 | if ( incidence ) { |
3670 | DeleteIncidenceVisitor v; | 3674 | DeleteIncidenceVisitor v; |
3671 | v.act( incidence, this ); | 3675 | v.act( incidence, this ); |
3672 | } | 3676 | } |
3673 | } | 3677 | } |
3674 | 3678 | ||
3675 | 3679 | ||
3676 | void CalendarView::lookForOutgoingMessages() | 3680 | void CalendarView::lookForOutgoingMessages() |
3677 | { | 3681 | { |
3678 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3682 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3679 | ogd->loadMessages(); | 3683 | ogd->loadMessages(); |
3680 | } | 3684 | } |
3681 | 3685 | ||
3682 | void CalendarView::lookForIncomingMessages() | 3686 | void CalendarView::lookForIncomingMessages() |
3683 | { | 3687 | { |
3684 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3688 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3685 | icd->retrieve(); | 3689 | icd->retrieve(); |
3686 | } | 3690 | } |
3687 | 3691 | ||
3688 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3692 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3689 | { | 3693 | { |
3690 | bool deleteTodo = true; | 3694 | bool deleteTodo = true; |
3691 | QPtrList<Incidence> subTodos; | 3695 | QPtrList<Incidence> subTodos; |
3692 | Incidence *aTodo; | 3696 | Incidence *aTodo; |
3693 | subTodos = t->relations(); | 3697 | subTodos = t->relations(); |
3694 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3698 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3695 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3699 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3696 | deleteTodo = false; | 3700 | deleteTodo = false; |
3697 | } | 3701 | } |
3698 | if ( deleteTodo ) { | 3702 | if ( deleteTodo ) { |
3699 | if ( t->isCompleted() ) { | 3703 | if ( t->isCompleted() ) { |
3700 | checkExternalId( t ); | 3704 | checkExternalId( t ); |
3701 | mCalendar->deleteTodo( t ); | 3705 | mCalendar->deleteTodo( t ); |
3702 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3706 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3703 | } | 3707 | } |
3704 | else | 3708 | else |
3705 | deleteTodo = false; | 3709 | deleteTodo = false; |
3706 | } | 3710 | } |
3707 | return deleteTodo; | 3711 | return deleteTodo; |
3708 | 3712 | ||
3709 | } | 3713 | } |
3710 | void CalendarView::purgeCompleted() | 3714 | void CalendarView::purgeCompleted() |
3711 | { | 3715 | { |
3712 | int result = KMessageBox::warningContinueCancel(this, | 3716 | int result = KMessageBox::warningContinueCancel(this, |
3713 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3717 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3714 | 3718 | ||
3715 | if (result == KMessageBox::Continue) { | 3719 | if (result == KMessageBox::Continue) { |
3716 | 3720 | ||
3717 | QPtrList<Todo> todoCal; | 3721 | QPtrList<Todo> todoCal; |
3718 | QPtrList<Todo> rootTodos; | 3722 | QPtrList<Todo> rootTodos; |
3719 | //QPtrList<Incidence> rel; | 3723 | //QPtrList<Incidence> rel; |
3720 | Todo *aTodo;//, *rTodo; | 3724 | Todo *aTodo;//, *rTodo; |
3721 | Incidence *rIncidence; | 3725 | Incidence *rIncidence; |
3722 | bool childDelete = false; | 3726 | bool childDelete = false; |
3723 | bool deletedOne = true; | 3727 | bool deletedOne = true; |
3724 | todoCal = calendar()->todos(); | 3728 | todoCal = calendar()->todos(); |
3725 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3729 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3726 | if ( !aTodo->relatedTo() ) | 3730 | if ( !aTodo->relatedTo() ) |
3727 | rootTodos.append( aTodo ); | 3731 | rootTodos.append( aTodo ); |
3728 | } | 3732 | } |
3729 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3733 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3730 | removeCompletedSubTodos( aTodo ); | 3734 | removeCompletedSubTodos( aTodo ); |
3731 | } | 3735 | } |
3732 | 3736 | ||
3733 | updateView(); | 3737 | updateView(); |
3734 | } | 3738 | } |
3735 | } | 3739 | } |
3736 | 3740 | ||
3737 | void CalendarView::slotCalendarChanged() | 3741 | void CalendarView::slotCalendarChanged() |
3738 | { | 3742 | { |
3739 | ; | 3743 | ; |
3740 | } | 3744 | } |
3741 | 3745 | ||
3742 | NavigatorBar *CalendarView::navigatorBar() | 3746 | NavigatorBar *CalendarView::navigatorBar() |
3743 | { | 3747 | { |
3744 | return mNavigatorBar; | 3748 | return mNavigatorBar; |
3745 | } | 3749 | } |
3746 | 3750 | ||
3747 | 3751 | ||
3748 | 3752 | ||
3749 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3753 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3750 | { | 3754 | { |
3751 | //qDebug(" alendarView::keyPressEvent "); | 3755 | //qDebug(" alendarView::keyPressEvent "); |
3752 | e->ignore(); | 3756 | e->ignore(); |
3753 | } | 3757 | } |
3754 | 3758 | ||
3755 | 3759 | ||
3756 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3760 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3757 | { | 3761 | { |
3758 | // mSyncManager = manager; | 3762 | // mSyncManager = manager; |
3759 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3763 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3760 | qDebug("SyncKDE request detected!"); | 3764 | qDebug("SyncKDE request detected!"); |
3761 | } | 3765 | } |
3762 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3766 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3763 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3767 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3764 | return syncCalendar( filename, mode ); | 3768 | return syncCalendar( filename, mode ); |
3765 | } | 3769 | } |
3766 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3770 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3767 | { | 3771 | { |
3768 | //mSyncManager = manager; | 3772 | //mSyncManager = manager; |
3769 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3773 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3770 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3774 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3771 | if ( resource == "sharp" ) | 3775 | if ( resource == "sharp" ) |
3772 | syncExternal( 0 ); | 3776 | syncExternal( 0 ); |
3773 | if ( resource == "phone" ) | 3777 | if ( resource == "phone" ) |
3774 | syncExternal( 1 ); | 3778 | syncExternal( 1 ); |
3775 | // pending setmodified | 3779 | // pending setmodified |
3776 | return true; | 3780 | return true; |
3777 | } | 3781 | } |
3778 | void CalendarView::setSyncManager(KSyncManager* manager) | 3782 | void CalendarView::setSyncManager(KSyncManager* manager) |
3779 | { | 3783 | { |
3780 | mSyncManager = manager; | 3784 | mSyncManager = manager; |
3781 | } | 3785 | } |
3782 | 3786 | ||
3783 | void CalendarView::removeSyncInfo( QString syncProfile) | 3787 | void CalendarView::removeSyncInfo( QString syncProfile) |
3784 | { | 3788 | { |
3785 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); | 3789 | qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); |
3786 | mCalendar->removeSyncInfo( syncProfile ); | 3790 | mCalendar->removeSyncInfo( syncProfile ); |
3787 | 3791 | ||
3788 | } | 3792 | } |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index a12acd1..9cafc60 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -1,1118 +1,1119 @@ | |||
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 | mName = QString ( name ); |
61 | mCalendar = calendar; | 61 | mCalendar = calendar; |
62 | #ifndef DESKTOP_VERSION | 62 | #ifndef DESKTOP_VERSION |
63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 63 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
64 | #endif | 64 | #endif |
65 | mOldCurrent = 0; | 65 | mOldCurrent = 0; |
66 | mMousePressed = false; | 66 | mMousePressed = false; |
67 | 67 | ||
68 | setAcceptDrops(true); | 68 | setAcceptDrops(true); |
69 | viewport()->setAcceptDrops(true); | 69 | viewport()->setAcceptDrops(true); |
70 | int size = 16; | 70 | int size = 16; |
71 | if (qApp->desktop()->width() < 300 ) | 71 | if (qApp->desktop()->width() < 300 ) |
72 | size = 12; | 72 | size = 12; |
73 | setTreeStepSize( size + 6 ); | 73 | setTreeStepSize( size + 6 ); |
74 | 74 | ||
75 | } | 75 | } |
76 | 76 | ||
77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) | 77 | void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) |
78 | { | 78 | { |
79 | #ifndef KORG_NODND | 79 | #ifndef KORG_NODND |
80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; | 80 | // kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; |
81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 81 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
82 | !QTextDrag::canDecode( e ) ) { | 82 | !QTextDrag::canDecode( e ) ) { |
83 | e->ignore(); | 83 | e->ignore(); |
84 | return; | 84 | return; |
85 | } | 85 | } |
86 | 86 | ||
87 | mOldCurrent = currentItem(); | 87 | mOldCurrent = currentItem(); |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | 91 | ||
92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) | 92 | void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) |
93 | { | 93 | { |
94 | #ifndef KORG_NODND | 94 | #ifndef KORG_NODND |
95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; | 95 | // kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; |
96 | 96 | ||
97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 97 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
98 | !QTextDrag::canDecode( e ) ) { | 98 | !QTextDrag::canDecode( e ) ) { |
99 | e->ignore(); | 99 | e->ignore(); |
100 | return; | 100 | return; |
101 | } | 101 | } |
102 | 102 | ||
103 | e->accept(); | 103 | e->accept(); |
104 | #endif | 104 | #endif |
105 | } | 105 | } |
106 | 106 | ||
107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) | 107 | void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) |
108 | { | 108 | { |
109 | #ifndef KORG_NODND | 109 | #ifndef KORG_NODND |
110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; | 110 | // kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; |
111 | 111 | ||
112 | setCurrentItem(mOldCurrent); | 112 | setCurrentItem(mOldCurrent); |
113 | setSelected(mOldCurrent,true); | 113 | setSelected(mOldCurrent,true); |
114 | #endif | 114 | #endif |
115 | } | 115 | } |
116 | 116 | ||
117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) | 117 | void KOTodoListView::contentsDropEvent(QDropEvent *e) |
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | // kdDebug() << "Drop existing Todo" << endl; | 142 | // kdDebug() << "Drop existing Todo" << endl; |
143 | Incidence *to = destinationEvent; | 143 | Incidence *to = destinationEvent; |
144 | while(to) { | 144 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 145 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 146 | KMessageBox::sorry(this, |
147 | 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"), |
148 | i18n("Drop To-Do")); | 148 | i18n("Drop To-Do")); |
149 | delete todo; | 149 | delete todo; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | to = to->relatedTo(); | 152 | to = to->relatedTo(); |
153 | } | 153 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 154 | existingTodo->setRelatedTo(destinationEvent); |
155 | emit todoDropped(todo); | 155 | emit todoDropped(todo); |
156 | delete todo; | 156 | delete todo; |
157 | } else { | 157 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | 158 | // kdDebug() << "Drop new Todo" << endl; |
159 | todo->setRelatedTo(destinationEvent); | 159 | todo->setRelatedTo(destinationEvent); |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | ||
162 | emit todoDropped(todo); | 162 | emit todoDropped(todo); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else { | 165 | else { |
166 | QString text; | 166 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 167 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 170 | kdDebug() << "Dropped : " << text << endl; |
171 | QStringList emails = QStringList::split(",",text); | 171 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
173 | kdDebug() << " Email: " << (*it) << endl; | 173 | kdDebug() << " Email: " << (*it) << endl; |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | QListView::contentsMousePressEvent(e); | 192 | QListView::contentsMousePressEvent(e); |
193 | #ifndef KORG_NODND | 193 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 194 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 195 | QListViewItem *i = itemAt(p); |
196 | if (i) { | 196 | if (i) { |
197 | // 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 |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 213 | { |
214 | 214 | ||
215 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | 223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; |
224 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
225 | ICalDrag *vd = factory.createDragTodo( | 225 | ICalDrag *vd = factory.createDragTodo( |
226 | ((KOTodoViewItem *)item)->todo(),viewport()); | 226 | ((KOTodoViewItem *)item)->todo(),viewport()); |
227 | if (vd->drag()) { | 227 | if (vd->drag()) { |
228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; |
229 | } | 229 | } |
230 | /* | 230 | /* |
231 | QString source = fullPath(item); | 231 | QString source = fullPath(item); |
232 | if ( QFile::exists(source) ) { | 232 | if ( QFile::exists(source) ) { |
233 | QUriDrag* ud = new QUriDrag(viewport()); | 233 | QUriDrag* ud = new QUriDrag(viewport()); |
234 | ud->setFilenames( source ); | 234 | ud->setFilenames( source ); |
235 | if ( ud->drag() ) | 235 | if ( ud->drag() ) |
236 | QMessageBox::information( this, "Drag source", | 236 | QMessageBox::information( this, "Drag source", |
237 | QString("Delete ")+source, "Not implemented" ); | 237 | QString("Delete ")+source, "Not implemented" ); |
238 | */ | 238 | */ |
239 | } | 239 | } |
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | } | 242 | } |
243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
244 | { | 244 | { |
245 | 245 | ||
246 | QListViewItem* cn; | 246 | QListViewItem* cn; |
247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
248 | cn = currentItem(); | 248 | cn = currentItem(); |
249 | if ( cn ) { | 249 | if ( cn ) { |
250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
251 | if ( ci ){ | 251 | if ( ci ){ |
252 | if ( e->state() == ShiftButton ) | 252 | if ( e->state() == ShiftButton ) |
253 | ci->setOn( false ); | 253 | ci->setOn( false ); |
254 | else | 254 | else |
255 | ci->setOn( true ); | 255 | ci->setOn( true ); |
256 | cn = cn->nextSibling(); | 256 | cn = cn->nextSibling(); |
257 | if ( cn ) { | 257 | if ( cn ) { |
258 | setCurrentItem ( cn ); | 258 | setCurrentItem ( cn ); |
259 | ensureItemVisible ( cn ); | 259 | ensureItemVisible ( cn ); |
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | // qDebug("KOTodoListView::keyPressEvent "); | 268 | // qDebug("KOTodoListView::keyPressEvent "); |
269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
270 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
271 | case Qt::Key_Down: | 271 | case Qt::Key_Down: |
272 | case Qt::Key_Up: | 272 | case Qt::Key_Up: |
273 | QListView::keyPressEvent ( e ); | 273 | QListView::keyPressEvent ( e ); |
274 | break; | 274 | break; |
275 | case Qt::Key_Left: | 275 | case Qt::Key_Left: |
276 | case Qt::Key_Right: | 276 | case Qt::Key_Right: |
277 | QListView::keyPressEvent ( e ); | 277 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | 278 | e->accept(); |
279 | return; | 279 | return; |
280 | break; | 280 | break; |
281 | default: | 281 | default: |
282 | e->ignore(); | 282 | e->ignore(); |
283 | break; | 283 | break; |
284 | } | 284 | } |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | e->ignore(); | 287 | e->ignore(); |
288 | } | 288 | } |
289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
290 | { | 290 | { |
291 | QListView::contentsMouseReleaseEvent(e); | 291 | QListView::contentsMouseReleaseEvent(e); |
292 | mMousePressed = false; | 292 | mMousePressed = false; |
293 | } | 293 | } |
294 | 294 | ||
295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
296 | { | 296 | { |
297 | if (!e) return; | 297 | if (!e) return; |
298 | 298 | ||
299 | QPoint vp = contentsToViewport(e->pos()); | 299 | QPoint vp = contentsToViewport(e->pos()); |
300 | 300 | ||
301 | QListViewItem *item = itemAt(vp); | 301 | QListViewItem *item = itemAt(vp); |
302 | 302 | ||
303 | emit double_Clicked(item); | 303 | emit double_Clicked(item); |
304 | if (!item) return; | 304 | if (!item) return; |
305 | 305 | ||
306 | emit doubleClicked(item,vp,0); | 306 | emit doubleClicked(item,vp,0); |
307 | } | 307 | } |
308 | 308 | ||
309 | ///////////////////////////////////////////////////////////////////////////// | 309 | ///////////////////////////////////////////////////////////////////////////// |
310 | 310 | ||
311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
312 | QLineEdit(parent) | 312 | QLineEdit(parent) |
313 | { | 313 | { |
314 | setText(i18n("Click to add a new Todo")); | 314 | setText(i18n("Click to add a new Todo")); |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
318 | { | 318 | { |
319 | if ( text()==i18n("Click to add a new Todo") ) | 319 | if ( text()==i18n("Click to add a new Todo") ) |
320 | setText(""); | 320 | setText(""); |
321 | QLineEdit::focusInEvent(ev); | 321 | QLineEdit::focusInEvent(ev); |
322 | } | 322 | } |
323 | 323 | ||
324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
325 | { | 325 | { |
326 | setText(i18n("Click to add a new Todo")); | 326 | setText(i18n("Click to add a new Todo")); |
327 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
331 | 331 | ||
332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
333 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
334 | { | 334 | { |
335 | QBoxLayout *topLayout = new QVBoxLayout(this); | 335 | QBoxLayout *topLayout = new QVBoxLayout(this); |
336 | mName = QString ( name ); | 336 | mName = QString ( name ); |
337 | mBlockUpdate = false; | 337 | mBlockUpdate = false; |
338 | mQuickAdd = new KOQuickTodo(this); | 338 | mQuickAdd = new KOQuickTodo(this); |
339 | topLayout->addWidget(mQuickAdd); | 339 | topLayout->addWidget(mQuickAdd); |
340 | 340 | ||
341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
342 | 342 | ||
343 | mTodoListView = new KOTodoListView(calendar,this, name ); | 343 | mTodoListView = new KOTodoListView(calendar,this, name ); |
344 | topLayout->addWidget(mTodoListView); | 344 | topLayout->addWidget(mTodoListView); |
345 | //mTodoListView->header()->setMaximumHeight(30); | 345 | //mTodoListView->header()->setMaximumHeight(30); |
346 | mTodoListView->setRootIsDecorated(true); | 346 | mTodoListView->setRootIsDecorated(true); |
347 | mTodoListView->setAllColumnsShowFocus(true); | 347 | mTodoListView->setAllColumnsShowFocus(true); |
348 | 348 | ||
349 | mTodoListView->setShowSortIndicator(true); | 349 | mTodoListView->setShowSortIndicator(true); |
350 | 350 | ||
351 | mTodoListView->addColumn(i18n("Todo")); | 351 | mTodoListView->addColumn(i18n("Todo")); |
352 | mTodoListView->addColumn(i18n("Prio")); | 352 | mTodoListView->addColumn(i18n("Prio")); |
353 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 353 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
354 | mTodoListView->addColumn(i18n("Complete")); | 354 | mTodoListView->addColumn(i18n("Complete")); |
355 | mTodoListView->setColumnAlignment(2,AlignHCenter); | 355 | mTodoListView->setColumnAlignment(2,AlignHCenter); |
356 | mTodoListView->addColumn(i18n("Due Date")); | 356 | mTodoListView->addColumn(i18n("Due Date")); |
357 | mTodoListView->setColumnAlignment(3,AlignLeft); | 357 | mTodoListView->setColumnAlignment(3,AlignLeft); |
358 | mTodoListView->addColumn(i18n("Due Time")); | 358 | mTodoListView->addColumn(i18n("Due Time")); |
359 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 359 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
360 | mTodoListView->addColumn(i18n("Cancelled")); | 360 | mTodoListView->addColumn(i18n("Cancelled")); |
361 | mTodoListView->addColumn(i18n("Categories")); | 361 | mTodoListView->addColumn(i18n("Categories")); |
362 | #if 0 | 362 | #if 0 |
363 | mTodoListView->addColumn(i18n("Sort Id")); | 363 | mTodoListView->addColumn(i18n("Sort Id")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | #endif | 365 | #endif |
366 | 366 | ||
367 | mTodoListView->setMinimumHeight( 60 ); | 367 | mTodoListView->setMinimumHeight( 60 ); |
368 | mTodoListView->setItemsRenameable( true ); | 368 | mTodoListView->setItemsRenameable( true ); |
369 | mTodoListView->setRenameable( 0 ); | 369 | mTodoListView->setRenameable( 0 ); |
370 | mTodoListView->setColumnWidth( 0, 120 ); | 370 | mTodoListView->setColumnWidth( 0, 120 ); |
371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
377 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | ||
377 | mTodoListView->setColumnAlignment( 2, AlignCenter ); | 378 | mTodoListView->setColumnAlignment( 2, AlignCenter ); |
378 | #if 0 | 379 | #if 0 |
379 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 380 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
380 | #endif | 381 | #endif |
381 | 382 | ||
382 | mPriorityPopupMenu = new QPopupMenu(this); | 383 | mPriorityPopupMenu = new QPopupMenu(this); |
383 | for (int i = 1; i <= 5; i++) { | 384 | for (int i = 1; i <= 5; i++) { |
384 | QString label = QString ("%1").arg (i); | 385 | QString label = QString ("%1").arg (i); |
385 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 386 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
386 | } | 387 | } |
387 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 388 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
388 | 389 | ||
389 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 390 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
390 | for (int i = 0; i <= 100; i+=20) { | 391 | for (int i = 0; i <= 100; i+=20) { |
391 | QString label = QString ("%1 %").arg (i); | 392 | QString label = QString ("%1 %").arg (i); |
392 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 393 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
393 | } | 394 | } |
394 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 395 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
395 | 396 | ||
396 | 397 | ||
397 | 398 | ||
398 | mItemPopupMenu = new QPopupMenu(this); | 399 | mItemPopupMenu = new QPopupMenu(this); |
399 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 400 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
400 | SLOT (showTodo())); | 401 | SLOT (showTodo())); |
401 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 402 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
402 | SLOT (editTodo())); | 403 | SLOT (editTodo())); |
403 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 404 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
404 | SLOT (deleteTodo())); | 405 | SLOT (deleteTodo())); |
405 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 406 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
406 | SLOT (cloneTodo())); | 407 | SLOT (cloneTodo())); |
407 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 408 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
408 | SLOT (moveTodo())); | 409 | SLOT (moveTodo())); |
409 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 410 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
410 | SLOT (beamTodo())); | 411 | SLOT (beamTodo())); |
411 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 412 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
412 | SLOT (cancelTodo())); | 413 | SLOT (cancelTodo())); |
413 | mItemPopupMenu->insertSeparator(); | 414 | mItemPopupMenu->insertSeparator(); |
414 | 415 | ||
415 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 416 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
416 | SLOT (newTodo())); | 417 | SLOT (newTodo())); |
417 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 418 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
418 | SLOT (newSubTodo())); | 419 | SLOT (newSubTodo())); |
419 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 420 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
420 | SLOT (unparentTodo()),0,21); | 421 | SLOT (unparentTodo()),0,21); |
421 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 422 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
422 | SLOT (reparentTodo()),0,22); | 423 | SLOT (reparentTodo()),0,22); |
423 | mItemPopupMenu->insertSeparator(); | 424 | mItemPopupMenu->insertSeparator(); |
424 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 425 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
425 | this, SLOT( purgeCompleted() ) ); | 426 | this, SLOT( purgeCompleted() ) ); |
426 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 427 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
427 | this, SLOT( toggleCompleted() ),0, 33 ); | 428 | this, SLOT( toggleCompleted() ),0, 33 ); |
428 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 429 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
429 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 430 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
430 | 431 | ||
431 | mPopupMenu = new QPopupMenu(this); | 432 | mPopupMenu = new QPopupMenu(this); |
432 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 433 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
433 | SLOT (newTodo()),0,1); | 434 | SLOT (newTodo()),0,1); |
434 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 435 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
435 | this, SLOT(purgeCompleted()),0,2); | 436 | this, SLOT(purgeCompleted()),0,2); |
436 | mPopupMenu->insertItem(i18n("Show Completed"), | 437 | mPopupMenu->insertItem(i18n("Show Completed"), |
437 | this, SLOT( toggleCompleted() ),0,3 ); | 438 | this, SLOT( toggleCompleted() ),0,3 ); |
438 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 439 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
439 | this, SLOT( toggleQuickTodo() ),0,4 ); | 440 | this, SLOT( toggleQuickTodo() ),0,4 ); |
440 | mDocPrefs = new DocPrefs( name ); | 441 | mDocPrefs = new DocPrefs( name ); |
441 | 442 | ||
442 | mPopupMenu->setCheckable( true ); | 443 | mPopupMenu->setCheckable( true ); |
443 | mItemPopupMenu->setCheckable( true ); | 444 | mItemPopupMenu->setCheckable( true ); |
444 | // Double clicking conflicts with opening/closing the subtree | 445 | // Double clicking conflicts with opening/closing the subtree |
445 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 446 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
446 | SLOT( editItem( QListViewItem *) ) ); | 447 | SLOT( editItem( QListViewItem *) ) ); |
447 | /* | 448 | /* |
448 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 449 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
449 | const QPoint &,int ) ), | 450 | const QPoint &,int ) ), |
450 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 451 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
451 | */ | 452 | */ |
452 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 453 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
453 | const QPoint &,int ) ), | 454 | const QPoint &,int ) ), |
454 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 455 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
455 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 456 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
456 | SLOT( itemClicked( QListViewItem * ) ) ); | 457 | SLOT( itemClicked( QListViewItem * ) ) ); |
457 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 458 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
458 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 459 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
459 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 460 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), |
460 | SLOT( updateView() ) ); | 461 | SLOT( updateView() ) ); |
461 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 462 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
462 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 463 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
463 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 464 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
464 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 465 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
465 | 466 | ||
466 | #if 0 | 467 | #if 0 |
467 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 468 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
468 | SLOT(selectionChanged(QListViewItem *))); | 469 | SLOT(selectionChanged(QListViewItem *))); |
469 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 470 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
470 | SLOT(selectionChanged(QListViewItem *))); | 471 | SLOT(selectionChanged(QListViewItem *))); |
471 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 472 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
472 | SLOT(selectionChanged(QListViewItem *))); | 473 | SLOT(selectionChanged(QListViewItem *))); |
473 | #endif | 474 | #endif |
474 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 475 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
475 | SLOT( processSelectionChange() ) ); | 476 | SLOT( processSelectionChange() ) ); |
476 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 477 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
477 | SLOT( addQuickTodo() ) ); | 478 | SLOT( addQuickTodo() ) ); |
478 | // if ( QApplication::desktop()->width() < 480 ) { | 479 | // if ( QApplication::desktop()->width() < 480 ) { |
479 | // setNarrow(); | 480 | // setNarrow(); |
480 | // mTodoListView->setColumnWidth( 0, 100 ); | 481 | // mTodoListView->setColumnWidth( 0, 100 ); |
481 | 482 | ||
482 | // } | 483 | // } |
483 | 484 | ||
484 | } | 485 | } |
485 | 486 | ||
486 | KOTodoView::~KOTodoView() | 487 | KOTodoView::~KOTodoView() |
487 | { | 488 | { |
488 | delete mDocPrefs; | 489 | delete mDocPrefs; |
489 | } | 490 | } |
490 | 491 | ||
491 | void KOTodoView::jumpToDate () | 492 | void KOTodoView::jumpToDate () |
492 | { | 493 | { |
493 | // if (mActiveItem) { | 494 | // if (mActiveItem) { |
494 | // mActiveItem->todo()); | 495 | // mActiveItem->todo()); |
495 | // if ( mActiveItem->todo()->hasDueDate() ) | 496 | // if ( mActiveItem->todo()->hasDueDate() ) |
496 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 497 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
497 | } | 498 | } |
498 | 499 | ||
499 | void KOTodoView::setNarrow() | 500 | void KOTodoView::setNarrow() |
500 | { | 501 | { |
501 | //mTodoListView->setColumnWidth( 0, 120 ); | 502 | //mTodoListView->setColumnWidth( 0, 120 ); |
502 | mTodoListView->setColumnWidth( 1, 35 ); | 503 | mTodoListView->setColumnWidth( 1, 35 ); |
503 | mTodoListView->setColumnWidth( 2, 40 ); | 504 | mTodoListView->setColumnWidth( 2, 40 ); |
504 | mTodoListView->setColumnWidth( 3, 80 ); | 505 | mTodoListView->setColumnWidth( 3, 80 ); |
505 | mTodoListView->setColumnWidth( 4, 40 ); | 506 | mTodoListView->setColumnWidth( 4, 40 ); |
506 | mTodoListView->setColumnWidth( 5, 90 ); | 507 | mTodoListView->setColumnWidth( 5, 90 ); |
507 | 508 | ||
508 | } | 509 | } |
509 | void KOTodoView::updateView() | 510 | void KOTodoView::updateView() |
510 | { | 511 | { |
511 | pendingSubtodo = 0; | 512 | pendingSubtodo = 0; |
512 | if ( mBlockUpdate ) { | 513 | if ( mBlockUpdate ) { |
513 | //qDebug("blocked "); | 514 | //qDebug("blocked "); |
514 | return; | 515 | return; |
515 | } | 516 | } |
516 | //qDebug("update "); | 517 | //qDebug("update "); |
517 | // kdDebug() << "KOTodoView::updateView()" << endl; | 518 | // kdDebug() << "KOTodoView::updateView()" << endl; |
518 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 519 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
519 | mTodoListView->clear(); | 520 | mTodoListView->clear(); |
520 | if ( mName == "todolistsmall" ) { | 521 | if ( mName == "todolistsmall" ) { |
521 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 522 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
522 | int ps = fo.pointSize() -2; | 523 | int ps = fo.pointSize() -2; |
523 | if ( ps > 12 ) | 524 | if ( ps > 12 ) |
524 | ps -= 2; | 525 | ps -= 2; |
525 | fo.setPointSize( ps ); | 526 | fo.setPointSize( ps ); |
526 | } | 527 | } |
527 | } | 528 | } |
528 | 529 | ||
529 | mTodoListView->setFont( fo ); | 530 | mTodoListView->setFont( fo ); |
530 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 531 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
531 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 532 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
532 | QPtrList<Todo> todoList = calendar()->todos(); | 533 | QPtrList<Todo> todoList = calendar()->todos(); |
533 | 534 | ||
534 | /* | 535 | /* |
535 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 536 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
536 | Event *t; | 537 | Event *t; |
537 | for(t = todoList.first(); t; t = todoList.next()) { | 538 | for(t = todoList.first(); t; t = todoList.next()) { |
538 | kdDebug() << " " << t->getSummary() << endl; | 539 | kdDebug() << " " << t->getSummary() << endl; |
539 | 540 | ||
540 | if (t->getRelatedTo()) { | 541 | if (t->getRelatedTo()) { |
541 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 542 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
542 | } | 543 | } |
543 | 544 | ||
544 | QPtrList<Event> l = t->getRelations(); | 545 | QPtrList<Event> l = t->getRelations(); |
545 | Event *c; | 546 | Event *c; |
546 | for(c=l.first();c;c=l.next()) { | 547 | for(c=l.first();c;c=l.next()) { |
547 | kdDebug() << " - relation: " << c->getSummary() << endl; | 548 | kdDebug() << " - relation: " << c->getSummary() << endl; |
548 | } | 549 | } |
549 | } | 550 | } |
550 | */ | 551 | */ |
551 | 552 | ||
552 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 553 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
553 | // specific order of events. That means that we have to generate parent items | 554 | // specific order of events. That means that we have to generate parent items |
554 | // recursively for proper hierarchical display of Todos. | 555 | // recursively for proper hierarchical display of Todos. |
555 | mTodoMap.clear(); | 556 | mTodoMap.clear(); |
556 | Todo *todo; | 557 | Todo *todo; |
557 | todo = todoList.first();// todo; todo = todoList.next()) { | 558 | todo = todoList.first();// todo; todo = todoList.next()) { |
558 | while ( todo ) { | 559 | while ( todo ) { |
559 | bool next = true; | 560 | bool next = true; |
560 | // qDebug("todo %s ", todo->summary().latin1()); | 561 | // qDebug("todo %s ", todo->summary().latin1()); |
561 | Incidence *incidence = todo->relatedTo(); | 562 | Incidence *incidence = todo->relatedTo(); |
562 | while ( incidence ) { | 563 | while ( incidence ) { |
563 | if ( incidence->type() == "Todo") { | 564 | if ( incidence->type() == "Todo") { |
564 | //qDebug("related %s ",incidence->summary().latin1() ); | 565 | //qDebug("related %s ",incidence->summary().latin1() ); |
565 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 566 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
566 | //qDebug("related not found "); | 567 | //qDebug("related not found "); |
567 | todoList.remove( ); | 568 | todoList.remove( ); |
568 | todo = todoList.current(); | 569 | todo = todoList.current(); |
569 | next = false; | 570 | next = false; |
570 | incidence = 0; | 571 | incidence = 0; |
571 | 572 | ||
572 | } else { | 573 | } else { |
573 | //qDebug("related found "); | 574 | //qDebug("related found "); |
574 | incidence = incidence->relatedTo(); | 575 | incidence = incidence->relatedTo(); |
575 | } | 576 | } |
576 | } else | 577 | } else |
577 | incidence = 0; | 578 | incidence = 0; |
578 | } | 579 | } |
579 | if ( next ) | 580 | if ( next ) |
580 | todo = todoList.next(); | 581 | todo = todoList.next(); |
581 | } | 582 | } |
582 | // qDebug("again .... "); | 583 | // qDebug("again .... "); |
583 | // for(todo = todoList.first(); todo; todo = todoList.next()) { | 584 | // for(todo = todoList.first(); todo; todo = todoList.next()) { |
584 | 585 | ||
585 | // qDebug("yytodo %s ", todo->summary().latin1()); | 586 | // qDebug("yytodo %s ", todo->summary().latin1()); |
586 | // } | 587 | // } |
587 | //qDebug("for "); | 588 | //qDebug("for "); |
588 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 589 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
589 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) | 590 | if (!mTodoMap.contains(todo) && ( KOPrefs::instance()->mShowCompletedTodo || !todo->isCompleted() ) ) |
590 | { | 591 | { |
591 | insertTodoItem(todo); | 592 | insertTodoItem(todo); |
592 | } | 593 | } |
593 | } | 594 | } |
594 | //qDebug("for end "); | 595 | //qDebug("for end "); |
595 | // Restore opened/closed state | 596 | // Restore opened/closed state |
596 | mTodoListView->blockSignals( true ); | 597 | mTodoListView->blockSignals( true ); |
597 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); | 598 | if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); |
598 | mTodoListView->blockSignals( false ); | 599 | mTodoListView->blockSignals( false ); |
599 | mTodoListView->setFocus(); | 600 | mTodoListView->setFocus(); |
600 | processSelectionChange(); | 601 | processSelectionChange(); |
601 | } | 602 | } |
602 | 603 | ||
603 | void KOTodoView::restoreItemState( QListViewItem *item ) | 604 | void KOTodoView::restoreItemState( QListViewItem *item ) |
604 | { | 605 | { |
605 | pendingSubtodo = 0; | 606 | pendingSubtodo = 0; |
606 | while( item ) { | 607 | while( item ) { |
607 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 608 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
608 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 609 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
609 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 610 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
610 | item = item->nextSibling(); | 611 | item = item->nextSibling(); |
611 | } | 612 | } |
612 | } | 613 | } |
613 | 614 | ||
614 | 615 | ||
615 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 616 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
616 | KOTodoView::insertTodoItem(Todo *todo) | 617 | KOTodoView::insertTodoItem(Todo *todo) |
617 | { | 618 | { |
618 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 619 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
619 | // TODO: Check, if dynmaic cast is necessary | 620 | // TODO: Check, if dynmaic cast is necessary |
620 | 621 | ||
621 | pendingSubtodo = 0; | 622 | pendingSubtodo = 0; |
622 | Incidence *incidence = todo->relatedTo(); | 623 | Incidence *incidence = todo->relatedTo(); |
623 | if (incidence && incidence->type() == "Todo") { | 624 | if (incidence && incidence->type() == "Todo") { |
624 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 625 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
625 | 626 | ||
626 | // kdDebug() << " has Related" << endl; | 627 | // kdDebug() << " has Related" << endl; |
627 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 628 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
628 | itemIterator = mTodoMap.find(relatedTodo); | 629 | itemIterator = mTodoMap.find(relatedTodo); |
629 | if (itemIterator == mTodoMap.end()) { | 630 | if (itemIterator == mTodoMap.end()) { |
630 | // kdDebug() << " related not yet in list" << endl; | 631 | // kdDebug() << " related not yet in list" << endl; |
631 | itemIterator = insertTodoItem (relatedTodo); | 632 | itemIterator = insertTodoItem (relatedTodo); |
632 | } | 633 | } |
633 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 634 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
634 | // and one into the map. Sure finding is more easy but why? -zecke | 635 | // and one into the map. Sure finding is more easy but why? -zecke |
635 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 636 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
636 | return mTodoMap.insert(todo,todoItem); | 637 | return mTodoMap.insert(todo,todoItem); |
637 | } else { | 638 | } else { |
638 | // kdDebug() << " no Related" << endl; | 639 | // kdDebug() << " no Related" << endl; |
639 | // see above -zecke | 640 | // see above -zecke |
640 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 641 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
641 | return mTodoMap.insert(todo,todoItem); | 642 | return mTodoMap.insert(todo,todoItem); |
642 | } | 643 | } |
643 | } | 644 | } |
644 | 645 | ||
645 | 646 | ||
646 | void KOTodoView::updateConfig() | 647 | void KOTodoView::updateConfig() |
647 | { | 648 | { |
648 | updateView(); | 649 | updateView(); |
649 | mTodoListView->repaintContents(); | 650 | mTodoListView->repaintContents(); |
650 | } | 651 | } |
651 | 652 | ||
652 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 653 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
653 | { | 654 | { |
654 | QPtrList<Incidence> selected; | 655 | QPtrList<Incidence> selected; |
655 | 656 | ||
656 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 657 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
657 | // if (!item) item = mActiveItem; | 658 | // if (!item) item = mActiveItem; |
658 | if (item) selected.append(item->todo()); | 659 | if (item) selected.append(item->todo()); |
659 | 660 | ||
660 | return selected; | 661 | return selected; |
661 | } | 662 | } |
662 | 663 | ||
663 | QPtrList<Todo> KOTodoView::selectedTodos() | 664 | QPtrList<Todo> KOTodoView::selectedTodos() |
664 | { | 665 | { |
665 | QPtrList<Todo> selected; | 666 | QPtrList<Todo> selected; |
666 | 667 | ||
667 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 668 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
668 | // if (!item) item = mActiveItem; | 669 | // if (!item) item = mActiveItem; |
669 | if (item) selected.append(item->todo()); | 670 | if (item) selected.append(item->todo()); |
670 | 671 | ||
671 | return selected; | 672 | return selected; |
672 | } | 673 | } |
673 | 674 | ||
674 | void KOTodoView::changeEventDisplay(Event *, int) | 675 | void KOTodoView::changeEventDisplay(Event *, int) |
675 | { | 676 | { |
676 | updateView(); | 677 | updateView(); |
677 | } | 678 | } |
678 | 679 | ||
679 | void KOTodoView::showDates(const QDate &, const QDate &) | 680 | void KOTodoView::showDates(const QDate &, const QDate &) |
680 | { | 681 | { |
681 | } | 682 | } |
682 | 683 | ||
683 | void KOTodoView::showEvents(QPtrList<Event>) | 684 | void KOTodoView::showEvents(QPtrList<Event>) |
684 | { | 685 | { |
685 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 686 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
686 | } | 687 | } |
687 | 688 | ||
688 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 689 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
689 | const QDate &td) | 690 | const QDate &td) |
690 | { | 691 | { |
691 | #ifndef KORG_NOPRINTER | 692 | #ifndef KORG_NOPRINTER |
692 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 693 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
693 | #endif | 694 | #endif |
694 | } | 695 | } |
695 | 696 | ||
696 | void KOTodoView::editItem(QListViewItem *item ) | 697 | void KOTodoView::editItem(QListViewItem *item ) |
697 | { | 698 | { |
698 | // qDebug("editItem(QListViewItem *item ) "); | 699 | // qDebug("editItem(QListViewItem *item ) "); |
699 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 700 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
700 | } | 701 | } |
701 | 702 | ||
702 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 703 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
703 | { | 704 | { |
704 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 705 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
705 | } | 706 | } |
706 | 707 | ||
707 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 708 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) |
708 | { | 709 | { |
709 | pendingSubtodo = 0; | 710 | pendingSubtodo = 0; |
710 | mActiveItem = (KOTodoViewItem *)item; | 711 | mActiveItem = (KOTodoViewItem *)item; |
711 | if (item) { | 712 | if (item) { |
712 | switch (column){ | 713 | switch (column){ |
713 | case 1: | 714 | case 1: |
714 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 715 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
715 | case 2: | 716 | case 2: |
716 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 717 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
717 | case 3: | 718 | case 3: |
718 | moveTodo(); | 719 | moveTodo(); |
719 | break; | 720 | break; |
720 | case 6: | 721 | case 6: |
721 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 722 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
722 | default: | 723 | default: |
723 | mItemPopupMenu->popup(QCursor::pos()); | 724 | mItemPopupMenu->popup(QCursor::pos()); |
724 | } | 725 | } |
725 | } else mPopupMenu->popup(QCursor::pos()); | 726 | } else mPopupMenu->popup(QCursor::pos()); |
726 | } | 727 | } |
727 | void KOTodoView::newTodo() | 728 | void KOTodoView::newTodo() |
728 | { | 729 | { |
729 | emit newTodoSignal(); | 730 | emit newTodoSignal(); |
730 | } | 731 | } |
731 | 732 | ||
732 | void KOTodoView::newSubTodo() | 733 | void KOTodoView::newSubTodo() |
733 | { | 734 | { |
734 | if (mActiveItem) { | 735 | if (mActiveItem) { |
735 | emit newSubTodoSignal(mActiveItem->todo()); | 736 | emit newSubTodoSignal(mActiveItem->todo()); |
736 | } | 737 | } |
737 | } | 738 | } |
738 | void KOTodoView::unparentTodo() | 739 | void KOTodoView::unparentTodo() |
739 | { | 740 | { |
740 | if (mActiveItem) { | 741 | if (mActiveItem) { |
741 | emit unparentTodoSignal(mActiveItem->todo()); | 742 | emit unparentTodoSignal(mActiveItem->todo()); |
742 | } | 743 | } |
743 | } | 744 | } |
744 | 745 | ||
745 | void KOTodoView::reparentTodo() | 746 | void KOTodoView::reparentTodo() |
746 | { | 747 | { |
747 | if (mActiveItem) { | 748 | if (mActiveItem) { |
748 | qDebug("KOTodoView::reparentTodo() "); | 749 | qDebug("KOTodoView::reparentTodo() "); |
749 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 750 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
750 | pendingSubtodo = mActiveItem; | 751 | pendingSubtodo = mActiveItem; |
751 | } | 752 | } |
752 | } | 753 | } |
753 | void KOTodoView::editTodo() | 754 | void KOTodoView::editTodo() |
754 | { | 755 | { |
755 | if (mActiveItem) { | 756 | if (mActiveItem) { |
756 | emit editTodoSignal(mActiveItem->todo()); | 757 | emit editTodoSignal(mActiveItem->todo()); |
757 | } | 758 | } |
758 | } | 759 | } |
759 | void KOTodoView::cloneTodo() | 760 | void KOTodoView::cloneTodo() |
760 | { | 761 | { |
761 | if (mActiveItem) { | 762 | if (mActiveItem) { |
762 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 763 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
763 | } | 764 | } |
764 | } | 765 | } |
765 | void KOTodoView::cancelTodo() | 766 | void KOTodoView::cancelTodo() |
766 | { | 767 | { |
767 | if (mActiveItem) { | 768 | if (mActiveItem) { |
768 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 769 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
769 | } | 770 | } |
770 | } | 771 | } |
771 | void KOTodoView::moveTodo() | 772 | void KOTodoView::moveTodo() |
772 | { | 773 | { |
773 | if (mActiveItem) { | 774 | if (mActiveItem) { |
774 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 775 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
775 | } | 776 | } |
776 | } | 777 | } |
777 | void KOTodoView::beamTodo() | 778 | void KOTodoView::beamTodo() |
778 | { | 779 | { |
779 | if (mActiveItem) { | 780 | if (mActiveItem) { |
780 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 781 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
781 | } | 782 | } |
782 | } | 783 | } |
783 | 784 | ||
784 | 785 | ||
785 | void KOTodoView::showTodo() | 786 | void KOTodoView::showTodo() |
786 | { | 787 | { |
787 | if (mActiveItem) { | 788 | if (mActiveItem) { |
788 | emit showTodoSignal(mActiveItem->todo()); | 789 | emit showTodoSignal(mActiveItem->todo()); |
789 | } | 790 | } |
790 | } | 791 | } |
791 | 792 | ||
792 | void KOTodoView::deleteTodo() | 793 | void KOTodoView::deleteTodo() |
793 | { | 794 | { |
794 | if (mActiveItem) { | 795 | if (mActiveItem) { |
795 | if (mActiveItem->childCount()) { | 796 | if (mActiveItem->childCount()) { |
796 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), | 797 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), |
797 | i18n("Delete To-Do")); | 798 | i18n("Delete To-Do")); |
798 | } else { | 799 | } else { |
799 | emit deleteTodoSignal(mActiveItem->todo()); | 800 | emit deleteTodoSignal(mActiveItem->todo()); |
800 | } | 801 | } |
801 | } | 802 | } |
802 | } | 803 | } |
803 | 804 | ||
804 | void KOTodoView::setNewPriority(int index) | 805 | void KOTodoView::setNewPriority(int index) |
805 | { | 806 | { |
806 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 807 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
807 | mActiveItem->todo()->setPriority(mPriority[index]); | 808 | mActiveItem->todo()->setPriority(mPriority[index]); |
808 | mActiveItem->construct(); | 809 | mActiveItem->construct(); |
809 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 810 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
810 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 811 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
811 | } | 812 | } |
812 | } | 813 | } |
813 | 814 | ||
814 | void KOTodoView::setNewPercentage(int index) | 815 | void KOTodoView::setNewPercentage(int index) |
815 | { | 816 | { |
816 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 817 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
817 | if (mPercentage[index] == 100) { | 818 | if (mPercentage[index] == 100) { |
818 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 819 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
819 | } else { | 820 | } else { |
820 | mActiveItem->todo()->setCompleted(false); | 821 | mActiveItem->todo()->setCompleted(false); |
821 | } | 822 | } |
822 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 823 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
823 | mActiveItem->construct(); | 824 | mActiveItem->construct(); |
824 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 825 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
825 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 826 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
826 | } | 827 | } |
827 | } | 828 | } |
828 | 829 | ||
829 | 830 | ||
830 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 831 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
831 | { | 832 | { |
832 | QPopupMenu* tempMenu = new QPopupMenu (this); | 833 | QPopupMenu* tempMenu = new QPopupMenu (this); |
833 | QStringList checkedCategories = todoItem->todo()->categories (); | 834 | QStringList checkedCategories = todoItem->todo()->categories (); |
834 | 835 | ||
835 | tempMenu->setCheckable (true); | 836 | tempMenu->setCheckable (true); |
836 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 837 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
837 | it != KOPrefs::instance()->mCustomCategories.end (); | 838 | it != KOPrefs::instance()->mCustomCategories.end (); |
838 | ++it) { | 839 | ++it) { |
839 | int index = tempMenu->insertItem (*it); | 840 | int index = tempMenu->insertItem (*it); |
840 | mCategory[index] = *it; | 841 | mCategory[index] = *it; |
841 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 842 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
842 | } | 843 | } |
843 | 844 | ||
844 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 845 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
845 | return tempMenu; | 846 | return tempMenu; |
846 | 847 | ||
847 | 848 | ||
848 | } | 849 | } |
849 | void KOTodoView::changedCategories(int index) | 850 | void KOTodoView::changedCategories(int index) |
850 | { | 851 | { |
851 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 852 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
852 | QStringList categories = mActiveItem->todo()->categories (); | 853 | QStringList categories = mActiveItem->todo()->categories (); |
853 | if (categories.find (mCategory[index]) != categories.end ()) | 854 | if (categories.find (mCategory[index]) != categories.end ()) |
854 | categories.remove (mCategory[index]); | 855 | categories.remove (mCategory[index]); |
855 | else | 856 | else |
856 | categories.insert (categories.end(), mCategory[index]); | 857 | categories.insert (categories.end(), mCategory[index]); |
857 | categories.sort (); | 858 | categories.sort (); |
858 | mActiveItem->todo()->setCategories (categories); | 859 | mActiveItem->todo()->setCategories (categories); |
859 | mActiveItem->construct(); | 860 | mActiveItem->construct(); |
860 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 861 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
861 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 862 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
862 | } | 863 | } |
863 | } | 864 | } |
864 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 865 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
865 | { | 866 | { |
866 | if ( pendingSubtodo != 0 ) { | 867 | if ( pendingSubtodo != 0 ) { |
867 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 868 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
868 | } | 869 | } |
869 | pendingSubtodo = 0; | 870 | pendingSubtodo = 0; |
870 | if (!item) { | 871 | if (!item) { |
871 | newTodo(); | 872 | newTodo(); |
872 | return; | 873 | return; |
873 | } | 874 | } |
874 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 875 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
875 | editItem( item ); | 876 | editItem( item ); |
876 | else | 877 | else |
877 | showItem( item , QPoint(), 0 ); | 878 | showItem( item , QPoint(), 0 ); |
878 | } | 879 | } |
879 | void KOTodoView::itemClicked(QListViewItem *item) | 880 | void KOTodoView::itemClicked(QListViewItem *item) |
880 | { | 881 | { |
881 | 882 | ||
882 | if (!item) { | 883 | if (!item) { |
883 | if ( pendingSubtodo != 0 ) { | 884 | if ( pendingSubtodo != 0 ) { |
884 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 885 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
885 | } | 886 | } |
886 | pendingSubtodo = 0; | 887 | pendingSubtodo = 0; |
887 | return; | 888 | return; |
888 | } | 889 | } |
889 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 890 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
890 | if ( pendingSubtodo != 0 ) { | 891 | if ( pendingSubtodo != 0 ) { |
891 | bool allowReparent = true; | 892 | bool allowReparent = true; |
892 | QListViewItem *par = item; | 893 | QListViewItem *par = item; |
893 | while ( par ) { | 894 | while ( par ) { |
894 | if ( par == pendingSubtodo ) { | 895 | if ( par == pendingSubtodo ) { |
895 | allowReparent = false; | 896 | allowReparent = false; |
896 | break; | 897 | break; |
897 | } | 898 | } |
898 | par = par->parent(); | 899 | par = par->parent(); |
899 | } | 900 | } |
900 | if ( !allowReparent ) { | 901 | if ( !allowReparent ) { |
901 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 902 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
902 | qDebug("Recursive reparenting not possible "); | 903 | qDebug("Recursive reparenting not possible "); |
903 | pendingSubtodo = 0; | 904 | pendingSubtodo = 0; |
904 | } else { | 905 | } else { |
905 | Todo* newParent = todoItem->todo(); | 906 | Todo* newParent = todoItem->todo(); |
906 | Todo* newSub = pendingSubtodo->todo(); | 907 | Todo* newSub = pendingSubtodo->todo(); |
907 | pendingSubtodo = 0; | 908 | pendingSubtodo = 0; |
908 | emit reparentTodoSignal( newParent,newSub ); | 909 | emit reparentTodoSignal( newParent,newSub ); |
909 | return; | 910 | return; |
910 | } | 911 | } |
911 | } | 912 | } |
912 | int completed = todoItem->todo()->isCompleted(); // Completed or not? | 913 | int completed = todoItem->todo()->isCompleted(); // Completed or not? |
913 | 914 | ||
914 | if (todoItem->isOn()) { | 915 | if (todoItem->isOn()) { |
915 | if (!completed) { | 916 | if (!completed) { |
916 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 917 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
917 | } | 918 | } |
918 | } else { | 919 | } else { |
919 | if (completed) { | 920 | if (completed) { |
920 | todoItem->todo()->setCompleted(false); | 921 | todoItem->todo()->setCompleted(false); |
921 | } | 922 | } |
922 | } | 923 | } |
923 | } | 924 | } |
924 | 925 | ||
925 | void KOTodoView::setDocumentId( const QString &id ) | 926 | void KOTodoView::setDocumentId( const QString &id ) |
926 | { | 927 | { |
927 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 928 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
928 | 929 | ||
929 | mDocPrefs->setDoc( id ); | 930 | mDocPrefs->setDoc( id ); |
930 | } | 931 | } |
931 | 932 | ||
932 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 933 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
933 | { | 934 | { |
934 | if (!item) return; | 935 | if (!item) return; |
935 | 936 | ||
936 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 937 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
937 | 938 | ||
938 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 939 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
939 | 940 | ||
940 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 941 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
941 | } | 942 | } |
942 | 943 | ||
943 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 944 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
944 | { | 945 | { |
945 | mTodoListView->saveLayout(config,group); | 946 | mTodoListView->saveLayout(config,group); |
946 | } | 947 | } |
947 | 948 | ||
948 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 949 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
949 | { | 950 | { |
950 | mTodoListView->restoreLayout(config,group); | 951 | mTodoListView->restoreLayout(config,group); |
951 | } | 952 | } |
952 | 953 | ||
953 | void KOTodoView::processSelectionChange() | 954 | void KOTodoView::processSelectionChange() |
954 | { | 955 | { |
955 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 956 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
956 | 957 | ||
957 | KOTodoViewItem *item = | 958 | KOTodoViewItem *item = |
958 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 959 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
959 | 960 | ||
960 | if ( !item ) { | 961 | if ( !item ) { |
961 | emit incidenceSelected( 0 ); | 962 | emit incidenceSelected( 0 ); |
962 | } else { | 963 | } else { |
963 | emit incidenceSelected( item->todo() ); | 964 | emit incidenceSelected( item->todo() ); |
964 | } | 965 | } |
965 | } | 966 | } |
966 | 967 | ||
967 | void KOTodoView::modified(bool b) | 968 | void KOTodoView::modified(bool b) |
968 | { | 969 | { |
969 | emit isModified(b); | 970 | emit isModified(b); |
970 | } | 971 | } |
971 | void KOTodoView::setTodoModified( Todo* todo ) | 972 | void KOTodoView::setTodoModified( Todo* todo ) |
972 | { | 973 | { |
973 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 974 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
974 | } | 975 | } |
975 | void KOTodoView::clearSelection() | 976 | void KOTodoView::clearSelection() |
976 | { | 977 | { |
977 | mTodoListView->selectAll( false ); | 978 | mTodoListView->selectAll( false ); |
978 | } | 979 | } |
979 | 980 | ||
980 | void KOTodoView::purgeCompleted() | 981 | void KOTodoView::purgeCompleted() |
981 | { | 982 | { |
982 | emit purgeCompletedSignal(); | 983 | emit purgeCompletedSignal(); |
983 | } | 984 | } |
984 | void KOTodoView::toggleQuickTodo() | 985 | void KOTodoView::toggleQuickTodo() |
985 | { | 986 | { |
986 | if ( mQuickAdd->isVisible() ) { | 987 | if ( mQuickAdd->isVisible() ) { |
987 | mQuickAdd->hide(); | 988 | mQuickAdd->hide(); |
988 | KOPrefs::instance()->mEnableQuickTodo = false; | 989 | KOPrefs::instance()->mEnableQuickTodo = false; |
989 | } | 990 | } |
990 | else { | 991 | else { |
991 | mQuickAdd->show(); | 992 | mQuickAdd->show(); |
992 | KOPrefs::instance()->mEnableQuickTodo = true; | 993 | KOPrefs::instance()->mEnableQuickTodo = true; |
993 | } | 994 | } |
994 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 995 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
995 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 996 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
996 | } | 997 | } |
997 | void KOTodoView::toggleCompleted() | 998 | void KOTodoView::toggleCompleted() |
998 | { | 999 | { |
999 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1000 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1000 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1001 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1001 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1002 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1002 | updateView(); | 1003 | updateView(); |
1003 | } | 1004 | } |
1004 | 1005 | ||
1005 | void KOTodoView::addQuickTodo() | 1006 | void KOTodoView::addQuickTodo() |
1006 | { | 1007 | { |
1007 | Todo *todo = new Todo(); | 1008 | Todo *todo = new Todo(); |
1008 | todo->setSummary(mQuickAdd->text()); | 1009 | todo->setSummary(mQuickAdd->text()); |
1009 | todo->setOrganizer(KOPrefs::instance()->email()); | 1010 | todo->setOrganizer(KOPrefs::instance()->email()); |
1010 | CalFilter * cf = mCalendar->filter(); | 1011 | CalFilter * cf = mCalendar->filter(); |
1011 | if ( cf ) { | 1012 | if ( cf ) { |
1012 | if ( cf->isEnabled()&& cf->showCategories()) { | 1013 | if ( cf->isEnabled()&& cf->showCategories()) { |
1013 | todo->setCategories(cf->categoryList()); | 1014 | todo->setCategories(cf->categoryList()); |
1014 | } | 1015 | } |
1015 | if ( cf->isEnabled() ) | 1016 | if ( cf->isEnabled() ) |
1016 | todo->setSecrecy( cf->getSecrecy()); | 1017 | todo->setSecrecy( cf->getSecrecy()); |
1017 | } | 1018 | } |
1018 | mCalendar->addTodo(todo); | 1019 | mCalendar->addTodo(todo); |
1019 | mQuickAdd->setText(""); | 1020 | mQuickAdd->setText(""); |
1020 | todoModified (todo, KOGlobals::EVENTADDED ); | 1021 | todoModified (todo, KOGlobals::EVENTADDED ); |
1021 | updateView(); | 1022 | updateView(); |
1022 | } | 1023 | } |
1023 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1024 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1024 | { | 1025 | { |
1025 | // e->ignore(); | 1026 | // e->ignore(); |
1026 | //return; | 1027 | //return; |
1027 | //qDebug("KOTodoView::keyPressEvent "); | 1028 | //qDebug("KOTodoView::keyPressEvent "); |
1028 | switch ( e->key() ) { | 1029 | switch ( e->key() ) { |
1029 | case Qt::Key_Down: | 1030 | case Qt::Key_Down: |
1030 | case Qt::Key_Up: | 1031 | case Qt::Key_Up: |
1031 | QWidget::keyPressEvent ( e ); | 1032 | QWidget::keyPressEvent ( e ); |
1032 | break; | 1033 | break; |
1033 | 1034 | ||
1034 | case Qt::Key_Q: | 1035 | case Qt::Key_Q: |
1035 | toggleQuickTodo(); | 1036 | toggleQuickTodo(); |
1036 | break; | 1037 | break; |
1037 | case Qt::Key_U: | 1038 | case Qt::Key_U: |
1038 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1039 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1039 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1040 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1040 | unparentTodo(); | 1041 | unparentTodo(); |
1041 | e->accept(); | 1042 | e->accept(); |
1042 | } else | 1043 | } else |
1043 | e->ignore(); | 1044 | e->ignore(); |
1044 | break; | 1045 | break; |
1045 | case Qt::Key_S: | 1046 | case Qt::Key_S: |
1046 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1047 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1047 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1048 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1048 | reparentTodo(); | 1049 | reparentTodo(); |
1049 | e->accept(); | 1050 | e->accept(); |
1050 | } else | 1051 | } else |
1051 | e->ignore(); | 1052 | e->ignore(); |
1052 | break; | 1053 | break; |
1053 | case Qt::Key_P: | 1054 | case Qt::Key_P: |
1054 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1055 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1055 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1056 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1056 | if ( pendingSubtodo ) | 1057 | if ( pendingSubtodo ) |
1057 | itemClicked(mActiveItem); | 1058 | itemClicked(mActiveItem); |
1058 | e->accept(); | 1059 | e->accept(); |
1059 | } else | 1060 | } else |
1060 | e->ignore(); | 1061 | e->ignore(); |
1061 | break; | 1062 | break; |
1062 | case Qt::Key_Escape: | 1063 | case Qt::Key_Escape: |
1063 | if ( pendingSubtodo ) { | 1064 | if ( pendingSubtodo ) { |
1064 | itemClicked(0); | 1065 | itemClicked(0); |
1065 | e->accept(); | 1066 | e->accept(); |
1066 | } else | 1067 | } else |
1067 | e->ignore(); | 1068 | e->ignore(); |
1068 | break; | 1069 | break; |
1069 | default: | 1070 | default: |
1070 | e->ignore(); | 1071 | e->ignore(); |
1071 | } | 1072 | } |
1072 | 1073 | ||
1073 | if ( true ) { | 1074 | if ( true ) { |
1074 | if ( e->key() == Qt::Key_I ) { | 1075 | if ( e->key() == Qt::Key_I ) { |
1075 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1076 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1076 | if ( cn ) { | 1077 | if ( cn ) { |
1077 | mActiveItem = cn; | 1078 | mActiveItem = cn; |
1078 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1079 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1079 | if ( ci ){ | 1080 | if ( ci ){ |
1080 | showTodo(); | 1081 | showTodo(); |
1081 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1082 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1082 | if ( cn ) { | 1083 | if ( cn ) { |
1083 | mTodoListView->setCurrentItem ( cn ); | 1084 | mTodoListView->setCurrentItem ( cn ); |
1084 | mTodoListView->ensureItemVisible ( cn ); | 1085 | mTodoListView->ensureItemVisible ( cn ); |
1085 | } | 1086 | } |
1086 | 1087 | ||
1087 | } | 1088 | } |
1088 | } | 1089 | } |
1089 | e->accept(); | 1090 | e->accept(); |
1090 | 1091 | ||
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | } | 1094 | } |
1094 | 1095 | ||
1095 | } | 1096 | } |
1096 | void KOTodoView::updateTodo( Todo * t, int type ) | 1097 | void KOTodoView::updateTodo( Todo * t, int type ) |
1097 | { | 1098 | { |
1098 | if ( mBlockUpdate) | 1099 | if ( mBlockUpdate) |
1099 | return; | 1100 | return; |
1100 | 1101 | ||
1101 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1102 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1102 | itemIterator = mTodoMap.find(t); | 1103 | itemIterator = mTodoMap.find(t); |
1103 | if (itemIterator != mTodoMap.end()) { | 1104 | if (itemIterator != mTodoMap.end()) { |
1104 | (*itemIterator)->construct(); | 1105 | (*itemIterator)->construct(); |
1105 | } else { | 1106 | } else { |
1106 | if ( type == KOGlobals::EVENTADDED ) { | 1107 | if ( type == KOGlobals::EVENTADDED ) { |
1107 | insertTodoItem( t ); | 1108 | insertTodoItem( t ); |
1108 | } | 1109 | } |
1109 | } | 1110 | } |
1110 | 1111 | ||
1111 | } | 1112 | } |
1112 | 1113 | ||
1113 | void KOTodoView::todoModified(Todo * t , int p ) | 1114 | void KOTodoView::todoModified(Todo * t , int p ) |
1114 | { | 1115 | { |
1115 | mBlockUpdate = true; | 1116 | mBlockUpdate = true; |
1116 | emit todoModifiedSignal ( t, p ); | 1117 | emit todoModifiedSignal ( t, p ); |
1117 | mBlockUpdate = false; | 1118 | mBlockUpdate = false; |
1118 | } | 1119 | } |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 85647b1..ae0b334 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,432 +1,432 @@ | |||
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 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | 23 | ||
24 | #include <kiconloader.h> | 24 | #include <kiconloader.h> |
25 | #include "kotodoviewitem.h" | 25 | #include "kotodoviewitem.h" |
26 | #include "kotodoview.h" | 26 | #include "kotodoview.h" |
27 | #include "koprefs.h" | 27 | #include "koprefs.h" |
28 | 28 | ||
29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
31 | { | 31 | { |
32 | construct(); | 32 | construct(); |
33 | } | 33 | } |
34 | 34 | ||
35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
37 | { | 37 | { |
38 | construct(); | 38 | construct(); |
39 | } | 39 | } |
40 | 40 | ||
41 | QString KOTodoViewItem::key(int column,bool) const | 41 | QString KOTodoViewItem::key(int column,bool) const |
42 | { | 42 | { |
43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
44 | if (it == mKeyMap.end()) { | 44 | if (it == mKeyMap.end()) { |
45 | return text(column); | 45 | return text(column).lower(); |
46 | } else { | 46 | } else { |
47 | return *it; | 47 | return *it; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void KOTodoViewItem:: setup() | 51 | void KOTodoViewItem:: setup() |
52 | { | 52 | { |
53 | 53 | ||
54 | int h = 20; | 54 | int h = 20; |
55 | if ( listView () ) { | 55 | if ( listView () ) { |
56 | QFontMetrics fm ( listView ()->font () ); | 56 | QFontMetrics fm ( listView ()->font () ); |
57 | h = fm.height(); | 57 | h = fm.height(); |
58 | } | 58 | } |
59 | setHeight( h ); | 59 | setHeight( h ); |
60 | 60 | ||
61 | } | 61 | } |
62 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 62 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
63 | { | 63 | { |
64 | mKeyMap.insert(column,key); | 64 | mKeyMap.insert(column,key); |
65 | } | 65 | } |
66 | 66 | ||
67 | #if QT_VERSION >= 300 | 67 | #if QT_VERSION >= 300 |
68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
69 | int y,int h) | 69 | int y,int h) |
70 | { | 70 | { |
71 | QListViewItem::paintBranches(p,cg,w,y,h); | 71 | QListViewItem::paintBranches(p,cg,w,y,h); |
72 | } | 72 | } |
73 | #else | 73 | #else |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | void KOTodoViewItem::construct() | 76 | void KOTodoViewItem::construct() |
77 | { | 77 | { |
78 | // qDebug("KOTodoViewItem::construct() "); | 78 | // qDebug("KOTodoViewItem::construct() "); |
79 | m_init = true; | 79 | m_init = true; |
80 | QString keyd = "=="; | 80 | QString keyd = "=="; |
81 | QString keyt = "=="; | 81 | QString keyt = "=="; |
82 | 82 | ||
83 | setOn(mTodo->isCompleted()); | 83 | setOn(mTodo->isCompleted()); |
84 | setText(0,mTodo->summary()); | 84 | setText(0,mTodo->summary()); |
85 | setText(1,QString::number(mTodo->priority())); | 85 | setText(1,QString::number(mTodo->priority())); |
86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
87 | if (mTodo->percentComplete()<100) { | 87 | if (mTodo->percentComplete()<100) { |
88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
89 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 89 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
90 | } | 90 | } |
91 | else { | 91 | else { |
92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
93 | else setSortKey(2,QString::number(99)); | 93 | else setSortKey(2,QString::number(99)); |
94 | } | 94 | } |
95 | if (mTodo->hasDueDate()) { | 95 | if (mTodo->hasDueDate()) { |
96 | setText(3, mTodo->dtDueDateStr()); | 96 | setText(3, mTodo->dtDueDateStr()); |
97 | QDate d = mTodo->dtDue().date(); | 97 | QDate d = mTodo->dtDue().date(); |
98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
99 | setSortKey(3,keyd); | 99 | setSortKey(3,keyd); |
100 | if (mTodo->doesFloat()) { | 100 | if (mTodo->doesFloat()) { |
101 | setText(4,""); | 101 | setText(4,""); |
102 | } | 102 | } |
103 | else { | 103 | else { |
104 | setText(4,mTodo->dtDueTimeStr()); | 104 | setText(4,mTodo->dtDueTimeStr()); |
105 | QTime t = mTodo->dtDue().time(); | 105 | QTime t = mTodo->dtDue().time(); |
106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
107 | setSortKey(4,keyt); | 107 | setSortKey(4,keyt); |
108 | } | 108 | } |
109 | } else { | 109 | } else { |
110 | setText(3,""); | 110 | setText(3,""); |
111 | setText(4,""); | 111 | setText(4,""); |
112 | } | 112 | } |
113 | setSortKey(3,keyd); | 113 | setSortKey(3,keyd); |
114 | setSortKey(4,keyt); | 114 | setSortKey(4,keyt); |
115 | 115 | ||
116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
118 | 118 | ||
119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
120 | setText(6,mTodo->categoriesStr()); | 120 | setText(6,mTodo->categoriesStr()); |
121 | 121 | ||
122 | #if 0 | 122 | #if 0 |
123 | // Find sort id in description. It's the text behind the last '#' character | 123 | // Find sort id in description. It's the text behind the last '#' character |
124 | // found in the description. White spaces are removed from beginning and end | 124 | // found in the description. White spaces are removed from beginning and end |
125 | // of sort id. | 125 | // of sort id. |
126 | int pos = mTodo->description().findRev('#'); | 126 | int pos = mTodo->description().findRev('#'); |
127 | if (pos < 0) { | 127 | if (pos < 0) { |
128 | setText(6,""); | 128 | setText(6,""); |
129 | } else { | 129 | } else { |
130 | QString str = mTodo->description().mid(pos+1); | 130 | QString str = mTodo->description().mid(pos+1); |
131 | str.stripWhiteSpace(); | 131 | str.stripWhiteSpace(); |
132 | setText(6,str); | 132 | setText(6,str); |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | m_known = false; | 136 | m_known = false; |
137 | m_init = false; | 137 | m_init = false; |
138 | 138 | ||
139 | setMyPixmap(); | 139 | setMyPixmap(); |
140 | 140 | ||
141 | } | 141 | } |
142 | void KOTodoViewItem::setMyPixmap() | 142 | void KOTodoViewItem::setMyPixmap() |
143 | { | 143 | { |
144 | int size = 5; | 144 | int size = 5; |
145 | QPixmap pixi = QPixmap( 1, 1 ); | 145 | QPixmap pixi = QPixmap( 1, 1 ); |
146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
147 | // pixi = SmallIcon("redcross16"); | 147 | // pixi = SmallIcon("redcross16"); |
148 | // } else { | 148 | // } else { |
149 | QPainter p; | 149 | QPainter p; |
150 | 150 | ||
151 | int pixSize = 0; | 151 | int pixSize = 0; |
152 | QPixmap pPix = QPixmap( size, size ); | 152 | QPixmap pPix = QPixmap( size, size ); |
153 | if ( mTodo->description().length() > 0 ) { | 153 | if ( mTodo->description().length() > 0 ) { |
154 | pixi.resize(size, pixSize+size); | 154 | pixi.resize(size, pixSize+size); |
155 | pPix.fill( Qt::darkGreen ); | 155 | pPix.fill( Qt::darkGreen ); |
156 | p.begin( &pixi ); | 156 | p.begin( &pixi ); |
157 | p. drawPixmap ( 0, pixSize, pPix); | 157 | p. drawPixmap ( 0, pixSize, pPix); |
158 | p.end(); | 158 | p.end(); |
159 | pixSize += size; | 159 | pixSize += size; |
160 | } | 160 | } |
161 | if ( mTodo->isAlarmEnabled() ) { | 161 | if ( mTodo->isAlarmEnabled() ) { |
162 | pixi.resize(size, pixSize+size); | 162 | pixi.resize(size, pixSize+size); |
163 | pPix.fill( Qt::red ); | 163 | pPix.fill( Qt::red ); |
164 | p.begin( &pixi ); | 164 | p.begin( &pixi ); |
165 | p. drawPixmap ( 0, pixSize, pPix); | 165 | p. drawPixmap ( 0, pixSize, pPix); |
166 | p.end(); | 166 | p.end(); |
167 | pixSize += size; | 167 | pixSize += size; |
168 | } | 168 | } |
169 | // } | 169 | // } |
170 | if ( pixi.width() > 1 ) { | 170 | if ( pixi.width() > 1 ) { |
171 | setPixmap ( 0,pixi ) ; | 171 | setPixmap ( 0,pixi ) ; |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | } | 175 | } |
176 | void KOTodoViewItem::stateChange(bool state) | 176 | void KOTodoViewItem::stateChange(bool state) |
177 | { | 177 | { |
178 | // qDebug("KOTodoViewItem::stateChange "); | 178 | // qDebug("KOTodoViewItem::stateChange "); |
179 | // do not change setting on startup | 179 | // do not change setting on startup |
180 | if ( m_init ) return; | 180 | if ( m_init ) return; |
181 | 181 | ||
182 | kdDebug() << "State changed, modified " << state << endl; | 182 | kdDebug() << "State changed, modified " << state << endl; |
183 | QString keyd = "=="; | 183 | QString keyd = "=="; |
184 | QString keyt = "=="; | 184 | QString keyt = "=="; |
185 | 185 | ||
186 | if (state) mTodo->setCompleted(state); | 186 | if (state) mTodo->setCompleted(state); |
187 | else mTodo->setPercentComplete(0); | 187 | else mTodo->setPercentComplete(0); |
188 | if (isOn()!=state) { | 188 | if (isOn()!=state) { |
189 | setOn(state); | 189 | setOn(state); |
190 | } | 190 | } |
191 | 191 | ||
192 | if (mTodo->hasDueDate()) { | 192 | if (mTodo->hasDueDate()) { |
193 | setText(3, mTodo->dtDueDateStr()); | 193 | setText(3, mTodo->dtDueDateStr()); |
194 | QDate d = mTodo->dtDue().date(); | 194 | QDate d = mTodo->dtDue().date(); |
195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
196 | setSortKey(3,keyd); | 196 | setSortKey(3,keyd); |
197 | if (mTodo->doesFloat()) { | 197 | if (mTodo->doesFloat()) { |
198 | setText(4,""); | 198 | setText(4,""); |
199 | } | 199 | } |
200 | else { | 200 | else { |
201 | setText(4,mTodo->dtDueTimeStr()); | 201 | setText(4,mTodo->dtDueTimeStr()); |
202 | QTime t = mTodo->dtDue().time(); | 202 | QTime t = mTodo->dtDue().time(); |
203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
204 | setSortKey(4,keyt); | 204 | setSortKey(4,keyt); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
209 | 209 | ||
210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
211 | if (mTodo->percentComplete()<100) { | 211 | if (mTodo->percentComplete()<100) { |
212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
213 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 213 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
214 | } | 214 | } |
215 | else { | 215 | else { |
216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
217 | else setSortKey(2,QString::number(99)); | 217 | else setSortKey(2,QString::number(99)); |
218 | } | 218 | } |
219 | QListViewItem * myChild = firstChild(); | 219 | QListViewItem * myChild = firstChild(); |
220 | KOTodoViewItem *item; | 220 | KOTodoViewItem *item; |
221 | while( myChild ) { | 221 | while( myChild ) { |
222 | item = static_cast<KOTodoViewItem*>(myChild); | 222 | item = static_cast<KOTodoViewItem*>(myChild); |
223 | item->stateChange(state); | 223 | item->stateChange(state); |
224 | myChild = myChild->nextSibling(); | 224 | myChild = myChild->nextSibling(); |
225 | } | 225 | } |
226 | mTodoView->modified(true); | 226 | mTodoView->modified(true); |
227 | mTodoView->setTodoModified( mTodo ); | 227 | mTodoView->setTodoModified( mTodo ); |
228 | setMyPixmap(); | 228 | setMyPixmap(); |
229 | } | 229 | } |
230 | 230 | ||
231 | bool KOTodoViewItem::isAlternate() | 231 | bool KOTodoViewItem::isAlternate() |
232 | { | 232 | { |
233 | #ifndef KORG_NOLVALTERNATION | 233 | #ifndef KORG_NOLVALTERNATION |
234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
235 | if (lv && lv->alternateBackground().isValid()) | 235 | if (lv && lv->alternateBackground().isValid()) |
236 | { | 236 | { |
237 | KOTodoViewItem *above = 0; | 237 | KOTodoViewItem *above = 0; |
238 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); | 238 | above = dynamic_cast<KOTodoViewItem *>(itemAbove()); |
239 | m_known = above ? above->m_known : true; | 239 | m_known = above ? above->m_known : true; |
240 | if (m_known) | 240 | if (m_known) |
241 | { | 241 | { |
242 | m_odd = above ? !above->m_odd : false; | 242 | m_odd = above ? !above->m_odd : false; |
243 | } | 243 | } |
244 | else | 244 | else |
245 | { | 245 | { |
246 | KOTodoViewItem *item; | 246 | KOTodoViewItem *item; |
247 | bool previous = true; | 247 | bool previous = true; |
248 | if (QListViewItem::parent()) | 248 | if (QListViewItem::parent()) |
249 | { | 249 | { |
250 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); | 250 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()); |
251 | if (item) | 251 | if (item) |
252 | previous = item->m_odd; | 252 | previous = item->m_odd; |
253 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); | 253 | item = dynamic_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); |
254 | } | 254 | } |
255 | else | 255 | else |
256 | { | 256 | { |
257 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); | 257 | item = dynamic_cast<KOTodoViewItem *>(lv->firstChild()); |
258 | } | 258 | } |
259 | 259 | ||
260 | while(item) | 260 | while(item) |
261 | { | 261 | { |
262 | item->m_odd = previous = !previous; | 262 | item->m_odd = previous = !previous; |
263 | item->m_known = true; | 263 | item->m_known = true; |
264 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); | 264 | item = dynamic_cast<KOTodoViewItem *>(item->nextSibling()); |
265 | } | 265 | } |
266 | } | 266 | } |
267 | return m_odd; | 267 | return m_odd; |
268 | } | 268 | } |
269 | return false; | 269 | return false; |
270 | #else | 270 | #else |
271 | return false; | 271 | return false; |
272 | #endif | 272 | #endif |
273 | } | 273 | } |
274 | 274 | ||
275 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) | 275 | void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) |
276 | { | 276 | { |
277 | QColorGroup _cg = cg; | 277 | QColorGroup _cg = cg; |
278 | QColorGroup::ColorRole role; | 278 | QColorGroup::ColorRole role; |
279 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) | 279 | if ( KOPrefs::instance()->mTodoViewUsesForegroundColor ) |
280 | role = QColorGroup::Text; | 280 | role = QColorGroup::Text; |
281 | else | 281 | else |
282 | role = QColorGroup::Base; | 282 | role = QColorGroup::Base; |
283 | //#ifndef KORG_NOLVALTERNATION | 283 | //#ifndef KORG_NOLVALTERNATION |
284 | // if (isAlternate()) | 284 | // if (isAlternate()) |
285 | // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); | 285 | // _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); |
286 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; | 286 | bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; |
287 | QColor colorToSet; | 287 | QColor colorToSet; |
288 | if ( setColor ) { | 288 | if ( setColor ) { |
289 | QStringList categories = mTodo->categories(); | 289 | QStringList categories = mTodo->categories(); |
290 | QString cat = categories.first(); | 290 | QString cat = categories.first(); |
291 | if ( !cat.isEmpty()) { | 291 | if ( !cat.isEmpty()) { |
292 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); | 292 | colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); |
293 | } else | 293 | } else |
294 | setColor = false; | 294 | setColor = false; |
295 | } | 295 | } |
296 | if (mTodo->hasDueDate()) { | 296 | if (mTodo->hasDueDate()) { |
297 | if (mTodo->dtDue().date()==QDate::currentDate() && | 297 | if (mTodo->dtDue().date()==QDate::currentDate() && |
298 | !mTodo->isCompleted()) { | 298 | !mTodo->isCompleted()) { |
299 | //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); | 299 | //_cg.setColor( role , KOPrefs::instance()->mTodoDueTodayColor); |
300 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; | 300 | colorToSet = KOPrefs::instance()->mTodoDueTodayColor; |
301 | setColor = true; | 301 | setColor = true; |
302 | } | 302 | } |
303 | if (mTodo->dtDue().date() < QDate::currentDate() && | 303 | if (mTodo->dtDue().date() < QDate::currentDate() && |
304 | !mTodo->isCompleted()) { | 304 | !mTodo->isCompleted()) { |
305 | //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); | 305 | //_cg.setColor( role, KOPrefs::instance()->mTodoOverdueColor); |
306 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; | 306 | colorToSet = KOPrefs::instance()->mTodoOverdueColor; |
307 | setColor = true; | 307 | setColor = true; |
308 | } | 308 | } |
309 | } | 309 | } |
310 | 310 | ||
311 | if ( setColor ) { | 311 | if ( setColor ) { |
312 | _cg.setColor(role,colorToSet ); | 312 | _cg.setColor(role,colorToSet ); |
313 | if ( role == QColorGroup::Base) { | 313 | if ( role == QColorGroup::Base) { |
314 | int rgb = colorToSet.red(); | 314 | int rgb = colorToSet.red(); |
315 | rgb += colorToSet.blue()/2; | 315 | rgb += colorToSet.blue()/2; |
316 | rgb += colorToSet.green(); | 316 | rgb += colorToSet.green(); |
317 | if ( rgb < 200 ) | 317 | if ( rgb < 200 ) |
318 | _cg.setColor(QColorGroup::Text,Qt::white ); | 318 | _cg.setColor(QColorGroup::Text,Qt::white ); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | //#endif | 321 | //#endif |
322 | if ( column > 0 ){ | 322 | if ( column > 0 ){ |
323 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { | 323 | if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { |
324 | p->save(); | 324 | p->save(); |
325 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); | 325 | int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); |
326 | 326 | ||
327 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background | 327 | p->fillRect( 0, 0, width, height(), _cg.base() ); // background |
328 | // p->setPen(Qt::black ); //border | 328 | // p->setPen(Qt::black ); //border |
329 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling | 329 | // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling |
330 | QColor fc = KOPrefs::instance()->mHighlightColor; | 330 | QColor fc = KOPrefs::instance()->mHighlightColor; |
331 | if ( mTodo->percentComplete() == 100 ) | 331 | if ( mTodo->percentComplete() == 100 ) |
332 | fc = darkGreen; | 332 | fc = darkGreen; |
333 | p->drawRect( 2, 2, width-4, height()-4); | 333 | p->drawRect( 2, 2, width-4, height()-4); |
334 | p->fillRect( 3, 3, progress, height()-6, | 334 | p->fillRect( 3, 3, progress, height()-6, |
335 | fc ); | 335 | fc ); |
336 | p->restore(); | 336 | p->restore(); |
337 | } else { | 337 | } else { |
338 | QCheckListItem::paintCell(p, _cg, column, width, alignment); | 338 | QCheckListItem::paintCell(p, _cg, column, width, alignment); |
339 | } | 339 | } |
340 | return; | 340 | return; |
341 | } | 341 | } |
342 | 342 | ||
343 | int align = alignment; | 343 | int align = alignment; |
344 | 344 | ||
345 | if ( !p ) | 345 | if ( !p ) |
346 | return; | 346 | return; |
347 | 347 | ||
348 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); | 348 | p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); |
349 | 349 | ||
350 | QListView *lv = listView(); | 350 | QListView *lv = listView(); |
351 | if ( !lv ) | 351 | if ( !lv ) |
352 | return; | 352 | return; |
353 | int marg = 2;//lv->itemMargin(); | 353 | int marg = 2;//lv->itemMargin(); |
354 | int r = 0; | 354 | int r = 0; |
355 | QCheckListItem::Type myType = QCheckListItem::CheckBox; | 355 | QCheckListItem::Type myType = QCheckListItem::CheckBox; |
356 | int BoxSize = 20; | 356 | int BoxSize = 20; |
357 | int boxOffset = 2; | 357 | int boxOffset = 2; |
358 | int xOffset = 2; | 358 | int xOffset = 2; |
359 | if (qApp->desktop()->width() < 300 ) { | 359 | if (qApp->desktop()->width() < 300 ) { |
360 | BoxSize = 14; | 360 | BoxSize = 14; |
361 | boxOffset = -1; | 361 | boxOffset = -1; |
362 | xOffset = 1; | 362 | xOffset = 1; |
363 | // marg = 0; | 363 | // marg = 0; |
364 | } | 364 | } |
365 | if ( height() < BoxSize ) { | 365 | if ( height() < BoxSize ) { |
366 | boxOffset = boxOffset - ((BoxSize - height())/2) ; | 366 | boxOffset = boxOffset - ((BoxSize - height())/2) ; |
367 | // qDebug("boxOffset %d height %d", boxOffset, height() ); | 367 | // qDebug("boxOffset %d height %d", boxOffset, height() ); |
368 | BoxSize = height(); | 368 | BoxSize = height(); |
369 | 369 | ||
370 | } | 370 | } |
371 | //bool winStyle = lv->style() == WindowsStyle; | 371 | //bool winStyle = lv->style() == WindowsStyle; |
372 | 372 | ||
373 | int lineStart = 5; | 373 | int lineStart = 5; |
374 | if ( myType == Controller ) { | 374 | if ( myType == Controller ) { |
375 | if ( !pixmap( 0 ) ) | 375 | if ( !pixmap( 0 ) ) |
376 | r += BoxSize + 4; | 376 | r += BoxSize + 4; |
377 | } else { | 377 | } else { |
378 | ASSERT( lv ); //### | 378 | ASSERT( lv ); //### |
379 | //QFontMetrics fm( lv->font() ); | 379 | //QFontMetrics fm( lv->font() ); |
380 | //int d = fm.height(); | 380 | //int d = fm.height(); |
381 | int x = 0; | 381 | int x = 0; |
382 | int y = (height() - BoxSize) / 2; | 382 | int y = (height() - BoxSize) / 2; |
383 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); | 383 | //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); |
384 | if ( myType == CheckBox ) { | 384 | if ( myType == CheckBox ) { |
385 | if ( isEnabled() ) | 385 | if ( isEnabled() ) |
386 | p->setPen( QPen( _cg.text(), 1 ) ); | 386 | p->setPen( QPen( _cg.text(), 1 ) ); |
387 | else | 387 | else |
388 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); | 388 | p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); |
389 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); | 389 | p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); |
390 | lineStart = x+marg; | 390 | lineStart = x+marg; |
391 | ///////////////////// | 391 | ///////////////////// |
392 | x++; | 392 | x++; |
393 | y++; | 393 | y++; |
394 | if ( isOn() ) { | 394 | if ( isOn() ) { |
395 | QPointArray a( 7*2 ); | 395 | QPointArray a( 7*2 ); |
396 | int i, xx, yy; | 396 | int i, xx, yy; |
397 | xx = x+xOffset+marg+(boxOffset/2); | 397 | xx = x+xOffset+marg+(boxOffset/2); |
398 | yy = y+5+boxOffset; | 398 | yy = y+5+boxOffset; |
399 | for ( i=0; i<3; i++ ) { | 399 | for ( i=0; i<3; i++ ) { |
400 | a.setPoint( 2*i, xx, yy ); | 400 | a.setPoint( 2*i, xx, yy ); |
401 | a.setPoint( 2*i+1, xx, yy+2 ); | 401 | a.setPoint( 2*i+1, xx, yy+2 ); |
402 | // qDebug(" "); | 402 | // qDebug(" "); |
403 | xx++; yy++; | 403 | xx++; yy++; |
404 | } | 404 | } |
405 | yy -= 2; | 405 | yy -= 2; |
406 | for ( i=3; i<7; i++ ) { | 406 | for ( i=3; i<7; i++ ) { |
407 | a.setPoint( 2*i, xx, yy ); | 407 | a.setPoint( 2*i, xx, yy ); |
408 | a.setPoint( 2*i+1, xx, yy+2 ); | 408 | a.setPoint( 2*i+1, xx, yy+2 ); |
409 | xx++; yy--; | 409 | xx++; yy--; |
410 | } | 410 | } |
411 | p->setPen( darkGreen ); | 411 | p->setPen( darkGreen ); |
412 | p->drawLineSegments( a ); | 412 | p->drawLineSegments( a ); |
413 | } | 413 | } |
414 | //////////////////////// | 414 | //////////////////////// |
415 | } | 415 | } |
416 | r += BoxSize + 4; | 416 | r += BoxSize + 4; |
417 | } | 417 | } |
418 | 418 | ||
419 | p->translate( r, 0 ); | 419 | p->translate( r, 0 ); |
420 | p->setPen( QPen( _cg.text() ) ); | 420 | p->setPen( QPen( _cg.text() ) ); |
421 | QListViewItem::paintCell( p, _cg, column, width - r, align ); | 421 | QListViewItem::paintCell( p, _cg, column, width - r, align ); |
422 | if ( mTodo->cancelled () ) { | 422 | if ( mTodo->cancelled () ) { |
423 | p->setPen( black ); | 423 | p->setPen( black ); |
424 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); | 424 | QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); |
425 | int wid = br.width() +lineStart; | 425 | int wid = br.width() +lineStart; |
426 | if ( wid > width-3 ) | 426 | if ( wid > width-3 ) |
427 | wid = width-3; | 427 | wid = width-3; |
428 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); | 428 | p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); |
429 | 429 | ||
430 | } | 430 | } |
431 | 431 | ||
432 | } | 432 | } |