author | zautrix <zautrix> | 2005-03-19 22:56:08 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-19 22:56:08 (UTC) |
commit | 84c18843bbd1203878367572d3a6800a0586c7f1 (patch) (unidiff) | |
tree | 9f58b7356ea700d47e6ec84fb4a462a666a24049 | |
parent | 39b719bdc75d95913c3aaf9a03aaa57b1161cc61 (diff) | |
download | kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.zip kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.gz kdepimpi-84c18843bbd1203878367572d3a6800a0586c7f1.tar.bz2 |
mochn fix
-rw-r--r-- | korganizer/calendarview.cpp | 1 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 20 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 7 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 5 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 2 |
5 files changed, 24 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 29c530b..9acbbb1 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,4046 +1,4045 @@ | |||
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 "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | class KOBeamPrefs : public QDialog | 142 | class KOBeamPrefs : public QDialog |
143 | { | 143 | { |
144 | public: | 144 | public: |
145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
146 | QDialog( parent, name, true ) | 146 | QDialog( parent, name, true ) |
147 | { | 147 | { |
148 | setCaption( i18n("Beam Options") ); | 148 | setCaption( i18n("Beam Options") ); |
149 | QVBoxLayout* lay = new QVBoxLayout( this ); | 149 | QVBoxLayout* lay = new QVBoxLayout( this ); |
150 | lay->setSpacing( 3 ); | 150 | lay->setSpacing( 3 ); |
151 | lay->setMargin( 3 ); | 151 | lay->setMargin( 3 ); |
152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
153 | lay->addWidget( format ); | 153 | lay->addWidget( format ); |
154 | format->setExclusive ( true ) ; | 154 | format->setExclusive ( true ) ; |
155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
156 | lay->addWidget( time ); time->setExclusive ( true ) ; | 156 | lay->addWidget( time ); time->setExclusive ( true ) ; |
157 | vcal = new QRadioButton(" vCalendar ", format ); | 157 | vcal = new QRadioButton(" vCalendar ", format ); |
158 | ical = new QRadioButton(" iCalendar ", format ); | 158 | ical = new QRadioButton(" iCalendar ", format ); |
159 | vcal->setChecked( true ); | 159 | vcal->setChecked( true ); |
160 | tz = new QRadioButton(i18n(" With timezone "), time ); | 160 | tz = new QRadioButton(i18n(" With timezone "), time ); |
161 | local = new QRadioButton(i18n(" Local time "), time ); | 161 | local = new QRadioButton(i18n(" Local time "), time ); |
162 | tz->setChecked( true ); | 162 | tz->setChecked( true ); |
163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
164 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
166 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
169 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
173 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
174 | private: | 174 | private: |
175 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
176 | }; | 176 | }; |
177 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
178 | { | 178 | { |
179 | public: | 179 | public: |
180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
181 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
182 | { | 182 | { |
183 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
184 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
185 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
186 | lay->setMargin( 3 ); | 186 | lay->setMargin( 3 ); |
187 | 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 | 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 ); |
188 | lay->addWidget( lab ); | 188 | lay->addWidget( lab ); |
189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
190 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
191 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
194 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
196 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
198 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
201 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
205 | private: | 205 | private: |
206 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
212 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
213 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
214 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
215 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
216 | { | 216 | { |
217 | 217 | ||
218 | mEventEditor = 0; | 218 | mEventEditor = 0; |
219 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
220 | 220 | ||
221 | init(); | 221 | init(); |
222 | } | 222 | } |
223 | 223 | ||
224 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
225 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
226 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
227 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
228 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
229 | { | 229 | { |
230 | 230 | ||
231 | mEventEditor = 0; | 231 | mEventEditor = 0; |
232 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
233 | init(); | 233 | init(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void CalendarView::init() | 236 | void CalendarView::init() |
237 | { | 237 | { |
238 | 238 | ||
239 | setFocusPolicy ( WheelFocus ); | 239 | setFocusPolicy ( WheelFocus ); |
240 | mViewerCallerIsSearchDialog = false; | 240 | mViewerCallerIsSearchDialog = false; |
241 | mBlockShowDates = false; | 241 | mBlockShowDates = false; |
242 | beamDialog = new KOBeamPrefs(); | 242 | beamDialog = new KOBeamPrefs(); |
243 | mDatePickerMode = 0; | 243 | mDatePickerMode = 0; |
244 | mCurrentSyncDevice = ""; | 244 | mCurrentSyncDevice = ""; |
245 | writeLocale(); | 245 | writeLocale(); |
246 | mViewManager = new KOViewManager( this ); | 246 | mViewManager = new KOViewManager( this ); |
247 | mDialogManager = new KODialogManager( this ); | 247 | mDialogManager = new KODialogManager( this ); |
248 | mEventViewerDialog = 0; | 248 | mEventViewerDialog = 0; |
249 | mModified = false; | 249 | mModified = false; |
250 | mReadOnly = false; | 250 | mReadOnly = false; |
251 | mSelectedIncidence = 0; | 251 | mSelectedIncidence = 0; |
252 | mCalPrinter = 0; | 252 | mCalPrinter = 0; |
253 | mFilters.setAutoDelete(true); | 253 | mFilters.setAutoDelete(true); |
254 | 254 | ||
255 | mCalendar->registerObserver( this ); | 255 | mCalendar->registerObserver( this ); |
256 | // TODO: Make sure that view is updated, when calendar is changed. | 256 | // TODO: Make sure that view is updated, when calendar is changed. |
257 | 257 | ||
258 | mStorage = new FileStorage( mCalendar ); | 258 | mStorage = new FileStorage( mCalendar ); |
259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
260 | 260 | ||
261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
262 | #ifndef KORG_NOSPLITTER | 262 | #ifndef KORG_NOSPLITTER |
263 | // create the main layout frames. | 263 | // create the main layout frames. |
264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
265 | topLayout->addWidget(mPanner); | 265 | topLayout->addWidget(mPanner); |
266 | 266 | ||
267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
268 | "CalendarView::LeftFrame"); | 268 | "CalendarView::LeftFrame"); |
269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
270 | 270 | ||
271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
272 | "CalendarView::DateNavigator" ); | 272 | "CalendarView::DateNavigator" ); |
273 | 273 | ||
274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
276 | mTodoList->setNavigator( mNavigator ); | 276 | mTodoList->setNavigator( mNavigator ); |
277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
278 | 278 | ||
279 | #ifdef KORG_NORESOURCEVIEW | 279 | #ifdef KORG_NORESOURCEVIEW |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | #else | 281 | #else |
282 | if ( mResourceManager ) { | 282 | if ( mResourceManager ) { |
283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
284 | mResourceView->updateView(); | 284 | mResourceView->updateView(); |
285 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 285 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
286 | SLOT( updateView() ) ); | 286 | SLOT( updateView() ) ); |
287 | } else { | 287 | } else { |
288 | mResourceView = 0; | 288 | mResourceView = 0; |
289 | } | 289 | } |
290 | #endif | 290 | #endif |
291 | QWidget *rightBox = new QWidget( mPanner ); | 291 | QWidget *rightBox = new QWidget( mPanner ); |
292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
293 | 293 | ||
294 | mRightFrame = new QWidgetStack( rightBox ); | 294 | mRightFrame = new QWidgetStack( rightBox ); |
295 | rightLayout->addWidget( mRightFrame, 1 ); | 295 | rightLayout->addWidget( mRightFrame, 1 ); |
296 | 296 | ||
297 | mLeftFrame = mLeftSplitter; | 297 | mLeftFrame = mLeftSplitter; |
298 | #else | 298 | #else |
299 | QWidget *mainBox = new QWidget( this ); | 299 | QWidget *mainBox = new QWidget( this ); |
300 | //QWidget *leftFrame = new QWidget( mainBox ); | 300 | //QWidget *leftFrame = new QWidget( mainBox ); |
301 | QBoxLayout * mainBoxLayout; | 301 | QBoxLayout * mainBoxLayout; |
302 | if ( KOPrefs::instance()->mVerticalScreen ) { | 302 | if ( KOPrefs::instance()->mVerticalScreen ) { |
303 | mainBoxLayout = new QVBoxLayout(mainBox); | 303 | mainBoxLayout = new QVBoxLayout(mainBox); |
304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
305 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);; | 305 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);; |
306 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); | 306 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); |
307 | } else { | 307 | } else { |
308 | mainBoxLayout = new QHBoxLayout(mainBox); | 308 | mainBoxLayout = new QHBoxLayout(mainBox); |
309 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 309 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
310 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; | 310 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; |
311 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 311 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
312 | } | 312 | } |
313 | //QBoxLayout * leftFrameLayout; | 313 | //QBoxLayout * leftFrameLayout; |
314 | topLayout->addWidget( mainBox ); | 314 | topLayout->addWidget( mainBox ); |
315 | mainBoxLayout->addWidget (mLeftFrame); | 315 | mainBoxLayout->addWidget (mLeftFrame); |
316 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 316 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
317 | "CalendarView::DateNavigator" ); | 317 | "CalendarView::DateNavigator" ); |
318 | #if 0 | 318 | #if 0 |
319 | // FIXME | 319 | // FIXME |
320 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 320 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
321 | "CalendarView::DateNavigator", QDate::currentDate()); | 321 | "CalendarView::DateNavigator", QDate::currentDate()); |
322 | #endif | 322 | #endif |
323 | // mDateNavigator->blockSignals( true ); | 323 | // mDateNavigator->blockSignals( true ); |
324 | //leftFrameLayout->addWidget( mDateNavigator ); | 324 | //leftFrameLayout->addWidget( mDateNavigator ); |
325 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 325 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
326 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 326 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
327 | mTodoList->setNavigator( mNavigator ); | 327 | mTodoList->setNavigator( mNavigator ); |
328 | #if 0 | 328 | #if 0 |
329 | if ( QApplication::desktop()->width() < 480 ) { | 329 | if ( QApplication::desktop()->width() < 480 ) { |
330 | leftFrameLayout->addWidget(mFilterView); | 330 | leftFrameLayout->addWidget(mFilterView); |
331 | leftFrameLayout->addWidget(mTodoList, 2 ); | 331 | leftFrameLayout->addWidget(mTodoList, 2 ); |
332 | 332 | ||
333 | } else { | 333 | } else { |
334 | leftFrameLayout->addWidget(mTodoList,2 ); | 334 | leftFrameLayout->addWidget(mTodoList,2 ); |
335 | leftFrameLayout->addWidget(mFilterView ); | 335 | leftFrameLayout->addWidget(mFilterView ); |
336 | } | 336 | } |
337 | #endif | 337 | #endif |
338 | mFilterView->hide(); | 338 | mFilterView->hide(); |
339 | QWidget *rightBox = new QWidget( mainBox ); | 339 | QWidget *rightBox = new QWidget( mainBox ); |
340 | mainBoxLayout->addWidget ( rightBox, 10 ); | 340 | mainBoxLayout->addWidget ( rightBox, 10 ); |
341 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 341 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
342 | mRightFrame = new QWidgetStack( rightBox ); | 342 | mRightFrame = new QWidgetStack( rightBox ); |
343 | rightLayout->addWidget( mRightFrame, 10 ); | 343 | rightLayout->addWidget( mRightFrame, 10 ); |
344 | 344 | ||
345 | //mLeftFrame = (QWidget *)leftFrame; | 345 | //mLeftFrame = (QWidget *)leftFrame; |
346 | if ( KOPrefs::instance()->mVerticalScreen ) { | 346 | if ( KOPrefs::instance()->mVerticalScreen ) { |
347 | mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 347 | mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
348 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 348 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
349 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 349 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
350 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 350 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
351 | } else { | 351 | } else { |
352 | mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 352 | mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
353 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 353 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
354 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 354 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
355 | } | 355 | } |
356 | if ( !KOPrefs::instance()->mShowDateNavigator) | 356 | if ( !KOPrefs::instance()->mShowDateNavigator) |
357 | mDateNavigator->hide(); | 357 | mDateNavigator->hide(); |
358 | //qDebug("Calendarview Size %d %d ", width(), height()); | 358 | //qDebug("Calendarview Size %d %d ", width(), height()); |
359 | #endif | 359 | #endif |
360 | 360 | ||
361 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 361 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
362 | SLOT( showDates( const KCal::DateList & ) ) ); | 362 | SLOT( showDates( const KCal::DateList & ) ) ); |
363 | 363 | ||
364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
365 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 365 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
366 | 366 | ||
367 | 367 | ||
368 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 368 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
369 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 369 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
370 | 370 | ||
371 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 371 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
372 | mNavigator, SLOT( selectPreviousYear() ) ); | 372 | mNavigator, SLOT( selectPreviousYear() ) ); |
373 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 373 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
374 | mNavigator, SLOT( selectNextYear() ) ); | 374 | mNavigator, SLOT( selectNextYear() ) ); |
375 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 375 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
376 | mNavigator, SLOT( selectPreviousMonth() ) ); | 376 | mNavigator, SLOT( selectPreviousMonth() ) ); |
377 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 377 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
378 | mNavigator, SLOT( selectNextMonth() ) ); | 378 | mNavigator, SLOT( selectNextMonth() ) ); |
379 | 379 | ||
380 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 380 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
381 | mNavigator, SLOT( selectPrevious() ) ); | 381 | mNavigator, SLOT( selectPrevious() ) ); |
382 | connect( mDateNavigator, SIGNAL( goNext() ), | 382 | connect( mDateNavigator, SIGNAL( goNext() ), |
383 | mNavigator, SLOT( selectNext() ) ); | 383 | mNavigator, SLOT( selectNext() ) ); |
384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
386 | 386 | ||
387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
389 | #if 0 | 389 | #if 0 |
390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
391 | SLOT( incidenceAdded( Incidence *) ) ); | 391 | SLOT( incidenceAdded( Incidence *) ) ); |
392 | #endif | 392 | #endif |
393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
394 | 394 | ||
395 | connect( this, SIGNAL( configChanged() ), | 395 | connect( this, SIGNAL( configChanged() ), |
396 | mDateNavigator, SLOT( updateConfig() ) ); | 396 | mDateNavigator, SLOT( updateConfig() ) ); |
397 | 397 | ||
398 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 398 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
399 | SLOT( newTodo() ) ); | 399 | SLOT( newTodo() ) ); |
400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
401 | SLOT( newSubTodo( Todo * ) ) ); | 401 | SLOT( newSubTodo( Todo * ) ) ); |
402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
403 | SLOT( editTodo( Todo * ) ) ); | 403 | SLOT( editTodo( Todo * ) ) ); |
404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
405 | SLOT( showTodo( Todo *) ) ); | 405 | SLOT( showTodo( Todo *) ) ); |
406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
407 | SLOT( deleteTodo( Todo *) ) ); | 407 | SLOT( deleteTodo( Todo *) ) ); |
408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
410 | SLOT( purgeCompleted() ) ); | 410 | SLOT( purgeCompleted() ) ); |
411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
412 | SIGNAL( todoModified( Todo *, int ) ) ); | 412 | SIGNAL( todoModified( Todo *, int ) ) ); |
413 | 413 | ||
414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
417 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 417 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
418 | 418 | ||
419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
420 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 420 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
422 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 422 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
423 | 423 | ||
424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
425 | this, SLOT ( todo_unsub( Todo * ) ) ); | 425 | this, SLOT ( todo_unsub( Todo * ) ) ); |
426 | 426 | ||
427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
430 | SLOT( updateTodo( Todo *, int ) ) ); | 430 | SLOT( updateTodo( Todo *, int ) ) ); |
431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
433 | 433 | ||
434 | 434 | ||
435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
439 | 439 | ||
440 | 440 | ||
441 | 441 | ||
442 | 442 | ||
443 | 443 | ||
444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
445 | SLOT(checkClipboard())); | 445 | SLOT(checkClipboard())); |
446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
447 | SLOT( processTodoListSelection( Incidence * ) ) ); | 447 | SLOT( processTodoListSelection( Incidence * ) ) ); |
448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
449 | 449 | ||
450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
451 | 451 | ||
452 | mDateFrame = new QVBox(0,0,WType_Popup); | 452 | mDateFrame = new QVBox(0,0,WType_Popup); |
453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
455 | mDateFrame->setLineWidth(3); | 455 | mDateFrame->setLineWidth(3); |
456 | mDateFrame->hide(); | 456 | mDateFrame->hide(); |
457 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 457 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
459 | 459 | ||
460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
461 | 461 | ||
462 | mEventEditor = mDialogManager->getEventEditor(); | 462 | mEventEditor = mDialogManager->getEventEditor(); |
463 | mTodoEditor = mDialogManager->getTodoEditor(); | 463 | mTodoEditor = mDialogManager->getTodoEditor(); |
464 | 464 | ||
465 | mFlagEditDescription = false; | 465 | mFlagEditDescription = false; |
466 | 466 | ||
467 | mSuspendTimer = new QTimer( this ); | 467 | mSuspendTimer = new QTimer( this ); |
468 | mAlarmTimer = new QTimer( this ); | 468 | mAlarmTimer = new QTimer( this ); |
469 | mRecheckAlarmTimer = new QTimer( this ); | 469 | mRecheckAlarmTimer = new QTimer( this ); |
470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
473 | mAlarmDialog = new AlarmDialog( this ); | 473 | mAlarmDialog = new AlarmDialog( this ); |
474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
475 | mAlarmDialog->setServerNotification( false ); | 475 | mAlarmDialog->setServerNotification( false ); |
476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
477 | 477 | ||
478 | 478 | ||
479 | #ifndef DESKTOP_VERSION | 479 | #ifndef DESKTOP_VERSION |
480 | //US listen for arriving address resultsets | 480 | //US listen for arriving address resultsets |
481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
483 | #endif | 483 | #endif |
484 | mDateNavigator->setCalendar( mCalendar ); | 484 | mDateNavigator->setCalendar( mCalendar ); |
485 | } | 485 | } |
486 | 486 | ||
487 | 487 | ||
488 | CalendarView::~CalendarView() | 488 | CalendarView::~CalendarView() |
489 | { | 489 | { |
490 | // kdDebug() << "~CalendarView()" << endl; | 490 | // kdDebug() << "~CalendarView()" << endl; |
491 | //qDebug("CalendarView::~CalendarView() "); | 491 | //qDebug("CalendarView::~CalendarView() "); |
492 | delete mDialogManager; | 492 | delete mDialogManager; |
493 | delete mViewManager; | 493 | delete mViewManager; |
494 | delete mStorage; | 494 | delete mStorage; |
495 | delete mDateFrame ; | 495 | delete mDateFrame ; |
496 | delete beamDialog; | 496 | delete beamDialog; |
497 | delete mEventViewerDialog; | 497 | delete mEventViewerDialog; |
498 | //kdDebug() << "~CalendarView() done" << endl; | 498 | //kdDebug() << "~CalendarView() done" << endl; |
499 | } | 499 | } |
500 | 500 | ||
501 | void CalendarView::showDay( QDate d ) | 501 | void CalendarView::showDay( QDate d ) |
502 | { | 502 | { |
503 | dateNavigator()->blockSignals( true ); | 503 | dateNavigator()->blockSignals( true ); |
504 | dateNavigator()->selectDate( d ); | 504 | dateNavigator()->selectDate( d ); |
505 | dateNavigator()->blockSignals( false ); | 505 | dateNavigator()->blockSignals( false ); |
506 | mViewManager->showDayView(); | 506 | mViewManager->showDayView(); |
507 | //dateNavigator()->selectDate( d ); | 507 | //dateNavigator()->selectDate( d ); |
508 | } | 508 | } |
509 | void CalendarView::timerAlarm() | 509 | void CalendarView::timerAlarm() |
510 | { | 510 | { |
511 | //qDebug("CalendarView::timerAlarm() "); | 511 | //qDebug("CalendarView::timerAlarm() "); |
512 | computeAlarm(mAlarmNotification ); | 512 | computeAlarm(mAlarmNotification ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void CalendarView::suspendAlarm() | 515 | void CalendarView::suspendAlarm() |
516 | { | 516 | { |
517 | //qDebug(" CalendarView::suspendAlarm() "); | 517 | //qDebug(" CalendarView::suspendAlarm() "); |
518 | computeAlarm(mSuspendAlarmNotification ); | 518 | computeAlarm(mSuspendAlarmNotification ); |
519 | 519 | ||
520 | } | 520 | } |
521 | 521 | ||
522 | void CalendarView::startAlarm( QString mess , QString filename) | 522 | void CalendarView::startAlarm( QString mess , QString filename) |
523 | { | 523 | { |
524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
526 | 526 | ||
527 | } | 527 | } |
528 | 528 | ||
529 | void CalendarView::checkNextTimerAlarm() | 529 | void CalendarView::checkNextTimerAlarm() |
530 | { | 530 | { |
531 | mCalendar->checkAlarmForIncidence( 0, true ); | 531 | mCalendar->checkAlarmForIncidence( 0, true ); |
532 | } | 532 | } |
533 | 533 | ||
534 | void CalendarView::computeAlarm( QString msg ) | 534 | void CalendarView::computeAlarm( QString msg ) |
535 | { | 535 | { |
536 | 536 | ||
537 | QString mess = msg; | 537 | QString mess = msg; |
538 | QString mAlarmMessage = mess.mid( 9 ); | 538 | QString mAlarmMessage = mess.mid( 9 ); |
539 | QString filename = MainWindow::resourcePath(); | 539 | QString filename = MainWindow::resourcePath(); |
540 | filename += "koalarm.wav"; | 540 | filename += "koalarm.wav"; |
541 | QString tempfilename; | 541 | QString tempfilename; |
542 | if ( mess.left( 13 ) == "suspend_alarm") { | 542 | if ( mess.left( 13 ) == "suspend_alarm") { |
543 | bool error = false; | 543 | bool error = false; |
544 | int len = mess.mid( 13 ).find("+++"); | 544 | int len = mess.mid( 13 ).find("+++"); |
545 | if ( len < 2 ) | 545 | if ( len < 2 ) |
546 | error = true; | 546 | error = true; |
547 | else { | 547 | else { |
548 | tempfilename = mess.mid( 13, len ); | 548 | tempfilename = mess.mid( 13, len ); |
549 | if ( !QFile::exists( tempfilename ) ) | 549 | if ( !QFile::exists( tempfilename ) ) |
550 | error = true; | 550 | error = true; |
551 | } | 551 | } |
552 | if ( ! error ) { | 552 | if ( ! error ) { |
553 | filename = tempfilename; | 553 | filename = tempfilename; |
554 | } | 554 | } |
555 | mAlarmMessage = mess.mid( 13+len+3 ); | 555 | mAlarmMessage = mess.mid( 13+len+3 ); |
556 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 556 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
557 | startAlarm( mAlarmMessage, filename); | 557 | startAlarm( mAlarmMessage, filename); |
558 | return; | 558 | return; |
559 | } | 559 | } |
560 | if ( mess.left( 11 ) == "timer_alarm") { | 560 | if ( mess.left( 11 ) == "timer_alarm") { |
561 | //mTimerTime = 0; | 561 | //mTimerTime = 0; |
562 | startAlarm( mess.mid( 11 ), filename ); | 562 | startAlarm( mess.mid( 11 ), filename ); |
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | if ( mess.left( 10 ) == "proc_alarm") { | 565 | if ( mess.left( 10 ) == "proc_alarm") { |
566 | bool error = false; | 566 | bool error = false; |
567 | int len = mess.mid( 10 ).find("+++"); | 567 | int len = mess.mid( 10 ).find("+++"); |
568 | if ( len < 2 ) | 568 | if ( len < 2 ) |
569 | error = true; | 569 | error = true; |
570 | else { | 570 | else { |
571 | tempfilename = mess.mid( 10, len ); | 571 | tempfilename = mess.mid( 10, len ); |
572 | if ( !QFile::exists( tempfilename ) ) | 572 | if ( !QFile::exists( tempfilename ) ) |
573 | error = true; | 573 | error = true; |
574 | } | 574 | } |
575 | if ( error ) { | 575 | if ( error ) { |
576 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 576 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
577 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 577 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
578 | } else { | 578 | } else { |
579 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 579 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
580 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 580 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
581 | #ifndef _WIN32_ | 581 | #ifndef _WIN32_ |
582 | if ( vfork () == 0 ) { | 582 | if ( vfork () == 0 ) { |
583 | execl ( tempfilename.latin1(), 0 ); | 583 | execl ( tempfilename.latin1(), 0 ); |
584 | return; | 584 | return; |
585 | } | 585 | } |
586 | #else | 586 | #else |
587 | QProcess* p = new QProcess(); | 587 | QProcess* p = new QProcess(); |
588 | p->addArgument( tempfilename.latin1() ); | 588 | p->addArgument( tempfilename.latin1() ); |
589 | p->start(); | 589 | p->start(); |
590 | return; | 590 | return; |
591 | #endif | 591 | #endif |
592 | 592 | ||
593 | return; | 593 | return; |
594 | } | 594 | } |
595 | 595 | ||
596 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 596 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
597 | } | 597 | } |
598 | if ( mess.left( 11 ) == "audio_alarm") { | 598 | if ( mess.left( 11 ) == "audio_alarm") { |
599 | bool error = false; | 599 | bool error = false; |
600 | int len = mess.mid( 11 ).find("+++"); | 600 | int len = mess.mid( 11 ).find("+++"); |
601 | if ( len < 2 ) | 601 | if ( len < 2 ) |
602 | error = true; | 602 | error = true; |
603 | else { | 603 | else { |
604 | tempfilename = mess.mid( 11, len ); | 604 | tempfilename = mess.mid( 11, len ); |
605 | if ( !QFile::exists( tempfilename ) ) | 605 | if ( !QFile::exists( tempfilename ) ) |
606 | error = true; | 606 | error = true; |
607 | } | 607 | } |
608 | if ( ! error ) { | 608 | if ( ! error ) { |
609 | filename = tempfilename; | 609 | filename = tempfilename; |
610 | } | 610 | } |
611 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 611 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
612 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 612 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
613 | } | 613 | } |
614 | if ( mess.left( 9 ) == "cal_alarm") { | 614 | if ( mess.left( 9 ) == "cal_alarm") { |
615 | mAlarmMessage = mess.mid( 9 ) ; | 615 | mAlarmMessage = mess.mid( 9 ) ; |
616 | } | 616 | } |
617 | 617 | ||
618 | startAlarm( mAlarmMessage, filename ); | 618 | startAlarm( mAlarmMessage, filename ); |
619 | 619 | ||
620 | 620 | ||
621 | } | 621 | } |
622 | 622 | ||
623 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 623 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
624 | { | 624 | { |
625 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 625 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
626 | 626 | ||
627 | mSuspendAlarmNotification = noti; | 627 | mSuspendAlarmNotification = noti; |
628 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 628 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
629 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 629 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
630 | mSuspendTimer->start( ms , true ); | 630 | mSuspendTimer->start( ms , true ); |
631 | 631 | ||
632 | } | 632 | } |
633 | 633 | ||
634 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 634 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
635 | { | 635 | { |
636 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 636 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
637 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 637 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
638 | #ifndef DESKTOP_VERSION | 638 | #ifndef DESKTOP_VERSION |
639 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 639 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
640 | #endif | 640 | #endif |
641 | return; | 641 | return; |
642 | } | 642 | } |
643 | int maxSec; | 643 | int maxSec; |
644 | //maxSec = 5; //testing only | 644 | //maxSec = 5; //testing only |
645 | maxSec = 86400+3600; // one day+1hour | 645 | maxSec = 86400+3600; // one day+1hour |
646 | mAlarmNotification = noti; | 646 | mAlarmNotification = noti; |
647 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 647 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
648 | if ( sec > maxSec ) { | 648 | if ( sec > maxSec ) { |
649 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 649 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
650 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 650 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
651 | return; | 651 | return; |
652 | } else { | 652 | } else { |
653 | mRecheckAlarmTimer->stop(); | 653 | mRecheckAlarmTimer->stop(); |
654 | } | 654 | } |
655 | //qDebug("Alarm timer started with secs: %d ", sec); | 655 | //qDebug("Alarm timer started with secs: %d ", sec); |
656 | mAlarmTimer->start( sec *1000 , true ); | 656 | mAlarmTimer->start( sec *1000 , true ); |
657 | 657 | ||
658 | } | 658 | } |
659 | // called by mRecheckAlarmTimer to get next alarm | 659 | // called by mRecheckAlarmTimer to get next alarm |
660 | // we need this, because a QTimer has only a max range of 25 days | 660 | // we need this, because a QTimer has only a max range of 25 days |
661 | void CalendarView::recheckTimerAlarm() | 661 | void CalendarView::recheckTimerAlarm() |
662 | { | 662 | { |
663 | mAlarmTimer->stop(); | 663 | mAlarmTimer->stop(); |
664 | mRecheckAlarmTimer->stop(); | 664 | mRecheckAlarmTimer->stop(); |
665 | mCalendar->checkAlarmForIncidence( 0, true ); | 665 | mCalendar->checkAlarmForIncidence( 0, true ); |
666 | } | 666 | } |
667 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 667 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
668 | { | 668 | { |
669 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 669 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
670 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 670 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
671 | #ifndef DESKTOP_VERSION | 671 | #ifndef DESKTOP_VERSION |
672 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 672 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
673 | #endif | 673 | #endif |
674 | return; | 674 | return; |
675 | } | 675 | } |
676 | mAlarmTimer->stop(); | 676 | mAlarmTimer->stop(); |
677 | } | 677 | } |
678 | void CalendarView::selectWeekNum ( int num ) | 678 | void CalendarView::selectWeekNum ( int num ) |
679 | { | 679 | { |
680 | dateNavigator()->blockSignals( true ); | 680 | dateNavigator()->blockSignals( true ); |
681 | dateNavigator()->selectWeek( num ); | 681 | dateNavigator()->selectWeek( num ); |
682 | dateNavigator()->blockSignals( false ); | 682 | dateNavigator()->blockSignals( false ); |
683 | mViewManager->showWeekView(); | 683 | mViewManager->showWeekView(); |
684 | } | 684 | } |
685 | KOViewManager *CalendarView::viewManager() | 685 | KOViewManager *CalendarView::viewManager() |
686 | { | 686 | { |
687 | return mViewManager; | 687 | return mViewManager; |
688 | } | 688 | } |
689 | 689 | ||
690 | KODialogManager *CalendarView::dialogManager() | 690 | KODialogManager *CalendarView::dialogManager() |
691 | { | 691 | { |
692 | return mDialogManager; | 692 | return mDialogManager; |
693 | } | 693 | } |
694 | 694 | ||
695 | QDate CalendarView::startDate() | 695 | QDate CalendarView::startDate() |
696 | { | 696 | { |
697 | DateList dates = mNavigator->selectedDates(); | 697 | DateList dates = mNavigator->selectedDates(); |
698 | 698 | ||
699 | return dates.first(); | 699 | return dates.first(); |
700 | } | 700 | } |
701 | 701 | ||
702 | QDate CalendarView::endDate() | 702 | QDate CalendarView::endDate() |
703 | { | 703 | { |
704 | DateList dates = mNavigator->selectedDates(); | 704 | DateList dates = mNavigator->selectedDates(); |
705 | 705 | ||
706 | return dates.last(); | 706 | return dates.last(); |
707 | } | 707 | } |
708 | 708 | ||
709 | 709 | ||
710 | void CalendarView::createPrinter() | 710 | void CalendarView::createPrinter() |
711 | { | 711 | { |
712 | #ifndef KORG_NOPRINTER | 712 | #ifndef KORG_NOPRINTER |
713 | if (!mCalPrinter) { | 713 | if (!mCalPrinter) { |
714 | mCalPrinter = new CalPrinter(this, mCalendar); | 714 | mCalPrinter = new CalPrinter(this, mCalendar); |
715 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 715 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
716 | } | 716 | } |
717 | #endif | 717 | #endif |
718 | } | 718 | } |
719 | 719 | ||
720 | 720 | ||
721 | //KOPrefs::instance()->mWriteBackFile | 721 | //KOPrefs::instance()->mWriteBackFile |
722 | //KOPrefs::instance()->mWriteBackExistingOnly | 722 | //KOPrefs::instance()->mWriteBackExistingOnly |
723 | 723 | ||
724 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 724 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
725 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 725 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
726 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 726 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
727 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 727 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
728 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 728 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
729 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 729 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
730 | 730 | ||
731 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 731 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
732 | { | 732 | { |
733 | 733 | ||
734 | // 0 equal | 734 | // 0 equal |
735 | // 1 take local | 735 | // 1 take local |
736 | // 2 take remote | 736 | // 2 take remote |
737 | // 3 cancel | 737 | // 3 cancel |
738 | QDateTime lastSync = mLastCalendarSync; | 738 | QDateTime lastSync = mLastCalendarSync; |
739 | QDateTime localMod = local->lastModified(); | 739 | QDateTime localMod = local->lastModified(); |
740 | QDateTime remoteMod = remote->lastModified(); | 740 | QDateTime remoteMod = remote->lastModified(); |
741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
742 | bool remCh, locCh; | 742 | bool remCh, locCh; |
743 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 743 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
744 | //if ( remCh ) | 744 | //if ( remCh ) |
745 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 745 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
746 | locCh = ( localMod > mLastCalendarSync ); | 746 | locCh = ( localMod > mLastCalendarSync ); |
747 | if ( !remCh && ! locCh ) { | 747 | if ( !remCh && ! locCh ) { |
748 | //qDebug("both not changed "); | 748 | //qDebug("both not changed "); |
749 | lastSync = localMod.addDays(1); | 749 | lastSync = localMod.addDays(1); |
750 | if ( mode <= SYNC_PREF_ASK ) | 750 | if ( mode <= SYNC_PREF_ASK ) |
751 | return 0; | 751 | return 0; |
752 | } else { | 752 | } else { |
753 | if ( locCh ) { | 753 | if ( locCh ) { |
754 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 754 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
755 | lastSync = localMod.addDays( -1 ); | 755 | lastSync = localMod.addDays( -1 ); |
756 | if ( !remCh ) | 756 | if ( !remCh ) |
757 | remoteMod = ( lastSync.addDays( -1 ) ); | 757 | remoteMod = ( lastSync.addDays( -1 ) ); |
758 | } else { | 758 | } else { |
759 | //qDebug(" not loc changed "); | 759 | //qDebug(" not loc changed "); |
760 | lastSync = localMod.addDays( 1 ); | 760 | lastSync = localMod.addDays( 1 ); |
761 | if ( remCh ) | 761 | if ( remCh ) |
762 | remoteMod =( lastSync.addDays( 1 ) ); | 762 | remoteMod =( lastSync.addDays( 1 ) ); |
763 | 763 | ||
764 | } | 764 | } |
765 | } | 765 | } |
766 | full = true; | 766 | full = true; |
767 | if ( mode < SYNC_PREF_ASK ) | 767 | if ( mode < SYNC_PREF_ASK ) |
768 | mode = SYNC_PREF_ASK; | 768 | mode = SYNC_PREF_ASK; |
769 | } else { | 769 | } else { |
770 | if ( localMod == remoteMod ) | 770 | if ( localMod == remoteMod ) |
771 | // if ( local->revision() == remote->revision() ) | 771 | // if ( local->revision() == remote->revision() ) |
772 | return 0; | 772 | return 0; |
773 | 773 | ||
774 | } | 774 | } |
775 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 775 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
776 | 776 | ||
777 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 777 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
778 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 778 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
779 | //full = true; //debug only | 779 | //full = true; //debug only |
780 | if ( full ) { | 780 | if ( full ) { |
781 | bool equ = false; | 781 | bool equ = false; |
782 | if ( local->type() == "Event" ) { | 782 | if ( local->type() == "Event" ) { |
783 | equ = (*((Event*) local) == *((Event*) remote)); | 783 | equ = (*((Event*) local) == *((Event*) remote)); |
784 | } | 784 | } |
785 | else if ( local->type() =="Todo" ) | 785 | else if ( local->type() =="Todo" ) |
786 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 786 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
787 | else if ( local->type() =="Journal" ) | 787 | else if ( local->type() =="Journal" ) |
788 | equ = (*((Journal*) local) == *((Journal*) remote)); | 788 | equ = (*((Journal*) local) == *((Journal*) remote)); |
789 | if ( equ ) { | 789 | if ( equ ) { |
790 | //qDebug("equal "); | 790 | //qDebug("equal "); |
791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
792 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 792 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
793 | } | 793 | } |
794 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 794 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
795 | return 0; | 795 | return 0; |
796 | 796 | ||
797 | }//else //debug only | 797 | }//else //debug only |
798 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 798 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
799 | } | 799 | } |
800 | int result; | 800 | int result; |
801 | bool localIsNew; | 801 | bool localIsNew; |
802 | //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() ); | 802 | //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() ); |
803 | 803 | ||
804 | if ( full && mode < SYNC_PREF_NEWEST ) | 804 | if ( full && mode < SYNC_PREF_NEWEST ) |
805 | mode = SYNC_PREF_ASK; | 805 | mode = SYNC_PREF_ASK; |
806 | 806 | ||
807 | switch( mode ) { | 807 | switch( mode ) { |
808 | case SYNC_PREF_LOCAL: | 808 | case SYNC_PREF_LOCAL: |
809 | if ( lastSync > remoteMod ) | 809 | if ( lastSync > remoteMod ) |
810 | return 1; | 810 | return 1; |
811 | if ( lastSync > localMod ) | 811 | if ( lastSync > localMod ) |
812 | return 2; | 812 | return 2; |
813 | return 1; | 813 | return 1; |
814 | break; | 814 | break; |
815 | case SYNC_PREF_REMOTE: | 815 | case SYNC_PREF_REMOTE: |
816 | if ( lastSync > remoteMod ) | 816 | if ( lastSync > remoteMod ) |
817 | return 1; | 817 | return 1; |
818 | if ( lastSync > localMod ) | 818 | if ( lastSync > localMod ) |
819 | return 2; | 819 | return 2; |
820 | return 2; | 820 | return 2; |
821 | break; | 821 | break; |
822 | case SYNC_PREF_NEWEST: | 822 | case SYNC_PREF_NEWEST: |
823 | if ( localMod > remoteMod ) | 823 | if ( localMod > remoteMod ) |
824 | return 1; | 824 | return 1; |
825 | else | 825 | else |
826 | return 2; | 826 | return 2; |
827 | break; | 827 | break; |
828 | case SYNC_PREF_ASK: | 828 | case SYNC_PREF_ASK: |
829 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 829 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
830 | if ( lastSync > remoteMod ) | 830 | if ( lastSync > remoteMod ) |
831 | return 1; | 831 | return 1; |
832 | if ( lastSync > localMod ) | 832 | if ( lastSync > localMod ) |
833 | return 2; | 833 | return 2; |
834 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 834 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
835 | localIsNew = localMod >= remoteMod; | 835 | localIsNew = localMod >= remoteMod; |
836 | if ( localIsNew ) | 836 | if ( localIsNew ) |
837 | getEventViewerDialog()->setColorMode( 1 ); | 837 | getEventViewerDialog()->setColorMode( 1 ); |
838 | else | 838 | else |
839 | getEventViewerDialog()->setColorMode( 2 ); | 839 | getEventViewerDialog()->setColorMode( 2 ); |
840 | getEventViewerDialog()->setIncidence(local); | 840 | getEventViewerDialog()->setIncidence(local); |
841 | if ( localIsNew ) | 841 | if ( localIsNew ) |
842 | getEventViewerDialog()->setColorMode( 2 ); | 842 | getEventViewerDialog()->setColorMode( 2 ); |
843 | else | 843 | else |
844 | getEventViewerDialog()->setColorMode( 1 ); | 844 | getEventViewerDialog()->setColorMode( 1 ); |
845 | getEventViewerDialog()->addIncidence(remote); | 845 | getEventViewerDialog()->addIncidence(remote); |
846 | getEventViewerDialog()->setColorMode( 0 ); | 846 | getEventViewerDialog()->setColorMode( 0 ); |
847 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 847 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
848 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 848 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
849 | getEventViewerDialog()->showMe(); | 849 | getEventViewerDialog()->showMe(); |
850 | result = getEventViewerDialog()->executeS( localIsNew ); | 850 | result = getEventViewerDialog()->executeS( localIsNew ); |
851 | return result; | 851 | return result; |
852 | 852 | ||
853 | break; | 853 | break; |
854 | case SYNC_PREF_FORCE_LOCAL: | 854 | case SYNC_PREF_FORCE_LOCAL: |
855 | return 1; | 855 | return 1; |
856 | break; | 856 | break; |
857 | case SYNC_PREF_FORCE_REMOTE: | 857 | case SYNC_PREF_FORCE_REMOTE: |
858 | return 2; | 858 | return 2; |
859 | break; | 859 | break; |
860 | 860 | ||
861 | default: | 861 | default: |
862 | // SYNC_PREF_TAKE_BOTH not implemented | 862 | // SYNC_PREF_TAKE_BOTH not implemented |
863 | break; | 863 | break; |
864 | } | 864 | } |
865 | return 0; | 865 | return 0; |
866 | } | 866 | } |
867 | Event* CalendarView::getLastSyncEvent() | 867 | Event* CalendarView::getLastSyncEvent() |
868 | { | 868 | { |
869 | Event* lse; | 869 | Event* lse; |
870 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 870 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
871 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 871 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
872 | if (!lse) { | 872 | if (!lse) { |
873 | lse = new Event(); | 873 | lse = new Event(); |
874 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 874 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
875 | QString sum = ""; | 875 | QString sum = ""; |
876 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 876 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
877 | sum = "E: "; | 877 | sum = "E: "; |
878 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 878 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
879 | lse->setDtStart( mLastCalendarSync ); | 879 | lse->setDtStart( mLastCalendarSync ); |
880 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 880 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
881 | lse->setCategories( i18n("SyncEvent") ); | 881 | lse->setCategories( i18n("SyncEvent") ); |
882 | lse->setReadOnly( true ); | 882 | lse->setReadOnly( true ); |
883 | mCalendar->addEvent( lse ); | 883 | mCalendar->addEvent( lse ); |
884 | } | 884 | } |
885 | 885 | ||
886 | return lse; | 886 | return lse; |
887 | 887 | ||
888 | } | 888 | } |
889 | 889 | ||
890 | // we check, if the to delete event has a id for a profile | 890 | // we check, if the to delete event has a id for a profile |
891 | // if yes, we set this id in the profile to delete | 891 | // if yes, we set this id in the profile to delete |
892 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 892 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
893 | { | 893 | { |
894 | if ( lastSync.count() == 0 ) { | 894 | if ( lastSync.count() == 0 ) { |
895 | //qDebug(" lastSync.count() == 0"); | 895 | //qDebug(" lastSync.count() == 0"); |
896 | return; | 896 | return; |
897 | } | 897 | } |
898 | if ( toDelete->type() == "Journal" ) | 898 | if ( toDelete->type() == "Journal" ) |
899 | return; | 899 | return; |
900 | 900 | ||
901 | Event* eve = lastSync.first(); | 901 | Event* eve = lastSync.first(); |
902 | 902 | ||
903 | while ( eve ) { | 903 | while ( eve ) { |
904 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 904 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
905 | if ( !id.isEmpty() ) { | 905 | if ( !id.isEmpty() ) { |
906 | QString des = eve->description(); | 906 | QString des = eve->description(); |
907 | QString pref = "e"; | 907 | QString pref = "e"; |
908 | if ( toDelete->type() == "Todo" ) | 908 | if ( toDelete->type() == "Todo" ) |
909 | pref = "t"; | 909 | pref = "t"; |
910 | des += pref+ id + ","; | 910 | des += pref+ id + ","; |
911 | eve->setReadOnly( false ); | 911 | eve->setReadOnly( false ); |
912 | eve->setDescription( des ); | 912 | eve->setDescription( des ); |
913 | //qDebug("setdes %s ", des.latin1()); | 913 | //qDebug("setdes %s ", des.latin1()); |
914 | eve->setReadOnly( true ); | 914 | eve->setReadOnly( true ); |
915 | } | 915 | } |
916 | eve = lastSync.next(); | 916 | eve = lastSync.next(); |
917 | } | 917 | } |
918 | 918 | ||
919 | } | 919 | } |
920 | void CalendarView::checkExternalId( Incidence * inc ) | 920 | void CalendarView::checkExternalId( Incidence * inc ) |
921 | { | 921 | { |
922 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 922 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
923 | checkExternSyncEvent( lastSync, inc ); | 923 | checkExternSyncEvent( lastSync, inc ); |
924 | 924 | ||
925 | } | 925 | } |
926 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 926 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
927 | { | 927 | { |
928 | bool syncOK = true; | 928 | bool syncOK = true; |
929 | int addedEvent = 0; | 929 | int addedEvent = 0; |
930 | int addedEventR = 0; | 930 | int addedEventR = 0; |
931 | int deletedEventR = 0; | 931 | int deletedEventR = 0; |
932 | int deletedEventL = 0; | 932 | int deletedEventL = 0; |
933 | int changedLocal = 0; | 933 | int changedLocal = 0; |
934 | int changedRemote = 0; | 934 | int changedRemote = 0; |
935 | int filteredIN = 0; | 935 | int filteredIN = 0; |
936 | int filteredOUT = 0; | 936 | int filteredOUT = 0; |
937 | //QPtrList<Event> el = local->rawEvents(); | 937 | //QPtrList<Event> el = local->rawEvents(); |
938 | Event* eventR; | 938 | Event* eventR; |
939 | QString uid; | 939 | QString uid; |
940 | int take; | 940 | int take; |
941 | Event* eventL; | 941 | Event* eventL; |
942 | Event* eventRSync; | 942 | Event* eventRSync; |
943 | Event* eventLSync; | 943 | Event* eventLSync; |
944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
946 | bool fullDateRange = false; | 946 | bool fullDateRange = false; |
947 | local->resetTempSyncStat(); | 947 | local->resetTempSyncStat(); |
948 | mLastCalendarSync = QDateTime::currentDateTime(); | 948 | mLastCalendarSync = QDateTime::currentDateTime(); |
949 | if ( mSyncManager->syncWithDesktop() ) { | 949 | if ( mSyncManager->syncWithDesktop() ) { |
950 | remote->resetPilotStat(1); | 950 | remote->resetPilotStat(1); |
951 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 951 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
952 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 952 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
953 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 953 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
954 | } else { | 954 | } else { |
955 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 955 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
956 | } | 956 | } |
957 | } | 957 | } |
958 | QDateTime modifiedCalendar = mLastCalendarSync; | 958 | QDateTime modifiedCalendar = mLastCalendarSync; |
959 | eventLSync = getLastSyncEvent(); | 959 | eventLSync = getLastSyncEvent(); |
960 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 960 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
961 | if ( eventR ) { | 961 | if ( eventR ) { |
962 | eventRSync = (Event*) eventR->clone(); | 962 | eventRSync = (Event*) eventR->clone(); |
963 | remote->deleteEvent(eventR ); | 963 | remote->deleteEvent(eventR ); |
964 | 964 | ||
965 | } else { | 965 | } else { |
966 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 966 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
967 | eventRSync = (Event*)eventLSync->clone(); | 967 | eventRSync = (Event*)eventLSync->clone(); |
968 | } else { | 968 | } else { |
969 | fullDateRange = true; | 969 | fullDateRange = true; |
970 | eventRSync = new Event(); | 970 | eventRSync = new Event(); |
971 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 971 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
972 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 972 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
973 | eventRSync->setDtStart( mLastCalendarSync ); | 973 | eventRSync->setDtStart( mLastCalendarSync ); |
974 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 974 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
975 | eventRSync->setCategories( i18n("SyncEvent") ); | 975 | eventRSync->setCategories( i18n("SyncEvent") ); |
976 | } | 976 | } |
977 | } | 977 | } |
978 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 978 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
979 | fullDateRange = true; | 979 | fullDateRange = true; |
980 | 980 | ||
981 | if ( ! fullDateRange ) { | 981 | if ( ! fullDateRange ) { |
982 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 982 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
983 | 983 | ||
984 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 984 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
985 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 985 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
986 | fullDateRange = true; | 986 | fullDateRange = true; |
987 | } | 987 | } |
988 | } | 988 | } |
989 | if ( mSyncManager->syncWithDesktop() ) { | 989 | if ( mSyncManager->syncWithDesktop() ) { |
990 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 990 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
991 | } | 991 | } |
992 | if ( fullDateRange ) | 992 | if ( fullDateRange ) |
993 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 993 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
994 | else | 994 | else |
995 | mLastCalendarSync = eventLSync->dtStart(); | 995 | mLastCalendarSync = eventLSync->dtStart(); |
996 | // for resyncing if own file has changed | 996 | // for resyncing if own file has changed |
997 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 997 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
998 | mLastCalendarSync = loadedFileVersion; | 998 | mLastCalendarSync = loadedFileVersion; |
999 | //qDebug("setting mLastCalendarSync "); | 999 | //qDebug("setting mLastCalendarSync "); |
1000 | } | 1000 | } |
1001 | //qDebug("*************************** "); | 1001 | //qDebug("*************************** "); |
1002 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1002 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1003 | QPtrList<Incidence> er = remote->rawIncidences(); | 1003 | QPtrList<Incidence> er = remote->rawIncidences(); |
1004 | Incidence* inR = er.first(); | 1004 | Incidence* inR = er.first(); |
1005 | Incidence* inL; | 1005 | Incidence* inL; |
1006 | QProgressBar bar( er.count(),0 ); | 1006 | QProgressBar bar( er.count(),0 ); |
1007 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1007 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1008 | 1008 | ||
1009 | // ************** setting up filter ************* | 1009 | // ************** setting up filter ************* |
1010 | CalFilter *filterIN = 0; | 1010 | CalFilter *filterIN = 0; |
1011 | CalFilter *filterOUT = 0; | 1011 | CalFilter *filterOUT = 0; |
1012 | CalFilter *filter = mFilters.first(); | 1012 | CalFilter *filter = mFilters.first(); |
1013 | while(filter) { | 1013 | while(filter) { |
1014 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1014 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1015 | filterIN = filter; | 1015 | filterIN = filter; |
1016 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1016 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1017 | filterOUT = filter; | 1017 | filterOUT = filter; |
1018 | filter = mFilters.next(); | 1018 | filter = mFilters.next(); |
1019 | } | 1019 | } |
1020 | int w = 300; | 1020 | int w = 300; |
1021 | if ( QApplication::desktop()->width() < 320 ) | 1021 | if ( QApplication::desktop()->width() < 320 ) |
1022 | w = 220; | 1022 | w = 220; |
1023 | int h = bar.sizeHint().height() ; | 1023 | int h = bar.sizeHint().height() ; |
1024 | int dw = QApplication::desktop()->width(); | 1024 | int dw = QApplication::desktop()->width(); |
1025 | int dh = QApplication::desktop()->height(); | 1025 | int dh = QApplication::desktop()->height(); |
1026 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1026 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1027 | bar.show(); | 1027 | bar.show(); |
1028 | int modulo = (er.count()/10)+1; | 1028 | int modulo = (er.count()/10)+1; |
1029 | int incCounter = 0; | 1029 | int incCounter = 0; |
1030 | while ( inR ) { | 1030 | while ( inR ) { |
1031 | if ( ! bar.isVisible() ) | 1031 | if ( ! bar.isVisible() ) |
1032 | return false; | 1032 | return false; |
1033 | if ( incCounter % modulo == 0 ) | 1033 | if ( incCounter % modulo == 0 ) |
1034 | bar.setProgress( incCounter ); | 1034 | bar.setProgress( incCounter ); |
1035 | ++incCounter; | 1035 | ++incCounter; |
1036 | uid = inR->uid(); | 1036 | uid = inR->uid(); |
1037 | bool skipIncidence = false; | 1037 | bool skipIncidence = false; |
1038 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1038 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1039 | skipIncidence = true; | 1039 | skipIncidence = true; |
1040 | QString idS; | 1040 | QString idS; |
1041 | qApp->processEvents(); | 1041 | qApp->processEvents(); |
1042 | if ( !skipIncidence ) { | 1042 | if ( !skipIncidence ) { |
1043 | inL = local->incidence( uid ); | 1043 | inL = local->incidence( uid ); |
1044 | if ( inL ) { // maybe conflict - same uid in both calendars | 1044 | if ( inL ) { // maybe conflict - same uid in both calendars |
1045 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1045 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1046 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1046 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1047 | if ( take == 3 ) | 1047 | if ( take == 3 ) |
1048 | return false; | 1048 | return false; |
1049 | if ( take == 1 ) {// take local ********************** | 1049 | if ( take == 1 ) {// take local ********************** |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1052 | else | 1052 | else |
1053 | idS = inR->IDStr(); | 1053 | idS = inR->IDStr(); |
1054 | remote->deleteIncidence( inR ); | 1054 | remote->deleteIncidence( inR ); |
1055 | inR = inL->clone(); | 1055 | inR = inL->clone(); |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1057 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1057 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1058 | inR->setIDStr( idS ); | 1058 | inR->setIDStr( idS ); |
1059 | remote->addIncidence( inR ); | 1059 | remote->addIncidence( inR ); |
1060 | if ( mSyncManager->syncWithDesktop() ) | 1060 | if ( mSyncManager->syncWithDesktop() ) |
1061 | inR->setPilotId( 2 ); | 1061 | inR->setPilotId( 2 ); |
1062 | ++changedRemote; | 1062 | ++changedRemote; |
1063 | } else {// take remote ********************** | 1063 | } else {// take remote ********************** |
1064 | idS = inL->IDStr(); | 1064 | idS = inL->IDStr(); |
1065 | int pid = inL->pilotId(); | 1065 | int pid = inL->pilotId(); |
1066 | local->deleteIncidence( inL ); | 1066 | local->deleteIncidence( inL ); |
1067 | inL = inR->clone(); | 1067 | inL = inR->clone(); |
1068 | if ( mSyncManager->syncWithDesktop() ) | 1068 | if ( mSyncManager->syncWithDesktop() ) |
1069 | inL->setPilotId( pid ); | 1069 | inL->setPilotId( pid ); |
1070 | inL->setIDStr( idS ); | 1070 | inL->setIDStr( idS ); |
1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1074 | } | 1074 | } |
1075 | local->addIncidence( inL ); | 1075 | local->addIncidence( inL ); |
1076 | ++changedLocal; | 1076 | ++changedLocal; |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | } else { // no conflict ********** add or delete remote | 1079 | } else { // no conflict ********** add or delete remote |
1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1082 | QString des = eventLSync->description(); | 1082 | QString des = eventLSync->description(); |
1083 | QString pref = "e"; | 1083 | QString pref = "e"; |
1084 | if ( inR->type() == "Todo" ) | 1084 | if ( inR->type() == "Todo" ) |
1085 | pref = "t"; | 1085 | pref = "t"; |
1086 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1086 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1087 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1087 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1088 | //remote->deleteIncidence( inR ); | 1088 | //remote->deleteIncidence( inR ); |
1089 | ++deletedEventR; | 1089 | ++deletedEventR; |
1090 | } else { | 1090 | } else { |
1091 | inR->setLastModified( modifiedCalendar ); | 1091 | inR->setLastModified( modifiedCalendar ); |
1092 | inL = inR->clone(); | 1092 | inL = inR->clone(); |
1093 | inL->setIDStr( ":" ); | 1093 | inL->setIDStr( ":" ); |
1094 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1094 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1095 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1095 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1096 | local->addIncidence( inL ); | 1096 | local->addIncidence( inL ); |
1097 | ++addedEvent; | 1097 | ++addedEvent; |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | } else { | 1100 | } else { |
1101 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1101 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1102 | inR->setLastModified( modifiedCalendar ); | 1102 | inR->setLastModified( modifiedCalendar ); |
1103 | inL = inR->clone(); | 1103 | inL = inR->clone(); |
1104 | inL->setIDStr( ":" ); | 1104 | inL->setIDStr( ":" ); |
1105 | local->addIncidence( inL ); | 1105 | local->addIncidence( inL ); |
1106 | ++addedEvent; | 1106 | ++addedEvent; |
1107 | 1107 | ||
1108 | } else { | 1108 | } else { |
1109 | checkExternSyncEvent(eventRSyncSharp, inR); | 1109 | checkExternSyncEvent(eventRSyncSharp, inR); |
1110 | remote->deleteIncidence( inR ); | 1110 | remote->deleteIncidence( inR ); |
1111 | ++deletedEventR; | 1111 | ++deletedEventR; |
1112 | } | 1112 | } |
1113 | } | 1113 | } |
1114 | } else { | 1114 | } else { |
1115 | ++filteredIN; | 1115 | ++filteredIN; |
1116 | } | 1116 | } |
1117 | } | 1117 | } |
1118 | } | 1118 | } |
1119 | inR = er.next(); | 1119 | inR = er.next(); |
1120 | } | 1120 | } |
1121 | QPtrList<Incidence> el = local->rawIncidences(); | 1121 | QPtrList<Incidence> el = local->rawIncidences(); |
1122 | inL = el.first(); | 1122 | inL = el.first(); |
1123 | modulo = (el.count()/10)+1; | 1123 | modulo = (el.count()/10)+1; |
1124 | bar.setCaption (i18n("Add / remove events") ); | 1124 | bar.setCaption (i18n("Add / remove events") ); |
1125 | bar.setTotalSteps ( el.count() ) ; | 1125 | bar.setTotalSteps ( el.count() ) ; |
1126 | bar.show(); | 1126 | bar.show(); |
1127 | incCounter = 0; | 1127 | incCounter = 0; |
1128 | 1128 | ||
1129 | while ( inL ) { | 1129 | while ( inL ) { |
1130 | 1130 | ||
1131 | qApp->processEvents(); | 1131 | qApp->processEvents(); |
1132 | if ( ! bar.isVisible() ) | 1132 | if ( ! bar.isVisible() ) |
1133 | return false; | 1133 | return false; |
1134 | if ( incCounter % modulo == 0 ) | 1134 | if ( incCounter % modulo == 0 ) |
1135 | bar.setProgress( incCounter ); | 1135 | bar.setProgress( incCounter ); |
1136 | ++incCounter; | 1136 | ++incCounter; |
1137 | uid = inL->uid(); | 1137 | uid = inL->uid(); |
1138 | bool skipIncidence = false; | 1138 | bool skipIncidence = false; |
1139 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1139 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1140 | skipIncidence = true; | 1140 | skipIncidence = true; |
1141 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1141 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1142 | skipIncidence = true; | 1142 | skipIncidence = true; |
1143 | if ( !skipIncidence ) { | 1143 | if ( !skipIncidence ) { |
1144 | inR = remote->incidence( uid ); | 1144 | inR = remote->incidence( uid ); |
1145 | if ( ! inR ) { | 1145 | if ( ! inR ) { |
1146 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1146 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1147 | // no conflict ********** add or delete local | 1147 | // no conflict ********** add or delete local |
1148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1149 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1149 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1150 | checkExternSyncEvent(eventLSyncSharp, inL); | 1150 | checkExternSyncEvent(eventLSyncSharp, inL); |
1151 | local->deleteIncidence( inL ); | 1151 | local->deleteIncidence( inL ); |
1152 | ++deletedEventL; | 1152 | ++deletedEventL; |
1153 | } else { | 1153 | } else { |
1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1155 | inL->removeID(mCurrentSyncDevice ); | 1155 | inL->removeID(mCurrentSyncDevice ); |
1156 | ++addedEventR; | 1156 | ++addedEventR; |
1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1158 | inL->setLastModified( modifiedCalendar ); | 1158 | inL->setLastModified( modifiedCalendar ); |
1159 | inR = inL->clone(); | 1159 | inR = inL->clone(); |
1160 | inR->setIDStr( ":" ); | 1160 | inR->setIDStr( ":" ); |
1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1162 | remote->addIncidence( inR ); | 1162 | remote->addIncidence( inR ); |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | } else { | 1165 | } else { |
1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1167 | checkExternSyncEvent(eventLSyncSharp, inL); | 1167 | checkExternSyncEvent(eventLSyncSharp, inL); |
1168 | local->deleteIncidence( inL ); | 1168 | local->deleteIncidence( inL ); |
1169 | ++deletedEventL; | 1169 | ++deletedEventL; |
1170 | } else { | 1170 | } else { |
1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1172 | ++addedEventR; | 1172 | ++addedEventR; |
1173 | inL->setLastModified( modifiedCalendar ); | 1173 | inL->setLastModified( modifiedCalendar ); |
1174 | inR = inL->clone(); | 1174 | inR = inL->clone(); |
1175 | inR->setIDStr( ":" ); | 1175 | inR->setIDStr( ":" ); |
1176 | remote->addIncidence( inR ); | 1176 | remote->addIncidence( inR ); |
1177 | } | 1177 | } |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | } else { | 1180 | } else { |
1181 | ++filteredOUT; | 1181 | ++filteredOUT; |
1182 | } | 1182 | } |
1183 | } | 1183 | } |
1184 | } | 1184 | } |
1185 | inL = el.next(); | 1185 | inL = el.next(); |
1186 | } | 1186 | } |
1187 | int delFut = 0; | 1187 | int delFut = 0; |
1188 | int remRem = 0; | 1188 | int remRem = 0; |
1189 | if ( mSyncManager->mWriteBackInFuture ) { | 1189 | if ( mSyncManager->mWriteBackInFuture ) { |
1190 | er = remote->rawIncidences(); | 1190 | er = remote->rawIncidences(); |
1191 | remRem = er.count(); | 1191 | remRem = er.count(); |
1192 | inR = er.first(); | 1192 | inR = er.first(); |
1193 | QDateTime dt; | 1193 | QDateTime dt; |
1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1196 | while ( inR ) { | 1196 | while ( inR ) { |
1197 | if ( inR->type() == "Todo" ) { | 1197 | if ( inR->type() == "Todo" ) { |
1198 | Todo * t = (Todo*)inR; | 1198 | Todo * t = (Todo*)inR; |
1199 | if ( t->hasDueDate() ) | 1199 | if ( t->hasDueDate() ) |
1200 | dt = t->dtDue(); | 1200 | dt = t->dtDue(); |
1201 | else | 1201 | else |
1202 | dt = cur.addSecs( 62 ); | 1202 | dt = cur.addSecs( 62 ); |
1203 | } | 1203 | } |
1204 | else if (inR->type() == "Event" ) { | 1204 | else if (inR->type() == "Event" ) { |
1205 | bool ok; | 1205 | bool ok; |
1206 | dt = inR->getNextOccurence( cur, &ok ); | 1206 | dt = inR->getNextOccurence( cur, &ok ); |
1207 | if ( !ok ) | 1207 | if ( !ok ) |
1208 | dt = cur.addSecs( -62 ); | 1208 | dt = cur.addSecs( -62 ); |
1209 | } | 1209 | } |
1210 | else | 1210 | else |
1211 | dt = inR->dtStart(); | 1211 | dt = inR->dtStart(); |
1212 | if ( dt < cur || dt > end ) { | 1212 | if ( dt < cur || dt > end ) { |
1213 | remote->deleteIncidence( inR ); | 1213 | remote->deleteIncidence( inR ); |
1214 | ++delFut; | 1214 | ++delFut; |
1215 | } | 1215 | } |
1216 | inR = er.next(); | 1216 | inR = er.next(); |
1217 | } | 1217 | } |
1218 | } | 1218 | } |
1219 | bar.hide(); | 1219 | bar.hide(); |
1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1221 | eventLSync->setReadOnly( false ); | 1221 | eventLSync->setReadOnly( false ); |
1222 | eventLSync->setDtStart( mLastCalendarSync ); | 1222 | eventLSync->setDtStart( mLastCalendarSync ); |
1223 | eventRSync->setDtStart( mLastCalendarSync ); | 1223 | eventRSync->setDtStart( mLastCalendarSync ); |
1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1228 | eventLSync->setReadOnly( true ); | 1228 | eventLSync->setReadOnly( true ); |
1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1231 | remote->addEvent( eventRSync ); | 1231 | remote->addEvent( eventRSync ); |
1232 | else | 1232 | else |
1233 | delete eventRSync; | 1233 | delete eventRSync; |
1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1235 | QString mes; | 1235 | QString mes; |
1236 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1236 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1237 | QString delmess; | 1237 | QString delmess; |
1238 | if ( delFut ) { | 1238 | if ( delFut ) { |
1239 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1239 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1240 | mes += delmess; | 1240 | mes += delmess; |
1241 | } | 1241 | } |
1242 | mes = i18n("Local calendar changed!\n") +mes; | 1242 | mes = i18n("Local calendar changed!\n") +mes; |
1243 | mCalendar->checkAlarmForIncidence( 0, true ); | 1243 | mCalendar->checkAlarmForIncidence( 0, true ); |
1244 | qDebug( mes ); | 1244 | qDebug( mes ); |
1245 | if ( mSyncManager->mShowSyncSummary ) { | 1245 | if ( mSyncManager->mShowSyncSummary ) { |
1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1248 | qDebug("KO: WB cancelled "); | 1248 | qDebug("KO: WB cancelled "); |
1249 | mSyncManager->mWriteBackFile = false; | 1249 | mSyncManager->mWriteBackFile = false; |
1250 | return syncOK; | 1250 | return syncOK; |
1251 | } | 1251 | } |
1252 | } | 1252 | } |
1253 | return syncOK; | 1253 | return syncOK; |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | void CalendarView::setSyncDevice( QString s ) | 1256 | void CalendarView::setSyncDevice( QString s ) |
1257 | { | 1257 | { |
1258 | mCurrentSyncDevice= s; | 1258 | mCurrentSyncDevice= s; |
1259 | } | 1259 | } |
1260 | void CalendarView::setSyncName( QString s ) | 1260 | void CalendarView::setSyncName( QString s ) |
1261 | { | 1261 | { |
1262 | mCurrentSyncName= s; | 1262 | mCurrentSyncName= s; |
1263 | } | 1263 | } |
1264 | bool CalendarView::syncCalendar(QString filename, int mode) | 1264 | bool CalendarView::syncCalendar(QString filename, int mode) |
1265 | { | 1265 | { |
1266 | //qDebug("syncCalendar %s ", filename.latin1()); | 1266 | //qDebug("syncCalendar %s ", filename.latin1()); |
1267 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1267 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1268 | CalendarLocal* calendar = new CalendarLocal(); | 1268 | CalendarLocal* calendar = new CalendarLocal(); |
1269 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1269 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1270 | FileStorage* storage = new FileStorage( calendar ); | 1270 | FileStorage* storage = new FileStorage( calendar ); |
1271 | bool syncOK = false; | 1271 | bool syncOK = false; |
1272 | storage->setFileName( filename ); | 1272 | storage->setFileName( filename ); |
1273 | // qDebug("loading ... "); | 1273 | // qDebug("loading ... "); |
1274 | if ( storage->load() ) { | 1274 | if ( storage->load() ) { |
1275 | getEventViewerDialog()->setSyncMode( true ); | 1275 | getEventViewerDialog()->setSyncMode( true ); |
1276 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1276 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1277 | getEventViewerDialog()->setSyncMode( false ); | 1277 | getEventViewerDialog()->setSyncMode( false ); |
1278 | if ( syncOK ) { | 1278 | if ( syncOK ) { |
1279 | if ( mSyncManager->mWriteBackFile ) | 1279 | if ( mSyncManager->mWriteBackFile ) |
1280 | { | 1280 | { |
1281 | storage->setSaveFormat( new ICalFormat() ); | 1281 | storage->setSaveFormat( new ICalFormat() ); |
1282 | storage->save(); | 1282 | storage->save(); |
1283 | } | 1283 | } |
1284 | } | 1284 | } |
1285 | setModified( true ); | 1285 | setModified( true ); |
1286 | } | 1286 | } |
1287 | delete storage; | 1287 | delete storage; |
1288 | delete calendar; | 1288 | delete calendar; |
1289 | if ( syncOK ) | 1289 | if ( syncOK ) |
1290 | updateView(); | 1290 | updateView(); |
1291 | return syncOK; | 1291 | return syncOK; |
1292 | } | 1292 | } |
1293 | 1293 | ||
1294 | void CalendarView::syncExternal( int mode ) | 1294 | void CalendarView::syncExternal( int mode ) |
1295 | { | 1295 | { |
1296 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1296 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1297 | 1297 | ||
1298 | qApp->processEvents(); | 1298 | qApp->processEvents(); |
1299 | CalendarLocal* calendar = new CalendarLocal(); | 1299 | CalendarLocal* calendar = new CalendarLocal(); |
1300 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1300 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1301 | bool syncOK = false; | 1301 | bool syncOK = false; |
1302 | bool loadSuccess = false; | 1302 | bool loadSuccess = false; |
1303 | PhoneFormat* phoneFormat = 0; | 1303 | PhoneFormat* phoneFormat = 0; |
1304 | emit tempDisableBR(true); | 1304 | emit tempDisableBR(true); |
1305 | #ifndef DESKTOP_VERSION | 1305 | #ifndef DESKTOP_VERSION |
1306 | SharpFormat* sharpFormat = 0; | 1306 | SharpFormat* sharpFormat = 0; |
1307 | if ( mode == 0 ) { // sharp | 1307 | if ( mode == 0 ) { // sharp |
1308 | sharpFormat = new SharpFormat () ; | 1308 | sharpFormat = new SharpFormat () ; |
1309 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1309 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1310 | 1310 | ||
1311 | } else | 1311 | } else |
1312 | #endif | 1312 | #endif |
1313 | if ( mode == 1 ) { // phone | 1313 | if ( mode == 1 ) { // phone |
1314 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1314 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1315 | mSyncManager->mPhoneDevice, | 1315 | mSyncManager->mPhoneDevice, |
1316 | mSyncManager->mPhoneConnection, | 1316 | mSyncManager->mPhoneConnection, |
1317 | mSyncManager->mPhoneModel); | 1317 | mSyncManager->mPhoneModel); |
1318 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1318 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1319 | 1319 | ||
1320 | } else { | 1320 | } else { |
1321 | emit tempDisableBR(false); | 1321 | emit tempDisableBR(false); |
1322 | return; | 1322 | return; |
1323 | } | 1323 | } |
1324 | if ( loadSuccess ) { | 1324 | if ( loadSuccess ) { |
1325 | getEventViewerDialog()->setSyncMode( true ); | 1325 | getEventViewerDialog()->setSyncMode( true ); |
1326 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1326 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1327 | getEventViewerDialog()->setSyncMode( false ); | 1327 | getEventViewerDialog()->setSyncMode( false ); |
1328 | qApp->processEvents(); | 1328 | qApp->processEvents(); |
1329 | if ( syncOK ) { | 1329 | if ( syncOK ) { |
1330 | if ( mSyncManager->mWriteBackFile ) | 1330 | if ( mSyncManager->mWriteBackFile ) |
1331 | { | 1331 | { |
1332 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1332 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1333 | Incidence* inc = iL.first(); | 1333 | Incidence* inc = iL.first(); |
1334 | if ( phoneFormat ) { | 1334 | if ( phoneFormat ) { |
1335 | while ( inc ) { | 1335 | while ( inc ) { |
1336 | inc->removeID(mCurrentSyncDevice); | 1336 | inc->removeID(mCurrentSyncDevice); |
1337 | inc = iL.next(); | 1337 | inc = iL.next(); |
1338 | } | 1338 | } |
1339 | } | 1339 | } |
1340 | #ifndef DESKTOP_VERSION | 1340 | #ifndef DESKTOP_VERSION |
1341 | if ( sharpFormat ) | 1341 | if ( sharpFormat ) |
1342 | sharpFormat->save(calendar); | 1342 | sharpFormat->save(calendar); |
1343 | #endif | 1343 | #endif |
1344 | if ( phoneFormat ) | 1344 | if ( phoneFormat ) |
1345 | phoneFormat->save(calendar); | 1345 | phoneFormat->save(calendar); |
1346 | iL = calendar->rawIncidences(); | 1346 | iL = calendar->rawIncidences(); |
1347 | inc = iL.first(); | 1347 | inc = iL.first(); |
1348 | Incidence* loc; | 1348 | Incidence* loc; |
1349 | while ( inc ) { | 1349 | while ( inc ) { |
1350 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1350 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1351 | loc = mCalendar->incidence(inc->uid() ); | 1351 | loc = mCalendar->incidence(inc->uid() ); |
1352 | if ( loc ) { | 1352 | if ( loc ) { |
1353 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1353 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1354 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1354 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1355 | } | 1355 | } |
1356 | } | 1356 | } |
1357 | inc = iL.next(); | 1357 | inc = iL.next(); |
1358 | } | 1358 | } |
1359 | Incidence* lse = getLastSyncEvent(); | 1359 | Incidence* lse = getLastSyncEvent(); |
1360 | if ( lse ) { | 1360 | if ( lse ) { |
1361 | lse->setReadOnly( false ); | 1361 | lse->setReadOnly( false ); |
1362 | lse->setDescription( "" ); | 1362 | lse->setDescription( "" ); |
1363 | lse->setReadOnly( true ); | 1363 | lse->setReadOnly( true ); |
1364 | } | 1364 | } |
1365 | } | 1365 | } |
1366 | } else { | 1366 | } else { |
1367 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1367 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1368 | } | 1368 | } |
1369 | setModified( true ); | 1369 | setModified( true ); |
1370 | } else { | 1370 | } else { |
1371 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1371 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1372 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1372 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1373 | question, i18n("Ok")) ; | 1373 | question, i18n("Ok")) ; |
1374 | 1374 | ||
1375 | } | 1375 | } |
1376 | delete calendar; | 1376 | delete calendar; |
1377 | updateView(); | 1377 | updateView(); |
1378 | emit tempDisableBR(false); | 1378 | emit tempDisableBR(false); |
1379 | return ;//syncOK; | 1379 | return ;//syncOK; |
1380 | 1380 | ||
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | bool CalendarView::importBday() | 1383 | bool CalendarView::importBday() |
1384 | { | 1384 | { |
1385 | #ifndef KORG_NOKABC | 1385 | #ifndef KORG_NOKABC |
1386 | 1386 | ||
1387 | #ifdef DESKTOP_VERSION | 1387 | #ifdef DESKTOP_VERSION |
1388 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1388 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1389 | KABC::AddressBook::Iterator it; | 1389 | KABC::AddressBook::Iterator it; |
1390 | int count = 0; | 1390 | int count = 0; |
1391 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1391 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1392 | ++count; | 1392 | ++count; |
1393 | } | 1393 | } |
1394 | QProgressBar bar(count,0 ); | 1394 | QProgressBar bar(count,0 ); |
1395 | int w = 300; | 1395 | int w = 300; |
1396 | if ( QApplication::desktop()->width() < 320 ) | 1396 | if ( QApplication::desktop()->width() < 320 ) |
1397 | w = 220; | 1397 | w = 220; |
1398 | int h = bar.sizeHint().height() ; | 1398 | int h = bar.sizeHint().height() ; |
1399 | int dw = QApplication::desktop()->width(); | 1399 | int dw = QApplication::desktop()->width(); |
1400 | int dh = QApplication::desktop()->height(); | 1400 | int dh = QApplication::desktop()->height(); |
1401 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1401 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1402 | bar.show(); | 1402 | bar.show(); |
1403 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1403 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1404 | qApp->processEvents(); | 1404 | qApp->processEvents(); |
1405 | count = 0; | 1405 | count = 0; |
1406 | int addCount = 0; | 1406 | int addCount = 0; |
1407 | KCal::Attendee* a = 0; | 1407 | KCal::Attendee* a = 0; |
1408 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1408 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1409 | if ( ! bar.isVisible() ) | 1409 | if ( ! bar.isVisible() ) |
1410 | return false; | 1410 | return false; |
1411 | bar.setProgress( count++ ); | 1411 | bar.setProgress( count++ ); |
1412 | qApp->processEvents(); | 1412 | qApp->processEvents(); |
1413 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1413 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1414 | if ( (*it).birthday().date().isValid() ){ | 1414 | if ( (*it).birthday().date().isValid() ){ |
1415 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1415 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1416 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1416 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1417 | ++addCount; | 1417 | ++addCount; |
1418 | } | 1418 | } |
1419 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1419 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1420 | if ( anni.isValid() ){ | 1420 | if ( anni.isValid() ){ |
1421 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1421 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1422 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1422 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1423 | ++addCount; | 1423 | ++addCount; |
1424 | } | 1424 | } |
1425 | } | 1425 | } |
1426 | updateView(); | 1426 | updateView(); |
1427 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1427 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1428 | #else //DESKTOP_VERSION | 1428 | #else //DESKTOP_VERSION |
1429 | 1429 | ||
1430 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1430 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1431 | // the result should now arrive through method insertBirthdays | 1431 | // the result should now arrive through method insertBirthdays |
1432 | 1432 | ||
1433 | #endif //DESKTOP_VERSION | 1433 | #endif //DESKTOP_VERSION |
1434 | 1434 | ||
1435 | #endif //KORG_NOKABC | 1435 | #endif //KORG_NOKABC |
1436 | 1436 | ||
1437 | 1437 | ||
1438 | return true; | 1438 | return true; |
1439 | } | 1439 | } |
1440 | 1440 | ||
1441 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1441 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1442 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1442 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1443 | const QStringList& anniversaryList, const QStringList& realNameList, | 1443 | const QStringList& anniversaryList, const QStringList& realNameList, |
1444 | const QStringList& emailList, const QStringList& assembledNameList, | 1444 | const QStringList& emailList, const QStringList& assembledNameList, |
1445 | const QStringList& uidList) | 1445 | const QStringList& uidList) |
1446 | { | 1446 | { |
1447 | //qDebug("KO::CalendarView::insertBirthdays"); | 1447 | //qDebug("KO::CalendarView::insertBirthdays"); |
1448 | if (uid == this->name()) | 1448 | if (uid == this->name()) |
1449 | { | 1449 | { |
1450 | int count = birthdayList.count(); | 1450 | int count = birthdayList.count(); |
1451 | int addCount = 0; | 1451 | int addCount = 0; |
1452 | KCal::Attendee* a = 0; | 1452 | KCal::Attendee* a = 0; |
1453 | 1453 | ||
1454 | //qDebug("CalView 1 %i", count); | 1454 | //qDebug("CalView 1 %i", count); |
1455 | 1455 | ||
1456 | QProgressBar bar(count,0 ); | 1456 | QProgressBar bar(count,0 ); |
1457 | int w = 300; | 1457 | int w = 300; |
1458 | if ( QApplication::desktop()->width() < 320 ) | 1458 | if ( QApplication::desktop()->width() < 320 ) |
1459 | w = 220; | 1459 | w = 220; |
1460 | int h = bar.sizeHint().height() ; | 1460 | int h = bar.sizeHint().height() ; |
1461 | int dw = QApplication::desktop()->width(); | 1461 | int dw = QApplication::desktop()->width(); |
1462 | int dh = QApplication::desktop()->height(); | 1462 | int dh = QApplication::desktop()->height(); |
1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1464 | bar.show(); | 1464 | bar.show(); |
1465 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1465 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1466 | qApp->processEvents(); | 1466 | qApp->processEvents(); |
1467 | 1467 | ||
1468 | QDate birthday; | 1468 | QDate birthday; |
1469 | QDate anniversary; | 1469 | QDate anniversary; |
1470 | QString realName; | 1470 | QString realName; |
1471 | QString email; | 1471 | QString email; |
1472 | QString assembledName; | 1472 | QString assembledName; |
1473 | QString uid; | 1473 | QString uid; |
1474 | bool ok = true; | 1474 | bool ok = true; |
1475 | for ( int i = 0; i < count; i++) | 1475 | for ( int i = 0; i < count; i++) |
1476 | { | 1476 | { |
1477 | if ( ! bar.isVisible() ) | 1477 | if ( ! bar.isVisible() ) |
1478 | return; | 1478 | return; |
1479 | bar.setProgress( i ); | 1479 | bar.setProgress( i ); |
1480 | qApp->processEvents(); | 1480 | qApp->processEvents(); |
1481 | 1481 | ||
1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1483 | if (!ok) { | 1483 | if (!ok) { |
1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1485 | } | 1485 | } |
1486 | 1486 | ||
1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1488 | if (!ok) { | 1488 | if (!ok) { |
1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1490 | } | 1490 | } |
1491 | realName = realNameList[i]; | 1491 | realName = realNameList[i]; |
1492 | email = emailList[i]; | 1492 | email = emailList[i]; |
1493 | assembledName = assembledNameList[i]; | 1493 | assembledName = assembledNameList[i]; |
1494 | uid = uidList[i]; | 1494 | uid = uidList[i]; |
1495 | //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() ); | 1495 | //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() ); |
1496 | 1496 | ||
1497 | if ( birthday.isValid() ){ | 1497 | if ( birthday.isValid() ){ |
1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1499 | KCal::Attendee::ReqParticipant,uid) ; | 1499 | KCal::Attendee::ReqParticipant,uid) ; |
1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1501 | ++addCount; | 1501 | ++addCount; |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | if ( anniversary.isValid() ){ | 1504 | if ( anniversary.isValid() ){ |
1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1506 | KCal::Attendee::ReqParticipant,uid) ; | 1506 | KCal::Attendee::ReqParticipant,uid) ; |
1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1508 | ++addCount; | 1508 | ++addCount; |
1509 | } | 1509 | } |
1510 | } | 1510 | } |
1511 | 1511 | ||
1512 | updateView(); | 1512 | updateView(); |
1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1514 | 1514 | ||
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | } | 1517 | } |
1518 | 1518 | ||
1519 | 1519 | ||
1520 | 1520 | ||
1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1522 | { | 1522 | { |
1523 | //qDebug("addAnni "); | 1523 | //qDebug("addAnni "); |
1524 | Event * ev = new Event(); | 1524 | Event * ev = new Event(); |
1525 | ev->setOrganizer(KOPrefs::instance()->email()); | 1525 | ev->setOrganizer(KOPrefs::instance()->email()); |
1526 | if ( a ) { | 1526 | if ( a ) { |
1527 | ev->addAttendee( a ); | 1527 | ev->addAttendee( a ); |
1528 | } | 1528 | } |
1529 | QString kind; | 1529 | QString kind; |
1530 | if ( birthday ) { | 1530 | if ( birthday ) { |
1531 | kind = i18n( "Birthday" ); | 1531 | kind = i18n( "Birthday" ); |
1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1533 | } | 1533 | } |
1534 | else { | 1534 | else { |
1535 | kind = i18n( "Anniversary" ); | 1535 | kind = i18n( "Anniversary" ); |
1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1537 | } | 1537 | } |
1538 | ev->setCategories( kind ); | 1538 | ev->setCategories( kind ); |
1539 | ev->setDtStart( QDateTime(date) ); | 1539 | ev->setDtStart( QDateTime(date) ); |
1540 | ev->setDtEnd( QDateTime(date) ); | 1540 | ev->setDtEnd( QDateTime(date) ); |
1541 | ev->setFloats( true ); | 1541 | ev->setFloats( true ); |
1542 | Recurrence * rec = ev->recurrence(); | 1542 | Recurrence * rec = ev->recurrence(); |
1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1544 | rec->addYearlyNum( date.month() ); | 1544 | rec->addYearlyNum( date.month() ); |
1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1546 | delete ev; | 1546 | delete ev; |
1547 | return false; | 1547 | return false; |
1548 | } | 1548 | } |
1549 | return true; | 1549 | return true; |
1550 | 1550 | ||
1551 | } | 1551 | } |
1552 | bool CalendarView::importQtopia( const QString &categories, | 1552 | bool CalendarView::importQtopia( const QString &categories, |
1553 | const QString &datebook, | 1553 | const QString &datebook, |
1554 | const QString &todolist ) | 1554 | const QString &todolist ) |
1555 | { | 1555 | { |
1556 | 1556 | ||
1557 | QtopiaFormat qtopiaFormat; | 1557 | QtopiaFormat qtopiaFormat; |
1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1562 | 1562 | ||
1563 | updateView(); | 1563 | updateView(); |
1564 | return true; | 1564 | return true; |
1565 | 1565 | ||
1566 | #if 0 | 1566 | #if 0 |
1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1568 | mCurrentSyncDevice = "qtopia-XML"; | 1568 | mCurrentSyncDevice = "qtopia-XML"; |
1569 | if ( mSyncManager->mAskForPreferences ) | 1569 | if ( mSyncManager->mAskForPreferences ) |
1570 | edit_sync_options(); | 1570 | edit_sync_options(); |
1571 | qApp->processEvents(); | 1571 | qApp->processEvents(); |
1572 | CalendarLocal* calendar = new CalendarLocal(); | 1572 | CalendarLocal* calendar = new CalendarLocal(); |
1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1574 | bool syncOK = false; | 1574 | bool syncOK = false; |
1575 | QtopiaFormat qtopiaFormat; | 1575 | QtopiaFormat qtopiaFormat; |
1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1577 | bool loadOk = true; | 1577 | bool loadOk = true; |
1578 | if ( !categories.isEmpty() ) | 1578 | if ( !categories.isEmpty() ) |
1579 | loadOk = qtopiaFormat.load( calendar, categories ); | 1579 | loadOk = qtopiaFormat.load( calendar, categories ); |
1580 | if ( loadOk && !datebook.isEmpty() ) | 1580 | if ( loadOk && !datebook.isEmpty() ) |
1581 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1581 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1582 | if ( loadOk && !todolist.isEmpty() ) | 1582 | if ( loadOk && !todolist.isEmpty() ) |
1583 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1583 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1584 | 1584 | ||
1585 | if ( loadOk ) { | 1585 | if ( loadOk ) { |
1586 | getEventViewerDialog()->setSyncMode( true ); | 1586 | getEventViewerDialog()->setSyncMode( true ); |
1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1588 | getEventViewerDialog()->setSyncMode( false ); | 1588 | getEventViewerDialog()->setSyncMode( false ); |
1589 | qApp->processEvents(); | 1589 | qApp->processEvents(); |
1590 | if ( syncOK ) { | 1590 | if ( syncOK ) { |
1591 | if ( mSyncManager->mWriteBackFile ) | 1591 | if ( mSyncManager->mWriteBackFile ) |
1592 | { | 1592 | { |
1593 | // write back XML file | 1593 | // write back XML file |
1594 | 1594 | ||
1595 | } | 1595 | } |
1596 | setModified( true ); | 1596 | setModified( true ); |
1597 | } | 1597 | } |
1598 | } else { | 1598 | } else { |
1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1601 | question, i18n("Ok")) ; | 1601 | question, i18n("Ok")) ; |
1602 | } | 1602 | } |
1603 | delete calendar; | 1603 | delete calendar; |
1604 | updateView(); | 1604 | updateView(); |
1605 | return syncOK; | 1605 | return syncOK; |
1606 | 1606 | ||
1607 | 1607 | ||
1608 | #endif | 1608 | #endif |
1609 | 1609 | ||
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | void CalendarView::setSyncEventsReadOnly() | 1612 | void CalendarView::setSyncEventsReadOnly() |
1613 | { | 1613 | { |
1614 | Event * ev; | 1614 | Event * ev; |
1615 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1615 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1616 | ev = eL.first(); | 1616 | ev = eL.first(); |
1617 | while ( ev ) { | 1617 | while ( ev ) { |
1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1619 | ev->setReadOnly( true ); | 1619 | ev->setReadOnly( true ); |
1620 | ev = eL.next(); | 1620 | ev = eL.next(); |
1621 | } | 1621 | } |
1622 | } | 1622 | } |
1623 | bool CalendarView::openCalendar(QString filename, bool merge) | 1623 | bool CalendarView::openCalendar(QString filename, bool merge) |
1624 | { | 1624 | { |
1625 | 1625 | ||
1626 | if (filename.isEmpty()) { | 1626 | if (filename.isEmpty()) { |
1627 | return false; | 1627 | return false; |
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | if (!QFile::exists(filename)) { | 1630 | if (!QFile::exists(filename)) { |
1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1632 | return false; | 1632 | return false; |
1633 | } | 1633 | } |
1634 | 1634 | ||
1635 | globalFlagBlockAgenda = 1; | 1635 | globalFlagBlockAgenda = 1; |
1636 | if (!merge) mCalendar->close(); | 1636 | if (!merge) mCalendar->close(); |
1637 | 1637 | ||
1638 | mStorage->setFileName( filename ); | 1638 | mStorage->setFileName( filename ); |
1639 | 1639 | ||
1640 | if ( mStorage->load() ) { | 1640 | if ( mStorage->load() ) { |
1641 | if ( merge ) ;//setModified( true ); | 1641 | if ( merge ) ;//setModified( true ); |
1642 | else { | 1642 | else { |
1643 | //setModified( true ); | 1643 | //setModified( true ); |
1644 | mViewManager->setDocumentId( filename ); | 1644 | mViewManager->setDocumentId( filename ); |
1645 | mDialogManager->setDocumentId( filename ); | 1645 | mDialogManager->setDocumentId( filename ); |
1646 | mTodoList->setDocumentId( filename ); | 1646 | mTodoList->setDocumentId( filename ); |
1647 | } | 1647 | } |
1648 | globalFlagBlockAgenda = 2; | 1648 | globalFlagBlockAgenda = 2; |
1649 | // if ( getLastSyncEvent() ) | 1649 | // if ( getLastSyncEvent() ) |
1650 | // getLastSyncEvent()->setReadOnly( true ); | 1650 | // getLastSyncEvent()->setReadOnly( true ); |
1651 | mCalendar->reInitAlarmSettings(); | 1651 | mCalendar->reInitAlarmSettings(); |
1652 | setSyncEventsReadOnly(); | 1652 | setSyncEventsReadOnly(); |
1653 | updateUnmanagedViews(); | 1653 | updateUnmanagedViews(); |
1654 | updateView(); | 1654 | updateView(); |
1655 | if ( filename != MainWindow::defaultFileName() ) { | 1655 | if ( filename != MainWindow::defaultFileName() ) { |
1656 | saveCalendar( MainWindow::defaultFileName() ); | 1656 | saveCalendar( MainWindow::defaultFileName() ); |
1657 | } else { | 1657 | } else { |
1658 | QFileInfo finf ( MainWindow::defaultFileName()); | 1658 | QFileInfo finf ( MainWindow::defaultFileName()); |
1659 | if ( finf.exists() ) { | 1659 | if ( finf.exists() ) { |
1660 | setLoadedFileVersion( finf.lastModified () ); | 1660 | setLoadedFileVersion( finf.lastModified () ); |
1661 | } | 1661 | } |
1662 | } | 1662 | } |
1663 | return true; | 1663 | return true; |
1664 | } else { | 1664 | } else { |
1665 | // while failing to load, the calendar object could | 1665 | // while failing to load, the calendar object could |
1666 | // have become partially populated. Clear it out. | 1666 | // have become partially populated. Clear it out. |
1667 | if ( !merge ) { | 1667 | if ( !merge ) { |
1668 | mCalendar->close(); | 1668 | mCalendar->close(); |
1669 | mViewManager->setDocumentId( filename ); | 1669 | mViewManager->setDocumentId( filename ); |
1670 | mDialogManager->setDocumentId( filename ); | 1670 | mDialogManager->setDocumentId( filename ); |
1671 | mTodoList->setDocumentId( filename ); | 1671 | mTodoList->setDocumentId( filename ); |
1672 | } | 1672 | } |
1673 | 1673 | ||
1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1675 | 1675 | ||
1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1677 | globalFlagBlockAgenda = 2; | 1677 | globalFlagBlockAgenda = 2; |
1678 | mCalendar->reInitAlarmSettings(); | 1678 | mCalendar->reInitAlarmSettings(); |
1679 | setSyncEventsReadOnly(); | 1679 | setSyncEventsReadOnly(); |
1680 | updateUnmanagedViews(); | 1680 | updateUnmanagedViews(); |
1681 | updateView(); | 1681 | updateView(); |
1682 | } | 1682 | } |
1683 | return false; | 1683 | return false; |
1684 | } | 1684 | } |
1685 | void CalendarView::showOpenError() | 1685 | void CalendarView::showOpenError() |
1686 | { | 1686 | { |
1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1688 | } | 1688 | } |
1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1690 | { | 1690 | { |
1691 | loadedFileVersion = dt; | 1691 | loadedFileVersion = dt; |
1692 | } | 1692 | } |
1693 | bool CalendarView::checkFileChanged(QString fn) | 1693 | bool CalendarView::checkFileChanged(QString fn) |
1694 | { | 1694 | { |
1695 | QFileInfo finf ( fn ); | 1695 | QFileInfo finf ( fn ); |
1696 | if ( !finf.exists() ) | 1696 | if ( !finf.exists() ) |
1697 | return true; | 1697 | return true; |
1698 | QDateTime dt = finf.lastModified (); | 1698 | QDateTime dt = finf.lastModified (); |
1699 | if ( dt <= loadedFileVersion ) | 1699 | if ( dt <= loadedFileVersion ) |
1700 | return false; | 1700 | return false; |
1701 | return true; | 1701 | return true; |
1702 | 1702 | ||
1703 | } | 1703 | } |
1704 | void CalendarView::watchSavedFile() | 1704 | void CalendarView::watchSavedFile() |
1705 | { | 1705 | { |
1706 | QFileInfo finf ( MainWindow::defaultFileName()); | 1706 | QFileInfo finf ( MainWindow::defaultFileName()); |
1707 | if ( !finf.exists() ) | 1707 | if ( !finf.exists() ) |
1708 | return; | 1708 | return; |
1709 | QDateTime dt = finf.lastModified (); | 1709 | QDateTime dt = finf.lastModified (); |
1710 | if ( dt < loadedFileVersion ) { | 1710 | if ( dt < loadedFileVersion ) { |
1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1713 | return; | 1713 | return; |
1714 | } | 1714 | } |
1715 | loadedFileVersion = dt; | 1715 | loadedFileVersion = dt; |
1716 | } | 1716 | } |
1717 | 1717 | ||
1718 | bool CalendarView::checkFileVersion(QString fn) | 1718 | bool CalendarView::checkFileVersion(QString fn) |
1719 | { | 1719 | { |
1720 | QFileInfo finf ( fn ); | 1720 | QFileInfo finf ( fn ); |
1721 | if ( !finf.exists() ) | 1721 | if ( !finf.exists() ) |
1722 | return true; | 1722 | return true; |
1723 | QDateTime dt = finf.lastModified (); | 1723 | QDateTime dt = finf.lastModified (); |
1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1725 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1725 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1726 | if ( dt <= loadedFileVersion ) | 1726 | if ( dt <= loadedFileVersion ) |
1727 | return true; | 1727 | return true; |
1728 | 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)) , | 1728 | 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)) , |
1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1730 | i18n("Sync+save")); | 1730 | i18n("Sync+save")); |
1731 | 1731 | ||
1732 | if ( km == KMessageBox::Cancel ) | 1732 | if ( km == KMessageBox::Cancel ) |
1733 | return false; | 1733 | return false; |
1734 | if ( km == KMessageBox::Yes ) | 1734 | if ( km == KMessageBox::Yes ) |
1735 | return true; | 1735 | return true; |
1736 | 1736 | ||
1737 | setSyncDevice("deleteaftersync" ); | 1737 | setSyncDevice("deleteaftersync" ); |
1738 | mSyncManager->mAskForPreferences = true; | 1738 | mSyncManager->mAskForPreferences = true; |
1739 | mSyncManager->mSyncAlgoPrefs = 3; | 1739 | mSyncManager->mSyncAlgoPrefs = 3; |
1740 | mSyncManager->mWriteBackFile = false; | 1740 | mSyncManager->mWriteBackFile = false; |
1741 | mSyncManager->mWriteBackExistingOnly = false; | 1741 | mSyncManager->mWriteBackExistingOnly = false; |
1742 | mSyncManager->mShowSyncSummary = false; | 1742 | mSyncManager->mShowSyncSummary = false; |
1743 | syncCalendar( fn, 3 ); | 1743 | syncCalendar( fn, 3 ); |
1744 | Event * e = getLastSyncEvent(); | 1744 | Event * e = getLastSyncEvent(); |
1745 | mCalendar->deleteEvent ( e ); | 1745 | mCalendar->deleteEvent ( e ); |
1746 | updateView(); | 1746 | updateView(); |
1747 | return true; | 1747 | return true; |
1748 | } | 1748 | } |
1749 | 1749 | ||
1750 | bool CalendarView::saveCalendar( QString filename ) | 1750 | bool CalendarView::saveCalendar( QString filename ) |
1751 | { | 1751 | { |
1752 | 1752 | ||
1753 | // Store back all unsaved data into calendar object | 1753 | // Store back all unsaved data into calendar object |
1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1755 | if ( mViewManager->currentView() ) | 1755 | if ( mViewManager->currentView() ) |
1756 | mViewManager->currentView()->flushView(); | 1756 | mViewManager->currentView()->flushView(); |
1757 | 1757 | ||
1758 | 1758 | ||
1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1760 | mStorage->setSaveFormat( new ICalFormat() ); | 1760 | mStorage->setSaveFormat( new ICalFormat() ); |
1761 | mStorage->setFileName( filename ); | 1761 | mStorage->setFileName( filename ); |
1762 | bool success; | 1762 | bool success; |
1763 | success = mStorage->save(); | 1763 | success = mStorage->save(); |
1764 | if ( !success ) { | 1764 | if ( !success ) { |
1765 | return false; | 1765 | return false; |
1766 | } | 1766 | } |
1767 | if ( filename == MainWindow::defaultFileName() ) { | 1767 | if ( filename == MainWindow::defaultFileName() ) { |
1768 | setLoadedFileVersion( lfv ); | 1768 | setLoadedFileVersion( lfv ); |
1769 | watchSavedFile(); | 1769 | watchSavedFile(); |
1770 | } | 1770 | } |
1771 | return true; | 1771 | return true; |
1772 | } | 1772 | } |
1773 | 1773 | ||
1774 | void CalendarView::closeCalendar() | 1774 | void CalendarView::closeCalendar() |
1775 | { | 1775 | { |
1776 | 1776 | ||
1777 | // child windows no longer valid | 1777 | // child windows no longer valid |
1778 | emit closingDown(); | 1778 | emit closingDown(); |
1779 | 1779 | ||
1780 | mCalendar->close(); | 1780 | mCalendar->close(); |
1781 | setModified(false); | 1781 | setModified(false); |
1782 | updateView(); | 1782 | updateView(); |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | void CalendarView::archiveCalendar() | 1785 | void CalendarView::archiveCalendar() |
1786 | { | 1786 | { |
1787 | mDialogManager->showArchiveDialog(); | 1787 | mDialogManager->showArchiveDialog(); |
1788 | } | 1788 | } |
1789 | 1789 | ||
1790 | 1790 | ||
1791 | void CalendarView::readSettings() | 1791 | void CalendarView::readSettings() |
1792 | { | 1792 | { |
1793 | 1793 | ||
1794 | 1794 | ||
1795 | // mViewManager->showAgendaView(); | 1795 | // mViewManager->showAgendaView(); |
1796 | QString str; | 1796 | QString str; |
1797 | //qDebug("CalendarView::readSettings() "); | 1797 | //qDebug("CalendarView::readSettings() "); |
1798 | // read settings from the KConfig, supplying reasonable | 1798 | // read settings from the KConfig, supplying reasonable |
1799 | // defaults where none are to be found | 1799 | // defaults where none are to be found |
1800 | KConfig *config = KOGlobals::config(); | 1800 | KConfig *config = KOGlobals::config(); |
1801 | #ifndef KORG_NOSPLITTER | 1801 | #ifndef KORG_NOSPLITTER |
1802 | config->setGroup("KOrganizer Geometry"); | 1802 | config->setGroup("KOrganizer Geometry"); |
1803 | 1803 | ||
1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1805 | if (sizes.count() != 2) { | 1805 | if (sizes.count() != 2) { |
1806 | sizes << mDateNavigator->minimumSizeHint().width(); | 1806 | sizes << mDateNavigator->minimumSizeHint().width(); |
1807 | sizes << 300; | 1807 | sizes << 300; |
1808 | } | 1808 | } |
1809 | mPanner->setSizes(sizes); | 1809 | mPanner->setSizes(sizes); |
1810 | 1810 | ||
1811 | sizes = config->readIntListEntry("Separator2"); | 1811 | sizes = config->readIntListEntry("Separator2"); |
1812 | if ( ( mResourceView && sizes.count() == 4 ) || | 1812 | if ( ( mResourceView && sizes.count() == 4 ) || |
1813 | ( !mResourceView && sizes.count() == 3 ) ) { | 1813 | ( !mResourceView && sizes.count() == 3 ) ) { |
1814 | mLeftSplitter->setSizes(sizes); | 1814 | mLeftSplitter->setSizes(sizes); |
1815 | } | 1815 | } |
1816 | #endif | 1816 | #endif |
1817 | globalFlagBlockAgenda = 1; | 1817 | globalFlagBlockAgenda = 1; |
1818 | mViewManager->showAgendaView(); | 1818 | mViewManager->showAgendaView(); |
1819 | //mViewManager->readSettings( config ); | 1819 | //mViewManager->readSettings( config ); |
1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1821 | readFilterSettings(config); | 1821 | readFilterSettings(config); |
1822 | config->setGroup( "Views" ); | 1822 | config->setGroup( "Views" ); |
1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1824 | 1824 | ||
1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1826 | 1826 | ||
1827 | int resetval = 0; | 1827 | int resetval = 0; |
1828 | int maxVal = 0; | 1828 | int maxVal = 0; |
1829 | if (sizes.count() != 3) { | 1829 | if (sizes.count() != 3) { |
1830 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1830 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1831 | resetval = mDateNavigator->sizeHint().width()+2; | 1831 | resetval = mDateNavigator->sizeHint().width()+2; |
1832 | } else { | 1832 | } else { |
1833 | resetval = mDateNavigator->sizeHint().height()+2; | 1833 | resetval = mDateNavigator->sizeHint().height()+2; |
1834 | } | 1834 | } |
1835 | } | 1835 | } |
1836 | if ( !resetval ){// i.e. sizes.count() == 3 | 1836 | if ( !resetval ){// i.e. sizes.count() == 3 |
1837 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1837 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | 1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) |
1839 | resetval = mDateNavigator->sizeHint().width()+2; | 1839 | resetval = mDateNavigator->sizeHint().width()+2; |
1840 | } else { | 1840 | } else { |
1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | 1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) |
1842 | resetval = mDateNavigator->sizeHint().height()+2; | 1842 | resetval = mDateNavigator->sizeHint().height()+2; |
1843 | } | 1843 | } |
1844 | } | 1844 | } |
1845 | if ( resetval ) { | 1845 | if ( resetval ) { |
1846 | sizes.clear(); | 1846 | sizes.clear(); |
1847 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1847 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1848 | maxVal = QApplication::desktop()->width() -10; | 1848 | maxVal = QApplication::desktop()->width() -10; |
1849 | } else { | 1849 | } else { |
1850 | maxVal = QApplication::desktop()->height()-10; | 1850 | maxVal = QApplication::desktop()->height()-10; |
1851 | } | 1851 | } |
1852 | sizes << resetval; | 1852 | sizes << resetval; |
1853 | if ( maxVal < resetval + resetval) | 1853 | if ( maxVal < resetval + resetval) |
1854 | resetval = maxVal - resetval; | 1854 | resetval = maxVal - resetval; |
1855 | sizes << resetval; | 1855 | sizes << resetval; |
1856 | sizes << 100; | 1856 | sizes << 100; |
1857 | } | 1857 | } |
1858 | mLeftFrame->setSizes(sizes); | 1858 | mLeftFrame->setSizes(sizes); |
1859 | qDebug("sizes count %d ", sizes.count()); | ||
1860 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1861 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1862 | else mNavigator->selectDates( dateCount ); | 1861 | else mNavigator->selectDates( dateCount ); |
1863 | // mViewManager->readSettings( config ); | 1862 | // mViewManager->readSettings( config ); |
1864 | updateConfig(); | 1863 | updateConfig(); |
1865 | globalFlagBlockAgenda = 2; | 1864 | globalFlagBlockAgenda = 2; |
1866 | mViewManager->readSettings( config ); | 1865 | mViewManager->readSettings( config ); |
1867 | #ifdef DESKTOP_VERSION | 1866 | #ifdef DESKTOP_VERSION |
1868 | config->setGroup("WidgetLayout"); | 1867 | config->setGroup("WidgetLayout"); |
1869 | QStringList list; | 1868 | QStringList list; |
1870 | list = config->readListEntry("MainLayout"); | 1869 | list = config->readListEntry("MainLayout"); |
1871 | int x,y,w,h; | 1870 | int x,y,w,h; |
1872 | if ( ! list.isEmpty() ) { | 1871 | if ( ! list.isEmpty() ) { |
1873 | x = list[0].toInt(); | 1872 | x = list[0].toInt(); |
1874 | y = list[1].toInt(); | 1873 | y = list[1].toInt(); |
1875 | w = list[2].toInt(); | 1874 | w = list[2].toInt(); |
1876 | h = list[3].toInt(); | 1875 | h = list[3].toInt(); |
1877 | topLevelWidget()->setGeometry(x,y,w,h); | 1876 | topLevelWidget()->setGeometry(x,y,w,h); |
1878 | 1877 | ||
1879 | } else { | 1878 | } else { |
1880 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1881 | } | 1880 | } |
1882 | list = config->readListEntry("EditEventLayout"); | 1881 | list = config->readListEntry("EditEventLayout"); |
1883 | if ( ! list.isEmpty() ) { | 1882 | if ( ! list.isEmpty() ) { |
1884 | x = list[0].toInt(); | 1883 | x = list[0].toInt(); |
1885 | y = list[1].toInt(); | 1884 | y = list[1].toInt(); |
1886 | w = list[2].toInt(); | 1885 | w = list[2].toInt(); |
1887 | h = list[3].toInt(); | 1886 | h = list[3].toInt(); |
1888 | mEventEditor->setGeometry(x,y,w,h); | 1887 | mEventEditor->setGeometry(x,y,w,h); |
1889 | 1888 | ||
1890 | } | 1889 | } |
1891 | list = config->readListEntry("EditTodoLayout"); | 1890 | list = config->readListEntry("EditTodoLayout"); |
1892 | if ( ! list.isEmpty() ) { | 1891 | if ( ! list.isEmpty() ) { |
1893 | x = list[0].toInt(); | 1892 | x = list[0].toInt(); |
1894 | y = list[1].toInt(); | 1893 | y = list[1].toInt(); |
1895 | w = list[2].toInt(); | 1894 | w = list[2].toInt(); |
1896 | h = list[3].toInt(); | 1895 | h = list[3].toInt(); |
1897 | mTodoEditor->setGeometry(x,y,w,h); | 1896 | mTodoEditor->setGeometry(x,y,w,h); |
1898 | 1897 | ||
1899 | } | 1898 | } |
1900 | list = config->readListEntry("ViewerLayout"); | 1899 | list = config->readListEntry("ViewerLayout"); |
1901 | if ( ! list.isEmpty() ) { | 1900 | if ( ! list.isEmpty() ) { |
1902 | x = list[0].toInt(); | 1901 | x = list[0].toInt(); |
1903 | y = list[1].toInt(); | 1902 | y = list[1].toInt(); |
1904 | w = list[2].toInt(); | 1903 | w = list[2].toInt(); |
1905 | h = list[3].toInt(); | 1904 | h = list[3].toInt(); |
1906 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1905 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1907 | } | 1906 | } |
1908 | #endif | 1907 | #endif |
1909 | 1908 | ||
1910 | } | 1909 | } |
1911 | 1910 | ||
1912 | 1911 | ||
1913 | void CalendarView::writeSettings() | 1912 | void CalendarView::writeSettings() |
1914 | { | 1913 | { |
1915 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1914 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1916 | 1915 | ||
1917 | KConfig *config = KOGlobals::config(); | 1916 | KConfig *config = KOGlobals::config(); |
1918 | 1917 | ||
1919 | #ifndef KORG_NOSPLITTER | 1918 | #ifndef KORG_NOSPLITTER |
1920 | config->setGroup("KOrganizer Geometry"); | 1919 | config->setGroup("KOrganizer Geometry"); |
1921 | 1920 | ||
1922 | QValueList<int> list = mPanner->sizes(); | 1921 | QValueList<int> list = mPanner->sizes(); |
1923 | config->writeEntry("Separator1",list); | 1922 | config->writeEntry("Separator1",list); |
1924 | 1923 | ||
1925 | list = mLeftSplitter->sizes(); | 1924 | list = mLeftSplitter->sizes(); |
1926 | config->writeEntry("Separator2",list); | 1925 | config->writeEntry("Separator2",list); |
1927 | #endif | 1926 | #endif |
1928 | 1927 | ||
1929 | mViewManager->writeSettings( config ); | 1928 | mViewManager->writeSettings( config ); |
1930 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1929 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1931 | mDialogManager->writeSettings( config ); | 1930 | mDialogManager->writeSettings( config ); |
1932 | //KOPrefs::instance()->usrWriteConfig(); | 1931 | //KOPrefs::instance()->usrWriteConfig(); |
1933 | KOPrefs::instance()->writeConfig(); | 1932 | KOPrefs::instance()->writeConfig(); |
1934 | 1933 | ||
1935 | writeFilterSettings(config); | 1934 | writeFilterSettings(config); |
1936 | 1935 | ||
1937 | config->setGroup( "Views" ); | 1936 | config->setGroup( "Views" ); |
1938 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1937 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1939 | 1938 | ||
1940 | QValueList<int> list = mLeftFrame->sizes(); | 1939 | QValueList<int> list = mLeftFrame->sizes(); |
1941 | config->writeEntry("Left Splitter Frame",list); | 1940 | config->writeEntry("Left Splitter Frame",list); |
1942 | 1941 | ||
1943 | #ifdef DESKTOP_VERSION | 1942 | #ifdef DESKTOP_VERSION |
1944 | config->setGroup("WidgetLayout"); | 1943 | config->setGroup("WidgetLayout"); |
1945 | QStringList list ;//= config->readListEntry("MainLayout"); | 1944 | QStringList list ;//= config->readListEntry("MainLayout"); |
1946 | int x,y,w,h; | 1945 | int x,y,w,h; |
1947 | QWidget* wid; | 1946 | QWidget* wid; |
1948 | wid = topLevelWidget(); | 1947 | wid = topLevelWidget(); |
1949 | x = wid->geometry().x(); | 1948 | x = wid->geometry().x(); |
1950 | y = wid->geometry().y(); | 1949 | y = wid->geometry().y(); |
1951 | w = wid->width(); | 1950 | w = wid->width(); |
1952 | h = wid->height(); | 1951 | h = wid->height(); |
1953 | list.clear(); | 1952 | list.clear(); |
1954 | list << QString::number( x ); | 1953 | list << QString::number( x ); |
1955 | list << QString::number( y ); | 1954 | list << QString::number( y ); |
1956 | list << QString::number( w ); | 1955 | list << QString::number( w ); |
1957 | list << QString::number( h ); | 1956 | list << QString::number( h ); |
1958 | config->writeEntry("MainLayout",list ); | 1957 | config->writeEntry("MainLayout",list ); |
1959 | 1958 | ||
1960 | wid = mEventEditor; | 1959 | wid = mEventEditor; |
1961 | x = wid->geometry().x(); | 1960 | x = wid->geometry().x(); |
1962 | y = wid->geometry().y(); | 1961 | y = wid->geometry().y(); |
1963 | w = wid->width(); | 1962 | w = wid->width(); |
1964 | h = wid->height(); | 1963 | h = wid->height(); |
1965 | list.clear(); | 1964 | list.clear(); |
1966 | list << QString::number( x ); | 1965 | list << QString::number( x ); |
1967 | list << QString::number( y ); | 1966 | list << QString::number( y ); |
1968 | list << QString::number( w ); | 1967 | list << QString::number( w ); |
1969 | list << QString::number( h ); | 1968 | list << QString::number( h ); |
1970 | config->writeEntry("EditEventLayout",list ); | 1969 | config->writeEntry("EditEventLayout",list ); |
1971 | 1970 | ||
1972 | wid = mTodoEditor; | 1971 | wid = mTodoEditor; |
1973 | x = wid->geometry().x(); | 1972 | x = wid->geometry().x(); |
1974 | y = wid->geometry().y(); | 1973 | y = wid->geometry().y(); |
1975 | w = wid->width(); | 1974 | w = wid->width(); |
1976 | h = wid->height(); | 1975 | h = wid->height(); |
1977 | list.clear(); | 1976 | list.clear(); |
1978 | list << QString::number( x ); | 1977 | list << QString::number( x ); |
1979 | list << QString::number( y ); | 1978 | list << QString::number( y ); |
1980 | list << QString::number( w ); | 1979 | list << QString::number( w ); |
1981 | list << QString::number( h ); | 1980 | list << QString::number( h ); |
1982 | config->writeEntry("EditTodoLayout",list ); | 1981 | config->writeEntry("EditTodoLayout",list ); |
1983 | wid = getEventViewerDialog(); | 1982 | wid = getEventViewerDialog(); |
1984 | x = wid->geometry().x(); | 1983 | x = wid->geometry().x(); |
1985 | y = wid->geometry().y(); | 1984 | y = wid->geometry().y(); |
1986 | w = wid->width(); | 1985 | w = wid->width(); |
1987 | h = wid->height(); | 1986 | h = wid->height(); |
1988 | list.clear(); | 1987 | list.clear(); |
1989 | list << QString::number( x ); | 1988 | list << QString::number( x ); |
1990 | list << QString::number( y ); | 1989 | list << QString::number( y ); |
1991 | list << QString::number( w ); | 1990 | list << QString::number( w ); |
1992 | list << QString::number( h ); | 1991 | list << QString::number( h ); |
1993 | config->writeEntry("ViewerLayout",list ); | 1992 | config->writeEntry("ViewerLayout",list ); |
1994 | wid = mDialogManager->getSearchDialog(); | 1993 | wid = mDialogManager->getSearchDialog(); |
1995 | if ( wid ) { | 1994 | if ( wid ) { |
1996 | x = wid->geometry().x(); | 1995 | x = wid->geometry().x(); |
1997 | y = wid->geometry().y(); | 1996 | y = wid->geometry().y(); |
1998 | w = wid->width(); | 1997 | w = wid->width(); |
1999 | h = wid->height(); | 1998 | h = wid->height(); |
2000 | list.clear(); | 1999 | list.clear(); |
2001 | list << QString::number( x ); | 2000 | list << QString::number( x ); |
2002 | list << QString::number( y ); | 2001 | list << QString::number( y ); |
2003 | list << QString::number( w ); | 2002 | list << QString::number( w ); |
2004 | list << QString::number( h ); | 2003 | list << QString::number( h ); |
2005 | config->writeEntry("SearchLayout",list ); | 2004 | config->writeEntry("SearchLayout",list ); |
2006 | } | 2005 | } |
2007 | #endif | 2006 | #endif |
2008 | 2007 | ||
2009 | 2008 | ||
2010 | config->sync(); | 2009 | config->sync(); |
2011 | } | 2010 | } |
2012 | 2011 | ||
2013 | void CalendarView::readFilterSettings(KConfig *config) | 2012 | void CalendarView::readFilterSettings(KConfig *config) |
2014 | { | 2013 | { |
2015 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2014 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2016 | 2015 | ||
2017 | mFilters.clear(); | 2016 | mFilters.clear(); |
2018 | 2017 | ||
2019 | config->setGroup("General"); | 2018 | config->setGroup("General"); |
2020 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2019 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2021 | 2020 | ||
2022 | QStringList::ConstIterator it = filterList.begin(); | 2021 | QStringList::ConstIterator it = filterList.begin(); |
2023 | QStringList::ConstIterator end = filterList.end(); | 2022 | QStringList::ConstIterator end = filterList.end(); |
2024 | while(it != end) { | 2023 | while(it != end) { |
2025 | // kdDebug() << " filter: " << (*it) << endl; | 2024 | // kdDebug() << " filter: " << (*it) << endl; |
2026 | 2025 | ||
2027 | CalFilter *filter; | 2026 | CalFilter *filter; |
2028 | filter = new CalFilter(*it); | 2027 | filter = new CalFilter(*it); |
2029 | config->setGroup("Filter_" + (*it)); | 2028 | config->setGroup("Filter_" + (*it)); |
2030 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2029 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2031 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2030 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2032 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2031 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2033 | mFilters.append(filter); | 2032 | mFilters.append(filter); |
2034 | 2033 | ||
2035 | ++it; | 2034 | ++it; |
2036 | } | 2035 | } |
2037 | 2036 | ||
2038 | if (mFilters.count() == 0) { | 2037 | if (mFilters.count() == 0) { |
2039 | CalFilter *filter = new CalFilter(i18n("Default")); | 2038 | CalFilter *filter = new CalFilter(i18n("Default")); |
2040 | mFilters.append(filter); | 2039 | mFilters.append(filter); |
2041 | } | 2040 | } |
2042 | mFilterView->updateFilters(); | 2041 | mFilterView->updateFilters(); |
2043 | config->setGroup("FilterView"); | 2042 | config->setGroup("FilterView"); |
2044 | 2043 | ||
2045 | mFilterView->blockSignals(true); | 2044 | mFilterView->blockSignals(true); |
2046 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2045 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2047 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2046 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2048 | mFilterView->blockSignals(false); | 2047 | mFilterView->blockSignals(false); |
2049 | // We do it manually to avoid it being done twice by the above calls | 2048 | // We do it manually to avoid it being done twice by the above calls |
2050 | updateFilter(); | 2049 | updateFilter(); |
2051 | } | 2050 | } |
2052 | 2051 | ||
2053 | void CalendarView::writeFilterSettings(KConfig *config) | 2052 | void CalendarView::writeFilterSettings(KConfig *config) |
2054 | { | 2053 | { |
2055 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2054 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2056 | 2055 | ||
2057 | QStringList filterList; | 2056 | QStringList filterList; |
2058 | 2057 | ||
2059 | CalFilter *filter = mFilters.first(); | 2058 | CalFilter *filter = mFilters.first(); |
2060 | while(filter) { | 2059 | while(filter) { |
2061 | // kdDebug() << " fn: " << filter->name() << endl; | 2060 | // kdDebug() << " fn: " << filter->name() << endl; |
2062 | filterList << filter->name(); | 2061 | filterList << filter->name(); |
2063 | config->setGroup("Filter_" + filter->name()); | 2062 | config->setGroup("Filter_" + filter->name()); |
2064 | config->writeEntry("Criteria",filter->criteria()); | 2063 | config->writeEntry("Criteria",filter->criteria()); |
2065 | config->writeEntry("CategoryList",filter->categoryList()); | 2064 | config->writeEntry("CategoryList",filter->categoryList()); |
2066 | filter = mFilters.next(); | 2065 | filter = mFilters.next(); |
2067 | } | 2066 | } |
2068 | config->setGroup("General"); | 2067 | config->setGroup("General"); |
2069 | config->writeEntry("CalendarFilters",filterList); | 2068 | config->writeEntry("CalendarFilters",filterList); |
2070 | 2069 | ||
2071 | config->setGroup("FilterView"); | 2070 | config->setGroup("FilterView"); |
2072 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2071 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2073 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2072 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2074 | } | 2073 | } |
2075 | 2074 | ||
2076 | 2075 | ||
2077 | void CalendarView::goToday() | 2076 | void CalendarView::goToday() |
2078 | { | 2077 | { |
2079 | if ( mViewManager->currentView()->isMonthView() ) | 2078 | if ( mViewManager->currentView()->isMonthView() ) |
2080 | mNavigator->selectTodayMonth(); | 2079 | mNavigator->selectTodayMonth(); |
2081 | else | 2080 | else |
2082 | mNavigator->selectToday(); | 2081 | mNavigator->selectToday(); |
2083 | } | 2082 | } |
2084 | 2083 | ||
2085 | void CalendarView::goNext() | 2084 | void CalendarView::goNext() |
2086 | { | 2085 | { |
2087 | mNavigator->selectNext(); | 2086 | mNavigator->selectNext(); |
2088 | } | 2087 | } |
2089 | 2088 | ||
2090 | void CalendarView::goPrevious() | 2089 | void CalendarView::goPrevious() |
2091 | { | 2090 | { |
2092 | mNavigator->selectPrevious(); | 2091 | mNavigator->selectPrevious(); |
2093 | } | 2092 | } |
2094 | void CalendarView::goNextMonth() | 2093 | void CalendarView::goNextMonth() |
2095 | { | 2094 | { |
2096 | mNavigator->selectNextMonth(); | 2095 | mNavigator->selectNextMonth(); |
2097 | } | 2096 | } |
2098 | 2097 | ||
2099 | void CalendarView::goPreviousMonth() | 2098 | void CalendarView::goPreviousMonth() |
2100 | { | 2099 | { |
2101 | mNavigator->selectPreviousMonth(); | 2100 | mNavigator->selectPreviousMonth(); |
2102 | } | 2101 | } |
2103 | void CalendarView::writeLocale() | 2102 | void CalendarView::writeLocale() |
2104 | { | 2103 | { |
2105 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2104 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2106 | #if 0 | 2105 | #if 0 |
2107 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2106 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2108 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2107 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2109 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2108 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2110 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2109 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2111 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2110 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2112 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2111 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2113 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2112 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2114 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2113 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2115 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2114 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2116 | KOPrefs::instance()->mDaylightsavingStart, | 2115 | KOPrefs::instance()->mDaylightsavingStart, |
2117 | KOPrefs::instance()->mDaylightsavingEnd ); | 2116 | KOPrefs::instance()->mDaylightsavingEnd ); |
2118 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2117 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2119 | #endif | 2118 | #endif |
2120 | } | 2119 | } |
2121 | void CalendarView::updateConfig() | 2120 | void CalendarView::updateConfig() |
2122 | { | 2121 | { |
2123 | writeLocale(); | 2122 | writeLocale(); |
2124 | if ( KOPrefs::instance()->mUseAppColors ) | 2123 | if ( KOPrefs::instance()->mUseAppColors ) |
2125 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2124 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2126 | emit configChanged(); | 2125 | emit configChanged(); |
2127 | mTodoList->updateConfig(); | 2126 | mTodoList->updateConfig(); |
2128 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2127 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2129 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2128 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2130 | // To make the "fill window" configurations work | 2129 | // To make the "fill window" configurations work |
2131 | //mViewManager->raiseCurrentView(); | 2130 | //mViewManager->raiseCurrentView(); |
2132 | } | 2131 | } |
2133 | 2132 | ||
2134 | 2133 | ||
2135 | void CalendarView::eventChanged(Event *event) | 2134 | void CalendarView::eventChanged(Event *event) |
2136 | { | 2135 | { |
2137 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2136 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2138 | //updateUnmanagedViews(); | 2137 | //updateUnmanagedViews(); |
2139 | } | 2138 | } |
2140 | 2139 | ||
2141 | void CalendarView::eventAdded(Event *event) | 2140 | void CalendarView::eventAdded(Event *event) |
2142 | { | 2141 | { |
2143 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2142 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2144 | } | 2143 | } |
2145 | 2144 | ||
2146 | void CalendarView::eventToBeDeleted(Event *) | 2145 | void CalendarView::eventToBeDeleted(Event *) |
2147 | { | 2146 | { |
2148 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2147 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2149 | } | 2148 | } |
2150 | 2149 | ||
2151 | void CalendarView::eventDeleted() | 2150 | void CalendarView::eventDeleted() |
2152 | { | 2151 | { |
2153 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2152 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2154 | } | 2153 | } |
2155 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2154 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2156 | { | 2155 | { |
2157 | changeIncidenceDisplay((Incidence *)which, action); | 2156 | changeIncidenceDisplay((Incidence *)which, action); |
2158 | mDateNavigator->updateView(); //LR | 2157 | mDateNavigator->updateView(); //LR |
2159 | //mDialogManager->updateSearchDialog(); | 2158 | //mDialogManager->updateSearchDialog(); |
2160 | 2159 | ||
2161 | if (which) { | 2160 | if (which) { |
2162 | mViewManager->updateWNview(); | 2161 | mViewManager->updateWNview(); |
2163 | //mTodoList->updateView(); | 2162 | //mTodoList->updateView(); |
2164 | } | 2163 | } |
2165 | 2164 | ||
2166 | } | 2165 | } |
2167 | 2166 | ||
2168 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2167 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2169 | { | 2168 | { |
2170 | updateUnmanagedViews(); | 2169 | updateUnmanagedViews(); |
2171 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2170 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2172 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2171 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2173 | mCalendar->checkAlarmForIncidence( 0, true ); | 2172 | mCalendar->checkAlarmForIncidence( 0, true ); |
2174 | if ( mEventViewerDialog ) | 2173 | if ( mEventViewerDialog ) |
2175 | mEventViewerDialog->hide(); | 2174 | mEventViewerDialog->hide(); |
2176 | } | 2175 | } |
2177 | else | 2176 | else |
2178 | mCalendar->checkAlarmForIncidence( which , false ); | 2177 | mCalendar->checkAlarmForIncidence( which , false ); |
2179 | } | 2178 | } |
2180 | 2179 | ||
2181 | // most of the changeEventDisplays() right now just call the view's | 2180 | // most of the changeEventDisplays() right now just call the view's |
2182 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2181 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2183 | void CalendarView::changeEventDisplay(Event *which, int action) | 2182 | void CalendarView::changeEventDisplay(Event *which, int action) |
2184 | { | 2183 | { |
2185 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2184 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2186 | changeIncidenceDisplay((Incidence *)which, action); | 2185 | changeIncidenceDisplay((Incidence *)which, action); |
2187 | mDateNavigator->updateView(); | 2186 | mDateNavigator->updateView(); |
2188 | //mDialogManager->updateSearchDialog(); | 2187 | //mDialogManager->updateSearchDialog(); |
2189 | 2188 | ||
2190 | if (which) { | 2189 | if (which) { |
2191 | // If there is an event view visible update the display | 2190 | // If there is an event view visible update the display |
2192 | mViewManager->currentView()->changeEventDisplay(which,action); | 2191 | mViewManager->currentView()->changeEventDisplay(which,action); |
2193 | // TODO: check, if update needed | 2192 | // TODO: check, if update needed |
2194 | // if (which->getTodoStatus()) { | 2193 | // if (which->getTodoStatus()) { |
2195 | mTodoList->updateView(); | 2194 | mTodoList->updateView(); |
2196 | // } | 2195 | // } |
2197 | } else { | 2196 | } else { |
2198 | mViewManager->currentView()->updateView(); | 2197 | mViewManager->currentView()->updateView(); |
2199 | } | 2198 | } |
2200 | } | 2199 | } |
2201 | 2200 | ||
2202 | 2201 | ||
2203 | void CalendarView::updateTodoViews() | 2202 | void CalendarView::updateTodoViews() |
2204 | { | 2203 | { |
2205 | mTodoList->updateView(); | 2204 | mTodoList->updateView(); |
2206 | mViewManager->currentView()->updateView(); | 2205 | mViewManager->currentView()->updateView(); |
2207 | 2206 | ||
2208 | } | 2207 | } |
2209 | 2208 | ||
2210 | 2209 | ||
2211 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2210 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2212 | { | 2211 | { |
2213 | mTodoList->updateView(); | 2212 | mTodoList->updateView(); |
2214 | mViewManager->updateView(start, end); | 2213 | mViewManager->updateView(start, end); |
2215 | //mDateNavigator->updateView(); | 2214 | //mDateNavigator->updateView(); |
2216 | } | 2215 | } |
2217 | 2216 | ||
2218 | void CalendarView::updateView() | 2217 | void CalendarView::updateView() |
2219 | { | 2218 | { |
2220 | DateList tmpList = mNavigator->selectedDates(); | 2219 | DateList tmpList = mNavigator->selectedDates(); |
2221 | 2220 | ||
2222 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2221 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2223 | mTodoList->updateView(); | 2222 | mTodoList->updateView(); |
2224 | // We assume that the navigator only selects consecutive days. | 2223 | // We assume that the navigator only selects consecutive days. |
2225 | updateView( tmpList.first(), tmpList.last() ); | 2224 | updateView( tmpList.first(), tmpList.last() ); |
2226 | } | 2225 | } |
2227 | 2226 | ||
2228 | void CalendarView::updateUnmanagedViews() | 2227 | void CalendarView::updateUnmanagedViews() |
2229 | { | 2228 | { |
2230 | mDateNavigator->updateDayMatrix(); | 2229 | mDateNavigator->updateDayMatrix(); |
2231 | } | 2230 | } |
2232 | 2231 | ||
2233 | int CalendarView::msgItemDelete(const QString name) | 2232 | int CalendarView::msgItemDelete(const QString name) |
2234 | { | 2233 | { |
2235 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2234 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2236 | i18n("This item will be\npermanently deleted."), | 2235 | i18n("This item will be\npermanently deleted."), |
2237 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2236 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2238 | } | 2237 | } |
2239 | 2238 | ||
2240 | 2239 | ||
2241 | void CalendarView::edit_cut() | 2240 | void CalendarView::edit_cut() |
2242 | { | 2241 | { |
2243 | Event *anEvent=0; | 2242 | Event *anEvent=0; |
2244 | 2243 | ||
2245 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2244 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2246 | 2245 | ||
2247 | if (mViewManager->currentView()->isEventView()) { | 2246 | if (mViewManager->currentView()->isEventView()) { |
2248 | if ( incidence && incidence->type() == "Event" ) { | 2247 | if ( incidence && incidence->type() == "Event" ) { |
2249 | anEvent = static_cast<Event *>(incidence); | 2248 | anEvent = static_cast<Event *>(incidence); |
2250 | } | 2249 | } |
2251 | } | 2250 | } |
2252 | 2251 | ||
2253 | if (!anEvent) { | 2252 | if (!anEvent) { |
2254 | KNotifyClient::beep(); | 2253 | KNotifyClient::beep(); |
2255 | return; | 2254 | return; |
2256 | } | 2255 | } |
2257 | DndFactory factory( mCalendar ); | 2256 | DndFactory factory( mCalendar ); |
2258 | factory.cutIncidence(anEvent); | 2257 | factory.cutIncidence(anEvent); |
2259 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2258 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2260 | } | 2259 | } |
2261 | 2260 | ||
2262 | void CalendarView::edit_copy() | 2261 | void CalendarView::edit_copy() |
2263 | { | 2262 | { |
2264 | Event *anEvent=0; | 2263 | Event *anEvent=0; |
2265 | 2264 | ||
2266 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2265 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2267 | 2266 | ||
2268 | if (mViewManager->currentView()->isEventView()) { | 2267 | if (mViewManager->currentView()->isEventView()) { |
2269 | if ( incidence && incidence->type() == "Event" ) { | 2268 | if ( incidence && incidence->type() == "Event" ) { |
2270 | anEvent = static_cast<Event *>(incidence); | 2269 | anEvent = static_cast<Event *>(incidence); |
2271 | } | 2270 | } |
2272 | } | 2271 | } |
2273 | 2272 | ||
2274 | if (!anEvent) { | 2273 | if (!anEvent) { |
2275 | KNotifyClient::beep(); | 2274 | KNotifyClient::beep(); |
2276 | return; | 2275 | return; |
2277 | } | 2276 | } |
2278 | DndFactory factory( mCalendar ); | 2277 | DndFactory factory( mCalendar ); |
2279 | factory.copyIncidence(anEvent); | 2278 | factory.copyIncidence(anEvent); |
2280 | } | 2279 | } |
2281 | 2280 | ||
2282 | void CalendarView::edit_paste() | 2281 | void CalendarView::edit_paste() |
2283 | { | 2282 | { |
2284 | QDate date = mNavigator->selectedDates().first(); | 2283 | QDate date = mNavigator->selectedDates().first(); |
2285 | 2284 | ||
2286 | DndFactory factory( mCalendar ); | 2285 | DndFactory factory( mCalendar ); |
2287 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2286 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2288 | 2287 | ||
2289 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2288 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2290 | } | 2289 | } |
2291 | 2290 | ||
2292 | void CalendarView::edit_options() | 2291 | void CalendarView::edit_options() |
2293 | { | 2292 | { |
2294 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2293 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2295 | emit save(); | 2294 | emit save(); |
2296 | emit saveStopTimer(); | 2295 | emit saveStopTimer(); |
2297 | mDialogManager->showOptionsDialog(); | 2296 | mDialogManager->showOptionsDialog(); |
2298 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2297 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2299 | emit saveStopTimer(); | 2298 | emit saveStopTimer(); |
2300 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), | 2299 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), |
2301 | i18n("Timezone settings"),i18n("Reload"))) { | 2300 | i18n("Timezone settings"),i18n("Reload"))) { |
2302 | qDebug("KO: TZ reload cancelled "); | 2301 | qDebug("KO: TZ reload cancelled "); |
2303 | return; | 2302 | return; |
2304 | } | 2303 | } |
2305 | qDebug("KO: Timezone change "); | 2304 | qDebug("KO: Timezone change "); |
2306 | openCalendar( MainWindow::defaultFileName() ); | 2305 | openCalendar( MainWindow::defaultFileName() ); |
2307 | setModified(true); | 2306 | setModified(true); |
2308 | } | 2307 | } |
2309 | else | 2308 | else |
2310 | qDebug("KO: No tz change "); | 2309 | qDebug("KO: No tz change "); |
2311 | 2310 | ||
2312 | } | 2311 | } |
2313 | 2312 | ||
2314 | 2313 | ||
2315 | void CalendarView::slotSelectPickerDate( QDate d) | 2314 | void CalendarView::slotSelectPickerDate( QDate d) |
2316 | { | 2315 | { |
2317 | mDateFrame->hide(); | 2316 | mDateFrame->hide(); |
2318 | if ( mDatePickerMode == 1 ) { | 2317 | if ( mDatePickerMode == 1 ) { |
2319 | mNavigator->slotDaySelect( d ); | 2318 | mNavigator->slotDaySelect( d ); |
2320 | } else if ( mDatePickerMode == 2 ) { | 2319 | } else if ( mDatePickerMode == 2 ) { |
2321 | if ( mMoveIncidence->type() == "Todo" ) { | 2320 | if ( mMoveIncidence->type() == "Todo" ) { |
2322 | Todo * to = (Todo *) mMoveIncidence; | 2321 | Todo * to = (Todo *) mMoveIncidence; |
2323 | QTime tim; | 2322 | QTime tim; |
2324 | int len = 0; | 2323 | int len = 0; |
2325 | if ( to->hasStartDate() && to->hasDueDate() ) | 2324 | if ( to->hasStartDate() && to->hasDueDate() ) |
2326 | len = to->dtStart().secsTo( to->dtDue()); | 2325 | len = to->dtStart().secsTo( to->dtDue()); |
2327 | if ( to->hasDueDate() ) | 2326 | if ( to->hasDueDate() ) |
2328 | tim = to->dtDue().time(); | 2327 | tim = to->dtDue().time(); |
2329 | else { | 2328 | else { |
2330 | tim = QTime ( 0,0,0 ); | 2329 | tim = QTime ( 0,0,0 ); |
2331 | to->setFloats( true ); | 2330 | to->setFloats( true ); |
2332 | to->setHasDueDate( true ); | 2331 | to->setHasDueDate( true ); |
2333 | } | 2332 | } |
2334 | QDateTime dt ( d,tim ); | 2333 | QDateTime dt ( d,tim ); |
2335 | to->setDtDue( dt ); | 2334 | to->setDtDue( dt ); |
2336 | 2335 | ||
2337 | if ( to->hasStartDate() ) { | 2336 | if ( to->hasStartDate() ) { |
2338 | if ( len>0 ) | 2337 | if ( len>0 ) |
2339 | to->setDtStart(to->dtDue().addSecs( -len )); | 2338 | to->setDtStart(to->dtDue().addSecs( -len )); |
2340 | else | 2339 | else |
2341 | if (to->dtStart() > to->dtDue() ) | 2340 | if (to->dtStart() > to->dtDue() ) |
2342 | to->setDtStart(to->dtDue().addDays( -3 )); | 2341 | to->setDtStart(to->dtDue().addDays( -3 )); |
2343 | } | 2342 | } |
2344 | 2343 | ||
2345 | todoChanged( to ); | 2344 | todoChanged( to ); |
2346 | } else { | 2345 | } else { |
2347 | if ( mMoveIncidence->doesRecur() ) { | 2346 | if ( mMoveIncidence->doesRecur() ) { |
2348 | #if 0 | 2347 | #if 0 |
2349 | // PENDING implement this | 2348 | // PENDING implement this |
2350 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2349 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2351 | mCalendar()->addIncidence( newInc ); | 2350 | mCalendar()->addIncidence( newInc ); |
2352 | if ( mMoveIncidence->type() == "Todo" ) | 2351 | if ( mMoveIncidence->type() == "Todo" ) |
2353 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2352 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2354 | else | 2353 | else |
2355 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2354 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2356 | mMoveIncidence = newInc; | 2355 | mMoveIncidence = newInc; |
2357 | 2356 | ||
2358 | #endif | 2357 | #endif |
2359 | } | 2358 | } |
2360 | QTime tim = mMoveIncidence->dtStart().time(); | 2359 | QTime tim = mMoveIncidence->dtStart().time(); |
2361 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2360 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2362 | QDateTime dt ( d,tim ); | 2361 | QDateTime dt ( d,tim ); |
2363 | mMoveIncidence->setDtStart( dt ); | 2362 | mMoveIncidence->setDtStart( dt ); |
2364 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2363 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2365 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2364 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2366 | } | 2365 | } |
2367 | 2366 | ||
2368 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2367 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2369 | } | 2368 | } |
2370 | } | 2369 | } |
2371 | 2370 | ||
2372 | void CalendarView::removeCategories() | 2371 | void CalendarView::removeCategories() |
2373 | { | 2372 | { |
2374 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2373 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2375 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2374 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2376 | QStringList catIncList; | 2375 | QStringList catIncList; |
2377 | QStringList newCatList; | 2376 | QStringList newCatList; |
2378 | Incidence* inc = incList.first(); | 2377 | Incidence* inc = incList.first(); |
2379 | int i; | 2378 | int i; |
2380 | int count = 0; | 2379 | int count = 0; |
2381 | while ( inc ) { | 2380 | while ( inc ) { |
2382 | newCatList.clear(); | 2381 | newCatList.clear(); |
2383 | catIncList = inc->categories() ; | 2382 | catIncList = inc->categories() ; |
2384 | for( i = 0; i< catIncList.count(); ++i ) { | 2383 | for( i = 0; i< catIncList.count(); ++i ) { |
2385 | if ( catList.contains (catIncList[i])) | 2384 | if ( catList.contains (catIncList[i])) |
2386 | newCatList.append( catIncList[i] ); | 2385 | newCatList.append( catIncList[i] ); |
2387 | } | 2386 | } |
2388 | newCatList.sort(); | 2387 | newCatList.sort(); |
2389 | inc->setCategories( newCatList.join(",") ); | 2388 | inc->setCategories( newCatList.join(",") ); |
2390 | inc = incList.next(); | 2389 | inc = incList.next(); |
2391 | } | 2390 | } |
2392 | } | 2391 | } |
2393 | 2392 | ||
2394 | int CalendarView::addCategories() | 2393 | int CalendarView::addCategories() |
2395 | { | 2394 | { |
2396 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2395 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2397 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2396 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2398 | QStringList catIncList; | 2397 | QStringList catIncList; |
2399 | Incidence* inc = incList.first(); | 2398 | Incidence* inc = incList.first(); |
2400 | int i; | 2399 | int i; |
2401 | int count = 0; | 2400 | int count = 0; |
2402 | while ( inc ) { | 2401 | while ( inc ) { |
2403 | catIncList = inc->categories() ; | 2402 | catIncList = inc->categories() ; |
2404 | for( i = 0; i< catIncList.count(); ++i ) { | 2403 | for( i = 0; i< catIncList.count(); ++i ) { |
2405 | if ( !catList.contains (catIncList[i])) { | 2404 | if ( !catList.contains (catIncList[i])) { |
2406 | catList.append( catIncList[i] ); | 2405 | catList.append( catIncList[i] ); |
2407 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2406 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2408 | ++count; | 2407 | ++count; |
2409 | } | 2408 | } |
2410 | } | 2409 | } |
2411 | inc = incList.next(); | 2410 | inc = incList.next(); |
2412 | } | 2411 | } |
2413 | catList.sort(); | 2412 | catList.sort(); |
2414 | KOPrefs::instance()->mCustomCategories = catList; | 2413 | KOPrefs::instance()->mCustomCategories = catList; |
2415 | return count; | 2414 | return count; |
2416 | } | 2415 | } |
2417 | 2416 | ||
2418 | void CalendarView::manageCategories() | 2417 | void CalendarView::manageCategories() |
2419 | { | 2418 | { |
2420 | KOCatPrefs* cp = new KOCatPrefs(); | 2419 | KOCatPrefs* cp = new KOCatPrefs(); |
2421 | cp->show(); | 2420 | cp->show(); |
2422 | int w =cp->sizeHint().width() ; | 2421 | int w =cp->sizeHint().width() ; |
2423 | int h = cp->sizeHint().height() ; | 2422 | int h = cp->sizeHint().height() ; |
2424 | int dw = QApplication::desktop()->width(); | 2423 | int dw = QApplication::desktop()->width(); |
2425 | int dh = QApplication::desktop()->height(); | 2424 | int dh = QApplication::desktop()->height(); |
2426 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2425 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2427 | if ( !cp->exec() ) { | 2426 | if ( !cp->exec() ) { |
2428 | delete cp; | 2427 | delete cp; |
2429 | return; | 2428 | return; |
2430 | } | 2429 | } |
2431 | int count = 0; | 2430 | int count = 0; |
2432 | if ( cp->addCat() ) { | 2431 | if ( cp->addCat() ) { |
2433 | count = addCategories(); | 2432 | count = addCategories(); |
2434 | if ( count ) { | 2433 | if ( count ) { |
2435 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2434 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2436 | writeSettings(); | 2435 | writeSettings(); |
2437 | } else | 2436 | } else |
2438 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2437 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2439 | } else { | 2438 | } else { |
2440 | removeCategories(); | 2439 | removeCategories(); |
2441 | updateView(); | 2440 | updateView(); |
2442 | } | 2441 | } |
2443 | delete cp; | 2442 | delete cp; |
2444 | } | 2443 | } |
2445 | 2444 | ||
2446 | void CalendarView::beamIncidence(Incidence * Inc) | 2445 | void CalendarView::beamIncidence(Incidence * Inc) |
2447 | { | 2446 | { |
2448 | QPtrList<Incidence> delSel ; | 2447 | QPtrList<Incidence> delSel ; |
2449 | delSel.append(Inc); | 2448 | delSel.append(Inc); |
2450 | beamIncidenceList( delSel ); | 2449 | beamIncidenceList( delSel ); |
2451 | } | 2450 | } |
2452 | void CalendarView::beamCalendar() | 2451 | void CalendarView::beamCalendar() |
2453 | { | 2452 | { |
2454 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2453 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2455 | //qDebug("beamCalendar() "); | 2454 | //qDebug("beamCalendar() "); |
2456 | beamIncidenceList( delSel ); | 2455 | beamIncidenceList( delSel ); |
2457 | } | 2456 | } |
2458 | void CalendarView::beamFilteredCalendar() | 2457 | void CalendarView::beamFilteredCalendar() |
2459 | { | 2458 | { |
2460 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2459 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2461 | //qDebug("beamFilteredCalendar() "); | 2460 | //qDebug("beamFilteredCalendar() "); |
2462 | beamIncidenceList( delSel ); | 2461 | beamIncidenceList( delSel ); |
2463 | } | 2462 | } |
2464 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2463 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2465 | { | 2464 | { |
2466 | if ( beamDialog->exec () == QDialog::Rejected ) | 2465 | if ( beamDialog->exec () == QDialog::Rejected ) |
2467 | return; | 2466 | return; |
2468 | #ifdef DESKTOP_VERSION | 2467 | #ifdef DESKTOP_VERSION |
2469 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2468 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2470 | #else | 2469 | #else |
2471 | QString fn = "/tmp/kopibeamfile"; | 2470 | QString fn = "/tmp/kopibeamfile"; |
2472 | #endif | 2471 | #endif |
2473 | QString mes; | 2472 | QString mes; |
2474 | bool createbup = true; | 2473 | bool createbup = true; |
2475 | if ( createbup ) { | 2474 | if ( createbup ) { |
2476 | QString description = "\n"; | 2475 | QString description = "\n"; |
2477 | CalendarLocal* cal = new CalendarLocal(); | 2476 | CalendarLocal* cal = new CalendarLocal(); |
2478 | if ( beamDialog->beamLocal() ) | 2477 | if ( beamDialog->beamLocal() ) |
2479 | cal->setLocalTime(); | 2478 | cal->setLocalTime(); |
2480 | else | 2479 | else |
2481 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2480 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2482 | Incidence *incidence = delSel.first(); | 2481 | Incidence *incidence = delSel.first(); |
2483 | bool addText = false; | 2482 | bool addText = false; |
2484 | if ( delSel.count() < 10 ) | 2483 | if ( delSel.count() < 10 ) |
2485 | addText = true; | 2484 | addText = true; |
2486 | else { | 2485 | else { |
2487 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2486 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2488 | } | 2487 | } |
2489 | while ( incidence ) { | 2488 | while ( incidence ) { |
2490 | Incidence *in = incidence->clone(); | 2489 | Incidence *in = incidence->clone(); |
2491 | if ( ! in->summary().isEmpty() ) { | 2490 | if ( ! in->summary().isEmpty() ) { |
2492 | in->setDescription(""); | 2491 | in->setDescription(""); |
2493 | } else { | 2492 | } else { |
2494 | in->setSummary( in->description().left(20)); | 2493 | in->setSummary( in->description().left(20)); |
2495 | in->setDescription(""); | 2494 | in->setDescription(""); |
2496 | } | 2495 | } |
2497 | if ( addText ) | 2496 | if ( addText ) |
2498 | description += in->summary() + "\n"; | 2497 | description += in->summary() + "\n"; |
2499 | cal->addIncidence( in ); | 2498 | cal->addIncidence( in ); |
2500 | incidence = delSel.next(); | 2499 | incidence = delSel.next(); |
2501 | } | 2500 | } |
2502 | if ( beamDialog->beamVcal() ) { | 2501 | if ( beamDialog->beamVcal() ) { |
2503 | fn += ".vcs"; | 2502 | fn += ".vcs"; |
2504 | FileStorage storage( cal, fn, new VCalFormat ); | 2503 | FileStorage storage( cal, fn, new VCalFormat ); |
2505 | storage.save(); | 2504 | storage.save(); |
2506 | } else { | 2505 | } else { |
2507 | fn += ".ics"; | 2506 | fn += ".ics"; |
2508 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2507 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2509 | storage.save(); | 2508 | storage.save(); |
2510 | } | 2509 | } |
2511 | delete cal; | 2510 | delete cal; |
2512 | mes = i18n("KO/Pi: Ready for beaming"); | 2511 | mes = i18n("KO/Pi: Ready for beaming"); |
2513 | topLevelWidget()->setCaption(mes); | 2512 | topLevelWidget()->setCaption(mes); |
2514 | KApplication::convert2latin1( fn ); | 2513 | KApplication::convert2latin1( fn ); |
2515 | #ifndef DESKTOP_VERSION | 2514 | #ifndef DESKTOP_VERSION |
2516 | Ir *ir = new Ir( this ); | 2515 | Ir *ir = new Ir( this ); |
2517 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2516 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2518 | ir->send( fn, description, "text/x-vCalendar" ); | 2517 | ir->send( fn, description, "text/x-vCalendar" ); |
2519 | #endif | 2518 | #endif |
2520 | } | 2519 | } |
2521 | } | 2520 | } |
2522 | void CalendarView::beamDone( Ir *ir ) | 2521 | void CalendarView::beamDone( Ir *ir ) |
2523 | { | 2522 | { |
2524 | #ifndef DESKTOP_VERSION | 2523 | #ifndef DESKTOP_VERSION |
2525 | delete ir; | 2524 | delete ir; |
2526 | #endif | 2525 | #endif |
2527 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2526 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2528 | topLevelWidget()->raise(); | 2527 | topLevelWidget()->raise(); |
2529 | } | 2528 | } |
2530 | 2529 | ||
2531 | void CalendarView::moveIncidence(Incidence * inc ) | 2530 | void CalendarView::moveIncidence(Incidence * inc ) |
2532 | { | 2531 | { |
2533 | if ( !inc ) return; | 2532 | if ( !inc ) return; |
2534 | showDatePickerPopup(); | 2533 | showDatePickerPopup(); |
2535 | mDatePickerMode = 2; | 2534 | mDatePickerMode = 2; |
2536 | mMoveIncidence = inc ; | 2535 | mMoveIncidence = inc ; |
2537 | QDate da; | 2536 | QDate da; |
2538 | if ( mMoveIncidence->type() == "Todo" ) { | 2537 | if ( mMoveIncidence->type() == "Todo" ) { |
2539 | Todo * to = (Todo *) mMoveIncidence; | 2538 | Todo * to = (Todo *) mMoveIncidence; |
2540 | if ( to->hasDueDate() ) | 2539 | if ( to->hasDueDate() ) |
2541 | da = to->dtDue().date(); | 2540 | da = to->dtDue().date(); |
2542 | else | 2541 | else |
2543 | da = QDate::currentDate(); | 2542 | da = QDate::currentDate(); |
2544 | } else { | 2543 | } else { |
2545 | da = mMoveIncidence->dtStart().date(); | 2544 | da = mMoveIncidence->dtStart().date(); |
2546 | } | 2545 | } |
2547 | //PENDING set date for recurring incidence to date of recurrence | 2546 | //PENDING set date for recurring incidence to date of recurrence |
2548 | //mMoveIncidenceOldDate; | 2547 | //mMoveIncidenceOldDate; |
2549 | mDatePicker->setDate( da ); | 2548 | mDatePicker->setDate( da ); |
2550 | } | 2549 | } |
2551 | void CalendarView::showDatePickerPopup() | 2550 | void CalendarView::showDatePickerPopup() |
2552 | { | 2551 | { |
2553 | if ( mDateFrame->isVisible() ) | 2552 | if ( mDateFrame->isVisible() ) |
2554 | mDateFrame->hide(); | 2553 | mDateFrame->hide(); |
2555 | else { | 2554 | else { |
2556 | int offX = 0, offY = 0; | 2555 | int offX = 0, offY = 0; |
2557 | #ifdef DESKTOP_VERSION | 2556 | #ifdef DESKTOP_VERSION |
2558 | int w =mDatePicker->sizeHint().width() ; | 2557 | int w =mDatePicker->sizeHint().width() ; |
2559 | int h = mDatePicker->sizeHint().height() ; | 2558 | int h = mDatePicker->sizeHint().height() ; |
2560 | int dw = topLevelWidget()->width(); | 2559 | int dw = topLevelWidget()->width(); |
2561 | int dh = topLevelWidget()->height(); | 2560 | int dh = topLevelWidget()->height(); |
2562 | offX = topLevelWidget()->x(); | 2561 | offX = topLevelWidget()->x(); |
2563 | offY = topLevelWidget()->y(); | 2562 | offY = topLevelWidget()->y(); |
2564 | #else | 2563 | #else |
2565 | int w =mDatePicker->sizeHint().width() ; | 2564 | int w =mDatePicker->sizeHint().width() ; |
2566 | int h = mDatePicker->sizeHint().height() ; | 2565 | int h = mDatePicker->sizeHint().height() ; |
2567 | int dw = QApplication::desktop()->width(); | 2566 | int dw = QApplication::desktop()->width(); |
2568 | int dh = QApplication::desktop()->height(); | 2567 | int dh = QApplication::desktop()->height(); |
2569 | #endif | 2568 | #endif |
2570 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2569 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2571 | mDateFrame->show(); | 2570 | mDateFrame->show(); |
2572 | } | 2571 | } |
2573 | } | 2572 | } |
2574 | void CalendarView::showDatePicker( ) | 2573 | void CalendarView::showDatePicker( ) |
2575 | { | 2574 | { |
2576 | showDatePickerPopup(); | 2575 | showDatePickerPopup(); |
2577 | mDatePickerMode = 1; | 2576 | mDatePickerMode = 1; |
2578 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2577 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2579 | } | 2578 | } |
2580 | 2579 | ||
2581 | void CalendarView::showEventEditor() | 2580 | void CalendarView::showEventEditor() |
2582 | { | 2581 | { |
2583 | #ifdef DESKTOP_VERSION | 2582 | #ifdef DESKTOP_VERSION |
2584 | int x,y,w,h; | 2583 | int x,y,w,h; |
2585 | x = mEventEditor->geometry().x(); | 2584 | x = mEventEditor->geometry().x(); |
2586 | y = mEventEditor->geometry().y(); | 2585 | y = mEventEditor->geometry().y(); |
2587 | w = mEventEditor->width(); | 2586 | w = mEventEditor->width(); |
2588 | h = mEventEditor->height(); | 2587 | h = mEventEditor->height(); |
2589 | mEventEditor->show(); | 2588 | mEventEditor->show(); |
2590 | mEventEditor->setGeometry(x,y,w,h); | 2589 | mEventEditor->setGeometry(x,y,w,h); |
2591 | #else | 2590 | #else |
2592 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2591 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2593 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2592 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2594 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2593 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2595 | qApp->processEvents(); | 2594 | qApp->processEvents(); |
2596 | delete mEventEditor; | 2595 | delete mEventEditor; |
2597 | mEventEditor = mDialogManager->getEventEditor(); | 2596 | mEventEditor = mDialogManager->getEventEditor(); |
2598 | topLevelWidget()->setCaption( i18n("") ); | 2597 | topLevelWidget()->setCaption( i18n("") ); |
2599 | } | 2598 | } |
2600 | mEventEditor->showMaximized(); | 2599 | mEventEditor->showMaximized(); |
2601 | #endif | 2600 | #endif |
2602 | } | 2601 | } |
2603 | void CalendarView::showTodoEditor() | 2602 | void CalendarView::showTodoEditor() |
2604 | { | 2603 | { |
2605 | #ifdef DESKTOP_VERSION | 2604 | #ifdef DESKTOP_VERSION |
2606 | int x,y,w,h; | 2605 | int x,y,w,h; |
2607 | x = mTodoEditor->geometry().x(); | 2606 | x = mTodoEditor->geometry().x(); |
2608 | y = mTodoEditor->geometry().y(); | 2607 | y = mTodoEditor->geometry().y(); |
2609 | w = mTodoEditor->width(); | 2608 | w = mTodoEditor->width(); |
2610 | h = mTodoEditor->height(); | 2609 | h = mTodoEditor->height(); |
2611 | mTodoEditor->show(); | 2610 | mTodoEditor->show(); |
2612 | mTodoEditor->setGeometry(x,y,w,h); | 2611 | mTodoEditor->setGeometry(x,y,w,h); |
2613 | #else | 2612 | #else |
2614 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2613 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2615 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2614 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2616 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2615 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2617 | qApp->processEvents(); | 2616 | qApp->processEvents(); |
2618 | delete mTodoEditor; | 2617 | delete mTodoEditor; |
2619 | mTodoEditor = mDialogManager->getTodoEditor(); | 2618 | mTodoEditor = mDialogManager->getTodoEditor(); |
2620 | topLevelWidget()->setCaption( i18n("") ); | 2619 | topLevelWidget()->setCaption( i18n("") ); |
2621 | } | 2620 | } |
2622 | mTodoEditor->showMaximized(); | 2621 | mTodoEditor->showMaximized(); |
2623 | #endif | 2622 | #endif |
2624 | } | 2623 | } |
2625 | 2624 | ||
2626 | void CalendarView::cloneIncidence() | 2625 | void CalendarView::cloneIncidence() |
2627 | { | 2626 | { |
2628 | Incidence *incidence = currentSelection(); | 2627 | Incidence *incidence = currentSelection(); |
2629 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2628 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2630 | if ( incidence ) { | 2629 | if ( incidence ) { |
2631 | cloneIncidence(incidence); | 2630 | cloneIncidence(incidence); |
2632 | } | 2631 | } |
2633 | } | 2632 | } |
2634 | void CalendarView::moveIncidence() | 2633 | void CalendarView::moveIncidence() |
2635 | { | 2634 | { |
2636 | Incidence *incidence = currentSelection(); | 2635 | Incidence *incidence = currentSelection(); |
2637 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2636 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2638 | if ( incidence ) { | 2637 | if ( incidence ) { |
2639 | moveIncidence(incidence); | 2638 | moveIncidence(incidence); |
2640 | } | 2639 | } |
2641 | } | 2640 | } |
2642 | void CalendarView::beamIncidence() | 2641 | void CalendarView::beamIncidence() |
2643 | { | 2642 | { |
2644 | Incidence *incidence = currentSelection(); | 2643 | Incidence *incidence = currentSelection(); |
2645 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2644 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2646 | if ( incidence ) { | 2645 | if ( incidence ) { |
2647 | beamIncidence(incidence); | 2646 | beamIncidence(incidence); |
2648 | } | 2647 | } |
2649 | } | 2648 | } |
2650 | void CalendarView::toggleCancelIncidence() | 2649 | void CalendarView::toggleCancelIncidence() |
2651 | { | 2650 | { |
2652 | Incidence *incidence = currentSelection(); | 2651 | Incidence *incidence = currentSelection(); |
2653 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2652 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2654 | if ( incidence ) { | 2653 | if ( incidence ) { |
2655 | cancelIncidence(incidence); | 2654 | cancelIncidence(incidence); |
2656 | } | 2655 | } |
2657 | } | 2656 | } |
2658 | 2657 | ||
2659 | 2658 | ||
2660 | void CalendarView::cancelIncidence(Incidence * inc ) | 2659 | void CalendarView::cancelIncidence(Incidence * inc ) |
2661 | { | 2660 | { |
2662 | inc->setCancelled( ! inc->cancelled() ); | 2661 | inc->setCancelled( ! inc->cancelled() ); |
2663 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2662 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2664 | updateView(); | 2663 | updateView(); |
2665 | } | 2664 | } |
2666 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2665 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2667 | { | 2666 | { |
2668 | Incidence * newInc = orgInc->clone(); | 2667 | Incidence * newInc = orgInc->clone(); |
2669 | newInc->recreate(); | 2668 | newInc->recreate(); |
2670 | 2669 | ||
2671 | if ( newInc->type() == "Todo" ) { | 2670 | if ( newInc->type() == "Todo" ) { |
2672 | Todo* t = (Todo*) newInc; | 2671 | Todo* t = (Todo*) newInc; |
2673 | showTodoEditor(); | 2672 | showTodoEditor(); |
2674 | mTodoEditor->editTodo( t ); | 2673 | mTodoEditor->editTodo( t ); |
2675 | if ( mTodoEditor->exec() ) { | 2674 | if ( mTodoEditor->exec() ) { |
2676 | mCalendar->addTodo( t ); | 2675 | mCalendar->addTodo( t ); |
2677 | updateView(); | 2676 | updateView(); |
2678 | } else { | 2677 | } else { |
2679 | delete t; | 2678 | delete t; |
2680 | } | 2679 | } |
2681 | } | 2680 | } |
2682 | else { | 2681 | else { |
2683 | Event* e = (Event*) newInc; | 2682 | Event* e = (Event*) newInc; |
2684 | showEventEditor(); | 2683 | showEventEditor(); |
2685 | mEventEditor->editEvent( e ); | 2684 | mEventEditor->editEvent( e ); |
2686 | if ( mEventEditor->exec() ) { | 2685 | if ( mEventEditor->exec() ) { |
2687 | mCalendar->addEvent( e ); | 2686 | mCalendar->addEvent( e ); |
2688 | updateView(); | 2687 | updateView(); |
2689 | } else { | 2688 | } else { |
2690 | delete e; | 2689 | delete e; |
2691 | } | 2690 | } |
2692 | } | 2691 | } |
2693 | setActiveWindow(); | 2692 | setActiveWindow(); |
2694 | } | 2693 | } |
2695 | 2694 | ||
2696 | void CalendarView::newEvent() | 2695 | void CalendarView::newEvent() |
2697 | { | 2696 | { |
2698 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2697 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2699 | KOAgendaView *aView = mViewManager->agendaView(); | 2698 | KOAgendaView *aView = mViewManager->agendaView(); |
2700 | if (aView) { | 2699 | if (aView) { |
2701 | if (aView->selectionStart().isValid()) { | 2700 | if (aView->selectionStart().isValid()) { |
2702 | if (aView->selectedIsAllDay()) { | 2701 | if (aView->selectedIsAllDay()) { |
2703 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2702 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2704 | } else { | 2703 | } else { |
2705 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2704 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2706 | } | 2705 | } |
2707 | return; | 2706 | return; |
2708 | } | 2707 | } |
2709 | } | 2708 | } |
2710 | 2709 | ||
2711 | QDate date = mNavigator->selectedDates().first(); | 2710 | QDate date = mNavigator->selectedDates().first(); |
2712 | QDateTime current = QDateTime::currentDateTime(); | 2711 | QDateTime current = QDateTime::currentDateTime(); |
2713 | if ( date <= current.date() ) { | 2712 | if ( date <= current.date() ) { |
2714 | int hour = current.time().hour() +1; | 2713 | int hour = current.time().hour() +1; |
2715 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2714 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2716 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2715 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2717 | } else | 2716 | } else |
2718 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2717 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2719 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2718 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2720 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2719 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2721 | } | 2720 | } |
2722 | 2721 | ||
2723 | void CalendarView::newEvent(QDateTime fh) | 2722 | void CalendarView::newEvent(QDateTime fh) |
2724 | { | 2723 | { |
2725 | newEvent(fh, | 2724 | newEvent(fh, |
2726 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2725 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2727 | } | 2726 | } |
2728 | 2727 | ||
2729 | void CalendarView::newEvent(QDate dt) | 2728 | void CalendarView::newEvent(QDate dt) |
2730 | { | 2729 | { |
2731 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2730 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2732 | QDateTime(dt, QTime(0,0,0)), true); | 2731 | QDateTime(dt, QTime(0,0,0)), true); |
2733 | } | 2732 | } |
2734 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2733 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2735 | { | 2734 | { |
2736 | newEvent(fromHint, toHint, false); | 2735 | newEvent(fromHint, toHint, false); |
2737 | } | 2736 | } |
2738 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2737 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2739 | { | 2738 | { |
2740 | 2739 | ||
2741 | showEventEditor(); | 2740 | showEventEditor(); |
2742 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2741 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2743 | if ( mFilterView->filtersEnabled() ) { | 2742 | if ( mFilterView->filtersEnabled() ) { |
2744 | CalFilter *filter = mFilterView->selectedFilter(); | 2743 | CalFilter *filter = mFilterView->selectedFilter(); |
2745 | if (filter && filter->showCategories()) { | 2744 | if (filter && filter->showCategories()) { |
2746 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2745 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2747 | } | 2746 | } |
2748 | if ( filter ) | 2747 | if ( filter ) |
2749 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2748 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2750 | } | 2749 | } |
2751 | mEventEditor->exec(); | 2750 | mEventEditor->exec(); |
2752 | setActiveWindow(); | 2751 | setActiveWindow(); |
2753 | } | 2752 | } |
2754 | void CalendarView::todoAdded(Todo * t) | 2753 | void CalendarView::todoAdded(Todo * t) |
2755 | { | 2754 | { |
2756 | 2755 | ||
2757 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2756 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2758 | updateTodoViews(); | 2757 | updateTodoViews(); |
2759 | } | 2758 | } |
2760 | void CalendarView::todoChanged(Todo * t) | 2759 | void CalendarView::todoChanged(Todo * t) |
2761 | { | 2760 | { |
2762 | emit todoModified( t, 4 ); | 2761 | emit todoModified( t, 4 ); |
2763 | // updateTodoViews(); | 2762 | // updateTodoViews(); |
2764 | } | 2763 | } |
2765 | void CalendarView::todoToBeDeleted(Todo *) | 2764 | void CalendarView::todoToBeDeleted(Todo *) |
2766 | { | 2765 | { |
2767 | //qDebug("todoToBeDeleted(Todo *) "); | 2766 | //qDebug("todoToBeDeleted(Todo *) "); |
2768 | updateTodoViews(); | 2767 | updateTodoViews(); |
2769 | } | 2768 | } |
2770 | void CalendarView::todoDeleted() | 2769 | void CalendarView::todoDeleted() |
2771 | { | 2770 | { |
2772 | //qDebug(" todoDeleted()"); | 2771 | //qDebug(" todoDeleted()"); |
2773 | updateTodoViews(); | 2772 | updateTodoViews(); |
2774 | } | 2773 | } |
2775 | 2774 | ||
2776 | 2775 | ||
2777 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2776 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2778 | { | 2777 | { |
2779 | showTodoEditor(); | 2778 | showTodoEditor(); |
2780 | mTodoEditor->newTodo(dt,0,allday); | 2779 | mTodoEditor->newTodo(dt,0,allday); |
2781 | if ( mFilterView->filtersEnabled() ) { | 2780 | if ( mFilterView->filtersEnabled() ) { |
2782 | CalFilter *filter = mFilterView->selectedFilter(); | 2781 | CalFilter *filter = mFilterView->selectedFilter(); |
2783 | if (filter && filter->showCategories()) { | 2782 | if (filter && filter->showCategories()) { |
2784 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2783 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2785 | } | 2784 | } |
2786 | if ( filter ) | 2785 | if ( filter ) |
2787 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2786 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2788 | } | 2787 | } |
2789 | mTodoEditor->exec(); | 2788 | mTodoEditor->exec(); |
2790 | setActiveWindow(); | 2789 | setActiveWindow(); |
2791 | } | 2790 | } |
2792 | 2791 | ||
2793 | void CalendarView::newTodo() | 2792 | void CalendarView::newTodo() |
2794 | { | 2793 | { |
2795 | newTodoDateTime( QDateTime(),true ); | 2794 | newTodoDateTime( QDateTime(),true ); |
2796 | } | 2795 | } |
2797 | 2796 | ||
2798 | void CalendarView::newSubTodo() | 2797 | void CalendarView::newSubTodo() |
2799 | { | 2798 | { |
2800 | Todo *todo = selectedTodo(); | 2799 | Todo *todo = selectedTodo(); |
2801 | if ( todo ) newSubTodo( todo ); | 2800 | if ( todo ) newSubTodo( todo ); |
2802 | } | 2801 | } |
2803 | 2802 | ||
2804 | void CalendarView::newSubTodo(Todo *parentEvent) | 2803 | void CalendarView::newSubTodo(Todo *parentEvent) |
2805 | { | 2804 | { |
2806 | 2805 | ||
2807 | showTodoEditor(); | 2806 | showTodoEditor(); |
2808 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2807 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2809 | mTodoEditor->exec(); | 2808 | mTodoEditor->exec(); |
2810 | setActiveWindow(); | 2809 | setActiveWindow(); |
2811 | } | 2810 | } |
2812 | 2811 | ||
2813 | void CalendarView::newFloatingEvent() | 2812 | void CalendarView::newFloatingEvent() |
2814 | { | 2813 | { |
2815 | DateList tmpList = mNavigator->selectedDates(); | 2814 | DateList tmpList = mNavigator->selectedDates(); |
2816 | QDate date = tmpList.first(); | 2815 | QDate date = tmpList.first(); |
2817 | 2816 | ||
2818 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2817 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2819 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2818 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2820 | } | 2819 | } |
2821 | 2820 | ||
2822 | 2821 | ||
2823 | void CalendarView::editEvent( Event *event ) | 2822 | void CalendarView::editEvent( Event *event ) |
2824 | { | 2823 | { |
2825 | 2824 | ||
2826 | if ( !event ) return; | 2825 | if ( !event ) return; |
2827 | if ( event->isReadOnly() ) { | 2826 | if ( event->isReadOnly() ) { |
2828 | showEvent( event ); | 2827 | showEvent( event ); |
2829 | return; | 2828 | return; |
2830 | } | 2829 | } |
2831 | showEventEditor(); | 2830 | showEventEditor(); |
2832 | mEventEditor->editEvent( event , mFlagEditDescription); | 2831 | mEventEditor->editEvent( event , mFlagEditDescription); |
2833 | mEventEditor->exec(); | 2832 | mEventEditor->exec(); |
2834 | setActiveWindow(); | 2833 | setActiveWindow(); |
2835 | 2834 | ||
2836 | } | 2835 | } |
2837 | void CalendarView::editJournal( Journal *jour ) | 2836 | void CalendarView::editJournal( Journal *jour ) |
2838 | { | 2837 | { |
2839 | if ( !jour ) return; | 2838 | if ( !jour ) return; |
2840 | mDialogManager->hideSearchDialog(); | 2839 | mDialogManager->hideSearchDialog(); |
2841 | mViewManager->showJournalView(); | 2840 | mViewManager->showJournalView(); |
2842 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2841 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2843 | } | 2842 | } |
2844 | void CalendarView::editTodo( Todo *todo ) | 2843 | void CalendarView::editTodo( Todo *todo ) |
2845 | { | 2844 | { |
2846 | if ( !todo ) return; | 2845 | if ( !todo ) return; |
2847 | 2846 | ||
2848 | if ( todo->isReadOnly() ) { | 2847 | if ( todo->isReadOnly() ) { |
2849 | showTodo( todo ); | 2848 | showTodo( todo ); |
2850 | return; | 2849 | return; |
2851 | } | 2850 | } |
2852 | showTodoEditor(); | 2851 | showTodoEditor(); |
2853 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2852 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2854 | mTodoEditor->exec(); | 2853 | mTodoEditor->exec(); |
2855 | setActiveWindow(); | 2854 | setActiveWindow(); |
2856 | 2855 | ||
2857 | } | 2856 | } |
2858 | 2857 | ||
2859 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2858 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2860 | { | 2859 | { |
2861 | if ( !mEventViewerDialog ) { | 2860 | if ( !mEventViewerDialog ) { |
2862 | mEventViewerDialog = new KOEventViewerDialog(0); | 2861 | mEventViewerDialog = new KOEventViewerDialog(0); |
2863 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2862 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2864 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2863 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2865 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2864 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2866 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2865 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2867 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2866 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2868 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2867 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2869 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 2868 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
2870 | this, SLOT( slotViewerClosed() ) ); | 2869 | this, SLOT( slotViewerClosed() ) ); |
2871 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2870 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2872 | this, SLOT( todoChanged(Todo *) ) ); | 2871 | this, SLOT( todoChanged(Todo *) ) ); |
2873 | mEventViewerDialog->resize( 640, 480 ); | 2872 | mEventViewerDialog->resize( 640, 480 ); |
2874 | 2873 | ||
2875 | } | 2874 | } |
2876 | return mEventViewerDialog; | 2875 | return mEventViewerDialog; |
2877 | } | 2876 | } |
2878 | void CalendarView::showEvent(Event *event) | 2877 | void CalendarView::showEvent(Event *event) |
2879 | { | 2878 | { |
2880 | getEventViewerDialog()->setEvent(event); | 2879 | getEventViewerDialog()->setEvent(event); |
2881 | getEventViewerDialog()->showMe(); | 2880 | getEventViewerDialog()->showMe(); |
2882 | } | 2881 | } |
2883 | 2882 | ||
2884 | void CalendarView::showTodo(Todo *event) | 2883 | void CalendarView::showTodo(Todo *event) |
2885 | { | 2884 | { |
2886 | getEventViewerDialog()->setTodo(event); | 2885 | getEventViewerDialog()->setTodo(event); |
2887 | getEventViewerDialog()->showMe(); | 2886 | getEventViewerDialog()->showMe(); |
2888 | } | 2887 | } |
2889 | void CalendarView::showJournal( Journal *jour ) | 2888 | void CalendarView::showJournal( Journal *jour ) |
2890 | { | 2889 | { |
2891 | getEventViewerDialog()->setJournal(jour); | 2890 | getEventViewerDialog()->setJournal(jour); |
2892 | getEventViewerDialog()->showMe(); | 2891 | getEventViewerDialog()->showMe(); |
2893 | 2892 | ||
2894 | } | 2893 | } |
2895 | // void CalendarView::todoModified (Todo *event, int changed) | 2894 | // void CalendarView::todoModified (Todo *event, int changed) |
2896 | // { | 2895 | // { |
2897 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2896 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2898 | // // kdDebug() << "Todo modified and open" << endl; | 2897 | // // kdDebug() << "Todo modified and open" << endl; |
2899 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2898 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2900 | // // temp->modified (changed); | 2899 | // // temp->modified (changed); |
2901 | 2900 | ||
2902 | // // } | 2901 | // // } |
2903 | 2902 | ||
2904 | // mViewManager->updateView(); | 2903 | // mViewManager->updateView(); |
2905 | // } | 2904 | // } |
2906 | 2905 | ||
2907 | void CalendarView::appointment_show() | 2906 | void CalendarView::appointment_show() |
2908 | { | 2907 | { |
2909 | Event *anEvent = 0; | 2908 | Event *anEvent = 0; |
2910 | 2909 | ||
2911 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2910 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2912 | 2911 | ||
2913 | if (mViewManager->currentView()->isEventView()) { | 2912 | if (mViewManager->currentView()->isEventView()) { |
2914 | if ( incidence && incidence->type() == "Event" ) { | 2913 | if ( incidence && incidence->type() == "Event" ) { |
2915 | anEvent = static_cast<Event *>(incidence); | 2914 | anEvent = static_cast<Event *>(incidence); |
2916 | } | 2915 | } |
2917 | } | 2916 | } |
2918 | 2917 | ||
2919 | if (!anEvent) { | 2918 | if (!anEvent) { |
2920 | KNotifyClient::beep(); | 2919 | KNotifyClient::beep(); |
2921 | return; | 2920 | return; |
2922 | } | 2921 | } |
2923 | 2922 | ||
2924 | showEvent(anEvent); | 2923 | showEvent(anEvent); |
2925 | } | 2924 | } |
2926 | 2925 | ||
2927 | void CalendarView::appointment_edit() | 2926 | void CalendarView::appointment_edit() |
2928 | { | 2927 | { |
2929 | Event *anEvent = 0; | 2928 | Event *anEvent = 0; |
2930 | 2929 | ||
2931 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2930 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2932 | 2931 | ||
2933 | if (mViewManager->currentView()->isEventView()) { | 2932 | if (mViewManager->currentView()->isEventView()) { |
2934 | if ( incidence && incidence->type() == "Event" ) { | 2933 | if ( incidence && incidence->type() == "Event" ) { |
2935 | anEvent = static_cast<Event *>(incidence); | 2934 | anEvent = static_cast<Event *>(incidence); |
2936 | } | 2935 | } |
2937 | } | 2936 | } |
2938 | 2937 | ||
2939 | if (!anEvent) { | 2938 | if (!anEvent) { |
2940 | KNotifyClient::beep(); | 2939 | KNotifyClient::beep(); |
2941 | return; | 2940 | return; |
2942 | } | 2941 | } |
2943 | 2942 | ||
2944 | editEvent(anEvent); | 2943 | editEvent(anEvent); |
2945 | } | 2944 | } |
2946 | 2945 | ||
2947 | void CalendarView::appointment_delete() | 2946 | void CalendarView::appointment_delete() |
2948 | { | 2947 | { |
2949 | Event *anEvent = 0; | 2948 | Event *anEvent = 0; |
2950 | 2949 | ||
2951 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2950 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2952 | 2951 | ||
2953 | if (mViewManager->currentView()->isEventView()) { | 2952 | if (mViewManager->currentView()->isEventView()) { |
2954 | if ( incidence && incidence->type() == "Event" ) { | 2953 | if ( incidence && incidence->type() == "Event" ) { |
2955 | anEvent = static_cast<Event *>(incidence); | 2954 | anEvent = static_cast<Event *>(incidence); |
2956 | } | 2955 | } |
2957 | } | 2956 | } |
2958 | 2957 | ||
2959 | if (!anEvent) { | 2958 | if (!anEvent) { |
2960 | KNotifyClient::beep(); | 2959 | KNotifyClient::beep(); |
2961 | return; | 2960 | return; |
2962 | } | 2961 | } |
2963 | 2962 | ||
2964 | deleteEvent(anEvent); | 2963 | deleteEvent(anEvent); |
2965 | } | 2964 | } |
2966 | 2965 | ||
2967 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2966 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2968 | { | 2967 | { |
2969 | if (!sub) return; | 2968 | if (!sub) return; |
2970 | if (!parent) return; | 2969 | if (!parent) return; |
2971 | if ( sub->relatedTo() ) | 2970 | if ( sub->relatedTo() ) |
2972 | sub->relatedTo()->removeRelation(sub); | 2971 | sub->relatedTo()->removeRelation(sub); |
2973 | sub->setRelatedTo(parent); | 2972 | sub->setRelatedTo(parent); |
2974 | sub->setRelatedToUid(parent->uid()); | 2973 | sub->setRelatedToUid(parent->uid()); |
2975 | parent->addRelation(sub); | 2974 | parent->addRelation(sub); |
2976 | sub->updated(); | 2975 | sub->updated(); |
2977 | parent->updated(); | 2976 | parent->updated(); |
2978 | setModified(true); | 2977 | setModified(true); |
2979 | updateView(); | 2978 | updateView(); |
2980 | } | 2979 | } |
2981 | void CalendarView::todo_unsub(Todo *anTodo ) | 2980 | void CalendarView::todo_unsub(Todo *anTodo ) |
2982 | { | 2981 | { |
2983 | // Todo *anTodo = selectedTodo(); | 2982 | // Todo *anTodo = selectedTodo(); |
2984 | if (!anTodo) return; | 2983 | if (!anTodo) return; |
2985 | if (!anTodo->relatedTo()) return; | 2984 | if (!anTodo->relatedTo()) return; |
2986 | anTodo->relatedTo()->removeRelation(anTodo); | 2985 | anTodo->relatedTo()->removeRelation(anTodo); |
2987 | anTodo->setRelatedTo(0); | 2986 | anTodo->setRelatedTo(0); |
2988 | anTodo->updated(); | 2987 | anTodo->updated(); |
2989 | anTodo->setRelatedToUid(""); | 2988 | anTodo->setRelatedToUid(""); |
2990 | setModified(true); | 2989 | setModified(true); |
2991 | updateView(); | 2990 | updateView(); |
2992 | } | 2991 | } |
2993 | 2992 | ||
2994 | void CalendarView::deleteTodo(Todo *todo) | 2993 | void CalendarView::deleteTodo(Todo *todo) |
2995 | { | 2994 | { |
2996 | if (!todo) { | 2995 | if (!todo) { |
2997 | KNotifyClient::beep(); | 2996 | KNotifyClient::beep(); |
2998 | return; | 2997 | return; |
2999 | } | 2998 | } |
3000 | if (KOPrefs::instance()->mConfirm) { | 2999 | if (KOPrefs::instance()->mConfirm) { |
3001 | QString text = todo->summary().left(20); | 3000 | QString text = todo->summary().left(20); |
3002 | if (!todo->relations().isEmpty()) { | 3001 | if (!todo->relations().isEmpty()) { |
3003 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3002 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3004 | 3003 | ||
3005 | } | 3004 | } |
3006 | switch (msgItemDelete(text)) { | 3005 | switch (msgItemDelete(text)) { |
3007 | case KMessageBox::Continue: // OK | 3006 | case KMessageBox::Continue: // OK |
3008 | bool deleteT = false; | 3007 | bool deleteT = false; |
3009 | if (!todo->relations().isEmpty()) { | 3008 | if (!todo->relations().isEmpty()) { |
3010 | deleteT = removeCompletedSubTodos( todo ); | 3009 | deleteT = removeCompletedSubTodos( todo ); |
3011 | } | 3010 | } |
3012 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3011 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3013 | if ( !deleteT ) { | 3012 | if ( !deleteT ) { |
3014 | checkExternalId( todo ); | 3013 | checkExternalId( todo ); |
3015 | calendar()->deleteTodo(todo); | 3014 | calendar()->deleteTodo(todo); |
3016 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3015 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3017 | updateView(); | 3016 | updateView(); |
3018 | } | 3017 | } |
3019 | break; | 3018 | break; |
3020 | } // switch | 3019 | } // switch |
3021 | } else { | 3020 | } else { |
3022 | checkExternalId( todo ); | 3021 | checkExternalId( todo ); |
3023 | mCalendar->deleteTodo(todo); | 3022 | mCalendar->deleteTodo(todo); |
3024 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3023 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3025 | updateView(); | 3024 | updateView(); |
3026 | } | 3025 | } |
3027 | 3026 | ||
3028 | emit updateSearchDialog(); | 3027 | emit updateSearchDialog(); |
3029 | } | 3028 | } |
3030 | void CalendarView::deleteJournal(Journal *jour) | 3029 | void CalendarView::deleteJournal(Journal *jour) |
3031 | { | 3030 | { |
3032 | if (!jour) { | 3031 | if (!jour) { |
3033 | KNotifyClient::beep(); | 3032 | KNotifyClient::beep(); |
3034 | return; | 3033 | return; |
3035 | } | 3034 | } |
3036 | if (KOPrefs::instance()->mConfirm) { | 3035 | if (KOPrefs::instance()->mConfirm) { |
3037 | switch (msgItemDelete( jour->description().left(20))) { | 3036 | switch (msgItemDelete( jour->description().left(20))) { |
3038 | case KMessageBox::Continue: // OK | 3037 | case KMessageBox::Continue: // OK |
3039 | calendar()->deleteJournal(jour); | 3038 | calendar()->deleteJournal(jour); |
3040 | updateView(); | 3039 | updateView(); |
3041 | break; | 3040 | break; |
3042 | } // switch | 3041 | } // switch |
3043 | } else { | 3042 | } else { |
3044 | calendar()->deleteJournal(jour);; | 3043 | calendar()->deleteJournal(jour);; |
3045 | updateView(); | 3044 | updateView(); |
3046 | } | 3045 | } |
3047 | emit updateSearchDialog(); | 3046 | emit updateSearchDialog(); |
3048 | } | 3047 | } |
3049 | 3048 | ||
3050 | void CalendarView::deleteEvent(Event *anEvent) | 3049 | void CalendarView::deleteEvent(Event *anEvent) |
3051 | { | 3050 | { |
3052 | if (!anEvent) { | 3051 | if (!anEvent) { |
3053 | KNotifyClient::beep(); | 3052 | KNotifyClient::beep(); |
3054 | return; | 3053 | return; |
3055 | } | 3054 | } |
3056 | 3055 | ||
3057 | if (anEvent->recurrence()->doesRecur()) { | 3056 | if (anEvent->recurrence()->doesRecur()) { |
3058 | QDate itemDate = mViewManager->currentSelectionDate(); | 3057 | QDate itemDate = mViewManager->currentSelectionDate(); |
3059 | int km; | 3058 | int km; |
3060 | if (!itemDate.isValid()) { | 3059 | if (!itemDate.isValid()) { |
3061 | //kdDebug() << "Date Not Valid" << endl; | 3060 | //kdDebug() << "Date Not Valid" << endl; |
3062 | if (KOPrefs::instance()->mConfirm) { | 3061 | if (KOPrefs::instance()->mConfirm) { |
3063 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3062 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3064 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3063 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3065 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3064 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3066 | if ( km == KMessageBox::Continue ) | 3065 | if ( km == KMessageBox::Continue ) |
3067 | km = KMessageBox::No; // No = all below | 3066 | km = KMessageBox::No; // No = all below |
3068 | } else | 3067 | } else |
3069 | km = KMessageBox::No; | 3068 | km = KMessageBox::No; |
3070 | } else { | 3069 | } else { |
3071 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3070 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3072 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3071 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3073 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3072 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3074 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3073 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3075 | i18n("All")); | 3074 | i18n("All")); |
3076 | } | 3075 | } |
3077 | switch(km) { | 3076 | switch(km) { |
3078 | 3077 | ||
3079 | case KMessageBox::No: // Continue // all | 3078 | case KMessageBox::No: // Continue // all |
3080 | //qDebug("KMessageBox::No "); | 3079 | //qDebug("KMessageBox::No "); |
3081 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3080 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3082 | schedule(Scheduler::Cancel,anEvent); | 3081 | schedule(Scheduler::Cancel,anEvent); |
3083 | 3082 | ||
3084 | checkExternalId( anEvent); | 3083 | checkExternalId( anEvent); |
3085 | mCalendar->deleteEvent(anEvent); | 3084 | mCalendar->deleteEvent(anEvent); |
3086 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3085 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3087 | break; | 3086 | break; |
3088 | 3087 | ||
3089 | // Disabled because it does not work | 3088 | // Disabled because it does not work |
3090 | //#if 0 | 3089 | //#if 0 |
3091 | case KMessageBox::Yes: // just this one | 3090 | case KMessageBox::Yes: // just this one |
3092 | //QDate qd = mNavigator->selectedDates().first(); | 3091 | //QDate qd = mNavigator->selectedDates().first(); |
3093 | //if (!qd.isValid()) { | 3092 | //if (!qd.isValid()) { |
3094 | // kdDebug() << "no date selected, or invalid date" << endl; | 3093 | // kdDebug() << "no date selected, or invalid date" << endl; |
3095 | // KNotifyClient::beep(); | 3094 | // KNotifyClient::beep(); |
3096 | // return; | 3095 | // return; |
3097 | //} | 3096 | //} |
3098 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3097 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3099 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3098 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3100 | anEvent->addExDate(itemDate); | 3099 | anEvent->addExDate(itemDate); |
3101 | int duration = anEvent->recurrence()->duration(); | 3100 | int duration = anEvent->recurrence()->duration(); |
3102 | if ( duration > 0 ) { | 3101 | if ( duration > 0 ) { |
3103 | anEvent->recurrence()->setDuration( duration - 1 ); | 3102 | anEvent->recurrence()->setDuration( duration - 1 ); |
3104 | } | 3103 | } |
3105 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3104 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3106 | } | 3105 | } |
3107 | break; | 3106 | break; |
3108 | //#endif | 3107 | //#endif |
3109 | } // switch | 3108 | } // switch |
3110 | } else { | 3109 | } else { |
3111 | if (KOPrefs::instance()->mConfirm) { | 3110 | if (KOPrefs::instance()->mConfirm) { |
3112 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3111 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3113 | i18n("\nAre you sure you want\nto delete this event?"), | 3112 | i18n("\nAre you sure you want\nto delete this event?"), |
3114 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3113 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3115 | case KMessageBox::Continue: // OK | 3114 | case KMessageBox::Continue: // OK |
3116 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3115 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3117 | schedule(Scheduler::Cancel,anEvent); | 3116 | schedule(Scheduler::Cancel,anEvent); |
3118 | checkExternalId( anEvent); | 3117 | checkExternalId( anEvent); |
3119 | mCalendar->deleteEvent(anEvent); | 3118 | mCalendar->deleteEvent(anEvent); |
3120 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3119 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3121 | break; | 3120 | break; |
3122 | } // switch | 3121 | } // switch |
3123 | } else { | 3122 | } else { |
3124 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3123 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3125 | schedule(Scheduler::Cancel,anEvent); | 3124 | schedule(Scheduler::Cancel,anEvent); |
3126 | checkExternalId( anEvent); | 3125 | checkExternalId( anEvent); |
3127 | mCalendar->deleteEvent(anEvent); | 3126 | mCalendar->deleteEvent(anEvent); |
3128 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3127 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3129 | } | 3128 | } |
3130 | } // if-else | 3129 | } // if-else |
3131 | emit updateSearchDialog(); | 3130 | emit updateSearchDialog(); |
3132 | } | 3131 | } |
3133 | 3132 | ||
3134 | bool CalendarView::deleteEvent(const QString &uid) | 3133 | bool CalendarView::deleteEvent(const QString &uid) |
3135 | { | 3134 | { |
3136 | Event *ev = mCalendar->event(uid); | 3135 | Event *ev = mCalendar->event(uid); |
3137 | if (ev) { | 3136 | if (ev) { |
3138 | deleteEvent(ev); | 3137 | deleteEvent(ev); |
3139 | return true; | 3138 | return true; |
3140 | } else { | 3139 | } else { |
3141 | return false; | 3140 | return false; |
3142 | } | 3141 | } |
3143 | } | 3142 | } |
3144 | 3143 | ||
3145 | /*****************************************************************************/ | 3144 | /*****************************************************************************/ |
3146 | 3145 | ||
3147 | void CalendarView::action_mail() | 3146 | void CalendarView::action_mail() |
3148 | { | 3147 | { |
3149 | #ifndef KORG_NOMAIL | 3148 | #ifndef KORG_NOMAIL |
3150 | KOMailClient mailClient; | 3149 | KOMailClient mailClient; |
3151 | 3150 | ||
3152 | Incidence *incidence = currentSelection(); | 3151 | Incidence *incidence = currentSelection(); |
3153 | 3152 | ||
3154 | if (!incidence) { | 3153 | if (!incidence) { |
3155 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3154 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3156 | return; | 3155 | return; |
3157 | } | 3156 | } |
3158 | if(incidence->attendeeCount() == 0 ) { | 3157 | if(incidence->attendeeCount() == 0 ) { |
3159 | KMessageBox::sorry(this, | 3158 | KMessageBox::sorry(this, |
3160 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3159 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3161 | return; | 3160 | return; |
3162 | } | 3161 | } |
3163 | 3162 | ||
3164 | CalendarLocal cal_tmp; | 3163 | CalendarLocal cal_tmp; |
3165 | Event *event = 0; | 3164 | Event *event = 0; |
3166 | Event *ev = 0; | 3165 | Event *ev = 0; |
3167 | if ( incidence && incidence->type() == "Event" ) { | 3166 | if ( incidence && incidence->type() == "Event" ) { |
3168 | event = static_cast<Event *>(incidence); | 3167 | event = static_cast<Event *>(incidence); |
3169 | ev = new Event(*event); | 3168 | ev = new Event(*event); |
3170 | cal_tmp.addEvent(ev); | 3169 | cal_tmp.addEvent(ev); |
3171 | } | 3170 | } |
3172 | ICalFormat mForm(); | 3171 | ICalFormat mForm(); |
3173 | QString attachment = mForm.toString( &cal_tmp ); | 3172 | QString attachment = mForm.toString( &cal_tmp ); |
3174 | if (ev) delete(ev); | 3173 | if (ev) delete(ev); |
3175 | 3174 | ||
3176 | mailClient.mailAttendees(currentSelection(), attachment); | 3175 | mailClient.mailAttendees(currentSelection(), attachment); |
3177 | 3176 | ||
3178 | #endif | 3177 | #endif |
3179 | 3178 | ||
3180 | #if 0 | 3179 | #if 0 |
3181 | Event *anEvent = 0; | 3180 | Event *anEvent = 0; |
3182 | if (mViewManager->currentView()->isEventView()) { | 3181 | if (mViewManager->currentView()->isEventView()) { |
3183 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3182 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3184 | } | 3183 | } |
3185 | 3184 | ||
3186 | if (!anEvent) { | 3185 | if (!anEvent) { |
3187 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3186 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3188 | return; | 3187 | return; |
3189 | } | 3188 | } |
3190 | if(anEvent->attendeeCount() == 0 ) { | 3189 | if(anEvent->attendeeCount() == 0 ) { |
3191 | KMessageBox::sorry(this, | 3190 | KMessageBox::sorry(this, |
3192 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3191 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3193 | return; | 3192 | return; |
3194 | } | 3193 | } |
3195 | 3194 | ||
3196 | mailobject.emailEvent(anEvent); | 3195 | mailobject.emailEvent(anEvent); |
3197 | #endif | 3196 | #endif |
3198 | } | 3197 | } |
3199 | 3198 | ||
3200 | 3199 | ||
3201 | void CalendarView::schedule_publish(Incidence *incidence) | 3200 | void CalendarView::schedule_publish(Incidence *incidence) |
3202 | { | 3201 | { |
3203 | Event *event = 0; | 3202 | Event *event = 0; |
3204 | Todo *todo = 0; | 3203 | Todo *todo = 0; |
3205 | 3204 | ||
3206 | if (incidence == 0) { | 3205 | if (incidence == 0) { |
3207 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3206 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3208 | if (incidence == 0) { | 3207 | if (incidence == 0) { |
3209 | incidence = mTodoList->selectedIncidences().first(); | 3208 | incidence = mTodoList->selectedIncidences().first(); |
3210 | } | 3209 | } |
3211 | } | 3210 | } |
3212 | if ( incidence && incidence->type() == "Event" ) { | 3211 | if ( incidence && incidence->type() == "Event" ) { |
3213 | event = static_cast<Event *>(incidence); | 3212 | event = static_cast<Event *>(incidence); |
3214 | } else { | 3213 | } else { |
3215 | if ( incidence && incidence->type() == "Todo" ) { | 3214 | if ( incidence && incidence->type() == "Todo" ) { |
3216 | todo = static_cast<Todo *>(incidence); | 3215 | todo = static_cast<Todo *>(incidence); |
3217 | } | 3216 | } |
3218 | } | 3217 | } |
3219 | 3218 | ||
3220 | if (!event && !todo) { | 3219 | if (!event && !todo) { |
3221 | KMessageBox::sorry(this,i18n("No event selected.")); | 3220 | KMessageBox::sorry(this,i18n("No event selected.")); |
3222 | return; | 3221 | return; |
3223 | } | 3222 | } |
3224 | 3223 | ||
3225 | PublishDialog *publishdlg = new PublishDialog(); | 3224 | PublishDialog *publishdlg = new PublishDialog(); |
3226 | if (incidence->attendeeCount()>0) { | 3225 | if (incidence->attendeeCount()>0) { |
3227 | QPtrList<Attendee> attendees = incidence->attendees(); | 3226 | QPtrList<Attendee> attendees = incidence->attendees(); |
3228 | attendees.first(); | 3227 | attendees.first(); |
3229 | while ( attendees.current()!=0 ) { | 3228 | while ( attendees.current()!=0 ) { |
3230 | publishdlg->addAttendee(attendees.current()); | 3229 | publishdlg->addAttendee(attendees.current()); |
3231 | attendees.next(); | 3230 | attendees.next(); |
3232 | } | 3231 | } |
3233 | } | 3232 | } |
3234 | bool send = true; | 3233 | bool send = true; |
3235 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3234 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3236 | if ( publishdlg->exec() != QDialog::Accepted ) | 3235 | if ( publishdlg->exec() != QDialog::Accepted ) |
3237 | send = false; | 3236 | send = false; |
3238 | } | 3237 | } |
3239 | if ( send ) { | 3238 | if ( send ) { |
3240 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3239 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3241 | if ( event ) { | 3240 | if ( event ) { |
3242 | Event *ev = new Event(*event); | 3241 | Event *ev = new Event(*event); |
3243 | ev->registerObserver(0); | 3242 | ev->registerObserver(0); |
3244 | ev->clearAttendees(); | 3243 | ev->clearAttendees(); |
3245 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3244 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3246 | delete(ev); | 3245 | delete(ev); |
3247 | } | 3246 | } |
3248 | } else { | 3247 | } else { |
3249 | if ( todo ) { | 3248 | if ( todo ) { |
3250 | Todo *ev = new Todo(*todo); | 3249 | Todo *ev = new Todo(*todo); |
3251 | ev->registerObserver(0); | 3250 | ev->registerObserver(0); |
3252 | ev->clearAttendees(); | 3251 | ev->clearAttendees(); |
3253 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3252 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3254 | delete(ev); | 3253 | delete(ev); |
3255 | } | 3254 | } |
3256 | } | 3255 | } |
3257 | } | 3256 | } |
3258 | } | 3257 | } |
3259 | delete publishdlg; | 3258 | delete publishdlg; |
3260 | } | 3259 | } |
3261 | 3260 | ||
3262 | void CalendarView::schedule_request(Incidence *incidence) | 3261 | void CalendarView::schedule_request(Incidence *incidence) |
3263 | { | 3262 | { |
3264 | schedule(Scheduler::Request,incidence); | 3263 | schedule(Scheduler::Request,incidence); |
3265 | } | 3264 | } |
3266 | 3265 | ||
3267 | void CalendarView::schedule_refresh(Incidence *incidence) | 3266 | void CalendarView::schedule_refresh(Incidence *incidence) |
3268 | { | 3267 | { |
3269 | schedule(Scheduler::Refresh,incidence); | 3268 | schedule(Scheduler::Refresh,incidence); |
3270 | } | 3269 | } |
3271 | 3270 | ||
3272 | void CalendarView::schedule_cancel(Incidence *incidence) | 3271 | void CalendarView::schedule_cancel(Incidence *incidence) |
3273 | { | 3272 | { |
3274 | schedule(Scheduler::Cancel,incidence); | 3273 | schedule(Scheduler::Cancel,incidence); |
3275 | } | 3274 | } |
3276 | 3275 | ||
3277 | void CalendarView::schedule_add(Incidence *incidence) | 3276 | void CalendarView::schedule_add(Incidence *incidence) |
3278 | { | 3277 | { |
3279 | schedule(Scheduler::Add,incidence); | 3278 | schedule(Scheduler::Add,incidence); |
3280 | } | 3279 | } |
3281 | 3280 | ||
3282 | void CalendarView::schedule_reply(Incidence *incidence) | 3281 | void CalendarView::schedule_reply(Incidence *incidence) |
3283 | { | 3282 | { |
3284 | schedule(Scheduler::Reply,incidence); | 3283 | schedule(Scheduler::Reply,incidence); |
3285 | } | 3284 | } |
3286 | 3285 | ||
3287 | void CalendarView::schedule_counter(Incidence *incidence) | 3286 | void CalendarView::schedule_counter(Incidence *incidence) |
3288 | { | 3287 | { |
3289 | schedule(Scheduler::Counter,incidence); | 3288 | schedule(Scheduler::Counter,incidence); |
3290 | } | 3289 | } |
3291 | 3290 | ||
3292 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3291 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3293 | { | 3292 | { |
3294 | schedule(Scheduler::Declinecounter,incidence); | 3293 | schedule(Scheduler::Declinecounter,incidence); |
3295 | } | 3294 | } |
3296 | 3295 | ||
3297 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3296 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3298 | { | 3297 | { |
3299 | QDateTime start = QDateTime::currentDateTime(); | 3298 | QDateTime start = QDateTime::currentDateTime(); |
3300 | QDateTime end = start.addDays(daysToPublish); | 3299 | QDateTime end = start.addDays(daysToPublish); |
3301 | 3300 | ||
3302 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3301 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3303 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3302 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3304 | 3303 | ||
3305 | 3304 | ||
3306 | PublishDialog *publishdlg = new PublishDialog(); | 3305 | PublishDialog *publishdlg = new PublishDialog(); |
3307 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3306 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3308 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3307 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3309 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3308 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3310 | delete(freebusy); | 3309 | delete(freebusy); |
3311 | } | 3310 | } |
3312 | } | 3311 | } |
3313 | delete publishdlg; | 3312 | delete publishdlg; |
3314 | } | 3313 | } |
3315 | 3314 | ||
3316 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3315 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3317 | { | 3316 | { |
3318 | Event *event = 0; | 3317 | Event *event = 0; |
3319 | Todo *todo = 0; | 3318 | Todo *todo = 0; |
3320 | 3319 | ||
3321 | if (incidence == 0) { | 3320 | if (incidence == 0) { |
3322 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3321 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3323 | if (incidence == 0) { | 3322 | if (incidence == 0) { |
3324 | incidence = mTodoList->selectedIncidences().first(); | 3323 | incidence = mTodoList->selectedIncidences().first(); |
3325 | } | 3324 | } |
3326 | } | 3325 | } |
3327 | if ( incidence && incidence->type() == "Event" ) { | 3326 | if ( incidence && incidence->type() == "Event" ) { |
3328 | event = static_cast<Event *>(incidence); | 3327 | event = static_cast<Event *>(incidence); |
3329 | } | 3328 | } |
3330 | if ( incidence && incidence->type() == "Todo" ) { | 3329 | if ( incidence && incidence->type() == "Todo" ) { |
3331 | todo = static_cast<Todo *>(incidence); | 3330 | todo = static_cast<Todo *>(incidence); |
3332 | } | 3331 | } |
3333 | 3332 | ||
3334 | if (!event && !todo) { | 3333 | if (!event && !todo) { |
3335 | KMessageBox::sorry(this,i18n("No event selected.")); | 3334 | KMessageBox::sorry(this,i18n("No event selected.")); |
3336 | return; | 3335 | return; |
3337 | } | 3336 | } |
3338 | 3337 | ||
3339 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3338 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3340 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3339 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3341 | return; | 3340 | return; |
3342 | } | 3341 | } |
3343 | 3342 | ||
3344 | Event *ev = 0; | 3343 | Event *ev = 0; |
3345 | if (event) ev = new Event(*event); | 3344 | if (event) ev = new Event(*event); |
3346 | Todo *to = 0; | 3345 | Todo *to = 0; |
3347 | if (todo) to = new Todo(*todo); | 3346 | if (todo) to = new Todo(*todo); |
3348 | 3347 | ||
3349 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3348 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3350 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3349 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3351 | if (!me) { | 3350 | if (!me) { |
3352 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3351 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3353 | return; | 3352 | return; |
3354 | } | 3353 | } |
3355 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3354 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3356 | StatusDialog *statdlg = new StatusDialog(this); | 3355 | StatusDialog *statdlg = new StatusDialog(this); |
3357 | if (!statdlg->exec()==QDialog::Accepted) return; | 3356 | if (!statdlg->exec()==QDialog::Accepted) return; |
3358 | me->setStatus( statdlg->status() ); | 3357 | me->setStatus( statdlg->status() ); |
3359 | delete(statdlg); | 3358 | delete(statdlg); |
3360 | } | 3359 | } |
3361 | Attendee *menew = new Attendee(*me); | 3360 | Attendee *menew = new Attendee(*me); |
3362 | if (ev) { | 3361 | if (ev) { |
3363 | ev->clearAttendees(); | 3362 | ev->clearAttendees(); |
3364 | ev->addAttendee(menew,false); | 3363 | ev->addAttendee(menew,false); |
3365 | } else { | 3364 | } else { |
3366 | if (to) { | 3365 | if (to) { |
3367 | todo->clearAttendees(); | 3366 | todo->clearAttendees(); |
3368 | todo->addAttendee(menew,false); | 3367 | todo->addAttendee(menew,false); |
3369 | } | 3368 | } |
3370 | } | 3369 | } |
3371 | } | 3370 | } |
3372 | 3371 | ||
3373 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3372 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3374 | if (ev) { | 3373 | if (ev) { |
3375 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3374 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3376 | } else { | 3375 | } else { |
3377 | if (to) { | 3376 | if (to) { |
3378 | if ( !dlg->addMessage(to,method) ) delete(to); | 3377 | if ( !dlg->addMessage(to,method) ) delete(to); |
3379 | } | 3378 | } |
3380 | } | 3379 | } |
3381 | } | 3380 | } |
3382 | 3381 | ||
3383 | void CalendarView::openAddressbook() | 3382 | void CalendarView::openAddressbook() |
3384 | { | 3383 | { |
3385 | KRun::runCommand("kaddressbook"); | 3384 | KRun::runCommand("kaddressbook"); |
3386 | } | 3385 | } |
3387 | 3386 | ||
3388 | void CalendarView::setModified(bool modified) | 3387 | void CalendarView::setModified(bool modified) |
3389 | { | 3388 | { |
3390 | if ( modified ) | 3389 | if ( modified ) |
3391 | emit signalmodified(); | 3390 | emit signalmodified(); |
3392 | if (mModified != modified) { | 3391 | if (mModified != modified) { |
3393 | mModified = modified; | 3392 | mModified = modified; |
3394 | emit modifiedChanged(mModified); | 3393 | emit modifiedChanged(mModified); |
3395 | } | 3394 | } |
3396 | } | 3395 | } |
3397 | 3396 | ||
3398 | bool CalendarView::isReadOnly() | 3397 | bool CalendarView::isReadOnly() |
3399 | { | 3398 | { |
3400 | return mReadOnly; | 3399 | return mReadOnly; |
3401 | } | 3400 | } |
3402 | 3401 | ||
3403 | void CalendarView::setReadOnly(bool readOnly) | 3402 | void CalendarView::setReadOnly(bool readOnly) |
3404 | { | 3403 | { |
3405 | if (mReadOnly != readOnly) { | 3404 | if (mReadOnly != readOnly) { |
3406 | mReadOnly = readOnly; | 3405 | mReadOnly = readOnly; |
3407 | emit readOnlyChanged(mReadOnly); | 3406 | emit readOnlyChanged(mReadOnly); |
3408 | } | 3407 | } |
3409 | } | 3408 | } |
3410 | 3409 | ||
3411 | bool CalendarView::isModified() | 3410 | bool CalendarView::isModified() |
3412 | { | 3411 | { |
3413 | return mModified; | 3412 | return mModified; |
3414 | } | 3413 | } |
3415 | 3414 | ||
3416 | void CalendarView::printSetup() | 3415 | void CalendarView::printSetup() |
3417 | { | 3416 | { |
3418 | #ifndef KORG_NOPRINTER | 3417 | #ifndef KORG_NOPRINTER |
3419 | createPrinter(); | 3418 | createPrinter(); |
3420 | 3419 | ||
3421 | mCalPrinter->setupPrinter(); | 3420 | mCalPrinter->setupPrinter(); |
3422 | #endif | 3421 | #endif |
3423 | } | 3422 | } |
3424 | 3423 | ||
3425 | void CalendarView::print() | 3424 | void CalendarView::print() |
3426 | { | 3425 | { |
3427 | #ifndef KORG_NOPRINTER | 3426 | #ifndef KORG_NOPRINTER |
3428 | createPrinter(); | 3427 | createPrinter(); |
3429 | 3428 | ||
3430 | DateList tmpDateList = mNavigator->selectedDates(); | 3429 | DateList tmpDateList = mNavigator->selectedDates(); |
3431 | mCalPrinter->print(CalPrinter::Month, | 3430 | mCalPrinter->print(CalPrinter::Month, |
3432 | tmpDateList.first(), tmpDateList.last()); | 3431 | tmpDateList.first(), tmpDateList.last()); |
3433 | #endif | 3432 | #endif |
3434 | } | 3433 | } |
3435 | 3434 | ||
3436 | void CalendarView::printPreview() | 3435 | void CalendarView::printPreview() |
3437 | { | 3436 | { |
3438 | #ifndef KORG_NOPRINTER | 3437 | #ifndef KORG_NOPRINTER |
3439 | kdDebug() << "CalendarView::printPreview()" << endl; | 3438 | kdDebug() << "CalendarView::printPreview()" << endl; |
3440 | 3439 | ||
3441 | createPrinter(); | 3440 | createPrinter(); |
3442 | 3441 | ||
3443 | DateList tmpDateList = mNavigator->selectedDates(); | 3442 | DateList tmpDateList = mNavigator->selectedDates(); |
3444 | 3443 | ||
3445 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3444 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3446 | tmpDateList.last()); | 3445 | tmpDateList.last()); |
3447 | #endif | 3446 | #endif |
3448 | } | 3447 | } |
3449 | 3448 | ||
3450 | void CalendarView::exportICalendar() | 3449 | void CalendarView::exportICalendar() |
3451 | { | 3450 | { |
3452 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3451 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3453 | 3452 | ||
3454 | // Force correct extension | 3453 | // Force correct extension |
3455 | if (filename.right(4) != ".ics") filename += ".ics"; | 3454 | if (filename.right(4) != ".ics") filename += ".ics"; |
3456 | 3455 | ||
3457 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3456 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3458 | storage.save(); | 3457 | storage.save(); |
3459 | } | 3458 | } |
3460 | 3459 | ||
3461 | bool CalendarView::exportVCalendar( QString filename ) | 3460 | bool CalendarView::exportVCalendar( QString filename ) |
3462 | { | 3461 | { |
3463 | if (mCalendar->journals().count() > 0) { | 3462 | if (mCalendar->journals().count() > 0) { |
3464 | int result = KMessageBox::warningContinueCancel(this, | 3463 | int result = KMessageBox::warningContinueCancel(this, |
3465 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3464 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3466 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3465 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3467 | true); | 3466 | true); |
3468 | if (result != KMessageBox::Continue) return false; | 3467 | if (result != KMessageBox::Continue) return false; |
3469 | } | 3468 | } |
3470 | 3469 | ||
3471 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3470 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3472 | 3471 | ||
3473 | // Force correct extension | 3472 | // Force correct extension |
3474 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3473 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3475 | 3474 | ||
3476 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3475 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3477 | return storage.save(); | 3476 | return storage.save(); |
3478 | 3477 | ||
3479 | } | 3478 | } |
3480 | 3479 | ||
3481 | void CalendarView::eventUpdated(Incidence *) | 3480 | void CalendarView::eventUpdated(Incidence *) |
3482 | { | 3481 | { |
3483 | setModified(); | 3482 | setModified(); |
3484 | // Don't call updateView here. The code, which has caused the update of the | 3483 | // Don't call updateView here. The code, which has caused the update of the |
3485 | // event is responsible for updating the view. | 3484 | // event is responsible for updating the view. |
3486 | // updateView(); | 3485 | // updateView(); |
3487 | } | 3486 | } |
3488 | 3487 | ||
3489 | void CalendarView::adaptNavigationUnits() | 3488 | void CalendarView::adaptNavigationUnits() |
3490 | { | 3489 | { |
3491 | if (mViewManager->currentView()->isEventView()) { | 3490 | if (mViewManager->currentView()->isEventView()) { |
3492 | int days = mViewManager->currentView()->currentDateCount(); | 3491 | int days = mViewManager->currentView()->currentDateCount(); |
3493 | if (days == 1) { | 3492 | if (days == 1) { |
3494 | emit changeNavStringPrev(i18n("&Previous Day")); | 3493 | emit changeNavStringPrev(i18n("&Previous Day")); |
3495 | emit changeNavStringNext(i18n("&Next Day")); | 3494 | emit changeNavStringNext(i18n("&Next Day")); |
3496 | } else { | 3495 | } else { |
3497 | emit changeNavStringPrev(i18n("&Previous Week")); | 3496 | emit changeNavStringPrev(i18n("&Previous Week")); |
3498 | emit changeNavStringNext(i18n("&Next Week")); | 3497 | emit changeNavStringNext(i18n("&Next Week")); |
3499 | } | 3498 | } |
3500 | } | 3499 | } |
3501 | } | 3500 | } |
3502 | 3501 | ||
3503 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3502 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3504 | { | 3503 | { |
3505 | if ( incidence ) mTodoList->clearSelection(); | 3504 | if ( incidence ) mTodoList->clearSelection(); |
3506 | processIncidenceSelection( incidence ); | 3505 | processIncidenceSelection( incidence ); |
3507 | } | 3506 | } |
3508 | 3507 | ||
3509 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3508 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3510 | { | 3509 | { |
3511 | if ( incidence && mViewManager->currentView() ) { | 3510 | if ( incidence && mViewManager->currentView() ) { |
3512 | mViewManager->currentView()->clearSelection(); | 3511 | mViewManager->currentView()->clearSelection(); |
3513 | } | 3512 | } |
3514 | processIncidenceSelection( incidence ); | 3513 | processIncidenceSelection( incidence ); |
3515 | } | 3514 | } |
3516 | 3515 | ||
3517 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3516 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3518 | { | 3517 | { |
3519 | if ( incidence == mSelectedIncidence ) return; | 3518 | if ( incidence == mSelectedIncidence ) return; |
3520 | 3519 | ||
3521 | mSelectedIncidence = incidence; | 3520 | mSelectedIncidence = incidence; |
3522 | 3521 | ||
3523 | emit incidenceSelected( mSelectedIncidence ); | 3522 | emit incidenceSelected( mSelectedIncidence ); |
3524 | 3523 | ||
3525 | if ( incidence && incidence->type() == "Event" ) { | 3524 | if ( incidence && incidence->type() == "Event" ) { |
3526 | Event *event = static_cast<Event *>( incidence ); | 3525 | Event *event = static_cast<Event *>( incidence ); |
3527 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3526 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3528 | emit organizerEventsSelected( true ); | 3527 | emit organizerEventsSelected( true ); |
3529 | } else { | 3528 | } else { |
3530 | emit organizerEventsSelected(false); | 3529 | emit organizerEventsSelected(false); |
3531 | } | 3530 | } |
3532 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3531 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3533 | KOPrefs::instance()->email() ) ) { | 3532 | KOPrefs::instance()->email() ) ) { |
3534 | emit groupEventsSelected( true ); | 3533 | emit groupEventsSelected( true ); |
3535 | } else { | 3534 | } else { |
3536 | emit groupEventsSelected(false); | 3535 | emit groupEventsSelected(false); |
3537 | } | 3536 | } |
3538 | return; | 3537 | return; |
3539 | } else { | 3538 | } else { |
3540 | if ( incidence && incidence->type() == "Todo" ) { | 3539 | if ( incidence && incidence->type() == "Todo" ) { |
3541 | emit todoSelected( true ); | 3540 | emit todoSelected( true ); |
3542 | Todo *event = static_cast<Todo *>( incidence ); | 3541 | Todo *event = static_cast<Todo *>( incidence ); |
3543 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3542 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3544 | emit organizerEventsSelected( true ); | 3543 | emit organizerEventsSelected( true ); |
3545 | } else { | 3544 | } else { |
3546 | emit organizerEventsSelected(false); | 3545 | emit organizerEventsSelected(false); |
3547 | } | 3546 | } |
3548 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3547 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3549 | KOPrefs::instance()->email() ) ) { | 3548 | KOPrefs::instance()->email() ) ) { |
3550 | emit groupEventsSelected( true ); | 3549 | emit groupEventsSelected( true ); |
3551 | } else { | 3550 | } else { |
3552 | emit groupEventsSelected(false); | 3551 | emit groupEventsSelected(false); |
3553 | } | 3552 | } |
3554 | return; | 3553 | return; |
3555 | } else { | 3554 | } else { |
3556 | emit todoSelected( false ); | 3555 | emit todoSelected( false ); |
3557 | emit organizerEventsSelected(false); | 3556 | emit organizerEventsSelected(false); |
3558 | emit groupEventsSelected(false); | 3557 | emit groupEventsSelected(false); |
3559 | } | 3558 | } |
3560 | return; | 3559 | return; |
3561 | } | 3560 | } |
3562 | 3561 | ||
3563 | /* if ( incidence && incidence->type() == "Todo" ) { | 3562 | /* if ( incidence && incidence->type() == "Todo" ) { |
3564 | emit todoSelected( true ); | 3563 | emit todoSelected( true ); |
3565 | } else { | 3564 | } else { |
3566 | emit todoSelected( false ); | 3565 | emit todoSelected( false ); |
3567 | }*/ | 3566 | }*/ |
3568 | } | 3567 | } |
3569 | 3568 | ||
3570 | 3569 | ||
3571 | void CalendarView::checkClipboard() | 3570 | void CalendarView::checkClipboard() |
3572 | { | 3571 | { |
3573 | #ifndef KORG_NODND | 3572 | #ifndef KORG_NODND |
3574 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3573 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3575 | emit pasteEnabled(true); | 3574 | emit pasteEnabled(true); |
3576 | } else { | 3575 | } else { |
3577 | emit pasteEnabled(false); | 3576 | emit pasteEnabled(false); |
3578 | } | 3577 | } |
3579 | #endif | 3578 | #endif |
3580 | } | 3579 | } |
3581 | 3580 | ||
3582 | void CalendarView::showDates(const DateList &selectedDates) | 3581 | void CalendarView::showDates(const DateList &selectedDates) |
3583 | { | 3582 | { |
3584 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3583 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3585 | 3584 | ||
3586 | 3585 | ||
3587 | if ( !mBlockShowDates ) { | 3586 | if ( !mBlockShowDates ) { |
3588 | if ( mViewManager->currentView() ) { | 3587 | if ( mViewManager->currentView() ) { |
3589 | updateView( selectedDates.first(), selectedDates.last() ); | 3588 | updateView( selectedDates.first(), selectedDates.last() ); |
3590 | } else { | 3589 | } else { |
3591 | mViewManager->showAgendaView(); | 3590 | mViewManager->showAgendaView(); |
3592 | } | 3591 | } |
3593 | } | 3592 | } |
3594 | 3593 | ||
3595 | QString selDates; | 3594 | QString selDates; |
3596 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3595 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3597 | if (selectedDates.first() < selectedDates.last() ) | 3596 | if (selectedDates.first() < selectedDates.last() ) |
3598 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3597 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3599 | else { | 3598 | else { |
3600 | QString addString; | 3599 | QString addString; |
3601 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3600 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3602 | addString = i18n("Today"); | 3601 | addString = i18n("Today"); |
3603 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3602 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3604 | addString = i18n("Tomorrow"); | 3603 | addString = i18n("Tomorrow"); |
3605 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3604 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3606 | addString = i18n("Yesterday"); | 3605 | addString = i18n("Yesterday"); |
3607 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3606 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3608 | addString = i18n("Day before yesterday"); | 3607 | addString = i18n("Day before yesterday"); |
3609 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3608 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3610 | addString = i18n("Day after tomorrow"); | 3609 | addString = i18n("Day after tomorrow"); |
3611 | if ( !addString.isEmpty() ) { | 3610 | if ( !addString.isEmpty() ) { |
3612 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3611 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3613 | return; | 3612 | return; |
3614 | } | 3613 | } |
3615 | } | 3614 | } |
3616 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3615 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3617 | 3616 | ||
3618 | } | 3617 | } |
3619 | 3618 | ||
3620 | QPtrList<CalFilter> CalendarView::filters() | 3619 | QPtrList<CalFilter> CalendarView::filters() |
3621 | { | 3620 | { |
3622 | return mFilters; | 3621 | return mFilters; |
3623 | 3622 | ||
3624 | } | 3623 | } |
3625 | void CalendarView::editFilters() | 3624 | void CalendarView::editFilters() |
3626 | { | 3625 | { |
3627 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3626 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3628 | 3627 | ||
3629 | CalFilter *filter = mFilters.first(); | 3628 | CalFilter *filter = mFilters.first(); |
3630 | while(filter) { | 3629 | while(filter) { |
3631 | kdDebug() << " Filter: " << filter->name() << endl; | 3630 | kdDebug() << " Filter: " << filter->name() << endl; |
3632 | filter = mFilters.next(); | 3631 | filter = mFilters.next(); |
3633 | } | 3632 | } |
3634 | 3633 | ||
3635 | mDialogManager->showFilterEditDialog(&mFilters); | 3634 | mDialogManager->showFilterEditDialog(&mFilters); |
3636 | } | 3635 | } |
3637 | void CalendarView::toggleFilter() | 3636 | void CalendarView::toggleFilter() |
3638 | { | 3637 | { |
3639 | showFilter(! mFilterView->isVisible()); | 3638 | showFilter(! mFilterView->isVisible()); |
3640 | } | 3639 | } |
3641 | 3640 | ||
3642 | KOFilterView *CalendarView::filterView() | 3641 | KOFilterView *CalendarView::filterView() |
3643 | { | 3642 | { |
3644 | return mFilterView; | 3643 | return mFilterView; |
3645 | } | 3644 | } |
3646 | void CalendarView::selectFilter( int fil ) | 3645 | void CalendarView::selectFilter( int fil ) |
3647 | { | 3646 | { |
3648 | mFilterView->setSelectedFilter( fil ); | 3647 | mFilterView->setSelectedFilter( fil ); |
3649 | } | 3648 | } |
3650 | void CalendarView::showFilter(bool visible) | 3649 | void CalendarView::showFilter(bool visible) |
3651 | { | 3650 | { |
3652 | if (visible) mFilterView->show(); | 3651 | if (visible) mFilterView->show(); |
3653 | else mFilterView->hide(); | 3652 | else mFilterView->hide(); |
3654 | } | 3653 | } |
3655 | void CalendarView::toggleFilerEnabled( ) | 3654 | void CalendarView::toggleFilerEnabled( ) |
3656 | { | 3655 | { |
3657 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3656 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3658 | if ( !mFilterView->filtersEnabled() ) | 3657 | if ( !mFilterView->filtersEnabled() ) |
3659 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3658 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3660 | 3659 | ||
3661 | } | 3660 | } |
3662 | void CalendarView::updateFilter() | 3661 | void CalendarView::updateFilter() |
3663 | { | 3662 | { |
3664 | CalFilter *filter = mFilterView->selectedFilter(); | 3663 | CalFilter *filter = mFilterView->selectedFilter(); |
3665 | if (filter) { | 3664 | if (filter) { |
3666 | QString mess; | 3665 | QString mess; |
3667 | if (mFilterView->filtersEnabled()) { | 3666 | if (mFilterView->filtersEnabled()) { |
3668 | mess = i18n("Filter selected: ")+filter->name(); | 3667 | mess = i18n("Filter selected: ")+filter->name(); |
3669 | filter->setEnabled(true); | 3668 | filter->setEnabled(true); |
3670 | } | 3669 | } |
3671 | else filter->setEnabled(false); | 3670 | else filter->setEnabled(false); |
3672 | mCalendar->setFilter(filter); | 3671 | mCalendar->setFilter(filter); |
3673 | updateView(); | 3672 | updateView(); |
3674 | if ( !mess.isEmpty() ) | 3673 | if ( !mess.isEmpty() ) |
3675 | topLevelWidget()->setCaption( mess ); | 3674 | topLevelWidget()->setCaption( mess ); |
3676 | 3675 | ||
3677 | } | 3676 | } |
3678 | } | 3677 | } |
3679 | 3678 | ||
3680 | void CalendarView::filterEdited() | 3679 | void CalendarView::filterEdited() |
3681 | { | 3680 | { |
3682 | mFilterView->updateFilters(); | 3681 | mFilterView->updateFilters(); |
3683 | updateFilter(); | 3682 | updateFilter(); |
3684 | writeSettings(); | 3683 | writeSettings(); |
3685 | } | 3684 | } |
3686 | 3685 | ||
3687 | 3686 | ||
3688 | void CalendarView::takeOverEvent() | 3687 | void CalendarView::takeOverEvent() |
3689 | { | 3688 | { |
3690 | Incidence *incidence = currentSelection(); | 3689 | Incidence *incidence = currentSelection(); |
3691 | 3690 | ||
3692 | if (!incidence) return; | 3691 | if (!incidence) return; |
3693 | 3692 | ||
3694 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3693 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3695 | incidence->recreate(); | 3694 | incidence->recreate(); |
3696 | incidence->setReadOnly(false); | 3695 | incidence->setReadOnly(false); |
3697 | 3696 | ||
3698 | updateView(); | 3697 | updateView(); |
3699 | } | 3698 | } |
3700 | 3699 | ||
3701 | void CalendarView::takeOverCalendar() | 3700 | void CalendarView::takeOverCalendar() |
3702 | { | 3701 | { |
3703 | // TODO: Create Calendar::allIncidences() function and use it here | 3702 | // TODO: Create Calendar::allIncidences() function and use it here |
3704 | 3703 | ||
3705 | QPtrList<Event> events = mCalendar->events(); | 3704 | QPtrList<Event> events = mCalendar->events(); |
3706 | for(uint i=0; i<events.count(); ++i) { | 3705 | for(uint i=0; i<events.count(); ++i) { |
3707 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3706 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3708 | events.at(i)->recreate(); | 3707 | events.at(i)->recreate(); |
3709 | events.at(i)->setReadOnly(false); | 3708 | events.at(i)->setReadOnly(false); |
3710 | } | 3709 | } |
3711 | 3710 | ||
3712 | QPtrList<Todo> todos = mCalendar->todos(); | 3711 | QPtrList<Todo> todos = mCalendar->todos(); |
3713 | for(uint i=0; i<todos.count(); ++i) { | 3712 | for(uint i=0; i<todos.count(); ++i) { |
3714 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3713 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3715 | todos.at(i)->recreate(); | 3714 | todos.at(i)->recreate(); |
3716 | todos.at(i)->setReadOnly(false); | 3715 | todos.at(i)->setReadOnly(false); |
3717 | } | 3716 | } |
3718 | 3717 | ||
3719 | QPtrList<Journal> journals = mCalendar->journals(); | 3718 | QPtrList<Journal> journals = mCalendar->journals(); |
3720 | for(uint i=0; i<journals.count(); ++i) { | 3719 | for(uint i=0; i<journals.count(); ++i) { |
3721 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3720 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3722 | journals.at(i)->recreate(); | 3721 | journals.at(i)->recreate(); |
3723 | journals.at(i)->setReadOnly(false); | 3722 | journals.at(i)->setReadOnly(false); |
3724 | } | 3723 | } |
3725 | 3724 | ||
3726 | updateView(); | 3725 | updateView(); |
3727 | } | 3726 | } |
3728 | 3727 | ||
3729 | void CalendarView::showIntro() | 3728 | void CalendarView::showIntro() |
3730 | { | 3729 | { |
3731 | kdDebug() << "To be implemented." << endl; | 3730 | kdDebug() << "To be implemented." << endl; |
3732 | } | 3731 | } |
3733 | 3732 | ||
3734 | QWidgetStack *CalendarView::viewStack() | 3733 | QWidgetStack *CalendarView::viewStack() |
3735 | { | 3734 | { |
3736 | return mRightFrame; | 3735 | return mRightFrame; |
3737 | } | 3736 | } |
3738 | 3737 | ||
3739 | QWidget *CalendarView::leftFrame() | 3738 | QWidget *CalendarView::leftFrame() |
3740 | { | 3739 | { |
3741 | return ( QWidget *)mLeftFrame; | 3740 | return ( QWidget *)mLeftFrame; |
3742 | } | 3741 | } |
3743 | 3742 | ||
3744 | DateNavigator *CalendarView::dateNavigator() | 3743 | DateNavigator *CalendarView::dateNavigator() |
3745 | { | 3744 | { |
3746 | return mNavigator; | 3745 | return mNavigator; |
3747 | } | 3746 | } |
3748 | 3747 | ||
3749 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3748 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3750 | { | 3749 | { |
3751 | return mDateNavigator->navigatorView(); | 3750 | return mDateNavigator->navigatorView(); |
3752 | } | 3751 | } |
3753 | void CalendarView::toggleDateNavigatorWidget() | 3752 | void CalendarView::toggleDateNavigatorWidget() |
3754 | { | 3753 | { |
3755 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3754 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3756 | 3755 | ||
3757 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3756 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3758 | mDateNavigator->hide(); | 3757 | mDateNavigator->hide(); |
3759 | else | 3758 | else |
3760 | mDateNavigator->show(); | 3759 | mDateNavigator->show(); |
3761 | } | 3760 | } |
3762 | void CalendarView::addView(KOrg::BaseView *view) | 3761 | void CalendarView::addView(KOrg::BaseView *view) |
3763 | { | 3762 | { |
3764 | mViewManager->addView(view); | 3763 | mViewManager->addView(view); |
3765 | } | 3764 | } |
3766 | 3765 | ||
3767 | void CalendarView::showView(KOrg::BaseView *view) | 3766 | void CalendarView::showView(KOrg::BaseView *view) |
3768 | { | 3767 | { |
3769 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3768 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3770 | } | 3769 | } |
3771 | 3770 | ||
3772 | Incidence *CalendarView::currentSelection() | 3771 | Incidence *CalendarView::currentSelection() |
3773 | { | 3772 | { |
3774 | return mViewManager->currentSelection(); | 3773 | return mViewManager->currentSelection(); |
3775 | } | 3774 | } |
3776 | void CalendarView::toggleAllDaySize() | 3775 | void CalendarView::toggleAllDaySize() |
3777 | { | 3776 | { |
3778 | /* | 3777 | /* |
3779 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3778 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3780 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3779 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3781 | else | 3780 | else |
3782 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3781 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3783 | */ | 3782 | */ |
3784 | viewManager()->agendaView()->toggleAllDay(); | 3783 | viewManager()->agendaView()->toggleAllDay(); |
3785 | } | 3784 | } |
3786 | void CalendarView::toggleExpand() | 3785 | void CalendarView::toggleExpand() |
3787 | { | 3786 | { |
3788 | // if ( mLeftFrame->isHidden() ) { | 3787 | // if ( mLeftFrame->isHidden() ) { |
3789 | // mLeftFrame->show(); | 3788 | // mLeftFrame->show(); |
3790 | // emit calendarViewExpanded( false ); | 3789 | // emit calendarViewExpanded( false ); |
3791 | // } else { | 3790 | // } else { |
3792 | // mLeftFrame->hide(); | 3791 | // mLeftFrame->hide(); |
3793 | // emit calendarViewExpanded( true ); | 3792 | // emit calendarViewExpanded( true ); |
3794 | // } | 3793 | // } |
3795 | //qDebug(" CalendarView::toggleExpand()"); | 3794 | //qDebug(" CalendarView::toggleExpand()"); |
3796 | globalFlagBlockAgenda = 1; | 3795 | globalFlagBlockAgenda = 1; |
3797 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3796 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3798 | globalFlagBlockAgenda = 5; | 3797 | globalFlagBlockAgenda = 5; |
3799 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3798 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3800 | //mViewManager->showView( 0, true ); | 3799 | //mViewManager->showView( 0, true ); |
3801 | } | 3800 | } |
3802 | 3801 | ||
3803 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3802 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3804 | { | 3803 | { |
3805 | setModified( modified ); | 3804 | setModified( modified ); |
3806 | } | 3805 | } |
3807 | 3806 | ||
3808 | Todo *CalendarView::selectedTodo() | 3807 | Todo *CalendarView::selectedTodo() |
3809 | { | 3808 | { |
3810 | Incidence *incidence = currentSelection(); | 3809 | Incidence *incidence = currentSelection(); |
3811 | if ( incidence && incidence->type() == "Todo" ) { | 3810 | if ( incidence && incidence->type() == "Todo" ) { |
3812 | return static_cast<Todo *>( incidence ); | 3811 | return static_cast<Todo *>( incidence ); |
3813 | } | 3812 | } |
3814 | 3813 | ||
3815 | incidence = mTodoList->selectedIncidences().first(); | 3814 | incidence = mTodoList->selectedIncidences().first(); |
3816 | if ( incidence && incidence->type() == "Todo" ) { | 3815 | if ( incidence && incidence->type() == "Todo" ) { |
3817 | return static_cast<Todo *>( incidence ); | 3816 | return static_cast<Todo *>( incidence ); |
3818 | } | 3817 | } |
3819 | 3818 | ||
3820 | return 0; | 3819 | return 0; |
3821 | } | 3820 | } |
3822 | 3821 | ||
3823 | void CalendarView::dialogClosing(Incidence *in) | 3822 | void CalendarView::dialogClosing(Incidence *in) |
3824 | { | 3823 | { |
3825 | // mDialogList.remove(in); | 3824 | // mDialogList.remove(in); |
3826 | } | 3825 | } |
3827 | 3826 | ||
3828 | void CalendarView::showIncidence() | 3827 | void CalendarView::showIncidence() |
3829 | { | 3828 | { |
3830 | mViewerCallerIsSearchDialog = false; | 3829 | mViewerCallerIsSearchDialog = false; |
3831 | Incidence *incidence = currentSelection(); | 3830 | Incidence *incidence = currentSelection(); |
3832 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3831 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3833 | if ( incidence ) { | 3832 | if ( incidence ) { |
3834 | ShowIncidenceVisitor v; | 3833 | ShowIncidenceVisitor v; |
3835 | v.act( incidence, this ); | 3834 | v.act( incidence, this ); |
3836 | } | 3835 | } |
3837 | } | 3836 | } |
3838 | void CalendarView::editIncidenceDescription() | 3837 | void CalendarView::editIncidenceDescription() |
3839 | { | 3838 | { |
3840 | mFlagEditDescription = true; | 3839 | mFlagEditDescription = true; |
3841 | editIncidence(); | 3840 | editIncidence(); |
3842 | mFlagEditDescription = false; | 3841 | mFlagEditDescription = false; |
3843 | } | 3842 | } |
3844 | void CalendarView::editIncidence() | 3843 | void CalendarView::editIncidence() |
3845 | { | 3844 | { |
3846 | // qDebug("editIncidence() "); | 3845 | // qDebug("editIncidence() "); |
3847 | Incidence *incidence = currentSelection(); | 3846 | Incidence *incidence = currentSelection(); |
3848 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3847 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3849 | if ( incidence ) { | 3848 | if ( incidence ) { |
3850 | EditIncidenceVisitor v; | 3849 | EditIncidenceVisitor v; |
3851 | v.act( incidence, this ); | 3850 | v.act( incidence, this ); |
3852 | } | 3851 | } |
3853 | } | 3852 | } |
3854 | 3853 | ||
3855 | void CalendarView::deleteIncidence() | 3854 | void CalendarView::deleteIncidence() |
3856 | { | 3855 | { |
3857 | Incidence *incidence = currentSelection(); | 3856 | Incidence *incidence = currentSelection(); |
3858 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3857 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3859 | if ( incidence ) { | 3858 | if ( incidence ) { |
3860 | deleteIncidence(incidence); | 3859 | deleteIncidence(incidence); |
3861 | } | 3860 | } |
3862 | } | 3861 | } |
3863 | 3862 | ||
3864 | void CalendarView::showIncidence(Incidence *incidence) | 3863 | void CalendarView::showIncidence(Incidence *incidence) |
3865 | { | 3864 | { |
3866 | mViewerCallerIsSearchDialog = false; | 3865 | mViewerCallerIsSearchDialog = false; |
3867 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3866 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3868 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3867 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3869 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3868 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3870 | mViewerCallerIsSearchDialog = true; | 3869 | mViewerCallerIsSearchDialog = true; |
3871 | } | 3870 | } |
3872 | } | 3871 | } |
3873 | if ( incidence ) { | 3872 | if ( incidence ) { |
3874 | ShowIncidenceVisitor v; | 3873 | ShowIncidenceVisitor v; |
3875 | v.act( incidence, this ); | 3874 | v.act( incidence, this ); |
3876 | } | 3875 | } |
3877 | } | 3876 | } |
3878 | 3877 | ||
3879 | void CalendarView::editIncidence(Incidence *incidence) | 3878 | void CalendarView::editIncidence(Incidence *incidence) |
3880 | { | 3879 | { |
3881 | if ( incidence ) { | 3880 | if ( incidence ) { |
3882 | 3881 | ||
3883 | EditIncidenceVisitor v; | 3882 | EditIncidenceVisitor v; |
3884 | v.act( incidence, this ); | 3883 | v.act( incidence, this ); |
3885 | 3884 | ||
3886 | } | 3885 | } |
3887 | } | 3886 | } |
3888 | 3887 | ||
3889 | void CalendarView::deleteIncidence(Incidence *incidence) | 3888 | void CalendarView::deleteIncidence(Incidence *incidence) |
3890 | { | 3889 | { |
3891 | //qDebug(" CalendarView::deleteIncidence "); | 3890 | //qDebug(" CalendarView::deleteIncidence "); |
3892 | if ( incidence ) { | 3891 | if ( incidence ) { |
3893 | DeleteIncidenceVisitor v; | 3892 | DeleteIncidenceVisitor v; |
3894 | v.act( incidence, this ); | 3893 | v.act( incidence, this ); |
3895 | } | 3894 | } |
3896 | } | 3895 | } |
3897 | 3896 | ||
3898 | 3897 | ||
3899 | void CalendarView::lookForOutgoingMessages() | 3898 | void CalendarView::lookForOutgoingMessages() |
3900 | { | 3899 | { |
3901 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3900 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3902 | ogd->loadMessages(); | 3901 | ogd->loadMessages(); |
3903 | } | 3902 | } |
3904 | 3903 | ||
3905 | void CalendarView::lookForIncomingMessages() | 3904 | void CalendarView::lookForIncomingMessages() |
3906 | { | 3905 | { |
3907 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3906 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3908 | icd->retrieve(); | 3907 | icd->retrieve(); |
3909 | } | 3908 | } |
3910 | 3909 | ||
3911 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3910 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3912 | { | 3911 | { |
3913 | bool deleteTodo = true; | 3912 | bool deleteTodo = true; |
3914 | QPtrList<Incidence> subTodos; | 3913 | QPtrList<Incidence> subTodos; |
3915 | Incidence *aTodo; | 3914 | Incidence *aTodo; |
3916 | subTodos = t->relations(); | 3915 | subTodos = t->relations(); |
3917 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3916 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3918 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3917 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3919 | deleteTodo = false; | 3918 | deleteTodo = false; |
3920 | } | 3919 | } |
3921 | if ( deleteTodo ) { | 3920 | if ( deleteTodo ) { |
3922 | if ( t->isCompleted() && !t->doesRecur()) { | 3921 | if ( t->isCompleted() && !t->doesRecur()) { |
3923 | checkExternalId( t ); | 3922 | checkExternalId( t ); |
3924 | mCalendar->deleteTodo( t ); | 3923 | mCalendar->deleteTodo( t ); |
3925 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3924 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3926 | } | 3925 | } |
3927 | else | 3926 | else |
3928 | deleteTodo = false; | 3927 | deleteTodo = false; |
3929 | } | 3928 | } |
3930 | return deleteTodo; | 3929 | return deleteTodo; |
3931 | 3930 | ||
3932 | } | 3931 | } |
3933 | void CalendarView::purgeCompleted() | 3932 | void CalendarView::purgeCompleted() |
3934 | { | 3933 | { |
3935 | int result = KMessageBox::warningContinueCancel(this, | 3934 | int result = KMessageBox::warningContinueCancel(this, |
3936 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3935 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3937 | 3936 | ||
3938 | if (result == KMessageBox::Continue) { | 3937 | if (result == KMessageBox::Continue) { |
3939 | 3938 | ||
3940 | QPtrList<Todo> todoCal; | 3939 | QPtrList<Todo> todoCal; |
3941 | QPtrList<Todo> rootTodos; | 3940 | QPtrList<Todo> rootTodos; |
3942 | //QPtrList<Incidence> rel; | 3941 | //QPtrList<Incidence> rel; |
3943 | Todo *aTodo;//, *rTodo; | 3942 | Todo *aTodo;//, *rTodo; |
3944 | Incidence *rIncidence; | 3943 | Incidence *rIncidence; |
3945 | bool childDelete = false; | 3944 | bool childDelete = false; |
3946 | bool deletedOne = true; | 3945 | bool deletedOne = true; |
3947 | todoCal = calendar()->todos(); | 3946 | todoCal = calendar()->todos(); |
3948 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3947 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3949 | if ( !aTodo->relatedTo() ) | 3948 | if ( !aTodo->relatedTo() ) |
3950 | rootTodos.append( aTodo ); | 3949 | rootTodos.append( aTodo ); |
3951 | } | 3950 | } |
3952 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3951 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3953 | removeCompletedSubTodos( aTodo ); | 3952 | removeCompletedSubTodos( aTodo ); |
3954 | } | 3953 | } |
3955 | 3954 | ||
3956 | updateView(); | 3955 | updateView(); |
3957 | } | 3956 | } |
3958 | } | 3957 | } |
3959 | 3958 | ||
3960 | void CalendarView::slotCalendarChanged() | 3959 | void CalendarView::slotCalendarChanged() |
3961 | { | 3960 | { |
3962 | ; | 3961 | ; |
3963 | } | 3962 | } |
3964 | 3963 | ||
3965 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3964 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3966 | { | 3965 | { |
3967 | //qDebug(" alendarView::keyPressEvent "); | 3966 | //qDebug(" alendarView::keyPressEvent "); |
3968 | e->ignore(); | 3967 | e->ignore(); |
3969 | } | 3968 | } |
3970 | 3969 | ||
3971 | 3970 | ||
3972 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3971 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3973 | { | 3972 | { |
3974 | // mSyncManager = manager; | 3973 | // mSyncManager = manager; |
3975 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3974 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3976 | qDebug("KO: SyncKDE request detected!"); | 3975 | qDebug("KO: SyncKDE request detected!"); |
3977 | } | 3976 | } |
3978 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3977 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3979 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3978 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3980 | return syncCalendar( filename, mode ); | 3979 | return syncCalendar( filename, mode ); |
3981 | } | 3980 | } |
3982 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3981 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3983 | { | 3982 | { |
3984 | //mSyncManager = manager; | 3983 | //mSyncManager = manager; |
3985 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3984 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3986 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3985 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3987 | if ( resource == "sharp" ) | 3986 | if ( resource == "sharp" ) |
3988 | syncExternal( 0 ); | 3987 | syncExternal( 0 ); |
3989 | if ( resource == "phone" ) | 3988 | if ( resource == "phone" ) |
3990 | syncExternal( 1 ); | 3989 | syncExternal( 1 ); |
3991 | // pending setmodified | 3990 | // pending setmodified |
3992 | return true; | 3991 | return true; |
3993 | } | 3992 | } |
3994 | void CalendarView::setSyncManager(KSyncManager* manager) | 3993 | void CalendarView::setSyncManager(KSyncManager* manager) |
3995 | { | 3994 | { |
3996 | mSyncManager = manager; | 3995 | mSyncManager = manager; |
3997 | } | 3996 | } |
3998 | 3997 | ||
3999 | void CalendarView::removeSyncInfo( QString syncProfile) | 3998 | void CalendarView::removeSyncInfo( QString syncProfile) |
4000 | { | 3999 | { |
4001 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 4000 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
4002 | mCalendar->removeSyncInfo( syncProfile ); | 4001 | mCalendar->removeSyncInfo( syncProfile ); |
4003 | 4002 | ||
4004 | } | 4003 | } |
4005 | 4004 | ||
4006 | void CalendarView::undo_delete() | 4005 | void CalendarView::undo_delete() |
4007 | { | 4006 | { |
4008 | //qDebug("undo_delete() "); | 4007 | //qDebug("undo_delete() "); |
4009 | Incidence* undo = mCalendar->undoIncidence(); | 4008 | Incidence* undo = mCalendar->undoIncidence(); |
4010 | if ( !undo ) { | 4009 | if ( !undo ) { |
4011 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 4010 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
4012 | i18n("KO/Pi")); | 4011 | i18n("KO/Pi")); |
4013 | return; | 4012 | return; |
4014 | } | 4013 | } |
4015 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 4014 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
4016 | i18n("\nAre you sure you want\nto restore this?"), | 4015 | i18n("\nAre you sure you want\nto restore this?"), |
4017 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 4016 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
4018 | mCalendar->undoDeleteIncidence(); | 4017 | mCalendar->undoDeleteIncidence(); |
4019 | updateView(); | 4018 | updateView(); |
4020 | } | 4019 | } |
4021 | } | 4020 | } |
4022 | 4021 | ||
4023 | void CalendarView::slotViewerClosed() | 4022 | void CalendarView::slotViewerClosed() |
4024 | { | 4023 | { |
4025 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 4024 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
4026 | } | 4025 | } |
4027 | 4026 | ||
4028 | void CalendarView::resetFocus() | 4027 | void CalendarView::resetFocus() |
4029 | { | 4028 | { |
4030 | if ( mViewerCallerIsSearchDialog ) { | 4029 | if ( mViewerCallerIsSearchDialog ) { |
4031 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 4030 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
4032 | mDialogManager->getSearchDialog()->raise(); | 4031 | mDialogManager->getSearchDialog()->raise(); |
4033 | mDialogManager->getSearchDialog()->setActiveWindow(); | 4032 | mDialogManager->getSearchDialog()->setActiveWindow(); |
4034 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 4033 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
4035 | } else | 4034 | } else |
4036 | mViewerCallerIsSearchDialog = false; | 4035 | mViewerCallerIsSearchDialog = false; |
4037 | } | 4036 | } |
4038 | if ( !mViewerCallerIsSearchDialog ) { | 4037 | if ( !mViewerCallerIsSearchDialog ) { |
4039 | //mViewManager->currentView()->setFocus(); | 4038 | //mViewManager->currentView()->setFocus(); |
4040 | //qDebug("sssssssssssssssset focus "); | 4039 | //qDebug("sssssssssssssssset focus "); |
4041 | topLevelWidget()->raise(); | 4040 | topLevelWidget()->raise(); |
4042 | setActiveWindow(); | 4041 | setActiveWindow(); |
4043 | //setFocus(); | 4042 | //setFocus(); |
4044 | } | 4043 | } |
4045 | mViewerCallerIsSearchDialog = false; | 4044 | mViewerCallerIsSearchDialog = false; |
4046 | } | 4045 | } |
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 3f6e29b..d09f484 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,219 +1,229 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | //#include "koglobals.h" | 29 | //#include "koglobals.h" |
30 | #include "navigatorbar.h" | 30 | #include "navigatorbar.h" |
31 | #include "kdatenavigator.h" | 31 | #include "kdatenavigator.h" |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | 36 | ||
37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
38 | const char *name ) | 38 | const char *name ) |
39 | : QWidget( parent, name ), mCalendar( 0 ), | 39 | : QWidget( parent, name ), mCalendar( 0 ), |
40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
41 | { | 41 | { |
42 | mExtraViews.setAutoDelete( true ); | 42 | mExtraViews.setAutoDelete( true ); |
43 | 43 | ||
44 | mNavigatorView = new KDateNavigator( this, name ); | 44 | mNavigatorView = new KDateNavigator( this, name ); |
45 | 45 | ||
46 | connectNavigatorView( mNavigatorView ); | 46 | connectNavigatorView( mNavigatorView ); |
47 | } | 47 | } |
48 | 48 | ||
49 | DateNavigatorContainer::~DateNavigatorContainer() | 49 | DateNavigatorContainer::~DateNavigatorContainer() |
50 | { | 50 | { |
51 | } | 51 | } |
52 | 52 | ||
53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
54 | { | 54 | { |
55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
57 | #if 0 | 57 | #if 0 |
58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
62 | #endif | 62 | #endif |
63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
64 | SIGNAL( weekClicked( const QDate & ) ) ); | 64 | SIGNAL( weekClicked( const QDate & ) ) ); |
65 | 65 | ||
66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
68 | 68 | ||
69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
73 | 73 | ||
74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
75 | } | 75 | } |
76 | 76 | ||
77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
78 | { | 78 | { |
79 | mCalendar = cal; | 79 | mCalendar = cal; |
80 | mNavigatorView->setCalendar( cal ); | 80 | mNavigatorView->setCalendar( cal ); |
81 | KDateNavigator *n; | 81 | KDateNavigator *n; |
82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
83 | n->setCalendar( cal ); | 83 | n->setCalendar( cal ); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | void DateNavigatorContainer::updateDayMatrix() | 87 | void DateNavigatorContainer::updateDayMatrix() |
88 | { | 88 | { |
89 | mNavigatorView->updateDayMatrix(); | 89 | mNavigatorView->updateDayMatrix(); |
90 | KDateNavigator *n; | 90 | KDateNavigator *n; |
91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
92 | n->updateDayMatrix(); | 92 | n->updateDayMatrix(); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | void DateNavigatorContainer::updateToday() | 96 | void DateNavigatorContainer::updateToday() |
97 | { | 97 | { |
98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
99 | #if 0 | 99 | #if 0 |
100 | mNavigatorView->updateToday(); | 100 | mNavigatorView->updateToday(); |
101 | KDateNavigator *n; | 101 | KDateNavigator *n; |
102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
103 | n->updateToday(); | 103 | n->updateToday(); |
104 | } | 104 | } |
105 | #endif | 105 | #endif |
106 | } | 106 | } |
107 | 107 | ||
108 | void DateNavigatorContainer::updateView() | 108 | void DateNavigatorContainer::updateView() |
109 | { | 109 | { |
110 | mNavigatorView->updateView(); | 110 | mNavigatorView->updateView(); |
111 | KDateNavigator *n; | 111 | KDateNavigator *n; |
112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
113 | n->updateView(); | 113 | n->updateView(); |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | void DateNavigatorContainer::updateConfig() | 117 | void DateNavigatorContainer::updateConfig() |
118 | { | 118 | { |
119 | mNavigatorView->updateConfig(); | 119 | mNavigatorView->updateConfig(); |
120 | KDateNavigator *n; | 120 | KDateNavigator *n; |
121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
122 | n->updateConfig(); | 122 | n->updateConfig(); |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
127 | { | 127 | { |
128 | mNavigatorView->selectDates( dateList ); | 128 | mNavigatorView->selectDates( dateList ); |
129 | setBaseDates(); | 129 | setBaseDates(); |
130 | if ( mExtraViews.count() ) { | ||
131 | KDateNavigator *view = mExtraViews.at( 0 ); | ||
132 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | ||
133 | view->dayMatrix()->repaint(); | ||
134 | } | ||
130 | } | 135 | } |
131 | 136 | ||
132 | void DateNavigatorContainer::setBaseDates() | 137 | void DateNavigatorContainer::setBaseDates() |
133 | { | 138 | { |
134 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 139 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
135 | if ( dateList.isEmpty() ) { | 140 | if ( dateList.isEmpty() ) { |
136 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 141 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
137 | } | 142 | } |
138 | QDate baseDate = dateList.first(); | 143 | QDate baseDate = dateList.first(); |
139 | KDateNavigator *n; | 144 | KDateNavigator *n; |
145 | bool doRepaint = false; // skip first repaint | ||
140 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 146 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
141 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); | 147 | baseDate = baseDate.addDays( baseDate.daysInMonth () ); |
142 | n->setBaseDate( baseDate ); | 148 | n->setBaseDate( baseDate, doRepaint ); |
149 | doRepaint = true; | ||
143 | } | 150 | } |
144 | } | 151 | } |
145 | 152 | ||
146 | void DateNavigatorContainer::resizeEvent( QResizeEvent * ) | 153 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
147 | { | 154 | { |
148 | #if 0 | 155 | #if 0 |
149 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 156 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
150 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 157 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
151 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 158 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
152 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 159 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
153 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 160 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
154 | #endif | 161 | #endif |
155 | 162 | QSize minSize = mNavigatorView->yourSizeHint(); | |
156 | QSize minSize = mNavigatorView->minimumSizeHint(); | ||
157 | 163 | ||
158 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 164 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
159 | 165 | ||
160 | int verticalCount = size().height() / minSize.height(); | 166 | int verticalCount = size().height() / minSize.height(); |
161 | int horizontalCount = size().width() / minSize.width(); | 167 | int horizontalCount = size().width() / minSize.width(); |
168 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | ||
162 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 169 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
163 | if ( horizontalCount != mHorizontalCount || | 170 | if ( horizontalCount != mHorizontalCount || |
164 | verticalCount != mVerticalCount ) { | 171 | verticalCount != mVerticalCount ) { |
165 | uint count = horizontalCount * verticalCount; | 172 | uint count = horizontalCount * verticalCount; |
166 | if ( count == 0 ) return; | 173 | if ( count == 0 ) { |
174 | mNavigatorView->resize( minSize ); | ||
175 | return; | ||
176 | } | ||
167 | 177 | ||
168 | while ( count > ( mExtraViews.count() + 1 ) ) { | 178 | while ( count > ( mExtraViews.count() + 1 ) ) { |
169 | KDateNavigator *n = new KDateNavigator( this ); | 179 | KDateNavigator *n = new KDateNavigator( this ); |
170 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 180 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
171 | mExtraViews.append( n ); | 181 | mExtraViews.append( n ); |
172 | n->setCalendar( mCalendar ); | 182 | n->setCalendar( mCalendar ); |
173 | setBaseDates(); | 183 | setBaseDates(); |
174 | connectNavigatorView( n ); | 184 | connectNavigatorView( n ); |
175 | n->show(); | 185 | n->show(); |
176 | } | 186 | } |
177 | 187 | ||
178 | while ( count < ( mExtraViews.count() + 1 ) ) { | 188 | while ( count < ( mExtraViews.count() + 1 ) ) { |
179 | mExtraViews.removeLast(); | 189 | mExtraViews.removeLast(); |
180 | } | 190 | } |
181 | 191 | ||
182 | mHorizontalCount = horizontalCount; | 192 | mHorizontalCount = horizontalCount; |
183 | mVerticalCount = verticalCount; | 193 | mVerticalCount = verticalCount; |
184 | } | 194 | } |
185 | 195 | ||
186 | int height = size().height() / verticalCount; | 196 | int height = size().height() / verticalCount; |
187 | int width = size().width() / horizontalCount; | 197 | int width = size().width() / horizontalCount; |
188 | 198 | ||
189 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 199 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
190 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 200 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
191 | else bar->showButtons( true, true ); | 201 | else bar->showButtons( true, true ); |
192 | 202 | ||
193 | mNavigatorView->setGeometry(0, | 203 | mNavigatorView->setGeometry(0, |
194 | 0, width, height ); | 204 | 0, width, height ); |
195 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | 205 | for( uint i = 0; i < mExtraViews.count(); ++i ) { |
196 | int x = ( i + 1 ) % horizontalCount; | 206 | int x = ( i + 1 ) % horizontalCount; |
197 | int y = ( i + 1 ) / horizontalCount; | 207 | int y = ( i + 1 ) / horizontalCount; |
198 | 208 | ||
199 | KDateNavigator *view = mExtraViews.at( i ); | 209 | KDateNavigator *view = mExtraViews.at( i ); |
200 | bar = view->navigatorBar(); | 210 | bar = view->navigatorBar(); |
201 | if ( y > 0 ) bar->showButtons( false, false ); | 211 | if ( y > 0 ) bar->showButtons( false, false ); |
202 | else { | 212 | else { |
203 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 213 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
204 | else bar->showButtons( false, false ); | 214 | else bar->showButtons( false, false ); |
205 | } | 215 | } |
206 | view->setGeometry( x * width, | 216 | view->setGeometry( x * width, |
207 | y * height, width, height ); | 217 | y * height, width, height ); |
208 | } | 218 | } |
209 | } | 219 | } |
210 | 220 | ||
211 | QSize DateNavigatorContainer::minimumSizeHint() const | 221 | QSize DateNavigatorContainer::minimumSizeHint() const |
212 | { | 222 | { |
213 | return mNavigatorView->minimumSizeHint(); | 223 | return mNavigatorView->minimumSizeHint(); |
214 | } | 224 | } |
215 | 225 | ||
216 | QSize DateNavigatorContainer::sizeHint() const | 226 | QSize DateNavigatorContainer::sizeHint() const |
217 | { | 227 | { |
218 | return mNavigatorView->sizeHint(); | 228 | return mNavigatorView->sizeHint(); |
219 | } | 229 | } |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index ab9a40f..b097dc1 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,389 +1,390 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 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 <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | 64 | ||
65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
66 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
68 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
74 | 74 | ||
75 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
77 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | 80 | ||
81 | // Set up the heading fields. | 81 | // Set up the heading fields. |
82 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
83 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
85 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
86 | 86 | ||
87 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
88 | } | 88 | } |
89 | 89 | ||
90 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
91 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
92 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
93 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter); |
94 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
95 | if(!m_bShowWeekNums) { | 95 | if(!m_bShowWeekNums) { |
96 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
97 | } | 97 | } |
98 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
99 | 99 | ||
100 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
101 | } | 101 | } |
102 | 102 | ||
103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
105 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
106 | 106 | ||
107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
109 | 109 | ||
110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
111 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
112 | 112 | ||
113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
114 | 114 | ||
115 | // read settings from configuration file. | 115 | // read settings from configuration file. |
116 | updateConfig(); | 116 | updateConfig(); |
117 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
118 | //setFixedSize ( sizeHint() ); | 118 | mySizeHint = sizeHint(); |
119 | } | 119 | } |
120 | void KDateNavigator::slotMonthSelected( int m ) | 120 | void KDateNavigator::slotMonthSelected( int m ) |
121 | { | 121 | { |
122 | if ( m_MthYr.month() <= mMonthSignalOffset) | 122 | if ( m_MthYr.month() <= mMonthSignalOffset) |
123 | m += 12; | 123 | m += 12; |
124 | int mo = m - mMonthSignalOffset; | 124 | int mo = m - mMonthSignalOffset; |
125 | emit monthSelected( m - mMonthSignalOffset ); | 125 | emit monthSelected( m - mMonthSignalOffset ); |
126 | 126 | ||
127 | } | 127 | } |
128 | void KDateNavigator::setCalendar( Calendar *cal ) | 128 | void KDateNavigator::setCalendar( Calendar *cal ) |
129 | { | 129 | { |
130 | daymatrix->setCalendar( cal ); | 130 | daymatrix->setCalendar( cal ); |
131 | } | 131 | } |
132 | 132 | ||
133 | void KDateNavigator::setBaseDate( const QDate &date ) | 133 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
134 | { | 134 | { |
135 | m_MthYr = date; | 135 | m_MthYr = date; |
136 | 136 | ||
137 | updateDates(); | 137 | updateDates(); |
138 | updateView(); | 138 | updateView(); |
139 | 139 | ||
140 | KCal::DateList dates; | 140 | KCal::DateList dates; |
141 | dates.append( date ); | 141 | dates.append( date ); |
142 | mNavigatorBar->selectDates( dates ); | 142 | mNavigatorBar->selectDates( dates ); |
143 | 143 | ||
144 | daymatrix->clearSelection(); | 144 | daymatrix->clearSelection(); |
145 | daymatrix->repaint(); | 145 | if ( doRepaint ) |
146 | daymatrix->repaint(); | ||
146 | } | 147 | } |
147 | 148 | ||
148 | void KDateNavigator::enableRollover(RolloverType r) | 149 | void KDateNavigator::enableRollover(RolloverType r) |
149 | { | 150 | { |
150 | switch(r) | 151 | switch(r) |
151 | { | 152 | { |
152 | case None : | 153 | case None : |
153 | if (updateTimer) | 154 | if (updateTimer) |
154 | { | 155 | { |
155 | updateTimer->stop(); | 156 | updateTimer->stop(); |
156 | delete updateTimer; | 157 | delete updateTimer; |
157 | updateTimer=0L; | 158 | updateTimer=0L; |
158 | } | 159 | } |
159 | break; | 160 | break; |
160 | case FollowDay : | 161 | case FollowDay : |
161 | case FollowMonth : | 162 | case FollowMonth : |
162 | if (!updateTimer) | 163 | if (!updateTimer) |
163 | { | 164 | { |
164 | updateTimer = new QTimer(this); | 165 | updateTimer = new QTimer(this); |
165 | QObject::connect(updateTimer,SIGNAL(timeout()), | 166 | QObject::connect(updateTimer,SIGNAL(timeout()), |
166 | this,SLOT(possiblyPastMidnight())); | 167 | this,SLOT(possiblyPastMidnight())); |
167 | } | 168 | } |
168 | updateTimer->start(0,true); | 169 | updateTimer->start(0,true); |
169 | lastDayChecked = QDate::currentDate(); | 170 | lastDayChecked = QDate::currentDate(); |
170 | } | 171 | } |
171 | updateRollover=r; | 172 | updateRollover=r; |
172 | } | 173 | } |
173 | 174 | ||
174 | 175 | ||
175 | KDateNavigator::~KDateNavigator() | 176 | KDateNavigator::~KDateNavigator() |
176 | { | 177 | { |
177 | } | 178 | } |
178 | 179 | ||
179 | 180 | ||
180 | void KDateNavigator::passedMidnight() | 181 | void KDateNavigator::passedMidnight() |
181 | { | 182 | { |
182 | QDate today = QDate::currentDate(); | 183 | QDate today = QDate::currentDate(); |
183 | bool emitMonth = false; | 184 | bool emitMonth = false; |
184 | 185 | ||
185 | if (today.month() != lastDayChecked.month()) | 186 | if (today.month() != lastDayChecked.month()) |
186 | { | 187 | { |
187 | if (updateRollover==FollowMonth && | 188 | if (updateRollover==FollowMonth && |
188 | daymatrix->isEndOfMonth()) { | 189 | daymatrix->isEndOfMonth()) { |
189 | goNextMonth(); | 190 | goNextMonth(); |
190 | emitMonth=true; | 191 | emitMonth=true; |
191 | } | 192 | } |
192 | } | 193 | } |
193 | daymatrix->recalculateToday(); | 194 | daymatrix->recalculateToday(); |
194 | daymatrix->repaint(); | 195 | daymatrix->repaint(); |
195 | emit dayPassed(today); | 196 | emit dayPassed(today); |
196 | if (emitMonth) { emit monthPassed(today); } | 197 | if (emitMonth) { emit monthPassed(today); } |
197 | } | 198 | } |
198 | 199 | ||
199 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 200 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
200 | { | 201 | { |
201 | if (lastDayChecked!=QDate::currentDate()) | 202 | if (lastDayChecked!=QDate::currentDate()) |
202 | { | 203 | { |
203 | passedMidnight(); | 204 | passedMidnight(); |
204 | lastDayChecked=QDate::currentDate(); | 205 | lastDayChecked=QDate::currentDate(); |
205 | } | 206 | } |
206 | // Set the timer to go off 1 second after midnight | 207 | // Set the timer to go off 1 second after midnight |
207 | // or after 8 minutes, whichever comes first. | 208 | // or after 8 minutes, whichever comes first. |
208 | if (updateTimer) | 209 | if (updateTimer) |
209 | { | 210 | { |
210 | QTime now = QTime::currentTime(); | 211 | QTime now = QTime::currentTime(); |
211 | QTime midnight = QTime(23,59,59); | 212 | QTime midnight = QTime(23,59,59); |
212 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 213 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
213 | 214 | ||
214 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 215 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
215 | //.arg(now.toString()).arg(midnight.toString())); | 216 | //.arg(now.toString()).arg(midnight.toString())); |
216 | 217 | ||
217 | updateTimer->stop(); | 218 | updateTimer->stop(); |
218 | updateTimer->start(msecsWait,true); | 219 | updateTimer->start(msecsWait,true); |
219 | } | 220 | } |
220 | } | 221 | } |
221 | 222 | ||
222 | void KDateNavigator::updateDates() | 223 | void KDateNavigator::updateDates() |
223 | { | 224 | { |
224 | // Find the first day of the week of the current month. | 225 | // Find the first day of the week of the current month. |
225 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 226 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
226 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 227 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
227 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 228 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
228 | //int di = d1 - d2 + 1; | 229 | //int di = d1 - d2 + 1; |
229 | dayone = dayone.addDays( -d2 + 1 ); | 230 | dayone = dayone.addDays( -d2 + 1 ); |
230 | 231 | ||
231 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 232 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
232 | 233 | ||
233 | // If month begins on Monday and Monday is first day of week, | 234 | // If month begins on Monday and Monday is first day of week, |
234 | // month should begin on second line. Sunday doesn't have this problem. | 235 | // month should begin on second line. Sunday doesn't have this problem. |
235 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 236 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
236 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 237 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
237 | 238 | ||
238 | // update the matrix dates | 239 | // update the matrix dates |
239 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 240 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
240 | 241 | ||
241 | 242 | ||
242 | daymatrix->updateView(dayone.addDays(index)); | 243 | daymatrix->updateView(dayone.addDays(index)); |
243 | //each updateDates is followed by an updateView -> repaint is issued there ! | 244 | //each updateDates is followed by an updateView -> repaint is issued there ! |
244 | // daymatrix->repaint(); | 245 | // daymatrix->repaint(); |
245 | } | 246 | } |
246 | 247 | ||
247 | void KDateNavigator::updateDayMatrix() | 248 | void KDateNavigator::updateDayMatrix() |
248 | { | 249 | { |
249 | daymatrix->updateView(); | 250 | daymatrix->updateView(); |
250 | //daymatrix->repaint(); | 251 | //daymatrix->repaint(); |
251 | } | 252 | } |
252 | 253 | ||
253 | 254 | ||
254 | void KDateNavigator::updateView() | 255 | void KDateNavigator::updateView() |
255 | { | 256 | { |
256 | 257 | ||
257 | setUpdatesEnabled( false ); | 258 | setUpdatesEnabled( false ); |
258 | 259 | ||
259 | int i; | 260 | int i; |
260 | 261 | ||
261 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 262 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
262 | daymatrix->updateView(); | 263 | daymatrix->updateView(); |
263 | 264 | ||
264 | // set the week numbers. | 265 | // set the week numbers. |
265 | for(i = 0; i < 6; i++) { | 266 | for(i = 0; i < 6; i++) { |
266 | QString weeknum; | 267 | QString weeknum; |
267 | // remember, according to ISO 8601, the first week of the year is the | 268 | // remember, according to ISO 8601, the first week of the year is the |
268 | // first week that contains a thursday. Thus we must subtract off 4, | 269 | // first week that contains a thursday. Thus we must subtract off 4, |
269 | // not just 1. | 270 | // not just 1. |
270 | 271 | ||
271 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 272 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
272 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 273 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
273 | 274 | ||
274 | int add = 0; | 275 | int add = 0; |
275 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 276 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
276 | ++add; | 277 | ++add; |
277 | if (dayOfYear % 7 != 0) | 278 | if (dayOfYear % 7 != 0) |
278 | weeknum.setNum(dayOfYear / 7 + 1+add); | 279 | weeknum.setNum(dayOfYear / 7 + 1+add); |
279 | else | 280 | else |
280 | weeknum.setNum(dayOfYear / 7 +add); | 281 | weeknum.setNum(dayOfYear / 7 +add); |
281 | weeknos[i]->setText(weeknum); | 282 | weeknos[i]->setText(weeknum); |
282 | } | 283 | } |
283 | 284 | ||
284 | setUpdatesEnabled( true ); | 285 | setUpdatesEnabled( true ); |
285 | // kdDebug() << "updateView() -> repaint()" << endl; | 286 | // kdDebug() << "updateView() -> repaint()" << endl; |
286 | repaint(); | 287 | repaint(); |
287 | // daymatrix->repaint(); | 288 | // daymatrix->repaint(); |
288 | } | 289 | } |
289 | 290 | ||
290 | void KDateNavigator::updateConfig() | 291 | void KDateNavigator::updateConfig() |
291 | { | 292 | { |
292 | int day; | 293 | int day; |
293 | for(int i=0; i<7; i++) { | 294 | for(int i=0; i<7; i++) { |
294 | // take the first letter of the day name to be the abbreviation | 295 | // take the first letter of the day name to be the abbreviation |
295 | if (KGlobal::locale()->weekStartsMonday()) { | 296 | if (KGlobal::locale()->weekStartsMonday()) { |
296 | day = i+1; | 297 | day = i+1; |
297 | } else { | 298 | } else { |
298 | if (i==0) day = 7; | 299 | if (i==0) day = 7; |
299 | else day = i; | 300 | else day = i; |
300 | } | 301 | } |
301 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 302 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
302 | true ); | 303 | true ); |
303 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 304 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
304 | headings[i]->setText( dayName ); | 305 | headings[i]->setText( dayName ); |
305 | } | 306 | } |
306 | updateDates(); | 307 | updateDates(); |
307 | updateView(); | 308 | updateView(); |
308 | } | 309 | } |
309 | 310 | ||
310 | void KDateNavigator::setShowWeekNums(bool enabled) | 311 | void KDateNavigator::setShowWeekNums(bool enabled) |
311 | { | 312 | { |
312 | m_bShowWeekNums = enabled; | 313 | m_bShowWeekNums = enabled; |
313 | for(int i=0; i<6; i++) { | 314 | for(int i=0; i<6; i++) { |
314 | if(enabled) | 315 | if(enabled) |
315 | weeknos[i]->show(); | 316 | weeknos[i]->show(); |
316 | else | 317 | else |
317 | weeknos[i]->hide(); | 318 | weeknos[i]->hide(); |
318 | } | 319 | } |
319 | resize(size()); | 320 | resize(size()); |
320 | } | 321 | } |
321 | 322 | ||
322 | void KDateNavigator::selectDates(const DateList& dateList) | 323 | void KDateNavigator::selectDates(const DateList& dateList) |
323 | { | 324 | { |
324 | 325 | ||
325 | if (dateList.count() > 0) { | 326 | if (dateList.count() > 0) { |
326 | mNavigatorBar->selectDates( dateList ); | 327 | mNavigatorBar->selectDates( dateList ); |
327 | mSelectedDates = dateList; | 328 | mSelectedDates = dateList; |
328 | 329 | ||
329 | // set our record of the month and year that this datetbl is | 330 | // set our record of the month and year that this datetbl is |
330 | // displaying. | 331 | // displaying. |
331 | m_MthYr = mSelectedDates.first(); | 332 | m_MthYr = mSelectedDates.first(); |
332 | 333 | ||
333 | 334 | ||
334 | // set our record of the first day of the week of the current | 335 | // set our record of the first day of the week of the current |
335 | // month. This needs to be done before calling dayToIndex, since it | 336 | // month. This needs to be done before calling dayToIndex, since it |
336 | // relies on this information being up to date. | 337 | // relies on this information being up to date. |
337 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 338 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
338 | m_fstDayOfWk = dayone.dayOfWeek(); | 339 | m_fstDayOfWk = dayone.dayOfWeek(); |
339 | 340 | ||
340 | updateDates(); | 341 | updateDates(); |
341 | 342 | ||
342 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 343 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
343 | 344 | ||
344 | updateView(); | 345 | updateView(); |
345 | } | 346 | } |
346 | } | 347 | } |
347 | 348 | ||
348 | int KDateNavigator::dayNum(int row, int col) | 349 | int KDateNavigator::dayNum(int row, int col) |
349 | { | 350 | { |
350 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 351 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
351 | } | 352 | } |
352 | 353 | ||
353 | int KDateNavigator::dayToIndex(int dayNum) | 354 | int KDateNavigator::dayToIndex(int dayNum) |
354 | { | 355 | { |
355 | int row, col; | 356 | int row, col; |
356 | 357 | ||
357 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 358 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
358 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 359 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
359 | row++; | 360 | row++; |
360 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 361 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
361 | return row * 7 + col; | 362 | return row * 7 + col; |
362 | } | 363 | } |
363 | 364 | ||
364 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 365 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
365 | { | 366 | { |
366 | if(e->delta()>0) emit goPrevious(); | 367 | if(e->delta()>0) emit goPrevious(); |
367 | else emit goNext(); | 368 | else emit goNext(); |
368 | 369 | ||
369 | e->accept(); | 370 | e->accept(); |
370 | } | 371 | } |
371 | 372 | ||
372 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 373 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
373 | { | 374 | { |
374 | if (e->type() == QEvent::MouseButtonPress) { | 375 | if (e->type() == QEvent::MouseButtonPress) { |
375 | int i; | 376 | int i; |
376 | for(i=0;i<6;++i) { | 377 | for(i=0;i<6;++i) { |
377 | if (o == weeknos[i]) { | 378 | if (o == weeknos[i]) { |
378 | QDate weekstart = daymatrix->getDate(i*7); | 379 | QDate weekstart = daymatrix->getDate(i*7); |
379 | emit weekClicked(weekstart); | 380 | emit weekClicked(weekstart); |
380 | break; | 381 | break; |
381 | } | 382 | } |
382 | } | 383 | } |
383 | return true; | 384 | return true; |
384 | } else { | 385 | } else { |
385 | return false; | 386 | return false; |
386 | } | 387 | } |
387 | } | 388 | } |
388 | 389 | ||
389 | //#include "kdatenavigator.moc" | 390 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 56822fa..292e71c 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -1,151 +1,154 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KDATENAVIGATOR_H | 23 | #ifndef KDATENAVIGATOR_H |
24 | #define KDATENAVIGATOR_H | 24 | #define KDATENAVIGATOR_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | #include "kodaymatrix.h" | 32 | #include "kodaymatrix.h" |
33 | 33 | ||
34 | class QPushButton; | 34 | class QPushButton; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class KCalendarSystem; | 37 | class KCalendarSystem; |
38 | 38 | ||
39 | class NavigatorBar; | 39 | class NavigatorBar; |
40 | 40 | ||
41 | class KDateNavigator: public QFrame | 41 | class KDateNavigator: public QFrame |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); | 45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); |
46 | ~KDateNavigator(); | 46 | ~KDateNavigator(); |
47 | 47 | ||
48 | /** The DateNavigator automatically checks for | 48 | /** The DateNavigator automatically checks for |
49 | * the passage of midnight. If rollover type is | 49 | * the passage of midnight. If rollover type is |
50 | * set to None, no signals are emitted and no | 50 | * set to None, no signals are emitted and no |
51 | * processing is done. With rollover set to | 51 | * processing is done. With rollover set to |
52 | * FollowDay, the day highlighter changes at | 52 | * FollowDay, the day highlighter changes at |
53 | * midnight and dayPassed() is emitted. | 53 | * midnight and dayPassed() is emitted. |
54 | * With FollowMonth, it has the same effect | 54 | * With FollowMonth, it has the same effect |
55 | * as FollowDay but also adjusts the month that is | 55 | * as FollowDay but also adjusts the month that is |
56 | * visible and emits monthPassed() when the month changes. | 56 | * visible and emits monthPassed() when the month changes. |
57 | */ | 57 | */ |
58 | enum RolloverType { None, FollowDay, FollowMonth } ; | 58 | enum RolloverType { None, FollowDay, FollowMonth } ; |
59 | void enableRollover( RolloverType ); | 59 | void enableRollover( RolloverType ); |
60 | 60 | ||
61 | void setShowWeekNums( bool enabled ); | 61 | void setShowWeekNums( bool enabled ); |
62 | void setCalendar( Calendar * ); | 62 | void setCalendar( Calendar * ); |
63 | void setBaseDate( const QDate & ); | 63 | void setBaseDate( const QDate & , bool doRepaint = true ); |
64 | KCal::DateList selectedDates() const { return mSelectedDates; } | 64 | KCal::DateList selectedDates() const { return mSelectedDates; } |
65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } | 65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } |
66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} | 66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} |
67 | QSize yourSizeHint() { return mySizeHint; } | ||
68 | KODayMatrix *dayMatrix() { return daymatrix ;} | ||
67 | public slots: | 69 | public slots: |
68 | void selectDates( const KCal::DateList & ); | 70 | void selectDates( const KCal::DateList & ); |
69 | void updateView(); | 71 | void updateView(); |
70 | void updateConfig(); | 72 | void updateConfig(); |
71 | void updateDayMatrix(); | 73 | void updateDayMatrix(); |
72 | 74 | ||
73 | signals: | 75 | signals: |
74 | void datesSelected( const KCal::DateList & ); | 76 | void datesSelected( const KCal::DateList & ); |
75 | void eventDropped( Event * ); | 77 | void eventDropped( Event * ); |
76 | void weekClicked( const QDate &); | 78 | void weekClicked( const QDate &); |
77 | 79 | ||
78 | void goPrevious(); | 80 | void goPrevious(); |
79 | void goNext(); | 81 | void goNext(); |
80 | 82 | ||
81 | void goNextMonth(); | 83 | void goNextMonth(); |
82 | void goPrevMonth(); | 84 | void goPrevMonth(); |
83 | void goNextYear(); | 85 | void goNextYear(); |
84 | void goPrevYear(); | 86 | void goPrevYear(); |
85 | void monthSelected( int ); | 87 | void monthSelected( int ); |
86 | 88 | ||
87 | // Signals emitted at midnight carrying the new date. | 89 | // Signals emitted at midnight carrying the new date. |
88 | void dayPassed( QDate ); | 90 | void dayPassed( QDate ); |
89 | void monthPassed( QDate ); | 91 | void monthPassed( QDate ); |
90 | 92 | ||
91 | protected slots: | 93 | protected slots: |
92 | 94 | ||
93 | /** | 95 | /** |
94 | * Called regularly to see if we need to update the view | 96 | * Called regularly to see if we need to update the view |
95 | * wrt. the today box and the month box. Only important | 97 | * wrt. the today box and the month box. Only important |
96 | * if you leave KOrganizer idle for long periods of time. | 98 | * if you leave KOrganizer idle for long periods of time. |
97 | * | 99 | * |
98 | * Until we have a reliable way of setting QTimers to go | 100 | * Until we have a reliable way of setting QTimers to go |
99 | * off at a particular wall-clock time, we need this, | 101 | * off at a particular wall-clock time, we need this, |
100 | * which calls passedMidnight() at the right moments. | 102 | * which calls passedMidnight() at the right moments. |
101 | */ | 103 | */ |
102 | void possiblyPastMidnight(); | 104 | void possiblyPastMidnight(); |
103 | 105 | ||
104 | /** handles updating the view when midnight has come by due to idle time. | 106 | /** handles updating the view when midnight has come by due to idle time. |
105 | * | 107 | * |
106 | */ | 108 | */ |
107 | void passedMidnight(); | 109 | void passedMidnight(); |
108 | void slotMonthSelected( int m ); | 110 | void slotMonthSelected( int m ); |
109 | protected: | 111 | protected: |
110 | void updateDates(); | 112 | void updateDates(); |
111 | 113 | ||
112 | void wheelEvent (QWheelEvent *); | 114 | void wheelEvent (QWheelEvent *); |
113 | 115 | ||
114 | bool eventFilter (QObject *,QEvent *); | 116 | bool eventFilter (QObject *,QEvent *); |
115 | 117 | ||
116 | private: | 118 | private: |
119 | QSize mySizeHint; | ||
117 | int mMonthSignalOffset; | 120 | int mMonthSignalOffset; |
118 | NavigatorBar *mNavigatorBar; | 121 | NavigatorBar *mNavigatorBar; |
119 | 122 | ||
120 | QFrame *headingSep; | 123 | QFrame *headingSep; |
121 | QFrame *weeknumSep; | 124 | QFrame *weeknumSep; |
122 | QLabel *headings[7]; | 125 | QLabel *headings[7]; |
123 | QLabel *weeknos[7]; | 126 | QLabel *weeknos[7]; |
124 | KODayMatrix *daymatrix; | 127 | KODayMatrix *daymatrix; |
125 | 128 | ||
126 | KCal::DateList mSelectedDates; | 129 | KCal::DateList mSelectedDates; |
127 | QDate m_MthYr; | 130 | QDate m_MthYr; |
128 | int m_fstDayOfWk; | 131 | int m_fstDayOfWk; |
129 | bool m_bShowWeekNums; | 132 | bool m_bShowWeekNums; |
130 | 133 | ||
131 | int dayNum(int row, int col); | 134 | int dayNum(int row, int col); |
132 | int dayToIndex(int dayNum); | 135 | int dayToIndex(int dayNum); |
133 | 136 | ||
134 | Calendar *mCalendar; | 137 | Calendar *mCalendar; |
135 | KCalendarSystem *mCalendarSystem; | 138 | KCalendarSystem *mCalendarSystem; |
136 | 139 | ||
137 | const QString *curHeaders; | 140 | const QString *curHeaders; |
138 | 141 | ||
139 | /** used to update the day view periodically, in particular every | 142 | /** used to update the day view periodically, in particular every |
140 | * midnight to move the "today" rectangle. | 143 | * midnight to move the "today" rectangle. |
141 | */ | 144 | */ |
142 | QTimer *updateTimer; | 145 | QTimer *updateTimer; |
143 | QDate lastDayChecked; | 146 | QDate lastDayChecked; |
144 | RolloverType updateRollover; | 147 | RolloverType updateRollover; |
145 | 148 | ||
146 | // Disabling copy constructor and assignment operator | 149 | // Disabling copy constructor and assignment operator |
147 | KDateNavigator(const KDateNavigator & ); | 150 | KDateNavigator(const KDateNavigator & ); |
148 | KDateNavigator &operator=(const KDateNavigator &); | 151 | KDateNavigator &operator=(const KDateNavigator &); |
149 | }; | 152 | }; |
150 | 153 | ||
151 | #endif | 154 | #endif |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index a886f4a..17a8546 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,672 +1,672 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | 29 | ||
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | #include <libkcal/vcaldrag.h> | 34 | #include <libkcal/vcaldrag.h> |
35 | #include <libkcal/icaldrag.h> | 35 | #include <libkcal/icaldrag.h> |
36 | #include <libkcal/dndfactory.h> | 36 | #include <libkcal/dndfactory.h> |
37 | #include <libkcal/calendarresources.h> | 37 | #include <libkcal/calendarresources.h> |
38 | #include <libkcal/resourcecalendar.h> | 38 | #include <libkcal/resourcecalendar.h> |
39 | #include <kresources/resourceselectdialog.h> | 39 | #include <kresources/resourceselectdialog.h> |
40 | 40 | ||
41 | #include <kcalendarsystem.h> | 41 | #include <kcalendarsystem.h> |
42 | 42 | ||
43 | #ifndef KORG_NOPLUGINS | 43 | #ifndef KORG_NOPLUGINS |
44 | #include "kocore.h" | 44 | #include "kocore.h" |
45 | #endif | 45 | #endif |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "koglobals.h" | 47 | #include "koglobals.h" |
48 | 48 | ||
49 | #include "kodaymatrix.h" | 49 | #include "kodaymatrix.h" |
50 | 50 | ||
51 | // ============================================================================ | 51 | // ============================================================================ |
52 | // D Y N A M I C T I P | 52 | // D Y N A M I C T I P |
53 | // ============================================================================ | 53 | // ============================================================================ |
54 | 54 | ||
55 | DynamicTip::DynamicTip( QWidget * parent ) | 55 | DynamicTip::DynamicTip( QWidget * parent ) |
56 | : QToolTip( parent ) | 56 | : QToolTip( parent ) |
57 | { | 57 | { |
58 | matrix = (KODayMatrix*)parent; | 58 | matrix = (KODayMatrix*)parent; |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | void DynamicTip::maybeTip( const QPoint &pos ) | 62 | void DynamicTip::maybeTip( const QPoint &pos ) |
63 | { | 63 | { |
64 | //calculate which cell of the matrix the mouse is in | 64 | //calculate which cell of the matrix the mouse is in |
65 | QRect sz = matrix->frameRect(); | 65 | QRect sz = matrix->frameRect(); |
66 | int dheight = sz.height()*7 / 42; | 66 | int dheight = sz.height()*7 / 42; |
67 | int dwidth = sz.width() / 7; | 67 | int dwidth = sz.width() / 7; |
68 | int row = pos.y()/dheight; | 68 | int row = pos.y()/dheight; |
69 | int col = pos.x()/dwidth; | 69 | int col = pos.x()/dwidth; |
70 | 70 | ||
71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 71 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
72 | 72 | ||
73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 73 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
74 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 74 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
75 | 75 | ||
76 | //show holiday names only | 76 | //show holiday names only |
77 | QString str = matrix->getHolidayLabel(col+row*7); | 77 | QString str = matrix->getHolidayLabel(col+row*7); |
78 | if (str.isEmpty()) return; | 78 | if (str.isEmpty()) return; |
79 | tip(rct, str); | 79 | tip(rct, str); |
80 | } | 80 | } |
81 | 81 | ||
82 | 82 | ||
83 | // ============================================================================ | 83 | // ============================================================================ |
84 | // K O D A Y M A T R I X | 84 | // K O D A Y M A T R I X |
85 | // ============================================================================ | 85 | // ============================================================================ |
86 | 86 | ||
87 | const int KODayMatrix::NOSELECTION = -1000; | 87 | const int KODayMatrix::NOSELECTION = -1000; |
88 | const int KODayMatrix::NUMDAYS = 42; | 88 | const int KODayMatrix::NUMDAYS = 42; |
89 | 89 | ||
90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 90 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
91 | : QFrame( parent, name ), mCalendar( 0 ) | 91 | : QFrame( parent, name ), mCalendar( 0 ) |
92 | 92 | ||
93 | #if 0 | 93 | #if 0 |
94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 94 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
95 | QFrame(parent, name) | 95 | QFrame(parent, name) |
96 | #endif | 96 | #endif |
97 | { | 97 | { |
98 | 98 | ||
99 | mPendingUpdateBeforeRepaint = false; | 99 | mPendingUpdateBeforeRepaint = false; |
100 | 100 | ||
101 | // initialize dynamic arrays | 101 | // initialize dynamic arrays |
102 | days = new QDate[NUMDAYS]; | 102 | days = new QDate[NUMDAYS]; |
103 | daylbls = new QString[NUMDAYS]; | 103 | daylbls = new QString[NUMDAYS]; |
104 | events = new int[NUMDAYS]; | 104 | events = new int[NUMDAYS]; |
105 | mToolTip = new DynamicTip(this); | 105 | mToolTip = new DynamicTip(this); |
106 | 106 | ||
107 | // set default values used for drawing the matrix | 107 | // set default values used for drawing the matrix |
108 | mDefaultBackColor = palette().active().base(); | 108 | mDefaultBackColor = palette().active().base(); |
109 | mDefaultTextColor = palette().active().foreground(); | 109 | mDefaultTextColor = palette().active().foreground(); |
110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 110 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 111 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
112 | mSelectedDaysColor = QColor("white"); | 112 | mSelectedDaysColor = QColor("white"); |
113 | mTodayMarginWidth = 2; | 113 | mTodayMarginWidth = 2; |
114 | mSelEnd = mSelStart = NOSELECTION; | 114 | mSelEnd = mSelStart = NOSELECTION; |
115 | 115 | ||
116 | setAcceptDrops(true); | 116 | setAcceptDrops(true); |
117 | //setFont( QFont("Arial", 10) ); | 117 | //setFont( QFont("Arial", 10) ); |
118 | 118 | ||
119 | mUpdateTimer = new QTimer( this ); | 119 | mUpdateTimer = new QTimer( this ); |
120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 120 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
121 | mRepaintTimer = new QTimer( this ); | 121 | mRepaintTimer = new QTimer( this ); |
122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 122 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
123 | mDayChanged = false; | 123 | mDayChanged = false; |
124 | updateView(); | 124 | updateView(); |
125 | } | 125 | } |
126 | void KODayMatrix::setCalendar( Calendar *cal ) | 126 | void KODayMatrix::setCalendar( Calendar *cal ) |
127 | { | 127 | { |
128 | mCalendar = cal; | 128 | mCalendar = cal; |
129 | 129 | ||
130 | setAcceptDrops( mCalendar ); | 130 | setAcceptDrops( mCalendar ); |
131 | 131 | ||
132 | updateEvents(); | 132 | updateEvents(); |
133 | } | 133 | } |
134 | 134 | ||
135 | QColor KODayMatrix::getShadedColor(QColor color) | 135 | QColor KODayMatrix::getShadedColor(QColor color) |
136 | { | 136 | { |
137 | QColor shaded; | 137 | QColor shaded; |
138 | int h=0; | 138 | int h=0; |
139 | int s=0; | 139 | int s=0; |
140 | int v=0; | 140 | int v=0; |
141 | color.hsv(&h,&s,&v); | 141 | color.hsv(&h,&s,&v); |
142 | s = s/4; | 142 | s = s/4; |
143 | v = 192+v/4; | 143 | v = 192+v/4; |
144 | shaded.setHsv(h,s,v); | 144 | shaded.setHsv(h,s,v); |
145 | 145 | ||
146 | return shaded; | 146 | return shaded; |
147 | } | 147 | } |
148 | 148 | ||
149 | KODayMatrix::~KODayMatrix() | 149 | KODayMatrix::~KODayMatrix() |
150 | { | 150 | { |
151 | delete [] days; | 151 | delete [] days; |
152 | delete [] daylbls; | 152 | delete [] daylbls; |
153 | delete [] events; | 153 | delete [] events; |
154 | delete mToolTip; | 154 | delete mToolTip; |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | void KODayMatrix::setStartDate(QDate start) | 158 | void KODayMatrix::setStartDate(QDate start) |
159 | { | 159 | { |
160 | updateView(start); | 160 | updateView(start); |
161 | } | 161 | } |
162 | */ | 162 | */ |
163 | 163 | ||
164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 164 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
165 | { | 165 | { |
166 | 166 | ||
167 | if (mSelStart == NOSELECTION) { | 167 | if (mSelStart == NOSELECTION) { |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | 170 | ||
171 | //cope with selection being out of matrix limits at top (< 0) | 171 | //cope with selection being out of matrix limits at top (< 0) |
172 | int i0 = mSelStart; | 172 | int i0 = mSelStart; |
173 | if (i0 < 0) { | 173 | if (i0 < 0) { |
174 | for (int i = i0; i < 0; i++) { | 174 | for (int i = i0; i < 0; i++) { |
175 | selDays.append(days[0].addDays(i)); | 175 | selDays.append(days[0].addDays(i)); |
176 | } | 176 | } |
177 | i0 = 0; | 177 | i0 = 0; |
178 | } | 178 | } |
179 | 179 | ||
180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 180 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
181 | if (mSelEnd > NUMDAYS-1) { | 181 | if (mSelEnd > NUMDAYS-1) { |
182 | for (int i = i0; i <= NUMDAYS-1; i++) { | 182 | for (int i = i0; i <= NUMDAYS-1; i++) { |
183 | selDays.append(days[i]); | 183 | selDays.append(days[i]); |
184 | } | 184 | } |
185 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 185 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
186 | selDays.append(days[0].addDays(i)); | 186 | selDays.append(days[0].addDays(i)); |
187 | } | 187 | } |
188 | 188 | ||
189 | // apply normal routine to selection being entirely within matrix limits | 189 | // apply normal routine to selection being entirely within matrix limits |
190 | } else { | 190 | } else { |
191 | for (int i = i0; i <= mSelEnd; i++) { | 191 | for (int i = i0; i <= mSelEnd; i++) { |
192 | selDays.append(days[i]); | 192 | selDays.append(days[i]); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 197 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
198 | { | 198 | { |
199 | mSelStart = startdate.daysTo(start); | 199 | mSelStart = startdate.daysTo(start); |
200 | mSelEnd = startdate.daysTo(end); | 200 | mSelEnd = startdate.daysTo(end); |
201 | } | 201 | } |
202 | void KODayMatrix::clearSelection() | 202 | void KODayMatrix::clearSelection() |
203 | { | 203 | { |
204 | mSelEnd = mSelStart = NOSELECTION; | 204 | mSelEnd = mSelStart = NOSELECTION; |
205 | } | 205 | } |
206 | 206 | ||
207 | 207 | ||
208 | void KODayMatrix::recalculateToday() | 208 | void KODayMatrix::recalculateToday() |
209 | { | 209 | { |
210 | today = -1; | 210 | today = -1; |
211 | for (int i=0; i<NUMDAYS; i++) { | 211 | for (int i=0; i<NUMDAYS; i++) { |
212 | events[i] = 0; | 212 | events[i] = 0; |
213 | days[i] = startdate.addDays(i); | 213 | days[i] = startdate.addDays(i); |
214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 214 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
215 | 215 | ||
216 | // if today is in the currently displayed month, hilight today | 216 | // if today is in the currently displayed month, hilight today |
217 | if (days[i].year() == QDate::currentDate().year() && | 217 | if (days[i].year() == QDate::currentDate().year() && |
218 | days[i].month() == QDate::currentDate().month() && | 218 | days[i].month() == QDate::currentDate().month() && |
219 | days[i].day() == QDate::currentDate().day()) { | 219 | days[i].day() == QDate::currentDate().day()) { |
220 | today = i; | 220 | today = i; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | // qDebug(QString("Today is visible at %1.").arg(today)); | 223 | // qDebug(QString("Today is visible at %1.").arg(today)); |
224 | } | 224 | } |
225 | 225 | ||
226 | void KODayMatrix::updateView() | 226 | void KODayMatrix::updateView() |
227 | { | 227 | { |
228 | updateView(startdate); | 228 | updateView(startdate); |
229 | } | 229 | } |
230 | void KODayMatrix::repaintViewTimed() | 230 | void KODayMatrix::repaintViewTimed() |
231 | { | 231 | { |
232 | mRepaintTimer->stop(); | 232 | mRepaintTimer->stop(); |
233 | repaint(false); | 233 | repaint(false); |
234 | } | 234 | } |
235 | void KODayMatrix::updateViewTimed() | 235 | void KODayMatrix::updateViewTimed() |
236 | { | 236 | { |
237 | mUpdateTimer->stop(); | 237 | mUpdateTimer->stop(); |
238 | if ( !mCalendar ) { | 238 | if ( !mCalendar ) { |
239 | qDebug("NOT CAL "); | 239 | qDebug("NOT CAL "); |
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | //qDebug("KODayMatrix::updateViewTimed "); | 242 | //qDebug("KODayMatrix::updateViewTimed "); |
243 | for(int i = 0; i < NUMDAYS; i++) { | 243 | for(int i = 0; i < NUMDAYS; i++) { |
244 | // if events are set for the day then remember to draw it bold | 244 | // if events are set for the day then remember to draw it bold |
245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 245 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
246 | Event *event; | 246 | Event *event; |
247 | int numEvents = eventlist.count(); | 247 | int numEvents = eventlist.count(); |
248 | QString holiStr = ""; | 248 | QString holiStr = ""; |
249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 249 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
250 | ushort recurType = event->recurrence()->doesRecur(); | 250 | ushort recurType = event->recurrence()->doesRecur(); |
251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 251 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 252 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
253 | numEvents--; | 253 | numEvents--; |
254 | } | 254 | } |
255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 255 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
256 | if ( !holiStr.isEmpty() ) | 256 | if ( !holiStr.isEmpty() ) |
257 | holiStr += "\n"; | 257 | holiStr += "\n"; |
258 | holiStr += event->summary(); | 258 | holiStr += event->summary(); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | events[i] = numEvents; | 261 | events[i] = numEvents; |
262 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 262 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 263 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
264 | !holiStr.isEmpty()) { | 264 | !holiStr.isEmpty()) { |
265 | mHolidays[i] = holiStr; | 265 | mHolidays[i] = holiStr; |
266 | } else { | 266 | } else { |
267 | mHolidays[i] = QString::null; | 267 | mHolidays[i] = QString::null; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | if ( ! mPendingUpdateBeforeRepaint ) | 270 | if ( ! mPendingUpdateBeforeRepaint ) |
271 | repaint(false); | 271 | repaint(false); |
272 | } | 272 | } |
273 | void KODayMatrix::updateView(QDate actdate) | 273 | void KODayMatrix::updateView(QDate actdate) |
274 | { | 274 | { |
275 | 275 | ||
276 | if ( ! actdate.isValid() ) { | 276 | if ( ! actdate.isValid() ) { |
277 | //qDebug("date not valid "); | 277 | //qDebug("date not valid "); |
278 | return; | 278 | return; |
279 | } | 279 | } |
280 | mDayChanged = false; | 280 | mDayChanged = false; |
281 | //flag to indicate if the starting day of the matrix has changed by this call | 281 | //flag to indicate if the starting day of the matrix has changed by this call |
282 | //mDayChanged = false; | 282 | //mDayChanged = false; |
283 | // if a new startdate is to be set then apply Cornelius's calculation | 283 | // if a new startdate is to be set then apply Cornelius's calculation |
284 | // of the first day to be shown | 284 | // of the first day to be shown |
285 | if (actdate != startdate) { | 285 | if (actdate != startdate) { |
286 | // reset index of selection according to shift of starting date from startdate to actdate | 286 | // reset index of selection according to shift of starting date from startdate to actdate |
287 | if (mSelStart != NOSELECTION) { | 287 | if (mSelStart != NOSELECTION) { |
288 | int tmp = actdate.daysTo(startdate); | 288 | int tmp = actdate.daysTo(startdate); |
289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 289 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
290 | // shift selection if new one would be visible at least partly ! | 290 | // shift selection if new one would be visible at least partly ! |
291 | 291 | ||
292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 292 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
293 | // nested if is required for next X display pushed from a different month - correction required | 293 | // nested if is required for next X display pushed from a different month - correction required |
294 | // otherwise, for month forward and backward, it must be avoided | 294 | // otherwise, for month forward and backward, it must be avoided |
295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 295 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
296 | mSelStart = mSelStart + tmp; | 296 | mSelStart = mSelStart + tmp; |
297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 297 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
298 | mSelEnd = mSelEnd + tmp; | 298 | mSelEnd = mSelEnd + tmp; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | startdate = actdate; | 301 | startdate = actdate; |
302 | mDayChanged = true; | 302 | mDayChanged = true; |
303 | recalculateToday(); | 303 | recalculateToday(); |
304 | } | 304 | } |
305 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 305 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
306 | if ( !isVisible() ) { | 306 | if ( !isVisible() ) { |
307 | mPendingUpdateBeforeRepaint = true; | 307 | mPendingUpdateBeforeRepaint = true; |
308 | } else { | 308 | } else { |
309 | #ifdef DESKTOP_VERSION | 309 | #ifdef DESKTOP_VERSION |
310 | //mRepaintTimer->start( 250 ); | 310 | //mRepaintTimer->start( 250 ); |
311 | mUpdateTimer->start( 250 ); | 311 | mUpdateTimer->start( 250 ); |
312 | #else | 312 | #else |
313 | mRepaintTimer->start( 350 ); | 313 | mRepaintTimer->start( 350 ); |
314 | mUpdateTimer->start( 2000 ); | 314 | mUpdateTimer->start( 2000 ); |
315 | #endif | 315 | #endif |
316 | } | 316 | } |
317 | } | 317 | } |
318 | void KODayMatrix::updateEvents() | 318 | void KODayMatrix::updateEvents() |
319 | { | 319 | { |
320 | if ( !mCalendar ) return; | 320 | if ( !mCalendar ) return; |
321 | 321 | ||
322 | for( int i = 0; i < NUMDAYS; i++ ) { | 322 | for( int i = 0; i < NUMDAYS; i++ ) { |
323 | // if events are set for the day then remember to draw it bold | 323 | // if events are set for the day then remember to draw it bold |
324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 324 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
325 | int numEvents = eventlist.count(); | 325 | int numEvents = eventlist.count(); |
326 | Event *event; | 326 | Event *event; |
327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 327 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
328 | ushort recurType = event->doesRecur(); | 328 | ushort recurType = event->doesRecur(); |
329 | 329 | ||
330 | if ( ( recurType == Recurrence::rDaily && | 330 | if ( ( recurType == Recurrence::rDaily && |
331 | !KOPrefs::instance()->mDailyRecur ) || | 331 | !KOPrefs::instance()->mDailyRecur ) || |
332 | ( recurType == Recurrence::rWeekly && | 332 | ( recurType == Recurrence::rWeekly && |
333 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 333 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
334 | numEvents--; | 334 | numEvents--; |
335 | } | 335 | } |
336 | } | 336 | } |
337 | events[ i ] = numEvents; | 337 | events[ i ] = numEvents; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | 340 | ||
341 | const QDate& KODayMatrix::getDate(int offset) | 341 | const QDate& KODayMatrix::getDate(int offset) |
342 | { | 342 | { |
343 | if (offset < 0 || offset > NUMDAYS-1) { | 343 | if (offset < 0 || offset > NUMDAYS-1) { |
344 | qDebug("Wrong offset2 "); | 344 | qDebug("Wrong offset2 "); |
345 | return days[0]; | 345 | return days[0]; |
346 | } | 346 | } |
347 | return days[offset]; | 347 | return days[offset]; |
348 | } | 348 | } |
349 | 349 | ||
350 | QString KODayMatrix::getHolidayLabel(int offset) | 350 | QString KODayMatrix::getHolidayLabel(int offset) |
351 | { | 351 | { |
352 | if (offset < 0 || offset > NUMDAYS-1) { | 352 | if (offset < 0 || offset > NUMDAYS-1) { |
353 | qDebug("Wrong offset1 "); | 353 | qDebug("Wrong offset1 "); |
354 | return 0; | 354 | return 0; |
355 | } | 355 | } |
356 | return mHolidays[offset]; | 356 | return mHolidays[offset]; |
357 | } | 357 | } |
358 | 358 | ||
359 | int KODayMatrix::getDayIndexFrom(int x, int y) | 359 | int KODayMatrix::getDayIndexFrom(int x, int y) |
360 | { | 360 | { |
361 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 361 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
362 | 6 - x/daysize.width() : x/daysize.width()); | 362 | 6 - x/daysize.width() : x/daysize.width()); |
363 | } | 363 | } |
364 | 364 | ||
365 | // ---------------------------------------------------------------------------- | 365 | // ---------------------------------------------------------------------------- |
366 | // M O U S E E V E N T H A N D L I N G | 366 | // M O U S E E V E N T H A N D L I N G |
367 | // ---------------------------------------------------------------------------- | 367 | // ---------------------------------------------------------------------------- |
368 | 368 | ||
369 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 369 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
370 | { | 370 | { |
371 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 371 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
372 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 372 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
373 | mSelInit = mSelStart; | 373 | mSelInit = mSelStart; |
374 | } | 374 | } |
375 | 375 | ||
376 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 376 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
377 | { | 377 | { |
378 | 378 | ||
379 | int tmp = getDayIndexFrom(e->x(), e->y()); | 379 | int tmp = getDayIndexFrom(e->x(), e->y()); |
380 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 380 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
381 | 381 | ||
382 | if (mSelInit > tmp) { | 382 | if (mSelInit > tmp) { |
383 | mSelEnd = mSelInit; | 383 | mSelEnd = mSelInit; |
384 | if (tmp != mSelStart) { | 384 | if (tmp != mSelStart) { |
385 | mSelStart = tmp; | 385 | mSelStart = tmp; |
386 | repaint(false); | 386 | repaint(false); |
387 | } | 387 | } |
388 | } else { | 388 | } else { |
389 | mSelStart = mSelInit; | 389 | mSelStart = mSelInit; |
390 | 390 | ||
391 | //repaint only if selection has changed | 391 | //repaint only if selection has changed |
392 | if (tmp != mSelEnd) { | 392 | if (tmp != mSelEnd) { |
393 | mSelEnd = tmp; | 393 | mSelEnd = tmp; |
394 | repaint(false); | 394 | repaint(false); |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | DateList daylist; | 398 | DateList daylist; |
399 | if ( mSelStart < 0 ) | 399 | if ( mSelStart < 0 ) |
400 | mSelStart = 0; | 400 | mSelStart = 0; |
401 | for (int i = mSelStart; i <= mSelEnd; i++) { | 401 | for (int i = mSelStart; i <= mSelEnd; i++) { |
402 | daylist.append(days[i]); | 402 | daylist.append(days[i]); |
403 | } | 403 | } |
404 | emit selected((const DateList)daylist); | 404 | emit selected((const DateList)daylist); |
405 | 405 | ||
406 | } | 406 | } |
407 | 407 | ||
408 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 408 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
409 | { | 409 | { |
410 | int tmp = getDayIndexFrom(e->x(), e->y()); | 410 | int tmp = getDayIndexFrom(e->x(), e->y()); |
411 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 411 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
412 | 412 | ||
413 | if (mSelInit > tmp) { | 413 | if (mSelInit > tmp) { |
414 | mSelEnd = mSelInit; | 414 | mSelEnd = mSelInit; |
415 | if (tmp != mSelStart) { | 415 | if (tmp != mSelStart) { |
416 | mSelStart = tmp; | 416 | mSelStart = tmp; |
417 | repaint(false); | 417 | repaint(false); |
418 | } | 418 | } |
419 | } else { | 419 | } else { |
420 | mSelStart = mSelInit; | 420 | mSelStart = mSelInit; |
421 | 421 | ||
422 | //repaint only if selection has changed | 422 | //repaint only if selection has changed |
423 | if (tmp != mSelEnd) { | 423 | if (tmp != mSelEnd) { |
424 | mSelEnd = tmp; | 424 | mSelEnd = tmp; |
425 | repaint(false); | 425 | repaint(false); |
426 | } | 426 | } |
427 | } | 427 | } |
428 | } | 428 | } |
429 | 429 | ||
430 | // ---------------------------------------------------------------------------- | 430 | // ---------------------------------------------------------------------------- |
431 | // D R A G ' N D R O P H A N D L I N G | 431 | // D R A G ' N D R O P H A N D L I N G |
432 | // ---------------------------------------------------------------------------- | 432 | // ---------------------------------------------------------------------------- |
433 | 433 | ||
434 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 434 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
435 | { | 435 | { |
436 | #ifndef KORG_NODND | 436 | #ifndef KORG_NODND |
437 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 437 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
438 | e->ignore(); | 438 | e->ignore(); |
439 | return; | 439 | return; |
440 | } | 440 | } |
441 | 441 | ||
442 | // some visual feedback | 442 | // some visual feedback |
443 | // oldPalette = palette(); | 443 | // oldPalette = palette(); |
444 | // setPalette(my_HilitePalette); | 444 | // setPalette(my_HilitePalette); |
445 | // update(); | 445 | // update(); |
446 | #endif | 446 | #endif |
447 | } | 447 | } |
448 | 448 | ||
449 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 449 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
450 | { | 450 | { |
451 | #ifndef KORG_NODND | 451 | #ifndef KORG_NODND |
452 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 452 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
453 | e->ignore(); | 453 | e->ignore(); |
454 | return; | 454 | return; |
455 | } | 455 | } |
456 | 456 | ||
457 | e->accept(); | 457 | e->accept(); |
458 | #endif | 458 | #endif |
459 | } | 459 | } |
460 | 460 | ||
461 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 461 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
462 | { | 462 | { |
463 | #ifndef KORG_NODND | 463 | #ifndef KORG_NODND |
464 | // setPalette(oldPalette); | 464 | // setPalette(oldPalette); |
465 | // update(); | 465 | // update(); |
466 | #endif | 466 | #endif |
467 | } | 467 | } |
468 | 468 | ||
469 | void KODayMatrix::dropEvent(QDropEvent *e) | 469 | void KODayMatrix::dropEvent(QDropEvent *e) |
470 | { | 470 | { |
471 | #ifndef KORG_NODND | 471 | #ifndef KORG_NODND |
472 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 472 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
473 | 473 | ||
474 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 474 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
475 | e->ignore(); | 475 | e->ignore(); |
476 | return; | 476 | return; |
477 | } | 477 | } |
478 | 478 | ||
479 | DndFactory factory( mCalendar ); | 479 | DndFactory factory( mCalendar ); |
480 | Event *event = factory.createDrop(e); | 480 | Event *event = factory.createDrop(e); |
481 | 481 | ||
482 | if (event) { | 482 | if (event) { |
483 | e->acceptAction(); | 483 | e->acceptAction(); |
484 | 484 | ||
485 | Event *existingEvent = mCalendar->event(event->uid()); | 485 | Event *existingEvent = mCalendar->event(event->uid()); |
486 | 486 | ||
487 | if(existingEvent) { | 487 | if(existingEvent) { |
488 | // uniquify event | 488 | // uniquify event |
489 | event->recreate(); | 489 | event->recreate(); |
490 | /* | 490 | /* |
491 | KMessageBox::sorry(this, | 491 | KMessageBox::sorry(this, |
492 | i18n("Event already exists in this calendar."), | 492 | i18n("Event already exists in this calendar."), |
493 | i18n("Drop Event")); | 493 | i18n("Drop Event")); |
494 | delete event; | 494 | delete event; |
495 | return; | 495 | return; |
496 | */ | 496 | */ |
497 | } | 497 | } |
498 | // kdDebug() << "Drop new Event" << endl; | 498 | // kdDebug() << "Drop new Event" << endl; |
499 | // Adjust date | 499 | // Adjust date |
500 | QDateTime start = event->dtStart(); | 500 | QDateTime start = event->dtStart(); |
501 | QDateTime end = event->dtEnd(); | 501 | QDateTime end = event->dtEnd(); |
502 | int duration = start.daysTo(end); | 502 | int duration = start.daysTo(end); |
503 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 503 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
504 | 504 | ||
505 | start.setDate(days[idx]); | 505 | start.setDate(days[idx]); |
506 | end.setDate(days[idx].addDays(duration)); | 506 | end.setDate(days[idx].addDays(duration)); |
507 | 507 | ||
508 | event->setDtStart(start); | 508 | event->setDtStart(start); |
509 | event->setDtEnd(end); | 509 | event->setDtEnd(end); |
510 | mCalendar->addEvent(event); | 510 | mCalendar->addEvent(event); |
511 | 511 | ||
512 | emit eventDropped(event); | 512 | emit eventDropped(event); |
513 | } else { | 513 | } else { |
514 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 514 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
515 | e->ignore(); | 515 | e->ignore(); |
516 | } | 516 | } |
517 | #endif | 517 | #endif |
518 | } | 518 | } |
519 | 519 | ||
520 | // ---------------------------------------------------------------------------- | 520 | // ---------------------------------------------------------------------------- |
521 | // P A I N T E V E N T H A N D L I N G | 521 | // P A I N T E V E N T H A N D L I N G |
522 | // ---------------------------------------------------------------------------- | 522 | // ---------------------------------------------------------------------------- |
523 | 523 | ||
524 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 524 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
525 | { | 525 | { |
526 | if ( width() <= 0 || height() <= 0 ) | 526 | if ( width() <= 0 || height() <= 0 ) |
527 | return; | 527 | return; |
528 | if ( mPendingUpdateBeforeRepaint ) { | 528 | if ( mPendingUpdateBeforeRepaint ) { |
529 | updateViewTimed(); | 529 | updateViewTimed(); |
530 | mPendingUpdateBeforeRepaint = false; | 530 | mPendingUpdateBeforeRepaint = false; |
531 | } | 531 | } |
532 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 532 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
533 | myPix.resize(size() ); | 533 | myPix.resize(size() ); |
534 | } | 534 | } |
535 | QPainter p(&myPix); | 535 | QPainter p(&myPix); |
536 | p.setFont(font()); | 536 | p.setFont(font()); |
537 | 537 | ||
538 | QRect sz = frameRect(); | 538 | QRect sz = frameRect(); |
539 | int dheight = daysize.height(); | 539 | int dheight = daysize.height(); |
540 | int dwidth = daysize.width(); | 540 | int dwidth = daysize.width(); |
541 | int row,col; | 541 | int row,col; |
542 | int selw, selh; | 542 | int selw, selh; |
543 | bool isRTL = KOGlobals::self()->reverseLayout(); | 543 | bool isRTL = KOGlobals::self()->reverseLayout(); |
544 | 544 | ||
545 | // draw background and topleft frame | 545 | // draw background and topleft frame |
546 | p.fillRect(pevent->rect(), mDefaultBackColor); | 546 | p.fillRect(pevent->rect(), mDefaultBackColor); |
547 | p.setPen(mDefaultTextColor); | 547 | p.setPen(mDefaultTextColor); |
548 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 548 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
549 | 549 | ||
550 | // draw selected days with highlighted background color | 550 | // draw selected days with highlighted background color |
551 | if (mSelStart != NOSELECTION) { | 551 | if (mSelStart != NOSELECTION) { |
552 | 552 | ||
553 | row = mSelStart/7; | 553 | row = mSelStart/7; |
554 | col = mSelStart -row*7; | 554 | col = mSelStart -row*7; |
555 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 555 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
556 | 556 | ||
557 | if (row == mSelEnd/7) { | 557 | if (row == mSelEnd/7) { |
558 | // Single row selection | 558 | // Single row selection |
559 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, | 559 | p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, |
560 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); | 560 | row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); |
561 | } else { | 561 | } else { |
562 | // draw first row to the right | 562 | // draw first row to the right |
563 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 563 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
564 | dheight, selcol); | 564 | dheight, selcol); |
565 | // draw full block till last line | 565 | // draw full block till last line |
566 | selh = mSelEnd/7-row; | 566 | selh = mSelEnd/7-row; |
567 | if (selh > 1) { | 567 | if (selh > 1) { |
568 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 568 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
569 | } | 569 | } |
570 | // draw last block from left to mSelEnd | 570 | // draw last block from left to mSelEnd |
571 | selw = mSelEnd-7*(mSelEnd/7)+1; | 571 | selw = mSelEnd-7*(mSelEnd/7)+1; |
572 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 572 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
573 | selw*dwidth, dheight, selcol); | 573 | selw*dwidth, dheight, selcol); |
574 | } | 574 | } |
575 | } | 575 | } |
576 | 576 | ||
577 | // iterate over all days in the matrix and draw the day label in appropriate colors | 577 | // iterate over all days in the matrix and draw the day label in appropriate colors |
578 | QColor actcol = mDefaultTextColorShaded; | 578 | QColor actcol = mDefaultTextColorShaded; |
579 | p.setPen(actcol); | 579 | p.setPen(actcol); |
580 | QPen tmppen; | 580 | QPen tmppen; |
581 | for(int i = 0; i < NUMDAYS; i++) { | 581 | for(int i = 0; i < NUMDAYS; i++) { |
582 | row = i/7; | 582 | row = i/7; |
583 | col = isRTL ? 6-(i-row*7) : i-row*7; | 583 | col = isRTL ? 6-(i-row*7) : i-row*7; |
584 | 584 | ||
585 | // if it is the first day of a month switch color from normal to shaded and vice versa | 585 | // if it is the first day of a month switch color from normal to shaded and vice versa |
586 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 586 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
587 | if (actcol == mDefaultTextColorShaded) { | 587 | if (actcol == mDefaultTextColorShaded) { |
588 | actcol = mDefaultTextColor; | 588 | actcol = mDefaultTextColor; |
589 | } else { | 589 | } else { |
590 | actcol = mDefaultTextColorShaded; | 590 | actcol = mDefaultTextColorShaded; |
591 | } | 591 | } |
592 | p.setPen(actcol); | 592 | p.setPen(actcol); |
593 | } | 593 | } |
594 | 594 | ||
595 | //Reset pen color after selected days block | 595 | //Reset pen color after selected days block |
596 | if (i == mSelEnd+1) { | 596 | if (i == mSelEnd+1) { |
597 | p.setPen(actcol); | 597 | p.setPen(actcol); |
598 | } | 598 | } |
599 | 599 | ||
600 | // if today then draw rectangle around day | 600 | // if today then draw rectangle around day |
601 | if (today == i) { | 601 | if (today == i) { |
602 | tmppen = p.pen(); | 602 | tmppen = p.pen(); |
603 | QPen mTodayPen(p.pen()); | 603 | QPen mTodayPen(p.pen()); |
604 | 604 | ||
605 | mTodayPen.setWidth(mTodayMarginWidth); | 605 | mTodayPen.setWidth(mTodayMarginWidth); |
606 | //draw red rectangle for holidays | 606 | //draw red rectangle for holidays |
607 | if (!mHolidays[i].isNull()) { | 607 | if (!mHolidays[i].isNull()) { |
608 | if (actcol == mDefaultTextColor) { | 608 | if (actcol == mDefaultTextColor) { |
609 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 609 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
610 | } else { | 610 | } else { |
611 | mTodayPen.setColor(mHolidayColorShaded); | 611 | mTodayPen.setColor(mHolidayColorShaded); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | //draw gray rectangle for today if in selection | 614 | //draw gray rectangle for today if in selection |
615 | if (i >= mSelStart && i <= mSelEnd) { | 615 | if (i >= mSelStart && i <= mSelEnd) { |
616 | QColor grey("grey"); | 616 | QColor grey("grey"); |
617 | mTodayPen.setColor(grey); | 617 | mTodayPen.setColor(grey); |
618 | } | 618 | } |
619 | p.setPen(mTodayPen); | 619 | p.setPen(mTodayPen); |
620 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 620 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
621 | p.setPen(tmppen); | 621 | p.setPen(tmppen); |
622 | } | 622 | } |
623 | 623 | ||
624 | // if any events are on that day then draw it using a bold font | 624 | // if any events are on that day then draw it using a bold font |
625 | if (events[i] > 0) { | 625 | if (events[i] > 0) { |
626 | QFont myFont = font(); | 626 | QFont myFont = font(); |
627 | myFont.setBold(true); | 627 | myFont.setBold(true); |
628 | p.setFont(myFont); | 628 | p.setFont(myFont); |
629 | } | 629 | } |
630 | 630 | ||
631 | // if it is a holiday then use the default holiday color | 631 | // if it is a holiday then use the default holiday color |
632 | if (!mHolidays[i].isNull()) { | 632 | if (!mHolidays[i].isNull()) { |
633 | if (actcol == mDefaultTextColor) { | 633 | if (actcol == mDefaultTextColor) { |
634 | p.setPen(KOPrefs::instance()->mHolidayColor); | 634 | p.setPen(KOPrefs::instance()->mHolidayColor); |
635 | } else { | 635 | } else { |
636 | p.setPen(mHolidayColorShaded); | 636 | p.setPen(mHolidayColorShaded); |
637 | } | 637 | } |
638 | } | 638 | } |
639 | 639 | ||
640 | // draw selected days with special color | 640 | // draw selected days with special color |
641 | // DO NOT specially highlight holidays in selection ! | 641 | // DO NOT specially highlight holidays in selection ! |
642 | if (i >= mSelStart && i <= mSelEnd) { | 642 | if (i >= mSelStart && i <= mSelEnd) { |
643 | p.setPen(mSelectedDaysColor); | 643 | p.setPen(mSelectedDaysColor); |
644 | } | 644 | } |
645 | 645 | ||
646 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 646 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
647 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 647 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
648 | 648 | ||
649 | // reset color to actual color | 649 | // reset color to actual color |
650 | if (!mHolidays[i].isNull()) { | 650 | if (!mHolidays[i].isNull()) { |
651 | p.setPen(actcol); | 651 | p.setPen(actcol); |
652 | } | 652 | } |
653 | // reset bold font to plain font | 653 | // reset bold font to plain font |
654 | if (events[i] > 0) { | 654 | if (events[i] > 0) { |
655 | QFont myFont = font(); | 655 | QFont myFont = font(); |
656 | myFont.setBold(false); | 656 | myFont.setBold(false); |
657 | p.setFont(myFont); | 657 | p.setFont(myFont); |
658 | } | 658 | } |
659 | } | 659 | } |
660 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 660 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
661 | } | 661 | } |
662 | 662 | ||
663 | // ---------------------------------------------------------------------------- | 663 | // ---------------------------------------------------------------------------- |
664 | // R E SI Z E E V E N T H A N D L I N G | 664 | // R E SI Z E E V E N T H A N D L I N G |
665 | // ---------------------------------------------------------------------------- | 665 | // ---------------------------------------------------------------------------- |
666 | 666 | ||
667 | void KODayMatrix::resizeEvent(QResizeEvent *) | 667 | void KODayMatrix::resizeEvent(QResizeEvent *) |
668 | { | 668 | { |
669 | QRect sz = frameRect(); | 669 | QRect sz = frameRect(); |
670 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 670 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
671 | daysize.setWidth(sz.width() / 7); | 671 | daysize.setWidth(sz.width() / 7); |
672 | } | 672 | } |