-rw-r--r-- | korganizer/calendarview.cpp | 16 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 25 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 18 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 11 |
5 files changed, 68 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1009956..d6918d3 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3974 +1,3988 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init(); | 232 | init(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void CalendarView::init() | 235 | void CalendarView::init() |
236 | { | 236 | { |
237 | 237 | ||
238 | setFocusPolicy ( WheelFocus ); | 238 | setFocusPolicy ( WheelFocus ); |
239 | mViewerCallerIsSearchDialog = false; | 239 | mViewerCallerIsSearchDialog = false; |
240 | mBlockShowDates = false; | 240 | mBlockShowDates = false; |
241 | beamDialog = new KOBeamPrefs(); | 241 | beamDialog = new KOBeamPrefs(); |
242 | mDatePickerMode = 0; | 242 | mDatePickerMode = 0; |
243 | mCurrentSyncDevice = ""; | 243 | mCurrentSyncDevice = ""; |
244 | writeLocale(); | 244 | writeLocale(); |
245 | mViewManager = new KOViewManager( this ); | 245 | mViewManager = new KOViewManager( this ); |
246 | mDialogManager = new KODialogManager( this ); | 246 | mDialogManager = new KODialogManager( this ); |
247 | mEventViewerDialog = 0; | 247 | mEventViewerDialog = 0; |
248 | mModified = false; | 248 | mModified = false; |
249 | mReadOnly = false; | 249 | mReadOnly = false; |
250 | mSelectedIncidence = 0; | 250 | mSelectedIncidence = 0; |
251 | mCalPrinter = 0; | 251 | mCalPrinter = 0; |
252 | mFilters.setAutoDelete(true); | 252 | mFilters.setAutoDelete(true); |
253 | 253 | ||
254 | mCalendar->registerObserver( this ); | 254 | mCalendar->registerObserver( this ); |
255 | // TODO: Make sure that view is updated, when calendar is changed. | 255 | // TODO: Make sure that view is updated, when calendar is changed. |
256 | 256 | ||
257 | mStorage = new FileStorage( mCalendar ); | 257 | mStorage = new FileStorage( mCalendar ); |
258 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 258 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
259 | 259 | ||
260 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 260 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
261 | #ifndef KORG_NOSPLITTER | 261 | #ifndef KORG_NOSPLITTER |
262 | // create the main layout frames. | 262 | // create the main layout frames. |
263 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 263 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
264 | topLayout->addWidget(mPanner); | 264 | topLayout->addWidget(mPanner); |
265 | 265 | ||
266 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 266 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
267 | "CalendarView::LeftFrame"); | 267 | "CalendarView::LeftFrame"); |
268 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 268 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
269 | 269 | ||
270 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 270 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
271 | "CalendarView::DateNavigator", QDate::currentDate() ); | 271 | "CalendarView::DateNavigator", QDate::currentDate() ); |
272 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 272 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
273 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 273 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
274 | mTodoList->setNavigator( mNavigator ); | 274 | mTodoList->setNavigator( mNavigator ); |
275 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 275 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
276 | 276 | ||
277 | #ifdef KORG_NORESOURCEVIEW | 277 | #ifdef KORG_NORESOURCEVIEW |
278 | mResourceView = 0; | 278 | mResourceView = 0; |
279 | #else | 279 | #else |
280 | if ( mResourceManager ) { | 280 | if ( mResourceManager ) { |
281 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 281 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
282 | mResourceView->updateView(); | 282 | mResourceView->updateView(); |
283 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 283 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
284 | SLOT( updateView() ) ); | 284 | SLOT( updateView() ) ); |
285 | } else { | 285 | } else { |
286 | mResourceView = 0; | 286 | mResourceView = 0; |
287 | } | 287 | } |
288 | #endif | 288 | #endif |
289 | QWidget *rightBox = new QWidget( mPanner ); | 289 | QWidget *rightBox = new QWidget( mPanner ); |
290 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 290 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
291 | 291 | ||
292 | mRightFrame = new QWidgetStack( rightBox ); | 292 | mRightFrame = new QWidgetStack( rightBox ); |
293 | rightLayout->addWidget( mRightFrame, 1 ); | 293 | rightLayout->addWidget( mRightFrame, 1 ); |
294 | 294 | ||
295 | mLeftFrame = mLeftSplitter; | 295 | mLeftFrame = mLeftSplitter; |
296 | #else | 296 | #else |
297 | QWidget *mainBox = new QWidget( this ); | 297 | QWidget *mainBox = new QWidget( this ); |
298 | QWidget *leftFrame = new QWidget( mainBox ); | 298 | QWidget *leftFrame = new QWidget( mainBox ); |
299 | 299 | ||
300 | QBoxLayout * mainBoxLayout; | 300 | QBoxLayout * mainBoxLayout; |
301 | QBoxLayout * leftFrameLayout; | 301 | QBoxLayout * leftFrameLayout; |
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 | } else { | 305 | } else { |
306 | mainBoxLayout = new QHBoxLayout(mainBox); | 306 | mainBoxLayout = new QHBoxLayout(mainBox); |
307 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 307 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
308 | } | 308 | } |
309 | topLayout->addWidget( mainBox ); | 309 | topLayout->addWidget( mainBox ); |
310 | mainBoxLayout->addWidget (leftFrame); | 310 | mainBoxLayout->addWidget (leftFrame); |
311 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 311 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
312 | "CalendarView::DateNavigator", QDate::currentDate()); | 312 | "CalendarView::DateNavigator", QDate::currentDate()); |
313 | // mDateNavigator->blockSignals( true ); | 313 | // mDateNavigator->blockSignals( true ); |
314 | leftFrameLayout->addWidget( mDateNavigator ); | 314 | leftFrameLayout->addWidget( mDateNavigator ); |
315 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 315 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
316 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 316 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
317 | mTodoList->setNavigator( mNavigator ); | 317 | mTodoList->setNavigator( mNavigator ); |
318 | 318 | ||
319 | if ( QApplication::desktop()->width() < 480 ) { | 319 | if ( QApplication::desktop()->width() < 480 ) { |
320 | leftFrameLayout->addWidget(mFilterView); | 320 | leftFrameLayout->addWidget(mFilterView); |
321 | leftFrameLayout->addWidget(mTodoList, 2 ); | 321 | leftFrameLayout->addWidget(mTodoList, 2 ); |
322 | 322 | ||
323 | } else { | 323 | } else { |
324 | leftFrameLayout->addWidget(mTodoList,2 ); | 324 | leftFrameLayout->addWidget(mTodoList,2 ); |
325 | leftFrameLayout->addWidget(mFilterView ); | 325 | leftFrameLayout->addWidget(mFilterView ); |
326 | } | 326 | } |
327 | mFilterView->hide(); | 327 | mFilterView->hide(); |
328 | QWidget *rightBox = new QWidget( mainBox ); | 328 | QWidget *rightBox = new QWidget( mainBox ); |
329 | mainBoxLayout->addWidget ( rightBox, 10 ); | 329 | mainBoxLayout->addWidget ( rightBox, 10 ); |
330 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 330 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
331 | mRightFrame = new QWidgetStack( rightBox ); | 331 | mRightFrame = new QWidgetStack( rightBox ); |
332 | rightLayout->addWidget( mRightFrame, 10 ); | 332 | rightLayout->addWidget( mRightFrame, 10 ); |
333 | 333 | ||
334 | mLeftFrame = leftFrame; | 334 | mLeftFrame = leftFrame; |
335 | if ( KOPrefs::instance()->mVerticalScreen ) { | 335 | if ( KOPrefs::instance()->mVerticalScreen ) { |
336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 336 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 337 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
338 | } else { | 338 | } else { |
339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 339 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 340 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
341 | } | 341 | } |
342 | if ( !KOPrefs::instance()->mShowDateNavigator) | 342 | if ( !KOPrefs::instance()->mShowDateNavigator) |
343 | mDateNavigator->hide(); | 343 | mDateNavigator->hide(); |
344 | //qDebug("Calendarview Size %d %d ", width(), height()); | 344 | //qDebug("Calendarview Size %d %d ", width(), height()); |
345 | #endif | 345 | #endif |
346 | 346 | ||
347 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 347 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
348 | SLOT( showDates( const KCal::DateList & ) ) ); | 348 | SLOT( showDates( const KCal::DateList & ) ) ); |
349 | 349 | ||
350 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 350 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
351 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 351 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
352 | 352 | ||
353 | 353 | ||
354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 354 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 355 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
356 | 356 | ||
357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 357 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
358 | mNavigator, SLOT( selectPreviousYear() ) ); | 358 | mNavigator, SLOT( selectPreviousYear() ) ); |
359 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 359 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
360 | mNavigator, SLOT( selectNextYear() ) ); | 360 | mNavigator, SLOT( selectNextYear() ) ); |
361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 361 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
362 | mNavigator, SLOT( selectPreviousMonth() ) ); | 362 | mNavigator, SLOT( selectPreviousMonth() ) ); |
363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 363 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
364 | mNavigator, SLOT( selectNextMonth() ) ); | 364 | mNavigator, SLOT( selectNextMonth() ) ); |
365 | 365 | ||
366 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 366 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
367 | mNavigator, SLOT( selectPrevious() ) ); | 367 | mNavigator, SLOT( selectPrevious() ) ); |
368 | connect( mDateNavigator, SIGNAL( goNext() ), | 368 | connect( mDateNavigator, SIGNAL( goNext() ), |
369 | mNavigator, SLOT( selectNext() ) ); | 369 | mNavigator, SLOT( selectNext() ) ); |
370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 370 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 371 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
372 | 372 | ||
373 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 373 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
374 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 374 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
375 | 375 | ||
376 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 376 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
377 | SLOT( eventAdded( Event *) ) ); | 377 | SLOT( eventAdded( Event *) ) ); |
378 | 378 | ||
379 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 379 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
380 | 380 | ||
381 | connect( this, SIGNAL( configChanged() ), | 381 | connect( this, SIGNAL( configChanged() ), |
382 | mDateNavigator, SLOT( updateConfig() ) ); | 382 | mDateNavigator, SLOT( updateConfig() ) ); |
383 | 383 | ||
384 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 384 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
385 | SLOT( newTodo() ) ); | 385 | SLOT( newTodo() ) ); |
386 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 386 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
387 | SLOT( newSubTodo( Todo * ) ) ); | 387 | SLOT( newSubTodo( Todo * ) ) ); |
388 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 388 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
389 | SLOT( editTodo( Todo * ) ) ); | 389 | SLOT( editTodo( Todo * ) ) ); |
390 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 390 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
391 | SLOT( showTodo( Todo *) ) ); | 391 | SLOT( showTodo( Todo *) ) ); |
392 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 392 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
393 | SLOT( deleteTodo( Todo *) ) ); | 393 | SLOT( deleteTodo( Todo *) ) ); |
394 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 394 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
395 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 395 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
396 | SLOT( purgeCompleted() ) ); | 396 | SLOT( purgeCompleted() ) ); |
397 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 397 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
398 | SIGNAL( todoModified( Todo *, int ) ) ); | 398 | SIGNAL( todoModified( Todo *, int ) ) ); |
399 | 399 | ||
400 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 400 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
401 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 401 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
402 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 402 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
403 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 403 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
404 | 404 | ||
405 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 405 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
406 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 406 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
407 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 407 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
408 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 408 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
409 | 409 | ||
410 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 410 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
411 | this, SLOT ( todo_unsub( Todo * ) ) ); | 411 | this, SLOT ( todo_unsub( Todo * ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 413 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
414 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 414 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 415 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
416 | SLOT( updateTodo( Todo *, int ) ) ); | 416 | SLOT( updateTodo( Todo *, int ) ) ); |
417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 417 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 418 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
419 | 419 | ||
420 | 420 | ||
421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 421 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 422 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 423 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
425 | 425 | ||
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 430 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
431 | SLOT(checkClipboard())); | 431 | SLOT(checkClipboard())); |
432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 432 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
433 | SLOT( processTodoListSelection( Incidence * ) ) ); | 433 | SLOT( processTodoListSelection( Incidence * ) ) ); |
434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 434 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
435 | 435 | ||
436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 436 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
437 | 437 | ||
438 | mDateFrame = new QVBox(0,0,WType_Popup); | 438 | mDateFrame = new QVBox(0,0,WType_Popup); |
439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 439 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 440 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
441 | mDateFrame->setLineWidth(3); | 441 | mDateFrame->setLineWidth(3); |
442 | mDateFrame->hide(); | 442 | mDateFrame->hide(); |
443 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 443 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 444 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
445 | 445 | ||
446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 446 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
447 | 447 | ||
448 | mEventEditor = mDialogManager->getEventEditor(); | 448 | mEventEditor = mDialogManager->getEventEditor(); |
449 | mTodoEditor = mDialogManager->getTodoEditor(); | 449 | mTodoEditor = mDialogManager->getTodoEditor(); |
450 | 450 | ||
451 | mFlagEditDescription = false; | 451 | mFlagEditDescription = false; |
452 | 452 | ||
453 | mSuspendTimer = new QTimer( this ); | 453 | mSuspendTimer = new QTimer( this ); |
454 | mAlarmTimer = new QTimer( this ); | 454 | mAlarmTimer = new QTimer( this ); |
455 | mRecheckAlarmTimer = new QTimer( this ); | 455 | mRecheckAlarmTimer = new QTimer( this ); |
456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 456 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 457 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 458 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
459 | mAlarmDialog = new AlarmDialog( this ); | 459 | mAlarmDialog = new AlarmDialog( this ); |
460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 460 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
461 | mAlarmDialog->setServerNotification( false ); | 461 | mAlarmDialog->setServerNotification( false ); |
462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 462 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
463 | 463 | ||
464 | 464 | ||
465 | #ifndef DESKTOP_VERSION | 465 | #ifndef DESKTOP_VERSION |
466 | //US listen for arriving address resultsets | 466 | //US listen for arriving address resultsets |
467 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 467 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
468 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 468 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
469 | #endif | 469 | #endif |
470 | 470 | ||
471 | } | 471 | } |
472 | 472 | ||
473 | 473 | ||
474 | CalendarView::~CalendarView() | 474 | CalendarView::~CalendarView() |
475 | { | 475 | { |
476 | // kdDebug() << "~CalendarView()" << endl; | 476 | // kdDebug() << "~CalendarView()" << endl; |
477 | //qDebug("CalendarView::~CalendarView() "); | 477 | //qDebug("CalendarView::~CalendarView() "); |
478 | delete mDialogManager; | 478 | delete mDialogManager; |
479 | delete mViewManager; | 479 | delete mViewManager; |
480 | delete mStorage; | 480 | delete mStorage; |
481 | delete mDateFrame ; | 481 | delete mDateFrame ; |
482 | delete beamDialog; | 482 | delete beamDialog; |
483 | delete mEventViewerDialog; | ||
483 | //kdDebug() << "~CalendarView() done" << endl; | 484 | //kdDebug() << "~CalendarView() done" << endl; |
484 | } | 485 | } |
485 | 486 | ||
486 | void CalendarView::showDay( QDate d ) | 487 | void CalendarView::showDay( QDate d ) |
487 | { | 488 | { |
488 | dateNavigator()->blockSignals( true ); | 489 | dateNavigator()->blockSignals( true ); |
489 | dateNavigator()->selectDate( d ); | 490 | dateNavigator()->selectDate( d ); |
490 | dateNavigator()->blockSignals( false ); | 491 | dateNavigator()->blockSignals( false ); |
491 | mViewManager->showDayView(); | 492 | mViewManager->showDayView(); |
492 | //dateNavigator()->selectDate( d ); | 493 | //dateNavigator()->selectDate( d ); |
493 | } | 494 | } |
494 | void CalendarView::timerAlarm() | 495 | void CalendarView::timerAlarm() |
495 | { | 496 | { |
496 | //qDebug("CalendarView::timerAlarm() "); | 497 | //qDebug("CalendarView::timerAlarm() "); |
497 | computeAlarm(mAlarmNotification ); | 498 | computeAlarm(mAlarmNotification ); |
498 | } | 499 | } |
499 | 500 | ||
500 | void CalendarView::suspendAlarm() | 501 | void CalendarView::suspendAlarm() |
501 | { | 502 | { |
502 | //qDebug(" CalendarView::suspendAlarm() "); | 503 | //qDebug(" CalendarView::suspendAlarm() "); |
503 | computeAlarm(mSuspendAlarmNotification ); | 504 | computeAlarm(mSuspendAlarmNotification ); |
504 | 505 | ||
505 | } | 506 | } |
506 | 507 | ||
507 | void CalendarView::startAlarm( QString mess , QString filename) | 508 | void CalendarView::startAlarm( QString mess , QString filename) |
508 | { | 509 | { |
509 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 510 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
510 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 511 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
511 | 512 | ||
512 | } | 513 | } |
513 | 514 | ||
514 | void CalendarView::checkNextTimerAlarm() | 515 | void CalendarView::checkNextTimerAlarm() |
515 | { | 516 | { |
516 | mCalendar->checkAlarmForIncidence( 0, true ); | 517 | mCalendar->checkAlarmForIncidence( 0, true ); |
517 | } | 518 | } |
518 | 519 | ||
519 | void CalendarView::computeAlarm( QString msg ) | 520 | void CalendarView::computeAlarm( QString msg ) |
520 | { | 521 | { |
521 | 522 | ||
522 | QString mess = msg; | 523 | QString mess = msg; |
523 | QString mAlarmMessage = mess.mid( 9 ); | 524 | QString mAlarmMessage = mess.mid( 9 ); |
524 | QString filename = MainWindow::resourcePath(); | 525 | QString filename = MainWindow::resourcePath(); |
525 | filename += "koalarm.wav"; | 526 | filename += "koalarm.wav"; |
526 | QString tempfilename; | 527 | QString tempfilename; |
527 | if ( mess.left( 13 ) == "suspend_alarm") { | 528 | if ( mess.left( 13 ) == "suspend_alarm") { |
528 | bool error = false; | 529 | bool error = false; |
529 | int len = mess.mid( 13 ).find("+++"); | 530 | int len = mess.mid( 13 ).find("+++"); |
530 | if ( len < 2 ) | 531 | if ( len < 2 ) |
531 | error = true; | 532 | error = true; |
532 | else { | 533 | else { |
533 | tempfilename = mess.mid( 13, len ); | 534 | tempfilename = mess.mid( 13, len ); |
534 | if ( !QFile::exists( tempfilename ) ) | 535 | if ( !QFile::exists( tempfilename ) ) |
535 | error = true; | 536 | error = true; |
536 | } | 537 | } |
537 | if ( ! error ) { | 538 | if ( ! error ) { |
538 | filename = tempfilename; | 539 | filename = tempfilename; |
539 | } | 540 | } |
540 | mAlarmMessage = mess.mid( 13+len+3 ); | 541 | mAlarmMessage = mess.mid( 13+len+3 ); |
541 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 542 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
542 | startAlarm( mAlarmMessage, filename); | 543 | startAlarm( mAlarmMessage, filename); |
543 | return; | 544 | return; |
544 | } | 545 | } |
545 | if ( mess.left( 11 ) == "timer_alarm") { | 546 | if ( mess.left( 11 ) == "timer_alarm") { |
546 | //mTimerTime = 0; | 547 | //mTimerTime = 0; |
547 | startAlarm( mess.mid( 11 ), filename ); | 548 | startAlarm( mess.mid( 11 ), filename ); |
548 | return; | 549 | return; |
549 | } | 550 | } |
550 | if ( mess.left( 10 ) == "proc_alarm") { | 551 | if ( mess.left( 10 ) == "proc_alarm") { |
551 | bool error = false; | 552 | bool error = false; |
552 | int len = mess.mid( 10 ).find("+++"); | 553 | int len = mess.mid( 10 ).find("+++"); |
553 | if ( len < 2 ) | 554 | if ( len < 2 ) |
554 | error = true; | 555 | error = true; |
555 | else { | 556 | else { |
556 | tempfilename = mess.mid( 10, len ); | 557 | tempfilename = mess.mid( 10, len ); |
557 | if ( !QFile::exists( tempfilename ) ) | 558 | if ( !QFile::exists( tempfilename ) ) |
558 | error = true; | 559 | error = true; |
559 | } | 560 | } |
560 | if ( error ) { | 561 | if ( error ) { |
561 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 562 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
562 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 563 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
563 | } else { | 564 | } else { |
564 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 565 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
565 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 566 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
566 | #ifndef _WIN32_ | 567 | #ifndef _WIN32_ |
567 | if ( vfork () == 0 ) { | 568 | if ( vfork () == 0 ) { |
568 | execl ( tempfilename.latin1(), 0 ); | 569 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 570 | return; |
570 | } | 571 | } |
571 | #else | 572 | #else |
572 | QProcess* p = new QProcess(); | 573 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 574 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 575 | p->start(); |
575 | return; | 576 | return; |
576 | #endif | 577 | #endif |
577 | 578 | ||
578 | return; | 579 | return; |
579 | } | 580 | } |
580 | 581 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 582 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 583 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 584 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 585 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 586 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 587 | if ( len < 2 ) |
587 | error = true; | 588 | error = true; |
588 | else { | 589 | else { |
589 | tempfilename = mess.mid( 11, len ); | 590 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 591 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 592 | error = true; |
592 | } | 593 | } |
593 | if ( ! error ) { | 594 | if ( ! error ) { |
594 | filename = tempfilename; | 595 | filename = tempfilename; |
595 | } | 596 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 597 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 598 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 599 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 600 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 601 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 602 | } |
602 | 603 | ||
603 | startAlarm( mAlarmMessage, filename ); | 604 | startAlarm( mAlarmMessage, filename ); |
604 | 605 | ||
605 | 606 | ||
606 | } | 607 | } |
607 | 608 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 609 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 610 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 611 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 612 | ||
612 | mSuspendAlarmNotification = noti; | 613 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 614 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 615 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 616 | mSuspendTimer->start( ms , true ); |
616 | 617 | ||
617 | } | 618 | } |
618 | 619 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 620 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 621 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 622 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 623 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 624 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 625 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 626 | #endif |
626 | return; | 627 | return; |
627 | } | 628 | } |
628 | int maxSec; | 629 | int maxSec; |
629 | //maxSec = 5; //testing only | 630 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 631 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 632 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 633 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 634 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 635 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 636 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 637 | return; |
637 | } else { | 638 | } else { |
638 | mRecheckAlarmTimer->stop(); | 639 | mRecheckAlarmTimer->stop(); |
639 | } | 640 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 641 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 642 | mAlarmTimer->start( sec *1000 , true ); |
642 | 643 | ||
643 | } | 644 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 645 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 646 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 647 | void CalendarView::recheckTimerAlarm() |
647 | { | 648 | { |
648 | mAlarmTimer->stop(); | 649 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 650 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 651 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 652 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 653 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 654 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 655 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 656 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 657 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 658 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 659 | #endif |
659 | return; | 660 | return; |
660 | } | 661 | } |
661 | mAlarmTimer->stop(); | 662 | mAlarmTimer->stop(); |
662 | } | 663 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 664 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 665 | { |
665 | dateNavigator()->blockSignals( true ); | 666 | dateNavigator()->blockSignals( true ); |
666 | dateNavigator()->selectWeek( num ); | 667 | dateNavigator()->selectWeek( num ); |
667 | dateNavigator()->blockSignals( false ); | 668 | dateNavigator()->blockSignals( false ); |
668 | mViewManager->showWeekView(); | 669 | mViewManager->showWeekView(); |
669 | } | 670 | } |
670 | KOViewManager *CalendarView::viewManager() | 671 | KOViewManager *CalendarView::viewManager() |
671 | { | 672 | { |
672 | return mViewManager; | 673 | return mViewManager; |
673 | } | 674 | } |
674 | 675 | ||
675 | KODialogManager *CalendarView::dialogManager() | 676 | KODialogManager *CalendarView::dialogManager() |
676 | { | 677 | { |
677 | return mDialogManager; | 678 | return mDialogManager; |
678 | } | 679 | } |
679 | 680 | ||
680 | QDate CalendarView::startDate() | 681 | QDate CalendarView::startDate() |
681 | { | 682 | { |
682 | DateList dates = mNavigator->selectedDates(); | 683 | DateList dates = mNavigator->selectedDates(); |
683 | 684 | ||
684 | return dates.first(); | 685 | return dates.first(); |
685 | } | 686 | } |
686 | 687 | ||
687 | QDate CalendarView::endDate() | 688 | QDate CalendarView::endDate() |
688 | { | 689 | { |
689 | DateList dates = mNavigator->selectedDates(); | 690 | DateList dates = mNavigator->selectedDates(); |
690 | 691 | ||
691 | return dates.last(); | 692 | return dates.last(); |
692 | } | 693 | } |
693 | 694 | ||
694 | 695 | ||
695 | void CalendarView::createPrinter() | 696 | void CalendarView::createPrinter() |
696 | { | 697 | { |
697 | #ifndef KORG_NOPRINTER | 698 | #ifndef KORG_NOPRINTER |
698 | if (!mCalPrinter) { | 699 | if (!mCalPrinter) { |
699 | mCalPrinter = new CalPrinter(this, mCalendar); | 700 | mCalPrinter = new CalPrinter(this, mCalendar); |
700 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 701 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
701 | } | 702 | } |
702 | #endif | 703 | #endif |
703 | } | 704 | } |
704 | 705 | ||
705 | 706 | ||
706 | //KOPrefs::instance()->mWriteBackFile | 707 | //KOPrefs::instance()->mWriteBackFile |
707 | //KOPrefs::instance()->mWriteBackExistingOnly | 708 | //KOPrefs::instance()->mWriteBackExistingOnly |
708 | 709 | ||
709 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 710 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
710 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 711 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
711 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 712 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
712 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 713 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
713 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 714 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
714 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 715 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
715 | 716 | ||
716 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 717 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
717 | { | 718 | { |
718 | 719 | ||
719 | // 0 equal | 720 | // 0 equal |
720 | // 1 take local | 721 | // 1 take local |
721 | // 2 take remote | 722 | // 2 take remote |
722 | // 3 cancel | 723 | // 3 cancel |
723 | QDateTime lastSync = mLastCalendarSync; | 724 | QDateTime lastSync = mLastCalendarSync; |
724 | QDateTime localMod = local->lastModified(); | 725 | QDateTime localMod = local->lastModified(); |
725 | QDateTime remoteMod = remote->lastModified(); | 726 | QDateTime remoteMod = remote->lastModified(); |
726 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 727 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
727 | bool remCh, locCh; | 728 | bool remCh, locCh; |
728 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 729 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
729 | //if ( remCh ) | 730 | //if ( remCh ) |
730 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 731 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
731 | locCh = ( localMod > mLastCalendarSync ); | 732 | locCh = ( localMod > mLastCalendarSync ); |
732 | if ( !remCh && ! locCh ) { | 733 | if ( !remCh && ! locCh ) { |
733 | //qDebug("both not changed "); | 734 | //qDebug("both not changed "); |
734 | lastSync = localMod.addDays(1); | 735 | lastSync = localMod.addDays(1); |
735 | if ( mode <= SYNC_PREF_ASK ) | 736 | if ( mode <= SYNC_PREF_ASK ) |
736 | return 0; | 737 | return 0; |
737 | } else { | 738 | } else { |
738 | if ( locCh ) { | 739 | if ( locCh ) { |
739 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 740 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
740 | lastSync = localMod.addDays( -1 ); | 741 | lastSync = localMod.addDays( -1 ); |
741 | if ( !remCh ) | 742 | if ( !remCh ) |
742 | remoteMod = ( lastSync.addDays( -1 ) ); | 743 | remoteMod = ( lastSync.addDays( -1 ) ); |
743 | } else { | 744 | } else { |
744 | //qDebug(" not loc changed "); | 745 | //qDebug(" not loc changed "); |
745 | lastSync = localMod.addDays( 1 ); | 746 | lastSync = localMod.addDays( 1 ); |
746 | if ( remCh ) | 747 | if ( remCh ) |
747 | remoteMod =( lastSync.addDays( 1 ) ); | 748 | remoteMod =( lastSync.addDays( 1 ) ); |
748 | 749 | ||
749 | } | 750 | } |
750 | } | 751 | } |
751 | full = true; | 752 | full = true; |
752 | if ( mode < SYNC_PREF_ASK ) | 753 | if ( mode < SYNC_PREF_ASK ) |
753 | mode = SYNC_PREF_ASK; | 754 | mode = SYNC_PREF_ASK; |
754 | } else { | 755 | } else { |
755 | if ( localMod == remoteMod ) | 756 | if ( localMod == remoteMod ) |
756 | // if ( local->revision() == remote->revision() ) | 757 | // if ( local->revision() == remote->revision() ) |
757 | return 0; | 758 | return 0; |
758 | 759 | ||
759 | } | 760 | } |
760 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 761 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
761 | 762 | ||
762 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 763 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
763 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 764 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
764 | //full = true; //debug only | 765 | //full = true; //debug only |
765 | if ( full ) { | 766 | if ( full ) { |
766 | bool equ = false; | 767 | bool equ = false; |
767 | if ( local->type() == "Event" ) { | 768 | if ( local->type() == "Event" ) { |
768 | equ = (*((Event*) local) == *((Event*) remote)); | 769 | equ = (*((Event*) local) == *((Event*) remote)); |
769 | } | 770 | } |
770 | else if ( local->type() =="Todo" ) | 771 | else if ( local->type() =="Todo" ) |
771 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 772 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
772 | else if ( local->type() =="Journal" ) | 773 | else if ( local->type() =="Journal" ) |
773 | equ = (*((Journal*) local) == *((Journal*) remote)); | 774 | equ = (*((Journal*) local) == *((Journal*) remote)); |
774 | if ( equ ) { | 775 | if ( equ ) { |
775 | //qDebug("equal "); | 776 | //qDebug("equal "); |
776 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 777 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
777 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 778 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
778 | } | 779 | } |
779 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 780 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
780 | return 0; | 781 | return 0; |
781 | 782 | ||
782 | }//else //debug only | 783 | }//else //debug only |
783 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 784 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
784 | } | 785 | } |
785 | int result; | 786 | int result; |
786 | bool localIsNew; | 787 | bool localIsNew; |
787 | //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() ); | 788 | //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() ); |
788 | 789 | ||
789 | if ( full && mode < SYNC_PREF_NEWEST ) | 790 | if ( full && mode < SYNC_PREF_NEWEST ) |
790 | mode = SYNC_PREF_ASK; | 791 | mode = SYNC_PREF_ASK; |
791 | 792 | ||
792 | switch( mode ) { | 793 | switch( mode ) { |
793 | case SYNC_PREF_LOCAL: | 794 | case SYNC_PREF_LOCAL: |
794 | if ( lastSync > remoteMod ) | 795 | if ( lastSync > remoteMod ) |
795 | return 1; | 796 | return 1; |
796 | if ( lastSync > localMod ) | 797 | if ( lastSync > localMod ) |
797 | return 2; | 798 | return 2; |
798 | return 1; | 799 | return 1; |
799 | break; | 800 | break; |
800 | case SYNC_PREF_REMOTE: | 801 | case SYNC_PREF_REMOTE: |
801 | if ( lastSync > remoteMod ) | 802 | if ( lastSync > remoteMod ) |
802 | return 1; | 803 | return 1; |
803 | if ( lastSync > localMod ) | 804 | if ( lastSync > localMod ) |
804 | return 2; | 805 | return 2; |
805 | return 2; | 806 | return 2; |
806 | break; | 807 | break; |
807 | case SYNC_PREF_NEWEST: | 808 | case SYNC_PREF_NEWEST: |
808 | if ( localMod > remoteMod ) | 809 | if ( localMod > remoteMod ) |
809 | return 1; | 810 | return 1; |
810 | else | 811 | else |
811 | return 2; | 812 | return 2; |
812 | break; | 813 | break; |
813 | case SYNC_PREF_ASK: | 814 | case SYNC_PREF_ASK: |
814 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 815 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
815 | if ( lastSync > remoteMod ) | 816 | if ( lastSync > remoteMod ) |
816 | return 1; | 817 | return 1; |
817 | if ( lastSync > localMod ) | 818 | if ( lastSync > localMod ) |
818 | return 2; | 819 | return 2; |
819 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 820 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
820 | localIsNew = localMod >= remoteMod; | 821 | localIsNew = localMod >= remoteMod; |
821 | if ( localIsNew ) | 822 | if ( localIsNew ) |
822 | getEventViewerDialog()->setColorMode( 1 ); | 823 | getEventViewerDialog()->setColorMode( 1 ); |
823 | else | 824 | else |
824 | getEventViewerDialog()->setColorMode( 2 ); | 825 | getEventViewerDialog()->setColorMode( 2 ); |
825 | getEventViewerDialog()->setIncidence(local); | 826 | getEventViewerDialog()->setIncidence(local); |
826 | if ( localIsNew ) | 827 | if ( localIsNew ) |
827 | getEventViewerDialog()->setColorMode( 2 ); | 828 | getEventViewerDialog()->setColorMode( 2 ); |
828 | else | 829 | else |
829 | getEventViewerDialog()->setColorMode( 1 ); | 830 | getEventViewerDialog()->setColorMode( 1 ); |
830 | getEventViewerDialog()->addIncidence(remote); | 831 | getEventViewerDialog()->addIncidence(remote); |
831 | getEventViewerDialog()->setColorMode( 0 ); | 832 | getEventViewerDialog()->setColorMode( 0 ); |
832 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 833 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
833 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 834 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
834 | getEventViewerDialog()->showMe(); | 835 | getEventViewerDialog()->showMe(); |
835 | result = getEventViewerDialog()->executeS( localIsNew ); | 836 | result = getEventViewerDialog()->executeS( localIsNew ); |
836 | return result; | 837 | return result; |
837 | 838 | ||
838 | break; | 839 | break; |
839 | case SYNC_PREF_FORCE_LOCAL: | 840 | case SYNC_PREF_FORCE_LOCAL: |
840 | return 1; | 841 | return 1; |
841 | break; | 842 | break; |
842 | case SYNC_PREF_FORCE_REMOTE: | 843 | case SYNC_PREF_FORCE_REMOTE: |
843 | return 2; | 844 | return 2; |
844 | break; | 845 | break; |
845 | 846 | ||
846 | default: | 847 | default: |
847 | // SYNC_PREF_TAKE_BOTH not implemented | 848 | // SYNC_PREF_TAKE_BOTH not implemented |
848 | break; | 849 | break; |
849 | } | 850 | } |
850 | return 0; | 851 | return 0; |
851 | } | 852 | } |
852 | Event* CalendarView::getLastSyncEvent() | 853 | Event* CalendarView::getLastSyncEvent() |
853 | { | 854 | { |
854 | Event* lse; | 855 | Event* lse; |
855 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 856 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
856 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 857 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
857 | if (!lse) { | 858 | if (!lse) { |
858 | lse = new Event(); | 859 | lse = new Event(); |
859 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 860 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
860 | QString sum = ""; | 861 | QString sum = ""; |
861 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 862 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
862 | sum = "E: "; | 863 | sum = "E: "; |
863 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 864 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
864 | lse->setDtStart( mLastCalendarSync ); | 865 | lse->setDtStart( mLastCalendarSync ); |
865 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 866 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
866 | lse->setCategories( i18n("SyncEvent") ); | 867 | lse->setCategories( i18n("SyncEvent") ); |
867 | lse->setReadOnly( true ); | 868 | lse->setReadOnly( true ); |
868 | mCalendar->addEvent( lse ); | 869 | mCalendar->addEvent( lse ); |
869 | } | 870 | } |
870 | 871 | ||
871 | return lse; | 872 | return lse; |
872 | 873 | ||
873 | } | 874 | } |
874 | 875 | ||
875 | // we check, if the to delete event has a id for a profile | 876 | // we check, if the to delete event has a id for a profile |
876 | // if yes, we set this id in the profile to delete | 877 | // if yes, we set this id in the profile to delete |
877 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 878 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
878 | { | 879 | { |
879 | if ( lastSync.count() == 0 ) { | 880 | if ( lastSync.count() == 0 ) { |
880 | //qDebug(" lastSync.count() == 0"); | 881 | //qDebug(" lastSync.count() == 0"); |
881 | return; | 882 | return; |
882 | } | 883 | } |
883 | if ( toDelete->type() == "Journal" ) | 884 | if ( toDelete->type() == "Journal" ) |
884 | return; | 885 | return; |
885 | 886 | ||
886 | Event* eve = lastSync.first(); | 887 | Event* eve = lastSync.first(); |
887 | 888 | ||
888 | while ( eve ) { | 889 | while ( eve ) { |
889 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 890 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
890 | if ( !id.isEmpty() ) { | 891 | if ( !id.isEmpty() ) { |
891 | QString des = eve->description(); | 892 | QString des = eve->description(); |
892 | QString pref = "e"; | 893 | QString pref = "e"; |
893 | if ( toDelete->type() == "Todo" ) | 894 | if ( toDelete->type() == "Todo" ) |
894 | pref = "t"; | 895 | pref = "t"; |
895 | des += pref+ id + ","; | 896 | des += pref+ id + ","; |
896 | eve->setReadOnly( false ); | 897 | eve->setReadOnly( false ); |
897 | eve->setDescription( des ); | 898 | eve->setDescription( des ); |
898 | //qDebug("setdes %s ", des.latin1()); | 899 | //qDebug("setdes %s ", des.latin1()); |
899 | eve->setReadOnly( true ); | 900 | eve->setReadOnly( true ); |
900 | } | 901 | } |
901 | eve = lastSync.next(); | 902 | eve = lastSync.next(); |
902 | } | 903 | } |
903 | 904 | ||
904 | } | 905 | } |
905 | void CalendarView::checkExternalId( Incidence * inc ) | 906 | void CalendarView::checkExternalId( Incidence * inc ) |
906 | { | 907 | { |
907 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 908 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
908 | checkExternSyncEvent( lastSync, inc ); | 909 | checkExternSyncEvent( lastSync, inc ); |
909 | 910 | ||
910 | } | 911 | } |
911 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 912 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
912 | { | 913 | { |
913 | bool syncOK = true; | 914 | bool syncOK = true; |
914 | int addedEvent = 0; | 915 | int addedEvent = 0; |
915 | int addedEventR = 0; | 916 | int addedEventR = 0; |
916 | int deletedEventR = 0; | 917 | int deletedEventR = 0; |
917 | int deletedEventL = 0; | 918 | int deletedEventL = 0; |
918 | int changedLocal = 0; | 919 | int changedLocal = 0; |
919 | int changedRemote = 0; | 920 | int changedRemote = 0; |
920 | int filteredIN = 0; | 921 | int filteredIN = 0; |
921 | int filteredOUT = 0; | 922 | int filteredOUT = 0; |
922 | //QPtrList<Event> el = local->rawEvents(); | 923 | //QPtrList<Event> el = local->rawEvents(); |
923 | Event* eventR; | 924 | Event* eventR; |
924 | QString uid; | 925 | QString uid; |
925 | int take; | 926 | int take; |
926 | Event* eventL; | 927 | Event* eventL; |
927 | Event* eventRSync; | 928 | Event* eventRSync; |
928 | Event* eventLSync; | 929 | Event* eventLSync; |
929 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 930 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
930 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 931 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
931 | bool fullDateRange = false; | 932 | bool fullDateRange = false; |
932 | local->resetTempSyncStat(); | 933 | local->resetTempSyncStat(); |
933 | mLastCalendarSync = QDateTime::currentDateTime(); | 934 | mLastCalendarSync = QDateTime::currentDateTime(); |
934 | if ( mSyncManager->syncWithDesktop() ) { | 935 | if ( mSyncManager->syncWithDesktop() ) { |
935 | remote->resetPilotStat(1); | 936 | remote->resetPilotStat(1); |
936 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 937 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
937 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 938 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
938 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 939 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
939 | } else { | 940 | } else { |
940 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 941 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
941 | } | 942 | } |
942 | } | 943 | } |
943 | QDateTime modifiedCalendar = mLastCalendarSync; | 944 | QDateTime modifiedCalendar = mLastCalendarSync; |
944 | eventLSync = getLastSyncEvent(); | 945 | eventLSync = getLastSyncEvent(); |
945 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 946 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
946 | if ( eventR ) { | 947 | if ( eventR ) { |
947 | eventRSync = (Event*) eventR->clone(); | 948 | eventRSync = (Event*) eventR->clone(); |
948 | remote->deleteEvent(eventR ); | 949 | remote->deleteEvent(eventR ); |
949 | 950 | ||
950 | } else { | 951 | } else { |
951 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 952 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
952 | eventRSync = (Event*)eventLSync->clone(); | 953 | eventRSync = (Event*)eventLSync->clone(); |
953 | } else { | 954 | } else { |
954 | fullDateRange = true; | 955 | fullDateRange = true; |
955 | eventRSync = new Event(); | 956 | eventRSync = new Event(); |
956 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 957 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
957 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 958 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
958 | eventRSync->setDtStart( mLastCalendarSync ); | 959 | eventRSync->setDtStart( mLastCalendarSync ); |
959 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 960 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
960 | eventRSync->setCategories( i18n("SyncEvent") ); | 961 | eventRSync->setCategories( i18n("SyncEvent") ); |
961 | } | 962 | } |
962 | } | 963 | } |
963 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 964 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
964 | fullDateRange = true; | 965 | fullDateRange = true; |
965 | 966 | ||
966 | if ( ! fullDateRange ) { | 967 | if ( ! fullDateRange ) { |
967 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 968 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
968 | 969 | ||
969 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 970 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
970 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 971 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
971 | fullDateRange = true; | 972 | fullDateRange = true; |
972 | } | 973 | } |
973 | } | 974 | } |
974 | if ( mSyncManager->syncWithDesktop() ) { | 975 | if ( mSyncManager->syncWithDesktop() ) { |
975 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 976 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
976 | } | 977 | } |
977 | if ( fullDateRange ) | 978 | if ( fullDateRange ) |
978 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 979 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
979 | else | 980 | else |
980 | mLastCalendarSync = eventLSync->dtStart(); | 981 | mLastCalendarSync = eventLSync->dtStart(); |
981 | // for resyncing if own file has changed | 982 | // for resyncing if own file has changed |
982 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 983 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
983 | mLastCalendarSync = loadedFileVersion; | 984 | mLastCalendarSync = loadedFileVersion; |
984 | //qDebug("setting mLastCalendarSync "); | 985 | //qDebug("setting mLastCalendarSync "); |
985 | } | 986 | } |
986 | //qDebug("*************************** "); | 987 | //qDebug("*************************** "); |
987 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 988 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
988 | QPtrList<Incidence> er = remote->rawIncidences(); | 989 | QPtrList<Incidence> er = remote->rawIncidences(); |
989 | Incidence* inR = er.first(); | 990 | Incidence* inR = er.first(); |
990 | Incidence* inL; | 991 | Incidence* inL; |
991 | QProgressBar bar( er.count(),0 ); | 992 | QProgressBar bar( er.count(),0 ); |
992 | bar.setCaption (i18n("Syncing - close to abort!") ); | 993 | bar.setCaption (i18n("Syncing - close to abort!") ); |
993 | 994 | ||
994 | // ************** setting up filter ************* | 995 | // ************** setting up filter ************* |
995 | CalFilter *filterIN = 0; | 996 | CalFilter *filterIN = 0; |
996 | CalFilter *filterOUT = 0; | 997 | CalFilter *filterOUT = 0; |
997 | CalFilter *filter = mFilters.first(); | 998 | CalFilter *filter = mFilters.first(); |
998 | while(filter) { | 999 | while(filter) { |
999 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1000 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1000 | filterIN = filter; | 1001 | filterIN = filter; |
1001 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1002 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1002 | filterOUT = filter; | 1003 | filterOUT = filter; |
1003 | filter = mFilters.next(); | 1004 | filter = mFilters.next(); |
1004 | } | 1005 | } |
1005 | int w = 300; | 1006 | int w = 300; |
1006 | if ( QApplication::desktop()->width() < 320 ) | 1007 | if ( QApplication::desktop()->width() < 320 ) |
1007 | w = 220; | 1008 | w = 220; |
1008 | int h = bar.sizeHint().height() ; | 1009 | int h = bar.sizeHint().height() ; |
1009 | int dw = QApplication::desktop()->width(); | 1010 | int dw = QApplication::desktop()->width(); |
1010 | int dh = QApplication::desktop()->height(); | 1011 | int dh = QApplication::desktop()->height(); |
1011 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1012 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1012 | bar.show(); | 1013 | bar.show(); |
1013 | int modulo = (er.count()/10)+1; | 1014 | int modulo = (er.count()/10)+1; |
1014 | int incCounter = 0; | 1015 | int incCounter = 0; |
1015 | while ( inR ) { | 1016 | while ( inR ) { |
1016 | if ( ! bar.isVisible() ) | 1017 | if ( ! bar.isVisible() ) |
1017 | return false; | 1018 | return false; |
1018 | if ( incCounter % modulo == 0 ) | 1019 | if ( incCounter % modulo == 0 ) |
1019 | bar.setProgress( incCounter ); | 1020 | bar.setProgress( incCounter ); |
1020 | ++incCounter; | 1021 | ++incCounter; |
1021 | uid = inR->uid(); | 1022 | uid = inR->uid(); |
1022 | bool skipIncidence = false; | 1023 | bool skipIncidence = false; |
1023 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1024 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1024 | skipIncidence = true; | 1025 | skipIncidence = true; |
1025 | QString idS; | 1026 | QString idS; |
1026 | qApp->processEvents(); | 1027 | qApp->processEvents(); |
1027 | if ( !skipIncidence ) { | 1028 | if ( !skipIncidence ) { |
1028 | inL = local->incidence( uid ); | 1029 | inL = local->incidence( uid ); |
1029 | if ( inL ) { // maybe conflict - same uid in both calendars | 1030 | if ( inL ) { // maybe conflict - same uid in both calendars |
1030 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1031 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1031 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1032 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1032 | if ( take == 3 ) | 1033 | if ( take == 3 ) |
1033 | return false; | 1034 | return false; |
1034 | if ( take == 1 ) {// take local ********************** | 1035 | if ( take == 1 ) {// take local ********************** |
1035 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1036 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1036 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1037 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1037 | else | 1038 | else |
1038 | idS = inR->IDStr(); | 1039 | idS = inR->IDStr(); |
1039 | remote->deleteIncidence( inR ); | 1040 | remote->deleteIncidence( inR ); |
1040 | inR = inL->clone(); | 1041 | inR = inL->clone(); |
1041 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1042 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1042 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1043 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1043 | inR->setIDStr( idS ); | 1044 | inR->setIDStr( idS ); |
1044 | remote->addIncidence( inR ); | 1045 | remote->addIncidence( inR ); |
1045 | if ( mSyncManager->syncWithDesktop() ) | 1046 | if ( mSyncManager->syncWithDesktop() ) |
1046 | inR->setPilotId( 2 ); | 1047 | inR->setPilotId( 2 ); |
1047 | ++changedRemote; | 1048 | ++changedRemote; |
1048 | } else {// take remote ********************** | 1049 | } else {// take remote ********************** |
1049 | idS = inL->IDStr(); | 1050 | idS = inL->IDStr(); |
1050 | int pid = inL->pilotId(); | 1051 | int pid = inL->pilotId(); |
1051 | local->deleteIncidence( inL ); | 1052 | local->deleteIncidence( inL ); |
1052 | inL = inR->clone(); | 1053 | inL = inR->clone(); |
1053 | if ( mSyncManager->syncWithDesktop() ) | 1054 | if ( mSyncManager->syncWithDesktop() ) |
1054 | inL->setPilotId( pid ); | 1055 | inL->setPilotId( pid ); |
1055 | inL->setIDStr( idS ); | 1056 | inL->setIDStr( idS ); |
1056 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1057 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1057 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1058 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1058 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1059 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1059 | } | 1060 | } |
1060 | local->addIncidence( inL ); | 1061 | local->addIncidence( inL ); |
1061 | ++changedLocal; | 1062 | ++changedLocal; |
1062 | } | 1063 | } |
1063 | } | 1064 | } |
1064 | } else { // no conflict ********** add or delete remote | 1065 | } else { // no conflict ********** add or delete remote |
1065 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1066 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1066 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1067 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1067 | QString des = eventLSync->description(); | 1068 | QString des = eventLSync->description(); |
1068 | QString pref = "e"; | 1069 | QString pref = "e"; |
1069 | if ( inR->type() == "Todo" ) | 1070 | if ( inR->type() == "Todo" ) |
1070 | pref = "t"; | 1071 | pref = "t"; |
1071 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1072 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1072 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1073 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1073 | //remote->deleteIncidence( inR ); | 1074 | //remote->deleteIncidence( inR ); |
1074 | ++deletedEventR; | 1075 | ++deletedEventR; |
1075 | } else { | 1076 | } else { |
1076 | inR->setLastModified( modifiedCalendar ); | 1077 | inR->setLastModified( modifiedCalendar ); |
1077 | inL = inR->clone(); | 1078 | inL = inR->clone(); |
1078 | inL->setIDStr( ":" ); | 1079 | inL->setIDStr( ":" ); |
1079 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1080 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1080 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1081 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1081 | local->addIncidence( inL ); | 1082 | local->addIncidence( inL ); |
1082 | ++addedEvent; | 1083 | ++addedEvent; |
1083 | 1084 | ||
1084 | } | 1085 | } |
1085 | } else { | 1086 | } else { |
1086 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1087 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1087 | inR->setLastModified( modifiedCalendar ); | 1088 | inR->setLastModified( modifiedCalendar ); |
1088 | inL = inR->clone(); | 1089 | inL = inR->clone(); |
1089 | inL->setIDStr( ":" ); | 1090 | inL->setIDStr( ":" ); |
1090 | local->addIncidence( inL ); | 1091 | local->addIncidence( inL ); |
1091 | ++addedEvent; | 1092 | ++addedEvent; |
1092 | 1093 | ||
1093 | } else { | 1094 | } else { |
1094 | checkExternSyncEvent(eventRSyncSharp, inR); | 1095 | checkExternSyncEvent(eventRSyncSharp, inR); |
1095 | remote->deleteIncidence( inR ); | 1096 | remote->deleteIncidence( inR ); |
1096 | ++deletedEventR; | 1097 | ++deletedEventR; |
1097 | } | 1098 | } |
1098 | } | 1099 | } |
1099 | } else { | 1100 | } else { |
1100 | ++filteredIN; | 1101 | ++filteredIN; |
1101 | } | 1102 | } |
1102 | } | 1103 | } |
1103 | } | 1104 | } |
1104 | inR = er.next(); | 1105 | inR = er.next(); |
1105 | } | 1106 | } |
1106 | QPtrList<Incidence> el = local->rawIncidences(); | 1107 | QPtrList<Incidence> el = local->rawIncidences(); |
1107 | inL = el.first(); | 1108 | inL = el.first(); |
1108 | modulo = (el.count()/10)+1; | 1109 | modulo = (el.count()/10)+1; |
1109 | bar.setCaption (i18n("Add / remove events") ); | 1110 | bar.setCaption (i18n("Add / remove events") ); |
1110 | bar.setTotalSteps ( el.count() ) ; | 1111 | bar.setTotalSteps ( el.count() ) ; |
1111 | bar.show(); | 1112 | bar.show(); |
1112 | incCounter = 0; | 1113 | incCounter = 0; |
1113 | 1114 | ||
1114 | while ( inL ) { | 1115 | while ( inL ) { |
1115 | 1116 | ||
1116 | qApp->processEvents(); | 1117 | qApp->processEvents(); |
1117 | if ( ! bar.isVisible() ) | 1118 | if ( ! bar.isVisible() ) |
1118 | return false; | 1119 | return false; |
1119 | if ( incCounter % modulo == 0 ) | 1120 | if ( incCounter % modulo == 0 ) |
1120 | bar.setProgress( incCounter ); | 1121 | bar.setProgress( incCounter ); |
1121 | ++incCounter; | 1122 | ++incCounter; |
1122 | uid = inL->uid(); | 1123 | uid = inL->uid(); |
1123 | bool skipIncidence = false; | 1124 | bool skipIncidence = false; |
1124 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1125 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1125 | skipIncidence = true; | 1126 | skipIncidence = true; |
1126 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1127 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1127 | skipIncidence = true; | 1128 | skipIncidence = true; |
1128 | if ( !skipIncidence ) { | 1129 | if ( !skipIncidence ) { |
1129 | inR = remote->incidence( uid ); | 1130 | inR = remote->incidence( uid ); |
1130 | if ( ! inR ) { | 1131 | if ( ! inR ) { |
1131 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1132 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1132 | // no conflict ********** add or delete local | 1133 | // no conflict ********** add or delete local |
1133 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1134 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1134 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1135 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1135 | checkExternSyncEvent(eventLSyncSharp, inL); | 1136 | checkExternSyncEvent(eventLSyncSharp, inL); |
1136 | local->deleteIncidence( inL ); | 1137 | local->deleteIncidence( inL ); |
1137 | ++deletedEventL; | 1138 | ++deletedEventL; |
1138 | } else { | 1139 | } else { |
1139 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1140 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1140 | inL->removeID(mCurrentSyncDevice ); | 1141 | inL->removeID(mCurrentSyncDevice ); |
1141 | ++addedEventR; | 1142 | ++addedEventR; |
1142 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1143 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1143 | inL->setLastModified( modifiedCalendar ); | 1144 | inL->setLastModified( modifiedCalendar ); |
1144 | inR = inL->clone(); | 1145 | inR = inL->clone(); |
1145 | inR->setIDStr( ":" ); | 1146 | inR->setIDStr( ":" ); |
1146 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1147 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1147 | remote->addIncidence( inR ); | 1148 | remote->addIncidence( inR ); |
1148 | } | 1149 | } |
1149 | } | 1150 | } |
1150 | } else { | 1151 | } else { |
1151 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1152 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1152 | checkExternSyncEvent(eventLSyncSharp, inL); | 1153 | checkExternSyncEvent(eventLSyncSharp, inL); |
1153 | local->deleteIncidence( inL ); | 1154 | local->deleteIncidence( inL ); |
1154 | ++deletedEventL; | 1155 | ++deletedEventL; |
1155 | } else { | 1156 | } else { |
1156 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1157 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1157 | ++addedEventR; | 1158 | ++addedEventR; |
1158 | inL->setLastModified( modifiedCalendar ); | 1159 | inL->setLastModified( modifiedCalendar ); |
1159 | inR = inL->clone(); | 1160 | inR = inL->clone(); |
1160 | inR->setIDStr( ":" ); | 1161 | inR->setIDStr( ":" ); |
1161 | remote->addIncidence( inR ); | 1162 | remote->addIncidence( inR ); |
1162 | } | 1163 | } |
1163 | } | 1164 | } |
1164 | } | 1165 | } |
1165 | } else { | 1166 | } else { |
1166 | ++filteredOUT; | 1167 | ++filteredOUT; |
1167 | } | 1168 | } |
1168 | } | 1169 | } |
1169 | } | 1170 | } |
1170 | inL = el.next(); | 1171 | inL = el.next(); |
1171 | } | 1172 | } |
1172 | int delFut = 0; | 1173 | int delFut = 0; |
1173 | int remRem = 0; | 1174 | int remRem = 0; |
1174 | if ( mSyncManager->mWriteBackInFuture ) { | 1175 | if ( mSyncManager->mWriteBackInFuture ) { |
1175 | er = remote->rawIncidences(); | 1176 | er = remote->rawIncidences(); |
1176 | remRem = er.count(); | 1177 | remRem = er.count(); |
1177 | inR = er.first(); | 1178 | inR = er.first(); |
1178 | QDateTime dt; | 1179 | QDateTime dt; |
1179 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1180 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1180 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1181 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1181 | while ( inR ) { | 1182 | while ( inR ) { |
1182 | if ( inR->type() == "Todo" ) { | 1183 | if ( inR->type() == "Todo" ) { |
1183 | Todo * t = (Todo*)inR; | 1184 | Todo * t = (Todo*)inR; |
1184 | if ( t->hasDueDate() ) | 1185 | if ( t->hasDueDate() ) |
1185 | dt = t->dtDue(); | 1186 | dt = t->dtDue(); |
1186 | else | 1187 | else |
1187 | dt = cur.addSecs( 62 ); | 1188 | dt = cur.addSecs( 62 ); |
1188 | } | 1189 | } |
1189 | else if (inR->type() == "Event" ) { | 1190 | else if (inR->type() == "Event" ) { |
1190 | bool ok; | 1191 | bool ok; |
1191 | dt = inR->getNextOccurence( cur, &ok ); | 1192 | dt = inR->getNextOccurence( cur, &ok ); |
1192 | if ( !ok ) | 1193 | if ( !ok ) |
1193 | dt = cur.addSecs( -62 ); | 1194 | dt = cur.addSecs( -62 ); |
1194 | } | 1195 | } |
1195 | else | 1196 | else |
1196 | dt = inR->dtStart(); | 1197 | dt = inR->dtStart(); |
1197 | if ( dt < cur || dt > end ) { | 1198 | if ( dt < cur || dt > end ) { |
1198 | remote->deleteIncidence( inR ); | 1199 | remote->deleteIncidence( inR ); |
1199 | ++delFut; | 1200 | ++delFut; |
1200 | } | 1201 | } |
1201 | inR = er.next(); | 1202 | inR = er.next(); |
1202 | } | 1203 | } |
1203 | } | 1204 | } |
1204 | bar.hide(); | 1205 | bar.hide(); |
1205 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1206 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1206 | eventLSync->setReadOnly( false ); | 1207 | eventLSync->setReadOnly( false ); |
1207 | eventLSync->setDtStart( mLastCalendarSync ); | 1208 | eventLSync->setDtStart( mLastCalendarSync ); |
1208 | eventRSync->setDtStart( mLastCalendarSync ); | 1209 | eventRSync->setDtStart( mLastCalendarSync ); |
1209 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1210 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1210 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1211 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1211 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1212 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1212 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1213 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1213 | eventLSync->setReadOnly( true ); | 1214 | eventLSync->setReadOnly( true ); |
1214 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1215 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1215 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1216 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1216 | remote->addEvent( eventRSync ); | 1217 | remote->addEvent( eventRSync ); |
1217 | else | 1218 | else |
1218 | delete eventRSync; | 1219 | delete eventRSync; |
1219 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1220 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1220 | QString mes; | 1221 | QString mes; |
1221 | 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 ); | 1222 | 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 ); |
1222 | QString delmess; | 1223 | QString delmess; |
1223 | if ( delFut ) { | 1224 | if ( delFut ) { |
1224 | 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); | 1225 | 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); |
1225 | mes += delmess; | 1226 | mes += delmess; |
1226 | } | 1227 | } |
1227 | mes = i18n("Local calendar changed!\n") +mes; | 1228 | mes = i18n("Local calendar changed!\n") +mes; |
1228 | mCalendar->checkAlarmForIncidence( 0, true ); | 1229 | mCalendar->checkAlarmForIncidence( 0, true ); |
1229 | qDebug( mes ); | 1230 | qDebug( mes ); |
1230 | if ( mSyncManager->mShowSyncSummary ) { | 1231 | if ( mSyncManager->mShowSyncSummary ) { |
1231 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1232 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1232 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1233 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1233 | qDebug("KO: WB cancelled "); | 1234 | qDebug("KO: WB cancelled "); |
1234 | mSyncManager->mWriteBackFile = false; | 1235 | mSyncManager->mWriteBackFile = false; |
1235 | return syncOK; | 1236 | return syncOK; |
1236 | } | 1237 | } |
1237 | } | 1238 | } |
1238 | return syncOK; | 1239 | return syncOK; |
1239 | } | 1240 | } |
1240 | 1241 | ||
1241 | void CalendarView::setSyncDevice( QString s ) | 1242 | void CalendarView::setSyncDevice( QString s ) |
1242 | { | 1243 | { |
1243 | mCurrentSyncDevice= s; | 1244 | mCurrentSyncDevice= s; |
1244 | } | 1245 | } |
1245 | void CalendarView::setSyncName( QString s ) | 1246 | void CalendarView::setSyncName( QString s ) |
1246 | { | 1247 | { |
1247 | mCurrentSyncName= s; | 1248 | mCurrentSyncName= s; |
1248 | } | 1249 | } |
1249 | bool CalendarView::syncCalendar(QString filename, int mode) | 1250 | bool CalendarView::syncCalendar(QString filename, int mode) |
1250 | { | 1251 | { |
1251 | //qDebug("syncCalendar %s ", filename.latin1()); | 1252 | //qDebug("syncCalendar %s ", filename.latin1()); |
1252 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1253 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1253 | CalendarLocal* calendar = new CalendarLocal(); | 1254 | CalendarLocal* calendar = new CalendarLocal(); |
1254 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1255 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1255 | FileStorage* storage = new FileStorage( calendar ); | 1256 | FileStorage* storage = new FileStorage( calendar ); |
1256 | bool syncOK = false; | 1257 | bool syncOK = false; |
1257 | storage->setFileName( filename ); | 1258 | storage->setFileName( filename ); |
1258 | // qDebug("loading ... "); | 1259 | // qDebug("loading ... "); |
1259 | if ( storage->load() ) { | 1260 | if ( storage->load() ) { |
1260 | getEventViewerDialog()->setSyncMode( true ); | 1261 | getEventViewerDialog()->setSyncMode( true ); |
1261 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1262 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1262 | getEventViewerDialog()->setSyncMode( false ); | 1263 | getEventViewerDialog()->setSyncMode( false ); |
1263 | if ( syncOK ) { | 1264 | if ( syncOK ) { |
1264 | if ( mSyncManager->mWriteBackFile ) | 1265 | if ( mSyncManager->mWriteBackFile ) |
1265 | { | 1266 | { |
1266 | storage->setSaveFormat( new ICalFormat() ); | 1267 | storage->setSaveFormat( new ICalFormat() ); |
1267 | storage->save(); | 1268 | storage->save(); |
1268 | } | 1269 | } |
1269 | } | 1270 | } |
1270 | setModified( true ); | 1271 | setModified( true ); |
1271 | } | 1272 | } |
1272 | delete storage; | 1273 | delete storage; |
1273 | delete calendar; | 1274 | delete calendar; |
1274 | if ( syncOK ) | 1275 | if ( syncOK ) |
1275 | updateView(); | 1276 | updateView(); |
1276 | return syncOK; | 1277 | return syncOK; |
1277 | } | 1278 | } |
1278 | 1279 | ||
1279 | void CalendarView::syncExternal( int mode ) | 1280 | void CalendarView::syncExternal( int mode ) |
1280 | { | 1281 | { |
1281 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1282 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1282 | 1283 | ||
1283 | qApp->processEvents(); | 1284 | qApp->processEvents(); |
1284 | CalendarLocal* calendar = new CalendarLocal(); | 1285 | CalendarLocal* calendar = new CalendarLocal(); |
1285 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1286 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1286 | bool syncOK = false; | 1287 | bool syncOK = false; |
1287 | bool loadSuccess = false; | 1288 | bool loadSuccess = false; |
1288 | PhoneFormat* phoneFormat = 0; | 1289 | PhoneFormat* phoneFormat = 0; |
1289 | emit tempDisableBR(true); | 1290 | emit tempDisableBR(true); |
1290 | #ifndef DESKTOP_VERSION | 1291 | #ifndef DESKTOP_VERSION |
1291 | SharpFormat* sharpFormat = 0; | 1292 | SharpFormat* sharpFormat = 0; |
1292 | if ( mode == 0 ) { // sharp | 1293 | if ( mode == 0 ) { // sharp |
1293 | sharpFormat = new SharpFormat () ; | 1294 | sharpFormat = new SharpFormat () ; |
1294 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1295 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1295 | 1296 | ||
1296 | } else | 1297 | } else |
1297 | #endif | 1298 | #endif |
1298 | if ( mode == 1 ) { // phone | 1299 | if ( mode == 1 ) { // phone |
1299 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1300 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1300 | mSyncManager->mPhoneDevice, | 1301 | mSyncManager->mPhoneDevice, |
1301 | mSyncManager->mPhoneConnection, | 1302 | mSyncManager->mPhoneConnection, |
1302 | mSyncManager->mPhoneModel); | 1303 | mSyncManager->mPhoneModel); |
1303 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1304 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1304 | 1305 | ||
1305 | } else { | 1306 | } else { |
1306 | emit tempDisableBR(false); | 1307 | emit tempDisableBR(false); |
1307 | return; | 1308 | return; |
1308 | } | 1309 | } |
1309 | if ( loadSuccess ) { | 1310 | if ( loadSuccess ) { |
1310 | getEventViewerDialog()->setSyncMode( true ); | 1311 | getEventViewerDialog()->setSyncMode( true ); |
1311 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1312 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1312 | getEventViewerDialog()->setSyncMode( false ); | 1313 | getEventViewerDialog()->setSyncMode( false ); |
1313 | qApp->processEvents(); | 1314 | qApp->processEvents(); |
1314 | if ( syncOK ) { | 1315 | if ( syncOK ) { |
1315 | if ( mSyncManager->mWriteBackFile ) | 1316 | if ( mSyncManager->mWriteBackFile ) |
1316 | { | 1317 | { |
1317 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1318 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1318 | Incidence* inc = iL.first(); | 1319 | Incidence* inc = iL.first(); |
1319 | if ( phoneFormat ) { | 1320 | if ( phoneFormat ) { |
1320 | while ( inc ) { | 1321 | while ( inc ) { |
1321 | inc->removeID(mCurrentSyncDevice); | 1322 | inc->removeID(mCurrentSyncDevice); |
1322 | inc = iL.next(); | 1323 | inc = iL.next(); |
1323 | } | 1324 | } |
1324 | } | 1325 | } |
1325 | #ifndef DESKTOP_VERSION | 1326 | #ifndef DESKTOP_VERSION |
1326 | if ( sharpFormat ) | 1327 | if ( sharpFormat ) |
1327 | sharpFormat->save(calendar); | 1328 | sharpFormat->save(calendar); |
1328 | #endif | 1329 | #endif |
1329 | if ( phoneFormat ) | 1330 | if ( phoneFormat ) |
1330 | phoneFormat->save(calendar); | 1331 | phoneFormat->save(calendar); |
1331 | iL = calendar->rawIncidences(); | 1332 | iL = calendar->rawIncidences(); |
1332 | inc = iL.first(); | 1333 | inc = iL.first(); |
1333 | Incidence* loc; | 1334 | Incidence* loc; |
1334 | while ( inc ) { | 1335 | while ( inc ) { |
1335 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1336 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1336 | loc = mCalendar->incidence(inc->uid() ); | 1337 | loc = mCalendar->incidence(inc->uid() ); |
1337 | if ( loc ) { | 1338 | if ( loc ) { |
1338 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1339 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1339 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1340 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1340 | } | 1341 | } |
1341 | } | 1342 | } |
1342 | inc = iL.next(); | 1343 | inc = iL.next(); |
1343 | } | 1344 | } |
1344 | Incidence* lse = getLastSyncEvent(); | 1345 | Incidence* lse = getLastSyncEvent(); |
1345 | if ( lse ) { | 1346 | if ( lse ) { |
1346 | lse->setReadOnly( false ); | 1347 | lse->setReadOnly( false ); |
1347 | lse->setDescription( "" ); | 1348 | lse->setDescription( "" ); |
1348 | lse->setReadOnly( true ); | 1349 | lse->setReadOnly( true ); |
1349 | } | 1350 | } |
1350 | } | 1351 | } |
1351 | } else { | 1352 | } else { |
1352 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1353 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1353 | } | 1354 | } |
1354 | setModified( true ); | 1355 | setModified( true ); |
1355 | } else { | 1356 | } else { |
1356 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1357 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1357 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1358 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1358 | question, i18n("Ok")) ; | 1359 | question, i18n("Ok")) ; |
1359 | 1360 | ||
1360 | } | 1361 | } |
1361 | delete calendar; | 1362 | delete calendar; |
1362 | updateView(); | 1363 | updateView(); |
1363 | emit tempDisableBR(false); | 1364 | emit tempDisableBR(false); |
1364 | return ;//syncOK; | 1365 | return ;//syncOK; |
1365 | 1366 | ||
1366 | } | 1367 | } |
1367 | 1368 | ||
1368 | bool CalendarView::importBday() | 1369 | bool CalendarView::importBday() |
1369 | { | 1370 | { |
1370 | #ifndef KORG_NOKABC | 1371 | #ifndef KORG_NOKABC |
1371 | 1372 | ||
1372 | #ifdef DESKTOP_VERSION | 1373 | #ifdef DESKTOP_VERSION |
1373 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1374 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1374 | KABC::AddressBook::Iterator it; | 1375 | KABC::AddressBook::Iterator it; |
1375 | int count = 0; | 1376 | int count = 0; |
1376 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1377 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1377 | ++count; | 1378 | ++count; |
1378 | } | 1379 | } |
1379 | QProgressBar bar(count,0 ); | 1380 | QProgressBar bar(count,0 ); |
1380 | int w = 300; | 1381 | int w = 300; |
1381 | if ( QApplication::desktop()->width() < 320 ) | 1382 | if ( QApplication::desktop()->width() < 320 ) |
1382 | w = 220; | 1383 | w = 220; |
1383 | int h = bar.sizeHint().height() ; | 1384 | int h = bar.sizeHint().height() ; |
1384 | int dw = QApplication::desktop()->width(); | 1385 | int dw = QApplication::desktop()->width(); |
1385 | int dh = QApplication::desktop()->height(); | 1386 | int dh = QApplication::desktop()->height(); |
1386 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1387 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1387 | bar.show(); | 1388 | bar.show(); |
1388 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1389 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1389 | qApp->processEvents(); | 1390 | qApp->processEvents(); |
1390 | count = 0; | 1391 | count = 0; |
1391 | int addCount = 0; | 1392 | int addCount = 0; |
1392 | KCal::Attendee* a = 0; | 1393 | KCal::Attendee* a = 0; |
1393 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1394 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1394 | if ( ! bar.isVisible() ) | 1395 | if ( ! bar.isVisible() ) |
1395 | return false; | 1396 | return false; |
1396 | bar.setProgress( count++ ); | 1397 | bar.setProgress( count++ ); |
1397 | qApp->processEvents(); | 1398 | qApp->processEvents(); |
1398 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1399 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1399 | if ( (*it).birthday().date().isValid() ){ | 1400 | if ( (*it).birthday().date().isValid() ){ |
1400 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1401 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1401 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1402 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1402 | ++addCount; | 1403 | ++addCount; |
1403 | } | 1404 | } |
1404 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1405 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1405 | if ( anni.isValid() ){ | 1406 | if ( anni.isValid() ){ |
1406 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1407 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1407 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1408 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1408 | ++addCount; | 1409 | ++addCount; |
1409 | } | 1410 | } |
1410 | } | 1411 | } |
1411 | updateView(); | 1412 | updateView(); |
1412 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1413 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1413 | #else //DESKTOP_VERSION | 1414 | #else //DESKTOP_VERSION |
1414 | 1415 | ||
1415 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1416 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1416 | // the result should now arrive through method insertBirthdays | 1417 | // the result should now arrive through method insertBirthdays |
1417 | 1418 | ||
1418 | #endif //DESKTOP_VERSION | 1419 | #endif //DESKTOP_VERSION |
1419 | 1420 | ||
1420 | #endif //KORG_NOKABC | 1421 | #endif //KORG_NOKABC |
1421 | 1422 | ||
1422 | 1423 | ||
1423 | return true; | 1424 | return true; |
1424 | } | 1425 | } |
1425 | 1426 | ||
1426 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1427 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1427 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1428 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1428 | const QStringList& anniversaryList, const QStringList& realNameList, | 1429 | const QStringList& anniversaryList, const QStringList& realNameList, |
1429 | const QStringList& emailList, const QStringList& assembledNameList, | 1430 | const QStringList& emailList, const QStringList& assembledNameList, |
1430 | const QStringList& uidList) | 1431 | const QStringList& uidList) |
1431 | { | 1432 | { |
1432 | //qDebug("KO::CalendarView::insertBirthdays"); | 1433 | //qDebug("KO::CalendarView::insertBirthdays"); |
1433 | if (uid == this->name()) | 1434 | if (uid == this->name()) |
1434 | { | 1435 | { |
1435 | int count = birthdayList.count(); | 1436 | int count = birthdayList.count(); |
1436 | int addCount = 0; | 1437 | int addCount = 0; |
1437 | KCal::Attendee* a = 0; | 1438 | KCal::Attendee* a = 0; |
1438 | 1439 | ||
1439 | //qDebug("CalView 1 %i", count); | 1440 | //qDebug("CalView 1 %i", count); |
1440 | 1441 | ||
1441 | QProgressBar bar(count,0 ); | 1442 | QProgressBar bar(count,0 ); |
1442 | int w = 300; | 1443 | int w = 300; |
1443 | if ( QApplication::desktop()->width() < 320 ) | 1444 | if ( QApplication::desktop()->width() < 320 ) |
1444 | w = 220; | 1445 | w = 220; |
1445 | int h = bar.sizeHint().height() ; | 1446 | int h = bar.sizeHint().height() ; |
1446 | int dw = QApplication::desktop()->width(); | 1447 | int dw = QApplication::desktop()->width(); |
1447 | int dh = QApplication::desktop()->height(); | 1448 | int dh = QApplication::desktop()->height(); |
1448 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1449 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1449 | bar.show(); | 1450 | bar.show(); |
1450 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1451 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1451 | qApp->processEvents(); | 1452 | qApp->processEvents(); |
1452 | 1453 | ||
1453 | QDate birthday; | 1454 | QDate birthday; |
1454 | QDate anniversary; | 1455 | QDate anniversary; |
1455 | QString realName; | 1456 | QString realName; |
1456 | QString email; | 1457 | QString email; |
1457 | QString assembledName; | 1458 | QString assembledName; |
1458 | QString uid; | 1459 | QString uid; |
1459 | bool ok = true; | 1460 | bool ok = true; |
1460 | for ( int i = 0; i < count; i++) | 1461 | for ( int i = 0; i < count; i++) |
1461 | { | 1462 | { |
1462 | if ( ! bar.isVisible() ) | 1463 | if ( ! bar.isVisible() ) |
1463 | return; | 1464 | return; |
1464 | bar.setProgress( i ); | 1465 | bar.setProgress( i ); |
1465 | qApp->processEvents(); | 1466 | qApp->processEvents(); |
1466 | 1467 | ||
1467 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1468 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1468 | if (!ok) { | 1469 | if (!ok) { |
1469 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1470 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1470 | } | 1471 | } |
1471 | 1472 | ||
1472 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1473 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1473 | if (!ok) { | 1474 | if (!ok) { |
1474 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1475 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1475 | } | 1476 | } |
1476 | realName = realNameList[i]; | 1477 | realName = realNameList[i]; |
1477 | email = emailList[i]; | 1478 | email = emailList[i]; |
1478 | assembledName = assembledNameList[i]; | 1479 | assembledName = assembledNameList[i]; |
1479 | uid = uidList[i]; | 1480 | uid = uidList[i]; |
1480 | //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() ); | 1481 | //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() ); |
1481 | 1482 | ||
1482 | if ( birthday.isValid() ){ | 1483 | if ( birthday.isValid() ){ |
1483 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1484 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1484 | KCal::Attendee::ReqParticipant,uid) ; | 1485 | KCal::Attendee::ReqParticipant,uid) ; |
1485 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1486 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1486 | ++addCount; | 1487 | ++addCount; |
1487 | } | 1488 | } |
1488 | 1489 | ||
1489 | if ( anniversary.isValid() ){ | 1490 | if ( anniversary.isValid() ){ |
1490 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1491 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1491 | KCal::Attendee::ReqParticipant,uid) ; | 1492 | KCal::Attendee::ReqParticipant,uid) ; |
1492 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1493 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1493 | ++addCount; | 1494 | ++addCount; |
1494 | } | 1495 | } |
1495 | } | 1496 | } |
1496 | 1497 | ||
1497 | updateView(); | 1498 | updateView(); |
1498 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1499 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1499 | 1500 | ||
1500 | } | 1501 | } |
1501 | 1502 | ||
1502 | } | 1503 | } |
1503 | 1504 | ||
1504 | 1505 | ||
1505 | 1506 | ||
1506 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1507 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1507 | { | 1508 | { |
1508 | //qDebug("addAnni "); | 1509 | //qDebug("addAnni "); |
1509 | Event * ev = new Event(); | 1510 | Event * ev = new Event(); |
1510 | ev->setOrganizer(KOPrefs::instance()->email()); | 1511 | ev->setOrganizer(KOPrefs::instance()->email()); |
1511 | if ( a ) { | 1512 | if ( a ) { |
1512 | ev->addAttendee( a ); | 1513 | ev->addAttendee( a ); |
1513 | } | 1514 | } |
1514 | QString kind; | 1515 | QString kind; |
1515 | if ( birthday ) { | 1516 | if ( birthday ) { |
1516 | kind = i18n( "Birthday" ); | 1517 | kind = i18n( "Birthday" ); |
1517 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1518 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1518 | } | 1519 | } |
1519 | else { | 1520 | else { |
1520 | kind = i18n( "Anniversary" ); | 1521 | kind = i18n( "Anniversary" ); |
1521 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1522 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1522 | } | 1523 | } |
1523 | ev->setCategories( kind ); | 1524 | ev->setCategories( kind ); |
1524 | ev->setDtStart( QDateTime(date) ); | 1525 | ev->setDtStart( QDateTime(date) ); |
1525 | ev->setDtEnd( QDateTime(date) ); | 1526 | ev->setDtEnd( QDateTime(date) ); |
1526 | ev->setFloats( true ); | 1527 | ev->setFloats( true ); |
1527 | Recurrence * rec = ev->recurrence(); | 1528 | Recurrence * rec = ev->recurrence(); |
1528 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1529 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1529 | rec->addYearlyNum( date.month() ); | 1530 | rec->addYearlyNum( date.month() ); |
1530 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1531 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1531 | delete ev; | 1532 | delete ev; |
1532 | return false; | 1533 | return false; |
1533 | } | 1534 | } |
1534 | return true; | 1535 | return true; |
1535 | 1536 | ||
1536 | } | 1537 | } |
1537 | bool CalendarView::importQtopia( const QString &categories, | 1538 | bool CalendarView::importQtopia( const QString &categories, |
1538 | const QString &datebook, | 1539 | const QString &datebook, |
1539 | const QString &todolist ) | 1540 | const QString &todolist ) |
1540 | { | 1541 | { |
1541 | 1542 | ||
1542 | QtopiaFormat qtopiaFormat; | 1543 | QtopiaFormat qtopiaFormat; |
1543 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1544 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1544 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1545 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1545 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1546 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1546 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1547 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1547 | 1548 | ||
1548 | updateView(); | 1549 | updateView(); |
1549 | return true; | 1550 | return true; |
1550 | 1551 | ||
1551 | #if 0 | 1552 | #if 0 |
1552 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1553 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1553 | mCurrentSyncDevice = "qtopia-XML"; | 1554 | mCurrentSyncDevice = "qtopia-XML"; |
1554 | if ( mSyncManager->mAskForPreferences ) | 1555 | if ( mSyncManager->mAskForPreferences ) |
1555 | edit_sync_options(); | 1556 | edit_sync_options(); |
1556 | qApp->processEvents(); | 1557 | qApp->processEvents(); |
1557 | CalendarLocal* calendar = new CalendarLocal(); | 1558 | CalendarLocal* calendar = new CalendarLocal(); |
1558 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1559 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1559 | bool syncOK = false; | 1560 | bool syncOK = false; |
1560 | QtopiaFormat qtopiaFormat; | 1561 | QtopiaFormat qtopiaFormat; |
1561 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1562 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1562 | bool loadOk = true; | 1563 | bool loadOk = true; |
1563 | if ( !categories.isEmpty() ) | 1564 | if ( !categories.isEmpty() ) |
1564 | loadOk = qtopiaFormat.load( calendar, categories ); | 1565 | loadOk = qtopiaFormat.load( calendar, categories ); |
1565 | if ( loadOk && !datebook.isEmpty() ) | 1566 | if ( loadOk && !datebook.isEmpty() ) |
1566 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1567 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1567 | if ( loadOk && !todolist.isEmpty() ) | 1568 | if ( loadOk && !todolist.isEmpty() ) |
1568 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1569 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1569 | 1570 | ||
1570 | if ( loadOk ) { | 1571 | if ( loadOk ) { |
1571 | getEventViewerDialog()->setSyncMode( true ); | 1572 | getEventViewerDialog()->setSyncMode( true ); |
1572 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1573 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1573 | getEventViewerDialog()->setSyncMode( false ); | 1574 | getEventViewerDialog()->setSyncMode( false ); |
1574 | qApp->processEvents(); | 1575 | qApp->processEvents(); |
1575 | if ( syncOK ) { | 1576 | if ( syncOK ) { |
1576 | if ( mSyncManager->mWriteBackFile ) | 1577 | if ( mSyncManager->mWriteBackFile ) |
1577 | { | 1578 | { |
1578 | // write back XML file | 1579 | // write back XML file |
1579 | 1580 | ||
1580 | } | 1581 | } |
1581 | setModified( true ); | 1582 | setModified( true ); |
1582 | } | 1583 | } |
1583 | } else { | 1584 | } else { |
1584 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1585 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1585 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1586 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1586 | question, i18n("Ok")) ; | 1587 | question, i18n("Ok")) ; |
1587 | } | 1588 | } |
1588 | delete calendar; | 1589 | delete calendar; |
1589 | updateView(); | 1590 | updateView(); |
1590 | return syncOK; | 1591 | return syncOK; |
1591 | 1592 | ||
1592 | 1593 | ||
1593 | #endif | 1594 | #endif |
1594 | 1595 | ||
1595 | } | 1596 | } |
1596 | 1597 | ||
1597 | void CalendarView::setSyncEventsReadOnly() | 1598 | void CalendarView::setSyncEventsReadOnly() |
1598 | { | 1599 | { |
1599 | Event * ev; | 1600 | Event * ev; |
1600 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1601 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1601 | ev = eL.first(); | 1602 | ev = eL.first(); |
1602 | while ( ev ) { | 1603 | while ( ev ) { |
1603 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1604 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1604 | ev->setReadOnly( true ); | 1605 | ev->setReadOnly( true ); |
1605 | ev = eL.next(); | 1606 | ev = eL.next(); |
1606 | } | 1607 | } |
1607 | } | 1608 | } |
1608 | bool CalendarView::openCalendar(QString filename, bool merge) | 1609 | bool CalendarView::openCalendar(QString filename, bool merge) |
1609 | { | 1610 | { |
1610 | 1611 | ||
1611 | if (filename.isEmpty()) { | 1612 | if (filename.isEmpty()) { |
1612 | return false; | 1613 | return false; |
1613 | } | 1614 | } |
1614 | 1615 | ||
1615 | if (!QFile::exists(filename)) { | 1616 | if (!QFile::exists(filename)) { |
1616 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1617 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1617 | return false; | 1618 | return false; |
1618 | } | 1619 | } |
1619 | 1620 | ||
1620 | globalFlagBlockAgenda = 1; | 1621 | globalFlagBlockAgenda = 1; |
1621 | if (!merge) mCalendar->close(); | 1622 | if (!merge) mCalendar->close(); |
1622 | 1623 | ||
1623 | mStorage->setFileName( filename ); | 1624 | mStorage->setFileName( filename ); |
1624 | 1625 | ||
1625 | if ( mStorage->load() ) { | 1626 | if ( mStorage->load() ) { |
1626 | if ( merge ) ;//setModified( true ); | 1627 | if ( merge ) ;//setModified( true ); |
1627 | else { | 1628 | else { |
1628 | //setModified( true ); | 1629 | //setModified( true ); |
1629 | mViewManager->setDocumentId( filename ); | 1630 | mViewManager->setDocumentId( filename ); |
1630 | mDialogManager->setDocumentId( filename ); | 1631 | mDialogManager->setDocumentId( filename ); |
1631 | mTodoList->setDocumentId( filename ); | 1632 | mTodoList->setDocumentId( filename ); |
1632 | } | 1633 | } |
1633 | globalFlagBlockAgenda = 2; | 1634 | globalFlagBlockAgenda = 2; |
1634 | // if ( getLastSyncEvent() ) | 1635 | // if ( getLastSyncEvent() ) |
1635 | // getLastSyncEvent()->setReadOnly( true ); | 1636 | // getLastSyncEvent()->setReadOnly( true ); |
1636 | mCalendar->reInitAlarmSettings(); | 1637 | mCalendar->reInitAlarmSettings(); |
1637 | setSyncEventsReadOnly(); | 1638 | setSyncEventsReadOnly(); |
1638 | updateUnmanagedViews(); | 1639 | updateUnmanagedViews(); |
1639 | updateView(); | 1640 | updateView(); |
1640 | if ( filename != MainWindow::defaultFileName() ) { | 1641 | if ( filename != MainWindow::defaultFileName() ) { |
1641 | saveCalendar( MainWindow::defaultFileName() ); | 1642 | saveCalendar( MainWindow::defaultFileName() ); |
1642 | } else { | 1643 | } else { |
1643 | QFileInfo finf ( MainWindow::defaultFileName()); | 1644 | QFileInfo finf ( MainWindow::defaultFileName()); |
1644 | if ( finf.exists() ) { | 1645 | if ( finf.exists() ) { |
1645 | setLoadedFileVersion( finf.lastModified () ); | 1646 | setLoadedFileVersion( finf.lastModified () ); |
1646 | } | 1647 | } |
1647 | } | 1648 | } |
1648 | return true; | 1649 | return true; |
1649 | } else { | 1650 | } else { |
1650 | // while failing to load, the calendar object could | 1651 | // while failing to load, the calendar object could |
1651 | // have become partially populated. Clear it out. | 1652 | // have become partially populated. Clear it out. |
1652 | if ( !merge ) { | 1653 | if ( !merge ) { |
1653 | mCalendar->close(); | 1654 | mCalendar->close(); |
1654 | mViewManager->setDocumentId( filename ); | 1655 | mViewManager->setDocumentId( filename ); |
1655 | mDialogManager->setDocumentId( filename ); | 1656 | mDialogManager->setDocumentId( filename ); |
1656 | mTodoList->setDocumentId( filename ); | 1657 | mTodoList->setDocumentId( filename ); |
1657 | } | 1658 | } |
1658 | 1659 | ||
1659 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1660 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1660 | 1661 | ||
1661 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1662 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1662 | globalFlagBlockAgenda = 2; | 1663 | globalFlagBlockAgenda = 2; |
1663 | mCalendar->reInitAlarmSettings(); | 1664 | mCalendar->reInitAlarmSettings(); |
1664 | setSyncEventsReadOnly(); | 1665 | setSyncEventsReadOnly(); |
1665 | updateUnmanagedViews(); | 1666 | updateUnmanagedViews(); |
1666 | updateView(); | 1667 | updateView(); |
1667 | } | 1668 | } |
1668 | return false; | 1669 | return false; |
1669 | } | 1670 | } |
1670 | void CalendarView::showOpenError() | 1671 | void CalendarView::showOpenError() |
1671 | { | 1672 | { |
1672 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1673 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1673 | } | 1674 | } |
1674 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1675 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1675 | { | 1676 | { |
1676 | loadedFileVersion = dt; | 1677 | loadedFileVersion = dt; |
1677 | } | 1678 | } |
1678 | bool CalendarView::checkFileChanged(QString fn) | 1679 | bool CalendarView::checkFileChanged(QString fn) |
1679 | { | 1680 | { |
1680 | QFileInfo finf ( fn ); | 1681 | QFileInfo finf ( fn ); |
1681 | if ( !finf.exists() ) | 1682 | if ( !finf.exists() ) |
1682 | return true; | 1683 | return true; |
1683 | QDateTime dt = finf.lastModified (); | 1684 | QDateTime dt = finf.lastModified (); |
1684 | if ( dt <= loadedFileVersion ) | 1685 | if ( dt <= loadedFileVersion ) |
1685 | return false; | 1686 | return false; |
1686 | return true; | 1687 | return true; |
1687 | 1688 | ||
1688 | } | 1689 | } |
1689 | void CalendarView::watchSavedFile() | 1690 | void CalendarView::watchSavedFile() |
1690 | { | 1691 | { |
1691 | QFileInfo finf ( MainWindow::defaultFileName()); | 1692 | QFileInfo finf ( MainWindow::defaultFileName()); |
1692 | if ( !finf.exists() ) | 1693 | if ( !finf.exists() ) |
1693 | return; | 1694 | return; |
1694 | QDateTime dt = finf.lastModified (); | 1695 | QDateTime dt = finf.lastModified (); |
1695 | if ( dt < loadedFileVersion ) { | 1696 | if ( dt < loadedFileVersion ) { |
1696 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1697 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1697 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1698 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1698 | return; | 1699 | return; |
1699 | } | 1700 | } |
1700 | loadedFileVersion = dt; | 1701 | loadedFileVersion = dt; |
1701 | } | 1702 | } |
1702 | 1703 | ||
1703 | bool CalendarView::checkFileVersion(QString fn) | 1704 | bool CalendarView::checkFileVersion(QString fn) |
1704 | { | 1705 | { |
1705 | QFileInfo finf ( fn ); | 1706 | QFileInfo finf ( fn ); |
1706 | if ( !finf.exists() ) | 1707 | if ( !finf.exists() ) |
1707 | return true; | 1708 | return true; |
1708 | QDateTime dt = finf.lastModified (); | 1709 | QDateTime dt = finf.lastModified (); |
1709 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1710 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1710 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1711 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1711 | if ( dt <= loadedFileVersion ) | 1712 | if ( dt <= loadedFileVersion ) |
1712 | return true; | 1713 | return true; |
1713 | 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)) , | 1714 | 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)) , |
1714 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1715 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1715 | i18n("Sync+save")); | 1716 | i18n("Sync+save")); |
1716 | 1717 | ||
1717 | if ( km == KMessageBox::Cancel ) | 1718 | if ( km == KMessageBox::Cancel ) |
1718 | return false; | 1719 | return false; |
1719 | if ( km == KMessageBox::Yes ) | 1720 | if ( km == KMessageBox::Yes ) |
1720 | return true; | 1721 | return true; |
1721 | 1722 | ||
1722 | setSyncDevice("deleteaftersync" ); | 1723 | setSyncDevice("deleteaftersync" ); |
1723 | mSyncManager->mAskForPreferences = true; | 1724 | mSyncManager->mAskForPreferences = true; |
1724 | mSyncManager->mSyncAlgoPrefs = 3; | 1725 | mSyncManager->mSyncAlgoPrefs = 3; |
1725 | mSyncManager->mWriteBackFile = false; | 1726 | mSyncManager->mWriteBackFile = false; |
1726 | mSyncManager->mWriteBackExistingOnly = false; | 1727 | mSyncManager->mWriteBackExistingOnly = false; |
1727 | mSyncManager->mShowSyncSummary = false; | 1728 | mSyncManager->mShowSyncSummary = false; |
1728 | syncCalendar( fn, 3 ); | 1729 | syncCalendar( fn, 3 ); |
1729 | Event * e = getLastSyncEvent(); | 1730 | Event * e = getLastSyncEvent(); |
1730 | mCalendar->deleteEvent ( e ); | 1731 | mCalendar->deleteEvent ( e ); |
1731 | updateView(); | 1732 | updateView(); |
1732 | return true; | 1733 | return true; |
1733 | } | 1734 | } |
1734 | 1735 | ||
1735 | bool CalendarView::saveCalendar( QString filename ) | 1736 | bool CalendarView::saveCalendar( QString filename ) |
1736 | { | 1737 | { |
1737 | 1738 | ||
1738 | // Store back all unsaved data into calendar object | 1739 | // Store back all unsaved data into calendar object |
1739 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1740 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1740 | if ( mViewManager->currentView() ) | 1741 | if ( mViewManager->currentView() ) |
1741 | mViewManager->currentView()->flushView(); | 1742 | mViewManager->currentView()->flushView(); |
1742 | 1743 | ||
1743 | 1744 | ||
1744 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1745 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1745 | mStorage->setSaveFormat( new ICalFormat() ); | 1746 | mStorage->setSaveFormat( new ICalFormat() ); |
1746 | mStorage->setFileName( filename ); | 1747 | mStorage->setFileName( filename ); |
1747 | bool success; | 1748 | bool success; |
1748 | success = mStorage->save(); | 1749 | success = mStorage->save(); |
1749 | if ( !success ) { | 1750 | if ( !success ) { |
1750 | return false; | 1751 | return false; |
1751 | } | 1752 | } |
1752 | if ( filename == MainWindow::defaultFileName() ) { | 1753 | if ( filename == MainWindow::defaultFileName() ) { |
1753 | setLoadedFileVersion( lfv ); | 1754 | setLoadedFileVersion( lfv ); |
1754 | watchSavedFile(); | 1755 | watchSavedFile(); |
1755 | } | 1756 | } |
1756 | return true; | 1757 | return true; |
1757 | } | 1758 | } |
1758 | 1759 | ||
1759 | void CalendarView::closeCalendar() | 1760 | void CalendarView::closeCalendar() |
1760 | { | 1761 | { |
1761 | 1762 | ||
1762 | // child windows no longer valid | 1763 | // child windows no longer valid |
1763 | emit closingDown(); | 1764 | emit closingDown(); |
1764 | 1765 | ||
1765 | mCalendar->close(); | 1766 | mCalendar->close(); |
1766 | setModified(false); | 1767 | setModified(false); |
1767 | updateView(); | 1768 | updateView(); |
1768 | } | 1769 | } |
1769 | 1770 | ||
1770 | void CalendarView::archiveCalendar() | 1771 | void CalendarView::archiveCalendar() |
1771 | { | 1772 | { |
1772 | mDialogManager->showArchiveDialog(); | 1773 | mDialogManager->showArchiveDialog(); |
1773 | } | 1774 | } |
1774 | 1775 | ||
1775 | 1776 | ||
1776 | void CalendarView::readSettings() | 1777 | void CalendarView::readSettings() |
1777 | { | 1778 | { |
1778 | 1779 | ||
1779 | 1780 | ||
1780 | // mViewManager->showAgendaView(); | 1781 | // mViewManager->showAgendaView(); |
1781 | QString str; | 1782 | QString str; |
1782 | //qDebug("CalendarView::readSettings() "); | 1783 | //qDebug("CalendarView::readSettings() "); |
1783 | // read settings from the KConfig, supplying reasonable | 1784 | // read settings from the KConfig, supplying reasonable |
1784 | // defaults where none are to be found | 1785 | // defaults where none are to be found |
1785 | KConfig *config = KOGlobals::config(); | 1786 | KConfig *config = KOGlobals::config(); |
1786 | #ifndef KORG_NOSPLITTER | 1787 | #ifndef KORG_NOSPLITTER |
1787 | config->setGroup("KOrganizer Geometry"); | 1788 | config->setGroup("KOrganizer Geometry"); |
1788 | 1789 | ||
1789 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1790 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1790 | if (sizes.count() != 2) { | 1791 | if (sizes.count() != 2) { |
1791 | sizes << mDateNavigator->minimumSizeHint().width(); | 1792 | sizes << mDateNavigator->minimumSizeHint().width(); |
1792 | sizes << 300; | 1793 | sizes << 300; |
1793 | } | 1794 | } |
1794 | mPanner->setSizes(sizes); | 1795 | mPanner->setSizes(sizes); |
1795 | 1796 | ||
1796 | sizes = config->readIntListEntry("Separator2"); | 1797 | sizes = config->readIntListEntry("Separator2"); |
1797 | if ( ( mResourceView && sizes.count() == 4 ) || | 1798 | if ( ( mResourceView && sizes.count() == 4 ) || |
1798 | ( !mResourceView && sizes.count() == 3 ) ) { | 1799 | ( !mResourceView && sizes.count() == 3 ) ) { |
1799 | mLeftSplitter->setSizes(sizes); | 1800 | mLeftSplitter->setSizes(sizes); |
1800 | } | 1801 | } |
1801 | #endif | 1802 | #endif |
1802 | globalFlagBlockAgenda = 1; | 1803 | globalFlagBlockAgenda = 1; |
1803 | mViewManager->showAgendaView(); | 1804 | mViewManager->showAgendaView(); |
1804 | //mViewManager->readSettings( config ); | 1805 | //mViewManager->readSettings( config ); |
1805 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1806 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1806 | readFilterSettings(config); | 1807 | readFilterSettings(config); |
1807 | config->setGroup( "Views" ); | 1808 | config->setGroup( "Views" ); |
1808 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1809 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1809 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1810 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1810 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1811 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1811 | else mNavigator->selectDates( dateCount ); | 1812 | else mNavigator->selectDates( dateCount ); |
1812 | // mViewManager->readSettings( config ); | 1813 | // mViewManager->readSettings( config ); |
1813 | updateConfig(); | 1814 | updateConfig(); |
1814 | globalFlagBlockAgenda = 2; | 1815 | globalFlagBlockAgenda = 2; |
1815 | mViewManager->readSettings( config ); | 1816 | mViewManager->readSettings( config ); |
1816 | #ifdef DESKTOP_VERSION | 1817 | #ifdef DESKTOP_VERSION |
1817 | config->setGroup("WidgetLayout"); | 1818 | config->setGroup("WidgetLayout"); |
1818 | QStringList list; | 1819 | QStringList list; |
1819 | list = config->readListEntry("MainLayout"); | 1820 | list = config->readListEntry("MainLayout"); |
1820 | int x,y,w,h; | 1821 | int x,y,w,h; |
1821 | if ( ! list.isEmpty() ) { | 1822 | if ( ! list.isEmpty() ) { |
1822 | x = list[0].toInt(); | 1823 | x = list[0].toInt(); |
1823 | y = list[1].toInt(); | 1824 | y = list[1].toInt(); |
1824 | w = list[2].toInt(); | 1825 | w = list[2].toInt(); |
1825 | h = list[3].toInt(); | 1826 | h = list[3].toInt(); |
1826 | topLevelWidget()->setGeometry(x,y,w,h); | 1827 | topLevelWidget()->setGeometry(x,y,w,h); |
1827 | 1828 | ||
1828 | } else { | 1829 | } else { |
1829 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1830 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1830 | } | 1831 | } |
1831 | list = config->readListEntry("EditEventLayout"); | 1832 | list = config->readListEntry("EditEventLayout"); |
1832 | if ( ! list.isEmpty() ) { | 1833 | if ( ! list.isEmpty() ) { |
1833 | x = list[0].toInt(); | 1834 | x = list[0].toInt(); |
1834 | y = list[1].toInt(); | 1835 | y = list[1].toInt(); |
1835 | w = list[2].toInt(); | 1836 | w = list[2].toInt(); |
1836 | h = list[3].toInt(); | 1837 | h = list[3].toInt(); |
1837 | mEventEditor->setGeometry(x,y,w,h); | 1838 | mEventEditor->setGeometry(x,y,w,h); |
1838 | 1839 | ||
1839 | } | 1840 | } |
1840 | list = config->readListEntry("EditTodoLayout"); | 1841 | list = config->readListEntry("EditTodoLayout"); |
1841 | if ( ! list.isEmpty() ) { | 1842 | if ( ! list.isEmpty() ) { |
1842 | x = list[0].toInt(); | 1843 | x = list[0].toInt(); |
1843 | y = list[1].toInt(); | 1844 | y = list[1].toInt(); |
1844 | w = list[2].toInt(); | 1845 | w = list[2].toInt(); |
1845 | h = list[3].toInt(); | 1846 | h = list[3].toInt(); |
1846 | mTodoEditor->setGeometry(x,y,w,h); | 1847 | mTodoEditor->setGeometry(x,y,w,h); |
1847 | 1848 | ||
1848 | } | 1849 | } |
1849 | list = config->readListEntry("ViewerLayout"); | 1850 | list = config->readListEntry("ViewerLayout"); |
1850 | if ( ! list.isEmpty() ) { | 1851 | if ( ! list.isEmpty() ) { |
1851 | x = list[0].toInt(); | 1852 | x = list[0].toInt(); |
1852 | y = list[1].toInt(); | 1853 | y = list[1].toInt(); |
1853 | w = list[2].toInt(); | 1854 | w = list[2].toInt(); |
1854 | h = list[3].toInt(); | 1855 | h = list[3].toInt(); |
1855 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1856 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1856 | } | 1857 | } |
1857 | #endif | 1858 | #endif |
1858 | 1859 | ||
1859 | } | 1860 | } |
1860 | 1861 | ||
1861 | 1862 | ||
1862 | void CalendarView::writeSettings() | 1863 | void CalendarView::writeSettings() |
1863 | { | 1864 | { |
1864 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1865 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1865 | 1866 | ||
1866 | KConfig *config = KOGlobals::config(); | 1867 | KConfig *config = KOGlobals::config(); |
1867 | 1868 | ||
1868 | #ifndef KORG_NOSPLITTER | 1869 | #ifndef KORG_NOSPLITTER |
1869 | config->setGroup("KOrganizer Geometry"); | 1870 | config->setGroup("KOrganizer Geometry"); |
1870 | 1871 | ||
1871 | QValueList<int> list = mPanner->sizes(); | 1872 | QValueList<int> list = mPanner->sizes(); |
1872 | config->writeEntry("Separator1",list); | 1873 | config->writeEntry("Separator1",list); |
1873 | 1874 | ||
1874 | list = mLeftSplitter->sizes(); | 1875 | list = mLeftSplitter->sizes(); |
1875 | config->writeEntry("Separator2",list); | 1876 | config->writeEntry("Separator2",list); |
1876 | #endif | 1877 | #endif |
1877 | 1878 | ||
1878 | mViewManager->writeSettings( config ); | 1879 | mViewManager->writeSettings( config ); |
1879 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1880 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1880 | mDialogManager->writeSettings( config ); | 1881 | mDialogManager->writeSettings( config ); |
1881 | //KOPrefs::instance()->usrWriteConfig(); | 1882 | //KOPrefs::instance()->usrWriteConfig(); |
1882 | KOPrefs::instance()->writeConfig(); | 1883 | KOPrefs::instance()->writeConfig(); |
1883 | 1884 | ||
1884 | writeFilterSettings(config); | 1885 | writeFilterSettings(config); |
1885 | 1886 | ||
1886 | config->setGroup( "Views" ); | 1887 | config->setGroup( "Views" ); |
1887 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1888 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1888 | 1889 | ||
1889 | #ifdef DESKTOP_VERSION | 1890 | #ifdef DESKTOP_VERSION |
1890 | config->setGroup("WidgetLayout"); | 1891 | config->setGroup("WidgetLayout"); |
1891 | QStringList list ;//= config->readListEntry("MainLayout"); | 1892 | QStringList list ;//= config->readListEntry("MainLayout"); |
1892 | int x,y,w,h; | 1893 | int x,y,w,h; |
1893 | QWidget* wid; | 1894 | QWidget* wid; |
1894 | wid = topLevelWidget(); | 1895 | wid = topLevelWidget(); |
1895 | x = wid->geometry().x(); | 1896 | x = wid->geometry().x(); |
1896 | y = wid->geometry().y(); | 1897 | y = wid->geometry().y(); |
1897 | w = wid->width(); | 1898 | w = wid->width(); |
1898 | h = wid->height(); | 1899 | h = wid->height(); |
1899 | list.clear(); | 1900 | list.clear(); |
1900 | list << QString::number( x ); | 1901 | list << QString::number( x ); |
1901 | list << QString::number( y ); | 1902 | list << QString::number( y ); |
1902 | list << QString::number( w ); | 1903 | list << QString::number( w ); |
1903 | list << QString::number( h ); | 1904 | list << QString::number( h ); |
1904 | config->writeEntry("MainLayout",list ); | 1905 | config->writeEntry("MainLayout",list ); |
1905 | 1906 | ||
1906 | wid = mEventEditor; | 1907 | wid = mEventEditor; |
1907 | x = wid->geometry().x(); | 1908 | x = wid->geometry().x(); |
1908 | y = wid->geometry().y(); | 1909 | y = wid->geometry().y(); |
1909 | w = wid->width(); | 1910 | w = wid->width(); |
1910 | h = wid->height(); | 1911 | h = wid->height(); |
1911 | list.clear(); | 1912 | list.clear(); |
1912 | list << QString::number( x ); | 1913 | list << QString::number( x ); |
1913 | list << QString::number( y ); | 1914 | list << QString::number( y ); |
1914 | list << QString::number( w ); | 1915 | list << QString::number( w ); |
1915 | list << QString::number( h ); | 1916 | list << QString::number( h ); |
1916 | config->writeEntry("EditEventLayout",list ); | 1917 | config->writeEntry("EditEventLayout",list ); |
1917 | 1918 | ||
1918 | wid = mTodoEditor; | 1919 | wid = mTodoEditor; |
1919 | x = wid->geometry().x(); | 1920 | x = wid->geometry().x(); |
1920 | y = wid->geometry().y(); | 1921 | y = wid->geometry().y(); |
1921 | w = wid->width(); | 1922 | w = wid->width(); |
1922 | h = wid->height(); | 1923 | h = wid->height(); |
1923 | list.clear(); | 1924 | list.clear(); |
1924 | list << QString::number( x ); | 1925 | list << QString::number( x ); |
1925 | list << QString::number( y ); | 1926 | list << QString::number( y ); |
1926 | list << QString::number( w ); | 1927 | list << QString::number( w ); |
1927 | list << QString::number( h ); | 1928 | list << QString::number( h ); |
1928 | config->writeEntry("EditTodoLayout",list ); | 1929 | config->writeEntry("EditTodoLayout",list ); |
1929 | wid = getEventViewerDialog(); | 1930 | wid = getEventViewerDialog(); |
1930 | x = wid->geometry().x(); | 1931 | x = wid->geometry().x(); |
1931 | y = wid->geometry().y(); | 1932 | y = wid->geometry().y(); |
1932 | w = wid->width(); | 1933 | w = wid->width(); |
1933 | h = wid->height(); | 1934 | h = wid->height(); |
1934 | list.clear(); | 1935 | list.clear(); |
1935 | list << QString::number( x ); | 1936 | list << QString::number( x ); |
1936 | list << QString::number( y ); | 1937 | list << QString::number( y ); |
1937 | list << QString::number( w ); | 1938 | list << QString::number( w ); |
1938 | list << QString::number( h ); | 1939 | list << QString::number( h ); |
1939 | config->writeEntry("ViewerLayout",list ); | 1940 | config->writeEntry("ViewerLayout",list ); |
1940 | wid = mDialogManager->getSearchDialog(); | 1941 | wid = mDialogManager->getSearchDialog(); |
1941 | if ( wid ) { | 1942 | if ( wid ) { |
1942 | x = wid->geometry().x(); | 1943 | x = wid->geometry().x(); |
1943 | y = wid->geometry().y(); | 1944 | y = wid->geometry().y(); |
1944 | w = wid->width(); | 1945 | w = wid->width(); |
1945 | h = wid->height(); | 1946 | h = wid->height(); |
1946 | list.clear(); | 1947 | list.clear(); |
1947 | list << QString::number( x ); | 1948 | list << QString::number( x ); |
1948 | list << QString::number( y ); | 1949 | list << QString::number( y ); |
1949 | list << QString::number( w ); | 1950 | list << QString::number( w ); |
1950 | list << QString::number( h ); | 1951 | list << QString::number( h ); |
1951 | config->writeEntry("SearchLayout",list ); | 1952 | config->writeEntry("SearchLayout",list ); |
1952 | } | 1953 | } |
1953 | #endif | 1954 | #endif |
1954 | 1955 | ||
1955 | 1956 | ||
1956 | config->sync(); | 1957 | config->sync(); |
1957 | } | 1958 | } |
1958 | 1959 | ||
1959 | void CalendarView::readFilterSettings(KConfig *config) | 1960 | void CalendarView::readFilterSettings(KConfig *config) |
1960 | { | 1961 | { |
1961 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1962 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1962 | 1963 | ||
1963 | mFilters.clear(); | 1964 | mFilters.clear(); |
1964 | 1965 | ||
1965 | config->setGroup("General"); | 1966 | config->setGroup("General"); |
1966 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1967 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1967 | 1968 | ||
1968 | QStringList::ConstIterator it = filterList.begin(); | 1969 | QStringList::ConstIterator it = filterList.begin(); |
1969 | QStringList::ConstIterator end = filterList.end(); | 1970 | QStringList::ConstIterator end = filterList.end(); |
1970 | while(it != end) { | 1971 | while(it != end) { |
1971 | // kdDebug() << " filter: " << (*it) << endl; | 1972 | // kdDebug() << " filter: " << (*it) << endl; |
1972 | 1973 | ||
1973 | CalFilter *filter; | 1974 | CalFilter *filter; |
1974 | filter = new CalFilter(*it); | 1975 | filter = new CalFilter(*it); |
1975 | config->setGroup("Filter_" + (*it)); | 1976 | config->setGroup("Filter_" + (*it)); |
1976 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1977 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1977 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1978 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1978 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1979 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1979 | mFilters.append(filter); | 1980 | mFilters.append(filter); |
1980 | 1981 | ||
1981 | ++it; | 1982 | ++it; |
1982 | } | 1983 | } |
1983 | 1984 | ||
1984 | if (mFilters.count() == 0) { | 1985 | if (mFilters.count() == 0) { |
1985 | CalFilter *filter = new CalFilter(i18n("Default")); | 1986 | CalFilter *filter = new CalFilter(i18n("Default")); |
1986 | mFilters.append(filter); | 1987 | mFilters.append(filter); |
1987 | } | 1988 | } |
1988 | mFilterView->updateFilters(); | 1989 | mFilterView->updateFilters(); |
1989 | config->setGroup("FilterView"); | 1990 | config->setGroup("FilterView"); |
1990 | 1991 | ||
1991 | mFilterView->blockSignals(true); | 1992 | mFilterView->blockSignals(true); |
1992 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1993 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1993 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1994 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1994 | mFilterView->blockSignals(false); | 1995 | mFilterView->blockSignals(false); |
1995 | // We do it manually to avoid it being done twice by the above calls | 1996 | // We do it manually to avoid it being done twice by the above calls |
1996 | updateFilter(); | 1997 | updateFilter(); |
1997 | } | 1998 | } |
1998 | 1999 | ||
1999 | void CalendarView::writeFilterSettings(KConfig *config) | 2000 | void CalendarView::writeFilterSettings(KConfig *config) |
2000 | { | 2001 | { |
2001 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2002 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2002 | 2003 | ||
2003 | QStringList filterList; | 2004 | QStringList filterList; |
2004 | 2005 | ||
2005 | CalFilter *filter = mFilters.first(); | 2006 | CalFilter *filter = mFilters.first(); |
2006 | while(filter) { | 2007 | while(filter) { |
2007 | // kdDebug() << " fn: " << filter->name() << endl; | 2008 | // kdDebug() << " fn: " << filter->name() << endl; |
2008 | filterList << filter->name(); | 2009 | filterList << filter->name(); |
2009 | config->setGroup("Filter_" + filter->name()); | 2010 | config->setGroup("Filter_" + filter->name()); |
2010 | config->writeEntry("Criteria",filter->criteria()); | 2011 | config->writeEntry("Criteria",filter->criteria()); |
2011 | config->writeEntry("CategoryList",filter->categoryList()); | 2012 | config->writeEntry("CategoryList",filter->categoryList()); |
2012 | filter = mFilters.next(); | 2013 | filter = mFilters.next(); |
2013 | } | 2014 | } |
2014 | config->setGroup("General"); | 2015 | config->setGroup("General"); |
2015 | config->writeEntry("CalendarFilters",filterList); | 2016 | config->writeEntry("CalendarFilters",filterList); |
2016 | 2017 | ||
2017 | config->setGroup("FilterView"); | 2018 | config->setGroup("FilterView"); |
2018 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2019 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2019 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2020 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2020 | } | 2021 | } |
2021 | 2022 | ||
2022 | 2023 | ||
2023 | void CalendarView::goToday() | 2024 | void CalendarView::goToday() |
2024 | { | 2025 | { |
2025 | if ( mViewManager->currentView()->isMonthView() ) | 2026 | if ( mViewManager->currentView()->isMonthView() ) |
2026 | mNavigator->selectTodayMonth(); | 2027 | mNavigator->selectTodayMonth(); |
2027 | else | 2028 | else |
2028 | mNavigator->selectToday(); | 2029 | mNavigator->selectToday(); |
2029 | } | 2030 | } |
2030 | 2031 | ||
2031 | void CalendarView::goNext() | 2032 | void CalendarView::goNext() |
2032 | { | 2033 | { |
2033 | mNavigator->selectNext(); | 2034 | mNavigator->selectNext(); |
2034 | } | 2035 | } |
2035 | 2036 | ||
2036 | void CalendarView::goPrevious() | 2037 | void CalendarView::goPrevious() |
2037 | { | 2038 | { |
2038 | mNavigator->selectPrevious(); | 2039 | mNavigator->selectPrevious(); |
2039 | } | 2040 | } |
2040 | void CalendarView::goNextMonth() | 2041 | void CalendarView::goNextMonth() |
2041 | { | 2042 | { |
2042 | mNavigator->selectNextMonth(); | 2043 | mNavigator->selectNextMonth(); |
2043 | } | 2044 | } |
2044 | 2045 | ||
2045 | void CalendarView::goPreviousMonth() | 2046 | void CalendarView::goPreviousMonth() |
2046 | { | 2047 | { |
2047 | mNavigator->selectPreviousMonth(); | 2048 | mNavigator->selectPreviousMonth(); |
2048 | } | 2049 | } |
2049 | void CalendarView::writeLocale() | 2050 | void CalendarView::writeLocale() |
2050 | { | 2051 | { |
2051 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2052 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2052 | #if 0 | 2053 | #if 0 |
2053 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2054 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2054 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2055 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2055 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2056 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2056 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2057 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2057 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2058 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2058 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2059 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2059 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2060 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2060 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2061 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2061 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2062 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2062 | KOPrefs::instance()->mDaylightsavingStart, | 2063 | KOPrefs::instance()->mDaylightsavingStart, |
2063 | KOPrefs::instance()->mDaylightsavingEnd ); | 2064 | KOPrefs::instance()->mDaylightsavingEnd ); |
2064 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2065 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2065 | #endif | 2066 | #endif |
2066 | } | 2067 | } |
2067 | void CalendarView::updateConfig() | 2068 | void CalendarView::updateConfig() |
2068 | { | 2069 | { |
2069 | writeLocale(); | 2070 | writeLocale(); |
2070 | if ( KOPrefs::instance()->mUseAppColors ) | 2071 | if ( KOPrefs::instance()->mUseAppColors ) |
2071 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2072 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2072 | emit configChanged(); | 2073 | emit configChanged(); |
2073 | mTodoList->updateConfig(); | 2074 | mTodoList->updateConfig(); |
2074 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2075 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2075 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2076 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2076 | // To make the "fill window" configurations work | 2077 | // To make the "fill window" configurations work |
2077 | //mViewManager->raiseCurrentView(); | 2078 | //mViewManager->raiseCurrentView(); |
2078 | } | 2079 | } |
2079 | 2080 | ||
2080 | 2081 | ||
2081 | void CalendarView::eventChanged(Event *event) | 2082 | void CalendarView::eventChanged(Event *event) |
2082 | { | 2083 | { |
2083 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2084 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2084 | //updateUnmanagedViews(); | 2085 | //updateUnmanagedViews(); |
2085 | } | 2086 | } |
2086 | 2087 | ||
2087 | void CalendarView::eventAdded(Event *event) | 2088 | void CalendarView::eventAdded(Event *event) |
2088 | { | 2089 | { |
2089 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2090 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2090 | } | 2091 | } |
2091 | 2092 | ||
2092 | void CalendarView::eventToBeDeleted(Event *) | 2093 | void CalendarView::eventToBeDeleted(Event *) |
2093 | { | 2094 | { |
2094 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2095 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2095 | } | 2096 | } |
2096 | 2097 | ||
2097 | void CalendarView::eventDeleted() | 2098 | void CalendarView::eventDeleted() |
2098 | { | 2099 | { |
2099 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2100 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2100 | } | 2101 | } |
2101 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2102 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2102 | { | 2103 | { |
2103 | changeIncidenceDisplay((Incidence *)which, action); | 2104 | changeIncidenceDisplay((Incidence *)which, action); |
2104 | mDateNavigator->updateView(); //LR | 2105 | mDateNavigator->updateView(); //LR |
2105 | //mDialogManager->updateSearchDialog(); | 2106 | //mDialogManager->updateSearchDialog(); |
2106 | 2107 | ||
2107 | if (which) { | 2108 | if (which) { |
2108 | mViewManager->updateWNview(); | 2109 | mViewManager->updateWNview(); |
2109 | //mTodoList->updateView(); | 2110 | //mTodoList->updateView(); |
2110 | } | 2111 | } |
2111 | 2112 | ||
2112 | } | 2113 | } |
2113 | 2114 | ||
2114 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2115 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2115 | { | 2116 | { |
2116 | updateUnmanagedViews(); | 2117 | updateUnmanagedViews(); |
2117 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2118 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2118 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2119 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2119 | mCalendar->checkAlarmForIncidence( 0, true ); | 2120 | mCalendar->checkAlarmForIncidence( 0, true ); |
2120 | if ( mEventViewerDialog ) | 2121 | if ( mEventViewerDialog ) |
2121 | mEventViewerDialog->hide(); | 2122 | mEventViewerDialog->hide(); |
2122 | } | 2123 | } |
2123 | else | 2124 | else |
2124 | mCalendar->checkAlarmForIncidence( which , false ); | 2125 | mCalendar->checkAlarmForIncidence( which , false ); |
2125 | } | 2126 | } |
2126 | 2127 | ||
2127 | // most of the changeEventDisplays() right now just call the view's | 2128 | // most of the changeEventDisplays() right now just call the view's |
2128 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2129 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2129 | void CalendarView::changeEventDisplay(Event *which, int action) | 2130 | void CalendarView::changeEventDisplay(Event *which, int action) |
2130 | { | 2131 | { |
2131 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2132 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2132 | changeIncidenceDisplay((Incidence *)which, action); | 2133 | changeIncidenceDisplay((Incidence *)which, action); |
2133 | mDateNavigator->updateView(); | 2134 | mDateNavigator->updateView(); |
2134 | //mDialogManager->updateSearchDialog(); | 2135 | //mDialogManager->updateSearchDialog(); |
2135 | 2136 | ||
2136 | if (which) { | 2137 | if (which) { |
2137 | // If there is an event view visible update the display | 2138 | // If there is an event view visible update the display |
2138 | mViewManager->currentView()->changeEventDisplay(which,action); | 2139 | mViewManager->currentView()->changeEventDisplay(which,action); |
2139 | // TODO: check, if update needed | 2140 | // TODO: check, if update needed |
2140 | // if (which->getTodoStatus()) { | 2141 | // if (which->getTodoStatus()) { |
2141 | mTodoList->updateView(); | 2142 | mTodoList->updateView(); |
2142 | // } | 2143 | // } |
2143 | } else { | 2144 | } else { |
2144 | mViewManager->currentView()->updateView(); | 2145 | mViewManager->currentView()->updateView(); |
2145 | } | 2146 | } |
2146 | } | 2147 | } |
2147 | 2148 | ||
2148 | 2149 | ||
2149 | void CalendarView::updateTodoViews() | 2150 | void CalendarView::updateTodoViews() |
2150 | { | 2151 | { |
2151 | mTodoList->updateView(); | 2152 | mTodoList->updateView(); |
2152 | mViewManager->currentView()->updateView(); | 2153 | mViewManager->currentView()->updateView(); |
2153 | 2154 | ||
2154 | } | 2155 | } |
2155 | 2156 | ||
2156 | 2157 | ||
2157 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2158 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2158 | { | 2159 | { |
2159 | mTodoList->updateView(); | 2160 | mTodoList->updateView(); |
2160 | mViewManager->updateView(start, end); | 2161 | mViewManager->updateView(start, end); |
2161 | //mDateNavigator->updateView(); | 2162 | //mDateNavigator->updateView(); |
2162 | } | 2163 | } |
2163 | 2164 | ||
2164 | void CalendarView::updateView() | 2165 | void CalendarView::updateView() |
2165 | { | 2166 | { |
2166 | DateList tmpList = mNavigator->selectedDates(); | 2167 | DateList tmpList = mNavigator->selectedDates(); |
2167 | 2168 | ||
2168 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2169 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2169 | mTodoList->updateView(); | 2170 | mTodoList->updateView(); |
2170 | // We assume that the navigator only selects consecutive days. | 2171 | // We assume that the navigator only selects consecutive days. |
2171 | updateView( tmpList.first(), tmpList.last() ); | 2172 | updateView( tmpList.first(), tmpList.last() ); |
2172 | } | 2173 | } |
2173 | 2174 | ||
2174 | void CalendarView::updateUnmanagedViews() | 2175 | void CalendarView::updateUnmanagedViews() |
2175 | { | 2176 | { |
2176 | mDateNavigator->updateDayMatrix(); | 2177 | mDateNavigator->updateDayMatrix(); |
2177 | } | 2178 | } |
2178 | 2179 | ||
2179 | int CalendarView::msgItemDelete(const QString name) | 2180 | int CalendarView::msgItemDelete(const QString name) |
2180 | { | 2181 | { |
2181 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2182 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2182 | i18n("This item will be\npermanently deleted."), | 2183 | i18n("This item will be\npermanently deleted."), |
2183 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2184 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2184 | } | 2185 | } |
2185 | 2186 | ||
2186 | 2187 | ||
2187 | void CalendarView::edit_cut() | 2188 | void CalendarView::edit_cut() |
2188 | { | 2189 | { |
2189 | Event *anEvent=0; | 2190 | Event *anEvent=0; |
2190 | 2191 | ||
2191 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2192 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2192 | 2193 | ||
2193 | if (mViewManager->currentView()->isEventView()) { | 2194 | if (mViewManager->currentView()->isEventView()) { |
2194 | if ( incidence && incidence->type() == "Event" ) { | 2195 | if ( incidence && incidence->type() == "Event" ) { |
2195 | anEvent = static_cast<Event *>(incidence); | 2196 | anEvent = static_cast<Event *>(incidence); |
2196 | } | 2197 | } |
2197 | } | 2198 | } |
2198 | 2199 | ||
2199 | if (!anEvent) { | 2200 | if (!anEvent) { |
2200 | KNotifyClient::beep(); | 2201 | KNotifyClient::beep(); |
2201 | return; | 2202 | return; |
2202 | } | 2203 | } |
2203 | DndFactory factory( mCalendar ); | 2204 | DndFactory factory( mCalendar ); |
2204 | factory.cutIncidence(anEvent); | 2205 | factory.cutIncidence(anEvent); |
2205 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2206 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2206 | } | 2207 | } |
2207 | 2208 | ||
2208 | void CalendarView::edit_copy() | 2209 | void CalendarView::edit_copy() |
2209 | { | 2210 | { |
2210 | Event *anEvent=0; | 2211 | Event *anEvent=0; |
2211 | 2212 | ||
2212 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2213 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2213 | 2214 | ||
2214 | if (mViewManager->currentView()->isEventView()) { | 2215 | if (mViewManager->currentView()->isEventView()) { |
2215 | if ( incidence && incidence->type() == "Event" ) { | 2216 | if ( incidence && incidence->type() == "Event" ) { |
2216 | anEvent = static_cast<Event *>(incidence); | 2217 | anEvent = static_cast<Event *>(incidence); |
2217 | } | 2218 | } |
2218 | } | 2219 | } |
2219 | 2220 | ||
2220 | if (!anEvent) { | 2221 | if (!anEvent) { |
2221 | KNotifyClient::beep(); | 2222 | KNotifyClient::beep(); |
2222 | return; | 2223 | return; |
2223 | } | 2224 | } |
2224 | DndFactory factory( mCalendar ); | 2225 | DndFactory factory( mCalendar ); |
2225 | factory.copyIncidence(anEvent); | 2226 | factory.copyIncidence(anEvent); |
2226 | } | 2227 | } |
2227 | 2228 | ||
2228 | void CalendarView::edit_paste() | 2229 | void CalendarView::edit_paste() |
2229 | { | 2230 | { |
2230 | QDate date = mNavigator->selectedDates().first(); | 2231 | QDate date = mNavigator->selectedDates().first(); |
2231 | 2232 | ||
2232 | DndFactory factory( mCalendar ); | 2233 | DndFactory factory( mCalendar ); |
2233 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2234 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2234 | 2235 | ||
2235 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2236 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2236 | } | 2237 | } |
2237 | 2238 | ||
2238 | void CalendarView::edit_options() | 2239 | void CalendarView::edit_options() |
2239 | { | 2240 | { |
2240 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2241 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2241 | emit save(); | 2242 | emit save(); |
2242 | emit saveStopTimer(); | 2243 | emit saveStopTimer(); |
2243 | mDialogManager->showOptionsDialog(); | 2244 | mDialogManager->showOptionsDialog(); |
2244 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2245 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2245 | emit saveStopTimer(); | 2246 | emit saveStopTimer(); |
2246 | 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!"), | 2247 | 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!"), |
2247 | i18n("Timezone settings"),i18n("Reload"))) { | 2248 | i18n("Timezone settings"),i18n("Reload"))) { |
2248 | qDebug("KO: TZ reload cancelled "); | 2249 | qDebug("KO: TZ reload cancelled "); |
2249 | return; | 2250 | return; |
2250 | } | 2251 | } |
2251 | qDebug("KO: Timezone change "); | 2252 | qDebug("KO: Timezone change "); |
2252 | openCalendar( MainWindow::defaultFileName() ); | 2253 | openCalendar( MainWindow::defaultFileName() ); |
2253 | setModified(true); | 2254 | setModified(true); |
2254 | } | 2255 | } |
2255 | else | 2256 | else |
2256 | qDebug("KO: No tz change "); | 2257 | qDebug("KO: No tz change "); |
2257 | 2258 | ||
2258 | } | 2259 | } |
2259 | 2260 | ||
2260 | 2261 | ||
2261 | void CalendarView::slotSelectPickerDate( QDate d) | 2262 | void CalendarView::slotSelectPickerDate( QDate d) |
2262 | { | 2263 | { |
2263 | mDateFrame->hide(); | 2264 | mDateFrame->hide(); |
2264 | if ( mDatePickerMode == 1 ) { | 2265 | if ( mDatePickerMode == 1 ) { |
2265 | mNavigator->slotDaySelect( d ); | 2266 | mNavigator->slotDaySelect( d ); |
2266 | } else if ( mDatePickerMode == 2 ) { | 2267 | } else if ( mDatePickerMode == 2 ) { |
2267 | if ( mMoveIncidence->type() == "Todo" ) { | 2268 | if ( mMoveIncidence->type() == "Todo" ) { |
2268 | Todo * to = (Todo *) mMoveIncidence; | 2269 | Todo * to = (Todo *) mMoveIncidence; |
2269 | QTime tim; | 2270 | QTime tim; |
2270 | int len = 0; | 2271 | int len = 0; |
2271 | if ( to->hasStartDate() && to->hasDueDate() ) | 2272 | if ( to->hasStartDate() && to->hasDueDate() ) |
2272 | len = to->dtStart().secsTo( to->dtDue()); | 2273 | len = to->dtStart().secsTo( to->dtDue()); |
2273 | if ( to->hasDueDate() ) | 2274 | if ( to->hasDueDate() ) |
2274 | tim = to->dtDue().time(); | 2275 | tim = to->dtDue().time(); |
2275 | else { | 2276 | else { |
2276 | tim = QTime ( 0,0,0 ); | 2277 | tim = QTime ( 0,0,0 ); |
2277 | to->setFloats( true ); | 2278 | to->setFloats( true ); |
2278 | to->setHasDueDate( true ); | 2279 | to->setHasDueDate( true ); |
2279 | } | 2280 | } |
2280 | QDateTime dt ( d,tim ); | 2281 | QDateTime dt ( d,tim ); |
2281 | to->setDtDue( dt ); | 2282 | to->setDtDue( dt ); |
2282 | 2283 | ||
2283 | if ( to->hasStartDate() ) { | 2284 | if ( to->hasStartDate() ) { |
2284 | if ( len>0 ) | 2285 | if ( len>0 ) |
2285 | to->setDtStart(to->dtDue().addSecs( -len )); | 2286 | to->setDtStart(to->dtDue().addSecs( -len )); |
2286 | else | 2287 | else |
2287 | if (to->dtStart() > to->dtDue() ) | 2288 | if (to->dtStart() > to->dtDue() ) |
2288 | to->setDtStart(to->dtDue().addDays( -3 )); | 2289 | to->setDtStart(to->dtDue().addDays( -3 )); |
2289 | } | 2290 | } |
2290 | 2291 | ||
2291 | todoChanged( to ); | 2292 | todoChanged( to ); |
2292 | } else { | 2293 | } else { |
2293 | if ( mMoveIncidence->doesRecur() ) { | 2294 | if ( mMoveIncidence->doesRecur() ) { |
2294 | #if 0 | 2295 | #if 0 |
2295 | // PENDING implement this | 2296 | // PENDING implement this |
2296 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2297 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2297 | mCalendar()->addIncidence( newInc ); | 2298 | mCalendar()->addIncidence( newInc ); |
2298 | if ( mMoveIncidence->type() == "Todo" ) | 2299 | if ( mMoveIncidence->type() == "Todo" ) |
2299 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2300 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2300 | else | 2301 | else |
2301 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2302 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2302 | mMoveIncidence = newInc; | 2303 | mMoveIncidence = newInc; |
2303 | 2304 | ||
2304 | #endif | 2305 | #endif |
2305 | } | 2306 | } |
2306 | QTime tim = mMoveIncidence->dtStart().time(); | 2307 | QTime tim = mMoveIncidence->dtStart().time(); |
2307 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2308 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2308 | QDateTime dt ( d,tim ); | 2309 | QDateTime dt ( d,tim ); |
2309 | mMoveIncidence->setDtStart( dt ); | 2310 | mMoveIncidence->setDtStart( dt ); |
2310 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2311 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2311 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2312 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2312 | } | 2313 | } |
2313 | 2314 | ||
2314 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2315 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2315 | } | 2316 | } |
2316 | } | 2317 | } |
2317 | 2318 | ||
2318 | void CalendarView::removeCategories() | 2319 | void CalendarView::removeCategories() |
2319 | { | 2320 | { |
2320 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2321 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2321 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2322 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2322 | QStringList catIncList; | 2323 | QStringList catIncList; |
2323 | QStringList newCatList; | 2324 | QStringList newCatList; |
2324 | Incidence* inc = incList.first(); | 2325 | Incidence* inc = incList.first(); |
2325 | int i; | 2326 | int i; |
2326 | int count = 0; | 2327 | int count = 0; |
2327 | while ( inc ) { | 2328 | while ( inc ) { |
2328 | newCatList.clear(); | 2329 | newCatList.clear(); |
2329 | catIncList = inc->categories() ; | 2330 | catIncList = inc->categories() ; |
2330 | for( i = 0; i< catIncList.count(); ++i ) { | 2331 | for( i = 0; i< catIncList.count(); ++i ) { |
2331 | if ( catList.contains (catIncList[i])) | 2332 | if ( catList.contains (catIncList[i])) |
2332 | newCatList.append( catIncList[i] ); | 2333 | newCatList.append( catIncList[i] ); |
2333 | } | 2334 | } |
2334 | newCatList.sort(); | 2335 | newCatList.sort(); |
2335 | inc->setCategories( newCatList.join(",") ); | 2336 | inc->setCategories( newCatList.join(",") ); |
2336 | inc = incList.next(); | 2337 | inc = incList.next(); |
2337 | } | 2338 | } |
2338 | } | 2339 | } |
2339 | 2340 | ||
2340 | int CalendarView::addCategories() | 2341 | int CalendarView::addCategories() |
2341 | { | 2342 | { |
2342 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2343 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2343 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2344 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2344 | QStringList catIncList; | 2345 | QStringList catIncList; |
2345 | Incidence* inc = incList.first(); | 2346 | Incidence* inc = incList.first(); |
2346 | int i; | 2347 | int i; |
2347 | int count = 0; | 2348 | int count = 0; |
2348 | while ( inc ) { | 2349 | while ( inc ) { |
2349 | catIncList = inc->categories() ; | 2350 | catIncList = inc->categories() ; |
2350 | for( i = 0; i< catIncList.count(); ++i ) { | 2351 | for( i = 0; i< catIncList.count(); ++i ) { |
2351 | if ( !catList.contains (catIncList[i])) { | 2352 | if ( !catList.contains (catIncList[i])) { |
2352 | catList.append( catIncList[i] ); | 2353 | catList.append( catIncList[i] ); |
2353 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2354 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2354 | ++count; | 2355 | ++count; |
2355 | } | 2356 | } |
2356 | } | 2357 | } |
2357 | inc = incList.next(); | 2358 | inc = incList.next(); |
2358 | } | 2359 | } |
2359 | catList.sort(); | 2360 | catList.sort(); |
2360 | KOPrefs::instance()->mCustomCategories = catList; | 2361 | KOPrefs::instance()->mCustomCategories = catList; |
2361 | return count; | 2362 | return count; |
2362 | } | 2363 | } |
2363 | 2364 | ||
2364 | void CalendarView::manageCategories() | 2365 | void CalendarView::manageCategories() |
2365 | { | 2366 | { |
2366 | KOCatPrefs* cp = new KOCatPrefs(); | 2367 | KOCatPrefs* cp = new KOCatPrefs(); |
2367 | cp->show(); | 2368 | cp->show(); |
2368 | int w =cp->sizeHint().width() ; | 2369 | int w =cp->sizeHint().width() ; |
2369 | int h = cp->sizeHint().height() ; | 2370 | int h = cp->sizeHint().height() ; |
2370 | int dw = QApplication::desktop()->width(); | 2371 | int dw = QApplication::desktop()->width(); |
2371 | int dh = QApplication::desktop()->height(); | 2372 | int dh = QApplication::desktop()->height(); |
2372 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2373 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2373 | if ( !cp->exec() ) { | 2374 | if ( !cp->exec() ) { |
2374 | delete cp; | 2375 | delete cp; |
2375 | return; | 2376 | return; |
2376 | } | 2377 | } |
2377 | int count = 0; | 2378 | int count = 0; |
2378 | if ( cp->addCat() ) { | 2379 | if ( cp->addCat() ) { |
2379 | count = addCategories(); | 2380 | count = addCategories(); |
2380 | if ( count ) { | 2381 | if ( count ) { |
2381 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2382 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2382 | writeSettings(); | 2383 | writeSettings(); |
2383 | } else | 2384 | } else |
2384 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2385 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2385 | } else { | 2386 | } else { |
2386 | removeCategories(); | 2387 | removeCategories(); |
2387 | updateView(); | 2388 | updateView(); |
2388 | } | 2389 | } |
2389 | delete cp; | 2390 | delete cp; |
2390 | } | 2391 | } |
2391 | 2392 | ||
2392 | void CalendarView::beamIncidence(Incidence * Inc) | 2393 | void CalendarView::beamIncidence(Incidence * Inc) |
2393 | { | 2394 | { |
2394 | QPtrList<Incidence> delSel ; | 2395 | QPtrList<Incidence> delSel ; |
2395 | delSel.append(Inc); | 2396 | delSel.append(Inc); |
2396 | beamIncidenceList( delSel ); | 2397 | beamIncidenceList( delSel ); |
2397 | } | 2398 | } |
2398 | void CalendarView::beamCalendar() | 2399 | void CalendarView::beamCalendar() |
2399 | { | 2400 | { |
2400 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2401 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2401 | //qDebug("beamCalendar() "); | 2402 | //qDebug("beamCalendar() "); |
2402 | beamIncidenceList( delSel ); | 2403 | beamIncidenceList( delSel ); |
2403 | } | 2404 | } |
2404 | void CalendarView::beamFilteredCalendar() | 2405 | void CalendarView::beamFilteredCalendar() |
2405 | { | 2406 | { |
2406 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2407 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2407 | //qDebug("beamFilteredCalendar() "); | 2408 | //qDebug("beamFilteredCalendar() "); |
2408 | beamIncidenceList( delSel ); | 2409 | beamIncidenceList( delSel ); |
2409 | } | 2410 | } |
2410 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2411 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2411 | { | 2412 | { |
2412 | if ( beamDialog->exec () == QDialog::Rejected ) | 2413 | if ( beamDialog->exec () == QDialog::Rejected ) |
2413 | return; | 2414 | return; |
2414 | #ifdef DESKTOP_VERSION | 2415 | #ifdef DESKTOP_VERSION |
2415 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2416 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2416 | #else | 2417 | #else |
2417 | QString fn = "/tmp/kopibeamfile"; | 2418 | QString fn = "/tmp/kopibeamfile"; |
2418 | #endif | 2419 | #endif |
2419 | QString mes; | 2420 | QString mes; |
2420 | bool createbup = true; | 2421 | bool createbup = true; |
2421 | if ( createbup ) { | 2422 | if ( createbup ) { |
2422 | QString description = "\n"; | 2423 | QString description = "\n"; |
2423 | CalendarLocal* cal = new CalendarLocal(); | 2424 | CalendarLocal* cal = new CalendarLocal(); |
2424 | if ( beamDialog->beamLocal() ) | 2425 | if ( beamDialog->beamLocal() ) |
2425 | cal->setLocalTime(); | 2426 | cal->setLocalTime(); |
2426 | else | 2427 | else |
2427 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2428 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2428 | Incidence *incidence = delSel.first(); | 2429 | Incidence *incidence = delSel.first(); |
2429 | bool addText = false; | 2430 | bool addText = false; |
2430 | if ( delSel.count() < 10 ) | 2431 | if ( delSel.count() < 10 ) |
2431 | addText = true; | 2432 | addText = true; |
2432 | else { | 2433 | else { |
2433 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2434 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2434 | } | 2435 | } |
2435 | while ( incidence ) { | 2436 | while ( incidence ) { |
2436 | Incidence *in = incidence->clone(); | 2437 | Incidence *in = incidence->clone(); |
2437 | if ( ! in->summary().isEmpty() ) { | 2438 | if ( ! in->summary().isEmpty() ) { |
2438 | in->setDescription(""); | 2439 | in->setDescription(""); |
2439 | } else { | 2440 | } else { |
2440 | in->setSummary( in->description().left(20)); | 2441 | in->setSummary( in->description().left(20)); |
2441 | in->setDescription(""); | 2442 | in->setDescription(""); |
2442 | } | 2443 | } |
2443 | if ( addText ) | 2444 | if ( addText ) |
2444 | description += in->summary() + "\n"; | 2445 | description += in->summary() + "\n"; |
2445 | cal->addIncidence( in ); | 2446 | cal->addIncidence( in ); |
2446 | incidence = delSel.next(); | 2447 | incidence = delSel.next(); |
2447 | } | 2448 | } |
2448 | if ( beamDialog->beamVcal() ) { | 2449 | if ( beamDialog->beamVcal() ) { |
2449 | fn += ".vcs"; | 2450 | fn += ".vcs"; |
2450 | FileStorage storage( cal, fn, new VCalFormat ); | 2451 | FileStorage storage( cal, fn, new VCalFormat ); |
2451 | storage.save(); | 2452 | storage.save(); |
2452 | } else { | 2453 | } else { |
2453 | fn += ".ics"; | 2454 | fn += ".ics"; |
2454 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2455 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2455 | storage.save(); | 2456 | storage.save(); |
2456 | } | 2457 | } |
2457 | delete cal; | 2458 | delete cal; |
2458 | mes = i18n("KO/Pi: Ready for beaming"); | 2459 | mes = i18n("KO/Pi: Ready for beaming"); |
2459 | topLevelWidget()->setCaption(mes); | 2460 | topLevelWidget()->setCaption(mes); |
2460 | KApplication::convert2latin1( fn ); | 2461 | KApplication::convert2latin1( fn ); |
2461 | #ifndef DESKTOP_VERSION | 2462 | #ifndef DESKTOP_VERSION |
2462 | Ir *ir = new Ir( this ); | 2463 | Ir *ir = new Ir( this ); |
2463 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2464 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2464 | ir->send( fn, description, "text/x-vCalendar" ); | 2465 | ir->send( fn, description, "text/x-vCalendar" ); |
2465 | #endif | 2466 | #endif |
2466 | } | 2467 | } |
2467 | } | 2468 | } |
2468 | void CalendarView::beamDone( Ir *ir ) | 2469 | void CalendarView::beamDone( Ir *ir ) |
2469 | { | 2470 | { |
2470 | #ifndef DESKTOP_VERSION | 2471 | #ifndef DESKTOP_VERSION |
2471 | delete ir; | 2472 | delete ir; |
2472 | #endif | 2473 | #endif |
2473 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2474 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2474 | topLevelWidget()->raise(); | 2475 | topLevelWidget()->raise(); |
2475 | } | 2476 | } |
2476 | 2477 | ||
2477 | void CalendarView::moveIncidence(Incidence * inc ) | 2478 | void CalendarView::moveIncidence(Incidence * inc ) |
2478 | { | 2479 | { |
2479 | if ( !inc ) return; | 2480 | if ( !inc ) return; |
2480 | showDatePickerPopup(); | 2481 | showDatePickerPopup(); |
2481 | mDatePickerMode = 2; | 2482 | mDatePickerMode = 2; |
2482 | mMoveIncidence = inc ; | 2483 | mMoveIncidence = inc ; |
2483 | QDate da; | 2484 | QDate da; |
2484 | if ( mMoveIncidence->type() == "Todo" ) { | 2485 | if ( mMoveIncidence->type() == "Todo" ) { |
2485 | Todo * to = (Todo *) mMoveIncidence; | 2486 | Todo * to = (Todo *) mMoveIncidence; |
2486 | if ( to->hasDueDate() ) | 2487 | if ( to->hasDueDate() ) |
2487 | da = to->dtDue().date(); | 2488 | da = to->dtDue().date(); |
2488 | else | 2489 | else |
2489 | da = QDate::currentDate(); | 2490 | da = QDate::currentDate(); |
2490 | } else { | 2491 | } else { |
2491 | da = mMoveIncidence->dtStart().date(); | 2492 | da = mMoveIncidence->dtStart().date(); |
2492 | } | 2493 | } |
2493 | //PENDING set date for recurring incidence to date of recurrence | 2494 | //PENDING set date for recurring incidence to date of recurrence |
2494 | //mMoveIncidenceOldDate; | 2495 | //mMoveIncidenceOldDate; |
2495 | mDatePicker->setDate( da ); | 2496 | mDatePicker->setDate( da ); |
2496 | } | 2497 | } |
2497 | void CalendarView::showDatePickerPopup() | 2498 | void CalendarView::showDatePickerPopup() |
2498 | { | 2499 | { |
2499 | if ( mDateFrame->isVisible() ) | 2500 | if ( mDateFrame->isVisible() ) |
2500 | mDateFrame->hide(); | 2501 | mDateFrame->hide(); |
2501 | else { | 2502 | else { |
2502 | int offX = 0, offY = 0; | 2503 | int offX = 0, offY = 0; |
2503 | #ifdef DESKTOP_VERSION | 2504 | #ifdef DESKTOP_VERSION |
2504 | int w =mDatePicker->sizeHint().width() ; | 2505 | int w =mDatePicker->sizeHint().width() ; |
2505 | int h = mDatePicker->sizeHint().height() ; | 2506 | int h = mDatePicker->sizeHint().height() ; |
2506 | int dw = topLevelWidget()->width(); | 2507 | int dw = topLevelWidget()->width(); |
2507 | int dh = topLevelWidget()->height(); | 2508 | int dh = topLevelWidget()->height(); |
2508 | offX = topLevelWidget()->x(); | 2509 | offX = topLevelWidget()->x(); |
2509 | offY = topLevelWidget()->y(); | 2510 | offY = topLevelWidget()->y(); |
2510 | #else | 2511 | #else |
2511 | int w =mDatePicker->sizeHint().width() ; | 2512 | int w =mDatePicker->sizeHint().width() ; |
2512 | int h = mDatePicker->sizeHint().height() ; | 2513 | int h = mDatePicker->sizeHint().height() ; |
2513 | int dw = QApplication::desktop()->width(); | 2514 | int dw = QApplication::desktop()->width(); |
2514 | int dh = QApplication::desktop()->height(); | 2515 | int dh = QApplication::desktop()->height(); |
2515 | #endif | 2516 | #endif |
2516 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2517 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2517 | mDateFrame->show(); | 2518 | mDateFrame->show(); |
2518 | } | 2519 | } |
2519 | } | 2520 | } |
2520 | void CalendarView::showDatePicker( ) | 2521 | void CalendarView::showDatePicker( ) |
2521 | { | 2522 | { |
2522 | showDatePickerPopup(); | 2523 | showDatePickerPopup(); |
2523 | mDatePickerMode = 1; | 2524 | mDatePickerMode = 1; |
2524 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2525 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2525 | } | 2526 | } |
2526 | 2527 | ||
2527 | void CalendarView::showEventEditor() | 2528 | void CalendarView::showEventEditor() |
2528 | { | 2529 | { |
2529 | #ifdef DESKTOP_VERSION | 2530 | #ifdef DESKTOP_VERSION |
2531 | int x,y,w,h; | ||
2532 | x = mEventEditor->geometry().x(); | ||
2533 | y = mEventEditor->geometry().y(); | ||
2534 | w = mEventEditor->width(); | ||
2535 | h = mEventEditor->height(); | ||
2530 | mEventEditor->show(); | 2536 | mEventEditor->show(); |
2537 | mEventEditor->setGeometry(x,y,w,h); | ||
2531 | #else | 2538 | #else |
2532 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2539 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2533 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2540 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2534 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2541 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2535 | qApp->processEvents(); | 2542 | qApp->processEvents(); |
2536 | delete mEventEditor; | 2543 | delete mEventEditor; |
2537 | mEventEditor = mDialogManager->getEventEditor(); | 2544 | mEventEditor = mDialogManager->getEventEditor(); |
2538 | topLevelWidget()->setCaption( i18n("") ); | 2545 | topLevelWidget()->setCaption( i18n("") ); |
2539 | } | 2546 | } |
2540 | mEventEditor->showMaximized(); | 2547 | mEventEditor->showMaximized(); |
2541 | #endif | 2548 | #endif |
2542 | } | 2549 | } |
2543 | void CalendarView::showTodoEditor() | 2550 | void CalendarView::showTodoEditor() |
2544 | { | 2551 | { |
2545 | #ifdef DESKTOP_VERSION | 2552 | #ifdef DESKTOP_VERSION |
2553 | int x,y,w,h; | ||
2554 | x = mTodoEditor->geometry().x(); | ||
2555 | y = mTodoEditor->geometry().y(); | ||
2556 | w = mTodoEditor->width(); | ||
2557 | h = mTodoEditor->height(); | ||
2546 | mTodoEditor->show(); | 2558 | mTodoEditor->show(); |
2559 | mTodoEditor->setGeometry(x,y,w,h); | ||
2547 | #else | 2560 | #else |
2548 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2561 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2549 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2562 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2550 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2563 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2551 | qApp->processEvents(); | 2564 | qApp->processEvents(); |
2552 | delete mTodoEditor; | 2565 | delete mTodoEditor; |
2553 | mTodoEditor = mDialogManager->getTodoEditor(); | 2566 | mTodoEditor = mDialogManager->getTodoEditor(); |
2554 | topLevelWidget()->setCaption( i18n("") ); | 2567 | topLevelWidget()->setCaption( i18n("") ); |
2555 | } | 2568 | } |
2556 | mTodoEditor->showMaximized(); | 2569 | mTodoEditor->showMaximized(); |
2557 | #endif | 2570 | #endif |
2558 | } | 2571 | } |
2559 | 2572 | ||
2560 | void CalendarView::cloneIncidence() | 2573 | void CalendarView::cloneIncidence() |
2561 | { | 2574 | { |
2562 | Incidence *incidence = currentSelection(); | 2575 | Incidence *incidence = currentSelection(); |
2563 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2576 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2564 | if ( incidence ) { | 2577 | if ( incidence ) { |
2565 | cloneIncidence(incidence); | 2578 | cloneIncidence(incidence); |
2566 | } | 2579 | } |
2567 | } | 2580 | } |
2568 | void CalendarView::moveIncidence() | 2581 | void CalendarView::moveIncidence() |
2569 | { | 2582 | { |
2570 | Incidence *incidence = currentSelection(); | 2583 | Incidence *incidence = currentSelection(); |
2571 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2584 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2572 | if ( incidence ) { | 2585 | if ( incidence ) { |
2573 | moveIncidence(incidence); | 2586 | moveIncidence(incidence); |
2574 | } | 2587 | } |
2575 | } | 2588 | } |
2576 | void CalendarView::beamIncidence() | 2589 | void CalendarView::beamIncidence() |
2577 | { | 2590 | { |
2578 | Incidence *incidence = currentSelection(); | 2591 | Incidence *incidence = currentSelection(); |
2579 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2592 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2580 | if ( incidence ) { | 2593 | if ( incidence ) { |
2581 | beamIncidence(incidence); | 2594 | beamIncidence(incidence); |
2582 | } | 2595 | } |
2583 | } | 2596 | } |
2584 | void CalendarView::toggleCancelIncidence() | 2597 | void CalendarView::toggleCancelIncidence() |
2585 | { | 2598 | { |
2586 | Incidence *incidence = currentSelection(); | 2599 | Incidence *incidence = currentSelection(); |
2587 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2600 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2588 | if ( incidence ) { | 2601 | if ( incidence ) { |
2589 | cancelIncidence(incidence); | 2602 | cancelIncidence(incidence); |
2590 | } | 2603 | } |
2591 | } | 2604 | } |
2592 | 2605 | ||
2593 | 2606 | ||
2594 | void CalendarView::cancelIncidence(Incidence * inc ) | 2607 | void CalendarView::cancelIncidence(Incidence * inc ) |
2595 | { | 2608 | { |
2596 | inc->setCancelled( ! inc->cancelled() ); | 2609 | inc->setCancelled( ! inc->cancelled() ); |
2597 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2610 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2598 | updateView(); | 2611 | updateView(); |
2599 | } | 2612 | } |
2600 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2613 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2601 | { | 2614 | { |
2602 | Incidence * newInc = orgInc->clone(); | 2615 | Incidence * newInc = orgInc->clone(); |
2603 | newInc->recreate(); | 2616 | newInc->recreate(); |
2604 | 2617 | ||
2605 | if ( newInc->type() == "Todo" ) { | 2618 | if ( newInc->type() == "Todo" ) { |
2606 | Todo* t = (Todo*) newInc; | 2619 | Todo* t = (Todo*) newInc; |
2607 | showTodoEditor(); | 2620 | showTodoEditor(); |
2608 | mTodoEditor->editTodo( t ); | 2621 | mTodoEditor->editTodo( t ); |
2609 | if ( mTodoEditor->exec() ) { | 2622 | if ( mTodoEditor->exec() ) { |
2610 | mCalendar->addTodo( t ); | 2623 | mCalendar->addTodo( t ); |
2611 | updateView(); | 2624 | updateView(); |
2612 | } else { | 2625 | } else { |
2613 | delete t; | 2626 | delete t; |
2614 | } | 2627 | } |
2615 | } | 2628 | } |
2616 | else { | 2629 | else { |
2617 | Event* e = (Event*) newInc; | 2630 | Event* e = (Event*) newInc; |
2618 | showEventEditor(); | 2631 | showEventEditor(); |
2619 | mEventEditor->editEvent( e ); | 2632 | mEventEditor->editEvent( e ); |
2620 | if ( mEventEditor->exec() ) { | 2633 | if ( mEventEditor->exec() ) { |
2621 | mCalendar->addEvent( e ); | 2634 | mCalendar->addEvent( e ); |
2622 | updateView(); | 2635 | updateView(); |
2623 | } else { | 2636 | } else { |
2624 | delete e; | 2637 | delete e; |
2625 | } | 2638 | } |
2626 | } | 2639 | } |
2627 | setActiveWindow(); | 2640 | setActiveWindow(); |
2628 | } | 2641 | } |
2629 | 2642 | ||
2630 | void CalendarView::newEvent() | 2643 | void CalendarView::newEvent() |
2631 | { | 2644 | { |
2632 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2645 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2633 | KOAgendaView *aView = mViewManager->agendaView(); | 2646 | KOAgendaView *aView = mViewManager->agendaView(); |
2634 | if (aView) { | 2647 | if (aView) { |
2635 | if (aView->selectionStart().isValid()) { | 2648 | if (aView->selectionStart().isValid()) { |
2636 | if (aView->selectedIsAllDay()) { | 2649 | if (aView->selectedIsAllDay()) { |
2637 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2650 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2638 | } else { | 2651 | } else { |
2639 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2652 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2640 | } | 2653 | } |
2641 | return; | 2654 | return; |
2642 | } | 2655 | } |
2643 | } | 2656 | } |
2644 | 2657 | ||
2645 | QDate date = mNavigator->selectedDates().first(); | 2658 | QDate date = mNavigator->selectedDates().first(); |
2646 | QDateTime current = QDateTime::currentDateTime(); | 2659 | QDateTime current = QDateTime::currentDateTime(); |
2647 | if ( date <= current.date() ) { | 2660 | if ( date <= current.date() ) { |
2648 | int hour = current.time().hour() +1; | 2661 | int hour = current.time().hour() +1; |
2649 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2662 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2650 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2663 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2651 | } else | 2664 | } else |
2652 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2665 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2653 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2666 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2654 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2667 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2655 | } | 2668 | } |
2656 | 2669 | ||
2657 | void CalendarView::newEvent(QDateTime fh) | 2670 | void CalendarView::newEvent(QDateTime fh) |
2658 | { | 2671 | { |
2659 | newEvent(fh, | 2672 | newEvent(fh, |
2660 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2673 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2661 | } | 2674 | } |
2662 | 2675 | ||
2663 | void CalendarView::newEvent(QDate dt) | 2676 | void CalendarView::newEvent(QDate dt) |
2664 | { | 2677 | { |
2665 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2678 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2666 | QDateTime(dt, QTime(0,0,0)), true); | 2679 | QDateTime(dt, QTime(0,0,0)), true); |
2667 | } | 2680 | } |
2668 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2681 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2669 | { | 2682 | { |
2670 | newEvent(fromHint, toHint, false); | 2683 | newEvent(fromHint, toHint, false); |
2671 | } | 2684 | } |
2672 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2685 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2673 | { | 2686 | { |
2674 | 2687 | ||
2675 | showEventEditor(); | 2688 | showEventEditor(); |
2676 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2689 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2677 | if ( mFilterView->filtersEnabled() ) { | 2690 | if ( mFilterView->filtersEnabled() ) { |
2678 | CalFilter *filter = mFilterView->selectedFilter(); | 2691 | CalFilter *filter = mFilterView->selectedFilter(); |
2679 | if (filter && filter->showCategories()) { | 2692 | if (filter && filter->showCategories()) { |
2680 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2693 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2681 | } | 2694 | } |
2682 | if ( filter ) | 2695 | if ( filter ) |
2683 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2696 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2684 | } | 2697 | } |
2685 | mEventEditor->exec(); | 2698 | mEventEditor->exec(); |
2686 | setActiveWindow(); | 2699 | setActiveWindow(); |
2687 | } | 2700 | } |
2688 | void CalendarView::todoAdded(Todo * t) | 2701 | void CalendarView::todoAdded(Todo * t) |
2689 | { | 2702 | { |
2690 | 2703 | ||
2691 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2704 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2692 | updateTodoViews(); | 2705 | updateTodoViews(); |
2693 | } | 2706 | } |
2694 | void CalendarView::todoChanged(Todo * t) | 2707 | void CalendarView::todoChanged(Todo * t) |
2695 | { | 2708 | { |
2696 | emit todoModified( t, 4 ); | 2709 | emit todoModified( t, 4 ); |
2697 | // updateTodoViews(); | 2710 | // updateTodoViews(); |
2698 | } | 2711 | } |
2699 | void CalendarView::todoToBeDeleted(Todo *) | 2712 | void CalendarView::todoToBeDeleted(Todo *) |
2700 | { | 2713 | { |
2701 | //qDebug("todoToBeDeleted(Todo *) "); | 2714 | //qDebug("todoToBeDeleted(Todo *) "); |
2702 | updateTodoViews(); | 2715 | updateTodoViews(); |
2703 | } | 2716 | } |
2704 | void CalendarView::todoDeleted() | 2717 | void CalendarView::todoDeleted() |
2705 | { | 2718 | { |
2706 | //qDebug(" todoDeleted()"); | 2719 | //qDebug(" todoDeleted()"); |
2707 | updateTodoViews(); | 2720 | updateTodoViews(); |
2708 | } | 2721 | } |
2709 | 2722 | ||
2710 | 2723 | ||
2711 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2724 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2712 | { | 2725 | { |
2713 | showTodoEditor(); | 2726 | showTodoEditor(); |
2714 | mTodoEditor->newTodo(dt,0,allday); | 2727 | mTodoEditor->newTodo(dt,0,allday); |
2715 | if ( mFilterView->filtersEnabled() ) { | 2728 | if ( mFilterView->filtersEnabled() ) { |
2716 | CalFilter *filter = mFilterView->selectedFilter(); | 2729 | CalFilter *filter = mFilterView->selectedFilter(); |
2717 | if (filter && filter->showCategories()) { | 2730 | if (filter && filter->showCategories()) { |
2718 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2731 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2719 | } | 2732 | } |
2720 | if ( filter ) | 2733 | if ( filter ) |
2721 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2734 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2722 | } | 2735 | } |
2723 | mTodoEditor->exec(); | 2736 | mTodoEditor->exec(); |
2724 | setActiveWindow(); | 2737 | setActiveWindow(); |
2725 | } | 2738 | } |
2726 | 2739 | ||
2727 | void CalendarView::newTodo() | 2740 | void CalendarView::newTodo() |
2728 | { | 2741 | { |
2729 | newTodoDateTime( QDateTime(),true ); | 2742 | newTodoDateTime( QDateTime(),true ); |
2730 | } | 2743 | } |
2731 | 2744 | ||
2732 | void CalendarView::newSubTodo() | 2745 | void CalendarView::newSubTodo() |
2733 | { | 2746 | { |
2734 | Todo *todo = selectedTodo(); | 2747 | Todo *todo = selectedTodo(); |
2735 | if ( todo ) newSubTodo( todo ); | 2748 | if ( todo ) newSubTodo( todo ); |
2736 | } | 2749 | } |
2737 | 2750 | ||
2738 | void CalendarView::newSubTodo(Todo *parentEvent) | 2751 | void CalendarView::newSubTodo(Todo *parentEvent) |
2739 | { | 2752 | { |
2740 | 2753 | ||
2741 | showTodoEditor(); | 2754 | showTodoEditor(); |
2742 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2755 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2743 | mTodoEditor->exec(); | 2756 | mTodoEditor->exec(); |
2744 | setActiveWindow(); | 2757 | setActiveWindow(); |
2745 | } | 2758 | } |
2746 | 2759 | ||
2747 | void CalendarView::newFloatingEvent() | 2760 | void CalendarView::newFloatingEvent() |
2748 | { | 2761 | { |
2749 | DateList tmpList = mNavigator->selectedDates(); | 2762 | DateList tmpList = mNavigator->selectedDates(); |
2750 | QDate date = tmpList.first(); | 2763 | QDate date = tmpList.first(); |
2751 | 2764 | ||
2752 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2765 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2753 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2766 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2754 | } | 2767 | } |
2755 | 2768 | ||
2756 | 2769 | ||
2757 | void CalendarView::editEvent( Event *event ) | 2770 | void CalendarView::editEvent( Event *event ) |
2758 | { | 2771 | { |
2759 | 2772 | ||
2760 | if ( !event ) return; | 2773 | if ( !event ) return; |
2761 | if ( event->isReadOnly() ) { | 2774 | if ( event->isReadOnly() ) { |
2762 | showEvent( event ); | 2775 | showEvent( event ); |
2763 | return; | 2776 | return; |
2764 | } | 2777 | } |
2765 | showEventEditor(); | 2778 | showEventEditor(); |
2766 | mEventEditor->editEvent( event , mFlagEditDescription); | 2779 | mEventEditor->editEvent( event , mFlagEditDescription); |
2767 | mEventEditor->exec(); | 2780 | mEventEditor->exec(); |
2768 | setActiveWindow(); | 2781 | setActiveWindow(); |
2769 | 2782 | ||
2770 | } | 2783 | } |
2771 | void CalendarView::editJournal( Journal *jour ) | 2784 | void CalendarView::editJournal( Journal *jour ) |
2772 | { | 2785 | { |
2773 | if ( !jour ) return; | 2786 | if ( !jour ) return; |
2774 | mDialogManager->hideSearchDialog(); | 2787 | mDialogManager->hideSearchDialog(); |
2775 | mViewManager->showJournalView(); | 2788 | mViewManager->showJournalView(); |
2776 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2789 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2777 | } | 2790 | } |
2778 | void CalendarView::editTodo( Todo *todo ) | 2791 | void CalendarView::editTodo( Todo *todo ) |
2779 | { | 2792 | { |
2780 | if ( !todo ) return; | 2793 | if ( !todo ) return; |
2781 | 2794 | ||
2782 | if ( todo->isReadOnly() ) { | 2795 | if ( todo->isReadOnly() ) { |
2783 | showTodo( todo ); | 2796 | showTodo( todo ); |
2784 | return; | 2797 | return; |
2785 | } | 2798 | } |
2786 | showTodoEditor(); | 2799 | showTodoEditor(); |
2787 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2800 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2788 | mTodoEditor->exec(); | 2801 | mTodoEditor->exec(); |
2789 | setActiveWindow(); | 2802 | setActiveWindow(); |
2790 | 2803 | ||
2791 | } | 2804 | } |
2792 | 2805 | ||
2793 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2806 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2794 | { | 2807 | { |
2795 | if ( !mEventViewerDialog ) { | 2808 | if ( !mEventViewerDialog ) { |
2796 | mEventViewerDialog = new KOEventViewerDialog(this); | 2809 | mEventViewerDialog = new KOEventViewerDialog(0); |
2797 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2810 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2798 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2811 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2799 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2812 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2800 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2813 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2801 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2814 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2802 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2815 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2803 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 2816 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
2804 | this, SLOT( slotViewerClosed() ) ); | 2817 | this, SLOT( slotViewerClosed() ) ); |
2805 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2818 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2806 | this, SLOT( todoChanged(Todo *) ) ); | 2819 | this, SLOT( todoChanged(Todo *) ) ); |
2807 | mEventViewerDialog->resize( 640, 480 ); | 2820 | mEventViewerDialog->resize( 640, 480 ); |
2808 | 2821 | ||
2809 | } | 2822 | } |
2810 | return mEventViewerDialog; | 2823 | return mEventViewerDialog; |
2811 | } | 2824 | } |
2812 | void CalendarView::showEvent(Event *event) | 2825 | void CalendarView::showEvent(Event *event) |
2813 | { | 2826 | { |
2814 | getEventViewerDialog()->setEvent(event); | 2827 | getEventViewerDialog()->setEvent(event); |
2815 | getEventViewerDialog()->showMe(); | 2828 | getEventViewerDialog()->showMe(); |
2816 | } | 2829 | } |
2817 | 2830 | ||
2818 | void CalendarView::showTodo(Todo *event) | 2831 | void CalendarView::showTodo(Todo *event) |
2819 | { | 2832 | { |
2820 | getEventViewerDialog()->setTodo(event); | 2833 | getEventViewerDialog()->setTodo(event); |
2821 | getEventViewerDialog()->showMe(); | 2834 | getEventViewerDialog()->showMe(); |
2822 | } | 2835 | } |
2823 | void CalendarView::showJournal( Journal *jour ) | 2836 | void CalendarView::showJournal( Journal *jour ) |
2824 | { | 2837 | { |
2825 | getEventViewerDialog()->setJournal(jour); | 2838 | getEventViewerDialog()->setJournal(jour); |
2826 | getEventViewerDialog()->showMe(); | 2839 | getEventViewerDialog()->showMe(); |
2827 | 2840 | ||
2828 | } | 2841 | } |
2829 | // void CalendarView::todoModified (Todo *event, int changed) | 2842 | // void CalendarView::todoModified (Todo *event, int changed) |
2830 | // { | 2843 | // { |
2831 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2844 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2832 | // // kdDebug() << "Todo modified and open" << endl; | 2845 | // // kdDebug() << "Todo modified and open" << endl; |
2833 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2846 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2834 | // // temp->modified (changed); | 2847 | // // temp->modified (changed); |
2835 | 2848 | ||
2836 | // // } | 2849 | // // } |
2837 | 2850 | ||
2838 | // mViewManager->updateView(); | 2851 | // mViewManager->updateView(); |
2839 | // } | 2852 | // } |
2840 | 2853 | ||
2841 | void CalendarView::appointment_show() | 2854 | void CalendarView::appointment_show() |
2842 | { | 2855 | { |
2843 | Event *anEvent = 0; | 2856 | Event *anEvent = 0; |
2844 | 2857 | ||
2845 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2858 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2846 | 2859 | ||
2847 | if (mViewManager->currentView()->isEventView()) { | 2860 | if (mViewManager->currentView()->isEventView()) { |
2848 | if ( incidence && incidence->type() == "Event" ) { | 2861 | if ( incidence && incidence->type() == "Event" ) { |
2849 | anEvent = static_cast<Event *>(incidence); | 2862 | anEvent = static_cast<Event *>(incidence); |
2850 | } | 2863 | } |
2851 | } | 2864 | } |
2852 | 2865 | ||
2853 | if (!anEvent) { | 2866 | if (!anEvent) { |
2854 | KNotifyClient::beep(); | 2867 | KNotifyClient::beep(); |
2855 | return; | 2868 | return; |
2856 | } | 2869 | } |
2857 | 2870 | ||
2858 | showEvent(anEvent); | 2871 | showEvent(anEvent); |
2859 | } | 2872 | } |
2860 | 2873 | ||
2861 | void CalendarView::appointment_edit() | 2874 | void CalendarView::appointment_edit() |
2862 | { | 2875 | { |
2863 | Event *anEvent = 0; | 2876 | Event *anEvent = 0; |
2864 | 2877 | ||
2865 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2878 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2866 | 2879 | ||
2867 | if (mViewManager->currentView()->isEventView()) { | 2880 | if (mViewManager->currentView()->isEventView()) { |
2868 | if ( incidence && incidence->type() == "Event" ) { | 2881 | if ( incidence && incidence->type() == "Event" ) { |
2869 | anEvent = static_cast<Event *>(incidence); | 2882 | anEvent = static_cast<Event *>(incidence); |
2870 | } | 2883 | } |
2871 | } | 2884 | } |
2872 | 2885 | ||
2873 | if (!anEvent) { | 2886 | if (!anEvent) { |
2874 | KNotifyClient::beep(); | 2887 | KNotifyClient::beep(); |
2875 | return; | 2888 | return; |
2876 | } | 2889 | } |
2877 | 2890 | ||
2878 | editEvent(anEvent); | 2891 | editEvent(anEvent); |
2879 | } | 2892 | } |
2880 | 2893 | ||
2881 | void CalendarView::appointment_delete() | 2894 | void CalendarView::appointment_delete() |
2882 | { | 2895 | { |
2883 | Event *anEvent = 0; | 2896 | Event *anEvent = 0; |
2884 | 2897 | ||
2885 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2898 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2886 | 2899 | ||
2887 | if (mViewManager->currentView()->isEventView()) { | 2900 | if (mViewManager->currentView()->isEventView()) { |
2888 | if ( incidence && incidence->type() == "Event" ) { | 2901 | if ( incidence && incidence->type() == "Event" ) { |
2889 | anEvent = static_cast<Event *>(incidence); | 2902 | anEvent = static_cast<Event *>(incidence); |
2890 | } | 2903 | } |
2891 | } | 2904 | } |
2892 | 2905 | ||
2893 | if (!anEvent) { | 2906 | if (!anEvent) { |
2894 | KNotifyClient::beep(); | 2907 | KNotifyClient::beep(); |
2895 | return; | 2908 | return; |
2896 | } | 2909 | } |
2897 | 2910 | ||
2898 | deleteEvent(anEvent); | 2911 | deleteEvent(anEvent); |
2899 | } | 2912 | } |
2900 | 2913 | ||
2901 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2914 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2902 | { | 2915 | { |
2903 | if (!sub) return; | 2916 | if (!sub) return; |
2904 | if (!parent) return; | 2917 | if (!parent) return; |
2905 | if ( sub->relatedTo() ) | 2918 | if ( sub->relatedTo() ) |
2906 | sub->relatedTo()->removeRelation(sub); | 2919 | sub->relatedTo()->removeRelation(sub); |
2907 | sub->setRelatedTo(parent); | 2920 | sub->setRelatedTo(parent); |
2908 | sub->setRelatedToUid(parent->uid()); | 2921 | sub->setRelatedToUid(parent->uid()); |
2909 | parent->addRelation(sub); | 2922 | parent->addRelation(sub); |
2910 | sub->updated(); | 2923 | sub->updated(); |
2911 | parent->updated(); | 2924 | parent->updated(); |
2912 | setModified(true); | 2925 | setModified(true); |
2913 | updateView(); | 2926 | updateView(); |
2914 | } | 2927 | } |
2915 | void CalendarView::todo_unsub(Todo *anTodo ) | 2928 | void CalendarView::todo_unsub(Todo *anTodo ) |
2916 | { | 2929 | { |
2917 | // Todo *anTodo = selectedTodo(); | 2930 | // Todo *anTodo = selectedTodo(); |
2918 | if (!anTodo) return; | 2931 | if (!anTodo) return; |
2919 | if (!anTodo->relatedTo()) return; | 2932 | if (!anTodo->relatedTo()) return; |
2920 | anTodo->relatedTo()->removeRelation(anTodo); | 2933 | anTodo->relatedTo()->removeRelation(anTodo); |
2921 | anTodo->setRelatedTo(0); | 2934 | anTodo->setRelatedTo(0); |
2922 | anTodo->updated(); | 2935 | anTodo->updated(); |
2923 | anTodo->setRelatedToUid(""); | 2936 | anTodo->setRelatedToUid(""); |
2924 | setModified(true); | 2937 | setModified(true); |
2925 | updateView(); | 2938 | updateView(); |
2926 | } | 2939 | } |
2927 | 2940 | ||
2928 | void CalendarView::deleteTodo(Todo *todo) | 2941 | void CalendarView::deleteTodo(Todo *todo) |
2929 | { | 2942 | { |
2930 | if (!todo) { | 2943 | if (!todo) { |
2931 | KNotifyClient::beep(); | 2944 | KNotifyClient::beep(); |
2932 | return; | 2945 | return; |
2933 | } | 2946 | } |
2934 | if (KOPrefs::instance()->mConfirm) { | 2947 | if (KOPrefs::instance()->mConfirm) { |
2935 | QString text = todo->summary().left(20); | 2948 | QString text = todo->summary().left(20); |
2936 | if (!todo->relations().isEmpty()) { | 2949 | if (!todo->relations().isEmpty()) { |
2937 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2950 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2938 | 2951 | ||
2939 | } | 2952 | } |
2940 | switch (msgItemDelete(text)) { | 2953 | switch (msgItemDelete(text)) { |
2941 | case KMessageBox::Continue: // OK | 2954 | case KMessageBox::Continue: // OK |
2942 | bool deleteT = false; | 2955 | bool deleteT = false; |
2943 | if (!todo->relations().isEmpty()) { | 2956 | if (!todo->relations().isEmpty()) { |
2944 | deleteT = removeCompletedSubTodos( todo ); | 2957 | deleteT = removeCompletedSubTodos( todo ); |
2945 | } | 2958 | } |
2946 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2959 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2947 | if ( !deleteT ) { | 2960 | if ( !deleteT ) { |
2948 | checkExternalId( todo ); | 2961 | checkExternalId( todo ); |
2949 | calendar()->deleteTodo(todo); | 2962 | calendar()->deleteTodo(todo); |
2950 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2963 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2951 | updateView(); | 2964 | updateView(); |
2952 | } | 2965 | } |
2953 | break; | 2966 | break; |
2954 | } // switch | 2967 | } // switch |
2955 | } else { | 2968 | } else { |
2956 | checkExternalId( todo ); | 2969 | checkExternalId( todo ); |
2957 | mCalendar->deleteTodo(todo); | 2970 | mCalendar->deleteTodo(todo); |
2958 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2971 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2959 | updateView(); | 2972 | updateView(); |
2960 | } | 2973 | } |
2961 | 2974 | ||
2962 | emit updateSearchDialog(); | 2975 | emit updateSearchDialog(); |
2963 | } | 2976 | } |
2964 | void CalendarView::deleteJournal(Journal *jour) | 2977 | void CalendarView::deleteJournal(Journal *jour) |
2965 | { | 2978 | { |
2966 | if (!jour) { | 2979 | if (!jour) { |
2967 | KNotifyClient::beep(); | 2980 | KNotifyClient::beep(); |
2968 | return; | 2981 | return; |
2969 | } | 2982 | } |
2970 | if (KOPrefs::instance()->mConfirm) { | 2983 | if (KOPrefs::instance()->mConfirm) { |
2971 | switch (msgItemDelete( jour->description().left(20))) { | 2984 | switch (msgItemDelete( jour->description().left(20))) { |
2972 | case KMessageBox::Continue: // OK | 2985 | case KMessageBox::Continue: // OK |
2973 | calendar()->deleteJournal(jour); | 2986 | calendar()->deleteJournal(jour); |
2974 | updateView(); | 2987 | updateView(); |
2975 | break; | 2988 | break; |
2976 | } // switch | 2989 | } // switch |
2977 | } else { | 2990 | } else { |
2978 | calendar()->deleteJournal(jour);; | 2991 | calendar()->deleteJournal(jour);; |
2979 | updateView(); | 2992 | updateView(); |
2980 | } | 2993 | } |
2981 | emit updateSearchDialog(); | 2994 | emit updateSearchDialog(); |
2982 | } | 2995 | } |
2983 | 2996 | ||
2984 | void CalendarView::deleteEvent(Event *anEvent) | 2997 | void CalendarView::deleteEvent(Event *anEvent) |
2985 | { | 2998 | { |
2986 | if (!anEvent) { | 2999 | if (!anEvent) { |
2987 | KNotifyClient::beep(); | 3000 | KNotifyClient::beep(); |
2988 | return; | 3001 | return; |
2989 | } | 3002 | } |
2990 | 3003 | ||
2991 | if (anEvent->recurrence()->doesRecur()) { | 3004 | if (anEvent->recurrence()->doesRecur()) { |
2992 | QDate itemDate = mViewManager->currentSelectionDate(); | 3005 | QDate itemDate = mViewManager->currentSelectionDate(); |
2993 | int km; | 3006 | int km; |
2994 | if (!itemDate.isValid()) { | 3007 | if (!itemDate.isValid()) { |
2995 | //kdDebug() << "Date Not Valid" << endl; | 3008 | //kdDebug() << "Date Not Valid" << endl; |
2996 | if (KOPrefs::instance()->mConfirm) { | 3009 | if (KOPrefs::instance()->mConfirm) { |
2997 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3010 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2998 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3011 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2999 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3012 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3000 | if ( km == KMessageBox::Continue ) | 3013 | if ( km == KMessageBox::Continue ) |
3001 | km = KMessageBox::No; // No = all below | 3014 | km = KMessageBox::No; // No = all below |
3002 | } else | 3015 | } else |
3003 | km = KMessageBox::No; | 3016 | km = KMessageBox::No; |
3004 | } else { | 3017 | } else { |
3005 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3018 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3006 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3019 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3007 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3020 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3008 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3021 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3009 | i18n("All")); | 3022 | i18n("All")); |
3010 | } | 3023 | } |
3011 | switch(km) { | 3024 | switch(km) { |
3012 | 3025 | ||
3013 | case KMessageBox::No: // Continue // all | 3026 | case KMessageBox::No: // Continue // all |
3014 | //qDebug("KMessageBox::No "); | 3027 | //qDebug("KMessageBox::No "); |
3015 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3028 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3016 | schedule(Scheduler::Cancel,anEvent); | 3029 | schedule(Scheduler::Cancel,anEvent); |
3017 | 3030 | ||
3018 | checkExternalId( anEvent); | 3031 | checkExternalId( anEvent); |
3019 | mCalendar->deleteEvent(anEvent); | 3032 | mCalendar->deleteEvent(anEvent); |
3020 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3033 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3021 | break; | 3034 | break; |
3022 | 3035 | ||
3023 | // Disabled because it does not work | 3036 | // Disabled because it does not work |
3024 | //#if 0 | 3037 | //#if 0 |
3025 | case KMessageBox::Yes: // just this one | 3038 | case KMessageBox::Yes: // just this one |
3026 | //QDate qd = mNavigator->selectedDates().first(); | 3039 | //QDate qd = mNavigator->selectedDates().first(); |
3027 | //if (!qd.isValid()) { | 3040 | //if (!qd.isValid()) { |
3028 | // kdDebug() << "no date selected, or invalid date" << endl; | 3041 | // kdDebug() << "no date selected, or invalid date" << endl; |
3029 | // KNotifyClient::beep(); | 3042 | // KNotifyClient::beep(); |
3030 | // return; | 3043 | // return; |
3031 | //} | 3044 | //} |
3032 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3045 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3033 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3046 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3034 | anEvent->addExDate(itemDate); | 3047 | anEvent->addExDate(itemDate); |
3035 | int duration = anEvent->recurrence()->duration(); | 3048 | int duration = anEvent->recurrence()->duration(); |
3036 | if ( duration > 0 ) { | 3049 | if ( duration > 0 ) { |
3037 | anEvent->recurrence()->setDuration( duration - 1 ); | 3050 | anEvent->recurrence()->setDuration( duration - 1 ); |
3038 | } | 3051 | } |
3039 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3052 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3040 | } | 3053 | } |
3041 | break; | 3054 | break; |
3042 | //#endif | 3055 | //#endif |
3043 | } // switch | 3056 | } // switch |
3044 | } else { | 3057 | } else { |
3045 | if (KOPrefs::instance()->mConfirm) { | 3058 | if (KOPrefs::instance()->mConfirm) { |
3046 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3059 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3047 | i18n("\nAre you sure you want\nto delete this event?"), | 3060 | i18n("\nAre you sure you want\nto delete this event?"), |
3048 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3061 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3049 | case KMessageBox::Continue: // OK | 3062 | case KMessageBox::Continue: // OK |
3050 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3063 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3051 | schedule(Scheduler::Cancel,anEvent); | 3064 | schedule(Scheduler::Cancel,anEvent); |
3052 | checkExternalId( anEvent); | 3065 | checkExternalId( anEvent); |
3053 | mCalendar->deleteEvent(anEvent); | 3066 | mCalendar->deleteEvent(anEvent); |
3054 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3067 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3055 | break; | 3068 | break; |
3056 | } // switch | 3069 | } // switch |
3057 | } else { | 3070 | } else { |
3058 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3071 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3059 | schedule(Scheduler::Cancel,anEvent); | 3072 | schedule(Scheduler::Cancel,anEvent); |
3060 | checkExternalId( anEvent); | 3073 | checkExternalId( anEvent); |
3061 | mCalendar->deleteEvent(anEvent); | 3074 | mCalendar->deleteEvent(anEvent); |
3062 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3075 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3063 | } | 3076 | } |
3064 | } // if-else | 3077 | } // if-else |
3065 | emit updateSearchDialog(); | 3078 | emit updateSearchDialog(); |
3066 | } | 3079 | } |
3067 | 3080 | ||
3068 | bool CalendarView::deleteEvent(const QString &uid) | 3081 | bool CalendarView::deleteEvent(const QString &uid) |
3069 | { | 3082 | { |
3070 | Event *ev = mCalendar->event(uid); | 3083 | Event *ev = mCalendar->event(uid); |
3071 | if (ev) { | 3084 | if (ev) { |
3072 | deleteEvent(ev); | 3085 | deleteEvent(ev); |
3073 | return true; | 3086 | return true; |
3074 | } else { | 3087 | } else { |
3075 | return false; | 3088 | return false; |
3076 | } | 3089 | } |
3077 | } | 3090 | } |
3078 | 3091 | ||
3079 | /*****************************************************************************/ | 3092 | /*****************************************************************************/ |
3080 | 3093 | ||
3081 | void CalendarView::action_mail() | 3094 | void CalendarView::action_mail() |
3082 | { | 3095 | { |
3083 | #ifndef KORG_NOMAIL | 3096 | #ifndef KORG_NOMAIL |
3084 | KOMailClient mailClient; | 3097 | KOMailClient mailClient; |
3085 | 3098 | ||
3086 | Incidence *incidence = currentSelection(); | 3099 | Incidence *incidence = currentSelection(); |
3087 | 3100 | ||
3088 | if (!incidence) { | 3101 | if (!incidence) { |
3089 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3102 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3090 | return; | 3103 | return; |
3091 | } | 3104 | } |
3092 | if(incidence->attendeeCount() == 0 ) { | 3105 | if(incidence->attendeeCount() == 0 ) { |
3093 | KMessageBox::sorry(this, | 3106 | KMessageBox::sorry(this, |
3094 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3107 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3095 | return; | 3108 | return; |
3096 | } | 3109 | } |
3097 | 3110 | ||
3098 | CalendarLocal cal_tmp; | 3111 | CalendarLocal cal_tmp; |
3099 | Event *event = 0; | 3112 | Event *event = 0; |
3100 | Event *ev = 0; | 3113 | Event *ev = 0; |
3101 | if ( incidence && incidence->type() == "Event" ) { | 3114 | if ( incidence && incidence->type() == "Event" ) { |
3102 | event = static_cast<Event *>(incidence); | 3115 | event = static_cast<Event *>(incidence); |
3103 | ev = new Event(*event); | 3116 | ev = new Event(*event); |
3104 | cal_tmp.addEvent(ev); | 3117 | cal_tmp.addEvent(ev); |
3105 | } | 3118 | } |
3106 | ICalFormat mForm(); | 3119 | ICalFormat mForm(); |
3107 | QString attachment = mForm.toString( &cal_tmp ); | 3120 | QString attachment = mForm.toString( &cal_tmp ); |
3108 | if (ev) delete(ev); | 3121 | if (ev) delete(ev); |
3109 | 3122 | ||
3110 | mailClient.mailAttendees(currentSelection(), attachment); | 3123 | mailClient.mailAttendees(currentSelection(), attachment); |
3111 | 3124 | ||
3112 | #endif | 3125 | #endif |
3113 | 3126 | ||
3114 | #if 0 | 3127 | #if 0 |
3115 | Event *anEvent = 0; | 3128 | Event *anEvent = 0; |
3116 | if (mViewManager->currentView()->isEventView()) { | 3129 | if (mViewManager->currentView()->isEventView()) { |
3117 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3130 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3118 | } | 3131 | } |
3119 | 3132 | ||
3120 | if (!anEvent) { | 3133 | if (!anEvent) { |
3121 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3134 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3122 | return; | 3135 | return; |
3123 | } | 3136 | } |
3124 | if(anEvent->attendeeCount() == 0 ) { | 3137 | if(anEvent->attendeeCount() == 0 ) { |
3125 | KMessageBox::sorry(this, | 3138 | KMessageBox::sorry(this, |
3126 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3139 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3127 | return; | 3140 | return; |
3128 | } | 3141 | } |
3129 | 3142 | ||
3130 | mailobject.emailEvent(anEvent); | 3143 | mailobject.emailEvent(anEvent); |
3131 | #endif | 3144 | #endif |
3132 | } | 3145 | } |
3133 | 3146 | ||
3134 | 3147 | ||
3135 | void CalendarView::schedule_publish(Incidence *incidence) | 3148 | void CalendarView::schedule_publish(Incidence *incidence) |
3136 | { | 3149 | { |
3137 | Event *event = 0; | 3150 | Event *event = 0; |
3138 | Todo *todo = 0; | 3151 | Todo *todo = 0; |
3139 | 3152 | ||
3140 | if (incidence == 0) { | 3153 | if (incidence == 0) { |
3141 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3154 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3142 | if (incidence == 0) { | 3155 | if (incidence == 0) { |
3143 | incidence = mTodoList->selectedIncidences().first(); | 3156 | incidence = mTodoList->selectedIncidences().first(); |
3144 | } | 3157 | } |
3145 | } | 3158 | } |
3146 | if ( incidence && incidence->type() == "Event" ) { | 3159 | if ( incidence && incidence->type() == "Event" ) { |
3147 | event = static_cast<Event *>(incidence); | 3160 | event = static_cast<Event *>(incidence); |
3148 | } else { | 3161 | } else { |
3149 | if ( incidence && incidence->type() == "Todo" ) { | 3162 | if ( incidence && incidence->type() == "Todo" ) { |
3150 | todo = static_cast<Todo *>(incidence); | 3163 | todo = static_cast<Todo *>(incidence); |
3151 | } | 3164 | } |
3152 | } | 3165 | } |
3153 | 3166 | ||
3154 | if (!event && !todo) { | 3167 | if (!event && !todo) { |
3155 | KMessageBox::sorry(this,i18n("No event selected.")); | 3168 | KMessageBox::sorry(this,i18n("No event selected.")); |
3156 | return; | 3169 | return; |
3157 | } | 3170 | } |
3158 | 3171 | ||
3159 | PublishDialog *publishdlg = new PublishDialog(); | 3172 | PublishDialog *publishdlg = new PublishDialog(); |
3160 | if (incidence->attendeeCount()>0) { | 3173 | if (incidence->attendeeCount()>0) { |
3161 | QPtrList<Attendee> attendees = incidence->attendees(); | 3174 | QPtrList<Attendee> attendees = incidence->attendees(); |
3162 | attendees.first(); | 3175 | attendees.first(); |
3163 | while ( attendees.current()!=0 ) { | 3176 | while ( attendees.current()!=0 ) { |
3164 | publishdlg->addAttendee(attendees.current()); | 3177 | publishdlg->addAttendee(attendees.current()); |
3165 | attendees.next(); | 3178 | attendees.next(); |
3166 | } | 3179 | } |
3167 | } | 3180 | } |
3168 | bool send = true; | 3181 | bool send = true; |
3169 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3182 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3170 | if ( publishdlg->exec() != QDialog::Accepted ) | 3183 | if ( publishdlg->exec() != QDialog::Accepted ) |
3171 | send = false; | 3184 | send = false; |
3172 | } | 3185 | } |
3173 | if ( send ) { | 3186 | if ( send ) { |
3174 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3187 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3175 | if ( event ) { | 3188 | if ( event ) { |
3176 | Event *ev = new Event(*event); | 3189 | Event *ev = new Event(*event); |
3177 | ev->registerObserver(0); | 3190 | ev->registerObserver(0); |
3178 | ev->clearAttendees(); | 3191 | ev->clearAttendees(); |
3179 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3192 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3180 | delete(ev); | 3193 | delete(ev); |
3181 | } | 3194 | } |
3182 | } else { | 3195 | } else { |
3183 | if ( todo ) { | 3196 | if ( todo ) { |
3184 | Todo *ev = new Todo(*todo); | 3197 | Todo *ev = new Todo(*todo); |
3185 | ev->registerObserver(0); | 3198 | ev->registerObserver(0); |
3186 | ev->clearAttendees(); | 3199 | ev->clearAttendees(); |
3187 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3200 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3188 | delete(ev); | 3201 | delete(ev); |
3189 | } | 3202 | } |
3190 | } | 3203 | } |
3191 | } | 3204 | } |
3192 | } | 3205 | } |
3193 | delete publishdlg; | 3206 | delete publishdlg; |
3194 | } | 3207 | } |
3195 | 3208 | ||
3196 | void CalendarView::schedule_request(Incidence *incidence) | 3209 | void CalendarView::schedule_request(Incidence *incidence) |
3197 | { | 3210 | { |
3198 | schedule(Scheduler::Request,incidence); | 3211 | schedule(Scheduler::Request,incidence); |
3199 | } | 3212 | } |
3200 | 3213 | ||
3201 | void CalendarView::schedule_refresh(Incidence *incidence) | 3214 | void CalendarView::schedule_refresh(Incidence *incidence) |
3202 | { | 3215 | { |
3203 | schedule(Scheduler::Refresh,incidence); | 3216 | schedule(Scheduler::Refresh,incidence); |
3204 | } | 3217 | } |
3205 | 3218 | ||
3206 | void CalendarView::schedule_cancel(Incidence *incidence) | 3219 | void CalendarView::schedule_cancel(Incidence *incidence) |
3207 | { | 3220 | { |
3208 | schedule(Scheduler::Cancel,incidence); | 3221 | schedule(Scheduler::Cancel,incidence); |
3209 | } | 3222 | } |
3210 | 3223 | ||
3211 | void CalendarView::schedule_add(Incidence *incidence) | 3224 | void CalendarView::schedule_add(Incidence *incidence) |
3212 | { | 3225 | { |
3213 | schedule(Scheduler::Add,incidence); | 3226 | schedule(Scheduler::Add,incidence); |
3214 | } | 3227 | } |
3215 | 3228 | ||
3216 | void CalendarView::schedule_reply(Incidence *incidence) | 3229 | void CalendarView::schedule_reply(Incidence *incidence) |
3217 | { | 3230 | { |
3218 | schedule(Scheduler::Reply,incidence); | 3231 | schedule(Scheduler::Reply,incidence); |
3219 | } | 3232 | } |
3220 | 3233 | ||
3221 | void CalendarView::schedule_counter(Incidence *incidence) | 3234 | void CalendarView::schedule_counter(Incidence *incidence) |
3222 | { | 3235 | { |
3223 | schedule(Scheduler::Counter,incidence); | 3236 | schedule(Scheduler::Counter,incidence); |
3224 | } | 3237 | } |
3225 | 3238 | ||
3226 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3239 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3227 | { | 3240 | { |
3228 | schedule(Scheduler::Declinecounter,incidence); | 3241 | schedule(Scheduler::Declinecounter,incidence); |
3229 | } | 3242 | } |
3230 | 3243 | ||
3231 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3244 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3232 | { | 3245 | { |
3233 | QDateTime start = QDateTime::currentDateTime(); | 3246 | QDateTime start = QDateTime::currentDateTime(); |
3234 | QDateTime end = start.addDays(daysToPublish); | 3247 | QDateTime end = start.addDays(daysToPublish); |
3235 | 3248 | ||
3236 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3249 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3237 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3250 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3238 | 3251 | ||
3239 | 3252 | ||
3240 | PublishDialog *publishdlg = new PublishDialog(); | 3253 | PublishDialog *publishdlg = new PublishDialog(); |
3241 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3254 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3242 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3255 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3243 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3256 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3244 | delete(freebusy); | 3257 | delete(freebusy); |
3245 | } | 3258 | } |
3246 | } | 3259 | } |
3247 | delete publishdlg; | 3260 | delete publishdlg; |
3248 | } | 3261 | } |
3249 | 3262 | ||
3250 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3263 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3251 | { | 3264 | { |
3252 | Event *event = 0; | 3265 | Event *event = 0; |
3253 | Todo *todo = 0; | 3266 | Todo *todo = 0; |
3254 | 3267 | ||
3255 | if (incidence == 0) { | 3268 | if (incidence == 0) { |
3256 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3269 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3257 | if (incidence == 0) { | 3270 | if (incidence == 0) { |
3258 | incidence = mTodoList->selectedIncidences().first(); | 3271 | incidence = mTodoList->selectedIncidences().first(); |
3259 | } | 3272 | } |
3260 | } | 3273 | } |
3261 | if ( incidence && incidence->type() == "Event" ) { | 3274 | if ( incidence && incidence->type() == "Event" ) { |
3262 | event = static_cast<Event *>(incidence); | 3275 | event = static_cast<Event *>(incidence); |
3263 | } | 3276 | } |
3264 | if ( incidence && incidence->type() == "Todo" ) { | 3277 | if ( incidence && incidence->type() == "Todo" ) { |
3265 | todo = static_cast<Todo *>(incidence); | 3278 | todo = static_cast<Todo *>(incidence); |
3266 | } | 3279 | } |
3267 | 3280 | ||
3268 | if (!event && !todo) { | 3281 | if (!event && !todo) { |
3269 | KMessageBox::sorry(this,i18n("No event selected.")); | 3282 | KMessageBox::sorry(this,i18n("No event selected.")); |
3270 | return; | 3283 | return; |
3271 | } | 3284 | } |
3272 | 3285 | ||
3273 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3286 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3274 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3287 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3275 | return; | 3288 | return; |
3276 | } | 3289 | } |
3277 | 3290 | ||
3278 | Event *ev = 0; | 3291 | Event *ev = 0; |
3279 | if (event) ev = new Event(*event); | 3292 | if (event) ev = new Event(*event); |
3280 | Todo *to = 0; | 3293 | Todo *to = 0; |
3281 | if (todo) to = new Todo(*todo); | 3294 | if (todo) to = new Todo(*todo); |
3282 | 3295 | ||
3283 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3296 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3284 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3297 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3285 | if (!me) { | 3298 | if (!me) { |
3286 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3299 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3287 | return; | 3300 | return; |
3288 | } | 3301 | } |
3289 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3302 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3290 | StatusDialog *statdlg = new StatusDialog(this); | 3303 | StatusDialog *statdlg = new StatusDialog(this); |
3291 | if (!statdlg->exec()==QDialog::Accepted) return; | 3304 | if (!statdlg->exec()==QDialog::Accepted) return; |
3292 | me->setStatus( statdlg->status() ); | 3305 | me->setStatus( statdlg->status() ); |
3293 | delete(statdlg); | 3306 | delete(statdlg); |
3294 | } | 3307 | } |
3295 | Attendee *menew = new Attendee(*me); | 3308 | Attendee *menew = new Attendee(*me); |
3296 | if (ev) { | 3309 | if (ev) { |
3297 | ev->clearAttendees(); | 3310 | ev->clearAttendees(); |
3298 | ev->addAttendee(menew,false); | 3311 | ev->addAttendee(menew,false); |
3299 | } else { | 3312 | } else { |
3300 | if (to) { | 3313 | if (to) { |
3301 | todo->clearAttendees(); | 3314 | todo->clearAttendees(); |
3302 | todo->addAttendee(menew,false); | 3315 | todo->addAttendee(menew,false); |
3303 | } | 3316 | } |
3304 | } | 3317 | } |
3305 | } | 3318 | } |
3306 | 3319 | ||
3307 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3320 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3308 | if (ev) { | 3321 | if (ev) { |
3309 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3322 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3310 | } else { | 3323 | } else { |
3311 | if (to) { | 3324 | if (to) { |
3312 | if ( !dlg->addMessage(to,method) ) delete(to); | 3325 | if ( !dlg->addMessage(to,method) ) delete(to); |
3313 | } | 3326 | } |
3314 | } | 3327 | } |
3315 | } | 3328 | } |
3316 | 3329 | ||
3317 | void CalendarView::openAddressbook() | 3330 | void CalendarView::openAddressbook() |
3318 | { | 3331 | { |
3319 | KRun::runCommand("kaddressbook"); | 3332 | KRun::runCommand("kaddressbook"); |
3320 | } | 3333 | } |
3321 | 3334 | ||
3322 | void CalendarView::setModified(bool modified) | 3335 | void CalendarView::setModified(bool modified) |
3323 | { | 3336 | { |
3324 | if ( modified ) | 3337 | if ( modified ) |
3325 | emit signalmodified(); | 3338 | emit signalmodified(); |
3326 | if (mModified != modified) { | 3339 | if (mModified != modified) { |
3327 | mModified = modified; | 3340 | mModified = modified; |
3328 | emit modifiedChanged(mModified); | 3341 | emit modifiedChanged(mModified); |
3329 | } | 3342 | } |
3330 | } | 3343 | } |
3331 | 3344 | ||
3332 | bool CalendarView::isReadOnly() | 3345 | bool CalendarView::isReadOnly() |
3333 | { | 3346 | { |
3334 | return mReadOnly; | 3347 | return mReadOnly; |
3335 | } | 3348 | } |
3336 | 3349 | ||
3337 | void CalendarView::setReadOnly(bool readOnly) | 3350 | void CalendarView::setReadOnly(bool readOnly) |
3338 | { | 3351 | { |
3339 | if (mReadOnly != readOnly) { | 3352 | if (mReadOnly != readOnly) { |
3340 | mReadOnly = readOnly; | 3353 | mReadOnly = readOnly; |
3341 | emit readOnlyChanged(mReadOnly); | 3354 | emit readOnlyChanged(mReadOnly); |
3342 | } | 3355 | } |
3343 | } | 3356 | } |
3344 | 3357 | ||
3345 | bool CalendarView::isModified() | 3358 | bool CalendarView::isModified() |
3346 | { | 3359 | { |
3347 | return mModified; | 3360 | return mModified; |
3348 | } | 3361 | } |
3349 | 3362 | ||
3350 | void CalendarView::printSetup() | 3363 | void CalendarView::printSetup() |
3351 | { | 3364 | { |
3352 | #ifndef KORG_NOPRINTER | 3365 | #ifndef KORG_NOPRINTER |
3353 | createPrinter(); | 3366 | createPrinter(); |
3354 | 3367 | ||
3355 | mCalPrinter->setupPrinter(); | 3368 | mCalPrinter->setupPrinter(); |
3356 | #endif | 3369 | #endif |
3357 | } | 3370 | } |
3358 | 3371 | ||
3359 | void CalendarView::print() | 3372 | void CalendarView::print() |
3360 | { | 3373 | { |
3361 | #ifndef KORG_NOPRINTER | 3374 | #ifndef KORG_NOPRINTER |
3362 | createPrinter(); | 3375 | createPrinter(); |
3363 | 3376 | ||
3364 | DateList tmpDateList = mNavigator->selectedDates(); | 3377 | DateList tmpDateList = mNavigator->selectedDates(); |
3365 | mCalPrinter->print(CalPrinter::Month, | 3378 | mCalPrinter->print(CalPrinter::Month, |
3366 | tmpDateList.first(), tmpDateList.last()); | 3379 | tmpDateList.first(), tmpDateList.last()); |
3367 | #endif | 3380 | #endif |
3368 | } | 3381 | } |
3369 | 3382 | ||
3370 | void CalendarView::printPreview() | 3383 | void CalendarView::printPreview() |
3371 | { | 3384 | { |
3372 | #ifndef KORG_NOPRINTER | 3385 | #ifndef KORG_NOPRINTER |
3373 | kdDebug() << "CalendarView::printPreview()" << endl; | 3386 | kdDebug() << "CalendarView::printPreview()" << endl; |
3374 | 3387 | ||
3375 | createPrinter(); | 3388 | createPrinter(); |
3376 | 3389 | ||
3377 | DateList tmpDateList = mNavigator->selectedDates(); | 3390 | DateList tmpDateList = mNavigator->selectedDates(); |
3378 | 3391 | ||
3379 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3392 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3380 | tmpDateList.last()); | 3393 | tmpDateList.last()); |
3381 | #endif | 3394 | #endif |
3382 | } | 3395 | } |
3383 | 3396 | ||
3384 | void CalendarView::exportICalendar() | 3397 | void CalendarView::exportICalendar() |
3385 | { | 3398 | { |
3386 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3399 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3387 | 3400 | ||
3388 | // Force correct extension | 3401 | // Force correct extension |
3389 | if (filename.right(4) != ".ics") filename += ".ics"; | 3402 | if (filename.right(4) != ".ics") filename += ".ics"; |
3390 | 3403 | ||
3391 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3404 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3392 | storage.save(); | 3405 | storage.save(); |
3393 | } | 3406 | } |
3394 | 3407 | ||
3395 | bool CalendarView::exportVCalendar( QString filename ) | 3408 | bool CalendarView::exportVCalendar( QString filename ) |
3396 | { | 3409 | { |
3397 | if (mCalendar->journals().count() > 0) { | 3410 | if (mCalendar->journals().count() > 0) { |
3398 | int result = KMessageBox::warningContinueCancel(this, | 3411 | int result = KMessageBox::warningContinueCancel(this, |
3399 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3412 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3400 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3413 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3401 | true); | 3414 | true); |
3402 | if (result != KMessageBox::Continue) return false; | 3415 | if (result != KMessageBox::Continue) return false; |
3403 | } | 3416 | } |
3404 | 3417 | ||
3405 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3418 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3406 | 3419 | ||
3407 | // Force correct extension | 3420 | // Force correct extension |
3408 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3421 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3409 | 3422 | ||
3410 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3423 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3411 | return storage.save(); | 3424 | return storage.save(); |
3412 | 3425 | ||
3413 | } | 3426 | } |
3414 | 3427 | ||
3415 | void CalendarView::eventUpdated(Incidence *) | 3428 | void CalendarView::eventUpdated(Incidence *) |
3416 | { | 3429 | { |
3417 | setModified(); | 3430 | setModified(); |
3418 | // Don't call updateView here. The code, which has caused the update of the | 3431 | // Don't call updateView here. The code, which has caused the update of the |
3419 | // event is responsible for updating the view. | 3432 | // event is responsible for updating the view. |
3420 | // updateView(); | 3433 | // updateView(); |
3421 | } | 3434 | } |
3422 | 3435 | ||
3423 | void CalendarView::adaptNavigationUnits() | 3436 | void CalendarView::adaptNavigationUnits() |
3424 | { | 3437 | { |
3425 | if (mViewManager->currentView()->isEventView()) { | 3438 | if (mViewManager->currentView()->isEventView()) { |
3426 | int days = mViewManager->currentView()->currentDateCount(); | 3439 | int days = mViewManager->currentView()->currentDateCount(); |
3427 | if (days == 1) { | 3440 | if (days == 1) { |
3428 | emit changeNavStringPrev(i18n("&Previous Day")); | 3441 | emit changeNavStringPrev(i18n("&Previous Day")); |
3429 | emit changeNavStringNext(i18n("&Next Day")); | 3442 | emit changeNavStringNext(i18n("&Next Day")); |
3430 | } else { | 3443 | } else { |
3431 | emit changeNavStringPrev(i18n("&Previous Week")); | 3444 | emit changeNavStringPrev(i18n("&Previous Week")); |
3432 | emit changeNavStringNext(i18n("&Next Week")); | 3445 | emit changeNavStringNext(i18n("&Next Week")); |
3433 | } | 3446 | } |
3434 | } | 3447 | } |
3435 | } | 3448 | } |
3436 | 3449 | ||
3437 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3450 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3438 | { | 3451 | { |
3439 | if ( incidence ) mTodoList->clearSelection(); | 3452 | if ( incidence ) mTodoList->clearSelection(); |
3440 | processIncidenceSelection( incidence ); | 3453 | processIncidenceSelection( incidence ); |
3441 | } | 3454 | } |
3442 | 3455 | ||
3443 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3456 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3444 | { | 3457 | { |
3445 | if ( incidence && mViewManager->currentView() ) { | 3458 | if ( incidence && mViewManager->currentView() ) { |
3446 | mViewManager->currentView()->clearSelection(); | 3459 | mViewManager->currentView()->clearSelection(); |
3447 | } | 3460 | } |
3448 | processIncidenceSelection( incidence ); | 3461 | processIncidenceSelection( incidence ); |
3449 | } | 3462 | } |
3450 | 3463 | ||
3451 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3464 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3452 | { | 3465 | { |
3453 | if ( incidence == mSelectedIncidence ) return; | 3466 | if ( incidence == mSelectedIncidence ) return; |
3454 | 3467 | ||
3455 | mSelectedIncidence = incidence; | 3468 | mSelectedIncidence = incidence; |
3456 | 3469 | ||
3457 | emit incidenceSelected( mSelectedIncidence ); | 3470 | emit incidenceSelected( mSelectedIncidence ); |
3458 | 3471 | ||
3459 | if ( incidence && incidence->type() == "Event" ) { | 3472 | if ( incidence && incidence->type() == "Event" ) { |
3460 | Event *event = static_cast<Event *>( incidence ); | 3473 | Event *event = static_cast<Event *>( incidence ); |
3461 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3474 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3462 | emit organizerEventsSelected( true ); | 3475 | emit organizerEventsSelected( true ); |
3463 | } else { | 3476 | } else { |
3464 | emit organizerEventsSelected(false); | 3477 | emit organizerEventsSelected(false); |
3465 | } | 3478 | } |
3466 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3479 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3467 | KOPrefs::instance()->email() ) ) { | 3480 | KOPrefs::instance()->email() ) ) { |
3468 | emit groupEventsSelected( true ); | 3481 | emit groupEventsSelected( true ); |
3469 | } else { | 3482 | } else { |
3470 | emit groupEventsSelected(false); | 3483 | emit groupEventsSelected(false); |
3471 | } | 3484 | } |
3472 | return; | 3485 | return; |
3473 | } else { | 3486 | } else { |
3474 | if ( incidence && incidence->type() == "Todo" ) { | 3487 | if ( incidence && incidence->type() == "Todo" ) { |
3475 | emit todoSelected( true ); | 3488 | emit todoSelected( true ); |
3476 | Todo *event = static_cast<Todo *>( incidence ); | 3489 | Todo *event = static_cast<Todo *>( incidence ); |
3477 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3490 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3478 | emit organizerEventsSelected( true ); | 3491 | emit organizerEventsSelected( true ); |
3479 | } else { | 3492 | } else { |
3480 | emit organizerEventsSelected(false); | 3493 | emit organizerEventsSelected(false); |
3481 | } | 3494 | } |
3482 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3495 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3483 | KOPrefs::instance()->email() ) ) { | 3496 | KOPrefs::instance()->email() ) ) { |
3484 | emit groupEventsSelected( true ); | 3497 | emit groupEventsSelected( true ); |
3485 | } else { | 3498 | } else { |
3486 | emit groupEventsSelected(false); | 3499 | emit groupEventsSelected(false); |
3487 | } | 3500 | } |
3488 | return; | 3501 | return; |
3489 | } else { | 3502 | } else { |
3490 | emit todoSelected( false ); | 3503 | emit todoSelected( false ); |
3491 | emit organizerEventsSelected(false); | 3504 | emit organizerEventsSelected(false); |
3492 | emit groupEventsSelected(false); | 3505 | emit groupEventsSelected(false); |
3493 | } | 3506 | } |
3494 | return; | 3507 | return; |
3495 | } | 3508 | } |
3496 | 3509 | ||
3497 | /* if ( incidence && incidence->type() == "Todo" ) { | 3510 | /* if ( incidence && incidence->type() == "Todo" ) { |
3498 | emit todoSelected( true ); | 3511 | emit todoSelected( true ); |
3499 | } else { | 3512 | } else { |
3500 | emit todoSelected( false ); | 3513 | emit todoSelected( false ); |
3501 | }*/ | 3514 | }*/ |
3502 | } | 3515 | } |
3503 | 3516 | ||
3504 | 3517 | ||
3505 | void CalendarView::checkClipboard() | 3518 | void CalendarView::checkClipboard() |
3506 | { | 3519 | { |
3507 | #ifndef KORG_NODND | 3520 | #ifndef KORG_NODND |
3508 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3521 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3509 | emit pasteEnabled(true); | 3522 | emit pasteEnabled(true); |
3510 | } else { | 3523 | } else { |
3511 | emit pasteEnabled(false); | 3524 | emit pasteEnabled(false); |
3512 | } | 3525 | } |
3513 | #endif | 3526 | #endif |
3514 | } | 3527 | } |
3515 | 3528 | ||
3516 | void CalendarView::showDates(const DateList &selectedDates) | 3529 | void CalendarView::showDates(const DateList &selectedDates) |
3517 | { | 3530 | { |
3518 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3531 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3519 | 3532 | ||
3520 | 3533 | ||
3521 | if ( !mBlockShowDates ) { | 3534 | if ( !mBlockShowDates ) { |
3522 | if ( mViewManager->currentView() ) { | 3535 | if ( mViewManager->currentView() ) { |
3523 | updateView( selectedDates.first(), selectedDates.last() ); | 3536 | updateView( selectedDates.first(), selectedDates.last() ); |
3524 | } else { | 3537 | } else { |
3525 | mViewManager->showAgendaView(); | 3538 | mViewManager->showAgendaView(); |
3526 | } | 3539 | } |
3527 | } | 3540 | } |
3528 | 3541 | ||
3529 | QString selDates; | 3542 | QString selDates; |
3530 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3543 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3531 | if (selectedDates.first() < selectedDates.last() ) | 3544 | if (selectedDates.first() < selectedDates.last() ) |
3532 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3545 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3533 | else { | 3546 | else { |
3534 | QString addString; | 3547 | QString addString; |
3535 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3548 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3536 | addString = i18n("Today"); | 3549 | addString = i18n("Today"); |
3537 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3550 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3538 | addString = i18n("Tomorrow"); | 3551 | addString = i18n("Tomorrow"); |
3539 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3552 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3540 | addString = i18n("Yesterday"); | 3553 | addString = i18n("Yesterday"); |
3541 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3554 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3542 | addString = i18n("Day before yesterday"); | 3555 | addString = i18n("Day before yesterday"); |
3543 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3556 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3544 | addString = i18n("Day after tomorrow"); | 3557 | addString = i18n("Day after tomorrow"); |
3545 | if ( !addString.isEmpty() ) { | 3558 | if ( !addString.isEmpty() ) { |
3546 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3559 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3547 | return; | 3560 | return; |
3548 | } | 3561 | } |
3549 | } | 3562 | } |
3550 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3563 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3551 | 3564 | ||
3552 | } | 3565 | } |
3553 | 3566 | ||
3554 | QPtrList<CalFilter> CalendarView::filters() | 3567 | QPtrList<CalFilter> CalendarView::filters() |
3555 | { | 3568 | { |
3556 | return mFilters; | 3569 | return mFilters; |
3557 | 3570 | ||
3558 | } | 3571 | } |
3559 | void CalendarView::editFilters() | 3572 | void CalendarView::editFilters() |
3560 | { | 3573 | { |
3561 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3574 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3562 | 3575 | ||
3563 | CalFilter *filter = mFilters.first(); | 3576 | CalFilter *filter = mFilters.first(); |
3564 | while(filter) { | 3577 | while(filter) { |
3565 | kdDebug() << " Filter: " << filter->name() << endl; | 3578 | kdDebug() << " Filter: " << filter->name() << endl; |
3566 | filter = mFilters.next(); | 3579 | filter = mFilters.next(); |
3567 | } | 3580 | } |
3568 | 3581 | ||
3569 | mDialogManager->showFilterEditDialog(&mFilters); | 3582 | mDialogManager->showFilterEditDialog(&mFilters); |
3570 | } | 3583 | } |
3571 | void CalendarView::toggleFilter() | 3584 | void CalendarView::toggleFilter() |
3572 | { | 3585 | { |
3573 | showFilter(! mFilterView->isVisible()); | 3586 | showFilter(! mFilterView->isVisible()); |
3574 | } | 3587 | } |
3575 | 3588 | ||
3576 | KOFilterView *CalendarView::filterView() | 3589 | KOFilterView *CalendarView::filterView() |
3577 | { | 3590 | { |
3578 | return mFilterView; | 3591 | return mFilterView; |
3579 | } | 3592 | } |
3580 | void CalendarView::selectFilter( int fil ) | 3593 | void CalendarView::selectFilter( int fil ) |
3581 | { | 3594 | { |
3582 | mFilterView->setSelectedFilter( fil ); | 3595 | mFilterView->setSelectedFilter( fil ); |
3583 | } | 3596 | } |
3584 | void CalendarView::showFilter(bool visible) | 3597 | void CalendarView::showFilter(bool visible) |
3585 | { | 3598 | { |
3586 | if (visible) mFilterView->show(); | 3599 | if (visible) mFilterView->show(); |
3587 | else mFilterView->hide(); | 3600 | else mFilterView->hide(); |
3588 | } | 3601 | } |
3589 | void CalendarView::toggleFilerEnabled( ) | 3602 | void CalendarView::toggleFilerEnabled( ) |
3590 | { | 3603 | { |
3591 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3604 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3592 | if ( !mFilterView->filtersEnabled() ) | 3605 | if ( !mFilterView->filtersEnabled() ) |
3593 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3606 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3594 | 3607 | ||
3595 | } | 3608 | } |
3596 | void CalendarView::updateFilter() | 3609 | void CalendarView::updateFilter() |
3597 | { | 3610 | { |
3598 | CalFilter *filter = mFilterView->selectedFilter(); | 3611 | CalFilter *filter = mFilterView->selectedFilter(); |
3599 | if (filter) { | 3612 | if (filter) { |
3600 | if (mFilterView->filtersEnabled()) { | 3613 | if (mFilterView->filtersEnabled()) { |
3601 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3614 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3602 | filter->setEnabled(true); | 3615 | filter->setEnabled(true); |
3603 | } | 3616 | } |
3604 | else filter->setEnabled(false); | 3617 | else filter->setEnabled(false); |
3605 | mCalendar->setFilter(filter); | 3618 | mCalendar->setFilter(filter); |
3606 | updateView(); | 3619 | updateView(); |
3607 | } | 3620 | } |
3608 | } | 3621 | } |
3609 | 3622 | ||
3610 | void CalendarView::filterEdited() | 3623 | void CalendarView::filterEdited() |
3611 | { | 3624 | { |
3612 | mFilterView->updateFilters(); | 3625 | mFilterView->updateFilters(); |
3613 | updateFilter(); | 3626 | updateFilter(); |
3614 | writeSettings(); | 3627 | writeSettings(); |
3615 | } | 3628 | } |
3616 | 3629 | ||
3617 | 3630 | ||
3618 | void CalendarView::takeOverEvent() | 3631 | void CalendarView::takeOverEvent() |
3619 | { | 3632 | { |
3620 | Incidence *incidence = currentSelection(); | 3633 | Incidence *incidence = currentSelection(); |
3621 | 3634 | ||
3622 | if (!incidence) return; | 3635 | if (!incidence) return; |
3623 | 3636 | ||
3624 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3637 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3625 | incidence->recreate(); | 3638 | incidence->recreate(); |
3626 | incidence->setReadOnly(false); | 3639 | incidence->setReadOnly(false); |
3627 | 3640 | ||
3628 | updateView(); | 3641 | updateView(); |
3629 | } | 3642 | } |
3630 | 3643 | ||
3631 | void CalendarView::takeOverCalendar() | 3644 | void CalendarView::takeOverCalendar() |
3632 | { | 3645 | { |
3633 | // TODO: Create Calendar::allIncidences() function and use it here | 3646 | // TODO: Create Calendar::allIncidences() function and use it here |
3634 | 3647 | ||
3635 | QPtrList<Event> events = mCalendar->events(); | 3648 | QPtrList<Event> events = mCalendar->events(); |
3636 | for(uint i=0; i<events.count(); ++i) { | 3649 | for(uint i=0; i<events.count(); ++i) { |
3637 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3650 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3638 | events.at(i)->recreate(); | 3651 | events.at(i)->recreate(); |
3639 | events.at(i)->setReadOnly(false); | 3652 | events.at(i)->setReadOnly(false); |
3640 | } | 3653 | } |
3641 | 3654 | ||
3642 | QPtrList<Todo> todos = mCalendar->todos(); | 3655 | QPtrList<Todo> todos = mCalendar->todos(); |
3643 | for(uint i=0; i<todos.count(); ++i) { | 3656 | for(uint i=0; i<todos.count(); ++i) { |
3644 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3657 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3645 | todos.at(i)->recreate(); | 3658 | todos.at(i)->recreate(); |
3646 | todos.at(i)->setReadOnly(false); | 3659 | todos.at(i)->setReadOnly(false); |
3647 | } | 3660 | } |
3648 | 3661 | ||
3649 | QPtrList<Journal> journals = mCalendar->journals(); | 3662 | QPtrList<Journal> journals = mCalendar->journals(); |
3650 | for(uint i=0; i<journals.count(); ++i) { | 3663 | for(uint i=0; i<journals.count(); ++i) { |
3651 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3664 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3652 | journals.at(i)->recreate(); | 3665 | journals.at(i)->recreate(); |
3653 | journals.at(i)->setReadOnly(false); | 3666 | journals.at(i)->setReadOnly(false); |
3654 | } | 3667 | } |
3655 | 3668 | ||
3656 | updateView(); | 3669 | updateView(); |
3657 | } | 3670 | } |
3658 | 3671 | ||
3659 | void CalendarView::showIntro() | 3672 | void CalendarView::showIntro() |
3660 | { | 3673 | { |
3661 | kdDebug() << "To be implemented." << endl; | 3674 | kdDebug() << "To be implemented." << endl; |
3662 | } | 3675 | } |
3663 | 3676 | ||
3664 | QWidgetStack *CalendarView::viewStack() | 3677 | QWidgetStack *CalendarView::viewStack() |
3665 | { | 3678 | { |
3666 | return mRightFrame; | 3679 | return mRightFrame; |
3667 | } | 3680 | } |
3668 | 3681 | ||
3669 | QWidget *CalendarView::leftFrame() | 3682 | QWidget *CalendarView::leftFrame() |
3670 | { | 3683 | { |
3671 | return mLeftFrame; | 3684 | return mLeftFrame; |
3672 | } | 3685 | } |
3673 | 3686 | ||
3674 | DateNavigator *CalendarView::dateNavigator() | 3687 | DateNavigator *CalendarView::dateNavigator() |
3675 | { | 3688 | { |
3676 | return mNavigator; | 3689 | return mNavigator; |
3677 | } | 3690 | } |
3678 | 3691 | ||
3679 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3692 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3680 | { | 3693 | { |
3681 | return mDateNavigator; | 3694 | return mDateNavigator; |
3682 | } | 3695 | } |
3683 | void CalendarView::toggleDateNavigatorWidget() | 3696 | void CalendarView::toggleDateNavigatorWidget() |
3684 | { | 3697 | { |
3685 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3698 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3686 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3699 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3687 | mDateNavigator->hide(); | 3700 | mDateNavigator->hide(); |
3688 | else | 3701 | else |
3689 | mDateNavigator->show(); | 3702 | mDateNavigator->show(); |
3690 | } | 3703 | } |
3691 | void CalendarView::addView(KOrg::BaseView *view) | 3704 | void CalendarView::addView(KOrg::BaseView *view) |
3692 | { | 3705 | { |
3693 | mViewManager->addView(view); | 3706 | mViewManager->addView(view); |
3694 | } | 3707 | } |
3695 | 3708 | ||
3696 | void CalendarView::showView(KOrg::BaseView *view) | 3709 | void CalendarView::showView(KOrg::BaseView *view) |
3697 | { | 3710 | { |
3698 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3711 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3699 | } | 3712 | } |
3700 | 3713 | ||
3701 | Incidence *CalendarView::currentSelection() | 3714 | Incidence *CalendarView::currentSelection() |
3702 | { | 3715 | { |
3703 | return mViewManager->currentSelection(); | 3716 | return mViewManager->currentSelection(); |
3704 | } | 3717 | } |
3705 | void CalendarView::toggleAllDaySize() | 3718 | void CalendarView::toggleAllDaySize() |
3706 | { | 3719 | { |
3707 | /* | 3720 | /* |
3708 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3721 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3709 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3722 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3710 | else | 3723 | else |
3711 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3724 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3712 | */ | 3725 | */ |
3713 | viewManager()->agendaView()->toggleAllDay(); | 3726 | viewManager()->agendaView()->toggleAllDay(); |
3714 | } | 3727 | } |
3715 | void CalendarView::toggleExpand() | 3728 | void CalendarView::toggleExpand() |
3716 | { | 3729 | { |
3717 | // if ( mLeftFrame->isHidden() ) { | 3730 | // if ( mLeftFrame->isHidden() ) { |
3718 | // mLeftFrame->show(); | 3731 | // mLeftFrame->show(); |
3719 | // emit calendarViewExpanded( false ); | 3732 | // emit calendarViewExpanded( false ); |
3720 | // } else { | 3733 | // } else { |
3721 | // mLeftFrame->hide(); | 3734 | // mLeftFrame->hide(); |
3722 | // emit calendarViewExpanded( true ); | 3735 | // emit calendarViewExpanded( true ); |
3723 | // } | 3736 | // } |
3724 | //qDebug(" CalendarView::toggleExpand()"); | 3737 | //qDebug(" CalendarView::toggleExpand()"); |
3725 | globalFlagBlockAgenda = 1; | 3738 | globalFlagBlockAgenda = 1; |
3726 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3739 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3727 | globalFlagBlockAgenda = 5; | 3740 | globalFlagBlockAgenda = 5; |
3728 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3741 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3729 | //mViewManager->showView( 0, true ); | 3742 | //mViewManager->showView( 0, true ); |
3730 | } | 3743 | } |
3731 | 3744 | ||
3732 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3745 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3733 | { | 3746 | { |
3734 | setModified( modified ); | 3747 | setModified( modified ); |
3735 | } | 3748 | } |
3736 | 3749 | ||
3737 | Todo *CalendarView::selectedTodo() | 3750 | Todo *CalendarView::selectedTodo() |
3738 | { | 3751 | { |
3739 | Incidence *incidence = currentSelection(); | 3752 | Incidence *incidence = currentSelection(); |
3740 | if ( incidence && incidence->type() == "Todo" ) { | 3753 | if ( incidence && incidence->type() == "Todo" ) { |
3741 | return static_cast<Todo *>( incidence ); | 3754 | return static_cast<Todo *>( incidence ); |
3742 | } | 3755 | } |
3743 | 3756 | ||
3744 | incidence = mTodoList->selectedIncidences().first(); | 3757 | incidence = mTodoList->selectedIncidences().first(); |
3745 | if ( incidence && incidence->type() == "Todo" ) { | 3758 | if ( incidence && incidence->type() == "Todo" ) { |
3746 | return static_cast<Todo *>( incidence ); | 3759 | return static_cast<Todo *>( incidence ); |
3747 | } | 3760 | } |
3748 | 3761 | ||
3749 | return 0; | 3762 | return 0; |
3750 | } | 3763 | } |
3751 | 3764 | ||
3752 | void CalendarView::dialogClosing(Incidence *in) | 3765 | void CalendarView::dialogClosing(Incidence *in) |
3753 | { | 3766 | { |
3754 | // mDialogList.remove(in); | 3767 | // mDialogList.remove(in); |
3755 | } | 3768 | } |
3756 | 3769 | ||
3757 | void CalendarView::showIncidence() | 3770 | void CalendarView::showIncidence() |
3758 | { | 3771 | { |
3759 | mViewerCallerIsSearchDialog = false; | 3772 | mViewerCallerIsSearchDialog = false; |
3760 | Incidence *incidence = currentSelection(); | 3773 | Incidence *incidence = currentSelection(); |
3761 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3774 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3762 | if ( incidence ) { | 3775 | if ( incidence ) { |
3763 | ShowIncidenceVisitor v; | 3776 | ShowIncidenceVisitor v; |
3764 | v.act( incidence, this ); | 3777 | v.act( incidence, this ); |
3765 | } | 3778 | } |
3766 | } | 3779 | } |
3767 | void CalendarView::editIncidenceDescription() | 3780 | void CalendarView::editIncidenceDescription() |
3768 | { | 3781 | { |
3769 | mFlagEditDescription = true; | 3782 | mFlagEditDescription = true; |
3770 | editIncidence(); | 3783 | editIncidence(); |
3771 | mFlagEditDescription = false; | 3784 | mFlagEditDescription = false; |
3772 | } | 3785 | } |
3773 | void CalendarView::editIncidence() | 3786 | void CalendarView::editIncidence() |
3774 | { | 3787 | { |
3775 | // qDebug("editIncidence() "); | 3788 | // qDebug("editIncidence() "); |
3776 | Incidence *incidence = currentSelection(); | 3789 | Incidence *incidence = currentSelection(); |
3777 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3790 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3778 | if ( incidence ) { | 3791 | if ( incidence ) { |
3779 | EditIncidenceVisitor v; | 3792 | EditIncidenceVisitor v; |
3780 | v.act( incidence, this ); | 3793 | v.act( incidence, this ); |
3781 | } | 3794 | } |
3782 | } | 3795 | } |
3783 | 3796 | ||
3784 | void CalendarView::deleteIncidence() | 3797 | void CalendarView::deleteIncidence() |
3785 | { | 3798 | { |
3786 | Incidence *incidence = currentSelection(); | 3799 | Incidence *incidence = currentSelection(); |
3787 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3800 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3788 | if ( incidence ) { | 3801 | if ( incidence ) { |
3789 | deleteIncidence(incidence); | 3802 | deleteIncidence(incidence); |
3790 | } | 3803 | } |
3791 | } | 3804 | } |
3792 | 3805 | ||
3793 | void CalendarView::showIncidence(Incidence *incidence) | 3806 | void CalendarView::showIncidence(Incidence *incidence) |
3794 | { | 3807 | { |
3795 | mViewerCallerIsSearchDialog = false; | 3808 | mViewerCallerIsSearchDialog = false; |
3796 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3809 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3797 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3810 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3798 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3811 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3799 | mViewerCallerIsSearchDialog = true; | 3812 | mViewerCallerIsSearchDialog = true; |
3800 | } | 3813 | } |
3801 | } | 3814 | } |
3802 | if ( incidence ) { | 3815 | if ( incidence ) { |
3803 | ShowIncidenceVisitor v; | 3816 | ShowIncidenceVisitor v; |
3804 | v.act( incidence, this ); | 3817 | v.act( incidence, this ); |
3805 | } | 3818 | } |
3806 | } | 3819 | } |
3807 | 3820 | ||
3808 | void CalendarView::editIncidence(Incidence *incidence) | 3821 | void CalendarView::editIncidence(Incidence *incidence) |
3809 | { | 3822 | { |
3810 | if ( incidence ) { | 3823 | if ( incidence ) { |
3811 | 3824 | ||
3812 | EditIncidenceVisitor v; | 3825 | EditIncidenceVisitor v; |
3813 | v.act( incidence, this ); | 3826 | v.act( incidence, this ); |
3814 | 3827 | ||
3815 | } | 3828 | } |
3816 | } | 3829 | } |
3817 | 3830 | ||
3818 | void CalendarView::deleteIncidence(Incidence *incidence) | 3831 | void CalendarView::deleteIncidence(Incidence *incidence) |
3819 | { | 3832 | { |
3820 | //qDebug(" CalendarView::deleteIncidence "); | 3833 | //qDebug(" CalendarView::deleteIncidence "); |
3821 | if ( incidence ) { | 3834 | if ( incidence ) { |
3822 | DeleteIncidenceVisitor v; | 3835 | DeleteIncidenceVisitor v; |
3823 | v.act( incidence, this ); | 3836 | v.act( incidence, this ); |
3824 | } | 3837 | } |
3825 | } | 3838 | } |
3826 | 3839 | ||
3827 | 3840 | ||
3828 | void CalendarView::lookForOutgoingMessages() | 3841 | void CalendarView::lookForOutgoingMessages() |
3829 | { | 3842 | { |
3830 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3843 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3831 | ogd->loadMessages(); | 3844 | ogd->loadMessages(); |
3832 | } | 3845 | } |
3833 | 3846 | ||
3834 | void CalendarView::lookForIncomingMessages() | 3847 | void CalendarView::lookForIncomingMessages() |
3835 | { | 3848 | { |
3836 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3849 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3837 | icd->retrieve(); | 3850 | icd->retrieve(); |
3838 | } | 3851 | } |
3839 | 3852 | ||
3840 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3853 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3841 | { | 3854 | { |
3842 | bool deleteTodo = true; | 3855 | bool deleteTodo = true; |
3843 | QPtrList<Incidence> subTodos; | 3856 | QPtrList<Incidence> subTodos; |
3844 | Incidence *aTodo; | 3857 | Incidence *aTodo; |
3845 | subTodos = t->relations(); | 3858 | subTodos = t->relations(); |
3846 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3859 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3847 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3860 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3848 | deleteTodo = false; | 3861 | deleteTodo = false; |
3849 | } | 3862 | } |
3850 | if ( deleteTodo ) { | 3863 | if ( deleteTodo ) { |
3851 | if ( t->isCompleted() && !t->doesRecur()) { | 3864 | if ( t->isCompleted() && !t->doesRecur()) { |
3852 | checkExternalId( t ); | 3865 | checkExternalId( t ); |
3853 | mCalendar->deleteTodo( t ); | 3866 | mCalendar->deleteTodo( t ); |
3854 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3867 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3855 | } | 3868 | } |
3856 | else | 3869 | else |
3857 | deleteTodo = false; | 3870 | deleteTodo = false; |
3858 | } | 3871 | } |
3859 | return deleteTodo; | 3872 | return deleteTodo; |
3860 | 3873 | ||
3861 | } | 3874 | } |
3862 | void CalendarView::purgeCompleted() | 3875 | void CalendarView::purgeCompleted() |
3863 | { | 3876 | { |
3864 | int result = KMessageBox::warningContinueCancel(this, | 3877 | int result = KMessageBox::warningContinueCancel(this, |
3865 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3878 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3866 | 3879 | ||
3867 | if (result == KMessageBox::Continue) { | 3880 | if (result == KMessageBox::Continue) { |
3868 | 3881 | ||
3869 | QPtrList<Todo> todoCal; | 3882 | QPtrList<Todo> todoCal; |
3870 | QPtrList<Todo> rootTodos; | 3883 | QPtrList<Todo> rootTodos; |
3871 | //QPtrList<Incidence> rel; | 3884 | //QPtrList<Incidence> rel; |
3872 | Todo *aTodo;//, *rTodo; | 3885 | Todo *aTodo;//, *rTodo; |
3873 | Incidence *rIncidence; | 3886 | Incidence *rIncidence; |
3874 | bool childDelete = false; | 3887 | bool childDelete = false; |
3875 | bool deletedOne = true; | 3888 | bool deletedOne = true; |
3876 | todoCal = calendar()->todos(); | 3889 | todoCal = calendar()->todos(); |
3877 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3890 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3878 | if ( !aTodo->relatedTo() ) | 3891 | if ( !aTodo->relatedTo() ) |
3879 | rootTodos.append( aTodo ); | 3892 | rootTodos.append( aTodo ); |
3880 | } | 3893 | } |
3881 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3894 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3882 | removeCompletedSubTodos( aTodo ); | 3895 | removeCompletedSubTodos( aTodo ); |
3883 | } | 3896 | } |
3884 | 3897 | ||
3885 | updateView(); | 3898 | updateView(); |
3886 | } | 3899 | } |
3887 | } | 3900 | } |
3888 | 3901 | ||
3889 | void CalendarView::slotCalendarChanged() | 3902 | void CalendarView::slotCalendarChanged() |
3890 | { | 3903 | { |
3891 | ; | 3904 | ; |
3892 | } | 3905 | } |
3893 | 3906 | ||
3894 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3907 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3895 | { | 3908 | { |
3896 | //qDebug(" alendarView::keyPressEvent "); | 3909 | //qDebug(" alendarView::keyPressEvent "); |
3897 | e->ignore(); | 3910 | e->ignore(); |
3898 | } | 3911 | } |
3899 | 3912 | ||
3900 | 3913 | ||
3901 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3914 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3902 | { | 3915 | { |
3903 | // mSyncManager = manager; | 3916 | // mSyncManager = manager; |
3904 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3917 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3905 | qDebug("KO: SyncKDE request detected!"); | 3918 | qDebug("KO: SyncKDE request detected!"); |
3906 | } | 3919 | } |
3907 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3920 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3908 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3921 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3909 | return syncCalendar( filename, mode ); | 3922 | return syncCalendar( filename, mode ); |
3910 | } | 3923 | } |
3911 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3924 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3912 | { | 3925 | { |
3913 | //mSyncManager = manager; | 3926 | //mSyncManager = manager; |
3914 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3927 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3915 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3928 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3916 | if ( resource == "sharp" ) | 3929 | if ( resource == "sharp" ) |
3917 | syncExternal( 0 ); | 3930 | syncExternal( 0 ); |
3918 | if ( resource == "phone" ) | 3931 | if ( resource == "phone" ) |
3919 | syncExternal( 1 ); | 3932 | syncExternal( 1 ); |
3920 | // pending setmodified | 3933 | // pending setmodified |
3921 | return true; | 3934 | return true; |
3922 | } | 3935 | } |
3923 | void CalendarView::setSyncManager(KSyncManager* manager) | 3936 | void CalendarView::setSyncManager(KSyncManager* manager) |
3924 | { | 3937 | { |
3925 | mSyncManager = manager; | 3938 | mSyncManager = manager; |
3926 | } | 3939 | } |
3927 | 3940 | ||
3928 | void CalendarView::removeSyncInfo( QString syncProfile) | 3941 | void CalendarView::removeSyncInfo( QString syncProfile) |
3929 | { | 3942 | { |
3930 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3943 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3931 | mCalendar->removeSyncInfo( syncProfile ); | 3944 | mCalendar->removeSyncInfo( syncProfile ); |
3932 | 3945 | ||
3933 | } | 3946 | } |
3934 | 3947 | ||
3935 | void CalendarView::undo_delete() | 3948 | void CalendarView::undo_delete() |
3936 | { | 3949 | { |
3937 | //qDebug("undo_delete() "); | 3950 | //qDebug("undo_delete() "); |
3938 | Incidence* undo = mCalendar->undoIncidence(); | 3951 | Incidence* undo = mCalendar->undoIncidence(); |
3939 | if ( !undo ) { | 3952 | if ( !undo ) { |
3940 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3953 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3941 | i18n("KO/Pi")); | 3954 | i18n("KO/Pi")); |
3942 | return; | 3955 | return; |
3943 | } | 3956 | } |
3944 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3957 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3945 | i18n("\nAre you sure you want\nto restore this?"), | 3958 | i18n("\nAre you sure you want\nto restore this?"), |
3946 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3959 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3947 | mCalendar->undoDeleteIncidence(); | 3960 | mCalendar->undoDeleteIncidence(); |
3948 | updateView(); | 3961 | updateView(); |
3949 | } | 3962 | } |
3950 | } | 3963 | } |
3951 | 3964 | ||
3952 | void CalendarView::slotViewerClosed() | 3965 | void CalendarView::slotViewerClosed() |
3953 | { | 3966 | { |
3954 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 3967 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
3955 | } | 3968 | } |
3956 | 3969 | ||
3957 | void CalendarView::resetFocus() | 3970 | void CalendarView::resetFocus() |
3958 | { | 3971 | { |
3959 | if ( mViewerCallerIsSearchDialog ) { | 3972 | if ( mViewerCallerIsSearchDialog ) { |
3960 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 3973 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
3961 | mDialogManager->getSearchDialog()->raise(); | 3974 | mDialogManager->getSearchDialog()->raise(); |
3962 | mDialogManager->getSearchDialog()->setActiveWindow(); | 3975 | mDialogManager->getSearchDialog()->setActiveWindow(); |
3963 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 3976 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
3964 | } else | 3977 | } else |
3965 | mViewerCallerIsSearchDialog = false; | 3978 | mViewerCallerIsSearchDialog = false; |
3966 | } | 3979 | } |
3967 | if ( !mViewerCallerIsSearchDialog ) { | 3980 | if ( !mViewerCallerIsSearchDialog ) { |
3968 | //mViewManager->currentView()->setFocus(); | 3981 | //mViewManager->currentView()->setFocus(); |
3969 | //qDebug("sssssssssssssssset focus "); | 3982 | //qDebug("sssssssssssssssset focus "); |
3983 | topLevelWidget()->raise(); | ||
3970 | setActiveWindow(); | 3984 | setActiveWindow(); |
3971 | //setFocus(); | 3985 | //setFocus(); |
3972 | } | 3986 | } |
3973 | mViewerCallerIsSearchDialog = false; | 3987 | mViewerCallerIsSearchDialog = false; |
3974 | } | 3988 | } |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 195b1fa..ec81d44 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,2040 +1,2063 @@ | |||
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 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
66 | { | 66 | { |
67 | setLineWidth(0); | 67 | setLineWidth(0); |
68 | setMargin(0); | 68 | setMargin(0); |
69 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
70 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
72 | minutes->start(0, true); | 72 | minutes->start(0, true); |
73 | 73 | ||
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | delete minutes; | 88 | delete minutes; |
89 | } | 89 | } |
90 | 90 | ||
91 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
92 | { | 92 | { |
93 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
94 | 94 | ||
95 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
97 | int col = 0; | 97 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
102 | ++col; | 102 | ++col; |
103 | } | 103 | } |
104 | 104 | ||
105 | return -1; | 105 | return -1; |
106 | } | 106 | } |
107 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
108 | { | 108 | { |
109 | updateLocation(); | 109 | updateLocation(); |
110 | } | 110 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 112 | { |
113 | 113 | ||
114 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 117 | recalculate = true; |
118 | 118 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 125 | ||
126 | oldTime = tim; | 126 | oldTime = tim; |
127 | oldToday = today; | 127 | oldToday = today; |
128 | 128 | ||
129 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
131 | return; | 131 | return; |
132 | } else { | 132 | } else { |
133 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
134 | } | 134 | } |
135 | 135 | ||
136 | if(recalculate) | 136 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
139 | raise(); | 139 | raise(); |
140 | 140 | ||
141 | if(recalculate) | 141 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 144 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 146 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 147 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 148 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 149 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 150 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 151 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 153 | y-mTimeBox->height()); |
154 | 154 | ||
155 | mTimeBox->raise(); | 155 | mTimeBox->raise(); |
156 | //mTimeBox->setAutoMask(true); | 156 | //mTimeBox->setAutoMask(true); |
157 | minutes->start(5000,true); | 157 | minutes->start(5000,true); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 161 | //////////////////////////////////////////////////////////////////////////// |
162 | 162 | ||
163 | 163 | ||
164 | /* | 164 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 165 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 166 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 168 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 169 | QScrollView(parent,name,f) |
170 | { | 170 | { |
171 | 171 | ||
172 | 172 | ||
173 | mColumns = columns; | 173 | mColumns = columns; |
174 | mRows = rows; | 174 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 175 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 176 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 177 | #ifndef DESKTOP_VERSION |
178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 178 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 179 | #endif |
180 | mHolidayMask = 0; | 180 | mHolidayMask = 0; |
181 | init(); | 181 | init(); |
182 | } | 182 | } |
183 | 183 | ||
184 | /* | 184 | /* |
185 | Create an agenda widget with columns columns and one row. This is used for | 185 | Create an agenda widget with columns columns and one row. This is used for |
186 | all-day events. | 186 | all-day events. |
187 | */ | 187 | */ |
188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 188 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
189 | QScrollView(parent,name,f) | 189 | QScrollView(parent,name,f) |
190 | { | 190 | { |
191 | blockResize = false; | 191 | blockResize = false; |
192 | mColumns = columns; | 192 | mColumns = columns; |
193 | mRows = 1; | 193 | mRows = 1; |
194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 194 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 195 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
196 | mAllDayMode = true; | 196 | mAllDayMode = true; |
197 | #ifndef DESKTOP_VERSION | 197 | #ifndef DESKTOP_VERSION |
198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 198 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
199 | #endif | 199 | #endif |
200 | mHolidayMask = 0; | 200 | mHolidayMask = 0; |
201 | init(); | 201 | init(); |
202 | } | 202 | } |
203 | 203 | ||
204 | 204 | ||
205 | KOAgenda::~KOAgenda() | 205 | KOAgenda::~KOAgenda() |
206 | { | 206 | { |
207 | if(mMarcusBains) delete mMarcusBains; | 207 | if(mMarcusBains) delete mMarcusBains; |
208 | 208 | ||
209 | } | 209 | } |
210 | 210 | ||
211 | Incidence *KOAgenda::selectedIncidence() const | 211 | Incidence *KOAgenda::selectedIncidence() const |
212 | { | 212 | { |
213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 213 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | QDate KOAgenda::selectedIncidenceDate() const | 217 | QDate KOAgenda::selectedIncidenceDate() const |
218 | { | 218 | { |
219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 219 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
220 | } | 220 | } |
221 | 221 | ||
222 | 222 | ||
223 | void KOAgenda::init() | 223 | void KOAgenda::init() |
224 | { | 224 | { |
225 | mNewItemPopup = new QPopupMenu( this ); | 225 | mNewItemPopup = new QPopupMenu( this ); |
226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 226 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
227 | QString pathString = ""; | 227 | QString pathString = ""; |
228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 228 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
229 | if ( QApplication::desktop()->width() < 480 ) | 229 | if ( QApplication::desktop()->width() < 480 ) |
230 | pathString += "icons16/"; | 230 | pathString += "icons16/"; |
231 | } else | 231 | } else |
232 | pathString += "iconsmini/"; | 232 | pathString += "iconsmini/"; |
233 | 233 | ||
234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 234 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 235 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
236 | mNewItemPopup->insertSeparator ( ); | 236 | mNewItemPopup->insertSeparator ( ); |
237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 237 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 238 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); | 241 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
243 | #ifndef _WIN32_ | 243 | #ifndef _WIN32_ |
244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 244 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
245 | viewport()->setWFlags ( wflags); | 245 | viewport()->setWFlags ( wflags); |
246 | #endif | 246 | #endif |
247 | mGridSpacingX = 80; | 247 | mGridSpacingX = 80; |
248 | mResizeBorderWidth = 8; | 248 | mResizeBorderWidth = 8; |
249 | mScrollBorderWidth = 8; | 249 | mScrollBorderWidth = 8; |
250 | mScrollDelay = 30; | 250 | mScrollDelay = 30; |
251 | mScrollOffset = 10; | 251 | mScrollOffset = 10; |
252 | mPaintPixmap.resize( 20,20); | 252 | mPaintPixmap.resize( 20,20); |
253 | //enableClipper(true); | 253 | //enableClipper(true); |
254 | 254 | ||
255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 255 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
256 | // effect. Has to be fixed. | 256 | // effect. Has to be fixed. |
257 | setFocusPolicy(WheelFocus); | 257 | setFocusPolicy(WheelFocus); |
258 | 258 | ||
259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 259 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 260 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 261 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
262 | 262 | ||
263 | mStartCellX = 0; | 263 | mStartCellX = 0; |
264 | mStartCellY = 0; | 264 | mStartCellY = 0; |
265 | mCurrentCellX = 0; | 265 | mCurrentCellX = 0; |
266 | mCurrentCellY = 0; | 266 | mCurrentCellY = 0; |
267 | 267 | ||
268 | mSelectionCellX = 0; | 268 | mSelectionCellX = 0; |
269 | mSelectionYTop = 0; | 269 | mSelectionYTop = 0; |
270 | mSelectionHeight = 0; | 270 | mSelectionHeight = 0; |
271 | 271 | ||
272 | mOldLowerScrollValue = -1; | 272 | mOldLowerScrollValue = -1; |
273 | mOldUpperScrollValue = -1; | 273 | mOldUpperScrollValue = -1; |
274 | 274 | ||
275 | mClickedItem = 0; | 275 | mClickedItem = 0; |
276 | 276 | ||
277 | mActionItem = 0; | 277 | mActionItem = 0; |
278 | mActionType = NOP; | 278 | mActionType = NOP; |
279 | mItemMoved = false; | 279 | mItemMoved = false; |
280 | 280 | ||
281 | mSelectedItem = 0; | 281 | mSelectedItem = 0; |
282 | 282 | ||
283 | // mItems.setAutoDelete(true); | 283 | // mItems.setAutoDelete(true); |
284 | 284 | ||
285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 285 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
286 | 286 | ||
287 | viewport()->update(); | 287 | viewport()->update(); |
288 | 288 | ||
289 | setMinimumSize(30, 1); | 289 | setMinimumSize(30, 1); |
290 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 290 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
291 | 291 | ||
292 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 292 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
293 | // controlled in a way that the contents horizontally always fits. Then it is | 293 | // controlled in a way that the contents horizontally always fits. Then it is |
294 | // not necessary to turn off the scrollbar. | 294 | // not necessary to turn off the scrollbar. |
295 | setHScrollBarMode(AlwaysOff); | 295 | setHScrollBarMode(AlwaysOff); |
296 | if ( ! mAllDayMode ) | 296 | if ( ! mAllDayMode ) |
297 | setVScrollBarMode(AlwaysOn); | 297 | setVScrollBarMode(AlwaysOn); |
298 | else | 298 | else |
299 | setVScrollBarMode(AlwaysOff); | 299 | setVScrollBarMode(AlwaysOff); |
300 | 300 | ||
301 | setStartHour(KOPrefs::instance()->mDayBegins); | 301 | setStartHour(KOPrefs::instance()->mDayBegins); |
302 | 302 | ||
303 | calculateWorkingHours(); | 303 | calculateWorkingHours(); |
304 | 304 | ||
305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 305 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
306 | SLOT(checkScrollBoundaries(int))); | 306 | SLOT(checkScrollBoundaries(int))); |
307 | 307 | ||
308 | // Create the Marcus Bains line. | 308 | // Create the Marcus Bains line. |
309 | if(mAllDayMode) | 309 | if(mAllDayMode) |
310 | mMarcusBains = 0; | 310 | mMarcusBains = 0; |
311 | else { | 311 | else { |
312 | mMarcusBains = new MarcusBains(this); | 312 | mMarcusBains = new MarcusBains(this); |
313 | addChild(mMarcusBains); | 313 | addChild(mMarcusBains); |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOAgenda::clear() | 317 | void KOAgenda::clear() |
318 | { | 318 | { |
319 | KOAgendaItem *item; | 319 | KOAgendaItem *item; |
320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 320 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
321 | mUnusedItems.append( item ); | 321 | mUnusedItems.append( item ); |
322 | //item->hide(); | 322 | //item->hide(); |
323 | } | 323 | } |
324 | mItems.clear(); | 324 | mItems.clear(); |
325 | mSelectedItem = 0; | 325 | mSelectedItem = 0; |
326 | clearSelection(); | 326 | clearSelection(); |
327 | } | 327 | } |
328 | 328 | ||
329 | void KOAgenda::clearSelection() | 329 | void KOAgenda::clearSelection() |
330 | { | 330 | { |
331 | mSelectionCellX = 0; | 331 | mSelectionCellX = 0; |
332 | mSelectionYTop = 0; | 332 | mSelectionYTop = 0; |
333 | mSelectionHeight = 0; | 333 | mSelectionHeight = 0; |
334 | } | 334 | } |
335 | 335 | ||
336 | void KOAgenda::marcus_bains() | 336 | void KOAgenda::marcus_bains() |
337 | { | 337 | { |
338 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 338 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
339 | } | 339 | } |
340 | 340 | ||
341 | 341 | ||
342 | void KOAgenda::changeColumns(int columns) | 342 | void KOAgenda::changeColumns(int columns) |
343 | { | 343 | { |
344 | if (columns == 0) { | 344 | if (columns == 0) { |
345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; | 345 | kdDebug() << "KOAgenda::changeColumns() called with argument 0" << endl; |
346 | return; | 346 | return; |
347 | } | 347 | } |
348 | 348 | ||
349 | clear(); | 349 | clear(); |
350 | 350 | ||
351 | mColumns = columns; | 351 | mColumns = columns; |
352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); | 352 | // setMinimumSize(mColumns * 10, mGridSpacingY + 1); |
353 | // init(); | 353 | // init(); |
354 | // update(); | 354 | // update(); |
355 | //qDebug("KOAgenda::changeColumns "); | 355 | //qDebug("KOAgenda::changeColumns "); |
356 | computeSizes(); | 356 | computeSizes(); |
357 | // QResizeEvent event( size(), size() ); | 357 | // QResizeEvent event( size(), size() ); |
358 | 358 | ||
359 | //QApplication::sendEvent( this, &event ); | 359 | //QApplication::sendEvent( this, &event ); |
360 | } | 360 | } |
361 | 361 | ||
362 | /* | 362 | /* |
363 | This is the eventFilter function, which gets all events from the KOAgendaItems | 363 | This is the eventFilter function, which gets all events from the KOAgendaItems |
364 | contained in the agenda. It has to handle moving and resizing for all items. | 364 | contained in the agenda. It has to handle moving and resizing for all items. |
365 | */ | 365 | */ |
366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 366 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
367 | { | 367 | { |
368 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 368 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
369 | switch(event->type()) { | 369 | switch(event->type()) { |
370 | case QEvent::MouseButtonPress: | 370 | case QEvent::MouseButtonPress: |
371 | case QEvent::MouseButtonDblClick: | 371 | case QEvent::MouseButtonDblClick: |
372 | case QEvent::MouseButtonRelease: | 372 | case QEvent::MouseButtonRelease: |
373 | case QEvent::MouseMove: | 373 | case QEvent::MouseMove: |
374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 374 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
375 | 375 | ||
376 | case (QEvent::Leave): | 376 | case (QEvent::Leave): |
377 | if (!mActionItem) | 377 | if (!mActionItem) |
378 | setCursor(arrowCursor); | 378 | setCursor(arrowCursor); |
379 | return true; | 379 | return true; |
380 | 380 | ||
381 | default: | 381 | default: |
382 | return QScrollView::eventFilter(object,event); | 382 | return QScrollView::eventFilter(object,event); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | 385 | ||
386 | 386 | ||
387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 387 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
388 | { | 388 | { |
389 | //qDebug("KOAgenda::eventFilter_mous "); | 389 | //qDebug("KOAgenda::eventFilter_mous "); |
390 | QPoint viewportPos; | 390 | QPoint viewportPos; |
391 | if (object != viewport()) { | 391 | if (object != viewport()) { |
392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 392 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
393 | } else { | 393 | } else { |
394 | viewportPos = me->pos(); | 394 | viewportPos = me->pos(); |
395 | } | 395 | } |
396 | static int startX = 0; | 396 | static int startX = 0; |
397 | static int startY = 0; | 397 | static int startY = 0; |
398 | static bool block = true; | 398 | static bool block = true; |
399 | switch (me->type()) { | 399 | switch (me->type()) { |
400 | case QEvent::MouseButtonPress: | 400 | case QEvent::MouseButtonPress: |
401 | //qDebug("QEvent::MouseButtonPress: "); | 401 | //qDebug("QEvent::MouseButtonPress: "); |
402 | // kdDebug() << "koagenda: filtered button press" << endl; | 402 | // kdDebug() << "koagenda: filtered button press" << endl; |
403 | if (object != viewport()) { | 403 | if (object != viewport()) { |
404 | if (me->button() == RightButton) { | 404 | if (me->button() == RightButton) { |
405 | mClickedItem = (KOAgendaItem *)object; | 405 | mClickedItem = (KOAgendaItem *)object; |
406 | if (mClickedItem) { | 406 | if (mClickedItem) { |
407 | selectItem(mClickedItem); | 407 | selectItem(mClickedItem); |
408 | // emit showIncidencePopupSignal(mClickedItem->incidence()); | 408 | // emit showIncidencePopupSignal(mClickedItem->incidence()); |
409 | } | 409 | } |
410 | //mItemPopup->popup(QCursor::pos()); | 410 | //mItemPopup->popup(QCursor::pos()); |
411 | } else { | 411 | } else { |
412 | mActionItem = (KOAgendaItem *)object; | 412 | mActionItem = (KOAgendaItem *)object; |
413 | if (mActionItem) { | 413 | if (mActionItem) { |
414 | if ( mSelectionHeight > 0 ) { | 414 | if ( mSelectionHeight > 0 ) { |
415 | int selectionCellX = mSelectionCellX * mGridSpacingX; | 415 | int selectionCellX = mSelectionCellX * mGridSpacingX; |
416 | int selectionYTop = mSelectionYTop; | 416 | int selectionYTop = mSelectionYTop; |
417 | int gridSpacingX = mGridSpacingX; | 417 | int gridSpacingX = mGridSpacingX; |
418 | int selectionHeight = mSelectionHeight; | 418 | int selectionHeight = mSelectionHeight; |
419 | clearSelection(); | 419 | clearSelection(); |
420 | repaintContents( selectionCellX, selectionYTop, | 420 | repaintContents( selectionCellX, selectionYTop, |
421 | gridSpacingX, selectionHeight,false ); | 421 | gridSpacingX, selectionHeight,false ); |
422 | } | 422 | } |
423 | selectItem(mActionItem); | 423 | selectItem(mActionItem); |
424 | Incidence *incidence = mActionItem->incidence(); | 424 | Incidence *incidence = mActionItem->incidence(); |
425 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { | 425 | if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { |
426 | mActionItem = 0; | 426 | mActionItem = 0; |
427 | } else { | 427 | } else { |
428 | startItemAction(viewportPos); | 428 | startItemAction(viewportPos); |
429 | startX = viewportPos.x(); | 429 | startX = viewportPos.x(); |
430 | startY = viewportPos.y(); | 430 | startY = viewportPos.y(); |
431 | block = true; | 431 | block = true; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } else { | 435 | } else { |
436 | selectItem(0); | 436 | selectItem(0); |
437 | mActionItem = 0; | 437 | mActionItem = 0; |
438 | if (me->button() == RightButton ) { | 438 | if (me->button() == RightButton ) { |
439 | blockNewEvent = true; | 439 | blockNewEvent = true; |
440 | block = false; | 440 | block = false; |
441 | } else { | 441 | } else { |
442 | blockNewEvent = false; | 442 | blockNewEvent = false; |
443 | setCursor(arrowCursor); | 443 | setCursor(arrowCursor); |
444 | startSelectAction(viewportPos); | 444 | startSelectAction(viewportPos); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | break; | 447 | break; |
448 | 448 | ||
449 | case QEvent::MouseButtonRelease: | 449 | case QEvent::MouseButtonRelease: |
450 | //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); | 450 | //qDebug("QEvent::MouseButtonRelease: %d",blockNewEvent ); |
451 | if (me->button() == RightButton && blockNewEvent && !block) { | 451 | if (me->button() == RightButton && blockNewEvent && !block) { |
452 | int x,y; | 452 | int x,y; |
453 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 453 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
454 | int gx,gy; | 454 | int gx,gy; |
455 | contentsToGrid(x,y,gx,gy); | 455 | contentsToGrid(x,y,gx,gy); |
456 | if ( object == viewport() ) { | 456 | if ( object == viewport() ) { |
457 | if ( mCurrentCellY < mStartCellY +1 ) { | 457 | if ( mCurrentCellY < mStartCellY +1 ) { |
458 | //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); | 458 | //qDebug("mCurrentCellY %d mStartCellY %d ", mCurrentCellY,mStartCellY); |
459 | mCurrentCellX = gx; | 459 | mCurrentCellX = gx; |
460 | mCurrentCellY = gy; | 460 | mCurrentCellY = gy; |
461 | mStartCellX = gx; | 461 | mStartCellX = gx; |
462 | mStartCellY = gy; | 462 | mStartCellY = gy; |
463 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); | 463 | mNewItemPopup->popup( viewport()->mapToGlobal( me->pos() ) ); |
464 | break; | 464 | break; |
465 | } else { | 465 | } else { |
466 | blockNewEvent = false; | 466 | blockNewEvent = false; |
467 | } | 467 | } |
468 | } else { | 468 | } else { |
469 | mClickedItem = (KOAgendaItem *)object; | 469 | mClickedItem = (KOAgendaItem *)object; |
470 | if (mActionItem ) { | 470 | if (mActionItem ) { |
471 | endItemAction(); | 471 | endItemAction(); |
472 | } | 472 | } |
473 | if (mClickedItem) { | 473 | if (mClickedItem) { |
474 | selectItem(mClickedItem); | 474 | selectItem(mClickedItem); |
475 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 475 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
476 | } | 476 | } |
477 | } | 477 | } |
478 | } else if (me->button() == RightButton && block ) { | 478 | } else if (me->button() == RightButton && block ) { |
479 | if (object != viewport()) { | 479 | if (object != viewport()) { |
480 | mClickedItem = (KOAgendaItem *)object; | 480 | mClickedItem = (KOAgendaItem *)object; |
481 | if (mActionItem ) { | 481 | if (mActionItem ) { |
482 | endItemAction(); | 482 | endItemAction(); |
483 | } | 483 | } |
484 | if (mClickedItem) { | 484 | if (mClickedItem) { |
485 | selectItem(mClickedItem); | 485 | selectItem(mClickedItem); |
486 | emit showIncidencePopupSignal(mClickedItem->incidence()); | 486 | emit showIncidencePopupSignal(mClickedItem->incidence()); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | break; | 489 | break; |
490 | } | 490 | } |
491 | block = true; | 491 | block = true; |
492 | if (mActionItem) { | 492 | if (mActionItem) { |
493 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 493 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
494 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 494 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
495 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 495 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
496 | mScrollUpTimer.stop(); | 496 | mScrollUpTimer.stop(); |
497 | mScrollDownTimer.stop(); | 497 | mScrollDownTimer.stop(); |
498 | mActionItem->resetMove(); | 498 | mActionItem->resetMove(); |
499 | placeSubCells( mActionItem ); | 499 | placeSubCells( mActionItem ); |
500 | // emit startDragSignal( mActionItem->incidence() ); | 500 | // emit startDragSignal( mActionItem->incidence() ); |
501 | setCursor( arrowCursor ); | 501 | setCursor( arrowCursor ); |
502 | mActionItem = 0; | 502 | mActionItem = 0; |
503 | mActionType = NOP; | 503 | mActionType = NOP; |
504 | mItemMoved = 0; | 504 | mItemMoved = 0; |
505 | return true; | 505 | return true; |
506 | } | 506 | } |
507 | endItemAction(); | 507 | endItemAction(); |
508 | } else if ( mActionType == SELECT ) { | 508 | } else if ( mActionType == SELECT ) { |
509 | if (me->button() == RightButton ) { | 509 | if (me->button() == RightButton ) { |
510 | } else { | 510 | } else { |
511 | endSelectAction( !blockNewEvent ); | 511 | endSelectAction( !blockNewEvent ); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | break; | 514 | break; |
515 | 515 | ||
516 | case QEvent::MouseMove: | 516 | case QEvent::MouseMove: |
517 | if (object != viewport()) { | 517 | if (object != viewport()) { |
518 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 518 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
519 | //qDebug("moveItem %d ",moveItem ); | 519 | //qDebug("moveItem %d ",moveItem ); |
520 | if (!moveItem->incidence()->isReadOnly() /*&& | 520 | if (!moveItem->incidence()->isReadOnly() /*&& |
521 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) | 521 | !moveItem->incidence()->recurrence()->doesRecur()*/ ) |
522 | if (!mActionItem) | 522 | if (!mActionItem) |
523 | setNoActionCursor(moveItem,viewportPos); | 523 | setNoActionCursor(moveItem,viewportPos); |
524 | else { | 524 | else { |
525 | if ( block ) { | 525 | if ( block ) { |
526 | int dX, dY; | 526 | int dX, dY; |
527 | dX = startX - viewportPos.x(); | 527 | dX = startX - viewportPos.x(); |
528 | if ( dX < 0 ) | 528 | if ( dX < 0 ) |
529 | dX = -dX; | 529 | dX = -dX; |
530 | dY = viewportPos.y() - startY; | 530 | dY = viewportPos.y() - startY; |
531 | if ( dY < 0 ) | 531 | if ( dY < 0 ) |
532 | dY = -dY; | 532 | dY = -dY; |
533 | int diff = 30; | 533 | int diff = 30; |
534 | if ( QApplication::desktop()->width() < 480 ) | 534 | if ( QApplication::desktop()->width() < 480 ) |
535 | diff = 15; | 535 | diff = 15; |
536 | // qDebug(" %d %d ",dX, dY ); | 536 | // qDebug(" %d %d ",dX, dY ); |
537 | if ( dX > diff || dY > diff ) { | 537 | if ( dX > diff || dY > diff ) { |
538 | block = false; | 538 | block = false; |
539 | } | 539 | } |
540 | } | 540 | } |
541 | if ( !block ) | 541 | if ( !block ) |
542 | performItemAction(viewportPos); | 542 | performItemAction(viewportPos); |
543 | } | 543 | } |
544 | } else { | 544 | } else { |
545 | if ( mActionType == SELECT ) { | 545 | if ( mActionType == SELECT ) { |
546 | performSelectAction( viewportPos ); | 546 | performSelectAction( viewportPos ); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | break; | 549 | break; |
550 | 550 | ||
551 | case QEvent::MouseButtonDblClick: | 551 | case QEvent::MouseButtonDblClick: |
552 | if (object == viewport()) { | 552 | if (object == viewport()) { |
553 | selectItem(0); | 553 | selectItem(0); |
554 | int x,y; | 554 | int x,y; |
555 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 555 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
556 | int gx,gy; | 556 | int gx,gy; |
557 | contentsToGrid(x,y,gx,gy); | 557 | contentsToGrid(x,y,gx,gy); |
558 | emit newEventSignal(gx,gy); | 558 | emit newEventSignal(gx,gy); |
559 | } else { | 559 | } else { |
560 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 560 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
561 | selectItem(doubleClickedItem); | 561 | selectItem(doubleClickedItem); |
562 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 562 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
563 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 563 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
564 | else | 564 | else |
565 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 565 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
566 | } | 566 | } |
567 | break; | 567 | break; |
568 | 568 | ||
569 | default: | 569 | default: |
570 | break; | 570 | break; |
571 | } | 571 | } |
572 | 572 | ||
573 | return true; | 573 | return true; |
574 | } | 574 | } |
575 | 575 | ||
576 | void KOAgenda::newItem( int item ) | 576 | void KOAgenda::newItem( int item ) |
577 | { | 577 | { |
578 | if ( item == 1 ) { //new event | 578 | if ( item == 1 ) { //new event |
579 | newEventSignal(mStartCellX ,mStartCellY ); | 579 | newEventSignal(mStartCellX ,mStartCellY ); |
580 | } else | 580 | } else |
581 | if ( item == 2 ) { //new event | 581 | if ( item == 2 ) { //new event |
582 | newTodoSignal(mStartCellX ,mStartCellY ); | 582 | newTodoSignal(mStartCellX ,mStartCellY ); |
583 | } else | 583 | } else |
584 | { | 584 | { |
585 | QDate day = mSelectedDates[mStartCellX]; | 585 | QDate day = mSelectedDates[mStartCellX]; |
586 | emit showDateView( item, day ); | 586 | emit showDateView( item, day ); |
587 | // 3Day view | 587 | // 3Day view |
588 | // 4Week view | 588 | // 4Week view |
589 | // 5Month view | 589 | // 5Month view |
590 | // 6Journal view | 590 | // 6Journal view |
591 | } | 591 | } |
592 | } | 592 | } |
593 | void KOAgenda::startSelectAction(QPoint viewportPos) | 593 | void KOAgenda::startSelectAction(QPoint viewportPos) |
594 | { | 594 | { |
595 | //emit newStartSelectSignal(); | 595 | //emit newStartSelectSignal(); |
596 | 596 | ||
597 | mActionType = SELECT; | 597 | mActionType = SELECT; |
598 | 598 | ||
599 | int x,y; | 599 | int x,y; |
600 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 600 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
601 | int gx,gy; | 601 | int gx,gy; |
602 | contentsToGrid(x,y,gx,gy); | 602 | contentsToGrid(x,y,gx,gy); |
603 | 603 | ||
604 | mStartCellX = gx; | 604 | mStartCellX = gx; |
605 | mStartCellY = gy; | 605 | mStartCellY = gy; |
606 | mCurrentCellX = gx; | 606 | mCurrentCellX = gx; |
607 | mCurrentCellY = gy; | 607 | mCurrentCellY = gy; |
608 | 608 | ||
609 | // Store coordinates of old selection | 609 | // Store coordinates of old selection |
610 | int selectionX = mSelectionCellX * mGridSpacingX; | 610 | int selectionX = mSelectionCellX * mGridSpacingX; |
611 | int selectionYTop = mSelectionYTop; | 611 | int selectionYTop = mSelectionYTop; |
612 | int selectionHeight = mSelectionHeight; | 612 | int selectionHeight = mSelectionHeight; |
613 | 613 | ||
614 | // Store new selection | 614 | // Store new selection |
615 | mSelectionCellX = gx; | 615 | mSelectionCellX = gx; |
616 | mSelectionYTop = gy * mGridSpacingY; | 616 | mSelectionYTop = gy * mGridSpacingY; |
617 | mSelectionHeight = mGridSpacingY; | 617 | mSelectionHeight = mGridSpacingY; |
618 | 618 | ||
619 | // Clear old selection | 619 | // Clear old selection |
620 | repaintContents( selectionX, selectionYTop, | 620 | repaintContents( selectionX, selectionYTop, |
621 | mGridSpacingX, selectionHeight,false ); | 621 | mGridSpacingX, selectionHeight,false ); |
622 | 622 | ||
623 | // Paint new selection | 623 | // Paint new selection |
624 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, | 624 | // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, |
625 | // mGridSpacingX, mSelectionHeight ); | 625 | // mGridSpacingX, mSelectionHeight ); |
626 | } | 626 | } |
627 | 627 | ||
628 | void KOAgenda::performSelectAction(QPoint viewportPos) | 628 | void KOAgenda::performSelectAction(QPoint viewportPos) |
629 | { | 629 | { |
630 | int x,y; | 630 | int x,y; |
631 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 631 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
632 | int gx,gy; | 632 | int gx,gy; |
633 | contentsToGrid(x,y,gx,gy); | 633 | contentsToGrid(x,y,gx,gy); |
634 | 634 | ||
635 | QPoint clipperPos = clipper()-> | 635 | QPoint clipperPos = clipper()-> |
636 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 636 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
637 | 637 | ||
638 | // Scroll if cursor was moved to upper or lower end of agenda. | 638 | // Scroll if cursor was moved to upper or lower end of agenda. |
639 | if (clipperPos.y() < mScrollBorderWidth) { | 639 | if (clipperPos.y() < mScrollBorderWidth) { |
640 | mScrollUpTimer.start(mScrollDelay); | 640 | mScrollUpTimer.start(mScrollDelay); |
641 | } else if (visibleHeight() - clipperPos.y() < | 641 | } else if (visibleHeight() - clipperPos.y() < |
642 | mScrollBorderWidth) { | 642 | mScrollBorderWidth) { |
643 | mScrollDownTimer.start(mScrollDelay); | 643 | mScrollDownTimer.start(mScrollDelay); |
644 | } else { | 644 | } else { |
645 | mScrollUpTimer.stop(); | 645 | mScrollUpTimer.stop(); |
646 | mScrollDownTimer.stop(); | 646 | mScrollDownTimer.stop(); |
647 | } | 647 | } |
648 | 648 | ||
649 | if ( gy > mCurrentCellY ) { | 649 | if ( gy > mCurrentCellY ) { |
650 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 650 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
651 | 651 | ||
652 | #if 0 | 652 | #if 0 |
653 | // FIXME: Repaint only the newly selected region | 653 | // FIXME: Repaint only the newly selected region |
654 | repaintContents( mSelectionCellX * mGridSpacingX, | 654 | repaintContents( mSelectionCellX * mGridSpacingX, |
655 | mCurrentCellY + mGridSpacingY, | 655 | mCurrentCellY + mGridSpacingY, |
656 | mGridSpacingX, | 656 | mGridSpacingX, |
657 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); | 657 | mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); |
658 | #else | 658 | #else |
659 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 659 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
660 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 660 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
661 | mGridSpacingX, mSelectionYTop, | 661 | mGridSpacingX, mSelectionYTop, |
662 | mGridSpacingX, mSelectionHeight , false); | 662 | mGridSpacingX, mSelectionHeight , false); |
663 | #endif | 663 | #endif |
664 | 664 | ||
665 | mCurrentCellY = gy; | 665 | mCurrentCellY = gy; |
666 | } else if ( gy < mCurrentCellY ) { | 666 | } else if ( gy < mCurrentCellY ) { |
667 | if ( gy >= mStartCellY ) { | 667 | if ( gy >= mStartCellY ) { |
668 | int selectionHeight = mSelectionHeight; | 668 | int selectionHeight = mSelectionHeight; |
669 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; | 669 | mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; |
670 | 670 | ||
671 | repaintContents( (KOGlobals::self()->reverseLayout() ? | 671 | repaintContents( (KOGlobals::self()->reverseLayout() ? |
672 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * | 672 | mColumns - 1 - mSelectionCellX : mSelectionCellX) * |
673 | mGridSpacingX, mSelectionYTop, | 673 | mGridSpacingX, mSelectionYTop, |
674 | mGridSpacingX, selectionHeight,false ); | 674 | mGridSpacingX, selectionHeight,false ); |
675 | 675 | ||
676 | mCurrentCellY = gy; | 676 | mCurrentCellY = gy; |
677 | } else { | 677 | } else { |
678 | } | 678 | } |
679 | } | 679 | } |
680 | } | 680 | } |
681 | 681 | ||
682 | void KOAgenda::endSelectAction( bool emitNewEvent ) | 682 | void KOAgenda::endSelectAction( bool emitNewEvent ) |
683 | { | 683 | { |
684 | mActionType = NOP; | 684 | mActionType = NOP; |
685 | mScrollUpTimer.stop(); | 685 | mScrollUpTimer.stop(); |
686 | mScrollDownTimer.stop(); | 686 | mScrollDownTimer.stop(); |
687 | 687 | ||
688 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 688 | emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
689 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) | 689 | if ( emitNewEvent && mStartCellY < mCurrentCellY ) |
690 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); | 690 | emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); |
691 | } | 691 | } |
692 | 692 | ||
693 | void KOAgenda::startItemAction(QPoint viewportPos) | 693 | void KOAgenda::startItemAction(QPoint viewportPos) |
694 | { | 694 | { |
695 | int x,y; | 695 | int x,y; |
696 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 696 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
697 | int gx,gy; | 697 | int gx,gy; |
698 | contentsToGrid(x,y,gx,gy); | 698 | contentsToGrid(x,y,gx,gy); |
699 | 699 | ||
700 | mStartCellX = gx; | 700 | mStartCellX = gx; |
701 | mStartCellY = gy; | 701 | mStartCellY = gy; |
702 | mCurrentCellX = gx; | 702 | mCurrentCellX = gx; |
703 | mCurrentCellY = gy; | 703 | mCurrentCellY = gy; |
704 | 704 | ||
705 | if (mAllDayMode) { | 705 | if (mAllDayMode) { |
706 | int gridDistanceX = (x - gx * mGridSpacingX); | 706 | int gridDistanceX = (x - gx * mGridSpacingX); |
707 | if (gridDistanceX < mResizeBorderWidth && | 707 | if (gridDistanceX < mResizeBorderWidth && |
708 | mActionItem->cellX() == mCurrentCellX) { | 708 | mActionItem->cellX() == mCurrentCellX) { |
709 | mActionType = RESIZELEFT; | 709 | mActionType = RESIZELEFT; |
710 | setCursor(sizeHorCursor); | 710 | setCursor(sizeHorCursor); |
711 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 711 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
712 | mActionItem->cellXWidth() == mCurrentCellX) { | 712 | mActionItem->cellXWidth() == mCurrentCellX) { |
713 | mActionType = RESIZERIGHT; | 713 | mActionType = RESIZERIGHT; |
714 | setCursor(sizeHorCursor); | 714 | setCursor(sizeHorCursor); |
715 | } else { | 715 | } else { |
716 | mActionType = MOVE; | 716 | mActionType = MOVE; |
717 | mActionItem->startMove(); | 717 | mActionItem->startMove(); |
718 | setCursor(sizeAllCursor); | 718 | setCursor(sizeAllCursor); |
719 | } | 719 | } |
720 | } else { | 720 | } else { |
721 | int gridDistanceY = (y - gy * mGridSpacingY); | 721 | int gridDistanceY = (y - gy * mGridSpacingY); |
722 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); | 722 | bool allowResize = ( mActionItem->incidence()->type() != "Todo" ); |
723 | if (allowResize && gridDistanceY < mResizeBorderWidth && | 723 | if (allowResize && gridDistanceY < mResizeBorderWidth && |
724 | mActionItem->cellYTop() == mCurrentCellY && | 724 | mActionItem->cellYTop() == mCurrentCellY && |
725 | !mActionItem->firstMultiItem()) { | 725 | !mActionItem->firstMultiItem()) { |
726 | mActionType = RESIZETOP; | 726 | mActionType = RESIZETOP; |
727 | setCursor(sizeVerCursor); | 727 | setCursor(sizeVerCursor); |
728 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 728 | } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
729 | mActionItem->cellYBottom() == mCurrentCellY && | 729 | mActionItem->cellYBottom() == mCurrentCellY && |
730 | !mActionItem->lastMultiItem()) { | 730 | !mActionItem->lastMultiItem()) { |
731 | mActionType = RESIZEBOTTOM; | 731 | mActionType = RESIZEBOTTOM; |
732 | setCursor(sizeVerCursor); | 732 | setCursor(sizeVerCursor); |
733 | } else { | 733 | } else { |
734 | mActionType = MOVE; | 734 | mActionType = MOVE; |
735 | mActionItem->startMove(); | 735 | mActionItem->startMove(); |
736 | setCursor(sizeAllCursor); | 736 | setCursor(sizeAllCursor); |
737 | } | 737 | } |
738 | } | 738 | } |
739 | } | 739 | } |
740 | 740 | ||
741 | void KOAgenda::performItemAction(QPoint viewportPos) | 741 | void KOAgenda::performItemAction(QPoint viewportPos) |
742 | { | 742 | { |
743 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 743 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
744 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 744 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
745 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 745 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
746 | // point = clipper()->mapFromGlobal(point); | 746 | // point = clipper()->mapFromGlobal(point); |
747 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 747 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
748 | // kdDebug() << "visible height: " << visibleHeight() << endl; | 748 | // kdDebug() << "visible height: " << visibleHeight() << endl; |
749 | int x,y; | 749 | int x,y; |
750 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 750 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
751 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 751 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
752 | int gx,gy; | 752 | int gx,gy; |
753 | contentsToGrid(x,y,gx,gy); | 753 | contentsToGrid(x,y,gx,gy); |
754 | QPoint clipperPos = clipper()-> | 754 | QPoint clipperPos = clipper()-> |
755 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 755 | mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
756 | 756 | ||
757 | // Cursor left active agenda area. | 757 | // Cursor left active agenda area. |
758 | // This starts a drag. | 758 | // This starts a drag. |
759 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ | 759 | if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ |
760 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { | 760 | clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { |
761 | if ( mActionType == MOVE ) { | 761 | if ( mActionType == MOVE ) { |
762 | mScrollUpTimer.stop(); | 762 | mScrollUpTimer.stop(); |
763 | mScrollDownTimer.stop(); | 763 | mScrollDownTimer.stop(); |
764 | mActionItem->resetMove(); | 764 | mActionItem->resetMove(); |
765 | placeSubCells( mActionItem ); | 765 | placeSubCells( mActionItem ); |
766 | // emit startDragSignal( mActionItem->incidence() ); | 766 | // emit startDragSignal( mActionItem->incidence() ); |
767 | setCursor( arrowCursor ); | 767 | setCursor( arrowCursor ); |
768 | mActionItem = 0; | 768 | mActionItem = 0; |
769 | mActionType = NOP; | 769 | mActionType = NOP; |
770 | mItemMoved = 0; | 770 | mItemMoved = 0; |
771 | return; | 771 | return; |
772 | } | 772 | } |
773 | } else { | 773 | } else { |
774 | switch ( mActionType ) { | 774 | switch ( mActionType ) { |
775 | case MOVE: | 775 | case MOVE: |
776 | setCursor( sizeAllCursor ); | 776 | setCursor( sizeAllCursor ); |
777 | break; | 777 | break; |
778 | case RESIZETOP: | 778 | case RESIZETOP: |
779 | case RESIZEBOTTOM: | 779 | case RESIZEBOTTOM: |
780 | setCursor( sizeVerCursor ); | 780 | setCursor( sizeVerCursor ); |
781 | break; | 781 | break; |
782 | case RESIZELEFT: | 782 | case RESIZELEFT: |
783 | case RESIZERIGHT: | 783 | case RESIZERIGHT: |
784 | setCursor( sizeHorCursor ); | 784 | setCursor( sizeHorCursor ); |
785 | break; | 785 | break; |
786 | default: | 786 | default: |
787 | setCursor( arrowCursor ); | 787 | setCursor( arrowCursor ); |
788 | } | 788 | } |
789 | } | 789 | } |
790 | 790 | ||
791 | // Scroll if item was moved to upper or lower end of agenda. | 791 | // Scroll if item was moved to upper or lower end of agenda. |
792 | if (clipperPos.y() < mScrollBorderWidth) { | 792 | if (clipperPos.y() < mScrollBorderWidth) { |
793 | mScrollUpTimer.start(mScrollDelay); | 793 | mScrollUpTimer.start(mScrollDelay); |
794 | } else if (visibleHeight() - clipperPos.y() < | 794 | } else if (visibleHeight() - clipperPos.y() < |
795 | mScrollBorderWidth) { | 795 | mScrollBorderWidth) { |
796 | mScrollDownTimer.start(mScrollDelay); | 796 | mScrollDownTimer.start(mScrollDelay); |
797 | } else { | 797 | } else { |
798 | mScrollUpTimer.stop(); | 798 | mScrollUpTimer.stop(); |
799 | mScrollDownTimer.stop(); | 799 | mScrollDownTimer.stop(); |
800 | } | 800 | } |
801 | 801 | ||
802 | // Move or resize item if necessary | 802 | // Move or resize item if necessary |
803 | if (mCurrentCellX != gx || mCurrentCellY != gy) { | 803 | if (mCurrentCellX != gx || mCurrentCellY != gy) { |
804 | mItemMoved = true; | 804 | mItemMoved = true; |
805 | mActionItem->raise(); | 805 | mActionItem->raise(); |
806 | if (mActionType == MOVE) { | 806 | if (mActionType == MOVE) { |
807 | // Move all items belonging to a multi item | 807 | // Move all items belonging to a multi item |
808 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); | 808 | KOAgendaItem *moveItem = mActionItem->firstMultiItem(); |
809 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); | 809 | bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); |
810 | if (!moveItem) moveItem = mActionItem; | 810 | if (!moveItem) moveItem = mActionItem; |
811 | while (moveItem) { | 811 | while (moveItem) { |
812 | int dy; | 812 | int dy; |
813 | if (isMultiItem) dy = 0; | 813 | if (isMultiItem) dy = 0; |
814 | else dy = gy - mCurrentCellY; | 814 | else dy = gy - mCurrentCellY; |
815 | moveItem->moveRelative(gx - mCurrentCellX,dy); | 815 | moveItem->moveRelative(gx - mCurrentCellX,dy); |
816 | int x,y; | 816 | int x,y; |
817 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); | 817 | gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); |
818 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), | 818 | moveItem->resize(mGridSpacingX * moveItem->cellWidth(), |
819 | mGridSpacingY * moveItem->cellHeight()); | 819 | mGridSpacingY * moveItem->cellHeight()); |
820 | moveChild(moveItem,x,y); | 820 | moveChild(moveItem,x,y); |
821 | moveItem = moveItem->nextMultiItem(); | 821 | moveItem = moveItem->nextMultiItem(); |
822 | } | 822 | } |
823 | } else if (mActionType == RESIZETOP) { | 823 | } else if (mActionType == RESIZETOP) { |
824 | if (mCurrentCellY <= mActionItem->cellYBottom()) { | 824 | if (mCurrentCellY <= mActionItem->cellYBottom()) { |
825 | mActionItem->expandTop(gy - mCurrentCellY); | 825 | mActionItem->expandTop(gy - mCurrentCellY); |
826 | mActionItem->resize(mActionItem->width(), | 826 | mActionItem->resize(mActionItem->width(), |
827 | mGridSpacingY * mActionItem->cellHeight()); | 827 | mGridSpacingY * mActionItem->cellHeight()); |
828 | int x,y; | 828 | int x,y; |
829 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); | 829 | gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); |
830 | //moveChild(mActionItem,childX(mActionItem),y); | 830 | //moveChild(mActionItem,childX(mActionItem),y); |
831 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); | 831 | QScrollView::moveChild( mActionItem,childX(mActionItem),y ); |
832 | } | 832 | } |
833 | } else if (mActionType == RESIZEBOTTOM) { | 833 | } else if (mActionType == RESIZEBOTTOM) { |
834 | if (mCurrentCellY >= mActionItem->cellYTop()) { | 834 | if (mCurrentCellY >= mActionItem->cellYTop()) { |
835 | mActionItem->expandBottom(gy - mCurrentCellY); | 835 | mActionItem->expandBottom(gy - mCurrentCellY); |
836 | mActionItem->resize(mActionItem->width(), | 836 | mActionItem->resize(mActionItem->width(), |
837 | mGridSpacingY * mActionItem->cellHeight()); | 837 | mGridSpacingY * mActionItem->cellHeight()); |
838 | } | 838 | } |
839 | } else if (mActionType == RESIZELEFT) { | 839 | } else if (mActionType == RESIZELEFT) { |
840 | if (mCurrentCellX <= mActionItem->cellXWidth()) { | 840 | if (mCurrentCellX <= mActionItem->cellXWidth()) { |
841 | mActionItem->expandLeft(gx - mCurrentCellX); | 841 | mActionItem->expandLeft(gx - mCurrentCellX); |
842 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 842 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
843 | mActionItem->height()); | 843 | mActionItem->height()); |
844 | int x,y; | 844 | int x,y; |
845 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); | 845 | gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); |
846 | moveChild(mActionItem,x,childY(mActionItem)); | 846 | moveChild(mActionItem,x,childY(mActionItem)); |
847 | } | 847 | } |
848 | } else if (mActionType == RESIZERIGHT) { | 848 | } else if (mActionType == RESIZERIGHT) { |
849 | if (mCurrentCellX >= mActionItem->cellX()) { | 849 | if (mCurrentCellX >= mActionItem->cellX()) { |
850 | mActionItem->expandRight(gx - mCurrentCellX); | 850 | mActionItem->expandRight(gx - mCurrentCellX); |
851 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), | 851 | mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), |
852 | mActionItem->height()); | 852 | mActionItem->height()); |
853 | } | 853 | } |
854 | } | 854 | } |
855 | mCurrentCellX = gx; | 855 | mCurrentCellX = gx; |
856 | mCurrentCellY = gy; | 856 | mCurrentCellY = gy; |
857 | } | 857 | } |
858 | } | 858 | } |
859 | 859 | ||
860 | void KOAgenda::endItemAction() | 860 | void KOAgenda::endItemAction() |
861 | { | 861 | { |
862 | 862 | ||
863 | if ( mItemMoved ) { | 863 | if ( mItemMoved ) { |
864 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); | 864 | KOAgendaItem *placeItem = mActionItem->firstMultiItem(); |
865 | if ( !placeItem ) { | 865 | if ( !placeItem ) { |
866 | placeItem = mActionItem; | 866 | placeItem = mActionItem; |
867 | } | 867 | } |
868 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { | 868 | if ( placeItem->incidence()->recurrence()->doesRecur() ) { |
869 | Incidence* oldInc = placeItem->incidence(); | 869 | Incidence* oldInc = placeItem->incidence(); |
870 | placeItem->recreateIncidence(); | 870 | placeItem->recreateIncidence(); |
871 | emit addToCalSignal(placeItem->incidence(), oldInc ); | 871 | emit addToCalSignal(placeItem->incidence(), oldInc ); |
872 | } | 872 | } |
873 | int type = mActionType; | 873 | int type = mActionType; |
874 | if ( mAllDayMode ) | 874 | if ( mAllDayMode ) |
875 | type = -1; | 875 | type = -1; |
876 | KOAgendaItem *modifiedItem = placeItem; | 876 | KOAgendaItem *modifiedItem = placeItem; |
877 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); | 877 | //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); |
878 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); | 878 | QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); |
879 | KOAgendaItem *item; | 879 | KOAgendaItem *item; |
880 | 880 | ||
881 | if ( placeItem->incidence()->type() == "Todo" ) { | 881 | if ( placeItem->incidence()->type() == "Todo" ) { |
882 | mSelectedItem = 0; | 882 | mSelectedItem = 0; |
883 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); | 883 | //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); |
884 | modifiedItem->mLastMoveXPos = mCurrentCellX; | 884 | modifiedItem->mLastMoveXPos = mCurrentCellX; |
885 | emit itemModified( modifiedItem, mActionType ); | 885 | emit itemModified( modifiedItem, mActionType ); |
886 | } | 886 | } |
887 | else { | 887 | else { |
888 | #if 0 | 888 | #if 0 |
889 | for ( item=oldconflictItems.first(); item != 0; | 889 | for ( item=oldconflictItems.first(); item != 0; |
890 | item=oldconflictItems.next() ) { | 890 | item=oldconflictItems.next() ) { |
891 | placeSubCells(item); | 891 | placeSubCells(item); |
892 | } | 892 | } |
893 | while ( placeItem ) { | 893 | while ( placeItem ) { |
894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 894 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
895 | placeSubCells( placeItem ); | 895 | placeSubCells( placeItem ); |
896 | placeItem = placeItem->nextMultiItem(); | 896 | placeItem = placeItem->nextMultiItem(); |
897 | } | 897 | } |
898 | #endif | 898 | #endif |
899 | 899 | ||
900 | globalFlagBlockAgendaItemPaint = 1; | 900 | globalFlagBlockAgendaItemPaint = 1; |
901 | for ( item=oldconflictItems.first(); item != 0; | 901 | for ( item=oldconflictItems.first(); item != 0; |
902 | item=oldconflictItems.next() ) { | 902 | item=oldconflictItems.next() ) { |
903 | placeSubCells(item); | 903 | placeSubCells(item); |
904 | } | 904 | } |
905 | while ( placeItem ) { | 905 | while ( placeItem ) { |
906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 906 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
907 | oldconflictItems = placeItem->conflictItems(); | 907 | oldconflictItems = placeItem->conflictItems(); |
908 | for ( item=oldconflictItems.first(); item != 0; | 908 | for ( item=oldconflictItems.first(); item != 0; |
909 | item=oldconflictItems.next() ) { | 909 | item=oldconflictItems.next() ) { |
910 | placeSubCells(item); | 910 | placeSubCells(item); |
911 | } | 911 | } |
912 | placeSubCells( placeItem ); | 912 | placeSubCells( placeItem ); |
913 | placeItem = placeItem->nextMultiItem(); | 913 | placeItem = placeItem->nextMultiItem(); |
914 | } | 914 | } |
915 | globalFlagBlockAgendaItemPaint = 0; | 915 | globalFlagBlockAgendaItemPaint = 0; |
916 | for ( item=oldconflictItems.first(); item != 0; | 916 | for ( item=oldconflictItems.first(); item != 0; |
917 | item=oldconflictItems.next() ) { | 917 | item=oldconflictItems.next() ) { |
918 | globalFlagBlockAgendaItemUpdate = 0; | 918 | globalFlagBlockAgendaItemUpdate = 0; |
919 | item->repaintMe(); | 919 | item->repaintMe(); |
920 | globalFlagBlockAgendaItemUpdate = 1; | 920 | globalFlagBlockAgendaItemUpdate = 1; |
921 | item->repaint( false ); | 921 | item->repaint( false ); |
922 | } | 922 | } |
923 | placeItem = modifiedItem; | 923 | placeItem = modifiedItem; |
924 | 924 | ||
925 | while ( placeItem ) { | 925 | while ( placeItem ) { |
926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); | 926 | //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); |
927 | globalFlagBlockAgendaItemUpdate = 0; | 927 | globalFlagBlockAgendaItemUpdate = 0; |
928 | placeItem->repaintMe(); | 928 | placeItem->repaintMe(); |
929 | globalFlagBlockAgendaItemUpdate = 1; | 929 | globalFlagBlockAgendaItemUpdate = 1; |
930 | placeItem->repaint(false); | 930 | placeItem->repaint(false); |
931 | placeItem = placeItem->nextMultiItem(); | 931 | placeItem = placeItem->nextMultiItem(); |
932 | } | 932 | } |
933 | emit itemModified( modifiedItem, mActionType ); | 933 | emit itemModified( modifiedItem, mActionType ); |
934 | 934 | ||
935 | 935 | ||
936 | placeItem = modifiedItem; | 936 | placeItem = modifiedItem; |
937 | while ( placeItem ) { | 937 | while ( placeItem ) { |
938 | oldconflictItems = placeItem->conflictItems(); | 938 | oldconflictItems = placeItem->conflictItems(); |
939 | for ( item=oldconflictItems.first(); item != 0; | 939 | for ( item=oldconflictItems.first(); item != 0; |
940 | item=oldconflictItems.next() ) { | 940 | item=oldconflictItems.next() ) { |
941 | placeSubCells(item); | 941 | placeSubCells(item); |
942 | } | 942 | } |
943 | placeSubCells( placeItem ); | 943 | placeSubCells( placeItem ); |
944 | placeItem = placeItem->nextMultiItem(); | 944 | placeItem = placeItem->nextMultiItem(); |
945 | 945 | ||
946 | } | 946 | } |
947 | placeItem = modifiedItem; | 947 | placeItem = modifiedItem; |
948 | while ( placeItem ) { | 948 | while ( placeItem ) { |
949 | oldconflictItems = placeItem->conflictItems(); | 949 | oldconflictItems = placeItem->conflictItems(); |
950 | for ( item=oldconflictItems.first(); item != 0; | 950 | for ( item=oldconflictItems.first(); item != 0; |
951 | item=oldconflictItems.next() ) { | 951 | item=oldconflictItems.next() ) { |
952 | globalFlagBlockAgendaItemUpdate = 0; | 952 | globalFlagBlockAgendaItemUpdate = 0; |
953 | item->repaintMe(); | 953 | item->repaintMe(); |
954 | globalFlagBlockAgendaItemUpdate = 1; | 954 | globalFlagBlockAgendaItemUpdate = 1; |
955 | item->repaint(false); | 955 | item->repaint(false); |
956 | } | 956 | } |
957 | placeItem = placeItem->nextMultiItem(); | 957 | placeItem = placeItem->nextMultiItem(); |
958 | } | 958 | } |
959 | /* | 959 | /* |
960 | 960 | ||
961 | oldconflictItems = modifiedItem->conflictItems(); | 961 | oldconflictItems = modifiedItem->conflictItems(); |
962 | for ( item=oldconflictItems.first(); item != 0; | 962 | for ( item=oldconflictItems.first(); item != 0; |
963 | item=oldconflictItems.next() ) { | 963 | item=oldconflictItems.next() ) { |
964 | globalFlagBlockAgendaItemUpdate = 0; | 964 | globalFlagBlockAgendaItemUpdate = 0; |
965 | item->paintMe(false); | 965 | item->paintMe(false); |
966 | globalFlagBlockAgendaItemUpdate = 1; | 966 | globalFlagBlockAgendaItemUpdate = 1; |
967 | item->repaint(false); | 967 | item->repaint(false); |
968 | } | 968 | } |
969 | */ | 969 | */ |
970 | 970 | ||
971 | 971 | ||
972 | } | 972 | } |
973 | 973 | ||
974 | } | 974 | } |
975 | 975 | ||
976 | mScrollUpTimer.stop(); | 976 | mScrollUpTimer.stop(); |
977 | mScrollDownTimer.stop(); | 977 | mScrollDownTimer.stop(); |
978 | setCursor( arrowCursor ); | 978 | setCursor( arrowCursor ); |
979 | mActionItem = 0; | 979 | mActionItem = 0; |
980 | mActionType = NOP; | 980 | mActionType = NOP; |
981 | mItemMoved = 0; | 981 | mItemMoved = 0; |
982 | 982 | ||
983 | } | 983 | } |
984 | 984 | ||
985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) | 985 | void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) |
986 | { | 986 | { |
987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; | 987 | // kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; |
988 | // QPoint point = viewport()->mapToGlobal(viewportPos); | 988 | // QPoint point = viewport()->mapToGlobal(viewportPos); |
989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; | 989 | // kdDebug() << "Global: " << point.x() << "," << point.y() << endl; |
990 | // point = clipper()->mapFromGlobal(point); | 990 | // point = clipper()->mapFromGlobal(point); |
991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; | 991 | // kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; |
992 | 992 | ||
993 | int x,y; | 993 | int x,y; |
994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 994 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; | 995 | // kdDebug() << "contents: " << x << "," << y << "\n" << endl; |
996 | int gx,gy; | 996 | int gx,gy; |
997 | contentsToGrid(x,y,gx,gy); | 997 | contentsToGrid(x,y,gx,gy); |
998 | 998 | ||
999 | // Change cursor to resize cursor if appropriate | 999 | // Change cursor to resize cursor if appropriate |
1000 | if (mAllDayMode) { | 1000 | if (mAllDayMode) { |
1001 | int gridDistanceX = (x - gx * mGridSpacingX); | 1001 | int gridDistanceX = (x - gx * mGridSpacingX); |
1002 | if (gridDistanceX < mResizeBorderWidth && | 1002 | if (gridDistanceX < mResizeBorderWidth && |
1003 | moveItem->cellX() == gx) { | 1003 | moveItem->cellX() == gx) { |
1004 | setCursor(sizeHorCursor); | 1004 | setCursor(sizeHorCursor); |
1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && | 1005 | } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && |
1006 | moveItem->cellXWidth() == gx) { | 1006 | moveItem->cellXWidth() == gx) { |
1007 | setCursor(sizeHorCursor); | 1007 | setCursor(sizeHorCursor); |
1008 | } else { | 1008 | } else { |
1009 | setCursor(arrowCursor); | 1009 | setCursor(arrowCursor); |
1010 | } | 1010 | } |
1011 | } else { | 1011 | } else { |
1012 | int gridDistanceY = (y - gy * mGridSpacingY); | 1012 | int gridDistanceY = (y - gy * mGridSpacingY); |
1013 | if (gridDistanceY < mResizeBorderWidth && | 1013 | if (gridDistanceY < mResizeBorderWidth && |
1014 | moveItem->cellYTop() == gy && | 1014 | moveItem->cellYTop() == gy && |
1015 | !moveItem->firstMultiItem()) { | 1015 | !moveItem->firstMultiItem()) { |
1016 | setCursor(sizeVerCursor); | 1016 | setCursor(sizeVerCursor); |
1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && | 1017 | } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && |
1018 | moveItem->cellYBottom() == gy && | 1018 | moveItem->cellYBottom() == gy && |
1019 | !moveItem->lastMultiItem()) { | 1019 | !moveItem->lastMultiItem()) { |
1020 | setCursor(sizeVerCursor); | 1020 | setCursor(sizeVerCursor); |
1021 | } else { | 1021 | } else { |
1022 | setCursor(arrowCursor); | 1022 | setCursor(arrowCursor); |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | 1027 | ||
1028 | /* | 1028 | /* |
1029 | Place item in cell and take care that multiple items using the same cell do | 1029 | Place item in cell and take care that multiple items using the same cell do |
1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space | 1030 | not overlap. This method is not yet optimal. It doesn´t use the maximum space |
1031 | it can get in all cases. | 1031 | it can get in all cases. |
1032 | At the moment the method has a bug: When an item is placed only the sub cell | 1032 | At the moment the method has a bug: When an item is placed only the sub cell |
1033 | widths of the items are changed, which are within the Y region the item to | 1033 | widths of the items are changed, which are within the Y region the item to |
1034 | place spans. When the sub cell width change of one of this items affects a | 1034 | place spans. When the sub cell width change of one of this items affects a |
1035 | cell, where other items are, which do not overlap in Y with the item to place, | 1035 | cell, where other items are, which do not overlap in Y with the item to place, |
1036 | the display gets corrupted, although the corruption looks quite nice. | 1036 | the display gets corrupted, although the corruption looks quite nice. |
1037 | */ | 1037 | */ |
1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) | 1038 | void KOAgenda::placeSubCells(KOAgendaItem *placeItem) |
1039 | { | 1039 | { |
1040 | 1040 | ||
1041 | QPtrList<KOAgendaItem> conflictItems; | 1041 | QPtrList<KOAgendaItem> conflictItems; |
1042 | int maxSubCells = 0; | 1042 | int maxSubCells = 0; |
1043 | QIntDict<KOAgendaItem> subCellDict(5); | 1043 | QIntDict<KOAgendaItem> subCellDict(5); |
1044 | 1044 | ||
1045 | KOAgendaItem *item; | 1045 | KOAgendaItem *item; |
1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1046 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1047 | if (item != placeItem) { | 1047 | if (item != placeItem) { |
1048 | if (placeItem->cellX() <= item->cellXWidth() && | 1048 | if (placeItem->cellX() <= item->cellXWidth() && |
1049 | placeItem->cellXWidth() >= item->cellX()) { | 1049 | placeItem->cellXWidth() >= item->cellX()) { |
1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && | 1050 | if ((placeItem->cellYTop() <= item->cellYBottom()) && |
1051 | (placeItem->cellYBottom() >= item->cellYTop())) { | 1051 | (placeItem->cellYBottom() >= item->cellYTop())) { |
1052 | conflictItems.append(item); | 1052 | conflictItems.append(item); |
1053 | if (item->subCells() > maxSubCells) | 1053 | if (item->subCells() > maxSubCells) |
1054 | maxSubCells = item->subCells(); | 1054 | maxSubCells = item->subCells(); |
1055 | subCellDict.insert(item->subCell(),item); | 1055 | subCellDict.insert(item->subCell(),item); |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | if (conflictItems.count() > 0) { | 1061 | if (conflictItems.count() > 0) { |
1062 | // Look for unused sub cell and insert item | 1062 | // Look for unused sub cell and insert item |
1063 | int i; | 1063 | int i; |
1064 | for(i=0;i<maxSubCells;++i) { | 1064 | for(i=0;i<maxSubCells;++i) { |
1065 | if (!subCellDict.find(i)) { | 1065 | if (!subCellDict.find(i)) { |
1066 | placeItem->setSubCell(i); | 1066 | placeItem->setSubCell(i); |
1067 | break; | 1067 | break; |
1068 | } | 1068 | } |
1069 | } | 1069 | } |
1070 | if (i == maxSubCells) { | 1070 | if (i == maxSubCells) { |
1071 | placeItem->setSubCell(maxSubCells); | 1071 | placeItem->setSubCell(maxSubCells); |
1072 | maxSubCells++; // add new item to number of sub cells | 1072 | maxSubCells++; // add new item to number of sub cells |
1073 | } | 1073 | } |
1074 | 1074 | ||
1075 | // Prepare for sub cell geometry adjustment | 1075 | // Prepare for sub cell geometry adjustment |
1076 | int newSubCellWidth; | 1076 | int newSubCellWidth; |
1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; | 1077 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; |
1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; | 1078 | else newSubCellWidth = mGridSpacingX / maxSubCells; |
1079 | conflictItems.append(placeItem); | 1079 | conflictItems.append(placeItem); |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | // Adjust sub cell geometry of all direct conflict items | 1082 | // Adjust sub cell geometry of all direct conflict items |
1083 | for ( item=conflictItems.first(); item != 0; | 1083 | for ( item=conflictItems.first(); item != 0; |
1084 | item=conflictItems.next() ) { | 1084 | item=conflictItems.next() ) { |
1085 | item->setSubCells(maxSubCells); | 1085 | item->setSubCells(maxSubCells); |
1086 | if (mAllDayMode) { | 1086 | if (mAllDayMode) { |
1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | 1087 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); |
1088 | } else { | 1088 | } else { |
1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | 1089 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); |
1090 | } | 1090 | } |
1091 | int x,y; | 1091 | int x,y; |
1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); | 1092 | gridToContents(item->cellX(),item->cellYTop(),x,y); |
1093 | if (mAllDayMode) { | 1093 | if (mAllDayMode) { |
1094 | y += item->subCell() * newSubCellWidth; | 1094 | y += item->subCell() * newSubCellWidth; |
1095 | } else { | 1095 | } else { |
1096 | x += item->subCell() * newSubCellWidth; | 1096 | x += item->subCell() * newSubCellWidth; |
1097 | } | 1097 | } |
1098 | moveChild(item,x,y); | 1098 | moveChild(item,x,y); |
1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); | 1099 | // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); |
1100 | //item->updateItem(); | 1100 | //item->updateItem(); |
1101 | } | 1101 | } |
1102 | // Adjust sub cell geometry of all conflict items of all conflict items | 1102 | // Adjust sub cell geometry of all conflict items of all conflict items |
1103 | for ( item=conflictItems.first(); item != 0; | 1103 | for ( item=conflictItems.first(); item != 0; |
1104 | item=conflictItems.next() ) { | 1104 | item=conflictItems.next() ) { |
1105 | if ( placeItem != item ) { | 1105 | if ( placeItem != item ) { |
1106 | KOAgendaItem *item2; | 1106 | KOAgendaItem *item2; |
1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); | 1107 | QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); |
1108 | for ( item2=conflictItems2.first(); item2 != 0; | 1108 | for ( item2=conflictItems2.first(); item2 != 0; |
1109 | item2=conflictItems2.next() ) { | 1109 | item2=conflictItems2.next() ) { |
1110 | if ( item2->subCells() != maxSubCells) { | 1110 | if ( item2->subCells() != maxSubCells) { |
1111 | item2->setSubCells(maxSubCells); | 1111 | item2->setSubCells(maxSubCells); |
1112 | if (mAllDayMode) { | 1112 | if (mAllDayMode) { |
1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); | 1113 | item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); |
1114 | } else { | 1114 | } else { |
1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); | 1115 | item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); |
1116 | } | 1116 | } |
1117 | int x,y; | 1117 | int x,y; |
1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); | 1118 | gridToContents(item2->cellX(),item2->cellYTop(),x,y); |
1119 | if (mAllDayMode) { | 1119 | if (mAllDayMode) { |
1120 | y += item2->subCell() * newSubCellWidth; | 1120 | y += item2->subCell() * newSubCellWidth; |
1121 | } else { | 1121 | } else { |
1122 | x += item2->subCell() * newSubCellWidth; | 1122 | x += item2->subCell() * newSubCellWidth; |
1123 | } | 1123 | } |
1124 | moveChild(item2,x,y); | 1124 | moveChild(item2,x,y); |
1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); | 1125 | //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | } | 1128 | } |
1129 | } | 1129 | } |
1130 | } else { | 1130 | } else { |
1131 | placeItem->setSubCell(0); | 1131 | placeItem->setSubCell(0); |
1132 | placeItem->setSubCells(1); | 1132 | placeItem->setSubCells(1); |
1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); | 1133 | if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); |
1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); | 1134 | else placeItem->resize(mGridSpacingX,placeItem->height()); |
1135 | int x,y; | 1135 | int x,y; |
1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); | 1136 | gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); |
1137 | moveChild(placeItem,x,y); | 1137 | moveChild(placeItem,x,y); |
1138 | } | 1138 | } |
1139 | placeItem->setConflictItems(conflictItems); | 1139 | placeItem->setConflictItems(conflictItems); |
1140 | // for ( item=conflictItems.first(); item != 0; | 1140 | // for ( item=conflictItems.first(); item != 0; |
1141 | // item=conflictItems.next() ) { | 1141 | // item=conflictItems.next() ) { |
1142 | // //item->updateItem(); | 1142 | // //item->updateItem(); |
1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); | 1143 | // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); |
1144 | // } | 1144 | // } |
1145 | // placeItem->updateItem(); | 1145 | // placeItem->updateItem(); |
1146 | } | 1146 | } |
1147 | 1147 | ||
1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) | 1148 | void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) |
1149 | { | 1149 | { |
1150 | if ( globalFlagBlockAgenda ) | 1150 | if ( globalFlagBlockAgenda ) |
1151 | return; | 1151 | return; |
1152 | //qDebug("KOAgenda::drawContents "); | 1152 | //qDebug("KOAgenda::drawContents "); |
1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) | 1153 | if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) |
1154 | ;//drawContentsToPainter(); | 1154 | ;//drawContentsToPainter(); |
1155 | 1155 | ||
1156 | QPaintDevice* pd = p->device(); | 1156 | QPaintDevice* pd = p->device(); |
1157 | p->end(); | 1157 | p->end(); |
1158 | int vx, vy; | 1158 | int vx, vy; |
1159 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1159 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1160 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1161 | mSelectionCellX * mGridSpacingX; | 1161 | mSelectionCellX * mGridSpacingX; |
1162 | contentsToViewport ( cx, cy, vx,vy); | 1162 | contentsToViewport ( cx, cy, vx,vy); |
1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; | 1163 | // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; |
1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) | 1164 | if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) |
1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); | 1165 | bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); |
1166 | 1166 | ||
1167 | if ( mSelectionHeight > 0 ) { | 1167 | if ( mSelectionHeight > 0 ) { |
1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); | 1168 | //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); |
1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1169 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1170 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); | 1171 | contentsToViewport ( selectionX, mSelectionYTop, vx,vy); |
1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); | 1172 | bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | //qDebug("btbl "); | 1175 | //qDebug("btbl "); |
1176 | p->begin( pd ); | 1176 | p->begin( pd ); |
1177 | //qDebug("end "); | 1177 | //qDebug("end "); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | void KOAgenda::finishUpdate() | 1180 | void KOAgenda::finishUpdate() |
1181 | { | 1181 | { |
1182 | 1182 | ||
1183 | KOAgendaItem *item; | 1183 | KOAgendaItem *item; |
1184 | globalFlagBlockAgendaItemPaint = 1; | 1184 | globalFlagBlockAgendaItemPaint = 1; |
1185 | // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems | ||
1186 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | ||
1187 | if ( !item->checkLayout() ) { | ||
1188 | //qDebug(" conflictitem found "); | ||
1189 | int newSubCellWidth; | ||
1190 | if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); | ||
1191 | else newSubCellWidth = mGridSpacingX / item->subCells(); | ||
1192 | |||
1193 | if (mAllDayMode) { | ||
1194 | item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); | ||
1195 | } else { | ||
1196 | item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); | ||
1197 | } | ||
1198 | int x,y; | ||
1199 | gridToContents(item->cellX(),item->cellYTop(),x,y); | ||
1200 | if (mAllDayMode) { | ||
1201 | y += item->subCell() * newSubCellWidth; | ||
1202 | } else { | ||
1203 | x += item->subCell() * newSubCellWidth; | ||
1204 | } | ||
1205 | moveChild(item,x,y); | ||
1206 | } | ||
1207 | } | ||
1185 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1208 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1186 | if ( !item->isVisible() ) | 1209 | if ( !item->isVisible() ) |
1187 | item->show(); | 1210 | item->show(); |
1188 | 1211 | ||
1189 | } | 1212 | } |
1190 | globalFlagBlockAgendaItemUpdate = 0; | 1213 | globalFlagBlockAgendaItemUpdate = 0; |
1191 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1214 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1192 | item->repaintMe( ); | 1215 | item->repaintMe( ); |
1193 | } | 1216 | } |
1194 | globalFlagBlockAgendaItemUpdate = 1; | 1217 | globalFlagBlockAgendaItemUpdate = 1; |
1195 | qApp->processEvents(); | 1218 | qApp->processEvents(); |
1196 | globalFlagBlockAgendaItemPaint = 0; | 1219 | globalFlagBlockAgendaItemPaint = 0; |
1197 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1220 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1198 | item->repaint( false ); | 1221 | item->repaint( false ); |
1199 | } | 1222 | } |
1200 | 1223 | ||
1201 | } | 1224 | } |
1202 | 1225 | ||
1203 | /* | 1226 | /* |
1204 | Draw grid in the background of the agenda. | 1227 | Draw grid in the background of the agenda. |
1205 | */ | 1228 | */ |
1206 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) | 1229 | void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) |
1207 | { | 1230 | { |
1208 | 1231 | ||
1209 | 1232 | ||
1210 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) | 1233 | if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) |
1211 | return; | 1234 | return; |
1212 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) | 1235 | if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) |
1213 | return; | 1236 | return; |
1214 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); | 1237 | int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); |
1215 | if ( ch < 1 ) | 1238 | if ( ch < 1 ) |
1216 | ch = 1; | 1239 | ch = 1; |
1217 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { | 1240 | if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { |
1218 | mPaintPixmap.resize( contentsWidth()+42, ch ); | 1241 | mPaintPixmap.resize( contentsWidth()+42, ch ); |
1219 | } | 1242 | } |
1220 | mCurPixWid = contentsWidth(); | 1243 | mCurPixWid = contentsWidth(); |
1221 | mCurPixHei = ch; | 1244 | mCurPixHei = ch; |
1222 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { | 1245 | if ( mHighlightPixmap.width() < mGridSpacingX-1 || mHighlightPixmap.height() < ch ) { |
1223 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); | 1246 | mHighlightPixmap.resize( mGridSpacingX-1, ch ); |
1224 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); | 1247 | mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); |
1225 | } | 1248 | } |
1226 | mPixPainter.begin( &mPaintPixmap) ; | 1249 | mPixPainter.begin( &mPaintPixmap) ; |
1227 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); | 1250 | //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); |
1228 | QPainter * p ; | 1251 | QPainter * p ; |
1229 | if (paint == 0) { | 1252 | if (paint == 0) { |
1230 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); | 1253 | mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); |
1231 | p = &mPixPainter; | 1254 | p = &mPixPainter; |
1232 | } | 1255 | } |
1233 | else | 1256 | else |
1234 | p = paint ; | 1257 | p = paint ; |
1235 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); | 1258 | // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); |
1236 | 1259 | ||
1237 | //--cx;++cw; | 1260 | //--cx;++cw; |
1238 | int lGridSpacingY = mGridSpacingY*2; | 1261 | int lGridSpacingY = mGridSpacingY*2; |
1239 | int selDay; | 1262 | int selDay; |
1240 | if ( !backgroundOnly ) | 1263 | if ( !backgroundOnly ) |
1241 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 1264 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
1242 | { | 1265 | { |
1243 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { | 1266 | if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) { |
1244 | int x1 = cx; | 1267 | int x1 = cx; |
1245 | int y1 = 0; | 1268 | int y1 = 0; |
1246 | if (y1 < cy) y1 = cy; | 1269 | if (y1 < cy) y1 = cy; |
1247 | int x2 = cx+cw-1; | 1270 | int x2 = cx+cw-1; |
1248 | int y2 = contentsHeight(); | 1271 | int y2 = contentsHeight(); |
1249 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1272 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1250 | if (x2 >= x1 && y2 >= y1) { | 1273 | if (x2 >= x1 && y2 >= y1) { |
1251 | int gxStart = selDay; | 1274 | int gxStart = selDay; |
1252 | int gxEnd = gxStart ; | 1275 | int gxEnd = gxStart ; |
1253 | int xStart = KOGlobals::self()->reverseLayout() ? | 1276 | int xStart = KOGlobals::self()->reverseLayout() ? |
1254 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1277 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1255 | gxStart*mGridSpacingX; | 1278 | gxStart*mGridSpacingX; |
1256 | if (xStart < x1) xStart = x1; | 1279 | if (xStart < x1) xStart = x1; |
1257 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1280 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1258 | (mColumns - gxStart)*mGridSpacingX-1 : | 1281 | (mColumns - gxStart)*mGridSpacingX-1 : |
1259 | (gxStart+1)*mGridSpacingX-1; | 1282 | (gxStart+1)*mGridSpacingX-1; |
1260 | if (xEnd > x2) xEnd = x2; | 1283 | if (xEnd > x2) xEnd = x2; |
1261 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1284 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1262 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1285 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1263 | KOPrefs::instance()->mAgendaBgColor.light()); | 1286 | KOPrefs::instance()->mAgendaBgColor.light()); |
1264 | else | 1287 | else |
1265 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1288 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1266 | KOPrefs::instance()->mAgendaBgColor.dark()); | 1289 | KOPrefs::instance()->mAgendaBgColor.dark()); |
1267 | 1290 | ||
1268 | } | 1291 | } |
1269 | } | 1292 | } |
1270 | } | 1293 | } |
1271 | // Highlight working hours | 1294 | // Highlight working hours |
1272 | 1295 | ||
1273 | if ( !backgroundOnly ) | 1296 | if ( !backgroundOnly ) |
1274 | if (mWorkingHoursEnable) { | 1297 | if (mWorkingHoursEnable) { |
1275 | int x1 = cx; | 1298 | int x1 = cx; |
1276 | int y1 = mWorkingHoursYTop; | 1299 | int y1 = mWorkingHoursYTop; |
1277 | if (y1 < cy) y1 = cy; | 1300 | if (y1 < cy) y1 = cy; |
1278 | int x2 = cx+cw-1; | 1301 | int x2 = cx+cw-1; |
1279 | // int x2 = mGridSpacingX * 5 - 1; | 1302 | // int x2 = mGridSpacingX * 5 - 1; |
1280 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; | 1303 | // if (x2 > cx+cw-1) x2 = cx + cw - 1; |
1281 | int y2 = mWorkingHoursYBottom; | 1304 | int y2 = mWorkingHoursYBottom; |
1282 | if (y2 > cy+ch-1) y2=cy+ch-1; | 1305 | if (y2 > cy+ch-1) y2=cy+ch-1; |
1283 | 1306 | ||
1284 | if (x2 >= x1 && y2 >= y1) { | 1307 | if (x2 >= x1 && y2 >= y1) { |
1285 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); | 1308 | // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); |
1286 | int gxStart = x1/mGridSpacingX; | 1309 | int gxStart = x1/mGridSpacingX; |
1287 | int gxEnd = x2/mGridSpacingX; | 1310 | int gxEnd = x2/mGridSpacingX; |
1288 | while(gxStart <= gxEnd) { | 1311 | while(gxStart <= gxEnd) { |
1289 | if (gxStart < int(mHolidayMask->count()) && | 1312 | if (gxStart < int(mHolidayMask->count()) && |
1290 | !mHolidayMask->at(gxStart)) { | 1313 | !mHolidayMask->at(gxStart)) { |
1291 | int xStart = KOGlobals::self()->reverseLayout() ? | 1314 | int xStart = KOGlobals::self()->reverseLayout() ? |
1292 | (mColumns - 1 - gxStart)*mGridSpacingX : | 1315 | (mColumns - 1 - gxStart)*mGridSpacingX : |
1293 | gxStart*mGridSpacingX; | 1316 | gxStart*mGridSpacingX; |
1294 | if (xStart < x1) xStart = x1; | 1317 | if (xStart < x1) xStart = x1; |
1295 | int xEnd = KOGlobals::self()->reverseLayout() ? | 1318 | int xEnd = KOGlobals::self()->reverseLayout() ? |
1296 | (mColumns - gxStart)*mGridSpacingX-1 : | 1319 | (mColumns - gxStart)*mGridSpacingX-1 : |
1297 | (gxStart+1)*mGridSpacingX-1; | 1320 | (gxStart+1)*mGridSpacingX-1; |
1298 | if (xEnd > x2) xEnd = x2; | 1321 | if (xEnd > x2) xEnd = x2; |
1299 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { | 1322 | if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) { |
1300 | if ( KOPrefs::instance()->mUseHighlightLightColor ) | 1323 | if ( KOPrefs::instance()->mUseHighlightLightColor ) |
1301 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1324 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1302 | KOPrefs::instance()->mWorkingHoursColor.light()); | 1325 | KOPrefs::instance()->mWorkingHoursColor.light()); |
1303 | else | 1326 | else |
1304 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1327 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1305 | KOPrefs::instance()->mWorkingHoursColor.dark()); | 1328 | KOPrefs::instance()->mWorkingHoursColor.dark()); |
1306 | } else { | 1329 | } else { |
1307 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, | 1330 | p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, |
1308 | KOPrefs::instance()->mWorkingHoursColor); | 1331 | KOPrefs::instance()->mWorkingHoursColor); |
1309 | } | 1332 | } |
1310 | } | 1333 | } |
1311 | ++gxStart; | 1334 | ++gxStart; |
1312 | } | 1335 | } |
1313 | } | 1336 | } |
1314 | } | 1337 | } |
1315 | /* | 1338 | /* |
1316 | int selectionX = KOGlobals::self()->reverseLayout() ? | 1339 | int selectionX = KOGlobals::self()->reverseLayout() ? |
1317 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : | 1340 | (mColumns - 1 - mSelectionCellX) * mGridSpacingX : |
1318 | mSelectionCellX * mGridSpacingX; | 1341 | mSelectionCellX * mGridSpacingX; |
1319 | 1342 | ||
1320 | // Draw selection | 1343 | // Draw selection |
1321 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && | 1344 | if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && |
1322 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { | 1345 | ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { |
1323 | // TODO: paint only part within cx,cy,cw,ch | 1346 | // TODO: paint only part within cx,cy,cw,ch |
1324 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, | 1347 | p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, |
1325 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); | 1348 | mSelectionHeight, KOPrefs::instance()->mHighlightColor ); |
1326 | } | 1349 | } |
1327 | */ | 1350 | */ |
1328 | // Draw vertical lines of grid | 1351 | // Draw vertical lines of grid |
1329 | 1352 | ||
1330 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; | 1353 | int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; |
1331 | if ( mGridSpacingX > 0 ) { | 1354 | if ( mGridSpacingX > 0 ) { |
1332 | while (x < cx + cw) { | 1355 | while (x < cx + cw) { |
1333 | p->drawLine(x,cy,x,cy+ch); | 1356 | p->drawLine(x,cy,x,cy+ch); |
1334 | x+=mGridSpacingX; | 1357 | x+=mGridSpacingX; |
1335 | } | 1358 | } |
1336 | } | 1359 | } |
1337 | // Draw horizontal lines of grid | 1360 | // Draw horizontal lines of grid |
1338 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; | 1361 | int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; |
1339 | if ( lGridSpacingY > 0 ) { | 1362 | if ( lGridSpacingY > 0 ) { |
1340 | while (y < cy + ch) { | 1363 | while (y < cy + ch) { |
1341 | p->setPen( SolidLine ); | 1364 | p->setPen( SolidLine ); |
1342 | p->drawLine(cx,y,cx+cw,y); | 1365 | p->drawLine(cx,y,cx+cw,y); |
1343 | y+=lGridSpacingY; | 1366 | y+=lGridSpacingY; |
1344 | p->setPen( DotLine ); | 1367 | p->setPen( DotLine ); |
1345 | p->drawLine(cx,y,cx+cw,y); | 1368 | p->drawLine(cx,y,cx+cw,y); |
1346 | y+=lGridSpacingY; | 1369 | y+=lGridSpacingY; |
1347 | } | 1370 | } |
1348 | p->setPen( SolidLine ); | 1371 | p->setPen( SolidLine ); |
1349 | } | 1372 | } |
1350 | mPixPainter.end() ; | 1373 | mPixPainter.end() ; |
1351 | } | 1374 | } |
1352 | 1375 | ||
1353 | /* | 1376 | /* |
1354 | Convert srcollview contents coordinates to agenda grid coordinates. | 1377 | Convert srcollview contents coordinates to agenda grid coordinates. |
1355 | */ | 1378 | */ |
1356 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) | 1379 | void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) |
1357 | { | 1380 | { |
1358 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : | 1381 | gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : |
1359 | x/mGridSpacingX; | 1382 | x/mGridSpacingX; |
1360 | gy = y/mGridSpacingY; | 1383 | gy = y/mGridSpacingY; |
1361 | } | 1384 | } |
1362 | 1385 | ||
1363 | /* | 1386 | /* |
1364 | Convert agenda grid coordinates to scrollview contents coordinates. | 1387 | Convert agenda grid coordinates to scrollview contents coordinates. |
1365 | */ | 1388 | */ |
1366 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) | 1389 | void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) |
1367 | { | 1390 | { |
1368 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: | 1391 | x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: |
1369 | gx*mGridSpacingX; | 1392 | gx*mGridSpacingX; |
1370 | y = gy*mGridSpacingY; | 1393 | y = gy*mGridSpacingY; |
1371 | } | 1394 | } |
1372 | 1395 | ||
1373 | 1396 | ||
1374 | /* | 1397 | /* |
1375 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into | 1398 | Return Y coordinate corresponding to time. Coordinates are rounded to fit into |
1376 | the grid. | 1399 | the grid. |
1377 | */ | 1400 | */ |
1378 | int KOAgenda::timeToY(const QTime &time) | 1401 | int KOAgenda::timeToY(const QTime &time) |
1379 | { | 1402 | { |
1380 | int minutesPerCell = 24 * 60 / mRows; | 1403 | int minutesPerCell = 24 * 60 / mRows; |
1381 | int timeMinutes = time.hour() * 60 + time.minute(); | 1404 | int timeMinutes = time.hour() * 60 + time.minute(); |
1382 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; | 1405 | int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; |
1383 | return Y; | 1406 | return Y; |
1384 | } | 1407 | } |
1385 | 1408 | ||
1386 | 1409 | ||
1387 | /* | 1410 | /* |
1388 | Return time corresponding to cell y coordinate. Coordinates are rounded to | 1411 | Return time corresponding to cell y coordinate. Coordinates are rounded to |
1389 | fit into the grid. | 1412 | fit into the grid. |
1390 | */ | 1413 | */ |
1391 | QTime KOAgenda::gyToTime(int gy) | 1414 | QTime KOAgenda::gyToTime(int gy) |
1392 | { | 1415 | { |
1393 | 1416 | ||
1394 | int secondsPerCell = 24 * 60 * 60/ mRows; | 1417 | int secondsPerCell = 24 * 60 * 60/ mRows; |
1395 | 1418 | ||
1396 | int timeSeconds = secondsPerCell * gy; | 1419 | int timeSeconds = secondsPerCell * gy; |
1397 | 1420 | ||
1398 | QTime time( 0, 0, 0 ); | 1421 | QTime time( 0, 0, 0 ); |
1399 | if ( timeSeconds < 24 * 60 * 60 ) { | 1422 | if ( timeSeconds < 24 * 60 * 60 ) { |
1400 | time = time.addSecs(timeSeconds); | 1423 | time = time.addSecs(timeSeconds); |
1401 | } else { | 1424 | } else { |
1402 | time.setHMS( 23, 59, 59 ); | 1425 | time.setHMS( 23, 59, 59 ); |
1403 | } | 1426 | } |
1404 | 1427 | ||
1405 | return time; | 1428 | return time; |
1406 | } | 1429 | } |
1407 | 1430 | ||
1408 | void KOAgenda::setStartHour(int startHour) | 1431 | void KOAgenda::setStartHour(int startHour) |
1409 | { | 1432 | { |
1410 | int startCell = startHour * mRows / 24; | 1433 | int startCell = startHour * mRows / 24; |
1411 | setContentsPos(0,startCell * gridSpacingY()); | 1434 | setContentsPos(0,startCell * gridSpacingY()); |
1412 | } | 1435 | } |
1413 | void KOAgenda::hideUnused() | 1436 | void KOAgenda::hideUnused() |
1414 | { | 1437 | { |
1415 | // experimental only | 1438 | // experimental only |
1416 | // return; | 1439 | // return; |
1417 | KOAgendaItem *item; | 1440 | KOAgendaItem *item; |
1418 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { | 1441 | for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { |
1419 | item->hide(); | 1442 | item->hide(); |
1420 | } | 1443 | } |
1421 | } | 1444 | } |
1422 | 1445 | ||
1423 | 1446 | ||
1424 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) | 1447 | KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) |
1425 | { | 1448 | { |
1426 | 1449 | ||
1427 | KOAgendaItem *fi; | 1450 | KOAgendaItem *fi; |
1428 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { | 1451 | for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { |
1429 | if ( fi->incidence() == event ) { | 1452 | if ( fi->incidence() == event ) { |
1430 | mUnusedItems.remove(); | 1453 | mUnusedItems.remove(); |
1431 | fi->init( event, qd ); | 1454 | fi->init( event, qd ); |
1432 | return fi; | 1455 | return fi; |
1433 | } | 1456 | } |
1434 | } | 1457 | } |
1435 | fi=mUnusedItems.first(); | 1458 | fi=mUnusedItems.first(); |
1436 | if ( fi ) { | 1459 | if ( fi ) { |
1437 | mUnusedItems.remove(); | 1460 | mUnusedItems.remove(); |
1438 | fi->init( event, qd ); | 1461 | fi->init( event, qd ); |
1439 | return fi; | 1462 | return fi; |
1440 | } | 1463 | } |
1441 | // qDebug("new KOAgendaItem "); | 1464 | // qDebug("new KOAgendaItem "); |
1442 | 1465 | ||
1443 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); | 1466 | KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); |
1444 | agendaItem->installEventFilter(this); | 1467 | agendaItem->installEventFilter(this); |
1445 | addChild(agendaItem,0,0); | 1468 | addChild(agendaItem,0,0); |
1446 | return agendaItem; | 1469 | return agendaItem; |
1447 | } | 1470 | } |
1448 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) | 1471 | KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) |
1449 | { | 1472 | { |
1450 | KOAgendaItem *item; | 1473 | KOAgendaItem *item; |
1451 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1474 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1452 | if ( item->incidence() == todo ) { | 1475 | if ( item->incidence() == todo ) { |
1453 | mItems.remove(); | 1476 | mItems.remove(); |
1454 | return item; | 1477 | return item; |
1455 | } | 1478 | } |
1456 | } | 1479 | } |
1457 | return 0; | 1480 | return 0; |
1458 | } | 1481 | } |
1459 | 1482 | ||
1460 | 1483 | ||
1461 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) | 1484 | void KOAgenda::updateTodo( Todo * todo, int days, bool remove) |
1462 | { | 1485 | { |
1463 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| | 1486 | // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| |
1464 | KOAgendaItem *item; | 1487 | KOAgendaItem *item; |
1465 | item = getItemForTodo ( todo ); | 1488 | item = getItemForTodo ( todo ); |
1466 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); | 1489 | //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); |
1467 | if ( item ) { | 1490 | if ( item ) { |
1468 | blockSignals( true ); | 1491 | blockSignals( true ); |
1469 | //qDebug("item found "); | 1492 | //qDebug("item found "); |
1470 | item->hide(); | 1493 | item->hide(); |
1471 | item->setCellX(-2, -1 ); | 1494 | item->setCellX(-2, -1 ); |
1472 | item->select(false); | 1495 | item->select(false); |
1473 | mUnusedItems.append( item ); | 1496 | mUnusedItems.append( item ); |
1474 | mItems.remove( item ); | 1497 | mItems.remove( item ); |
1475 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1498 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1476 | KOAgendaItem *itemit; | 1499 | KOAgendaItem *itemit; |
1477 | //globalFlagBlockAgendaItemPaint = 1; | 1500 | //globalFlagBlockAgendaItemPaint = 1; |
1478 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1501 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1479 | itemit=oldconflictItems.next() ) { | 1502 | itemit=oldconflictItems.next() ) { |
1480 | if ( itemit != item ) | 1503 | if ( itemit != item ) |
1481 | placeSubCells(itemit); | 1504 | placeSubCells(itemit); |
1482 | } | 1505 | } |
1483 | qApp->processEvents(); | 1506 | qApp->processEvents(); |
1484 | //globalFlagBlockAgendaItemPaint = 0; | 1507 | //globalFlagBlockAgendaItemPaint = 0; |
1485 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1508 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1486 | itemit=oldconflictItems.next() ) { | 1509 | itemit=oldconflictItems.next() ) { |
1487 | globalFlagBlockAgendaItemUpdate = 0; | 1510 | globalFlagBlockAgendaItemUpdate = 0; |
1488 | if ( itemit != item ) | 1511 | if ( itemit != item ) |
1489 | itemit->repaintMe(); | 1512 | itemit->repaintMe(); |
1490 | globalFlagBlockAgendaItemUpdate = 1; | 1513 | globalFlagBlockAgendaItemUpdate = 1; |
1491 | itemit->repaint(); | 1514 | itemit->repaint(); |
1492 | } | 1515 | } |
1493 | blockSignals( false ); | 1516 | blockSignals( false ); |
1494 | } | 1517 | } |
1495 | if ( remove ) { | 1518 | if ( remove ) { |
1496 | //qDebug("remove****************************************** "); | 1519 | //qDebug("remove****************************************** "); |
1497 | return; | 1520 | return; |
1498 | } | 1521 | } |
1499 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); | 1522 | //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); |
1500 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); | 1523 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda ); |
1501 | QDate currentDate; | 1524 | QDate currentDate; |
1502 | QDateTime dt; | 1525 | QDateTime dt; |
1503 | if ( todo->hasCompletedDate() ) | 1526 | if ( todo->hasCompletedDate() ) |
1504 | dt = todo->completed(); | 1527 | dt = todo->completed(); |
1505 | else | 1528 | else |
1506 | dt = todo->dtDue(); | 1529 | dt = todo->dtDue(); |
1507 | if ( overdue ) { | 1530 | if ( overdue ) { |
1508 | currentDate = QDate::currentDate(); | 1531 | currentDate = QDate::currentDate(); |
1509 | days += todo->dtDue().date().daysTo( currentDate ); | 1532 | days += todo->dtDue().date().daysTo( currentDate ); |
1510 | } | 1533 | } |
1511 | else | 1534 | else |
1512 | currentDate = dt.date(); | 1535 | currentDate = dt.date(); |
1513 | 1536 | ||
1514 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { | 1537 | if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { |
1515 | if ( ! mAllDayMode ) return; | 1538 | if ( ! mAllDayMode ) return; |
1516 | // aldayagenda | 1539 | // aldayagenda |
1517 | globalFlagBlockAgendaItemPaint = 1; | 1540 | globalFlagBlockAgendaItemPaint = 1; |
1518 | item = insertAllDayItem(todo, currentDate,days, days); | 1541 | item = insertAllDayItem(todo, currentDate,days, days); |
1519 | item->show(); | 1542 | item->show(); |
1520 | 1543 | ||
1521 | } | 1544 | } |
1522 | else { | 1545 | else { |
1523 | if ( mAllDayMode ) return; | 1546 | if ( mAllDayMode ) return; |
1524 | // mAgenda | 1547 | // mAgenda |
1525 | globalFlagBlockAgendaItemPaint = 1; | 1548 | globalFlagBlockAgendaItemPaint = 1; |
1526 | int endY = timeToY(dt.time()) - 1; | 1549 | int endY = timeToY(dt.time()) - 1; |
1527 | int hi = 12/KOPrefs::instance()->mHourSize; | 1550 | int hi = 12/KOPrefs::instance()->mHourSize; |
1528 | int startY = endY - 1-hi; | 1551 | int startY = endY - 1-hi; |
1529 | item = insertItem(todo,currentDate,days,startY,endY); | 1552 | item = insertItem(todo,currentDate,days,startY,endY); |
1530 | item->show(); | 1553 | item->show(); |
1531 | } | 1554 | } |
1532 | qApp->processEvents(); | 1555 | qApp->processEvents(); |
1533 | globalFlagBlockAgendaItemPaint = 0; | 1556 | globalFlagBlockAgendaItemPaint = 0; |
1534 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); | 1557 | QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); |
1535 | KOAgendaItem *itemit; | 1558 | KOAgendaItem *itemit; |
1536 | for ( itemit=oldconflictItems.first(); itemit != 0; | 1559 | for ( itemit=oldconflictItems.first(); itemit != 0; |
1537 | itemit=oldconflictItems.next() ) { | 1560 | itemit=oldconflictItems.next() ) { |
1538 | globalFlagBlockAgendaItemUpdate = 0; | 1561 | globalFlagBlockAgendaItemUpdate = 0; |
1539 | itemit->repaintMe(); | 1562 | itemit->repaintMe(); |
1540 | globalFlagBlockAgendaItemUpdate = 1; | 1563 | globalFlagBlockAgendaItemUpdate = 1; |
1541 | itemit->repaint(); | 1564 | itemit->repaint(); |
1542 | } | 1565 | } |
1543 | globalFlagBlockAgendaItemUpdate = 0; | 1566 | globalFlagBlockAgendaItemUpdate = 0; |
1544 | item->repaintMe(); | 1567 | item->repaintMe(); |
1545 | globalFlagBlockAgendaItemUpdate = 1; | 1568 | globalFlagBlockAgendaItemUpdate = 1; |
1546 | item->repaint(); | 1569 | item->repaint(); |
1547 | } | 1570 | } |
1548 | /* | 1571 | /* |
1549 | Insert KOAgendaItem into agenda. | 1572 | Insert KOAgendaItem into agenda. |
1550 | */ | 1573 | */ |
1551 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) | 1574 | KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) |
1552 | { | 1575 | { |
1553 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; | 1576 | //kdDebug() << "KOAgenda::insertItem:" << event->summary() << "-" << qd.toString() << " ;top, bottom:" << YTop << "," << YBottom << endl; |
1554 | 1577 | ||
1555 | if (mAllDayMode) { | 1578 | if (mAllDayMode) { |
1556 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; | 1579 | kdDebug() << "KOAgenda: calling insertItem in all-day mode is illegal." << endl; |
1557 | return 0; | 1580 | return 0; |
1558 | } | 1581 | } |
1559 | 1582 | ||
1560 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1583 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1561 | //agendaItem->setFrameStyle(WinPanel|Raised); | 1584 | //agendaItem->setFrameStyle(WinPanel|Raised); |
1562 | 1585 | ||
1563 | int YSize = YBottom - YTop + 1; | 1586 | int YSize = YBottom - YTop + 1; |
1564 | if (YSize < 0) { | 1587 | if (YSize < 0) { |
1565 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; | 1588 | kdDebug() << "KOAgenda::insertItem(): Text: " << agendaItem->text() << " YSize<0" << endl; |
1566 | YSize = 1; | 1589 | YSize = 1; |
1567 | } | 1590 | } |
1568 | int iheight = mGridSpacingY * YSize; | 1591 | int iheight = mGridSpacingY * YSize; |
1569 | 1592 | ||
1570 | agendaItem->resize(mGridSpacingX,iheight ); | 1593 | agendaItem->resize(mGridSpacingX,iheight ); |
1571 | agendaItem->setCellXY(X,YTop,YBottom); | 1594 | agendaItem->setCellXY(X,YTop,YBottom); |
1572 | agendaItem->setCellXWidth(X); | 1595 | agendaItem->setCellXWidth(X); |
1573 | 1596 | ||
1574 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); | 1597 | //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); |
1575 | mItems.append(agendaItem); | 1598 | mItems.append(agendaItem); |
1576 | 1599 | ||
1577 | placeSubCells(agendaItem); | 1600 | placeSubCells(agendaItem); |
1578 | 1601 | ||
1579 | //agendaItem->show(); | 1602 | //agendaItem->show(); |
1580 | 1603 | ||
1581 | marcus_bains(); | 1604 | marcus_bains(); |
1582 | 1605 | ||
1583 | return agendaItem; | 1606 | return agendaItem; |
1584 | } | 1607 | } |
1585 | 1608 | ||
1586 | 1609 | ||
1587 | /* | 1610 | /* |
1588 | Insert all-day KOAgendaItem into agenda. | 1611 | Insert all-day KOAgendaItem into agenda. |
1589 | */ | 1612 | */ |
1590 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) | 1613 | KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) |
1591 | { | 1614 | { |
1592 | if (!mAllDayMode) { | 1615 | if (!mAllDayMode) { |
1593 | return 0; | 1616 | return 0; |
1594 | } | 1617 | } |
1595 | 1618 | ||
1596 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); | 1619 | KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); |
1597 | 1620 | ||
1598 | agendaItem->setCellXY(XBegin,0,0); | 1621 | agendaItem->setCellXY(XBegin,0,0); |
1599 | agendaItem->setCellXWidth(XEnd); | 1622 | agendaItem->setCellXWidth(XEnd); |
1600 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); | 1623 | agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); |
1601 | 1624 | ||
1602 | //addChild(agendaItem,XBegin*mGridSpacingX,0); | 1625 | //addChild(agendaItem,XBegin*mGridSpacingX,0); |
1603 | mItems.append(agendaItem); | 1626 | mItems.append(agendaItem); |
1604 | 1627 | ||
1605 | placeSubCells(agendaItem); | 1628 | placeSubCells(agendaItem); |
1606 | 1629 | ||
1607 | //agendaItem->show(); | 1630 | //agendaItem->show(); |
1608 | 1631 | ||
1609 | return agendaItem; | 1632 | return agendaItem; |
1610 | } | 1633 | } |
1611 | 1634 | ||
1612 | 1635 | ||
1613 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 1636 | void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
1614 | int YTop,int YBottom) | 1637 | int YTop,int YBottom) |
1615 | { | 1638 | { |
1616 | if (mAllDayMode) { | 1639 | if (mAllDayMode) { |
1617 | ; | 1640 | ; |
1618 | return; | 1641 | return; |
1619 | } | 1642 | } |
1620 | 1643 | ||
1621 | int cellX,cellYTop,cellYBottom; | 1644 | int cellX,cellYTop,cellYBottom; |
1622 | QString newtext; | 1645 | QString newtext; |
1623 | int width = XEnd - XBegin + 1; | 1646 | int width = XEnd - XBegin + 1; |
1624 | int count = 0; | 1647 | int count = 0; |
1625 | KOAgendaItem *current = 0; | 1648 | KOAgendaItem *current = 0; |
1626 | QPtrList<KOAgendaItem> multiItems; | 1649 | QPtrList<KOAgendaItem> multiItems; |
1627 | for (cellX = XBegin;cellX <= XEnd;++cellX) { | 1650 | for (cellX = XBegin;cellX <= XEnd;++cellX) { |
1628 | if (cellX == XBegin) cellYTop = YTop; | 1651 | if (cellX == XBegin) cellYTop = YTop; |
1629 | else cellYTop = 0; | 1652 | else cellYTop = 0; |
1630 | if (cellX == XEnd) cellYBottom = YBottom; | 1653 | if (cellX == XEnd) cellYBottom = YBottom; |
1631 | else cellYBottom = rows() - 1; | 1654 | else cellYBottom = rows() - 1; |
1632 | newtext = QString("(%1/%2): ").arg(++count).arg(width); | 1655 | newtext = QString("(%1/%2): ").arg(++count).arg(width); |
1633 | newtext.append(event->summary()); | 1656 | newtext.append(event->summary()); |
1634 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); | 1657 | current = insertItem(event,qd,cellX,cellYTop,cellYBottom); |
1635 | current->setText(newtext); | 1658 | current->setText(newtext); |
1636 | multiItems.append(current); | 1659 | multiItems.append(current); |
1637 | } | 1660 | } |
1638 | 1661 | ||
1639 | KOAgendaItem *next = 0; | 1662 | KOAgendaItem *next = 0; |
1640 | KOAgendaItem *last = multiItems.last(); | 1663 | KOAgendaItem *last = multiItems.last(); |
1641 | KOAgendaItem *first = multiItems.first(); | 1664 | KOAgendaItem *first = multiItems.first(); |
1642 | KOAgendaItem *setFirst,*setLast; | 1665 | KOAgendaItem *setFirst,*setLast; |
1643 | current = first; | 1666 | current = first; |
1644 | while (current) { | 1667 | while (current) { |
1645 | next = multiItems.next(); | 1668 | next = multiItems.next(); |
1646 | if (current == first) setFirst = 0; | 1669 | if (current == first) setFirst = 0; |
1647 | else setFirst = first; | 1670 | else setFirst = first; |
1648 | if (current == last) setLast = 0; | 1671 | if (current == last) setLast = 0; |
1649 | else setLast = last; | 1672 | else setLast = last; |
1650 | 1673 | ||
1651 | current->setMultiItem(setFirst,next,setLast); | 1674 | current->setMultiItem(setFirst,next,setLast); |
1652 | current = next; | 1675 | current = next; |
1653 | } | 1676 | } |
1654 | 1677 | ||
1655 | marcus_bains(); | 1678 | marcus_bains(); |
1656 | } | 1679 | } |
1657 | 1680 | ||
1658 | 1681 | ||
1659 | //QSizePolicy KOAgenda::sizePolicy() const | 1682 | //QSizePolicy KOAgenda::sizePolicy() const |
1660 | //{ | 1683 | //{ |
1661 | // Thought this would make the all-day event agenda minimum size and the | 1684 | // Thought this would make the all-day event agenda minimum size and the |
1662 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter | 1685 | // normal agenda take the remaining space. But it doesn´t work. The QSplitter |
1663 | // don´t seem to think that an Expanding widget needs more space than a | 1686 | // don´t seem to think that an Expanding widget needs more space than a |
1664 | // Preferred one. | 1687 | // Preferred one. |
1665 | // But it doesn´t hurt, so it stays. | 1688 | // But it doesn´t hurt, so it stays. |
1666 | // if (mAllDayMode) { | 1689 | // if (mAllDayMode) { |
1667 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); | 1690 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); |
1668 | // } else { | 1691 | // } else { |
1669 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); | 1692 | // return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); |
1670 | // } | 1693 | // } |
1671 | //} | 1694 | //} |
1672 | void KOAgenda::finishResize ( ) | 1695 | void KOAgenda::finishResize ( ) |
1673 | { | 1696 | { |
1674 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); | 1697 | //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); |
1675 | if ( globalFlagBlockAgenda == 0 ) { | 1698 | if ( globalFlagBlockAgenda == 0 ) { |
1676 | finishUpdate(); | 1699 | finishUpdate(); |
1677 | //qDebug("finishUpdate() called "); | 1700 | //qDebug("finishUpdate() called "); |
1678 | } | 1701 | } |
1679 | } | 1702 | } |
1680 | /* | 1703 | /* |
1681 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. | 1704 | Overridden from QScrollView to provide proper resizing of KOAgendaItems. |
1682 | */ | 1705 | */ |
1683 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) | 1706 | void KOAgenda::resizeEvent ( QResizeEvent *ev ) |
1684 | { | 1707 | { |
1685 | 1708 | ||
1686 | mResizeTimer.start( 150 , true ); | 1709 | mResizeTimer.start( 150 , true ); |
1687 | computeSizes(); | 1710 | computeSizes(); |
1688 | return; | 1711 | return; |
1689 | 1712 | ||
1690 | } | 1713 | } |
1691 | void KOAgenda::computeSizes() | 1714 | void KOAgenda::computeSizes() |
1692 | { | 1715 | { |
1693 | if ( globalFlagBlockStartup ) | 1716 | if ( globalFlagBlockStartup ) |
1694 | return; | 1717 | return; |
1695 | 1718 | ||
1696 | if (mAllDayMode) { | 1719 | if (mAllDayMode) { |
1697 | mGridSpacingX = (width()-3) / mColumns; | 1720 | mGridSpacingX = (width()-3) / mColumns; |
1698 | mGridSpacingY = height() - 2 * frameWidth() - 1; | 1721 | mGridSpacingY = height() - 2 * frameWidth() - 1; |
1699 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); | 1722 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); |
1700 | // mGridSpacingY = height(); | 1723 | // mGridSpacingY = height(); |
1701 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1724 | // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1702 | 1725 | ||
1703 | KOAgendaItem *item; | 1726 | KOAgendaItem *item; |
1704 | int subCellWidth; | 1727 | int subCellWidth; |
1705 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1728 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1706 | subCellWidth = mGridSpacingY / item->subCells(); | 1729 | subCellWidth = mGridSpacingY / item->subCells(); |
1707 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); | 1730 | item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); |
1708 | moveChild(item,KOGlobals::self()->reverseLayout() ? | 1731 | moveChild(item,KOGlobals::self()->reverseLayout() ? |
1709 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1732 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1710 | item->cellX() * mGridSpacingX, | 1733 | item->cellX() * mGridSpacingX, |
1711 | item->subCell() * subCellWidth); | 1734 | item->subCell() * subCellWidth); |
1712 | } | 1735 | } |
1713 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; | 1736 | KOPrefs::instance()->mAllDaySize = mGridSpacingY; |
1714 | } else { | 1737 | } else { |
1715 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; | 1738 | mGridSpacingX = (width() - verticalScrollBar()->width()-3)/mColumns; |
1716 | if (height() > mGridSpacingY * mRows + 1 ) { | 1739 | if (height() > mGridSpacingY * mRows + 1 ) { |
1717 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; | 1740 | KOPrefs::instance()->mHourSize = ((height())/mRows)+1; |
1718 | mGridSpacingY = KOPrefs::instance()->mHourSize ; | 1741 | mGridSpacingY = KOPrefs::instance()->mHourSize ; |
1719 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1742 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1720 | emit resizedSignal(); | 1743 | emit resizedSignal(); |
1721 | } else | 1744 | } else |
1722 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 1745 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
1723 | KOAgendaItem *item; | 1746 | KOAgendaItem *item; |
1724 | int subCellWidth; | 1747 | int subCellWidth; |
1725 | 1748 | ||
1726 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 1749 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
1727 | subCellWidth = mGridSpacingX / item->subCells(); | 1750 | subCellWidth = mGridSpacingX / item->subCells(); |
1728 | item->resize(subCellWidth,item->height()); | 1751 | item->resize(subCellWidth,item->height()); |
1729 | moveChild(item,(KOGlobals::self()->reverseLayout() ? | 1752 | moveChild(item,(KOGlobals::self()->reverseLayout() ? |
1730 | (mColumns - 1 - item->cellX()) * mGridSpacingX : | 1753 | (mColumns - 1 - item->cellX()) * mGridSpacingX : |
1731 | item->cellX() * mGridSpacingX) + | 1754 | item->cellX() * mGridSpacingX) + |
1732 | item->subCell() * subCellWidth,childY(item)); | 1755 | item->subCell() * subCellWidth,childY(item)); |
1733 | } | 1756 | } |
1734 | } | 1757 | } |
1735 | int cw = contentsWidth(); | 1758 | int cw = contentsWidth(); |
1736 | int ch = contentsHeight(); | 1759 | int ch = contentsHeight(); |
1737 | if ( mAllDayMode ) { | 1760 | if ( mAllDayMode ) { |
1738 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); | 1761 | QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); |
1739 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) | 1762 | if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) |
1740 | paintPixAll->resize( cw, ch ); | 1763 | paintPixAll->resize( cw, ch ); |
1741 | } else { | 1764 | } else { |
1742 | QPixmap* paintPix = KOAgendaItem::paintPix(); | 1765 | QPixmap* paintPix = KOAgendaItem::paintPix(); |
1743 | if ( paintPix->width() < cw || paintPix->height() < ch ) | 1766 | if ( paintPix->width() < cw || paintPix->height() < ch ) |
1744 | KOAgendaItem::resizePixmap( cw , ch ); | 1767 | KOAgendaItem::resizePixmap( cw , ch ); |
1745 | } | 1768 | } |
1746 | 1769 | ||
1747 | checkScrollBoundaries(); | 1770 | checkScrollBoundaries(); |
1748 | marcus_bains(); | 1771 | marcus_bains(); |
1749 | drawContentsToPainter(); | 1772 | drawContentsToPainter(); |
1750 | viewport()->repaint(false); | 1773 | viewport()->repaint(false); |
1751 | } | 1774 | } |
1752 | 1775 | ||
1753 | void KOAgenda::scrollUp() | 1776 | void KOAgenda::scrollUp() |
1754 | { | 1777 | { |
1755 | scrollBy(0,-mScrollOffset); | 1778 | scrollBy(0,-mScrollOffset); |
1756 | } | 1779 | } |
1757 | 1780 | ||
1758 | 1781 | ||
1759 | void KOAgenda::scrollDown() | 1782 | void KOAgenda::scrollDown() |
1760 | { | 1783 | { |
1761 | scrollBy(0,mScrollOffset); | 1784 | scrollBy(0,mScrollOffset); |
1762 | } | 1785 | } |
1763 | 1786 | ||
1764 | void KOAgenda::popupAlarm() | 1787 | void KOAgenda::popupAlarm() |
1765 | { | 1788 | { |
1766 | if (!mClickedItem) { | 1789 | if (!mClickedItem) { |
1767 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); | 1790 | qDebug("KOAgenda::popupAlarm() called without having a clicked item "); |
1768 | return; | 1791 | return; |
1769 | } | 1792 | } |
1770 | // TODO: deal correctly with multiple alarms | 1793 | // TODO: deal correctly with multiple alarms |
1771 | Alarm* alarm; | 1794 | Alarm* alarm; |
1772 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); | 1795 | QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); |
1773 | for(alarm=list.first();alarm;alarm=list.next()) { | 1796 | for(alarm=list.first();alarm;alarm=list.next()) { |
1774 | alarm->toggleAlarm(); | 1797 | alarm->toggleAlarm(); |
1775 | } | 1798 | } |
1776 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); | 1799 | emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); |
1777 | mClickedItem->paintMe( true ); | 1800 | mClickedItem->paintMe( true ); |
1778 | mClickedItem->repaint( false ); | 1801 | mClickedItem->repaint( false ); |
1779 | } | 1802 | } |
1780 | 1803 | ||
1781 | /* | 1804 | /* |
1782 | Calculates the minimum width | 1805 | Calculates the minimum width |
1783 | */ | 1806 | */ |
1784 | int KOAgenda::minimumWidth() const | 1807 | int KOAgenda::minimumWidth() const |
1785 | { | 1808 | { |
1786 | // TODO:: develop a way to dynamically determine the minimum width | 1809 | // TODO:: develop a way to dynamically determine the minimum width |
1787 | int min = 100; | 1810 | int min = 100; |
1788 | 1811 | ||
1789 | return min; | 1812 | return min; |
1790 | } | 1813 | } |
1791 | 1814 | ||
1792 | void KOAgenda::updateConfig() | 1815 | void KOAgenda::updateConfig() |
1793 | { | 1816 | { |
1794 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) | 1817 | if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) |
1795 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); | 1818 | viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); |
1796 | if ( mAllDayMode ) { | 1819 | if ( mAllDayMode ) { |
1797 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; | 1820 | mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; |
1798 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 1821 | //mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
1799 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); | 1822 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); |
1800 | // setMaximumHeight( mGridSpacingY+1 ); | 1823 | // setMaximumHeight( mGridSpacingY+1 ); |
1801 | viewport()->repaint( false ); | 1824 | viewport()->repaint( false ); |
1802 | //setFixedHeight( mGridSpacingY+1 ); | 1825 | //setFixedHeight( mGridSpacingY+1 ); |
1803 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); | 1826 | //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); |
1804 | } | 1827 | } |
1805 | else { | 1828 | else { |
1806 | mGridSpacingY = KOPrefs::instance()->mHourSize; | 1829 | mGridSpacingY = KOPrefs::instance()->mHourSize; |
1807 | calculateWorkingHours(); | 1830 | calculateWorkingHours(); |
1808 | marcus_bains(); | 1831 | marcus_bains(); |
1809 | } | 1832 | } |
1810 | } | 1833 | } |
1811 | 1834 | ||
1812 | void KOAgenda::checkScrollBoundaries() | 1835 | void KOAgenda::checkScrollBoundaries() |
1813 | { | 1836 | { |
1814 | // Invalidate old values to force update | 1837 | // Invalidate old values to force update |
1815 | mOldLowerScrollValue = -1; | 1838 | mOldLowerScrollValue = -1; |
1816 | mOldUpperScrollValue = -1; | 1839 | mOldUpperScrollValue = -1; |
1817 | 1840 | ||
1818 | checkScrollBoundaries(verticalScrollBar()->value()); | 1841 | checkScrollBoundaries(verticalScrollBar()->value()); |
1819 | } | 1842 | } |
1820 | 1843 | ||
1821 | void KOAgenda::checkScrollBoundaries(int v) | 1844 | void KOAgenda::checkScrollBoundaries(int v) |
1822 | { | 1845 | { |
1823 | if ( mGridSpacingY == 0 ) | 1846 | if ( mGridSpacingY == 0 ) |
1824 | return; | 1847 | return; |
1825 | int yMin = v/mGridSpacingY; | 1848 | int yMin = v/mGridSpacingY; |
1826 | int yMax = (v+visibleHeight())/mGridSpacingY; | 1849 | int yMax = (v+visibleHeight())/mGridSpacingY; |
1827 | 1850 | ||
1828 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; | 1851 | // kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; |
1829 | 1852 | ||
1830 | if (yMin != mOldLowerScrollValue) { | 1853 | if (yMin != mOldLowerScrollValue) { |
1831 | mOldLowerScrollValue = yMin; | 1854 | mOldLowerScrollValue = yMin; |
1832 | emit lowerYChanged(yMin); | 1855 | emit lowerYChanged(yMin); |
1833 | } | 1856 | } |
1834 | if (yMax != mOldUpperScrollValue) { | 1857 | if (yMax != mOldUpperScrollValue) { |
1835 | mOldUpperScrollValue = yMax; | 1858 | mOldUpperScrollValue = yMax; |
1836 | emit upperYChanged(yMax); | 1859 | emit upperYChanged(yMax); |
1837 | } | 1860 | } |
1838 | } | 1861 | } |
1839 | 1862 | ||
1840 | void KOAgenda::deselectItem() | 1863 | void KOAgenda::deselectItem() |
1841 | { | 1864 | { |
1842 | if (mSelectedItem.isNull()) return; | 1865 | if (mSelectedItem.isNull()) return; |
1843 | mSelectedItem->select(false); | 1866 | mSelectedItem->select(false); |
1844 | mSelectedItem = 0; | 1867 | mSelectedItem = 0; |
1845 | } | 1868 | } |
1846 | 1869 | ||
1847 | void KOAgenda::selectItem(KOAgendaItem *item) | 1870 | void KOAgenda::selectItem(KOAgendaItem *item) |
1848 | { | 1871 | { |
1849 | if ((KOAgendaItem *)mSelectedItem == item) return; | 1872 | if ((KOAgendaItem *)mSelectedItem == item) return; |
1850 | deselectItem(); | 1873 | deselectItem(); |
1851 | if (item == 0) { | 1874 | if (item == 0) { |
1852 | emit incidenceSelected( 0 ); | 1875 | emit incidenceSelected( 0 ); |
1853 | return; | 1876 | return; |
1854 | } | 1877 | } |
1855 | mSelectedItem = item; | 1878 | mSelectedItem = item; |
1856 | mSelectedItem->select(); | 1879 | mSelectedItem->select(); |
1857 | emit incidenceSelected( mSelectedItem->incidence() ); | 1880 | emit incidenceSelected( mSelectedItem->incidence() ); |
1858 | } | 1881 | } |
1859 | 1882 | ||
1860 | // This function seems never be called. | 1883 | // This function seems never be called. |
1861 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) | 1884 | void KOAgenda::keyPressEvent( QKeyEvent *kev ) |
1862 | { | 1885 | { |
1863 | switch(kev->key()) { | 1886 | switch(kev->key()) { |
1864 | case Key_PageDown: | 1887 | case Key_PageDown: |
1865 | verticalScrollBar()->addPage(); | 1888 | verticalScrollBar()->addPage(); |
1866 | break; | 1889 | break; |
1867 | case Key_PageUp: | 1890 | case Key_PageUp: |
1868 | verticalScrollBar()->subtractPage(); | 1891 | verticalScrollBar()->subtractPage(); |
1869 | break; | 1892 | break; |
1870 | case Key_Down: | 1893 | case Key_Down: |
1871 | verticalScrollBar()->addLine(); | 1894 | verticalScrollBar()->addLine(); |
1872 | break; | 1895 | break; |
1873 | case Key_Up: | 1896 | case Key_Up: |
1874 | verticalScrollBar()->subtractLine(); | 1897 | verticalScrollBar()->subtractLine(); |
1875 | break; | 1898 | break; |
1876 | default: | 1899 | default: |
1877 | ; | 1900 | ; |
1878 | } | 1901 | } |
1879 | } | 1902 | } |
1880 | 1903 | ||
1881 | void KOAgenda::calculateWorkingHours() | 1904 | void KOAgenda::calculateWorkingHours() |
1882 | { | 1905 | { |
1883 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; | 1906 | // mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; |
1884 | mWorkingHoursEnable = !mAllDayMode; | 1907 | mWorkingHoursEnable = !mAllDayMode; |
1885 | 1908 | ||
1886 | mWorkingHoursYTop = mGridSpacingY * | 1909 | mWorkingHoursYTop = mGridSpacingY * |
1887 | KOPrefs::instance()->mWorkingHoursStart * 4; | 1910 | KOPrefs::instance()->mWorkingHoursStart * 4; |
1888 | mWorkingHoursYBottom = mGridSpacingY * | 1911 | mWorkingHoursYBottom = mGridSpacingY * |
1889 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; | 1912 | KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; |
1890 | } | 1913 | } |
1891 | 1914 | ||
1892 | 1915 | ||
1893 | DateList KOAgenda::dateList() const | 1916 | DateList KOAgenda::dateList() const |
1894 | { | 1917 | { |
1895 | return mSelectedDates; | 1918 | return mSelectedDates; |
1896 | } | 1919 | } |
1897 | 1920 | ||
1898 | void KOAgenda::setDateList(const DateList &selectedDates) | 1921 | void KOAgenda::setDateList(const DateList &selectedDates) |
1899 | { | 1922 | { |
1900 | mSelectedDates = selectedDates; | 1923 | mSelectedDates = selectedDates; |
1901 | marcus_bains(); | 1924 | marcus_bains(); |
1902 | } | 1925 | } |
1903 | 1926 | ||
1904 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) | 1927 | void KOAgenda::setHolidayMask(QMemArray<bool> *mask) |
1905 | { | 1928 | { |
1906 | mHolidayMask = mask; | 1929 | mHolidayMask = mask; |
1907 | 1930 | ||
1908 | /* | 1931 | /* |
1909 | kdDebug() << "HolidayMask: "; | 1932 | kdDebug() << "HolidayMask: "; |
1910 | for(uint i=0;i<mask->count();++i) { | 1933 | for(uint i=0;i<mask->count();++i) { |
1911 | kdDebug() << (mask->at(i) ? "*" : "o"); | 1934 | kdDebug() << (mask->at(i) ? "*" : "o"); |
1912 | } | 1935 | } |
1913 | kdDebug() << endl; | 1936 | kdDebug() << endl; |
1914 | */ | 1937 | */ |
1915 | } | 1938 | } |
1916 | 1939 | ||
1917 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) | 1940 | void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) |
1918 | { | 1941 | { |
1919 | 1942 | ||
1920 | QScrollView::contentsMousePressEvent(event); | 1943 | QScrollView::contentsMousePressEvent(event); |
1921 | } | 1944 | } |
1922 | 1945 | ||
1923 | void KOAgenda::storePosition() | 1946 | void KOAgenda::storePosition() |
1924 | { | 1947 | { |
1925 | //mContentPosition | 1948 | //mContentPosition |
1926 | int max = mGridSpacingY*4*24; | 1949 | int max = mGridSpacingY*4*24; |
1927 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) | 1950 | if ( contentsY() < 5 && max > viewport()->height()*3/2 ) |
1928 | mContentPosition = 0; | 1951 | mContentPosition = 0; |
1929 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) | 1952 | else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) |
1930 | mContentPosition = -1.0; | 1953 | mContentPosition = -1.0; |
1931 | else | 1954 | else |
1932 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); | 1955 | mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); |
1933 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); | 1956 | //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); |
1934 | 1957 | ||
1935 | } | 1958 | } |
1936 | void KOAgenda::restorePosition() | 1959 | void KOAgenda::restorePosition() |
1937 | { | 1960 | { |
1938 | int posY; | 1961 | int posY; |
1939 | int max = mGridSpacingY*4*24; | 1962 | int max = mGridSpacingY*4*24; |
1940 | if ( mContentPosition < 0 ) | 1963 | if ( mContentPosition < 0 ) |
1941 | posY = max-viewport()->height(); | 1964 | posY = max-viewport()->height(); |
1942 | else | 1965 | else |
1943 | if ( mContentPosition == 0 ) | 1966 | if ( mContentPosition == 0 ) |
1944 | posY = 0; | 1967 | posY = 0; |
1945 | else | 1968 | else |
1946 | posY = (max/mContentPosition)-(viewport()->height()/2); | 1969 | posY = (max/mContentPosition)-(viewport()->height()/2); |
1947 | setContentsPos (0, posY ); | 1970 | setContentsPos (0, posY ); |
1948 | //qDebug("posY %d hei %d", posY, max); | 1971 | //qDebug("posY %d hei %d", posY, max); |
1949 | 1972 | ||
1950 | } | 1973 | } |
1951 | void KOAgenda::moveChild( QWidget *w, int x , int y ) | 1974 | void KOAgenda::moveChild( QWidget *w, int x , int y ) |
1952 | { | 1975 | { |
1953 | ++x; | 1976 | ++x; |
1954 | QScrollView::moveChild( w, x , y ); | 1977 | QScrollView::moveChild( w, x , y ); |
1955 | } | 1978 | } |
1956 | #include <qmessagebox.h> | 1979 | #include <qmessagebox.h> |
1957 | #ifdef DESKTOP_VERSION | 1980 | #ifdef DESKTOP_VERSION |
1958 | #include <qprinter.h> | 1981 | #include <qprinter.h> |
1959 | #include <qpainter.h> | 1982 | #include <qpainter.h> |
1960 | #include <qpaintdevicemetrics.h> | 1983 | #include <qpaintdevicemetrics.h> |
1961 | 1984 | ||
1962 | #endif | 1985 | #endif |
1963 | void KOAgenda::printSelection() | 1986 | void KOAgenda::printSelection() |
1964 | { | 1987 | { |
1965 | #ifdef DESKTOP_VERSION | 1988 | #ifdef DESKTOP_VERSION |
1966 | if ( mStartCellY == mCurrentCellY ) { | 1989 | if ( mStartCellY == mCurrentCellY ) { |
1967 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 1990 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
1968 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), | 1991 | i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), |
1969 | i18n("OK"), 0, 0, | 1992 | i18n("OK"), 0, 0, |
1970 | 0, 1 ); | 1993 | 0, 1 ); |
1971 | return; | 1994 | return; |
1972 | } | 1995 | } |
1973 | 1996 | ||
1974 | float dx, dy; | 1997 | float dx, dy; |
1975 | int x,y,w,h; | 1998 | int x,y,w,h; |
1976 | x= 0; | 1999 | x= 0; |
1977 | w= contentsWidth()+2; | 2000 | w= contentsWidth()+2; |
1978 | // h= contentsHeight(); | 2001 | // h= contentsHeight(); |
1979 | y = mGridSpacingY*mStartCellY; | 2002 | y = mGridSpacingY*mStartCellY; |
1980 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; | 2003 | h = mGridSpacingY*(mCurrentCellY+1)-y+2; |
1981 | 2004 | ||
1982 | //return; | 2005 | //return; |
1983 | QPrinter* printer = new QPrinter(); | 2006 | QPrinter* printer = new QPrinter(); |
1984 | if ( !printer->setup()) { | 2007 | if ( !printer->setup()) { |
1985 | delete printer; | 2008 | delete printer; |
1986 | return; | 2009 | return; |
1987 | } | 2010 | } |
1988 | QPainter p( printer ); | 2011 | QPainter p( printer ); |
1989 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); | 2012 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); |
1990 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); | 2013 | QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); |
1991 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); | 2014 | date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); |
1992 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); | 2015 | int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); |
1993 | // p.drawText( 0, 0, date ); | 2016 | // p.drawText( 0, 0, date ); |
1994 | int offset = m.width()/8; | 2017 | int offset = m.width()/8; |
1995 | // compute the scale | 2018 | // compute the scale |
1996 | dx = ((float) m.width()-offset) / (float)w; | 2019 | dx = ((float) m.width()-offset) / (float)w; |
1997 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; | 2020 | dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; |
1998 | float scale; | 2021 | float scale; |
1999 | // scale to fit the width or height of the paper | 2022 | // scale to fit the width or height of the paper |
2000 | if ( dx < dy ) | 2023 | if ( dx < dy ) |
2001 | scale = dx; | 2024 | scale = dx; |
2002 | else | 2025 | else |
2003 | scale = dy; | 2026 | scale = dy; |
2004 | // set the scale | 2027 | // set the scale |
2005 | p.drawText( offset* scale, offset* scale*3/4, date ); | 2028 | p.drawText( offset* scale, offset* scale*3/4, date ); |
2006 | 2029 | ||
2007 | int selDay; | 2030 | int selDay; |
2008 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); | 2031 | float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); |
2009 | float startX = 1; | 2032 | float startX = 1; |
2010 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) | 2033 | for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) |
2011 | { | 2034 | { |
2012 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); | 2035 | QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); |
2013 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); | 2036 | p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); |
2014 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); | 2037 | p.drawText( offset* scale+startX, (offset+hei)* scale, text ); |
2015 | startX += widOffset; | 2038 | startX += widOffset; |
2016 | 2039 | ||
2017 | } | 2040 | } |
2018 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); | 2041 | p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); |
2019 | p.scale( scale, scale ); | 2042 | p.scale( scale, scale ); |
2020 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); | 2043 | p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); |
2021 | // now printing with y offset: 2 hei | 2044 | // now printing with y offset: 2 hei |
2022 | // p.translate( 0, -y*scale); | 2045 | // p.translate( 0, -y*scale); |
2023 | 2046 | ||
2024 | drawContentsToPainter(&p, true ); | 2047 | drawContentsToPainter(&p, true ); |
2025 | globalFlagBlockAgendaItemUpdate = false; | 2048 | globalFlagBlockAgendaItemUpdate = false; |
2026 | KOAgendaItem *item; | 2049 | KOAgendaItem *item; |
2027 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 2050 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
2028 | item->select(false); | 2051 | item->select(false); |
2029 | item->paintMe( false, &p ); | 2052 | item->paintMe( false, &p ); |
2030 | } | 2053 | } |
2031 | globalFlagBlockAgendaItemUpdate = true; | 2054 | globalFlagBlockAgendaItemUpdate = true; |
2032 | p.end(); | 2055 | p.end(); |
2033 | delete printer; | 2056 | delete printer; |
2034 | #else | 2057 | #else |
2035 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), | 2058 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), |
2036 | i18n("Not supported \non PDA!\n"), | 2059 | i18n("Not supported \non PDA!\n"), |
2037 | i18n("OK"), 0, 0, | 2060 | i18n("OK"), 0, 0, |
2038 | 0, 1 ); | 2061 | 0, 1 ); |
2039 | #endif | 2062 | #endif |
2040 | } | 2063 | } |
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 38bd93a..042a789 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -1,766 +1,784 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qlabel.h> | 20 | #include <qlabel.h> |
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qvbox.h> | 23 | #include <qvbox.h> |
24 | #include <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qwhatsthis.h> | 25 | #include <qwhatsthis.h> |
26 | #include <qdragobject.h> | 26 | #include <qdragobject.h> |
27 | #include <qdrawutil.h> | 27 | #include <qdrawutil.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | #include <kiconloader.h> | 30 | #include <kiconloader.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | 32 | #include <kglobal.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #ifndef DESKTOP_VERSION | 34 | #ifndef DESKTOP_VERSION |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #define AGENDA_ICON_SIZE 5 | 36 | #define AGENDA_ICON_SIZE 5 |
37 | #else | 37 | #else |
38 | #define AGENDA_ICON_SIZE 7 | 38 | #define AGENDA_ICON_SIZE 7 |
39 | #endif | 39 | #endif |
40 | #include <libkcal/icaldrag.h> | 40 | #include <libkcal/icaldrag.h> |
41 | #include <libkcal/vcaldrag.h> | 41 | #include <libkcal/vcaldrag.h> |
42 | #include <libkcal/kincidenceformatter.h> | 42 | #include <libkcal/kincidenceformatter.h> |
43 | extern int globalFlagBlockAgenda; | 43 | extern int globalFlagBlockAgenda; |
44 | extern int globalFlagBlockAgendaItemPaint; | 44 | extern int globalFlagBlockAgendaItemPaint; |
45 | extern int globalFlagBlockAgendaItemUpdate; | 45 | extern int globalFlagBlockAgendaItemUpdate; |
46 | 46 | ||
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | 48 | ||
49 | #include "koagendaitem.h" | 49 | #include "koagendaitem.h" |
50 | //#include "koagendaitem.moc" | 50 | //#include "koagendaitem.moc" |
51 | 51 | ||
52 | 52 | ||
53 | //-------------------------------------------------------------------------- | 53 | //-------------------------------------------------------------------------- |
54 | 54 | ||
55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; | 55 | QToolTipGroup *KOAgendaItem::mToolTipGroup = 0; |
56 | 56 | ||
57 | //-------------------------------------------------------------------------- | 57 | //-------------------------------------------------------------------------- |
58 | 58 | ||
59 | class KOAgendaItemWhatsThis :public QWhatsThis | 59 | class KOAgendaItemWhatsThis :public QWhatsThis |
60 | { | 60 | { |
61 | public: | 61 | public: |
62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; | 62 | KOAgendaItemWhatsThis( KOAgendaItem* view ) : QWhatsThis( view ),_view (view) { }; |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | virtual QString text( const QPoint& ) | 65 | virtual QString text( const QPoint& ) |
66 | { | 66 | { |
67 | return _view->getWhatsThisText() ; | 67 | return _view->getWhatsThisText() ; |
68 | } | 68 | } |
69 | private: | 69 | private: |
70 | KOAgendaItem * _view; | 70 | KOAgendaItem * _view; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, | 73 | KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool allday, |
74 | const char *name,WFlags) : | 74 | const char *name,WFlags) : |
75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) | 75 | QWidget(parent, name), mIncidence(incidence), mDate(qd) |
76 | { | 76 | { |
77 | #ifndef DESKTOP_VERSION | 77 | #ifndef DESKTOP_VERSION |
78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); | 78 | QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); |
79 | #endif | 79 | #endif |
80 | new KOAgendaItemWhatsThis(this); | 80 | new KOAgendaItemWhatsThis(this); |
81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase | 81 | int wflags = getWFlags() |WRepaintNoErase;// WResizeNoErase |
82 | setWFlags ( wflags); | 82 | setWFlags ( wflags); |
83 | mAllDay = allday; | 83 | mAllDay = allday; |
84 | init ( incidence, qd ); | 84 | init ( incidence, qd ); |
85 | setMouseTracking(true); | 85 | setMouseTracking(true); |
86 | //setAcceptDrops(true); | 86 | //setAcceptDrops(true); |
87 | xPaintCoord = -1; | 87 | xPaintCoord = -1; |
88 | yPaintCoord = -1; | 88 | yPaintCoord = -1; |
89 | } | 89 | } |
90 | QString KOAgendaItem::getWhatsThisText() | 90 | QString KOAgendaItem::getWhatsThisText() |
91 | { | 91 | { |
92 | if ( mIncidence ) | 92 | if ( mIncidence ) |
93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, | 93 | return KIncidenceFormatter::instance()->getFormattedText( mIncidence, |
94 | KOPrefs::instance()->mWTshowDetails, | 94 | KOPrefs::instance()->mWTshowDetails, |
95 | KOPrefs::instance()->mWTshowCreated, | 95 | KOPrefs::instance()->mWTshowCreated, |
96 | KOPrefs::instance()->mWTshowChanged); | 96 | KOPrefs::instance()->mWTshowChanged); |
97 | return "KOAgendaItem::getWhatsThisText()::internal error"; | 97 | return "KOAgendaItem::getWhatsThisText()::internal error"; |
98 | } | 98 | } |
99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) | 99 | void KOAgendaItem::init ( Incidence *incidence, QDate qd ) |
100 | { | 100 | { |
101 | mIncidence = incidence; | 101 | mIncidence = incidence; |
102 | mDate = qd; | 102 | mDate = qd; |
103 | mFirstMultiItem = 0; | 103 | mFirstMultiItem = 0; |
104 | mNextMultiItem = 0; | 104 | mNextMultiItem = 0; |
105 | mLastMultiItem = 0; | 105 | mLastMultiItem = 0; |
106 | computeText(); | 106 | computeText(); |
107 | 107 | ||
108 | if ( (incidence->type() == "Todo") && | 108 | if ( (incidence->type() == "Todo") && |
109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && | 109 | ( !((static_cast<Todo*>(incidence))->isCompleted()) && |
110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { | 110 | ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { |
111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) | 111 | if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) |
112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; | 112 | mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; |
113 | else | 113 | else |
114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; | 114 | mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; |
115 | } | 115 | } |
116 | else { | 116 | else { |
117 | QStringList categories = mIncidence->categories(); | 117 | QStringList categories = mIncidence->categories(); |
118 | QString cat = categories.first(); | 118 | QString cat = categories.first(); |
119 | if (cat.isEmpty()) { | 119 | if (cat.isEmpty()) { |
120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) | 120 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) |
121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 121 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
122 | else | 122 | else |
123 | mBackgroundColor =KOPrefs::instance()->mEventColor; | 123 | mBackgroundColor =KOPrefs::instance()->mEventColor; |
124 | } else { | 124 | } else { |
125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); | 125 | mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); |
126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { | 126 | if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { |
127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) | 127 | if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) |
128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; | 128 | mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; |
129 | } | 129 | } |
130 | } | 130 | } |
131 | 131 | ||
132 | } | 132 | } |
133 | mColorGroup = QColorGroup( mBackgroundColor.light(), | 133 | mColorGroup = QColorGroup( mBackgroundColor.light(), |
134 | mBackgroundColor.dark(),mBackgroundColor.light(), | 134 | mBackgroundColor.dark(),mBackgroundColor.light(), |
135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; | 135 | mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; |
136 | setBackgroundColor( mBackgroundColor ); | 136 | setBackgroundColor( mBackgroundColor ); |
137 | 137 | ||
138 | mConflictItems.clear(); | 138 | mConflictItems.clear(); |
139 | setCellXY(0,0,1); | 139 | setCellXY(0,0,1); |
140 | setCellXWidth(0); | 140 | setCellXWidth(0); |
141 | setSubCell(0); | 141 | setSubCell(0); |
142 | setSubCells(1); | 142 | setSubCells(1); |
143 | setMultiItem(0,0,0); | 143 | setMultiItem(0,0,0); |
144 | startMove(); | 144 | startMove(); |
145 | mSelected = true; | 145 | mSelected = true; |
146 | select(false); | 146 | select(false); |
147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); | 147 | QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); |
148 | mFontPixelSize = fontinf.height();; | 148 | mFontPixelSize = fontinf.height();; |
149 | hide(); | 149 | hide(); |
150 | xPaintCoord = -1; | 150 | xPaintCoord = -1; |
151 | yPaintCoord = -1; | 151 | yPaintCoord = -1; |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | KOAgendaItem::~KOAgendaItem() | 155 | KOAgendaItem::~KOAgendaItem() |
156 | { | 156 | { |
157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); | 157 | // qDebug("deleteKOAgendaItem::~KOAgendaItem( "); |
158 | 158 | ||
159 | } | 159 | } |
160 | 160 | ||
161 | void KOAgendaItem::recreateIncidence() | 161 | void KOAgendaItem::recreateIncidence() |
162 | { | 162 | { |
163 | #if 0 | 163 | #if 0 |
164 | Incidence* newInc = mIncidence->clone(); | 164 | Incidence* newInc = mIncidence->clone(); |
165 | newInc->recreate(); | 165 | newInc->recreate(); |
166 | if ( mIncidence->doesRecur() ) { | 166 | if ( mIncidence->doesRecur() ) { |
167 | mIncidence->addExDate( mDate ); | 167 | mIncidence->addExDate( mDate ); |
168 | newInc->recurrence()->unsetRecurs(); | 168 | newInc->recurrence()->unsetRecurs(); |
169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); | 169 | int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); |
170 | QTime tim = mIncidence->dtStart().time(); | 170 | QTime tim = mIncidence->dtStart().time(); |
171 | newInc->setDtStart( QDateTime(mDate, tim) ); | 171 | newInc->setDtStart( QDateTime(mDate, tim) ); |
172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 172 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
173 | } | 173 | } |
174 | #endif | 174 | #endif |
175 | mIncidence = mIncidence->recreateCloneException( mDate ); | 175 | mIncidence = mIncidence->recreateCloneException( mDate ); |
176 | } | 176 | } |
177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | 177 | bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) |
178 | { | 178 | { |
179 | int size = AGENDA_ICON_SIZE; | 179 | int size = AGENDA_ICON_SIZE; |
180 | 180 | ||
181 | int yOff = 0; | 181 | int yOff = 0; |
182 | int xOff = 0; | 182 | int xOff = 0; |
183 | int x = pos().x() +3; | 183 | int x = pos().x() +3; |
184 | int y; | 184 | int y; |
185 | if ( mAllDay ) | 185 | if ( mAllDay ) |
186 | y = pos().y()+3; | 186 | y = pos().y()+3; |
187 | else | 187 | else |
188 | y = mCellYTop * ( height() / cellHeight() ) +3; | 188 | y = mCellYTop * ( height() / cellHeight() ) +3; |
189 | if (mIncidence->cancelled()) { | 189 | if (mIncidence->cancelled()) { |
190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; | 190 | int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; |
191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; | 191 | int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; |
192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); | 192 | p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); |
193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); | 193 | p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); |
194 | if ( horLayout ) | 194 | if ( horLayout ) |
195 | ++xOff; | 195 | ++xOff; |
196 | else | 196 | else |
197 | ++yOff; | 197 | ++yOff; |
198 | } | 198 | } |
199 | if (mIncidence->isAlarmEnabled()) { | 199 | if (mIncidence->isAlarmEnabled()) { |
200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); | 200 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); |
201 | if ( horLayout ) | 201 | if ( horLayout ) |
202 | ++xOff; | 202 | ++xOff; |
203 | else | 203 | else |
204 | ++yOff; | 204 | ++yOff; |
205 | } | 205 | } |
206 | if (mIncidence->recurrence()->doesRecur()) { | 206 | if (mIncidence->recurrence()->doesRecur()) { |
207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); | 207 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); |
208 | if ( horLayout ) | 208 | if ( horLayout ) |
209 | ++xOff; | 209 | ++xOff; |
210 | else | 210 | else |
211 | ++yOff; | 211 | ++yOff; |
212 | } | 212 | } |
213 | if (mIncidence->description().length() > 0) { | 213 | if (mIncidence->description().length() > 0) { |
214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); | 214 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); |
215 | if ( horLayout ) | 215 | if ( horLayout ) |
216 | ++xOff; | 216 | ++xOff; |
217 | else | 217 | else |
218 | ++yOff; | 218 | ++yOff; |
219 | } | 219 | } |
220 | if (mIncidence->isReadOnly()) { | 220 | if (mIncidence->isReadOnly()) { |
221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); | 221 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); |
222 | if ( horLayout ) | 222 | if ( horLayout ) |
223 | ++xOff; | 223 | ++xOff; |
224 | else | 224 | else |
225 | ++yOff; | 225 | ++yOff; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (mIncidence->attendeeCount()>0) { | 228 | if (mIncidence->attendeeCount()>0) { |
229 | 229 | ||
230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { | 230 | if (mIncidence->organizer() == KOPrefs::instance()->email()) { |
231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); | 231 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); |
232 | if ( horLayout ) | 232 | if ( horLayout ) |
233 | ++xOff; | 233 | ++xOff; |
234 | else | 234 | else |
235 | ++yOff; | 235 | ++yOff; |
236 | } else { | 236 | } else { |
237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 237 | Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
238 | if (me!=0) { | 238 | if (me!=0) { |
239 | 239 | ||
240 | 240 | ||
241 | } else { | 241 | } else { |
242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); | 242 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); |
243 | if ( horLayout ) | 243 | if ( horLayout ) |
244 | ++xOff; | 244 | ++xOff; |
245 | else | 245 | else |
246 | ++yOff; | 246 | ++yOff; |
247 | 247 | ||
248 | } | 248 | } |
249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 249 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
250 | if ( horLayout ) | 250 | if ( horLayout ) |
251 | ++xOff; | 251 | ++xOff; |
252 | else | 252 | else |
253 | ++yOff; | 253 | ++yOff; |
254 | 254 | ||
255 | } | 255 | } |
256 | 256 | ||
257 | } | 257 | } |
258 | return ( yOff || xOff ); | 258 | return ( yOff || xOff ); |
259 | } | 259 | } |
260 | 260 | ||
261 | 261 | ||
262 | void KOAgendaItem::select(bool selected) | 262 | void KOAgendaItem::select(bool selected) |
263 | { | 263 | { |
264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 264 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
265 | if (mSelected == selected) return; | 265 | if (mSelected == selected) return; |
266 | mSelected = selected; | 266 | mSelected = selected; |
267 | if ( ! isVisible() ) | 267 | if ( ! isVisible() ) |
268 | return; | 268 | return; |
269 | if ( firstMultiItem() ) | 269 | if ( firstMultiItem() ) |
270 | firstMultiItem()->select( selected ); | 270 | firstMultiItem()->select( selected ); |
271 | if ( !firstMultiItem() && nextMultiItem() ) { | 271 | if ( !firstMultiItem() && nextMultiItem() ) { |
272 | KOAgendaItem * placeItem = nextMultiItem(); | 272 | KOAgendaItem * placeItem = nextMultiItem(); |
273 | while ( placeItem ) { | 273 | while ( placeItem ) { |
274 | placeItem->select( selected ); | 274 | placeItem->select( selected ); |
275 | placeItem = placeItem->nextMultiItem(); | 275 | placeItem = placeItem->nextMultiItem(); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | globalFlagBlockAgendaItemUpdate = 0; | 278 | globalFlagBlockAgendaItemUpdate = 0; |
279 | paintMe( selected ); | 279 | paintMe( selected ); |
280 | globalFlagBlockAgendaItemUpdate = 1; | 280 | globalFlagBlockAgendaItemUpdate = 1; |
281 | repaint( false ); | 281 | repaint( false ); |
282 | } | 282 | } |
283 | 283 | ||
284 | 284 | ||
285 | /* | 285 | /* |
286 | The eventFilter has to filter the mouse events of the agenda item childs. The | 286 | The eventFilter has to filter the mouse events of the agenda item childs. The |
287 | events are fed into the event handling method of KOAgendaItem. This allows the | 287 | events are fed into the event handling method of KOAgendaItem. This allows the |
288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 288 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
289 | */ | 289 | */ |
290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 290 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
291 | { | 291 | { |
292 | if (e->type() == QEvent::MouseButtonPress || | 292 | if (e->type() == QEvent::MouseButtonPress || |
293 | e->type() == QEvent::MouseButtonDblClick || | 293 | e->type() == QEvent::MouseButtonDblClick || |
294 | e->type() == QEvent::MouseButtonRelease || | 294 | e->type() == QEvent::MouseButtonRelease || |
295 | e->type() == QEvent::MouseMove) { | 295 | e->type() == QEvent::MouseMove) { |
296 | QMouseEvent *me = (QMouseEvent *)e; | 296 | QMouseEvent *me = (QMouseEvent *)e; |
297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 297 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
298 | mapToGlobal(me->pos())); | 298 | mapToGlobal(me->pos())); |
299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 299 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
300 | return event(&returnEvent); | 300 | return event(&returnEvent); |
301 | } else { | 301 | } else { |
302 | return false; | 302 | return false; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | void KOAgendaItem::repaintMe( ) | 305 | void KOAgendaItem::repaintMe( ) |
306 | { | 306 | { |
307 | paintMe ( mSelected ); | 307 | paintMe ( mSelected ); |
308 | } | 308 | } |
309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 309 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
310 | { | 310 | { |
311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 311 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
312 | return; | 312 | return; |
313 | QPainter pa; | 313 | QPainter pa; |
314 | 314 | ||
315 | if ( mSelected ) { | 315 | if ( mSelected ) { |
316 | pa.begin( paintPixSel() ); | 316 | pa.begin( paintPixSel() ); |
317 | } else { | 317 | } else { |
318 | if ( mAllDay ) | 318 | if ( mAllDay ) |
319 | pa.begin( paintPixAllday() ); | 319 | pa.begin( paintPixAllday() ); |
320 | else | 320 | else |
321 | pa.begin( paintPix() ); | 321 | pa.begin( paintPix() ); |
322 | } | 322 | } |
323 | int x, yy, w, h; | 323 | int x, yy, w, h; |
324 | float nfh = 7.0; | 324 | float nfh = 7.0; |
325 | x = pos().x(); w = width(); h = height (); | 325 | x = pos().x(); w = width(); h = height (); |
326 | if ( mAllDay ) | 326 | if ( mAllDay ) |
327 | yy = y(); | 327 | yy = y(); |
328 | else | 328 | else |
329 | yy = mCellYTop * ( height() / cellHeight() ); | 329 | yy = mCellYTop * ( height() / cellHeight() ); |
330 | xPaintCoord= x; | 330 | xPaintCoord= x; |
331 | yPaintCoord = yy; | 331 | yPaintCoord = yy; |
332 | wPaintCoord = width(); | 332 | wPaintCoord = width(); |
333 | hPaintCoord = height(); | 333 | hPaintCoord = height(); |
334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 334 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
335 | if ( paint == 0 ) | 335 | if ( paint == 0 ) |
336 | paint = &pa; | 336 | paint = &pa; |
337 | bool horLayout = ( w < h ); | 337 | bool horLayout = ( w < h ); |
338 | int maxhei = mFontPixelSize+4; | 338 | int maxhei = mFontPixelSize+4; |
339 | if ( horLayout ) | 339 | if ( horLayout ) |
340 | maxhei += AGENDA_ICON_SIZE -4; | 340 | maxhei += AGENDA_ICON_SIZE -4; |
341 | bool small = ( h < maxhei ); | 341 | bool small = ( h < maxhei ); |
342 | if ( ! small ) | 342 | if ( ! small ) |
343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 343 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
344 | else { | 344 | else { |
345 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 345 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
346 | f.setBold( false ); | 346 | f.setBold( false ); |
347 | int fh = f.pointSize(); | 347 | int fh = f.pointSize(); |
348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 348 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
349 | if ( nfh < 6 ) | 349 | if ( nfh < 6 ) |
350 | nfh = 6; | 350 | nfh = 6; |
351 | f.setPointSize( nfh ); | 351 | f.setPointSize( nfh ); |
352 | paint->setFont(f); | 352 | paint->setFont(f); |
353 | } | 353 | } |
354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 354 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 355 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 356 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
357 | if ( mIncidence->type() == "Todo" ) { | 357 | if ( mIncidence->type() == "Todo" ) { |
358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 358 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 359 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
360 | int yyy = yy+3; | 360 | int yyy = yy+3; |
361 | if ( tempTodo->isCompleted() ) | 361 | if ( tempTodo->isCompleted() ) |
362 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 362 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
363 | else { | 363 | else { |
364 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 364 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
365 | 365 | ||
366 | } | 366 | } |
367 | } | 367 | } |
368 | bool addIcon = false; | 368 | bool addIcon = false; |
369 | if ( ! small || w > 3 * h || h > 3* w ) | 369 | if ( ! small || w > 3 * h || h > 3* w ) |
370 | addIcon = updateIcons( paint, horLayout ); | 370 | addIcon = updateIcons( paint, horLayout ); |
371 | 371 | ||
372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 372 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 373 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
374 | if ( ! small ) { | 374 | if ( ! small ) { |
375 | x += 3; yy += 3;w -= 6; h-= 5; | 375 | x += 3; yy += 3;w -= 6; h-= 5; |
376 | } else { | 376 | } else { |
377 | x += 2; yy += 1;w -= 4; h-= 4; | 377 | x += 2; yy += 1;w -= 4; h-= 4; |
378 | if ( nfh < 6.01 ) { | 378 | if ( nfh < 6.01 ) { |
379 | yy -= 2; | 379 | yy -= 2; |
380 | h += 4; | 380 | h += 4; |
381 | } | 381 | } |
382 | else | 382 | else |
383 | if ( nfh < h -2 ) | 383 | if ( nfh < h -2 ) |
384 | ++yy; | 384 | ++yy; |
385 | } | 385 | } |
386 | int align; | 386 | int align; |
387 | #ifndef DESKTOP_VERSION | 387 | #ifndef DESKTOP_VERSION |
388 | align = ( AlignLeft|WordBreak|AlignTop); | 388 | align = ( AlignLeft|WordBreak|AlignTop); |
389 | #else | 389 | #else |
390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 390 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
391 | #endif | 391 | #endif |
392 | if ( addIcon ) { | 392 | if ( addIcon ) { |
393 | if ( ! horLayout ) { | 393 | if ( ! horLayout ) { |
394 | x += AGENDA_ICON_SIZE+3; | 394 | x += AGENDA_ICON_SIZE+3; |
395 | w -= (AGENDA_ICON_SIZE+3); | 395 | w -= (AGENDA_ICON_SIZE+3); |
396 | } | 396 | } |
397 | else { | 397 | else { |
398 | yy+= AGENDA_ICON_SIZE+2; | 398 | yy+= AGENDA_ICON_SIZE+2; |
399 | h -=(AGENDA_ICON_SIZE+3); | 399 | h -=(AGENDA_ICON_SIZE+3); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
403 | if ( colsum < 250 ) | 403 | if ( colsum < 250 ) |
404 | paint->setPen ( white); | 404 | paint->setPen ( white); |
405 | if ( x < 0 ) { | 405 | if ( x < 0 ) { |
406 | w = w+x-3; | 406 | w = w+x-3; |
407 | x = 3; | 407 | x = 3; |
408 | if ( w > parentWidget()->width() ){ | 408 | if ( w > parentWidget()->width() ){ |
409 | w = parentWidget()->width() - 6; | 409 | w = parentWidget()->width() - 6; |
410 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
411 | align = ( AlignHCenter|WordBreak|AlignTop); | 411 | align = ( AlignHCenter|WordBreak|AlignTop); |
412 | #else | 412 | #else |
413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | } | 416 | } |
417 | } | 417 | } |
418 | QRect dr; | 418 | QRect dr; |
419 | if ( w + x > parentWidget()->width() ) | 419 | if ( w + x > parentWidget()->width() ) |
420 | w = parentWidget()->width()-x; | 420 | w = parentWidget()->width()-x; |
421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
422 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 422 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
423 | if ( mIncidence->cancelled() ){ | 423 | if ( mIncidence->cancelled() ){ |
424 | if ( ! small ) { | 424 | if ( ! small ) { |
425 | QFontMetrics fm ( paint->font() ); | 425 | QFontMetrics fm ( paint->font() ); |
426 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 426 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
427 | } | 427 | } |
428 | 428 | ||
429 | } | 429 | } |
430 | pa.end(); | 430 | pa.end(); |
431 | 431 | ||
432 | } | 432 | } |
433 | void KOAgendaItem::resizePixmap( int w , int h ) | 433 | void KOAgendaItem::resizePixmap( int w , int h ) |
434 | { | 434 | { |
435 | paintPix()->resize( w, h ); | 435 | paintPix()->resize( w, h ); |
436 | paintPixSel()->resize( w, h ); | 436 | paintPixSel()->resize( w, h ); |
437 | 437 | ||
438 | } | 438 | } |
439 | QPixmap * KOAgendaItem::paintPix() | 439 | QPixmap * KOAgendaItem::paintPix() |
440 | { | 440 | { |
441 | static QPixmap* mPaintPix = 0; | 441 | static QPixmap* mPaintPix = 0; |
442 | if ( ! mPaintPix ) | 442 | if ( ! mPaintPix ) |
443 | mPaintPix = new QPixmap(1,1); | 443 | mPaintPix = new QPixmap(1,1); |
444 | return mPaintPix ; | 444 | return mPaintPix ; |
445 | } | 445 | } |
446 | QPixmap * KOAgendaItem::paintPixAllday() | 446 | QPixmap * KOAgendaItem::paintPixAllday() |
447 | { | 447 | { |
448 | static QPixmap* mPaintPixA = 0; | 448 | static QPixmap* mPaintPixA = 0; |
449 | if ( ! mPaintPixA ) | 449 | if ( ! mPaintPixA ) |
450 | mPaintPixA = new QPixmap(1,1); | 450 | mPaintPixA = new QPixmap(1,1); |
451 | return mPaintPixA ; | 451 | return mPaintPixA ; |
452 | } | 452 | } |
453 | QPixmap * KOAgendaItem::paintPixSel() | 453 | QPixmap * KOAgendaItem::paintPixSel() |
454 | { | 454 | { |
455 | static QPixmap* mPaintPixSel = 0; | 455 | static QPixmap* mPaintPixSel = 0; |
456 | if ( ! mPaintPixSel ) | 456 | if ( ! mPaintPixSel ) |
457 | mPaintPixSel = new QPixmap(1,1); | 457 | mPaintPixSel = new QPixmap(1,1); |
458 | return mPaintPixSel ; | 458 | return mPaintPixSel ; |
459 | } | 459 | } |
460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 460 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
461 | { | 461 | { |
462 | 462 | ||
463 | if ( globalFlagBlockAgendaItemPaint ) | 463 | if ( globalFlagBlockAgendaItemPaint ) |
464 | return; | 464 | return; |
465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 465 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
466 | return; | 466 | return; |
467 | int yy; | 467 | int yy; |
468 | if ( mAllDay ) | 468 | if ( mAllDay ) |
469 | yy = y(); | 469 | yy = y(); |
470 | else | 470 | else |
471 | yy = mCellYTop * ( height() / cellHeight() ); | 471 | yy = mCellYTop * ( height() / cellHeight() ); |
472 | int xx = x(); | 472 | int xx = x(); |
473 | if ( xPaintCoord != xx || yPaintCoord != yy || | 473 | if ( xPaintCoord != xx || yPaintCoord != yy || |
474 | wPaintCoord != width() || hPaintCoord != height()) { | 474 | wPaintCoord != width() || hPaintCoord != height()) { |
475 | xPaintCoord= xx; | 475 | xPaintCoord= xx; |
476 | yPaintCoord = yy; | 476 | yPaintCoord = yy; |
477 | wPaintCoord = width(); | 477 | wPaintCoord = width(); |
478 | hPaintCoord = height(); | 478 | hPaintCoord = height(); |
479 | globalFlagBlockAgendaItemUpdate = 0; | 479 | globalFlagBlockAgendaItemUpdate = 0; |
480 | paintMe( mSelected ); | 480 | paintMe( mSelected ); |
481 | //qDebug("calling paintMe "); | 481 | //qDebug("calling paintMe "); |
482 | globalFlagBlockAgendaItemUpdate = 1; | 482 | globalFlagBlockAgendaItemUpdate = 1; |
483 | } | 483 | } |
484 | int rx, ry, rw, rh; | 484 | int rx, ry, rw, rh; |
485 | rx = e->rect().x(); | 485 | rx = e->rect().x(); |
486 | ry = e->rect().y(); | 486 | ry = e->rect().y(); |
487 | rw = e->rect().width(); | 487 | rw = e->rect().width(); |
488 | rh = e->rect().height(); | 488 | rh = e->rect().height(); |
489 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 489 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
490 | 490 | ||
491 | QPixmap* paintFrom ; | 491 | QPixmap* paintFrom ; |
492 | if ( mSelected ) { | 492 | if ( mSelected ) { |
493 | paintFrom = paintPixSel(); | 493 | paintFrom = paintPixSel(); |
494 | } else { | 494 | } else { |
495 | if ( mAllDay ) | 495 | if ( mAllDay ) |
496 | paintFrom = paintPixAllday(); | 496 | paintFrom = paintPixAllday(); |
497 | else | 497 | else |
498 | paintFrom = paintPix(); | 498 | paintFrom = paintPix(); |
499 | } | 499 | } |
500 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 500 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
501 | } | 501 | } |
502 | void KOAgendaItem::computeText() | 502 | void KOAgendaItem::computeText() |
503 | { | 503 | { |
504 | 504 | ||
505 | mDisplayedText = mIncidence->summary(); | 505 | mDisplayedText = mIncidence->summary(); |
506 | if ( (mIncidence->type() == "Todo") ) { | 506 | if ( (mIncidence->type() == "Todo") ) { |
507 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 507 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
508 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 508 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
509 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 509 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
510 | else if ( !(mIncidence->doesFloat())) | 510 | else if ( !(mIncidence->doesFloat())) |
511 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 511 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
512 | } | 512 | } |
513 | } else { | 513 | } else { |
514 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 514 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
515 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 515 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
516 | 516 | ||
517 | if ( mAllDay ) { | 517 | if ( mAllDay ) { |
518 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 518 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
519 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 519 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
520 | } | 520 | } |
521 | } | 521 | } |
522 | 522 | ||
523 | } | 523 | } |
524 | 524 | ||
525 | if ( !mIncidence->location().isEmpty() ) { | 525 | if ( !mIncidence->location().isEmpty() ) { |
526 | if ( mAllDay ) | 526 | if ( mAllDay ) |
527 | mDisplayedText += " ("; | 527 | mDisplayedText += " ("; |
528 | else | 528 | else |
529 | mDisplayedText += "\n("; | 529 | mDisplayedText += "\n("; |
530 | mDisplayedText += mIncidence->location() +")"; | 530 | mDisplayedText += mIncidence->location() +")"; |
531 | } | 531 | } |
532 | 532 | ||
533 | QString tipText = mIncidence->summary(); | 533 | QString tipText = mIncidence->summary(); |
534 | if ( !mIncidence->doesFloat() ) { | 534 | if ( !mIncidence->doesFloat() ) { |
535 | if ( mIncidence->type() == "Event" ) { | 535 | if ( mIncidence->type() == "Event" ) { |
536 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 536 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
537 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 537 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
538 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 538 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
539 | } | 539 | } |
540 | else { | 540 | else { |
541 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 541 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
542 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 542 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
543 | } | 543 | } |
544 | } | 544 | } |
545 | else if ( mIncidence->type() == "Todo" ) { | 545 | else if ( mIncidence->type() == "Todo" ) { |
546 | if (mIncidence->hasStartDate()) | 546 | if (mIncidence->hasStartDate()) |
547 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 547 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
548 | if (((Todo*)mIncidence)->hasDueDate()) | 548 | if (((Todo*)mIncidence)->hasDueDate()) |
549 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 549 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
550 | } | 550 | } |
551 | } else if ( mIncidence->type() == "Todo" ) { | 551 | } else if ( mIncidence->type() == "Todo" ) { |
552 | if (mIncidence->hasStartDate()) | 552 | if (mIncidence->hasStartDate()) |
553 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 553 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
554 | if (((Todo*)mIncidence)->hasDueDate()) | 554 | if (((Todo*)mIncidence)->hasDueDate()) |
555 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 555 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
556 | } | 556 | } |
557 | 557 | ||
558 | if (!mIncidence->location().isEmpty()) { | 558 | if (!mIncidence->location().isEmpty()) { |
559 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 559 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
560 | } | 560 | } |
561 | QToolTip::add(this,tipText,toolTipGroup(),""); | 561 | QToolTip::add(this,tipText,toolTipGroup(),""); |
562 | 562 | ||
563 | } | 563 | } |
564 | void KOAgendaItem::updateItem() | 564 | void KOAgendaItem::updateItem() |
565 | { | 565 | { |
566 | computeText(); | 566 | computeText(); |
567 | 567 | ||
568 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 568 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
569 | paintMe( mSelected ); | 569 | paintMe( mSelected ); |
570 | repaint( false); | 570 | repaint( false); |
571 | } | 571 | } |
572 | 572 | ||
573 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 573 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
574 | { | 574 | { |
575 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 575 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
576 | paintMe( mSelected ); | 576 | paintMe( mSelected ); |
577 | repaint( false ); | 577 | repaint( false ); |
578 | } | 578 | } |
579 | 579 | ||
580 | /* | 580 | /* |
581 | Return height of item in units of agenda cells | 581 | Return height of item in units of agenda cells |
582 | */ | 582 | */ |
583 | int KOAgendaItem::cellHeight() | 583 | int KOAgendaItem::cellHeight() |
584 | { | 584 | { |
585 | int ret = mCellYBottom - mCellYTop + 1; | 585 | int ret = mCellYBottom - mCellYTop + 1; |
586 | if ( ret <= 0 ) { | 586 | if ( ret <= 0 ) { |
587 | ret = 1; | 587 | ret = 1; |
588 | mCellYBottom = 0; | 588 | mCellYBottom = 0; |
589 | mCellYTop = 0; | 589 | mCellYTop = 0; |
590 | } | 590 | } |
591 | return ret; | 591 | return ret; |
592 | } | 592 | } |
593 | 593 | ||
594 | /* | 594 | /* |
595 | Return height of item in units of agenda cells | 595 | Return height of item in units of agenda cells |
596 | */ | 596 | */ |
597 | int KOAgendaItem::cellWidth() | 597 | int KOAgendaItem::cellWidth() |
598 | { | 598 | { |
599 | return mCellXWidth - mCellX + 1; | 599 | return mCellXWidth - mCellX + 1; |
600 | } | 600 | } |
601 | 601 | ||
602 | void KOAgendaItem::setItemDate(QDate qd) | 602 | void KOAgendaItem::setItemDate(QDate qd) |
603 | { | 603 | { |
604 | mDate = qd; | 604 | mDate = qd; |
605 | } | 605 | } |
606 | 606 | ||
607 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 607 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
608 | { | 608 | { |
609 | mCellX = X; | 609 | mCellX = X; |
610 | mCellYTop = YTop; | 610 | mCellYTop = YTop; |
611 | mCellYBottom = YBottom; | 611 | mCellYBottom = YBottom; |
612 | } | 612 | } |
613 | 613 | ||
614 | void KOAgendaItem::setCellXWidth(int xwidth) | 614 | void KOAgendaItem::setCellXWidth(int xwidth) |
615 | { | 615 | { |
616 | mCellXWidth = xwidth; | 616 | mCellXWidth = xwidth; |
617 | } | 617 | } |
618 | 618 | ||
619 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 619 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
620 | { | 620 | { |
621 | mCellX = XLeft; | 621 | mCellX = XLeft; |
622 | mCellXWidth = XRight; | 622 | mCellXWidth = XRight; |
623 | } | 623 | } |
624 | 624 | ||
625 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 625 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
626 | { | 626 | { |
627 | mCellYTop = YTop; | 627 | mCellYTop = YTop; |
628 | mCellYBottom = YBottom; | 628 | mCellYBottom = YBottom; |
629 | } | 629 | } |
630 | 630 | ||
631 | void KOAgendaItem::setSubCell(int subCell) | 631 | void KOAgendaItem::setSubCell(int subCell) |
632 | { | 632 | { |
633 | mSubCell = subCell; | 633 | mSubCell = subCell; |
634 | } | 634 | } |
635 | 635 | ||
636 | void KOAgendaItem::setSubCells(int subCells) | 636 | void KOAgendaItem::setSubCells(int subCells) |
637 | { | 637 | { |
638 | mSubCells = subCells; | 638 | mSubCells = subCells; |
639 | } | 639 | } |
640 | 640 | ||
641 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 641 | void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
642 | KOAgendaItem *last) | 642 | KOAgendaItem *last) |
643 | { | 643 | { |
644 | mFirstMultiItem = first; | 644 | mFirstMultiItem = first; |
645 | mNextMultiItem = next; | 645 | mNextMultiItem = next; |
646 | mLastMultiItem = last; | 646 | mLastMultiItem = last; |
647 | } | 647 | } |
648 | 648 | ||
649 | void KOAgendaItem::startMove() | 649 | void KOAgendaItem::startMove() |
650 | { | 650 | { |
651 | mStartCellX = mCellX; | 651 | mStartCellX = mCellX; |
652 | mStartCellXWidth = mCellXWidth; | 652 | mStartCellXWidth = mCellXWidth; |
653 | mStartCellYTop = mCellYTop; | 653 | mStartCellYTop = mCellYTop; |
654 | mStartCellYBottom = mCellYBottom; | 654 | mStartCellYBottom = mCellYBottom; |
655 | } | 655 | } |
656 | 656 | ||
657 | void KOAgendaItem::resetMove() | 657 | void KOAgendaItem::resetMove() |
658 | { | 658 | { |
659 | mCellX = mStartCellX; | 659 | mCellX = mStartCellX; |
660 | mCellXWidth = mStartCellXWidth; | 660 | mCellXWidth = mStartCellXWidth; |
661 | mCellYTop = mStartCellYTop; | 661 | mCellYTop = mStartCellYTop; |
662 | mCellYBottom = mStartCellYBottom; | 662 | mCellYBottom = mStartCellYBottom; |
663 | } | 663 | } |
664 | 664 | ||
665 | void KOAgendaItem::moveRelative(int dx, int dy) | 665 | void KOAgendaItem::moveRelative(int dx, int dy) |
666 | { | 666 | { |
667 | int newX = cellX() + dx; | 667 | int newX = cellX() + dx; |
668 | int newXWidth = cellXWidth() + dx; | 668 | int newXWidth = cellXWidth() + dx; |
669 | int newYTop = cellYTop() + dy; | 669 | int newYTop = cellYTop() + dy; |
670 | int newYBottom = cellYBottom() + dy; | 670 | int newYBottom = cellYBottom() + dy; |
671 | setCellXY(newX,newYTop,newYBottom); | 671 | setCellXY(newX,newYTop,newYBottom); |
672 | setCellXWidth(newXWidth); | 672 | setCellXWidth(newXWidth); |
673 | } | 673 | } |
674 | 674 | ||
675 | void KOAgendaItem::expandTop(int dy) | 675 | void KOAgendaItem::expandTop(int dy) |
676 | { | 676 | { |
677 | int newYTop = cellYTop() + dy; | 677 | int newYTop = cellYTop() + dy; |
678 | int newYBottom = cellYBottom(); | 678 | int newYBottom = cellYBottom(); |
679 | if (newYTop > newYBottom) newYTop = newYBottom; | 679 | if (newYTop > newYBottom) newYTop = newYBottom; |
680 | setCellY(newYTop, newYBottom); | 680 | setCellY(newYTop, newYBottom); |
681 | } | 681 | } |
682 | 682 | ||
683 | void KOAgendaItem::expandBottom(int dy) | 683 | void KOAgendaItem::expandBottom(int dy) |
684 | { | 684 | { |
685 | int newYTop = cellYTop(); | 685 | int newYTop = cellYTop(); |
686 | int newYBottom = cellYBottom() + dy; | 686 | int newYBottom = cellYBottom() + dy; |
687 | if (newYBottom < newYTop) newYBottom = newYTop; | 687 | if (newYBottom < newYTop) newYBottom = newYTop; |
688 | setCellY(newYTop, newYBottom); | 688 | setCellY(newYTop, newYBottom); |
689 | } | 689 | } |
690 | 690 | ||
691 | void KOAgendaItem::expandLeft(int dx) | 691 | void KOAgendaItem::expandLeft(int dx) |
692 | { | 692 | { |
693 | int newX = cellX() + dx; | 693 | int newX = cellX() + dx; |
694 | int newXWidth = cellXWidth(); | 694 | int newXWidth = cellXWidth(); |
695 | if (newX > newXWidth) newX = newXWidth; | 695 | if (newX > newXWidth) newX = newXWidth; |
696 | setCellX(newX,newXWidth); | 696 | setCellX(newX,newXWidth); |
697 | } | 697 | } |
698 | 698 | ||
699 | void KOAgendaItem::expandRight(int dx) | 699 | void KOAgendaItem::expandRight(int dx) |
700 | { | 700 | { |
701 | int newX = cellX(); | 701 | int newX = cellX(); |
702 | int newXWidth = cellXWidth() + dx; | 702 | int newXWidth = cellXWidth() + dx; |
703 | if (newXWidth < newX) newXWidth = newX; | 703 | if (newXWidth < newX) newXWidth = newX; |
704 | setCellX(newX,newXWidth); | 704 | setCellX(newX,newXWidth); |
705 | } | 705 | } |
706 | 706 | ||
707 | QToolTipGroup *KOAgendaItem::toolTipGroup() | 707 | QToolTipGroup *KOAgendaItem::toolTipGroup() |
708 | { | 708 | { |
709 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 709 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
710 | return mToolTipGroup; | 710 | return mToolTipGroup; |
711 | } | 711 | } |
712 | 712 | ||
713 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) | 713 | void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) |
714 | { | 714 | { |
715 | #ifndef KORG_NODND | 715 | #ifndef KORG_NODND |
716 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || | 716 | if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || |
717 | !QTextDrag::canDecode( e ) ) { | 717 | !QTextDrag::canDecode( e ) ) { |
718 | e->ignore(); | 718 | e->ignore(); |
719 | return; | 719 | return; |
720 | } | 720 | } |
721 | e->accept(); | 721 | e->accept(); |
722 | #endif | 722 | #endif |
723 | } | 723 | } |
724 | 724 | ||
725 | void KOAgendaItem::dropEvent( QDropEvent *e ) | 725 | void KOAgendaItem::dropEvent( QDropEvent *e ) |
726 | { | 726 | { |
727 | #ifndef KORG_NODND | 727 | #ifndef KORG_NODND |
728 | QString text; | 728 | QString text; |
729 | if(QTextDrag::decode(e,text)) | 729 | if(QTextDrag::decode(e,text)) |
730 | { | 730 | { |
731 | kdDebug() << "Dropped : " << text << endl; | 731 | kdDebug() << "Dropped : " << text << endl; |
732 | QStringList emails = QStringList::split(",",text); | 732 | QStringList emails = QStringList::split(",",text); |
733 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 733 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
734 | kdDebug() << " Email: " << (*it) << endl; | 734 | kdDebug() << " Email: " << (*it) << endl; |
735 | int pos = (*it).find("<"); | 735 | int pos = (*it).find("<"); |
736 | QString name = (*it).left(pos); | 736 | QString name = (*it).left(pos); |
737 | QString email = (*it).mid(pos); | 737 | QString email = (*it).mid(pos); |
738 | if (!email.isEmpty()) { | 738 | if (!email.isEmpty()) { |
739 | mIncidence->addAttendee(new Attendee(name,email)); | 739 | mIncidence->addAttendee(new Attendee(name,email)); |
740 | } | 740 | } |
741 | } | 741 | } |
742 | } | 742 | } |
743 | #endif | 743 | #endif |
744 | } | 744 | } |
745 | 745 | ||
746 | 746 | ||
747 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() | 747 | QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() |
748 | { | 748 | { |
749 | return mConflictItems; | 749 | return mConflictItems; |
750 | } | 750 | } |
751 | 751 | ||
752 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) | 752 | void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) |
753 | { | 753 | { |
754 | mConflictItems = ci; | 754 | mConflictItems = ci; |
755 | KOAgendaItem *item; | 755 | KOAgendaItem *item; |
756 | for ( item=mConflictItems.first(); item != 0; | 756 | for ( item=mConflictItems.first(); item != 0; |
757 | item=mConflictItems.next() ) { | 757 | item=mConflictItems.next() ) { |
758 | item->addConflictItem(this); | 758 | item->addConflictItem(this); |
759 | } | 759 | } |
760 | } | 760 | } |
761 | 761 | ||
762 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) | 762 | void KOAgendaItem::addConflictItem(KOAgendaItem *ci) |
763 | { | 763 | { |
764 | if (mConflictItems.find(ci)<0) | 764 | if (mConflictItems.find(ci)<0) |
765 | mConflictItems.append(ci); | 765 | mConflictItems.append(ci); |
766 | } | 766 | } |
767 | |||
768 | bool KOAgendaItem::checkLayout() | ||
769 | { | ||
770 | if ( !mConflictItems.count() ) | ||
771 | return true; | ||
772 | int max = 0; | ||
773 | KOAgendaItem *item; | ||
774 | for ( item=mConflictItems.first(); item != 0; | ||
775 | item=mConflictItems.next() ) { | ||
776 | if ( item->subCells() > max ) | ||
777 | max = item->subCells(); | ||
778 | } | ||
779 | if ( max > subCells() ) { | ||
780 | setSubCells( max ); | ||
781 | return false; | ||
782 | } | ||
783 | return true; | ||
784 | } | ||
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 5b8f420..b4dba79 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h | |||
@@ -1,161 +1,162 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | #ifndef KOAGENDAITEM_H | 19 | #ifndef KOAGENDAITEM_H |
20 | #define KOAGENDAITEM_H | 20 | #define KOAGENDAITEM_H |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpixmap.h> | 24 | #include <qpixmap.h> |
25 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
26 | #include <qpalette.h> | 26 | #include <qpalette.h> |
27 | 27 | ||
28 | #include <libkcal/incidence.h> | 28 | #include <libkcal/incidence.h> |
29 | 29 | ||
30 | class QToolTipGroup; | 30 | class QToolTipGroup; |
31 | class QDragEnterEvent; | 31 | class QDragEnterEvent; |
32 | class QDropEvent; | 32 | class QDropEvent; |
33 | 33 | ||
34 | using namespace KCal; | 34 | using namespace KCal; |
35 | 35 | ||
36 | /* | 36 | /* |
37 | The KOAgendaItem has to make sure that it receives all mouse events, which are | 37 | The KOAgendaItem has to make sure that it receives all mouse events, which are |
38 | to be used for dragging and resizing. That means it has to be installed as | 38 | to be used for dragging and resizing. That means it has to be installed as |
39 | eventfiler for its children, if it has children, and it has to pass mouse | 39 | eventfiler for its children, if it has children, and it has to pass mouse |
40 | events from the cildren to itself. See eventFilter(). | 40 | events from the cildren to itself. See eventFilter(). |
41 | */ | 41 | */ |
42 | class KOAgendaItem : public QWidget | 42 | class KOAgendaItem : public QWidget |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, | 46 | KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, |
47 | WFlags f=0 ); | 47 | WFlags f=0 ); |
48 | ~KOAgendaItem(); | 48 | ~KOAgendaItem(); |
49 | QString getWhatsThisText(); | 49 | QString getWhatsThisText(); |
50 | void init ( Incidence *incidence, QDate qd ); | 50 | void init ( Incidence *incidence, QDate qd ); |
51 | int cellX() { return mCellX; } | 51 | int cellX() { return mCellX; } |
52 | int cellXWidth() { return mCellXWidth; } | 52 | int cellXWidth() { return mCellXWidth; } |
53 | int cellYTop() { return mCellYTop; } | 53 | int cellYTop() { return mCellYTop; } |
54 | int cellYBottom() { return mCellYBottom; } | 54 | int cellYBottom() { return mCellYBottom; } |
55 | int cellHeight(); | 55 | int cellHeight(); |
56 | int cellWidth(); | 56 | int cellWidth(); |
57 | int subCell() { return mSubCell; } | 57 | int subCell() { return mSubCell; } |
58 | int subCells() { return mSubCells; } | 58 | int subCells() { return mSubCells; } |
59 | 59 | ||
60 | void setCellXY(int X, int YTop, int YBottom); | 60 | void setCellXY(int X, int YTop, int YBottom); |
61 | void setCellY(int YTop, int YBottom); | 61 | void setCellY(int YTop, int YBottom); |
62 | void setCellX(int XLeft, int XRight); | 62 | void setCellX(int XLeft, int XRight); |
63 | void setCellXWidth(int xwidth); | 63 | void setCellXWidth(int xwidth); |
64 | void setSubCell(int subCell); | 64 | void setSubCell(int subCell); |
65 | void setSubCells(int subCells); | 65 | void setSubCells(int subCells); |
66 | 66 | ||
67 | /** Start movement */ | 67 | /** Start movement */ |
68 | void startMove(); | 68 | void startMove(); |
69 | /** Reset to original values */ | 69 | /** Reset to original values */ |
70 | void resetMove(); | 70 | void resetMove(); |
71 | 71 | ||
72 | void moveRelative(int dx,int dy); | 72 | void moveRelative(int dx,int dy); |
73 | void expandTop(int dy); | 73 | void expandTop(int dy); |
74 | void expandBottom(int dy); | 74 | void expandBottom(int dy); |
75 | void expandLeft(int dx); | 75 | void expandLeft(int dx); |
76 | void expandRight(int dx); | 76 | void expandRight(int dx); |
77 | int mLastMoveXPos; | 77 | int mLastMoveXPos; |
78 | 78 | ||
79 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, | 79 | void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, |
80 | KOAgendaItem *last); | 80 | KOAgendaItem *last); |
81 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } | 81 | KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } |
82 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } | 82 | KOAgendaItem *nextMultiItem() { return mNextMultiItem; } |
83 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } | 83 | KOAgendaItem *lastMultiItem() { return mLastMultiItem; } |
84 | 84 | ||
85 | Incidence *incidence() const { return mIncidence; } | 85 | Incidence *incidence() const { return mIncidence; } |
86 | QDate itemDate() { return mDate; } | 86 | QDate itemDate() { return mDate; } |
87 | 87 | ||
88 | /** Update the date of this item's occurence (not in the event) */ | 88 | /** Update the date of this item's occurence (not in the event) */ |
89 | void setItemDate(QDate qd); | 89 | void setItemDate(QDate qd); |
90 | 90 | ||
91 | void setText ( const QString & text ) { mDisplayedText = text; } | 91 | void setText ( const QString & text ) { mDisplayedText = text; } |
92 | QString text () { return mDisplayedText; } | 92 | QString text () { return mDisplayedText; } |
93 | 93 | ||
94 | virtual bool eventFilter ( QObject *, QEvent * ); | 94 | virtual bool eventFilter ( QObject *, QEvent * ); |
95 | 95 | ||
96 | static QToolTipGroup *toolTipGroup(); | 96 | static QToolTipGroup *toolTipGroup(); |
97 | 97 | ||
98 | QPtrList<KOAgendaItem> conflictItems(); | 98 | QPtrList<KOAgendaItem> conflictItems(); |
99 | void setConflictItems(QPtrList<KOAgendaItem>); | 99 | void setConflictItems(QPtrList<KOAgendaItem>); |
100 | void addConflictItem(KOAgendaItem *ci); | 100 | void addConflictItem(KOAgendaItem *ci); |
101 | void paintMe( bool, QPainter* painter = 0 ); | 101 | void paintMe( bool, QPainter* painter = 0 ); |
102 | void repaintMe(); | 102 | void repaintMe(); |
103 | static void resizePixmap( int, int ); | 103 | static void resizePixmap( int, int ); |
104 | static QPixmap * paintPix(); | 104 | static QPixmap * paintPix(); |
105 | static QPixmap * paintPixSel(); | 105 | static QPixmap * paintPixSel(); |
106 | static QPixmap * paintPixAllday(); | 106 | static QPixmap * paintPixAllday(); |
107 | void updateItem(); | 107 | void updateItem(); |
108 | void computeText(); | 108 | void computeText(); |
109 | void recreateIncidence(); | 109 | void recreateIncidence(); |
110 | bool checkLayout(); | ||
110 | public slots: | 111 | public slots: |
111 | bool updateIcons( QPainter *, bool ); | 112 | bool updateIcons( QPainter *, bool ); |
112 | void select(bool=true); | 113 | void select(bool=true); |
113 | 114 | ||
114 | protected: | 115 | protected: |
115 | void dragEnterEvent(QDragEnterEvent *e); | 116 | void dragEnterEvent(QDragEnterEvent *e); |
116 | void dropEvent(QDropEvent *e); | 117 | void dropEvent(QDropEvent *e); |
117 | void paintEvent ( QPaintEvent * ); | 118 | void paintEvent ( QPaintEvent * ); |
118 | void resizeEvent ( QResizeEvent *ev ); | 119 | void resizeEvent ( QResizeEvent *ev ); |
119 | 120 | ||
120 | private: | 121 | private: |
121 | bool mAllDay; | 122 | bool mAllDay; |
122 | int mCellX; | 123 | int mCellX; |
123 | int mCellXWidth; | 124 | int mCellXWidth; |
124 | int mCellYTop,mCellYBottom; | 125 | int mCellYTop,mCellYBottom; |
125 | int mSubCell; // subcell number of this item | 126 | int mSubCell; // subcell number of this item |
126 | int mSubCells; // Total number of subcells in cell of this item | 127 | int mSubCells; // Total number of subcells in cell of this item |
127 | int xPaintCoord; | 128 | int xPaintCoord; |
128 | int yPaintCoord; | 129 | int yPaintCoord; |
129 | int wPaintCoord; | 130 | int wPaintCoord; |
130 | int hPaintCoord; | 131 | int hPaintCoord; |
131 | // Variables to remember start position | 132 | // Variables to remember start position |
132 | int mStartCellX; | 133 | int mStartCellX; |
133 | int mStartCellXWidth; | 134 | int mStartCellXWidth; |
134 | int mStartCellYTop,mStartCellYBottom; | 135 | int mStartCellYTop,mStartCellYBottom; |
135 | int mLastMovePos; | 136 | int mLastMovePos; |
136 | 137 | ||
137 | // Multi item pointers | 138 | // Multi item pointers |
138 | KOAgendaItem *mFirstMultiItem; | 139 | KOAgendaItem *mFirstMultiItem; |
139 | KOAgendaItem *mNextMultiItem; | 140 | KOAgendaItem *mNextMultiItem; |
140 | KOAgendaItem *mLastMultiItem; | 141 | KOAgendaItem *mLastMultiItem; |
141 | 142 | ||
142 | int mFontPixelSize; | 143 | int mFontPixelSize; |
143 | Incidence *mIncidence; // corresponding event or todo | 144 | Incidence *mIncidence; // corresponding event or todo |
144 | QDate mDate; //date this events occurs (for recurrence) | 145 | QDate mDate; //date this events occurs (for recurrence) |
145 | //void showIcon( QLabel*, int ); | 146 | //void showIcon( QLabel*, int ); |
146 | //QLabel *mTodoIconLabel; | 147 | //QLabel *mTodoIconLabel; |
147 | //QLabel *mItemLabel; | 148 | //QLabel *mItemLabel; |
148 | //QWidget *mIconBox; | 149 | //QWidget *mIconBox; |
149 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; | 150 | //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; |
150 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; | 151 | //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; |
151 | //QLabel *mIconMoreInfo; | 152 | //QLabel *mIconMoreInfo; |
152 | static QToolTipGroup *mToolTipGroup; | 153 | static QToolTipGroup *mToolTipGroup; |
153 | 154 | ||
154 | QColor mBackgroundColor; | 155 | QColor mBackgroundColor; |
155 | QColorGroup mColorGroup; | 156 | QColorGroup mColorGroup; |
156 | QString mDisplayedText; | 157 | QString mDisplayedText; |
157 | bool mSelected; | 158 | bool mSelected; |
158 | QPtrList<KOAgendaItem> mConflictItems; | 159 | QPtrList<KOAgendaItem> mConflictItems; |
159 | }; | 160 | }; |
160 | 161 | ||
161 | #endif // KOAGENDAITEM_H | 162 | #endif // KOAGENDAITEM_H |
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index 8bada3b..e2c8e6e 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,283 +1,292 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | 21 | ||
22 | #include <libkcal/event.h> | 22 | #include <libkcal/event.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | 25 | ||
26 | #include "koeventviewer.h" | 26 | #include "koeventviewer.h" |
27 | #include "koprefs.h" | 27 | #include "koprefs.h" |
28 | #include <libkcal/todo.h> | 28 | #include <libkcal/todo.h> |
29 | #include "qapp.h" | 29 | #include "qapp.h" |
30 | 30 | ||
31 | #include "koeventviewerdialog.h" | 31 | #include "koeventviewerdialog.h" |
32 | extern int globalFlagBlockAgenda; | 32 | extern int globalFlagBlockAgenda; |
33 | 33 | ||
34 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 34 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
35 | : KDialogBase(parent,name, | 35 | : KDialogBase(parent,name, |
36 | #ifndef DESKTOP_VERSION | 36 | #ifndef DESKTOP_VERSION |
37 | true , | 37 | true , |
38 | #else | 38 | #else |
39 | false, | 39 | false, |
40 | #endif | 40 | #endif |
41 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 41 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
42 | { | 42 | { |
43 | sendSignalViewerClosed = true; | 43 | sendSignalViewerClosed = true; |
44 | mEventViewer = new KOEventViewer(this); | 44 | mEventViewer = new KOEventViewer(this); |
45 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 45 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
46 | setMainWidget(mEventViewer); | 46 | setMainWidget(mEventViewer); |
47 | setButtonText(Ok, i18n("Edit") ); | 47 | setButtonText(Ok, i18n("Edit") ); |
48 | 48 | ||
49 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 49 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
50 | SLOT(editIncidence())); | 50 | SLOT(editIncidence())); |
51 | QObject::connect(this,SIGNAL(user1Clicked()), | 51 | QObject::connect(this,SIGNAL(user1Clicked()), |
52 | SLOT(showIncidence())); | 52 | SLOT(showIncidence())); |
53 | mIncidence = 0; | 53 | mIncidence = 0; |
54 | // TODO: Set a sensible size (based on the content?). | 54 | // TODO: Set a sensible size (based on the content?). |
55 | //showMaximized(); | 55 | //showMaximized(); |
56 | //qDebug("++++++++++++KOEventViewerDialog() "); | 56 | //qDebug("++++++++++++KOEventViewerDialog() "); |
57 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 57 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
58 | // setFixedSize( 240,284 ); | 58 | // setFixedSize( 240,284 ); |
59 | // move( 0, 15 ); | 59 | // move( 0, 15 ); |
60 | // } else { | 60 | // } else { |
61 | // setMinimumSize(300,200); | 61 | // setMinimumSize(300,200); |
62 | // resize(320,300); | 62 | // resize(320,300); |
63 | // } | 63 | // } |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mSyncResult = 0; | 65 | mSyncResult = 0; |
66 | 66 | ||
67 | } | 67 | } |
68 | 68 | ||
69 | KOEventViewerDialog::~KOEventViewerDialog() | 69 | KOEventViewerDialog::~KOEventViewerDialog() |
70 | { | 70 | { |
71 | //qDebug("-------~KOEventViewerDialog() "); | 71 | //qDebug("-------~KOEventViewerDialog() "); |
72 | } | 72 | } |
73 | void KOEventViewerDialog::showMe() | 73 | void KOEventViewerDialog::showMe() |
74 | { | 74 | { |
75 | 75 | ||
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | int x,y,w,h; | ||
78 | x = geometry().x(); | ||
79 | y = geometry().y(); | ||
80 | w = width(); | ||
81 | h = height(); | ||
77 | show(); | 82 | show(); |
83 | setGeometry(x,y,w,h); | ||
78 | #else | 84 | #else |
79 | showMaximized(); | 85 | showMaximized(); |
80 | #endif | 86 | #endif |
87 | raise(); | ||
81 | setActiveWindow(); | 88 | setActiveWindow(); |
82 | mEventViewer->setFocus(); | 89 | mEventViewer->setFocus(); |
83 | 90 | ||
84 | } | 91 | } |
85 | void KOEventViewerDialog::setSyncMode( bool b ) | 92 | void KOEventViewerDialog::setSyncMode( bool b ) |
86 | { | 93 | { |
87 | mSyncMode = b; | 94 | mSyncMode = b; |
88 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 95 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
89 | if ( mSyncMode ) { | 96 | if ( mSyncMode ) { |
90 | findButton( Close )->setText( i18n("Cancel Sync")); | 97 | findButton( Close )->setText( i18n("Cancel Sync")); |
91 | findButton( Ok )->setText( i18n("Remote")); | 98 | findButton( Ok )->setText( i18n("Remote")); |
92 | findButton( User1 )->setText( i18n("Local")); | 99 | findButton( User1 )->setText( i18n("Local")); |
93 | } else { | 100 | } else { |
94 | findButton( Close )->setText( i18n("Close")); | 101 | findButton( Close )->setText( i18n("Close")); |
95 | findButton( Ok )->setText( i18n("Edit")); | 102 | findButton( Ok )->setText( i18n("Edit")); |
96 | findButton( User1 )->setText( i18n("Agenda")); | 103 | findButton( User1 )->setText( i18n("Agenda")); |
97 | } | 104 | } |
98 | mEventViewer->setSyncMode( b ); | 105 | mEventViewer->setSyncMode( b ); |
99 | } | 106 | } |
100 | void KOEventViewerDialog::setColorMode( int m ) | 107 | void KOEventViewerDialog::setColorMode( int m ) |
101 | { | 108 | { |
102 | mEventViewer->setColorMode( m ); | 109 | mEventViewer->setColorMode( m ); |
103 | } | 110 | } |
104 | int KOEventViewerDialog::executeS( bool local ) | 111 | int KOEventViewerDialog::executeS( bool local ) |
105 | { | 112 | { |
106 | mSyncResult = 3; | 113 | mSyncResult = 3; |
107 | if ( local ) | 114 | if ( local ) |
108 | findButton( User1 )->setFocus(); | 115 | findButton( User1 )->setFocus(); |
109 | else | 116 | else |
110 | findButton( Ok )->setFocus(); | 117 | findButton( Ok )->setFocus(); |
111 | exec(); | 118 | exec(); |
112 | return mSyncResult; | 119 | return mSyncResult; |
113 | } | 120 | } |
114 | 121 | ||
115 | void KOEventViewerDialog::updateConfig() | 122 | void KOEventViewerDialog::updateConfig() |
116 | { | 123 | { |
117 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 124 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
118 | 125 | ||
119 | } | 126 | } |
120 | void KOEventViewerDialog::setEvent(Event *event) | 127 | void KOEventViewerDialog::setEvent(Event *event) |
121 | { | 128 | { |
122 | mEventViewer->setEvent(event); | 129 | mEventViewer->setEvent(event); |
123 | mIncidence = event; | 130 | mIncidence = event; |
124 | mEventViewer->setFocus(); | 131 | mEventViewer->setFocus(); |
125 | //findButton( Close )->setFocus(); | 132 | //findButton( Close )->setFocus(); |
126 | if ( !mSyncMode ) { | 133 | if ( !mSyncMode ) { |
127 | findButton( User1 )->setText( i18n("Agenda")); | 134 | findButton( User1 )->setText( i18n("Agenda")); |
128 | } | 135 | } |
129 | } | 136 | } |
130 | void KOEventViewerDialog::setIncidence(Incidence *in ) | 137 | void KOEventViewerDialog::setIncidence(Incidence *in ) |
131 | { | 138 | { |
132 | if ( in->type() == "Event" ) | 139 | if ( in->type() == "Event" ) |
133 | setEvent( (Event*) in ); | 140 | setEvent( (Event*) in ); |
134 | else if ( in->type() =="Todo" ) | 141 | else if ( in->type() =="Todo" ) |
135 | setTodo( (Todo*) in ); | 142 | setTodo( (Todo*) in ); |
136 | else if ( in->type() =="Journal" ) | 143 | else if ( in->type() =="Journal" ) |
137 | setJournal( (Journal*) in ); | 144 | setJournal( (Journal*) in ); |
138 | } | 145 | } |
139 | void KOEventViewerDialog::addIncidence(Incidence *in) | 146 | void KOEventViewerDialog::addIncidence(Incidence *in) |
140 | { | 147 | { |
141 | if ( in->type() == "Event" ) | 148 | if ( in->type() == "Event" ) |
142 | addEvent( (Event*) in ); | 149 | addEvent( (Event*) in ); |
143 | else if ( in->type() =="Todo" ) | 150 | else if ( in->type() =="Todo" ) |
144 | mEventViewer->setTodo( (Todo*) in, false ); | 151 | mEventViewer->setTodo( (Todo*) in, false ); |
145 | else if ( in->type() =="Journal" ) | 152 | else if ( in->type() =="Journal" ) |
146 | mEventViewer->setJournal( (Journal*) in, false ); | 153 | mEventViewer->setJournal( (Journal*) in, false ); |
147 | if ( mSyncMode ) { | 154 | if ( mSyncMode ) { |
148 | findButton( User1 )->setFocus(); | 155 | findButton( User1 )->setFocus(); |
149 | setCaption(i18n("Conflict! Please choose entry")); | 156 | setCaption(i18n("Conflict! Please choose entry")); |
150 | } | 157 | } |
151 | } | 158 | } |
152 | 159 | ||
153 | void KOEventViewerDialog::addEvent(Event *event) | 160 | void KOEventViewerDialog::addEvent(Event *event) |
154 | { | 161 | { |
155 | mEventViewer->addEvent(event); | 162 | mEventViewer->addEvent(event); |
156 | mIncidence = event; | 163 | mIncidence = event; |
157 | mEventViewer->setFocus(); | 164 | mEventViewer->setFocus(); |
158 | //findButton( Close )->setFocus(); | 165 | //findButton( Close )->setFocus(); |
159 | if ( !mSyncMode ) { | 166 | if ( !mSyncMode ) { |
160 | findButton( User1 )->setText( i18n("Agenda")); | 167 | findButton( User1 )->setText( i18n("Agenda")); |
161 | } | 168 | } |
162 | } | 169 | } |
163 | 170 | ||
164 | void KOEventViewerDialog::setTodo(Todo *event) | 171 | void KOEventViewerDialog::setTodo(Todo *event) |
165 | { | 172 | { |
166 | mEventViewer->setTodo(event); | 173 | mEventViewer->setTodo(event); |
167 | mIncidence = (Incidence*)event; | 174 | mIncidence = (Incidence*)event; |
168 | mEventViewer->setFocus(); | 175 | mEventViewer->setFocus(); |
169 | //findButton( Close )->setFocus(); | 176 | //findButton( Close )->setFocus(); |
170 | if ( !mSyncMode ) { | 177 | if ( !mSyncMode ) { |
171 | findButton( User1 )->setText( i18n("Set complete")); | 178 | findButton( User1 )->setText( i18n("Set complete")); |
172 | } | 179 | } |
173 | } | 180 | } |
174 | void KOEventViewerDialog::setJournal(Journal *j) | 181 | void KOEventViewerDialog::setJournal(Journal *j) |
175 | { | 182 | { |
176 | mEventViewer->setJournal(j); | 183 | mEventViewer->setJournal(j); |
177 | mIncidence = (Incidence*)j; | 184 | mIncidence = (Incidence*)j; |
178 | mEventViewer->setFocus(); | 185 | mEventViewer->setFocus(); |
179 | //findButton( Close )->setFocus(); | 186 | //findButton( Close )->setFocus(); |
180 | if ( !mSyncMode ) { | 187 | if ( !mSyncMode ) { |
181 | findButton( User1 )->setText( i18n("Agenda")); | 188 | findButton( User1 )->setText( i18n("Agenda")); |
182 | } | 189 | } |
183 | } | 190 | } |
184 | 191 | ||
185 | void KOEventViewerDialog::addText(QString text) | 192 | void KOEventViewerDialog::addText(QString text) |
186 | { | 193 | { |
187 | mEventViewer->addText(text); | 194 | mEventViewer->addText(text); |
188 | mEventViewer->setFocus(); | 195 | mEventViewer->setFocus(); |
189 | //findButton( Close )->setFocus(); | 196 | //findButton( Close )->setFocus(); |
190 | } | 197 | } |
191 | void KOEventViewerDialog::editIncidence() | 198 | void KOEventViewerDialog::editIncidence() |
192 | { | 199 | { |
193 | sendSignalViewerClosed = false; | 200 | sendSignalViewerClosed = false; |
194 | if ( mSyncMode ) { | 201 | if ( mSyncMode ) { |
195 | mSyncResult = 2; | 202 | mSyncResult = 2; |
196 | accept(); | 203 | accept(); |
197 | return; | 204 | return; |
198 | } | 205 | } |
199 | if ( mIncidence ){ | 206 | if ( mIncidence ){ |
200 | #ifndef DESKTOP_VERSION | 207 | #ifndef DESKTOP_VERSION |
201 | hide(); | 208 | hide(); |
202 | #endif | 209 | #endif |
203 | emit editIncidence( mIncidence ); | 210 | emit editIncidence( mIncidence ); |
204 | } | 211 | } |
205 | } | 212 | } |
206 | void KOEventViewerDialog::showIncidence() | 213 | void KOEventViewerDialog::showIncidence() |
207 | { | 214 | { |
208 | sendSignalViewerClosed = false; | 215 | sendSignalViewerClosed = false; |
209 | if ( mSyncMode ) { | 216 | if ( mSyncMode ) { |
210 | mSyncResult = 1; | 217 | mSyncResult = 1; |
211 | accept(); | 218 | accept(); |
212 | return; | 219 | return; |
213 | } | 220 | } |
214 | 221 | ||
215 | if ( mIncidence ){ | 222 | if ( mIncidence ){ |
216 | #ifndef DESKTOP_VERSION | 223 | #ifndef DESKTOP_VERSION |
217 | hide(); | 224 | hide(); |
218 | #endif | 225 | #endif |
219 | QDate date; | 226 | QDate date; |
220 | if ( mIncidence->type() == "Todo" ) { | 227 | if ( mIncidence->type() == "Todo" ) { |
221 | /* | 228 | /* |
222 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 229 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
223 | date = ((Todo*)mIncidence)->dtDue().date(); | 230 | date = ((Todo*)mIncidence)->dtDue().date(); |
224 | else { | 231 | else { |
225 | globalFlagBlockAgenda = 2; | 232 | globalFlagBlockAgenda = 2; |
226 | emit showAgendaView( false ); | 233 | emit showAgendaView( false ); |
227 | return; | 234 | return; |
228 | } | 235 | } |
229 | */ | 236 | */ |
230 | ((Todo*)mIncidence)->setCompleted( true ); | 237 | ((Todo*)mIncidence)->setCompleted( true ); |
231 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 238 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
232 | hide(); | 239 | hide(); |
233 | emit todoCompleted(((Todo*)mIncidence)); | 240 | emit todoCompleted(((Todo*)mIncidence)); |
234 | return; | 241 | return; |
235 | 242 | ||
236 | } else | 243 | } else |
237 | date = mIncidence->dtStart().date(); | 244 | date = mIncidence->dtStart().date(); |
238 | globalFlagBlockAgenda = 1; | 245 | globalFlagBlockAgenda = 1; |
239 | emit showAgendaView( false ); | 246 | emit showAgendaView( false ); |
240 | globalFlagBlockAgenda = 2; | 247 | globalFlagBlockAgenda = 2; |
241 | emit jumpToTime( date ); | 248 | emit jumpToTime( date ); |
242 | } | 249 | } |
243 | } | 250 | } |
244 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 251 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
245 | { | 252 | { |
246 | switch ( e->key() ) { | 253 | switch ( e->key() ) { |
247 | 254 | ||
248 | case Qt::Key_A : | 255 | case Qt::Key_A : |
249 | case Qt::Key_L : | 256 | case Qt::Key_L : |
250 | showIncidence(); | 257 | showIncidence(); |
251 | break; | 258 | break; |
252 | case Qt::Key_E : | 259 | case Qt::Key_E : |
253 | case Qt::Key_R : | 260 | case Qt::Key_R : |
254 | editIncidence(); | 261 | editIncidence(); |
255 | break; | 262 | break; |
256 | case Qt::Key_C: | 263 | case Qt::Key_C: |
257 | case Qt::Key_Escape: | 264 | case Qt::Key_Escape: |
258 | close(); | 265 | close(); |
259 | break; | 266 | break; |
260 | case Qt::Key_I: | 267 | case Qt::Key_I: |
261 | accept(); | 268 | sendSignalViewerClosed = true; |
269 | slotViewerClosed(); | ||
270 | //accept(); | ||
262 | break; | 271 | break; |
263 | default: | 272 | default: |
264 | KDialogBase::keyPressEvent ( e ); | 273 | KDialogBase::keyPressEvent ( e ); |
265 | break; | 274 | break; |
266 | } | 275 | } |
267 | 276 | ||
268 | } | 277 | } |
269 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) | 278 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) |
270 | { | 279 | { |
271 | KDialogBase::hideEvent ( e ); | 280 | KDialogBase::hideEvent ( e ); |
272 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); | 281 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); |
273 | } | 282 | } |
274 | 283 | ||
275 | void KOEventViewerDialog::slotViewerClosed() | 284 | void KOEventViewerDialog::slotViewerClosed() |
276 | { | 285 | { |
277 | if ( sendSignalViewerClosed ) { | 286 | if ( sendSignalViewerClosed ) { |
278 | //qDebug("KOEventViewerDialog::hideEvent "); | 287 | //qDebug("KOEventViewerDialog::hideEvent "); |
279 | emit signalViewerClosed(); | 288 | emit signalViewerClosed(); |
280 | } | 289 | } |
281 | sendSignalViewerClosed = true; | 290 | sendSignalViewerClosed = true; |
282 | } | 291 | } |
283 | 292 | ||