-rw-r--r-- | korganizer/calendarview.cpp | 76 | ||||
-rw-r--r-- | korganizer/calendarview.h | 2 | ||||
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 36 | ||||
-rw-r--r-- | korganizer/kdatenavigator.cpp | 40 | ||||
-rw-r--r-- | korganizer/kdatenavigator.h | 8 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 11 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 1 | ||||
-rw-r--r-- | korganizer/navigatorbar.cpp | 67 | ||||
-rw-r--r-- | korganizer/navigatorbar.h | 1 |
9 files changed, 184 insertions, 58 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3ce123c..ab59d00 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3467 +1,3503 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | class KOBeamPrefs : public QDialog | 142 | class KOBeamPrefs : public QDialog |
143 | { | 143 | { |
144 | public: | 144 | public: |
145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 145 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
146 | QDialog( parent, name, true ) | 146 | QDialog( parent, name, true ) |
147 | { | 147 | { |
148 | setCaption( i18n("Beam Options") ); | 148 | setCaption( i18n("Beam Options") ); |
149 | QVBoxLayout* lay = new QVBoxLayout( this ); | 149 | QVBoxLayout* lay = new QVBoxLayout( this ); |
150 | lay->setSpacing( 3 ); | 150 | lay->setSpacing( 3 ); |
151 | lay->setMargin( 3 ); | 151 | lay->setMargin( 3 ); |
152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 152 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
153 | lay->addWidget( format ); | 153 | lay->addWidget( format ); |
154 | format->setExclusive ( true ) ; | 154 | format->setExclusive ( true ) ; |
155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 155 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
156 | lay->addWidget( time ); time->setExclusive ( true ) ; | 156 | lay->addWidget( time ); time->setExclusive ( true ) ; |
157 | vcal = new QRadioButton(" vCalendar ", format ); | 157 | vcal = new QRadioButton(" vCalendar ", format ); |
158 | ical = new QRadioButton(" iCalendar ", format ); | 158 | ical = new QRadioButton(" iCalendar ", format ); |
159 | vcal->setChecked( true ); | 159 | vcal->setChecked( true ); |
160 | tz = new QRadioButton(i18n(" With timezone "), time ); | 160 | tz = new QRadioButton(i18n(" With timezone "), time ); |
161 | local = new QRadioButton(i18n(" Local time "), time ); | 161 | local = new QRadioButton(i18n(" Local time "), time ); |
162 | tz->setChecked( true ); | 162 | tz->setChecked( true ); |
163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 163 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
164 | lay->addWidget( ok ); | 164 | lay->addWidget( ok ); |
165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 165 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
166 | lay->addWidget( cancel ); | 166 | lay->addWidget( cancel ); |
167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 167 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 168 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
169 | resize( 200, 200 ); | 169 | resize( 200, 200 ); |
170 | } | 170 | } |
171 | 171 | ||
172 | bool beamVcal() { return vcal->isChecked(); } | 172 | bool beamVcal() { return vcal->isChecked(); } |
173 | bool beamLocal() { return local->isChecked(); } | 173 | bool beamLocal() { return local->isChecked(); } |
174 | private: | 174 | private: |
175 | QRadioButton* vcal, *ical, *local, *tz; | 175 | QRadioButton* vcal, *ical, *local, *tz; |
176 | }; | 176 | }; |
177 | class KOCatPrefs : public QDialog | 177 | class KOCatPrefs : public QDialog |
178 | { | 178 | { |
179 | public: | 179 | public: |
180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 180 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
181 | QDialog( parent, name, true ) | 181 | QDialog( parent, name, true ) |
182 | { | 182 | { |
183 | setCaption( i18n("Manage new Categories") ); | 183 | setCaption( i18n("Manage new Categories") ); |
184 | QVBoxLayout* lay = new QVBoxLayout( this ); | 184 | QVBoxLayout* lay = new QVBoxLayout( this ); |
185 | lay->setSpacing( 3 ); | 185 | lay->setSpacing( 3 ); |
186 | lay->setMargin( 3 ); | 186 | lay->setMargin( 3 ); |
187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 187 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
188 | lay->addWidget( lab ); | 188 | lay->addWidget( lab ); |
189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 189 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
190 | lay->addWidget( format ); | 190 | lay->addWidget( format ); |
191 | format->setExclusive ( true ) ; | 191 | format->setExclusive ( true ) ; |
192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 192 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 193 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
194 | addCatBut->setChecked( true ); | 194 | addCatBut->setChecked( true ); |
195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 195 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
196 | lay->addWidget( ok ); | 196 | lay->addWidget( ok ); |
197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 197 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
198 | lay->addWidget( cancel ); | 198 | lay->addWidget( cancel ); |
199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 199 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 200 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
201 | resize( 200, 200 ); | 201 | resize( 200, 200 ); |
202 | } | 202 | } |
203 | 203 | ||
204 | bool addCat() { return addCatBut->isChecked(); } | 204 | bool addCat() { return addCatBut->isChecked(); } |
205 | private: | 205 | private: |
206 | QRadioButton* addCatBut; | 206 | QRadioButton* addCatBut; |
207 | }; | 207 | }; |
208 | 208 | ||
209 | 209 | ||
210 | 210 | ||
211 | CalendarView::CalendarView( CalendarResources *calendar, | 211 | CalendarView::CalendarView( CalendarResources *calendar, |
212 | QWidget *parent, const char *name ) | 212 | QWidget *parent, const char *name ) |
213 | : CalendarViewBase( parent, name ), | 213 | : CalendarViewBase( parent, name ), |
214 | mCalendar( calendar ), | 214 | mCalendar( calendar ), |
215 | mResourceManager( calendar->resourceManager() ) | 215 | mResourceManager( calendar->resourceManager() ) |
216 | { | 216 | { |
217 | 217 | ||
218 | mEventEditor = 0; | 218 | mEventEditor = 0; |
219 | mTodoEditor = 0; | 219 | mTodoEditor = 0; |
220 | 220 | ||
221 | init(); | 221 | init(); |
222 | } | 222 | } |
223 | 223 | ||
224 | CalendarView::CalendarView( Calendar *calendar, | 224 | CalendarView::CalendarView( Calendar *calendar, |
225 | QWidget *parent, const char *name ) | 225 | QWidget *parent, const char *name ) |
226 | : CalendarViewBase( parent, name ), | 226 | : CalendarViewBase( parent, name ), |
227 | mCalendar( calendar ), | 227 | mCalendar( calendar ), |
228 | mResourceManager( 0 ) | 228 | mResourceManager( 0 ) |
229 | { | 229 | { |
230 | 230 | ||
231 | mEventEditor = 0; | 231 | mEventEditor = 0; |
232 | mTodoEditor = 0; | 232 | mTodoEditor = 0; |
233 | init(); | 233 | init(); |
234 | } | 234 | } |
235 | 235 | ||
236 | void CalendarView::init() | 236 | void CalendarView::init() |
237 | { | 237 | { |
238 | 238 | ||
239 | setFocusPolicy ( WheelFocus ); | 239 | setFocusPolicy ( WheelFocus ); |
240 | mViewerCallerIsSearchDialog = false; | 240 | mViewerCallerIsSearchDialog = false; |
241 | mBlockShowDates = false; | 241 | mBlockShowDates = false; |
242 | beamDialog = new KOBeamPrefs(); | 242 | beamDialog = new KOBeamPrefs(); |
243 | mDatePickerMode = 0; | 243 | mDatePickerMode = 0; |
244 | mCurrentSyncDevice = ""; | 244 | mCurrentSyncDevice = ""; |
245 | writeLocale(); | 245 | writeLocale(); |
246 | mViewManager = new KOViewManager( this ); | 246 | mViewManager = new KOViewManager( this ); |
247 | mDialogManager = new KODialogManager( this ); | 247 | mDialogManager = new KODialogManager( this ); |
248 | mEventViewerDialog = 0; | 248 | mEventViewerDialog = 0; |
249 | mModified = false; | 249 | mModified = false; |
250 | mReadOnly = false; | 250 | mReadOnly = false; |
251 | mSelectedIncidence = 0; | 251 | mSelectedIncidence = 0; |
252 | mCalPrinter = 0; | 252 | mCalPrinter = 0; |
253 | mFilters.setAutoDelete(true); | 253 | mFilters.setAutoDelete(true); |
254 | 254 | ||
255 | mCalendar->registerObserver( this ); | 255 | mCalendar->registerObserver( this ); |
256 | // TODO: Make sure that view is updated, when calendar is changed. | 256 | // TODO: Make sure that view is updated, when calendar is changed. |
257 | 257 | ||
258 | mStorage = new FileStorage( mCalendar ); | 258 | mStorage = new FileStorage( mCalendar ); |
259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 259 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
260 | 260 | ||
261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 261 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
262 | #ifndef KORG_NOSPLITTER | 262 | #ifndef KORG_NOSPLITTER |
263 | // create the main layout frames. | 263 | // create the main layout frames. |
264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 264 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
265 | topLayout->addWidget(mPanner); | 265 | topLayout->addWidget(mPanner); |
266 | 266 | ||
267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 267 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
268 | "CalendarView::LeftFrame"); | 268 | "CalendarView::LeftFrame"); |
269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 269 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
270 | 270 | ||
271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 271 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
272 | "CalendarView::DateNavigator" ); | 272 | "CalendarView::DateNavigator" ); |
273 | 273 | ||
274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 274 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 275 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
276 | mTodoList->setNavigator( mNavigator ); | 276 | mTodoList->setNavigator( mNavigator ); |
277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 277 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
278 | 278 | ||
279 | #ifdef KORG_NORESOURCEVIEW | 279 | #ifdef KORG_NORESOURCEVIEW |
280 | mResourceView = 0; | 280 | mResourceView = 0; |
281 | #else | 281 | #else |
282 | if ( mResourceManager ) { | 282 | if ( mResourceManager ) { |
283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 283 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
284 | mResourceView->updateView(); | 284 | mResourceView->updateView(); |
285 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 285 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
286 | SLOT( updateView() ) ); | 286 | SLOT( updateView() ) ); |
287 | } else { | 287 | } else { |
288 | mResourceView = 0; | 288 | mResourceView = 0; |
289 | } | 289 | } |
290 | #endif | 290 | #endif |
291 | QWidget *rightBox = new QWidget( mPanner ); | 291 | QWidget *rightBox = new QWidget( mPanner ); |
292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 292 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
293 | 293 | ||
294 | mRightFrame = new QWidgetStack( rightBox ); | 294 | mRightFrame = new QWidgetStack( rightBox ); |
295 | rightLayout->addWidget( mRightFrame, 1 ); | 295 | rightLayout->addWidget( mRightFrame, 1 ); |
296 | 296 | ||
297 | mLeftFrame = mLeftSplitter; | 297 | mLeftFrame = mLeftSplitter; |
298 | #else | 298 | #else |
299 | QWidget *mainBox = new QWidget( this ); | 299 | //QWidget *mainBox = new QWidget( this ); |
300 | //QWidget *leftFrame = new QWidget( mainBox ); | 300 | //QWidget *leftFrame = new QWidget( mainBox ); |
301 | QBoxLayout * mainBoxLayout; | 301 | //QBoxLayout * mainBoxLayout; |
302 | if ( KOPrefs::instance()->mVerticalScreen ) { | 302 | if ( KOPrefs::instance()->mVerticalScreen ) { |
303 | mainBoxLayout = new QVBoxLayout(mainBox); | 303 | //mainBoxLayout = new QVBoxLayout(mainBox); |
304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 304 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
305 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mainBox);; | 305 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
306 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left ); | 306 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
307 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | ||
308 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | ||
307 | } else { | 309 | } else { |
308 | mainBoxLayout = new QHBoxLayout(mainBox); | 310 | //mainBoxLayout = new QHBoxLayout(mainBox); |
309 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 311 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
310 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mainBox);; | 312 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
313 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | ||
314 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | ||
311 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 315 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
312 | } | 316 | } |
313 | //QBoxLayout * leftFrameLayout; | 317 | //QBoxLayout * leftFrameLayout; |
314 | topLayout->addWidget( mainBox ); | 318 | topLayout->addWidget( mMainFrame ); |
315 | mainBoxLayout->addWidget (mLeftFrame); | 319 | //mainBoxLayout->addWidget (mLeftFrame); |
316 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 320 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
317 | "CalendarView::DateNavigator" ); | 321 | "CalendarView::DateNavigator" ); |
318 | #if 0 | 322 | #if 0 |
319 | // FIXME | 323 | // FIXME |
320 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 324 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
321 | "CalendarView::DateNavigator", QDate::currentDate()); | 325 | "CalendarView::DateNavigator", QDate::currentDate()); |
322 | #endif | 326 | #endif |
323 | // mDateNavigator->blockSignals( true ); | 327 | // mDateNavigator->blockSignals( true ); |
324 | //leftFrameLayout->addWidget( mDateNavigator ); | 328 | //leftFrameLayout->addWidget( mDateNavigator ); |
325 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 329 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
326 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 330 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
327 | mTodoList->setNavigator( mNavigator ); | 331 | mTodoList->setNavigator( mNavigator ); |
328 | #if 0 | 332 | #if 0 |
329 | if ( QApplication::desktop()->width() < 480 ) { | 333 | if ( QApplication::desktop()->width() < 480 ) { |
330 | leftFrameLayout->addWidget(mFilterView); | 334 | leftFrameLayout->addWidget(mFilterView); |
331 | leftFrameLayout->addWidget(mTodoList, 2 ); | 335 | leftFrameLayout->addWidget(mTodoList, 2 ); |
332 | 336 | ||
333 | } else { | 337 | } else { |
334 | leftFrameLayout->addWidget(mTodoList,2 ); | 338 | leftFrameLayout->addWidget(mTodoList,2 ); |
335 | leftFrameLayout->addWidget(mFilterView ); | 339 | leftFrameLayout->addWidget(mFilterView ); |
336 | } | 340 | } |
337 | #endif | 341 | #endif |
338 | mFilterView->hide(); | 342 | mFilterView->hide(); |
339 | QWidget *rightBox = new QWidget( mainBox ); | 343 | QWidget *rightBox = new QWidget( mMainFrame ); |
340 | mainBoxLayout->addWidget ( rightBox, 10 ); | 344 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
341 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 345 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
342 | mRightFrame = new QWidgetStack( rightBox ); | 346 | mRightFrame = new QWidgetStack( rightBox ); |
343 | rightLayout->addWidget( mRightFrame, 10 ); | 347 | rightLayout->addWidget( mRightFrame, 10 ); |
344 | 348 | ||
345 | //mLeftFrame = (QWidget *)leftFrame; | 349 | //mLeftFrame = (QWidget *)leftFrame; |
346 | if ( KOPrefs::instance()->mVerticalScreen ) { | 350 | if ( KOPrefs::instance()->mVerticalScreen ) { |
347 | mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 351 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
348 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 352 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
349 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 353 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
350 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 354 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
351 | } else { | 355 | } else { |
352 | mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 356 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
353 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 357 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
354 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 358 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
355 | } | 359 | } |
356 | if ( !KOPrefs::instance()->mShowDateNavigator) | 360 | if ( !KOPrefs::instance()->mShowDateNavigator) |
357 | mDateNavigator->hide(); | 361 | mDateNavigator->hide(); |
358 | //qDebug("Calendarview Size %d %d ", width(), height()); | 362 | //qDebug("Calendarview Size %d %d ", width(), height()); |
359 | #endif | 363 | #endif |
360 | 364 | ||
361 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 365 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
362 | SLOT( showDates( const KCal::DateList & ) ) ); | 366 | SLOT( showDates( const KCal::DateList & ) ) ); |
363 | 367 | ||
364 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 368 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
365 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 369 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
366 | 370 | ||
367 | 371 | ||
368 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 372 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
369 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 373 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
370 | 374 | ||
371 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 375 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
372 | mNavigator, SLOT( selectPreviousYear() ) ); | 376 | mNavigator, SLOT( selectPreviousYear() ) ); |
373 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 377 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
374 | mNavigator, SLOT( selectNextYear() ) ); | 378 | mNavigator, SLOT( selectNextYear() ) ); |
375 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 379 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
376 | mNavigator, SLOT( selectPreviousMonth() ) ); | 380 | mNavigator, SLOT( selectPreviousMonth() ) ); |
377 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 381 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
378 | mNavigator, SLOT( selectNextMonth() ) ); | 382 | mNavigator, SLOT( selectNextMonth() ) ); |
379 | 383 | ||
380 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 384 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
381 | mNavigator, SLOT( selectPrevious() ) ); | 385 | mNavigator, SLOT( selectPrevious() ) ); |
382 | connect( mDateNavigator, SIGNAL( goNext() ), | 386 | connect( mDateNavigator, SIGNAL( goNext() ), |
383 | mNavigator, SLOT( selectNext() ) ); | 387 | mNavigator, SLOT( selectNext() ) ); |
384 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 388 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
385 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 389 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
386 | 390 | ||
387 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 391 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
388 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 392 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
389 | #if 0 | 393 | #if 0 |
390 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 394 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
391 | SLOT( incidenceAdded( Incidence *) ) ); | 395 | SLOT( incidenceAdded( Incidence *) ) ); |
392 | #endif | 396 | #endif |
393 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 397 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
394 | 398 | ||
395 | connect( this, SIGNAL( configChanged() ), | 399 | connect( this, SIGNAL( configChanged() ), |
396 | mDateNavigator, SLOT( updateConfig() ) ); | 400 | mDateNavigator, SLOT( updateConfig() ) ); |
397 | 401 | ||
398 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 402 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
399 | SLOT( newTodo() ) ); | 403 | SLOT( newTodo() ) ); |
400 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 404 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
401 | SLOT( newSubTodo( Todo * ) ) ); | 405 | SLOT( newSubTodo( Todo * ) ) ); |
402 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 406 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
403 | SLOT( editTodo( Todo * ) ) ); | 407 | SLOT( editTodo( Todo * ) ) ); |
404 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 408 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
405 | SLOT( showTodo( Todo *) ) ); | 409 | SLOT( showTodo( Todo *) ) ); |
406 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 410 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
407 | SLOT( deleteTodo( Todo *) ) ); | 411 | SLOT( deleteTodo( Todo *) ) ); |
408 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 412 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
409 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 413 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
410 | SLOT( purgeCompleted() ) ); | 414 | SLOT( purgeCompleted() ) ); |
411 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 415 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
412 | SIGNAL( todoModified( Todo *, int ) ) ); | 416 | SIGNAL( todoModified( Todo *, int ) ) ); |
413 | 417 | ||
414 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 418 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
415 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 419 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
416 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 420 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
417 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 421 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
418 | 422 | ||
419 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 423 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
420 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 424 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
421 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 425 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
422 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 426 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
423 | 427 | ||
424 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 428 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
425 | this, SLOT ( todo_unsub( Todo * ) ) ); | 429 | this, SLOT ( todo_unsub( Todo * ) ) ); |
426 | 430 | ||
427 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 431 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
428 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 432 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
429 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 433 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
430 | SLOT( updateTodo( Todo *, int ) ) ); | 434 | SLOT( updateTodo( Todo *, int ) ) ); |
431 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 435 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
432 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 436 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
433 | 437 | ||
434 | 438 | ||
435 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 439 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
436 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 440 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
437 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 441 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
438 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 442 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
439 | 443 | ||
440 | 444 | ||
441 | 445 | ||
442 | 446 | ||
443 | 447 | ||
444 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 448 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
445 | SLOT(checkClipboard())); | 449 | SLOT(checkClipboard())); |
446 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 450 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
447 | SLOT( processTodoListSelection( Incidence * ) ) ); | 451 | SLOT( processTodoListSelection( Incidence * ) ) ); |
448 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 452 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
449 | 453 | ||
450 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 454 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
451 | 455 | ||
452 | mDateFrame = new QVBox(0,0,WType_Popup); | 456 | mDateFrame = new QVBox(0,0,WType_Popup); |
453 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 457 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
454 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 458 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
455 | mDateFrame->setLineWidth(3); | 459 | mDateFrame->setLineWidth(3); |
456 | mDateFrame->hide(); | 460 | mDateFrame->hide(); |
457 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 461 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
458 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 462 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
459 | 463 | ||
460 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 464 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
461 | 465 | ||
462 | mEventEditor = mDialogManager->getEventEditor(); | 466 | mEventEditor = mDialogManager->getEventEditor(); |
463 | mTodoEditor = mDialogManager->getTodoEditor(); | 467 | mTodoEditor = mDialogManager->getTodoEditor(); |
464 | 468 | ||
465 | mFlagEditDescription = false; | 469 | mFlagEditDescription = false; |
466 | 470 | ||
467 | mSuspendTimer = new QTimer( this ); | 471 | mSuspendTimer = new QTimer( this ); |
468 | mAlarmTimer = new QTimer( this ); | 472 | mAlarmTimer = new QTimer( this ); |
469 | mRecheckAlarmTimer = new QTimer( this ); | 473 | mRecheckAlarmTimer = new QTimer( this ); |
470 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 474 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
471 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 475 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
472 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 476 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
473 | mAlarmDialog = new AlarmDialog( this ); | 477 | mAlarmDialog = new AlarmDialog( this ); |
474 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 478 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
475 | mAlarmDialog->setServerNotification( false ); | 479 | mAlarmDialog->setServerNotification( false ); |
476 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 480 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
477 | 481 | ||
478 | 482 | ||
479 | #ifndef DESKTOP_VERSION | 483 | #ifndef DESKTOP_VERSION |
480 | //US listen for arriving address resultsets | 484 | //US listen for arriving address resultsets |
481 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 485 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
482 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 486 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
483 | #endif | 487 | #endif |
484 | mDateNavigator->setCalendar( mCalendar ); | 488 | mDateNavigator->setCalendar( mCalendar ); |
485 | } | 489 | } |
486 | 490 | ||
487 | 491 | ||
488 | CalendarView::~CalendarView() | 492 | CalendarView::~CalendarView() |
489 | { | 493 | { |
490 | // kdDebug() << "~CalendarView()" << endl; | 494 | // kdDebug() << "~CalendarView()" << endl; |
491 | //qDebug("CalendarView::~CalendarView() "); | 495 | //qDebug("CalendarView::~CalendarView() "); |
492 | delete mDialogManager; | 496 | delete mDialogManager; |
493 | delete mViewManager; | 497 | delete mViewManager; |
494 | delete mStorage; | 498 | delete mStorage; |
495 | delete mDateFrame ; | 499 | delete mDateFrame ; |
496 | delete beamDialog; | 500 | delete beamDialog; |
497 | delete mEventViewerDialog; | 501 | delete mEventViewerDialog; |
498 | //kdDebug() << "~CalendarView() done" << endl; | 502 | //kdDebug() << "~CalendarView() done" << endl; |
499 | } | 503 | } |
500 | 504 | ||
501 | void CalendarView::showDay( QDate d ) | 505 | void CalendarView::showDay( QDate d ) |
502 | { | 506 | { |
503 | dateNavigator()->blockSignals( true ); | 507 | dateNavigator()->blockSignals( true ); |
504 | dateNavigator()->selectDate( d ); | 508 | dateNavigator()->selectDate( d ); |
505 | dateNavigator()->blockSignals( false ); | 509 | dateNavigator()->blockSignals( false ); |
506 | mViewManager->showDayView(); | 510 | mViewManager->showDayView(); |
507 | //dateNavigator()->selectDate( d ); | 511 | //dateNavigator()->selectDate( d ); |
508 | } | 512 | } |
509 | void CalendarView::timerAlarm() | 513 | void CalendarView::timerAlarm() |
510 | { | 514 | { |
511 | //qDebug("CalendarView::timerAlarm() "); | 515 | //qDebug("CalendarView::timerAlarm() "); |
512 | computeAlarm(mAlarmNotification ); | 516 | computeAlarm(mAlarmNotification ); |
513 | } | 517 | } |
514 | 518 | ||
515 | void CalendarView::suspendAlarm() | 519 | void CalendarView::suspendAlarm() |
516 | { | 520 | { |
517 | //qDebug(" CalendarView::suspendAlarm() "); | 521 | //qDebug(" CalendarView::suspendAlarm() "); |
518 | computeAlarm(mSuspendAlarmNotification ); | 522 | computeAlarm(mSuspendAlarmNotification ); |
519 | 523 | ||
520 | } | 524 | } |
521 | 525 | ||
522 | void CalendarView::startAlarm( QString mess , QString filename) | 526 | void CalendarView::startAlarm( QString mess , QString filename) |
523 | { | 527 | { |
524 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 528 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
525 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 529 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
526 | 530 | ||
527 | } | 531 | } |
528 | 532 | ||
529 | void CalendarView::checkNextTimerAlarm() | 533 | void CalendarView::checkNextTimerAlarm() |
530 | { | 534 | { |
531 | mCalendar->checkAlarmForIncidence( 0, true ); | 535 | mCalendar->checkAlarmForIncidence( 0, true ); |
532 | } | 536 | } |
533 | 537 | ||
534 | void CalendarView::computeAlarm( QString msg ) | 538 | void CalendarView::computeAlarm( QString msg ) |
535 | { | 539 | { |
536 | 540 | ||
537 | QString mess = msg; | 541 | QString mess = msg; |
538 | QString mAlarmMessage = mess.mid( 9 ); | 542 | QString mAlarmMessage = mess.mid( 9 ); |
539 | QString filename = MainWindow::resourcePath(); | 543 | QString filename = MainWindow::resourcePath(); |
540 | filename += "koalarm.wav"; | 544 | filename += "koalarm.wav"; |
541 | QString tempfilename; | 545 | QString tempfilename; |
542 | if ( mess.left( 13 ) == "suspend_alarm") { | 546 | if ( mess.left( 13 ) == "suspend_alarm") { |
543 | bool error = false; | 547 | bool error = false; |
544 | int len = mess.mid( 13 ).find("+++"); | 548 | int len = mess.mid( 13 ).find("+++"); |
545 | if ( len < 2 ) | 549 | if ( len < 2 ) |
546 | error = true; | 550 | error = true; |
547 | else { | 551 | else { |
548 | tempfilename = mess.mid( 13, len ); | 552 | tempfilename = mess.mid( 13, len ); |
549 | if ( !QFile::exists( tempfilename ) ) | 553 | if ( !QFile::exists( tempfilename ) ) |
550 | error = true; | 554 | error = true; |
551 | } | 555 | } |
552 | if ( ! error ) { | 556 | if ( ! error ) { |
553 | filename = tempfilename; | 557 | filename = tempfilename; |
554 | } | 558 | } |
555 | mAlarmMessage = mess.mid( 13+len+3 ); | 559 | mAlarmMessage = mess.mid( 13+len+3 ); |
556 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 560 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
557 | startAlarm( mAlarmMessage, filename); | 561 | startAlarm( mAlarmMessage, filename); |
558 | return; | 562 | return; |
559 | } | 563 | } |
560 | if ( mess.left( 11 ) == "timer_alarm") { | 564 | if ( mess.left( 11 ) == "timer_alarm") { |
561 | //mTimerTime = 0; | 565 | //mTimerTime = 0; |
562 | startAlarm( mess.mid( 11 ), filename ); | 566 | startAlarm( mess.mid( 11 ), filename ); |
563 | return; | 567 | return; |
564 | } | 568 | } |
565 | if ( mess.left( 10 ) == "proc_alarm") { | 569 | if ( mess.left( 10 ) == "proc_alarm") { |
566 | bool error = false; | 570 | bool error = false; |
567 | int len = mess.mid( 10 ).find("+++"); | 571 | int len = mess.mid( 10 ).find("+++"); |
568 | if ( len < 2 ) | 572 | if ( len < 2 ) |
569 | error = true; | 573 | error = true; |
570 | else { | 574 | else { |
571 | tempfilename = mess.mid( 10, len ); | 575 | tempfilename = mess.mid( 10, len ); |
572 | if ( !QFile::exists( tempfilename ) ) | 576 | if ( !QFile::exists( tempfilename ) ) |
573 | error = true; | 577 | error = true; |
574 | } | 578 | } |
575 | if ( error ) { | 579 | if ( error ) { |
576 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 580 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
577 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 581 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
578 | } else { | 582 | } else { |
579 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 583 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
580 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 584 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
581 | #ifndef _WIN32_ | 585 | #ifndef _WIN32_ |
582 | if ( vfork () == 0 ) { | 586 | if ( vfork () == 0 ) { |
583 | execl ( tempfilename.latin1(), 0 ); | 587 | execl ( tempfilename.latin1(), 0 ); |
584 | return; | 588 | return; |
585 | } | 589 | } |
586 | #else | 590 | #else |
587 | QProcess* p = new QProcess(); | 591 | QProcess* p = new QProcess(); |
588 | p->addArgument( tempfilename.latin1() ); | 592 | p->addArgument( tempfilename.latin1() ); |
589 | p->start(); | 593 | p->start(); |
590 | return; | 594 | return; |
591 | #endif | 595 | #endif |
592 | 596 | ||
593 | return; | 597 | return; |
594 | } | 598 | } |
595 | 599 | ||
596 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 600 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
597 | } | 601 | } |
598 | if ( mess.left( 11 ) == "audio_alarm") { | 602 | if ( mess.left( 11 ) == "audio_alarm") { |
599 | bool error = false; | 603 | bool error = false; |
600 | int len = mess.mid( 11 ).find("+++"); | 604 | int len = mess.mid( 11 ).find("+++"); |
601 | if ( len < 2 ) | 605 | if ( len < 2 ) |
602 | error = true; | 606 | error = true; |
603 | else { | 607 | else { |
604 | tempfilename = mess.mid( 11, len ); | 608 | tempfilename = mess.mid( 11, len ); |
605 | if ( !QFile::exists( tempfilename ) ) | 609 | if ( !QFile::exists( tempfilename ) ) |
606 | error = true; | 610 | error = true; |
607 | } | 611 | } |
608 | if ( ! error ) { | 612 | if ( ! error ) { |
609 | filename = tempfilename; | 613 | filename = tempfilename; |
610 | } | 614 | } |
611 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 615 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
612 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 616 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
613 | } | 617 | } |
614 | if ( mess.left( 9 ) == "cal_alarm") { | 618 | if ( mess.left( 9 ) == "cal_alarm") { |
615 | mAlarmMessage = mess.mid( 9 ) ; | 619 | mAlarmMessage = mess.mid( 9 ) ; |
616 | } | 620 | } |
617 | 621 | ||
618 | startAlarm( mAlarmMessage, filename ); | 622 | startAlarm( mAlarmMessage, filename ); |
619 | 623 | ||
620 | 624 | ||
621 | } | 625 | } |
622 | 626 | ||
623 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 627 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
624 | { | 628 | { |
625 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 629 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
626 | 630 | ||
627 | mSuspendAlarmNotification = noti; | 631 | mSuspendAlarmNotification = noti; |
628 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 632 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
629 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 633 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
630 | mSuspendTimer->start( ms , true ); | 634 | mSuspendTimer->start( ms , true ); |
631 | 635 | ||
632 | } | 636 | } |
633 | 637 | ||
634 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 638 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
635 | { | 639 | { |
636 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 640 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
637 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 641 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
638 | #ifndef DESKTOP_VERSION | 642 | #ifndef DESKTOP_VERSION |
639 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 643 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
640 | #endif | 644 | #endif |
641 | return; | 645 | return; |
642 | } | 646 | } |
643 | int maxSec; | 647 | int maxSec; |
644 | //maxSec = 5; //testing only | 648 | //maxSec = 5; //testing only |
645 | maxSec = 86400+3600; // one day+1hour | 649 | maxSec = 86400+3600; // one day+1hour |
646 | mAlarmNotification = noti; | 650 | mAlarmNotification = noti; |
647 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 651 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
648 | if ( sec > maxSec ) { | 652 | if ( sec > maxSec ) { |
649 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 653 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
650 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 654 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
651 | return; | 655 | return; |
652 | } else { | 656 | } else { |
653 | mRecheckAlarmTimer->stop(); | 657 | mRecheckAlarmTimer->stop(); |
654 | } | 658 | } |
655 | //qDebug("Alarm timer started with secs: %d ", sec); | 659 | //qDebug("Alarm timer started with secs: %d ", sec); |
656 | mAlarmTimer->start( sec *1000 , true ); | 660 | mAlarmTimer->start( sec *1000 , true ); |
657 | 661 | ||
658 | } | 662 | } |
659 | // called by mRecheckAlarmTimer to get next alarm | 663 | // called by mRecheckAlarmTimer to get next alarm |
660 | // we need this, because a QTimer has only a max range of 25 days | 664 | // we need this, because a QTimer has only a max range of 25 days |
661 | void CalendarView::recheckTimerAlarm() | 665 | void CalendarView::recheckTimerAlarm() |
662 | { | 666 | { |
663 | mAlarmTimer->stop(); | 667 | mAlarmTimer->stop(); |
664 | mRecheckAlarmTimer->stop(); | 668 | mRecheckAlarmTimer->stop(); |
665 | mCalendar->checkAlarmForIncidence( 0, true ); | 669 | mCalendar->checkAlarmForIncidence( 0, true ); |
666 | } | 670 | } |
667 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 671 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
668 | { | 672 | { |
669 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 673 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
670 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 674 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
671 | #ifndef DESKTOP_VERSION | 675 | #ifndef DESKTOP_VERSION |
672 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 676 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
673 | #endif | 677 | #endif |
674 | return; | 678 | return; |
675 | } | 679 | } |
676 | mAlarmTimer->stop(); | 680 | mAlarmTimer->stop(); |
677 | } | 681 | } |
678 | void CalendarView::selectWeekNum ( int num ) | 682 | void CalendarView::selectWeekNum ( int num ) |
679 | { | 683 | { |
680 | dateNavigator()->blockSignals( true ); | 684 | dateNavigator()->blockSignals( true ); |
681 | dateNavigator()->selectWeek( num ); | 685 | dateNavigator()->selectWeek( num ); |
682 | dateNavigator()->blockSignals( false ); | 686 | dateNavigator()->blockSignals( false ); |
683 | mViewManager->showWeekView(); | 687 | mViewManager->showWeekView(); |
684 | } | 688 | } |
685 | KOViewManager *CalendarView::viewManager() | 689 | KOViewManager *CalendarView::viewManager() |
686 | { | 690 | { |
687 | return mViewManager; | 691 | return mViewManager; |
688 | } | 692 | } |
689 | 693 | ||
690 | KODialogManager *CalendarView::dialogManager() | 694 | KODialogManager *CalendarView::dialogManager() |
691 | { | 695 | { |
692 | return mDialogManager; | 696 | return mDialogManager; |
693 | } | 697 | } |
694 | 698 | ||
695 | QDate CalendarView::startDate() | 699 | QDate CalendarView::startDate() |
696 | { | 700 | { |
697 | DateList dates = mNavigator->selectedDates(); | 701 | DateList dates = mNavigator->selectedDates(); |
698 | 702 | ||
699 | return dates.first(); | 703 | return dates.first(); |
700 | } | 704 | } |
701 | 705 | ||
702 | QDate CalendarView::endDate() | 706 | QDate CalendarView::endDate() |
703 | { | 707 | { |
704 | DateList dates = mNavigator->selectedDates(); | 708 | DateList dates = mNavigator->selectedDates(); |
705 | 709 | ||
706 | return dates.last(); | 710 | return dates.last(); |
707 | } | 711 | } |
708 | 712 | ||
709 | 713 | ||
710 | void CalendarView::createPrinter() | 714 | void CalendarView::createPrinter() |
711 | { | 715 | { |
712 | #ifndef KORG_NOPRINTER | 716 | #ifndef KORG_NOPRINTER |
713 | if (!mCalPrinter) { | 717 | if (!mCalPrinter) { |
714 | mCalPrinter = new CalPrinter(this, mCalendar); | 718 | mCalPrinter = new CalPrinter(this, mCalendar); |
715 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 719 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
716 | } | 720 | } |
717 | #endif | 721 | #endif |
718 | } | 722 | } |
719 | 723 | ||
720 | 724 | ||
721 | //KOPrefs::instance()->mWriteBackFile | 725 | //KOPrefs::instance()->mWriteBackFile |
722 | //KOPrefs::instance()->mWriteBackExistingOnly | 726 | //KOPrefs::instance()->mWriteBackExistingOnly |
723 | 727 | ||
724 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 728 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
725 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 729 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
726 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 730 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
727 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 731 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
728 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 732 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
729 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 733 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
730 | 734 | ||
731 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 735 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
732 | { | 736 | { |
733 | 737 | ||
734 | // 0 equal | 738 | // 0 equal |
735 | // 1 take local | 739 | // 1 take local |
736 | // 2 take remote | 740 | // 2 take remote |
737 | // 3 cancel | 741 | // 3 cancel |
738 | QDateTime lastSync = mLastCalendarSync; | 742 | QDateTime lastSync = mLastCalendarSync; |
739 | QDateTime localMod = local->lastModified(); | 743 | QDateTime localMod = local->lastModified(); |
740 | QDateTime remoteMod = remote->lastModified(); | 744 | QDateTime remoteMod = remote->lastModified(); |
741 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 745 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
742 | bool remCh, locCh; | 746 | bool remCh, locCh; |
743 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 747 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
744 | //if ( remCh ) | 748 | //if ( remCh ) |
745 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 749 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
746 | locCh = ( localMod > mLastCalendarSync ); | 750 | locCh = ( localMod > mLastCalendarSync ); |
747 | if ( !remCh && ! locCh ) { | 751 | if ( !remCh && ! locCh ) { |
748 | //qDebug("both not changed "); | 752 | //qDebug("both not changed "); |
749 | lastSync = localMod.addDays(1); | 753 | lastSync = localMod.addDays(1); |
750 | if ( mode <= SYNC_PREF_ASK ) | 754 | if ( mode <= SYNC_PREF_ASK ) |
751 | return 0; | 755 | return 0; |
752 | } else { | 756 | } else { |
753 | if ( locCh ) { | 757 | if ( locCh ) { |
754 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 758 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
755 | lastSync = localMod.addDays( -1 ); | 759 | lastSync = localMod.addDays( -1 ); |
756 | if ( !remCh ) | 760 | if ( !remCh ) |
757 | remoteMod = ( lastSync.addDays( -1 ) ); | 761 | remoteMod = ( lastSync.addDays( -1 ) ); |
758 | } else { | 762 | } else { |
759 | //qDebug(" not loc changed "); | 763 | //qDebug(" not loc changed "); |
760 | lastSync = localMod.addDays( 1 ); | 764 | lastSync = localMod.addDays( 1 ); |
761 | if ( remCh ) | 765 | if ( remCh ) |
762 | remoteMod =( lastSync.addDays( 1 ) ); | 766 | remoteMod =( lastSync.addDays( 1 ) ); |
763 | 767 | ||
764 | } | 768 | } |
765 | } | 769 | } |
766 | full = true; | 770 | full = true; |
767 | if ( mode < SYNC_PREF_ASK ) | 771 | if ( mode < SYNC_PREF_ASK ) |
768 | mode = SYNC_PREF_ASK; | 772 | mode = SYNC_PREF_ASK; |
769 | } else { | 773 | } else { |
770 | if ( localMod == remoteMod ) | 774 | if ( localMod == remoteMod ) |
771 | // if ( local->revision() == remote->revision() ) | 775 | // if ( local->revision() == remote->revision() ) |
772 | return 0; | 776 | return 0; |
773 | 777 | ||
774 | } | 778 | } |
775 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 779 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
776 | 780 | ||
777 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 781 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
778 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 782 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
779 | //full = true; //debug only | 783 | //full = true; //debug only |
780 | if ( full ) { | 784 | if ( full ) { |
781 | bool equ = false; | 785 | bool equ = false; |
782 | if ( local->type() == "Event" ) { | 786 | if ( local->type() == "Event" ) { |
783 | equ = (*((Event*) local) == *((Event*) remote)); | 787 | equ = (*((Event*) local) == *((Event*) remote)); |
784 | } | 788 | } |
785 | else if ( local->type() =="Todo" ) | 789 | else if ( local->type() =="Todo" ) |
786 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 790 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
787 | else if ( local->type() =="Journal" ) | 791 | else if ( local->type() =="Journal" ) |
788 | equ = (*((Journal*) local) == *((Journal*) remote)); | 792 | equ = (*((Journal*) local) == *((Journal*) remote)); |
789 | if ( equ ) { | 793 | if ( equ ) { |
790 | //qDebug("equal "); | 794 | //qDebug("equal "); |
791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 795 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
792 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 796 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
793 | } | 797 | } |
794 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 798 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
795 | return 0; | 799 | return 0; |
796 | 800 | ||
797 | }//else //debug only | 801 | }//else //debug only |
798 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 802 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
799 | } | 803 | } |
800 | int result; | 804 | int result; |
801 | bool localIsNew; | 805 | bool localIsNew; |
802 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 806 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
803 | 807 | ||
804 | if ( full && mode < SYNC_PREF_NEWEST ) | 808 | if ( full && mode < SYNC_PREF_NEWEST ) |
805 | mode = SYNC_PREF_ASK; | 809 | mode = SYNC_PREF_ASK; |
806 | 810 | ||
807 | switch( mode ) { | 811 | switch( mode ) { |
808 | case SYNC_PREF_LOCAL: | 812 | case SYNC_PREF_LOCAL: |
809 | if ( lastSync > remoteMod ) | 813 | if ( lastSync > remoteMod ) |
810 | return 1; | 814 | return 1; |
811 | if ( lastSync > localMod ) | 815 | if ( lastSync > localMod ) |
812 | return 2; | 816 | return 2; |
813 | return 1; | 817 | return 1; |
814 | break; | 818 | break; |
815 | case SYNC_PREF_REMOTE: | 819 | case SYNC_PREF_REMOTE: |
816 | if ( lastSync > remoteMod ) | 820 | if ( lastSync > remoteMod ) |
817 | return 1; | 821 | return 1; |
818 | if ( lastSync > localMod ) | 822 | if ( lastSync > localMod ) |
819 | return 2; | 823 | return 2; |
820 | return 2; | 824 | return 2; |
821 | break; | 825 | break; |
822 | case SYNC_PREF_NEWEST: | 826 | case SYNC_PREF_NEWEST: |
823 | if ( localMod > remoteMod ) | 827 | if ( localMod > remoteMod ) |
824 | return 1; | 828 | return 1; |
825 | else | 829 | else |
826 | return 2; | 830 | return 2; |
827 | break; | 831 | break; |
828 | case SYNC_PREF_ASK: | 832 | case SYNC_PREF_ASK: |
829 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 833 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
830 | if ( lastSync > remoteMod ) | 834 | if ( lastSync > remoteMod ) |
831 | return 1; | 835 | return 1; |
832 | if ( lastSync > localMod ) | 836 | if ( lastSync > localMod ) |
833 | return 2; | 837 | return 2; |
834 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 838 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
835 | localIsNew = localMod >= remoteMod; | 839 | localIsNew = localMod >= remoteMod; |
836 | if ( localIsNew ) | 840 | if ( localIsNew ) |
837 | getEventViewerDialog()->setColorMode( 1 ); | 841 | getEventViewerDialog()->setColorMode( 1 ); |
838 | else | 842 | else |
839 | getEventViewerDialog()->setColorMode( 2 ); | 843 | getEventViewerDialog()->setColorMode( 2 ); |
840 | getEventViewerDialog()->setIncidence(local); | 844 | getEventViewerDialog()->setIncidence(local); |
841 | if ( localIsNew ) | 845 | if ( localIsNew ) |
842 | getEventViewerDialog()->setColorMode( 2 ); | 846 | getEventViewerDialog()->setColorMode( 2 ); |
843 | else | 847 | else |
844 | getEventViewerDialog()->setColorMode( 1 ); | 848 | getEventViewerDialog()->setColorMode( 1 ); |
845 | getEventViewerDialog()->addIncidence(remote); | 849 | getEventViewerDialog()->addIncidence(remote); |
846 | getEventViewerDialog()->setColorMode( 0 ); | 850 | getEventViewerDialog()->setColorMode( 0 ); |
847 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 851 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
848 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 852 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
849 | getEventViewerDialog()->showMe(); | 853 | getEventViewerDialog()->showMe(); |
850 | result = getEventViewerDialog()->executeS( localIsNew ); | 854 | result = getEventViewerDialog()->executeS( localIsNew ); |
851 | return result; | 855 | return result; |
852 | 856 | ||
853 | break; | 857 | break; |
854 | case SYNC_PREF_FORCE_LOCAL: | 858 | case SYNC_PREF_FORCE_LOCAL: |
855 | return 1; | 859 | return 1; |
856 | break; | 860 | break; |
857 | case SYNC_PREF_FORCE_REMOTE: | 861 | case SYNC_PREF_FORCE_REMOTE: |
858 | return 2; | 862 | return 2; |
859 | break; | 863 | break; |
860 | 864 | ||
861 | default: | 865 | default: |
862 | // SYNC_PREF_TAKE_BOTH not implemented | 866 | // SYNC_PREF_TAKE_BOTH not implemented |
863 | break; | 867 | break; |
864 | } | 868 | } |
865 | return 0; | 869 | return 0; |
866 | } | 870 | } |
867 | Event* CalendarView::getLastSyncEvent() | 871 | Event* CalendarView::getLastSyncEvent() |
868 | { | 872 | { |
869 | Event* lse; | 873 | Event* lse; |
870 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 874 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
871 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 875 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
872 | if (!lse) { | 876 | if (!lse) { |
873 | lse = new Event(); | 877 | lse = new Event(); |
874 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 878 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
875 | QString sum = ""; | 879 | QString sum = ""; |
876 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 880 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
877 | sum = "E: "; | 881 | sum = "E: "; |
878 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 882 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
879 | lse->setDtStart( mLastCalendarSync ); | 883 | lse->setDtStart( mLastCalendarSync ); |
880 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 884 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
881 | lse->setCategories( i18n("SyncEvent") ); | 885 | lse->setCategories( i18n("SyncEvent") ); |
882 | lse->setReadOnly( true ); | 886 | lse->setReadOnly( true ); |
883 | mCalendar->addEvent( lse ); | 887 | mCalendar->addEvent( lse ); |
884 | } | 888 | } |
885 | 889 | ||
886 | return lse; | 890 | return lse; |
887 | 891 | ||
888 | } | 892 | } |
889 | 893 | ||
890 | // we check, if the to delete event has a id for a profile | 894 | // we check, if the to delete event has a id for a profile |
891 | // if yes, we set this id in the profile to delete | 895 | // if yes, we set this id in the profile to delete |
892 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 896 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
893 | { | 897 | { |
894 | if ( lastSync.count() == 0 ) { | 898 | if ( lastSync.count() == 0 ) { |
895 | //qDebug(" lastSync.count() == 0"); | 899 | //qDebug(" lastSync.count() == 0"); |
896 | return; | 900 | return; |
897 | } | 901 | } |
898 | if ( toDelete->type() == "Journal" ) | 902 | if ( toDelete->type() == "Journal" ) |
899 | return; | 903 | return; |
900 | 904 | ||
901 | Event* eve = lastSync.first(); | 905 | Event* eve = lastSync.first(); |
902 | 906 | ||
903 | while ( eve ) { | 907 | while ( eve ) { |
904 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 908 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
905 | if ( !id.isEmpty() ) { | 909 | if ( !id.isEmpty() ) { |
906 | QString des = eve->description(); | 910 | QString des = eve->description(); |
907 | QString pref = "e"; | 911 | QString pref = "e"; |
908 | if ( toDelete->type() == "Todo" ) | 912 | if ( toDelete->type() == "Todo" ) |
909 | pref = "t"; | 913 | pref = "t"; |
910 | des += pref+ id + ","; | 914 | des += pref+ id + ","; |
911 | eve->setReadOnly( false ); | 915 | eve->setReadOnly( false ); |
912 | eve->setDescription( des ); | 916 | eve->setDescription( des ); |
913 | //qDebug("setdes %s ", des.latin1()); | 917 | //qDebug("setdes %s ", des.latin1()); |
914 | eve->setReadOnly( true ); | 918 | eve->setReadOnly( true ); |
915 | } | 919 | } |
916 | eve = lastSync.next(); | 920 | eve = lastSync.next(); |
917 | } | 921 | } |
918 | 922 | ||
919 | } | 923 | } |
920 | void CalendarView::checkExternalId( Incidence * inc ) | 924 | void CalendarView::checkExternalId( Incidence * inc ) |
921 | { | 925 | { |
922 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 926 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
923 | checkExternSyncEvent( lastSync, inc ); | 927 | checkExternSyncEvent( lastSync, inc ); |
924 | 928 | ||
925 | } | 929 | } |
926 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 930 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
927 | { | 931 | { |
928 | bool syncOK = true; | 932 | bool syncOK = true; |
929 | int addedEvent = 0; | 933 | int addedEvent = 0; |
930 | int addedEventR = 0; | 934 | int addedEventR = 0; |
931 | int deletedEventR = 0; | 935 | int deletedEventR = 0; |
932 | int deletedEventL = 0; | 936 | int deletedEventL = 0; |
933 | int changedLocal = 0; | 937 | int changedLocal = 0; |
934 | int changedRemote = 0; | 938 | int changedRemote = 0; |
935 | int filteredIN = 0; | 939 | int filteredIN = 0; |
936 | int filteredOUT = 0; | 940 | int filteredOUT = 0; |
937 | //QPtrList<Event> el = local->rawEvents(); | 941 | //QPtrList<Event> el = local->rawEvents(); |
938 | Event* eventR; | 942 | Event* eventR; |
939 | QString uid; | 943 | QString uid; |
940 | int take; | 944 | int take; |
941 | Event* eventL; | 945 | Event* eventL; |
942 | Event* eventRSync; | 946 | Event* eventRSync; |
943 | Event* eventLSync; | 947 | Event* eventLSync; |
944 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 948 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
945 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 949 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
946 | bool fullDateRange = false; | 950 | bool fullDateRange = false; |
947 | local->resetTempSyncStat(); | 951 | local->resetTempSyncStat(); |
948 | mLastCalendarSync = QDateTime::currentDateTime(); | 952 | mLastCalendarSync = QDateTime::currentDateTime(); |
949 | if ( mSyncManager->syncWithDesktop() ) { | 953 | if ( mSyncManager->syncWithDesktop() ) { |
950 | remote->resetPilotStat(1); | 954 | remote->resetPilotStat(1); |
951 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 955 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
952 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 956 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
953 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 957 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
954 | } else { | 958 | } else { |
955 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 959 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
956 | } | 960 | } |
957 | } | 961 | } |
958 | QDateTime modifiedCalendar = mLastCalendarSync; | 962 | QDateTime modifiedCalendar = mLastCalendarSync; |
959 | eventLSync = getLastSyncEvent(); | 963 | eventLSync = getLastSyncEvent(); |
960 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 964 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
961 | if ( eventR ) { | 965 | if ( eventR ) { |
962 | eventRSync = (Event*) eventR->clone(); | 966 | eventRSync = (Event*) eventR->clone(); |
963 | remote->deleteEvent(eventR ); | 967 | remote->deleteEvent(eventR ); |
964 | 968 | ||
965 | } else { | 969 | } else { |
966 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 970 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
967 | eventRSync = (Event*)eventLSync->clone(); | 971 | eventRSync = (Event*)eventLSync->clone(); |
968 | } else { | 972 | } else { |
969 | fullDateRange = true; | 973 | fullDateRange = true; |
970 | eventRSync = new Event(); | 974 | eventRSync = new Event(); |
971 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 975 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
972 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 976 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
973 | eventRSync->setDtStart( mLastCalendarSync ); | 977 | eventRSync->setDtStart( mLastCalendarSync ); |
974 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 978 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
975 | eventRSync->setCategories( i18n("SyncEvent") ); | 979 | eventRSync->setCategories( i18n("SyncEvent") ); |
976 | } | 980 | } |
977 | } | 981 | } |
978 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 982 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
979 | fullDateRange = true; | 983 | fullDateRange = true; |
980 | 984 | ||
981 | if ( ! fullDateRange ) { | 985 | if ( ! fullDateRange ) { |
982 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 986 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
983 | 987 | ||
984 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 988 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
985 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 989 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
986 | fullDateRange = true; | 990 | fullDateRange = true; |
987 | } | 991 | } |
988 | } | 992 | } |
989 | if ( mSyncManager->syncWithDesktop() ) { | 993 | if ( mSyncManager->syncWithDesktop() ) { |
990 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 994 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
991 | } | 995 | } |
992 | if ( fullDateRange ) | 996 | if ( fullDateRange ) |
993 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 997 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
994 | else | 998 | else |
995 | mLastCalendarSync = eventLSync->dtStart(); | 999 | mLastCalendarSync = eventLSync->dtStart(); |
996 | // for resyncing if own file has changed | 1000 | // for resyncing if own file has changed |
997 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1001 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
998 | mLastCalendarSync = loadedFileVersion; | 1002 | mLastCalendarSync = loadedFileVersion; |
999 | //qDebug("setting mLastCalendarSync "); | 1003 | //qDebug("setting mLastCalendarSync "); |
1000 | } | 1004 | } |
1001 | //qDebug("*************************** "); | 1005 | //qDebug("*************************** "); |
1002 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1006 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1003 | QPtrList<Incidence> er = remote->rawIncidences(); | 1007 | QPtrList<Incidence> er = remote->rawIncidences(); |
1004 | Incidence* inR = er.first(); | 1008 | Incidence* inR = er.first(); |
1005 | Incidence* inL; | 1009 | Incidence* inL; |
1006 | QProgressBar bar( er.count(),0 ); | 1010 | QProgressBar bar( er.count(),0 ); |
1007 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1011 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1008 | 1012 | ||
1009 | // ************** setting up filter ************* | 1013 | // ************** setting up filter ************* |
1010 | CalFilter *filterIN = 0; | 1014 | CalFilter *filterIN = 0; |
1011 | CalFilter *filterOUT = 0; | 1015 | CalFilter *filterOUT = 0; |
1012 | CalFilter *filter = mFilters.first(); | 1016 | CalFilter *filter = mFilters.first(); |
1013 | while(filter) { | 1017 | while(filter) { |
1014 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1018 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1015 | filterIN = filter; | 1019 | filterIN = filter; |
1016 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1020 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1017 | filterOUT = filter; | 1021 | filterOUT = filter; |
1018 | filter = mFilters.next(); | 1022 | filter = mFilters.next(); |
1019 | } | 1023 | } |
1020 | int w = 300; | 1024 | int w = 300; |
1021 | if ( QApplication::desktop()->width() < 320 ) | 1025 | if ( QApplication::desktop()->width() < 320 ) |
1022 | w = 220; | 1026 | w = 220; |
1023 | int h = bar.sizeHint().height() ; | 1027 | int h = bar.sizeHint().height() ; |
1024 | int dw = QApplication::desktop()->width(); | 1028 | int dw = QApplication::desktop()->width(); |
1025 | int dh = QApplication::desktop()->height(); | 1029 | int dh = QApplication::desktop()->height(); |
1026 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1030 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1027 | bar.show(); | 1031 | bar.show(); |
1028 | int modulo = (er.count()/10)+1; | 1032 | int modulo = (er.count()/10)+1; |
1029 | int incCounter = 0; | 1033 | int incCounter = 0; |
1030 | while ( inR ) { | 1034 | while ( inR ) { |
1031 | if ( ! bar.isVisible() ) | 1035 | if ( ! bar.isVisible() ) |
1032 | return false; | 1036 | return false; |
1033 | if ( incCounter % modulo == 0 ) | 1037 | if ( incCounter % modulo == 0 ) |
1034 | bar.setProgress( incCounter ); | 1038 | bar.setProgress( incCounter ); |
1035 | ++incCounter; | 1039 | ++incCounter; |
1036 | uid = inR->uid(); | 1040 | uid = inR->uid(); |
1037 | bool skipIncidence = false; | 1041 | bool skipIncidence = false; |
1038 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1042 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1039 | skipIncidence = true; | 1043 | skipIncidence = true; |
1040 | QString idS; | 1044 | QString idS; |
1041 | qApp->processEvents(); | 1045 | qApp->processEvents(); |
1042 | if ( !skipIncidence ) { | 1046 | if ( !skipIncidence ) { |
1043 | inL = local->incidence( uid ); | 1047 | inL = local->incidence( uid ); |
1044 | if ( inL ) { // maybe conflict - same uid in both calendars | 1048 | if ( inL ) { // maybe conflict - same uid in both calendars |
1045 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1049 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1046 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1050 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1047 | if ( take == 3 ) | 1051 | if ( take == 3 ) |
1048 | return false; | 1052 | return false; |
1049 | if ( take == 1 ) {// take local ********************** | 1053 | if ( take == 1 ) {// take local ********************** |
1050 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1054 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1051 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1055 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1052 | else | 1056 | else |
1053 | idS = inR->IDStr(); | 1057 | idS = inR->IDStr(); |
1054 | remote->deleteIncidence( inR ); | 1058 | remote->deleteIncidence( inR ); |
1055 | inR = inL->clone(); | 1059 | inR = inL->clone(); |
1056 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1060 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1057 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1061 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1058 | inR->setIDStr( idS ); | 1062 | inR->setIDStr( idS ); |
1059 | remote->addIncidence( inR ); | 1063 | remote->addIncidence( inR ); |
1060 | if ( mSyncManager->syncWithDesktop() ) | 1064 | if ( mSyncManager->syncWithDesktop() ) |
1061 | inR->setPilotId( 2 ); | 1065 | inR->setPilotId( 2 ); |
1062 | ++changedRemote; | 1066 | ++changedRemote; |
1063 | } else {// take remote ********************** | 1067 | } else {// take remote ********************** |
1064 | idS = inL->IDStr(); | 1068 | idS = inL->IDStr(); |
1065 | int pid = inL->pilotId(); | 1069 | int pid = inL->pilotId(); |
1066 | local->deleteIncidence( inL ); | 1070 | local->deleteIncidence( inL ); |
1067 | inL = inR->clone(); | 1071 | inL = inR->clone(); |
1068 | if ( mSyncManager->syncWithDesktop() ) | 1072 | if ( mSyncManager->syncWithDesktop() ) |
1069 | inL->setPilotId( pid ); | 1073 | inL->setPilotId( pid ); |
1070 | inL->setIDStr( idS ); | 1074 | inL->setIDStr( idS ); |
1071 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1075 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1072 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1076 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1073 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1077 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1074 | } | 1078 | } |
1075 | local->addIncidence( inL ); | 1079 | local->addIncidence( inL ); |
1076 | ++changedLocal; | 1080 | ++changedLocal; |
1077 | } | 1081 | } |
1078 | } | 1082 | } |
1079 | } else { // no conflict ********** add or delete remote | 1083 | } else { // no conflict ********** add or delete remote |
1080 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1084 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1081 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1085 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1082 | QString des = eventLSync->description(); | 1086 | QString des = eventLSync->description(); |
1083 | QString pref = "e"; | 1087 | QString pref = "e"; |
1084 | if ( inR->type() == "Todo" ) | 1088 | if ( inR->type() == "Todo" ) |
1085 | pref = "t"; | 1089 | pref = "t"; |
1086 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1090 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1087 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1091 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1088 | //remote->deleteIncidence( inR ); | 1092 | //remote->deleteIncidence( inR ); |
1089 | ++deletedEventR; | 1093 | ++deletedEventR; |
1090 | } else { | 1094 | } else { |
1091 | inR->setLastModified( modifiedCalendar ); | 1095 | inR->setLastModified( modifiedCalendar ); |
1092 | inL = inR->clone(); | 1096 | inL = inR->clone(); |
1093 | inL->setIDStr( ":" ); | 1097 | inL->setIDStr( ":" ); |
1094 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1098 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1095 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1099 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1096 | local->addIncidence( inL ); | 1100 | local->addIncidence( inL ); |
1097 | ++addedEvent; | 1101 | ++addedEvent; |
1098 | 1102 | ||
1099 | } | 1103 | } |
1100 | } else { | 1104 | } else { |
1101 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1105 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1102 | inR->setLastModified( modifiedCalendar ); | 1106 | inR->setLastModified( modifiedCalendar ); |
1103 | inL = inR->clone(); | 1107 | inL = inR->clone(); |
1104 | inL->setIDStr( ":" ); | 1108 | inL->setIDStr( ":" ); |
1105 | local->addIncidence( inL ); | 1109 | local->addIncidence( inL ); |
1106 | ++addedEvent; | 1110 | ++addedEvent; |
1107 | 1111 | ||
1108 | } else { | 1112 | } else { |
1109 | checkExternSyncEvent(eventRSyncSharp, inR); | 1113 | checkExternSyncEvent(eventRSyncSharp, inR); |
1110 | remote->deleteIncidence( inR ); | 1114 | remote->deleteIncidence( inR ); |
1111 | ++deletedEventR; | 1115 | ++deletedEventR; |
1112 | } | 1116 | } |
1113 | } | 1117 | } |
1114 | } else { | 1118 | } else { |
1115 | ++filteredIN; | 1119 | ++filteredIN; |
1116 | } | 1120 | } |
1117 | } | 1121 | } |
1118 | } | 1122 | } |
1119 | inR = er.next(); | 1123 | inR = er.next(); |
1120 | } | 1124 | } |
1121 | QPtrList<Incidence> el = local->rawIncidences(); | 1125 | QPtrList<Incidence> el = local->rawIncidences(); |
1122 | inL = el.first(); | 1126 | inL = el.first(); |
1123 | modulo = (el.count()/10)+1; | 1127 | modulo = (el.count()/10)+1; |
1124 | bar.setCaption (i18n("Add / remove events") ); | 1128 | bar.setCaption (i18n("Add / remove events") ); |
1125 | bar.setTotalSteps ( el.count() ) ; | 1129 | bar.setTotalSteps ( el.count() ) ; |
1126 | bar.show(); | 1130 | bar.show(); |
1127 | incCounter = 0; | 1131 | incCounter = 0; |
1128 | 1132 | ||
1129 | while ( inL ) { | 1133 | while ( inL ) { |
1130 | 1134 | ||
1131 | qApp->processEvents(); | 1135 | qApp->processEvents(); |
1132 | if ( ! bar.isVisible() ) | 1136 | if ( ! bar.isVisible() ) |
1133 | return false; | 1137 | return false; |
1134 | if ( incCounter % modulo == 0 ) | 1138 | if ( incCounter % modulo == 0 ) |
1135 | bar.setProgress( incCounter ); | 1139 | bar.setProgress( incCounter ); |
1136 | ++incCounter; | 1140 | ++incCounter; |
1137 | uid = inL->uid(); | 1141 | uid = inL->uid(); |
1138 | bool skipIncidence = false; | 1142 | bool skipIncidence = false; |
1139 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1143 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1140 | skipIncidence = true; | 1144 | skipIncidence = true; |
1141 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1145 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1142 | skipIncidence = true; | 1146 | skipIncidence = true; |
1143 | if ( !skipIncidence ) { | 1147 | if ( !skipIncidence ) { |
1144 | inR = remote->incidence( uid ); | 1148 | inR = remote->incidence( uid ); |
1145 | if ( ! inR ) { | 1149 | if ( ! inR ) { |
1146 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1150 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1147 | // no conflict ********** add or delete local | 1151 | // no conflict ********** add or delete local |
1148 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1152 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1149 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1153 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1150 | checkExternSyncEvent(eventLSyncSharp, inL); | 1154 | checkExternSyncEvent(eventLSyncSharp, inL); |
1151 | local->deleteIncidence( inL ); | 1155 | local->deleteIncidence( inL ); |
1152 | ++deletedEventL; | 1156 | ++deletedEventL; |
1153 | } else { | 1157 | } else { |
1154 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1158 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1155 | inL->removeID(mCurrentSyncDevice ); | 1159 | inL->removeID(mCurrentSyncDevice ); |
1156 | ++addedEventR; | 1160 | ++addedEventR; |
1157 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1161 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1158 | inL->setLastModified( modifiedCalendar ); | 1162 | inL->setLastModified( modifiedCalendar ); |
1159 | inR = inL->clone(); | 1163 | inR = inL->clone(); |
1160 | inR->setIDStr( ":" ); | 1164 | inR->setIDStr( ":" ); |
1161 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1165 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1162 | remote->addIncidence( inR ); | 1166 | remote->addIncidence( inR ); |
1163 | } | 1167 | } |
1164 | } | 1168 | } |
1165 | } else { | 1169 | } else { |
1166 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1170 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1167 | checkExternSyncEvent(eventLSyncSharp, inL); | 1171 | checkExternSyncEvent(eventLSyncSharp, inL); |
1168 | local->deleteIncidence( inL ); | 1172 | local->deleteIncidence( inL ); |
1169 | ++deletedEventL; | 1173 | ++deletedEventL; |
1170 | } else { | 1174 | } else { |
1171 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1175 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1172 | ++addedEventR; | 1176 | ++addedEventR; |
1173 | inL->setLastModified( modifiedCalendar ); | 1177 | inL->setLastModified( modifiedCalendar ); |
1174 | inR = inL->clone(); | 1178 | inR = inL->clone(); |
1175 | inR->setIDStr( ":" ); | 1179 | inR->setIDStr( ":" ); |
1176 | remote->addIncidence( inR ); | 1180 | remote->addIncidence( inR ); |
1177 | } | 1181 | } |
1178 | } | 1182 | } |
1179 | } | 1183 | } |
1180 | } else { | 1184 | } else { |
1181 | ++filteredOUT; | 1185 | ++filteredOUT; |
1182 | } | 1186 | } |
1183 | } | 1187 | } |
1184 | } | 1188 | } |
1185 | inL = el.next(); | 1189 | inL = el.next(); |
1186 | } | 1190 | } |
1187 | int delFut = 0; | 1191 | int delFut = 0; |
1188 | int remRem = 0; | 1192 | int remRem = 0; |
1189 | if ( mSyncManager->mWriteBackInFuture ) { | 1193 | if ( mSyncManager->mWriteBackInFuture ) { |
1190 | er = remote->rawIncidences(); | 1194 | er = remote->rawIncidences(); |
1191 | remRem = er.count(); | 1195 | remRem = er.count(); |
1192 | inR = er.first(); | 1196 | inR = er.first(); |
1193 | QDateTime dt; | 1197 | QDateTime dt; |
1194 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1198 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1195 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1199 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1196 | while ( inR ) { | 1200 | while ( inR ) { |
1197 | if ( inR->type() == "Todo" ) { | 1201 | if ( inR->type() == "Todo" ) { |
1198 | Todo * t = (Todo*)inR; | 1202 | Todo * t = (Todo*)inR; |
1199 | if ( t->hasDueDate() ) | 1203 | if ( t->hasDueDate() ) |
1200 | dt = t->dtDue(); | 1204 | dt = t->dtDue(); |
1201 | else | 1205 | else |
1202 | dt = cur.addSecs( 62 ); | 1206 | dt = cur.addSecs( 62 ); |
1203 | } | 1207 | } |
1204 | else if (inR->type() == "Event" ) { | 1208 | else if (inR->type() == "Event" ) { |
1205 | bool ok; | 1209 | bool ok; |
1206 | dt = inR->getNextOccurence( cur, &ok ); | 1210 | dt = inR->getNextOccurence( cur, &ok ); |
1207 | if ( !ok ) | 1211 | if ( !ok ) |
1208 | dt = cur.addSecs( -62 ); | 1212 | dt = cur.addSecs( -62 ); |
1209 | } | 1213 | } |
1210 | else | 1214 | else |
1211 | dt = inR->dtStart(); | 1215 | dt = inR->dtStart(); |
1212 | if ( dt < cur || dt > end ) { | 1216 | if ( dt < cur || dt > end ) { |
1213 | remote->deleteIncidence( inR ); | 1217 | remote->deleteIncidence( inR ); |
1214 | ++delFut; | 1218 | ++delFut; |
1215 | } | 1219 | } |
1216 | inR = er.next(); | 1220 | inR = er.next(); |
1217 | } | 1221 | } |
1218 | } | 1222 | } |
1219 | bar.hide(); | 1223 | bar.hide(); |
1220 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1224 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1221 | eventLSync->setReadOnly( false ); | 1225 | eventLSync->setReadOnly( false ); |
1222 | eventLSync->setDtStart( mLastCalendarSync ); | 1226 | eventLSync->setDtStart( mLastCalendarSync ); |
1223 | eventRSync->setDtStart( mLastCalendarSync ); | 1227 | eventRSync->setDtStart( mLastCalendarSync ); |
1224 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1228 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1225 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1229 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1226 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1230 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1227 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1231 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1228 | eventLSync->setReadOnly( true ); | 1232 | eventLSync->setReadOnly( true ); |
1229 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1233 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1230 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1234 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1231 | remote->addEvent( eventRSync ); | 1235 | remote->addEvent( eventRSync ); |
1232 | else | 1236 | else |
1233 | delete eventRSync; | 1237 | delete eventRSync; |
1234 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1238 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1235 | QString mes; | 1239 | QString mes; |
1236 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1240 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1237 | QString delmess; | 1241 | QString delmess; |
1238 | if ( delFut ) { | 1242 | if ( delFut ) { |
1239 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1243 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1240 | mes += delmess; | 1244 | mes += delmess; |
1241 | } | 1245 | } |
1242 | mes = i18n("Local calendar changed!\n") +mes; | 1246 | mes = i18n("Local calendar changed!\n") +mes; |
1243 | mCalendar->checkAlarmForIncidence( 0, true ); | 1247 | mCalendar->checkAlarmForIncidence( 0, true ); |
1244 | qDebug( mes ); | 1248 | qDebug( mes ); |
1245 | if ( mSyncManager->mShowSyncSummary ) { | 1249 | if ( mSyncManager->mShowSyncSummary ) { |
1246 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1250 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1247 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1251 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1248 | qDebug("KO: WB cancelled "); | 1252 | qDebug("KO: WB cancelled "); |
1249 | mSyncManager->mWriteBackFile = false; | 1253 | mSyncManager->mWriteBackFile = false; |
1250 | return syncOK; | 1254 | return syncOK; |
1251 | } | 1255 | } |
1252 | } | 1256 | } |
1253 | return syncOK; | 1257 | return syncOK; |
1254 | } | 1258 | } |
1255 | 1259 | ||
1256 | void CalendarView::setSyncDevice( QString s ) | 1260 | void CalendarView::setSyncDevice( QString s ) |
1257 | { | 1261 | { |
1258 | mCurrentSyncDevice= s; | 1262 | mCurrentSyncDevice= s; |
1259 | } | 1263 | } |
1260 | void CalendarView::setSyncName( QString s ) | 1264 | void CalendarView::setSyncName( QString s ) |
1261 | { | 1265 | { |
1262 | mCurrentSyncName= s; | 1266 | mCurrentSyncName= s; |
1263 | } | 1267 | } |
1264 | bool CalendarView::syncCalendar(QString filename, int mode) | 1268 | bool CalendarView::syncCalendar(QString filename, int mode) |
1265 | { | 1269 | { |
1266 | //qDebug("syncCalendar %s ", filename.latin1()); | 1270 | //qDebug("syncCalendar %s ", filename.latin1()); |
1267 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1271 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1268 | CalendarLocal* calendar = new CalendarLocal(); | 1272 | CalendarLocal* calendar = new CalendarLocal(); |
1269 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1273 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1270 | FileStorage* storage = new FileStorage( calendar ); | 1274 | FileStorage* storage = new FileStorage( calendar ); |
1271 | bool syncOK = false; | 1275 | bool syncOK = false; |
1272 | storage->setFileName( filename ); | 1276 | storage->setFileName( filename ); |
1273 | // qDebug("loading ... "); | 1277 | // qDebug("loading ... "); |
1274 | if ( storage->load() ) { | 1278 | if ( storage->load() ) { |
1275 | getEventViewerDialog()->setSyncMode( true ); | 1279 | getEventViewerDialog()->setSyncMode( true ); |
1276 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1280 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1277 | getEventViewerDialog()->setSyncMode( false ); | 1281 | getEventViewerDialog()->setSyncMode( false ); |
1278 | if ( syncOK ) { | 1282 | if ( syncOK ) { |
1279 | if ( mSyncManager->mWriteBackFile ) | 1283 | if ( mSyncManager->mWriteBackFile ) |
1280 | { | 1284 | { |
1281 | storage->setSaveFormat( new ICalFormat() ); | 1285 | storage->setSaveFormat( new ICalFormat() ); |
1282 | storage->save(); | 1286 | storage->save(); |
1283 | } | 1287 | } |
1284 | } | 1288 | } |
1285 | setModified( true ); | 1289 | setModified( true ); |
1286 | } | 1290 | } |
1287 | delete storage; | 1291 | delete storage; |
1288 | delete calendar; | 1292 | delete calendar; |
1289 | if ( syncOK ) | 1293 | if ( syncOK ) |
1290 | updateView(); | 1294 | updateView(); |
1291 | return syncOK; | 1295 | return syncOK; |
1292 | } | 1296 | } |
1293 | 1297 | ||
1294 | void CalendarView::syncExternal( int mode ) | 1298 | void CalendarView::syncExternal( int mode ) |
1295 | { | 1299 | { |
1296 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1300 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1297 | 1301 | ||
1298 | qApp->processEvents(); | 1302 | qApp->processEvents(); |
1299 | CalendarLocal* calendar = new CalendarLocal(); | 1303 | CalendarLocal* calendar = new CalendarLocal(); |
1300 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1304 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1301 | bool syncOK = false; | 1305 | bool syncOK = false; |
1302 | bool loadSuccess = false; | 1306 | bool loadSuccess = false; |
1303 | PhoneFormat* phoneFormat = 0; | 1307 | PhoneFormat* phoneFormat = 0; |
1304 | emit tempDisableBR(true); | 1308 | emit tempDisableBR(true); |
1305 | #ifndef DESKTOP_VERSION | 1309 | #ifndef DESKTOP_VERSION |
1306 | SharpFormat* sharpFormat = 0; | 1310 | SharpFormat* sharpFormat = 0; |
1307 | if ( mode == 0 ) { // sharp | 1311 | if ( mode == 0 ) { // sharp |
1308 | sharpFormat = new SharpFormat () ; | 1312 | sharpFormat = new SharpFormat () ; |
1309 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1313 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1310 | 1314 | ||
1311 | } else | 1315 | } else |
1312 | #endif | 1316 | #endif |
1313 | if ( mode == 1 ) { // phone | 1317 | if ( mode == 1 ) { // phone |
1314 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1318 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1315 | mSyncManager->mPhoneDevice, | 1319 | mSyncManager->mPhoneDevice, |
1316 | mSyncManager->mPhoneConnection, | 1320 | mSyncManager->mPhoneConnection, |
1317 | mSyncManager->mPhoneModel); | 1321 | mSyncManager->mPhoneModel); |
1318 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1322 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1319 | 1323 | ||
1320 | } else { | 1324 | } else { |
1321 | emit tempDisableBR(false); | 1325 | emit tempDisableBR(false); |
1322 | return; | 1326 | return; |
1323 | } | 1327 | } |
1324 | if ( loadSuccess ) { | 1328 | if ( loadSuccess ) { |
1325 | getEventViewerDialog()->setSyncMode( true ); | 1329 | getEventViewerDialog()->setSyncMode( true ); |
1326 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1330 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1327 | getEventViewerDialog()->setSyncMode( false ); | 1331 | getEventViewerDialog()->setSyncMode( false ); |
1328 | qApp->processEvents(); | 1332 | qApp->processEvents(); |
1329 | if ( syncOK ) { | 1333 | if ( syncOK ) { |
1330 | if ( mSyncManager->mWriteBackFile ) | 1334 | if ( mSyncManager->mWriteBackFile ) |
1331 | { | 1335 | { |
1332 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1336 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1333 | Incidence* inc = iL.first(); | 1337 | Incidence* inc = iL.first(); |
1334 | if ( phoneFormat ) { | 1338 | if ( phoneFormat ) { |
1335 | while ( inc ) { | 1339 | while ( inc ) { |
1336 | inc->removeID(mCurrentSyncDevice); | 1340 | inc->removeID(mCurrentSyncDevice); |
1337 | inc = iL.next(); | 1341 | inc = iL.next(); |
1338 | } | 1342 | } |
1339 | } | 1343 | } |
1340 | #ifndef DESKTOP_VERSION | 1344 | #ifndef DESKTOP_VERSION |
1341 | if ( sharpFormat ) | 1345 | if ( sharpFormat ) |
1342 | sharpFormat->save(calendar); | 1346 | sharpFormat->save(calendar); |
1343 | #endif | 1347 | #endif |
1344 | if ( phoneFormat ) | 1348 | if ( phoneFormat ) |
1345 | phoneFormat->save(calendar); | 1349 | phoneFormat->save(calendar); |
1346 | iL = calendar->rawIncidences(); | 1350 | iL = calendar->rawIncidences(); |
1347 | inc = iL.first(); | 1351 | inc = iL.first(); |
1348 | Incidence* loc; | 1352 | Incidence* loc; |
1349 | while ( inc ) { | 1353 | while ( inc ) { |
1350 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1354 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1351 | loc = mCalendar->incidence(inc->uid() ); | 1355 | loc = mCalendar->incidence(inc->uid() ); |
1352 | if ( loc ) { | 1356 | if ( loc ) { |
1353 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1357 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1354 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1358 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1355 | } | 1359 | } |
1356 | } | 1360 | } |
1357 | inc = iL.next(); | 1361 | inc = iL.next(); |
1358 | } | 1362 | } |
1359 | Incidence* lse = getLastSyncEvent(); | 1363 | Incidence* lse = getLastSyncEvent(); |
1360 | if ( lse ) { | 1364 | if ( lse ) { |
1361 | lse->setReadOnly( false ); | 1365 | lse->setReadOnly( false ); |
1362 | lse->setDescription( "" ); | 1366 | lse->setDescription( "" ); |
1363 | lse->setReadOnly( true ); | 1367 | lse->setReadOnly( true ); |
1364 | } | 1368 | } |
1365 | } | 1369 | } |
1366 | } else { | 1370 | } else { |
1367 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1371 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1368 | } | 1372 | } |
1369 | setModified( true ); | 1373 | setModified( true ); |
1370 | } else { | 1374 | } else { |
1371 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1375 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1372 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1376 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1373 | question, i18n("Ok")) ; | 1377 | question, i18n("Ok")) ; |
1374 | 1378 | ||
1375 | } | 1379 | } |
1376 | delete calendar; | 1380 | delete calendar; |
1377 | updateView(); | 1381 | updateView(); |
1378 | emit tempDisableBR(false); | 1382 | emit tempDisableBR(false); |
1379 | return ;//syncOK; | 1383 | return ;//syncOK; |
1380 | 1384 | ||
1381 | } | 1385 | } |
1382 | 1386 | ||
1383 | bool CalendarView::importBday() | 1387 | bool CalendarView::importBday() |
1384 | { | 1388 | { |
1385 | #ifndef KORG_NOKABC | 1389 | #ifndef KORG_NOKABC |
1386 | 1390 | ||
1387 | #ifdef DESKTOP_VERSION | 1391 | #ifdef DESKTOP_VERSION |
1388 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1392 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1389 | KABC::AddressBook::Iterator it; | 1393 | KABC::AddressBook::Iterator it; |
1390 | int count = 0; | 1394 | int count = 0; |
1391 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1395 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1392 | ++count; | 1396 | ++count; |
1393 | } | 1397 | } |
1394 | QProgressBar bar(count,0 ); | 1398 | QProgressBar bar(count,0 ); |
1395 | int w = 300; | 1399 | int w = 300; |
1396 | if ( QApplication::desktop()->width() < 320 ) | 1400 | if ( QApplication::desktop()->width() < 320 ) |
1397 | w = 220; | 1401 | w = 220; |
1398 | int h = bar.sizeHint().height() ; | 1402 | int h = bar.sizeHint().height() ; |
1399 | int dw = QApplication::desktop()->width(); | 1403 | int dw = QApplication::desktop()->width(); |
1400 | int dh = QApplication::desktop()->height(); | 1404 | int dh = QApplication::desktop()->height(); |
1401 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1405 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1402 | bar.show(); | 1406 | bar.show(); |
1403 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1407 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1404 | qApp->processEvents(); | 1408 | qApp->processEvents(); |
1405 | count = 0; | 1409 | count = 0; |
1406 | int addCount = 0; | 1410 | int addCount = 0; |
1407 | KCal::Attendee* a = 0; | 1411 | KCal::Attendee* a = 0; |
1408 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1412 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1409 | if ( ! bar.isVisible() ) | 1413 | if ( ! bar.isVisible() ) |
1410 | return false; | 1414 | return false; |
1411 | bar.setProgress( count++ ); | 1415 | bar.setProgress( count++ ); |
1412 | qApp->processEvents(); | 1416 | qApp->processEvents(); |
1413 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1417 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1414 | if ( (*it).birthday().date().isValid() ){ | 1418 | if ( (*it).birthday().date().isValid() ){ |
1415 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1419 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1416 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1420 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1417 | ++addCount; | 1421 | ++addCount; |
1418 | } | 1422 | } |
1419 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1423 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1420 | if ( anni.isValid() ){ | 1424 | if ( anni.isValid() ){ |
1421 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1425 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1422 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1426 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1423 | ++addCount; | 1427 | ++addCount; |
1424 | } | 1428 | } |
1425 | } | 1429 | } |
1426 | updateView(); | 1430 | updateView(); |
1427 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1431 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1428 | #else //DESKTOP_VERSION | 1432 | #else //DESKTOP_VERSION |
1429 | 1433 | ||
1430 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1434 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1431 | // the result should now arrive through method insertBirthdays | 1435 | // the result should now arrive through method insertBirthdays |
1432 | 1436 | ||
1433 | #endif //DESKTOP_VERSION | 1437 | #endif //DESKTOP_VERSION |
1434 | 1438 | ||
1435 | #endif //KORG_NOKABC | 1439 | #endif //KORG_NOKABC |
1436 | 1440 | ||
1437 | 1441 | ||
1438 | return true; | 1442 | return true; |
1439 | } | 1443 | } |
1440 | 1444 | ||
1441 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1445 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1442 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1446 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1443 | const QStringList& anniversaryList, const QStringList& realNameList, | 1447 | const QStringList& anniversaryList, const QStringList& realNameList, |
1444 | const QStringList& emailList, const QStringList& assembledNameList, | 1448 | const QStringList& emailList, const QStringList& assembledNameList, |
1445 | const QStringList& uidList) | 1449 | const QStringList& uidList) |
1446 | { | 1450 | { |
1447 | //qDebug("KO::CalendarView::insertBirthdays"); | 1451 | //qDebug("KO::CalendarView::insertBirthdays"); |
1448 | if (uid == this->name()) | 1452 | if (uid == this->name()) |
1449 | { | 1453 | { |
1450 | int count = birthdayList.count(); | 1454 | int count = birthdayList.count(); |
1451 | int addCount = 0; | 1455 | int addCount = 0; |
1452 | KCal::Attendee* a = 0; | 1456 | KCal::Attendee* a = 0; |
1453 | 1457 | ||
1454 | //qDebug("CalView 1 %i", count); | 1458 | //qDebug("CalView 1 %i", count); |
1455 | 1459 | ||
1456 | QProgressBar bar(count,0 ); | 1460 | QProgressBar bar(count,0 ); |
1457 | int w = 300; | 1461 | int w = 300; |
1458 | if ( QApplication::desktop()->width() < 320 ) | 1462 | if ( QApplication::desktop()->width() < 320 ) |
1459 | w = 220; | 1463 | w = 220; |
1460 | int h = bar.sizeHint().height() ; | 1464 | int h = bar.sizeHint().height() ; |
1461 | int dw = QApplication::desktop()->width(); | 1465 | int dw = QApplication::desktop()->width(); |
1462 | int dh = QApplication::desktop()->height(); | 1466 | int dh = QApplication::desktop()->height(); |
1463 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1467 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1464 | bar.show(); | 1468 | bar.show(); |
1465 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1469 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1466 | qApp->processEvents(); | 1470 | qApp->processEvents(); |
1467 | 1471 | ||
1468 | QDate birthday; | 1472 | QDate birthday; |
1469 | QDate anniversary; | 1473 | QDate anniversary; |
1470 | QString realName; | 1474 | QString realName; |
1471 | QString email; | 1475 | QString email; |
1472 | QString assembledName; | 1476 | QString assembledName; |
1473 | QString uid; | 1477 | QString uid; |
1474 | bool ok = true; | 1478 | bool ok = true; |
1475 | for ( int i = 0; i < count; i++) | 1479 | for ( int i = 0; i < count; i++) |
1476 | { | 1480 | { |
1477 | if ( ! bar.isVisible() ) | 1481 | if ( ! bar.isVisible() ) |
1478 | return; | 1482 | return; |
1479 | bar.setProgress( i ); | 1483 | bar.setProgress( i ); |
1480 | qApp->processEvents(); | 1484 | qApp->processEvents(); |
1481 | 1485 | ||
1482 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1486 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1483 | if (!ok) { | 1487 | if (!ok) { |
1484 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1488 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1485 | } | 1489 | } |
1486 | 1490 | ||
1487 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1491 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1488 | if (!ok) { | 1492 | if (!ok) { |
1489 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1493 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1490 | } | 1494 | } |
1491 | realName = realNameList[i]; | 1495 | realName = realNameList[i]; |
1492 | email = emailList[i]; | 1496 | email = emailList[i]; |
1493 | assembledName = assembledNameList[i]; | 1497 | assembledName = assembledNameList[i]; |
1494 | uid = uidList[i]; | 1498 | uid = uidList[i]; |
1495 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); | 1499 | //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); |
1496 | 1500 | ||
1497 | if ( birthday.isValid() ){ | 1501 | if ( birthday.isValid() ){ |
1498 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1502 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1499 | KCal::Attendee::ReqParticipant,uid) ; | 1503 | KCal::Attendee::ReqParticipant,uid) ; |
1500 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1504 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1501 | ++addCount; | 1505 | ++addCount; |
1502 | } | 1506 | } |
1503 | 1507 | ||
1504 | if ( anniversary.isValid() ){ | 1508 | if ( anniversary.isValid() ){ |
1505 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1509 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1506 | KCal::Attendee::ReqParticipant,uid) ; | 1510 | KCal::Attendee::ReqParticipant,uid) ; |
1507 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1511 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1508 | ++addCount; | 1512 | ++addCount; |
1509 | } | 1513 | } |
1510 | } | 1514 | } |
1511 | 1515 | ||
1512 | updateView(); | 1516 | updateView(); |
1513 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1517 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1514 | 1518 | ||
1515 | } | 1519 | } |
1516 | 1520 | ||
1517 | } | 1521 | } |
1518 | 1522 | ||
1519 | 1523 | ||
1520 | 1524 | ||
1521 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1525 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1522 | { | 1526 | { |
1523 | //qDebug("addAnni "); | 1527 | //qDebug("addAnni "); |
1524 | Event * ev = new Event(); | 1528 | Event * ev = new Event(); |
1525 | ev->setOrganizer(KOPrefs::instance()->email()); | 1529 | ev->setOrganizer(KOPrefs::instance()->email()); |
1526 | if ( a ) { | 1530 | if ( a ) { |
1527 | ev->addAttendee( a ); | 1531 | ev->addAttendee( a ); |
1528 | } | 1532 | } |
1529 | QString kind; | 1533 | QString kind; |
1530 | if ( birthday ) { | 1534 | if ( birthday ) { |
1531 | kind = i18n( "Birthday" ); | 1535 | kind = i18n( "Birthday" ); |
1532 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1536 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1533 | } | 1537 | } |
1534 | else { | 1538 | else { |
1535 | kind = i18n( "Anniversary" ); | 1539 | kind = i18n( "Anniversary" ); |
1536 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1540 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1537 | } | 1541 | } |
1538 | ev->setCategories( kind ); | 1542 | ev->setCategories( kind ); |
1539 | ev->setDtStart( QDateTime(date) ); | 1543 | ev->setDtStart( QDateTime(date) ); |
1540 | ev->setDtEnd( QDateTime(date) ); | 1544 | ev->setDtEnd( QDateTime(date) ); |
1541 | ev->setFloats( true ); | 1545 | ev->setFloats( true ); |
1542 | Recurrence * rec = ev->recurrence(); | 1546 | Recurrence * rec = ev->recurrence(); |
1543 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1547 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1544 | rec->addYearlyNum( date.month() ); | 1548 | rec->addYearlyNum( date.month() ); |
1545 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1549 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1546 | delete ev; | 1550 | delete ev; |
1547 | return false; | 1551 | return false; |
1548 | } | 1552 | } |
1549 | return true; | 1553 | return true; |
1550 | 1554 | ||
1551 | } | 1555 | } |
1552 | bool CalendarView::importQtopia( const QString &categories, | 1556 | bool CalendarView::importQtopia( const QString &categories, |
1553 | const QString &datebook, | 1557 | const QString &datebook, |
1554 | const QString &todolist ) | 1558 | const QString &todolist ) |
1555 | { | 1559 | { |
1556 | 1560 | ||
1557 | QtopiaFormat qtopiaFormat; | 1561 | QtopiaFormat qtopiaFormat; |
1558 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1562 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1559 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1563 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1560 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1564 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1561 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1565 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1562 | 1566 | ||
1563 | updateView(); | 1567 | updateView(); |
1564 | return true; | 1568 | return true; |
1565 | 1569 | ||
1566 | #if 0 | 1570 | #if 0 |
1567 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1571 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1568 | mCurrentSyncDevice = "qtopia-XML"; | 1572 | mCurrentSyncDevice = "qtopia-XML"; |
1569 | if ( mSyncManager->mAskForPreferences ) | 1573 | if ( mSyncManager->mAskForPreferences ) |
1570 | edit_sync_options(); | 1574 | edit_sync_options(); |
1571 | qApp->processEvents(); | 1575 | qApp->processEvents(); |
1572 | CalendarLocal* calendar = new CalendarLocal(); | 1576 | CalendarLocal* calendar = new CalendarLocal(); |
1573 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1577 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1574 | bool syncOK = false; | 1578 | bool syncOK = false; |
1575 | QtopiaFormat qtopiaFormat; | 1579 | QtopiaFormat qtopiaFormat; |
1576 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1580 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1577 | bool loadOk = true; | 1581 | bool loadOk = true; |
1578 | if ( !categories.isEmpty() ) | 1582 | if ( !categories.isEmpty() ) |
1579 | loadOk = qtopiaFormat.load( calendar, categories ); | 1583 | loadOk = qtopiaFormat.load( calendar, categories ); |
1580 | if ( loadOk && !datebook.isEmpty() ) | 1584 | if ( loadOk && !datebook.isEmpty() ) |
1581 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1585 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1582 | if ( loadOk && !todolist.isEmpty() ) | 1586 | if ( loadOk && !todolist.isEmpty() ) |
1583 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1587 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1584 | 1588 | ||
1585 | if ( loadOk ) { | 1589 | if ( loadOk ) { |
1586 | getEventViewerDialog()->setSyncMode( true ); | 1590 | getEventViewerDialog()->setSyncMode( true ); |
1587 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1591 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1588 | getEventViewerDialog()->setSyncMode( false ); | 1592 | getEventViewerDialog()->setSyncMode( false ); |
1589 | qApp->processEvents(); | 1593 | qApp->processEvents(); |
1590 | if ( syncOK ) { | 1594 | if ( syncOK ) { |
1591 | if ( mSyncManager->mWriteBackFile ) | 1595 | if ( mSyncManager->mWriteBackFile ) |
1592 | { | 1596 | { |
1593 | // write back XML file | 1597 | // write back XML file |
1594 | 1598 | ||
1595 | } | 1599 | } |
1596 | setModified( true ); | 1600 | setModified( true ); |
1597 | } | 1601 | } |
1598 | } else { | 1602 | } else { |
1599 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1603 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1600 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1604 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1601 | question, i18n("Ok")) ; | 1605 | question, i18n("Ok")) ; |
1602 | } | 1606 | } |
1603 | delete calendar; | 1607 | delete calendar; |
1604 | updateView(); | 1608 | updateView(); |
1605 | return syncOK; | 1609 | return syncOK; |
1606 | 1610 | ||
1607 | 1611 | ||
1608 | #endif | 1612 | #endif |
1609 | 1613 | ||
1610 | } | 1614 | } |
1611 | 1615 | ||
1612 | void CalendarView::setSyncEventsReadOnly() | 1616 | void CalendarView::setSyncEventsReadOnly() |
1613 | { | 1617 | { |
1614 | Event * ev; | 1618 | Event * ev; |
1615 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1619 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1616 | ev = eL.first(); | 1620 | ev = eL.first(); |
1617 | while ( ev ) { | 1621 | while ( ev ) { |
1618 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1622 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1619 | ev->setReadOnly( true ); | 1623 | ev->setReadOnly( true ); |
1620 | ev = eL.next(); | 1624 | ev = eL.next(); |
1621 | } | 1625 | } |
1622 | } | 1626 | } |
1623 | bool CalendarView::openCalendar(QString filename, bool merge) | 1627 | bool CalendarView::openCalendar(QString filename, bool merge) |
1624 | { | 1628 | { |
1625 | 1629 | ||
1626 | if (filename.isEmpty()) { | 1630 | if (filename.isEmpty()) { |
1627 | return false; | 1631 | return false; |
1628 | } | 1632 | } |
1629 | 1633 | ||
1630 | if (!QFile::exists(filename)) { | 1634 | if (!QFile::exists(filename)) { |
1631 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1635 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1632 | return false; | 1636 | return false; |
1633 | } | 1637 | } |
1634 | 1638 | ||
1635 | globalFlagBlockAgenda = 1; | 1639 | globalFlagBlockAgenda = 1; |
1636 | if (!merge) mCalendar->close(); | 1640 | if (!merge) mCalendar->close(); |
1637 | 1641 | ||
1638 | mStorage->setFileName( filename ); | 1642 | mStorage->setFileName( filename ); |
1639 | 1643 | ||
1640 | if ( mStorage->load() ) { | 1644 | if ( mStorage->load() ) { |
1641 | if ( merge ) ;//setModified( true ); | 1645 | if ( merge ) ;//setModified( true ); |
1642 | else { | 1646 | else { |
1643 | //setModified( true ); | 1647 | //setModified( true ); |
1644 | mViewManager->setDocumentId( filename ); | 1648 | mViewManager->setDocumentId( filename ); |
1645 | mDialogManager->setDocumentId( filename ); | 1649 | mDialogManager->setDocumentId( filename ); |
1646 | mTodoList->setDocumentId( filename ); | 1650 | mTodoList->setDocumentId( filename ); |
1647 | } | 1651 | } |
1648 | globalFlagBlockAgenda = 2; | 1652 | globalFlagBlockAgenda = 2; |
1649 | // if ( getLastSyncEvent() ) | 1653 | // if ( getLastSyncEvent() ) |
1650 | // getLastSyncEvent()->setReadOnly( true ); | 1654 | // getLastSyncEvent()->setReadOnly( true ); |
1651 | mCalendar->reInitAlarmSettings(); | 1655 | mCalendar->reInitAlarmSettings(); |
1652 | setSyncEventsReadOnly(); | 1656 | setSyncEventsReadOnly(); |
1653 | updateUnmanagedViews(); | 1657 | updateUnmanagedViews(); |
1654 | updateView(); | 1658 | updateView(); |
1655 | if ( filename != MainWindow::defaultFileName() ) { | 1659 | if ( filename != MainWindow::defaultFileName() ) { |
1656 | saveCalendar( MainWindow::defaultFileName() ); | 1660 | saveCalendar( MainWindow::defaultFileName() ); |
1657 | } else { | 1661 | } else { |
1658 | QFileInfo finf ( MainWindow::defaultFileName()); | 1662 | QFileInfo finf ( MainWindow::defaultFileName()); |
1659 | if ( finf.exists() ) { | 1663 | if ( finf.exists() ) { |
1660 | setLoadedFileVersion( finf.lastModified () ); | 1664 | setLoadedFileVersion( finf.lastModified () ); |
1661 | } | 1665 | } |
1662 | } | 1666 | } |
1663 | return true; | 1667 | return true; |
1664 | } else { | 1668 | } else { |
1665 | // while failing to load, the calendar object could | 1669 | // while failing to load, the calendar object could |
1666 | // have become partially populated. Clear it out. | 1670 | // have become partially populated. Clear it out. |
1667 | if ( !merge ) { | 1671 | if ( !merge ) { |
1668 | mCalendar->close(); | 1672 | mCalendar->close(); |
1669 | mViewManager->setDocumentId( filename ); | 1673 | mViewManager->setDocumentId( filename ); |
1670 | mDialogManager->setDocumentId( filename ); | 1674 | mDialogManager->setDocumentId( filename ); |
1671 | mTodoList->setDocumentId( filename ); | 1675 | mTodoList->setDocumentId( filename ); |
1672 | } | 1676 | } |
1673 | 1677 | ||
1674 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1678 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1675 | 1679 | ||
1676 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1680 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1677 | globalFlagBlockAgenda = 2; | 1681 | globalFlagBlockAgenda = 2; |
1678 | mCalendar->reInitAlarmSettings(); | 1682 | mCalendar->reInitAlarmSettings(); |
1679 | setSyncEventsReadOnly(); | 1683 | setSyncEventsReadOnly(); |
1680 | updateUnmanagedViews(); | 1684 | updateUnmanagedViews(); |
1681 | updateView(); | 1685 | updateView(); |
1682 | } | 1686 | } |
1683 | return false; | 1687 | return false; |
1684 | } | 1688 | } |
1685 | void CalendarView::showOpenError() | 1689 | void CalendarView::showOpenError() |
1686 | { | 1690 | { |
1687 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1691 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1688 | } | 1692 | } |
1689 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1693 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1690 | { | 1694 | { |
1691 | loadedFileVersion = dt; | 1695 | loadedFileVersion = dt; |
1692 | } | 1696 | } |
1693 | bool CalendarView::checkFileChanged(QString fn) | 1697 | bool CalendarView::checkFileChanged(QString fn) |
1694 | { | 1698 | { |
1695 | QFileInfo finf ( fn ); | 1699 | QFileInfo finf ( fn ); |
1696 | if ( !finf.exists() ) | 1700 | if ( !finf.exists() ) |
1697 | return true; | 1701 | return true; |
1698 | QDateTime dt = finf.lastModified (); | 1702 | QDateTime dt = finf.lastModified (); |
1699 | if ( dt <= loadedFileVersion ) | 1703 | if ( dt <= loadedFileVersion ) |
1700 | return false; | 1704 | return false; |
1701 | return true; | 1705 | return true; |
1702 | 1706 | ||
1703 | } | 1707 | } |
1704 | void CalendarView::watchSavedFile() | 1708 | void CalendarView::watchSavedFile() |
1705 | { | 1709 | { |
1706 | QFileInfo finf ( MainWindow::defaultFileName()); | 1710 | QFileInfo finf ( MainWindow::defaultFileName()); |
1707 | if ( !finf.exists() ) | 1711 | if ( !finf.exists() ) |
1708 | return; | 1712 | return; |
1709 | QDateTime dt = finf.lastModified (); | 1713 | QDateTime dt = finf.lastModified (); |
1710 | if ( dt < loadedFileVersion ) { | 1714 | if ( dt < loadedFileVersion ) { |
1711 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1715 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1712 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1716 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1713 | return; | 1717 | return; |
1714 | } | 1718 | } |
1715 | loadedFileVersion = dt; | 1719 | loadedFileVersion = dt; |
1716 | } | 1720 | } |
1717 | 1721 | ||
1718 | bool CalendarView::checkFileVersion(QString fn) | 1722 | bool CalendarView::checkFileVersion(QString fn) |
1719 | { | 1723 | { |
1720 | QFileInfo finf ( fn ); | 1724 | QFileInfo finf ( fn ); |
1721 | if ( !finf.exists() ) | 1725 | if ( !finf.exists() ) |
1722 | return true; | 1726 | return true; |
1723 | QDateTime dt = finf.lastModified (); | 1727 | QDateTime dt = finf.lastModified (); |
1724 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1728 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1725 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1729 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1726 | if ( dt <= loadedFileVersion ) | 1730 | if ( dt <= loadedFileVersion ) |
1727 | return true; | 1731 | return true; |
1728 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , | 1732 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , |
1729 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1733 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1730 | i18n("Sync+save")); | 1734 | i18n("Sync+save")); |
1731 | 1735 | ||
1732 | if ( km == KMessageBox::Cancel ) | 1736 | if ( km == KMessageBox::Cancel ) |
1733 | return false; | 1737 | return false; |
1734 | if ( km == KMessageBox::Yes ) | 1738 | if ( km == KMessageBox::Yes ) |
1735 | return true; | 1739 | return true; |
1736 | 1740 | ||
1737 | setSyncDevice("deleteaftersync" ); | 1741 | setSyncDevice("deleteaftersync" ); |
1738 | mSyncManager->mAskForPreferences = true; | 1742 | mSyncManager->mAskForPreferences = true; |
1739 | mSyncManager->mSyncAlgoPrefs = 3; | 1743 | mSyncManager->mSyncAlgoPrefs = 3; |
1740 | mSyncManager->mWriteBackFile = false; | 1744 | mSyncManager->mWriteBackFile = false; |
1741 | mSyncManager->mWriteBackExistingOnly = false; | 1745 | mSyncManager->mWriteBackExistingOnly = false; |
1742 | mSyncManager->mShowSyncSummary = false; | 1746 | mSyncManager->mShowSyncSummary = false; |
1743 | syncCalendar( fn, 3 ); | 1747 | syncCalendar( fn, 3 ); |
1744 | Event * e = getLastSyncEvent(); | 1748 | Event * e = getLastSyncEvent(); |
1745 | mCalendar->deleteEvent ( e ); | 1749 | mCalendar->deleteEvent ( e ); |
1746 | updateView(); | 1750 | updateView(); |
1747 | return true; | 1751 | return true; |
1748 | } | 1752 | } |
1749 | 1753 | ||
1750 | bool CalendarView::saveCalendar( QString filename ) | 1754 | bool CalendarView::saveCalendar( QString filename ) |
1751 | { | 1755 | { |
1752 | 1756 | ||
1753 | // Store back all unsaved data into calendar object | 1757 | // Store back all unsaved data into calendar object |
1754 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1758 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1755 | if ( mViewManager->currentView() ) | 1759 | if ( mViewManager->currentView() ) |
1756 | mViewManager->currentView()->flushView(); | 1760 | mViewManager->currentView()->flushView(); |
1757 | 1761 | ||
1758 | 1762 | ||
1759 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1763 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1760 | mStorage->setSaveFormat( new ICalFormat() ); | 1764 | mStorage->setSaveFormat( new ICalFormat() ); |
1761 | mStorage->setFileName( filename ); | 1765 | mStorage->setFileName( filename ); |
1762 | bool success; | 1766 | bool success; |
1763 | success = mStorage->save(); | 1767 | success = mStorage->save(); |
1764 | if ( !success ) { | 1768 | if ( !success ) { |
1765 | return false; | 1769 | return false; |
1766 | } | 1770 | } |
1767 | if ( filename == MainWindow::defaultFileName() ) { | 1771 | if ( filename == MainWindow::defaultFileName() ) { |
1768 | setLoadedFileVersion( lfv ); | 1772 | setLoadedFileVersion( lfv ); |
1769 | watchSavedFile(); | 1773 | watchSavedFile(); |
1770 | } | 1774 | } |
1771 | return true; | 1775 | return true; |
1772 | } | 1776 | } |
1773 | 1777 | ||
1774 | void CalendarView::closeCalendar() | 1778 | void CalendarView::closeCalendar() |
1775 | { | 1779 | { |
1776 | 1780 | ||
1777 | // child windows no longer valid | 1781 | // child windows no longer valid |
1778 | emit closingDown(); | 1782 | emit closingDown(); |
1779 | 1783 | ||
1780 | mCalendar->close(); | 1784 | mCalendar->close(); |
1781 | setModified(false); | 1785 | setModified(false); |
1782 | updateView(); | 1786 | updateView(); |
1783 | } | 1787 | } |
1784 | 1788 | ||
1785 | void CalendarView::archiveCalendar() | 1789 | void CalendarView::archiveCalendar() |
1786 | { | 1790 | { |
1787 | mDialogManager->showArchiveDialog(); | 1791 | mDialogManager->showArchiveDialog(); |
1788 | } | 1792 | } |
1789 | 1793 | ||
1790 | 1794 | ||
1791 | void CalendarView::readSettings() | 1795 | void CalendarView::readSettings() |
1792 | { | 1796 | { |
1793 | 1797 | ||
1794 | 1798 | ||
1795 | // mViewManager->showAgendaView(); | 1799 | // mViewManager->showAgendaView(); |
1796 | QString str; | 1800 | QString str; |
1797 | //qDebug("CalendarView::readSettings() "); | 1801 | //qDebug("CalendarView::readSettings() "); |
1798 | // read settings from the KConfig, supplying reasonable | 1802 | // read settings from the KConfig, supplying reasonable |
1799 | // defaults where none are to be found | 1803 | // defaults where none are to be found |
1800 | KConfig *config = KOGlobals::config(); | 1804 | KConfig *config = KOGlobals::config(); |
1801 | #ifndef KORG_NOSPLITTER | 1805 | #ifndef KORG_NOSPLITTER |
1802 | config->setGroup("KOrganizer Geometry"); | 1806 | config->setGroup("KOrganizer Geometry"); |
1803 | 1807 | ||
1804 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1808 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1805 | if (sizes.count() != 2) { | 1809 | if (sizes.count() != 2) { |
1806 | sizes << mDateNavigator->minimumSizeHint().width(); | 1810 | sizes << mDateNavigator->minimumSizeHint().width(); |
1807 | sizes << 300; | 1811 | sizes << 300; |
1808 | } | 1812 | } |
1809 | mPanner->setSizes(sizes); | 1813 | mPanner->setSizes(sizes); |
1810 | 1814 | ||
1811 | sizes = config->readIntListEntry("Separator2"); | 1815 | sizes = config->readIntListEntry("Separator2"); |
1812 | if ( ( mResourceView && sizes.count() == 4 ) || | 1816 | if ( ( mResourceView && sizes.count() == 4 ) || |
1813 | ( !mResourceView && sizes.count() == 3 ) ) { | 1817 | ( !mResourceView && sizes.count() == 3 ) ) { |
1814 | mLeftSplitter->setSizes(sizes); | 1818 | mLeftSplitter->setSizes(sizes); |
1815 | } | 1819 | } |
1816 | #endif | 1820 | #endif |
1817 | globalFlagBlockAgenda = 1; | 1821 | globalFlagBlockAgenda = 1; |
1818 | mViewManager->showAgendaView(); | 1822 | mViewManager->showAgendaView(); |
1819 | //mViewManager->readSettings( config ); | 1823 | //mViewManager->readSettings( config ); |
1820 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1824 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1821 | readFilterSettings(config); | 1825 | readFilterSettings(config); |
1822 | config->setGroup( "Views" ); | 1826 | config->setGroup( "Views" ); |
1823 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1827 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1824 | 1828 | ||
1825 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); | 1829 | QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); |
1826 | 1830 | ||
1827 | int resetval = 0; | 1831 | int resetval = 0; |
1828 | int maxVal = 0; | 1832 | int maxVal = 0; |
1829 | if (sizes.count() != 3) { | 1833 | if (sizes.count() != 3) { |
1830 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1834 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1831 | resetval = mDateNavigator->sizeHint().width()+2; | 1835 | resetval = mDateNavigator->sizeHint().width()+2; |
1832 | } else { | 1836 | } else { |
1833 | resetval = mDateNavigator->sizeHint().height()+2; | 1837 | resetval = mDateNavigator->sizeHint().height()+2; |
1834 | } | 1838 | } |
1835 | } | 1839 | } |
1836 | if ( !resetval ){// i.e. sizes.count() == 3 | 1840 | if ( !resetval ){// i.e. sizes.count() == 3 |
1837 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1841 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1838 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | 1842 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) |
1839 | resetval = mDateNavigator->sizeHint().width()+2; | 1843 | resetval = mDateNavigator->sizeHint().width()+2; |
1840 | } else { | 1844 | } else { |
1841 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | 1845 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) |
1842 | resetval = mDateNavigator->sizeHint().height()+2; | 1846 | resetval = mDateNavigator->sizeHint().height()+2; |
1843 | } | 1847 | } |
1844 | } | 1848 | } |
1845 | if ( resetval ) { | 1849 | if ( resetval ) { |
1846 | sizes.clear(); | 1850 | sizes.clear(); |
1847 | if ( KOPrefs::instance()->mVerticalScreen ) { | 1851 | if ( KOPrefs::instance()->mVerticalScreen ) { |
1848 | maxVal = QApplication::desktop()->width() -10; | 1852 | maxVal = QApplication::desktop()->width() -10; |
1849 | } else { | 1853 | } else { |
1850 | maxVal = QApplication::desktop()->height()-10; | 1854 | maxVal = QApplication::desktop()->height()-10; |
1851 | } | 1855 | } |
1852 | sizes << resetval; | 1856 | sizes << resetval; |
1853 | if ( maxVal < resetval + resetval) | 1857 | if ( maxVal < resetval + resetval) |
1854 | resetval = maxVal - resetval; | 1858 | resetval = maxVal - resetval; |
1855 | sizes << resetval; | 1859 | sizes << resetval; |
1856 | sizes << 100; | 1860 | sizes << 100; |
1857 | } | 1861 | } |
1858 | mLeftFrame->setSizes(sizes); | 1862 | mLeftFrame->setSizes(sizes); |
1863 | sizes = config->readIntListEntry("Main Splitter Frame"); | ||
1864 | if (sizes.count() != 3) { | ||
1865 | if ( !KOPrefs::instance()->mVerticalScreen ) { | ||
1866 | resetval = mDateNavigator->sizeHint().width()+2; | ||
1867 | } else { | ||
1868 | resetval = mDateNavigator->sizeHint().height()+2; | ||
1869 | } | ||
1870 | } | ||
1871 | if ( !resetval ){// i.e. sizes.count() == 3 | ||
1872 | if ( !KOPrefs::instance()->mVerticalScreen ) { | ||
1873 | if ( sizes[0] < mDateNavigator->sizeHint().width()+1 ) | ||
1874 | resetval = mDateNavigator->sizeHint().width()+2; | ||
1875 | } else { | ||
1876 | if ( sizes[0] < mDateNavigator->sizeHint().height()+1 ) | ||
1877 | resetval = mDateNavigator->sizeHint().height()+2; | ||
1878 | } | ||
1879 | } | ||
1880 | if ( resetval ) { | ||
1881 | sizes.clear(); | ||
1882 | if ( !KOPrefs::instance()->mVerticalScreen ) { | ||
1883 | maxVal = QApplication::desktop()->width() -10; | ||
1884 | } else { | ||
1885 | maxVal = QApplication::desktop()->height()-10; | ||
1886 | } | ||
1887 | sizes << resetval; | ||
1888 | if ( maxVal < resetval + resetval) | ||
1889 | resetval = maxVal - resetval; | ||
1890 | sizes << resetval; | ||
1891 | } | ||
1892 | mMainFrame->setSizes(sizes); | ||
1893 | |||
1859 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1894 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1860 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1895 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1861 | else mNavigator->selectDates( dateCount ); | 1896 | else mNavigator->selectDates( dateCount ); |
1862 | // mViewManager->readSettings( config ); | 1897 | // mViewManager->readSettings( config ); |
1863 | updateConfig(); | 1898 | updateConfig(); |
1864 | globalFlagBlockAgenda = 2; | 1899 | globalFlagBlockAgenda = 2; |
1865 | mViewManager->readSettings( config ); | 1900 | mViewManager->readSettings( config ); |
1866 | #ifdef DESKTOP_VERSION | 1901 | #ifdef DESKTOP_VERSION |
1867 | config->setGroup("WidgetLayout"); | 1902 | config->setGroup("WidgetLayout"); |
1868 | QStringList list; | 1903 | QStringList list; |
1869 | list = config->readListEntry("MainLayout"); | 1904 | list = config->readListEntry("MainLayout"); |
1870 | int x,y,w,h; | 1905 | int x,y,w,h; |
1871 | if ( ! list.isEmpty() ) { | 1906 | if ( ! list.isEmpty() ) { |
1872 | x = list[0].toInt(); | 1907 | x = list[0].toInt(); |
1873 | y = list[1].toInt(); | 1908 | y = list[1].toInt(); |
1874 | w = list[2].toInt(); | 1909 | w = list[2].toInt(); |
1875 | h = list[3].toInt(); | 1910 | h = list[3].toInt(); |
1876 | topLevelWidget()->setGeometry(x,y,w,h); | 1911 | topLevelWidget()->setGeometry(x,y,w,h); |
1877 | 1912 | ||
1878 | } else { | 1913 | } else { |
1879 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1914 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1880 | } | 1915 | } |
1881 | list = config->readListEntry("EditEventLayout"); | 1916 | list = config->readListEntry("EditEventLayout"); |
1882 | if ( ! list.isEmpty() ) { | 1917 | if ( ! list.isEmpty() ) { |
1883 | x = list[0].toInt(); | 1918 | x = list[0].toInt(); |
1884 | y = list[1].toInt(); | 1919 | y = list[1].toInt(); |
1885 | w = list[2].toInt(); | 1920 | w = list[2].toInt(); |
1886 | h = list[3].toInt(); | 1921 | h = list[3].toInt(); |
1887 | mEventEditor->setGeometry(x,y,w,h); | 1922 | mEventEditor->setGeometry(x,y,w,h); |
1888 | 1923 | ||
1889 | } | 1924 | } |
1890 | list = config->readListEntry("EditTodoLayout"); | 1925 | list = config->readListEntry("EditTodoLayout"); |
1891 | if ( ! list.isEmpty() ) { | 1926 | if ( ! list.isEmpty() ) { |
1892 | x = list[0].toInt(); | 1927 | x = list[0].toInt(); |
1893 | y = list[1].toInt(); | 1928 | y = list[1].toInt(); |
1894 | w = list[2].toInt(); | 1929 | w = list[2].toInt(); |
1895 | h = list[3].toInt(); | 1930 | h = list[3].toInt(); |
1896 | mTodoEditor->setGeometry(x,y,w,h); | 1931 | mTodoEditor->setGeometry(x,y,w,h); |
1897 | 1932 | ||
1898 | } | 1933 | } |
1899 | list = config->readListEntry("ViewerLayout"); | 1934 | list = config->readListEntry("ViewerLayout"); |
1900 | if ( ! list.isEmpty() ) { | 1935 | if ( ! list.isEmpty() ) { |
1901 | x = list[0].toInt(); | 1936 | x = list[0].toInt(); |
1902 | y = list[1].toInt(); | 1937 | y = list[1].toInt(); |
1903 | w = list[2].toInt(); | 1938 | w = list[2].toInt(); |
1904 | h = list[3].toInt(); | 1939 | h = list[3].toInt(); |
1905 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1940 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1906 | } | 1941 | } |
1907 | #endif | 1942 | #endif |
1908 | 1943 | ||
1909 | } | 1944 | } |
1910 | 1945 | ||
1911 | 1946 | ||
1912 | void CalendarView::writeSettings() | 1947 | void CalendarView::writeSettings() |
1913 | { | 1948 | { |
1914 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1949 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1915 | 1950 | ||
1916 | KConfig *config = KOGlobals::config(); | 1951 | KConfig *config = KOGlobals::config(); |
1917 | 1952 | ||
1918 | mViewManager->writeSettings( config ); | 1953 | mViewManager->writeSettings( config ); |
1919 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1954 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1920 | mDialogManager->writeSettings( config ); | 1955 | mDialogManager->writeSettings( config ); |
1921 | //KOPrefs::instance()->usrWriteConfig(); | 1956 | //KOPrefs::instance()->usrWriteConfig(); |
1922 | KOPrefs::instance()->writeConfig(); | 1957 | KOPrefs::instance()->writeConfig(); |
1923 | 1958 | ||
1924 | writeFilterSettings(config); | 1959 | writeFilterSettings(config); |
1925 | 1960 | ||
1926 | config->setGroup( "Views" ); | 1961 | config->setGroup( "Views" ); |
1927 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1962 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1928 | 1963 | ||
1929 | QValueList<int> listINT = mLeftFrame->sizes(); | 1964 | QValueList<int> listINT = mLeftFrame->sizes(); |
1930 | config->writeEntry("Left Splitter Frame",listINT); | 1965 | config->writeEntry("Left Splitter Frame",listINT); |
1931 | 1966 | listINT = mMainFrame->sizes(); | |
1967 | config->writeEntry("Main Splitter Frame",listINT); | ||
1932 | #ifdef DESKTOP_VERSION | 1968 | #ifdef DESKTOP_VERSION |
1933 | config->setGroup("WidgetLayout"); | 1969 | config->setGroup("WidgetLayout"); |
1934 | QStringList list ;//= config->readListEntry("MainLayout"); | 1970 | QStringList list ;//= config->readListEntry("MainLayout"); |
1935 | int x,y,w,h; | 1971 | int x,y,w,h; |
1936 | QWidget* wid; | 1972 | QWidget* wid; |
1937 | wid = topLevelWidget(); | 1973 | wid = topLevelWidget(); |
1938 | x = wid->geometry().x(); | 1974 | x = wid->geometry().x(); |
1939 | y = wid->geometry().y(); | 1975 | y = wid->geometry().y(); |
1940 | w = wid->width(); | 1976 | w = wid->width(); |
1941 | h = wid->height(); | 1977 | h = wid->height(); |
1942 | list.clear(); | 1978 | list.clear(); |
1943 | list << QString::number( x ); | 1979 | list << QString::number( x ); |
1944 | list << QString::number( y ); | 1980 | list << QString::number( y ); |
1945 | list << QString::number( w ); | 1981 | list << QString::number( w ); |
1946 | list << QString::number( h ); | 1982 | list << QString::number( h ); |
1947 | config->writeEntry("MainLayout",list ); | 1983 | config->writeEntry("MainLayout",list ); |
1948 | 1984 | ||
1949 | wid = mEventEditor; | 1985 | wid = mEventEditor; |
1950 | x = wid->geometry().x(); | 1986 | x = wid->geometry().x(); |
1951 | y = wid->geometry().y(); | 1987 | y = wid->geometry().y(); |
1952 | w = wid->width(); | 1988 | w = wid->width(); |
1953 | h = wid->height(); | 1989 | h = wid->height(); |
1954 | list.clear(); | 1990 | list.clear(); |
1955 | list << QString::number( x ); | 1991 | list << QString::number( x ); |
1956 | list << QString::number( y ); | 1992 | list << QString::number( y ); |
1957 | list << QString::number( w ); | 1993 | list << QString::number( w ); |
1958 | list << QString::number( h ); | 1994 | list << QString::number( h ); |
1959 | config->writeEntry("EditEventLayout",list ); | 1995 | config->writeEntry("EditEventLayout",list ); |
1960 | 1996 | ||
1961 | wid = mTodoEditor; | 1997 | wid = mTodoEditor; |
1962 | x = wid->geometry().x(); | 1998 | x = wid->geometry().x(); |
1963 | y = wid->geometry().y(); | 1999 | y = wid->geometry().y(); |
1964 | w = wid->width(); | 2000 | w = wid->width(); |
1965 | h = wid->height(); | 2001 | h = wid->height(); |
1966 | list.clear(); | 2002 | list.clear(); |
1967 | list << QString::number( x ); | 2003 | list << QString::number( x ); |
1968 | list << QString::number( y ); | 2004 | list << QString::number( y ); |
1969 | list << QString::number( w ); | 2005 | list << QString::number( w ); |
1970 | list << QString::number( h ); | 2006 | list << QString::number( h ); |
1971 | config->writeEntry("EditTodoLayout",list ); | 2007 | config->writeEntry("EditTodoLayout",list ); |
1972 | wid = getEventViewerDialog(); | 2008 | wid = getEventViewerDialog(); |
1973 | x = wid->geometry().x(); | 2009 | x = wid->geometry().x(); |
1974 | y = wid->geometry().y(); | 2010 | y = wid->geometry().y(); |
1975 | w = wid->width(); | 2011 | w = wid->width(); |
1976 | h = wid->height(); | 2012 | h = wid->height(); |
1977 | list.clear(); | 2013 | list.clear(); |
1978 | list << QString::number( x ); | 2014 | list << QString::number( x ); |
1979 | list << QString::number( y ); | 2015 | list << QString::number( y ); |
1980 | list << QString::number( w ); | 2016 | list << QString::number( w ); |
1981 | list << QString::number( h ); | 2017 | list << QString::number( h ); |
1982 | config->writeEntry("ViewerLayout",list ); | 2018 | config->writeEntry("ViewerLayout",list ); |
1983 | wid = mDialogManager->getSearchDialog(); | 2019 | wid = mDialogManager->getSearchDialog(); |
1984 | if ( wid ) { | 2020 | if ( wid ) { |
1985 | x = wid->geometry().x(); | 2021 | x = wid->geometry().x(); |
1986 | y = wid->geometry().y(); | 2022 | y = wid->geometry().y(); |
1987 | w = wid->width(); | 2023 | w = wid->width(); |
1988 | h = wid->height(); | 2024 | h = wid->height(); |
1989 | list.clear(); | 2025 | list.clear(); |
1990 | list << QString::number( x ); | 2026 | list << QString::number( x ); |
1991 | list << QString::number( y ); | 2027 | list << QString::number( y ); |
1992 | list << QString::number( w ); | 2028 | list << QString::number( w ); |
1993 | list << QString::number( h ); | 2029 | list << QString::number( h ); |
1994 | config->writeEntry("SearchLayout",list ); | 2030 | config->writeEntry("SearchLayout",list ); |
1995 | } | 2031 | } |
1996 | #endif | 2032 | #endif |
1997 | 2033 | ||
1998 | 2034 | ||
1999 | config->sync(); | 2035 | config->sync(); |
2000 | } | 2036 | } |
2001 | 2037 | ||
2002 | void CalendarView::readFilterSettings(KConfig *config) | 2038 | void CalendarView::readFilterSettings(KConfig *config) |
2003 | { | 2039 | { |
2004 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 2040 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
2005 | 2041 | ||
2006 | mFilters.clear(); | 2042 | mFilters.clear(); |
2007 | 2043 | ||
2008 | config->setGroup("General"); | 2044 | config->setGroup("General"); |
2009 | QStringList filterList = config->readListEntry("CalendarFilters"); | 2045 | QStringList filterList = config->readListEntry("CalendarFilters"); |
2010 | 2046 | ||
2011 | QStringList::ConstIterator it = filterList.begin(); | 2047 | QStringList::ConstIterator it = filterList.begin(); |
2012 | QStringList::ConstIterator end = filterList.end(); | 2048 | QStringList::ConstIterator end = filterList.end(); |
2013 | while(it != end) { | 2049 | while(it != end) { |
2014 | // kdDebug() << " filter: " << (*it) << endl; | 2050 | // kdDebug() << " filter: " << (*it) << endl; |
2015 | 2051 | ||
2016 | CalFilter *filter; | 2052 | CalFilter *filter; |
2017 | filter = new CalFilter(*it); | 2053 | filter = new CalFilter(*it); |
2018 | config->setGroup("Filter_" + (*it)); | 2054 | config->setGroup("Filter_" + (*it)); |
2019 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 2055 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
2020 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 2056 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
2021 | filter->setCategoryList(config->readListEntry("CategoryList")); | 2057 | filter->setCategoryList(config->readListEntry("CategoryList")); |
2022 | mFilters.append(filter); | 2058 | mFilters.append(filter); |
2023 | 2059 | ||
2024 | ++it; | 2060 | ++it; |
2025 | } | 2061 | } |
2026 | 2062 | ||
2027 | if (mFilters.count() == 0) { | 2063 | if (mFilters.count() == 0) { |
2028 | CalFilter *filter = new CalFilter(i18n("Default")); | 2064 | CalFilter *filter = new CalFilter(i18n("Default")); |
2029 | mFilters.append(filter); | 2065 | mFilters.append(filter); |
2030 | } | 2066 | } |
2031 | mFilterView->updateFilters(); | 2067 | mFilterView->updateFilters(); |
2032 | config->setGroup("FilterView"); | 2068 | config->setGroup("FilterView"); |
2033 | 2069 | ||
2034 | mFilterView->blockSignals(true); | 2070 | mFilterView->blockSignals(true); |
2035 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 2071 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
2036 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 2072 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
2037 | mFilterView->blockSignals(false); | 2073 | mFilterView->blockSignals(false); |
2038 | // We do it manually to avoid it being done twice by the above calls | 2074 | // We do it manually to avoid it being done twice by the above calls |
2039 | updateFilter(); | 2075 | updateFilter(); |
2040 | } | 2076 | } |
2041 | 2077 | ||
2042 | void CalendarView::writeFilterSettings(KConfig *config) | 2078 | void CalendarView::writeFilterSettings(KConfig *config) |
2043 | { | 2079 | { |
2044 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 2080 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
2045 | 2081 | ||
2046 | QStringList filterList; | 2082 | QStringList filterList; |
2047 | 2083 | ||
2048 | CalFilter *filter = mFilters.first(); | 2084 | CalFilter *filter = mFilters.first(); |
2049 | while(filter) { | 2085 | while(filter) { |
2050 | // kdDebug() << " fn: " << filter->name() << endl; | 2086 | // kdDebug() << " fn: " << filter->name() << endl; |
2051 | filterList << filter->name(); | 2087 | filterList << filter->name(); |
2052 | config->setGroup("Filter_" + filter->name()); | 2088 | config->setGroup("Filter_" + filter->name()); |
2053 | config->writeEntry("Criteria",filter->criteria()); | 2089 | config->writeEntry("Criteria",filter->criteria()); |
2054 | config->writeEntry("CategoryList",filter->categoryList()); | 2090 | config->writeEntry("CategoryList",filter->categoryList()); |
2055 | filter = mFilters.next(); | 2091 | filter = mFilters.next(); |
2056 | } | 2092 | } |
2057 | config->setGroup("General"); | 2093 | config->setGroup("General"); |
2058 | config->writeEntry("CalendarFilters",filterList); | 2094 | config->writeEntry("CalendarFilters",filterList); |
2059 | 2095 | ||
2060 | config->setGroup("FilterView"); | 2096 | config->setGroup("FilterView"); |
2061 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2097 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2062 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2098 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2063 | } | 2099 | } |
2064 | 2100 | ||
2065 | 2101 | ||
2066 | void CalendarView::goToday() | 2102 | void CalendarView::goToday() |
2067 | { | 2103 | { |
2068 | if ( mViewManager->currentView()->isMonthView() ) | 2104 | if ( mViewManager->currentView()->isMonthView() ) |
2069 | mNavigator->selectTodayMonth(); | 2105 | mNavigator->selectTodayMonth(); |
2070 | else | 2106 | else |
2071 | mNavigator->selectToday(); | 2107 | mNavigator->selectToday(); |
2072 | } | 2108 | } |
2073 | 2109 | ||
2074 | void CalendarView::goNext() | 2110 | void CalendarView::goNext() |
2075 | { | 2111 | { |
2076 | mNavigator->selectNext(); | 2112 | mNavigator->selectNext(); |
2077 | } | 2113 | } |
2078 | 2114 | ||
2079 | void CalendarView::goPrevious() | 2115 | void CalendarView::goPrevious() |
2080 | { | 2116 | { |
2081 | mNavigator->selectPrevious(); | 2117 | mNavigator->selectPrevious(); |
2082 | } | 2118 | } |
2083 | void CalendarView::goNextMonth() | 2119 | void CalendarView::goNextMonth() |
2084 | { | 2120 | { |
2085 | mNavigator->selectNextMonth(); | 2121 | mNavigator->selectNextMonth(); |
2086 | } | 2122 | } |
2087 | 2123 | ||
2088 | void CalendarView::goPreviousMonth() | 2124 | void CalendarView::goPreviousMonth() |
2089 | { | 2125 | { |
2090 | mNavigator->selectPreviousMonth(); | 2126 | mNavigator->selectPreviousMonth(); |
2091 | } | 2127 | } |
2092 | void CalendarView::writeLocale() | 2128 | void CalendarView::writeLocale() |
2093 | { | 2129 | { |
2094 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2130 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2095 | #if 0 | 2131 | #if 0 |
2096 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2132 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2097 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2133 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2098 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2134 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2099 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2135 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2100 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2136 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2101 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2137 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2102 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2138 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2103 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2139 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2104 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2140 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2105 | KOPrefs::instance()->mDaylightsavingStart, | 2141 | KOPrefs::instance()->mDaylightsavingStart, |
2106 | KOPrefs::instance()->mDaylightsavingEnd ); | 2142 | KOPrefs::instance()->mDaylightsavingEnd ); |
2107 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2143 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2108 | #endif | 2144 | #endif |
2109 | } | 2145 | } |
2110 | void CalendarView::updateConfig() | 2146 | void CalendarView::updateConfig() |
2111 | { | 2147 | { |
2112 | writeLocale(); | 2148 | writeLocale(); |
2113 | if ( KOPrefs::instance()->mUseAppColors ) | 2149 | if ( KOPrefs::instance()->mUseAppColors ) |
2114 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2150 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2115 | emit configChanged(); | 2151 | emit configChanged(); |
2116 | mTodoList->updateConfig(); | 2152 | mTodoList->updateConfig(); |
2117 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2153 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2118 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2154 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2119 | // To make the "fill window" configurations work | 2155 | // To make the "fill window" configurations work |
2120 | //mViewManager->raiseCurrentView(); | 2156 | //mViewManager->raiseCurrentView(); |
2121 | } | 2157 | } |
2122 | 2158 | ||
2123 | 2159 | ||
2124 | void CalendarView::eventChanged(Event *event) | 2160 | void CalendarView::eventChanged(Event *event) |
2125 | { | 2161 | { |
2126 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2162 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2127 | //updateUnmanagedViews(); | 2163 | //updateUnmanagedViews(); |
2128 | } | 2164 | } |
2129 | 2165 | ||
2130 | void CalendarView::eventAdded(Event *event) | 2166 | void CalendarView::eventAdded(Event *event) |
2131 | { | 2167 | { |
2132 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2168 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2133 | } | 2169 | } |
2134 | 2170 | ||
2135 | void CalendarView::eventToBeDeleted(Event *) | 2171 | void CalendarView::eventToBeDeleted(Event *) |
2136 | { | 2172 | { |
2137 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2173 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2138 | } | 2174 | } |
2139 | 2175 | ||
2140 | void CalendarView::eventDeleted() | 2176 | void CalendarView::eventDeleted() |
2141 | { | 2177 | { |
2142 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2178 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2143 | } | 2179 | } |
2144 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2180 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2145 | { | 2181 | { |
2146 | changeIncidenceDisplay((Incidence *)which, action); | 2182 | changeIncidenceDisplay((Incidence *)which, action); |
2147 | mDateNavigator->updateView(); //LR | 2183 | mDateNavigator->updateView(); //LR |
2148 | //mDialogManager->updateSearchDialog(); | 2184 | //mDialogManager->updateSearchDialog(); |
2149 | 2185 | ||
2150 | if (which) { | 2186 | if (which) { |
2151 | mViewManager->updateWNview(); | 2187 | mViewManager->updateWNview(); |
2152 | //mTodoList->updateView(); | 2188 | //mTodoList->updateView(); |
2153 | } | 2189 | } |
2154 | 2190 | ||
2155 | } | 2191 | } |
2156 | 2192 | ||
2157 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2193 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2158 | { | 2194 | { |
2159 | updateUnmanagedViews(); | 2195 | updateUnmanagedViews(); |
2160 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2196 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2161 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2197 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2162 | mCalendar->checkAlarmForIncidence( 0, true ); | 2198 | mCalendar->checkAlarmForIncidence( 0, true ); |
2163 | if ( mEventViewerDialog ) | 2199 | if ( mEventViewerDialog ) |
2164 | mEventViewerDialog->hide(); | 2200 | mEventViewerDialog->hide(); |
2165 | } | 2201 | } |
2166 | else | 2202 | else |
2167 | mCalendar->checkAlarmForIncidence( which , false ); | 2203 | mCalendar->checkAlarmForIncidence( which , false ); |
2168 | } | 2204 | } |
2169 | 2205 | ||
2170 | // most of the changeEventDisplays() right now just call the view's | 2206 | // most of the changeEventDisplays() right now just call the view's |
2171 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2207 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2172 | void CalendarView::changeEventDisplay(Event *which, int action) | 2208 | void CalendarView::changeEventDisplay(Event *which, int action) |
2173 | { | 2209 | { |
2174 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2210 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2175 | changeIncidenceDisplay((Incidence *)which, action); | 2211 | changeIncidenceDisplay((Incidence *)which, action); |
2176 | mDateNavigator->updateView(); | 2212 | mDateNavigator->updateView(); |
2177 | //mDialogManager->updateSearchDialog(); | 2213 | //mDialogManager->updateSearchDialog(); |
2178 | 2214 | ||
2179 | if (which) { | 2215 | if (which) { |
2180 | // If there is an event view visible update the display | 2216 | // If there is an event view visible update the display |
2181 | mViewManager->currentView()->changeEventDisplay(which,action); | 2217 | mViewManager->currentView()->changeEventDisplay(which,action); |
2182 | // TODO: check, if update needed | 2218 | // TODO: check, if update needed |
2183 | // if (which->getTodoStatus()) { | 2219 | // if (which->getTodoStatus()) { |
2184 | mTodoList->updateView(); | 2220 | mTodoList->updateView(); |
2185 | // } | 2221 | // } |
2186 | } else { | 2222 | } else { |
2187 | mViewManager->currentView()->updateView(); | 2223 | mViewManager->currentView()->updateView(); |
2188 | } | 2224 | } |
2189 | } | 2225 | } |
2190 | 2226 | ||
2191 | 2227 | ||
2192 | void CalendarView::updateTodoViews() | 2228 | void CalendarView::updateTodoViews() |
2193 | { | 2229 | { |
2194 | mTodoList->updateView(); | 2230 | mTodoList->updateView(); |
2195 | mViewManager->currentView()->updateView(); | 2231 | mViewManager->currentView()->updateView(); |
2196 | 2232 | ||
2197 | } | 2233 | } |
2198 | 2234 | ||
2199 | 2235 | ||
2200 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2236 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2201 | { | 2237 | { |
2202 | mTodoList->updateView(); | 2238 | mTodoList->updateView(); |
2203 | mViewManager->updateView(start, end); | 2239 | mViewManager->updateView(start, end); |
2204 | //mDateNavigator->updateView(); | 2240 | //mDateNavigator->updateView(); |
2205 | } | 2241 | } |
2206 | 2242 | ||
2207 | void CalendarView::updateView() | 2243 | void CalendarView::updateView() |
2208 | { | 2244 | { |
2209 | DateList tmpList = mNavigator->selectedDates(); | 2245 | DateList tmpList = mNavigator->selectedDates(); |
2210 | 2246 | ||
2211 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2247 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2212 | mTodoList->updateView(); | 2248 | mTodoList->updateView(); |
2213 | // We assume that the navigator only selects consecutive days. | 2249 | // We assume that the navigator only selects consecutive days. |
2214 | updateView( tmpList.first(), tmpList.last() ); | 2250 | updateView( tmpList.first(), tmpList.last() ); |
2215 | } | 2251 | } |
2216 | 2252 | ||
2217 | void CalendarView::updateUnmanagedViews() | 2253 | void CalendarView::updateUnmanagedViews() |
2218 | { | 2254 | { |
2219 | mDateNavigator->updateDayMatrix(); | 2255 | mDateNavigator->updateDayMatrix(); |
2220 | } | 2256 | } |
2221 | 2257 | ||
2222 | int CalendarView::msgItemDelete(const QString name) | 2258 | int CalendarView::msgItemDelete(const QString name) |
2223 | { | 2259 | { |
2224 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2260 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2225 | i18n("This item will be\npermanently deleted."), | 2261 | i18n("This item will be\npermanently deleted."), |
2226 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2262 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2227 | } | 2263 | } |
2228 | 2264 | ||
2229 | 2265 | ||
2230 | void CalendarView::edit_cut() | 2266 | void CalendarView::edit_cut() |
2231 | { | 2267 | { |
2232 | Event *anEvent=0; | 2268 | Event *anEvent=0; |
2233 | 2269 | ||
2234 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2270 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2235 | 2271 | ||
2236 | if (mViewManager->currentView()->isEventView()) { | 2272 | if (mViewManager->currentView()->isEventView()) { |
2237 | if ( incidence && incidence->type() == "Event" ) { | 2273 | if ( incidence && incidence->type() == "Event" ) { |
2238 | anEvent = static_cast<Event *>(incidence); | 2274 | anEvent = static_cast<Event *>(incidence); |
2239 | } | 2275 | } |
2240 | } | 2276 | } |
2241 | 2277 | ||
2242 | if (!anEvent) { | 2278 | if (!anEvent) { |
2243 | KNotifyClient::beep(); | 2279 | KNotifyClient::beep(); |
2244 | return; | 2280 | return; |
2245 | } | 2281 | } |
2246 | DndFactory factory( mCalendar ); | 2282 | DndFactory factory( mCalendar ); |
2247 | factory.cutIncidence(anEvent); | 2283 | factory.cutIncidence(anEvent); |
2248 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2284 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2249 | } | 2285 | } |
2250 | 2286 | ||
2251 | void CalendarView::edit_copy() | 2287 | void CalendarView::edit_copy() |
2252 | { | 2288 | { |
2253 | Event *anEvent=0; | 2289 | Event *anEvent=0; |
2254 | 2290 | ||
2255 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2291 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2256 | 2292 | ||
2257 | if (mViewManager->currentView()->isEventView()) { | 2293 | if (mViewManager->currentView()->isEventView()) { |
2258 | if ( incidence && incidence->type() == "Event" ) { | 2294 | if ( incidence && incidence->type() == "Event" ) { |
2259 | anEvent = static_cast<Event *>(incidence); | 2295 | anEvent = static_cast<Event *>(incidence); |
2260 | } | 2296 | } |
2261 | } | 2297 | } |
2262 | 2298 | ||
2263 | if (!anEvent) { | 2299 | if (!anEvent) { |
2264 | KNotifyClient::beep(); | 2300 | KNotifyClient::beep(); |
2265 | return; | 2301 | return; |
2266 | } | 2302 | } |
2267 | DndFactory factory( mCalendar ); | 2303 | DndFactory factory( mCalendar ); |
2268 | factory.copyIncidence(anEvent); | 2304 | factory.copyIncidence(anEvent); |
2269 | } | 2305 | } |
2270 | 2306 | ||
2271 | void CalendarView::edit_paste() | 2307 | void CalendarView::edit_paste() |
2272 | { | 2308 | { |
2273 | QDate date = mNavigator->selectedDates().first(); | 2309 | QDate date = mNavigator->selectedDates().first(); |
2274 | 2310 | ||
2275 | DndFactory factory( mCalendar ); | 2311 | DndFactory factory( mCalendar ); |
2276 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2312 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2277 | 2313 | ||
2278 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2314 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2279 | } | 2315 | } |
2280 | 2316 | ||
2281 | void CalendarView::edit_options() | 2317 | void CalendarView::edit_options() |
2282 | { | 2318 | { |
2283 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2319 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2284 | emit save(); | 2320 | emit save(); |
2285 | emit saveStopTimer(); | 2321 | emit saveStopTimer(); |
2286 | mDialogManager->showOptionsDialog(); | 2322 | mDialogManager->showOptionsDialog(); |
2287 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2323 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2288 | emit saveStopTimer(); | 2324 | emit saveStopTimer(); |
2289 | 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!"), | 2325 | 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!"), |
2290 | i18n("Timezone settings"),i18n("Reload"))) { | 2326 | i18n("Timezone settings"),i18n("Reload"))) { |
2291 | qDebug("KO: TZ reload cancelled "); | 2327 | qDebug("KO: TZ reload cancelled "); |
2292 | return; | 2328 | return; |
2293 | } | 2329 | } |
2294 | qDebug("KO: Timezone change "); | 2330 | qDebug("KO: Timezone change "); |
2295 | openCalendar( MainWindow::defaultFileName() ); | 2331 | openCalendar( MainWindow::defaultFileName() ); |
2296 | setModified(true); | 2332 | setModified(true); |
2297 | } | 2333 | } |
2298 | else | 2334 | else |
2299 | qDebug("KO: No tz change "); | 2335 | qDebug("KO: No tz change "); |
2300 | 2336 | ||
2301 | } | 2337 | } |
2302 | 2338 | ||
2303 | 2339 | ||
2304 | void CalendarView::slotSelectPickerDate( QDate d) | 2340 | void CalendarView::slotSelectPickerDate( QDate d) |
2305 | { | 2341 | { |
2306 | mDateFrame->hide(); | 2342 | mDateFrame->hide(); |
2307 | if ( mDatePickerMode == 1 ) { | 2343 | if ( mDatePickerMode == 1 ) { |
2308 | mNavigator->slotDaySelect( d ); | 2344 | mNavigator->slotDaySelect( d ); |
2309 | } else if ( mDatePickerMode == 2 ) { | 2345 | } else if ( mDatePickerMode == 2 ) { |
2310 | if ( mMoveIncidence->type() == "Todo" ) { | 2346 | if ( mMoveIncidence->type() == "Todo" ) { |
2311 | Todo * to = (Todo *) mMoveIncidence; | 2347 | Todo * to = (Todo *) mMoveIncidence; |
2312 | QTime tim; | 2348 | QTime tim; |
2313 | int len = 0; | 2349 | int len = 0; |
2314 | if ( to->hasStartDate() && to->hasDueDate() ) | 2350 | if ( to->hasStartDate() && to->hasDueDate() ) |
2315 | len = to->dtStart().secsTo( to->dtDue()); | 2351 | len = to->dtStart().secsTo( to->dtDue()); |
2316 | if ( to->hasDueDate() ) | 2352 | if ( to->hasDueDate() ) |
2317 | tim = to->dtDue().time(); | 2353 | tim = to->dtDue().time(); |
2318 | else { | 2354 | else { |
2319 | tim = QTime ( 0,0,0 ); | 2355 | tim = QTime ( 0,0,0 ); |
2320 | to->setFloats( true ); | 2356 | to->setFloats( true ); |
2321 | to->setHasDueDate( true ); | 2357 | to->setHasDueDate( true ); |
2322 | } | 2358 | } |
2323 | QDateTime dt ( d,tim ); | 2359 | QDateTime dt ( d,tim ); |
2324 | to->setDtDue( dt ); | 2360 | to->setDtDue( dt ); |
2325 | 2361 | ||
2326 | if ( to->hasStartDate() ) { | 2362 | if ( to->hasStartDate() ) { |
2327 | if ( len>0 ) | 2363 | if ( len>0 ) |
2328 | to->setDtStart(to->dtDue().addSecs( -len )); | 2364 | to->setDtStart(to->dtDue().addSecs( -len )); |
2329 | else | 2365 | else |
2330 | if (to->dtStart() > to->dtDue() ) | 2366 | if (to->dtStart() > to->dtDue() ) |
2331 | to->setDtStart(to->dtDue().addDays( -3 )); | 2367 | to->setDtStart(to->dtDue().addDays( -3 )); |
2332 | } | 2368 | } |
2333 | 2369 | ||
2334 | todoChanged( to ); | 2370 | todoChanged( to ); |
2335 | } else { | 2371 | } else { |
2336 | if ( mMoveIncidence->doesRecur() ) { | 2372 | if ( mMoveIncidence->doesRecur() ) { |
2337 | #if 0 | 2373 | #if 0 |
2338 | // PENDING implement this | 2374 | // PENDING implement this |
2339 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2375 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2340 | mCalendar()->addIncidence( newInc ); | 2376 | mCalendar()->addIncidence( newInc ); |
2341 | if ( mMoveIncidence->type() == "Todo" ) | 2377 | if ( mMoveIncidence->type() == "Todo" ) |
2342 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2378 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2343 | else | 2379 | else |
2344 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2380 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2345 | mMoveIncidence = newInc; | 2381 | mMoveIncidence = newInc; |
2346 | 2382 | ||
2347 | #endif | 2383 | #endif |
2348 | } | 2384 | } |
2349 | QTime tim = mMoveIncidence->dtStart().time(); | 2385 | QTime tim = mMoveIncidence->dtStart().time(); |
2350 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2386 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2351 | QDateTime dt ( d,tim ); | 2387 | QDateTime dt ( d,tim ); |
2352 | mMoveIncidence->setDtStart( dt ); | 2388 | mMoveIncidence->setDtStart( dt ); |
2353 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2389 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2354 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2390 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2355 | } | 2391 | } |
2356 | 2392 | ||
2357 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2393 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2358 | } | 2394 | } |
2359 | } | 2395 | } |
2360 | 2396 | ||
2361 | void CalendarView::removeCategories() | 2397 | void CalendarView::removeCategories() |
2362 | { | 2398 | { |
2363 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2399 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2364 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2400 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2365 | QStringList catIncList; | 2401 | QStringList catIncList; |
2366 | QStringList newCatList; | 2402 | QStringList newCatList; |
2367 | Incidence* inc = incList.first(); | 2403 | Incidence* inc = incList.first(); |
2368 | int i; | 2404 | int i; |
2369 | int count = 0; | 2405 | int count = 0; |
2370 | while ( inc ) { | 2406 | while ( inc ) { |
2371 | newCatList.clear(); | 2407 | newCatList.clear(); |
2372 | catIncList = inc->categories() ; | 2408 | catIncList = inc->categories() ; |
2373 | for( i = 0; i< catIncList.count(); ++i ) { | 2409 | for( i = 0; i< catIncList.count(); ++i ) { |
2374 | if ( catList.contains (catIncList[i])) | 2410 | if ( catList.contains (catIncList[i])) |
2375 | newCatList.append( catIncList[i] ); | 2411 | newCatList.append( catIncList[i] ); |
2376 | } | 2412 | } |
2377 | newCatList.sort(); | 2413 | newCatList.sort(); |
2378 | inc->setCategories( newCatList.join(",") ); | 2414 | inc->setCategories( newCatList.join(",") ); |
2379 | inc = incList.next(); | 2415 | inc = incList.next(); |
2380 | } | 2416 | } |
2381 | } | 2417 | } |
2382 | 2418 | ||
2383 | int CalendarView::addCategories() | 2419 | int CalendarView::addCategories() |
2384 | { | 2420 | { |
2385 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2421 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2386 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2422 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2387 | QStringList catIncList; | 2423 | QStringList catIncList; |
2388 | Incidence* inc = incList.first(); | 2424 | Incidence* inc = incList.first(); |
2389 | int i; | 2425 | int i; |
2390 | int count = 0; | 2426 | int count = 0; |
2391 | while ( inc ) { | 2427 | while ( inc ) { |
2392 | catIncList = inc->categories() ; | 2428 | catIncList = inc->categories() ; |
2393 | for( i = 0; i< catIncList.count(); ++i ) { | 2429 | for( i = 0; i< catIncList.count(); ++i ) { |
2394 | if ( !catList.contains (catIncList[i])) { | 2430 | if ( !catList.contains (catIncList[i])) { |
2395 | catList.append( catIncList[i] ); | 2431 | catList.append( catIncList[i] ); |
2396 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2432 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2397 | ++count; | 2433 | ++count; |
2398 | } | 2434 | } |
2399 | } | 2435 | } |
2400 | inc = incList.next(); | 2436 | inc = incList.next(); |
2401 | } | 2437 | } |
2402 | catList.sort(); | 2438 | catList.sort(); |
2403 | KOPrefs::instance()->mCustomCategories = catList; | 2439 | KOPrefs::instance()->mCustomCategories = catList; |
2404 | return count; | 2440 | return count; |
2405 | } | 2441 | } |
2406 | 2442 | ||
2407 | void CalendarView::manageCategories() | 2443 | void CalendarView::manageCategories() |
2408 | { | 2444 | { |
2409 | KOCatPrefs* cp = new KOCatPrefs(); | 2445 | KOCatPrefs* cp = new KOCatPrefs(); |
2410 | cp->show(); | 2446 | cp->show(); |
2411 | int w =cp->sizeHint().width() ; | 2447 | int w =cp->sizeHint().width() ; |
2412 | int h = cp->sizeHint().height() ; | 2448 | int h = cp->sizeHint().height() ; |
2413 | int dw = QApplication::desktop()->width(); | 2449 | int dw = QApplication::desktop()->width(); |
2414 | int dh = QApplication::desktop()->height(); | 2450 | int dh = QApplication::desktop()->height(); |
2415 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2451 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2416 | if ( !cp->exec() ) { | 2452 | if ( !cp->exec() ) { |
2417 | delete cp; | 2453 | delete cp; |
2418 | return; | 2454 | return; |
2419 | } | 2455 | } |
2420 | int count = 0; | 2456 | int count = 0; |
2421 | if ( cp->addCat() ) { | 2457 | if ( cp->addCat() ) { |
2422 | count = addCategories(); | 2458 | count = addCategories(); |
2423 | if ( count ) { | 2459 | if ( count ) { |
2424 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2460 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2425 | writeSettings(); | 2461 | writeSettings(); |
2426 | } else | 2462 | } else |
2427 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2463 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2428 | } else { | 2464 | } else { |
2429 | removeCategories(); | 2465 | removeCategories(); |
2430 | updateView(); | 2466 | updateView(); |
2431 | } | 2467 | } |
2432 | delete cp; | 2468 | delete cp; |
2433 | } | 2469 | } |
2434 | 2470 | ||
2435 | void CalendarView::beamIncidence(Incidence * Inc) | 2471 | void CalendarView::beamIncidence(Incidence * Inc) |
2436 | { | 2472 | { |
2437 | QPtrList<Incidence> delSel ; | 2473 | QPtrList<Incidence> delSel ; |
2438 | delSel.append(Inc); | 2474 | delSel.append(Inc); |
2439 | beamIncidenceList( delSel ); | 2475 | beamIncidenceList( delSel ); |
2440 | } | 2476 | } |
2441 | void CalendarView::beamCalendar() | 2477 | void CalendarView::beamCalendar() |
2442 | { | 2478 | { |
2443 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2479 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2444 | //qDebug("beamCalendar() "); | 2480 | //qDebug("beamCalendar() "); |
2445 | beamIncidenceList( delSel ); | 2481 | beamIncidenceList( delSel ); |
2446 | } | 2482 | } |
2447 | void CalendarView::beamFilteredCalendar() | 2483 | void CalendarView::beamFilteredCalendar() |
2448 | { | 2484 | { |
2449 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2485 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2450 | //qDebug("beamFilteredCalendar() "); | 2486 | //qDebug("beamFilteredCalendar() "); |
2451 | beamIncidenceList( delSel ); | 2487 | beamIncidenceList( delSel ); |
2452 | } | 2488 | } |
2453 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2489 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2454 | { | 2490 | { |
2455 | if ( beamDialog->exec () == QDialog::Rejected ) | 2491 | if ( beamDialog->exec () == QDialog::Rejected ) |
2456 | return; | 2492 | return; |
2457 | #ifdef DESKTOP_VERSION | 2493 | #ifdef DESKTOP_VERSION |
2458 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2494 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2459 | #else | 2495 | #else |
2460 | QString fn = "/tmp/kopibeamfile"; | 2496 | QString fn = "/tmp/kopibeamfile"; |
2461 | #endif | 2497 | #endif |
2462 | QString mes; | 2498 | QString mes; |
2463 | bool createbup = true; | 2499 | bool createbup = true; |
2464 | if ( createbup ) { | 2500 | if ( createbup ) { |
2465 | QString description = "\n"; | 2501 | QString description = "\n"; |
2466 | CalendarLocal* cal = new CalendarLocal(); | 2502 | CalendarLocal* cal = new CalendarLocal(); |
2467 | if ( beamDialog->beamLocal() ) | 2503 | if ( beamDialog->beamLocal() ) |
2468 | cal->setLocalTime(); | 2504 | cal->setLocalTime(); |
2469 | else | 2505 | else |
2470 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2506 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2471 | Incidence *incidence = delSel.first(); | 2507 | Incidence *incidence = delSel.first(); |
2472 | bool addText = false; | 2508 | bool addText = false; |
2473 | if ( delSel.count() < 10 ) | 2509 | if ( delSel.count() < 10 ) |
2474 | addText = true; | 2510 | addText = true; |
2475 | else { | 2511 | else { |
2476 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2512 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2477 | } | 2513 | } |
2478 | while ( incidence ) { | 2514 | while ( incidence ) { |
2479 | Incidence *in = incidence->clone(); | 2515 | Incidence *in = incidence->clone(); |
2480 | if ( ! in->summary().isEmpty() ) { | 2516 | if ( ! in->summary().isEmpty() ) { |
2481 | in->setDescription(""); | 2517 | in->setDescription(""); |
2482 | } else { | 2518 | } else { |
2483 | in->setSummary( in->description().left(20)); | 2519 | in->setSummary( in->description().left(20)); |
2484 | in->setDescription(""); | 2520 | in->setDescription(""); |
2485 | } | 2521 | } |
2486 | if ( addText ) | 2522 | if ( addText ) |
2487 | description += in->summary() + "\n"; | 2523 | description += in->summary() + "\n"; |
2488 | cal->addIncidence( in ); | 2524 | cal->addIncidence( in ); |
2489 | incidence = delSel.next(); | 2525 | incidence = delSel.next(); |
2490 | } | 2526 | } |
2491 | if ( beamDialog->beamVcal() ) { | 2527 | if ( beamDialog->beamVcal() ) { |
2492 | fn += ".vcs"; | 2528 | fn += ".vcs"; |
2493 | FileStorage storage( cal, fn, new VCalFormat ); | 2529 | FileStorage storage( cal, fn, new VCalFormat ); |
2494 | storage.save(); | 2530 | storage.save(); |
2495 | } else { | 2531 | } else { |
2496 | fn += ".ics"; | 2532 | fn += ".ics"; |
2497 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2533 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2498 | storage.save(); | 2534 | storage.save(); |
2499 | } | 2535 | } |
2500 | delete cal; | 2536 | delete cal; |
2501 | mes = i18n("KO/Pi: Ready for beaming"); | 2537 | mes = i18n("KO/Pi: Ready for beaming"); |
2502 | topLevelWidget()->setCaption(mes); | 2538 | topLevelWidget()->setCaption(mes); |
2503 | KApplication::convert2latin1( fn ); | 2539 | KApplication::convert2latin1( fn ); |
2504 | #ifndef DESKTOP_VERSION | 2540 | #ifndef DESKTOP_VERSION |
2505 | Ir *ir = new Ir( this ); | 2541 | Ir *ir = new Ir( this ); |
2506 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2542 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2507 | ir->send( fn, description, "text/x-vCalendar" ); | 2543 | ir->send( fn, description, "text/x-vCalendar" ); |
2508 | #endif | 2544 | #endif |
2509 | } | 2545 | } |
2510 | } | 2546 | } |
2511 | void CalendarView::beamDone( Ir *ir ) | 2547 | void CalendarView::beamDone( Ir *ir ) |
2512 | { | 2548 | { |
2513 | #ifndef DESKTOP_VERSION | 2549 | #ifndef DESKTOP_VERSION |
2514 | delete ir; | 2550 | delete ir; |
2515 | #endif | 2551 | #endif |
2516 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2552 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2517 | topLevelWidget()->raise(); | 2553 | topLevelWidget()->raise(); |
2518 | } | 2554 | } |
2519 | 2555 | ||
2520 | void CalendarView::moveIncidence(Incidence * inc ) | 2556 | void CalendarView::moveIncidence(Incidence * inc ) |
2521 | { | 2557 | { |
2522 | if ( !inc ) return; | 2558 | if ( !inc ) return; |
2523 | showDatePickerPopup(); | 2559 | showDatePickerPopup(); |
2524 | mDatePickerMode = 2; | 2560 | mDatePickerMode = 2; |
2525 | mMoveIncidence = inc ; | 2561 | mMoveIncidence = inc ; |
2526 | QDate da; | 2562 | QDate da; |
2527 | if ( mMoveIncidence->type() == "Todo" ) { | 2563 | if ( mMoveIncidence->type() == "Todo" ) { |
2528 | Todo * to = (Todo *) mMoveIncidence; | 2564 | Todo * to = (Todo *) mMoveIncidence; |
2529 | if ( to->hasDueDate() ) | 2565 | if ( to->hasDueDate() ) |
2530 | da = to->dtDue().date(); | 2566 | da = to->dtDue().date(); |
2531 | else | 2567 | else |
2532 | da = QDate::currentDate(); | 2568 | da = QDate::currentDate(); |
2533 | } else { | 2569 | } else { |
2534 | da = mMoveIncidence->dtStart().date(); | 2570 | da = mMoveIncidence->dtStart().date(); |
2535 | } | 2571 | } |
2536 | //PENDING set date for recurring incidence to date of recurrence | 2572 | //PENDING set date for recurring incidence to date of recurrence |
2537 | //mMoveIncidenceOldDate; | 2573 | //mMoveIncidenceOldDate; |
2538 | mDatePicker->setDate( da ); | 2574 | mDatePicker->setDate( da ); |
2539 | } | 2575 | } |
2540 | void CalendarView::showDatePickerPopup() | 2576 | void CalendarView::showDatePickerPopup() |
2541 | { | 2577 | { |
2542 | if ( mDateFrame->isVisible() ) | 2578 | if ( mDateFrame->isVisible() ) |
2543 | mDateFrame->hide(); | 2579 | mDateFrame->hide(); |
2544 | else { | 2580 | else { |
2545 | int offX = 0, offY = 0; | 2581 | int offX = 0, offY = 0; |
2546 | #ifdef DESKTOP_VERSION | 2582 | #ifdef DESKTOP_VERSION |
2547 | int w =mDatePicker->sizeHint().width() ; | 2583 | int w =mDatePicker->sizeHint().width() ; |
2548 | int h = mDatePicker->sizeHint().height() ; | 2584 | int h = mDatePicker->sizeHint().height() ; |
2549 | int dw = topLevelWidget()->width(); | 2585 | int dw = topLevelWidget()->width(); |
2550 | int dh = topLevelWidget()->height(); | 2586 | int dh = topLevelWidget()->height(); |
2551 | offX = topLevelWidget()->x(); | 2587 | offX = topLevelWidget()->x(); |
2552 | offY = topLevelWidget()->y(); | 2588 | offY = topLevelWidget()->y(); |
2553 | #else | 2589 | #else |
2554 | int w =mDatePicker->sizeHint().width() ; | 2590 | int w =mDatePicker->sizeHint().width() ; |
2555 | int h = mDatePicker->sizeHint().height() ; | 2591 | int h = mDatePicker->sizeHint().height() ; |
2556 | int dw = QApplication::desktop()->width(); | 2592 | int dw = QApplication::desktop()->width(); |
2557 | int dh = QApplication::desktop()->height(); | 2593 | int dh = QApplication::desktop()->height(); |
2558 | #endif | 2594 | #endif |
2559 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2595 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2560 | mDateFrame->show(); | 2596 | mDateFrame->show(); |
2561 | } | 2597 | } |
2562 | } | 2598 | } |
2563 | void CalendarView::showDatePicker( ) | 2599 | void CalendarView::showDatePicker( ) |
2564 | { | 2600 | { |
2565 | showDatePickerPopup(); | 2601 | showDatePickerPopup(); |
2566 | mDatePickerMode = 1; | 2602 | mDatePickerMode = 1; |
2567 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2603 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2568 | } | 2604 | } |
2569 | 2605 | ||
2570 | void CalendarView::showEventEditor() | 2606 | void CalendarView::showEventEditor() |
2571 | { | 2607 | { |
2572 | #ifdef DESKTOP_VERSION | 2608 | #ifdef DESKTOP_VERSION |
2573 | int x,y,w,h; | 2609 | int x,y,w,h; |
2574 | x = mEventEditor->geometry().x(); | 2610 | x = mEventEditor->geometry().x(); |
2575 | y = mEventEditor->geometry().y(); | 2611 | y = mEventEditor->geometry().y(); |
2576 | w = mEventEditor->width(); | 2612 | w = mEventEditor->width(); |
2577 | h = mEventEditor->height(); | 2613 | h = mEventEditor->height(); |
2578 | mEventEditor->show(); | 2614 | mEventEditor->show(); |
2579 | mEventEditor->setGeometry(x,y,w,h); | 2615 | mEventEditor->setGeometry(x,y,w,h); |
2580 | #else | 2616 | #else |
2581 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2617 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2582 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2618 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2583 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2619 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2584 | qApp->processEvents(); | 2620 | qApp->processEvents(); |
2585 | delete mEventEditor; | 2621 | delete mEventEditor; |
2586 | mEventEditor = mDialogManager->getEventEditor(); | 2622 | mEventEditor = mDialogManager->getEventEditor(); |
2587 | topLevelWidget()->setCaption( i18n("") ); | 2623 | topLevelWidget()->setCaption( i18n("") ); |
2588 | } | 2624 | } |
2589 | mEventEditor->showMaximized(); | 2625 | mEventEditor->showMaximized(); |
2590 | #endif | 2626 | #endif |
2591 | } | 2627 | } |
2592 | void CalendarView::showTodoEditor() | 2628 | void CalendarView::showTodoEditor() |
2593 | { | 2629 | { |
2594 | #ifdef DESKTOP_VERSION | 2630 | #ifdef DESKTOP_VERSION |
2595 | int x,y,w,h; | 2631 | int x,y,w,h; |
2596 | x = mTodoEditor->geometry().x(); | 2632 | x = mTodoEditor->geometry().x(); |
2597 | y = mTodoEditor->geometry().y(); | 2633 | y = mTodoEditor->geometry().y(); |
2598 | w = mTodoEditor->width(); | 2634 | w = mTodoEditor->width(); |
2599 | h = mTodoEditor->height(); | 2635 | h = mTodoEditor->height(); |
2600 | mTodoEditor->show(); | 2636 | mTodoEditor->show(); |
2601 | mTodoEditor->setGeometry(x,y,w,h); | 2637 | mTodoEditor->setGeometry(x,y,w,h); |
2602 | #else | 2638 | #else |
2603 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2639 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2604 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2640 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2605 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2641 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2606 | qApp->processEvents(); | 2642 | qApp->processEvents(); |
2607 | delete mTodoEditor; | 2643 | delete mTodoEditor; |
2608 | mTodoEditor = mDialogManager->getTodoEditor(); | 2644 | mTodoEditor = mDialogManager->getTodoEditor(); |
2609 | topLevelWidget()->setCaption( i18n("") ); | 2645 | topLevelWidget()->setCaption( i18n("") ); |
2610 | } | 2646 | } |
2611 | mTodoEditor->showMaximized(); | 2647 | mTodoEditor->showMaximized(); |
2612 | #endif | 2648 | #endif |
2613 | } | 2649 | } |
2614 | 2650 | ||
2615 | void CalendarView::cloneIncidence() | 2651 | void CalendarView::cloneIncidence() |
2616 | { | 2652 | { |
2617 | Incidence *incidence = currentSelection(); | 2653 | Incidence *incidence = currentSelection(); |
2618 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2654 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2619 | if ( incidence ) { | 2655 | if ( incidence ) { |
2620 | cloneIncidence(incidence); | 2656 | cloneIncidence(incidence); |
2621 | } | 2657 | } |
2622 | } | 2658 | } |
2623 | void CalendarView::moveIncidence() | 2659 | void CalendarView::moveIncidence() |
2624 | { | 2660 | { |
2625 | Incidence *incidence = currentSelection(); | 2661 | Incidence *incidence = currentSelection(); |
2626 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2662 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2627 | if ( incidence ) { | 2663 | if ( incidence ) { |
2628 | moveIncidence(incidence); | 2664 | moveIncidence(incidence); |
2629 | } | 2665 | } |
2630 | } | 2666 | } |
2631 | void CalendarView::beamIncidence() | 2667 | void CalendarView::beamIncidence() |
2632 | { | 2668 | { |
2633 | Incidence *incidence = currentSelection(); | 2669 | Incidence *incidence = currentSelection(); |
2634 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2670 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2635 | if ( incidence ) { | 2671 | if ( incidence ) { |
2636 | beamIncidence(incidence); | 2672 | beamIncidence(incidence); |
2637 | } | 2673 | } |
2638 | } | 2674 | } |
2639 | void CalendarView::toggleCancelIncidence() | 2675 | void CalendarView::toggleCancelIncidence() |
2640 | { | 2676 | { |
2641 | Incidence *incidence = currentSelection(); | 2677 | Incidence *incidence = currentSelection(); |
2642 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2678 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2643 | if ( incidence ) { | 2679 | if ( incidence ) { |
2644 | cancelIncidence(incidence); | 2680 | cancelIncidence(incidence); |
2645 | } | 2681 | } |
2646 | } | 2682 | } |
2647 | 2683 | ||
2648 | 2684 | ||
2649 | void CalendarView::cancelIncidence(Incidence * inc ) | 2685 | void CalendarView::cancelIncidence(Incidence * inc ) |
2650 | { | 2686 | { |
2651 | inc->setCancelled( ! inc->cancelled() ); | 2687 | inc->setCancelled( ! inc->cancelled() ); |
2652 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2688 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2653 | updateView(); | 2689 | updateView(); |
2654 | } | 2690 | } |
2655 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2691 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2656 | { | 2692 | { |
2657 | Incidence * newInc = orgInc->clone(); | 2693 | Incidence * newInc = orgInc->clone(); |
2658 | newInc->recreate(); | 2694 | newInc->recreate(); |
2659 | 2695 | ||
2660 | if ( newInc->type() == "Todo" ) { | 2696 | if ( newInc->type() == "Todo" ) { |
2661 | Todo* t = (Todo*) newInc; | 2697 | Todo* t = (Todo*) newInc; |
2662 | showTodoEditor(); | 2698 | showTodoEditor(); |
2663 | mTodoEditor->editTodo( t ); | 2699 | mTodoEditor->editTodo( t ); |
2664 | if ( mTodoEditor->exec() ) { | 2700 | if ( mTodoEditor->exec() ) { |
2665 | mCalendar->addTodo( t ); | 2701 | mCalendar->addTodo( t ); |
2666 | updateView(); | 2702 | updateView(); |
2667 | } else { | 2703 | } else { |
2668 | delete t; | 2704 | delete t; |
2669 | } | 2705 | } |
2670 | } | 2706 | } |
2671 | else { | 2707 | else { |
2672 | Event* e = (Event*) newInc; | 2708 | Event* e = (Event*) newInc; |
2673 | showEventEditor(); | 2709 | showEventEditor(); |
2674 | mEventEditor->editEvent( e ); | 2710 | mEventEditor->editEvent( e ); |
2675 | if ( mEventEditor->exec() ) { | 2711 | if ( mEventEditor->exec() ) { |
2676 | mCalendar->addEvent( e ); | 2712 | mCalendar->addEvent( e ); |
2677 | updateView(); | 2713 | updateView(); |
2678 | } else { | 2714 | } else { |
2679 | delete e; | 2715 | delete e; |
2680 | } | 2716 | } |
2681 | } | 2717 | } |
2682 | setActiveWindow(); | 2718 | setActiveWindow(); |
2683 | } | 2719 | } |
2684 | 2720 | ||
2685 | void CalendarView::newEvent() | 2721 | void CalendarView::newEvent() |
2686 | { | 2722 | { |
2687 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2723 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2688 | KOAgendaView *aView = mViewManager->agendaView(); | 2724 | KOAgendaView *aView = mViewManager->agendaView(); |
2689 | if (aView) { | 2725 | if (aView) { |
2690 | if (aView->selectionStart().isValid()) { | 2726 | if (aView->selectionStart().isValid()) { |
2691 | if (aView->selectedIsAllDay()) { | 2727 | if (aView->selectedIsAllDay()) { |
2692 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2728 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2693 | } else { | 2729 | } else { |
2694 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2730 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2695 | } | 2731 | } |
2696 | return; | 2732 | return; |
2697 | } | 2733 | } |
2698 | } | 2734 | } |
2699 | 2735 | ||
2700 | QDate date = mNavigator->selectedDates().first(); | 2736 | QDate date = mNavigator->selectedDates().first(); |
2701 | QDateTime current = QDateTime::currentDateTime(); | 2737 | QDateTime current = QDateTime::currentDateTime(); |
2702 | if ( date <= current.date() ) { | 2738 | if ( date <= current.date() ) { |
2703 | int hour = current.time().hour() +1; | 2739 | int hour = current.time().hour() +1; |
2704 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2740 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2705 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2741 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2706 | } else | 2742 | } else |
2707 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2743 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2708 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2744 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2709 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2745 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2710 | } | 2746 | } |
2711 | 2747 | ||
2712 | void CalendarView::newEvent(QDateTime fh) | 2748 | void CalendarView::newEvent(QDateTime fh) |
2713 | { | 2749 | { |
2714 | newEvent(fh, | 2750 | newEvent(fh, |
2715 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2751 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2716 | } | 2752 | } |
2717 | 2753 | ||
2718 | void CalendarView::newEvent(QDate dt) | 2754 | void CalendarView::newEvent(QDate dt) |
2719 | { | 2755 | { |
2720 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2756 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2721 | QDateTime(dt, QTime(0,0,0)), true); | 2757 | QDateTime(dt, QTime(0,0,0)), true); |
2722 | } | 2758 | } |
2723 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2759 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2724 | { | 2760 | { |
2725 | newEvent(fromHint, toHint, false); | 2761 | newEvent(fromHint, toHint, false); |
2726 | } | 2762 | } |
2727 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2763 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2728 | { | 2764 | { |
2729 | 2765 | ||
2730 | showEventEditor(); | 2766 | showEventEditor(); |
2731 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2767 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2732 | if ( mFilterView->filtersEnabled() ) { | 2768 | if ( mFilterView->filtersEnabled() ) { |
2733 | CalFilter *filter = mFilterView->selectedFilter(); | 2769 | CalFilter *filter = mFilterView->selectedFilter(); |
2734 | if (filter && filter->showCategories()) { | 2770 | if (filter && filter->showCategories()) { |
2735 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2771 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2736 | } | 2772 | } |
2737 | if ( filter ) | 2773 | if ( filter ) |
2738 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2774 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2739 | } | 2775 | } |
2740 | mEventEditor->exec(); | 2776 | mEventEditor->exec(); |
2741 | setActiveWindow(); | 2777 | setActiveWindow(); |
2742 | } | 2778 | } |
2743 | void CalendarView::todoAdded(Todo * t) | 2779 | void CalendarView::todoAdded(Todo * t) |
2744 | { | 2780 | { |
2745 | 2781 | ||
2746 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2782 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2747 | updateTodoViews(); | 2783 | updateTodoViews(); |
2748 | } | 2784 | } |
2749 | void CalendarView::todoChanged(Todo * t) | 2785 | void CalendarView::todoChanged(Todo * t) |
2750 | { | 2786 | { |
2751 | emit todoModified( t, 4 ); | 2787 | emit todoModified( t, 4 ); |
2752 | // updateTodoViews(); | 2788 | // updateTodoViews(); |
2753 | } | 2789 | } |
2754 | void CalendarView::todoToBeDeleted(Todo *) | 2790 | void CalendarView::todoToBeDeleted(Todo *) |
2755 | { | 2791 | { |
2756 | //qDebug("todoToBeDeleted(Todo *) "); | 2792 | //qDebug("todoToBeDeleted(Todo *) "); |
2757 | updateTodoViews(); | 2793 | updateTodoViews(); |
2758 | } | 2794 | } |
2759 | void CalendarView::todoDeleted() | 2795 | void CalendarView::todoDeleted() |
2760 | { | 2796 | { |
2761 | //qDebug(" todoDeleted()"); | 2797 | //qDebug(" todoDeleted()"); |
2762 | updateTodoViews(); | 2798 | updateTodoViews(); |
2763 | } | 2799 | } |
2764 | 2800 | ||
2765 | 2801 | ||
2766 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2802 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2767 | { | 2803 | { |
2768 | showTodoEditor(); | 2804 | showTodoEditor(); |
2769 | mTodoEditor->newTodo(dt,0,allday); | 2805 | mTodoEditor->newTodo(dt,0,allday); |
2770 | if ( mFilterView->filtersEnabled() ) { | 2806 | if ( mFilterView->filtersEnabled() ) { |
2771 | CalFilter *filter = mFilterView->selectedFilter(); | 2807 | CalFilter *filter = mFilterView->selectedFilter(); |
2772 | if (filter && filter->showCategories()) { | 2808 | if (filter && filter->showCategories()) { |
2773 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2809 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2774 | } | 2810 | } |
2775 | if ( filter ) | 2811 | if ( filter ) |
2776 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2812 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2777 | } | 2813 | } |
2778 | mTodoEditor->exec(); | 2814 | mTodoEditor->exec(); |
2779 | setActiveWindow(); | 2815 | setActiveWindow(); |
2780 | } | 2816 | } |
2781 | 2817 | ||
2782 | void CalendarView::newTodo() | 2818 | void CalendarView::newTodo() |
2783 | { | 2819 | { |
2784 | newTodoDateTime( QDateTime(),true ); | 2820 | newTodoDateTime( QDateTime(),true ); |
2785 | } | 2821 | } |
2786 | 2822 | ||
2787 | void CalendarView::newSubTodo() | 2823 | void CalendarView::newSubTodo() |
2788 | { | 2824 | { |
2789 | Todo *todo = selectedTodo(); | 2825 | Todo *todo = selectedTodo(); |
2790 | if ( todo ) newSubTodo( todo ); | 2826 | if ( todo ) newSubTodo( todo ); |
2791 | } | 2827 | } |
2792 | 2828 | ||
2793 | void CalendarView::newSubTodo(Todo *parentEvent) | 2829 | void CalendarView::newSubTodo(Todo *parentEvent) |
2794 | { | 2830 | { |
2795 | 2831 | ||
2796 | showTodoEditor(); | 2832 | showTodoEditor(); |
2797 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2833 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2798 | mTodoEditor->exec(); | 2834 | mTodoEditor->exec(); |
2799 | setActiveWindow(); | 2835 | setActiveWindow(); |
2800 | } | 2836 | } |
2801 | 2837 | ||
2802 | void CalendarView::newFloatingEvent() | 2838 | void CalendarView::newFloatingEvent() |
2803 | { | 2839 | { |
2804 | DateList tmpList = mNavigator->selectedDates(); | 2840 | DateList tmpList = mNavigator->selectedDates(); |
2805 | QDate date = tmpList.first(); | 2841 | QDate date = tmpList.first(); |
2806 | 2842 | ||
2807 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2843 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2808 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2844 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2809 | } | 2845 | } |
2810 | 2846 | ||
2811 | 2847 | ||
2812 | void CalendarView::editEvent( Event *event ) | 2848 | void CalendarView::editEvent( Event *event ) |
2813 | { | 2849 | { |
2814 | 2850 | ||
2815 | if ( !event ) return; | 2851 | if ( !event ) return; |
2816 | if ( event->isReadOnly() ) { | 2852 | if ( event->isReadOnly() ) { |
2817 | showEvent( event ); | 2853 | showEvent( event ); |
2818 | return; | 2854 | return; |
2819 | } | 2855 | } |
2820 | showEventEditor(); | 2856 | showEventEditor(); |
2821 | mEventEditor->editEvent( event , mFlagEditDescription); | 2857 | mEventEditor->editEvent( event , mFlagEditDescription); |
2822 | mEventEditor->exec(); | 2858 | mEventEditor->exec(); |
2823 | setActiveWindow(); | 2859 | setActiveWindow(); |
2824 | 2860 | ||
2825 | } | 2861 | } |
2826 | void CalendarView::editJournal( Journal *jour ) | 2862 | void CalendarView::editJournal( Journal *jour ) |
2827 | { | 2863 | { |
2828 | if ( !jour ) return; | 2864 | if ( !jour ) return; |
2829 | mDialogManager->hideSearchDialog(); | 2865 | mDialogManager->hideSearchDialog(); |
2830 | mViewManager->showJournalView(); | 2866 | mViewManager->showJournalView(); |
2831 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2867 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2832 | } | 2868 | } |
2833 | void CalendarView::editTodo( Todo *todo ) | 2869 | void CalendarView::editTodo( Todo *todo ) |
2834 | { | 2870 | { |
2835 | if ( !todo ) return; | 2871 | if ( !todo ) return; |
2836 | 2872 | ||
2837 | if ( todo->isReadOnly() ) { | 2873 | if ( todo->isReadOnly() ) { |
2838 | showTodo( todo ); | 2874 | showTodo( todo ); |
2839 | return; | 2875 | return; |
2840 | } | 2876 | } |
2841 | showTodoEditor(); | 2877 | showTodoEditor(); |
2842 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2878 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2843 | mTodoEditor->exec(); | 2879 | mTodoEditor->exec(); |
2844 | setActiveWindow(); | 2880 | setActiveWindow(); |
2845 | 2881 | ||
2846 | } | 2882 | } |
2847 | 2883 | ||
2848 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2884 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2849 | { | 2885 | { |
2850 | if ( !mEventViewerDialog ) { | 2886 | if ( !mEventViewerDialog ) { |
2851 | mEventViewerDialog = new KOEventViewerDialog(0); | 2887 | mEventViewerDialog = new KOEventViewerDialog(0); |
2852 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2888 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2853 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2889 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2854 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2890 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2855 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2891 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2856 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2892 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2857 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2893 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2858 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 2894 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
2859 | this, SLOT( slotViewerClosed() ) ); | 2895 | this, SLOT( slotViewerClosed() ) ); |
2860 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2896 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2861 | this, SLOT( todoChanged(Todo *) ) ); | 2897 | this, SLOT( todoChanged(Todo *) ) ); |
2862 | mEventViewerDialog->resize( 640, 480 ); | 2898 | mEventViewerDialog->resize( 640, 480 ); |
2863 | 2899 | ||
2864 | } | 2900 | } |
2865 | return mEventViewerDialog; | 2901 | return mEventViewerDialog; |
2866 | } | 2902 | } |
2867 | void CalendarView::showEvent(Event *event) | 2903 | void CalendarView::showEvent(Event *event) |
2868 | { | 2904 | { |
2869 | getEventViewerDialog()->setEvent(event); | 2905 | getEventViewerDialog()->setEvent(event); |
2870 | getEventViewerDialog()->showMe(); | 2906 | getEventViewerDialog()->showMe(); |
2871 | } | 2907 | } |
2872 | 2908 | ||
2873 | void CalendarView::showTodo(Todo *event) | 2909 | void CalendarView::showTodo(Todo *event) |
2874 | { | 2910 | { |
2875 | getEventViewerDialog()->setTodo(event); | 2911 | getEventViewerDialog()->setTodo(event); |
2876 | getEventViewerDialog()->showMe(); | 2912 | getEventViewerDialog()->showMe(); |
2877 | } | 2913 | } |
2878 | void CalendarView::showJournal( Journal *jour ) | 2914 | void CalendarView::showJournal( Journal *jour ) |
2879 | { | 2915 | { |
2880 | getEventViewerDialog()->setJournal(jour); | 2916 | getEventViewerDialog()->setJournal(jour); |
2881 | getEventViewerDialog()->showMe(); | 2917 | getEventViewerDialog()->showMe(); |
2882 | 2918 | ||
2883 | } | 2919 | } |
2884 | // void CalendarView::todoModified (Todo *event, int changed) | 2920 | // void CalendarView::todoModified (Todo *event, int changed) |
2885 | // { | 2921 | // { |
2886 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2922 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2887 | // // kdDebug() << "Todo modified and open" << endl; | 2923 | // // kdDebug() << "Todo modified and open" << endl; |
2888 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2924 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2889 | // // temp->modified (changed); | 2925 | // // temp->modified (changed); |
2890 | 2926 | ||
2891 | // // } | 2927 | // // } |
2892 | 2928 | ||
2893 | // mViewManager->updateView(); | 2929 | // mViewManager->updateView(); |
2894 | // } | 2930 | // } |
2895 | 2931 | ||
2896 | void CalendarView::appointment_show() | 2932 | void CalendarView::appointment_show() |
2897 | { | 2933 | { |
2898 | Event *anEvent = 0; | 2934 | Event *anEvent = 0; |
2899 | 2935 | ||
2900 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2936 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2901 | 2937 | ||
2902 | if (mViewManager->currentView()->isEventView()) { | 2938 | if (mViewManager->currentView()->isEventView()) { |
2903 | if ( incidence && incidence->type() == "Event" ) { | 2939 | if ( incidence && incidence->type() == "Event" ) { |
2904 | anEvent = static_cast<Event *>(incidence); | 2940 | anEvent = static_cast<Event *>(incidence); |
2905 | } | 2941 | } |
2906 | } | 2942 | } |
2907 | 2943 | ||
2908 | if (!anEvent) { | 2944 | if (!anEvent) { |
2909 | KNotifyClient::beep(); | 2945 | KNotifyClient::beep(); |
2910 | return; | 2946 | return; |
2911 | } | 2947 | } |
2912 | 2948 | ||
2913 | showEvent(anEvent); | 2949 | showEvent(anEvent); |
2914 | } | 2950 | } |
2915 | 2951 | ||
2916 | void CalendarView::appointment_edit() | 2952 | void CalendarView::appointment_edit() |
2917 | { | 2953 | { |
2918 | Event *anEvent = 0; | 2954 | Event *anEvent = 0; |
2919 | 2955 | ||
2920 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2956 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2921 | 2957 | ||
2922 | if (mViewManager->currentView()->isEventView()) { | 2958 | if (mViewManager->currentView()->isEventView()) { |
2923 | if ( incidence && incidence->type() == "Event" ) { | 2959 | if ( incidence && incidence->type() == "Event" ) { |
2924 | anEvent = static_cast<Event *>(incidence); | 2960 | anEvent = static_cast<Event *>(incidence); |
2925 | } | 2961 | } |
2926 | } | 2962 | } |
2927 | 2963 | ||
2928 | if (!anEvent) { | 2964 | if (!anEvent) { |
2929 | KNotifyClient::beep(); | 2965 | KNotifyClient::beep(); |
2930 | return; | 2966 | return; |
2931 | } | 2967 | } |
2932 | 2968 | ||
2933 | editEvent(anEvent); | 2969 | editEvent(anEvent); |
2934 | } | 2970 | } |
2935 | 2971 | ||
2936 | void CalendarView::appointment_delete() | 2972 | void CalendarView::appointment_delete() |
2937 | { | 2973 | { |
2938 | Event *anEvent = 0; | 2974 | Event *anEvent = 0; |
2939 | 2975 | ||
2940 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2976 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2941 | 2977 | ||
2942 | if (mViewManager->currentView()->isEventView()) { | 2978 | if (mViewManager->currentView()->isEventView()) { |
2943 | if ( incidence && incidence->type() == "Event" ) { | 2979 | if ( incidence && incidence->type() == "Event" ) { |
2944 | anEvent = static_cast<Event *>(incidence); | 2980 | anEvent = static_cast<Event *>(incidence); |
2945 | } | 2981 | } |
2946 | } | 2982 | } |
2947 | 2983 | ||
2948 | if (!anEvent) { | 2984 | if (!anEvent) { |
2949 | KNotifyClient::beep(); | 2985 | KNotifyClient::beep(); |
2950 | return; | 2986 | return; |
2951 | } | 2987 | } |
2952 | 2988 | ||
2953 | deleteEvent(anEvent); | 2989 | deleteEvent(anEvent); |
2954 | } | 2990 | } |
2955 | 2991 | ||
2956 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2992 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2957 | { | 2993 | { |
2958 | if (!sub) return; | 2994 | if (!sub) return; |
2959 | if (!parent) return; | 2995 | if (!parent) return; |
2960 | if ( sub->relatedTo() ) | 2996 | if ( sub->relatedTo() ) |
2961 | sub->relatedTo()->removeRelation(sub); | 2997 | sub->relatedTo()->removeRelation(sub); |
2962 | sub->setRelatedTo(parent); | 2998 | sub->setRelatedTo(parent); |
2963 | sub->setRelatedToUid(parent->uid()); | 2999 | sub->setRelatedToUid(parent->uid()); |
2964 | parent->addRelation(sub); | 3000 | parent->addRelation(sub); |
2965 | sub->updated(); | 3001 | sub->updated(); |
2966 | parent->updated(); | 3002 | parent->updated(); |
2967 | setModified(true); | 3003 | setModified(true); |
2968 | updateView(); | 3004 | updateView(); |
2969 | } | 3005 | } |
2970 | void CalendarView::todo_unsub(Todo *anTodo ) | 3006 | void CalendarView::todo_unsub(Todo *anTodo ) |
2971 | { | 3007 | { |
2972 | // Todo *anTodo = selectedTodo(); | 3008 | // Todo *anTodo = selectedTodo(); |
2973 | if (!anTodo) return; | 3009 | if (!anTodo) return; |
2974 | if (!anTodo->relatedTo()) return; | 3010 | if (!anTodo->relatedTo()) return; |
2975 | anTodo->relatedTo()->removeRelation(anTodo); | 3011 | anTodo->relatedTo()->removeRelation(anTodo); |
2976 | anTodo->setRelatedTo(0); | 3012 | anTodo->setRelatedTo(0); |
2977 | anTodo->updated(); | 3013 | anTodo->updated(); |
2978 | anTodo->setRelatedToUid(""); | 3014 | anTodo->setRelatedToUid(""); |
2979 | setModified(true); | 3015 | setModified(true); |
2980 | updateView(); | 3016 | updateView(); |
2981 | } | 3017 | } |
2982 | 3018 | ||
2983 | void CalendarView::deleteTodo(Todo *todo) | 3019 | void CalendarView::deleteTodo(Todo *todo) |
2984 | { | 3020 | { |
2985 | if (!todo) { | 3021 | if (!todo) { |
2986 | KNotifyClient::beep(); | 3022 | KNotifyClient::beep(); |
2987 | return; | 3023 | return; |
2988 | } | 3024 | } |
2989 | if (KOPrefs::instance()->mConfirm) { | 3025 | if (KOPrefs::instance()->mConfirm) { |
2990 | QString text = todo->summary().left(20); | 3026 | QString text = todo->summary().left(20); |
2991 | if (!todo->relations().isEmpty()) { | 3027 | if (!todo->relations().isEmpty()) { |
2992 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3028 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2993 | 3029 | ||
2994 | } | 3030 | } |
2995 | switch (msgItemDelete(text)) { | 3031 | switch (msgItemDelete(text)) { |
2996 | case KMessageBox::Continue: // OK | 3032 | case KMessageBox::Continue: // OK |
2997 | bool deleteT = false; | 3033 | bool deleteT = false; |
2998 | if (!todo->relations().isEmpty()) { | 3034 | if (!todo->relations().isEmpty()) { |
2999 | deleteT = removeCompletedSubTodos( todo ); | 3035 | deleteT = removeCompletedSubTodos( todo ); |
3000 | } | 3036 | } |
3001 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3037 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3002 | if ( !deleteT ) { | 3038 | if ( !deleteT ) { |
3003 | checkExternalId( todo ); | 3039 | checkExternalId( todo ); |
3004 | calendar()->deleteTodo(todo); | 3040 | calendar()->deleteTodo(todo); |
3005 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3041 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3006 | updateView(); | 3042 | updateView(); |
3007 | } | 3043 | } |
3008 | break; | 3044 | break; |
3009 | } // switch | 3045 | } // switch |
3010 | } else { | 3046 | } else { |
3011 | checkExternalId( todo ); | 3047 | checkExternalId( todo ); |
3012 | mCalendar->deleteTodo(todo); | 3048 | mCalendar->deleteTodo(todo); |
3013 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3049 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3014 | updateView(); | 3050 | updateView(); |
3015 | } | 3051 | } |
3016 | 3052 | ||
3017 | emit updateSearchDialog(); | 3053 | emit updateSearchDialog(); |
3018 | } | 3054 | } |
3019 | void CalendarView::deleteJournal(Journal *jour) | 3055 | void CalendarView::deleteJournal(Journal *jour) |
3020 | { | 3056 | { |
3021 | if (!jour) { | 3057 | if (!jour) { |
3022 | KNotifyClient::beep(); | 3058 | KNotifyClient::beep(); |
3023 | return; | 3059 | return; |
3024 | } | 3060 | } |
3025 | if (KOPrefs::instance()->mConfirm) { | 3061 | if (KOPrefs::instance()->mConfirm) { |
3026 | switch (msgItemDelete( jour->description().left(20))) { | 3062 | switch (msgItemDelete( jour->description().left(20))) { |
3027 | case KMessageBox::Continue: // OK | 3063 | case KMessageBox::Continue: // OK |
3028 | calendar()->deleteJournal(jour); | 3064 | calendar()->deleteJournal(jour); |
3029 | updateView(); | 3065 | updateView(); |
3030 | break; | 3066 | break; |
3031 | } // switch | 3067 | } // switch |
3032 | } else { | 3068 | } else { |
3033 | calendar()->deleteJournal(jour);; | 3069 | calendar()->deleteJournal(jour);; |
3034 | updateView(); | 3070 | updateView(); |
3035 | } | 3071 | } |
3036 | emit updateSearchDialog(); | 3072 | emit updateSearchDialog(); |
3037 | } | 3073 | } |
3038 | 3074 | ||
3039 | void CalendarView::deleteEvent(Event *anEvent) | 3075 | void CalendarView::deleteEvent(Event *anEvent) |
3040 | { | 3076 | { |
3041 | if (!anEvent) { | 3077 | if (!anEvent) { |
3042 | KNotifyClient::beep(); | 3078 | KNotifyClient::beep(); |
3043 | return; | 3079 | return; |
3044 | } | 3080 | } |
3045 | 3081 | ||
3046 | if (anEvent->recurrence()->doesRecur()) { | 3082 | if (anEvent->recurrence()->doesRecur()) { |
3047 | QDate itemDate = mViewManager->currentSelectionDate(); | 3083 | QDate itemDate = mViewManager->currentSelectionDate(); |
3048 | int km; | 3084 | int km; |
3049 | if (!itemDate.isValid()) { | 3085 | if (!itemDate.isValid()) { |
3050 | //kdDebug() << "Date Not Valid" << endl; | 3086 | //kdDebug() << "Date Not Valid" << endl; |
3051 | if (KOPrefs::instance()->mConfirm) { | 3087 | if (KOPrefs::instance()->mConfirm) { |
3052 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3088 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3053 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3089 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3054 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3090 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3055 | if ( km == KMessageBox::Continue ) | 3091 | if ( km == KMessageBox::Continue ) |
3056 | km = KMessageBox::No; // No = all below | 3092 | km = KMessageBox::No; // No = all below |
3057 | } else | 3093 | } else |
3058 | km = KMessageBox::No; | 3094 | km = KMessageBox::No; |
3059 | } else { | 3095 | } else { |
3060 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3096 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3061 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3097 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3062 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3098 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3063 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3099 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3064 | i18n("All")); | 3100 | i18n("All")); |
3065 | } | 3101 | } |
3066 | switch(km) { | 3102 | switch(km) { |
3067 | 3103 | ||
3068 | case KMessageBox::No: // Continue // all | 3104 | case KMessageBox::No: // Continue // all |
3069 | //qDebug("KMessageBox::No "); | 3105 | //qDebug("KMessageBox::No "); |
3070 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3106 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3071 | schedule(Scheduler::Cancel,anEvent); | 3107 | schedule(Scheduler::Cancel,anEvent); |
3072 | 3108 | ||
3073 | checkExternalId( anEvent); | 3109 | checkExternalId( anEvent); |
3074 | mCalendar->deleteEvent(anEvent); | 3110 | mCalendar->deleteEvent(anEvent); |
3075 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3111 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3076 | break; | 3112 | break; |
3077 | 3113 | ||
3078 | // Disabled because it does not work | 3114 | // Disabled because it does not work |
3079 | //#if 0 | 3115 | //#if 0 |
3080 | case KMessageBox::Yes: // just this one | 3116 | case KMessageBox::Yes: // just this one |
3081 | //QDate qd = mNavigator->selectedDates().first(); | 3117 | //QDate qd = mNavigator->selectedDates().first(); |
3082 | //if (!qd.isValid()) { | 3118 | //if (!qd.isValid()) { |
3083 | // kdDebug() << "no date selected, or invalid date" << endl; | 3119 | // kdDebug() << "no date selected, or invalid date" << endl; |
3084 | // KNotifyClient::beep(); | 3120 | // KNotifyClient::beep(); |
3085 | // return; | 3121 | // return; |
3086 | //} | 3122 | //} |
3087 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3123 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3088 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3124 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3089 | anEvent->addExDate(itemDate); | 3125 | anEvent->addExDate(itemDate); |
3090 | int duration = anEvent->recurrence()->duration(); | 3126 | int duration = anEvent->recurrence()->duration(); |
3091 | if ( duration > 0 ) { | 3127 | if ( duration > 0 ) { |
3092 | anEvent->recurrence()->setDuration( duration - 1 ); | 3128 | anEvent->recurrence()->setDuration( duration - 1 ); |
3093 | } | 3129 | } |
3094 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3130 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3095 | } | 3131 | } |
3096 | break; | 3132 | break; |
3097 | //#endif | 3133 | //#endif |
3098 | } // switch | 3134 | } // switch |
3099 | } else { | 3135 | } else { |
3100 | if (KOPrefs::instance()->mConfirm) { | 3136 | if (KOPrefs::instance()->mConfirm) { |
3101 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3137 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3102 | i18n("\nAre you sure you want\nto delete this event?"), | 3138 | i18n("\nAre you sure you want\nto delete this event?"), |
3103 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3139 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3104 | case KMessageBox::Continue: // OK | 3140 | case KMessageBox::Continue: // OK |
3105 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3141 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3106 | schedule(Scheduler::Cancel,anEvent); | 3142 | schedule(Scheduler::Cancel,anEvent); |
3107 | checkExternalId( anEvent); | 3143 | checkExternalId( anEvent); |
3108 | mCalendar->deleteEvent(anEvent); | 3144 | mCalendar->deleteEvent(anEvent); |
3109 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3145 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3110 | break; | 3146 | break; |
3111 | } // switch | 3147 | } // switch |
3112 | } else { | 3148 | } else { |
3113 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3149 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3114 | schedule(Scheduler::Cancel,anEvent); | 3150 | schedule(Scheduler::Cancel,anEvent); |
3115 | checkExternalId( anEvent); | 3151 | checkExternalId( anEvent); |
3116 | mCalendar->deleteEvent(anEvent); | 3152 | mCalendar->deleteEvent(anEvent); |
3117 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3153 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3118 | } | 3154 | } |
3119 | } // if-else | 3155 | } // if-else |
3120 | emit updateSearchDialog(); | 3156 | emit updateSearchDialog(); |
3121 | } | 3157 | } |
3122 | 3158 | ||
3123 | bool CalendarView::deleteEvent(const QString &uid) | 3159 | bool CalendarView::deleteEvent(const QString &uid) |
3124 | { | 3160 | { |
3125 | Event *ev = mCalendar->event(uid); | 3161 | Event *ev = mCalendar->event(uid); |
3126 | if (ev) { | 3162 | if (ev) { |
3127 | deleteEvent(ev); | 3163 | deleteEvent(ev); |
3128 | return true; | 3164 | return true; |
3129 | } else { | 3165 | } else { |
3130 | return false; | 3166 | return false; |
3131 | } | 3167 | } |
3132 | } | 3168 | } |
3133 | 3169 | ||
3134 | /*****************************************************************************/ | 3170 | /*****************************************************************************/ |
3135 | 3171 | ||
3136 | void CalendarView::action_mail() | 3172 | void CalendarView::action_mail() |
3137 | { | 3173 | { |
3138 | #ifndef KORG_NOMAIL | 3174 | #ifndef KORG_NOMAIL |
3139 | KOMailClient mailClient; | 3175 | KOMailClient mailClient; |
3140 | 3176 | ||
3141 | Incidence *incidence = currentSelection(); | 3177 | Incidence *incidence = currentSelection(); |
3142 | 3178 | ||
3143 | if (!incidence) { | 3179 | if (!incidence) { |
3144 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3180 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3145 | return; | 3181 | return; |
3146 | } | 3182 | } |
3147 | if(incidence->attendeeCount() == 0 ) { | 3183 | if(incidence->attendeeCount() == 0 ) { |
3148 | KMessageBox::sorry(this, | 3184 | KMessageBox::sorry(this, |
3149 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3185 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3150 | return; | 3186 | return; |
3151 | } | 3187 | } |
3152 | 3188 | ||
3153 | CalendarLocal cal_tmp; | 3189 | CalendarLocal cal_tmp; |
3154 | Event *event = 0; | 3190 | Event *event = 0; |
3155 | Event *ev = 0; | 3191 | Event *ev = 0; |
3156 | if ( incidence && incidence->type() == "Event" ) { | 3192 | if ( incidence && incidence->type() == "Event" ) { |
3157 | event = static_cast<Event *>(incidence); | 3193 | event = static_cast<Event *>(incidence); |
3158 | ev = new Event(*event); | 3194 | ev = new Event(*event); |
3159 | cal_tmp.addEvent(ev); | 3195 | cal_tmp.addEvent(ev); |
3160 | } | 3196 | } |
3161 | ICalFormat mForm(); | 3197 | ICalFormat mForm(); |
3162 | QString attachment = mForm.toString( &cal_tmp ); | 3198 | QString attachment = mForm.toString( &cal_tmp ); |
3163 | if (ev) delete(ev); | 3199 | if (ev) delete(ev); |
3164 | 3200 | ||
3165 | mailClient.mailAttendees(currentSelection(), attachment); | 3201 | mailClient.mailAttendees(currentSelection(), attachment); |
3166 | 3202 | ||
3167 | #endif | 3203 | #endif |
3168 | 3204 | ||
3169 | #if 0 | 3205 | #if 0 |
3170 | Event *anEvent = 0; | 3206 | Event *anEvent = 0; |
3171 | if (mViewManager->currentView()->isEventView()) { | 3207 | if (mViewManager->currentView()->isEventView()) { |
3172 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3208 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3173 | } | 3209 | } |
3174 | 3210 | ||
3175 | if (!anEvent) { | 3211 | if (!anEvent) { |
3176 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3212 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3177 | return; | 3213 | return; |
3178 | } | 3214 | } |
3179 | if(anEvent->attendeeCount() == 0 ) { | 3215 | if(anEvent->attendeeCount() == 0 ) { |
3180 | KMessageBox::sorry(this, | 3216 | KMessageBox::sorry(this, |
3181 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3217 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3182 | return; | 3218 | return; |
3183 | } | 3219 | } |
3184 | 3220 | ||
3185 | mailobject.emailEvent(anEvent); | 3221 | mailobject.emailEvent(anEvent); |
3186 | #endif | 3222 | #endif |
3187 | } | 3223 | } |
3188 | 3224 | ||
3189 | 3225 | ||
3190 | void CalendarView::schedule_publish(Incidence *incidence) | 3226 | void CalendarView::schedule_publish(Incidence *incidence) |
3191 | { | 3227 | { |
3192 | Event *event = 0; | 3228 | Event *event = 0; |
3193 | Todo *todo = 0; | 3229 | Todo *todo = 0; |
3194 | 3230 | ||
3195 | if (incidence == 0) { | 3231 | if (incidence == 0) { |
3196 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3232 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3197 | if (incidence == 0) { | 3233 | if (incidence == 0) { |
3198 | incidence = mTodoList->selectedIncidences().first(); | 3234 | incidence = mTodoList->selectedIncidences().first(); |
3199 | } | 3235 | } |
3200 | } | 3236 | } |
3201 | if ( incidence && incidence->type() == "Event" ) { | 3237 | if ( incidence && incidence->type() == "Event" ) { |
3202 | event = static_cast<Event *>(incidence); | 3238 | event = static_cast<Event *>(incidence); |
3203 | } else { | 3239 | } else { |
3204 | if ( incidence && incidence->type() == "Todo" ) { | 3240 | if ( incidence && incidence->type() == "Todo" ) { |
3205 | todo = static_cast<Todo *>(incidence); | 3241 | todo = static_cast<Todo *>(incidence); |
3206 | } | 3242 | } |
3207 | } | 3243 | } |
3208 | 3244 | ||
3209 | if (!event && !todo) { | 3245 | if (!event && !todo) { |
3210 | KMessageBox::sorry(this,i18n("No event selected.")); | 3246 | KMessageBox::sorry(this,i18n("No event selected.")); |
3211 | return; | 3247 | return; |
3212 | } | 3248 | } |
3213 | 3249 | ||
3214 | PublishDialog *publishdlg = new PublishDialog(); | 3250 | PublishDialog *publishdlg = new PublishDialog(); |
3215 | if (incidence->attendeeCount()>0) { | 3251 | if (incidence->attendeeCount()>0) { |
3216 | QPtrList<Attendee> attendees = incidence->attendees(); | 3252 | QPtrList<Attendee> attendees = incidence->attendees(); |
3217 | attendees.first(); | 3253 | attendees.first(); |
3218 | while ( attendees.current()!=0 ) { | 3254 | while ( attendees.current()!=0 ) { |
3219 | publishdlg->addAttendee(attendees.current()); | 3255 | publishdlg->addAttendee(attendees.current()); |
3220 | attendees.next(); | 3256 | attendees.next(); |
3221 | } | 3257 | } |
3222 | } | 3258 | } |
3223 | bool send = true; | 3259 | bool send = true; |
3224 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3260 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3225 | if ( publishdlg->exec() != QDialog::Accepted ) | 3261 | if ( publishdlg->exec() != QDialog::Accepted ) |
3226 | send = false; | 3262 | send = false; |
3227 | } | 3263 | } |
3228 | if ( send ) { | 3264 | if ( send ) { |
3229 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3265 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3230 | if ( event ) { | 3266 | if ( event ) { |
3231 | Event *ev = new Event(*event); | 3267 | Event *ev = new Event(*event); |
3232 | ev->registerObserver(0); | 3268 | ev->registerObserver(0); |
3233 | ev->clearAttendees(); | 3269 | ev->clearAttendees(); |
3234 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3270 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3235 | delete(ev); | 3271 | delete(ev); |
3236 | } | 3272 | } |
3237 | } else { | 3273 | } else { |
3238 | if ( todo ) { | 3274 | if ( todo ) { |
3239 | Todo *ev = new Todo(*todo); | 3275 | Todo *ev = new Todo(*todo); |
3240 | ev->registerObserver(0); | 3276 | ev->registerObserver(0); |
3241 | ev->clearAttendees(); | 3277 | ev->clearAttendees(); |
3242 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3278 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3243 | delete(ev); | 3279 | delete(ev); |
3244 | } | 3280 | } |
3245 | } | 3281 | } |
3246 | } | 3282 | } |
3247 | } | 3283 | } |
3248 | delete publishdlg; | 3284 | delete publishdlg; |
3249 | } | 3285 | } |
3250 | 3286 | ||
3251 | void CalendarView::schedule_request(Incidence *incidence) | 3287 | void CalendarView::schedule_request(Incidence *incidence) |
3252 | { | 3288 | { |
3253 | schedule(Scheduler::Request,incidence); | 3289 | schedule(Scheduler::Request,incidence); |
3254 | } | 3290 | } |
3255 | 3291 | ||
3256 | void CalendarView::schedule_refresh(Incidence *incidence) | 3292 | void CalendarView::schedule_refresh(Incidence *incidence) |
3257 | { | 3293 | { |
3258 | schedule(Scheduler::Refresh,incidence); | 3294 | schedule(Scheduler::Refresh,incidence); |
3259 | } | 3295 | } |
3260 | 3296 | ||
3261 | void CalendarView::schedule_cancel(Incidence *incidence) | 3297 | void CalendarView::schedule_cancel(Incidence *incidence) |
3262 | { | 3298 | { |
3263 | schedule(Scheduler::Cancel,incidence); | 3299 | schedule(Scheduler::Cancel,incidence); |
3264 | } | 3300 | } |
3265 | 3301 | ||
3266 | void CalendarView::schedule_add(Incidence *incidence) | 3302 | void CalendarView::schedule_add(Incidence *incidence) |
3267 | { | 3303 | { |
3268 | schedule(Scheduler::Add,incidence); | 3304 | schedule(Scheduler::Add,incidence); |
3269 | } | 3305 | } |
3270 | 3306 | ||
3271 | void CalendarView::schedule_reply(Incidence *incidence) | 3307 | void CalendarView::schedule_reply(Incidence *incidence) |
3272 | { | 3308 | { |
3273 | schedule(Scheduler::Reply,incidence); | 3309 | schedule(Scheduler::Reply,incidence); |
3274 | } | 3310 | } |
3275 | 3311 | ||
3276 | void CalendarView::schedule_counter(Incidence *incidence) | 3312 | void CalendarView::schedule_counter(Incidence *incidence) |
3277 | { | 3313 | { |
3278 | schedule(Scheduler::Counter,incidence); | 3314 | schedule(Scheduler::Counter,incidence); |
3279 | } | 3315 | } |
3280 | 3316 | ||
3281 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3317 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3282 | { | 3318 | { |
3283 | schedule(Scheduler::Declinecounter,incidence); | 3319 | schedule(Scheduler::Declinecounter,incidence); |
3284 | } | 3320 | } |
3285 | 3321 | ||
3286 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3322 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3287 | { | 3323 | { |
3288 | QDateTime start = QDateTime::currentDateTime(); | 3324 | QDateTime start = QDateTime::currentDateTime(); |
3289 | QDateTime end = start.addDays(daysToPublish); | 3325 | QDateTime end = start.addDays(daysToPublish); |
3290 | 3326 | ||
3291 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3327 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3292 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3328 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3293 | 3329 | ||
3294 | 3330 | ||
3295 | PublishDialog *publishdlg = new PublishDialog(); | 3331 | PublishDialog *publishdlg = new PublishDialog(); |
3296 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3332 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3297 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3333 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3298 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3334 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3299 | delete(freebusy); | 3335 | delete(freebusy); |
3300 | } | 3336 | } |
3301 | } | 3337 | } |
3302 | delete publishdlg; | 3338 | delete publishdlg; |
3303 | } | 3339 | } |
3304 | 3340 | ||
3305 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3341 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3306 | { | 3342 | { |
3307 | Event *event = 0; | 3343 | Event *event = 0; |
3308 | Todo *todo = 0; | 3344 | Todo *todo = 0; |
3309 | 3345 | ||
3310 | if (incidence == 0) { | 3346 | if (incidence == 0) { |
3311 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3347 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3312 | if (incidence == 0) { | 3348 | if (incidence == 0) { |
3313 | incidence = mTodoList->selectedIncidences().first(); | 3349 | incidence = mTodoList->selectedIncidences().first(); |
3314 | } | 3350 | } |
3315 | } | 3351 | } |
3316 | if ( incidence && incidence->type() == "Event" ) { | 3352 | if ( incidence && incidence->type() == "Event" ) { |
3317 | event = static_cast<Event *>(incidence); | 3353 | event = static_cast<Event *>(incidence); |
3318 | } | 3354 | } |
3319 | if ( incidence && incidence->type() == "Todo" ) { | 3355 | if ( incidence && incidence->type() == "Todo" ) { |
3320 | todo = static_cast<Todo *>(incidence); | 3356 | todo = static_cast<Todo *>(incidence); |
3321 | } | 3357 | } |
3322 | 3358 | ||
3323 | if (!event && !todo) { | 3359 | if (!event && !todo) { |
3324 | KMessageBox::sorry(this,i18n("No event selected.")); | 3360 | KMessageBox::sorry(this,i18n("No event selected.")); |
3325 | return; | 3361 | return; |
3326 | } | 3362 | } |
3327 | 3363 | ||
3328 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3364 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3329 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3365 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3330 | return; | 3366 | return; |
3331 | } | 3367 | } |
3332 | 3368 | ||
3333 | Event *ev = 0; | 3369 | Event *ev = 0; |
3334 | if (event) ev = new Event(*event); | 3370 | if (event) ev = new Event(*event); |
3335 | Todo *to = 0; | 3371 | Todo *to = 0; |
3336 | if (todo) to = new Todo(*todo); | 3372 | if (todo) to = new Todo(*todo); |
3337 | 3373 | ||
3338 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3374 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3339 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3375 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3340 | if (!me) { | 3376 | if (!me) { |
3341 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3377 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3342 | return; | 3378 | return; |
3343 | } | 3379 | } |
3344 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3380 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3345 | StatusDialog *statdlg = new StatusDialog(this); | 3381 | StatusDialog *statdlg = new StatusDialog(this); |
3346 | if (!statdlg->exec()==QDialog::Accepted) return; | 3382 | if (!statdlg->exec()==QDialog::Accepted) return; |
3347 | me->setStatus( statdlg->status() ); | 3383 | me->setStatus( statdlg->status() ); |
3348 | delete(statdlg); | 3384 | delete(statdlg); |
3349 | } | 3385 | } |
3350 | Attendee *menew = new Attendee(*me); | 3386 | Attendee *menew = new Attendee(*me); |
3351 | if (ev) { | 3387 | if (ev) { |
3352 | ev->clearAttendees(); | 3388 | ev->clearAttendees(); |
3353 | ev->addAttendee(menew,false); | 3389 | ev->addAttendee(menew,false); |
3354 | } else { | 3390 | } else { |
3355 | if (to) { | 3391 | if (to) { |
3356 | todo->clearAttendees(); | 3392 | todo->clearAttendees(); |
3357 | todo->addAttendee(menew,false); | 3393 | todo->addAttendee(menew,false); |
3358 | } | 3394 | } |
3359 | } | 3395 | } |
3360 | } | 3396 | } |
3361 | 3397 | ||
3362 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3398 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3363 | if (ev) { | 3399 | if (ev) { |
3364 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3400 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3365 | } else { | 3401 | } else { |
3366 | if (to) { | 3402 | if (to) { |
3367 | if ( !dlg->addMessage(to,method) ) delete(to); | 3403 | if ( !dlg->addMessage(to,method) ) delete(to); |
3368 | } | 3404 | } |
3369 | } | 3405 | } |
3370 | } | 3406 | } |
3371 | 3407 | ||
3372 | void CalendarView::openAddressbook() | 3408 | void CalendarView::openAddressbook() |
3373 | { | 3409 | { |
3374 | KRun::runCommand("kaddressbook"); | 3410 | KRun::runCommand("kaddressbook"); |
3375 | } | 3411 | } |
3376 | 3412 | ||
3377 | void CalendarView::setModified(bool modified) | 3413 | void CalendarView::setModified(bool modified) |
3378 | { | 3414 | { |
3379 | if ( modified ) | 3415 | if ( modified ) |
3380 | emit signalmodified(); | 3416 | emit signalmodified(); |
3381 | if (mModified != modified) { | 3417 | if (mModified != modified) { |
3382 | mModified = modified; | 3418 | mModified = modified; |
3383 | emit modifiedChanged(mModified); | 3419 | emit modifiedChanged(mModified); |
3384 | } | 3420 | } |
3385 | } | 3421 | } |
3386 | 3422 | ||
3387 | bool CalendarView::isReadOnly() | 3423 | bool CalendarView::isReadOnly() |
3388 | { | 3424 | { |
3389 | return mReadOnly; | 3425 | return mReadOnly; |
3390 | } | 3426 | } |
3391 | 3427 | ||
3392 | void CalendarView::setReadOnly(bool readOnly) | 3428 | void CalendarView::setReadOnly(bool readOnly) |
3393 | { | 3429 | { |
3394 | if (mReadOnly != readOnly) { | 3430 | if (mReadOnly != readOnly) { |
3395 | mReadOnly = readOnly; | 3431 | mReadOnly = readOnly; |
3396 | emit readOnlyChanged(mReadOnly); | 3432 | emit readOnlyChanged(mReadOnly); |
3397 | } | 3433 | } |
3398 | } | 3434 | } |
3399 | 3435 | ||
3400 | bool CalendarView::isModified() | 3436 | bool CalendarView::isModified() |
3401 | { | 3437 | { |
3402 | return mModified; | 3438 | return mModified; |
3403 | } | 3439 | } |
3404 | 3440 | ||
3405 | void CalendarView::printSetup() | 3441 | void CalendarView::printSetup() |
3406 | { | 3442 | { |
3407 | #ifndef KORG_NOPRINTER | 3443 | #ifndef KORG_NOPRINTER |
3408 | createPrinter(); | 3444 | createPrinter(); |
3409 | 3445 | ||
3410 | mCalPrinter->setupPrinter(); | 3446 | mCalPrinter->setupPrinter(); |
3411 | #endif | 3447 | #endif |
3412 | } | 3448 | } |
3413 | 3449 | ||
3414 | void CalendarView::print() | 3450 | void CalendarView::print() |
3415 | { | 3451 | { |
3416 | #ifndef KORG_NOPRINTER | 3452 | #ifndef KORG_NOPRINTER |
3417 | createPrinter(); | 3453 | createPrinter(); |
3418 | 3454 | ||
3419 | DateList tmpDateList = mNavigator->selectedDates(); | 3455 | DateList tmpDateList = mNavigator->selectedDates(); |
3420 | mCalPrinter->print(CalPrinter::Month, | 3456 | mCalPrinter->print(CalPrinter::Month, |
3421 | tmpDateList.first(), tmpDateList.last()); | 3457 | tmpDateList.first(), tmpDateList.last()); |
3422 | #endif | 3458 | #endif |
3423 | } | 3459 | } |
3424 | 3460 | ||
3425 | void CalendarView::printPreview() | 3461 | void CalendarView::printPreview() |
3426 | { | 3462 | { |
3427 | #ifndef KORG_NOPRINTER | 3463 | #ifndef KORG_NOPRINTER |
3428 | kdDebug() << "CalendarView::printPreview()" << endl; | 3464 | kdDebug() << "CalendarView::printPreview()" << endl; |
3429 | 3465 | ||
3430 | createPrinter(); | 3466 | createPrinter(); |
3431 | 3467 | ||
3432 | DateList tmpDateList = mNavigator->selectedDates(); | 3468 | DateList tmpDateList = mNavigator->selectedDates(); |
3433 | 3469 | ||
3434 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3470 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3435 | tmpDateList.last()); | 3471 | tmpDateList.last()); |
3436 | #endif | 3472 | #endif |
3437 | } | 3473 | } |
3438 | 3474 | ||
3439 | void CalendarView::exportICalendar() | 3475 | void CalendarView::exportICalendar() |
3440 | { | 3476 | { |
3441 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3477 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3442 | 3478 | ||
3443 | // Force correct extension | 3479 | // Force correct extension |
3444 | if (filename.right(4) != ".ics") filename += ".ics"; | 3480 | if (filename.right(4) != ".ics") filename += ".ics"; |
3445 | 3481 | ||
3446 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3482 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3447 | storage.save(); | 3483 | storage.save(); |
3448 | } | 3484 | } |
3449 | 3485 | ||
3450 | bool CalendarView::exportVCalendar( QString filename ) | 3486 | bool CalendarView::exportVCalendar( QString filename ) |
3451 | { | 3487 | { |
3452 | if (mCalendar->journals().count() > 0) { | 3488 | if (mCalendar->journals().count() > 0) { |
3453 | int result = KMessageBox::warningContinueCancel(this, | 3489 | int result = KMessageBox::warningContinueCancel(this, |
3454 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3490 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3455 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3491 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3456 | true); | 3492 | true); |
3457 | if (result != KMessageBox::Continue) return false; | 3493 | if (result != KMessageBox::Continue) return false; |
3458 | } | 3494 | } |
3459 | 3495 | ||
3460 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3496 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3461 | 3497 | ||
3462 | // Force correct extension | 3498 | // Force correct extension |
3463 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3499 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3464 | 3500 | ||
3465 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3501 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3466 | return storage.save(); | 3502 | return storage.save(); |
3467 | 3503 | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index fac9a9e..16e671f 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -1,617 +1,617 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000, 2001 | 3 | Copyright (c) 2000, 2001 |
4 | Cornelius Schumacher <schumacher@kde.org> | 4 | Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef CALENDARVIEW_H | 24 | #ifndef CALENDARVIEW_H |
25 | #define CALENDARVIEW_H | 25 | #define CALENDARVIEW_H |
26 | 26 | ||
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qptrlist.h> | 30 | #include <qptrlist.h> |
31 | #include <qvbox.h> | 31 | #include <qvbox.h> |
32 | #include <qmap.h> | 32 | #include <qmap.h> |
33 | #ifndef DESKTOP_VERSION | 33 | #ifndef DESKTOP_VERSION |
34 | #include <qtopia/ir.h> | 34 | #include <qtopia/ir.h> |
35 | #else | 35 | #else |
36 | #define Ir char | 36 | #define Ir char |
37 | #endif | 37 | #endif |
38 | #include <libkcal/calendar.h> | 38 | #include <libkcal/calendar.h> |
39 | #include <libkcal/scheduler.h> | 39 | #include <libkcal/scheduler.h> |
40 | #include <libkcal/calendarresources.h> | 40 | #include <libkcal/calendarresources.h> |
41 | #include <libkcal/resourcecalendar.h> | 41 | #include <libkcal/resourcecalendar.h> |
42 | #include <KDGanttMinimizeSplitter.h> | 42 | #include <KDGanttMinimizeSplitter.h> |
43 | 43 | ||
44 | #include <korganizer/calendarviewbase.h> | 44 | #include <korganizer/calendarviewbase.h> |
45 | 45 | ||
46 | #include <ksyncmanager.h> | 46 | #include <ksyncmanager.h> |
47 | 47 | ||
48 | class QWidgetStack; | 48 | class QWidgetStack; |
49 | class QSplitter; | 49 | class QSplitter; |
50 | 50 | ||
51 | class CalPrinter; | 51 | class CalPrinter; |
52 | class KOFilterView; | 52 | class KOFilterView; |
53 | class KOViewManager; | 53 | class KOViewManager; |
54 | class KODialogManager; | 54 | class KODialogManager; |
55 | class KOTodoView; | 55 | class KOTodoView; |
56 | class KDateNavigator; | 56 | class KDateNavigator; |
57 | class DateNavigatorContainer; | 57 | class DateNavigatorContainer; |
58 | class DateNavigator; | 58 | class DateNavigator; |
59 | class KOIncidenceEditor; | 59 | class KOIncidenceEditor; |
60 | class KDatePicker; | 60 | class KDatePicker; |
61 | class ResourceView; | 61 | class ResourceView; |
62 | class KOEventEditor; | 62 | class KOEventEditor; |
63 | class KOTodoEditor ; | 63 | class KOTodoEditor ; |
64 | class KOEventViewerDialog; | 64 | class KOEventViewerDialog; |
65 | class KOBeamPrefs; | 65 | class KOBeamPrefs; |
66 | class KSyncProfile; | 66 | class KSyncProfile; |
67 | class AlarmDialog; | 67 | class AlarmDialog; |
68 | class KCal::Attendee; | 68 | class KCal::Attendee; |
69 | 69 | ||
70 | namespace KCal { class FileStorage; } | 70 | namespace KCal { class FileStorage; } |
71 | 71 | ||
72 | using namespace KCal; | 72 | using namespace KCal; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | This is the main calendar widget. It provides the different vies on t he | 75 | This is the main calendar widget. It provides the different vies on t he |
76 | calendar data as well as the date navigator. It also handles synchronisation | 76 | calendar data as well as the date navigator. It also handles synchronisation |
77 | of the different views and controls the different dialogs like preferences, | 77 | of the different views and controls the different dialogs like preferences, |
78 | event editor, search dialog etc. | 78 | event editor, search dialog etc. |
79 | 79 | ||
80 | @short main calendar view widget | 80 | @short main calendar view widget |
81 | @author Cornelius Schumacher | 81 | @author Cornelius Schumacher |
82 | */ | 82 | */ |
83 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface | 83 | class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface |
84 | { | 84 | { |
85 | Q_OBJECT | 85 | Q_OBJECT |
86 | public: | 86 | public: |
87 | /** | 87 | /** |
88 | Constructs a new calendar view widget. | 88 | Constructs a new calendar view widget. |
89 | 89 | ||
90 | @param calendar calendar document | 90 | @param calendar calendar document |
91 | @param parent parent window | 91 | @param parent parent window |
92 | @param name Qt internal widget object name | 92 | @param name Qt internal widget object name |
93 | */ | 93 | */ |
94 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, | 94 | CalendarView( CalendarResources *calendar, QWidget *parent = 0, |
95 | const char *name = 0 ); | 95 | const char *name = 0 ); |
96 | CalendarView( Calendar *calendar, QWidget *parent = 0, | 96 | CalendarView( Calendar *calendar, QWidget *parent = 0, |
97 | const char *name = 0 ); | 97 | const char *name = 0 ); |
98 | virtual ~CalendarView(); | 98 | virtual ~CalendarView(); |
99 | 99 | ||
100 | Calendar *calendar() { return mCalendar; } | 100 | Calendar *calendar() { return mCalendar; } |
101 | 101 | ||
102 | KOViewManager *viewManager(); | 102 | KOViewManager *viewManager(); |
103 | KODialogManager *dialogManager(); | 103 | KODialogManager *dialogManager(); |
104 | 104 | ||
105 | QDate startDate(); | 105 | QDate startDate(); |
106 | QDate endDate(); | 106 | QDate endDate(); |
107 | 107 | ||
108 | QWidgetStack *viewStack(); | 108 | QWidgetStack *viewStack(); |
109 | QWidget *leftFrame(); | 109 | QWidget *leftFrame(); |
110 | 110 | ||
111 | DateNavigator *dateNavigator(); | 111 | DateNavigator *dateNavigator(); |
112 | KDateNavigator *dateNavigatorWidget(); | 112 | KDateNavigator *dateNavigatorWidget(); |
113 | 113 | ||
114 | void addView(KOrg::BaseView *); | 114 | void addView(KOrg::BaseView *); |
115 | void showView(KOrg::BaseView *); | 115 | void showView(KOrg::BaseView *); |
116 | KOEventViewerDialog* getEventViewerDialog(); | 116 | KOEventViewerDialog* getEventViewerDialog(); |
117 | Incidence *currentSelection(); | 117 | Incidence *currentSelection(); |
118 | 118 | ||
119 | signals: | 119 | signals: |
120 | void save (); | 120 | void save (); |
121 | void saveStopTimer (); | 121 | void saveStopTimer (); |
122 | void tempDisableBR(bool); | 122 | void tempDisableBR(bool); |
123 | /** This todo has been modified */ | 123 | /** This todo has been modified */ |
124 | void todoModified(Todo *, int); | 124 | void todoModified(Todo *, int); |
125 | 125 | ||
126 | /** when change is made to options dialog, the topwidget will catch this | 126 | /** when change is made to options dialog, the topwidget will catch this |
127 | * and emit this signal which notifies all widgets which have registered | 127 | * and emit this signal which notifies all widgets which have registered |
128 | * for notification to update their settings. */ | 128 | * for notification to update their settings. */ |
129 | void configChanged(); | 129 | void configChanged(); |
130 | /** emitted when the topwidget is closing down, so that any attached | 130 | /** emitted when the topwidget is closing down, so that any attached |
131 | child windows can also close. */ | 131 | child windows can also close. */ |
132 | void closingDown(); | 132 | void closingDown(); |
133 | /** emitted right before we die */ | 133 | /** emitted right before we die */ |
134 | void closed(QWidget *); | 134 | void closed(QWidget *); |
135 | 135 | ||
136 | /** Emitted when state of modified flag changes */ | 136 | /** Emitted when state of modified flag changes */ |
137 | void modifiedChanged(bool); | 137 | void modifiedChanged(bool); |
138 | void signalmodified(); | 138 | void signalmodified(); |
139 | 139 | ||
140 | /** Emitted when state of read-only flag changes */ | 140 | /** Emitted when state of read-only flag changes */ |
141 | void readOnlyChanged(bool); | 141 | void readOnlyChanged(bool); |
142 | 142 | ||
143 | /** Emitted when the unit of navigation changes */ | 143 | /** Emitted when the unit of navigation changes */ |
144 | void changeNavStringPrev(const QString &); | 144 | void changeNavStringPrev(const QString &); |
145 | void changeNavStringNext(const QString &); | 145 | void changeNavStringNext(const QString &); |
146 | 146 | ||
147 | /** Emitted when state of events selection has changed and user is organizer*/ | 147 | /** Emitted when state of events selection has changed and user is organizer*/ |
148 | void organizerEventsSelected(bool); | 148 | void organizerEventsSelected(bool); |
149 | /** Emitted when state of events selection has changed and user is attendee*/ | 149 | /** Emitted when state of events selection has changed and user is attendee*/ |
150 | void groupEventsSelected(bool); | 150 | void groupEventsSelected(bool); |
151 | /** | 151 | /** |
152 | Emitted when an incidence gets selected. If the selection is cleared the | 152 | Emitted when an incidence gets selected. If the selection is cleared the |
153 | signal is emitted with 0 as argument. | 153 | signal is emitted with 0 as argument. |
154 | */ | 154 | */ |
155 | void incidenceSelected( Incidence * ); | 155 | void incidenceSelected( Incidence * ); |
156 | /** Emitted, when a todoitem is selected or deselected. */ | 156 | /** Emitted, when a todoitem is selected or deselected. */ |
157 | void todoSelected( bool ); | 157 | void todoSelected( bool ); |
158 | 158 | ||
159 | /** | 159 | /** |
160 | Emitted, when clipboard content changes. Parameter indicates if paste | 160 | Emitted, when clipboard content changes. Parameter indicates if paste |
161 | is possible or not. | 161 | is possible or not. |
162 | */ | 162 | */ |
163 | void pasteEnabled(bool); | 163 | void pasteEnabled(bool); |
164 | 164 | ||
165 | /** Emitted, when the number of incoming messages has changed. */ | 165 | /** Emitted, when the number of incoming messages has changed. */ |
166 | void numIncomingChanged(int); | 166 | void numIncomingChanged(int); |
167 | 167 | ||
168 | /** Emitted, when the number of outgoing messages has changed. */ | 168 | /** Emitted, when the number of outgoing messages has changed. */ |
169 | void numOutgoingChanged(int); | 169 | void numOutgoingChanged(int); |
170 | 170 | ||
171 | /** Send status message, which can e.g. be displayed in the status bar. */ | 171 | /** Send status message, which can e.g. be displayed in the status bar. */ |
172 | void statusMessage(const QString &); | 172 | void statusMessage(const QString &); |
173 | 173 | ||
174 | void calendarViewExpanded( bool ); | 174 | void calendarViewExpanded( bool ); |
175 | void updateSearchDialog(); | 175 | void updateSearchDialog(); |
176 | 176 | ||
177 | 177 | ||
178 | public slots: | 178 | public slots: |
179 | void showOpenError(); | 179 | void showOpenError(); |
180 | void watchSavedFile(); | 180 | void watchSavedFile(); |
181 | void recheckTimerAlarm(); | 181 | void recheckTimerAlarm(); |
182 | void checkNextTimerAlarm(); | 182 | void checkNextTimerAlarm(); |
183 | void addAlarm(const QDateTime &qdt, const QString ¬i ); | 183 | void addAlarm(const QDateTime &qdt, const QString ¬i ); |
184 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); | 184 | void addSuspendAlarm(const QDateTime &qdt, const QString ¬i ); |
185 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); | 185 | void removeAlarm(const QDateTime &qdt, const QString ¬i ); |
186 | 186 | ||
187 | /** options dialog made a changed to the configuration. we catch this | 187 | /** options dialog made a changed to the configuration. we catch this |
188 | * and notify all widgets which need to update their configuration. */ | 188 | * and notify all widgets which need to update their configuration. */ |
189 | void updateConfig(); | 189 | void updateConfig(); |
190 | 190 | ||
191 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, | 191 | void insertBirthdays(const QString& uid, const QStringList& birthdayList, |
192 | const QStringList& anniversaryList, const QStringList& realNameList, | 192 | const QStringList& anniversaryList, const QStringList& realNameList, |
193 | const QStringList& emailList, const QStringList& assembledNameList, | 193 | const QStringList& emailList, const QStringList& assembledNameList, |
194 | const QStringList& uidList); | 194 | const QStringList& uidList); |
195 | 195 | ||
196 | /** | 196 | /** |
197 | Load calendar from file \a filename. If \a merge is true, load | 197 | Load calendar from file \a filename. If \a merge is true, load |
198 | calendar into existing one, if it is false, clear calendar, before | 198 | calendar into existing one, if it is false, clear calendar, before |
199 | loading. Return true, if calendar could be successfully loaded. | 199 | loading. Return true, if calendar could be successfully loaded. |
200 | */ | 200 | */ |
201 | bool openCalendar(QString filename, bool merge=false); | 201 | bool openCalendar(QString filename, bool merge=false); |
202 | bool syncCalendar(QString filename,int mode = 0 ); | 202 | bool syncCalendar(QString filename,int mode = 0 ); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | Save calendar data to file. Return true if calendar could be | 205 | Save calendar data to file. Return true if calendar could be |
206 | successfully saved. | 206 | successfully saved. |
207 | */ | 207 | */ |
208 | bool saveCalendar(QString filename); | 208 | bool saveCalendar(QString filename); |
209 | 209 | ||
210 | /** | 210 | /** |
211 | Close calendar. Clear calendar data and reset views to display an empty | 211 | Close calendar. Clear calendar data and reset views to display an empty |
212 | calendar. | 212 | calendar. |
213 | */ | 213 | */ |
214 | void closeCalendar(); | 214 | void closeCalendar(); |
215 | 215 | ||
216 | /** Archive old events of calendar */ | 216 | /** Archive old events of calendar */ |
217 | void archiveCalendar(); | 217 | void archiveCalendar(); |
218 | 218 | ||
219 | void showIncidence(); | 219 | void showIncidence(); |
220 | void editIncidence(); | 220 | void editIncidence(); |
221 | void editIncidenceDescription(); | 221 | void editIncidenceDescription(); |
222 | void deleteIncidence(); | 222 | void deleteIncidence(); |
223 | void cloneIncidence(); | 223 | void cloneIncidence(); |
224 | void moveIncidence(); | 224 | void moveIncidence(); |
225 | void beamIncidence(); | 225 | void beamIncidence(); |
226 | void toggleCancelIncidence(); | 226 | void toggleCancelIncidence(); |
227 | 227 | ||
228 | /** create an editeventwin with supplied date/time, and if bool is true, | 228 | /** create an editeventwin with supplied date/time, and if bool is true, |
229 | * make the event take all day. */ | 229 | * make the event take all day. */ |
230 | void newEvent(QDateTime, QDateTime, bool allDay ); | 230 | void newEvent(QDateTime, QDateTime, bool allDay ); |
231 | void newEvent(QDateTime, QDateTime); | 231 | void newEvent(QDateTime, QDateTime); |
232 | void newEvent(QDateTime fh); | 232 | void newEvent(QDateTime fh); |
233 | void newEvent(QDate dt); | 233 | void newEvent(QDate dt); |
234 | /** create new event without having a date hint. Takes current date as | 234 | /** create new event without having a date hint. Takes current date as |
235 | default hint. */ | 235 | default hint. */ |
236 | void newEvent(); | 236 | void newEvent(); |
237 | void newFloatingEvent(); | 237 | void newFloatingEvent(); |
238 | 238 | ||
239 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ | 239 | /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ |
240 | void showIncidence(Incidence *); | 240 | void showIncidence(Incidence *); |
241 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ | 241 | /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ |
242 | void editIncidence(Incidence *); | 242 | void editIncidence(Incidence *); |
243 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ | 243 | /** Delete the supplied incidence. It calls the correct deleteXXX method*/ |
244 | void deleteIncidence(Incidence *); | 244 | void deleteIncidence(Incidence *); |
245 | void cloneIncidence(Incidence *); | 245 | void cloneIncidence(Incidence *); |
246 | void cancelIncidence(Incidence *); | 246 | void cancelIncidence(Incidence *); |
247 | /** Create an editor for the supplied event. */ | 247 | /** Create an editor for the supplied event. */ |
248 | void editEvent(Event *); | 248 | void editEvent(Event *); |
249 | /** Delete the supplied event. */ | 249 | /** Delete the supplied event. */ |
250 | void deleteEvent(Event *); | 250 | void deleteEvent(Event *); |
251 | /** Delete the event with the given unique ID. Returns false, if event wasn't | 251 | /** Delete the event with the given unique ID. Returns false, if event wasn't |
252 | found. */ | 252 | found. */ |
253 | bool deleteEvent(const QString &uid); | 253 | bool deleteEvent(const QString &uid); |
254 | /** Create a read-only viewer dialog for the supplied event. */ | 254 | /** Create a read-only viewer dialog for the supplied event. */ |
255 | void showEvent(Event *); | 255 | void showEvent(Event *); |
256 | 256 | ||
257 | void editJournal(Journal *); | 257 | void editJournal(Journal *); |
258 | void showJournal(Journal *); | 258 | void showJournal(Journal *); |
259 | void deleteJournal(Journal *); | 259 | void deleteJournal(Journal *); |
260 | /** Create an editor dialog for a todo */ | 260 | /** Create an editor dialog for a todo */ |
261 | void editTodo(Todo *); | 261 | void editTodo(Todo *); |
262 | /** Create a read-only viewer dialog for the supplied todo */ | 262 | /** Create a read-only viewer dialog for the supplied todo */ |
263 | void showTodo(Todo *); | 263 | void showTodo(Todo *); |
264 | /** create new todo */ | 264 | /** create new todo */ |
265 | void newTodo(); | 265 | void newTodo(); |
266 | void newTodoDateTime(QDateTime, bool allday); | 266 | void newTodoDateTime(QDateTime, bool allday); |
267 | /** create new todo with a parent todo */ | 267 | /** create new todo with a parent todo */ |
268 | void newSubTodo(); | 268 | void newSubTodo(); |
269 | /** create new todo with a parent todo */ | 269 | /** create new todo with a parent todo */ |
270 | void newSubTodo(Todo *); | 270 | void newSubTodo(Todo *); |
271 | /** Delete todo */ | 271 | /** Delete todo */ |
272 | void deleteTodo(Todo *); | 272 | void deleteTodo(Todo *); |
273 | 273 | ||
274 | 274 | ||
275 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is | 275 | /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is |
276 | * emitted as result. */ | 276 | * emitted as result. */ |
277 | void checkClipboard(); | 277 | void checkClipboard(); |
278 | 278 | ||
279 | /** using the KConfig associated with the kapp variable, read in the | 279 | /** using the KConfig associated with the kapp variable, read in the |
280 | * settings from the config file. | 280 | * settings from the config file. |
281 | */ | 281 | */ |
282 | void readSettings(); | 282 | void readSettings(); |
283 | 283 | ||
284 | /** write current state to config file. */ | 284 | /** write current state to config file. */ |
285 | void writeSettings(); | 285 | void writeSettings(); |
286 | 286 | ||
287 | /** read settings for calendar filters */ | 287 | /** read settings for calendar filters */ |
288 | void readFilterSettings(KConfig *config); | 288 | void readFilterSettings(KConfig *config); |
289 | 289 | ||
290 | /** write settings for calendar filters */ | 290 | /** write settings for calendar filters */ |
291 | void writeFilterSettings(KConfig *config); | 291 | void writeFilterSettings(KConfig *config); |
292 | 292 | ||
293 | /** passes on the message that an event has changed to the currently | 293 | /** passes on the message that an event has changed to the currently |
294 | * activated view so that it can make appropriate display changes. */ | 294 | * activated view so that it can make appropriate display changes. */ |
295 | void changeEventDisplay(Event *, int); | 295 | void changeEventDisplay(Event *, int); |
296 | void changeIncidenceDisplay(Incidence *, int); | 296 | void changeIncidenceDisplay(Incidence *, int); |
297 | void changeTodoDisplay(Todo *, int); | 297 | void changeTodoDisplay(Todo *, int); |
298 | 298 | ||
299 | void eventAdded(Event *); | 299 | void eventAdded(Event *); |
300 | void eventChanged(Event *); | 300 | void eventChanged(Event *); |
301 | void eventToBeDeleted(Event *); | 301 | void eventToBeDeleted(Event *); |
302 | void eventDeleted(); | 302 | void eventDeleted(); |
303 | 303 | ||
304 | void todoAdded(Todo *); | 304 | void todoAdded(Todo *); |
305 | void todoChanged(Todo *); | 305 | void todoChanged(Todo *); |
306 | void todoToBeDeleted(Todo *); | 306 | void todoToBeDeleted(Todo *); |
307 | void todoDeleted(); | 307 | void todoDeleted(); |
308 | 308 | ||
309 | void updateView(const QDate &start, const QDate &end); | 309 | void updateView(const QDate &start, const QDate &end); |
310 | void updateView(); | 310 | void updateView(); |
311 | 311 | ||
312 | /** Full update of visible todo views */ | 312 | /** Full update of visible todo views */ |
313 | void updateTodoViews(); | 313 | void updateTodoViews(); |
314 | 314 | ||
315 | void updateUnmanagedViews(); | 315 | void updateUnmanagedViews(); |
316 | 316 | ||
317 | /** cut the current appointment to the clipboard */ | 317 | /** cut the current appointment to the clipboard */ |
318 | void edit_cut(); | 318 | void edit_cut(); |
319 | 319 | ||
320 | /** copy the current appointment(s) to the clipboard */ | 320 | /** copy the current appointment(s) to the clipboard */ |
321 | void edit_copy(); | 321 | void edit_copy(); |
322 | 322 | ||
323 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 323 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
324 | void edit_paste(); | 324 | void edit_paste(); |
325 | 325 | ||
326 | /** edit viewing and configuration options. */ | 326 | /** edit viewing and configuration options. */ |
327 | void edit_options(); | 327 | void edit_options(); |
328 | /** | 328 | /** |
329 | Functions for printing, previewing a print, and setting up printing | 329 | Functions for printing, previewing a print, and setting up printing |
330 | parameters. | 330 | parameters. |
331 | */ | 331 | */ |
332 | void print(); | 332 | void print(); |
333 | void printSetup(); | 333 | void printSetup(); |
334 | void printPreview(); | 334 | void printPreview(); |
335 | 335 | ||
336 | /** Export as iCalendar file */ | 336 | /** Export as iCalendar file */ |
337 | void exportICalendar(); | 337 | void exportICalendar(); |
338 | 338 | ||
339 | /** Export as vCalendar file */ | 339 | /** Export as vCalendar file */ |
340 | bool exportVCalendar( QString fn); | 340 | bool exportVCalendar( QString fn); |
341 | 341 | ||
342 | /** pop up a dialog to show an existing appointment. */ | 342 | /** pop up a dialog to show an existing appointment. */ |
343 | void appointment_show(); | 343 | void appointment_show(); |
344 | /** | 344 | /** |
345 | * pop up an Appointment Dialog to edit an existing appointment.Get | 345 | * pop up an Appointment Dialog to edit an existing appointment.Get |
346 | * information on the appointment from the list of unique IDs that is | 346 | * information on the appointment from the list of unique IDs that is |
347 | * currently in the View, called currIds. | 347 | * currently in the View, called currIds. |
348 | */ | 348 | */ |
349 | void appointment_edit(); | 349 | void appointment_edit(); |
350 | /** | 350 | /** |
351 | * pop up dialog confirming deletion of currently selected event in the | 351 | * pop up dialog confirming deletion of currently selected event in the |
352 | * View. | 352 | * View. |
353 | */ | 353 | */ |
354 | void appointment_delete(); | 354 | void appointment_delete(); |
355 | 355 | ||
356 | /** mails the currently selected event to a particular user as a vCalendar | 356 | /** mails the currently selected event to a particular user as a vCalendar |
357 | attachment. */ | 357 | attachment. */ |
358 | void action_mail(); | 358 | void action_mail(); |
359 | 359 | ||
360 | /* frees a subtodo from it's relation */ | 360 | /* frees a subtodo from it's relation */ |
361 | void todo_unsub( Todo * ); | 361 | void todo_unsub( Todo * ); |
362 | void todo_resub( Todo * parent, Todo * sub ); | 362 | void todo_resub( Todo * parent, Todo * sub ); |
363 | 363 | ||
364 | /** Take ownership of selected event. */ | 364 | /** Take ownership of selected event. */ |
365 | void takeOverEvent(); | 365 | void takeOverEvent(); |
366 | 366 | ||
367 | /** Take ownership of all events in calendar. */ | 367 | /** Take ownership of all events in calendar. */ |
368 | void takeOverCalendar(); | 368 | void takeOverCalendar(); |
369 | 369 | ||
370 | /** query whether or not the calendar is "dirty". */ | 370 | /** query whether or not the calendar is "dirty". */ |
371 | bool isModified(); | 371 | bool isModified(); |
372 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 372 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
373 | void setModified(bool modified=true); | 373 | void setModified(bool modified=true); |
374 | 374 | ||
375 | /** query if the calendar is read-only. */ | 375 | /** query if the calendar is read-only. */ |
376 | bool isReadOnly(); | 376 | bool isReadOnly(); |
377 | /** set state of calendar to read-only */ | 377 | /** set state of calendar to read-only */ |
378 | void setReadOnly(bool readOnly=true); | 378 | void setReadOnly(bool readOnly=true); |
379 | 379 | ||
380 | void eventUpdated(Incidence *); | 380 | void eventUpdated(Incidence *); |
381 | 381 | ||
382 | /* iTIP scheduling actions */ | 382 | /* iTIP scheduling actions */ |
383 | void schedule_publish(Incidence *incidence = 0); | 383 | void schedule_publish(Incidence *incidence = 0); |
384 | void schedule_request(Incidence *incidence = 0); | 384 | void schedule_request(Incidence *incidence = 0); |
385 | void schedule_refresh(Incidence *incidence = 0); | 385 | void schedule_refresh(Incidence *incidence = 0); |
386 | void schedule_cancel(Incidence *incidence = 0); | 386 | void schedule_cancel(Incidence *incidence = 0); |
387 | void schedule_add(Incidence *incidence = 0); | 387 | void schedule_add(Incidence *incidence = 0); |
388 | void schedule_reply(Incidence *incidence = 0); | 388 | void schedule_reply(Incidence *incidence = 0); |
389 | void schedule_counter(Incidence *incidence = 0); | 389 | void schedule_counter(Incidence *incidence = 0); |
390 | void schedule_declinecounter(Incidence *incidence = 0); | 390 | void schedule_declinecounter(Incidence *incidence = 0); |
391 | void schedule_publish_freebusy(int daysToPublish = 30); | 391 | void schedule_publish_freebusy(int daysToPublish = 30); |
392 | 392 | ||
393 | void openAddressbook(); | 393 | void openAddressbook(); |
394 | 394 | ||
395 | void editFilters(); | 395 | void editFilters(); |
396 | void toggleFilerEnabled(); | 396 | void toggleFilerEnabled(); |
397 | QPtrList<CalFilter> filters(); | 397 | QPtrList<CalFilter> filters(); |
398 | void toggleFilter(); | 398 | void toggleFilter(); |
399 | void showFilter(bool visible); | 399 | void showFilter(bool visible); |
400 | void updateFilter(); | 400 | void updateFilter(); |
401 | void filterEdited(); | 401 | void filterEdited(); |
402 | void selectFilter( int ); | 402 | void selectFilter( int ); |
403 | KOFilterView *filterView(); | 403 | KOFilterView *filterView(); |
404 | 404 | ||
405 | void showIntro(); | 405 | void showIntro(); |
406 | 406 | ||
407 | /** Move the curdatepient view date to today */ | 407 | /** Move the curdatepient view date to today */ |
408 | void goToday(); | 408 | void goToday(); |
409 | 409 | ||
410 | /** Move to the next date(s) in the current view */ | 410 | /** Move to the next date(s) in the current view */ |
411 | void goNext(); | 411 | void goNext(); |
412 | 412 | ||
413 | /** Move to the previous date(s) in the current view */ | 413 | /** Move to the previous date(s) in the current view */ |
414 | void goPrevious(); | 414 | void goPrevious(); |
415 | /** Move to the next date(s) in the current view */ | 415 | /** Move to the next date(s) in the current view */ |
416 | void goNextMonth(); | 416 | void goNextMonth(); |
417 | 417 | ||
418 | /** Move to the previous date(s) in the current view */ | 418 | /** Move to the previous date(s) in the current view */ |
419 | void goPreviousMonth(); | 419 | void goPreviousMonth(); |
420 | 420 | ||
421 | void toggleExpand(); | 421 | void toggleExpand(); |
422 | void toggleDateNavigatorWidget(); | 422 | void toggleDateNavigatorWidget(); |
423 | void toggleAllDaySize(); | 423 | void toggleAllDaySize(); |
424 | void dialogClosing(Incidence *); | 424 | void dialogClosing(Incidence *); |
425 | 425 | ||
426 | /** Look for new messages in the inbox */ | 426 | /** Look for new messages in the inbox */ |
427 | void lookForIncomingMessages(); | 427 | void lookForIncomingMessages(); |
428 | /** Look for new messages in the outbox */ | 428 | /** Look for new messages in the outbox */ |
429 | void lookForOutgoingMessages(); | 429 | void lookForOutgoingMessages(); |
430 | 430 | ||
431 | void processMainViewSelection( Incidence * ); | 431 | void processMainViewSelection( Incidence * ); |
432 | void processTodoListSelection( Incidence * ); | 432 | void processTodoListSelection( Incidence * ); |
433 | 433 | ||
434 | void processIncidenceSelection( Incidence * ); | 434 | void processIncidenceSelection( Incidence * ); |
435 | 435 | ||
436 | void purgeCompleted(); | 436 | void purgeCompleted(); |
437 | bool removeCompletedSubTodos( Todo* ); | 437 | bool removeCompletedSubTodos( Todo* ); |
438 | void slotCalendarChanged(); | 438 | void slotCalendarChanged(); |
439 | bool importBday(); | 439 | bool importBday(); |
440 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 440 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
441 | bool importQtopia( const QString &categoriesFile, | 441 | bool importQtopia( const QString &categoriesFile, |
442 | const QString &datebookFile, | 442 | const QString &datebookFile, |
443 | const QString &tasklistFile ); | 443 | const QString &tasklistFile ); |
444 | void syncExternal( int mode ); | 444 | void syncExternal( int mode ); |
445 | void slotSelectPickerDate( QDate ) ; | 445 | void slotSelectPickerDate( QDate ) ; |
446 | void showDatePicker() ; | 446 | void showDatePicker() ; |
447 | void showDatePickerPopup() ; | 447 | void showDatePickerPopup() ; |
448 | void moveIncidence(Incidence *) ; | 448 | void moveIncidence(Incidence *) ; |
449 | void beamIncidence(Incidence *) ; | 449 | void beamIncidence(Incidence *) ; |
450 | void beamCalendar() ; | 450 | void beamCalendar() ; |
451 | void beamFilteredCalendar() ; | 451 | void beamFilteredCalendar() ; |
452 | void beamIncidenceList(QPtrList<Incidence>) ; | 452 | void beamIncidenceList(QPtrList<Incidence>) ; |
453 | void manageCategories(); | 453 | void manageCategories(); |
454 | int addCategories(); | 454 | int addCategories(); |
455 | void removeCategories(); | 455 | void removeCategories(); |
456 | void setSyncDevice( QString ); | 456 | void setSyncDevice( QString ); |
457 | void setSyncName( QString ); | 457 | void setSyncName( QString ); |
458 | void showDay( QDate ); | 458 | void showDay( QDate ); |
459 | void undo_delete(); | 459 | void undo_delete(); |
460 | protected slots: | 460 | protected slots: |
461 | void resetFocus(); | 461 | void resetFocus(); |
462 | void slotViewerClosed(); | 462 | void slotViewerClosed(); |
463 | void timerAlarm(); | 463 | void timerAlarm(); |
464 | void suspendAlarm(); | 464 | void suspendAlarm(); |
465 | void beamDone( Ir *ir ); | 465 | void beamDone( Ir *ir ); |
466 | /** Select a view or adapt the current view to display the specified dates. */ | 466 | /** Select a view or adapt the current view to display the specified dates. */ |
467 | void showDates( const KCal::DateList & ); | 467 | void showDates( const KCal::DateList & ); |
468 | void selectWeekNum ( int ); | 468 | void selectWeekNum ( int ); |
469 | 469 | ||
470 | public: | 470 | public: |
471 | // show a standard warning | 471 | // show a standard warning |
472 | // returns KMsgBox::yesNoCancel() | 472 | // returns KMsgBox::yesNoCancel() |
473 | int msgCalModified(); | 473 | int msgCalModified(); |
474 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 474 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
475 | 475 | ||
476 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 476 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
477 | virtual void removeSyncInfo( QString syncProfile); | 477 | virtual void removeSyncInfo( QString syncProfile); |
478 | void setSyncManager(KSyncManager* manager); | 478 | void setSyncManager(KSyncManager* manager); |
479 | void setLoadedFileVersion(QDateTime); | 479 | void setLoadedFileVersion(QDateTime); |
480 | bool checkFileVersion(QString fn); | 480 | bool checkFileVersion(QString fn); |
481 | bool checkFileChanged(QString fn); | 481 | bool checkFileChanged(QString fn); |
482 | Event* getLastSyncEvent(); | 482 | Event* getLastSyncEvent(); |
483 | /** Adapt navigation units correpsonding to step size of navigation of the | 483 | /** Adapt navigation units correpsonding to step size of navigation of the |
484 | * current view. | 484 | * current view. |
485 | */ | 485 | */ |
486 | void adaptNavigationUnits(); | 486 | void adaptNavigationUnits(); |
487 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 487 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
488 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 488 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
489 | //Attendee* getYourAttendee(Event *event); | 489 | //Attendee* getYourAttendee(Event *event); |
490 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} | 490 | void setBlockShowDates( bool b ) { mBlockShowDates = b ;} |
491 | protected: | 491 | protected: |
492 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 492 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
493 | 493 | ||
494 | // returns KMsgBox::OKCandel() | 494 | // returns KMsgBox::OKCandel() |
495 | int msgItemDelete(const QString name); | 495 | int msgItemDelete(const QString name); |
496 | void showEventEditor(); | 496 | void showEventEditor(); |
497 | void showTodoEditor(); | 497 | void showTodoEditor(); |
498 | void writeLocale(); | 498 | void writeLocale(); |
499 | Todo *selectedTodo(); | 499 | Todo *selectedTodo(); |
500 | 500 | ||
501 | private: | 501 | private: |
502 | bool mViewerCallerIsSearchDialog; | 502 | bool mViewerCallerIsSearchDialog; |
503 | bool mBlockShowDates; | 503 | bool mBlockShowDates; |
504 | KSyncManager* mSyncManager; | 504 | KSyncManager* mSyncManager; |
505 | AlarmDialog * mAlarmDialog; | 505 | AlarmDialog * mAlarmDialog; |
506 | QString mAlarmNotification; | 506 | QString mAlarmNotification; |
507 | QString mSuspendAlarmNotification; | 507 | QString mSuspendAlarmNotification; |
508 | QTimer* mSuspendTimer; | 508 | QTimer* mSuspendTimer; |
509 | QTimer* mAlarmTimer; | 509 | QTimer* mAlarmTimer; |
510 | QTimer* mRecheckAlarmTimer; | 510 | QTimer* mRecheckAlarmTimer; |
511 | void computeAlarm( QString ); | 511 | void computeAlarm( QString ); |
512 | void startAlarm( QString, QString ); | 512 | void startAlarm( QString, QString ); |
513 | void setSyncEventsReadOnly(); | 513 | void setSyncEventsReadOnly(); |
514 | 514 | ||
515 | QDateTime loadedFileVersion; | 515 | QDateTime loadedFileVersion; |
516 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 516 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
517 | void checkExternalId( Incidence * inc ); | 517 | void checkExternalId( Incidence * inc ); |
518 | int mGlobalSyncMode; | 518 | int mGlobalSyncMode; |
519 | QString mCurrentSyncDevice; | 519 | QString mCurrentSyncDevice; |
520 | QString mCurrentSyncName; | 520 | QString mCurrentSyncName; |
521 | KOBeamPrefs* beamDialog; | 521 | KOBeamPrefs* beamDialog; |
522 | void init(); | 522 | void init(); |
523 | int mDatePickerMode; | 523 | int mDatePickerMode; |
524 | bool mFlagEditDescription; | 524 | bool mFlagEditDescription; |
525 | QDateTime mLastCalendarSync; | 525 | QDateTime mLastCalendarSync; |
526 | void createPrinter(); | 526 | void createPrinter(); |
527 | 527 | ||
528 | void calendarModified( bool, Calendar * ); | 528 | void calendarModified( bool, Calendar * ); |
529 | 529 | ||
530 | CalPrinter *mCalPrinter; | 530 | CalPrinter *mCalPrinter; |
531 | 531 | ||
532 | QSplitter *mPanner; | 532 | QSplitter *mPanner; |
533 | QSplitter *mLeftSplitter; | 533 | QSplitter *mLeftSplitter; |
534 | KDGanttMinimizeSplitter *mLeftFrame; | 534 | KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; |
535 | QWidgetStack *mRightFrame; | 535 | QWidgetStack *mRightFrame; |
536 | 536 | ||
537 | KDatePicker* mDatePicker; | 537 | KDatePicker* mDatePicker; |
538 | QVBox* mDateFrame; | 538 | QVBox* mDateFrame; |
539 | 539 | ||
540 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. | 540 | DateNavigatorContainer *mDateNavigator; // widget showing small month view. |
541 | 541 | ||
542 | KOFilterView *mFilterView; | 542 | KOFilterView *mFilterView; |
543 | 543 | ||
544 | ResourceView *mResourceView; | 544 | ResourceView *mResourceView; |
545 | 545 | ||
546 | // calendar object for this viewing instance | 546 | // calendar object for this viewing instance |
547 | Calendar *mCalendar; | 547 | Calendar *mCalendar; |
548 | 548 | ||
549 | CalendarResourceManager *mResourceManager; | 549 | CalendarResourceManager *mResourceManager; |
550 | 550 | ||
551 | FileStorage *mStorage; | 551 | FileStorage *mStorage; |
552 | 552 | ||
553 | DateNavigator *mNavigator; | 553 | DateNavigator *mNavigator; |
554 | 554 | ||
555 | KOViewManager *mViewManager; | 555 | KOViewManager *mViewManager; |
556 | KODialogManager *mDialogManager; | 556 | KODialogManager *mDialogManager; |
557 | 557 | ||
558 | // Calendar filters | 558 | // Calendar filters |
559 | QPtrList<CalFilter> mFilters; | 559 | QPtrList<CalFilter> mFilters; |
560 | 560 | ||
561 | // various housekeeping variables. | 561 | // various housekeeping variables. |
562 | bool mModified; // flag indicating if calendar is modified | 562 | bool mModified; // flag indicating if calendar is modified |
563 | bool mReadOnly; // flag indicating if calendar is read-only | 563 | bool mReadOnly; // flag indicating if calendar is read-only |
564 | QDate mSaveSingleDate; | 564 | QDate mSaveSingleDate; |
565 | 565 | ||
566 | Incidence *mSelectedIncidence; | 566 | Incidence *mSelectedIncidence; |
567 | Incidence *mMoveIncidence; | 567 | Incidence *mMoveIncidence; |
568 | QDate mMoveIncidenceOldDate; | 568 | QDate mMoveIncidenceOldDate; |
569 | KOTodoView *mTodoList; | 569 | KOTodoView *mTodoList; |
570 | KOEventEditor * mEventEditor; | 570 | KOEventEditor * mEventEditor; |
571 | KOTodoEditor * mTodoEditor; | 571 | KOTodoEditor * mTodoEditor; |
572 | KOEventViewerDialog * mEventViewerDialog; | 572 | KOEventViewerDialog * mEventViewerDialog; |
573 | void keyPressEvent ( QKeyEvent *e) ; | 573 | void keyPressEvent ( QKeyEvent *e) ; |
574 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 574 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
575 | }; | 575 | }; |
576 | 576 | ||
577 | 577 | ||
578 | class CalendarViewVisitor : public Incidence::Visitor | 578 | class CalendarViewVisitor : public Incidence::Visitor |
579 | { | 579 | { |
580 | public: | 580 | public: |
581 | CalendarViewVisitor() : mView( 0 ) {} | 581 | CalendarViewVisitor() : mView( 0 ) {} |
582 | 582 | ||
583 | bool act( Incidence *incidence, CalendarView *view ) | 583 | bool act( Incidence *incidence, CalendarView *view ) |
584 | { | 584 | { |
585 | mView = view; | 585 | mView = view; |
586 | return incidence->accept( *this ); | 586 | return incidence->accept( *this ); |
587 | } | 587 | } |
588 | 588 | ||
589 | protected: | 589 | protected: |
590 | CalendarView *mView; | 590 | CalendarView *mView; |
591 | }; | 591 | }; |
592 | 592 | ||
593 | class ShowIncidenceVisitor : public CalendarViewVisitor | 593 | class ShowIncidenceVisitor : public CalendarViewVisitor |
594 | { | 594 | { |
595 | protected: | 595 | protected: |
596 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 596 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
597 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 597 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
598 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 598 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
599 | }; | 599 | }; |
600 | 600 | ||
601 | class EditIncidenceVisitor : public CalendarViewVisitor | 601 | class EditIncidenceVisitor : public CalendarViewVisitor |
602 | { | 602 | { |
603 | protected: | 603 | protected: |
604 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 604 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
605 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 605 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
606 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 606 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
607 | }; | 607 | }; |
608 | 608 | ||
609 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 609 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
610 | { | 610 | { |
611 | protected: | 611 | protected: |
612 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 612 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
613 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 613 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
614 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 614 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
615 | }; | 615 | }; |
616 | 616 | ||
617 | #endif | 617 | #endif |
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index b9bd1b9..3358ecf 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp | |||
@@ -1,229 +1,257 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> |
5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> | 5 | Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> |
6 | 6 | ||
7 | This program is free software; you can redistribute it and/or modify | 7 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | 8 | it under the terms of the GNU General Public License as published by |
9 | the Free Software Foundation; either version 2 of the License, or | 9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | 10 | (at your option) any later version. |
11 | 11 | ||
12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | 16 | ||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software | 18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 | 20 | ||
21 | As a special exception, permission is given to link this program | 21 | As a special exception, permission is given to link this program |
22 | with any edition of Qt, and distribute the resulting executable, | 22 | with any edition of Qt, and distribute the resulting executable, |
23 | without including the source code for Qt in the source distribution. | 23 | without including the source code for Qt in the source distribution. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | 28 | ||
29 | //#include "koglobals.h" | 29 | //#include "koglobals.h" |
30 | #include "navigatorbar.h" | 30 | #include "navigatorbar.h" |
31 | #include "kdatenavigator.h" | 31 | #include "kdatenavigator.h" |
32 | 32 | ||
33 | #include <kcalendarsystem.h> | 33 | #include <kcalendarsystem.h> |
34 | 34 | ||
35 | #include "datenavigatorcontainer.h" | 35 | #include "datenavigatorcontainer.h" |
36 | #include "koprefs.h" | ||
36 | 37 | ||
37 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, | 38 | DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, |
38 | const char *name ) | 39 | const char *name ) |
39 | : QWidget( parent, name ), mCalendar( 0 ), | 40 | : QWidget( parent, name ), mCalendar( 0 ), |
40 | mHorizontalCount( 1 ), mVerticalCount( 1 ) | 41 | mHorizontalCount( 1 ), mVerticalCount( 1 ) |
41 | { | 42 | { |
42 | mExtraViews.setAutoDelete( true ); | 43 | mExtraViews.setAutoDelete( true ); |
43 | 44 | ||
44 | mNavigatorView = new KDateNavigator( this, name ); | 45 | mNavigatorView = new KDateNavigator( this, name ); |
45 | 46 | ||
46 | connectNavigatorView( mNavigatorView ); | 47 | connectNavigatorView( mNavigatorView ); |
47 | } | 48 | } |
48 | 49 | ||
49 | DateNavigatorContainer::~DateNavigatorContainer() | 50 | DateNavigatorContainer::~DateNavigatorContainer() |
50 | { | 51 | { |
51 | } | 52 | } |
52 | 53 | ||
53 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) | 54 | void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v ) |
54 | { | 55 | { |
55 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), | 56 | connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ), |
56 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 57 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
57 | #if 0 | 58 | #if 0 |
58 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), | 59 | connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ), |
59 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); | 60 | SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) ); |
60 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), | 61 | connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ), |
61 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); | 62 | SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) ); |
62 | #endif | 63 | #endif |
63 | connect( v, SIGNAL( weekClicked( const QDate & ) ), | 64 | connect( v, SIGNAL( weekClicked( const QDate & ) ), |
64 | SIGNAL( weekClicked( const QDate & ) ) ); | 65 | SIGNAL( weekClicked( const QDate & ) ) ); |
65 | 66 | ||
66 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); | 67 | connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); |
67 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); | 68 | connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); |
68 | 69 | ||
69 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 70 | connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
70 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 71 | connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
72 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 73 | connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
73 | 74 | ||
74 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); | 75 | connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); |
75 | } | 76 | } |
76 | 77 | ||
77 | void DateNavigatorContainer::setCalendar( Calendar *cal ) | 78 | void DateNavigatorContainer::setCalendar( Calendar *cal ) |
78 | { | 79 | { |
79 | mCalendar = cal; | 80 | mCalendar = cal; |
80 | mNavigatorView->setCalendar( cal ); | 81 | mNavigatorView->setCalendar( cal ); |
81 | KDateNavigator *n; | 82 | KDateNavigator *n; |
82 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 83 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
83 | n->setCalendar( cal ); | 84 | n->setCalendar( cal ); |
84 | } | 85 | } |
85 | } | 86 | } |
86 | 87 | ||
87 | void DateNavigatorContainer::updateDayMatrix() | 88 | void DateNavigatorContainer::updateDayMatrix() |
88 | { | 89 | { |
89 | mNavigatorView->updateDayMatrix(); | 90 | mNavigatorView->updateDayMatrix(); |
90 | KDateNavigator *n; | 91 | KDateNavigator *n; |
91 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 92 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
92 | n->updateDayMatrix(); | 93 | n->updateDayMatrix(); |
93 | } | 94 | } |
94 | } | 95 | } |
95 | 96 | ||
96 | void DateNavigatorContainer::updateToday() | 97 | void DateNavigatorContainer::updateToday() |
97 | { | 98 | { |
98 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); | 99 | qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); |
99 | #if 0 | 100 | #if 0 |
100 | mNavigatorView->updateToday(); | 101 | mNavigatorView->updateToday(); |
101 | KDateNavigator *n; | 102 | KDateNavigator *n; |
102 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 103 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
103 | n->updateToday(); | 104 | n->updateToday(); |
104 | } | 105 | } |
105 | #endif | 106 | #endif |
106 | } | 107 | } |
107 | 108 | ||
108 | void DateNavigatorContainer::updateView() | 109 | void DateNavigatorContainer::updateView() |
109 | { | 110 | { |
110 | mNavigatorView->updateView(); | 111 | mNavigatorView->updateView(); |
111 | KDateNavigator *n; | 112 | KDateNavigator *n; |
112 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 113 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
113 | n->updateView(); | 114 | n->updateView(); |
114 | } | 115 | } |
115 | } | 116 | } |
116 | 117 | ||
117 | void DateNavigatorContainer::updateConfig() | 118 | void DateNavigatorContainer::updateConfig() |
118 | { | 119 | { |
119 | mNavigatorView->updateConfig(); | 120 | mNavigatorView->updateConfig(); |
120 | KDateNavigator *n; | 121 | KDateNavigator *n; |
121 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 122 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
122 | n->updateConfig(); | 123 | n->updateConfig(); |
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | void DateNavigatorContainer::selectDates( const DateList &dateList ) | 127 | void DateNavigatorContainer::selectDates( const DateList &dateList ) |
127 | { | 128 | { |
128 | mNavigatorView->selectDates( dateList ); | 129 | mNavigatorView->selectDates( dateList ); |
129 | setBaseDates(); | 130 | setBaseDates(); |
130 | if ( mExtraViews.count() ) { | 131 | if ( mExtraViews.count() ) { |
131 | KDateNavigator *view = mExtraViews.at( 0 ); | 132 | KDateNavigator *view = mExtraViews.at( 0 ); |
132 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 133 | view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
133 | view->dayMatrix()->repaint(); | 134 | view->dayMatrix()->repaint(); |
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
137 | void DateNavigatorContainer::setBaseDates() | 138 | void DateNavigatorContainer::setBaseDates() |
138 | { | 139 | { |
139 | KCal::DateList dateList = mNavigatorView->selectedDates(); | 140 | KCal::DateList dateList = mNavigatorView->selectedDates(); |
140 | if ( dateList.isEmpty() ) { | 141 | if ( dateList.isEmpty() ) { |
141 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; | 142 | kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; |
142 | } | 143 | } |
143 | QDate baseDate = dateList.first(); | 144 | QDate baseDate = dateList.first(); |
144 | KDateNavigator *n; | 145 | KDateNavigator *n; |
145 | bool doRepaint = false; // skip first repaint | 146 | bool doRepaint = false; // skip first repaint |
146 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { | 147 | for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { |
147 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); | 148 | baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); |
148 | n->setBaseDate( baseDate, doRepaint ); | 149 | n->setBaseDate( baseDate, doRepaint ); |
149 | doRepaint = true; | 150 | doRepaint = true; |
150 | } | 151 | } |
151 | } | 152 | } |
152 | 153 | ||
153 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) | 154 | void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) |
154 | { | 155 | { |
155 | #if 0 | 156 | #if 0 |
156 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; | 157 | kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl; |
157 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; | 158 | kdDebug(5850) << " CURRENT SIZE: " << size() << endl; |
158 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; | 159 | kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl; |
159 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; | 160 | kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl; |
160 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; | 161 | kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl; |
161 | #endif | 162 | #endif |
162 | QSize minSize = mNavigatorView->yourSizeHint(); | 163 | QSize minSize = mNavigatorView->yourSizeHint(); |
163 | 164 | ||
164 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; | 165 | // kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl; |
165 | 166 | ||
166 | int verticalCount = size().height() / minSize.height(); | 167 | int verticalCount = size().height() / minSize.height(); |
167 | int horizontalCount = size().width() / minSize.width(); | 168 | int horizontalCount = size().width() / minSize.width(); |
168 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); | 169 | //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); |
169 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); | 170 | //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); |
171 | bool fontchange = false; | ||
172 | QFont fo; | ||
170 | if ( horizontalCount != mHorizontalCount || | 173 | if ( horizontalCount != mHorizontalCount || |
171 | verticalCount != mVerticalCount ) { | 174 | verticalCount != mVerticalCount ) { |
172 | uint count = horizontalCount * verticalCount; | 175 | uint count = horizontalCount * verticalCount; |
173 | if ( count == 0 ) { | 176 | if ( count == 0 ) { |
174 | mNavigatorView->resize( minSize ); | 177 | bool ok; |
175 | return; | 178 | fo = mNavigatorView->yourFontHint( size() , &ok); |
179 | //mNavigatorView->resize( size() ); | ||
180 | //if ( ! ok ) | ||
181 | // return; | ||
182 | minSize = mNavigatorView->sizeHint(); | ||
183 | verticalCount = size().height() / minSize.height(); | ||
184 | horizontalCount = size().width() / minSize.width(); | ||
185 | if ( horizontalCount == 0 ) | ||
186 | horizontalCount = 1; | ||
187 | if ( verticalCount == 0 ) | ||
188 | verticalCount = 1; | ||
189 | fontchange = true; | ||
190 | count = horizontalCount * verticalCount; | ||
191 | } else { | ||
192 | if ( mNavigatorView->fontChanged() ) { | ||
193 | fontchange = true; | ||
194 | fo = KOPrefs::instance()->mDateNavigatorFont; | ||
195 | mNavigatorView->changeFont( fo ); | ||
196 | mNavigatorView->unsetFontChanged(); | ||
197 | } | ||
176 | } | 198 | } |
177 | 199 | ||
178 | while ( count > ( mExtraViews.count() + 1 ) ) { | 200 | while ( count > ( mExtraViews.count() + 1 ) ) { |
179 | KDateNavigator *n = new KDateNavigator( this ); | 201 | KDateNavigator *n = new KDateNavigator( this ); |
180 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); | 202 | n->setMonthSignalOffset ( mExtraViews.count()+1 ); |
181 | mExtraViews.append( n ); | 203 | mExtraViews.append( n ); |
182 | n->setCalendar( mCalendar ); | 204 | n->setCalendar( mCalendar ); |
183 | setBaseDates(); | 205 | setBaseDates(); |
184 | connectNavigatorView( n ); | 206 | connectNavigatorView( n ); |
185 | n->show(); | 207 | n->show(); |
186 | } | 208 | } |
187 | 209 | ||
188 | while ( count < ( mExtraViews.count() + 1 ) ) { | 210 | while ( count < ( mExtraViews.count() + 1 ) ) { |
189 | mExtraViews.removeLast(); | 211 | mExtraViews.removeLast(); |
190 | } | 212 | } |
191 | 213 | if ( fontchange ) { | |
214 | //mNavigatorView->changeFont( fo ); | ||
215 | uint i; | ||
216 | for( i = 0; i < mExtraViews.count(); ++i ) { | ||
217 | KDateNavigator *view = mExtraViews.at( i ); | ||
218 | view->changeFont( fo ); | ||
219 | } | ||
220 | } | ||
192 | mHorizontalCount = horizontalCount; | 221 | mHorizontalCount = horizontalCount; |
193 | mVerticalCount = verticalCount; | 222 | mVerticalCount = verticalCount; |
194 | } | 223 | } |
195 | |||
196 | int height = size().height() / verticalCount; | 224 | int height = size().height() / verticalCount; |
197 | int width = size().width() / horizontalCount; | 225 | int width = size().width() / horizontalCount; |
198 | 226 | ||
199 | NavigatorBar *bar = mNavigatorView->navigatorBar(); | 227 | NavigatorBar *bar = mNavigatorView->navigatorBar(); |
200 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); | 228 | if ( horizontalCount > 1 ) bar->showButtons( true, false ); |
201 | else bar->showButtons( true, true ); | 229 | else bar->showButtons( true, true ); |
202 | 230 | ||
203 | mNavigatorView->setGeometry(0, | 231 | mNavigatorView->setGeometry(0, |
204 | 0, width, height ); | 232 | 0, width, height ); |
205 | for( uint i = 0; i < mExtraViews.count(); ++i ) { | 233 | for( uint i = 0; i < mExtraViews.count(); ++i ) { |
206 | int x = ( i + 1 ) % horizontalCount; | 234 | int x = ( i + 1 ) % horizontalCount; |
207 | int y = ( i + 1 ) / horizontalCount; | 235 | int y = ( i + 1 ) / horizontalCount; |
208 | 236 | ||
209 | KDateNavigator *view = mExtraViews.at( i ); | 237 | KDateNavigator *view = mExtraViews.at( i ); |
210 | bar = view->navigatorBar(); | 238 | bar = view->navigatorBar(); |
211 | if ( y > 0 ) bar->showButtons( false, false ); | 239 | if ( y > 0 ) bar->showButtons( false, false ); |
212 | else { | 240 | else { |
213 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); | 241 | if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); |
214 | else bar->showButtons( false, false ); | 242 | else bar->showButtons( false, false ); |
215 | } | 243 | } |
216 | view->setGeometry( x * width, | 244 | view->setGeometry( x * width, |
217 | y * height, width, height ); | 245 | y * height, width, height ); |
218 | } | 246 | } |
219 | } | 247 | } |
220 | 248 | ||
221 | QSize DateNavigatorContainer::minimumSizeHint() const | 249 | QSize DateNavigatorContainer::minimumSizeHint() const |
222 | { | 250 | { |
223 | return mNavigatorView->minimumSizeHint(); | 251 | return mNavigatorView->minimumSizeHint(); |
224 | } | 252 | } |
225 | 253 | ||
226 | QSize DateNavigatorContainer::sizeHint() const | 254 | QSize DateNavigatorContainer::sizeHint() const |
227 | { | 255 | { |
228 | return mNavigatorView->sizeHint(); | 256 | return mNavigatorView->sizeHint(); |
229 | } | 257 | } |
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index b097dc1..92a0ac2 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,390 +1,430 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | 64 | ||
65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
66 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
68 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
74 | 74 | ||
75 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
77 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | 80 | ||
81 | // Set up the heading fields. | 81 | // Set up the heading fields. |
82 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
83 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
85 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
86 | 86 | ||
87 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
88 | } | 88 | } |
89 | 89 | ||
90 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
91 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
92 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
93 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter); |
94 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
95 | if(!m_bShowWeekNums) { | 95 | if(!m_bShowWeekNums) { |
96 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
97 | } | 97 | } |
98 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
99 | 99 | ||
100 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
101 | } | 101 | } |
102 | 102 | ||
103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
105 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
106 | 106 | ||
107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
109 | 109 | ||
110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
111 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
112 | 112 | ||
113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
114 | 114 | ||
115 | // read settings from configuration file. | 115 | // read settings from configuration file. |
116 | updateConfig(); | 116 | updateConfig(); |
117 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
118 | mySizeHint = sizeHint(); | 118 | mySizeHint = sizeHint(); |
119 | mFontChanged = false; | ||
120 | } | ||
121 | void KDateNavigator::changeFont ( QFont fo ) | ||
122 | { | ||
123 | setFont( fo ); | ||
124 | mNavigatorBar->resetFont( fo ); | ||
125 | } | ||
126 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | ||
127 | { | ||
128 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | ||
129 | *b = false; | ||
130 | int fontPoint = fo.pointSize(); | ||
131 | while ( fontPoint > 5 ) { | ||
132 | --fontPoint; | ||
133 | fo.setPointSize( fontPoint ); | ||
134 | setFont( fo ); | ||
135 | mFontChanged = true; | ||
136 | mNavigatorBar->resetFont( fo ); | ||
137 | QSize sh = sizeHint(); | ||
138 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | ||
139 | if ( si.width() > sh.width() && si.height() > sh.height()) { | ||
140 | *b = true; | ||
141 | //qDebug("fooooooooooooooooooooooouuuuund "); | ||
142 | break; | ||
143 | } | ||
144 | } | ||
145 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | ||
146 | return fo; | ||
147 | } | ||
148 | QSize KDateNavigator::sizeHint() const | ||
149 | { | ||
150 | QFontMetrics fm ( font() ); | ||
151 | QSize day = daymatrix->sizeHint(); | ||
152 | QSize nav = mNavigatorBar->sizeHint(); | ||
153 | int wid = fm.width( "30") + day.width()+3; | ||
154 | int hei = fm.height() +day.height()+nav.height()+2; | ||
155 | if ( wid < nav.width() ) | ||
156 | wid = nav.width() ; | ||
157 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | ||
158 | return QSize ( wid, hei ); | ||
119 | } | 159 | } |
120 | void KDateNavigator::slotMonthSelected( int m ) | 160 | void KDateNavigator::slotMonthSelected( int m ) |
121 | { | 161 | { |
122 | if ( m_MthYr.month() <= mMonthSignalOffset) | 162 | if ( m_MthYr.month() <= mMonthSignalOffset) |
123 | m += 12; | 163 | m += 12; |
124 | int mo = m - mMonthSignalOffset; | 164 | int mo = m - mMonthSignalOffset; |
125 | emit monthSelected( m - mMonthSignalOffset ); | 165 | emit monthSelected( m - mMonthSignalOffset ); |
126 | 166 | ||
127 | } | 167 | } |
128 | void KDateNavigator::setCalendar( Calendar *cal ) | 168 | void KDateNavigator::setCalendar( Calendar *cal ) |
129 | { | 169 | { |
130 | daymatrix->setCalendar( cal ); | 170 | daymatrix->setCalendar( cal ); |
131 | } | 171 | } |
132 | 172 | ||
133 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 173 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
134 | { | 174 | { |
135 | m_MthYr = date; | 175 | m_MthYr = date; |
136 | 176 | ||
137 | updateDates(); | 177 | updateDates(); |
138 | updateView(); | 178 | updateView(); |
139 | 179 | ||
140 | KCal::DateList dates; | 180 | KCal::DateList dates; |
141 | dates.append( date ); | 181 | dates.append( date ); |
142 | mNavigatorBar->selectDates( dates ); | 182 | mNavigatorBar->selectDates( dates ); |
143 | 183 | ||
144 | daymatrix->clearSelection(); | 184 | daymatrix->clearSelection(); |
145 | if ( doRepaint ) | 185 | if ( doRepaint ) |
146 | daymatrix->repaint(); | 186 | daymatrix->repaint(); |
147 | } | 187 | } |
148 | 188 | ||
149 | void KDateNavigator::enableRollover(RolloverType r) | 189 | void KDateNavigator::enableRollover(RolloverType r) |
150 | { | 190 | { |
151 | switch(r) | 191 | switch(r) |
152 | { | 192 | { |
153 | case None : | 193 | case None : |
154 | if (updateTimer) | 194 | if (updateTimer) |
155 | { | 195 | { |
156 | updateTimer->stop(); | 196 | updateTimer->stop(); |
157 | delete updateTimer; | 197 | delete updateTimer; |
158 | updateTimer=0L; | 198 | updateTimer=0L; |
159 | } | 199 | } |
160 | break; | 200 | break; |
161 | case FollowDay : | 201 | case FollowDay : |
162 | case FollowMonth : | 202 | case FollowMonth : |
163 | if (!updateTimer) | 203 | if (!updateTimer) |
164 | { | 204 | { |
165 | updateTimer = new QTimer(this); | 205 | updateTimer = new QTimer(this); |
166 | QObject::connect(updateTimer,SIGNAL(timeout()), | 206 | QObject::connect(updateTimer,SIGNAL(timeout()), |
167 | this,SLOT(possiblyPastMidnight())); | 207 | this,SLOT(possiblyPastMidnight())); |
168 | } | 208 | } |
169 | updateTimer->start(0,true); | 209 | updateTimer->start(0,true); |
170 | lastDayChecked = QDate::currentDate(); | 210 | lastDayChecked = QDate::currentDate(); |
171 | } | 211 | } |
172 | updateRollover=r; | 212 | updateRollover=r; |
173 | } | 213 | } |
174 | 214 | ||
175 | 215 | ||
176 | KDateNavigator::~KDateNavigator() | 216 | KDateNavigator::~KDateNavigator() |
177 | { | 217 | { |
178 | } | 218 | } |
179 | 219 | ||
180 | 220 | ||
181 | void KDateNavigator::passedMidnight() | 221 | void KDateNavigator::passedMidnight() |
182 | { | 222 | { |
183 | QDate today = QDate::currentDate(); | 223 | QDate today = QDate::currentDate(); |
184 | bool emitMonth = false; | 224 | bool emitMonth = false; |
185 | 225 | ||
186 | if (today.month() != lastDayChecked.month()) | 226 | if (today.month() != lastDayChecked.month()) |
187 | { | 227 | { |
188 | if (updateRollover==FollowMonth && | 228 | if (updateRollover==FollowMonth && |
189 | daymatrix->isEndOfMonth()) { | 229 | daymatrix->isEndOfMonth()) { |
190 | goNextMonth(); | 230 | goNextMonth(); |
191 | emitMonth=true; | 231 | emitMonth=true; |
192 | } | 232 | } |
193 | } | 233 | } |
194 | daymatrix->recalculateToday(); | 234 | daymatrix->recalculateToday(); |
195 | daymatrix->repaint(); | 235 | daymatrix->repaint(); |
196 | emit dayPassed(today); | 236 | emit dayPassed(today); |
197 | if (emitMonth) { emit monthPassed(today); } | 237 | if (emitMonth) { emit monthPassed(today); } |
198 | } | 238 | } |
199 | 239 | ||
200 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 240 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
201 | { | 241 | { |
202 | if (lastDayChecked!=QDate::currentDate()) | 242 | if (lastDayChecked!=QDate::currentDate()) |
203 | { | 243 | { |
204 | passedMidnight(); | 244 | passedMidnight(); |
205 | lastDayChecked=QDate::currentDate(); | 245 | lastDayChecked=QDate::currentDate(); |
206 | } | 246 | } |
207 | // Set the timer to go off 1 second after midnight | 247 | // Set the timer to go off 1 second after midnight |
208 | // or after 8 minutes, whichever comes first. | 248 | // or after 8 minutes, whichever comes first. |
209 | if (updateTimer) | 249 | if (updateTimer) |
210 | { | 250 | { |
211 | QTime now = QTime::currentTime(); | 251 | QTime now = QTime::currentTime(); |
212 | QTime midnight = QTime(23,59,59); | 252 | QTime midnight = QTime(23,59,59); |
213 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 253 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
214 | 254 | ||
215 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 255 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
216 | //.arg(now.toString()).arg(midnight.toString())); | 256 | //.arg(now.toString()).arg(midnight.toString())); |
217 | 257 | ||
218 | updateTimer->stop(); | 258 | updateTimer->stop(); |
219 | updateTimer->start(msecsWait,true); | 259 | updateTimer->start(msecsWait,true); |
220 | } | 260 | } |
221 | } | 261 | } |
222 | 262 | ||
223 | void KDateNavigator::updateDates() | 263 | void KDateNavigator::updateDates() |
224 | { | 264 | { |
225 | // Find the first day of the week of the current month. | 265 | // Find the first day of the week of the current month. |
226 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 266 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
227 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 267 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
228 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 268 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
229 | //int di = d1 - d2 + 1; | 269 | //int di = d1 - d2 + 1; |
230 | dayone = dayone.addDays( -d2 + 1 ); | 270 | dayone = dayone.addDays( -d2 + 1 ); |
231 | 271 | ||
232 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 272 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
233 | 273 | ||
234 | // If month begins on Monday and Monday is first day of week, | 274 | // If month begins on Monday and Monday is first day of week, |
235 | // month should begin on second line. Sunday doesn't have this problem. | 275 | // month should begin on second line. Sunday doesn't have this problem. |
236 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 276 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
237 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 277 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
238 | 278 | ||
239 | // update the matrix dates | 279 | // update the matrix dates |
240 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 280 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
241 | 281 | ||
242 | 282 | ||
243 | daymatrix->updateView(dayone.addDays(index)); | 283 | daymatrix->updateView(dayone.addDays(index)); |
244 | //each updateDates is followed by an updateView -> repaint is issued there ! | 284 | //each updateDates is followed by an updateView -> repaint is issued there ! |
245 | // daymatrix->repaint(); | 285 | // daymatrix->repaint(); |
246 | } | 286 | } |
247 | 287 | ||
248 | void KDateNavigator::updateDayMatrix() | 288 | void KDateNavigator::updateDayMatrix() |
249 | { | 289 | { |
250 | daymatrix->updateView(); | 290 | daymatrix->updateView(); |
251 | //daymatrix->repaint(); | 291 | //daymatrix->repaint(); |
252 | } | 292 | } |
253 | 293 | ||
254 | 294 | ||
255 | void KDateNavigator::updateView() | 295 | void KDateNavigator::updateView() |
256 | { | 296 | { |
257 | 297 | ||
258 | setUpdatesEnabled( false ); | 298 | setUpdatesEnabled( false ); |
259 | 299 | ||
260 | int i; | 300 | int i; |
261 | 301 | ||
262 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 302 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
263 | daymatrix->updateView(); | 303 | daymatrix->updateView(); |
264 | 304 | ||
265 | // set the week numbers. | 305 | // set the week numbers. |
266 | for(i = 0; i < 6; i++) { | 306 | for(i = 0; i < 6; i++) { |
267 | QString weeknum; | 307 | QString weeknum; |
268 | // remember, according to ISO 8601, the first week of the year is the | 308 | // remember, according to ISO 8601, the first week of the year is the |
269 | // first week that contains a thursday. Thus we must subtract off 4, | 309 | // first week that contains a thursday. Thus we must subtract off 4, |
270 | // not just 1. | 310 | // not just 1. |
271 | 311 | ||
272 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 312 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
273 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 313 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
274 | 314 | ||
275 | int add = 0; | 315 | int add = 0; |
276 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 316 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
277 | ++add; | 317 | ++add; |
278 | if (dayOfYear % 7 != 0) | 318 | if (dayOfYear % 7 != 0) |
279 | weeknum.setNum(dayOfYear / 7 + 1+add); | 319 | weeknum.setNum(dayOfYear / 7 + 1+add); |
280 | else | 320 | else |
281 | weeknum.setNum(dayOfYear / 7 +add); | 321 | weeknum.setNum(dayOfYear / 7 +add); |
282 | weeknos[i]->setText(weeknum); | 322 | weeknos[i]->setText(weeknum); |
283 | } | 323 | } |
284 | 324 | ||
285 | setUpdatesEnabled( true ); | 325 | setUpdatesEnabled( true ); |
286 | // kdDebug() << "updateView() -> repaint()" << endl; | 326 | // kdDebug() << "updateView() -> repaint()" << endl; |
287 | repaint(); | 327 | repaint(); |
288 | // daymatrix->repaint(); | 328 | // daymatrix->repaint(); |
289 | } | 329 | } |
290 | 330 | ||
291 | void KDateNavigator::updateConfig() | 331 | void KDateNavigator::updateConfig() |
292 | { | 332 | { |
293 | int day; | 333 | int day; |
294 | for(int i=0; i<7; i++) { | 334 | for(int i=0; i<7; i++) { |
295 | // take the first letter of the day name to be the abbreviation | 335 | // take the first letter of the day name to be the abbreviation |
296 | if (KGlobal::locale()->weekStartsMonday()) { | 336 | if (KGlobal::locale()->weekStartsMonday()) { |
297 | day = i+1; | 337 | day = i+1; |
298 | } else { | 338 | } else { |
299 | if (i==0) day = 7; | 339 | if (i==0) day = 7; |
300 | else day = i; | 340 | else day = i; |
301 | } | 341 | } |
302 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 342 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
303 | true ); | 343 | true ); |
304 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 344 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
305 | headings[i]->setText( dayName ); | 345 | headings[i]->setText( dayName ); |
306 | } | 346 | } |
307 | updateDates(); | 347 | updateDates(); |
308 | updateView(); | 348 | updateView(); |
309 | } | 349 | } |
310 | 350 | ||
311 | void KDateNavigator::setShowWeekNums(bool enabled) | 351 | void KDateNavigator::setShowWeekNums(bool enabled) |
312 | { | 352 | { |
313 | m_bShowWeekNums = enabled; | 353 | m_bShowWeekNums = enabled; |
314 | for(int i=0; i<6; i++) { | 354 | for(int i=0; i<6; i++) { |
315 | if(enabled) | 355 | if(enabled) |
316 | weeknos[i]->show(); | 356 | weeknos[i]->show(); |
317 | else | 357 | else |
318 | weeknos[i]->hide(); | 358 | weeknos[i]->hide(); |
319 | } | 359 | } |
320 | resize(size()); | 360 | resize(size()); |
321 | } | 361 | } |
322 | 362 | ||
323 | void KDateNavigator::selectDates(const DateList& dateList) | 363 | void KDateNavigator::selectDates(const DateList& dateList) |
324 | { | 364 | { |
325 | 365 | ||
326 | if (dateList.count() > 0) { | 366 | if (dateList.count() > 0) { |
327 | mNavigatorBar->selectDates( dateList ); | 367 | mNavigatorBar->selectDates( dateList ); |
328 | mSelectedDates = dateList; | 368 | mSelectedDates = dateList; |
329 | 369 | ||
330 | // set our record of the month and year that this datetbl is | 370 | // set our record of the month and year that this datetbl is |
331 | // displaying. | 371 | // displaying. |
332 | m_MthYr = mSelectedDates.first(); | 372 | m_MthYr = mSelectedDates.first(); |
333 | 373 | ||
334 | 374 | ||
335 | // set our record of the first day of the week of the current | 375 | // set our record of the first day of the week of the current |
336 | // month. This needs to be done before calling dayToIndex, since it | 376 | // month. This needs to be done before calling dayToIndex, since it |
337 | // relies on this information being up to date. | 377 | // relies on this information being up to date. |
338 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 378 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
339 | m_fstDayOfWk = dayone.dayOfWeek(); | 379 | m_fstDayOfWk = dayone.dayOfWeek(); |
340 | 380 | ||
341 | updateDates(); | 381 | updateDates(); |
342 | 382 | ||
343 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 383 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
344 | 384 | ||
345 | updateView(); | 385 | updateView(); |
346 | } | 386 | } |
347 | } | 387 | } |
348 | 388 | ||
349 | int KDateNavigator::dayNum(int row, int col) | 389 | int KDateNavigator::dayNum(int row, int col) |
350 | { | 390 | { |
351 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 391 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
352 | } | 392 | } |
353 | 393 | ||
354 | int KDateNavigator::dayToIndex(int dayNum) | 394 | int KDateNavigator::dayToIndex(int dayNum) |
355 | { | 395 | { |
356 | int row, col; | 396 | int row, col; |
357 | 397 | ||
358 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 398 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
359 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 399 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
360 | row++; | 400 | row++; |
361 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; | 401 | col = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) % 7; |
362 | return row * 7 + col; | 402 | return row * 7 + col; |
363 | } | 403 | } |
364 | 404 | ||
365 | void KDateNavigator::wheelEvent (QWheelEvent *e) | 405 | void KDateNavigator::wheelEvent (QWheelEvent *e) |
366 | { | 406 | { |
367 | if(e->delta()>0) emit goPrevious(); | 407 | if(e->delta()>0) emit goPrevious(); |
368 | else emit goNext(); | 408 | else emit goNext(); |
369 | 409 | ||
370 | e->accept(); | 410 | e->accept(); |
371 | } | 411 | } |
372 | 412 | ||
373 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) | 413 | bool KDateNavigator::eventFilter (QObject *o,QEvent *e) |
374 | { | 414 | { |
375 | if (e->type() == QEvent::MouseButtonPress) { | 415 | if (e->type() == QEvent::MouseButtonPress) { |
376 | int i; | 416 | int i; |
377 | for(i=0;i<6;++i) { | 417 | for(i=0;i<6;++i) { |
378 | if (o == weeknos[i]) { | 418 | if (o == weeknos[i]) { |
379 | QDate weekstart = daymatrix->getDate(i*7); | 419 | QDate weekstart = daymatrix->getDate(i*7); |
380 | emit weekClicked(weekstart); | 420 | emit weekClicked(weekstart); |
381 | break; | 421 | break; |
382 | } | 422 | } |
383 | } | 423 | } |
384 | return true; | 424 | return true; |
385 | } else { | 425 | } else { |
386 | return false; | 426 | return false; |
387 | } | 427 | } |
388 | } | 428 | } |
389 | 429 | ||
390 | //#include "kdatenavigator.moc" | 430 | //#include "kdatenavigator.moc" |
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h index 292e71c..3177687 100644 --- a/korganizer/kdatenavigator.h +++ b/korganizer/kdatenavigator.h | |||
@@ -1,154 +1,160 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KDATENAVIGATOR_H | 23 | #ifndef KDATENAVIGATOR_H |
24 | #define KDATENAVIGATOR_H | 24 | #define KDATENAVIGATOR_H |
25 | 25 | ||
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | 29 | ||
30 | #include <libkcal/calendar.h> | 30 | #include <libkcal/calendar.h> |
31 | 31 | ||
32 | #include "kodaymatrix.h" | 32 | #include "kodaymatrix.h" |
33 | 33 | ||
34 | class QPushButton; | 34 | class QPushButton; |
35 | class QTimer; | 35 | class QTimer; |
36 | 36 | ||
37 | class KCalendarSystem; | 37 | class KCalendarSystem; |
38 | 38 | ||
39 | class NavigatorBar; | 39 | class NavigatorBar; |
40 | 40 | ||
41 | class KDateNavigator: public QFrame | 41 | class KDateNavigator: public QFrame |
42 | { | 42 | { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | public: | 44 | public: |
45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); | 45 | KDateNavigator( QWidget *parent = 0,const char *name = 0 ); |
46 | ~KDateNavigator(); | 46 | ~KDateNavigator(); |
47 | 47 | ||
48 | /** The DateNavigator automatically checks for | 48 | /** The DateNavigator automatically checks for |
49 | * the passage of midnight. If rollover type is | 49 | * the passage of midnight. If rollover type is |
50 | * set to None, no signals are emitted and no | 50 | * set to None, no signals are emitted and no |
51 | * processing is done. With rollover set to | 51 | * processing is done. With rollover set to |
52 | * FollowDay, the day highlighter changes at | 52 | * FollowDay, the day highlighter changes at |
53 | * midnight and dayPassed() is emitted. | 53 | * midnight and dayPassed() is emitted. |
54 | * With FollowMonth, it has the same effect | 54 | * With FollowMonth, it has the same effect |
55 | * as FollowDay but also adjusts the month that is | 55 | * as FollowDay but also adjusts the month that is |
56 | * visible and emits monthPassed() when the month changes. | 56 | * visible and emits monthPassed() when the month changes. |
57 | */ | 57 | */ |
58 | enum RolloverType { None, FollowDay, FollowMonth } ; | 58 | enum RolloverType { None, FollowDay, FollowMonth } ; |
59 | void enableRollover( RolloverType ); | 59 | void enableRollover( RolloverType ); |
60 | 60 | ||
61 | void setShowWeekNums( bool enabled ); | 61 | void setShowWeekNums( bool enabled ); |
62 | void setCalendar( Calendar * ); | 62 | void setCalendar( Calendar * ); |
63 | void setBaseDate( const QDate & , bool doRepaint = true ); | 63 | void setBaseDate( const QDate & , bool doRepaint = true ); |
64 | KCal::DateList selectedDates() const { return mSelectedDates; } | 64 | KCal::DateList selectedDates() const { return mSelectedDates; } |
65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } | 65 | NavigatorBar *navigatorBar() const { return mNavigatorBar; } |
66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} | 66 | void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off;} |
67 | QSize yourSizeHint() { return mySizeHint; } | 67 | QSize yourSizeHint() { return mySizeHint; } |
68 | KODayMatrix *dayMatrix() { return daymatrix ;} | 68 | QFont yourFontHint( QSize , bool * b); |
69 | bool fontChanged() {return mFontChanged; } | ||
70 | void unsetFontChanged() { mFontChanged = false; } | ||
71 | KODayMatrix *dayMatrix() { return daymatrix ;} | ||
72 | QSize sizeHint() const; | ||
73 | void changeFont ( QFont fo ); | ||
69 | public slots: | 74 | public slots: |
70 | void selectDates( const KCal::DateList & ); | 75 | void selectDates( const KCal::DateList & ); |
71 | void updateView(); | 76 | void updateView(); |
72 | void updateConfig(); | 77 | void updateConfig(); |
73 | void updateDayMatrix(); | 78 | void updateDayMatrix(); |
74 | 79 | ||
75 | signals: | 80 | signals: |
76 | void datesSelected( const KCal::DateList & ); | 81 | void datesSelected( const KCal::DateList & ); |
77 | void eventDropped( Event * ); | 82 | void eventDropped( Event * ); |
78 | void weekClicked( const QDate &); | 83 | void weekClicked( const QDate &); |
79 | 84 | ||
80 | void goPrevious(); | 85 | void goPrevious(); |
81 | void goNext(); | 86 | void goNext(); |
82 | 87 | ||
83 | void goNextMonth(); | 88 | void goNextMonth(); |
84 | void goPrevMonth(); | 89 | void goPrevMonth(); |
85 | void goNextYear(); | 90 | void goNextYear(); |
86 | void goPrevYear(); | 91 | void goPrevYear(); |
87 | void monthSelected( int ); | 92 | void monthSelected( int ); |
88 | 93 | ||
89 | // Signals emitted at midnight carrying the new date. | 94 | // Signals emitted at midnight carrying the new date. |
90 | void dayPassed( QDate ); | 95 | void dayPassed( QDate ); |
91 | void monthPassed( QDate ); | 96 | void monthPassed( QDate ); |
92 | 97 | ||
93 | protected slots: | 98 | protected slots: |
94 | 99 | ||
95 | /** | 100 | /** |
96 | * Called regularly to see if we need to update the view | 101 | * Called regularly to see if we need to update the view |
97 | * wrt. the today box and the month box. Only important | 102 | * wrt. the today box and the month box. Only important |
98 | * if you leave KOrganizer idle for long periods of time. | 103 | * if you leave KOrganizer idle for long periods of time. |
99 | * | 104 | * |
100 | * Until we have a reliable way of setting QTimers to go | 105 | * Until we have a reliable way of setting QTimers to go |
101 | * off at a particular wall-clock time, we need this, | 106 | * off at a particular wall-clock time, we need this, |
102 | * which calls passedMidnight() at the right moments. | 107 | * which calls passedMidnight() at the right moments. |
103 | */ | 108 | */ |
104 | void possiblyPastMidnight(); | 109 | void possiblyPastMidnight(); |
105 | 110 | ||
106 | /** handles updating the view when midnight has come by due to idle time. | 111 | /** handles updating the view when midnight has come by due to idle time. |
107 | * | 112 | * |
108 | */ | 113 | */ |
109 | void passedMidnight(); | 114 | void passedMidnight(); |
110 | void slotMonthSelected( int m ); | 115 | void slotMonthSelected( int m ); |
111 | protected: | 116 | protected: |
112 | void updateDates(); | 117 | void updateDates(); |
113 | 118 | ||
114 | void wheelEvent (QWheelEvent *); | 119 | void wheelEvent (QWheelEvent *); |
115 | 120 | ||
116 | bool eventFilter (QObject *,QEvent *); | 121 | bool eventFilter (QObject *,QEvent *); |
117 | 122 | ||
118 | private: | 123 | private: |
119 | QSize mySizeHint; | 124 | QSize mySizeHint; |
125 | bool mFontChanged; | ||
120 | int mMonthSignalOffset; | 126 | int mMonthSignalOffset; |
121 | NavigatorBar *mNavigatorBar; | 127 | NavigatorBar *mNavigatorBar; |
122 | 128 | ||
123 | QFrame *headingSep; | 129 | QFrame *headingSep; |
124 | QFrame *weeknumSep; | 130 | QFrame *weeknumSep; |
125 | QLabel *headings[7]; | 131 | QLabel *headings[7]; |
126 | QLabel *weeknos[7]; | 132 | QLabel *weeknos[7]; |
127 | KODayMatrix *daymatrix; | 133 | KODayMatrix *daymatrix; |
128 | 134 | ||
129 | KCal::DateList mSelectedDates; | 135 | KCal::DateList mSelectedDates; |
130 | QDate m_MthYr; | 136 | QDate m_MthYr; |
131 | int m_fstDayOfWk; | 137 | int m_fstDayOfWk; |
132 | bool m_bShowWeekNums; | 138 | bool m_bShowWeekNums; |
133 | 139 | ||
134 | int dayNum(int row, int col); | 140 | int dayNum(int row, int col); |
135 | int dayToIndex(int dayNum); | 141 | int dayToIndex(int dayNum); |
136 | 142 | ||
137 | Calendar *mCalendar; | 143 | Calendar *mCalendar; |
138 | KCalendarSystem *mCalendarSystem; | 144 | KCalendarSystem *mCalendarSystem; |
139 | 145 | ||
140 | const QString *curHeaders; | 146 | const QString *curHeaders; |
141 | 147 | ||
142 | /** used to update the day view periodically, in particular every | 148 | /** used to update the day view periodically, in particular every |
143 | * midnight to move the "today" rectangle. | 149 | * midnight to move the "today" rectangle. |
144 | */ | 150 | */ |
145 | QTimer *updateTimer; | 151 | QTimer *updateTimer; |
146 | QDate lastDayChecked; | 152 | QDate lastDayChecked; |
147 | RolloverType updateRollover; | 153 | RolloverType updateRollover; |
148 | 154 | ||
149 | // Disabling copy constructor and assignment operator | 155 | // Disabling copy constructor and assignment operator |
150 | KDateNavigator(const KDateNavigator & ); | 156 | KDateNavigator(const KDateNavigator & ); |
151 | KDateNavigator &operator=(const KDateNavigator &); | 157 | KDateNavigator &operator=(const KDateNavigator &); |
152 | }; | 158 | }; |
153 | 159 | ||
154 | #endif | 160 | #endif |
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index 619ae39..9181936 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp | |||
@@ -1,798 +1,809 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | Parts of the source code have been copied from kdpdatebutton.cpp | 4 | Parts of the source code have been copied from kdpdatebutton.cpp |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source ode for Qt in the source distribution. | 22 | without including the source ode for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qevent.h> | 25 | #include <qevent.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | 34 | ||
35 | #include <libkcal/vcaldrag.h> | 35 | #include <libkcal/vcaldrag.h> |
36 | #include <libkcal/icaldrag.h> | 36 | #include <libkcal/icaldrag.h> |
37 | #include <libkcal/dndfactory.h> | 37 | #include <libkcal/dndfactory.h> |
38 | #include <libkcal/calendarresources.h> | 38 | #include <libkcal/calendarresources.h> |
39 | #include <libkcal/resourcecalendar.h> | 39 | #include <libkcal/resourcecalendar.h> |
40 | #include <kresources/resourceselectdialog.h> | 40 | #include <kresources/resourceselectdialog.h> |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #ifndef KORG_NOPLUGINS | 44 | #ifndef KORG_NOPLUGINS |
45 | #include "kocore.h" | 45 | #include "kocore.h" |
46 | #endif | 46 | #endif |
47 | #include "koprefs.h" | 47 | #include "koprefs.h" |
48 | #include "koglobals.h" | 48 | #include "koglobals.h" |
49 | 49 | ||
50 | #include "kodaymatrix.h" | 50 | #include "kodaymatrix.h" |
51 | 51 | ||
52 | // ============================================================================ | 52 | // ============================================================================ |
53 | // D Y N A M I C T I P | 53 | // D Y N A M I C T I P |
54 | // ============================================================================ | 54 | // ============================================================================ |
55 | 55 | ||
56 | DynamicTip::DynamicTip( QWidget * parent ) | 56 | DynamicTip::DynamicTip( QWidget * parent ) |
57 | : QToolTip( parent ) | 57 | : QToolTip( parent ) |
58 | { | 58 | { |
59 | matrix = (KODayMatrix*)parent; | 59 | matrix = (KODayMatrix*)parent; |
60 | } | 60 | } |
61 | 61 | ||
62 | class KODaymatrixWhatsThis :public QWhatsThis | 62 | class KODaymatrixWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { }; | 65 | KODaymatrixWhatsThis( KODayMatrix* view ) : QWhatsThis( view ),_view (view) { }; |
66 | 66 | ||
67 | protected: | 67 | protected: |
68 | virtual QString text( const QPoint& p ) | 68 | virtual QString text( const QPoint& p ) |
69 | { | 69 | { |
70 | return _view->getWhatsThisText( p ) ; | 70 | return _view->getWhatsThisText( p ) ; |
71 | } | 71 | } |
72 | private: | 72 | private: |
73 | KODayMatrix * _view; | 73 | KODayMatrix * _view; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | void DynamicTip::maybeTip( const QPoint &pos ) | 76 | void DynamicTip::maybeTip( const QPoint &pos ) |
77 | { | 77 | { |
78 | //calculate which cell of the matrix the mouse is in | 78 | //calculate which cell of the matrix the mouse is in |
79 | QRect sz = matrix->frameRect(); | 79 | QRect sz = matrix->frameRect(); |
80 | int dheight = sz.height()*7 / 42; | 80 | int dheight = sz.height()*7 / 42; |
81 | int dwidth = sz.width() / 7; | 81 | int dwidth = sz.width() / 7; |
82 | int row = pos.y()/dheight; | 82 | int row = pos.y()/dheight; |
83 | int col = pos.x()/dwidth; | 83 | int col = pos.x()/dwidth; |
84 | 84 | ||
85 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); | 85 | QRect rct(col*dwidth, row*dheight, dwidth, dheight); |
86 | 86 | ||
87 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << | 87 | // kdDebug() << "DynamicTip::maybeTip matrix cell index [" << |
88 | // col << "][" << row << "] => " <<(col+row*7) << endl; | 88 | // col << "][" << row << "] => " <<(col+row*7) << endl; |
89 | 89 | ||
90 | //show holiday names only | 90 | //show holiday names only |
91 | QString str = matrix->getHolidayLabel(col+row*7); | 91 | QString str = matrix->getHolidayLabel(col+row*7); |
92 | if (str.isEmpty()) return; | 92 | if (str.isEmpty()) return; |
93 | tip(rct, str); | 93 | tip(rct, str); |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | // ============================================================================ | 97 | // ============================================================================ |
98 | // K O D A Y M A T R I X | 98 | // K O D A Y M A T R I X |
99 | // ============================================================================ | 99 | // ============================================================================ |
100 | 100 | ||
101 | const int KODayMatrix::NOSELECTION = -1000; | 101 | const int KODayMatrix::NOSELECTION = -1000; |
102 | const int KODayMatrix::NUMDAYS = 42; | 102 | const int KODayMatrix::NUMDAYS = 42; |
103 | 103 | ||
104 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) | 104 | KODayMatrix::KODayMatrix( QWidget *parent, const char *name ) |
105 | : QFrame( parent, name ), mCalendar( 0 ) | 105 | : QFrame( parent, name ), mCalendar( 0 ) |
106 | 106 | ||
107 | #if 0 | 107 | #if 0 |
108 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : | 108 | KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : |
109 | QFrame(parent, name) | 109 | QFrame(parent, name) |
110 | #endif | 110 | #endif |
111 | { | 111 | { |
112 | new KODaymatrixWhatsThis(this); | 112 | new KODaymatrixWhatsThis(this); |
113 | mPendingUpdateBeforeRepaint = false; | 113 | mPendingUpdateBeforeRepaint = false; |
114 | mouseDown = false; | 114 | mouseDown = false; |
115 | // initialize dynamic arrays | 115 | // initialize dynamic arrays |
116 | bDays.resize ( NUMDAYS ); | 116 | bDays.resize ( NUMDAYS ); |
117 | days = new QDate[NUMDAYS]; | 117 | days = new QDate[NUMDAYS]; |
118 | daylbls = new QString[NUMDAYS]; | 118 | daylbls = new QString[NUMDAYS]; |
119 | events = new int[NUMDAYS]; | 119 | events = new int[NUMDAYS]; |
120 | mToolTip = new DynamicTip(this); | 120 | mToolTip = new DynamicTip(this); |
121 | 121 | ||
122 | // set default values used for drawing the matrix | 122 | // set default values used for drawing the matrix |
123 | mDefaultBackColor = palette().active().base(); | 123 | mDefaultBackColor = palette().active().base(); |
124 | mDefaultTextColor = palette().active().foreground(); | 124 | mDefaultTextColor = palette().active().foreground(); |
125 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); | 125 | mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); |
126 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); | 126 | mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); |
127 | mSelectedDaysColor = QColor("white"); | 127 | mSelectedDaysColor = QColor("white"); |
128 | mTodayMarginWidth = 2; | 128 | mTodayMarginWidth = 2; |
129 | mSelEnd = mSelStart = NOSELECTION; | 129 | mSelEnd = mSelStart = NOSELECTION; |
130 | 130 | ||
131 | setAcceptDrops(true); | 131 | setAcceptDrops(true); |
132 | //setFont( QFont("Arial", 10) ); | 132 | //setFont( QFont("Arial", 10) ); |
133 | 133 | ||
134 | mUpdateTimer = new QTimer( this ); | 134 | mUpdateTimer = new QTimer( this ); |
135 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); | 135 | connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); |
136 | mRepaintTimer = new QTimer( this ); | 136 | mRepaintTimer = new QTimer( this ); |
137 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); | 137 | connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); |
138 | mDayChanged = false; | 138 | mDayChanged = false; |
139 | updateView(); | 139 | updateView(); |
140 | } | 140 | } |
141 | QString KODayMatrix::getWhatsThisText( QPoint p ) | 141 | QString KODayMatrix::getWhatsThisText( QPoint p ) |
142 | { | 142 | { |
143 | 143 | ||
144 | int tmp = getDayIndexFrom(p.x(), p.y()); | 144 | int tmp = getDayIndexFrom(p.x(), p.y()); |
145 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) | 145 | if ( tmp < 0 || tmp > NUMDAYS-1 || !mCalendar ) |
146 | return QString(); | 146 | return QString(); |
147 | QDate mDate = days[tmp]; | 147 | QDate mDate = days[tmp]; |
148 | QPtrList<Event> eventlist = mCalendar->events(mDate); | 148 | QPtrList<Event> eventlist = mCalendar->events(mDate); |
149 | Event *event; | 149 | Event *event; |
150 | QStringList mToolTip; | 150 | QStringList mToolTip; |
151 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 151 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
152 | QString mToolTipText; | 152 | QString mToolTipText; |
153 | QString text; | 153 | QString text; |
154 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 154 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
155 | if (event->isMultiDay()) { | 155 | if (event->isMultiDay()) { |
156 | QString prefix = "<->";multiday = 2; | 156 | QString prefix = "<->";multiday = 2; |
157 | QString time; | 157 | QString time; |
158 | if ( event->doesRecur() ) { | 158 | if ( event->doesRecur() ) { |
159 | if ( event->recursOn( mDate) ) { | 159 | if ( event->recursOn( mDate) ) { |
160 | prefix ="->" ;multiday = 1; | 160 | prefix ="->" ;multiday = 1; |
161 | } | 161 | } |
162 | else { | 162 | else { |
163 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 163 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
164 | if ( event->recursOn( mDate.addDays( -days)) ) { | 164 | if ( event->recursOn( mDate.addDays( -days)) ) { |
165 | prefix ="<-" ;multiday = 3; | 165 | prefix ="<-" ;multiday = 3; |
166 | } | 166 | } |
167 | } | 167 | } |
168 | } else { | 168 | } else { |
169 | if (mDate == event->dtStart().date()) { | 169 | if (mDate == event->dtStart().date()) { |
170 | prefix ="->" ;multiday = 1; | 170 | prefix ="->" ;multiday = 1; |
171 | } else if (mDate == event->dtEnd().date()) { | 171 | } else if (mDate == event->dtEnd().date()) { |
172 | prefix ="<-" ;multiday = 3; | 172 | prefix ="<-" ;multiday = 3; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | if ( !event->doesFloat() ) { | 175 | if ( !event->doesFloat() ) { |
176 | if ( mDate == event->dtStart().date () ) | 176 | if ( mDate == event->dtStart().date () ) |
177 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 177 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
178 | else if ( mDate == event->dtEnd().date () ) | 178 | else if ( mDate == event->dtEnd().date () ) |
179 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 179 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
180 | 180 | ||
181 | } | 181 | } |
182 | text = time + event->summary(); | 182 | text = time + event->summary(); |
183 | mToolTipText += prefix + text; | 183 | mToolTipText += prefix + text; |
184 | } else { | 184 | } else { |
185 | if (event->doesFloat()) { | 185 | if (event->doesFloat()) { |
186 | text = event->summary(); | 186 | text = event->summary(); |
187 | mToolTipText += text; | 187 | mToolTipText += text; |
188 | } | 188 | } |
189 | else { | 189 | else { |
190 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 190 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
191 | text += " " + event->summary(); | 191 | text += " " + event->summary(); |
192 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 192 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | mToolTip.append( mToolTipText ); | 195 | mToolTip.append( mToolTipText ); |
196 | } | 196 | } |
197 | mToolTip.sort(); | 197 | mToolTip.sort(); |
198 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); | 198 | return "<b>"+KGlobal::locale()->formatDate(days[tmp]) + "</b><br>" + mToolTip.join("<br>"); |
199 | } | 199 | } |
200 | void KODayMatrix::setCalendar( Calendar *cal ) | 200 | void KODayMatrix::setCalendar( Calendar *cal ) |
201 | { | 201 | { |
202 | mCalendar = cal; | 202 | mCalendar = cal; |
203 | 203 | ||
204 | setAcceptDrops( mCalendar ); | 204 | setAcceptDrops( mCalendar ); |
205 | 205 | ||
206 | updateEvents(); | 206 | updateEvents(); |
207 | } | 207 | } |
208 | 208 | ||
209 | QColor KODayMatrix::getShadedColor(QColor color) | 209 | QColor KODayMatrix::getShadedColor(QColor color) |
210 | { | 210 | { |
211 | QColor shaded; | 211 | QColor shaded; |
212 | int h=0; | 212 | int h=0; |
213 | int s=0; | 213 | int s=0; |
214 | int v=0; | 214 | int v=0; |
215 | color.hsv(&h,&s,&v); | 215 | color.hsv(&h,&s,&v); |
216 | s = s/4; | 216 | s = s/4; |
217 | v = 192+v/4; | 217 | v = 192+v/4; |
218 | shaded.setHsv(h,s,v); | 218 | shaded.setHsv(h,s,v); |
219 | 219 | ||
220 | return shaded; | 220 | return shaded; |
221 | } | 221 | } |
222 | 222 | ||
223 | KODayMatrix::~KODayMatrix() | 223 | KODayMatrix::~KODayMatrix() |
224 | { | 224 | { |
225 | delete [] days; | 225 | delete [] days; |
226 | delete [] daylbls; | 226 | delete [] daylbls; |
227 | delete [] events; | 227 | delete [] events; |
228 | delete mToolTip; | 228 | delete mToolTip; |
229 | } | 229 | } |
230 | 230 | ||
231 | /* | 231 | /* |
232 | void KODayMatrix::setStartDate(QDate start) | 232 | void KODayMatrix::setStartDate(QDate start) |
233 | { | 233 | { |
234 | updateView(start); | 234 | updateView(start); |
235 | } | 235 | } |
236 | */ | 236 | */ |
237 | 237 | ||
238 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) | 238 | void KODayMatrix::addSelectedDaysTo(DateList& selDays) |
239 | { | 239 | { |
240 | 240 | ||
241 | if (mSelStart == NOSELECTION) { | 241 | if (mSelStart == NOSELECTION) { |
242 | return; | 242 | return; |
243 | } | 243 | } |
244 | 244 | ||
245 | //cope with selection being out of matrix limits at top (< 0) | 245 | //cope with selection being out of matrix limits at top (< 0) |
246 | int i0 = mSelStart; | 246 | int i0 = mSelStart; |
247 | if (i0 < 0) { | 247 | if (i0 < 0) { |
248 | for (int i = i0; i < 0; i++) { | 248 | for (int i = i0; i < 0; i++) { |
249 | selDays.append(days[0].addDays(i)); | 249 | selDays.append(days[0].addDays(i)); |
250 | } | 250 | } |
251 | i0 = 0; | 251 | i0 = 0; |
252 | } | 252 | } |
253 | 253 | ||
254 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) | 254 | //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) |
255 | if (mSelEnd > NUMDAYS-1) { | 255 | if (mSelEnd > NUMDAYS-1) { |
256 | for (int i = i0; i <= NUMDAYS-1; i++) { | 256 | for (int i = i0; i <= NUMDAYS-1; i++) { |
257 | selDays.append(days[i]); | 257 | selDays.append(days[i]); |
258 | } | 258 | } |
259 | for (int i = NUMDAYS; i < mSelEnd; i++) { | 259 | for (int i = NUMDAYS; i < mSelEnd; i++) { |
260 | selDays.append(days[0].addDays(i)); | 260 | selDays.append(days[0].addDays(i)); |
261 | } | 261 | } |
262 | 262 | ||
263 | // apply normal routine to selection being entirely within matrix limits | 263 | // apply normal routine to selection being entirely within matrix limits |
264 | } else { | 264 | } else { |
265 | for (int i = i0; i <= mSelEnd; i++) { | 265 | for (int i = i0; i <= mSelEnd; i++) { |
266 | selDays.append(days[i]); | 266 | selDays.append(days[i]); |
267 | } | 267 | } |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) | 271 | void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) |
272 | { | 272 | { |
273 | mSelStart = startdate.daysTo(start); | 273 | mSelStart = startdate.daysTo(start); |
274 | if ( mSelStart < 0 ) | 274 | if ( mSelStart < 0 ) |
275 | mSelStart = 0; | 275 | mSelStart = 0; |
276 | mSelEnd = startdate.daysTo(end); | 276 | mSelEnd = startdate.daysTo(end); |
277 | if ( mSelEnd < 0 ) | 277 | if ( mSelEnd < 0 ) |
278 | clearSelection(); | 278 | clearSelection(); |
279 | } | 279 | } |
280 | void KODayMatrix::clearSelection() | 280 | void KODayMatrix::clearSelection() |
281 | { | 281 | { |
282 | mSelEnd = mSelStart = NOSELECTION; | 282 | mSelEnd = mSelStart = NOSELECTION; |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | void KODayMatrix::recalculateToday() | 286 | void KODayMatrix::recalculateToday() |
287 | { | 287 | { |
288 | today = -1; | 288 | today = -1; |
289 | for (int i=0; i<NUMDAYS; i++) { | 289 | for (int i=0; i<NUMDAYS; i++) { |
290 | events[i] = 0; | 290 | events[i] = 0; |
291 | days[i] = startdate.addDays(i); | 291 | days[i] = startdate.addDays(i); |
292 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); | 292 | daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); |
293 | 293 | ||
294 | // if today is in the currently displayed month, hilight today | 294 | // if today is in the currently displayed month, hilight today |
295 | if (days[i].year() == QDate::currentDate().year() && | 295 | if (days[i].year() == QDate::currentDate().year() && |
296 | days[i].month() == QDate::currentDate().month() && | 296 | days[i].month() == QDate::currentDate().month() && |
297 | days[i].day() == QDate::currentDate().day()) { | 297 | days[i].day() == QDate::currentDate().day()) { |
298 | today = i; | 298 | today = i; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | // qDebug(QString("Today is visible at %1.").arg(today)); | 301 | // qDebug(QString("Today is visible at %1.").arg(today)); |
302 | } | 302 | } |
303 | 303 | ||
304 | void KODayMatrix::updateView() | 304 | void KODayMatrix::updateView() |
305 | { | 305 | { |
306 | updateView(startdate); | 306 | updateView(startdate); |
307 | } | 307 | } |
308 | void KODayMatrix::repaintViewTimed() | 308 | void KODayMatrix::repaintViewTimed() |
309 | { | 309 | { |
310 | mRepaintTimer->stop(); | 310 | mRepaintTimer->stop(); |
311 | repaint(false); | 311 | repaint(false); |
312 | } | 312 | } |
313 | void KODayMatrix::updateViewTimed() | 313 | void KODayMatrix::updateViewTimed() |
314 | { | 314 | { |
315 | mUpdateTimer->stop(); | 315 | mUpdateTimer->stop(); |
316 | if ( !mCalendar ) { | 316 | if ( !mCalendar ) { |
317 | qDebug("NOT CAL "); | 317 | qDebug("NOT CAL "); |
318 | return; | 318 | return; |
319 | } | 319 | } |
320 | //qDebug("KODayMatrix::updateViewTimed "); | 320 | //qDebug("KODayMatrix::updateViewTimed "); |
321 | for(int i = 0; i < NUMDAYS; i++) { | 321 | for(int i = 0; i < NUMDAYS; i++) { |
322 | // if events are set for the day then remember to draw it bold | 322 | // if events are set for the day then remember to draw it bold |
323 | QPtrList<Event> eventlist = mCalendar->events(days[i]); | 323 | QPtrList<Event> eventlist = mCalendar->events(days[i]); |
324 | Event *event; | 324 | Event *event; |
325 | int numEvents = eventlist.count(); | 325 | int numEvents = eventlist.count(); |
326 | QString holiStr = ""; | 326 | QString holiStr = ""; |
327 | bDays.clearBit(i); | 327 | bDays.clearBit(i); |
328 | for(event=eventlist.first();event != 0;event=eventlist.next()) { | 328 | for(event=eventlist.first();event != 0;event=eventlist.next()) { |
329 | ushort recurType = event->recurrence()->doesRecur(); | 329 | ushort recurType = event->recurrence()->doesRecur(); |
330 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || | 330 | if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || |
331 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { | 331 | (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { |
332 | numEvents--; | 332 | numEvents--; |
333 | } | 333 | } |
334 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { | 334 | if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) { |
335 | if ( !holiStr.isEmpty() ) | 335 | if ( !holiStr.isEmpty() ) |
336 | holiStr += "\n"; | 336 | holiStr += "\n"; |
337 | holiStr += event->summary(); | 337 | holiStr += event->summary(); |
338 | } | 338 | } |
339 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { | 339 | if ( event->categories().contains( i18n("Birthday") ) || event->categories().contains( "Birthday" )) { |
340 | if ( !holiStr.isEmpty() ) | 340 | if ( !holiStr.isEmpty() ) |
341 | holiStr += "\n"; | 341 | holiStr += "\n"; |
342 | holiStr += event->summary(); | 342 | holiStr += event->summary(); |
343 | bDays.setBit(i); | 343 | bDays.setBit(i); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | events[i] = numEvents; | 346 | events[i] = numEvents; |
347 | //if it is a holy day then draw it red. Sundays are consider holidays, too | 347 | //if it is a holy day then draw it red. Sundays are consider holidays, too |
348 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || | 348 | if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || |
349 | !holiStr.isEmpty()) { | 349 | !holiStr.isEmpty()) { |
350 | mHolidays[i] = holiStr; | 350 | mHolidays[i] = holiStr; |
351 | } else { | 351 | } else { |
352 | mHolidays[i] = QString::null; | 352 | mHolidays[i] = QString::null; |
353 | } | 353 | } |
354 | } | 354 | } |
355 | if ( ! mPendingUpdateBeforeRepaint ) | 355 | if ( ! mPendingUpdateBeforeRepaint ) |
356 | repaint(false); | 356 | repaint(false); |
357 | } | 357 | } |
358 | void KODayMatrix::updateView(QDate actdate) | 358 | void KODayMatrix::updateView(QDate actdate) |
359 | { | 359 | { |
360 | 360 | ||
361 | if ( ! actdate.isValid() ) { | 361 | if ( ! actdate.isValid() ) { |
362 | //qDebug("date not valid "); | 362 | //qDebug("date not valid "); |
363 | return; | 363 | return; |
364 | } | 364 | } |
365 | mDayChanged = false; | 365 | mDayChanged = false; |
366 | //flag to indicate if the starting day of the matrix has changed by this call | 366 | //flag to indicate if the starting day of the matrix has changed by this call |
367 | //mDayChanged = false; | 367 | //mDayChanged = false; |
368 | // if a new startdate is to be set then apply Cornelius's calculation | 368 | // if a new startdate is to be set then apply Cornelius's calculation |
369 | // of the first day to be shown | 369 | // of the first day to be shown |
370 | if (actdate != startdate) { | 370 | if (actdate != startdate) { |
371 | // reset index of selection according to shift of starting date from startdate to actdate | 371 | // reset index of selection according to shift of starting date from startdate to actdate |
372 | if (mSelStart != NOSELECTION) { | 372 | if (mSelStart != NOSELECTION) { |
373 | int tmp = actdate.daysTo(startdate); | 373 | int tmp = actdate.daysTo(startdate); |
374 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; | 374 | //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; |
375 | // shift selection if new one would be visible at least partly ! | 375 | // shift selection if new one would be visible at least partly ! |
376 | 376 | ||
377 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { | 377 | if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { |
378 | // nested if is required for next X display pushed from a different month - correction required | 378 | // nested if is required for next X display pushed from a different month - correction required |
379 | // otherwise, for month forward and backward, it must be avoided | 379 | // otherwise, for month forward and backward, it must be avoided |
380 | if( mSelStart > NUMDAYS || mSelStart < 0 ) | 380 | if( mSelStart > NUMDAYS || mSelStart < 0 ) |
381 | mSelStart = mSelStart + tmp; | 381 | mSelStart = mSelStart + tmp; |
382 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) | 382 | if( mSelEnd > NUMDAYS || mSelEnd < 0 ) |
383 | mSelEnd = mSelEnd + tmp; | 383 | mSelEnd = mSelEnd + tmp; |
384 | } | 384 | } |
385 | } | 385 | } |
386 | startdate = actdate; | 386 | startdate = actdate; |
387 | mDayChanged = true; | 387 | mDayChanged = true; |
388 | recalculateToday(); | 388 | recalculateToday(); |
389 | } | 389 | } |
390 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); | 390 | //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); |
391 | if ( !isVisible() ) { | 391 | if ( !isVisible() ) { |
392 | mPendingUpdateBeforeRepaint = true; | 392 | mPendingUpdateBeforeRepaint = true; |
393 | } else { | 393 | } else { |
394 | #ifdef DESKTOP_VERSION | 394 | #ifdef DESKTOP_VERSION |
395 | //mRepaintTimer->start( 150 ); | 395 | //mRepaintTimer->start( 150 ); |
396 | mUpdateTimer->start( 150 ); | 396 | mUpdateTimer->start( 150 ); |
397 | #else | 397 | #else |
398 | mRepaintTimer->start( 350 ); | 398 | mRepaintTimer->start( 350 ); |
399 | mUpdateTimer->start( 1200 ); | 399 | mUpdateTimer->start( 1200 ); |
400 | #endif | 400 | #endif |
401 | } | 401 | } |
402 | } | 402 | } |
403 | void KODayMatrix::updateEvents() | 403 | void KODayMatrix::updateEvents() |
404 | { | 404 | { |
405 | if ( !mCalendar ) return; | 405 | if ( !mCalendar ) return; |
406 | 406 | ||
407 | for( int i = 0; i < NUMDAYS; i++ ) { | 407 | for( int i = 0; i < NUMDAYS; i++ ) { |
408 | // if events are set for the day then remember to draw it bold | 408 | // if events are set for the day then remember to draw it bold |
409 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); | 409 | QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); |
410 | int numEvents = eventlist.count(); | 410 | int numEvents = eventlist.count(); |
411 | Event *event; | 411 | Event *event; |
412 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { | 412 | for( event = eventlist.first(); event != 0;event=eventlist.next()) { |
413 | ushort recurType = event->doesRecur(); | 413 | ushort recurType = event->doesRecur(); |
414 | 414 | ||
415 | if ( ( recurType == Recurrence::rDaily && | 415 | if ( ( recurType == Recurrence::rDaily && |
416 | !KOPrefs::instance()->mDailyRecur ) || | 416 | !KOPrefs::instance()->mDailyRecur ) || |
417 | ( recurType == Recurrence::rWeekly && | 417 | ( recurType == Recurrence::rWeekly && |
418 | !KOPrefs::instance()->mWeeklyRecur ) ) { | 418 | !KOPrefs::instance()->mWeeklyRecur ) ) { |
419 | numEvents--; | 419 | numEvents--; |
420 | } | 420 | } |
421 | } | 421 | } |
422 | events[ i ] = numEvents; | 422 | events[ i ] = numEvents; |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | const QDate& KODayMatrix::getDate(int offset) | 426 | const QDate& KODayMatrix::getDate(int offset) |
427 | { | 427 | { |
428 | if (offset < 0 || offset > NUMDAYS-1) { | 428 | if (offset < 0 || offset > NUMDAYS-1) { |
429 | qDebug("Wrong offset2 "); | 429 | qDebug("Wrong offset2 "); |
430 | return days[0]; | 430 | return days[0]; |
431 | } | 431 | } |
432 | return days[offset]; | 432 | return days[offset]; |
433 | } | 433 | } |
434 | 434 | ||
435 | QString KODayMatrix::getHolidayLabel(int offset) | 435 | QString KODayMatrix::getHolidayLabel(int offset) |
436 | { | 436 | { |
437 | if (offset < 0 || offset > NUMDAYS-1) { | 437 | if (offset < 0 || offset > NUMDAYS-1) { |
438 | qDebug("Wrong offset1 "); | 438 | qDebug("Wrong offset1 "); |
439 | return 0; | 439 | return 0; |
440 | } | 440 | } |
441 | return mHolidays[offset]; | 441 | return mHolidays[offset]; |
442 | } | 442 | } |
443 | 443 | ||
444 | int KODayMatrix::getDayIndexFrom(int x, int y) | 444 | int KODayMatrix::getDayIndexFrom(int x, int y) |
445 | { | 445 | { |
446 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? | 446 | return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? |
447 | 6 - x/daysize.width() : x/daysize.width()); | 447 | 6 - x/daysize.width() : x/daysize.width()); |
448 | } | 448 | } |
449 | 449 | ||
450 | // ---------------------------------------------------------------------------- | 450 | // ---------------------------------------------------------------------------- |
451 | // M O U S E E V E N T H A N D L I N G | 451 | // M O U S E E V E N T H A N D L I N G |
452 | // ---------------------------------------------------------------------------- | 452 | // ---------------------------------------------------------------------------- |
453 | 453 | ||
454 | void KODayMatrix::mousePressEvent (QMouseEvent* e) | 454 | void KODayMatrix::mousePressEvent (QMouseEvent* e) |
455 | { | 455 | { |
456 | 456 | ||
457 | if ( e->button() == LeftButton ) | 457 | if ( e->button() == LeftButton ) |
458 | mouseDown = true; | 458 | mouseDown = true; |
459 | mSelStart = getDayIndexFrom(e->x(), e->y()); | 459 | mSelStart = getDayIndexFrom(e->x(), e->y()); |
460 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; | 460 | if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; |
461 | mSelInit = mSelStart; | 461 | mSelInit = mSelStart; |
462 | } | 462 | } |
463 | 463 | ||
464 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) | 464 | void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) |
465 | { | 465 | { |
466 | if ( e->button() == LeftButton ) | 466 | if ( e->button() == LeftButton ) |
467 | if ( ! mouseDown ) { | 467 | if ( ! mouseDown ) { |
468 | return; | 468 | return; |
469 | } | 469 | } |
470 | else | 470 | else |
471 | mouseDown = false; | 471 | mouseDown = false; |
472 | int tmp = getDayIndexFrom(e->x(), e->y()); | 472 | int tmp = getDayIndexFrom(e->x(), e->y()); |
473 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 473 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
474 | 474 | ||
475 | if (mSelInit > tmp) { | 475 | if (mSelInit > tmp) { |
476 | mSelEnd = mSelInit; | 476 | mSelEnd = mSelInit; |
477 | if (tmp != mSelStart) { | 477 | if (tmp != mSelStart) { |
478 | mSelStart = tmp; | 478 | mSelStart = tmp; |
479 | repaint(false); | 479 | repaint(false); |
480 | } | 480 | } |
481 | } else { | 481 | } else { |
482 | mSelStart = mSelInit; | 482 | mSelStart = mSelInit; |
483 | 483 | ||
484 | //repaint only if selection has changed | 484 | //repaint only if selection has changed |
485 | if (tmp != mSelEnd) { | 485 | if (tmp != mSelEnd) { |
486 | mSelEnd = tmp; | 486 | mSelEnd = tmp; |
487 | repaint(false); | 487 | repaint(false); |
488 | } | 488 | } |
489 | } | 489 | } |
490 | 490 | ||
491 | DateList daylist; | 491 | DateList daylist; |
492 | if ( mSelStart < 0 ) | 492 | if ( mSelStart < 0 ) |
493 | mSelStart = 0; | 493 | mSelStart = 0; |
494 | for (int i = mSelStart; i <= mSelEnd; i++) { | 494 | for (int i = mSelStart; i <= mSelEnd; i++) { |
495 | daylist.append(days[i]); | 495 | daylist.append(days[i]); |
496 | } | 496 | } |
497 | emit selected((const DateList)daylist); | 497 | emit selected((const DateList)daylist); |
498 | 498 | ||
499 | } | 499 | } |
500 | 500 | ||
501 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) | 501 | void KODayMatrix::mouseMoveEvent (QMouseEvent* e) |
502 | { | 502 | { |
503 | if ( ! mouseDown ) { | 503 | if ( ! mouseDown ) { |
504 | return; | 504 | return; |
505 | } | 505 | } |
506 | int tmp = getDayIndexFrom(e->x(), e->y()); | 506 | int tmp = getDayIndexFrom(e->x(), e->y()); |
507 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; | 507 | if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; |
508 | 508 | ||
509 | if (mSelInit > tmp) { | 509 | if (mSelInit > tmp) { |
510 | mSelEnd = mSelInit; | 510 | mSelEnd = mSelInit; |
511 | if (tmp != mSelStart) { | 511 | if (tmp != mSelStart) { |
512 | mSelStart = tmp; | 512 | mSelStart = tmp; |
513 | repaint(false); | 513 | repaint(false); |
514 | } | 514 | } |
515 | } else { | 515 | } else { |
516 | mSelStart = mSelInit; | 516 | mSelStart = mSelInit; |
517 | 517 | ||
518 | //repaint only if selection has changed | 518 | //repaint only if selection has changed |
519 | if (tmp != mSelEnd) { | 519 | if (tmp != mSelEnd) { |
520 | mSelEnd = tmp; | 520 | mSelEnd = tmp; |
521 | repaint(false); | 521 | repaint(false); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | } | 524 | } |
525 | 525 | ||
526 | // ---------------------------------------------------------------------------- | 526 | // ---------------------------------------------------------------------------- |
527 | // D R A G ' N D R O P H A N D L I N G | 527 | // D R A G ' N D R O P H A N D L I N G |
528 | // ---------------------------------------------------------------------------- | 528 | // ---------------------------------------------------------------------------- |
529 | 529 | ||
530 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) | 530 | void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) |
531 | { | 531 | { |
532 | #ifndef KORG_NODND | 532 | #ifndef KORG_NODND |
533 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 533 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
534 | e->ignore(); | 534 | e->ignore(); |
535 | return; | 535 | return; |
536 | } | 536 | } |
537 | 537 | ||
538 | // some visual feedback | 538 | // some visual feedback |
539 | // oldPalette = palette(); | 539 | // oldPalette = palette(); |
540 | // setPalette(my_HilitePalette); | 540 | // setPalette(my_HilitePalette); |
541 | // update(); | 541 | // update(); |
542 | #endif | 542 | #endif |
543 | } | 543 | } |
544 | 544 | ||
545 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) | 545 | void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) |
546 | { | 546 | { |
547 | #ifndef KORG_NODND | 547 | #ifndef KORG_NODND |
548 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 548 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
549 | e->ignore(); | 549 | e->ignore(); |
550 | return; | 550 | return; |
551 | } | 551 | } |
552 | 552 | ||
553 | e->accept(); | 553 | e->accept(); |
554 | #endif | 554 | #endif |
555 | } | 555 | } |
556 | 556 | ||
557 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) | 557 | void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) |
558 | { | 558 | { |
559 | #ifndef KORG_NODND | 559 | #ifndef KORG_NODND |
560 | // setPalette(oldPalette); | 560 | // setPalette(oldPalette); |
561 | // update(); | 561 | // update(); |
562 | #endif | 562 | #endif |
563 | } | 563 | } |
564 | 564 | ||
565 | void KODayMatrix::dropEvent(QDropEvent *e) | 565 | void KODayMatrix::dropEvent(QDropEvent *e) |
566 | { | 566 | { |
567 | #ifndef KORG_NODND | 567 | #ifndef KORG_NODND |
568 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; | 568 | // kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; |
569 | 569 | ||
570 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { | 570 | if (!mCalendar || !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { |
571 | e->ignore(); | 571 | e->ignore(); |
572 | return; | 572 | return; |
573 | } | 573 | } |
574 | 574 | ||
575 | DndFactory factory( mCalendar ); | 575 | DndFactory factory( mCalendar ); |
576 | Event *event = factory.createDrop(e); | 576 | Event *event = factory.createDrop(e); |
577 | 577 | ||
578 | if (event) { | 578 | if (event) { |
579 | e->acceptAction(); | 579 | e->acceptAction(); |
580 | 580 | ||
581 | Event *existingEvent = mCalendar->event(event->uid()); | 581 | Event *existingEvent = mCalendar->event(event->uid()); |
582 | 582 | ||
583 | if(existingEvent) { | 583 | if(existingEvent) { |
584 | // uniquify event | 584 | // uniquify event |
585 | event->recreate(); | 585 | event->recreate(); |
586 | /* | 586 | /* |
587 | KMessageBox::sorry(this, | 587 | KMessageBox::sorry(this, |
588 | i18n("Event already exists in this calendar."), | 588 | i18n("Event already exists in this calendar."), |
589 | i18n("Drop Event")); | 589 | i18n("Drop Event")); |
590 | delete event; | 590 | delete event; |
591 | return; | 591 | return; |
592 | */ | 592 | */ |
593 | } | 593 | } |
594 | // kdDebug() << "Drop new Event" << endl; | 594 | // kdDebug() << "Drop new Event" << endl; |
595 | // Adjust date | 595 | // Adjust date |
596 | QDateTime start = event->dtStart(); | 596 | QDateTime start = event->dtStart(); |
597 | QDateTime end = event->dtEnd(); | 597 | QDateTime end = event->dtEnd(); |
598 | int duration = start.daysTo(end); | 598 | int duration = start.daysTo(end); |
599 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); | 599 | int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); |
600 | 600 | ||
601 | start.setDate(days[idx]); | 601 | start.setDate(days[idx]); |
602 | end.setDate(days[idx].addDays(duration)); | 602 | end.setDate(days[idx].addDays(duration)); |
603 | 603 | ||
604 | event->setDtStart(start); | 604 | event->setDtStart(start); |
605 | event->setDtEnd(end); | 605 | event->setDtEnd(end); |
606 | mCalendar->addEvent(event); | 606 | mCalendar->addEvent(event); |
607 | 607 | ||
608 | emit eventDropped(event); | 608 | emit eventDropped(event); |
609 | } else { | 609 | } else { |
610 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; | 610 | // kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; |
611 | e->ignore(); | 611 | e->ignore(); |
612 | } | 612 | } |
613 | #endif | 613 | #endif |
614 | } | 614 | } |
615 | 615 | ||
616 | // ---------------------------------------------------------------------------- | 616 | // ---------------------------------------------------------------------------- |
617 | // P A I N T E V E N T H A N D L I N G | 617 | // P A I N T E V E N T H A N D L I N G |
618 | // ---------------------------------------------------------------------------- | 618 | // ---------------------------------------------------------------------------- |
619 | 619 | ||
620 | void KODayMatrix::paintEvent(QPaintEvent * pevent) | 620 | void KODayMatrix::paintEvent(QPaintEvent * pevent) |
621 | { | 621 | { |
622 | if ( width() <= 0 || height() <= 0 ) | 622 | if ( width() <= 0 || height() <= 0 ) |
623 | return; | 623 | return; |
624 | if ( mPendingUpdateBeforeRepaint ) { | 624 | if ( mPendingUpdateBeforeRepaint ) { |
625 | updateViewTimed(); | 625 | updateViewTimed(); |
626 | mPendingUpdateBeforeRepaint = false; | 626 | mPendingUpdateBeforeRepaint = false; |
627 | } | 627 | } |
628 | if ( myPix.width() != width() || myPix.height()!=height() ) { | 628 | if ( myPix.width() != width() || myPix.height()!=height() ) { |
629 | myPix.resize(size() ); | 629 | myPix.resize(size() ); |
630 | } | 630 | } |
631 | QPainter p(&myPix); | 631 | QPainter p(&myPix); |
632 | p.setFont(font()); | 632 | p.setFont(font()); |
633 | 633 | ||
634 | QRect sz = frameRect(); | 634 | QRect sz = frameRect(); |
635 | int dheight = daysize.height(); | 635 | int dheight = daysize.height(); |
636 | int dwidth = daysize.width(); | 636 | int dwidth = daysize.width(); |
637 | int row,col; | 637 | int row,col; |
638 | int selw, selh; | 638 | int selw, selh; |
639 | bool isRTL = KOGlobals::self()->reverseLayout(); | 639 | bool isRTL = KOGlobals::self()->reverseLayout(); |
640 | 640 | ||
641 | // draw background and topleft frame | 641 | // draw background and topleft frame |
642 | p.fillRect(pevent->rect(), mDefaultBackColor); | 642 | p.fillRect(pevent->rect(), mDefaultBackColor); |
643 | p.setPen(mDefaultTextColor); | 643 | p.setPen(mDefaultTextColor); |
644 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); | 644 | p.drawRect(0, 0, sz.width()+1, sz.height()+1); |
645 | int mSelStartT = mSelStart; | 645 | int mSelStartT = mSelStart; |
646 | int mSelEndT = mSelEnd; | 646 | int mSelEndT = mSelEnd; |
647 | if ( mSelEndT >= NUMDAYS ) | 647 | if ( mSelEndT >= NUMDAYS ) |
648 | mSelEndT = NUMDAYS-1; | 648 | mSelEndT = NUMDAYS-1; |
649 | // draw selected days with highlighted background color | 649 | // draw selected days with highlighted background color |
650 | if (mSelStart != NOSELECTION) { | 650 | if (mSelStart != NOSELECTION) { |
651 | bool skip = false; | 651 | bool skip = false; |
652 | if ( ! mouseDown ) { | 652 | if ( ! mouseDown ) { |
653 | int mo = days[20].month(); | 653 | int mo = days[20].month(); |
654 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); | 654 | //qDebug("-- %d %d ", mSelStartT, mSelEndT); |
655 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); | 655 | //qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() ); |
656 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { | 656 | if ( days[mSelStartT].month() > mo || days[mSelEndT].month() < mo ) { |
657 | skip = true; | 657 | skip = true; |
658 | } else { | 658 | } else { |
659 | if ( days[mSelStartT].month() != mo ) { | 659 | if ( days[mSelStartT].month() != mo ) { |
660 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); | 660 | int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day(); |
661 | mSelStartT += add +1; | 661 | mSelStartT += add +1; |
662 | } | 662 | } |
663 | if ( days[mSelEndT].month() != mo ) { | 663 | if ( days[mSelEndT].month() != mo ) { |
664 | int sub = days[mSelEndT].day(); | 664 | int sub = days[mSelEndT].day(); |
665 | mSelEndT -= sub ; | 665 | mSelEndT -= sub ; |
666 | } | 666 | } |
667 | } | 667 | } |
668 | } | 668 | } |
669 | if ( ! skip ) { | 669 | if ( ! skip ) { |
670 | row = mSelStartT/7; | 670 | row = mSelStartT/7; |
671 | col = mSelStartT -row*7; | 671 | col = mSelStartT -row*7; |
672 | QColor selcol = KOPrefs::instance()->mHighlightColor; | 672 | QColor selcol = KOPrefs::instance()->mHighlightColor; |
673 | 673 | ||
674 | if (row == mSelEndT/7) { | 674 | if (row == mSelEndT/7) { |
675 | // Single row selection | 675 | // Single row selection |
676 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth, | 676 | p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth, |
677 | row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol); | 677 | row*dheight, (mSelEndT-mSelStartT+1)*dwidth, dheight, selcol); |
678 | } else { | 678 | } else { |
679 | // draw first row to the right | 679 | // draw first row to the right |
680 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, | 680 | p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, |
681 | dheight, selcol); | 681 | dheight, selcol); |
682 | // draw full block till last line | 682 | // draw full block till last line |
683 | selh = mSelEndT/7-row; | 683 | selh = mSelEndT/7-row; |
684 | if (selh > 1) { | 684 | if (selh > 1) { |
685 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); | 685 | p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); |
686 | } | 686 | } |
687 | // draw last block from left to mSelEndT | 687 | // draw last block from left to mSelEndT |
688 | selw = mSelEndT-7*(mSelEndT/7)+1; | 688 | selw = mSelEndT-7*(mSelEndT/7)+1; |
689 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, | 689 | p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, |
690 | selw*dwidth, dheight, selcol); | 690 | selw*dwidth, dheight, selcol); |
691 | } | 691 | } |
692 | } | 692 | } |
693 | } | 693 | } |
694 | 694 | ||
695 | // iterate over all days in the matrix and draw the day label in appropriate colors | 695 | // iterate over all days in the matrix and draw the day label in appropriate colors |
696 | QColor actcol = mDefaultTextColorShaded; | 696 | QColor actcol = mDefaultTextColorShaded; |
697 | p.setPen(actcol); | 697 | p.setPen(actcol); |
698 | QPen tmppen; | 698 | QPen tmppen; |
699 | for(int i = 0; i < NUMDAYS; i++) { | 699 | for(int i = 0; i < NUMDAYS; i++) { |
700 | row = i/7; | 700 | row = i/7; |
701 | col = isRTL ? 6-(i-row*7) : i-row*7; | 701 | col = isRTL ? 6-(i-row*7) : i-row*7; |
702 | 702 | ||
703 | // if it is the first day of a month switch color from normal to shaded and vice versa | 703 | // if it is the first day of a month switch color from normal to shaded and vice versa |
704 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { | 704 | if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { |
705 | if (actcol == mDefaultTextColorShaded) { | 705 | if (actcol == mDefaultTextColorShaded) { |
706 | actcol = mDefaultTextColor; | 706 | actcol = mDefaultTextColor; |
707 | } else { | 707 | } else { |
708 | actcol = mDefaultTextColorShaded; | 708 | actcol = mDefaultTextColorShaded; |
709 | } | 709 | } |
710 | p.setPen(actcol); | 710 | p.setPen(actcol); |
711 | } | 711 | } |
712 | if (actcol == mDefaultTextColorShaded) { | 712 | if (actcol == mDefaultTextColorShaded) { |
713 | if ( ! mouseDown ) { | 713 | if ( ! mouseDown ) { |
714 | continue; | 714 | continue; |
715 | } | 715 | } |
716 | } | 716 | } |
717 | //Reset pen color after selected days block | 717 | //Reset pen color after selected days block |
718 | if (i == mSelEndT+1) { | 718 | if (i == mSelEndT+1) { |
719 | p.setPen(actcol); | 719 | p.setPen(actcol); |
720 | } | 720 | } |
721 | 721 | ||
722 | // if today then draw rectangle around day | 722 | // if today then draw rectangle around day |
723 | if (today == i) { | 723 | if (today == i) { |
724 | tmppen = p.pen(); | 724 | tmppen = p.pen(); |
725 | QPen mTodayPen(p.pen()); | 725 | QPen mTodayPen(p.pen()); |
726 | 726 | ||
727 | mTodayPen.setWidth(mTodayMarginWidth); | 727 | mTodayPen.setWidth(mTodayMarginWidth); |
728 | //draw red rectangle for holidays | 728 | //draw red rectangle for holidays |
729 | if (!mHolidays[i].isNull()) { | 729 | if (!mHolidays[i].isNull()) { |
730 | if (actcol == mDefaultTextColor) { | 730 | if (actcol == mDefaultTextColor) { |
731 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); | 731 | mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); |
732 | } else { | 732 | } else { |
733 | mTodayPen.setColor(mHolidayColorShaded); | 733 | mTodayPen.setColor(mHolidayColorShaded); |
734 | } | 734 | } |
735 | } | 735 | } |
736 | //draw gray rectangle for today if in selection | 736 | //draw gray rectangle for today if in selection |
737 | if (i >= mSelStartT && i <= mSelEndT) { | 737 | if (i >= mSelStartT && i <= mSelEndT) { |
738 | QColor grey("grey"); | 738 | QColor grey("grey"); |
739 | mTodayPen.setColor(grey); | 739 | mTodayPen.setColor(grey); |
740 | } | 740 | } |
741 | p.setPen(mTodayPen); | 741 | p.setPen(mTodayPen); |
742 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); | 742 | p.drawRect(col*dwidth, row*dheight, dwidth, dheight); |
743 | p.setPen(tmppen); | 743 | p.setPen(tmppen); |
744 | } | 744 | } |
745 | 745 | ||
746 | // if any events are on that day then draw it using a bold font | 746 | // if any events are on that day then draw it using a bold font |
747 | if (events[i] > 0) { | 747 | if (events[i] > 0) { |
748 | QFont myFont = font(); | 748 | QFont myFont = font(); |
749 | myFont.setBold(true); | 749 | myFont.setBold(true); |
750 | p.setFont(myFont); | 750 | p.setFont(myFont); |
751 | } | 751 | } |
752 | 752 | ||
753 | // if it is a holiday then use the default holiday color | 753 | // if it is a holiday then use the default holiday color |
754 | if (!mHolidays[i].isNull()) { | 754 | if (!mHolidays[i].isNull()) { |
755 | if ( bDays.testBit(i) ) { | 755 | if ( bDays.testBit(i) ) { |
756 | p.setPen(Qt::green); | 756 | p.setPen(Qt::green); |
757 | } else { | 757 | } else { |
758 | if (actcol == mDefaultTextColor) { | 758 | if (actcol == mDefaultTextColor) { |
759 | p.setPen(KOPrefs::instance()->mHolidayColor); | 759 | p.setPen(KOPrefs::instance()->mHolidayColor); |
760 | } else { | 760 | } else { |
761 | p.setPen(mHolidayColorShaded); | 761 | p.setPen(mHolidayColorShaded); |
762 | } | 762 | } |
763 | } | 763 | } |
764 | } | 764 | } |
765 | 765 | ||
766 | // draw selected days with special color | 766 | // draw selected days with special color |
767 | // DO NOT specially highlight holidays in selection ! | 767 | // DO NOT specially highlight holidays in selection ! |
768 | if (i >= mSelStartT && i <= mSelEndT) { | 768 | if (i >= mSelStartT && i <= mSelEndT) { |
769 | ;//p.setPen(mSelectedDaysColor); | 769 | ;//p.setPen(mSelectedDaysColor); |
770 | } | 770 | } |
771 | 771 | ||
772 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, | 772 | p.drawText(col*dwidth, row*dheight, dwidth, dheight, |
773 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); | 773 | Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); |
774 | 774 | ||
775 | // reset color to actual color | 775 | // reset color to actual color |
776 | if (!mHolidays[i].isNull()) { | 776 | if (!mHolidays[i].isNull()) { |
777 | p.setPen(actcol); | 777 | p.setPen(actcol); |
778 | } | 778 | } |
779 | // reset bold font to plain font | 779 | // reset bold font to plain font |
780 | if (events[i] > 0) { | 780 | if (events[i] > 0) { |
781 | QFont myFont = font(); | 781 | QFont myFont = font(); |
782 | myFont.setBold(false); | 782 | myFont.setBold(false); |
783 | p.setFont(myFont); | 783 | p.setFont(myFont); |
784 | } | 784 | } |
785 | } | 785 | } |
786 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); | 786 | bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP); |
787 | } | 787 | } |
788 | 788 | ||
789 | // ---------------------------------------------------------------------------- | 789 | // ---------------------------------------------------------------------------- |
790 | // R E SI Z E E V E N T H A N D L I N G | 790 | // R E SI Z E E V E N T H A N D L I N G |
791 | // ---------------------------------------------------------------------------- | 791 | // ---------------------------------------------------------------------------- |
792 | 792 | ||
793 | void KODayMatrix::resizeEvent(QResizeEvent *) | 793 | void KODayMatrix::resizeEvent(QResizeEvent *) |
794 | { | 794 | { |
795 | QRect sz = frameRect(); | 795 | QRect sz = frameRect(); |
796 | daysize.setHeight(sz.height()*7 / NUMDAYS); | 796 | daysize.setHeight(sz.height()*7 / NUMDAYS); |
797 | daysize.setWidth(sz.width() / 7); | 797 | daysize.setWidth(sz.width() / 7); |
798 | } | 798 | } |
799 | |||
800 | QSize KODayMatrix::sizeHint() const | ||
801 | { | ||
802 | |||
803 | QFontMetrics fm ( font() ); | ||
804 | int wid = fm.width( "30") *7+7; | ||
805 | int hei = fm.height() * 6+4; | ||
806 | //qDebug("KODayMatrix::sizeHint()********************* %d %d", wid , hei); | ||
807 | return QSize ( wid, hei ); | ||
808 | |||
809 | } | ||
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index c049942..39946de 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h | |||
@@ -1,321 +1,322 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> | 3 | Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef _KODAYMAT_H | 23 | #ifndef _KODAYMAT_H |
24 | #define _KODAYMAT_H | 24 | #define _KODAYMAT_H |
25 | 25 | ||
26 | #include <libkcal/calendar.h> | 26 | #include <libkcal/calendar.h> |
27 | 27 | ||
28 | #include <qstring.h> | 28 | #include <qstring.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qcolor.h> | 30 | #include <qcolor.h> |
31 | #include <qpen.h> | 31 | #include <qpen.h> |
32 | #include <qdatetime.h> | 32 | #include <qdatetime.h> |
33 | #include <qtooltip.h> | 33 | #include <qtooltip.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qbitarray.h> | 35 | #include <qbitarray.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | class QDragEnterEvent; | 38 | class QDragEnterEvent; |
39 | class QDragMoveEvent; | 39 | class QDragMoveEvent; |
40 | class QDragLeaveEvent; | 40 | class QDragLeaveEvent; |
41 | class QDropEvent; | 41 | class QDropEvent; |
42 | 42 | ||
43 | class KODayMatrix; | 43 | class KODayMatrix; |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * small helper class to dynamically show tooltips inside the day matrix. | 49 | * small helper class to dynamically show tooltips inside the day matrix. |
50 | * This class asks the day matrix object for a appropriate label which | 50 | * This class asks the day matrix object for a appropriate label which |
51 | * is in our special case the name of the holiday or null if this day is no holiday. | 51 | * is in our special case the name of the holiday or null if this day is no holiday. |
52 | */ | 52 | */ |
53 | class DynamicTip : public QToolTip | 53 | class DynamicTip : public QToolTip |
54 | { | 54 | { |
55 | public: | 55 | public: |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Constructor that expects a KODayMatrix object as parent. | 58 | * Constructor that expects a KODayMatrix object as parent. |
59 | * | 59 | * |
60 | * @param parent the parent KODayMatrix control. | 60 | * @param parent the parent KODayMatrix control. |
61 | */ | 61 | */ |
62 | DynamicTip(QWidget* parent ); | 62 | DynamicTip(QWidget* parent ); |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Qt's callback to ask the object to provide an approrpiate text for the | 67 | * Qt's callback to ask the object to provide an approrpiate text for the |
68 | * tooltip to be shown. | 68 | * tooltip to be shown. |
69 | * | 69 | * |
70 | * @param pos coordinates of the mouse. | 70 | * @param pos coordinates of the mouse. |
71 | */ | 71 | */ |
72 | void maybeTip( const QPoint & pos); | 72 | void maybeTip( const QPoint & pos); |
73 | 73 | ||
74 | private: | 74 | private: |
75 | 75 | ||
76 | /** the parent control this tooltip is designed for. */ | 76 | /** the parent control this tooltip is designed for. */ |
77 | KODayMatrix* matrix; | 77 | KODayMatrix* matrix; |
78 | }; | 78 | }; |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. | 81 | * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. |
82 | * Cornelius thought this was a waste of memory and a lot of overhead. | 82 | * Cornelius thought this was a waste of memory and a lot of overhead. |
83 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame | 83 | * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame |
84 | * that draws the labels and allows for dragging selection while maintaining nearly full | 84 | * that draws the labels and allows for dragging selection while maintaining nearly full |
85 | * compatibility in behaviour with its predecessor. | 85 | * compatibility in behaviour with its predecessor. |
86 | * | 86 | * |
87 | * The following functionality has been changed: | 87 | * The following functionality has been changed: |
88 | * | 88 | * |
89 | * o when shifting events in the agenda view from one day to another the day matrix is updated now | 89 | * o when shifting events in the agenda view from one day to another the day matrix is updated now |
90 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. | 90 | * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. |
91 | * o no support for Ctrl+click to create groups of dates | 91 | * o no support for Ctrl+click to create groups of dates |
92 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it | 92 | * (This has not really been supported in the predecessor. It was not very intuitive nor was it |
93 | * user friendly.) | 93 | * user friendly.) |
94 | * This feature has been replaced with dragging a selection on the matrix. The matrix will | 94 | * This feature has been replaced with dragging a selection on the matrix. The matrix will |
95 | * automatically choose the appropriate selection (e.g. you are not any longer able to select | 95 | * automatically choose the appropriate selection (e.g. you are not any longer able to select |
96 | * two distinct groups of date selections as in the old class) | 96 | * two distinct groups of date selections as in the old class) |
97 | * o now that you can select more then a week it can happen that not all selected days are | 97 | * o now that you can select more then a week it can happen that not all selected days are |
98 | * displayed in the matrix. However this is preferred to the alternative which would mean to | 98 | * displayed in the matrix. However this is preferred to the alternative which would mean to |
99 | * adjust the selection and leave some days undisplayed while scrolling through the months | 99 | * adjust the selection and leave some days undisplayed while scrolling through the months |
100 | * | 100 | * |
101 | * @short day matrix widget of the KDateNavigator | 101 | * @short day matrix widget of the KDateNavigator |
102 | * | 102 | * |
103 | * @author Eitzenberger Thomas | 103 | * @author Eitzenberger Thomas |
104 | */ | 104 | */ |
105 | class KODayMatrix: public QFrame { | 105 | class KODayMatrix: public QFrame { |
106 | 106 | ||
107 | Q_OBJECT | 107 | Q_OBJECT |
108 | 108 | ||
109 | public: | 109 | public: |
110 | 110 | ||
111 | /** constructor to create a day matrix widget. | 111 | /** constructor to create a day matrix widget. |
112 | * | 112 | * |
113 | * @param parent widget that is the parent of the day matrix. Normally this should | 113 | * @param parent widget that is the parent of the day matrix. Normally this should |
114 | * be a KDateNavigator | 114 | * be a KDateNavigator |
115 | * @param calendar instance of a calendar on which all calculations are based | 115 | * @param calendar instance of a calendar on which all calculations are based |
116 | * @param date start date of the matrix (is expected to be already fixed). It is | 116 | * @param date start date of the matrix (is expected to be already fixed). It is |
117 | * assumed that this date is the first week day to be shown in the matrix. | 117 | * assumed that this date is the first week day to be shown in the matrix. |
118 | * @param name name of the widget | 118 | * @param name name of the widget |
119 | */ | 119 | */ |
120 | KODayMatrix( QWidget *parent, const char *name ); | 120 | KODayMatrix( QWidget *parent, const char *name ); |
121 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); | 121 | //KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); |
122 | 122 | ||
123 | /** destructor that deallocates all dynamically allocated private members. | 123 | /** destructor that deallocates all dynamically allocated private members. |
124 | */ | 124 | */ |
125 | ~KODayMatrix(); | 125 | ~KODayMatrix(); |
126 | 126 | ||
127 | /** updates the day matrix to start with the given date. Does all the necessary | 127 | /** updates the day matrix to start with the given date. Does all the necessary |
128 | * checks for holidays or events on a day and stores them for display later on. | 128 | * checks for holidays or events on a day and stores them for display later on. |
129 | * Does NOT update the view visually. Call repaint() for this. | 129 | * Does NOT update the view visually. Call repaint() for this. |
130 | * | 130 | * |
131 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this | 131 | * @param actdate recalculates the day matrix to show NUMDAYS starting from this |
132 | * date. | 132 | * date. |
133 | */ | 133 | */ |
134 | void updateView(QDate actdate); | 134 | void updateView(QDate actdate); |
135 | void updateEvents(); | 135 | void updateEvents(); |
136 | 136 | ||
137 | /** returns the QDate object associated with day indexed by the | 137 | /** returns the QDate object associated with day indexed by the |
138 | * supplied offset. | 138 | * supplied offset. |
139 | */ | 139 | */ |
140 | const QDate& getDate(int offset); | 140 | const QDate& getDate(int offset); |
141 | void setCalendar( Calendar * ); | 141 | void setCalendar( Calendar * ); |
142 | /** returns the official name of this holy day or 0 if there is no label | 142 | /** returns the official name of this holy day or 0 if there is no label |
143 | * for this day. | 143 | * for this day. |
144 | */ | 144 | */ |
145 | QString getHolidayLabel(int offset); | 145 | QString getHolidayLabel(int offset); |
146 | 146 | ||
147 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied | 147 | /** adds all actual selected days from mSelStart to mSelEnd to the supplied |
148 | * DateList. | 148 | * DateList. |
149 | */ | 149 | */ |
150 | void addSelectedDaysTo(DateList&); | 150 | void addSelectedDaysTo(DateList&); |
151 | 151 | ||
152 | /** sets the actual to be displayed selection in the day matrix starting from | 152 | /** sets the actual to be displayed selection in the day matrix starting from |
153 | * start and ending with end. Theview must be manually updated by calling | 153 | * start and ending with end. Theview must be manually updated by calling |
154 | * repaint. (?) | 154 | * repaint. (?) |
155 | */ | 155 | */ |
156 | void setSelectedDaysFrom(const QDate& start, const QDate& end); | 156 | void setSelectedDaysFrom(const QDate& start, const QDate& end); |
157 | void clearSelection(); | 157 | void clearSelection(); |
158 | 158 | ||
159 | /** Is today visible in the view? Keep this in sync with | 159 | /** Is today visible in the view? Keep this in sync with |
160 | * the values today (below) can take. | 160 | * the values today (below) can take. |
161 | */ | 161 | */ |
162 | bool isTodayVisible() const { return today>=0; } ; | 162 | bool isTodayVisible() const { return today>=0; } ; |
163 | 163 | ||
164 | /** If today is visible, then we can find out if today is | 164 | /** If today is visible, then we can find out if today is |
165 | * near the beginning or the end of the month. | 165 | * near the beginning or the end of the month. |
166 | * This is dependent on today remaining the index | 166 | * This is dependent on today remaining the index |
167 | * in the array of visible dates and going from | 167 | * in the array of visible dates and going from |
168 | * top left (0) to bottom right (41). | 168 | * top left (0) to bottom right (41). |
169 | */ | 169 | */ |
170 | bool isBeginningOfMonth() const { return today<=8; } ; | 170 | bool isBeginningOfMonth() const { return today<=8; } ; |
171 | bool isEndOfMonth() const { return today>=27; } ; | 171 | bool isEndOfMonth() const { return today>=27; } ; |
172 | QString getWhatsThisText( QPoint ) ; | 172 | QString getWhatsThisText( QPoint ) ; |
173 | QSize sizeHint() const; | ||
173 | 174 | ||
174 | public slots: | 175 | public slots: |
175 | /** Recalculates all the flags of the days in the matrix like holidays or events | 176 | /** Recalculates all the flags of the days in the matrix like holidays or events |
176 | * on a day (Actually calls above method with the actual startdate). | 177 | * on a day (Actually calls above method with the actual startdate). |
177 | */ | 178 | */ |
178 | void updateView(); | 179 | void updateView(); |
179 | void updateViewTimed(); | 180 | void updateViewTimed(); |
180 | void repaintViewTimed(); | 181 | void repaintViewTimed(); |
181 | 182 | ||
182 | /** | 183 | /** |
183 | * Calculate which square in the matrix should be | 184 | * Calculate which square in the matrix should be |
184 | * hilighted to indicate it's today. | 185 | * hilighted to indicate it's today. |
185 | */ | 186 | */ |
186 | void recalculateToday(); | 187 | void recalculateToday(); |
187 | 188 | ||
188 | /* | 189 | /* |
189 | void setStartDate(QDate); | 190 | void setStartDate(QDate); |
190 | */ | 191 | */ |
191 | 192 | ||
192 | signals: | 193 | signals: |
193 | 194 | ||
194 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle | 195 | /** emitted if the user selects a block of days with the mouse by dragging a rectangle |
195 | * inside the matrix | 196 | * inside the matrix |
196 | * | 197 | * |
197 | * @param daylist list of days that have been selected by the user | 198 | * @param daylist list of days that have been selected by the user |
198 | */ | 199 | */ |
199 | void selected( const KCal::DateList &daylist ); | 200 | void selected( const KCal::DateList &daylist ); |
200 | 201 | ||
201 | /** emitted if the user has dropped an event inside the matrix | 202 | /** emitted if the user has dropped an event inside the matrix |
202 | * | 203 | * |
203 | * @param event the dropped calendar event | 204 | * @param event the dropped calendar event |
204 | */ | 205 | */ |
205 | void eventDropped(Event *event); | 206 | void eventDropped(Event *event); |
206 | 207 | ||
207 | protected: | 208 | protected: |
208 | 209 | ||
209 | void paintEvent(QPaintEvent *ev); | 210 | void paintEvent(QPaintEvent *ev); |
210 | 211 | ||
211 | void mousePressEvent (QMouseEvent* e); | 212 | void mousePressEvent (QMouseEvent* e); |
212 | 213 | ||
213 | void mouseReleaseEvent (QMouseEvent* e); | 214 | void mouseReleaseEvent (QMouseEvent* e); |
214 | 215 | ||
215 | void mouseMoveEvent (QMouseEvent* e); | 216 | void mouseMoveEvent (QMouseEvent* e); |
216 | 217 | ||
217 | void dragEnterEvent(QDragEnterEvent *); | 218 | void dragEnterEvent(QDragEnterEvent *); |
218 | 219 | ||
219 | void dragMoveEvent(QDragMoveEvent *); | 220 | void dragMoveEvent(QDragMoveEvent *); |
220 | 221 | ||
221 | void dragLeaveEvent(QDragLeaveEvent *); | 222 | void dragLeaveEvent(QDragLeaveEvent *); |
222 | 223 | ||
223 | void dropEvent(QDropEvent *); | 224 | void dropEvent(QDropEvent *); |
224 | 225 | ||
225 | void resizeEvent(QResizeEvent *); | 226 | void resizeEvent(QResizeEvent *); |
226 | 227 | ||
227 | private: | 228 | private: |
228 | bool mouseDown; | 229 | bool mouseDown; |
229 | QBitArray bDays; | 230 | QBitArray bDays; |
230 | QPixmap myPix; | 231 | QPixmap myPix; |
231 | QTimer* mUpdateTimer; | 232 | QTimer* mUpdateTimer; |
232 | QTimer* mRepaintTimer; | 233 | QTimer* mRepaintTimer; |
233 | bool mDayChanged; | 234 | bool mDayChanged; |
234 | bool mPendingUpdateBeforeRepaint; | 235 | bool mPendingUpdateBeforeRepaint; |
235 | 236 | ||
236 | /** returns the index of the day located at the matrix's widget (x,y) position. | 237 | /** returns the index of the day located at the matrix's widget (x,y) position. |
237 | * | 238 | * |
238 | * @param x horizontal coordinate | 239 | * @param x horizontal coordinate |
239 | * @param y vertical coordinate | 240 | * @param y vertical coordinate |
240 | */ | 241 | */ |
241 | int getDayIndexFrom(int x, int y); | 242 | int getDayIndexFrom(int x, int y); |
242 | 243 | ||
243 | /** calculates a "shaded" color from the supplied color object. | 244 | /** calculates a "shaded" color from the supplied color object. |
244 | * (Copied from Cornelius's kdpdatebutton.cpp) | 245 | * (Copied from Cornelius's kdpdatebutton.cpp) |
245 | * | 246 | * |
246 | * @param color source based on which a shaded color should be calculated. | 247 | * @param color source based on which a shaded color should be calculated. |
247 | */ | 248 | */ |
248 | QColor getShadedColor(QColor color); | 249 | QColor getShadedColor(QColor color); |
249 | 250 | ||
250 | /** number of days to be displayed. For now there is no support for any other number then 42. | 251 | /** number of days to be displayed. For now there is no support for any other number then 42. |
251 | so change it at your own risk :o) */ | 252 | so change it at your own risk :o) */ |
252 | static const int NUMDAYS; | 253 | static const int NUMDAYS; |
253 | 254 | ||
254 | /** calendar instance to be queried for holidays, events, ... */ | 255 | /** calendar instance to be queried for holidays, events, ... */ |
255 | Calendar *mCalendar; | 256 | Calendar *mCalendar; |
256 | 257 | ||
257 | /** starting date of the matrix */ | 258 | /** starting date of the matrix */ |
258 | QDate startdate; | 259 | QDate startdate; |
259 | 260 | ||
260 | /** array of day labels to optimeize drawing performance. */ | 261 | /** array of day labels to optimeize drawing performance. */ |
261 | QString *daylbls; | 262 | QString *daylbls; |
262 | 263 | ||
263 | /** array of days displayed to reduce memory consumption by | 264 | /** array of days displayed to reduce memory consumption by |
264 | subsequently calling QDate::addDays(). */ | 265 | subsequently calling QDate::addDays(). */ |
265 | QDate *days; | 266 | QDate *days; |
266 | 267 | ||
267 | /** array of storing the number of events on a given day. | 268 | /** array of storing the number of events on a given day. |
268 | * used for drawing a bold font if there is at least one event on that day. | 269 | * used for drawing a bold font if there is at least one event on that day. |
269 | */ | 270 | */ |
270 | int *events; | 271 | int *events; |
271 | 272 | ||
272 | /** stores holiday names of the days shown in the matrix. */ | 273 | /** stores holiday names of the days shown in the matrix. */ |
273 | QMap<int,QString> mHolidays; | 274 | QMap<int,QString> mHolidays; |
274 | 275 | ||
275 | /** indey of today or -1 if today is not visible in the matrix. */ | 276 | /** indey of today or -1 if today is not visible in the matrix. */ |
276 | int today; | 277 | int today; |
277 | 278 | ||
278 | /** index of day where dragged selection was initiated. | 279 | /** index of day where dragged selection was initiated. |
279 | used to detect "negative" timely selections */ | 280 | used to detect "negative" timely selections */ |
280 | int mSelInit; | 281 | int mSelInit; |
281 | 282 | ||
282 | /** if mSelStart has this value it indicates that there is no | 283 | /** if mSelStart has this value it indicates that there is no |
283 | actual selection in the matrix. */ | 284 | actual selection in the matrix. */ |
284 | static const int NOSELECTION; | 285 | static const int NOSELECTION; |
285 | 286 | ||
286 | /** index of first selected day. */ | 287 | /** index of first selected day. */ |
287 | int mSelStart; | 288 | int mSelStart; |
288 | 289 | ||
289 | /** index of last selected day. */ | 290 | /** index of last selected day. */ |
290 | int mSelEnd; | 291 | int mSelEnd; |
291 | 292 | ||
292 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ | 293 | /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ |
293 | DynamicTip* mToolTip; | 294 | DynamicTip* mToolTip; |
294 | 295 | ||
295 | 296 | ||
296 | /** default background colour of the matrix. */ | 297 | /** default background colour of the matrix. */ |
297 | QColor mDefaultBackColor; | 298 | QColor mDefaultBackColor; |
298 | 299 | ||
299 | /** default text color of the matrix. */ | 300 | /** default text color of the matrix. */ |
300 | QColor mDefaultTextColor; | 301 | QColor mDefaultTextColor; |
301 | 302 | ||
302 | /** default text color for days not in the actual month. */ | 303 | /** default text color for days not in the actual month. */ |
303 | QColor mDefaultTextColorShaded; | 304 | QColor mDefaultTextColorShaded; |
304 | 305 | ||
305 | /** default text color for holidays not in the actual month. */ | 306 | /** default text color for holidays not in the actual month. */ |
306 | QColor mHolidayColorShaded; | 307 | QColor mHolidayColorShaded; |
307 | 308 | ||
308 | /** text color for selected days. */ | 309 | /** text color for selected days. */ |
309 | QColor mSelectedDaysColor; | 310 | QColor mSelectedDaysColor; |
310 | 311 | ||
311 | /** default width of the frame drawn around today if it is visible in the matrix. */ | 312 | /** default width of the frame drawn around today if it is visible in the matrix. */ |
312 | int mTodayMarginWidth; | 313 | int mTodayMarginWidth; |
313 | 314 | ||
314 | /** stores actual size of each day in the widget so that I dont need to ask this data | 315 | /** stores actual size of each day in the widget so that I dont need to ask this data |
315 | * on every repaint. | 316 | * on every repaint. |
316 | */ | 317 | */ |
317 | QRect daysize; | 318 | QRect daysize; |
318 | 319 | ||
319 | }; | 320 | }; |
320 | 321 | ||
321 | #endif | 322 | #endif |
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp index 27d4d17..4a51bba 100644 --- a/korganizer/navigatorbar.cpp +++ b/korganizer/navigatorbar.cpp | |||
@@ -1,244 +1,247 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qstring.h> | 25 | #include <qstring.h> |
26 | #include <qtooltip.h> | 26 | #include <qtooltip.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qframe.h> | 29 | #include <qframe.h> |
30 | #include <qlabel.h> | 30 | #include <qlabel.h> |
31 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | 33 | ||
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <klocale.h> | 35 | #include <klocale.h> |
36 | #include <kglobal.h> | 36 | #include <kglobal.h> |
37 | #include <kiconloader.h> | 37 | #include <kiconloader.h> |
38 | #include "libkdepim/kdatepicker.h" | 38 | #include "libkdepim/kdatepicker.h" |
39 | #include <knotifyclient.h> | 39 | #include <knotifyclient.h> |
40 | #include "kdatetbl.h" | 40 | #include "kdatetbl.h" |
41 | 41 | ||
42 | #include "koglobals.h" | 42 | #include "koglobals.h" |
43 | #include <kglobalsettings.h> | 43 | #include <kglobalsettings.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #ifndef KORG_NOPLUGINS | 45 | #ifndef KORG_NOPLUGINS |
46 | #include "kocore.h" | 46 | #include "kocore.h" |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <kcalendarsystem.h> | 49 | #include <kcalendarsystem.h> |
50 | 50 | ||
51 | #include "navigatorbar.h" | 51 | #include "navigatorbar.h" |
52 | 52 | ||
53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) | 53 | NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) |
54 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ) |
55 | { | 55 | { |
56 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 56 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
57 | 57 | ||
58 | // Set up the control buttons and date label | 58 | // Set up the control buttons and date label |
59 | mCtrlFrame = new QFrame( this ); | 59 | mCtrlFrame = new QFrame( this ); |
60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); | 60 | mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); |
61 | mCtrlFrame->setLineWidth(1); | 61 | mCtrlFrame->setLineWidth(1); |
62 | 62 | ||
63 | topLayout->addWidget( mCtrlFrame ); | 63 | topLayout->addWidget( mCtrlFrame ); |
64 | 64 | ||
65 | QFont tfont = font(); | 65 | |
66 | if ( QApplication::desktop()->width() >= 480 ) | ||
67 | tfont.setPointSize(tfont.pointSize()+2); | ||
68 | tfont.setBold(true); | ||
69 | 66 | ||
70 | bool isRTL = KOGlobals::self()->reverseLayout(); | 67 | bool isRTL = KOGlobals::self()->reverseLayout(); |
71 | #ifndef DESKTOP_VERSION | 68 | #ifndef DESKTOP_VERSION |
72 | bool isDesktop = false; | 69 | bool isDesktop = false; |
73 | #else | 70 | #else |
74 | bool isDesktop = true; | 71 | bool isDesktop = true; |
75 | #endif | 72 | #endif |
76 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) | 73 | if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) |
77 | isDesktop = true; | 74 | isDesktop = true; |
78 | // Create backward navigation buttons | 75 | // Create backward navigation buttons |
79 | mPrevYear = new QPushButton( mCtrlFrame ); | 76 | mPrevYear = new QPushButton( mCtrlFrame ); |
80 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); | 77 | mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); |
81 | QToolTip::add( mPrevYear, i18n("Previous Year") ); | 78 | QToolTip::add( mPrevYear, i18n("Previous Year") ); |
82 | 79 | ||
83 | mPrevMonth = new QPushButton( mCtrlFrame ); | 80 | mPrevMonth = new QPushButton( mCtrlFrame ); |
84 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 81 | mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
85 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); | 82 | QToolTip::add( mPrevMonth, i18n("Previous Month") ); |
86 | 83 | ||
87 | // Create forward navigation buttons | 84 | // Create forward navigation buttons |
88 | mNextMonth = new QPushButton( mCtrlFrame ); | 85 | mNextMonth = new QPushButton( mCtrlFrame ); |
89 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 86 | mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
90 | QToolTip::add( mNextMonth, i18n("Next Month") ); | 87 | QToolTip::add( mNextMonth, i18n("Next Month") ); |
91 | 88 | ||
92 | mPrevWeek = new QPushButton( mCtrlFrame ); | 89 | mPrevWeek = new QPushButton( mCtrlFrame ); |
93 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); | 90 | mPrevWeek->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); |
94 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); | 91 | QToolTip::add( mPrevWeek, i18n("Previous Week") ); |
95 | 92 | ||
96 | // Create forward navigation buttons | 93 | // Create forward navigation buttons |
97 | mNextWeek = new QPushButton( mCtrlFrame ); | 94 | mNextWeek = new QPushButton( mCtrlFrame ); |
98 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); | 95 | mNextWeek->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); |
99 | QToolTip::add( mNextWeek, i18n("Next Week") ); | 96 | QToolTip::add( mNextWeek, i18n("Next Week") ); |
100 | 97 | ||
101 | mNextYear = new QPushButton( mCtrlFrame ); | 98 | mNextYear = new QPushButton( mCtrlFrame ); |
102 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); | 99 | mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); |
103 | QToolTip::add( mNextYear, i18n("Next Year") ); | 100 | QToolTip::add( mNextYear, i18n("Next Year") ); |
104 | mSelectMonth = new QPushButton( mCtrlFrame ); | 101 | mSelectMonth = new QPushButton( mCtrlFrame ); |
105 | // Create month name label | 102 | // Create month name label |
106 | //selectMonth->setFont( tfont ); | 103 | //selectMonth->setFont( tfont ); |
107 | // selectMonth->setAlignment( AlignCenter ); | 104 | // selectMonth->setAlignment( AlignCenter ); |
108 | //mDateLabel = new QLabel( selectMonth ); | 105 | //mDateLabel = new QLabel( selectMonth ); |
109 | //mDateLabel->setFont( tfont ); | 106 | //mDateLabel->setFont( tfont ); |
110 | //mDateLabel->setAlignment( AlignCenter ); | 107 | //mDateLabel->setAlignment( AlignCenter ); |
111 | if ( QString ( name ) == QString("useBigPixmaps") ) { | 108 | if ( QString ( name ) == QString("useBigPixmaps") ) { |
112 | mNextMonth->setFlat( true); | 109 | mNextMonth->setFlat( true); |
113 | mNextWeek->setFlat( true); | 110 | mNextWeek->setFlat( true); |
114 | mNextYear->setFlat( true); | 111 | mNextYear->setFlat( true); |
115 | mSelectMonth->setFlat( true); | 112 | mSelectMonth->setFlat( true); |
116 | mPrevYear->setFlat( true); | 113 | mPrevYear->setFlat( true); |
117 | mPrevMonth->setFlat( true); | 114 | mPrevMonth->setFlat( true); |
118 | mPrevWeek->setFlat( true); | 115 | mPrevWeek->setFlat( true); |
119 | } else { | 116 | } else { |
120 | mPrevWeek->hide(); | 117 | mPrevWeek->hide(); |
121 | mNextWeek->hide(); | 118 | mNextWeek->hide(); |
122 | } | 119 | } |
123 | mSelectMonth->setFont( tfont ); | ||
124 | // Set minimum width to width of widest month name label | ||
125 | int i; | ||
126 | int maxwidth = 0; | ||
127 | QFontMetrics fm ( mSelectMonth->font() ); | ||
128 | int width = fm.width("September '00" ); | ||
129 | // for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); | ||
130 | // ++i ) { | ||
131 | // //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, | ||
132 | // // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); | ||
133 | // int width = fm.width("September 2000" ); | ||
134 | // if ( width > maxwidth ) maxwidth = width; | ||
135 | // } | ||
136 | maxwidth = width+2; | ||
137 | int size = fm.height()+2; | ||
138 | if ( QApplication::desktop()->width() >= 480 ) { | ||
139 | size += 6; | ||
140 | maxwidth+= 6; | ||
141 | } | ||
142 | 120 | ||
143 | mSelectMonth->setFixedWidth( maxwidth ); | 121 | resetFont( font() ); |
144 | mSelectMonth->setFixedHeight( size ); | 122 | |
145 | mPrevYear->setFixedHeight( size ); | 123 | |
146 | mPrevMonth->setFixedHeight( size ); | ||
147 | mPrevWeek->setFixedHeight( size ); | ||
148 | mNextMonth->setFixedHeight( size ); | ||
149 | mNextWeek->setFixedHeight( size ); | ||
150 | mNextYear->setFixedHeight ( size ); | ||
151 | // set up control frame layout | 124 | // set up control frame layout |
152 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); | 125 | QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); |
153 | ctrlLayout->addWidget( mPrevYear, 3 ); | 126 | ctrlLayout->addWidget( mPrevYear, 3 ); |
154 | ctrlLayout->addWidget( mPrevMonth, 3 ); | 127 | ctrlLayout->addWidget( mPrevMonth, 3 ); |
155 | ctrlLayout->addWidget( mPrevWeek, 3 ); | 128 | ctrlLayout->addWidget( mPrevWeek, 3 ); |
156 | //ctrlLayout->addStretch( 1 ); | 129 | //ctrlLayout->addStretch( 1 ); |
157 | // ctrlLayout->addSpacing( 1 ); | 130 | // ctrlLayout->addSpacing( 1 ); |
158 | // ctrlLayout->addWidget( mDateLabel ); | 131 | // ctrlLayout->addWidget( mDateLabel ); |
159 | ctrlLayout->addWidget( mSelectMonth ); | 132 | ctrlLayout->addWidget( mSelectMonth ); |
160 | // ctrlLayout->addSpacing( 1 ); | 133 | // ctrlLayout->addSpacing( 1 ); |
161 | // ctrlLayout->addStretch( 1 ); | 134 | // ctrlLayout->addStretch( 1 ); |
162 | ctrlLayout->addWidget( mNextWeek, 3 ); | 135 | ctrlLayout->addWidget( mNextWeek, 3 ); |
163 | ctrlLayout->addWidget( mNextMonth, 3 ); | 136 | ctrlLayout->addWidget( mNextMonth, 3 ); |
164 | ctrlLayout->addWidget( mNextYear, 3 ); | 137 | ctrlLayout->addWidget( mNextYear, 3 ); |
165 | 138 | ||
166 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); | 139 | connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); |
167 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); | 140 | connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); |
168 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); | 141 | connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); |
169 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); | 142 | connect( mPrevWeek, SIGNAL( clicked() ), SIGNAL( goPrevWeek() ) ); |
170 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); | 143 | connect( mNextWeek, SIGNAL( clicked() ), SIGNAL( goNextWeek() ) ); |
171 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); | 144 | connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); |
172 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); | 145 | connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); |
173 | mPrevYear->setFocusPolicy(NoFocus); | 146 | mPrevYear->setFocusPolicy(NoFocus); |
174 | mPrevMonth->setFocusPolicy(NoFocus); | 147 | mPrevMonth->setFocusPolicy(NoFocus); |
175 | mNextMonth->setFocusPolicy(NoFocus); | 148 | mNextMonth->setFocusPolicy(NoFocus); |
176 | mPrevWeek->setFocusPolicy(NoFocus); | 149 | mPrevWeek->setFocusPolicy(NoFocus); |
177 | mNextWeek->setFocusPolicy(NoFocus); | 150 | mNextWeek->setFocusPolicy(NoFocus); |
178 | mNextYear->setFocusPolicy(NoFocus); | 151 | mNextYear->setFocusPolicy(NoFocus); |
179 | mSelectMonth->setFocusPolicy(NoFocus); | 152 | mSelectMonth->setFocusPolicy(NoFocus); |
180 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 153 | setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
181 | 154 | ||
182 | } | 155 | } |
183 | 156 | ||
184 | NavigatorBar::~NavigatorBar() | 157 | NavigatorBar::~NavigatorBar() |
185 | { | 158 | { |
186 | } | 159 | } |
160 | void NavigatorBar::resetFont ( QFont fo ) | ||
161 | { | ||
162 | |||
163 | QFont tfont = fo; | ||
164 | if ( QApplication::desktop()->width() >= 480 ) | ||
165 | tfont.setPointSize(tfont.pointSize()+2); | ||
166 | tfont.setBold(true); | ||
167 | |||
168 | mSelectMonth->setFont( tfont ); | ||
169 | // Set minimum width to width of widest month name label | ||
170 | int i; | ||
171 | int maxwidth = 0; | ||
172 | QFontMetrics fm ( mSelectMonth->font() ); | ||
173 | int width = fm.width("September '00" ); | ||
174 | maxwidth = width+2; | ||
175 | int size = fm.height()+2; | ||
176 | if ( QApplication::desktop()->width() >= 480 ) { | ||
177 | size += 6; | ||
178 | maxwidth+= 6; | ||
179 | } | ||
180 | mSelectMonth->setMinimumWidth( maxwidth ); | ||
181 | mSelectMonth->setFixedHeight( size ); | ||
182 | mPrevYear->setFixedHeight( size ); | ||
183 | mPrevMonth->setFixedHeight( size ); | ||
184 | mPrevWeek->setFixedHeight( size ); | ||
185 | mNextMonth->setFixedHeight( size ); | ||
186 | mNextWeek->setFixedHeight( size ); | ||
187 | mNextYear->setFixedHeight ( size ); | ||
188 | } | ||
189 | |||
187 | void NavigatorBar::showButtons( bool left, bool right ) | 190 | void NavigatorBar::showButtons( bool left, bool right ) |
188 | { | 191 | { |
189 | if ( left ) { | 192 | if ( left ) { |
190 | mPrevYear->show(); | 193 | mPrevYear->show(); |
191 | mPrevMonth->show(); | 194 | mPrevMonth->show(); |
192 | } else { | 195 | } else { |
193 | mPrevYear->hide(); | 196 | mPrevYear->hide(); |
194 | mPrevMonth->hide(); | 197 | mPrevMonth->hide(); |
195 | } | 198 | } |
196 | 199 | ||
197 | if ( right ) { | 200 | if ( right ) { |
198 | mNextYear->show(); | 201 | mNextYear->show(); |
199 | mNextMonth->show(); | 202 | mNextMonth->show(); |
200 | } else { | 203 | } else { |
201 | mNextYear->hide(); | 204 | mNextYear->hide(); |
202 | mNextMonth->hide(); | 205 | mNextMonth->hide(); |
203 | } | 206 | } |
204 | if ( !left && !right ) { | 207 | if ( !left && !right ) { |
205 | mSelectMonth->setMaximumWidth( 1024 ); | 208 | //mSelectMonth->setMaximumWidth( 1024 ); |
206 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); | 209 | mSelectMonth->setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); |
207 | } | 210 | } |
208 | } | 211 | } |
209 | 212 | ||
210 | void NavigatorBar::selectMonth() | 213 | void NavigatorBar::selectMonth() |
211 | { | 214 | { |
212 | 215 | ||
213 | int month; | 216 | int month; |
214 | KPopupFrame* popup = new KPopupFrame(this); | 217 | KPopupFrame* popup = new KPopupFrame(this); |
215 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); | 218 | KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(popup); |
216 | // ----- | 219 | // ----- |
217 | picker->resize(picker->sizeHint()); | 220 | picker->resize(picker->sizeHint()); |
218 | popup->setMainWidget(picker); | 221 | popup->setMainWidget(picker); |
219 | picker->setFocus(); | 222 | picker->setFocus(); |
220 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); | 223 | connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); |
221 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) | 224 | if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) |
222 | { | 225 | { |
223 | month = picker->getResult(); | 226 | month = picker->getResult(); |
224 | emit monthSelected ( month ); | 227 | emit monthSelected ( month ); |
225 | } else { | 228 | } else { |
226 | KNotifyClient::beep(); | 229 | KNotifyClient::beep(); |
227 | } | 230 | } |
228 | delete popup; | 231 | delete popup; |
229 | } | 232 | } |
230 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) | 233 | void NavigatorBar::selectDates( const KCal::DateList &dateList ) |
231 | { | 234 | { |
232 | if (dateList.count() > 0) { | 235 | if (dateList.count() > 0) { |
233 | QDate date = dateList.first(); | 236 | QDate date = dateList.first(); |
234 | 237 | ||
235 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); | 238 | const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); |
236 | 239 | ||
237 | // compute the label at the top of the navigator | 240 | // compute the label at the top of the navigator |
238 | QString dtstr = i18n(calSys->monthName( date )) + " '" + | 241 | QString dtstr = i18n(calSys->monthName( date )) + " '" + |
239 | QString::number( calSys->year( date ) ).right(2); | 242 | QString::number( calSys->year( date ) ).right(2); |
240 | 243 | ||
241 | mSelectMonth->setText( dtstr ); | 244 | mSelectMonth->setText( dtstr ); |
242 | } | 245 | } |
243 | } | 246 | } |
244 | 247 | ||
diff --git a/korganizer/navigatorbar.h b/korganizer/navigatorbar.h index 4442caa..0b2f60b 100644 --- a/korganizer/navigatorbar.h +++ b/korganizer/navigatorbar.h | |||
@@ -1,70 +1,71 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | #ifndef NAVIGATORBAR_H | 24 | #ifndef NAVIGATORBAR_H |
25 | #define NAVIGATORBAR_H | 25 | #define NAVIGATORBAR_H |
26 | 26 | ||
27 | #include <libkcal/incidencebase.h> | 27 | #include <libkcal/incidencebase.h> |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | 30 | ||
31 | class QPushButton; | 31 | class QPushButton; |
32 | class QFrame; | 32 | class QFrame; |
33 | class QLabel; | 33 | class QLabel; |
34 | 34 | ||
35 | class NavigatorBar: public QWidget | 35 | class NavigatorBar: public QWidget |
36 | { | 36 | { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | public: | 38 | public: |
39 | NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); | 39 | NavigatorBar( const QDate & date, QWidget *parent = 0, const char *name = 0 ); |
40 | ~NavigatorBar(); | 40 | ~NavigatorBar(); |
41 | void showButtons( bool left, bool right ); | 41 | void showButtons( bool left, bool right ); |
42 | void resetFont ( QFont fo ); | ||
42 | 43 | ||
43 | public slots: | 44 | public slots: |
44 | void selectDates( const KCal::DateList & ); | 45 | void selectDates( const KCal::DateList & ); |
45 | void selectMonth(); | 46 | void selectMonth(); |
46 | 47 | ||
47 | signals: | 48 | signals: |
48 | void goNextMonth(); | 49 | void goNextMonth(); |
49 | void goPrevMonth(); | 50 | void goPrevMonth(); |
50 | void goNextWeek(); | 51 | void goNextWeek(); |
51 | void goPrevWeek(); | 52 | void goPrevWeek(); |
52 | void goNextYear(); | 53 | void goNextYear(); |
53 | void goPrevYear(); | 54 | void goPrevYear(); |
54 | void monthSelected( int ); | 55 | void monthSelected( int ); |
55 | 56 | ||
56 | private: | 57 | private: |
57 | QFrame *mCtrlFrame; | 58 | QFrame *mCtrlFrame; |
58 | 59 | ||
59 | QPushButton *mPrevYear; | 60 | QPushButton *mPrevYear; |
60 | QPushButton *mPrevMonth; | 61 | QPushButton *mPrevMonth; |
61 | QPushButton *mNextMonth; | 62 | QPushButton *mNextMonth; |
62 | QPushButton *mPrevWeek; | 63 | QPushButton *mPrevWeek; |
63 | QPushButton *mNextWeek; | 64 | QPushButton *mNextWeek; |
64 | QPushButton *mNextYear; | 65 | QPushButton *mNextYear; |
65 | QPushButton *mSelectMonth; | 66 | QPushButton *mSelectMonth; |
66 | 67 | ||
67 | //QLabel *mDateLabel; | 68 | //QLabel *mDateLabel; |
68 | }; | 69 | }; |
69 | 70 | ||
70 | #endif | 71 | #endif |