-rw-r--r-- | korganizer/calendarview.cpp | 14 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 17 | ||||
-rw-r--r-- | korganizer/koeventviewer.cpp | 7 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 2 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 3 | ||||
-rw-r--r-- | korganizer/kowhatsnextview.cpp | 6 |
6 files changed, 45 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 7c8316f..3dac20b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3912 +1,3924 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "statusdialog.h" | 110 | #include "statusdialog.h" |
111 | #include "kdatenavigator.h" | 111 | #include "kdatenavigator.h" |
112 | #include "kotodoview.h" | 112 | #include "kotodoview.h" |
113 | #include "datenavigator.h" | 113 | #include "datenavigator.h" |
114 | #include "resourceview.h" | 114 | #include "resourceview.h" |
115 | #include "navigatorbar.h" | 115 | #include "navigatorbar.h" |
116 | #include "searchdialog.h" | 116 | #include "searchdialog.h" |
117 | #include "mainwindow.h" | 117 | #include "mainwindow.h" |
118 | 118 | ||
119 | #include "calendarview.h" | 119 | #include "calendarview.h" |
120 | #ifndef DESKTOP_VERSION | 120 | #ifndef DESKTOP_VERSION |
121 | #include <qtopia/alarmserver.h> | 121 | #include <qtopia/alarmserver.h> |
122 | #endif | 122 | #endif |
123 | #ifndef _WIN32_ | 123 | #ifndef _WIN32_ |
124 | #include <stdlib.h> | 124 | #include <stdlib.h> |
125 | #include <stdio.h> | 125 | #include <stdio.h> |
126 | #include <unistd.h> | 126 | #include <unistd.h> |
127 | #else | 127 | #else |
128 | #include <qprocess.h> | 128 | #include <qprocess.h> |
129 | #endif | 129 | #endif |
130 | 130 | ||
131 | #ifdef DESKTOP_VERSION | 131 | #ifdef DESKTOP_VERSION |
132 | #include <kabc/stdaddressbook.h> | 132 | #include <kabc/stdaddressbook.h> |
133 | #endif | 133 | #endif |
134 | using namespace KOrg; | 134 | using namespace KOrg; |
135 | using namespace KCal; | 135 | using namespace KCal; |
136 | extern int globalFlagBlockAgenda; | 136 | extern int globalFlagBlockAgenda; |
137 | extern int globalFlagBlockStartup; | 137 | extern int globalFlagBlockStartup; |
138 | 138 | ||
139 | 139 | ||
140 | 140 | ||
141 | class KOBeamPrefs : public QDialog | 141 | class KOBeamPrefs : public QDialog |
142 | { | 142 | { |
143 | public: | 143 | public: |
144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 144 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
145 | QDialog( parent, name, true ) | 145 | QDialog( parent, name, true ) |
146 | { | 146 | { |
147 | setCaption( i18n("Beam Options") ); | 147 | setCaption( i18n("Beam Options") ); |
148 | QVBoxLayout* lay = new QVBoxLayout( this ); | 148 | QVBoxLayout* lay = new QVBoxLayout( this ); |
149 | lay->setSpacing( 3 ); | 149 | lay->setSpacing( 3 ); |
150 | lay->setMargin( 3 ); | 150 | lay->setMargin( 3 ); |
151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 151 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
152 | lay->addWidget( format ); | 152 | lay->addWidget( format ); |
153 | format->setExclusive ( true ) ; | 153 | format->setExclusive ( true ) ; |
154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 154 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
155 | lay->addWidget( time ); time->setExclusive ( true ) ; | 155 | lay->addWidget( time ); time->setExclusive ( true ) ; |
156 | vcal = new QRadioButton(" vCalendar ", format ); | 156 | vcal = new QRadioButton(" vCalendar ", format ); |
157 | ical = new QRadioButton(" iCalendar ", format ); | 157 | ical = new QRadioButton(" iCalendar ", format ); |
158 | vcal->setChecked( true ); | 158 | vcal->setChecked( true ); |
159 | tz = new QRadioButton(i18n(" With timezone "), time ); | 159 | tz = new QRadioButton(i18n(" With timezone "), time ); |
160 | local = new QRadioButton(i18n(" Local time "), time ); | 160 | local = new QRadioButton(i18n(" Local time "), time ); |
161 | tz->setChecked( true ); | 161 | tz->setChecked( true ); |
162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 162 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
163 | lay->addWidget( ok ); | 163 | lay->addWidget( ok ); |
164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 164 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
165 | lay->addWidget( cancel ); | 165 | lay->addWidget( cancel ); |
166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 166 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 167 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
168 | resize( 200, 200 ); | 168 | resize( 200, 200 ); |
169 | } | 169 | } |
170 | 170 | ||
171 | bool beamVcal() { return vcal->isChecked(); } | 171 | bool beamVcal() { return vcal->isChecked(); } |
172 | bool beamLocal() { return local->isChecked(); } | 172 | bool beamLocal() { return local->isChecked(); } |
173 | private: | 173 | private: |
174 | QRadioButton* vcal, *ical, *local, *tz; | 174 | QRadioButton* vcal, *ical, *local, *tz; |
175 | }; | 175 | }; |
176 | class KOCatPrefs : public QDialog | 176 | class KOCatPrefs : public QDialog |
177 | { | 177 | { |
178 | public: | 178 | public: |
179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 179 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
180 | QDialog( parent, name, true ) | 180 | QDialog( parent, name, true ) |
181 | { | 181 | { |
182 | setCaption( i18n("Manage new Categories") ); | 182 | setCaption( i18n("Manage new Categories") ); |
183 | QVBoxLayout* lay = new QVBoxLayout( this ); | 183 | QVBoxLayout* lay = new QVBoxLayout( this ); |
184 | lay->setSpacing( 3 ); | 184 | lay->setSpacing( 3 ); |
185 | lay->setMargin( 3 ); | 185 | lay->setMargin( 3 ); |
186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 186 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
187 | lay->addWidget( lab ); | 187 | lay->addWidget( lab ); |
188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 188 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
189 | lay->addWidget( format ); | 189 | lay->addWidget( format ); |
190 | format->setExclusive ( true ) ; | 190 | format->setExclusive ( true ) ; |
191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 191 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 192 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
193 | addCatBut->setChecked( true ); | 193 | addCatBut->setChecked( true ); |
194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 194 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
195 | lay->addWidget( ok ); | 195 | lay->addWidget( ok ); |
196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 196 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
197 | lay->addWidget( cancel ); | 197 | lay->addWidget( cancel ); |
198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 198 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 199 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
200 | resize( 200, 200 ); | 200 | resize( 200, 200 ); |
201 | } | 201 | } |
202 | 202 | ||
203 | bool addCat() { return addCatBut->isChecked(); } | 203 | bool addCat() { return addCatBut->isChecked(); } |
204 | private: | 204 | private: |
205 | QRadioButton* addCatBut; | 205 | QRadioButton* addCatBut; |
206 | }; | 206 | }; |
207 | 207 | ||
208 | 208 | ||
209 | 209 | ||
210 | CalendarView::CalendarView( CalendarResources *calendar, | 210 | CalendarView::CalendarView( CalendarResources *calendar, |
211 | QWidget *parent, const char *name ) | 211 | QWidget *parent, const char *name ) |
212 | : CalendarViewBase( parent, name ), | 212 | : CalendarViewBase( parent, name ), |
213 | mCalendar( calendar ), | 213 | mCalendar( calendar ), |
214 | mResourceManager( calendar->resourceManager() ) | 214 | mResourceManager( calendar->resourceManager() ) |
215 | { | 215 | { |
216 | 216 | ||
217 | mEventEditor = 0; | 217 | mEventEditor = 0; |
218 | mTodoEditor = 0; | 218 | mTodoEditor = 0; |
219 | 219 | ||
220 | init(); | 220 | init(); |
221 | } | 221 | } |
222 | 222 | ||
223 | CalendarView::CalendarView( Calendar *calendar, | 223 | CalendarView::CalendarView( Calendar *calendar, |
224 | QWidget *parent, const char *name ) | 224 | QWidget *parent, const char *name ) |
225 | : CalendarViewBase( parent, name ), | 225 | : CalendarViewBase( parent, name ), |
226 | mCalendar( calendar ), | 226 | mCalendar( calendar ), |
227 | mResourceManager( 0 ) | 227 | mResourceManager( 0 ) |
228 | { | 228 | { |
229 | 229 | ||
230 | mEventEditor = 0; | 230 | mEventEditor = 0; |
231 | mTodoEditor = 0; | 231 | mTodoEditor = 0; |
232 | init();} | 232 | init();} |
233 | 233 | ||
234 | void CalendarView::init() | 234 | void CalendarView::init() |
235 | { | 235 | { |
236 | mBlockShowDates = false; | 236 | mBlockShowDates = false; |
237 | beamDialog = new KOBeamPrefs(); | 237 | beamDialog = new KOBeamPrefs(); |
238 | mDatePickerMode = 0; | 238 | mDatePickerMode = 0; |
239 | mCurrentSyncDevice = ""; | 239 | mCurrentSyncDevice = ""; |
240 | writeLocale(); | 240 | writeLocale(); |
241 | mViewManager = new KOViewManager( this ); | 241 | mViewManager = new KOViewManager( this ); |
242 | mDialogManager = new KODialogManager( this ); | 242 | mDialogManager = new KODialogManager( this ); |
243 | mEventViewerDialog = 0; | 243 | mEventViewerDialog = 0; |
244 | mModified = false; | 244 | mModified = false; |
245 | mReadOnly = false; | 245 | mReadOnly = false; |
246 | mSelectedIncidence = 0; | 246 | mSelectedIncidence = 0; |
247 | mCalPrinter = 0; | 247 | mCalPrinter = 0; |
248 | mFilters.setAutoDelete(true); | 248 | mFilters.setAutoDelete(true); |
249 | 249 | ||
250 | mCalendar->registerObserver( this ); | 250 | mCalendar->registerObserver( this ); |
251 | // TODO: Make sure that view is updated, when calendar is changed. | 251 | // TODO: Make sure that view is updated, when calendar is changed. |
252 | 252 | ||
253 | mStorage = new FileStorage( mCalendar ); | 253 | mStorage = new FileStorage( mCalendar ); |
254 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 254 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
255 | 255 | ||
256 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 256 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
257 | #ifndef KORG_NOSPLITTER | 257 | #ifndef KORG_NOSPLITTER |
258 | // create the main layout frames. | 258 | // create the main layout frames. |
259 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 259 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
260 | topLayout->addWidget(mPanner); | 260 | topLayout->addWidget(mPanner); |
261 | 261 | ||
262 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 262 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
263 | "CalendarView::LeftFrame"); | 263 | "CalendarView::LeftFrame"); |
264 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 264 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
265 | 265 | ||
266 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 266 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
267 | "CalendarView::DateNavigator", QDate::currentDate() ); | 267 | "CalendarView::DateNavigator", QDate::currentDate() ); |
268 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 268 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
269 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 269 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
270 | mTodoList->setNavigator( mNavigator ); | 270 | mTodoList->setNavigator( mNavigator ); |
271 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 271 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
272 | 272 | ||
273 | #ifdef KORG_NORESOURCEVIEW | 273 | #ifdef KORG_NORESOURCEVIEW |
274 | mResourceView = 0; | 274 | mResourceView = 0; |
275 | #else | 275 | #else |
276 | if ( mResourceManager ) { | 276 | if ( mResourceManager ) { |
277 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 277 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
278 | mResourceView->updateView(); | 278 | mResourceView->updateView(); |
279 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 279 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
280 | SLOT( updateView() ) ); | 280 | SLOT( updateView() ) ); |
281 | } else { | 281 | } else { |
282 | mResourceView = 0; | 282 | mResourceView = 0; |
283 | } | 283 | } |
284 | #endif | 284 | #endif |
285 | QWidget *rightBox = new QWidget( mPanner ); | 285 | QWidget *rightBox = new QWidget( mPanner ); |
286 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 286 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
287 | 287 | ||
288 | mRightFrame = new QWidgetStack( rightBox ); | 288 | mRightFrame = new QWidgetStack( rightBox ); |
289 | rightLayout->addWidget( mRightFrame, 1 ); | 289 | rightLayout->addWidget( mRightFrame, 1 ); |
290 | 290 | ||
291 | mLeftFrame = mLeftSplitter; | 291 | mLeftFrame = mLeftSplitter; |
292 | #else | 292 | #else |
293 | QWidget *mainBox = new QWidget( this ); | 293 | QWidget *mainBox = new QWidget( this ); |
294 | QWidget *leftFrame = new QWidget( mainBox ); | 294 | QWidget *leftFrame = new QWidget( mainBox ); |
295 | 295 | ||
296 | QBoxLayout * mainBoxLayout; | 296 | QBoxLayout * mainBoxLayout; |
297 | QBoxLayout * leftFrameLayout; | 297 | QBoxLayout * leftFrameLayout; |
298 | if ( KOPrefs::instance()->mVerticalScreen ) { | 298 | if ( KOPrefs::instance()->mVerticalScreen ) { |
299 | mainBoxLayout = new QVBoxLayout(mainBox); | 299 | mainBoxLayout = new QVBoxLayout(mainBox); |
300 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 300 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
301 | } else { | 301 | } else { |
302 | mainBoxLayout = new QHBoxLayout(mainBox); | 302 | mainBoxLayout = new QHBoxLayout(mainBox); |
303 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 303 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
304 | } | 304 | } |
305 | topLayout->addWidget( mainBox ); | 305 | topLayout->addWidget( mainBox ); |
306 | mainBoxLayout->addWidget (leftFrame); | 306 | mainBoxLayout->addWidget (leftFrame); |
307 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 307 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
308 | "CalendarView::DateNavigator", QDate::currentDate()); | 308 | "CalendarView::DateNavigator", QDate::currentDate()); |
309 | // mDateNavigator->blockSignals( true ); | 309 | // mDateNavigator->blockSignals( true ); |
310 | leftFrameLayout->addWidget( mDateNavigator ); | 310 | leftFrameLayout->addWidget( mDateNavigator ); |
311 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 311 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
312 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); | 312 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); |
313 | mTodoList->setNavigator( mNavigator ); | 313 | mTodoList->setNavigator( mNavigator ); |
314 | 314 | ||
315 | if ( QApplication::desktop()->width() < 480 ) { | 315 | if ( QApplication::desktop()->width() < 480 ) { |
316 | leftFrameLayout->addWidget(mFilterView); | 316 | leftFrameLayout->addWidget(mFilterView); |
317 | leftFrameLayout->addWidget(mTodoList, 2 ); | 317 | leftFrameLayout->addWidget(mTodoList, 2 ); |
318 | 318 | ||
319 | } else { | 319 | } else { |
320 | leftFrameLayout->addWidget(mTodoList,2 ); | 320 | leftFrameLayout->addWidget(mTodoList,2 ); |
321 | leftFrameLayout->addWidget(mFilterView ); | 321 | leftFrameLayout->addWidget(mFilterView ); |
322 | } | 322 | } |
323 | mFilterView->hide(); | 323 | mFilterView->hide(); |
324 | QWidget *rightBox = new QWidget( mainBox ); | 324 | QWidget *rightBox = new QWidget( mainBox ); |
325 | mainBoxLayout->addWidget ( rightBox, 10 ); | 325 | mainBoxLayout->addWidget ( rightBox, 10 ); |
326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 326 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
327 | mRightFrame = new QWidgetStack( rightBox ); | 327 | mRightFrame = new QWidgetStack( rightBox ); |
328 | rightLayout->addWidget( mRightFrame, 10 ); | 328 | rightLayout->addWidget( mRightFrame, 10 ); |
329 | 329 | ||
330 | mLeftFrame = leftFrame; | 330 | mLeftFrame = leftFrame; |
331 | if ( KOPrefs::instance()->mVerticalScreen ) { | 331 | if ( KOPrefs::instance()->mVerticalScreen ) { |
332 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 332 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
333 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 333 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
334 | } else { | 334 | } else { |
335 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 335 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
336 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 336 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
337 | } | 337 | } |
338 | if ( !KOPrefs::instance()->mShowDateNavigator) | 338 | if ( !KOPrefs::instance()->mShowDateNavigator) |
339 | mDateNavigator->hide(); | 339 | mDateNavigator->hide(); |
340 | //qDebug("Calendarview Size %d %d ", width(), height()); | 340 | //qDebug("Calendarview Size %d %d ", width(), height()); |
341 | #endif | 341 | #endif |
342 | 342 | ||
343 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 343 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
344 | SLOT( showDates( const KCal::DateList & ) ) ); | 344 | SLOT( showDates( const KCal::DateList & ) ) ); |
345 | 345 | ||
346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 346 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 347 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
348 | 348 | ||
349 | 349 | ||
350 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 350 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
351 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 351 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
352 | 352 | ||
353 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 353 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
354 | mNavigator, SLOT( selectPreviousYear() ) ); | 354 | mNavigator, SLOT( selectPreviousYear() ) ); |
355 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 355 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
356 | mNavigator, SLOT( selectNextYear() ) ); | 356 | mNavigator, SLOT( selectNextYear() ) ); |
357 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 357 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
358 | mNavigator, SLOT( selectPreviousMonth() ) ); | 358 | mNavigator, SLOT( selectPreviousMonth() ) ); |
359 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 359 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
360 | mNavigator, SLOT( selectNextMonth() ) ); | 360 | mNavigator, SLOT( selectNextMonth() ) ); |
361 | 361 | ||
362 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 362 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
363 | mNavigator, SLOT( selectPrevious() ) ); | 363 | mNavigator, SLOT( selectPrevious() ) ); |
364 | connect( mDateNavigator, SIGNAL( goNext() ), | 364 | connect( mDateNavigator, SIGNAL( goNext() ), |
365 | mNavigator, SLOT( selectNext() ) ); | 365 | mNavigator, SLOT( selectNext() ) ); |
366 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 366 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
367 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 367 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
368 | 368 | ||
369 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 369 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
370 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 370 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
371 | 371 | ||
372 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 372 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
373 | SLOT( eventAdded( Event *) ) ); | 373 | SLOT( eventAdded( Event *) ) ); |
374 | 374 | ||
375 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 375 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
376 | 376 | ||
377 | connect( this, SIGNAL( configChanged() ), | 377 | connect( this, SIGNAL( configChanged() ), |
378 | mDateNavigator, SLOT( updateConfig() ) ); | 378 | mDateNavigator, SLOT( updateConfig() ) ); |
379 | 379 | ||
380 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 380 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
381 | SLOT( newTodo() ) ); | 381 | SLOT( newTodo() ) ); |
382 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 382 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
383 | SLOT( newSubTodo( Todo * ) ) ); | 383 | SLOT( newSubTodo( Todo * ) ) ); |
384 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 384 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
385 | SLOT( editTodo( Todo * ) ) ); | 385 | SLOT( editTodo( Todo * ) ) ); |
386 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 386 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
387 | SLOT( showTodo( Todo *) ) ); | 387 | SLOT( showTodo( Todo *) ) ); |
388 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 388 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
389 | SLOT( deleteTodo( Todo *) ) ); | 389 | SLOT( deleteTodo( Todo *) ) ); |
390 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 390 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
391 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 391 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
392 | SLOT( purgeCompleted() ) ); | 392 | SLOT( purgeCompleted() ) ); |
393 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 393 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
394 | SIGNAL( todoModified( Todo *, int ) ) ); | 394 | SIGNAL( todoModified( Todo *, int ) ) ); |
395 | 395 | ||
396 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 396 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
397 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 397 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
398 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 398 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
399 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 399 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
400 | 400 | ||
401 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 401 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
402 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 402 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
403 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 403 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
404 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 404 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
405 | 405 | ||
406 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 406 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
407 | this, SLOT ( todo_unsub( Todo * ) ) ); | 407 | this, SLOT ( todo_unsub( Todo * ) ) ); |
408 | 408 | ||
409 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 409 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
410 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 410 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
411 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 411 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
412 | SLOT( updateTodo( Todo *, int ) ) ); | 412 | SLOT( updateTodo( Todo *, int ) ) ); |
413 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 413 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
414 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 414 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
415 | 415 | ||
416 | 416 | ||
417 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 417 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
418 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 418 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
419 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 419 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
420 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 420 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
421 | 421 | ||
422 | 422 | ||
423 | 423 | ||
424 | 424 | ||
425 | 425 | ||
426 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 426 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
427 | SLOT(checkClipboard())); | 427 | SLOT(checkClipboard())); |
428 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 428 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
429 | SLOT( processTodoListSelection( Incidence * ) ) ); | 429 | SLOT( processTodoListSelection( Incidence * ) ) ); |
430 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 430 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
431 | 431 | ||
432 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 432 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
433 | 433 | ||
434 | mDateFrame = new QVBox(0,0,WType_Popup); | 434 | mDateFrame = new QVBox(0,0,WType_Popup); |
435 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 435 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
436 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 436 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
437 | mDateFrame->setLineWidth(3); | 437 | mDateFrame->setLineWidth(3); |
438 | mDateFrame->hide(); | 438 | mDateFrame->hide(); |
439 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 439 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
440 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 440 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
441 | 441 | ||
442 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 442 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
443 | 443 | ||
444 | mEventEditor = mDialogManager->getEventEditor(); | 444 | mEventEditor = mDialogManager->getEventEditor(); |
445 | mTodoEditor = mDialogManager->getTodoEditor(); | 445 | mTodoEditor = mDialogManager->getTodoEditor(); |
446 | 446 | ||
447 | mFlagEditDescription = false; | 447 | mFlagEditDescription = false; |
448 | 448 | ||
449 | mSuspendTimer = new QTimer( this ); | 449 | mSuspendTimer = new QTimer( this ); |
450 | mAlarmTimer = new QTimer( this ); | 450 | mAlarmTimer = new QTimer( this ); |
451 | mRecheckAlarmTimer = new QTimer( this ); | 451 | mRecheckAlarmTimer = new QTimer( this ); |
452 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 452 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
453 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 453 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
454 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 454 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
455 | mAlarmDialog = new AlarmDialog( this ); | 455 | mAlarmDialog = new AlarmDialog( this ); |
456 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 456 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
457 | mAlarmDialog->setServerNotification( false ); | 457 | mAlarmDialog->setServerNotification( false ); |
458 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 458 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
459 | 459 | ||
460 | 460 | ||
461 | #ifndef DESKTOP_VERSION | 461 | #ifndef DESKTOP_VERSION |
462 | //US listen for arriving address resultsets | 462 | //US listen for arriving address resultsets |
463 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 463 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
464 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 464 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
465 | #endif | 465 | #endif |
466 | 466 | ||
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
470 | CalendarView::~CalendarView() | 470 | CalendarView::~CalendarView() |
471 | { | 471 | { |
472 | // kdDebug() << "~CalendarView()" << endl; | 472 | // kdDebug() << "~CalendarView()" << endl; |
473 | //qDebug("CalendarView::~CalendarView() "); | 473 | //qDebug("CalendarView::~CalendarView() "); |
474 | delete mDialogManager; | 474 | delete mDialogManager; |
475 | delete mViewManager; | 475 | delete mViewManager; |
476 | delete mStorage; | 476 | delete mStorage; |
477 | delete mDateFrame ; | 477 | delete mDateFrame ; |
478 | delete beamDialog; | 478 | delete beamDialog; |
479 | //kdDebug() << "~CalendarView() done" << endl; | 479 | //kdDebug() << "~CalendarView() done" << endl; |
480 | } | 480 | } |
481 | 481 | ||
482 | void CalendarView::showDay( QDate d ) | 482 | void CalendarView::showDay( QDate d ) |
483 | { | 483 | { |
484 | dateNavigator()->blockSignals( true ); | 484 | dateNavigator()->blockSignals( true ); |
485 | dateNavigator()->selectDate( d ); | 485 | dateNavigator()->selectDate( d ); |
486 | dateNavigator()->blockSignals( false ); | 486 | dateNavigator()->blockSignals( false ); |
487 | mViewManager->showDayView(); | 487 | mViewManager->showDayView(); |
488 | //dateNavigator()->selectDate( d ); | 488 | //dateNavigator()->selectDate( d ); |
489 | } | 489 | } |
490 | void CalendarView::timerAlarm() | 490 | void CalendarView::timerAlarm() |
491 | { | 491 | { |
492 | //qDebug("CalendarView::timerAlarm() "); | 492 | //qDebug("CalendarView::timerAlarm() "); |
493 | computeAlarm(mAlarmNotification ); | 493 | computeAlarm(mAlarmNotification ); |
494 | } | 494 | } |
495 | 495 | ||
496 | void CalendarView::suspendAlarm() | 496 | void CalendarView::suspendAlarm() |
497 | { | 497 | { |
498 | //qDebug(" CalendarView::suspendAlarm() "); | 498 | //qDebug(" CalendarView::suspendAlarm() "); |
499 | computeAlarm(mSuspendAlarmNotification ); | 499 | computeAlarm(mSuspendAlarmNotification ); |
500 | 500 | ||
501 | } | 501 | } |
502 | 502 | ||
503 | void CalendarView::startAlarm( QString mess , QString filename) | 503 | void CalendarView::startAlarm( QString mess , QString filename) |
504 | { | 504 | { |
505 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 505 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
506 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 506 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
507 | 507 | ||
508 | } | 508 | } |
509 | 509 | ||
510 | void CalendarView::checkNextTimerAlarm() | 510 | void CalendarView::checkNextTimerAlarm() |
511 | { | 511 | { |
512 | mCalendar->checkAlarmForIncidence( 0, true ); | 512 | mCalendar->checkAlarmForIncidence( 0, true ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void CalendarView::computeAlarm( QString msg ) | 515 | void CalendarView::computeAlarm( QString msg ) |
516 | { | 516 | { |
517 | 517 | ||
518 | QString mess = msg; | 518 | QString mess = msg; |
519 | QString mAlarmMessage = mess.mid( 9 ); | 519 | QString mAlarmMessage = mess.mid( 9 ); |
520 | QString filename = MainWindow::resourcePath(); | 520 | QString filename = MainWindow::resourcePath(); |
521 | filename += "koalarm.wav"; | 521 | filename += "koalarm.wav"; |
522 | QString tempfilename; | 522 | QString tempfilename; |
523 | if ( mess.left( 13 ) == "suspend_alarm") { | 523 | if ( mess.left( 13 ) == "suspend_alarm") { |
524 | bool error = false; | 524 | bool error = false; |
525 | int len = mess.mid( 13 ).find("+++"); | 525 | int len = mess.mid( 13 ).find("+++"); |
526 | if ( len < 2 ) | 526 | if ( len < 2 ) |
527 | error = true; | 527 | error = true; |
528 | else { | 528 | else { |
529 | tempfilename = mess.mid( 13, len ); | 529 | tempfilename = mess.mid( 13, len ); |
530 | if ( !QFile::exists( tempfilename ) ) | 530 | if ( !QFile::exists( tempfilename ) ) |
531 | error = true; | 531 | error = true; |
532 | } | 532 | } |
533 | if ( ! error ) { | 533 | if ( ! error ) { |
534 | filename = tempfilename; | 534 | filename = tempfilename; |
535 | } | 535 | } |
536 | mAlarmMessage = mess.mid( 13+len+3 ); | 536 | mAlarmMessage = mess.mid( 13+len+3 ); |
537 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 537 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
538 | startAlarm( mAlarmMessage, filename); | 538 | startAlarm( mAlarmMessage, filename); |
539 | return; | 539 | return; |
540 | } | 540 | } |
541 | if ( mess.left( 11 ) == "timer_alarm") { | 541 | if ( mess.left( 11 ) == "timer_alarm") { |
542 | //mTimerTime = 0; | 542 | //mTimerTime = 0; |
543 | startAlarm( mess.mid( 11 ), filename ); | 543 | startAlarm( mess.mid( 11 ), filename ); |
544 | return; | 544 | return; |
545 | } | 545 | } |
546 | if ( mess.left( 10 ) == "proc_alarm") { | 546 | if ( mess.left( 10 ) == "proc_alarm") { |
547 | bool error = false; | 547 | bool error = false; |
548 | int len = mess.mid( 10 ).find("+++"); | 548 | int len = mess.mid( 10 ).find("+++"); |
549 | if ( len < 2 ) | 549 | if ( len < 2 ) |
550 | error = true; | 550 | error = true; |
551 | else { | 551 | else { |
552 | tempfilename = mess.mid( 10, len ); | 552 | tempfilename = mess.mid( 10, len ); |
553 | if ( !QFile::exists( tempfilename ) ) | 553 | if ( !QFile::exists( tempfilename ) ) |
554 | error = true; | 554 | error = true; |
555 | } | 555 | } |
556 | if ( error ) { | 556 | if ( error ) { |
557 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 557 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
558 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 558 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
559 | } else { | 559 | } else { |
560 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 560 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
561 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 561 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
562 | #ifndef _WIN32_ | 562 | #ifndef _WIN32_ |
563 | if ( vfork () == 0 ) { | 563 | if ( vfork () == 0 ) { |
564 | execl ( tempfilename.latin1(), 0 ); | 564 | execl ( tempfilename.latin1(), 0 ); |
565 | return; | 565 | return; |
566 | } | 566 | } |
567 | #else | 567 | #else |
568 | QProcess* p = new QProcess(); | 568 | QProcess* p = new QProcess(); |
569 | p->addArgument( tempfilename.latin1() ); | 569 | p->addArgument( tempfilename.latin1() ); |
570 | p->start(); | 570 | p->start(); |
571 | return; | 571 | return; |
572 | #endif | 572 | #endif |
573 | 573 | ||
574 | return; | 574 | return; |
575 | } | 575 | } |
576 | 576 | ||
577 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 577 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
578 | } | 578 | } |
579 | if ( mess.left( 11 ) == "audio_alarm") { | 579 | if ( mess.left( 11 ) == "audio_alarm") { |
580 | bool error = false; | 580 | bool error = false; |
581 | int len = mess.mid( 11 ).find("+++"); | 581 | int len = mess.mid( 11 ).find("+++"); |
582 | if ( len < 2 ) | 582 | if ( len < 2 ) |
583 | error = true; | 583 | error = true; |
584 | else { | 584 | else { |
585 | tempfilename = mess.mid( 11, len ); | 585 | tempfilename = mess.mid( 11, len ); |
586 | if ( !QFile::exists( tempfilename ) ) | 586 | if ( !QFile::exists( tempfilename ) ) |
587 | error = true; | 587 | error = true; |
588 | } | 588 | } |
589 | if ( ! error ) { | 589 | if ( ! error ) { |
590 | filename = tempfilename; | 590 | filename = tempfilename; |
591 | } | 591 | } |
592 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 592 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
593 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 593 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
594 | } | 594 | } |
595 | if ( mess.left( 9 ) == "cal_alarm") { | 595 | if ( mess.left( 9 ) == "cal_alarm") { |
596 | mAlarmMessage = mess.mid( 9 ) ; | 596 | mAlarmMessage = mess.mid( 9 ) ; |
597 | } | 597 | } |
598 | 598 | ||
599 | startAlarm( mAlarmMessage, filename ); | 599 | startAlarm( mAlarmMessage, filename ); |
600 | 600 | ||
601 | 601 | ||
602 | } | 602 | } |
603 | 603 | ||
604 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 604 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
605 | { | 605 | { |
606 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 606 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
607 | 607 | ||
608 | mSuspendAlarmNotification = noti; | 608 | mSuspendAlarmNotification = noti; |
609 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 609 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
610 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 610 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
611 | mSuspendTimer->start( ms , true ); | 611 | mSuspendTimer->start( ms , true ); |
612 | 612 | ||
613 | } | 613 | } |
614 | 614 | ||
615 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 615 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
616 | { | 616 | { |
617 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 617 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
618 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 618 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
619 | #ifndef DESKTOP_VERSION | 619 | #ifndef DESKTOP_VERSION |
620 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 620 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
621 | #endif | 621 | #endif |
622 | return; | 622 | return; |
623 | } | 623 | } |
624 | int maxSec; | 624 | int maxSec; |
625 | //maxSec = 5; //testing only | 625 | //maxSec = 5; //testing only |
626 | maxSec = 86400+3600; // one day+1hour | 626 | maxSec = 86400+3600; // one day+1hour |
627 | mAlarmNotification = noti; | 627 | mAlarmNotification = noti; |
628 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 628 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
629 | if ( sec > maxSec ) { | 629 | if ( sec > maxSec ) { |
630 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 630 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
631 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 631 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
632 | return; | 632 | return; |
633 | } else { | 633 | } else { |
634 | mRecheckAlarmTimer->stop(); | 634 | mRecheckAlarmTimer->stop(); |
635 | } | 635 | } |
636 | //qDebug("Alarm timer started with secs: %d ", sec); | 636 | //qDebug("Alarm timer started with secs: %d ", sec); |
637 | mAlarmTimer->start( sec *1000 , true ); | 637 | mAlarmTimer->start( sec *1000 , true ); |
638 | 638 | ||
639 | } | 639 | } |
640 | // called by mRecheckAlarmTimer to get next alarm | 640 | // called by mRecheckAlarmTimer to get next alarm |
641 | // we need this, because a QTimer has only a max range of 25 days | 641 | // we need this, because a QTimer has only a max range of 25 days |
642 | void CalendarView::recheckTimerAlarm() | 642 | void CalendarView::recheckTimerAlarm() |
643 | { | 643 | { |
644 | mAlarmTimer->stop(); | 644 | mAlarmTimer->stop(); |
645 | mRecheckAlarmTimer->stop(); | 645 | mRecheckAlarmTimer->stop(); |
646 | mCalendar->checkAlarmForIncidence( 0, true ); | 646 | mCalendar->checkAlarmForIncidence( 0, true ); |
647 | } | 647 | } |
648 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 648 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
649 | { | 649 | { |
650 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 650 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
651 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 651 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
652 | #ifndef DESKTOP_VERSION | 652 | #ifndef DESKTOP_VERSION |
653 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 653 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
654 | #endif | 654 | #endif |
655 | return; | 655 | return; |
656 | } | 656 | } |
657 | mAlarmTimer->stop(); | 657 | mAlarmTimer->stop(); |
658 | } | 658 | } |
659 | void CalendarView::selectWeekNum ( int num ) | 659 | void CalendarView::selectWeekNum ( int num ) |
660 | { | 660 | { |
661 | dateNavigator()->blockSignals( true ); | 661 | dateNavigator()->blockSignals( true ); |
662 | dateNavigator()->selectWeek( num ); | 662 | dateNavigator()->selectWeek( num ); |
663 | dateNavigator()->blockSignals( false ); | 663 | dateNavigator()->blockSignals( false ); |
664 | mViewManager->showWeekView(); | 664 | mViewManager->showWeekView(); |
665 | } | 665 | } |
666 | KOViewManager *CalendarView::viewManager() | 666 | KOViewManager *CalendarView::viewManager() |
667 | { | 667 | { |
668 | return mViewManager; | 668 | return mViewManager; |
669 | } | 669 | } |
670 | 670 | ||
671 | KODialogManager *CalendarView::dialogManager() | 671 | KODialogManager *CalendarView::dialogManager() |
672 | { | 672 | { |
673 | return mDialogManager; | 673 | return mDialogManager; |
674 | } | 674 | } |
675 | 675 | ||
676 | QDate CalendarView::startDate() | 676 | QDate CalendarView::startDate() |
677 | { | 677 | { |
678 | DateList dates = mNavigator->selectedDates(); | 678 | DateList dates = mNavigator->selectedDates(); |
679 | 679 | ||
680 | return dates.first(); | 680 | return dates.first(); |
681 | } | 681 | } |
682 | 682 | ||
683 | QDate CalendarView::endDate() | 683 | QDate CalendarView::endDate() |
684 | { | 684 | { |
685 | DateList dates = mNavigator->selectedDates(); | 685 | DateList dates = mNavigator->selectedDates(); |
686 | 686 | ||
687 | return dates.last(); | 687 | return dates.last(); |
688 | } | 688 | } |
689 | 689 | ||
690 | 690 | ||
691 | void CalendarView::createPrinter() | 691 | void CalendarView::createPrinter() |
692 | { | 692 | { |
693 | #ifndef KORG_NOPRINTER | 693 | #ifndef KORG_NOPRINTER |
694 | if (!mCalPrinter) { | 694 | if (!mCalPrinter) { |
695 | mCalPrinter = new CalPrinter(this, mCalendar); | 695 | mCalPrinter = new CalPrinter(this, mCalendar); |
696 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 696 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
697 | } | 697 | } |
698 | #endif | 698 | #endif |
699 | } | 699 | } |
700 | 700 | ||
701 | 701 | ||
702 | //KOPrefs::instance()->mWriteBackFile | 702 | //KOPrefs::instance()->mWriteBackFile |
703 | //KOPrefs::instance()->mWriteBackExistingOnly | 703 | //KOPrefs::instance()->mWriteBackExistingOnly |
704 | 704 | ||
705 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 705 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
706 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 706 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
707 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 707 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
708 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 708 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
709 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 709 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
710 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 710 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
711 | 711 | ||
712 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 712 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
713 | { | 713 | { |
714 | 714 | ||
715 | // 0 equal | 715 | // 0 equal |
716 | // 1 take local | 716 | // 1 take local |
717 | // 2 take remote | 717 | // 2 take remote |
718 | // 3 cancel | 718 | // 3 cancel |
719 | QDateTime lastSync = mLastCalendarSync; | 719 | QDateTime lastSync = mLastCalendarSync; |
720 | QDateTime localMod = local->lastModified(); | 720 | QDateTime localMod = local->lastModified(); |
721 | QDateTime remoteMod = remote->lastModified(); | 721 | QDateTime remoteMod = remote->lastModified(); |
722 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 722 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
723 | bool remCh, locCh; | 723 | bool remCh, locCh; |
724 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 724 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
725 | //if ( remCh ) | 725 | //if ( remCh ) |
726 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 726 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
727 | locCh = ( localMod > mLastCalendarSync ); | 727 | locCh = ( localMod > mLastCalendarSync ); |
728 | if ( !remCh && ! locCh ) { | 728 | if ( !remCh && ! locCh ) { |
729 | //qDebug("both not changed "); | 729 | //qDebug("both not changed "); |
730 | lastSync = localMod.addDays(1); | 730 | lastSync = localMod.addDays(1); |
731 | if ( mode <= SYNC_PREF_ASK ) | 731 | if ( mode <= SYNC_PREF_ASK ) |
732 | return 0; | 732 | return 0; |
733 | } else { | 733 | } else { |
734 | if ( locCh ) { | 734 | if ( locCh ) { |
735 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 735 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
736 | lastSync = localMod.addDays( -1 ); | 736 | lastSync = localMod.addDays( -1 ); |
737 | if ( !remCh ) | 737 | if ( !remCh ) |
738 | remoteMod = ( lastSync.addDays( -1 ) ); | 738 | remoteMod = ( lastSync.addDays( -1 ) ); |
739 | } else { | 739 | } else { |
740 | //qDebug(" not loc changed "); | 740 | //qDebug(" not loc changed "); |
741 | lastSync = localMod.addDays( 1 ); | 741 | lastSync = localMod.addDays( 1 ); |
742 | if ( remCh ) | 742 | if ( remCh ) |
743 | remoteMod =( lastSync.addDays( 1 ) ); | 743 | remoteMod =( lastSync.addDays( 1 ) ); |
744 | 744 | ||
745 | } | 745 | } |
746 | } | 746 | } |
747 | full = true; | 747 | full = true; |
748 | if ( mode < SYNC_PREF_ASK ) | 748 | if ( mode < SYNC_PREF_ASK ) |
749 | mode = SYNC_PREF_ASK; | 749 | mode = SYNC_PREF_ASK; |
750 | } else { | 750 | } else { |
751 | if ( localMod == remoteMod ) | 751 | if ( localMod == remoteMod ) |
752 | // if ( local->revision() == remote->revision() ) | 752 | // if ( local->revision() == remote->revision() ) |
753 | return 0; | 753 | return 0; |
754 | 754 | ||
755 | } | 755 | } |
756 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 756 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
757 | 757 | ||
758 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 758 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
759 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 759 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
760 | //full = true; //debug only | 760 | //full = true; //debug only |
761 | if ( full ) { | 761 | if ( full ) { |
762 | bool equ = false; | 762 | bool equ = false; |
763 | if ( local->type() == "Event" ) { | 763 | if ( local->type() == "Event" ) { |
764 | equ = (*((Event*) local) == *((Event*) remote)); | 764 | equ = (*((Event*) local) == *((Event*) remote)); |
765 | } | 765 | } |
766 | else if ( local->type() =="Todo" ) | 766 | else if ( local->type() =="Todo" ) |
767 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 767 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
768 | else if ( local->type() =="Journal" ) | 768 | else if ( local->type() =="Journal" ) |
769 | equ = (*((Journal*) local) == *((Journal*) remote)); | 769 | equ = (*((Journal*) local) == *((Journal*) remote)); |
770 | if ( equ ) { | 770 | if ( equ ) { |
771 | //qDebug("equal "); | 771 | //qDebug("equal "); |
772 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 772 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
773 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 773 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
774 | } | 774 | } |
775 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 775 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
776 | return 0; | 776 | return 0; |
777 | 777 | ||
778 | }//else //debug only | 778 | }//else //debug only |
779 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 779 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
780 | } | 780 | } |
781 | int result; | 781 | int result; |
782 | bool localIsNew; | 782 | bool localIsNew; |
783 | //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() ); | 783 | //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() ); |
784 | 784 | ||
785 | if ( full && mode < SYNC_PREF_NEWEST ) | 785 | if ( full && mode < SYNC_PREF_NEWEST ) |
786 | mode = SYNC_PREF_ASK; | 786 | mode = SYNC_PREF_ASK; |
787 | 787 | ||
788 | switch( mode ) { | 788 | switch( mode ) { |
789 | case SYNC_PREF_LOCAL: | 789 | case SYNC_PREF_LOCAL: |
790 | if ( lastSync > remoteMod ) | 790 | if ( lastSync > remoteMod ) |
791 | return 1; | 791 | return 1; |
792 | if ( lastSync > localMod ) | 792 | if ( lastSync > localMod ) |
793 | return 2; | 793 | return 2; |
794 | return 1; | 794 | return 1; |
795 | break; | 795 | break; |
796 | case SYNC_PREF_REMOTE: | 796 | case SYNC_PREF_REMOTE: |
797 | if ( lastSync > remoteMod ) | 797 | if ( lastSync > remoteMod ) |
798 | return 1; | 798 | return 1; |
799 | if ( lastSync > localMod ) | 799 | if ( lastSync > localMod ) |
800 | return 2; | 800 | return 2; |
801 | return 2; | 801 | return 2; |
802 | break; | 802 | break; |
803 | case SYNC_PREF_NEWEST: | 803 | case SYNC_PREF_NEWEST: |
804 | if ( localMod > remoteMod ) | 804 | if ( localMod > remoteMod ) |
805 | return 1; | 805 | return 1; |
806 | else | 806 | else |
807 | return 2; | 807 | return 2; |
808 | break; | 808 | break; |
809 | case SYNC_PREF_ASK: | 809 | case SYNC_PREF_ASK: |
810 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 810 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
811 | if ( lastSync > remoteMod ) | 811 | if ( lastSync > remoteMod ) |
812 | return 1; | 812 | return 1; |
813 | if ( lastSync > localMod ) | 813 | if ( lastSync > localMod ) |
814 | return 2; | 814 | return 2; |
815 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 815 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
816 | localIsNew = localMod >= remoteMod; | 816 | localIsNew = localMod >= remoteMod; |
817 | if ( localIsNew ) | 817 | if ( localIsNew ) |
818 | getEventViewerDialog()->setColorMode( 1 ); | 818 | getEventViewerDialog()->setColorMode( 1 ); |
819 | else | 819 | else |
820 | getEventViewerDialog()->setColorMode( 2 ); | 820 | getEventViewerDialog()->setColorMode( 2 ); |
821 | getEventViewerDialog()->setIncidence(local); | 821 | getEventViewerDialog()->setIncidence(local); |
822 | if ( localIsNew ) | 822 | if ( localIsNew ) |
823 | getEventViewerDialog()->setColorMode( 2 ); | 823 | getEventViewerDialog()->setColorMode( 2 ); |
824 | else | 824 | else |
825 | getEventViewerDialog()->setColorMode( 1 ); | 825 | getEventViewerDialog()->setColorMode( 1 ); |
826 | getEventViewerDialog()->addIncidence(remote); | 826 | getEventViewerDialog()->addIncidence(remote); |
827 | getEventViewerDialog()->setColorMode( 0 ); | 827 | getEventViewerDialog()->setColorMode( 0 ); |
828 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 828 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
829 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 829 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
830 | getEventViewerDialog()->showMe(); | 830 | getEventViewerDialog()->showMe(); |
831 | result = getEventViewerDialog()->executeS( localIsNew ); | 831 | result = getEventViewerDialog()->executeS( localIsNew ); |
832 | return result; | 832 | return result; |
833 | 833 | ||
834 | break; | 834 | break; |
835 | case SYNC_PREF_FORCE_LOCAL: | 835 | case SYNC_PREF_FORCE_LOCAL: |
836 | return 1; | 836 | return 1; |
837 | break; | 837 | break; |
838 | case SYNC_PREF_FORCE_REMOTE: | 838 | case SYNC_PREF_FORCE_REMOTE: |
839 | return 2; | 839 | return 2; |
840 | break; | 840 | break; |
841 | 841 | ||
842 | default: | 842 | default: |
843 | // SYNC_PREF_TAKE_BOTH not implemented | 843 | // SYNC_PREF_TAKE_BOTH not implemented |
844 | break; | 844 | break; |
845 | } | 845 | } |
846 | return 0; | 846 | return 0; |
847 | } | 847 | } |
848 | Event* CalendarView::getLastSyncEvent() | 848 | Event* CalendarView::getLastSyncEvent() |
849 | { | 849 | { |
850 | Event* lse; | 850 | Event* lse; |
851 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 851 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
852 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 852 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
853 | if (!lse) { | 853 | if (!lse) { |
854 | lse = new Event(); | 854 | lse = new Event(); |
855 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 855 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
856 | QString sum = ""; | 856 | QString sum = ""; |
857 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 857 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
858 | sum = "E: "; | 858 | sum = "E: "; |
859 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 859 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
860 | lse->setDtStart( mLastCalendarSync ); | 860 | lse->setDtStart( mLastCalendarSync ); |
861 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 861 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
862 | lse->setCategories( i18n("SyncEvent") ); | 862 | lse->setCategories( i18n("SyncEvent") ); |
863 | lse->setReadOnly( true ); | 863 | lse->setReadOnly( true ); |
864 | mCalendar->addEvent( lse ); | 864 | mCalendar->addEvent( lse ); |
865 | } | 865 | } |
866 | 866 | ||
867 | return lse; | 867 | return lse; |
868 | 868 | ||
869 | } | 869 | } |
870 | 870 | ||
871 | // we check, if the to delete event has a id for a profile | 871 | // we check, if the to delete event has a id for a profile |
872 | // if yes, we set this id in the profile to delete | 872 | // if yes, we set this id in the profile to delete |
873 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 873 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
874 | { | 874 | { |
875 | if ( lastSync.count() == 0 ) { | 875 | if ( lastSync.count() == 0 ) { |
876 | //qDebug(" lastSync.count() == 0"); | 876 | //qDebug(" lastSync.count() == 0"); |
877 | return; | 877 | return; |
878 | } | 878 | } |
879 | if ( toDelete->type() == "Journal" ) | 879 | if ( toDelete->type() == "Journal" ) |
880 | return; | 880 | return; |
881 | 881 | ||
882 | Event* eve = lastSync.first(); | 882 | Event* eve = lastSync.first(); |
883 | 883 | ||
884 | while ( eve ) { | 884 | while ( eve ) { |
885 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 885 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
886 | if ( !id.isEmpty() ) { | 886 | if ( !id.isEmpty() ) { |
887 | QString des = eve->description(); | 887 | QString des = eve->description(); |
888 | QString pref = "e"; | 888 | QString pref = "e"; |
889 | if ( toDelete->type() == "Todo" ) | 889 | if ( toDelete->type() == "Todo" ) |
890 | pref = "t"; | 890 | pref = "t"; |
891 | des += pref+ id + ","; | 891 | des += pref+ id + ","; |
892 | eve->setReadOnly( false ); | 892 | eve->setReadOnly( false ); |
893 | eve->setDescription( des ); | 893 | eve->setDescription( des ); |
894 | //qDebug("setdes %s ", des.latin1()); | 894 | //qDebug("setdes %s ", des.latin1()); |
895 | eve->setReadOnly( true ); | 895 | eve->setReadOnly( true ); |
896 | } | 896 | } |
897 | eve = lastSync.next(); | 897 | eve = lastSync.next(); |
898 | } | 898 | } |
899 | 899 | ||
900 | } | 900 | } |
901 | void CalendarView::checkExternalId( Incidence * inc ) | 901 | void CalendarView::checkExternalId( Incidence * inc ) |
902 | { | 902 | { |
903 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 903 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
904 | checkExternSyncEvent( lastSync, inc ); | 904 | checkExternSyncEvent( lastSync, inc ); |
905 | 905 | ||
906 | } | 906 | } |
907 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 907 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
908 | { | 908 | { |
909 | bool syncOK = true; | 909 | bool syncOK = true; |
910 | int addedEvent = 0; | 910 | int addedEvent = 0; |
911 | int addedEventR = 0; | 911 | int addedEventR = 0; |
912 | int deletedEventR = 0; | 912 | int deletedEventR = 0; |
913 | int deletedEventL = 0; | 913 | int deletedEventL = 0; |
914 | int changedLocal = 0; | 914 | int changedLocal = 0; |
915 | int changedRemote = 0; | 915 | int changedRemote = 0; |
916 | int filteredIN = 0; | 916 | int filteredIN = 0; |
917 | int filteredOUT = 0; | 917 | int filteredOUT = 0; |
918 | //QPtrList<Event> el = local->rawEvents(); | 918 | //QPtrList<Event> el = local->rawEvents(); |
919 | Event* eventR; | 919 | Event* eventR; |
920 | QString uid; | 920 | QString uid; |
921 | int take; | 921 | int take; |
922 | Event* eventL; | 922 | Event* eventL; |
923 | Event* eventRSync; | 923 | Event* eventRSync; |
924 | Event* eventLSync; | 924 | Event* eventLSync; |
925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 925 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 926 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
927 | bool fullDateRange = false; | 927 | bool fullDateRange = false; |
928 | local->resetTempSyncStat(); | 928 | local->resetTempSyncStat(); |
929 | mLastCalendarSync = QDateTime::currentDateTime(); | 929 | mLastCalendarSync = QDateTime::currentDateTime(); |
930 | if ( mSyncManager->syncWithDesktop() ) { | 930 | if ( mSyncManager->syncWithDesktop() ) { |
931 | remote->resetPilotStat(1); | 931 | remote->resetPilotStat(1); |
932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 932 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 933 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
934 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 934 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
935 | } else { | 935 | } else { |
936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 936 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
937 | } | 937 | } |
938 | } | 938 | } |
939 | QDateTime modifiedCalendar = mLastCalendarSync; | 939 | QDateTime modifiedCalendar = mLastCalendarSync; |
940 | eventLSync = getLastSyncEvent(); | 940 | eventLSync = getLastSyncEvent(); |
941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 941 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
942 | if ( eventR ) { | 942 | if ( eventR ) { |
943 | eventRSync = (Event*) eventR->clone(); | 943 | eventRSync = (Event*) eventR->clone(); |
944 | remote->deleteEvent(eventR ); | 944 | remote->deleteEvent(eventR ); |
945 | 945 | ||
946 | } else { | 946 | } else { |
947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 947 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
948 | eventRSync = (Event*)eventLSync->clone(); | 948 | eventRSync = (Event*)eventLSync->clone(); |
949 | } else { | 949 | } else { |
950 | fullDateRange = true; | 950 | fullDateRange = true; |
951 | eventRSync = new Event(); | 951 | eventRSync = new Event(); |
952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 952 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 953 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
954 | eventRSync->setDtStart( mLastCalendarSync ); | 954 | eventRSync->setDtStart( mLastCalendarSync ); |
955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 955 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
956 | eventRSync->setCategories( i18n("SyncEvent") ); | 956 | eventRSync->setCategories( i18n("SyncEvent") ); |
957 | } | 957 | } |
958 | } | 958 | } |
959 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 959 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
960 | fullDateRange = true; | 960 | fullDateRange = true; |
961 | 961 | ||
962 | if ( ! fullDateRange ) { | 962 | if ( ! fullDateRange ) { |
963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 963 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
964 | 964 | ||
965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 965 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 966 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
967 | fullDateRange = true; | 967 | fullDateRange = true; |
968 | } | 968 | } |
969 | } | 969 | } |
970 | if ( mSyncManager->syncWithDesktop() ) { | 970 | if ( mSyncManager->syncWithDesktop() ) { |
971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 971 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
972 | } | 972 | } |
973 | if ( fullDateRange ) | 973 | if ( fullDateRange ) |
974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 974 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
975 | else | 975 | else |
976 | mLastCalendarSync = eventLSync->dtStart(); | 976 | mLastCalendarSync = eventLSync->dtStart(); |
977 | // for resyncing if own file has changed | 977 | // for resyncing if own file has changed |
978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 978 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
979 | mLastCalendarSync = loadedFileVersion; | 979 | mLastCalendarSync = loadedFileVersion; |
980 | //qDebug("setting mLastCalendarSync "); | 980 | //qDebug("setting mLastCalendarSync "); |
981 | } | 981 | } |
982 | //qDebug("*************************** "); | 982 | //qDebug("*************************** "); |
983 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 983 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
984 | QPtrList<Incidence> er = remote->rawIncidences(); | 984 | QPtrList<Incidence> er = remote->rawIncidences(); |
985 | Incidence* inR = er.first(); | 985 | Incidence* inR = er.first(); |
986 | Incidence* inL; | 986 | Incidence* inL; |
987 | QProgressBar bar( er.count(),0 ); | 987 | QProgressBar bar( er.count(),0 ); |
988 | bar.setCaption (i18n("Syncing - close to abort!") ); | 988 | bar.setCaption (i18n("Syncing - close to abort!") ); |
989 | 989 | ||
990 | // ************** setting up filter ************* | 990 | // ************** setting up filter ************* |
991 | CalFilter *filterIN = 0; | 991 | CalFilter *filterIN = 0; |
992 | CalFilter *filterOUT = 0; | 992 | CalFilter *filterOUT = 0; |
993 | CalFilter *filter = mFilters.first(); | 993 | CalFilter *filter = mFilters.first(); |
994 | while(filter) { | 994 | while(filter) { |
995 | if ( filter->name() == mSyncManager->mFilterInCal ) | 995 | if ( filter->name() == mSyncManager->mFilterInCal ) |
996 | filterIN = filter; | 996 | filterIN = filter; |
997 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 997 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
998 | filterOUT = filter; | 998 | filterOUT = filter; |
999 | filter = mFilters.next(); | 999 | filter = mFilters.next(); |
1000 | } | 1000 | } |
1001 | int w = 300; | 1001 | int w = 300; |
1002 | if ( QApplication::desktop()->width() < 320 ) | 1002 | if ( QApplication::desktop()->width() < 320 ) |
1003 | w = 220; | 1003 | w = 220; |
1004 | int h = bar.sizeHint().height() ; | 1004 | int h = bar.sizeHint().height() ; |
1005 | int dw = QApplication::desktop()->width(); | 1005 | int dw = QApplication::desktop()->width(); |
1006 | int dh = QApplication::desktop()->height(); | 1006 | int dh = QApplication::desktop()->height(); |
1007 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1007 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1008 | bar.show(); | 1008 | bar.show(); |
1009 | int modulo = (er.count()/10)+1; | 1009 | int modulo = (er.count()/10)+1; |
1010 | int incCounter = 0; | 1010 | int incCounter = 0; |
1011 | while ( inR ) { | 1011 | while ( inR ) { |
1012 | if ( ! bar.isVisible() ) | 1012 | if ( ! bar.isVisible() ) |
1013 | return false; | 1013 | return false; |
1014 | if ( incCounter % modulo == 0 ) | 1014 | if ( incCounter % modulo == 0 ) |
1015 | bar.setProgress( incCounter ); | 1015 | bar.setProgress( incCounter ); |
1016 | ++incCounter; | 1016 | ++incCounter; |
1017 | uid = inR->uid(); | 1017 | uid = inR->uid(); |
1018 | bool skipIncidence = false; | 1018 | bool skipIncidence = false; |
1019 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1019 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1020 | skipIncidence = true; | 1020 | skipIncidence = true; |
1021 | QString idS; | 1021 | QString idS; |
1022 | qApp->processEvents(); | 1022 | qApp->processEvents(); |
1023 | if ( !skipIncidence ) { | 1023 | if ( !skipIncidence ) { |
1024 | inL = local->incidence( uid ); | 1024 | inL = local->incidence( uid ); |
1025 | if ( inL ) { // maybe conflict - same uid in both calendars | 1025 | if ( inL ) { // maybe conflict - same uid in both calendars |
1026 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1026 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1027 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1027 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1028 | if ( take == 3 ) | 1028 | if ( take == 3 ) |
1029 | return false; | 1029 | return false; |
1030 | if ( take == 1 ) {// take local ********************** | 1030 | if ( take == 1 ) {// take local ********************** |
1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1031 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1032 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1033 | else | 1033 | else |
1034 | idS = inR->IDStr(); | 1034 | idS = inR->IDStr(); |
1035 | remote->deleteIncidence( inR ); | 1035 | remote->deleteIncidence( inR ); |
1036 | inR = inL->clone(); | 1036 | inR = inL->clone(); |
1037 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1037 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1038 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1038 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1039 | inR->setIDStr( idS ); | 1039 | inR->setIDStr( idS ); |
1040 | remote->addIncidence( inR ); | 1040 | remote->addIncidence( inR ); |
1041 | if ( mSyncManager->syncWithDesktop() ) | 1041 | if ( mSyncManager->syncWithDesktop() ) |
1042 | inR->setPilotId( 2 ); | 1042 | inR->setPilotId( 2 ); |
1043 | ++changedRemote; | 1043 | ++changedRemote; |
1044 | } else {// take remote ********************** | 1044 | } else {// take remote ********************** |
1045 | idS = inL->IDStr(); | 1045 | idS = inL->IDStr(); |
1046 | int pid = inL->pilotId(); | 1046 | int pid = inL->pilotId(); |
1047 | local->deleteIncidence( inL ); | 1047 | local->deleteIncidence( inL ); |
1048 | inL = inR->clone(); | 1048 | inL = inR->clone(); |
1049 | if ( mSyncManager->syncWithDesktop() ) | 1049 | if ( mSyncManager->syncWithDesktop() ) |
1050 | inL->setPilotId( pid ); | 1050 | inL->setPilotId( pid ); |
1051 | inL->setIDStr( idS ); | 1051 | inL->setIDStr( idS ); |
1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1053 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1053 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1054 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1054 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1055 | } | 1055 | } |
1056 | local->addIncidence( inL ); | 1056 | local->addIncidence( inL ); |
1057 | ++changedLocal; | 1057 | ++changedLocal; |
1058 | } | 1058 | } |
1059 | } | 1059 | } |
1060 | } else { // no conflict ********** add or delete remote | 1060 | } else { // no conflict ********** add or delete remote |
1061 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1061 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1062 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1063 | QString des = eventLSync->description(); | 1063 | QString des = eventLSync->description(); |
1064 | QString pref = "e"; | 1064 | QString pref = "e"; |
1065 | if ( inR->type() == "Todo" ) | 1065 | if ( inR->type() == "Todo" ) |
1066 | pref = "t"; | 1066 | pref = "t"; |
1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1067 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1068 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1069 | //remote->deleteIncidence( inR ); | 1069 | //remote->deleteIncidence( inR ); |
1070 | ++deletedEventR; | 1070 | ++deletedEventR; |
1071 | } else { | 1071 | } else { |
1072 | inR->setLastModified( modifiedCalendar ); | 1072 | inR->setLastModified( modifiedCalendar ); |
1073 | inL = inR->clone(); | 1073 | inL = inR->clone(); |
1074 | inL->setIDStr( ":" ); | 1074 | inL->setIDStr( ":" ); |
1075 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1075 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1076 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1076 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1077 | local->addIncidence( inL ); | 1077 | local->addIncidence( inL ); |
1078 | ++addedEvent; | 1078 | ++addedEvent; |
1079 | 1079 | ||
1080 | } | 1080 | } |
1081 | } else { | 1081 | } else { |
1082 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1082 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1083 | inR->setLastModified( modifiedCalendar ); | 1083 | inR->setLastModified( modifiedCalendar ); |
1084 | inL = inR->clone(); | 1084 | inL = inR->clone(); |
1085 | inL->setIDStr( ":" ); | 1085 | inL->setIDStr( ":" ); |
1086 | local->addIncidence( inL ); | 1086 | local->addIncidence( inL ); |
1087 | ++addedEvent; | 1087 | ++addedEvent; |
1088 | 1088 | ||
1089 | } else { | 1089 | } else { |
1090 | checkExternSyncEvent(eventRSyncSharp, inR); | 1090 | checkExternSyncEvent(eventRSyncSharp, inR); |
1091 | remote->deleteIncidence( inR ); | 1091 | remote->deleteIncidence( inR ); |
1092 | ++deletedEventR; | 1092 | ++deletedEventR; |
1093 | } | 1093 | } |
1094 | } | 1094 | } |
1095 | } else { | 1095 | } else { |
1096 | ++filteredIN; | 1096 | ++filteredIN; |
1097 | } | 1097 | } |
1098 | } | 1098 | } |
1099 | } | 1099 | } |
1100 | inR = er.next(); | 1100 | inR = er.next(); |
1101 | } | 1101 | } |
1102 | QPtrList<Incidence> el = local->rawIncidences(); | 1102 | QPtrList<Incidence> el = local->rawIncidences(); |
1103 | inL = el.first(); | 1103 | inL = el.first(); |
1104 | modulo = (el.count()/10)+1; | 1104 | modulo = (el.count()/10)+1; |
1105 | bar.setCaption (i18n("Add / remove events") ); | 1105 | bar.setCaption (i18n("Add / remove events") ); |
1106 | bar.setTotalSteps ( el.count() ) ; | 1106 | bar.setTotalSteps ( el.count() ) ; |
1107 | bar.show(); | 1107 | bar.show(); |
1108 | incCounter = 0; | 1108 | incCounter = 0; |
1109 | 1109 | ||
1110 | while ( inL ) { | 1110 | while ( inL ) { |
1111 | 1111 | ||
1112 | qApp->processEvents(); | 1112 | qApp->processEvents(); |
1113 | if ( ! bar.isVisible() ) | 1113 | if ( ! bar.isVisible() ) |
1114 | return false; | 1114 | return false; |
1115 | if ( incCounter % modulo == 0 ) | 1115 | if ( incCounter % modulo == 0 ) |
1116 | bar.setProgress( incCounter ); | 1116 | bar.setProgress( incCounter ); |
1117 | ++incCounter; | 1117 | ++incCounter; |
1118 | uid = inL->uid(); | 1118 | uid = inL->uid(); |
1119 | bool skipIncidence = false; | 1119 | bool skipIncidence = false; |
1120 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1120 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1121 | skipIncidence = true; | 1121 | skipIncidence = true; |
1122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1122 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1123 | skipIncidence = true; | 1123 | skipIncidence = true; |
1124 | if ( !skipIncidence ) { | 1124 | if ( !skipIncidence ) { |
1125 | inR = remote->incidence( uid ); | 1125 | inR = remote->incidence( uid ); |
1126 | if ( ! inR ) { | 1126 | if ( ! inR ) { |
1127 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1127 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1128 | // no conflict ********** add or delete local | 1128 | // no conflict ********** add or delete local |
1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1129 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1130 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1130 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1131 | checkExternSyncEvent(eventLSyncSharp, inL); | 1131 | checkExternSyncEvent(eventLSyncSharp, inL); |
1132 | local->deleteIncidence( inL ); | 1132 | local->deleteIncidence( inL ); |
1133 | ++deletedEventL; | 1133 | ++deletedEventL; |
1134 | } else { | 1134 | } else { |
1135 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1135 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1136 | inL->removeID(mCurrentSyncDevice ); | 1136 | inL->removeID(mCurrentSyncDevice ); |
1137 | ++addedEventR; | 1137 | ++addedEventR; |
1138 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1138 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1139 | inL->setLastModified( modifiedCalendar ); | 1139 | inL->setLastModified( modifiedCalendar ); |
1140 | inR = inL->clone(); | 1140 | inR = inL->clone(); |
1141 | inR->setIDStr( ":" ); | 1141 | inR->setIDStr( ":" ); |
1142 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1142 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1143 | remote->addIncidence( inR ); | 1143 | remote->addIncidence( inR ); |
1144 | } | 1144 | } |
1145 | } | 1145 | } |
1146 | } else { | 1146 | } else { |
1147 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1147 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1148 | checkExternSyncEvent(eventLSyncSharp, inL); | 1148 | checkExternSyncEvent(eventLSyncSharp, inL); |
1149 | local->deleteIncidence( inL ); | 1149 | local->deleteIncidence( inL ); |
1150 | ++deletedEventL; | 1150 | ++deletedEventL; |
1151 | } else { | 1151 | } else { |
1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1152 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1153 | ++addedEventR; | 1153 | ++addedEventR; |
1154 | inL->setLastModified( modifiedCalendar ); | 1154 | inL->setLastModified( modifiedCalendar ); |
1155 | inR = inL->clone(); | 1155 | inR = inL->clone(); |
1156 | inR->setIDStr( ":" ); | 1156 | inR->setIDStr( ":" ); |
1157 | remote->addIncidence( inR ); | 1157 | remote->addIncidence( inR ); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | } else { | 1161 | } else { |
1162 | ++filteredOUT; | 1162 | ++filteredOUT; |
1163 | } | 1163 | } |
1164 | } | 1164 | } |
1165 | } | 1165 | } |
1166 | inL = el.next(); | 1166 | inL = el.next(); |
1167 | } | 1167 | } |
1168 | int delFut = 0; | 1168 | int delFut = 0; |
1169 | int remRem = 0; | 1169 | int remRem = 0; |
1170 | if ( mSyncManager->mWriteBackInFuture ) { | 1170 | if ( mSyncManager->mWriteBackInFuture ) { |
1171 | er = remote->rawIncidences(); | 1171 | er = remote->rawIncidences(); |
1172 | remRem = er.count(); | 1172 | remRem = er.count(); |
1173 | inR = er.first(); | 1173 | inR = er.first(); |
1174 | QDateTime dt; | 1174 | QDateTime dt; |
1175 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1175 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1176 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1176 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1177 | while ( inR ) { | 1177 | while ( inR ) { |
1178 | if ( inR->type() == "Todo" ) { | 1178 | if ( inR->type() == "Todo" ) { |
1179 | Todo * t = (Todo*)inR; | 1179 | Todo * t = (Todo*)inR; |
1180 | if ( t->hasDueDate() ) | 1180 | if ( t->hasDueDate() ) |
1181 | dt = t->dtDue(); | 1181 | dt = t->dtDue(); |
1182 | else | 1182 | else |
1183 | dt = cur.addSecs( 62 ); | 1183 | dt = cur.addSecs( 62 ); |
1184 | } | 1184 | } |
1185 | else if (inR->type() == "Event" ) { | 1185 | else if (inR->type() == "Event" ) { |
1186 | bool ok; | 1186 | bool ok; |
1187 | dt = inR->getNextOccurence( cur, &ok ); | 1187 | dt = inR->getNextOccurence( cur, &ok ); |
1188 | if ( !ok ) | 1188 | if ( !ok ) |
1189 | dt = cur.addSecs( -62 ); | 1189 | dt = cur.addSecs( -62 ); |
1190 | } | 1190 | } |
1191 | else | 1191 | else |
1192 | dt = inR->dtStart(); | 1192 | dt = inR->dtStart(); |
1193 | if ( dt < cur || dt > end ) { | 1193 | if ( dt < cur || dt > end ) { |
1194 | remote->deleteIncidence( inR ); | 1194 | remote->deleteIncidence( inR ); |
1195 | ++delFut; | 1195 | ++delFut; |
1196 | } | 1196 | } |
1197 | inR = er.next(); | 1197 | inR = er.next(); |
1198 | } | 1198 | } |
1199 | } | 1199 | } |
1200 | bar.hide(); | 1200 | bar.hide(); |
1201 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1201 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1202 | eventLSync->setReadOnly( false ); | 1202 | eventLSync->setReadOnly( false ); |
1203 | eventLSync->setDtStart( mLastCalendarSync ); | 1203 | eventLSync->setDtStart( mLastCalendarSync ); |
1204 | eventRSync->setDtStart( mLastCalendarSync ); | 1204 | eventRSync->setDtStart( mLastCalendarSync ); |
1205 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1205 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1206 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1206 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1207 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1207 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1208 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1208 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1209 | eventLSync->setReadOnly( true ); | 1209 | eventLSync->setReadOnly( true ); |
1210 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1210 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1211 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1211 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1212 | remote->addEvent( eventRSync ); | 1212 | remote->addEvent( eventRSync ); |
1213 | else | 1213 | else |
1214 | delete eventRSync; | 1214 | delete eventRSync; |
1215 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1215 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1216 | QString mes; | 1216 | QString mes; |
1217 | 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 ); | 1217 | 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 ); |
1218 | QString delmess; | 1218 | QString delmess; |
1219 | if ( delFut ) { | 1219 | if ( delFut ) { |
1220 | 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); | 1220 | 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); |
1221 | mes += delmess; | 1221 | mes += delmess; |
1222 | } | 1222 | } |
1223 | mes = i18n("Local calendar changed!\n") +mes; | 1223 | mes = i18n("Local calendar changed!\n") +mes; |
1224 | mCalendar->checkAlarmForIncidence( 0, true ); | 1224 | mCalendar->checkAlarmForIncidence( 0, true ); |
1225 | qDebug( mes ); | 1225 | qDebug( mes ); |
1226 | if ( mSyncManager->mShowSyncSummary ) { | 1226 | if ( mSyncManager->mShowSyncSummary ) { |
1227 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1227 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1228 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1228 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1229 | qDebug("KO: WB cancelled "); | 1229 | qDebug("KO: WB cancelled "); |
1230 | mSyncManager->mWriteBackFile = false; | 1230 | mSyncManager->mWriteBackFile = false; |
1231 | return syncOK; | 1231 | return syncOK; |
1232 | } | 1232 | } |
1233 | } | 1233 | } |
1234 | return syncOK; | 1234 | return syncOK; |
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | void CalendarView::setSyncDevice( QString s ) | 1237 | void CalendarView::setSyncDevice( QString s ) |
1238 | { | 1238 | { |
1239 | mCurrentSyncDevice= s; | 1239 | mCurrentSyncDevice= s; |
1240 | } | 1240 | } |
1241 | void CalendarView::setSyncName( QString s ) | 1241 | void CalendarView::setSyncName( QString s ) |
1242 | { | 1242 | { |
1243 | mCurrentSyncName= s; | 1243 | mCurrentSyncName= s; |
1244 | } | 1244 | } |
1245 | bool CalendarView::syncCalendar(QString filename, int mode) | 1245 | bool CalendarView::syncCalendar(QString filename, int mode) |
1246 | { | 1246 | { |
1247 | //qDebug("syncCalendar %s ", filename.latin1()); | 1247 | //qDebug("syncCalendar %s ", filename.latin1()); |
1248 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1248 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1249 | CalendarLocal* calendar = new CalendarLocal(); | 1249 | CalendarLocal* calendar = new CalendarLocal(); |
1250 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1250 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1251 | FileStorage* storage = new FileStorage( calendar ); | 1251 | FileStorage* storage = new FileStorage( calendar ); |
1252 | bool syncOK = false; | 1252 | bool syncOK = false; |
1253 | storage->setFileName( filename ); | 1253 | storage->setFileName( filename ); |
1254 | // qDebug("loading ... "); | 1254 | // qDebug("loading ... "); |
1255 | if ( storage->load() ) { | 1255 | if ( storage->load() ) { |
1256 | getEventViewerDialog()->setSyncMode( true ); | 1256 | getEventViewerDialog()->setSyncMode( true ); |
1257 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1257 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1258 | getEventViewerDialog()->setSyncMode( false ); | 1258 | getEventViewerDialog()->setSyncMode( false ); |
1259 | if ( syncOK ) { | 1259 | if ( syncOK ) { |
1260 | if ( mSyncManager->mWriteBackFile ) | 1260 | if ( mSyncManager->mWriteBackFile ) |
1261 | { | 1261 | { |
1262 | storage->setSaveFormat( new ICalFormat() ); | 1262 | storage->setSaveFormat( new ICalFormat() ); |
1263 | storage->save(); | 1263 | storage->save(); |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | setModified( true ); | 1266 | setModified( true ); |
1267 | } | 1267 | } |
1268 | delete storage; | 1268 | delete storage; |
1269 | delete calendar; | 1269 | delete calendar; |
1270 | if ( syncOK ) | 1270 | if ( syncOK ) |
1271 | updateView(); | 1271 | updateView(); |
1272 | return syncOK; | 1272 | return syncOK; |
1273 | } | 1273 | } |
1274 | 1274 | ||
1275 | void CalendarView::syncExternal( int mode ) | 1275 | void CalendarView::syncExternal( int mode ) |
1276 | { | 1276 | { |
1277 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1277 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1278 | 1278 | ||
1279 | qApp->processEvents(); | 1279 | qApp->processEvents(); |
1280 | CalendarLocal* calendar = new CalendarLocal(); | 1280 | CalendarLocal* calendar = new CalendarLocal(); |
1281 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1281 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1282 | bool syncOK = false; | 1282 | bool syncOK = false; |
1283 | bool loadSuccess = false; | 1283 | bool loadSuccess = false; |
1284 | PhoneFormat* phoneFormat = 0; | 1284 | PhoneFormat* phoneFormat = 0; |
1285 | emit tempDisableBR(true); | 1285 | emit tempDisableBR(true); |
1286 | #ifndef DESKTOP_VERSION | 1286 | #ifndef DESKTOP_VERSION |
1287 | SharpFormat* sharpFormat = 0; | 1287 | SharpFormat* sharpFormat = 0; |
1288 | if ( mode == 0 ) { // sharp | 1288 | if ( mode == 0 ) { // sharp |
1289 | sharpFormat = new SharpFormat () ; | 1289 | sharpFormat = new SharpFormat () ; |
1290 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1290 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1291 | 1291 | ||
1292 | } else | 1292 | } else |
1293 | #endif | 1293 | #endif |
1294 | if ( mode == 1 ) { // phone | 1294 | if ( mode == 1 ) { // phone |
1295 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1295 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1296 | mSyncManager->mPhoneDevice, | 1296 | mSyncManager->mPhoneDevice, |
1297 | mSyncManager->mPhoneConnection, | 1297 | mSyncManager->mPhoneConnection, |
1298 | mSyncManager->mPhoneModel); | 1298 | mSyncManager->mPhoneModel); |
1299 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1299 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1300 | 1300 | ||
1301 | } else { | 1301 | } else { |
1302 | emit tempDisableBR(false); | 1302 | emit tempDisableBR(false); |
1303 | return; | 1303 | return; |
1304 | } | 1304 | } |
1305 | if ( loadSuccess ) { | 1305 | if ( loadSuccess ) { |
1306 | getEventViewerDialog()->setSyncMode( true ); | 1306 | getEventViewerDialog()->setSyncMode( true ); |
1307 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1307 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1308 | getEventViewerDialog()->setSyncMode( false ); | 1308 | getEventViewerDialog()->setSyncMode( false ); |
1309 | qApp->processEvents(); | 1309 | qApp->processEvents(); |
1310 | if ( syncOK ) { | 1310 | if ( syncOK ) { |
1311 | if ( mSyncManager->mWriteBackFile ) | 1311 | if ( mSyncManager->mWriteBackFile ) |
1312 | { | 1312 | { |
1313 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1313 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1314 | Incidence* inc = iL.first(); | 1314 | Incidence* inc = iL.first(); |
1315 | if ( phoneFormat ) { | 1315 | if ( phoneFormat ) { |
1316 | while ( inc ) { | 1316 | while ( inc ) { |
1317 | inc->removeID(mCurrentSyncDevice); | 1317 | inc->removeID(mCurrentSyncDevice); |
1318 | inc = iL.next(); | 1318 | inc = iL.next(); |
1319 | } | 1319 | } |
1320 | } | 1320 | } |
1321 | #ifndef DESKTOP_VERSION | 1321 | #ifndef DESKTOP_VERSION |
1322 | if ( sharpFormat ) | 1322 | if ( sharpFormat ) |
1323 | sharpFormat->save(calendar); | 1323 | sharpFormat->save(calendar); |
1324 | #endif | 1324 | #endif |
1325 | if ( phoneFormat ) | 1325 | if ( phoneFormat ) |
1326 | phoneFormat->save(calendar); | 1326 | phoneFormat->save(calendar); |
1327 | iL = calendar->rawIncidences(); | 1327 | iL = calendar->rawIncidences(); |
1328 | inc = iL.first(); | 1328 | inc = iL.first(); |
1329 | Incidence* loc; | 1329 | Incidence* loc; |
1330 | while ( inc ) { | 1330 | while ( inc ) { |
1331 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1331 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1332 | loc = mCalendar->incidence(inc->uid() ); | 1332 | loc = mCalendar->incidence(inc->uid() ); |
1333 | if ( loc ) { | 1333 | if ( loc ) { |
1334 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1334 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1335 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1335 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | inc = iL.next(); | 1338 | inc = iL.next(); |
1339 | } | 1339 | } |
1340 | Incidence* lse = getLastSyncEvent(); | 1340 | Incidence* lse = getLastSyncEvent(); |
1341 | if ( lse ) { | 1341 | if ( lse ) { |
1342 | lse->setReadOnly( false ); | 1342 | lse->setReadOnly( false ); |
1343 | lse->setDescription( "" ); | 1343 | lse->setDescription( "" ); |
1344 | lse->setReadOnly( true ); | 1344 | lse->setReadOnly( true ); |
1345 | } | 1345 | } |
1346 | } | 1346 | } |
1347 | } else { | 1347 | } else { |
1348 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1348 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1349 | } | 1349 | } |
1350 | setModified( true ); | 1350 | setModified( true ); |
1351 | } else { | 1351 | } else { |
1352 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1352 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1353 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1353 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1354 | question, i18n("Ok")) ; | 1354 | question, i18n("Ok")) ; |
1355 | 1355 | ||
1356 | } | 1356 | } |
1357 | delete calendar; | 1357 | delete calendar; |
1358 | updateView(); | 1358 | updateView(); |
1359 | emit tempDisableBR(false); | 1359 | emit tempDisableBR(false); |
1360 | return ;//syncOK; | 1360 | return ;//syncOK; |
1361 | 1361 | ||
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | bool CalendarView::importBday() | 1364 | bool CalendarView::importBday() |
1365 | { | 1365 | { |
1366 | #ifndef KORG_NOKABC | 1366 | #ifndef KORG_NOKABC |
1367 | 1367 | ||
1368 | #ifdef DESKTOP_VERSION | 1368 | #ifdef DESKTOP_VERSION |
1369 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1369 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1370 | KABC::AddressBook::Iterator it; | 1370 | KABC::AddressBook::Iterator it; |
1371 | int count = 0; | 1371 | int count = 0; |
1372 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1372 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1373 | ++count; | 1373 | ++count; |
1374 | } | 1374 | } |
1375 | QProgressBar bar(count,0 ); | 1375 | QProgressBar bar(count,0 ); |
1376 | int w = 300; | 1376 | int w = 300; |
1377 | if ( QApplication::desktop()->width() < 320 ) | 1377 | if ( QApplication::desktop()->width() < 320 ) |
1378 | w = 220; | 1378 | w = 220; |
1379 | int h = bar.sizeHint().height() ; | 1379 | int h = bar.sizeHint().height() ; |
1380 | int dw = QApplication::desktop()->width(); | 1380 | int dw = QApplication::desktop()->width(); |
1381 | int dh = QApplication::desktop()->height(); | 1381 | int dh = QApplication::desktop()->height(); |
1382 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1382 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1383 | bar.show(); | 1383 | bar.show(); |
1384 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1384 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1385 | qApp->processEvents(); | 1385 | qApp->processEvents(); |
1386 | count = 0; | 1386 | count = 0; |
1387 | int addCount = 0; | 1387 | int addCount = 0; |
1388 | KCal::Attendee* a = 0; | 1388 | KCal::Attendee* a = 0; |
1389 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1389 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1390 | if ( ! bar.isVisible() ) | 1390 | if ( ! bar.isVisible() ) |
1391 | return false; | 1391 | return false; |
1392 | bar.setProgress( count++ ); | 1392 | bar.setProgress( count++ ); |
1393 | qApp->processEvents(); | 1393 | qApp->processEvents(); |
1394 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1394 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1395 | if ( (*it).birthday().date().isValid() ){ | 1395 | if ( (*it).birthday().date().isValid() ){ |
1396 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1396 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1397 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1397 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1398 | ++addCount; | 1398 | ++addCount; |
1399 | } | 1399 | } |
1400 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1400 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1401 | if ( anni.isValid() ){ | 1401 | if ( anni.isValid() ){ |
1402 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1402 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1403 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1403 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1404 | ++addCount; | 1404 | ++addCount; |
1405 | } | 1405 | } |
1406 | } | 1406 | } |
1407 | updateView(); | 1407 | updateView(); |
1408 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1408 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1409 | #else //DESKTOP_VERSION | 1409 | #else //DESKTOP_VERSION |
1410 | 1410 | ||
1411 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1411 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1412 | // the result should now arrive through method insertBirthdays | 1412 | // the result should now arrive through method insertBirthdays |
1413 | 1413 | ||
1414 | #endif //DESKTOP_VERSION | 1414 | #endif //DESKTOP_VERSION |
1415 | 1415 | ||
1416 | #endif //KORG_NOKABC | 1416 | #endif //KORG_NOKABC |
1417 | 1417 | ||
1418 | 1418 | ||
1419 | return true; | 1419 | return true; |
1420 | } | 1420 | } |
1421 | 1421 | ||
1422 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI | 1422 | // This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI |
1423 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, | 1423 | void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, |
1424 | const QStringList& anniversaryList, const QStringList& realNameList, | 1424 | const QStringList& anniversaryList, const QStringList& realNameList, |
1425 | const QStringList& emailList, const QStringList& assembledNameList, | 1425 | const QStringList& emailList, const QStringList& assembledNameList, |
1426 | const QStringList& uidList) | 1426 | const QStringList& uidList) |
1427 | { | 1427 | { |
1428 | //qDebug("KO::CalendarView::insertBirthdays"); | 1428 | //qDebug("KO::CalendarView::insertBirthdays"); |
1429 | if (uid == this->name()) | 1429 | if (uid == this->name()) |
1430 | { | 1430 | { |
1431 | int count = birthdayList.count(); | 1431 | int count = birthdayList.count(); |
1432 | int addCount = 0; | 1432 | int addCount = 0; |
1433 | KCal::Attendee* a = 0; | 1433 | KCal::Attendee* a = 0; |
1434 | 1434 | ||
1435 | //qDebug("CalView 1 %i", count); | 1435 | //qDebug("CalView 1 %i", count); |
1436 | 1436 | ||
1437 | QProgressBar bar(count,0 ); | 1437 | QProgressBar bar(count,0 ); |
1438 | int w = 300; | 1438 | int w = 300; |
1439 | if ( QApplication::desktop()->width() < 320 ) | 1439 | if ( QApplication::desktop()->width() < 320 ) |
1440 | w = 220; | 1440 | w = 220; |
1441 | int h = bar.sizeHint().height() ; | 1441 | int h = bar.sizeHint().height() ; |
1442 | int dw = QApplication::desktop()->width(); | 1442 | int dw = QApplication::desktop()->width(); |
1443 | int dh = QApplication::desktop()->height(); | 1443 | int dh = QApplication::desktop()->height(); |
1444 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1444 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1445 | bar.show(); | 1445 | bar.show(); |
1446 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); | 1446 | bar.setCaption (i18n("inserting birthdays - close to abort!") ); |
1447 | qApp->processEvents(); | 1447 | qApp->processEvents(); |
1448 | 1448 | ||
1449 | QDate birthday; | 1449 | QDate birthday; |
1450 | QDate anniversary; | 1450 | QDate anniversary; |
1451 | QString realName; | 1451 | QString realName; |
1452 | QString email; | 1452 | QString email; |
1453 | QString assembledName; | 1453 | QString assembledName; |
1454 | QString uid; | 1454 | QString uid; |
1455 | bool ok = true; | 1455 | bool ok = true; |
1456 | for ( int i = 0; i < count; i++) | 1456 | for ( int i = 0; i < count; i++) |
1457 | { | 1457 | { |
1458 | if ( ! bar.isVisible() ) | 1458 | if ( ! bar.isVisible() ) |
1459 | return; | 1459 | return; |
1460 | bar.setProgress( i ); | 1460 | bar.setProgress( i ); |
1461 | qApp->processEvents(); | 1461 | qApp->processEvents(); |
1462 | 1462 | ||
1463 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); | 1463 | birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); |
1464 | if (!ok) { | 1464 | if (!ok) { |
1465 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); | 1465 | ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); |
1466 | } | 1466 | } |
1467 | 1467 | ||
1468 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); | 1468 | anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); |
1469 | if (!ok) { | 1469 | if (!ok) { |
1470 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); | 1470 | ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); |
1471 | } | 1471 | } |
1472 | realName = realNameList[i]; | 1472 | realName = realNameList[i]; |
1473 | email = emailList[i]; | 1473 | email = emailList[i]; |
1474 | assembledName = assembledNameList[i]; | 1474 | assembledName = assembledNameList[i]; |
1475 | uid = uidList[i]; | 1475 | uid = uidList[i]; |
1476 | //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() ); | 1476 | //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() ); |
1477 | 1477 | ||
1478 | if ( birthday.isValid() ){ | 1478 | if ( birthday.isValid() ){ |
1479 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1479 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1480 | KCal::Attendee::ReqParticipant,uid) ; | 1480 | KCal::Attendee::ReqParticipant,uid) ; |
1481 | if ( addAnniversary( birthday, assembledName, a, true ) ) | 1481 | if ( addAnniversary( birthday, assembledName, a, true ) ) |
1482 | ++addCount; | 1482 | ++addCount; |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | if ( anniversary.isValid() ){ | 1485 | if ( anniversary.isValid() ){ |
1486 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, | 1486 | a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, |
1487 | KCal::Attendee::ReqParticipant,uid) ; | 1487 | KCal::Attendee::ReqParticipant,uid) ; |
1488 | if ( addAnniversary( anniversary, assembledName, a, false ) ) | 1488 | if ( addAnniversary( anniversary, assembledName, a, false ) ) |
1489 | ++addCount; | 1489 | ++addCount; |
1490 | } | 1490 | } |
1491 | } | 1491 | } |
1492 | 1492 | ||
1493 | updateView(); | 1493 | updateView(); |
1494 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1494 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1495 | 1495 | ||
1496 | } | 1496 | } |
1497 | 1497 | ||
1498 | } | 1498 | } |
1499 | 1499 | ||
1500 | 1500 | ||
1501 | 1501 | ||
1502 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1502 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1503 | { | 1503 | { |
1504 | //qDebug("addAnni "); | 1504 | //qDebug("addAnni "); |
1505 | Event * ev = new Event(); | 1505 | Event * ev = new Event(); |
1506 | ev->setOrganizer(KOPrefs::instance()->email()); | 1506 | ev->setOrganizer(KOPrefs::instance()->email()); |
1507 | if ( a ) { | 1507 | if ( a ) { |
1508 | ev->addAttendee( a ); | 1508 | ev->addAttendee( a ); |
1509 | } | 1509 | } |
1510 | QString kind; | 1510 | QString kind; |
1511 | if ( birthday ) { | 1511 | if ( birthday ) { |
1512 | kind = i18n( "Birthday" ); | 1512 | kind = i18n( "Birthday" ); |
1513 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); | 1513 | ev->setSummary( name + " (" + QString::number(date.year()) +")"); |
1514 | } | 1514 | } |
1515 | else { | 1515 | else { |
1516 | kind = i18n( "Anniversary" ); | 1516 | kind = i18n( "Anniversary" ); |
1517 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1517 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1518 | } | 1518 | } |
1519 | ev->setCategories( kind ); | 1519 | ev->setCategories( kind ); |
1520 | ev->setDtStart( QDateTime(date) ); | 1520 | ev->setDtStart( QDateTime(date) ); |
1521 | ev->setDtEnd( QDateTime(date) ); | 1521 | ev->setDtEnd( QDateTime(date) ); |
1522 | ev->setFloats( true ); | 1522 | ev->setFloats( true ); |
1523 | Recurrence * rec = ev->recurrence(); | 1523 | Recurrence * rec = ev->recurrence(); |
1524 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1524 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1525 | rec->addYearlyNum( date.month() ); | 1525 | rec->addYearlyNum( date.month() ); |
1526 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1526 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1527 | delete ev; | 1527 | delete ev; |
1528 | return false; | 1528 | return false; |
1529 | } | 1529 | } |
1530 | return true; | 1530 | return true; |
1531 | 1531 | ||
1532 | } | 1532 | } |
1533 | bool CalendarView::importQtopia( const QString &categories, | 1533 | bool CalendarView::importQtopia( const QString &categories, |
1534 | const QString &datebook, | 1534 | const QString &datebook, |
1535 | const QString &todolist ) | 1535 | const QString &todolist ) |
1536 | { | 1536 | { |
1537 | 1537 | ||
1538 | QtopiaFormat qtopiaFormat; | 1538 | QtopiaFormat qtopiaFormat; |
1539 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1539 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1540 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1540 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1541 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1541 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1542 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1542 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1543 | 1543 | ||
1544 | updateView(); | 1544 | updateView(); |
1545 | return true; | 1545 | return true; |
1546 | 1546 | ||
1547 | #if 0 | 1547 | #if 0 |
1548 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1548 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1549 | mCurrentSyncDevice = "qtopia-XML"; | 1549 | mCurrentSyncDevice = "qtopia-XML"; |
1550 | if ( mSyncManager->mAskForPreferences ) | 1550 | if ( mSyncManager->mAskForPreferences ) |
1551 | edit_sync_options(); | 1551 | edit_sync_options(); |
1552 | qApp->processEvents(); | 1552 | qApp->processEvents(); |
1553 | CalendarLocal* calendar = new CalendarLocal(); | 1553 | CalendarLocal* calendar = new CalendarLocal(); |
1554 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1554 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1555 | bool syncOK = false; | 1555 | bool syncOK = false; |
1556 | QtopiaFormat qtopiaFormat; | 1556 | QtopiaFormat qtopiaFormat; |
1557 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1557 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1558 | bool loadOk = true; | 1558 | bool loadOk = true; |
1559 | if ( !categories.isEmpty() ) | 1559 | if ( !categories.isEmpty() ) |
1560 | loadOk = qtopiaFormat.load( calendar, categories ); | 1560 | loadOk = qtopiaFormat.load( calendar, categories ); |
1561 | if ( loadOk && !datebook.isEmpty() ) | 1561 | if ( loadOk && !datebook.isEmpty() ) |
1562 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1562 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1563 | if ( loadOk && !todolist.isEmpty() ) | 1563 | if ( loadOk && !todolist.isEmpty() ) |
1564 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1564 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1565 | 1565 | ||
1566 | if ( loadOk ) { | 1566 | if ( loadOk ) { |
1567 | getEventViewerDialog()->setSyncMode( true ); | 1567 | getEventViewerDialog()->setSyncMode( true ); |
1568 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1568 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1569 | getEventViewerDialog()->setSyncMode( false ); | 1569 | getEventViewerDialog()->setSyncMode( false ); |
1570 | qApp->processEvents(); | 1570 | qApp->processEvents(); |
1571 | if ( syncOK ) { | 1571 | if ( syncOK ) { |
1572 | if ( mSyncManager->mWriteBackFile ) | 1572 | if ( mSyncManager->mWriteBackFile ) |
1573 | { | 1573 | { |
1574 | // write back XML file | 1574 | // write back XML file |
1575 | 1575 | ||
1576 | } | 1576 | } |
1577 | setModified( true ); | 1577 | setModified( true ); |
1578 | } | 1578 | } |
1579 | } else { | 1579 | } else { |
1580 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1580 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1581 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1581 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1582 | question, i18n("Ok")) ; | 1582 | question, i18n("Ok")) ; |
1583 | } | 1583 | } |
1584 | delete calendar; | 1584 | delete calendar; |
1585 | updateView(); | 1585 | updateView(); |
1586 | return syncOK; | 1586 | return syncOK; |
1587 | 1587 | ||
1588 | 1588 | ||
1589 | #endif | 1589 | #endif |
1590 | 1590 | ||
1591 | } | 1591 | } |
1592 | 1592 | ||
1593 | void CalendarView::setSyncEventsReadOnly() | 1593 | void CalendarView::setSyncEventsReadOnly() |
1594 | { | 1594 | { |
1595 | Event * ev; | 1595 | Event * ev; |
1596 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1596 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1597 | ev = eL.first(); | 1597 | ev = eL.first(); |
1598 | while ( ev ) { | 1598 | while ( ev ) { |
1599 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 1599 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
1600 | ev->setReadOnly( true ); | 1600 | ev->setReadOnly( true ); |
1601 | ev = eL.next(); | 1601 | ev = eL.next(); |
1602 | } | 1602 | } |
1603 | } | 1603 | } |
1604 | bool CalendarView::openCalendar(QString filename, bool merge) | 1604 | bool CalendarView::openCalendar(QString filename, bool merge) |
1605 | { | 1605 | { |
1606 | 1606 | ||
1607 | if (filename.isEmpty()) { | 1607 | if (filename.isEmpty()) { |
1608 | return false; | 1608 | return false; |
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | if (!QFile::exists(filename)) { | 1611 | if (!QFile::exists(filename)) { |
1612 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1612 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1613 | return false; | 1613 | return false; |
1614 | } | 1614 | } |
1615 | 1615 | ||
1616 | globalFlagBlockAgenda = 1; | 1616 | globalFlagBlockAgenda = 1; |
1617 | if (!merge) mCalendar->close(); | 1617 | if (!merge) mCalendar->close(); |
1618 | 1618 | ||
1619 | mStorage->setFileName( filename ); | 1619 | mStorage->setFileName( filename ); |
1620 | 1620 | ||
1621 | if ( mStorage->load() ) { | 1621 | if ( mStorage->load() ) { |
1622 | if ( merge ) ;//setModified( true ); | 1622 | if ( merge ) ;//setModified( true ); |
1623 | else { | 1623 | else { |
1624 | //setModified( true ); | 1624 | //setModified( true ); |
1625 | mViewManager->setDocumentId( filename ); | 1625 | mViewManager->setDocumentId( filename ); |
1626 | mDialogManager->setDocumentId( filename ); | 1626 | mDialogManager->setDocumentId( filename ); |
1627 | mTodoList->setDocumentId( filename ); | 1627 | mTodoList->setDocumentId( filename ); |
1628 | } | 1628 | } |
1629 | globalFlagBlockAgenda = 2; | 1629 | globalFlagBlockAgenda = 2; |
1630 | // if ( getLastSyncEvent() ) | 1630 | // if ( getLastSyncEvent() ) |
1631 | // getLastSyncEvent()->setReadOnly( true ); | 1631 | // getLastSyncEvent()->setReadOnly( true ); |
1632 | mCalendar->reInitAlarmSettings(); | 1632 | mCalendar->reInitAlarmSettings(); |
1633 | setSyncEventsReadOnly(); | 1633 | setSyncEventsReadOnly(); |
1634 | updateUnmanagedViews(); | 1634 | updateUnmanagedViews(); |
1635 | updateView(); | 1635 | updateView(); |
1636 | if ( filename != MainWindow::defaultFileName() ) { | 1636 | if ( filename != MainWindow::defaultFileName() ) { |
1637 | saveCalendar( MainWindow::defaultFileName() ); | 1637 | saveCalendar( MainWindow::defaultFileName() ); |
1638 | } else { | 1638 | } else { |
1639 | QFileInfo finf ( MainWindow::defaultFileName()); | 1639 | QFileInfo finf ( MainWindow::defaultFileName()); |
1640 | if ( finf.exists() ) { | 1640 | if ( finf.exists() ) { |
1641 | setLoadedFileVersion( finf.lastModified () ); | 1641 | setLoadedFileVersion( finf.lastModified () ); |
1642 | } | 1642 | } |
1643 | } | 1643 | } |
1644 | return true; | 1644 | return true; |
1645 | } else { | 1645 | } else { |
1646 | // while failing to load, the calendar object could | 1646 | // while failing to load, the calendar object could |
1647 | // have become partially populated. Clear it out. | 1647 | // have become partially populated. Clear it out. |
1648 | if ( !merge ) { | 1648 | if ( !merge ) { |
1649 | mCalendar->close(); | 1649 | mCalendar->close(); |
1650 | mViewManager->setDocumentId( filename ); | 1650 | mViewManager->setDocumentId( filename ); |
1651 | mDialogManager->setDocumentId( filename ); | 1651 | mDialogManager->setDocumentId( filename ); |
1652 | mTodoList->setDocumentId( filename ); | 1652 | mTodoList->setDocumentId( filename ); |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1655 | //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1656 | 1656 | ||
1657 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); | 1657 | QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); |
1658 | globalFlagBlockAgenda = 2; | 1658 | globalFlagBlockAgenda = 2; |
1659 | mCalendar->reInitAlarmSettings(); | 1659 | mCalendar->reInitAlarmSettings(); |
1660 | setSyncEventsReadOnly(); | 1660 | setSyncEventsReadOnly(); |
1661 | updateUnmanagedViews(); | 1661 | updateUnmanagedViews(); |
1662 | updateView(); | 1662 | updateView(); |
1663 | } | 1663 | } |
1664 | return false; | 1664 | return false; |
1665 | } | 1665 | } |
1666 | void CalendarView::showOpenError() | 1666 | void CalendarView::showOpenError() |
1667 | { | 1667 | { |
1668 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 1668 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
1669 | } | 1669 | } |
1670 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1670 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1671 | { | 1671 | { |
1672 | loadedFileVersion = dt; | 1672 | loadedFileVersion = dt; |
1673 | } | 1673 | } |
1674 | bool CalendarView::checkFileChanged(QString fn) | 1674 | bool CalendarView::checkFileChanged(QString fn) |
1675 | { | 1675 | { |
1676 | QFileInfo finf ( fn ); | 1676 | QFileInfo finf ( fn ); |
1677 | if ( !finf.exists() ) | 1677 | if ( !finf.exists() ) |
1678 | return true; | 1678 | return true; |
1679 | QDateTime dt = finf.lastModified (); | 1679 | QDateTime dt = finf.lastModified (); |
1680 | if ( dt <= loadedFileVersion ) | 1680 | if ( dt <= loadedFileVersion ) |
1681 | return false; | 1681 | return false; |
1682 | return true; | 1682 | return true; |
1683 | 1683 | ||
1684 | } | 1684 | } |
1685 | void CalendarView::watchSavedFile() | 1685 | void CalendarView::watchSavedFile() |
1686 | { | 1686 | { |
1687 | QFileInfo finf ( MainWindow::defaultFileName()); | 1687 | QFileInfo finf ( MainWindow::defaultFileName()); |
1688 | if ( !finf.exists() ) | 1688 | if ( !finf.exists() ) |
1689 | return; | 1689 | return; |
1690 | QDateTime dt = finf.lastModified (); | 1690 | QDateTime dt = finf.lastModified (); |
1691 | if ( dt < loadedFileVersion ) { | 1691 | if ( dt < loadedFileVersion ) { |
1692 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); | 1692 | //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); |
1693 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); | 1693 | QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); |
1694 | return; | 1694 | return; |
1695 | } | 1695 | } |
1696 | loadedFileVersion = dt; | 1696 | loadedFileVersion = dt; |
1697 | } | 1697 | } |
1698 | 1698 | ||
1699 | bool CalendarView::checkFileVersion(QString fn) | 1699 | bool CalendarView::checkFileVersion(QString fn) |
1700 | { | 1700 | { |
1701 | QFileInfo finf ( fn ); | 1701 | QFileInfo finf ( fn ); |
1702 | if ( !finf.exists() ) | 1702 | if ( !finf.exists() ) |
1703 | return true; | 1703 | return true; |
1704 | QDateTime dt = finf.lastModified (); | 1704 | QDateTime dt = finf.lastModified (); |
1705 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1705 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1706 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1706 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1707 | if ( dt <= loadedFileVersion ) | 1707 | if ( dt <= loadedFileVersion ) |
1708 | return true; | 1708 | return true; |
1709 | 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)) , | 1709 | 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)) , |
1710 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1710 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1711 | i18n("Sync+save")); | 1711 | i18n("Sync+save")); |
1712 | 1712 | ||
1713 | if ( km == KMessageBox::Cancel ) | 1713 | if ( km == KMessageBox::Cancel ) |
1714 | return false; | 1714 | return false; |
1715 | if ( km == KMessageBox::Yes ) | 1715 | if ( km == KMessageBox::Yes ) |
1716 | return true; | 1716 | return true; |
1717 | 1717 | ||
1718 | setSyncDevice("deleteaftersync" ); | 1718 | setSyncDevice("deleteaftersync" ); |
1719 | mSyncManager->mAskForPreferences = true; | 1719 | mSyncManager->mAskForPreferences = true; |
1720 | mSyncManager->mSyncAlgoPrefs = 3; | 1720 | mSyncManager->mSyncAlgoPrefs = 3; |
1721 | mSyncManager->mWriteBackFile = false; | 1721 | mSyncManager->mWriteBackFile = false; |
1722 | mSyncManager->mWriteBackExistingOnly = false; | 1722 | mSyncManager->mWriteBackExistingOnly = false; |
1723 | mSyncManager->mShowSyncSummary = false; | 1723 | mSyncManager->mShowSyncSummary = false; |
1724 | syncCalendar( fn, 3 ); | 1724 | syncCalendar( fn, 3 ); |
1725 | Event * e = getLastSyncEvent(); | 1725 | Event * e = getLastSyncEvent(); |
1726 | mCalendar->deleteEvent ( e ); | 1726 | mCalendar->deleteEvent ( e ); |
1727 | updateView(); | 1727 | updateView(); |
1728 | return true; | 1728 | return true; |
1729 | } | 1729 | } |
1730 | 1730 | ||
1731 | bool CalendarView::saveCalendar( QString filename ) | 1731 | bool CalendarView::saveCalendar( QString filename ) |
1732 | { | 1732 | { |
1733 | 1733 | ||
1734 | // Store back all unsaved data into calendar object | 1734 | // Store back all unsaved data into calendar object |
1735 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1735 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1736 | if ( mViewManager->currentView() ) | 1736 | if ( mViewManager->currentView() ) |
1737 | mViewManager->currentView()->flushView(); | 1737 | mViewManager->currentView()->flushView(); |
1738 | 1738 | ||
1739 | 1739 | ||
1740 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); | 1740 | QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); |
1741 | mStorage->setSaveFormat( new ICalFormat() ); | 1741 | mStorage->setSaveFormat( new ICalFormat() ); |
1742 | mStorage->setFileName( filename ); | 1742 | mStorage->setFileName( filename ); |
1743 | bool success; | 1743 | bool success; |
1744 | success = mStorage->save(); | 1744 | success = mStorage->save(); |
1745 | if ( !success ) { | 1745 | if ( !success ) { |
1746 | return false; | 1746 | return false; |
1747 | } | 1747 | } |
1748 | if ( filename == MainWindow::defaultFileName() ) { | 1748 | if ( filename == MainWindow::defaultFileName() ) { |
1749 | setLoadedFileVersion( lfv ); | 1749 | setLoadedFileVersion( lfv ); |
1750 | watchSavedFile(); | 1750 | watchSavedFile(); |
1751 | } | 1751 | } |
1752 | return true; | 1752 | return true; |
1753 | } | 1753 | } |
1754 | 1754 | ||
1755 | void CalendarView::closeCalendar() | 1755 | void CalendarView::closeCalendar() |
1756 | { | 1756 | { |
1757 | 1757 | ||
1758 | // child windows no longer valid | 1758 | // child windows no longer valid |
1759 | emit closingDown(); | 1759 | emit closingDown(); |
1760 | 1760 | ||
1761 | mCalendar->close(); | 1761 | mCalendar->close(); |
1762 | setModified(false); | 1762 | setModified(false); |
1763 | updateView(); | 1763 | updateView(); |
1764 | } | 1764 | } |
1765 | 1765 | ||
1766 | void CalendarView::archiveCalendar() | 1766 | void CalendarView::archiveCalendar() |
1767 | { | 1767 | { |
1768 | mDialogManager->showArchiveDialog(); | 1768 | mDialogManager->showArchiveDialog(); |
1769 | } | 1769 | } |
1770 | 1770 | ||
1771 | 1771 | ||
1772 | void CalendarView::readSettings() | 1772 | void CalendarView::readSettings() |
1773 | { | 1773 | { |
1774 | 1774 | ||
1775 | 1775 | ||
1776 | // mViewManager->showAgendaView(); | 1776 | // mViewManager->showAgendaView(); |
1777 | QString str; | 1777 | QString str; |
1778 | //qDebug("CalendarView::readSettings() "); | 1778 | //qDebug("CalendarView::readSettings() "); |
1779 | // read settings from the KConfig, supplying reasonable | 1779 | // read settings from the KConfig, supplying reasonable |
1780 | // defaults where none are to be found | 1780 | // defaults where none are to be found |
1781 | KConfig *config = KOGlobals::config(); | 1781 | KConfig *config = KOGlobals::config(); |
1782 | #ifndef KORG_NOSPLITTER | 1782 | #ifndef KORG_NOSPLITTER |
1783 | config->setGroup("KOrganizer Geometry"); | 1783 | config->setGroup("KOrganizer Geometry"); |
1784 | 1784 | ||
1785 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1785 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1786 | if (sizes.count() != 2) { | 1786 | if (sizes.count() != 2) { |
1787 | sizes << mDateNavigator->minimumSizeHint().width(); | 1787 | sizes << mDateNavigator->minimumSizeHint().width(); |
1788 | sizes << 300; | 1788 | sizes << 300; |
1789 | } | 1789 | } |
1790 | mPanner->setSizes(sizes); | 1790 | mPanner->setSizes(sizes); |
1791 | 1791 | ||
1792 | sizes = config->readIntListEntry("Separator2"); | 1792 | sizes = config->readIntListEntry("Separator2"); |
1793 | if ( ( mResourceView && sizes.count() == 4 ) || | 1793 | if ( ( mResourceView && sizes.count() == 4 ) || |
1794 | ( !mResourceView && sizes.count() == 3 ) ) { | 1794 | ( !mResourceView && sizes.count() == 3 ) ) { |
1795 | mLeftSplitter->setSizes(sizes); | 1795 | mLeftSplitter->setSizes(sizes); |
1796 | } | 1796 | } |
1797 | #endif | 1797 | #endif |
1798 | globalFlagBlockAgenda = 1; | 1798 | globalFlagBlockAgenda = 1; |
1799 | mViewManager->showAgendaView(); | 1799 | mViewManager->showAgendaView(); |
1800 | //mViewManager->readSettings( config ); | 1800 | //mViewManager->readSettings( config ); |
1801 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1801 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1802 | readFilterSettings(config); | 1802 | readFilterSettings(config); |
1803 | config->setGroup( "Views" ); | 1803 | config->setGroup( "Views" ); |
1804 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1804 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1805 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1805 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1806 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1806 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1807 | else mNavigator->selectDates( dateCount ); | 1807 | else mNavigator->selectDates( dateCount ); |
1808 | // mViewManager->readSettings( config ); | 1808 | // mViewManager->readSettings( config ); |
1809 | updateConfig(); | 1809 | updateConfig(); |
1810 | globalFlagBlockAgenda = 2; | 1810 | globalFlagBlockAgenda = 2; |
1811 | mViewManager->readSettings( config ); | 1811 | mViewManager->readSettings( config ); |
1812 | #ifdef DESKTOP_VERSION | 1812 | #ifdef DESKTOP_VERSION |
1813 | config->setGroup("WidgetLayout"); | 1813 | config->setGroup("WidgetLayout"); |
1814 | QStringList list; | 1814 | QStringList list; |
1815 | list = config->readListEntry("MainLayout"); | 1815 | list = config->readListEntry("MainLayout"); |
1816 | int x,y,w,h; | 1816 | int x,y,w,h; |
1817 | if ( ! list.isEmpty() ) { | 1817 | if ( ! list.isEmpty() ) { |
1818 | x = list[0].toInt(); | 1818 | x = list[0].toInt(); |
1819 | y = list[1].toInt(); | 1819 | y = list[1].toInt(); |
1820 | w = list[2].toInt(); | 1820 | w = list[2].toInt(); |
1821 | h = list[3].toInt(); | 1821 | h = list[3].toInt(); |
1822 | topLevelWidget()->setGeometry(x,y,w,h); | 1822 | topLevelWidget()->setGeometry(x,y,w,h); |
1823 | 1823 | ||
1824 | } else { | 1824 | } else { |
1825 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1825 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1826 | } | 1826 | } |
1827 | list = config->readListEntry("EditEventLayout"); | 1827 | list = config->readListEntry("EditEventLayout"); |
1828 | if ( ! list.isEmpty() ) { | 1828 | if ( ! list.isEmpty() ) { |
1829 | x = list[0].toInt(); | 1829 | x = list[0].toInt(); |
1830 | y = list[1].toInt(); | 1830 | y = list[1].toInt(); |
1831 | w = list[2].toInt(); | 1831 | w = list[2].toInt(); |
1832 | h = list[3].toInt(); | 1832 | h = list[3].toInt(); |
1833 | mEventEditor->setGeometry(x,y,w,h); | 1833 | mEventEditor->setGeometry(x,y,w,h); |
1834 | 1834 | ||
1835 | } | 1835 | } |
1836 | list = config->readListEntry("EditTodoLayout"); | 1836 | list = config->readListEntry("EditTodoLayout"); |
1837 | if ( ! list.isEmpty() ) { | 1837 | if ( ! list.isEmpty() ) { |
1838 | x = list[0].toInt(); | 1838 | x = list[0].toInt(); |
1839 | y = list[1].toInt(); | 1839 | y = list[1].toInt(); |
1840 | w = list[2].toInt(); | 1840 | w = list[2].toInt(); |
1841 | h = list[3].toInt(); | 1841 | h = list[3].toInt(); |
1842 | mTodoEditor->setGeometry(x,y,w,h); | 1842 | mTodoEditor->setGeometry(x,y,w,h); |
1843 | 1843 | ||
1844 | } | 1844 | } |
1845 | list = config->readListEntry("ViewerLayout"); | 1845 | list = config->readListEntry("ViewerLayout"); |
1846 | if ( ! list.isEmpty() ) { | 1846 | if ( ! list.isEmpty() ) { |
1847 | x = list[0].toInt(); | 1847 | x = list[0].toInt(); |
1848 | y = list[1].toInt(); | 1848 | y = list[1].toInt(); |
1849 | w = list[2].toInt(); | 1849 | w = list[2].toInt(); |
1850 | h = list[3].toInt(); | 1850 | h = list[3].toInt(); |
1851 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1851 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1852 | } | 1852 | } |
1853 | #endif | 1853 | #endif |
1854 | 1854 | ||
1855 | } | 1855 | } |
1856 | 1856 | ||
1857 | 1857 | ||
1858 | void CalendarView::writeSettings() | 1858 | void CalendarView::writeSettings() |
1859 | { | 1859 | { |
1860 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1860 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1861 | 1861 | ||
1862 | KConfig *config = KOGlobals::config(); | 1862 | KConfig *config = KOGlobals::config(); |
1863 | 1863 | ||
1864 | #ifndef KORG_NOSPLITTER | 1864 | #ifndef KORG_NOSPLITTER |
1865 | config->setGroup("KOrganizer Geometry"); | 1865 | config->setGroup("KOrganizer Geometry"); |
1866 | 1866 | ||
1867 | QValueList<int> list = mPanner->sizes(); | 1867 | QValueList<int> list = mPanner->sizes(); |
1868 | config->writeEntry("Separator1",list); | 1868 | config->writeEntry("Separator1",list); |
1869 | 1869 | ||
1870 | list = mLeftSplitter->sizes(); | 1870 | list = mLeftSplitter->sizes(); |
1871 | config->writeEntry("Separator2",list); | 1871 | config->writeEntry("Separator2",list); |
1872 | #endif | 1872 | #endif |
1873 | 1873 | ||
1874 | mViewManager->writeSettings( config ); | 1874 | mViewManager->writeSettings( config ); |
1875 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1875 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1876 | mDialogManager->writeSettings( config ); | 1876 | mDialogManager->writeSettings( config ); |
1877 | //KOPrefs::instance()->usrWriteConfig(); | 1877 | //KOPrefs::instance()->usrWriteConfig(); |
1878 | KOPrefs::instance()->writeConfig(); | 1878 | KOPrefs::instance()->writeConfig(); |
1879 | 1879 | ||
1880 | writeFilterSettings(config); | 1880 | writeFilterSettings(config); |
1881 | 1881 | ||
1882 | config->setGroup( "Views" ); | 1882 | config->setGroup( "Views" ); |
1883 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1883 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1884 | 1884 | ||
1885 | #ifdef DESKTOP_VERSION | 1885 | #ifdef DESKTOP_VERSION |
1886 | config->setGroup("WidgetLayout"); | 1886 | config->setGroup("WidgetLayout"); |
1887 | QStringList list ;//= config->readListEntry("MainLayout"); | 1887 | QStringList list ;//= config->readListEntry("MainLayout"); |
1888 | int x,y,w,h; | 1888 | int x,y,w,h; |
1889 | QWidget* wid; | 1889 | QWidget* wid; |
1890 | wid = topLevelWidget(); | 1890 | wid = topLevelWidget(); |
1891 | x = wid->geometry().x(); | 1891 | x = wid->geometry().x(); |
1892 | y = wid->geometry().y(); | 1892 | y = wid->geometry().y(); |
1893 | w = wid->width(); | 1893 | w = wid->width(); |
1894 | h = wid->height(); | 1894 | h = wid->height(); |
1895 | list.clear(); | 1895 | list.clear(); |
1896 | list << QString::number( x ); | 1896 | list << QString::number( x ); |
1897 | list << QString::number( y ); | 1897 | list << QString::number( y ); |
1898 | list << QString::number( w ); | 1898 | list << QString::number( w ); |
1899 | list << QString::number( h ); | 1899 | list << QString::number( h ); |
1900 | config->writeEntry("MainLayout",list ); | 1900 | config->writeEntry("MainLayout",list ); |
1901 | 1901 | ||
1902 | wid = mEventEditor; | 1902 | wid = mEventEditor; |
1903 | x = wid->geometry().x(); | 1903 | x = wid->geometry().x(); |
1904 | y = wid->geometry().y(); | 1904 | y = wid->geometry().y(); |
1905 | w = wid->width(); | 1905 | w = wid->width(); |
1906 | h = wid->height(); | 1906 | h = wid->height(); |
1907 | list.clear(); | 1907 | list.clear(); |
1908 | list << QString::number( x ); | 1908 | list << QString::number( x ); |
1909 | list << QString::number( y ); | 1909 | list << QString::number( y ); |
1910 | list << QString::number( w ); | 1910 | list << QString::number( w ); |
1911 | list << QString::number( h ); | 1911 | list << QString::number( h ); |
1912 | config->writeEntry("EditEventLayout",list ); | 1912 | config->writeEntry("EditEventLayout",list ); |
1913 | 1913 | ||
1914 | wid = mTodoEditor; | 1914 | wid = mTodoEditor; |
1915 | x = wid->geometry().x(); | 1915 | x = wid->geometry().x(); |
1916 | y = wid->geometry().y(); | 1916 | y = wid->geometry().y(); |
1917 | w = wid->width(); | 1917 | w = wid->width(); |
1918 | h = wid->height(); | 1918 | h = wid->height(); |
1919 | list.clear(); | 1919 | list.clear(); |
1920 | list << QString::number( x ); | 1920 | list << QString::number( x ); |
1921 | list << QString::number( y ); | 1921 | list << QString::number( y ); |
1922 | list << QString::number( w ); | 1922 | list << QString::number( w ); |
1923 | list << QString::number( h ); | 1923 | list << QString::number( h ); |
1924 | config->writeEntry("EditTodoLayout",list ); | 1924 | config->writeEntry("EditTodoLayout",list ); |
1925 | wid = getEventViewerDialog(); | 1925 | wid = getEventViewerDialog(); |
1926 | x = wid->geometry().x(); | 1926 | x = wid->geometry().x(); |
1927 | y = wid->geometry().y(); | 1927 | y = wid->geometry().y(); |
1928 | w = wid->width(); | 1928 | w = wid->width(); |
1929 | h = wid->height(); | 1929 | h = wid->height(); |
1930 | list.clear(); | 1930 | list.clear(); |
1931 | list << QString::number( x ); | 1931 | list << QString::number( x ); |
1932 | list << QString::number( y ); | 1932 | list << QString::number( y ); |
1933 | list << QString::number( w ); | 1933 | list << QString::number( w ); |
1934 | list << QString::number( h ); | 1934 | list << QString::number( h ); |
1935 | config->writeEntry("ViewerLayout",list ); | 1935 | config->writeEntry("ViewerLayout",list ); |
1936 | wid = mDialogManager->getSearchDialog(); | 1936 | wid = mDialogManager->getSearchDialog(); |
1937 | if ( wid ) { | 1937 | if ( wid ) { |
1938 | x = wid->geometry().x(); | 1938 | x = wid->geometry().x(); |
1939 | y = wid->geometry().y(); | 1939 | y = wid->geometry().y(); |
1940 | w = wid->width(); | 1940 | w = wid->width(); |
1941 | h = wid->height(); | 1941 | h = wid->height(); |
1942 | list.clear(); | 1942 | list.clear(); |
1943 | list << QString::number( x ); | 1943 | list << QString::number( x ); |
1944 | list << QString::number( y ); | 1944 | list << QString::number( y ); |
1945 | list << QString::number( w ); | 1945 | list << QString::number( w ); |
1946 | list << QString::number( h ); | 1946 | list << QString::number( h ); |
1947 | config->writeEntry("SearchLayout",list ); | 1947 | config->writeEntry("SearchLayout",list ); |
1948 | } | 1948 | } |
1949 | #endif | 1949 | #endif |
1950 | 1950 | ||
1951 | 1951 | ||
1952 | config->sync(); | 1952 | config->sync(); |
1953 | } | 1953 | } |
1954 | 1954 | ||
1955 | void CalendarView::readFilterSettings(KConfig *config) | 1955 | void CalendarView::readFilterSettings(KConfig *config) |
1956 | { | 1956 | { |
1957 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1957 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1958 | 1958 | ||
1959 | mFilters.clear(); | 1959 | mFilters.clear(); |
1960 | 1960 | ||
1961 | config->setGroup("General"); | 1961 | config->setGroup("General"); |
1962 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1962 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1963 | 1963 | ||
1964 | QStringList::ConstIterator it = filterList.begin(); | 1964 | QStringList::ConstIterator it = filterList.begin(); |
1965 | QStringList::ConstIterator end = filterList.end(); | 1965 | QStringList::ConstIterator end = filterList.end(); |
1966 | while(it != end) { | 1966 | while(it != end) { |
1967 | // kdDebug() << " filter: " << (*it) << endl; | 1967 | // kdDebug() << " filter: " << (*it) << endl; |
1968 | 1968 | ||
1969 | CalFilter *filter; | 1969 | CalFilter *filter; |
1970 | filter = new CalFilter(*it); | 1970 | filter = new CalFilter(*it); |
1971 | config->setGroup("Filter_" + (*it)); | 1971 | config->setGroup("Filter_" + (*it)); |
1972 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1972 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1973 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1973 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1974 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1974 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1975 | mFilters.append(filter); | 1975 | mFilters.append(filter); |
1976 | 1976 | ||
1977 | ++it; | 1977 | ++it; |
1978 | } | 1978 | } |
1979 | 1979 | ||
1980 | if (mFilters.count() == 0) { | 1980 | if (mFilters.count() == 0) { |
1981 | CalFilter *filter = new CalFilter(i18n("Default")); | 1981 | CalFilter *filter = new CalFilter(i18n("Default")); |
1982 | mFilters.append(filter); | 1982 | mFilters.append(filter); |
1983 | } | 1983 | } |
1984 | mFilterView->updateFilters(); | 1984 | mFilterView->updateFilters(); |
1985 | config->setGroup("FilterView"); | 1985 | config->setGroup("FilterView"); |
1986 | 1986 | ||
1987 | mFilterView->blockSignals(true); | 1987 | mFilterView->blockSignals(true); |
1988 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1988 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1989 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1989 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1990 | mFilterView->blockSignals(false); | 1990 | mFilterView->blockSignals(false); |
1991 | // We do it manually to avoid it being done twice by the above calls | 1991 | // We do it manually to avoid it being done twice by the above calls |
1992 | updateFilter(); | 1992 | updateFilter(); |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | void CalendarView::writeFilterSettings(KConfig *config) | 1995 | void CalendarView::writeFilterSettings(KConfig *config) |
1996 | { | 1996 | { |
1997 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1997 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1998 | 1998 | ||
1999 | QStringList filterList; | 1999 | QStringList filterList; |
2000 | 2000 | ||
2001 | CalFilter *filter = mFilters.first(); | 2001 | CalFilter *filter = mFilters.first(); |
2002 | while(filter) { | 2002 | while(filter) { |
2003 | // kdDebug() << " fn: " << filter->name() << endl; | 2003 | // kdDebug() << " fn: " << filter->name() << endl; |
2004 | filterList << filter->name(); | 2004 | filterList << filter->name(); |
2005 | config->setGroup("Filter_" + filter->name()); | 2005 | config->setGroup("Filter_" + filter->name()); |
2006 | config->writeEntry("Criteria",filter->criteria()); | 2006 | config->writeEntry("Criteria",filter->criteria()); |
2007 | config->writeEntry("CategoryList",filter->categoryList()); | 2007 | config->writeEntry("CategoryList",filter->categoryList()); |
2008 | filter = mFilters.next(); | 2008 | filter = mFilters.next(); |
2009 | } | 2009 | } |
2010 | config->setGroup("General"); | 2010 | config->setGroup("General"); |
2011 | config->writeEntry("CalendarFilters",filterList); | 2011 | config->writeEntry("CalendarFilters",filterList); |
2012 | 2012 | ||
2013 | config->setGroup("FilterView"); | 2013 | config->setGroup("FilterView"); |
2014 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 2014 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
2015 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 2015 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
2016 | } | 2016 | } |
2017 | 2017 | ||
2018 | 2018 | ||
2019 | void CalendarView::goToday() | 2019 | void CalendarView::goToday() |
2020 | { | 2020 | { |
2021 | if ( mViewManager->currentView()->isMonthView() ) | 2021 | if ( mViewManager->currentView()->isMonthView() ) |
2022 | mNavigator->selectTodayMonth(); | 2022 | mNavigator->selectTodayMonth(); |
2023 | else | 2023 | else |
2024 | mNavigator->selectToday(); | 2024 | mNavigator->selectToday(); |
2025 | } | 2025 | } |
2026 | 2026 | ||
2027 | void CalendarView::goNext() | 2027 | void CalendarView::goNext() |
2028 | { | 2028 | { |
2029 | mNavigator->selectNext(); | 2029 | mNavigator->selectNext(); |
2030 | } | 2030 | } |
2031 | 2031 | ||
2032 | void CalendarView::goPrevious() | 2032 | void CalendarView::goPrevious() |
2033 | { | 2033 | { |
2034 | mNavigator->selectPrevious(); | 2034 | mNavigator->selectPrevious(); |
2035 | } | 2035 | } |
2036 | void CalendarView::goNextMonth() | 2036 | void CalendarView::goNextMonth() |
2037 | { | 2037 | { |
2038 | mNavigator->selectNextMonth(); | 2038 | mNavigator->selectNextMonth(); |
2039 | } | 2039 | } |
2040 | 2040 | ||
2041 | void CalendarView::goPreviousMonth() | 2041 | void CalendarView::goPreviousMonth() |
2042 | { | 2042 | { |
2043 | mNavigator->selectPreviousMonth(); | 2043 | mNavigator->selectPreviousMonth(); |
2044 | } | 2044 | } |
2045 | void CalendarView::writeLocale() | 2045 | void CalendarView::writeLocale() |
2046 | { | 2046 | { |
2047 | //KPimGlobalPrefs::instance()->setGlobalConfig(); | 2047 | //KPimGlobalPrefs::instance()->setGlobalConfig(); |
2048 | #if 0 | 2048 | #if 0 |
2049 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 2049 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
2050 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 2050 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
2051 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 2051 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
2052 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 2052 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
2053 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 2053 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
2054 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 2054 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
2055 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 2055 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
2056 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 2056 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
2057 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 2057 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
2058 | KOPrefs::instance()->mDaylightsavingStart, | 2058 | KOPrefs::instance()->mDaylightsavingStart, |
2059 | KOPrefs::instance()->mDaylightsavingEnd ); | 2059 | KOPrefs::instance()->mDaylightsavingEnd ); |
2060 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); | 2060 | KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); |
2061 | #endif | 2061 | #endif |
2062 | } | 2062 | } |
2063 | void CalendarView::updateConfig() | 2063 | void CalendarView::updateConfig() |
2064 | { | 2064 | { |
2065 | writeLocale(); | 2065 | writeLocale(); |
2066 | if ( KOPrefs::instance()->mUseAppColors ) | 2066 | if ( KOPrefs::instance()->mUseAppColors ) |
2067 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 2067 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
2068 | emit configChanged(); | 2068 | emit configChanged(); |
2069 | mTodoList->updateConfig(); | 2069 | mTodoList->updateConfig(); |
2070 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 2070 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
2071 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2071 | mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2072 | // To make the "fill window" configurations work | 2072 | // To make the "fill window" configurations work |
2073 | //mViewManager->raiseCurrentView(); | 2073 | //mViewManager->raiseCurrentView(); |
2074 | } | 2074 | } |
2075 | 2075 | ||
2076 | 2076 | ||
2077 | void CalendarView::eventChanged(Event *event) | 2077 | void CalendarView::eventChanged(Event *event) |
2078 | { | 2078 | { |
2079 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2079 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2080 | //updateUnmanagedViews(); | 2080 | //updateUnmanagedViews(); |
2081 | } | 2081 | } |
2082 | 2082 | ||
2083 | void CalendarView::eventAdded(Event *event) | 2083 | void CalendarView::eventAdded(Event *event) |
2084 | { | 2084 | { |
2085 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2085 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2086 | } | 2086 | } |
2087 | 2087 | ||
2088 | void CalendarView::eventToBeDeleted(Event *) | 2088 | void CalendarView::eventToBeDeleted(Event *) |
2089 | { | 2089 | { |
2090 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2090 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | void CalendarView::eventDeleted() | 2093 | void CalendarView::eventDeleted() |
2094 | { | 2094 | { |
2095 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2095 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2096 | } | 2096 | } |
2097 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2097 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2098 | { | 2098 | { |
2099 | changeIncidenceDisplay((Incidence *)which, action); | 2099 | changeIncidenceDisplay((Incidence *)which, action); |
2100 | mDateNavigator->updateView(); //LR | 2100 | mDateNavigator->updateView(); //LR |
2101 | //mDialogManager->updateSearchDialog(); | 2101 | //mDialogManager->updateSearchDialog(); |
2102 | 2102 | ||
2103 | if (which) { | 2103 | if (which) { |
2104 | mViewManager->updateWNview(); | 2104 | mViewManager->updateWNview(); |
2105 | //mTodoList->updateView(); | 2105 | //mTodoList->updateView(); |
2106 | } | 2106 | } |
2107 | 2107 | ||
2108 | } | 2108 | } |
2109 | 2109 | ||
2110 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2110 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2111 | { | 2111 | { |
2112 | updateUnmanagedViews(); | 2112 | updateUnmanagedViews(); |
2113 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2113 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2114 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2114 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2115 | mCalendar->checkAlarmForIncidence( 0, true ); | 2115 | mCalendar->checkAlarmForIncidence( 0, true ); |
2116 | if ( mEventViewerDialog ) | 2116 | if ( mEventViewerDialog ) |
2117 | mEventViewerDialog->hide(); | 2117 | mEventViewerDialog->hide(); |
2118 | } | 2118 | } |
2119 | else | 2119 | else |
2120 | mCalendar->checkAlarmForIncidence( which , false ); | 2120 | mCalendar->checkAlarmForIncidence( which , false ); |
2121 | } | 2121 | } |
2122 | 2122 | ||
2123 | // most of the changeEventDisplays() right now just call the view's | 2123 | // most of the changeEventDisplays() right now just call the view's |
2124 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2124 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2125 | void CalendarView::changeEventDisplay(Event *which, int action) | 2125 | void CalendarView::changeEventDisplay(Event *which, int action) |
2126 | { | 2126 | { |
2127 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2127 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2128 | changeIncidenceDisplay((Incidence *)which, action); | 2128 | changeIncidenceDisplay((Incidence *)which, action); |
2129 | mDateNavigator->updateView(); | 2129 | mDateNavigator->updateView(); |
2130 | //mDialogManager->updateSearchDialog(); | 2130 | //mDialogManager->updateSearchDialog(); |
2131 | 2131 | ||
2132 | if (which) { | 2132 | if (which) { |
2133 | // If there is an event view visible update the display | 2133 | // If there is an event view visible update the display |
2134 | mViewManager->currentView()->changeEventDisplay(which,action); | 2134 | mViewManager->currentView()->changeEventDisplay(which,action); |
2135 | // TODO: check, if update needed | 2135 | // TODO: check, if update needed |
2136 | // if (which->getTodoStatus()) { | 2136 | // if (which->getTodoStatus()) { |
2137 | mTodoList->updateView(); | 2137 | mTodoList->updateView(); |
2138 | // } | 2138 | // } |
2139 | } else { | 2139 | } else { |
2140 | mViewManager->currentView()->updateView(); | 2140 | mViewManager->currentView()->updateView(); |
2141 | } | 2141 | } |
2142 | } | 2142 | } |
2143 | 2143 | ||
2144 | 2144 | ||
2145 | void CalendarView::updateTodoViews() | 2145 | void CalendarView::updateTodoViews() |
2146 | { | 2146 | { |
2147 | mTodoList->updateView(); | 2147 | mTodoList->updateView(); |
2148 | mViewManager->currentView()->updateView(); | 2148 | mViewManager->currentView()->updateView(); |
2149 | 2149 | ||
2150 | } | 2150 | } |
2151 | 2151 | ||
2152 | 2152 | ||
2153 | void CalendarView::updateView(const QDate &start, const QDate &end) | 2153 | void CalendarView::updateView(const QDate &start, const QDate &end) |
2154 | { | 2154 | { |
2155 | mTodoList->updateView(); | 2155 | mTodoList->updateView(); |
2156 | mViewManager->updateView(start, end); | 2156 | mViewManager->updateView(start, end); |
2157 | //mDateNavigator->updateView(); | 2157 | //mDateNavigator->updateView(); |
2158 | } | 2158 | } |
2159 | 2159 | ||
2160 | void CalendarView::updateView() | 2160 | void CalendarView::updateView() |
2161 | { | 2161 | { |
2162 | DateList tmpList = mNavigator->selectedDates(); | 2162 | DateList tmpList = mNavigator->selectedDates(); |
2163 | 2163 | ||
2164 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2164 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2165 | mTodoList->updateView(); | 2165 | mTodoList->updateView(); |
2166 | // We assume that the navigator only selects consecutive days. | 2166 | // We assume that the navigator only selects consecutive days. |
2167 | updateView( tmpList.first(), tmpList.last() ); | 2167 | updateView( tmpList.first(), tmpList.last() ); |
2168 | } | 2168 | } |
2169 | 2169 | ||
2170 | void CalendarView::updateUnmanagedViews() | 2170 | void CalendarView::updateUnmanagedViews() |
2171 | { | 2171 | { |
2172 | mDateNavigator->updateDayMatrix(); | 2172 | mDateNavigator->updateDayMatrix(); |
2173 | } | 2173 | } |
2174 | 2174 | ||
2175 | int CalendarView::msgItemDelete(const QString name) | 2175 | int CalendarView::msgItemDelete(const QString name) |
2176 | { | 2176 | { |
2177 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2177 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2178 | i18n("This item will be\npermanently deleted."), | 2178 | i18n("This item will be\npermanently deleted."), |
2179 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2179 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2180 | } | 2180 | } |
2181 | 2181 | ||
2182 | 2182 | ||
2183 | void CalendarView::edit_cut() | 2183 | void CalendarView::edit_cut() |
2184 | { | 2184 | { |
2185 | Event *anEvent=0; | 2185 | Event *anEvent=0; |
2186 | 2186 | ||
2187 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2187 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2188 | 2188 | ||
2189 | if (mViewManager->currentView()->isEventView()) { | 2189 | if (mViewManager->currentView()->isEventView()) { |
2190 | if ( incidence && incidence->type() == "Event" ) { | 2190 | if ( incidence && incidence->type() == "Event" ) { |
2191 | anEvent = static_cast<Event *>(incidence); | 2191 | anEvent = static_cast<Event *>(incidence); |
2192 | } | 2192 | } |
2193 | } | 2193 | } |
2194 | 2194 | ||
2195 | if (!anEvent) { | 2195 | if (!anEvent) { |
2196 | KNotifyClient::beep(); | 2196 | KNotifyClient::beep(); |
2197 | return; | 2197 | return; |
2198 | } | 2198 | } |
2199 | DndFactory factory( mCalendar ); | 2199 | DndFactory factory( mCalendar ); |
2200 | factory.cutIncidence(anEvent); | 2200 | factory.cutIncidence(anEvent); |
2201 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2201 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2202 | } | 2202 | } |
2203 | 2203 | ||
2204 | void CalendarView::edit_copy() | 2204 | void CalendarView::edit_copy() |
2205 | { | 2205 | { |
2206 | Event *anEvent=0; | 2206 | Event *anEvent=0; |
2207 | 2207 | ||
2208 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2208 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2209 | 2209 | ||
2210 | if (mViewManager->currentView()->isEventView()) { | 2210 | if (mViewManager->currentView()->isEventView()) { |
2211 | if ( incidence && incidence->type() == "Event" ) { | 2211 | if ( incidence && incidence->type() == "Event" ) { |
2212 | anEvent = static_cast<Event *>(incidence); | 2212 | anEvent = static_cast<Event *>(incidence); |
2213 | } | 2213 | } |
2214 | } | 2214 | } |
2215 | 2215 | ||
2216 | if (!anEvent) { | 2216 | if (!anEvent) { |
2217 | KNotifyClient::beep(); | 2217 | KNotifyClient::beep(); |
2218 | return; | 2218 | return; |
2219 | } | 2219 | } |
2220 | DndFactory factory( mCalendar ); | 2220 | DndFactory factory( mCalendar ); |
2221 | factory.copyIncidence(anEvent); | 2221 | factory.copyIncidence(anEvent); |
2222 | } | 2222 | } |
2223 | 2223 | ||
2224 | void CalendarView::edit_paste() | 2224 | void CalendarView::edit_paste() |
2225 | { | 2225 | { |
2226 | QDate date = mNavigator->selectedDates().first(); | 2226 | QDate date = mNavigator->selectedDates().first(); |
2227 | 2227 | ||
2228 | DndFactory factory( mCalendar ); | 2228 | DndFactory factory( mCalendar ); |
2229 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); | 2229 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2230 | 2230 | ||
2231 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2231 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2232 | } | 2232 | } |
2233 | 2233 | ||
2234 | void CalendarView::edit_options() | 2234 | void CalendarView::edit_options() |
2235 | { | 2235 | { |
2236 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; | 2236 | QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; |
2237 | emit save(); | 2237 | emit save(); |
2238 | emit saveStopTimer(); | 2238 | emit saveStopTimer(); |
2239 | mDialogManager->showOptionsDialog(); | 2239 | mDialogManager->showOptionsDialog(); |
2240 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { | 2240 | if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { |
2241 | emit saveStopTimer(); | 2241 | emit saveStopTimer(); |
2242 | 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!"), | 2242 | 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!"), |
2243 | i18n("Timezone settings"),i18n("Reload"))) { | 2243 | i18n("Timezone settings"),i18n("Reload"))) { |
2244 | qDebug("KO: TZ reload cancelled "); | 2244 | qDebug("KO: TZ reload cancelled "); |
2245 | return; | 2245 | return; |
2246 | } | 2246 | } |
2247 | qDebug("KO: Timezone change "); | 2247 | qDebug("KO: Timezone change "); |
2248 | openCalendar( MainWindow::defaultFileName() ); | 2248 | openCalendar( MainWindow::defaultFileName() ); |
2249 | setModified(true); | 2249 | setModified(true); |
2250 | } | 2250 | } |
2251 | else | 2251 | else |
2252 | qDebug("KO: No tz change "); | 2252 | qDebug("KO: No tz change "); |
2253 | 2253 | ||
2254 | } | 2254 | } |
2255 | 2255 | ||
2256 | 2256 | ||
2257 | void CalendarView::slotSelectPickerDate( QDate d) | 2257 | void CalendarView::slotSelectPickerDate( QDate d) |
2258 | { | 2258 | { |
2259 | mDateFrame->hide(); | 2259 | mDateFrame->hide(); |
2260 | if ( mDatePickerMode == 1 ) { | 2260 | if ( mDatePickerMode == 1 ) { |
2261 | mNavigator->slotDaySelect( d ); | 2261 | mNavigator->slotDaySelect( d ); |
2262 | } else if ( mDatePickerMode == 2 ) { | 2262 | } else if ( mDatePickerMode == 2 ) { |
2263 | if ( mMoveIncidence->type() == "Todo" ) { | 2263 | if ( mMoveIncidence->type() == "Todo" ) { |
2264 | Todo * to = (Todo *) mMoveIncidence; | 2264 | Todo * to = (Todo *) mMoveIncidence; |
2265 | QTime tim; | 2265 | QTime tim; |
2266 | int len = 0; | ||
2267 | if ( to->hasStartDate() && to->hasDueDate() ) | ||
2268 | len = to->dtStart().secsTo( to->dtDue()); | ||
2266 | if ( to->hasDueDate() ) | 2269 | if ( to->hasDueDate() ) |
2267 | tim = to->dtDue().time(); | 2270 | tim = to->dtDue().time(); |
2268 | else { | 2271 | else { |
2269 | tim = QTime ( 0,0,0 ); | 2272 | tim = QTime ( 0,0,0 ); |
2270 | to->setFloats( true ); | 2273 | to->setFloats( true ); |
2271 | to->setHasDueDate( true ); | 2274 | to->setHasDueDate( true ); |
2272 | } | 2275 | } |
2273 | QDateTime dt ( d,tim ); | 2276 | QDateTime dt ( d,tim ); |
2274 | to->setDtDue( dt ); | 2277 | to->setDtDue( dt ); |
2278 | |||
2279 | if ( to->hasStartDate() ) { | ||
2280 | if ( len>0 ) | ||
2281 | to->setDtStart(to->dtDue().addSecs( -len )); | ||
2282 | else | ||
2283 | if (to->dtStart() > to->dtDue() ) | ||
2284 | to->setDtStart(to->dtDue().addDays( -3 )); | ||
2285 | } | ||
2286 | |||
2275 | todoChanged( to ); | 2287 | todoChanged( to ); |
2276 | } else { | 2288 | } else { |
2277 | if ( mMoveIncidence->doesRecur() ) { | 2289 | if ( mMoveIncidence->doesRecur() ) { |
2278 | #if 0 | 2290 | #if 0 |
2279 | // PENDING implement this | 2291 | // PENDING implement this |
2280 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2292 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2281 | mCalendar()->addIncidence( newInc ); | 2293 | mCalendar()->addIncidence( newInc ); |
2282 | if ( mMoveIncidence->type() == "Todo" ) | 2294 | if ( mMoveIncidence->type() == "Todo" ) |
2283 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2295 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2284 | else | 2296 | else |
2285 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2297 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2286 | mMoveIncidence = newInc; | 2298 | mMoveIncidence = newInc; |
2287 | 2299 | ||
2288 | #endif | 2300 | #endif |
2289 | } | 2301 | } |
2290 | QTime tim = mMoveIncidence->dtStart().time(); | 2302 | QTime tim = mMoveIncidence->dtStart().time(); |
2291 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2303 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2292 | QDateTime dt ( d,tim ); | 2304 | QDateTime dt ( d,tim ); |
2293 | mMoveIncidence->setDtStart( dt ); | 2305 | mMoveIncidence->setDtStart( dt ); |
2294 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2306 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2295 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2307 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2296 | } | 2308 | } |
2297 | 2309 | ||
2298 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2310 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2299 | } | 2311 | } |
2300 | } | 2312 | } |
2301 | 2313 | ||
2302 | void CalendarView::removeCategories() | 2314 | void CalendarView::removeCategories() |
2303 | { | 2315 | { |
2304 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2316 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2305 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2317 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2306 | QStringList catIncList; | 2318 | QStringList catIncList; |
2307 | QStringList newCatList; | 2319 | QStringList newCatList; |
2308 | Incidence* inc = incList.first(); | 2320 | Incidence* inc = incList.first(); |
2309 | int i; | 2321 | int i; |
2310 | int count = 0; | 2322 | int count = 0; |
2311 | while ( inc ) { | 2323 | while ( inc ) { |
2312 | newCatList.clear(); | 2324 | newCatList.clear(); |
2313 | catIncList = inc->categories() ; | 2325 | catIncList = inc->categories() ; |
2314 | for( i = 0; i< catIncList.count(); ++i ) { | 2326 | for( i = 0; i< catIncList.count(); ++i ) { |
2315 | if ( catList.contains (catIncList[i])) | 2327 | if ( catList.contains (catIncList[i])) |
2316 | newCatList.append( catIncList[i] ); | 2328 | newCatList.append( catIncList[i] ); |
2317 | } | 2329 | } |
2318 | newCatList.sort(); | 2330 | newCatList.sort(); |
2319 | inc->setCategories( newCatList.join(",") ); | 2331 | inc->setCategories( newCatList.join(",") ); |
2320 | inc = incList.next(); | 2332 | inc = incList.next(); |
2321 | } | 2333 | } |
2322 | } | 2334 | } |
2323 | 2335 | ||
2324 | int CalendarView::addCategories() | 2336 | int CalendarView::addCategories() |
2325 | { | 2337 | { |
2326 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2338 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2327 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2339 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2328 | QStringList catIncList; | 2340 | QStringList catIncList; |
2329 | Incidence* inc = incList.first(); | 2341 | Incidence* inc = incList.first(); |
2330 | int i; | 2342 | int i; |
2331 | int count = 0; | 2343 | int count = 0; |
2332 | while ( inc ) { | 2344 | while ( inc ) { |
2333 | catIncList = inc->categories() ; | 2345 | catIncList = inc->categories() ; |
2334 | for( i = 0; i< catIncList.count(); ++i ) { | 2346 | for( i = 0; i< catIncList.count(); ++i ) { |
2335 | if ( !catList.contains (catIncList[i])) { | 2347 | if ( !catList.contains (catIncList[i])) { |
2336 | catList.append( catIncList[i] ); | 2348 | catList.append( catIncList[i] ); |
2337 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2349 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2338 | ++count; | 2350 | ++count; |
2339 | } | 2351 | } |
2340 | } | 2352 | } |
2341 | inc = incList.next(); | 2353 | inc = incList.next(); |
2342 | } | 2354 | } |
2343 | catList.sort(); | 2355 | catList.sort(); |
2344 | KOPrefs::instance()->mCustomCategories = catList; | 2356 | KOPrefs::instance()->mCustomCategories = catList; |
2345 | return count; | 2357 | return count; |
2346 | } | 2358 | } |
2347 | 2359 | ||
2348 | void CalendarView::manageCategories() | 2360 | void CalendarView::manageCategories() |
2349 | { | 2361 | { |
2350 | KOCatPrefs* cp = new KOCatPrefs(); | 2362 | KOCatPrefs* cp = new KOCatPrefs(); |
2351 | cp->show(); | 2363 | cp->show(); |
2352 | int w =cp->sizeHint().width() ; | 2364 | int w =cp->sizeHint().width() ; |
2353 | int h = cp->sizeHint().height() ; | 2365 | int h = cp->sizeHint().height() ; |
2354 | int dw = QApplication::desktop()->width(); | 2366 | int dw = QApplication::desktop()->width(); |
2355 | int dh = QApplication::desktop()->height(); | 2367 | int dh = QApplication::desktop()->height(); |
2356 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2368 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2357 | if ( !cp->exec() ) { | 2369 | if ( !cp->exec() ) { |
2358 | delete cp; | 2370 | delete cp; |
2359 | return; | 2371 | return; |
2360 | } | 2372 | } |
2361 | int count = 0; | 2373 | int count = 0; |
2362 | if ( cp->addCat() ) { | 2374 | if ( cp->addCat() ) { |
2363 | count = addCategories(); | 2375 | count = addCategories(); |
2364 | if ( count ) { | 2376 | if ( count ) { |
2365 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2377 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2366 | writeSettings(); | 2378 | writeSettings(); |
2367 | } else | 2379 | } else |
2368 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2380 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2369 | } else { | 2381 | } else { |
2370 | removeCategories(); | 2382 | removeCategories(); |
2371 | updateView(); | 2383 | updateView(); |
2372 | } | 2384 | } |
2373 | delete cp; | 2385 | delete cp; |
2374 | } | 2386 | } |
2375 | 2387 | ||
2376 | void CalendarView::beamIncidence(Incidence * Inc) | 2388 | void CalendarView::beamIncidence(Incidence * Inc) |
2377 | { | 2389 | { |
2378 | QPtrList<Incidence> delSel ; | 2390 | QPtrList<Incidence> delSel ; |
2379 | delSel.append(Inc); | 2391 | delSel.append(Inc); |
2380 | beamIncidenceList( delSel ); | 2392 | beamIncidenceList( delSel ); |
2381 | } | 2393 | } |
2382 | void CalendarView::beamCalendar() | 2394 | void CalendarView::beamCalendar() |
2383 | { | 2395 | { |
2384 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2396 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2385 | //qDebug("beamCalendar() "); | 2397 | //qDebug("beamCalendar() "); |
2386 | beamIncidenceList( delSel ); | 2398 | beamIncidenceList( delSel ); |
2387 | } | 2399 | } |
2388 | void CalendarView::beamFilteredCalendar() | 2400 | void CalendarView::beamFilteredCalendar() |
2389 | { | 2401 | { |
2390 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2402 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2391 | //qDebug("beamFilteredCalendar() "); | 2403 | //qDebug("beamFilteredCalendar() "); |
2392 | beamIncidenceList( delSel ); | 2404 | beamIncidenceList( delSel ); |
2393 | } | 2405 | } |
2394 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2406 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2395 | { | 2407 | { |
2396 | if ( beamDialog->exec () == QDialog::Rejected ) | 2408 | if ( beamDialog->exec () == QDialog::Rejected ) |
2397 | return; | 2409 | return; |
2398 | #ifdef DESKTOP_VERSION | 2410 | #ifdef DESKTOP_VERSION |
2399 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2411 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2400 | #else | 2412 | #else |
2401 | QString fn = "/tmp/kopibeamfile"; | 2413 | QString fn = "/tmp/kopibeamfile"; |
2402 | #endif | 2414 | #endif |
2403 | QString mes; | 2415 | QString mes; |
2404 | bool createbup = true; | 2416 | bool createbup = true; |
2405 | if ( createbup ) { | 2417 | if ( createbup ) { |
2406 | QString description = "\n"; | 2418 | QString description = "\n"; |
2407 | CalendarLocal* cal = new CalendarLocal(); | 2419 | CalendarLocal* cal = new CalendarLocal(); |
2408 | if ( beamDialog->beamLocal() ) | 2420 | if ( beamDialog->beamLocal() ) |
2409 | cal->setLocalTime(); | 2421 | cal->setLocalTime(); |
2410 | else | 2422 | else |
2411 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2423 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2412 | Incidence *incidence = delSel.first(); | 2424 | Incidence *incidence = delSel.first(); |
2413 | bool addText = false; | 2425 | bool addText = false; |
2414 | if ( delSel.count() < 10 ) | 2426 | if ( delSel.count() < 10 ) |
2415 | addText = true; | 2427 | addText = true; |
2416 | else { | 2428 | else { |
2417 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2429 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2418 | } | 2430 | } |
2419 | while ( incidence ) { | 2431 | while ( incidence ) { |
2420 | Incidence *in = incidence->clone(); | 2432 | Incidence *in = incidence->clone(); |
2421 | if ( ! in->summary().isEmpty() ) { | 2433 | if ( ! in->summary().isEmpty() ) { |
2422 | in->setDescription(""); | 2434 | in->setDescription(""); |
2423 | } else { | 2435 | } else { |
2424 | in->setSummary( in->description().left(20)); | 2436 | in->setSummary( in->description().left(20)); |
2425 | in->setDescription(""); | 2437 | in->setDescription(""); |
2426 | } | 2438 | } |
2427 | if ( addText ) | 2439 | if ( addText ) |
2428 | description += in->summary() + "\n"; | 2440 | description += in->summary() + "\n"; |
2429 | cal->addIncidence( in ); | 2441 | cal->addIncidence( in ); |
2430 | incidence = delSel.next(); | 2442 | incidence = delSel.next(); |
2431 | } | 2443 | } |
2432 | if ( beamDialog->beamVcal() ) { | 2444 | if ( beamDialog->beamVcal() ) { |
2433 | fn += ".vcs"; | 2445 | fn += ".vcs"; |
2434 | FileStorage storage( cal, fn, new VCalFormat ); | 2446 | FileStorage storage( cal, fn, new VCalFormat ); |
2435 | storage.save(); | 2447 | storage.save(); |
2436 | } else { | 2448 | } else { |
2437 | fn += ".ics"; | 2449 | fn += ".ics"; |
2438 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2450 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2439 | storage.save(); | 2451 | storage.save(); |
2440 | } | 2452 | } |
2441 | delete cal; | 2453 | delete cal; |
2442 | mes = i18n("KO/Pi: Ready for beaming"); | 2454 | mes = i18n("KO/Pi: Ready for beaming"); |
2443 | topLevelWidget()->setCaption(mes); | 2455 | topLevelWidget()->setCaption(mes); |
2444 | KApplication::convert2latin1( fn ); | 2456 | KApplication::convert2latin1( fn ); |
2445 | #ifndef DESKTOP_VERSION | 2457 | #ifndef DESKTOP_VERSION |
2446 | Ir *ir = new Ir( this ); | 2458 | Ir *ir = new Ir( this ); |
2447 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2459 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2448 | ir->send( fn, description, "text/x-vCalendar" ); | 2460 | ir->send( fn, description, "text/x-vCalendar" ); |
2449 | #endif | 2461 | #endif |
2450 | } | 2462 | } |
2451 | } | 2463 | } |
2452 | void CalendarView::beamDone( Ir *ir ) | 2464 | void CalendarView::beamDone( Ir *ir ) |
2453 | { | 2465 | { |
2454 | #ifndef DESKTOP_VERSION | 2466 | #ifndef DESKTOP_VERSION |
2455 | delete ir; | 2467 | delete ir; |
2456 | #endif | 2468 | #endif |
2457 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2469 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2458 | topLevelWidget()->raise(); | 2470 | topLevelWidget()->raise(); |
2459 | } | 2471 | } |
2460 | 2472 | ||
2461 | void CalendarView::moveIncidence(Incidence * inc ) | 2473 | void CalendarView::moveIncidence(Incidence * inc ) |
2462 | { | 2474 | { |
2463 | if ( !inc ) return; | 2475 | if ( !inc ) return; |
2464 | showDatePickerPopup(); | 2476 | showDatePickerPopup(); |
2465 | mDatePickerMode = 2; | 2477 | mDatePickerMode = 2; |
2466 | mMoveIncidence = inc ; | 2478 | mMoveIncidence = inc ; |
2467 | QDate da; | 2479 | QDate da; |
2468 | if ( mMoveIncidence->type() == "Todo" ) { | 2480 | if ( mMoveIncidence->type() == "Todo" ) { |
2469 | Todo * to = (Todo *) mMoveIncidence; | 2481 | Todo * to = (Todo *) mMoveIncidence; |
2470 | if ( to->hasDueDate() ) | 2482 | if ( to->hasDueDate() ) |
2471 | da = to->dtDue().date(); | 2483 | da = to->dtDue().date(); |
2472 | else | 2484 | else |
2473 | da = QDate::currentDate(); | 2485 | da = QDate::currentDate(); |
2474 | } else { | 2486 | } else { |
2475 | da = mMoveIncidence->dtStart().date(); | 2487 | da = mMoveIncidence->dtStart().date(); |
2476 | } | 2488 | } |
2477 | //PENDING set date for recurring incidence to date of recurrence | 2489 | //PENDING set date for recurring incidence to date of recurrence |
2478 | //mMoveIncidenceOldDate; | 2490 | //mMoveIncidenceOldDate; |
2479 | mDatePicker->setDate( da ); | 2491 | mDatePicker->setDate( da ); |
2480 | } | 2492 | } |
2481 | void CalendarView::showDatePickerPopup() | 2493 | void CalendarView::showDatePickerPopup() |
2482 | { | 2494 | { |
2483 | if ( mDateFrame->isVisible() ) | 2495 | if ( mDateFrame->isVisible() ) |
2484 | mDateFrame->hide(); | 2496 | mDateFrame->hide(); |
2485 | else { | 2497 | else { |
2486 | int offX = 0, offY = 0; | 2498 | int offX = 0, offY = 0; |
2487 | #ifdef DESKTOP_VERSION | 2499 | #ifdef DESKTOP_VERSION |
2488 | int w =mDatePicker->sizeHint().width() ; | 2500 | int w =mDatePicker->sizeHint().width() ; |
2489 | int h = mDatePicker->sizeHint().height() ; | 2501 | int h = mDatePicker->sizeHint().height() ; |
2490 | int dw = topLevelWidget()->width(); | 2502 | int dw = topLevelWidget()->width(); |
2491 | int dh = topLevelWidget()->height(); | 2503 | int dh = topLevelWidget()->height(); |
2492 | offX = topLevelWidget()->x(); | 2504 | offX = topLevelWidget()->x(); |
2493 | offY = topLevelWidget()->y(); | 2505 | offY = topLevelWidget()->y(); |
2494 | #else | 2506 | #else |
2495 | int w =mDatePicker->sizeHint().width() ; | 2507 | int w =mDatePicker->sizeHint().width() ; |
2496 | int h = mDatePicker->sizeHint().height() ; | 2508 | int h = mDatePicker->sizeHint().height() ; |
2497 | int dw = QApplication::desktop()->width(); | 2509 | int dw = QApplication::desktop()->width(); |
2498 | int dh = QApplication::desktop()->height(); | 2510 | int dh = QApplication::desktop()->height(); |
2499 | #endif | 2511 | #endif |
2500 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 2512 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
2501 | mDateFrame->show(); | 2513 | mDateFrame->show(); |
2502 | } | 2514 | } |
2503 | } | 2515 | } |
2504 | void CalendarView::showDatePicker( ) | 2516 | void CalendarView::showDatePicker( ) |
2505 | { | 2517 | { |
2506 | showDatePickerPopup(); | 2518 | showDatePickerPopup(); |
2507 | mDatePickerMode = 1; | 2519 | mDatePickerMode = 1; |
2508 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2520 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2509 | } | 2521 | } |
2510 | 2522 | ||
2511 | void CalendarView::showEventEditor() | 2523 | void CalendarView::showEventEditor() |
2512 | { | 2524 | { |
2513 | #ifdef DESKTOP_VERSION | 2525 | #ifdef DESKTOP_VERSION |
2514 | mEventEditor->show(); | 2526 | mEventEditor->show(); |
2515 | #else | 2527 | #else |
2516 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2528 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2517 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2529 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2518 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2530 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2519 | qApp->processEvents(); | 2531 | qApp->processEvents(); |
2520 | delete mEventEditor; | 2532 | delete mEventEditor; |
2521 | mEventEditor = mDialogManager->getEventEditor(); | 2533 | mEventEditor = mDialogManager->getEventEditor(); |
2522 | topLevelWidget()->setCaption( i18n("") ); | 2534 | topLevelWidget()->setCaption( i18n("") ); |
2523 | } | 2535 | } |
2524 | mEventEditor->showMaximized(); | 2536 | mEventEditor->showMaximized(); |
2525 | #endif | 2537 | #endif |
2526 | } | 2538 | } |
2527 | void CalendarView::showTodoEditor() | 2539 | void CalendarView::showTodoEditor() |
2528 | { | 2540 | { |
2529 | #ifdef DESKTOP_VERSION | 2541 | #ifdef DESKTOP_VERSION |
2530 | mTodoEditor->show(); | 2542 | mTodoEditor->show(); |
2531 | #else | 2543 | #else |
2532 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2544 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2533 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2545 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2534 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2546 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2535 | qApp->processEvents(); | 2547 | qApp->processEvents(); |
2536 | delete mTodoEditor; | 2548 | delete mTodoEditor; |
2537 | mTodoEditor = mDialogManager->getTodoEditor(); | 2549 | mTodoEditor = mDialogManager->getTodoEditor(); |
2538 | topLevelWidget()->setCaption( i18n("") ); | 2550 | topLevelWidget()->setCaption( i18n("") ); |
2539 | } | 2551 | } |
2540 | mTodoEditor->showMaximized(); | 2552 | mTodoEditor->showMaximized(); |
2541 | #endif | 2553 | #endif |
2542 | } | 2554 | } |
2543 | 2555 | ||
2544 | void CalendarView::cloneIncidence() | 2556 | void CalendarView::cloneIncidence() |
2545 | { | 2557 | { |
2546 | Incidence *incidence = currentSelection(); | 2558 | Incidence *incidence = currentSelection(); |
2547 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2559 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2548 | if ( incidence ) { | 2560 | if ( incidence ) { |
2549 | cloneIncidence(incidence); | 2561 | cloneIncidence(incidence); |
2550 | } | 2562 | } |
2551 | } | 2563 | } |
2552 | void CalendarView::moveIncidence() | 2564 | void CalendarView::moveIncidence() |
2553 | { | 2565 | { |
2554 | Incidence *incidence = currentSelection(); | 2566 | Incidence *incidence = currentSelection(); |
2555 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2567 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2556 | if ( incidence ) { | 2568 | if ( incidence ) { |
2557 | moveIncidence(incidence); | 2569 | moveIncidence(incidence); |
2558 | } | 2570 | } |
2559 | } | 2571 | } |
2560 | void CalendarView::beamIncidence() | 2572 | void CalendarView::beamIncidence() |
2561 | { | 2573 | { |
2562 | Incidence *incidence = currentSelection(); | 2574 | Incidence *incidence = currentSelection(); |
2563 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2575 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2564 | if ( incidence ) { | 2576 | if ( incidence ) { |
2565 | beamIncidence(incidence); | 2577 | beamIncidence(incidence); |
2566 | } | 2578 | } |
2567 | } | 2579 | } |
2568 | void CalendarView::toggleCancelIncidence() | 2580 | void CalendarView::toggleCancelIncidence() |
2569 | { | 2581 | { |
2570 | Incidence *incidence = currentSelection(); | 2582 | Incidence *incidence = currentSelection(); |
2571 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2583 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2572 | if ( incidence ) { | 2584 | if ( incidence ) { |
2573 | cancelIncidence(incidence); | 2585 | cancelIncidence(incidence); |
2574 | } | 2586 | } |
2575 | } | 2587 | } |
2576 | 2588 | ||
2577 | 2589 | ||
2578 | void CalendarView::cancelIncidence(Incidence * inc ) | 2590 | void CalendarView::cancelIncidence(Incidence * inc ) |
2579 | { | 2591 | { |
2580 | inc->setCancelled( ! inc->cancelled() ); | 2592 | inc->setCancelled( ! inc->cancelled() ); |
2581 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2593 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2582 | updateView(); | 2594 | updateView(); |
2583 | } | 2595 | } |
2584 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2596 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2585 | { | 2597 | { |
2586 | Incidence * newInc = orgInc->clone(); | 2598 | Incidence * newInc = orgInc->clone(); |
2587 | newInc->recreate(); | 2599 | newInc->recreate(); |
2588 | 2600 | ||
2589 | if ( newInc->type() == "Todo" ) { | 2601 | if ( newInc->type() == "Todo" ) { |
2590 | Todo* t = (Todo*) newInc; | 2602 | Todo* t = (Todo*) newInc; |
2591 | showTodoEditor(); | 2603 | showTodoEditor(); |
2592 | mTodoEditor->editTodo( t ); | 2604 | mTodoEditor->editTodo( t ); |
2593 | if ( mTodoEditor->exec() ) { | 2605 | if ( mTodoEditor->exec() ) { |
2594 | mCalendar->addTodo( t ); | 2606 | mCalendar->addTodo( t ); |
2595 | updateView(); | 2607 | updateView(); |
2596 | } else { | 2608 | } else { |
2597 | delete t; | 2609 | delete t; |
2598 | } | 2610 | } |
2599 | } | 2611 | } |
2600 | else { | 2612 | else { |
2601 | Event* e = (Event*) newInc; | 2613 | Event* e = (Event*) newInc; |
2602 | showEventEditor(); | 2614 | showEventEditor(); |
2603 | mEventEditor->editEvent( e ); | 2615 | mEventEditor->editEvent( e ); |
2604 | if ( mEventEditor->exec() ) { | 2616 | if ( mEventEditor->exec() ) { |
2605 | mCalendar->addEvent( e ); | 2617 | mCalendar->addEvent( e ); |
2606 | updateView(); | 2618 | updateView(); |
2607 | } else { | 2619 | } else { |
2608 | delete e; | 2620 | delete e; |
2609 | } | 2621 | } |
2610 | } | 2622 | } |
2611 | } | 2623 | } |
2612 | 2624 | ||
2613 | void CalendarView::newEvent() | 2625 | void CalendarView::newEvent() |
2614 | { | 2626 | { |
2615 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2627 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2616 | KOAgendaView *aView = mViewManager->agendaView(); | 2628 | KOAgendaView *aView = mViewManager->agendaView(); |
2617 | if (aView) { | 2629 | if (aView) { |
2618 | if (aView->selectionStart().isValid()) { | 2630 | if (aView->selectionStart().isValid()) { |
2619 | if (aView->selectedIsAllDay()) { | 2631 | if (aView->selectedIsAllDay()) { |
2620 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2632 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2621 | } else { | 2633 | } else { |
2622 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2634 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2623 | } | 2635 | } |
2624 | return; | 2636 | return; |
2625 | } | 2637 | } |
2626 | } | 2638 | } |
2627 | 2639 | ||
2628 | QDate date = mNavigator->selectedDates().first(); | 2640 | QDate date = mNavigator->selectedDates().first(); |
2629 | QDateTime current = QDateTime::currentDateTime(); | 2641 | QDateTime current = QDateTime::currentDateTime(); |
2630 | if ( date <= current.date() ) { | 2642 | if ( date <= current.date() ) { |
2631 | int hour = current.time().hour() +1; | 2643 | int hour = current.time().hour() +1; |
2632 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2644 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2633 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2645 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2634 | } else | 2646 | } else |
2635 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2647 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2636 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2648 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2637 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2649 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2638 | } | 2650 | } |
2639 | 2651 | ||
2640 | void CalendarView::newEvent(QDateTime fh) | 2652 | void CalendarView::newEvent(QDateTime fh) |
2641 | { | 2653 | { |
2642 | newEvent(fh, | 2654 | newEvent(fh, |
2643 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2655 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2644 | } | 2656 | } |
2645 | 2657 | ||
2646 | void CalendarView::newEvent(QDate dt) | 2658 | void CalendarView::newEvent(QDate dt) |
2647 | { | 2659 | { |
2648 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2660 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2649 | QDateTime(dt, QTime(0,0,0)), true); | 2661 | QDateTime(dt, QTime(0,0,0)), true); |
2650 | } | 2662 | } |
2651 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2663 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2652 | { | 2664 | { |
2653 | newEvent(fromHint, toHint, false); | 2665 | newEvent(fromHint, toHint, false); |
2654 | } | 2666 | } |
2655 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2667 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2656 | { | 2668 | { |
2657 | 2669 | ||
2658 | showEventEditor(); | 2670 | showEventEditor(); |
2659 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2671 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2660 | if ( mFilterView->filtersEnabled() ) { | 2672 | if ( mFilterView->filtersEnabled() ) { |
2661 | CalFilter *filter = mFilterView->selectedFilter(); | 2673 | CalFilter *filter = mFilterView->selectedFilter(); |
2662 | if (filter && filter->showCategories()) { | 2674 | if (filter && filter->showCategories()) { |
2663 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2675 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2664 | } | 2676 | } |
2665 | if ( filter ) | 2677 | if ( filter ) |
2666 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2678 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2667 | } | 2679 | } |
2668 | } | 2680 | } |
2669 | void CalendarView::todoAdded(Todo * t) | 2681 | void CalendarView::todoAdded(Todo * t) |
2670 | { | 2682 | { |
2671 | 2683 | ||
2672 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2684 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2673 | updateTodoViews(); | 2685 | updateTodoViews(); |
2674 | } | 2686 | } |
2675 | void CalendarView::todoChanged(Todo * t) | 2687 | void CalendarView::todoChanged(Todo * t) |
2676 | { | 2688 | { |
2677 | emit todoModified( t, 4 ); | 2689 | emit todoModified( t, 4 ); |
2678 | // updateTodoViews(); | 2690 | // updateTodoViews(); |
2679 | } | 2691 | } |
2680 | void CalendarView::todoToBeDeleted(Todo *) | 2692 | void CalendarView::todoToBeDeleted(Todo *) |
2681 | { | 2693 | { |
2682 | //qDebug("todoToBeDeleted(Todo *) "); | 2694 | //qDebug("todoToBeDeleted(Todo *) "); |
2683 | updateTodoViews(); | 2695 | updateTodoViews(); |
2684 | } | 2696 | } |
2685 | void CalendarView::todoDeleted() | 2697 | void CalendarView::todoDeleted() |
2686 | { | 2698 | { |
2687 | //qDebug(" todoDeleted()"); | 2699 | //qDebug(" todoDeleted()"); |
2688 | updateTodoViews(); | 2700 | updateTodoViews(); |
2689 | } | 2701 | } |
2690 | 2702 | ||
2691 | 2703 | ||
2692 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2704 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2693 | { | 2705 | { |
2694 | showTodoEditor(); | 2706 | showTodoEditor(); |
2695 | mTodoEditor->newTodo(dt,0,allday); | 2707 | mTodoEditor->newTodo(dt,0,allday); |
2696 | if ( mFilterView->filtersEnabled() ) { | 2708 | if ( mFilterView->filtersEnabled() ) { |
2697 | CalFilter *filter = mFilterView->selectedFilter(); | 2709 | CalFilter *filter = mFilterView->selectedFilter(); |
2698 | if (filter && filter->showCategories()) { | 2710 | if (filter && filter->showCategories()) { |
2699 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2711 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2700 | } | 2712 | } |
2701 | if ( filter ) | 2713 | if ( filter ) |
2702 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2714 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2703 | } | 2715 | } |
2704 | } | 2716 | } |
2705 | 2717 | ||
2706 | void CalendarView::newTodo() | 2718 | void CalendarView::newTodo() |
2707 | { | 2719 | { |
2708 | newTodoDateTime( QDateTime(),true ); | 2720 | newTodoDateTime( QDateTime(),true ); |
2709 | } | 2721 | } |
2710 | 2722 | ||
2711 | void CalendarView::newSubTodo() | 2723 | void CalendarView::newSubTodo() |
2712 | { | 2724 | { |
2713 | Todo *todo = selectedTodo(); | 2725 | Todo *todo = selectedTodo(); |
2714 | if ( todo ) newSubTodo( todo ); | 2726 | if ( todo ) newSubTodo( todo ); |
2715 | } | 2727 | } |
2716 | 2728 | ||
2717 | void CalendarView::newSubTodo(Todo *parentEvent) | 2729 | void CalendarView::newSubTodo(Todo *parentEvent) |
2718 | { | 2730 | { |
2719 | 2731 | ||
2720 | showTodoEditor(); | 2732 | showTodoEditor(); |
2721 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2733 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2722 | } | 2734 | } |
2723 | 2735 | ||
2724 | void CalendarView::newFloatingEvent() | 2736 | void CalendarView::newFloatingEvent() |
2725 | { | 2737 | { |
2726 | DateList tmpList = mNavigator->selectedDates(); | 2738 | DateList tmpList = mNavigator->selectedDates(); |
2727 | QDate date = tmpList.first(); | 2739 | QDate date = tmpList.first(); |
2728 | 2740 | ||
2729 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2741 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2730 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2742 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2731 | } | 2743 | } |
2732 | 2744 | ||
2733 | 2745 | ||
2734 | void CalendarView::editEvent( Event *event ) | 2746 | void CalendarView::editEvent( Event *event ) |
2735 | { | 2747 | { |
2736 | 2748 | ||
2737 | if ( !event ) return; | 2749 | if ( !event ) return; |
2738 | if ( event->isReadOnly() ) { | 2750 | if ( event->isReadOnly() ) { |
2739 | showEvent( event ); | 2751 | showEvent( event ); |
2740 | return; | 2752 | return; |
2741 | } | 2753 | } |
2742 | showEventEditor(); | 2754 | showEventEditor(); |
2743 | mEventEditor->editEvent( event , mFlagEditDescription); | 2755 | mEventEditor->editEvent( event , mFlagEditDescription); |
2744 | } | 2756 | } |
2745 | void CalendarView::editJournal( Journal *jour ) | 2757 | void CalendarView::editJournal( Journal *jour ) |
2746 | { | 2758 | { |
2747 | if ( !jour ) return; | 2759 | if ( !jour ) return; |
2748 | mDialogManager->hideSearchDialog(); | 2760 | mDialogManager->hideSearchDialog(); |
2749 | mViewManager->showJournalView(); | 2761 | mViewManager->showJournalView(); |
2750 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2762 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2751 | } | 2763 | } |
2752 | void CalendarView::editTodo( Todo *todo ) | 2764 | void CalendarView::editTodo( Todo *todo ) |
2753 | { | 2765 | { |
2754 | if ( !todo ) return; | 2766 | if ( !todo ) return; |
2755 | 2767 | ||
2756 | if ( todo->isReadOnly() ) { | 2768 | if ( todo->isReadOnly() ) { |
2757 | showTodo( todo ); | 2769 | showTodo( todo ); |
2758 | return; | 2770 | return; |
2759 | } | 2771 | } |
2760 | showTodoEditor(); | 2772 | showTodoEditor(); |
2761 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2773 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2762 | 2774 | ||
2763 | } | 2775 | } |
2764 | 2776 | ||
2765 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2777 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2766 | { | 2778 | { |
2767 | if ( !mEventViewerDialog ) { | 2779 | if ( !mEventViewerDialog ) { |
2768 | mEventViewerDialog = new KOEventViewerDialog(this); | 2780 | mEventViewerDialog = new KOEventViewerDialog(this); |
2769 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2781 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2770 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2782 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2771 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2783 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2772 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2784 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2773 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2785 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2774 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2786 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2775 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2787 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2776 | this, SLOT( todoChanged(Todo *) ) ); | 2788 | this, SLOT( todoChanged(Todo *) ) ); |
2777 | mEventViewerDialog->resize( 640, 480 ); | 2789 | mEventViewerDialog->resize( 640, 480 ); |
2778 | 2790 | ||
2779 | } | 2791 | } |
2780 | return mEventViewerDialog; | 2792 | return mEventViewerDialog; |
2781 | } | 2793 | } |
2782 | void CalendarView::showEvent(Event *event) | 2794 | void CalendarView::showEvent(Event *event) |
2783 | { | 2795 | { |
2784 | getEventViewerDialog()->setEvent(event); | 2796 | getEventViewerDialog()->setEvent(event); |
2785 | getEventViewerDialog()->showMe(); | 2797 | getEventViewerDialog()->showMe(); |
2786 | } | 2798 | } |
2787 | 2799 | ||
2788 | void CalendarView::showTodo(Todo *event) | 2800 | void CalendarView::showTodo(Todo *event) |
2789 | { | 2801 | { |
2790 | getEventViewerDialog()->setTodo(event); | 2802 | getEventViewerDialog()->setTodo(event); |
2791 | getEventViewerDialog()->showMe(); | 2803 | getEventViewerDialog()->showMe(); |
2792 | } | 2804 | } |
2793 | void CalendarView::showJournal( Journal *jour ) | 2805 | void CalendarView::showJournal( Journal *jour ) |
2794 | { | 2806 | { |
2795 | getEventViewerDialog()->setJournal(jour); | 2807 | getEventViewerDialog()->setJournal(jour); |
2796 | getEventViewerDialog()->showMe(); | 2808 | getEventViewerDialog()->showMe(); |
2797 | 2809 | ||
2798 | } | 2810 | } |
2799 | // void CalendarView::todoModified (Todo *event, int changed) | 2811 | // void CalendarView::todoModified (Todo *event, int changed) |
2800 | // { | 2812 | // { |
2801 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2813 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2802 | // // kdDebug() << "Todo modified and open" << endl; | 2814 | // // kdDebug() << "Todo modified and open" << endl; |
2803 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2815 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2804 | // // temp->modified (changed); | 2816 | // // temp->modified (changed); |
2805 | 2817 | ||
2806 | // // } | 2818 | // // } |
2807 | 2819 | ||
2808 | // mViewManager->updateView(); | 2820 | // mViewManager->updateView(); |
2809 | // } | 2821 | // } |
2810 | 2822 | ||
2811 | void CalendarView::appointment_show() | 2823 | void CalendarView::appointment_show() |
2812 | { | 2824 | { |
2813 | Event *anEvent = 0; | 2825 | Event *anEvent = 0; |
2814 | 2826 | ||
2815 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2827 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2816 | 2828 | ||
2817 | if (mViewManager->currentView()->isEventView()) { | 2829 | if (mViewManager->currentView()->isEventView()) { |
2818 | if ( incidence && incidence->type() == "Event" ) { | 2830 | if ( incidence && incidence->type() == "Event" ) { |
2819 | anEvent = static_cast<Event *>(incidence); | 2831 | anEvent = static_cast<Event *>(incidence); |
2820 | } | 2832 | } |
2821 | } | 2833 | } |
2822 | 2834 | ||
2823 | if (!anEvent) { | 2835 | if (!anEvent) { |
2824 | KNotifyClient::beep(); | 2836 | KNotifyClient::beep(); |
2825 | return; | 2837 | return; |
2826 | } | 2838 | } |
2827 | 2839 | ||
2828 | showEvent(anEvent); | 2840 | showEvent(anEvent); |
2829 | } | 2841 | } |
2830 | 2842 | ||
2831 | void CalendarView::appointment_edit() | 2843 | void CalendarView::appointment_edit() |
2832 | { | 2844 | { |
2833 | Event *anEvent = 0; | 2845 | Event *anEvent = 0; |
2834 | 2846 | ||
2835 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2847 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2836 | 2848 | ||
2837 | if (mViewManager->currentView()->isEventView()) { | 2849 | if (mViewManager->currentView()->isEventView()) { |
2838 | if ( incidence && incidence->type() == "Event" ) { | 2850 | if ( incidence && incidence->type() == "Event" ) { |
2839 | anEvent = static_cast<Event *>(incidence); | 2851 | anEvent = static_cast<Event *>(incidence); |
2840 | } | 2852 | } |
2841 | } | 2853 | } |
2842 | 2854 | ||
2843 | if (!anEvent) { | 2855 | if (!anEvent) { |
2844 | KNotifyClient::beep(); | 2856 | KNotifyClient::beep(); |
2845 | return; | 2857 | return; |
2846 | } | 2858 | } |
2847 | 2859 | ||
2848 | editEvent(anEvent); | 2860 | editEvent(anEvent); |
2849 | } | 2861 | } |
2850 | 2862 | ||
2851 | void CalendarView::appointment_delete() | 2863 | void CalendarView::appointment_delete() |
2852 | { | 2864 | { |
2853 | Event *anEvent = 0; | 2865 | Event *anEvent = 0; |
2854 | 2866 | ||
2855 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2867 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2856 | 2868 | ||
2857 | if (mViewManager->currentView()->isEventView()) { | 2869 | if (mViewManager->currentView()->isEventView()) { |
2858 | if ( incidence && incidence->type() == "Event" ) { | 2870 | if ( incidence && incidence->type() == "Event" ) { |
2859 | anEvent = static_cast<Event *>(incidence); | 2871 | anEvent = static_cast<Event *>(incidence); |
2860 | } | 2872 | } |
2861 | } | 2873 | } |
2862 | 2874 | ||
2863 | if (!anEvent) { | 2875 | if (!anEvent) { |
2864 | KNotifyClient::beep(); | 2876 | KNotifyClient::beep(); |
2865 | return; | 2877 | return; |
2866 | } | 2878 | } |
2867 | 2879 | ||
2868 | deleteEvent(anEvent); | 2880 | deleteEvent(anEvent); |
2869 | } | 2881 | } |
2870 | 2882 | ||
2871 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2883 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2872 | { | 2884 | { |
2873 | if (!sub) return; | 2885 | if (!sub) return; |
2874 | if (!parent) return; | 2886 | if (!parent) return; |
2875 | if ( sub->relatedTo() ) | 2887 | if ( sub->relatedTo() ) |
2876 | sub->relatedTo()->removeRelation(sub); | 2888 | sub->relatedTo()->removeRelation(sub); |
2877 | sub->setRelatedTo(parent); | 2889 | sub->setRelatedTo(parent); |
2878 | sub->setRelatedToUid(parent->uid()); | 2890 | sub->setRelatedToUid(parent->uid()); |
2879 | parent->addRelation(sub); | 2891 | parent->addRelation(sub); |
2880 | sub->updated(); | 2892 | sub->updated(); |
2881 | parent->updated(); | 2893 | parent->updated(); |
2882 | setModified(true); | 2894 | setModified(true); |
2883 | updateView(); | 2895 | updateView(); |
2884 | } | 2896 | } |
2885 | void CalendarView::todo_unsub(Todo *anTodo ) | 2897 | void CalendarView::todo_unsub(Todo *anTodo ) |
2886 | { | 2898 | { |
2887 | // Todo *anTodo = selectedTodo(); | 2899 | // Todo *anTodo = selectedTodo(); |
2888 | if (!anTodo) return; | 2900 | if (!anTodo) return; |
2889 | if (!anTodo->relatedTo()) return; | 2901 | if (!anTodo->relatedTo()) return; |
2890 | anTodo->relatedTo()->removeRelation(anTodo); | 2902 | anTodo->relatedTo()->removeRelation(anTodo); |
2891 | anTodo->setRelatedTo(0); | 2903 | anTodo->setRelatedTo(0); |
2892 | anTodo->updated(); | 2904 | anTodo->updated(); |
2893 | anTodo->setRelatedToUid(""); | 2905 | anTodo->setRelatedToUid(""); |
2894 | setModified(true); | 2906 | setModified(true); |
2895 | updateView(); | 2907 | updateView(); |
2896 | } | 2908 | } |
2897 | 2909 | ||
2898 | void CalendarView::deleteTodo(Todo *todo) | 2910 | void CalendarView::deleteTodo(Todo *todo) |
2899 | { | 2911 | { |
2900 | if (!todo) { | 2912 | if (!todo) { |
2901 | KNotifyClient::beep(); | 2913 | KNotifyClient::beep(); |
2902 | return; | 2914 | return; |
2903 | } | 2915 | } |
2904 | if (KOPrefs::instance()->mConfirm) { | 2916 | if (KOPrefs::instance()->mConfirm) { |
2905 | QString text = todo->summary().left(20); | 2917 | QString text = todo->summary().left(20); |
2906 | if (!todo->relations().isEmpty()) { | 2918 | if (!todo->relations().isEmpty()) { |
2907 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2919 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2908 | 2920 | ||
2909 | } | 2921 | } |
2910 | switch (msgItemDelete(text)) { | 2922 | switch (msgItemDelete(text)) { |
2911 | case KMessageBox::Continue: // OK | 2923 | case KMessageBox::Continue: // OK |
2912 | bool deleteT = false; | 2924 | bool deleteT = false; |
2913 | if (!todo->relations().isEmpty()) { | 2925 | if (!todo->relations().isEmpty()) { |
2914 | deleteT = removeCompletedSubTodos( todo ); | 2926 | deleteT = removeCompletedSubTodos( todo ); |
2915 | } | 2927 | } |
2916 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2928 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2917 | if ( !deleteT ) { | 2929 | if ( !deleteT ) { |
2918 | checkExternalId( todo ); | 2930 | checkExternalId( todo ); |
2919 | calendar()->deleteTodo(todo); | 2931 | calendar()->deleteTodo(todo); |
2920 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2932 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2921 | updateView(); | 2933 | updateView(); |
2922 | } | 2934 | } |
2923 | break; | 2935 | break; |
2924 | } // switch | 2936 | } // switch |
2925 | } else { | 2937 | } else { |
2926 | checkExternalId( todo ); | 2938 | checkExternalId( todo ); |
2927 | mCalendar->deleteTodo(todo); | 2939 | mCalendar->deleteTodo(todo); |
2928 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2940 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2929 | updateView(); | 2941 | updateView(); |
2930 | } | 2942 | } |
2931 | 2943 | ||
2932 | emit updateSearchDialog(); | 2944 | emit updateSearchDialog(); |
2933 | } | 2945 | } |
2934 | void CalendarView::deleteJournal(Journal *jour) | 2946 | void CalendarView::deleteJournal(Journal *jour) |
2935 | { | 2947 | { |
2936 | if (!jour) { | 2948 | if (!jour) { |
2937 | KNotifyClient::beep(); | 2949 | KNotifyClient::beep(); |
2938 | return; | 2950 | return; |
2939 | } | 2951 | } |
2940 | if (KOPrefs::instance()->mConfirm) { | 2952 | if (KOPrefs::instance()->mConfirm) { |
2941 | switch (msgItemDelete( jour->description().left(20))) { | 2953 | switch (msgItemDelete( jour->description().left(20))) { |
2942 | case KMessageBox::Continue: // OK | 2954 | case KMessageBox::Continue: // OK |
2943 | calendar()->deleteJournal(jour); | 2955 | calendar()->deleteJournal(jour); |
2944 | updateView(); | 2956 | updateView(); |
2945 | break; | 2957 | break; |
2946 | } // switch | 2958 | } // switch |
2947 | } else { | 2959 | } else { |
2948 | calendar()->deleteJournal(jour);; | 2960 | calendar()->deleteJournal(jour);; |
2949 | updateView(); | 2961 | updateView(); |
2950 | } | 2962 | } |
2951 | emit updateSearchDialog(); | 2963 | emit updateSearchDialog(); |
2952 | } | 2964 | } |
2953 | 2965 | ||
2954 | void CalendarView::deleteEvent(Event *anEvent) | 2966 | void CalendarView::deleteEvent(Event *anEvent) |
2955 | { | 2967 | { |
2956 | if (!anEvent) { | 2968 | if (!anEvent) { |
2957 | KNotifyClient::beep(); | 2969 | KNotifyClient::beep(); |
2958 | return; | 2970 | return; |
2959 | } | 2971 | } |
2960 | 2972 | ||
2961 | if (anEvent->recurrence()->doesRecur()) { | 2973 | if (anEvent->recurrence()->doesRecur()) { |
2962 | QDate itemDate = mViewManager->currentSelectionDate(); | 2974 | QDate itemDate = mViewManager->currentSelectionDate(); |
2963 | int km; | 2975 | int km; |
2964 | if (!itemDate.isValid()) { | 2976 | if (!itemDate.isValid()) { |
2965 | //kdDebug() << "Date Not Valid" << endl; | 2977 | //kdDebug() << "Date Not Valid" << endl; |
2966 | if (KOPrefs::instance()->mConfirm) { | 2978 | if (KOPrefs::instance()->mConfirm) { |
2967 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2979 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2968 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2980 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2969 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2981 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2970 | if ( km == KMessageBox::Continue ) | 2982 | if ( km == KMessageBox::Continue ) |
2971 | km = KMessageBox::No; // No = all below | 2983 | km = KMessageBox::No; // No = all below |
2972 | } else | 2984 | } else |
2973 | km = KMessageBox::No; | 2985 | km = KMessageBox::No; |
2974 | } else { | 2986 | } else { |
2975 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2987 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2976 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2988 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2977 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2989 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2978 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2990 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2979 | i18n("All")); | 2991 | i18n("All")); |
2980 | } | 2992 | } |
2981 | switch(km) { | 2993 | switch(km) { |
2982 | 2994 | ||
2983 | case KMessageBox::No: // Continue // all | 2995 | case KMessageBox::No: // Continue // all |
2984 | //qDebug("KMessageBox::No "); | 2996 | //qDebug("KMessageBox::No "); |
2985 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2997 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2986 | schedule(Scheduler::Cancel,anEvent); | 2998 | schedule(Scheduler::Cancel,anEvent); |
2987 | 2999 | ||
2988 | checkExternalId( anEvent); | 3000 | checkExternalId( anEvent); |
2989 | mCalendar->deleteEvent(anEvent); | 3001 | mCalendar->deleteEvent(anEvent); |
2990 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3002 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2991 | break; | 3003 | break; |
2992 | 3004 | ||
2993 | // Disabled because it does not work | 3005 | // Disabled because it does not work |
2994 | //#if 0 | 3006 | //#if 0 |
2995 | case KMessageBox::Yes: // just this one | 3007 | case KMessageBox::Yes: // just this one |
2996 | //QDate qd = mNavigator->selectedDates().first(); | 3008 | //QDate qd = mNavigator->selectedDates().first(); |
2997 | //if (!qd.isValid()) { | 3009 | //if (!qd.isValid()) { |
2998 | // kdDebug() << "no date selected, or invalid date" << endl; | 3010 | // kdDebug() << "no date selected, or invalid date" << endl; |
2999 | // KNotifyClient::beep(); | 3011 | // KNotifyClient::beep(); |
3000 | // return; | 3012 | // return; |
3001 | //} | 3013 | //} |
3002 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3014 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3003 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3015 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3004 | anEvent->addExDate(itemDate); | 3016 | anEvent->addExDate(itemDate); |
3005 | int duration = anEvent->recurrence()->duration(); | 3017 | int duration = anEvent->recurrence()->duration(); |
3006 | if ( duration > 0 ) { | 3018 | if ( duration > 0 ) { |
3007 | anEvent->recurrence()->setDuration( duration - 1 ); | 3019 | anEvent->recurrence()->setDuration( duration - 1 ); |
3008 | } | 3020 | } |
3009 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3021 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3010 | } | 3022 | } |
3011 | break; | 3023 | break; |
3012 | //#endif | 3024 | //#endif |
3013 | } // switch | 3025 | } // switch |
3014 | } else { | 3026 | } else { |
3015 | if (KOPrefs::instance()->mConfirm) { | 3027 | if (KOPrefs::instance()->mConfirm) { |
3016 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3028 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3017 | i18n("\nAre you sure you want\nto delete this event?"), | 3029 | i18n("\nAre you sure you want\nto delete this event?"), |
3018 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3030 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3019 | case KMessageBox::Continue: // OK | 3031 | case KMessageBox::Continue: // OK |
3020 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3032 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3021 | schedule(Scheduler::Cancel,anEvent); | 3033 | schedule(Scheduler::Cancel,anEvent); |
3022 | checkExternalId( anEvent); | 3034 | checkExternalId( anEvent); |
3023 | mCalendar->deleteEvent(anEvent); | 3035 | mCalendar->deleteEvent(anEvent); |
3024 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3036 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3025 | break; | 3037 | break; |
3026 | } // switch | 3038 | } // switch |
3027 | } else { | 3039 | } else { |
3028 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3040 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3029 | schedule(Scheduler::Cancel,anEvent); | 3041 | schedule(Scheduler::Cancel,anEvent); |
3030 | checkExternalId( anEvent); | 3042 | checkExternalId( anEvent); |
3031 | mCalendar->deleteEvent(anEvent); | 3043 | mCalendar->deleteEvent(anEvent); |
3032 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3044 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3033 | } | 3045 | } |
3034 | } // if-else | 3046 | } // if-else |
3035 | emit updateSearchDialog(); | 3047 | emit updateSearchDialog(); |
3036 | } | 3048 | } |
3037 | 3049 | ||
3038 | bool CalendarView::deleteEvent(const QString &uid) | 3050 | bool CalendarView::deleteEvent(const QString &uid) |
3039 | { | 3051 | { |
3040 | Event *ev = mCalendar->event(uid); | 3052 | Event *ev = mCalendar->event(uid); |
3041 | if (ev) { | 3053 | if (ev) { |
3042 | deleteEvent(ev); | 3054 | deleteEvent(ev); |
3043 | return true; | 3055 | return true; |
3044 | } else { | 3056 | } else { |
3045 | return false; | 3057 | return false; |
3046 | } | 3058 | } |
3047 | } | 3059 | } |
3048 | 3060 | ||
3049 | /*****************************************************************************/ | 3061 | /*****************************************************************************/ |
3050 | 3062 | ||
3051 | void CalendarView::action_mail() | 3063 | void CalendarView::action_mail() |
3052 | { | 3064 | { |
3053 | #ifndef KORG_NOMAIL | 3065 | #ifndef KORG_NOMAIL |
3054 | KOMailClient mailClient; | 3066 | KOMailClient mailClient; |
3055 | 3067 | ||
3056 | Incidence *incidence = currentSelection(); | 3068 | Incidence *incidence = currentSelection(); |
3057 | 3069 | ||
3058 | if (!incidence) { | 3070 | if (!incidence) { |
3059 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3071 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3060 | return; | 3072 | return; |
3061 | } | 3073 | } |
3062 | if(incidence->attendeeCount() == 0 ) { | 3074 | if(incidence->attendeeCount() == 0 ) { |
3063 | KMessageBox::sorry(this, | 3075 | KMessageBox::sorry(this, |
3064 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3076 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3065 | return; | 3077 | return; |
3066 | } | 3078 | } |
3067 | 3079 | ||
3068 | CalendarLocal cal_tmp; | 3080 | CalendarLocal cal_tmp; |
3069 | Event *event = 0; | 3081 | Event *event = 0; |
3070 | Event *ev = 0; | 3082 | Event *ev = 0; |
3071 | if ( incidence && incidence->type() == "Event" ) { | 3083 | if ( incidence && incidence->type() == "Event" ) { |
3072 | event = static_cast<Event *>(incidence); | 3084 | event = static_cast<Event *>(incidence); |
3073 | ev = new Event(*event); | 3085 | ev = new Event(*event); |
3074 | cal_tmp.addEvent(ev); | 3086 | cal_tmp.addEvent(ev); |
3075 | } | 3087 | } |
3076 | ICalFormat mForm(); | 3088 | ICalFormat mForm(); |
3077 | QString attachment = mForm.toString( &cal_tmp ); | 3089 | QString attachment = mForm.toString( &cal_tmp ); |
3078 | if (ev) delete(ev); | 3090 | if (ev) delete(ev); |
3079 | 3091 | ||
3080 | mailClient.mailAttendees(currentSelection(), attachment); | 3092 | mailClient.mailAttendees(currentSelection(), attachment); |
3081 | 3093 | ||
3082 | #endif | 3094 | #endif |
3083 | 3095 | ||
3084 | #if 0 | 3096 | #if 0 |
3085 | Event *anEvent = 0; | 3097 | Event *anEvent = 0; |
3086 | if (mViewManager->currentView()->isEventView()) { | 3098 | if (mViewManager->currentView()->isEventView()) { |
3087 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3099 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3088 | } | 3100 | } |
3089 | 3101 | ||
3090 | if (!anEvent) { | 3102 | if (!anEvent) { |
3091 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3103 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3092 | return; | 3104 | return; |
3093 | } | 3105 | } |
3094 | if(anEvent->attendeeCount() == 0 ) { | 3106 | if(anEvent->attendeeCount() == 0 ) { |
3095 | KMessageBox::sorry(this, | 3107 | KMessageBox::sorry(this, |
3096 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3108 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3097 | return; | 3109 | return; |
3098 | } | 3110 | } |
3099 | 3111 | ||
3100 | mailobject.emailEvent(anEvent); | 3112 | mailobject.emailEvent(anEvent); |
3101 | #endif | 3113 | #endif |
3102 | } | 3114 | } |
3103 | 3115 | ||
3104 | 3116 | ||
3105 | void CalendarView::schedule_publish(Incidence *incidence) | 3117 | void CalendarView::schedule_publish(Incidence *incidence) |
3106 | { | 3118 | { |
3107 | Event *event = 0; | 3119 | Event *event = 0; |
3108 | Todo *todo = 0; | 3120 | Todo *todo = 0; |
3109 | 3121 | ||
3110 | if (incidence == 0) { | 3122 | if (incidence == 0) { |
3111 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3123 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3112 | if (incidence == 0) { | 3124 | if (incidence == 0) { |
3113 | incidence = mTodoList->selectedIncidences().first(); | 3125 | incidence = mTodoList->selectedIncidences().first(); |
3114 | } | 3126 | } |
3115 | } | 3127 | } |
3116 | if ( incidence && incidence->type() == "Event" ) { | 3128 | if ( incidence && incidence->type() == "Event" ) { |
3117 | event = static_cast<Event *>(incidence); | 3129 | event = static_cast<Event *>(incidence); |
3118 | } else { | 3130 | } else { |
3119 | if ( incidence && incidence->type() == "Todo" ) { | 3131 | if ( incidence && incidence->type() == "Todo" ) { |
3120 | todo = static_cast<Todo *>(incidence); | 3132 | todo = static_cast<Todo *>(incidence); |
3121 | } | 3133 | } |
3122 | } | 3134 | } |
3123 | 3135 | ||
3124 | if (!event && !todo) { | 3136 | if (!event && !todo) { |
3125 | KMessageBox::sorry(this,i18n("No event selected.")); | 3137 | KMessageBox::sorry(this,i18n("No event selected.")); |
3126 | return; | 3138 | return; |
3127 | } | 3139 | } |
3128 | 3140 | ||
3129 | PublishDialog *publishdlg = new PublishDialog(); | 3141 | PublishDialog *publishdlg = new PublishDialog(); |
3130 | if (incidence->attendeeCount()>0) { | 3142 | if (incidence->attendeeCount()>0) { |
3131 | QPtrList<Attendee> attendees = incidence->attendees(); | 3143 | QPtrList<Attendee> attendees = incidence->attendees(); |
3132 | attendees.first(); | 3144 | attendees.first(); |
3133 | while ( attendees.current()!=0 ) { | 3145 | while ( attendees.current()!=0 ) { |
3134 | publishdlg->addAttendee(attendees.current()); | 3146 | publishdlg->addAttendee(attendees.current()); |
3135 | attendees.next(); | 3147 | attendees.next(); |
3136 | } | 3148 | } |
3137 | } | 3149 | } |
3138 | bool send = true; | 3150 | bool send = true; |
3139 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3151 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3140 | if ( publishdlg->exec() != QDialog::Accepted ) | 3152 | if ( publishdlg->exec() != QDialog::Accepted ) |
3141 | send = false; | 3153 | send = false; |
3142 | } | 3154 | } |
3143 | if ( send ) { | 3155 | if ( send ) { |
3144 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3156 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3145 | if ( event ) { | 3157 | if ( event ) { |
3146 | Event *ev = new Event(*event); | 3158 | Event *ev = new Event(*event); |
3147 | ev->registerObserver(0); | 3159 | ev->registerObserver(0); |
3148 | ev->clearAttendees(); | 3160 | ev->clearAttendees(); |
3149 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3161 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3150 | delete(ev); | 3162 | delete(ev); |
3151 | } | 3163 | } |
3152 | } else { | 3164 | } else { |
3153 | if ( todo ) { | 3165 | if ( todo ) { |
3154 | Todo *ev = new Todo(*todo); | 3166 | Todo *ev = new Todo(*todo); |
3155 | ev->registerObserver(0); | 3167 | ev->registerObserver(0); |
3156 | ev->clearAttendees(); | 3168 | ev->clearAttendees(); |
3157 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3169 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3158 | delete(ev); | 3170 | delete(ev); |
3159 | } | 3171 | } |
3160 | } | 3172 | } |
3161 | } | 3173 | } |
3162 | } | 3174 | } |
3163 | delete publishdlg; | 3175 | delete publishdlg; |
3164 | } | 3176 | } |
3165 | 3177 | ||
3166 | void CalendarView::schedule_request(Incidence *incidence) | 3178 | void CalendarView::schedule_request(Incidence *incidence) |
3167 | { | 3179 | { |
3168 | schedule(Scheduler::Request,incidence); | 3180 | schedule(Scheduler::Request,incidence); |
3169 | } | 3181 | } |
3170 | 3182 | ||
3171 | void CalendarView::schedule_refresh(Incidence *incidence) | 3183 | void CalendarView::schedule_refresh(Incidence *incidence) |
3172 | { | 3184 | { |
3173 | schedule(Scheduler::Refresh,incidence); | 3185 | schedule(Scheduler::Refresh,incidence); |
3174 | } | 3186 | } |
3175 | 3187 | ||
3176 | void CalendarView::schedule_cancel(Incidence *incidence) | 3188 | void CalendarView::schedule_cancel(Incidence *incidence) |
3177 | { | 3189 | { |
3178 | schedule(Scheduler::Cancel,incidence); | 3190 | schedule(Scheduler::Cancel,incidence); |
3179 | } | 3191 | } |
3180 | 3192 | ||
3181 | void CalendarView::schedule_add(Incidence *incidence) | 3193 | void CalendarView::schedule_add(Incidence *incidence) |
3182 | { | 3194 | { |
3183 | schedule(Scheduler::Add,incidence); | 3195 | schedule(Scheduler::Add,incidence); |
3184 | } | 3196 | } |
3185 | 3197 | ||
3186 | void CalendarView::schedule_reply(Incidence *incidence) | 3198 | void CalendarView::schedule_reply(Incidence *incidence) |
3187 | { | 3199 | { |
3188 | schedule(Scheduler::Reply,incidence); | 3200 | schedule(Scheduler::Reply,incidence); |
3189 | } | 3201 | } |
3190 | 3202 | ||
3191 | void CalendarView::schedule_counter(Incidence *incidence) | 3203 | void CalendarView::schedule_counter(Incidence *incidence) |
3192 | { | 3204 | { |
3193 | schedule(Scheduler::Counter,incidence); | 3205 | schedule(Scheduler::Counter,incidence); |
3194 | } | 3206 | } |
3195 | 3207 | ||
3196 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3208 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3197 | { | 3209 | { |
3198 | schedule(Scheduler::Declinecounter,incidence); | 3210 | schedule(Scheduler::Declinecounter,incidence); |
3199 | } | 3211 | } |
3200 | 3212 | ||
3201 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3213 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3202 | { | 3214 | { |
3203 | QDateTime start = QDateTime::currentDateTime(); | 3215 | QDateTime start = QDateTime::currentDateTime(); |
3204 | QDateTime end = start.addDays(daysToPublish); | 3216 | QDateTime end = start.addDays(daysToPublish); |
3205 | 3217 | ||
3206 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3218 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3207 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3219 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3208 | 3220 | ||
3209 | 3221 | ||
3210 | PublishDialog *publishdlg = new PublishDialog(); | 3222 | PublishDialog *publishdlg = new PublishDialog(); |
3211 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3223 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3212 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3224 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3213 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3225 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3214 | delete(freebusy); | 3226 | delete(freebusy); |
3215 | } | 3227 | } |
3216 | } | 3228 | } |
3217 | delete publishdlg; | 3229 | delete publishdlg; |
3218 | } | 3230 | } |
3219 | 3231 | ||
3220 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3232 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3221 | { | 3233 | { |
3222 | Event *event = 0; | 3234 | Event *event = 0; |
3223 | Todo *todo = 0; | 3235 | Todo *todo = 0; |
3224 | 3236 | ||
3225 | if (incidence == 0) { | 3237 | if (incidence == 0) { |
3226 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3238 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3227 | if (incidence == 0) { | 3239 | if (incidence == 0) { |
3228 | incidence = mTodoList->selectedIncidences().first(); | 3240 | incidence = mTodoList->selectedIncidences().first(); |
3229 | } | 3241 | } |
3230 | } | 3242 | } |
3231 | if ( incidence && incidence->type() == "Event" ) { | 3243 | if ( incidence && incidence->type() == "Event" ) { |
3232 | event = static_cast<Event *>(incidence); | 3244 | event = static_cast<Event *>(incidence); |
3233 | } | 3245 | } |
3234 | if ( incidence && incidence->type() == "Todo" ) { | 3246 | if ( incidence && incidence->type() == "Todo" ) { |
3235 | todo = static_cast<Todo *>(incidence); | 3247 | todo = static_cast<Todo *>(incidence); |
3236 | } | 3248 | } |
3237 | 3249 | ||
3238 | if (!event && !todo) { | 3250 | if (!event && !todo) { |
3239 | KMessageBox::sorry(this,i18n("No event selected.")); | 3251 | KMessageBox::sorry(this,i18n("No event selected.")); |
3240 | return; | 3252 | return; |
3241 | } | 3253 | } |
3242 | 3254 | ||
3243 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3255 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3244 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3256 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3245 | return; | 3257 | return; |
3246 | } | 3258 | } |
3247 | 3259 | ||
3248 | Event *ev = 0; | 3260 | Event *ev = 0; |
3249 | if (event) ev = new Event(*event); | 3261 | if (event) ev = new Event(*event); |
3250 | Todo *to = 0; | 3262 | Todo *to = 0; |
3251 | if (todo) to = new Todo(*todo); | 3263 | if (todo) to = new Todo(*todo); |
3252 | 3264 | ||
3253 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3265 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3254 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3266 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3255 | if (!me) { | 3267 | if (!me) { |
3256 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3268 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3257 | return; | 3269 | return; |
3258 | } | 3270 | } |
3259 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3271 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3260 | StatusDialog *statdlg = new StatusDialog(this); | 3272 | StatusDialog *statdlg = new StatusDialog(this); |
3261 | if (!statdlg->exec()==QDialog::Accepted) return; | 3273 | if (!statdlg->exec()==QDialog::Accepted) return; |
3262 | me->setStatus( statdlg->status() ); | 3274 | me->setStatus( statdlg->status() ); |
3263 | delete(statdlg); | 3275 | delete(statdlg); |
3264 | } | 3276 | } |
3265 | Attendee *menew = new Attendee(*me); | 3277 | Attendee *menew = new Attendee(*me); |
3266 | if (ev) { | 3278 | if (ev) { |
3267 | ev->clearAttendees(); | 3279 | ev->clearAttendees(); |
3268 | ev->addAttendee(menew,false); | 3280 | ev->addAttendee(menew,false); |
3269 | } else { | 3281 | } else { |
3270 | if (to) { | 3282 | if (to) { |
3271 | todo->clearAttendees(); | 3283 | todo->clearAttendees(); |
3272 | todo->addAttendee(menew,false); | 3284 | todo->addAttendee(menew,false); |
3273 | } | 3285 | } |
3274 | } | 3286 | } |
3275 | } | 3287 | } |
3276 | 3288 | ||
3277 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3289 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3278 | if (ev) { | 3290 | if (ev) { |
3279 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3291 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3280 | } else { | 3292 | } else { |
3281 | if (to) { | 3293 | if (to) { |
3282 | if ( !dlg->addMessage(to,method) ) delete(to); | 3294 | if ( !dlg->addMessage(to,method) ) delete(to); |
3283 | } | 3295 | } |
3284 | } | 3296 | } |
3285 | } | 3297 | } |
3286 | 3298 | ||
3287 | void CalendarView::openAddressbook() | 3299 | void CalendarView::openAddressbook() |
3288 | { | 3300 | { |
3289 | KRun::runCommand("kaddressbook"); | 3301 | KRun::runCommand("kaddressbook"); |
3290 | } | 3302 | } |
3291 | 3303 | ||
3292 | void CalendarView::setModified(bool modified) | 3304 | void CalendarView::setModified(bool modified) |
3293 | { | 3305 | { |
3294 | if ( modified ) | 3306 | if ( modified ) |
3295 | emit signalmodified(); | 3307 | emit signalmodified(); |
3296 | if (mModified != modified) { | 3308 | if (mModified != modified) { |
3297 | mModified = modified; | 3309 | mModified = modified; |
3298 | emit modifiedChanged(mModified); | 3310 | emit modifiedChanged(mModified); |
3299 | } | 3311 | } |
3300 | } | 3312 | } |
3301 | 3313 | ||
3302 | bool CalendarView::isReadOnly() | 3314 | bool CalendarView::isReadOnly() |
3303 | { | 3315 | { |
3304 | return mReadOnly; | 3316 | return mReadOnly; |
3305 | } | 3317 | } |
3306 | 3318 | ||
3307 | void CalendarView::setReadOnly(bool readOnly) | 3319 | void CalendarView::setReadOnly(bool readOnly) |
3308 | { | 3320 | { |
3309 | if (mReadOnly != readOnly) { | 3321 | if (mReadOnly != readOnly) { |
3310 | mReadOnly = readOnly; | 3322 | mReadOnly = readOnly; |
3311 | emit readOnlyChanged(mReadOnly); | 3323 | emit readOnlyChanged(mReadOnly); |
3312 | } | 3324 | } |
3313 | } | 3325 | } |
3314 | 3326 | ||
3315 | bool CalendarView::isModified() | 3327 | bool CalendarView::isModified() |
3316 | { | 3328 | { |
3317 | return mModified; | 3329 | return mModified; |
3318 | } | 3330 | } |
3319 | 3331 | ||
3320 | void CalendarView::printSetup() | 3332 | void CalendarView::printSetup() |
3321 | { | 3333 | { |
3322 | #ifndef KORG_NOPRINTER | 3334 | #ifndef KORG_NOPRINTER |
3323 | createPrinter(); | 3335 | createPrinter(); |
3324 | 3336 | ||
3325 | mCalPrinter->setupPrinter(); | 3337 | mCalPrinter->setupPrinter(); |
3326 | #endif | 3338 | #endif |
3327 | } | 3339 | } |
3328 | 3340 | ||
3329 | void CalendarView::print() | 3341 | void CalendarView::print() |
3330 | { | 3342 | { |
3331 | #ifndef KORG_NOPRINTER | 3343 | #ifndef KORG_NOPRINTER |
3332 | createPrinter(); | 3344 | createPrinter(); |
3333 | 3345 | ||
3334 | DateList tmpDateList = mNavigator->selectedDates(); | 3346 | DateList tmpDateList = mNavigator->selectedDates(); |
3335 | mCalPrinter->print(CalPrinter::Month, | 3347 | mCalPrinter->print(CalPrinter::Month, |
3336 | tmpDateList.first(), tmpDateList.last()); | 3348 | tmpDateList.first(), tmpDateList.last()); |
3337 | #endif | 3349 | #endif |
3338 | } | 3350 | } |
3339 | 3351 | ||
3340 | void CalendarView::printPreview() | 3352 | void CalendarView::printPreview() |
3341 | { | 3353 | { |
3342 | #ifndef KORG_NOPRINTER | 3354 | #ifndef KORG_NOPRINTER |
3343 | kdDebug() << "CalendarView::printPreview()" << endl; | 3355 | kdDebug() << "CalendarView::printPreview()" << endl; |
3344 | 3356 | ||
3345 | createPrinter(); | 3357 | createPrinter(); |
3346 | 3358 | ||
3347 | DateList tmpDateList = mNavigator->selectedDates(); | 3359 | DateList tmpDateList = mNavigator->selectedDates(); |
3348 | 3360 | ||
3349 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3361 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3350 | tmpDateList.last()); | 3362 | tmpDateList.last()); |
3351 | #endif | 3363 | #endif |
3352 | } | 3364 | } |
3353 | 3365 | ||
3354 | void CalendarView::exportICalendar() | 3366 | void CalendarView::exportICalendar() |
3355 | { | 3367 | { |
3356 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3368 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3357 | 3369 | ||
3358 | // Force correct extension | 3370 | // Force correct extension |
3359 | if (filename.right(4) != ".ics") filename += ".ics"; | 3371 | if (filename.right(4) != ".ics") filename += ".ics"; |
3360 | 3372 | ||
3361 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3373 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3362 | storage.save(); | 3374 | storage.save(); |
3363 | } | 3375 | } |
3364 | 3376 | ||
3365 | bool CalendarView::exportVCalendar( QString filename ) | 3377 | bool CalendarView::exportVCalendar( QString filename ) |
3366 | { | 3378 | { |
3367 | if (mCalendar->journals().count() > 0) { | 3379 | if (mCalendar->journals().count() > 0) { |
3368 | int result = KMessageBox::warningContinueCancel(this, | 3380 | int result = KMessageBox::warningContinueCancel(this, |
3369 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3381 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3370 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3382 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3371 | true); | 3383 | true); |
3372 | if (result != KMessageBox::Continue) return false; | 3384 | if (result != KMessageBox::Continue) return false; |
3373 | } | 3385 | } |
3374 | 3386 | ||
3375 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3387 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3376 | 3388 | ||
3377 | // Force correct extension | 3389 | // Force correct extension |
3378 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3390 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3379 | 3391 | ||
3380 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3392 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3381 | return storage.save(); | 3393 | return storage.save(); |
3382 | 3394 | ||
3383 | } | 3395 | } |
3384 | 3396 | ||
3385 | void CalendarView::eventUpdated(Incidence *) | 3397 | void CalendarView::eventUpdated(Incidence *) |
3386 | { | 3398 | { |
3387 | setModified(); | 3399 | setModified(); |
3388 | // Don't call updateView here. The code, which has caused the update of the | 3400 | // Don't call updateView here. The code, which has caused the update of the |
3389 | // event is responsible for updating the view. | 3401 | // event is responsible for updating the view. |
3390 | // updateView(); | 3402 | // updateView(); |
3391 | } | 3403 | } |
3392 | 3404 | ||
3393 | void CalendarView::adaptNavigationUnits() | 3405 | void CalendarView::adaptNavigationUnits() |
3394 | { | 3406 | { |
3395 | if (mViewManager->currentView()->isEventView()) { | 3407 | if (mViewManager->currentView()->isEventView()) { |
3396 | int days = mViewManager->currentView()->currentDateCount(); | 3408 | int days = mViewManager->currentView()->currentDateCount(); |
3397 | if (days == 1) { | 3409 | if (days == 1) { |
3398 | emit changeNavStringPrev(i18n("&Previous Day")); | 3410 | emit changeNavStringPrev(i18n("&Previous Day")); |
3399 | emit changeNavStringNext(i18n("&Next Day")); | 3411 | emit changeNavStringNext(i18n("&Next Day")); |
3400 | } else { | 3412 | } else { |
3401 | emit changeNavStringPrev(i18n("&Previous Week")); | 3413 | emit changeNavStringPrev(i18n("&Previous Week")); |
3402 | emit changeNavStringNext(i18n("&Next Week")); | 3414 | emit changeNavStringNext(i18n("&Next Week")); |
3403 | } | 3415 | } |
3404 | } | 3416 | } |
3405 | } | 3417 | } |
3406 | 3418 | ||
3407 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3419 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3408 | { | 3420 | { |
3409 | if ( incidence ) mTodoList->clearSelection(); | 3421 | if ( incidence ) mTodoList->clearSelection(); |
3410 | processIncidenceSelection( incidence ); | 3422 | processIncidenceSelection( incidence ); |
3411 | } | 3423 | } |
3412 | 3424 | ||
3413 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3425 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3414 | { | 3426 | { |
3415 | if ( incidence && mViewManager->currentView() ) { | 3427 | if ( incidence && mViewManager->currentView() ) { |
3416 | mViewManager->currentView()->clearSelection(); | 3428 | mViewManager->currentView()->clearSelection(); |
3417 | } | 3429 | } |
3418 | processIncidenceSelection( incidence ); | 3430 | processIncidenceSelection( incidence ); |
3419 | } | 3431 | } |
3420 | 3432 | ||
3421 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3433 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3422 | { | 3434 | { |
3423 | if ( incidence == mSelectedIncidence ) return; | 3435 | if ( incidence == mSelectedIncidence ) return; |
3424 | 3436 | ||
3425 | mSelectedIncidence = incidence; | 3437 | mSelectedIncidence = incidence; |
3426 | 3438 | ||
3427 | emit incidenceSelected( mSelectedIncidence ); | 3439 | emit incidenceSelected( mSelectedIncidence ); |
3428 | 3440 | ||
3429 | if ( incidence && incidence->type() == "Event" ) { | 3441 | if ( incidence && incidence->type() == "Event" ) { |
3430 | Event *event = static_cast<Event *>( incidence ); | 3442 | Event *event = static_cast<Event *>( incidence ); |
3431 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3443 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3432 | emit organizerEventsSelected( true ); | 3444 | emit organizerEventsSelected( true ); |
3433 | } else { | 3445 | } else { |
3434 | emit organizerEventsSelected(false); | 3446 | emit organizerEventsSelected(false); |
3435 | } | 3447 | } |
3436 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3448 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3437 | KOPrefs::instance()->email() ) ) { | 3449 | KOPrefs::instance()->email() ) ) { |
3438 | emit groupEventsSelected( true ); | 3450 | emit groupEventsSelected( true ); |
3439 | } else { | 3451 | } else { |
3440 | emit groupEventsSelected(false); | 3452 | emit groupEventsSelected(false); |
3441 | } | 3453 | } |
3442 | return; | 3454 | return; |
3443 | } else { | 3455 | } else { |
3444 | if ( incidence && incidence->type() == "Todo" ) { | 3456 | if ( incidence && incidence->type() == "Todo" ) { |
3445 | emit todoSelected( true ); | 3457 | emit todoSelected( true ); |
3446 | Todo *event = static_cast<Todo *>( incidence ); | 3458 | Todo *event = static_cast<Todo *>( incidence ); |
3447 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3459 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3448 | emit organizerEventsSelected( true ); | 3460 | emit organizerEventsSelected( true ); |
3449 | } else { | 3461 | } else { |
3450 | emit organizerEventsSelected(false); | 3462 | emit organizerEventsSelected(false); |
3451 | } | 3463 | } |
3452 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3464 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3453 | KOPrefs::instance()->email() ) ) { | 3465 | KOPrefs::instance()->email() ) ) { |
3454 | emit groupEventsSelected( true ); | 3466 | emit groupEventsSelected( true ); |
3455 | } else { | 3467 | } else { |
3456 | emit groupEventsSelected(false); | 3468 | emit groupEventsSelected(false); |
3457 | } | 3469 | } |
3458 | return; | 3470 | return; |
3459 | } else { | 3471 | } else { |
3460 | emit todoSelected( false ); | 3472 | emit todoSelected( false ); |
3461 | emit organizerEventsSelected(false); | 3473 | emit organizerEventsSelected(false); |
3462 | emit groupEventsSelected(false); | 3474 | emit groupEventsSelected(false); |
3463 | } | 3475 | } |
3464 | return; | 3476 | return; |
3465 | } | 3477 | } |
3466 | 3478 | ||
3467 | /* if ( incidence && incidence->type() == "Todo" ) { | 3479 | /* if ( incidence && incidence->type() == "Todo" ) { |
3468 | emit todoSelected( true ); | 3480 | emit todoSelected( true ); |
3469 | } else { | 3481 | } else { |
3470 | emit todoSelected( false ); | 3482 | emit todoSelected( false ); |
3471 | }*/ | 3483 | }*/ |
3472 | } | 3484 | } |
3473 | 3485 | ||
3474 | 3486 | ||
3475 | void CalendarView::checkClipboard() | 3487 | void CalendarView::checkClipboard() |
3476 | { | 3488 | { |
3477 | #ifndef KORG_NODND | 3489 | #ifndef KORG_NODND |
3478 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3490 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3479 | emit pasteEnabled(true); | 3491 | emit pasteEnabled(true); |
3480 | } else { | 3492 | } else { |
3481 | emit pasteEnabled(false); | 3493 | emit pasteEnabled(false); |
3482 | } | 3494 | } |
3483 | #endif | 3495 | #endif |
3484 | } | 3496 | } |
3485 | 3497 | ||
3486 | void CalendarView::showDates(const DateList &selectedDates) | 3498 | void CalendarView::showDates(const DateList &selectedDates) |
3487 | { | 3499 | { |
3488 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3500 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3489 | 3501 | ||
3490 | 3502 | ||
3491 | if ( !mBlockShowDates ) { | 3503 | if ( !mBlockShowDates ) { |
3492 | if ( mViewManager->currentView() ) { | 3504 | if ( mViewManager->currentView() ) { |
3493 | updateView( selectedDates.first(), selectedDates.last() ); | 3505 | updateView( selectedDates.first(), selectedDates.last() ); |
3494 | } else { | 3506 | } else { |
3495 | mViewManager->showAgendaView(); | 3507 | mViewManager->showAgendaView(); |
3496 | } | 3508 | } |
3497 | } | 3509 | } |
3498 | 3510 | ||
3499 | QString selDates; | 3511 | QString selDates; |
3500 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3512 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3501 | if (selectedDates.first() < selectedDates.last() ) | 3513 | if (selectedDates.first() < selectedDates.last() ) |
3502 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3514 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3503 | else { | 3515 | else { |
3504 | QString addString; | 3516 | QString addString; |
3505 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3517 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3506 | addString = i18n("Today"); | 3518 | addString = i18n("Today"); |
3507 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3519 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3508 | addString = i18n("Tomorrow"); | 3520 | addString = i18n("Tomorrow"); |
3509 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3521 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3510 | addString = i18n("Yesterday"); | 3522 | addString = i18n("Yesterday"); |
3511 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3523 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3512 | addString = i18n("Day before yesterday"); | 3524 | addString = i18n("Day before yesterday"); |
3513 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3525 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3514 | addString = i18n("Day after tomorrow"); | 3526 | addString = i18n("Day after tomorrow"); |
3515 | if ( !addString.isEmpty() ) { | 3527 | if ( !addString.isEmpty() ) { |
3516 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3528 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3517 | return; | 3529 | return; |
3518 | } | 3530 | } |
3519 | } | 3531 | } |
3520 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3532 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3521 | 3533 | ||
3522 | } | 3534 | } |
3523 | 3535 | ||
3524 | QPtrList<CalFilter> CalendarView::filters() | 3536 | QPtrList<CalFilter> CalendarView::filters() |
3525 | { | 3537 | { |
3526 | return mFilters; | 3538 | return mFilters; |
3527 | 3539 | ||
3528 | } | 3540 | } |
3529 | void CalendarView::editFilters() | 3541 | void CalendarView::editFilters() |
3530 | { | 3542 | { |
3531 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3543 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3532 | 3544 | ||
3533 | CalFilter *filter = mFilters.first(); | 3545 | CalFilter *filter = mFilters.first(); |
3534 | while(filter) { | 3546 | while(filter) { |
3535 | kdDebug() << " Filter: " << filter->name() << endl; | 3547 | kdDebug() << " Filter: " << filter->name() << endl; |
3536 | filter = mFilters.next(); | 3548 | filter = mFilters.next(); |
3537 | } | 3549 | } |
3538 | 3550 | ||
3539 | mDialogManager->showFilterEditDialog(&mFilters); | 3551 | mDialogManager->showFilterEditDialog(&mFilters); |
3540 | } | 3552 | } |
3541 | void CalendarView::toggleFilter() | 3553 | void CalendarView::toggleFilter() |
3542 | { | 3554 | { |
3543 | showFilter(! mFilterView->isVisible()); | 3555 | showFilter(! mFilterView->isVisible()); |
3544 | } | 3556 | } |
3545 | 3557 | ||
3546 | KOFilterView *CalendarView::filterView() | 3558 | KOFilterView *CalendarView::filterView() |
3547 | { | 3559 | { |
3548 | return mFilterView; | 3560 | return mFilterView; |
3549 | } | 3561 | } |
3550 | void CalendarView::selectFilter( int fil ) | 3562 | void CalendarView::selectFilter( int fil ) |
3551 | { | 3563 | { |
3552 | mFilterView->setSelectedFilter( fil ); | 3564 | mFilterView->setSelectedFilter( fil ); |
3553 | } | 3565 | } |
3554 | void CalendarView::showFilter(bool visible) | 3566 | void CalendarView::showFilter(bool visible) |
3555 | { | 3567 | { |
3556 | if (visible) mFilterView->show(); | 3568 | if (visible) mFilterView->show(); |
3557 | else mFilterView->hide(); | 3569 | else mFilterView->hide(); |
3558 | } | 3570 | } |
3559 | void CalendarView::toggleFilerEnabled( ) | 3571 | void CalendarView::toggleFilerEnabled( ) |
3560 | { | 3572 | { |
3561 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3573 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3562 | if ( !mFilterView->filtersEnabled() ) | 3574 | if ( !mFilterView->filtersEnabled() ) |
3563 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3575 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3564 | 3576 | ||
3565 | } | 3577 | } |
3566 | void CalendarView::updateFilter() | 3578 | void CalendarView::updateFilter() |
3567 | { | 3579 | { |
3568 | CalFilter *filter = mFilterView->selectedFilter(); | 3580 | CalFilter *filter = mFilterView->selectedFilter(); |
3569 | if (filter) { | 3581 | if (filter) { |
3570 | if (mFilterView->filtersEnabled()) { | 3582 | if (mFilterView->filtersEnabled()) { |
3571 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3583 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3572 | filter->setEnabled(true); | 3584 | filter->setEnabled(true); |
3573 | } | 3585 | } |
3574 | else filter->setEnabled(false); | 3586 | else filter->setEnabled(false); |
3575 | mCalendar->setFilter(filter); | 3587 | mCalendar->setFilter(filter); |
3576 | updateView(); | 3588 | updateView(); |
3577 | } | 3589 | } |
3578 | } | 3590 | } |
3579 | 3591 | ||
3580 | void CalendarView::filterEdited() | 3592 | void CalendarView::filterEdited() |
3581 | { | 3593 | { |
3582 | mFilterView->updateFilters(); | 3594 | mFilterView->updateFilters(); |
3583 | updateFilter(); | 3595 | updateFilter(); |
3584 | writeSettings(); | 3596 | writeSettings(); |
3585 | } | 3597 | } |
3586 | 3598 | ||
3587 | 3599 | ||
3588 | void CalendarView::takeOverEvent() | 3600 | void CalendarView::takeOverEvent() |
3589 | { | 3601 | { |
3590 | Incidence *incidence = currentSelection(); | 3602 | Incidence *incidence = currentSelection(); |
3591 | 3603 | ||
3592 | if (!incidence) return; | 3604 | if (!incidence) return; |
3593 | 3605 | ||
3594 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3606 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3595 | incidence->recreate(); | 3607 | incidence->recreate(); |
3596 | incidence->setReadOnly(false); | 3608 | incidence->setReadOnly(false); |
3597 | 3609 | ||
3598 | updateView(); | 3610 | updateView(); |
3599 | } | 3611 | } |
3600 | 3612 | ||
3601 | void CalendarView::takeOverCalendar() | 3613 | void CalendarView::takeOverCalendar() |
3602 | { | 3614 | { |
3603 | // TODO: Create Calendar::allIncidences() function and use it here | 3615 | // TODO: Create Calendar::allIncidences() function and use it here |
3604 | 3616 | ||
3605 | QPtrList<Event> events = mCalendar->events(); | 3617 | QPtrList<Event> events = mCalendar->events(); |
3606 | for(uint i=0; i<events.count(); ++i) { | 3618 | for(uint i=0; i<events.count(); ++i) { |
3607 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3619 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3608 | events.at(i)->recreate(); | 3620 | events.at(i)->recreate(); |
3609 | events.at(i)->setReadOnly(false); | 3621 | events.at(i)->setReadOnly(false); |
3610 | } | 3622 | } |
3611 | 3623 | ||
3612 | QPtrList<Todo> todos = mCalendar->todos(); | 3624 | QPtrList<Todo> todos = mCalendar->todos(); |
3613 | for(uint i=0; i<todos.count(); ++i) { | 3625 | for(uint i=0; i<todos.count(); ++i) { |
3614 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3626 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3615 | todos.at(i)->recreate(); | 3627 | todos.at(i)->recreate(); |
3616 | todos.at(i)->setReadOnly(false); | 3628 | todos.at(i)->setReadOnly(false); |
3617 | } | 3629 | } |
3618 | 3630 | ||
3619 | QPtrList<Journal> journals = mCalendar->journals(); | 3631 | QPtrList<Journal> journals = mCalendar->journals(); |
3620 | for(uint i=0; i<journals.count(); ++i) { | 3632 | for(uint i=0; i<journals.count(); ++i) { |
3621 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3633 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3622 | journals.at(i)->recreate(); | 3634 | journals.at(i)->recreate(); |
3623 | journals.at(i)->setReadOnly(false); | 3635 | journals.at(i)->setReadOnly(false); |
3624 | } | 3636 | } |
3625 | 3637 | ||
3626 | updateView(); | 3638 | updateView(); |
3627 | } | 3639 | } |
3628 | 3640 | ||
3629 | void CalendarView::showIntro() | 3641 | void CalendarView::showIntro() |
3630 | { | 3642 | { |
3631 | kdDebug() << "To be implemented." << endl; | 3643 | kdDebug() << "To be implemented." << endl; |
3632 | } | 3644 | } |
3633 | 3645 | ||
3634 | QWidgetStack *CalendarView::viewStack() | 3646 | QWidgetStack *CalendarView::viewStack() |
3635 | { | 3647 | { |
3636 | return mRightFrame; | 3648 | return mRightFrame; |
3637 | } | 3649 | } |
3638 | 3650 | ||
3639 | QWidget *CalendarView::leftFrame() | 3651 | QWidget *CalendarView::leftFrame() |
3640 | { | 3652 | { |
3641 | return mLeftFrame; | 3653 | return mLeftFrame; |
3642 | } | 3654 | } |
3643 | 3655 | ||
3644 | DateNavigator *CalendarView::dateNavigator() | 3656 | DateNavigator *CalendarView::dateNavigator() |
3645 | { | 3657 | { |
3646 | return mNavigator; | 3658 | return mNavigator; |
3647 | } | 3659 | } |
3648 | 3660 | ||
3649 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3661 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3650 | { | 3662 | { |
3651 | return mDateNavigator; | 3663 | return mDateNavigator; |
3652 | } | 3664 | } |
3653 | void CalendarView::toggleDateNavigatorWidget() | 3665 | void CalendarView::toggleDateNavigatorWidget() |
3654 | { | 3666 | { |
3655 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3667 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3656 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3668 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3657 | mDateNavigator->hide(); | 3669 | mDateNavigator->hide(); |
3658 | else | 3670 | else |
3659 | mDateNavigator->show(); | 3671 | mDateNavigator->show(); |
3660 | } | 3672 | } |
3661 | void CalendarView::addView(KOrg::BaseView *view) | 3673 | void CalendarView::addView(KOrg::BaseView *view) |
3662 | { | 3674 | { |
3663 | mViewManager->addView(view); | 3675 | mViewManager->addView(view); |
3664 | } | 3676 | } |
3665 | 3677 | ||
3666 | void CalendarView::showView(KOrg::BaseView *view) | 3678 | void CalendarView::showView(KOrg::BaseView *view) |
3667 | { | 3679 | { |
3668 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3680 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3669 | } | 3681 | } |
3670 | 3682 | ||
3671 | Incidence *CalendarView::currentSelection() | 3683 | Incidence *CalendarView::currentSelection() |
3672 | { | 3684 | { |
3673 | return mViewManager->currentSelection(); | 3685 | return mViewManager->currentSelection(); |
3674 | } | 3686 | } |
3675 | void CalendarView::toggleAllDaySize() | 3687 | void CalendarView::toggleAllDaySize() |
3676 | { | 3688 | { |
3677 | /* | 3689 | /* |
3678 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3690 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3679 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3691 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3680 | else | 3692 | else |
3681 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3693 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3682 | */ | 3694 | */ |
3683 | viewManager()->agendaView()->toggleAllDay(); | 3695 | viewManager()->agendaView()->toggleAllDay(); |
3684 | } | 3696 | } |
3685 | void CalendarView::toggleExpand() | 3697 | void CalendarView::toggleExpand() |
3686 | { | 3698 | { |
3687 | // if ( mLeftFrame->isHidden() ) { | 3699 | // if ( mLeftFrame->isHidden() ) { |
3688 | // mLeftFrame->show(); | 3700 | // mLeftFrame->show(); |
3689 | // emit calendarViewExpanded( false ); | 3701 | // emit calendarViewExpanded( false ); |
3690 | // } else { | 3702 | // } else { |
3691 | // mLeftFrame->hide(); | 3703 | // mLeftFrame->hide(); |
3692 | // emit calendarViewExpanded( true ); | 3704 | // emit calendarViewExpanded( true ); |
3693 | // } | 3705 | // } |
3694 | //qDebug(" CalendarView::toggleExpand()"); | 3706 | //qDebug(" CalendarView::toggleExpand()"); |
3695 | globalFlagBlockAgenda = 1; | 3707 | globalFlagBlockAgenda = 1; |
3696 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3708 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3697 | globalFlagBlockAgenda = 5; | 3709 | globalFlagBlockAgenda = 5; |
3698 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3710 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3699 | //mViewManager->showView( 0, true ); | 3711 | //mViewManager->showView( 0, true ); |
3700 | } | 3712 | } |
3701 | 3713 | ||
3702 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3714 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3703 | { | 3715 | { |
3704 | setModified( modified ); | 3716 | setModified( modified ); |
3705 | } | 3717 | } |
3706 | 3718 | ||
3707 | Todo *CalendarView::selectedTodo() | 3719 | Todo *CalendarView::selectedTodo() |
3708 | { | 3720 | { |
3709 | Incidence *incidence = currentSelection(); | 3721 | Incidence *incidence = currentSelection(); |
3710 | if ( incidence && incidence->type() == "Todo" ) { | 3722 | if ( incidence && incidence->type() == "Todo" ) { |
3711 | return static_cast<Todo *>( incidence ); | 3723 | return static_cast<Todo *>( incidence ); |
3712 | } | 3724 | } |
3713 | 3725 | ||
3714 | incidence = mTodoList->selectedIncidences().first(); | 3726 | incidence = mTodoList->selectedIncidences().first(); |
3715 | if ( incidence && incidence->type() == "Todo" ) { | 3727 | if ( incidence && incidence->type() == "Todo" ) { |
3716 | return static_cast<Todo *>( incidence ); | 3728 | return static_cast<Todo *>( incidence ); |
3717 | } | 3729 | } |
3718 | 3730 | ||
3719 | return 0; | 3731 | return 0; |
3720 | } | 3732 | } |
3721 | 3733 | ||
3722 | void CalendarView::dialogClosing(Incidence *in) | 3734 | void CalendarView::dialogClosing(Incidence *in) |
3723 | { | 3735 | { |
3724 | // mDialogList.remove(in); | 3736 | // mDialogList.remove(in); |
3725 | } | 3737 | } |
3726 | 3738 | ||
3727 | void CalendarView::showIncidence() | 3739 | void CalendarView::showIncidence() |
3728 | { | 3740 | { |
3729 | Incidence *incidence = currentSelection(); | 3741 | Incidence *incidence = currentSelection(); |
3730 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3742 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3731 | if ( incidence ) { | 3743 | if ( incidence ) { |
3732 | ShowIncidenceVisitor v; | 3744 | ShowIncidenceVisitor v; |
3733 | v.act( incidence, this ); | 3745 | v.act( incidence, this ); |
3734 | } | 3746 | } |
3735 | } | 3747 | } |
3736 | void CalendarView::editIncidenceDescription() | 3748 | void CalendarView::editIncidenceDescription() |
3737 | { | 3749 | { |
3738 | mFlagEditDescription = true; | 3750 | mFlagEditDescription = true; |
3739 | editIncidence(); | 3751 | editIncidence(); |
3740 | mFlagEditDescription = false; | 3752 | mFlagEditDescription = false; |
3741 | } | 3753 | } |
3742 | void CalendarView::editIncidence() | 3754 | void CalendarView::editIncidence() |
3743 | { | 3755 | { |
3744 | // qDebug("editIncidence() "); | 3756 | // qDebug("editIncidence() "); |
3745 | Incidence *incidence = currentSelection(); | 3757 | Incidence *incidence = currentSelection(); |
3746 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3758 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3747 | if ( incidence ) { | 3759 | if ( incidence ) { |
3748 | EditIncidenceVisitor v; | 3760 | EditIncidenceVisitor v; |
3749 | v.act( incidence, this ); | 3761 | v.act( incidence, this ); |
3750 | } | 3762 | } |
3751 | } | 3763 | } |
3752 | 3764 | ||
3753 | void CalendarView::deleteIncidence() | 3765 | void CalendarView::deleteIncidence() |
3754 | { | 3766 | { |
3755 | Incidence *incidence = currentSelection(); | 3767 | Incidence *incidence = currentSelection(); |
3756 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3768 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3757 | if ( incidence ) { | 3769 | if ( incidence ) { |
3758 | deleteIncidence(incidence); | 3770 | deleteIncidence(incidence); |
3759 | } | 3771 | } |
3760 | } | 3772 | } |
3761 | 3773 | ||
3762 | void CalendarView::showIncidence(Incidence *incidence) | 3774 | void CalendarView::showIncidence(Incidence *incidence) |
3763 | { | 3775 | { |
3764 | if ( incidence ) { | 3776 | if ( incidence ) { |
3765 | ShowIncidenceVisitor v; | 3777 | ShowIncidenceVisitor v; |
3766 | v.act( incidence, this ); | 3778 | v.act( incidence, this ); |
3767 | } | 3779 | } |
3768 | } | 3780 | } |
3769 | 3781 | ||
3770 | void CalendarView::editIncidence(Incidence *incidence) | 3782 | void CalendarView::editIncidence(Incidence *incidence) |
3771 | { | 3783 | { |
3772 | if ( incidence ) { | 3784 | if ( incidence ) { |
3773 | 3785 | ||
3774 | EditIncidenceVisitor v; | 3786 | EditIncidenceVisitor v; |
3775 | v.act( incidence, this ); | 3787 | v.act( incidence, this ); |
3776 | 3788 | ||
3777 | } | 3789 | } |
3778 | } | 3790 | } |
3779 | 3791 | ||
3780 | void CalendarView::deleteIncidence(Incidence *incidence) | 3792 | void CalendarView::deleteIncidence(Incidence *incidence) |
3781 | { | 3793 | { |
3782 | //qDebug(" CalendarView::deleteIncidence "); | 3794 | //qDebug(" CalendarView::deleteIncidence "); |
3783 | if ( incidence ) { | 3795 | if ( incidence ) { |
3784 | DeleteIncidenceVisitor v; | 3796 | DeleteIncidenceVisitor v; |
3785 | v.act( incidence, this ); | 3797 | v.act( incidence, this ); |
3786 | } | 3798 | } |
3787 | } | 3799 | } |
3788 | 3800 | ||
3789 | 3801 | ||
3790 | void CalendarView::lookForOutgoingMessages() | 3802 | void CalendarView::lookForOutgoingMessages() |
3791 | { | 3803 | { |
3792 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3804 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3793 | ogd->loadMessages(); | 3805 | ogd->loadMessages(); |
3794 | } | 3806 | } |
3795 | 3807 | ||
3796 | void CalendarView::lookForIncomingMessages() | 3808 | void CalendarView::lookForIncomingMessages() |
3797 | { | 3809 | { |
3798 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3810 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3799 | icd->retrieve(); | 3811 | icd->retrieve(); |
3800 | } | 3812 | } |
3801 | 3813 | ||
3802 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3814 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3803 | { | 3815 | { |
3804 | bool deleteTodo = true; | 3816 | bool deleteTodo = true; |
3805 | QPtrList<Incidence> subTodos; | 3817 | QPtrList<Incidence> subTodos; |
3806 | Incidence *aTodo; | 3818 | Incidence *aTodo; |
3807 | subTodos = t->relations(); | 3819 | subTodos = t->relations(); |
3808 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3820 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3809 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3821 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3810 | deleteTodo = false; | 3822 | deleteTodo = false; |
3811 | } | 3823 | } |
3812 | if ( deleteTodo ) { | 3824 | if ( deleteTodo ) { |
3813 | if ( t->isCompleted() ) { | 3825 | if ( t->isCompleted() && !t->doesRecur()) { |
3814 | checkExternalId( t ); | 3826 | checkExternalId( t ); |
3815 | mCalendar->deleteTodo( t ); | 3827 | mCalendar->deleteTodo( t ); |
3816 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3828 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3817 | } | 3829 | } |
3818 | else | 3830 | else |
3819 | deleteTodo = false; | 3831 | deleteTodo = false; |
3820 | } | 3832 | } |
3821 | return deleteTodo; | 3833 | return deleteTodo; |
3822 | 3834 | ||
3823 | } | 3835 | } |
3824 | void CalendarView::purgeCompleted() | 3836 | void CalendarView::purgeCompleted() |
3825 | { | 3837 | { |
3826 | int result = KMessageBox::warningContinueCancel(this, | 3838 | int result = KMessageBox::warningContinueCancel(this, |
3827 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3839 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3828 | 3840 | ||
3829 | if (result == KMessageBox::Continue) { | 3841 | if (result == KMessageBox::Continue) { |
3830 | 3842 | ||
3831 | QPtrList<Todo> todoCal; | 3843 | QPtrList<Todo> todoCal; |
3832 | QPtrList<Todo> rootTodos; | 3844 | QPtrList<Todo> rootTodos; |
3833 | //QPtrList<Incidence> rel; | 3845 | //QPtrList<Incidence> rel; |
3834 | Todo *aTodo;//, *rTodo; | 3846 | Todo *aTodo;//, *rTodo; |
3835 | Incidence *rIncidence; | 3847 | Incidence *rIncidence; |
3836 | bool childDelete = false; | 3848 | bool childDelete = false; |
3837 | bool deletedOne = true; | 3849 | bool deletedOne = true; |
3838 | todoCal = calendar()->todos(); | 3850 | todoCal = calendar()->todos(); |
3839 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3851 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3840 | if ( !aTodo->relatedTo() ) | 3852 | if ( !aTodo->relatedTo() ) |
3841 | rootTodos.append( aTodo ); | 3853 | rootTodos.append( aTodo ); |
3842 | } | 3854 | } |
3843 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3855 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3844 | removeCompletedSubTodos( aTodo ); | 3856 | removeCompletedSubTodos( aTodo ); |
3845 | } | 3857 | } |
3846 | 3858 | ||
3847 | updateView(); | 3859 | updateView(); |
3848 | } | 3860 | } |
3849 | } | 3861 | } |
3850 | 3862 | ||
3851 | void CalendarView::slotCalendarChanged() | 3863 | void CalendarView::slotCalendarChanged() |
3852 | { | 3864 | { |
3853 | ; | 3865 | ; |
3854 | } | 3866 | } |
3855 | 3867 | ||
3856 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3868 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3857 | { | 3869 | { |
3858 | //qDebug(" alendarView::keyPressEvent "); | 3870 | //qDebug(" alendarView::keyPressEvent "); |
3859 | e->ignore(); | 3871 | e->ignore(); |
3860 | } | 3872 | } |
3861 | 3873 | ||
3862 | 3874 | ||
3863 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3875 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3864 | { | 3876 | { |
3865 | // mSyncManager = manager; | 3877 | // mSyncManager = manager; |
3866 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3878 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3867 | qDebug("KO: SyncKDE request detected!"); | 3879 | qDebug("KO: SyncKDE request detected!"); |
3868 | } | 3880 | } |
3869 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3881 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3870 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3882 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3871 | return syncCalendar( filename, mode ); | 3883 | return syncCalendar( filename, mode ); |
3872 | } | 3884 | } |
3873 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3885 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3874 | { | 3886 | { |
3875 | //mSyncManager = manager; | 3887 | //mSyncManager = manager; |
3876 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3888 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3877 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3889 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3878 | if ( resource == "sharp" ) | 3890 | if ( resource == "sharp" ) |
3879 | syncExternal( 0 ); | 3891 | syncExternal( 0 ); |
3880 | if ( resource == "phone" ) | 3892 | if ( resource == "phone" ) |
3881 | syncExternal( 1 ); | 3893 | syncExternal( 1 ); |
3882 | // pending setmodified | 3894 | // pending setmodified |
3883 | return true; | 3895 | return true; |
3884 | } | 3896 | } |
3885 | void CalendarView::setSyncManager(KSyncManager* manager) | 3897 | void CalendarView::setSyncManager(KSyncManager* manager) |
3886 | { | 3898 | { |
3887 | mSyncManager = manager; | 3899 | mSyncManager = manager; |
3888 | } | 3900 | } |
3889 | 3901 | ||
3890 | void CalendarView::removeSyncInfo( QString syncProfile) | 3902 | void CalendarView::removeSyncInfo( QString syncProfile) |
3891 | { | 3903 | { |
3892 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3904 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3893 | mCalendar->removeSyncInfo( syncProfile ); | 3905 | mCalendar->removeSyncInfo( syncProfile ); |
3894 | 3906 | ||
3895 | } | 3907 | } |
3896 | 3908 | ||
3897 | void CalendarView::undo_delete() | 3909 | void CalendarView::undo_delete() |
3898 | { | 3910 | { |
3899 | //qDebug("undo_delete() "); | 3911 | //qDebug("undo_delete() "); |
3900 | Incidence* undo = mCalendar->undoIncidence(); | 3912 | Incidence* undo = mCalendar->undoIncidence(); |
3901 | if ( !undo ) { | 3913 | if ( !undo ) { |
3902 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3914 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3903 | i18n("KO/Pi")); | 3915 | i18n("KO/Pi")); |
3904 | return; | 3916 | return; |
3905 | } | 3917 | } |
3906 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3918 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3907 | i18n("\nAre you sure you want\nto restore this?"), | 3919 | i18n("\nAre you sure you want\nto restore this?"), |
3908 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3920 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3909 | mCalendar->undoDeleteIncidence(); | 3921 | mCalendar->undoDeleteIncidence(); |
3910 | updateView(); | 3922 | updateView(); |
3911 | } | 3923 | } |
3912 | } | 3924 | } |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 13d8398..4ff6899 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1589 +1,1602 @@ | |||
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 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qframe.h> | 27 | #include <qframe.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #ifndef KORG_NOSPLITTER | 29 | #ifndef KORG_NOSPLITTER |
30 | #include <qsplitter.h> | 30 | #include <qsplitter.h> |
31 | #endif | 31 | #endif |
32 | #include <qfont.h> | 32 | #include <qfont.h> |
33 | #include <qfontmetrics.h> | 33 | #include <qfontmetrics.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtooltip.h> | 35 | #include <qtooltip.h> |
36 | #include <qpainter.h> | 36 | #include <qpainter.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | 39 | ||
40 | #include <kapplication.h> | 40 | #include <kapplication.h> |
41 | #include <KDGanttMinimizeSplitter.h> | 41 | #include <KDGanttMinimizeSplitter.h> |
42 | #include <kdebug.h> | 42 | #include <kdebug.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kiconloader.h> | 44 | #include <kiconloader.h> |
45 | #include <klocale.h> | 45 | #include <klocale.h> |
46 | #include <kconfig.h> | 46 | #include <kconfig.h> |
47 | #include <kglobal.h> | 47 | #include <kglobal.h> |
48 | #include "calendarview.h" | 48 | #include "calendarview.h" |
49 | #include "koviewmanager.h" | 49 | #include "koviewmanager.h" |
50 | 50 | ||
51 | #include <libkcal/calendar.h> | 51 | #include <libkcal/calendar.h> |
52 | #include <libkcal/icaldrag.h> | 52 | #include <libkcal/icaldrag.h> |
53 | #include <libkcal/dndfactory.h> | 53 | #include <libkcal/dndfactory.h> |
54 | 54 | ||
55 | #include <kcalendarsystem.h> | 55 | #include <kcalendarsystem.h> |
56 | 56 | ||
57 | #include "koglobals.h" | 57 | #include "koglobals.h" |
58 | #ifndef KORG_NOPLUGINS | 58 | #ifndef KORG_NOPLUGINS |
59 | #include "kocore.h" | 59 | #include "kocore.h" |
60 | #endif | 60 | #endif |
61 | #include "koprefs.h" | 61 | #include "koprefs.h" |
62 | #include "koagenda.h" | 62 | #include "koagenda.h" |
63 | #include "koagendaitem.h" | 63 | #include "koagendaitem.h" |
64 | #ifndef KORG_NOPRINTER | 64 | #ifndef KORG_NOPRINTER |
65 | #include "calprinter.h" | 65 | #include "calprinter.h" |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | #include "koagendaview.h" | 68 | #include "koagendaview.h" |
69 | //#include "koagendaview.moc" | 69 | //#include "koagendaview.moc" |
70 | 70 | ||
71 | //extern bool globalFlagBlockPainting; | 71 | //extern bool globalFlagBlockPainting; |
72 | extern int globalFlagBlockAgenda; | 72 | extern int globalFlagBlockAgenda; |
73 | extern int globalFlagBlockStartup; | 73 | extern int globalFlagBlockStartup; |
74 | extern int globalFlagBlockAgendaItemPaint; | 74 | extern int globalFlagBlockAgendaItemPaint; |
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | 79 | ||
80 | 80 | ||
81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : |
82 | QScrollView(parent,name,f) | 82 | QScrollView(parent,name,f) |
83 | { | 83 | { |
84 | mRows = rows; | 84 | mRows = rows; |
85 | 85 | ||
86 | setMinimumHeight( 20 ); | 86 | setMinimumHeight( 20 ); |
87 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 87 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
88 | 88 | ||
89 | enableClipper(true); | 89 | enableClipper(true); |
90 | 90 | ||
91 | setHScrollBarMode(AlwaysOff); | 91 | setHScrollBarMode(AlwaysOff); |
92 | setVScrollBarMode(AlwaysOff); | 92 | setVScrollBarMode(AlwaysOff); |
93 | 93 | ||
94 | resizeContents(50,mRows * mCellHeight); | 94 | resizeContents(50,mRows * mCellHeight); |
95 | 95 | ||
96 | viewport()->setBackgroundMode( PaletteBackground ); | 96 | viewport()->setBackgroundMode( PaletteBackground ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void TimeLabels::setCellHeight(int height) | 99 | void TimeLabels::setCellHeight(int height) |
100 | { | 100 | { |
101 | mCellHeight = height; | 101 | mCellHeight = height; |
102 | } | 102 | } |
103 | 103 | ||
104 | /* | 104 | /* |
105 | Optimization so that only the "dirty" portion of the scroll view | 105 | Optimization so that only the "dirty" portion of the scroll view |
106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 106 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
107 | */ | 107 | */ |
108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 108 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
109 | { | 109 | { |
110 | 110 | ||
111 | // if ( globalFlagBlockAgenda ) | 111 | // if ( globalFlagBlockAgenda ) |
112 | // return; | 112 | // return; |
113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be | 113 | // bug: the parameters cx, cy, cw, ch are the areas that need to be |
114 | // redrawn, not the area of the widget. unfortunately, this | 114 | // redrawn, not the area of the widget. unfortunately, this |
115 | // code assumes the latter... | 115 | // code assumes the latter... |
116 | 116 | ||
117 | // now, for a workaround... | 117 | // now, for a workaround... |
118 | // these two assignments fix the weird redraw bug | 118 | // these two assignments fix the weird redraw bug |
119 | cx = contentsX() + 2; | 119 | cx = contentsX() + 2; |
120 | cw = contentsWidth() - 2; | 120 | cw = contentsWidth() - 2; |
121 | // end of workaround | 121 | // end of workaround |
122 | 122 | ||
123 | int cell = ((int)(cy/mCellHeight)); | 123 | int cell = ((int)(cy/mCellHeight)); |
124 | int y = cell * mCellHeight; | 124 | int y = cell * mCellHeight; |
125 | QFontMetrics fm = fontMetrics(); | 125 | QFontMetrics fm = fontMetrics(); |
126 | QString hour; | 126 | QString hour; |
127 | QString suffix; | 127 | QString suffix; |
128 | QString fullTime; | 128 | QString fullTime; |
129 | int tW = fm.width("24:00i"); | 129 | int tW = fm.width("24:00i"); |
130 | 130 | ||
131 | while (y < cy + ch) { | 131 | while (y < cy + ch) { |
132 | p->drawLine(cx,y,cx+tW,y); | 132 | p->drawLine(cx,y,cx+tW,y); |
133 | hour.setNum(cell); | 133 | hour.setNum(cell); |
134 | suffix = "am"; | 134 | suffix = "am"; |
135 | 135 | ||
136 | // handle 24h and am/pm time formats | 136 | // handle 24h and am/pm time formats |
137 | if (KGlobal::locale()->use12Clock()) { | 137 | if (KGlobal::locale()->use12Clock()) { |
138 | if (cell > 11) suffix = "pm"; | 138 | if (cell > 11) suffix = "pm"; |
139 | if (cell == 0) hour.setNum(12); | 139 | if (cell == 0) hour.setNum(12); |
140 | if (cell > 12) hour.setNum(cell - 12); | 140 | if (cell > 12) hour.setNum(cell - 12); |
141 | } else { | 141 | } else { |
142 | suffix = ":00"; | 142 | suffix = ":00"; |
143 | } | 143 | } |
144 | 144 | ||
145 | // create string in format of "XX:XX" or "XXpm/am" | 145 | // create string in format of "XX:XX" or "XXpm/am" |
146 | fullTime = hour + suffix; | 146 | fullTime = hour + suffix; |
147 | 147 | ||
148 | // center and draw the time label | 148 | // center and draw the time label |
149 | int timeWidth = fm.width(fullTime+"i"); | 149 | int timeWidth = fm.width(fullTime+"i"); |
150 | int offset = this->width() - timeWidth; | 150 | int offset = this->width() - timeWidth; |
151 | int borderWidth = 5; | 151 | int borderWidth = 5; |
152 | int timeHeight = fm.height(); | 152 | int timeHeight = fm.height(); |
153 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); | 153 | timeHeight = timeHeight + 2 - ( timeHeight / 4 ); |
154 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); | 154 | p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); |
155 | 155 | ||
156 | // increment indices | 156 | // increment indices |
157 | y += mCellHeight; | 157 | y += mCellHeight; |
158 | cell++; | 158 | cell++; |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | /** | 162 | /** |
163 | Calculates the minimum width. | 163 | Calculates the minimum width. |
164 | */ | 164 | */ |
165 | int TimeLabels::minimumWidth() const | 165 | int TimeLabels::minimumWidth() const |
166 | { | 166 | { |
167 | QFontMetrics fm = fontMetrics(); | 167 | QFontMetrics fm = fontMetrics(); |
168 | 168 | ||
169 | //TODO: calculate this value | 169 | //TODO: calculate this value |
170 | int borderWidth = 4; | 170 | int borderWidth = 4; |
171 | 171 | ||
172 | // the maximum width possible | 172 | // the maximum width possible |
173 | int width = fm.width("88:88x") + borderWidth; | 173 | int width = fm.width("88:88x") + borderWidth; |
174 | 174 | ||
175 | return width; | 175 | return width; |
176 | } | 176 | } |
177 | 177 | ||
178 | /** updates widget's internal state */ | 178 | /** updates widget's internal state */ |
179 | void TimeLabels::updateConfig() | 179 | void TimeLabels::updateConfig() |
180 | { | 180 | { |
181 | // set the font | 181 | // set the font |
182 | // config->setGroup("Fonts"); | 182 | // config->setGroup("Fonts"); |
183 | // QFont font = config->readFontEntry("TimeBar Font"); | 183 | // QFont font = config->readFontEntry("TimeBar Font"); |
184 | setFont(KOPrefs::instance()->mTimeBarFont); | 184 | setFont(KOPrefs::instance()->mTimeBarFont); |
185 | 185 | ||
186 | // update geometry restrictions based on new settings | 186 | // update geometry restrictions based on new settings |
187 | setFixedWidth(minimumWidth()); | 187 | setFixedWidth(minimumWidth()); |
188 | 188 | ||
189 | // update HourSize | 189 | // update HourSize |
190 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 190 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
191 | resizeContents(50,mRows * mCellHeight); | 191 | resizeContents(50,mRows * mCellHeight); |
192 | } | 192 | } |
193 | 193 | ||
194 | /** update time label positions */ | 194 | /** update time label positions */ |
195 | void TimeLabels::positionChanged() | 195 | void TimeLabels::positionChanged() |
196 | { | 196 | { |
197 | int adjustment = mAgenda->contentsY(); | 197 | int adjustment = mAgenda->contentsY(); |
198 | setContentsPos(0, adjustment); | 198 | setContentsPos(0, adjustment); |
199 | } | 199 | } |
200 | 200 | ||
201 | /** */ | 201 | /** */ |
202 | void TimeLabels::setAgenda(KOAgenda* agenda) | 202 | void TimeLabels::setAgenda(KOAgenda* agenda) |
203 | { | 203 | { |
204 | mAgenda = agenda; | 204 | mAgenda = agenda; |
205 | } | 205 | } |
206 | 206 | ||
207 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 207 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
208 | { | 208 | { |
209 | mMouseDownY = e->pos().y(); | 209 | mMouseDownY = e->pos().y(); |
210 | mOrgCap = topLevelWidget()->caption(); | 210 | mOrgCap = topLevelWidget()->caption(); |
211 | } | 211 | } |
212 | 212 | ||
213 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 213 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
214 | { | 214 | { |
215 | int diff = mMouseDownY - e->pos().y(); | 215 | int diff = mMouseDownY - e->pos().y(); |
216 | if ( diff < 10 && diff > -10 ) | 216 | if ( diff < 10 && diff > -10 ) |
217 | return; | 217 | return; |
218 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 218 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
219 | if ( tSize < 4 ) | 219 | if ( tSize < 4 ) |
220 | tSize = 4; | 220 | tSize = 4; |
221 | if ( tSize > 22 ) | 221 | if ( tSize > 22 ) |
222 | tSize = 22; | 222 | tSize = 22; |
223 | tSize = (tSize-2)/2; | 223 | tSize = (tSize-2)/2; |
224 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 224 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
225 | 225 | ||
226 | } | 226 | } |
227 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 227 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
228 | { | 228 | { |
229 | topLevelWidget()->setCaption( mOrgCap ); | 229 | topLevelWidget()->setCaption( mOrgCap ); |
230 | int diff = mMouseDownY - e->pos().y(); | 230 | int diff = mMouseDownY - e->pos().y(); |
231 | if ( diff < 10 && diff > -10 ) | 231 | if ( diff < 10 && diff > -10 ) |
232 | return; | 232 | return; |
233 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 233 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
234 | if ( tSize < 4 ) | 234 | if ( tSize < 4 ) |
235 | tSize = 4; | 235 | tSize = 4; |
236 | if ( tSize > 22 ) | 236 | if ( tSize > 22 ) |
237 | tSize = 22; | 237 | tSize = 22; |
238 | tSize = (tSize/2)*2; | 238 | tSize = (tSize/2)*2; |
239 | if ( tSize == KOPrefs::instance()->mHourSize ) | 239 | if ( tSize == KOPrefs::instance()->mHourSize ) |
240 | return; | 240 | return; |
241 | KOPrefs::instance()->mHourSize = tSize; | 241 | KOPrefs::instance()->mHourSize = tSize; |
242 | emit scaleChanged(); | 242 | emit scaleChanged(); |
243 | } | 243 | } |
244 | 244 | ||
245 | /** This is called in response to repaint() */ | 245 | /** This is called in response to repaint() */ |
246 | void TimeLabels::paintEvent(QPaintEvent*) | 246 | void TimeLabels::paintEvent(QPaintEvent*) |
247 | { | 247 | { |
248 | 248 | ||
249 | // kdDebug() << "paintevent..." << endl; | 249 | // kdDebug() << "paintevent..." << endl; |
250 | // this is another hack! | 250 | // this is another hack! |
251 | // QPainter painter(this); | 251 | // QPainter painter(this); |
252 | //QString c | 252 | //QString c |
253 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 253 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
254 | } | 254 | } |
255 | 255 | ||
256 | //////////////////////////////////////////////////////////////////////////// | 256 | //////////////////////////////////////////////////////////////////////////// |
257 | 257 | ||
258 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 258 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
259 | : QFrame(parent,name) | 259 | : QFrame(parent,name) |
260 | { | 260 | { |
261 | mColumns = 1; | 261 | mColumns = 1; |
262 | mTopBox = 0; | 262 | mTopBox = 0; |
263 | mLocation = loc; | 263 | mLocation = loc; |
264 | mTopLayout = 0; | 264 | mTopLayout = 0; |
265 | mPaintWidget = 0; | 265 | mPaintWidget = 0; |
266 | mXOffset = 0; | 266 | mXOffset = 0; |
267 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 267 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
268 | else mPixmap = SmallIcon("1downarrow"); | 268 | else mPixmap = SmallIcon("1downarrow"); |
269 | mEnabled.resize(mColumns); | 269 | mEnabled.resize(mColumns); |
270 | if (mLocation == Top) | 270 | if (mLocation == Top) |
271 | setMaximumHeight(0); | 271 | setMaximumHeight(0); |
272 | else | 272 | else |
273 | setMinimumHeight(mPixmap.height()); | 273 | setMinimumHeight(mPixmap.height()); |
274 | } | 274 | } |
275 | 275 | ||
276 | EventIndicator::~EventIndicator() | 276 | EventIndicator::~EventIndicator() |
277 | { | 277 | { |
278 | } | 278 | } |
279 | 279 | ||
280 | void EventIndicator::drawContents(QPainter *p) | 280 | void EventIndicator::drawContents(QPainter *p) |
281 | { | 281 | { |
282 | 282 | ||
283 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 283 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
284 | KDGanttSplitterHandle* han = 0; | 284 | KDGanttSplitterHandle* han = 0; |
285 | if ( mPaintWidget ) | 285 | if ( mPaintWidget ) |
286 | han = mPaintWidget->firstHandle(); | 286 | han = mPaintWidget->firstHandle(); |
287 | if ( ! han ) { | 287 | if ( ! han ) { |
288 | int i; | 288 | int i; |
289 | for(i=0;i<mColumns;++i) { | 289 | for(i=0;i<mColumns;++i) { |
290 | if (mEnabled[i]) { | 290 | if (mEnabled[i]) { |
291 | int cellWidth = contentsRect().right()/mColumns; | 291 | int cellWidth = contentsRect().right()/mColumns; |
292 | int xOffset = KOGlobals::self()->reverseLayout() ? | 292 | int xOffset = KOGlobals::self()->reverseLayout() ? |
293 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 293 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
294 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 294 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
295 | p->drawPixmap(QPoint(xOffset,0),mPixmap); | 295 | p->drawPixmap(QPoint(xOffset,0),mPixmap); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | } else { | 298 | } else { |
299 | han->repaint(); | 299 | han->repaint(); |
300 | //mPaintWidget->setBackgroundColor( red ); | 300 | //mPaintWidget->setBackgroundColor( red ); |
301 | 301 | ||
302 | QPainter pa( han ); | 302 | QPainter pa( han ); |
303 | int i; | 303 | int i; |
304 | bool setColor = false; | 304 | bool setColor = false; |
305 | for(i=0;i<mColumns;++i) { | 305 | for(i=0;i<mColumns;++i) { |
306 | if (mEnabled[i]) { | 306 | if (mEnabled[i]) { |
307 | setColor = true; | 307 | setColor = true; |
308 | 308 | ||
309 | int cellWidth = contentsRect().right()/mColumns; | 309 | int cellWidth = contentsRect().right()/mColumns; |
310 | int xOffset = KOGlobals::self()->reverseLayout() ? | 310 | int xOffset = KOGlobals::self()->reverseLayout() ? |
311 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 311 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
312 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 312 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
313 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 313 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
314 | //qDebug("222draw pix %d ",xOffset ); | 314 | //qDebug("222draw pix %d ",xOffset ); |
315 | 315 | ||
316 | } | 316 | } |
317 | 317 | ||
318 | } | 318 | } |
319 | pa.end(); | 319 | pa.end(); |
320 | 320 | ||
321 | } | 321 | } |
322 | } | 322 | } |
323 | 323 | ||
324 | void EventIndicator::setXOffset( int x ) | 324 | void EventIndicator::setXOffset( int x ) |
325 | { | 325 | { |
326 | mXOffset = x; | 326 | mXOffset = x; |
327 | } | 327 | } |
328 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 328 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
329 | { | 329 | { |
330 | mPaintWidget = w; | 330 | mPaintWidget = w; |
331 | } | 331 | } |
332 | void EventIndicator::changeColumns(int columns) | 332 | void EventIndicator::changeColumns(int columns) |
333 | { | 333 | { |
334 | mColumns = columns; | 334 | mColumns = columns; |
335 | mEnabled.resize(mColumns); | 335 | mEnabled.resize(mColumns); |
336 | 336 | ||
337 | update(); | 337 | update(); |
338 | } | 338 | } |
339 | 339 | ||
340 | void EventIndicator::enableColumn(int column, bool enable) | 340 | void EventIndicator::enableColumn(int column, bool enable) |
341 | { | 341 | { |
342 | mEnabled[column] = enable; | 342 | mEnabled[column] = enable; |
343 | } | 343 | } |
344 | 344 | ||
345 | 345 | ||
346 | //////////////////////////////////////////////////////////////////////////// | 346 | //////////////////////////////////////////////////////////////////////////// |
347 | //////////////////////////////////////////////////////////////////////////// | 347 | //////////////////////////////////////////////////////////////////////////// |
348 | //////////////////////////////////////////////////////////////////////////// | 348 | //////////////////////////////////////////////////////////////////////////// |
349 | 349 | ||
350 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 350 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
351 | KOEventView (cal,parent,name) | 351 | KOEventView (cal,parent,name) |
352 | { | 352 | { |
353 | mBlockUpdating = true; | 353 | mBlockUpdating = true; |
354 | mStartHour = 8; | 354 | mStartHour = 8; |
355 | mSelectedDates.append(QDate::currentDate()); | 355 | mSelectedDates.append(QDate::currentDate()); |
356 | 356 | ||
357 | mLayoutDayLabels = 0; | 357 | mLayoutDayLabels = 0; |
358 | mDayLabelsFrame = 0; | 358 | mDayLabelsFrame = 0; |
359 | mDayLabels = 0; | 359 | mDayLabels = 0; |
360 | bool isRTL = KOGlobals::self()->reverseLayout(); | 360 | bool isRTL = KOGlobals::self()->reverseLayout(); |
361 | 361 | ||
362 | if ( KOPrefs::instance()->mVerticalScreen ) { | 362 | if ( KOPrefs::instance()->mVerticalScreen ) { |
363 | mExpandedPixmap = SmallIcon( "1downarrow" ); | 363 | mExpandedPixmap = SmallIcon( "1downarrow" ); |
364 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); | 364 | mNotExpandedPixmap = SmallIcon( "1uparrow" ); |
365 | } else { | 365 | } else { |
366 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); | 366 | mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); |
367 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); | 367 | mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); |
368 | } | 368 | } |
369 | 369 | ||
370 | QBoxLayout *topLayout = new QVBoxLayout(this); | 370 | QBoxLayout *topLayout = new QVBoxLayout(this); |
371 | 371 | ||
372 | // Create day name labels for agenda columns | 372 | // Create day name labels for agenda columns |
373 | mDayLabelsFrame = new QHBox(this); | 373 | mDayLabelsFrame = new QHBox(this); |
374 | topLayout->addWidget(mDayLabelsFrame); | 374 | topLayout->addWidget(mDayLabelsFrame); |
375 | mDayLabels = new QFrame (mDayLabelsFrame); | 375 | mDayLabels = new QFrame (mDayLabelsFrame); |
376 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 376 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
377 | // Create agenda splitter | 377 | // Create agenda splitter |
378 | #ifndef KORG_NOSPLITTER | 378 | #ifndef KORG_NOSPLITTER |
379 | mSplitterAgenda = new QSplitter(Vertical,this); | 379 | mSplitterAgenda = new QSplitter(Vertical,this); |
380 | topLayout->addWidget(mSplitterAgenda); | 380 | topLayout->addWidget(mSplitterAgenda); |
381 | mSplitterAgenda->setOpaqueResize(); | 381 | mSplitterAgenda->setOpaqueResize(); |
382 | 382 | ||
383 | mAllDayFrame = new QHBox(mSplitterAgenda); | 383 | mAllDayFrame = new QHBox(mSplitterAgenda); |
384 | 384 | ||
385 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 385 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
386 | #else | 386 | #else |
387 | #if 0 | 387 | #if 0 |
388 | QWidget *mainBox = new QWidget( this ); | 388 | QWidget *mainBox = new QWidget( this ); |
389 | topLayout->addWidget( mainBox ); | 389 | topLayout->addWidget( mainBox ); |
390 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); | 390 | QBoxLayout *mainLayout = new QVBoxLayout(mainBox); |
391 | mAllDayFrame = new QHBox(mainBox); | 391 | mAllDayFrame = new QHBox(mainBox); |
392 | mainLayout->addWidget(mAllDayFrame); | 392 | mainLayout->addWidget(mAllDayFrame); |
393 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); | 393 | mainLayout->setStretchFactor( mAllDayFrame, 0 ); |
394 | mAllDayFrame->setFocusPolicy(NoFocus); | 394 | mAllDayFrame->setFocusPolicy(NoFocus); |
395 | QWidget *agendaFrame = new QWidget(mainBox); | 395 | QWidget *agendaFrame = new QWidget(mainBox); |
396 | mainLayout->addWidget(agendaFrame); | 396 | mainLayout->addWidget(agendaFrame); |
397 | mainLayout->setStretchFactor( agendaFrame, 10 ); | 397 | mainLayout->setStretchFactor( agendaFrame, 10 ); |
398 | 398 | ||
399 | agendaFrame->setFocusPolicy(NoFocus); | 399 | agendaFrame->setFocusPolicy(NoFocus); |
400 | #endif | 400 | #endif |
401 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 401 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
402 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 402 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
403 | topLayout->addWidget( mSplitterAgenda ); | 403 | topLayout->addWidget( mSplitterAgenda ); |
404 | mAllDayFrame = new QHBox(mSplitterAgenda); | 404 | mAllDayFrame = new QHBox(mSplitterAgenda); |
405 | mAllDayFrame->setFocusPolicy(NoFocus); | 405 | mAllDayFrame->setFocusPolicy(NoFocus); |
406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 406 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
407 | agendaFrame->setFocusPolicy(NoFocus); | 407 | agendaFrame->setFocusPolicy(NoFocus); |
408 | 408 | ||
409 | #endif | 409 | #endif |
410 | 410 | ||
411 | // Create all-day agenda widget | 411 | // Create all-day agenda widget |
412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 412 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
413 | 413 | ||
414 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 414 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
415 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 415 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
416 | int widebut = mExpandButton->sizeHint().width(); | 416 | int widebut = mExpandButton->sizeHint().width(); |
417 | if ( QApplication::desktop()->width() < 480 ) | 417 | if ( QApplication::desktop()->width() < 480 ) |
418 | widebut = widebut*2; | 418 | widebut = widebut*2; |
419 | else | 419 | else |
420 | widebut = (widebut*3) / 2; | 420 | widebut = (widebut*3) / 2; |
421 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 421 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
422 | // QSizePolicy::Fixed ) ); | 422 | // QSizePolicy::Fixed ) ); |
423 | mExpandButton->setFixedSize( widebut, widebut); | 423 | mExpandButton->setFixedSize( widebut, widebut); |
424 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 424 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
425 | mExpandButton->setFocusPolicy(NoFocus); | 425 | mExpandButton->setFocusPolicy(NoFocus); |
426 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 426 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
427 | mAllDayAgenda->setFocusPolicy(NoFocus); | 427 | mAllDayAgenda->setFocusPolicy(NoFocus); |
428 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 428 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
429 | 429 | ||
430 | // Create event context menu for all day agenda | 430 | // Create event context menu for all day agenda |
431 | mAllDayAgendaPopup = eventPopup(); | 431 | mAllDayAgendaPopup = eventPopup(); |
432 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 432 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
433 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 433 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
434 | 434 | ||
435 | // Create agenda frame | 435 | // Create agenda frame |
436 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); | 436 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); |
437 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 437 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
438 | 438 | ||
439 | // create event indicator bars | 439 | // create event indicator bars |
440 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 440 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
441 | agendaLayout->addWidget(mEventIndicatorTop,0,1); | 441 | agendaLayout->addWidget(mEventIndicatorTop,0,1); |
442 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 442 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
443 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 443 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
444 | agendaFrame); | 444 | agendaFrame); |
445 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); | 445 | agendaLayout->addWidget(mEventIndicatorBottom,2,1); |
446 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 446 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
447 | agendaLayout->addWidget(dummyAgendaRight,0,2); | 447 | agendaLayout->addWidget(dummyAgendaRight,0,2); |
448 | 448 | ||
449 | // Create time labels | 449 | // Create time labels |
450 | mTimeLabels = new TimeLabels(24,agendaFrame); | 450 | mTimeLabels = new TimeLabels(24,agendaFrame); |
451 | agendaLayout->addWidget(mTimeLabels,1,0); | 451 | agendaLayout->addWidget(mTimeLabels,1,0); |
452 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 452 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
453 | this,SLOT(updateConfig())); | 453 | this,SLOT(updateConfig())); |
454 | 454 | ||
455 | // Create agenda | 455 | // Create agenda |
456 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 456 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
457 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); | 457 | agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); |
458 | agendaLayout->setColStretch(1,1); | 458 | agendaLayout->setColStretch(1,1); |
459 | mAgenda->setFocusPolicy(NoFocus); | 459 | mAgenda->setFocusPolicy(NoFocus); |
460 | // Create event context menu for agenda | 460 | // Create event context menu for agenda |
461 | mAgendaPopup = eventPopup(); | 461 | mAgendaPopup = eventPopup(); |
462 | 462 | ||
463 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 463 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
464 | i18n("Toggle Alarm"),mAgenda, | 464 | i18n("Toggle Alarm"),mAgenda, |
465 | SLOT(popupAlarm()),true); | 465 | SLOT(popupAlarm()),true); |
466 | 466 | ||
467 | 467 | ||
468 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 468 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
469 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 469 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
470 | 470 | ||
471 | // make connections between dependent widgets | 471 | // make connections between dependent widgets |
472 | mTimeLabels->setAgenda(mAgenda); | 472 | mTimeLabels->setAgenda(mAgenda); |
473 | 473 | ||
474 | // Update widgets to reflect user preferences | 474 | // Update widgets to reflect user preferences |
475 | // updateConfig(); | 475 | // updateConfig(); |
476 | 476 | ||
477 | // createDayLabels(); | 477 | // createDayLabels(); |
478 | 478 | ||
479 | // these blank widgets make the All Day Event box line up with the agenda | 479 | // these blank widgets make the All Day Event box line up with the agenda |
480 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 480 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
481 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 481 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
482 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 482 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
483 | 483 | ||
484 | // Scrolling | 484 | // Scrolling |
485 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 485 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
486 | mTimeLabels, SLOT(positionChanged())); | 486 | mTimeLabels, SLOT(positionChanged())); |
487 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 487 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
488 | SLOT(setContentsPos(int))); | 488 | SLOT(setContentsPos(int))); |
489 | 489 | ||
490 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 490 | connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
491 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); | 491 | connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); |
492 | 492 | ||
493 | // Create/Show/Edit/Delete Event | 493 | // Create/Show/Edit/Delete Event |
494 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 494 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
495 | SLOT(newEvent(int,int))); | 495 | SLOT(newEvent(int,int))); |
496 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 496 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
497 | SLOT(newTodo(int,int))); | 497 | SLOT(newTodo(int,int))); |
498 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 498 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
499 | SLOT(newEvent(int,int,int,int))); | 499 | SLOT(newEvent(int,int,int,int))); |
500 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 500 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
501 | SLOT(newEventAllDay(int,int))); | 501 | SLOT(newEventAllDay(int,int))); |
502 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 502 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
503 | SLOT(newTodoAllDay(int,int))); | 503 | SLOT(newTodoAllDay(int,int))); |
504 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 504 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
505 | SLOT(newEventAllDay(int,int))); | 505 | SLOT(newEventAllDay(int,int))); |
506 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 506 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
507 | SLOT(newTimeSpanSelected(int,int,int,int))); | 507 | SLOT(newTimeSpanSelected(int,int,int,int))); |
508 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 508 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
509 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 509 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
510 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 510 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
511 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 511 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
512 | 512 | ||
513 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 513 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
514 | SIGNAL(editIncidenceSignal(Incidence *))); | 514 | SIGNAL(editIncidenceSignal(Incidence *))); |
515 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 515 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
516 | SIGNAL(editIncidenceSignal(Incidence *))); | 516 | SIGNAL(editIncidenceSignal(Incidence *))); |
517 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 517 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
518 | SIGNAL(showIncidenceSignal(Incidence *))); | 518 | SIGNAL(showIncidenceSignal(Incidence *))); |
519 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 519 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
520 | SIGNAL(showIncidenceSignal(Incidence *))); | 520 | SIGNAL(showIncidenceSignal(Incidence *))); |
521 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 521 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
522 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 522 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
523 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 523 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
524 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 524 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
525 | 525 | ||
526 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 526 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
527 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 527 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
528 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 528 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
529 | SLOT(updateEventDates(KOAgendaItem *, int))); | 529 | SLOT(updateEventDates(KOAgendaItem *, int))); |
530 | 530 | ||
531 | // event indicator update | 531 | // event indicator update |
532 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 532 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
533 | SLOT(updateEventIndicatorTop(int))); | 533 | SLOT(updateEventIndicatorTop(int))); |
534 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 534 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
535 | SLOT(updateEventIndicatorBottom(int))); | 535 | SLOT(updateEventIndicatorBottom(int))); |
536 | // drag signals | 536 | // drag signals |
537 | /* | 537 | /* |
538 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 538 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
539 | SLOT(startDrag(Event *))); | 539 | SLOT(startDrag(Event *))); |
540 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 540 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
541 | SLOT(startDrag(Event *))); | 541 | SLOT(startDrag(Event *))); |
542 | */ | 542 | */ |
543 | // synchronize selections | 543 | // synchronize selections |
544 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 544 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
545 | mAllDayAgenda, SLOT( deselectItem() ) ); | 545 | mAllDayAgenda, SLOT( deselectItem() ) ); |
546 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 546 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
547 | mAgenda, SLOT( deselectItem() ) ); | 547 | mAgenda, SLOT( deselectItem() ) ); |
548 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 548 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
549 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 549 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
550 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 550 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
551 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 551 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
552 | connect( mAgenda, SIGNAL( resizedSignal() ), | 552 | connect( mAgenda, SIGNAL( resizedSignal() ), |
553 | SLOT( updateConfig( ) ) ); | 553 | SLOT( updateConfig( ) ) ); |
554 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 554 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
555 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 555 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
556 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 556 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
557 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 557 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
558 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 558 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
559 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 559 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
560 | 560 | ||
561 | 561 | ||
562 | } | 562 | } |
563 | 563 | ||
564 | void KOAgendaView::toggleAllDay() | 564 | void KOAgendaView::toggleAllDay() |
565 | { | 565 | { |
566 | if ( mSplitterAgenda->firstHandle() ) | 566 | if ( mSplitterAgenda->firstHandle() ) |
567 | mSplitterAgenda->firstHandle()->toggle(); | 567 | mSplitterAgenda->firstHandle()->toggle(); |
568 | } | 568 | } |
569 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 569 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
570 | { | 570 | { |
571 | calendar()->addIncidence( inc ); | 571 | calendar()->addIncidence( inc ); |
572 | 572 | ||
573 | if ( incOld ) { | 573 | if ( incOld ) { |
574 | if ( incOld->type() == "Todo" ) | 574 | if ( incOld->type() == "Todo" ) |
575 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 575 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
576 | else | 576 | else |
577 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 577 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
578 | } | 578 | } |
579 | 579 | ||
580 | } | 580 | } |
581 | 581 | ||
582 | KOAgendaView::~KOAgendaView() | 582 | KOAgendaView::~KOAgendaView() |
583 | { | 583 | { |
584 | delete mAgendaPopup; | 584 | delete mAgendaPopup; |
585 | delete mAllDayAgendaPopup; | 585 | delete mAllDayAgendaPopup; |
586 | delete KOAgendaItem::paintPix(); | 586 | delete KOAgendaItem::paintPix(); |
587 | delete KOAgendaItem::paintPixSel(); | 587 | delete KOAgendaItem::paintPixSel(); |
588 | } | 588 | } |
589 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 589 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
590 | { | 590 | { |
591 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 591 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
592 | bool uc = false; | 592 | bool uc = false; |
593 | int ow = e->oldSize().width(); | 593 | int ow = e->oldSize().width(); |
594 | int oh = e->oldSize().height(); | 594 | int oh = e->oldSize().height(); |
595 | int w = e->size().width(); | 595 | int w = e->size().width(); |
596 | int h = e->size().height(); | 596 | int h = e->size().height(); |
597 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 597 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
598 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 598 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
599 | uc = true; | 599 | uc = true; |
600 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 600 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
601 | } | 601 | } |
602 | mUpcomingWidth = e->size().width() ; | 602 | mUpcomingWidth = e->size().width() ; |
603 | if ( mBlockUpdating || uc ) { | 603 | if ( mBlockUpdating || uc ) { |
604 | mBlockUpdating = false; | 604 | mBlockUpdating = false; |
605 | //mAgenda->setMinimumSize(800 , 600 ); | 605 | //mAgenda->setMinimumSize(800 , 600 ); |
606 | //qDebug("mAgenda->resize+++++++++++++++ "); | 606 | //qDebug("mAgenda->resize+++++++++++++++ "); |
607 | updateConfig(); | 607 | updateConfig(); |
608 | //qDebug("KOAgendaView::Updating now possible "); | 608 | //qDebug("KOAgendaView::Updating now possible "); |
609 | } else | 609 | } else |
610 | createDayLabels(); | 610 | createDayLabels(); |
611 | //qDebug("resizeEvent end "); | 611 | //qDebug("resizeEvent end "); |
612 | 612 | ||
613 | } | 613 | } |
614 | void KOAgendaView::slotDaylabelClicked( int num ) | 614 | void KOAgendaView::slotDaylabelClicked( int num ) |
615 | { | 615 | { |
616 | 616 | ||
617 | QDate firstDate = mSelectedDates.first(); | 617 | QDate firstDate = mSelectedDates.first(); |
618 | if ( num == -1 ) | 618 | if ( num == -1 ) |
619 | emit showDateView( 6, firstDate ); | 619 | emit showDateView( 6, firstDate ); |
620 | else if (num >= 0 ) { | 620 | else if (num >= 0 ) { |
621 | if ( mSelectedDates.count() == 1) | 621 | if ( mSelectedDates.count() == 1) |
622 | emit showDateView( 9, firstDate.addDays( num ) ); | 622 | emit showDateView( 9, firstDate.addDays( num ) ); |
623 | else | 623 | else |
624 | emit showDateView( 3, firstDate.addDays( num ) ); | 624 | emit showDateView( 3, firstDate.addDays( num ) ); |
625 | } | 625 | } |
626 | else | 626 | else |
627 | showDateView( 10, firstDate.addDays(1) ); | 627 | showDateView( 10, firstDate.addDays(1) ); |
628 | } | 628 | } |
629 | 629 | ||
630 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 630 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
631 | { | 631 | { |
632 | 632 | ||
633 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 633 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
634 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 634 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
635 | mDayLabelsList.append( dayLabel ); | 635 | mDayLabelsList.append( dayLabel ); |
636 | mLayoutDayLabels->addWidget(dayLabel); | 636 | mLayoutDayLabels->addWidget(dayLabel); |
637 | return dayLabel ; | 637 | return dayLabel ; |
638 | } | 638 | } |
639 | 639 | ||
640 | void KOAgendaView::createDayLabels() | 640 | void KOAgendaView::createDayLabels() |
641 | { | 641 | { |
642 | 642 | ||
643 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 643 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
644 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 644 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
645 | return; | 645 | return; |
646 | 646 | ||
647 | } | 647 | } |
648 | int newHight; | 648 | int newHight; |
649 | 649 | ||
650 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 650 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
651 | // It would remove some flickering and gain speed (since this is called by | 651 | // It would remove some flickering and gain speed (since this is called by |
652 | // each updateView() call) | 652 | // each updateView() call) |
653 | 653 | ||
654 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; | 654 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; |
655 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 655 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
656 | if ( maxWid < 0 ) | 656 | if ( maxWid < 0 ) |
657 | maxWid = 20; | 657 | maxWid = 20; |
658 | 658 | ||
659 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 659 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
660 | QFontMetrics fm ( dlf ); | 660 | QFontMetrics fm ( dlf ); |
661 | int selCount = mSelectedDates.count(); | 661 | int selCount = mSelectedDates.count(); |
662 | QString dayTest = "Mon 20"; | 662 | QString dayTest = "Mon 20"; |
663 | //QString dayTest = "Mon 20"; | 663 | //QString dayTest = "Mon 20"; |
664 | int wid = fm.width( dayTest ); | 664 | int wid = fm.width( dayTest ); |
665 | //maxWid -= ( selCount * 3 ); //working for QLabels | 665 | //maxWid -= ( selCount * 3 ); //working for QLabels |
666 | maxWid -= ( selCount * 3 ); //working for QPushButton | 666 | maxWid -= ( selCount * 3 ); //working for QPushButton |
667 | if ( maxWid < 0 ) | 667 | if ( maxWid < 0 ) |
668 | maxWid = 20; | 668 | maxWid = 20; |
669 | int needWid = wid * selCount; | 669 | int needWid = wid * selCount; |
670 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 670 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
671 | //if ( needWid > maxWid ) | 671 | //if ( needWid > maxWid ) |
672 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 672 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
673 | while ( needWid > maxWid ) { | 673 | while ( needWid > maxWid ) { |
674 | dayTest = dayTest.left( dayTest.length() - 1 ); | 674 | dayTest = dayTest.left( dayTest.length() - 1 ); |
675 | wid = fm.width( dayTest ); | 675 | wid = fm.width( dayTest ); |
676 | needWid = wid * selCount; | 676 | needWid = wid * selCount; |
677 | } | 677 | } |
678 | int maxLen = dayTest.length(); | 678 | int maxLen = dayTest.length(); |
679 | int fontPoint = dlf.pointSize(); | 679 | int fontPoint = dlf.pointSize(); |
680 | if ( maxLen < 2 ) { | 680 | if ( maxLen < 2 ) { |
681 | int fontPoint = dlf.pointSize(); | 681 | int fontPoint = dlf.pointSize(); |
682 | while ( fontPoint > 4 ) { | 682 | while ( fontPoint > 4 ) { |
683 | --fontPoint; | 683 | --fontPoint; |
684 | dlf.setPointSize( fontPoint ); | 684 | dlf.setPointSize( fontPoint ); |
685 | QFontMetrics f( dlf ); | 685 | QFontMetrics f( dlf ); |
686 | wid = f.width( "30" ); | 686 | wid = f.width( "30" ); |
687 | needWid = wid * selCount; | 687 | needWid = wid * selCount; |
688 | if ( needWid < maxWid ) | 688 | if ( needWid < maxWid ) |
689 | break; | 689 | break; |
690 | } | 690 | } |
691 | maxLen = 2; | 691 | maxLen = 2; |
692 | } | 692 | } |
693 | //qDebug("Max len %d ", dayTest.length() ); | 693 | //qDebug("Max len %d ", dayTest.length() ); |
694 | 694 | ||
695 | QFontMetrics tempF( dlf ); | 695 | QFontMetrics tempF( dlf ); |
696 | newHight = tempF.height(); | 696 | newHight = tempF.height(); |
697 | mDayLabels->setFont( dlf ); | 697 | mDayLabels->setFont( dlf ); |
698 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 698 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
699 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 699 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
700 | //mLayoutDayLabels->addSpacing( 2 ); | 700 | //mLayoutDayLabels->addSpacing( 2 ); |
701 | // QFont lFont = dlf; | 701 | // QFont lFont = dlf; |
702 | bool appendLabels = false; | 702 | bool appendLabels = false; |
703 | KOAgendaButton *dayLabel; | 703 | KOAgendaButton *dayLabel; |
704 | dayLabel = mDayLabelsList.first(); | 704 | dayLabel = mDayLabelsList.first(); |
705 | if ( !dayLabel ) { | 705 | if ( !dayLabel ) { |
706 | appendLabels = true; | 706 | appendLabels = true; |
707 | dayLabel = getNewDaylabel(); | 707 | dayLabel = getNewDaylabel(); |
708 | } | 708 | } |
709 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); | 709 | dayLabel->setFixedWidth( mTimeLabels->width()+2 ); |
710 | dayLabel->setFont( dlf ); | 710 | dayLabel->setFont( dlf ); |
711 | dayLabel->setNum( -1 ); | 711 | dayLabel->setNum( -1 ); |
712 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 712 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
713 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 713 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
714 | dayLabel->show(); | 714 | dayLabel->show(); |
715 | DateList::ConstIterator dit; | 715 | DateList::ConstIterator dit; |
716 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 716 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
717 | int counter = -1; | 717 | int counter = -1; |
718 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 718 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
719 | ++counter; | 719 | ++counter; |
720 | QDate date = *dit; | 720 | QDate date = *dit; |
721 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 721 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
722 | if ( ! appendLabels ) { | 722 | if ( ! appendLabels ) { |
723 | dayLabel = mDayLabelsList.next(); | 723 | dayLabel = mDayLabelsList.next(); |
724 | if ( !dayLabel ) | 724 | if ( !dayLabel ) |
725 | appendLabels = true; | 725 | appendLabels = true; |
726 | } | 726 | } |
727 | if ( appendLabels ) { | 727 | if ( appendLabels ) { |
728 | dayLabel = getNewDaylabel(); | 728 | dayLabel = getNewDaylabel(); |
729 | } | 729 | } |
730 | dayLabel->setMinimumWidth( 1 ); | 730 | dayLabel->setMinimumWidth( 1 ); |
731 | dayLabel->setMaximumWidth( 1024 ); | 731 | dayLabel->setMaximumWidth( 1024 ); |
732 | dayLabel->setFont( dlf ); | 732 | dayLabel->setFont( dlf ); |
733 | dayLabel->show(); | 733 | dayLabel->show(); |
734 | dayLabel->setNum( counter ); | 734 | dayLabel->setNum( counter ); |
735 | QString str; | 735 | QString str; |
736 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 736 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
737 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 737 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
738 | switch ( maxLen ) { | 738 | switch ( maxLen ) { |
739 | case 2: | 739 | case 2: |
740 | str = QString::number( date.day() ); | 740 | str = QString::number( date.day() ); |
741 | break; | 741 | break; |
742 | 742 | ||
743 | case 3: | 743 | case 3: |
744 | str = dayName.left( 1 ) +QString::number( date.day()); | 744 | str = dayName.left( 1 ) +QString::number( date.day()); |
745 | 745 | ||
746 | break; | 746 | break; |
747 | case 4: | 747 | case 4: |
748 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 748 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
749 | 749 | ||
750 | break; | 750 | break; |
751 | case 5: | 751 | case 5: |
752 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 752 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
753 | 753 | ||
754 | break; | 754 | break; |
755 | case 6: | 755 | case 6: |
756 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 756 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
757 | break; | 757 | break; |
758 | 758 | ||
759 | default: | 759 | default: |
760 | break; | 760 | break; |
761 | } | 761 | } |
762 | if ( oneday ) { | 762 | if ( oneday ) { |
763 | QString addString; | 763 | QString addString; |
764 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 764 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
765 | addString = i18n("Today"); | 765 | addString = i18n("Today"); |
766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 766 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
767 | addString = i18n("Tomorrow"); | 767 | addString = i18n("Tomorrow"); |
768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 768 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
769 | addString = i18n("Yesterday"); | 769 | addString = i18n("Yesterday"); |
770 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 770 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
771 | addString = i18n("Day before yesterday"); | 771 | addString = i18n("Day before yesterday"); |
772 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 772 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
773 | addString = i18n("Day after tomorrow"); | 773 | addString = i18n("Day after tomorrow"); |
774 | if ( !addString.isEmpty() ) { | 774 | if ( !addString.isEmpty() ) { |
775 | str = addString+", " + str; | 775 | str = addString+", " + str; |
776 | } | 776 | } |
777 | } | 777 | } |
778 | dayLabel->setText(str); | 778 | dayLabel->setText(str); |
779 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 779 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
780 | if (date == QDate::currentDate()) { | 780 | if (date == QDate::currentDate()) { |
781 | QFont bFont = dlf; | 781 | QFont bFont = dlf; |
782 | bFont.setBold( true ); | 782 | bFont.setBold( true ); |
783 | dayLabel->setFont(bFont); | 783 | dayLabel->setFont(bFont); |
784 | } | 784 | } |
785 | //dayLayout->addWidget(dayLabel); | 785 | //dayLayout->addWidget(dayLabel); |
786 | 786 | ||
787 | #ifndef KORG_NOPLUGINS | 787 | #ifndef KORG_NOPLUGINS |
788 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 788 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
789 | CalendarDecoration *it; | 789 | CalendarDecoration *it; |
790 | for(it = cds.first(); it; it = cds.next()) { | 790 | for(it = cds.first(); it; it = cds.next()) { |
791 | QString text = it->shortText( date ); | 791 | QString text = it->shortText( date ); |
792 | if ( !text.isEmpty() ) { | 792 | if ( !text.isEmpty() ) { |
793 | QLabel *label = new QLabel(text,mDayLabels); | 793 | QLabel *label = new QLabel(text,mDayLabels); |
794 | label->setAlignment(AlignCenter); | 794 | label->setAlignment(AlignCenter); |
795 | dayLayout->addWidget(label); | 795 | dayLayout->addWidget(label); |
796 | } | 796 | } |
797 | } | 797 | } |
798 | 798 | ||
799 | for(it = cds.first(); it; it = cds.next()) { | 799 | for(it = cds.first(); it; it = cds.next()) { |
800 | QWidget *wid = it->smallWidget(mDayLabels,date); | 800 | QWidget *wid = it->smallWidget(mDayLabels,date); |
801 | if ( wid ) { | 801 | if ( wid ) { |
802 | // wid->setHeight(20); | 802 | // wid->setHeight(20); |
803 | dayLayout->addWidget(wid); | 803 | dayLayout->addWidget(wid); |
804 | } | 804 | } |
805 | } | 805 | } |
806 | #endif | 806 | #endif |
807 | } | 807 | } |
808 | if ( ! appendLabels ) { | 808 | if ( ! appendLabels ) { |
809 | dayLabel = mDayLabelsList.next(); | 809 | dayLabel = mDayLabelsList.next(); |
810 | if ( !dayLabel ) | 810 | if ( !dayLabel ) |
811 | appendLabels = true; | 811 | appendLabels = true; |
812 | } | 812 | } |
813 | if ( appendLabels ) { | 813 | if ( appendLabels ) { |
814 | dayLabel = getNewDaylabel(); | 814 | dayLabel = getNewDaylabel(); |
815 | } | 815 | } |
816 | //dayLabel->hide();//test only | 816 | //dayLabel->hide();//test only |
817 | 817 | ||
818 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; | 818 | int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; |
819 | if ( offset < 0 ) offset = 0; | 819 | if ( offset < 0 ) offset = 0; |
820 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); | 820 | //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); |
821 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); | 821 | dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); |
822 | dayLabel->setFont( dlf ); | 822 | dayLabel->setFont( dlf ); |
823 | dayLabel->show(); | 823 | dayLabel->show(); |
824 | dayLabel->setNum( -2 ); | 824 | dayLabel->setNum( -2 ); |
825 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); | 825 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); |
826 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); | 826 | //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); |
827 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 827 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
828 | if ( !appendLabels ) { | 828 | if ( !appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 829 | dayLabel = mDayLabelsList.next(); |
830 | while ( dayLabel ) { | 830 | while ( dayLabel ) { |
831 | //qDebug("!dayLabel %d",dayLabel ); | 831 | //qDebug("!dayLabel %d",dayLabel ); |
832 | dayLabel->hide(); | 832 | dayLabel->hide(); |
833 | dayLabel = mDayLabelsList.next(); | 833 | dayLabel = mDayLabelsList.next(); |
834 | } | 834 | } |
835 | } | 835 | } |
836 | //mDayLabelsFrame->show(); | 836 | //mDayLabelsFrame->show(); |
837 | //mDayLabels->show(); | 837 | //mDayLabels->show(); |
838 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); | 838 | //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); |
839 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); | 839 | //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); |
840 | mDayLabelsFrame->setFixedHeight( newHight ); | 840 | mDayLabelsFrame->setFixedHeight( newHight ); |
841 | } | 841 | } |
842 | 842 | ||
843 | int KOAgendaView::maxDatesHint() | 843 | int KOAgendaView::maxDatesHint() |
844 | { | 844 | { |
845 | // Not sure about the max number of events, so return 0 for now. | 845 | // Not sure about the max number of events, so return 0 for now. |
846 | return 0; | 846 | return 0; |
847 | } | 847 | } |
848 | 848 | ||
849 | int KOAgendaView::currentDateCount() | 849 | int KOAgendaView::currentDateCount() |
850 | { | 850 | { |
851 | return mSelectedDates.count(); | 851 | return mSelectedDates.count(); |
852 | } | 852 | } |
853 | 853 | ||
854 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 854 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
855 | { | 855 | { |
856 | QPtrList<Incidence> selected; | 856 | QPtrList<Incidence> selected; |
857 | Incidence *incidence; | 857 | Incidence *incidence; |
858 | 858 | ||
859 | incidence = mAgenda->selectedIncidence(); | 859 | incidence = mAgenda->selectedIncidence(); |
860 | if (incidence) selected.append(incidence); | 860 | if (incidence) selected.append(incidence); |
861 | 861 | ||
862 | incidence = mAllDayAgenda->selectedIncidence(); | 862 | incidence = mAllDayAgenda->selectedIncidence(); |
863 | if (incidence) selected.append(incidence); | 863 | if (incidence) selected.append(incidence); |
864 | 864 | ||
865 | return selected; | 865 | return selected; |
866 | } | 866 | } |
867 | 867 | ||
868 | DateList KOAgendaView::selectedDates() | 868 | DateList KOAgendaView::selectedDates() |
869 | { | 869 | { |
870 | DateList selected; | 870 | DateList selected; |
871 | QDate qd; | 871 | QDate qd; |
872 | 872 | ||
873 | qd = mAgenda->selectedIncidenceDate(); | 873 | qd = mAgenda->selectedIncidenceDate(); |
874 | if (qd.isValid()) selected.append(qd); | 874 | if (qd.isValid()) selected.append(qd); |
875 | 875 | ||
876 | qd = mAllDayAgenda->selectedIncidenceDate(); | 876 | qd = mAllDayAgenda->selectedIncidenceDate(); |
877 | if (qd.isValid()) selected.append(qd); | 877 | if (qd.isValid()) selected.append(qd); |
878 | 878 | ||
879 | return selected; | 879 | return selected; |
880 | } | 880 | } |
881 | 881 | ||
882 | 882 | ||
883 | void KOAgendaView::updateView() | 883 | void KOAgendaView::updateView() |
884 | { | 884 | { |
885 | if ( mBlockUpdating ) | 885 | if ( mBlockUpdating ) |
886 | return; | 886 | return; |
887 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 887 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
888 | fillAgenda(); | 888 | fillAgenda(); |
889 | 889 | ||
890 | } | 890 | } |
891 | 891 | ||
892 | 892 | ||
893 | /* | 893 | /* |
894 | Update configuration settings for the agenda view. This method is not | 894 | Update configuration settings for the agenda view. This method is not |
895 | complete. | 895 | complete. |
896 | */ | 896 | */ |
897 | void KOAgendaView::updateConfig() | 897 | void KOAgendaView::updateConfig() |
898 | { | 898 | { |
899 | if ( mBlockUpdating ) | 899 | if ( mBlockUpdating ) |
900 | return; | 900 | return; |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | // update config for children | 904 | // update config for children |
905 | mTimeLabels->updateConfig(); | 905 | mTimeLabels->updateConfig(); |
906 | mAgenda->storePosition(); | 906 | mAgenda->storePosition(); |
907 | mAgenda->updateConfig(); | 907 | mAgenda->updateConfig(); |
908 | mAllDayAgenda->updateConfig(); | 908 | mAllDayAgenda->updateConfig(); |
909 | // widget synchronization | 909 | // widget synchronization |
910 | //TODO: find a better way, maybe signal/slot | 910 | //TODO: find a better way, maybe signal/slot |
911 | mTimeLabels->positionChanged(); | 911 | mTimeLabels->positionChanged(); |
912 | 912 | ||
913 | // for some reason, this needs to be called explicitly | 913 | // for some reason, this needs to be called explicitly |
914 | mTimeLabels->repaint(); | 914 | mTimeLabels->repaint(); |
915 | 915 | ||
916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 916 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
917 | 917 | ||
918 | // ToolTips displaying summary of events | 918 | // ToolTips displaying summary of events |
919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 919 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
920 | ->mEnableToolTips); | 920 | ->mEnableToolTips); |
921 | 921 | ||
922 | //setHolidayMasks(); | 922 | //setHolidayMasks(); |
923 | 923 | ||
924 | //createDayLabels(); called by via updateView(); | 924 | //createDayLabels(); called by via updateView(); |
925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 925 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
926 | updateView(); | 926 | updateView(); |
927 | mAgenda->restorePosition(); | 927 | mAgenda->restorePosition(); |
928 | } | 928 | } |
929 | 929 | ||
930 | 930 | ||
931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 931 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
932 | { | 932 | { |
933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; | 933 | // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; |
934 | //qDebug("KOAgendaView::updateEventDates "); | 934 | //qDebug("KOAgendaView::updateEventDates "); |
935 | QDateTime startDt,endDt; | 935 | QDateTime startDt,endDt; |
936 | QDate startDate; | 936 | QDate startDate; |
937 | int lenInSecs; | 937 | int lenInSecs; |
938 | // if ( type == KOAgenda::RESIZETOP ) | 938 | // if ( type == KOAgenda::RESIZETOP ) |
939 | // qDebug("RESIZETOP "); | 939 | // qDebug("RESIZETOP "); |
940 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 940 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
941 | // qDebug("RESIZEBOTTOM "); | 941 | // qDebug("RESIZEBOTTOM "); |
942 | // if ( type == KOAgenda::MOVE ) | 942 | // if ( type == KOAgenda::MOVE ) |
943 | // qDebug("MOVE "); | 943 | // qDebug("MOVE "); |
944 | if ( item->incidence()->type() == "Event" ) { | 944 | if ( item->incidence()->type() == "Event" ) { |
945 | startDt =item->incidence()->dtStart(); | 945 | startDt =item->incidence()->dtStart(); |
946 | endDt = item->incidence()->dtEnd(); | 946 | endDt = item->incidence()->dtEnd(); |
947 | lenInSecs = startDt.secsTo( endDt ); | 947 | lenInSecs = startDt.secsTo( endDt ); |
948 | } | 948 | } |
949 | 949 | ||
950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 950 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
951 | 951 | ||
952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 952 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { |
953 | startDate = mSelectedDates[item->mLastMoveXPos]; | 953 | startDate = mSelectedDates[item->mLastMoveXPos]; |
954 | } else { | 954 | } else { |
955 | if (item->cellX() < 0) { | 955 | if (item->cellX() < 0) { |
956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 956 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
957 | } else { | 957 | } else { |
958 | startDate = mSelectedDates[item->cellX()]; | 958 | startDate = mSelectedDates[item->cellX()]; |
959 | } | 959 | } |
960 | } | 960 | } |
961 | startDt.setDate(startDate); | 961 | startDt.setDate(startDate); |
962 | 962 | ||
963 | if (item->incidence()->doesFloat()) { | 963 | if (item->incidence()->doesFloat()) { |
964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 964 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
965 | } else { | 965 | } else { |
966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 966 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 967 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
968 | if ( item->incidence()->type() == "Event" ) { | 968 | if ( item->incidence()->type() == "Event" ) { |
969 | if ( type == KOAgenda::MOVE ) { | 969 | if ( type == KOAgenda::MOVE ) { |
970 | endDt = startDt.addSecs(lenInSecs); | 970 | endDt = startDt.addSecs(lenInSecs); |
971 | 971 | ||
972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 972 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
973 | if (item->lastMultiItem()) { | 973 | if (item->lastMultiItem()) { |
974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 974 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
975 | endDt.setDate(startDate. | 975 | endDt.setDate(startDate. |
976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 976 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
977 | } else { | 977 | } else { |
978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 978 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
979 | endDt.setDate(startDate); | 979 | endDt.setDate(startDate); |
980 | } | 980 | } |
981 | } | 981 | } |
982 | } else { | 982 | } else { |
983 | // todo | 983 | // todo |
984 | if (item->lastMultiItem()) { | 984 | if (item->lastMultiItem()) { |
985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 985 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
986 | endDt.setDate(startDate. | 986 | endDt.setDate(startDate. |
987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 987 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
988 | } else { | 988 | } else { |
989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 989 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
990 | if ( item->cellYBottom() > 0 ) | 990 | if ( item->cellYBottom() > 0 ) |
991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 991 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
992 | else | 992 | else |
993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 993 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
994 | endDt.setDate(startDate); | 994 | endDt.setDate(startDate); |
995 | } | 995 | } |
996 | } | 996 | } |
997 | } | 997 | } |
998 | if ( item->incidence()->type() == "Event" ) { | 998 | if ( item->incidence()->type() == "Event" ) { |
999 | item->incidence()->setDtStart(startDt); | 999 | item->incidence()->setDtStart(startDt); |
1000 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1000 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1001 | } else if ( item->incidence()->type() == "Todo" ) { | 1001 | } else if ( item->incidence()->type() == "Todo" ) { |
1002 | (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); | 1002 | Todo* to = static_cast<Todo*>(item->incidence()); |
1003 | |||
1004 | int len = 0; | ||
1005 | if ( to->hasStartDate() && to->hasDueDate() ) | ||
1006 | len = to->dtStart().secsTo( to->dtDue()); | ||
1007 | to->setDtDue(endDt); | ||
1008 | if ( to->hasStartDate() ) { | ||
1009 | if ( len>0 ) | ||
1010 | to->setDtStart(to->dtDue().addSecs( -len )); | ||
1011 | else | ||
1012 | if (to->dtStart() > to->dtDue() ) | ||
1013 | to->setDtStart(to->dtDue().addDays( -3 )); | ||
1014 | } | ||
1015 | |||
1003 | } | 1016 | } |
1004 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1017 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1005 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1018 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1006 | item->setItemDate(startDt.date()); | 1019 | item->setItemDate(startDt.date()); |
1007 | //item->updateItem(); | 1020 | //item->updateItem(); |
1008 | if ( item->incidence()->type() == "Todo" ) { | 1021 | if ( item->incidence()->type() == "Todo" ) { |
1009 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1022 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1010 | 1023 | ||
1011 | } | 1024 | } |
1012 | else | 1025 | else |
1013 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1026 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1014 | item->updateItem(); | 1027 | item->updateItem(); |
1015 | } | 1028 | } |
1016 | 1029 | ||
1017 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1030 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1018 | { | 1031 | { |
1019 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1032 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1020 | 1033 | ||
1021 | mSelectedDates.clear(); | 1034 | mSelectedDates.clear(); |
1022 | // qDebug("KOAgendaView::showDates "); | 1035 | // qDebug("KOAgendaView::showDates "); |
1023 | QDate d = start; | 1036 | QDate d = start; |
1024 | while (d <= end) { | 1037 | while (d <= end) { |
1025 | mSelectedDates.append(d); | 1038 | mSelectedDates.append(d); |
1026 | d = d.addDays( 1 ); | 1039 | d = d.addDays( 1 ); |
1027 | } | 1040 | } |
1028 | 1041 | ||
1029 | // and update the view | 1042 | // and update the view |
1030 | fillAgenda(); | 1043 | fillAgenda(); |
1031 | } | 1044 | } |
1032 | 1045 | ||
1033 | 1046 | ||
1034 | void KOAgendaView::showEvents(QPtrList<Event>) | 1047 | void KOAgendaView::showEvents(QPtrList<Event>) |
1035 | { | 1048 | { |
1036 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1049 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1037 | } | 1050 | } |
1038 | 1051 | ||
1039 | void KOAgendaView::changeEventDisplay(Event *, int) | 1052 | void KOAgendaView::changeEventDisplay(Event *, int) |
1040 | { | 1053 | { |
1041 | // qDebug("KOAgendaView::changeEventDisplay "); | 1054 | // qDebug("KOAgendaView::changeEventDisplay "); |
1042 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1055 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1043 | // this should be re-written to be MUCH smarter. Right now we | 1056 | // this should be re-written to be MUCH smarter. Right now we |
1044 | // are just playing dumb. | 1057 | // are just playing dumb. |
1045 | fillAgenda(); | 1058 | fillAgenda(); |
1046 | } | 1059 | } |
1047 | 1060 | ||
1048 | void KOAgendaView::fillAgenda(const QDate &) | 1061 | void KOAgendaView::fillAgenda(const QDate &) |
1049 | { | 1062 | { |
1050 | // qDebug("KOAgendaView::fillAgenda "); | 1063 | // qDebug("KOAgendaView::fillAgenda "); |
1051 | fillAgenda(); | 1064 | fillAgenda(); |
1052 | } | 1065 | } |
1053 | 1066 | ||
1054 | void KOAgendaView::fillAgenda() | 1067 | void KOAgendaView::fillAgenda() |
1055 | { | 1068 | { |
1056 | if ( globalFlagBlockStartup ) | 1069 | if ( globalFlagBlockStartup ) |
1057 | return; | 1070 | return; |
1058 | if ( globalFlagBlockAgenda == 1 ) | 1071 | if ( globalFlagBlockAgenda == 1 ) |
1059 | return; | 1072 | return; |
1060 | //if ( globalFlagBlockAgenda == 2 ) | 1073 | //if ( globalFlagBlockAgenda == 2 ) |
1061 | //globalFlagBlockAgenda = 0; | 1074 | //globalFlagBlockAgenda = 0; |
1062 | // globalFlagBlockPainting = false; | 1075 | // globalFlagBlockPainting = false; |
1063 | if ( globalFlagBlockAgenda == 0 ) | 1076 | if ( globalFlagBlockAgenda == 0 ) |
1064 | globalFlagBlockAgenda = 1; | 1077 | globalFlagBlockAgenda = 1; |
1065 | // clearView(); | 1078 | // clearView(); |
1066 | //qDebug("fillAgenda()++++ "); | 1079 | //qDebug("fillAgenda()++++ "); |
1067 | globalFlagBlockAgendaItemPaint = 1; | 1080 | globalFlagBlockAgendaItemPaint = 1; |
1068 | 1081 | ||
1069 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1082 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1070 | mAgenda->changeColumns(mSelectedDates.count()); | 1083 | mAgenda->changeColumns(mSelectedDates.count()); |
1071 | qApp->processEvents(); | 1084 | qApp->processEvents(); |
1072 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1085 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1073 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1086 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1074 | setHolidayMasks(); | 1087 | setHolidayMasks(); |
1075 | 1088 | ||
1076 | //mAgenda->hideUnused(); | 1089 | //mAgenda->hideUnused(); |
1077 | //mAllDayAgenda->hideUnused(); | 1090 | //mAllDayAgenda->hideUnused(); |
1078 | 1091 | ||
1079 | // mAgenda->blockNextRepaint( false ); | 1092 | // mAgenda->blockNextRepaint( false ); |
1080 | // mAgenda->viewport()->repaint(); | 1093 | // mAgenda->viewport()->repaint(); |
1081 | // mAgenda->blockNextRepaint( true ); | 1094 | // mAgenda->blockNextRepaint( true ); |
1082 | mMinY.resize(mSelectedDates.count()); | 1095 | mMinY.resize(mSelectedDates.count()); |
1083 | mMaxY.resize(mSelectedDates.count()); | 1096 | mMaxY.resize(mSelectedDates.count()); |
1084 | 1097 | ||
1085 | QPtrList<Event> dayEvents; | 1098 | QPtrList<Event> dayEvents; |
1086 | 1099 | ||
1087 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1100 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1088 | // Therefore, gtodoset all of them. | 1101 | // Therefore, gtodoset all of them. |
1089 | QPtrList<Todo> todos = calendar()->todos(); | 1102 | QPtrList<Todo> todos = calendar()->todos(); |
1090 | 1103 | ||
1091 | mAgenda->setDateList(mSelectedDates); | 1104 | mAgenda->setDateList(mSelectedDates); |
1092 | 1105 | ||
1093 | QDate today = QDate::currentDate(); | 1106 | QDate today = QDate::currentDate(); |
1094 | 1107 | ||
1095 | DateList::ConstIterator dit; | 1108 | DateList::ConstIterator dit; |
1096 | int curCol = 0; | 1109 | int curCol = 0; |
1097 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1110 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1098 | QDate currentDate = *dit; | 1111 | QDate currentDate = *dit; |
1099 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1112 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1100 | // << endl; | 1113 | // << endl; |
1101 | 1114 | ||
1102 | dayEvents = calendar()->events(currentDate,true); | 1115 | dayEvents = calendar()->events(currentDate,true); |
1103 | 1116 | ||
1104 | // Default values, which can never be reached | 1117 | // Default values, which can never be reached |
1105 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1118 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1106 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1119 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1107 | 1120 | ||
1108 | unsigned int numEvent; | 1121 | unsigned int numEvent; |
1109 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1122 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1110 | Event *event = dayEvents.at(numEvent); | 1123 | Event *event = dayEvents.at(numEvent); |
1111 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1124 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1112 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1125 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1113 | continue; | 1126 | continue; |
1114 | // kdDebug() << " Event: " << event->summary() << endl; | 1127 | // kdDebug() << " Event: " << event->summary() << endl; |
1115 | 1128 | ||
1116 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1129 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1117 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1130 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1118 | 1131 | ||
1119 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1132 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1120 | 1133 | ||
1121 | if (event->doesFloat()) { | 1134 | if (event->doesFloat()) { |
1122 | if (event->recurrence()->doesRecur()) { | 1135 | if (event->recurrence()->doesRecur()) { |
1123 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1136 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1124 | } else { | 1137 | } else { |
1125 | if (beginX <= 0 && curCol == 0) { | 1138 | if (beginX <= 0 && curCol == 0) { |
1126 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1139 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1127 | } else if (beginX == curCol) { | 1140 | } else if (beginX == curCol) { |
1128 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1141 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1129 | } | 1142 | } |
1130 | } | 1143 | } |
1131 | } else if (event->isMultiDay()) { | 1144 | } else if (event->isMultiDay()) { |
1132 | if ( event->doesRecur () ) { | 1145 | if ( event->doesRecur () ) { |
1133 | QDate dateit = currentDate; | 1146 | QDate dateit = currentDate; |
1134 | int count = 0; | 1147 | int count = 0; |
1135 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1148 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1136 | while (! event->recursOn( dateit ) && count <= max ) { | 1149 | while (! event->recursOn( dateit ) && count <= max ) { |
1137 | ++count; | 1150 | ++count; |
1138 | dateit = dateit.addDays( -1 ); | 1151 | dateit = dateit.addDays( -1 ); |
1139 | } | 1152 | } |
1140 | bool ok; | 1153 | bool ok; |
1141 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1154 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1142 | if ( ok ) | 1155 | if ( ok ) |
1143 | { | 1156 | { |
1144 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1157 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1145 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1158 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1146 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1159 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1147 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1160 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1148 | 1161 | ||
1149 | } | 1162 | } |
1150 | } | 1163 | } |
1151 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1164 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1152 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1165 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1153 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1166 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1154 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1167 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1155 | //qDebug("insert!!! "); | 1168 | //qDebug("insert!!! "); |
1156 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1169 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1157 | } | 1170 | } |
1158 | if (beginX == curCol) { | 1171 | if (beginX == curCol) { |
1159 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1172 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1160 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1173 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1161 | } else if (endX == curCol) { | 1174 | } else if (endX == curCol) { |
1162 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1175 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1163 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1176 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1164 | } else { | 1177 | } else { |
1165 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1178 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1166 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1179 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1167 | } | 1180 | } |
1168 | } else { | 1181 | } else { |
1169 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1182 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1170 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1183 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1171 | if (endY < startY) endY = startY; | 1184 | if (endY < startY) endY = startY; |
1172 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1185 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1173 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1186 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1174 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1187 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1175 | } | 1188 | } |
1176 | } | 1189 | } |
1177 | // ---------- [display Todos -------------- | 1190 | // ---------- [display Todos -------------- |
1178 | unsigned int numTodo; | 1191 | unsigned int numTodo; |
1179 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1192 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1180 | Todo *todo = todos.at(numTodo); | 1193 | Todo *todo = todos.at(numTodo); |
1181 | 1194 | ||
1182 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1195 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1183 | 1196 | ||
1184 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1197 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1185 | // Already completed items can be displayed on their original due date | 1198 | // Already completed items can be displayed on their original due date |
1186 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1199 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1187 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1200 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1188 | bool fillIn = false; | 1201 | bool fillIn = false; |
1189 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1202 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1190 | fillIn = true; | 1203 | fillIn = true; |
1191 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1204 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1192 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1205 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1193 | if ( fillIn ) { | 1206 | if ( fillIn ) { |
1194 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1207 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1195 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1208 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1196 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1209 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1197 | } | 1210 | } |
1198 | else { | 1211 | else { |
1199 | QDateTime dt; | 1212 | QDateTime dt; |
1200 | if ( todo->hasCompletedDate() ) | 1213 | if ( todo->hasCompletedDate() ) |
1201 | dt = todo->completed(); | 1214 | dt = todo->completed(); |
1202 | else | 1215 | else |
1203 | dt = todo->dtDue();; | 1216 | dt = todo->dtDue();; |
1204 | 1217 | ||
1205 | 1218 | ||
1206 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1219 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1207 | int hi = (18/KOPrefs::instance()->mHourSize); | 1220 | int hi = (18/KOPrefs::instance()->mHourSize); |
1208 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1221 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1209 | int startY = endY -hi; | 1222 | int startY = endY -hi; |
1210 | 1223 | ||
1211 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1224 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1212 | 1225 | ||
1213 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1226 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1214 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1227 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1215 | } | 1228 | } |
1216 | } | 1229 | } |
1217 | } | 1230 | } |
1218 | // ---------- display Todos] -------------- | 1231 | // ---------- display Todos] -------------- |
1219 | 1232 | ||
1220 | ++curCol; | 1233 | ++curCol; |
1221 | } | 1234 | } |
1222 | mAgenda->hideUnused(); | 1235 | mAgenda->hideUnused(); |
1223 | mAllDayAgenda->hideUnused(); | 1236 | mAllDayAgenda->hideUnused(); |
1224 | mAgenda->checkScrollBoundaries(); | 1237 | mAgenda->checkScrollBoundaries(); |
1225 | 1238 | ||
1226 | deleteSelectedDateTime(); | 1239 | deleteSelectedDateTime(); |
1227 | 1240 | ||
1228 | createDayLabels(); | 1241 | createDayLabels(); |
1229 | emit incidenceSelected( 0 ); | 1242 | emit incidenceSelected( 0 ); |
1230 | 1243 | ||
1231 | if ( globalFlagBlockAgenda == 2 ) { | 1244 | if ( globalFlagBlockAgenda == 2 ) { |
1232 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1245 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1233 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1246 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1234 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1247 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1235 | setStartHour( QTime::currentTime ().hour() ); | 1248 | setStartHour( QTime::currentTime ().hour() ); |
1236 | // qApp->processEvents(); | 1249 | // qApp->processEvents(); |
1237 | } | 1250 | } |
1238 | qApp->processEvents(); | 1251 | qApp->processEvents(); |
1239 | //qDebug("qApp->processEvents(); END "); | 1252 | //qDebug("qApp->processEvents(); END "); |
1240 | globalFlagBlockAgenda = 0; | 1253 | globalFlagBlockAgenda = 0; |
1241 | 1254 | ||
1242 | // mAgenda->hideUnused(); | 1255 | // mAgenda->hideUnused(); |
1243 | //mAllDayAgenda->hideUnused(); | 1256 | //mAllDayAgenda->hideUnused(); |
1244 | mAllDayAgenda->drawContentsToPainter(); | 1257 | mAllDayAgenda->drawContentsToPainter(); |
1245 | mAgenda->drawContentsToPainter(); | 1258 | mAgenda->drawContentsToPainter(); |
1246 | repaintAgenda(); | 1259 | repaintAgenda(); |
1247 | // mAgenda->finishUpdate(); | 1260 | // mAgenda->finishUpdate(); |
1248 | //mAllDayAgenda->finishUpdate(); | 1261 | //mAllDayAgenda->finishUpdate(); |
1249 | 1262 | ||
1250 | // repaintAgenda(); | 1263 | // repaintAgenda(); |
1251 | //qApp->processEvents(); | 1264 | //qApp->processEvents(); |
1252 | // globalFlagBlockAgenda = 0; | 1265 | // globalFlagBlockAgenda = 0; |
1253 | } | 1266 | } |
1254 | void KOAgendaView::repaintAgenda() | 1267 | void KOAgendaView::repaintAgenda() |
1255 | { | 1268 | { |
1256 | // mAllDayAgenda->drawContentsToPainter(); | 1269 | // mAllDayAgenda->drawContentsToPainter(); |
1257 | // mAllDayAgenda->viewport()->repaint( false ); | 1270 | // mAllDayAgenda->viewport()->repaint( false ); |
1258 | // mAgenda->drawContentsToPainter(); | 1271 | // mAgenda->drawContentsToPainter(); |
1259 | // mAgenda->viewport()->repaint( false ); | 1272 | // mAgenda->viewport()->repaint( false ); |
1260 | // qApp->processEvents(); | 1273 | // qApp->processEvents(); |
1261 | 1274 | ||
1262 | //qDebug("KOAgendaView::repaintAgenda() "); | 1275 | //qDebug("KOAgendaView::repaintAgenda() "); |
1263 | //qApp->processEvents(); | 1276 | //qApp->processEvents(); |
1264 | mAgenda->viewport()->repaint( false ); | 1277 | mAgenda->viewport()->repaint( false ); |
1265 | mAllDayAgenda->viewport()->repaint( false ); | 1278 | mAllDayAgenda->viewport()->repaint( false ); |
1266 | mAgenda->finishUpdate(); | 1279 | mAgenda->finishUpdate(); |
1267 | mAllDayAgenda->finishUpdate(); | 1280 | mAllDayAgenda->finishUpdate(); |
1268 | } | 1281 | } |
1269 | 1282 | ||
1270 | 1283 | ||
1271 | void KOAgendaView::clearView() | 1284 | void KOAgendaView::clearView() |
1272 | { | 1285 | { |
1273 | // kdDebug() << "ClearView" << endl; | 1286 | // kdDebug() << "ClearView" << endl; |
1274 | mAllDayAgenda->clear(); | 1287 | mAllDayAgenda->clear(); |
1275 | mAgenda->clear(); | 1288 | mAgenda->clear(); |
1276 | } | 1289 | } |
1277 | 1290 | ||
1278 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1291 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1279 | const QDate &td) | 1292 | const QDate &td) |
1280 | { | 1293 | { |
1281 | #ifndef KORG_NOPRINTER | 1294 | #ifndef KORG_NOPRINTER |
1282 | if (fd == td) | 1295 | if (fd == td) |
1283 | calPrinter->preview(CalPrinter::Day, fd, td); | 1296 | calPrinter->preview(CalPrinter::Day, fd, td); |
1284 | else | 1297 | else |
1285 | calPrinter->preview(CalPrinter::Week, fd, td); | 1298 | calPrinter->preview(CalPrinter::Week, fd, td); |
1286 | #endif | 1299 | #endif |
1287 | } | 1300 | } |
1288 | 1301 | ||
1289 | // void KOAgendaView::updateMovedTodo() | 1302 | // void KOAgendaView::updateMovedTodo() |
1290 | // { | 1303 | // { |
1291 | // // updateConfig(); | 1304 | // // updateConfig(); |
1292 | // // emit updateTodoViews(); | 1305 | // // emit updateTodoViews(); |
1293 | // } | 1306 | // } |
1294 | 1307 | ||
1295 | void KOAgendaView::newEvent(int gx, int gy) | 1308 | void KOAgendaView::newEvent(int gx, int gy) |
1296 | { | 1309 | { |
1297 | if (!mSelectedDates.count()) return; | 1310 | if (!mSelectedDates.count()) return; |
1298 | 1311 | ||
1299 | QDate day = mSelectedDates[gx]; | 1312 | QDate day = mSelectedDates[gx]; |
1300 | 1313 | ||
1301 | QTime time = mAgenda->gyToTime(gy); | 1314 | QTime time = mAgenda->gyToTime(gy); |
1302 | QDateTime dt(day,time); | 1315 | QDateTime dt(day,time); |
1303 | // if ( dt < QDateTime::currentDateTime () ) | 1316 | // if ( dt < QDateTime::currentDateTime () ) |
1304 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1317 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1305 | emit newEventSignal(dt); | 1318 | emit newEventSignal(dt); |
1306 | } | 1319 | } |
1307 | 1320 | ||
1308 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1321 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1309 | { | 1322 | { |
1310 | if (!mSelectedDates.count()) return; | 1323 | if (!mSelectedDates.count()) return; |
1311 | 1324 | ||
1312 | QDate dayStart = mSelectedDates[gxStart]; | 1325 | QDate dayStart = mSelectedDates[gxStart]; |
1313 | QDate dayEnd = mSelectedDates[gxEnd]; | 1326 | QDate dayEnd = mSelectedDates[gxEnd]; |
1314 | 1327 | ||
1315 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1328 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1316 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1329 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1317 | 1330 | ||
1318 | QDateTime dtStart(dayStart,timeStart); | 1331 | QDateTime dtStart(dayStart,timeStart); |
1319 | QDateTime dtEnd(dayEnd,timeEnd); | 1332 | QDateTime dtEnd(dayEnd,timeEnd); |
1320 | 1333 | ||
1321 | emit newEventSignal(dtStart,dtEnd); | 1334 | emit newEventSignal(dtStart,dtEnd); |
1322 | } | 1335 | } |
1323 | 1336 | ||
1324 | void KOAgendaView::newEventAllDay(int gx, int ) | 1337 | void KOAgendaView::newEventAllDay(int gx, int ) |
1325 | { | 1338 | { |
1326 | if (!mSelectedDates.count()) return; | 1339 | if (!mSelectedDates.count()) return; |
1327 | 1340 | ||
1328 | QDate day = mSelectedDates[gx]; | 1341 | QDate day = mSelectedDates[gx]; |
1329 | 1342 | ||
1330 | emit newEventSignal(day); | 1343 | emit newEventSignal(day); |
1331 | } | 1344 | } |
1332 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1345 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1333 | { | 1346 | { |
1334 | if (!mSelectedDates.count()) return; | 1347 | if (!mSelectedDates.count()) return; |
1335 | 1348 | ||
1336 | QDateTime day (mSelectedDates[gx] ); | 1349 | QDateTime day (mSelectedDates[gx] ); |
1337 | emit newTodoSignal(day, true); | 1350 | emit newTodoSignal(day, true); |
1338 | } | 1351 | } |
1339 | void KOAgendaView::newTodo(int gx, int gy ) | 1352 | void KOAgendaView::newTodo(int gx, int gy ) |
1340 | { | 1353 | { |
1341 | if (!mSelectedDates.count()) return; | 1354 | if (!mSelectedDates.count()) return; |
1342 | QDate dayStart = mSelectedDates[gx]; | 1355 | QDate dayStart = mSelectedDates[gx]; |
1343 | QTime timeStart = mAgenda->gyToTime(gy); | 1356 | QTime timeStart = mAgenda->gyToTime(gy); |
1344 | QDateTime dt (dayStart,timeStart); | 1357 | QDateTime dt (dayStart,timeStart); |
1345 | emit newTodoSignal( dt, false ); | 1358 | emit newTodoSignal( dt, false ); |
1346 | } | 1359 | } |
1347 | 1360 | ||
1348 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1361 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1349 | { | 1362 | { |
1350 | uint i; | 1363 | uint i; |
1351 | for(i=0;i<mMinY.size();++i) { | 1364 | for(i=0;i<mMinY.size();++i) { |
1352 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1365 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1353 | else mEventIndicatorTop->enableColumn(i,false); | 1366 | else mEventIndicatorTop->enableColumn(i,false); |
1354 | } | 1367 | } |
1355 | 1368 | ||
1356 | mEventIndicatorTop->update(); | 1369 | mEventIndicatorTop->update(); |
1357 | } | 1370 | } |
1358 | 1371 | ||
1359 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1372 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1360 | { | 1373 | { |
1361 | uint i; | 1374 | uint i; |
1362 | for(i=0;i<mMaxY.size();++i) { | 1375 | for(i=0;i<mMaxY.size();++i) { |
1363 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1376 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1364 | else mEventIndicatorBottom->enableColumn(i,false); | 1377 | else mEventIndicatorBottom->enableColumn(i,false); |
1365 | } | 1378 | } |
1366 | 1379 | ||
1367 | mEventIndicatorBottom->update(); | 1380 | mEventIndicatorBottom->update(); |
1368 | } | 1381 | } |
1369 | 1382 | ||
1370 | void KOAgendaView::startDrag(Event *event) | 1383 | void KOAgendaView::startDrag(Event *event) |
1371 | { | 1384 | { |
1372 | #ifndef KORG_NODND | 1385 | #ifndef KORG_NODND |
1373 | DndFactory factory( calendar() ); | 1386 | DndFactory factory( calendar() ); |
1374 | ICalDrag *vd = factory.createDrag(event,this); | 1387 | ICalDrag *vd = factory.createDrag(event,this); |
1375 | if (vd->drag()) { | 1388 | if (vd->drag()) { |
1376 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1389 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1377 | } | 1390 | } |
1378 | #endif | 1391 | #endif |
1379 | } | 1392 | } |
1380 | 1393 | ||
1381 | void KOAgendaView::readSettings() | 1394 | void KOAgendaView::readSettings() |
1382 | { | 1395 | { |
1383 | readSettings(KOGlobals::config()); | 1396 | readSettings(KOGlobals::config()); |
1384 | } | 1397 | } |
1385 | 1398 | ||
1386 | void KOAgendaView::readSettings(KConfig *config) | 1399 | void KOAgendaView::readSettings(KConfig *config) |
1387 | { | 1400 | { |
1388 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1401 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1389 | 1402 | ||
1390 | config->setGroup("Views"); | 1403 | config->setGroup("Views"); |
1391 | 1404 | ||
1392 | //#ifndef KORG_NOSPLITTER | 1405 | //#ifndef KORG_NOSPLITTER |
1393 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1406 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1394 | if (sizes.count() == 2) { | 1407 | if (sizes.count() == 2) { |
1395 | if ( sizes[0] < 20 ) { | 1408 | if ( sizes[0] < 20 ) { |
1396 | sizes[1] = sizes[1] +20 - sizes[0]; | 1409 | sizes[1] = sizes[1] +20 - sizes[0]; |
1397 | sizes[0] = 20; | 1410 | sizes[0] = 20; |
1398 | } | 1411 | } |
1399 | mSplitterAgenda->setSizes(sizes); | 1412 | mSplitterAgenda->setSizes(sizes); |
1400 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1413 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1401 | } | 1414 | } |
1402 | //#endif | 1415 | //#endif |
1403 | 1416 | ||
1404 | // updateConfig(); | 1417 | // updateConfig(); |
1405 | } | 1418 | } |
1406 | 1419 | ||
1407 | void KOAgendaView::writeSettings(KConfig *config) | 1420 | void KOAgendaView::writeSettings(KConfig *config) |
1408 | { | 1421 | { |
1409 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1422 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1410 | 1423 | ||
1411 | config->setGroup("Views"); | 1424 | config->setGroup("Views"); |
1412 | 1425 | ||
1413 | //#ifndef KORG_NOSPLITTER | 1426 | //#ifndef KORG_NOSPLITTER |
1414 | QValueList<int> list = mSplitterAgenda->sizes(); | 1427 | QValueList<int> list = mSplitterAgenda->sizes(); |
1415 | config->writeEntry("Separator AgendaView",list); | 1428 | config->writeEntry("Separator AgendaView",list); |
1416 | //qDebug("write %d %d ", list[0],list[1] ); | 1429 | //qDebug("write %d %d ", list[0],list[1] ); |
1417 | //#endif | 1430 | //#endif |
1418 | } | 1431 | } |
1419 | 1432 | ||
1420 | void KOAgendaView::setHolidayMasks() | 1433 | void KOAgendaView::setHolidayMasks() |
1421 | { | 1434 | { |
1422 | mHolidayMask.resize(mSelectedDates.count()); | 1435 | mHolidayMask.resize(mSelectedDates.count()); |
1423 | 1436 | ||
1424 | uint i; | 1437 | uint i; |
1425 | for(i=0;i<mSelectedDates.count();++i) { | 1438 | for(i=0;i<mSelectedDates.count();++i) { |
1426 | QDate date = mSelectedDates[i]; | 1439 | QDate date = mSelectedDates[i]; |
1427 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1440 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1428 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1441 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1429 | bool showHoliday = false; | 1442 | bool showHoliday = false; |
1430 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1443 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1431 | QPtrList<Event> events = calendar()->events( date, true ); | 1444 | QPtrList<Event> events = calendar()->events( date, true ); |
1432 | Event *event; | 1445 | Event *event; |
1433 | for( event = events.first(); event; event = events.next() ) { | 1446 | for( event = events.first(); event; event = events.next() ) { |
1434 | if ( event->categories().contains("Holiday") || | 1447 | if ( event->categories().contains("Holiday") || |
1435 | event->categories().contains(i18n("Holiday"))) { | 1448 | event->categories().contains(i18n("Holiday"))) { |
1436 | showHoliday = true; | 1449 | showHoliday = true; |
1437 | break; | 1450 | break; |
1438 | } | 1451 | } |
1439 | } | 1452 | } |
1440 | 1453 | ||
1441 | } | 1454 | } |
1442 | 1455 | ||
1443 | #ifndef KORG_NOPLUGINS | 1456 | #ifndef KORG_NOPLUGINS |
1444 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1457 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1445 | !KOCore::self()->holiday(date).isEmpty(); | 1458 | !KOCore::self()->holiday(date).isEmpty(); |
1446 | #endif | 1459 | #endif |
1447 | bool showDay = showSaturday || showSunday || showHoliday; | 1460 | bool showDay = showSaturday || showSunday || showHoliday; |
1448 | 1461 | ||
1449 | if (showDay) { | 1462 | if (showDay) { |
1450 | mHolidayMask.at(i) = true; | 1463 | mHolidayMask.at(i) = true; |
1451 | } else { | 1464 | } else { |
1452 | mHolidayMask.at(i) = false; | 1465 | mHolidayMask.at(i) = false; |
1453 | } | 1466 | } |
1454 | } | 1467 | } |
1455 | 1468 | ||
1456 | mAgenda->setHolidayMask(&mHolidayMask); | 1469 | mAgenda->setHolidayMask(&mHolidayMask); |
1457 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1470 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1458 | } | 1471 | } |
1459 | 1472 | ||
1460 | void KOAgendaView::setContentsPos(int y) | 1473 | void KOAgendaView::setContentsPos(int y) |
1461 | { | 1474 | { |
1462 | mAgenda->setContentsPos(0,y); | 1475 | mAgenda->setContentsPos(0,y); |
1463 | } | 1476 | } |
1464 | 1477 | ||
1465 | void KOAgendaView::setExpandedButton( bool expanded ) | 1478 | void KOAgendaView::setExpandedButton( bool expanded ) |
1466 | { | 1479 | { |
1467 | if ( expanded ) { | 1480 | if ( expanded ) { |
1468 | mExpandButton->setPixmap( mExpandedPixmap ); | 1481 | mExpandButton->setPixmap( mExpandedPixmap ); |
1469 | } else { | 1482 | } else { |
1470 | mExpandButton->setPixmap( mNotExpandedPixmap ); | 1483 | mExpandButton->setPixmap( mNotExpandedPixmap ); |
1471 | } | 1484 | } |
1472 | } | 1485 | } |
1473 | 1486 | ||
1474 | void KOAgendaView::clearSelection() | 1487 | void KOAgendaView::clearSelection() |
1475 | { | 1488 | { |
1476 | mAgenda->deselectItem(); | 1489 | mAgenda->deselectItem(); |
1477 | mAllDayAgenda->deselectItem(); | 1490 | mAllDayAgenda->deselectItem(); |
1478 | } | 1491 | } |
1479 | 1492 | ||
1480 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1493 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1481 | int gxEnd, int gyEnd) | 1494 | int gxEnd, int gyEnd) |
1482 | { | 1495 | { |
1483 | mTimeSpanInAllDay = true; | 1496 | mTimeSpanInAllDay = true; |
1484 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1497 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1485 | } | 1498 | } |
1486 | 1499 | ||
1487 | 1500 | ||
1488 | 1501 | ||
1489 | 1502 | ||
1490 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1503 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1491 | int gxEnd, int gyEnd) | 1504 | int gxEnd, int gyEnd) |
1492 | { | 1505 | { |
1493 | if (!mSelectedDates.count()) return; | 1506 | if (!mSelectedDates.count()) return; |
1494 | 1507 | ||
1495 | QDate dayStart = mSelectedDates[gxStart]; | 1508 | QDate dayStart = mSelectedDates[gxStart]; |
1496 | QDate dayEnd = mSelectedDates[gxEnd]; | 1509 | QDate dayEnd = mSelectedDates[gxEnd]; |
1497 | 1510 | ||
1498 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1511 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1499 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1512 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1500 | 1513 | ||
1501 | QDateTime dtStart(dayStart,timeStart); | 1514 | QDateTime dtStart(dayStart,timeStart); |
1502 | QDateTime dtEnd(dayEnd,timeEnd); | 1515 | QDateTime dtEnd(dayEnd,timeEnd); |
1503 | 1516 | ||
1504 | mTimeSpanBegin = dtStart; | 1517 | mTimeSpanBegin = dtStart; |
1505 | mTimeSpanEnd = dtEnd; | 1518 | mTimeSpanEnd = dtEnd; |
1506 | 1519 | ||
1507 | } | 1520 | } |
1508 | 1521 | ||
1509 | void KOAgendaView::deleteSelectedDateTime() | 1522 | void KOAgendaView::deleteSelectedDateTime() |
1510 | { | 1523 | { |
1511 | mTimeSpanBegin.setDate(QDate()); | 1524 | mTimeSpanBegin.setDate(QDate()); |
1512 | mTimeSpanEnd.setDate(QDate()); | 1525 | mTimeSpanEnd.setDate(QDate()); |
1513 | mTimeSpanInAllDay = false; | 1526 | mTimeSpanInAllDay = false; |
1514 | } | 1527 | } |
1515 | 1528 | ||
1516 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1529 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1517 | { | 1530 | { |
1518 | e->ignore(); | 1531 | e->ignore(); |
1519 | } | 1532 | } |
1520 | 1533 | ||
1521 | void KOAgendaView::scrollOneHourUp() | 1534 | void KOAgendaView::scrollOneHourUp() |
1522 | { | 1535 | { |
1523 | 1536 | ||
1524 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1537 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1525 | } | 1538 | } |
1526 | void KOAgendaView::scrollOneHourDown() | 1539 | void KOAgendaView::scrollOneHourDown() |
1527 | { | 1540 | { |
1528 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1541 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1529 | } | 1542 | } |
1530 | 1543 | ||
1531 | void KOAgendaView::setStartHour( int h ) | 1544 | void KOAgendaView::setStartHour( int h ) |
1532 | { | 1545 | { |
1533 | mAgenda->setStartHour( h ); | 1546 | mAgenda->setStartHour( h ); |
1534 | 1547 | ||
1535 | } | 1548 | } |
1536 | void KOAgendaView::setInitStartHour() | 1549 | void KOAgendaView::setInitStartHour() |
1537 | { | 1550 | { |
1538 | 1551 | ||
1539 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1552 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1540 | setStartHour( QTime::currentTime ().hour() ); | 1553 | setStartHour( QTime::currentTime ().hour() ); |
1541 | else | 1554 | else |
1542 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1555 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1543 | 1556 | ||
1544 | } | 1557 | } |
1545 | 1558 | ||
1546 | 1559 | ||
1547 | void KOAgendaView::updateTodo( Todo * t, int ) | 1560 | void KOAgendaView::updateTodo( Todo * t, int ) |
1548 | { | 1561 | { |
1549 | if ( !isVisible() ) | 1562 | if ( !isVisible() ) |
1550 | return; | 1563 | return; |
1551 | bool remove = false; | 1564 | bool remove = false; |
1552 | bool removeAD = false; | 1565 | bool removeAD = false; |
1553 | QDate da; | 1566 | QDate da; |
1554 | if ( t->hasCompletedDate() ) | 1567 | if ( t->hasCompletedDate() ) |
1555 | da = t->completed().date(); | 1568 | da = t->completed().date(); |
1556 | else | 1569 | else |
1557 | da = t->dtDue().date(); | 1570 | da = t->dtDue().date(); |
1558 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1571 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1559 | remove = true; | 1572 | remove = true; |
1560 | removeAD = true; | 1573 | removeAD = true; |
1561 | } | 1574 | } |
1562 | else { | 1575 | else { |
1563 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1576 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1564 | if ( overdue && | 1577 | if ( overdue && |
1565 | QDate::currentDate() >= mSelectedDates.first() && | 1578 | QDate::currentDate() >= mSelectedDates.first() && |
1566 | QDate::currentDate() <= mSelectedDates.last()) { | 1579 | QDate::currentDate() <= mSelectedDates.last()) { |
1567 | removeAD = false; | 1580 | removeAD = false; |
1568 | remove = true; | 1581 | remove = true; |
1569 | } | 1582 | } |
1570 | else { | 1583 | else { |
1571 | 1584 | ||
1572 | if ( da < mSelectedDates.first() || | 1585 | if ( da < mSelectedDates.first() || |
1573 | da > mSelectedDates.last() ) { | 1586 | da > mSelectedDates.last() ) { |
1574 | remove = true; | 1587 | remove = true; |
1575 | removeAD = true; | 1588 | removeAD = true; |
1576 | } else { | 1589 | } else { |
1577 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1590 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1578 | removeAD = !remove; | 1591 | removeAD = !remove; |
1579 | } | 1592 | } |
1580 | } | 1593 | } |
1581 | } | 1594 | } |
1582 | int days = mSelectedDates.first().daysTo( da ); | 1595 | int days = mSelectedDates.first().daysTo( da ); |
1583 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1596 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1584 | mAgenda->updateTodo( t , days, remove); | 1597 | mAgenda->updateTodo( t , days, remove); |
1585 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1598 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1586 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1599 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1587 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1600 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1588 | 1601 | ||
1589 | } | 1602 | } |
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 39921a0..f6c9624 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,663 +1,670 @@ | |||
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 | 19 | ||
20 | #include <qcstring.h> | 20 | #include <qcstring.h> |
21 | #include <qwhatsthis.h> | 21 | #include <qwhatsthis.h> |
22 | #include <qdialog.h> | 22 | #include <qdialog.h> |
23 | #include <qapplication.h> | 23 | #include <qapplication.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | 26 | ||
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kapplication.h> | 28 | #include <kapplication.h> |
29 | #include <libkcal/event.h> | 29 | #include <libkcal/event.h> |
30 | #include <libkcal/todo.h> | 30 | #include <libkcal/todo.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kiconloader.h> | 32 | #include <kiconloader.h> |
33 | #include <krun.h> | 33 | #include <krun.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | #include <kprocess.h> | 35 | #include <kprocess.h> |
36 | #include "koprefs.h" | 36 | #include "koprefs.h" |
37 | 37 | ||
38 | #include <kabc/stdaddressbook.h> | 38 | #include <kabc/stdaddressbook.h> |
39 | 39 | ||
40 | #ifndef KORG_NODCOP | 40 | #ifndef KORG_NODCOP |
41 | #include <dcopclient.h> | 41 | #include <dcopclient.h> |
42 | #include "korganizer.h" | 42 | #include "korganizer.h" |
43 | #include "koprefs.h" | 43 | #include "koprefs.h" |
44 | #include "actionmanager.h" | 44 | #include "actionmanager.h" |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include "koeventviewer.h" | 47 | #include "koeventviewer.h" |
48 | //#ifndef KORG_NOKABC | 48 | //#ifndef KORG_NOKABC |
49 | //#include <kabc/stdaddressbook.h> | 49 | //#include <kabc/stdaddressbook.h> |
50 | //#define size count | 50 | //#define size count |
51 | //#endif | 51 | //#endif |
52 | 52 | ||
53 | #ifdef DESKTOP_VERSION | 53 | #ifdef DESKTOP_VERSION |
54 | #include <kabc/addresseedialog.h> | 54 | #include <kabc/addresseedialog.h> |
55 | #include <kabc/addresseeview.h> | 55 | #include <kabc/addresseeview.h> |
56 | #else //DESKTOP_VERSION | 56 | #else //DESKTOP_VERSION |
57 | #include <externalapphandler.h> | 57 | #include <externalapphandler.h> |
58 | #include <qtopia/qcopenvelope_qws.h> | 58 | #include <qtopia/qcopenvelope_qws.h> |
59 | #endif //DESKTOP_VERSION | 59 | #endif //DESKTOP_VERSION |
60 | 60 | ||
61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 61 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) |
62 | : QTextBrowser(parent,name) | 62 | : QTextBrowser(parent,name) |
63 | { | 63 | { |
64 | mSyncMode = false; | 64 | mSyncMode = false; |
65 | mColorMode = 0; | 65 | mColorMode = 0; |
66 | } | 66 | } |
67 | 67 | ||
68 | KOEventViewer::~KOEventViewer() | 68 | KOEventViewer::~KOEventViewer() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | void KOEventViewer::setSource(const QString& n) | 72 | void KOEventViewer::setSource(const QString& n) |
73 | { | 73 | { |
74 | 74 | ||
75 | if ( n.left(3) == "uid" ) | 75 | if ( n.left(3) == "uid" ) |
76 | #ifdef DESKTOP_VERSION | 76 | #ifdef DESKTOP_VERSION |
77 | { | 77 | { |
78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 78 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
79 | KABC::AddressBook::Iterator it; | 79 | KABC::AddressBook::Iterator it; |
80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 80 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
81 | // LR I do not understand, why the uid string is different on zaurus and desktop | 81 | // LR I do not understand, why the uid string is different on zaurus and desktop |
82 | QString uid = "uid://"+(*it).uid(); | 82 | QString uid = "uid://"+(*it).uid(); |
83 | 83 | ||
84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 84 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
85 | if (n == uid ) { | 85 | if (n == uid ) { |
86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 86 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
87 | QDialog dia( this,"dia123", true ); | 87 | QDialog dia( this,"dia123", true ); |
88 | dia.setCaption( i18n("Details of attendee") ); | 88 | dia.setCaption( i18n("Details of attendee") ); |
89 | QVBoxLayout lay ( &dia ); | 89 | QVBoxLayout lay ( &dia ); |
90 | KABC::AddresseeView av ( &dia ); | 90 | KABC::AddresseeView av ( &dia ); |
91 | av.setAddressee( (*it) ); | 91 | av.setAddressee( (*it) ); |
92 | lay.addWidget( &av ); | 92 | lay.addWidget( &av ); |
93 | if ( QApplication::desktop()->width() < 480 ) | 93 | if ( QApplication::desktop()->width() < 480 ) |
94 | dia.resize( 220, 240); | 94 | dia.resize( 220, 240); |
95 | else { | 95 | else { |
96 | dia.resize( 400,400); | 96 | dia.resize( 400,400); |
97 | } | 97 | } |
98 | dia.exec(); | 98 | dia.exec(); |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | #else | 104 | #else |
105 | { | 105 | { |
106 | if ( "uid:organizer" == n ) { | 106 | if ( "uid:organizer" == n ) { |
107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 107 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 110 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
111 | if (attendees.count()) { | 111 | if (attendees.count()) { |
112 | Attendee *a; | 112 | Attendee *a; |
113 | for(a=attendees.first();a;a=attendees.next()) { | 113 | for(a=attendees.first();a;a=attendees.next()) { |
114 | if ( "uid:"+a->uid() == n ) { | 114 | if ( "uid:"+a->uid() == n ) { |
115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 115 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
116 | return; | 116 | return; |
117 | } | 117 | } |
118 | } | 118 | } |
119 | } | 119 | } |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 122 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
123 | // the result should now arrive through method insertAttendees | 123 | // the result should now arrive through method insertAttendees |
124 | //QString uid = "uid:"+(*it).uid(); | 124 | //QString uid = "uid:"+(*it).uid(); |
125 | #endif | 125 | #endif |
126 | if ( n.left(6) == "mailto" ) { | 126 | if ( n.left(6) == "mailto" ) { |
127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 127 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
128 | #ifndef DESKTOP_VERSION | 128 | #ifndef DESKTOP_VERSION |
129 | if ( n.mid(7,3) == "ALL" ) { | 129 | if ( n.mid(7,3) == "ALL" ) { |
130 | qDebug("all "); | 130 | qDebug("all "); |
131 | mailToAttendees( true ); | 131 | mailToAttendees( true ); |
132 | } else if ( n.mid(7,4) == "RSVP" ) { | 132 | } else if ( n.mid(7,4) == "RSVP" ) { |
133 | mailToAttendees( false ); | 133 | mailToAttendees( false ); |
134 | qDebug("rsvp "); | 134 | qDebug("rsvp "); |
135 | } else { | 135 | } else { |
136 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 136 | QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
137 | e << n.mid(7); | 137 | e << n.mid(7); |
138 | } | 138 | } |
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | } | 141 | } |
142 | 142 | ||
143 | 143 | ||
144 | #ifndef KORG_NODCOP | 144 | #ifndef KORG_NODCOP |
145 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 145 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
146 | QString tmpStr; | 146 | QString tmpStr; |
147 | if (n.startsWith("mailto:")) { | 147 | if (n.startsWith("mailto:")) { |
148 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 148 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
149 | //emit showIncidence(n); | 149 | //emit showIncidence(n); |
150 | return; | 150 | return; |
151 | } else if (n.startsWith("uid:")) { | 151 | } else if (n.startsWith("uid:")) { |
152 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 152 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
153 | const QByteArray noParamData; | 153 | const QByteArray noParamData; |
154 | const QByteArray paramData; | 154 | const QByteArray paramData; |
155 | QByteArray replyData; | 155 | QByteArray replyData; |
156 | QCString replyTypeStr; | 156 | QCString replyTypeStr; |
157 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 157 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
158 | bool foundAbbrowser = PING_ABBROWSER; | 158 | bool foundAbbrowser = PING_ABBROWSER; |
159 | 159 | ||
160 | if (foundAbbrowser) { | 160 | if (foundAbbrowser) { |
161 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 161 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
162 | //client->send("kaddressbook","KAddressBookIface", | 162 | //client->send("kaddressbook","KAddressBookIface", |
163 | QDataStream arg(paramData, IO_WriteOnly); | 163 | QDataStream arg(paramData, IO_WriteOnly); |
164 | arg << n.mid(6); | 164 | arg << n.mid(6); |
165 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 165 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
166 | return; | 166 | return; |
167 | } else { | 167 | } else { |
168 | /* | 168 | /* |
169 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 169 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
170 | We start it without its main interface | 170 | We start it without its main interface |
171 | */ | 171 | */ |
172 | KIconLoader* iconLoader = new KIconLoader(); | 172 | KIconLoader* iconLoader = new KIconLoader(); |
173 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 173 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
174 | ActionManager::setStartedKAddressBook(true); | 174 | ActionManager::setStartedKAddressBook(true); |
175 | tmpStr = "kaddressbook --editor-only --uid "; | 175 | tmpStr = "kaddressbook --editor-only --uid "; |
176 | tmpStr += KProcess::quote(n.mid(6)); | 176 | tmpStr += KProcess::quote(n.mid(6)); |
177 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 177 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | } else { | 180 | } else { |
181 | //QTextBrowser::setSource(n); | 181 | //QTextBrowser::setSource(n); |
182 | } | 182 | } |
183 | #endif | 183 | #endif |
184 | } | 184 | } |
185 | void KOEventViewer::mailToAttendees( bool all ) | 185 | void KOEventViewer::mailToAttendees( bool all ) |
186 | { | 186 | { |
187 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 187 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
188 | if (attendees.count() == 0) return; | 188 | if (attendees.count() == 0) return; |
189 | QStringList nameList; | 189 | QStringList nameList; |
190 | QStringList emailList; | 190 | QStringList emailList; |
191 | QStringList uidList; | 191 | QStringList uidList; |
192 | Attendee* a; | 192 | Attendee* a; |
193 | for(a=attendees.first();a;a=attendees.next()) { | 193 | for(a=attendees.first();a;a=attendees.next()) { |
194 | if ( !all && !a->RSVP() ) continue; | 194 | if ( !all && !a->RSVP() ) continue; |
195 | if (!a->email().isEmpty()) { | 195 | if (!a->email().isEmpty()) { |
196 | nameList.append (a->name() ); | 196 | nameList.append (a->name() ); |
197 | emailList.append (a->email() ); | 197 | emailList.append (a->email() ); |
198 | uidList.append (a->uid() ); | 198 | uidList.append (a->uid() ); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 201 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
202 | #ifndef DESKTOP_VERSION | 202 | #ifndef DESKTOP_VERSION |
203 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 203 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
204 | #endif | 204 | #endif |
205 | 205 | ||
206 | } | 206 | } |
207 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 207 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
208 | { | 208 | { |
209 | int number=text.contains("\n"); | 209 | int number=text.contains("\n"); |
210 | QString str = "<" + tag + ">"; | 210 | QString str = "<" + tag + ">"; |
211 | QString tmpText=text; | 211 | QString tmpText=text; |
212 | QString tmpStr=str; | 212 | QString tmpStr=str; |
213 | if(number !=-1) | 213 | if(number !=-1) |
214 | { | 214 | { |
215 | if (number > 0) { | 215 | if (number > 0) { |
216 | int pos=0; | 216 | int pos=0; |
217 | QString tmp; | 217 | QString tmp; |
218 | for(int i=0;i<=number;i++) { | 218 | for(int i=0;i<=number;i++) { |
219 | pos=tmpText.find("\n"); | 219 | pos=tmpText.find("\n"); |
220 | tmp=tmpText.left(pos); | 220 | tmp=tmpText.left(pos); |
221 | tmpText=tmpText.right(tmpText.length()-pos-1); | 221 | tmpText=tmpText.right(tmpText.length()-pos-1); |
222 | tmpStr+=tmp+"<br>"; | 222 | tmpStr+=tmp+"<br>"; |
223 | } | 223 | } |
224 | } | 224 | } |
225 | else tmpStr += tmpText; | 225 | else tmpStr += tmpText; |
226 | tmpStr+="</" + tag + ">"; | 226 | tmpStr+="</" + tag + ">"; |
227 | mText.append(tmpStr); | 227 | mText.append(tmpStr); |
228 | } | 228 | } |
229 | else | 229 | else |
230 | { | 230 | { |
231 | str += text + "</" + tag + ">"; | 231 | str += text + "</" + tag + ">"; |
232 | mText.append(str); | 232 | mText.append(str); |
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | void KOEventViewer::setColorMode( int m ) | 236 | void KOEventViewer::setColorMode( int m ) |
237 | { | 237 | { |
238 | mColorMode = m; | 238 | mColorMode = m; |
239 | } | 239 | } |
240 | void KOEventViewer::appendEvent(Event *event, int mode ) | 240 | void KOEventViewer::appendEvent(Event *event, int mode ) |
241 | { | 241 | { |
242 | mMailSubject = ""; | 242 | mMailSubject = ""; |
243 | mCurrentIncidence = event; | 243 | mCurrentIncidence = event; |
244 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 244 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
245 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 245 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
246 | if ( mode == 0 ) { | 246 | if ( mode == 0 ) { |
247 | addTag("h2",event->summary()); | 247 | addTag("h2",event->summary()); |
248 | } | 248 | } |
249 | else { | 249 | else { |
250 | if ( mColorMode == 1 ) { | 250 | if ( mColorMode == 1 ) { |
251 | mText +="<font color=\"#00A000\">"; | 251 | mText +="<font color=\"#00A000\">"; |
252 | } | 252 | } |
253 | if ( mColorMode == 2 ) { | 253 | if ( mColorMode == 2 ) { |
254 | mText +="<font color=\"#C00000\">"; | 254 | mText +="<font color=\"#C00000\">"; |
255 | } | 255 | } |
256 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 256 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
257 | if ( mode == 1 ) { | 257 | if ( mode == 1 ) { |
258 | addTag("h2",i18n( "Local: " ) +event->summary()); | 258 | addTag("h2",i18n( "Local: " ) +event->summary()); |
259 | } else { | 259 | } else { |
260 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 260 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
261 | } | 261 | } |
262 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 262 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
263 | if ( mColorMode ) | 263 | if ( mColorMode ) |
264 | mText += "</font>"; | 264 | mText += "</font>"; |
265 | } | 265 | } |
266 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 266 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
267 | if (event->cancelled ()) { | 267 | if (event->cancelled ()) { |
268 | mText +="<font color=\"#B00000\">"; | 268 | mText +="<font color=\"#B00000\">"; |
269 | addTag("i",i18n("This event has been cancelled!")); | 269 | addTag("i",i18n("This event has been cancelled!")); |
270 | mText.append("<br>"); | 270 | mText.append("<br>"); |
271 | mText += "</font>"; | 271 | mText += "</font>"; |
272 | mMailSubject += i18n("(cancelled)"); | 272 | mMailSubject += i18n("(cancelled)"); |
273 | } | 273 | } |
274 | if (!event->location().isEmpty()) { | 274 | if (!event->location().isEmpty()) { |
275 | addTag("b",i18n("Location: ")); | 275 | addTag("b",i18n("Location: ")); |
276 | mText.append(event->location()+"<br>"); | 276 | mText.append(event->location()+"<br>"); |
277 | mMailSubject += i18n(" at ") + event->location(); | 277 | mMailSubject += i18n(" at ") + event->location(); |
278 | } | 278 | } |
279 | if (event->doesFloat()) { | 279 | if (event->doesFloat()) { |
280 | if (event->isMultiDay()) { | 280 | if (event->isMultiDay()) { |
281 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 281 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
282 | .arg(event->dtStartDateStr(shortDate)) | 282 | .arg(event->dtStartDateStr(shortDate)) |
283 | .arg(event->dtEndDateStr(shortDate))); | 283 | .arg(event->dtEndDateStr(shortDate))); |
284 | } else { | 284 | } else { |
285 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 285 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
286 | } | 286 | } |
287 | } else { | 287 | } else { |
288 | if (event->isMultiDay()) { | 288 | if (event->isMultiDay()) { |
289 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 289 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
290 | .arg(event->dtStartStr( shortDate))); | 290 | .arg(event->dtStartStr( shortDate))); |
291 | mText.append(i18n("<p><b>To:</b> %1</p>") | 291 | mText.append(i18n("<p><b>To:</b> %1</p>") |
292 | .arg(event->dtEndStr(shortDate))); | 292 | .arg(event->dtEndStr(shortDate))); |
293 | } else { | 293 | } else { |
294 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 294 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
295 | .arg(event->dtStartDateStr( shortDate ))); | 295 | .arg(event->dtStartDateStr( shortDate ))); |
296 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 296 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
297 | .arg(event->dtStartTimeStr()) | 297 | .arg(event->dtStartTimeStr()) |
298 | .arg(event->dtEndTimeStr())); | 298 | .arg(event->dtEndTimeStr())); |
299 | } | 299 | } |
300 | } | 300 | } |
301 | 301 | ||
302 | if (event->recurrence()->doesRecur()) { | 302 | if (event->recurrence()->doesRecur()) { |
303 | 303 | ||
304 | QString recurText = event->recurrence()->recurrenceText(); | 304 | QString recurText = event->recurrence()->recurrenceText(); |
305 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 305 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
306 | bool ok; | 306 | bool ok; |
307 | QDate start = QDate::currentDate(); | 307 | QDate start = QDate::currentDate(); |
308 | QDateTime next; | 308 | QDateTime next; |
309 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 309 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
310 | if ( ok ) { | 310 | if ( ok ) { |
311 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 311 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
312 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 312 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
313 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); | 313 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); |
314 | 314 | ||
315 | } else { | 315 | } else { |
316 | bool last; | 316 | bool last; |
317 | QDate nextd; | 317 | QDate nextd; |
318 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 318 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
319 | if ( last ) { | 319 | if ( last ) { |
320 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 320 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
321 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 321 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } else { | 324 | } else { |
325 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 325 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
326 | 326 | ||
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | if (event->isAlarmEnabled()) { | 330 | if (event->isAlarmEnabled()) { |
331 | Alarm *alarm =event->alarms().first() ; | 331 | Alarm *alarm =event->alarms().first() ; |
332 | QDateTime t = alarm->time(); | 332 | QDateTime t = alarm->time(); |
333 | int min = t.secsTo( event->dtStart() )/60; | 333 | int min = t.secsTo( event->dtStart() )/60; |
334 | QString s =i18n("( %1 min before )").arg( min ); | 334 | QString s =i18n("( %1 min before )").arg( min ); |
335 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 335 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
336 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 336 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
337 | //addTag("p",s); | 337 | //addTag("p",s); |
338 | } | 338 | } |
339 | 339 | ||
340 | addTag("b",i18n("Access: ")); | 340 | addTag("b",i18n("Access: ")); |
341 | mText.append(event->secrecyStr()+"<br>"); | 341 | mText.append(event->secrecyStr()+"<br>"); |
342 | if (!event->description().isEmpty()) { | 342 | if (!event->description().isEmpty()) { |
343 | addTag("p",i18n("<b>Details: </b>")); | 343 | addTag("p",i18n("<b>Details: </b>")); |
344 | addTag("p",event->description()); | 344 | addTag("p",event->description()); |
345 | } | 345 | } |
346 | 346 | ||
347 | formatCategories(event); | 347 | formatCategories(event); |
348 | 348 | ||
349 | formatReadOnly(event); | 349 | formatReadOnly(event); |
350 | formatAttendees(event); | 350 | formatAttendees(event); |
351 | 351 | ||
352 | setText(mText); | 352 | setText(mText); |
353 | //QWhatsThis::add(this,mText); | 353 | //QWhatsThis::add(this,mText); |
354 | 354 | ||
355 | } | 355 | } |
356 | 356 | ||
357 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 357 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
358 | { | 358 | { |
359 | mMailSubject = ""; | 359 | mMailSubject = ""; |
360 | mCurrentIncidence = event; | 360 | mCurrentIncidence = event; |
361 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 361 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
362 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 362 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
363 | if (mode == 0 ) | 363 | if (mode == 0 ) |
364 | addTag("h2",event->summary()); | 364 | addTag("h2",event->summary()); |
365 | else { | 365 | else { |
366 | if ( mColorMode == 1 ) { | 366 | if ( mColorMode == 1 ) { |
367 | mText +="<font color=\"#00A000\">"; | 367 | mText +="<font color=\"#00A000\">"; |
368 | } | 368 | } |
369 | if ( mColorMode == 2 ) { | 369 | if ( mColorMode == 2 ) { |
370 | mText +="<font color=\"#B00000\">"; | 370 | mText +="<font color=\"#B00000\">"; |
371 | } | 371 | } |
372 | if ( mode == 1 ) { | 372 | if ( mode == 1 ) { |
373 | addTag("h2",i18n( "Local: " ) +event->summary()); | 373 | addTag("h2",i18n( "Local: " ) +event->summary()); |
374 | } else { | 374 | } else { |
375 | addTag("h2",i18n( "Remote: " ) +event->summary()); | 375 | addTag("h2",i18n( "Remote: " ) +event->summary()); |
376 | } | 376 | } |
377 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 377 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
378 | if ( mColorMode ) | 378 | if ( mColorMode ) |
379 | mText += "</font>"; | 379 | mText += "</font>"; |
380 | } | 380 | } |
381 | mMailSubject += i18n( "Todo " )+ event->summary(); | 381 | mMailSubject += i18n( "Todo " )+ event->summary(); |
382 | 382 | ||
383 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 383 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
384 | mText +="<font color=\"#B00000\">"; | 384 | mText +="<font color=\"#B00000\">"; |
385 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); | 385 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); |
386 | mText += "</font>"; | 386 | mText += "</font>"; |
387 | } else { | 387 | } else { |
388 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 388 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
389 | .arg(event->percentComplete())); | 389 | .arg(event->percentComplete())); |
390 | } | 390 | } |
391 | 391 | ||
392 | if (event->cancelled ()) { | 392 | if (event->cancelled ()) { |
393 | mText +="<font color=\"#B00000\">"; | 393 | mText +="<font color=\"#B00000\">"; |
394 | addTag("i",i18n("This todo has been cancelled!")); | 394 | addTag("i",i18n("This todo has been cancelled!")); |
395 | mText.append("<br>"); | 395 | mText.append("<br>"); |
396 | mText += "</font>"; | 396 | mText += "</font>"; |
397 | mMailSubject += i18n("(cancelled)"); | 397 | mMailSubject += i18n("(cancelled)"); |
398 | } | 398 | } |
399 | 399 | ||
400 | if (!event->location().isEmpty()) { | 400 | if (!event->location().isEmpty()) { |
401 | addTag("b",i18n("Location: ")); | 401 | addTag("b",i18n("Location: ")); |
402 | mText.append(event->location()+"<br>"); | 402 | mText.append(event->location()+"<br>"); |
403 | mMailSubject += i18n(" at ") + event->location(); | 403 | mMailSubject += i18n(" at ") + event->location(); |
404 | } | 404 | } |
405 | |||
406 | if (event->recurrence()->doesRecur()) { | ||
407 | |||
408 | QString recurText = event->recurrence()->recurrenceText(); | ||
409 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | ||
410 | |||
411 | } | ||
405 | if (event->hasStartDate()) { | 412 | if (event->hasStartDate()) { |
406 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 413 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
407 | } | 414 | } |
408 | if (event->hasDueDate()) { | 415 | if (event->hasDueDate()) { |
409 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 416 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
410 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 417 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
411 | } | 418 | } |
412 | addTag("b",i18n("Access: ")); | 419 | addTag("b",i18n("Access: ")); |
413 | mText.append(event->secrecyStr()+"<br>"); | 420 | mText.append(event->secrecyStr()+"<br>"); |
414 | if (!event->description().isEmpty()) { | 421 | if (!event->description().isEmpty()) { |
415 | addTag("p",i18n("<b>Details: </b>")); | 422 | addTag("p",i18n("<b>Details: </b>")); |
416 | addTag("p",event->description()); | 423 | addTag("p",event->description()); |
417 | } | 424 | } |
418 | 425 | ||
419 | formatCategories(event); | 426 | formatCategories(event); |
420 | 427 | ||
421 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 428 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
422 | .arg(QString::number(event->priority()))); | 429 | .arg(QString::number(event->priority()))); |
423 | 430 | ||
424 | formatReadOnly(event); | 431 | formatReadOnly(event); |
425 | formatAttendees(event); | 432 | formatAttendees(event); |
426 | if ( event->relatedTo() ) { | 433 | if ( event->relatedTo() ) { |
427 | addTag("b",i18n("Parent todo:<br>")); | 434 | addTag("b",i18n("Parent todo:<br>")); |
428 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); | 435 | mText.append(event->relatedTo()->summary()+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); |
429 | } | 436 | } |
430 | QPtrList<Incidence> Relations = event->relations(); | 437 | QPtrList<Incidence> Relations = event->relations(); |
431 | Incidence *to; | 438 | Incidence *to; |
432 | if ( Relations.first() ) | 439 | if ( Relations.first() ) |
433 | addTag("b",i18n("Sub todos:<br>")); | 440 | addTag("b",i18n("Sub todos:<br>")); |
434 | for (to=Relations.first();to;to=Relations.next()) { | 441 | for (to=Relations.first();to;to=Relations.next()) { |
435 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); | 442 | mText.append( to->summary()+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); |
436 | 443 | ||
437 | } | 444 | } |
438 | setText(mText); | 445 | setText(mText); |
439 | } | 446 | } |
440 | 447 | ||
441 | void KOEventViewer::formatCategories(Incidence *event) | 448 | void KOEventViewer::formatCategories(Incidence *event) |
442 | { | 449 | { |
443 | if (!event->categoriesStr().isEmpty()) { | 450 | if (!event->categoriesStr().isEmpty()) { |
444 | if (event->categories().count() == 1) { | 451 | if (event->categories().count() == 1) { |
445 | addTag("h3",i18n("Category")); | 452 | addTag("h3",i18n("Category")); |
446 | } else { | 453 | } else { |
447 | addTag("h3",i18n("Categories")); | 454 | addTag("h3",i18n("Categories")); |
448 | } | 455 | } |
449 | addTag("p",event->categoriesStr()); | 456 | addTag("p",event->categoriesStr()); |
450 | } | 457 | } |
451 | } | 458 | } |
452 | void KOEventViewer::formatAttendees(Incidence *event) | 459 | void KOEventViewer::formatAttendees(Incidence *event) |
453 | { | 460 | { |
454 | QPtrList<Attendee> attendees = event->attendees(); | 461 | QPtrList<Attendee> attendees = event->attendees(); |
455 | if (attendees.count()) { | 462 | if (attendees.count()) { |
456 | 463 | ||
457 | 464 | ||
458 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 465 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
459 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 466 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
460 | addTag("h3",i18n("Organizer")); | 467 | addTag("h3",i18n("Organizer")); |
461 | mText.append("<ul><li>"); | 468 | mText.append("<ul><li>"); |
462 | #ifndef KORG_NOKABC | 469 | #ifndef KORG_NOKABC |
463 | 470 | ||
464 | #ifdef DESKTOP_VERSION | 471 | #ifdef DESKTOP_VERSION |
465 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 472 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
466 | KABC::Addressee::List addressList; | 473 | KABC::Addressee::List addressList; |
467 | addressList = add_book->findByEmail(event->organizer()); | 474 | addressList = add_book->findByEmail(event->organizer()); |
468 | KABC::Addressee o = addressList.first(); | 475 | KABC::Addressee o = addressList.first(); |
469 | if (!o.isEmpty() && addressList.size()<2) { | 476 | if (!o.isEmpty() && addressList.size()<2) { |
470 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 477 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
471 | mText += o.formattedName(); | 478 | mText += o.formattedName(); |
472 | mText += "</a>\n"; | 479 | mText += "</a>\n"; |
473 | } else { | 480 | } else { |
474 | mText.append(event->organizer()); | 481 | mText.append(event->organizer()); |
475 | } | 482 | } |
476 | #else //DESKTOP_VERSION | 483 | #else //DESKTOP_VERSION |
477 | mText += "<a href=\"uid:organizer\">"; | 484 | mText += "<a href=\"uid:organizer\">"; |
478 | mText += event->organizer(); | 485 | mText += event->organizer(); |
479 | mText += "</a>\n"; | 486 | mText += "</a>\n"; |
480 | #endif //DESKTOP_VERSION | 487 | #endif //DESKTOP_VERSION |
481 | 488 | ||
482 | 489 | ||
483 | #else | 490 | #else |
484 | mText.append(event->organizer()); | 491 | mText.append(event->organizer()); |
485 | #endif | 492 | #endif |
486 | 493 | ||
487 | if (iconPath) { | 494 | if (iconPath) { |
488 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 495 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
489 | mText += "<IMG src=\"" + iconPath + "\">"; | 496 | mText += "<IMG src=\"" + iconPath + "\">"; |
490 | mText += "</a>\n"; | 497 | mText += "</a>\n"; |
491 | } | 498 | } |
492 | mText.append("</li></ul>"); | 499 | mText.append("</li></ul>"); |
493 | 500 | ||
494 | addTag("h3",i18n("Attendees")); | 501 | addTag("h3",i18n("Attendees")); |
495 | Attendee *a; | 502 | Attendee *a; |
496 | mText.append("<ul>"); | 503 | mText.append("<ul>"); |
497 | int a_count = 0; | 504 | int a_count = 0; |
498 | int a_count_nr = 0; | 505 | int a_count_nr = 0; |
499 | 506 | ||
500 | for(a=attendees.first();a;a=attendees.next()) { | 507 | for(a=attendees.first();a;a=attendees.next()) { |
501 | #ifndef KORG_NOKABC | 508 | #ifndef KORG_NOKABC |
502 | #ifdef DESKTOP_VERSION | 509 | #ifdef DESKTOP_VERSION |
503 | if (a->name().isEmpty()) { | 510 | if (a->name().isEmpty()) { |
504 | addressList = add_book->findByEmail(a->email()); | 511 | addressList = add_book->findByEmail(a->email()); |
505 | KABC::Addressee o = addressList.first(); | 512 | KABC::Addressee o = addressList.first(); |
506 | if (!o.isEmpty() && addressList.size()<2) { | 513 | if (!o.isEmpty() && addressList.size()<2) { |
507 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 514 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
508 | mText += o.formattedName(); | 515 | mText += o.formattedName(); |
509 | mText += "</a>\n"; | 516 | mText += "</a>\n"; |
510 | } else { | 517 | } else { |
511 | mText += "<li>"; | 518 | mText += "<li>"; |
512 | mText.append(a->email()); | 519 | mText.append(a->email()); |
513 | mText += "\n"; | 520 | mText += "\n"; |
514 | } | 521 | } |
515 | } else { | 522 | } else { |
516 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 523 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
517 | if (!a->name().isEmpty()) mText += a->name(); | 524 | if (!a->name().isEmpty()) mText += a->name(); |
518 | else mText += a->email(); | 525 | else mText += a->email(); |
519 | mText += "</a>\n"; | 526 | mText += "</a>\n"; |
520 | } | 527 | } |
521 | #else //DESKTOP_VERSION | 528 | #else //DESKTOP_VERSION |
522 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 529 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
523 | if (!a->name().isEmpty()) mText += a->name(); | 530 | if (!a->name().isEmpty()) mText += a->name(); |
524 | else mText += a->email(); | 531 | else mText += a->email(); |
525 | mText += "</a>\n"; | 532 | mText += "</a>\n"; |
526 | #endif //DESKTOP_VERSION | 533 | #endif //DESKTOP_VERSION |
527 | #else | 534 | #else |
528 | //qDebug("nokabc "); | 535 | //qDebug("nokabc "); |
529 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 536 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
530 | if (!a->name().isEmpty()) mText += a->name(); | 537 | if (!a->name().isEmpty()) mText += a->name(); |
531 | else mText += a->email(); | 538 | else mText += a->email(); |
532 | mText += "</a>\n"; | 539 | mText += "</a>\n"; |
533 | #endif | 540 | #endif |
534 | 541 | ||
535 | 542 | ||
536 | if (!a->email().isEmpty()) { | 543 | if (!a->email().isEmpty()) { |
537 | if (iconPath) { | 544 | if (iconPath) { |
538 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 545 | mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
539 | if ( a->RSVP() ) { | 546 | if ( a->RSVP() ) { |
540 | ++a_count_nr; | 547 | ++a_count_nr; |
541 | mText += "<IMG src=\"" + iconPath + "\">"; | 548 | mText += "<IMG src=\"" + iconPath + "\">"; |
542 | } | 549 | } |
543 | else { | 550 | else { |
544 | ++a_count; | 551 | ++a_count; |
545 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 552 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
546 | } | 553 | } |
547 | mText += "</a>\n"; | 554 | mText += "</a>\n"; |
548 | } | 555 | } |
549 | } | 556 | } |
550 | if (a->status() != Attendee::NeedsAction ) | 557 | if (a->status() != Attendee::NeedsAction ) |
551 | mText +="[" + a->statusStr() + "] "; | 558 | mText +="[" + a->statusStr() + "] "; |
552 | if (a->role() == Attendee::Chair ) | 559 | if (a->role() == Attendee::Chair ) |
553 | mText +="(" + a->roleStr().left(1) + ".)"; | 560 | mText +="(" + a->roleStr().left(1) + ".)"; |
554 | } | 561 | } |
555 | mText.append("</li></ul>"); | 562 | mText.append("</li></ul>"); |
556 | if ( (a_count+a_count_nr) > 1 ) { | 563 | if ( (a_count+a_count_nr) > 1 ) { |
557 | mText += "<a href=\"mailto:ALL\">"; | 564 | mText += "<a href=\"mailto:ALL\">"; |
558 | mText += i18n( "Mail to all" ); | 565 | mText += i18n( "Mail to all" ); |
559 | mText += "</a> ( "; | 566 | mText += "</a> ( "; |
560 | mText += "<IMG src=\"" + iconPath + "\">"; | 567 | mText += "<IMG src=\"" + iconPath + "\">"; |
561 | mText += i18n( " and " ); | 568 | mText += i18n( " and " ); |
562 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; | 569 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; |
563 | mText += "<br>\n"; | 570 | mText += "<br>\n"; |
564 | 571 | ||
565 | 572 | ||
566 | } | 573 | } |
567 | if ( a_count_nr > 1 ) { | 574 | if ( a_count_nr > 1 ) { |
568 | mText += "<a href=\"mailto:RSVP\">"; | 575 | mText += "<a href=\"mailto:RSVP\">"; |
569 | mText += i18n( "Mail to selected" ); | 576 | mText += i18n( "Mail to selected" ); |
570 | mText += "</a> ( "; | 577 | mText += "</a> ( "; |
571 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); | 578 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); |
572 | mText += "<br>\n"; | 579 | mText += "<br>\n"; |
573 | } | 580 | } |
574 | } | 581 | } |
575 | 582 | ||
576 | } | 583 | } |
577 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 584 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
578 | { | 585 | { |
579 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 586 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
580 | if (mode == 0 ) { | 587 | if (mode == 0 ) { |
581 | addTag("h2",i18n("Journal from: ")); | 588 | addTag("h2",i18n("Journal from: ")); |
582 | } | 589 | } |
583 | else { | 590 | else { |
584 | if ( mode == 1 ) { | 591 | if ( mode == 1 ) { |
585 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); | 592 | addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); |
586 | } else { | 593 | } else { |
587 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); | 594 | addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); |
588 | } | 595 | } |
589 | } | 596 | } |
590 | topLevelWidget()->setCaption("Journal Viewer"); | 597 | topLevelWidget()->setCaption("Journal Viewer"); |
591 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 598 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
592 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 599 | addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
593 | if (!jour->description().isEmpty()) { | 600 | if (!jour->description().isEmpty()) { |
594 | addTag("p",jour->description()); | 601 | addTag("p",jour->description()); |
595 | } | 602 | } |
596 | setText(mText); | 603 | setText(mText); |
597 | } | 604 | } |
598 | 605 | ||
599 | void KOEventViewer::formatReadOnly(Incidence *event) | 606 | void KOEventViewer::formatReadOnly(Incidence *event) |
600 | { | 607 | { |
601 | if (event->isReadOnly()) { | 608 | if (event->isReadOnly()) { |
602 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 609 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
603 | } | 610 | } |
604 | } | 611 | } |
605 | void KOEventViewer::setSyncMode( bool b ) | 612 | void KOEventViewer::setSyncMode( bool b ) |
606 | { | 613 | { |
607 | mSyncMode = b; | 614 | mSyncMode = b; |
608 | } | 615 | } |
609 | 616 | ||
610 | 617 | ||
611 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 618 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
612 | { | 619 | { |
613 | if ( clearV ) | 620 | if ( clearV ) |
614 | clearEvents(); | 621 | clearEvents(); |
615 | if ( mSyncMode ) { | 622 | if ( mSyncMode ) { |
616 | if ( clearV ) | 623 | if ( clearV ) |
617 | appendTodo(event,1 ); | 624 | appendTodo(event,1 ); |
618 | else | 625 | else |
619 | appendTodo(event,2); | 626 | appendTodo(event,2); |
620 | } else | 627 | } else |
621 | appendTodo(event); | 628 | appendTodo(event); |
622 | } | 629 | } |
623 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 630 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
624 | { | 631 | { |
625 | if ( clearV ) | 632 | if ( clearV ) |
626 | clearEvents(); | 633 | clearEvents(); |
627 | if ( mSyncMode ) { | 634 | if ( mSyncMode ) { |
628 | if ( clearV ) | 635 | if ( clearV ) |
629 | appendJournal(event, 1); | 636 | appendJournal(event, 1); |
630 | else | 637 | else |
631 | appendJournal(event, 2); | 638 | appendJournal(event, 2); |
632 | } else | 639 | } else |
633 | appendJournal(event); | 640 | appendJournal(event); |
634 | } | 641 | } |
635 | 642 | ||
636 | void KOEventViewer::setEvent(Event *event) | 643 | void KOEventViewer::setEvent(Event *event) |
637 | { | 644 | { |
638 | clearEvents(); | 645 | clearEvents(); |
639 | if ( mSyncMode ) | 646 | if ( mSyncMode ) |
640 | appendEvent(event, 1); | 647 | appendEvent(event, 1); |
641 | else | 648 | else |
642 | appendEvent(event); | 649 | appendEvent(event); |
643 | } | 650 | } |
644 | 651 | ||
645 | void KOEventViewer::addEvent(Event *event) | 652 | void KOEventViewer::addEvent(Event *event) |
646 | { | 653 | { |
647 | if ( mSyncMode ) | 654 | if ( mSyncMode ) |
648 | appendEvent(event, 2); | 655 | appendEvent(event, 2); |
649 | else | 656 | else |
650 | appendEvent(event); | 657 | appendEvent(event); |
651 | } | 658 | } |
652 | 659 | ||
653 | void KOEventViewer::clearEvents(bool now) | 660 | void KOEventViewer::clearEvents(bool now) |
654 | { | 661 | { |
655 | mText = ""; | 662 | mText = ""; |
656 | if (now) setText(mText); | 663 | if (now) setText(mText); |
657 | } | 664 | } |
658 | 665 | ||
659 | void KOEventViewer::addText(QString text) | 666 | void KOEventViewer::addText(QString text) |
660 | { | 667 | { |
661 | mText.append(text); | 668 | mText.append(text); |
662 | setText(mText); | 669 | setText(mText); |
663 | } | 670 | } |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index acd9265..d8e940b 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -1,1183 +1,1183 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1999 Preston Brown | 3 | Copyright (c) 1999 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 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 <qlistview.h> | 25 | #include <qlistview.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qpopupmenu.h> | 28 | #include <qpopupmenu.h> |
29 | #include <qprogressbar.h> | 29 | #include <qprogressbar.h> |
30 | #include <qfileinfo.h> | 30 | #include <qfileinfo.h> |
31 | #include <qmessagebox.h> | 31 | #include <qmessagebox.h> |
32 | #include <qdialog.h> | 32 | #include <qdialog.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qwhatsthis.h> | 35 | #include <qwhatsthis.h> |
36 | #include <qregexp.h> | 36 | #include <qregexp.h> |
37 | 37 | ||
38 | #include <klocale.h> | 38 | #include <klocale.h> |
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | #include <kglobal.h> | 41 | #include <kglobal.h> |
42 | 42 | ||
43 | #include <libkdepim/kpimglobalprefs.h> | 43 | #include <libkdepim/kpimglobalprefs.h> |
44 | #include <libkcal/calendar.h> | 44 | #include <libkcal/calendar.h> |
45 | #include <libkcal/calendarlocal.h> | 45 | #include <libkcal/calendarlocal.h> |
46 | #include <libkcal/icalformat.h> | 46 | #include <libkcal/icalformat.h> |
47 | #include <libkcal/vcalformat.h> | 47 | #include <libkcal/vcalformat.h> |
48 | #include <libkcal/recurrence.h> | 48 | #include <libkcal/recurrence.h> |
49 | #include <libkcal/filestorage.h> | 49 | #include <libkcal/filestorage.h> |
50 | #include <libkdepim/categoryselectdialog.h> | 50 | #include <libkdepim/categoryselectdialog.h> |
51 | #include <libkcal/kincidenceformatter.h> | 51 | #include <libkcal/kincidenceformatter.h> |
52 | #ifndef DESKTOP_VERSION | 52 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 53 | #include <qpe/qpeapplication.h> |
54 | #else | 54 | #else |
55 | #include <qapplication.h> | 55 | #include <qapplication.h> |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #ifndef KORG_NOPRINTER | 58 | #ifndef KORG_NOPRINTER |
59 | #include "calprinter.h" | 59 | #include "calprinter.h" |
60 | #endif | 60 | #endif |
61 | #include "koglobals.h" | 61 | #include "koglobals.h" |
62 | #include "koprefs.h" | 62 | #include "koprefs.h" |
63 | #include "kfiledialog.h" | 63 | #include "kfiledialog.h" |
64 | 64 | ||
65 | #include "kolistview.h" | 65 | #include "kolistview.h" |
66 | 66 | ||
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | class KOListViewWhatsThis :public QWhatsThis | 70 | class KOListViewWhatsThis :public QWhatsThis |
71 | { | 71 | { |
72 | public: | 72 | public: |
73 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; | 73 | KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; |
74 | 74 | ||
75 | protected: | 75 | protected: |
76 | virtual QString text( const QPoint& p) | 76 | virtual QString text( const QPoint& p) |
77 | { | 77 | { |
78 | return _view->getWhatsThisText(p) ; | 78 | return _view->getWhatsThisText(p) ; |
79 | } | 79 | } |
80 | private: | 80 | private: |
81 | QWidget* _wid; | 81 | QWidget* _wid; |
82 | KOListView * _view; | 82 | KOListView * _view; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | 85 | ||
86 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) | 86 | ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) |
87 | { | 87 | { |
88 | mItem = item; | 88 | mItem = item; |
89 | mDate = date; | 89 | mDate = date; |
90 | } | 90 | } |
91 | 91 | ||
92 | ListItemVisitor::~ListItemVisitor() | 92 | ListItemVisitor::~ListItemVisitor() |
93 | { | 93 | { |
94 | } | 94 | } |
95 | 95 | ||
96 | bool ListItemVisitor::visit(Event *e) | 96 | bool ListItemVisitor::visit(Event *e) |
97 | { | 97 | { |
98 | 98 | ||
99 | bool ok = false; | 99 | bool ok = false; |
100 | QString start, end; | 100 | QString start, end; |
101 | QDate ds, de; | 101 | QDate ds, de; |
102 | if ( e->doesRecur() ) { | 102 | if ( e->doesRecur() ) { |
103 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); | 103 | ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); |
104 | if ( ok ) { | 104 | if ( ok ) { |
105 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); | 105 | int days = e->dtStart().date().daysTo(e->dtEnd().date() ); |
106 | start = KGlobal::locale()->formatDate(ds,true); | 106 | start = KGlobal::locale()->formatDate(ds,true); |
107 | de = ds.addDays( days); | 107 | de = ds.addDays( days); |
108 | end = KGlobal::locale()->formatDate(de,true); | 108 | end = KGlobal::locale()->formatDate(de,true); |
109 | } | 109 | } |
110 | 110 | ||
111 | } | 111 | } |
112 | if ( ! ok ) { | 112 | if ( ! ok ) { |
113 | start =e->dtStartDateStr(); | 113 | start =e->dtStartDateStr(); |
114 | end = e->dtEndDateStr(); | 114 | end = e->dtEndDateStr(); |
115 | ds = e->dtStart().date(); | 115 | ds = e->dtStart().date(); |
116 | de = e->dtEnd().date(); | 116 | de = e->dtEnd().date(); |
117 | } | 117 | } |
118 | mItem->setText(0,e->summary()); | 118 | mItem->setText(0,e->summary()); |
119 | mItem->setText(1,start); | 119 | mItem->setText(1,start); |
120 | mItem->setText(2,e->dtStartTimeStr()); | 120 | mItem->setText(2,e->dtStartTimeStr()); |
121 | mItem->setText(3,end); | 121 | mItem->setText(3,end); |
122 | mItem->setText(4,e->dtEndTimeStr()); | 122 | mItem->setText(4,e->dtEndTimeStr()); |
123 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 123 | mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
124 | mItem->setText(6, e->recurrence()->recurrenceText()); | 124 | mItem->setText(6, e->recurrence()->recurrenceText()); |
125 | mItem->setText(7,"---"); | 125 | mItem->setText(7,"---"); |
126 | mItem->setText(8,"---"); | 126 | mItem->setText(8,"---"); |
127 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); | 127 | mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); |
128 | mItem->setText(10,e->categoriesStr()); | 128 | mItem->setText(10,e->categoriesStr()); |
129 | 129 | ||
130 | QString key; | 130 | QString key; |
131 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); | 131 | QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); |
132 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); | 132 | key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); |
133 | mItem->setSortKey(1,key); | 133 | mItem->setSortKey(1,key); |
134 | 134 | ||
135 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); | 135 | t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); |
136 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); | 136 | key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); |
137 | mItem->setSortKey(3,key); | 137 | mItem->setSortKey(3,key); |
138 | 138 | ||
139 | return true; | 139 | return true; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool ListItemVisitor::visit(Todo *t) | 142 | bool ListItemVisitor::visit(Todo *t) |
143 | { | 143 | { |
144 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); | 144 | mItem->setText(0,i18n("To-Do: %1").arg(t->summary())); |
145 | if (t->hasStartDate()) { | 145 | if (t->hasStartDate()) { |
146 | mItem->setText(1,t->dtStartDateStr()); | 146 | mItem->setText(1,t->dtStartDateStr()); |
147 | if (t->doesFloat()) { | 147 | if (t->doesFloat()) { |
148 | mItem->setText(2,"---"); | 148 | mItem->setText(2,"---"); |
149 | } else { | 149 | } else { |
150 | mItem->setText(2,t->dtStartTimeStr()); | 150 | mItem->setText(2,t->dtStartTimeStr()); |
151 | } | 151 | } |
152 | } else { | 152 | } else { |
153 | mItem->setText(1,"---"); | 153 | mItem->setText(1,"---"); |
154 | mItem->setText(2,"---"); | 154 | mItem->setText(2,"---"); |
155 | } | 155 | } |
156 | mItem->setText(3,"---"); | 156 | mItem->setText(3,"---"); |
157 | mItem->setText(4,"---"); | 157 | mItem->setText(4,"---"); |
158 | mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No")); | 158 | mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No")); |
159 | mItem->setText(6,"---"); | 159 | mItem->setText(6, t->recurrence()->recurrenceText()); |
160 | if (t->hasDueDate()) { | 160 | if (t->hasDueDate()) { |
161 | mItem->setText(7,t->dtDueDateStr()); | 161 | mItem->setText(7,t->dtDueDateStr()); |
162 | if (t->doesFloat()) { | 162 | if (t->doesFloat()) { |
163 | mItem->setText(8,"---"); | 163 | mItem->setText(8,"---"); |
164 | } else { | 164 | } else { |
165 | mItem->setText(8,t->dtDueTimeStr()); | 165 | mItem->setText(8,t->dtDueTimeStr()); |
166 | } | 166 | } |
167 | } else { | 167 | } else { |
168 | mItem->setText(7,"---"); | 168 | mItem->setText(7,"---"); |
169 | mItem->setText(8,"---"); | 169 | mItem->setText(8,"---"); |
170 | } | 170 | } |
171 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); | 171 | mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); |
172 | mItem->setText(10,t->categoriesStr()); | 172 | mItem->setText(10,t->categoriesStr()); |
173 | 173 | ||
174 | QString key; | 174 | QString key; |
175 | QDate d; | 175 | QDate d; |
176 | if (t->hasDueDate()) { | 176 | if (t->hasDueDate()) { |
177 | d = t->dtDue().date(); | 177 | d = t->dtDue().date(); |
178 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); | 178 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); |
179 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 179 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
180 | mItem->setSortKey(7,key); | 180 | mItem->setSortKey(7,key); |
181 | } | 181 | } |
182 | if ( t->hasStartDate() ) { | 182 | if ( t->hasStartDate() ) { |
183 | d = t->dtStart().date(); | 183 | d = t->dtStart().date(); |
184 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); | 184 | QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); |
185 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); | 185 | key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); |
186 | mItem->setSortKey(1,key); | 186 | mItem->setSortKey(1,key); |
187 | } | 187 | } |
188 | return true; | 188 | return true; |
189 | } | 189 | } |
190 | 190 | ||
191 | bool ListItemVisitor::visit(Journal * j) | 191 | bool ListItemVisitor::visit(Journal * j) |
192 | { | 192 | { |
193 | QString des = j->description().left(50); | 193 | QString des = j->description().left(50); |
194 | des = des.simplifyWhiteSpace (); | 194 | des = des.simplifyWhiteSpace (); |
195 | des.replace (QRegExp ("\\n"),"" ); | 195 | des.replace (QRegExp ("\\n"),"" ); |
196 | des.replace (QRegExp ("\\r"),"" ); | 196 | des.replace (QRegExp ("\\r"),"" ); |
197 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); | 197 | mItem->setText(0,i18n("Journal")+": "+des.left(25)); |
198 | mItem->setText(1,j->dtStartDateStr()); | 198 | mItem->setText(1,j->dtStartDateStr()); |
199 | mItem->setText(2,"---"); | 199 | mItem->setText(2,"---"); |
200 | mItem->setText(3,"---"); | 200 | mItem->setText(3,"---"); |
201 | mItem->setText(4,"---"); | 201 | mItem->setText(4,"---"); |
202 | mItem->setText(5,"---"); | 202 | mItem->setText(5,"---"); |
203 | mItem->setText(6,"---"); | 203 | mItem->setText(6,"---"); |
204 | mItem->setText(7,j->dtStartDateStr()); | 204 | mItem->setText(7,j->dtStartDateStr()); |
205 | mItem->setText(8,"---"); | 205 | mItem->setText(8,"---"); |
206 | mItem->setText(9,"---"); | 206 | mItem->setText(9,"---"); |
207 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); | 207 | mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); |
208 | 208 | ||
209 | QString key; | 209 | QString key; |
210 | QDate d = j->dtStart().date(); | 210 | QDate d = j->dtStart().date(); |
211 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 211 | key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
212 | mItem->setSortKey(1,key); | 212 | mItem->setSortKey(1,key); |
213 | mItem->setSortKey(7,key); | 213 | mItem->setSortKey(7,key); |
214 | 214 | ||
215 | return true; | 215 | return true; |
216 | } | 216 | } |
217 | 217 | ||
218 | KOListView::KOListView(Calendar *calendar, QWidget *parent, | 218 | KOListView::KOListView(Calendar *calendar, QWidget *parent, |
219 | const char *name) | 219 | const char *name) |
220 | : KOEventView(calendar, parent, name) | 220 | : KOEventView(calendar, parent, name) |
221 | { | 221 | { |
222 | mActiveItem = 0; | 222 | mActiveItem = 0; |
223 | mListView = new KOListViewListView(this); | 223 | mListView = new KOListViewListView(this); |
224 | mListView->addColumn(i18n("Summary")); | 224 | mListView->addColumn(i18n("Summary")); |
225 | mListView->addColumn(i18n("Start Date")); | 225 | mListView->addColumn(i18n("Start Date")); |
226 | mListView->addColumn(i18n("Start Time")); | 226 | mListView->addColumn(i18n("Start Time")); |
227 | mListView->addColumn(i18n("End Date")); | 227 | mListView->addColumn(i18n("End Date")); |
228 | mListView->addColumn(i18n("End Time")); | 228 | mListView->addColumn(i18n("End Time")); |
229 | mListView->addColumn(i18n("Alarm")); // alarm set? | 229 | mListView->addColumn(i18n("Alarm")); // alarm set? |
230 | mListView->addColumn(i18n("Recurs")); // recurs? | 230 | mListView->addColumn(i18n("Recurs")); // recurs? |
231 | mListView->addColumn(i18n("Due Date")); | 231 | mListView->addColumn(i18n("Due Date")); |
232 | mListView->addColumn(i18n("Due Time")); | 232 | mListView->addColumn(i18n("Due Time")); |
233 | mListView->addColumn(i18n("Cancelled")); | 233 | mListView->addColumn(i18n("Cancelled")); |
234 | mListView->addColumn(i18n("Categories")); | 234 | mListView->addColumn(i18n("Categories")); |
235 | 235 | ||
236 | mListView->setColumnAlignment(0,AlignLeft); | 236 | mListView->setColumnAlignment(0,AlignLeft); |
237 | mListView->setColumnAlignment(1,AlignLeft); | 237 | mListView->setColumnAlignment(1,AlignLeft); |
238 | mListView->setColumnAlignment(2,AlignHCenter); | 238 | mListView->setColumnAlignment(2,AlignHCenter); |
239 | mListView->setColumnAlignment(3,AlignLeft); | 239 | mListView->setColumnAlignment(3,AlignLeft); |
240 | mListView->setColumnAlignment(4,AlignHCenter); | 240 | mListView->setColumnAlignment(4,AlignHCenter); |
241 | mListView->setColumnAlignment(5,AlignLeft); | 241 | mListView->setColumnAlignment(5,AlignLeft); |
242 | mListView->setColumnAlignment(6,AlignLeft); | 242 | mListView->setColumnAlignment(6,AlignLeft); |
243 | mListView->setColumnAlignment(7,AlignLeft); | 243 | mListView->setColumnAlignment(7,AlignLeft); |
244 | mListView->setColumnAlignment(8,AlignLeft); | 244 | mListView->setColumnAlignment(8,AlignLeft); |
245 | mListView->setColumnAlignment(9,AlignLeft); | 245 | mListView->setColumnAlignment(9,AlignLeft); |
246 | mListView->setColumnAlignment(10,AlignLeft); | 246 | mListView->setColumnAlignment(10,AlignLeft); |
247 | mListView->setColumnWidthMode(10, QListView::Manual); | 247 | mListView->setColumnWidthMode(10, QListView::Manual); |
248 | new KOListViewWhatsThis(mListView->viewport(),this); | 248 | new KOListViewWhatsThis(mListView->viewport(),this); |
249 | 249 | ||
250 | int iii = 0; | 250 | int iii = 0; |
251 | for ( iii = 0; iii< 10 ; ++iii ) | 251 | for ( iii = 0; iii< 10 ; ++iii ) |
252 | mListView->setColumnWidthMode( iii, QListView::Manual ); | 252 | mListView->setColumnWidthMode( iii, QListView::Manual ); |
253 | 253 | ||
254 | QBoxLayout *layoutTop = new QVBoxLayout(this); | 254 | QBoxLayout *layoutTop = new QVBoxLayout(this); |
255 | layoutTop->addWidget(mListView); | 255 | layoutTop->addWidget(mListView); |
256 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 256 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
257 | mPopupMenu = eventPopup(); | 257 | mPopupMenu = eventPopup(); |
258 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 258 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
259 | i18n("Select all"),this, | 259 | i18n("Select all"),this, |
260 | SLOT(allSelection()),true); | 260 | SLOT(allSelection()),true); |
261 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 261 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
262 | i18n("Deselect all"),this, | 262 | i18n("Deselect all"),this, |
263 | SLOT(clearSelection()),true); | 263 | SLOT(clearSelection()),true); |
264 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 264 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
265 | i18n("Delete all selected"),this, | 265 | i18n("Delete all selected"),this, |
266 | SLOT(deleteAll()),true); | 266 | SLOT(deleteAll()),true); |
267 | mPopupMenu->insertSeparator(); | 267 | mPopupMenu->insertSeparator(); |
268 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 268 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
269 | i18n("Save selected to file..."),this, | 269 | i18n("Save selected to file..."),this, |
270 | SLOT(saveToFile()),true); | 270 | SLOT(saveToFile()),true); |
271 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 271 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
272 | i18n("Save Journal/Description..."),this, | 272 | i18n("Save Journal/Description..."),this, |
273 | SLOT(saveDescriptionToFile()),true); | 273 | SLOT(saveDescriptionToFile()),true); |
274 | // mPopupMenu->insertSeparator(); | 274 | // mPopupMenu->insertSeparator(); |
275 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 275 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
276 | i18n("Add Categ. to selected..."),this, | 276 | i18n("Add Categ. to selected..."),this, |
277 | SLOT(addCat()),true); | 277 | SLOT(addCat()),true); |
278 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 278 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
279 | i18n("Set Categ. for selected..."),this, | 279 | i18n("Set Categ. for selected..."),this, |
280 | SLOT(setCat()),true); | 280 | SLOT(setCat()),true); |
281 | //mPopupMenu->insertSeparator(); | 281 | //mPopupMenu->insertSeparator(); |
282 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 282 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
283 | i18n("Set alarm for selected..."),this, | 283 | i18n("Set alarm for selected..."),this, |
284 | SLOT(setAlarm()),true); | 284 | SLOT(setAlarm()),true); |
285 | 285 | ||
286 | 286 | ||
287 | #ifndef DESKTOP_VERSION | 287 | #ifndef DESKTOP_VERSION |
288 | mPopupMenu->insertSeparator(); | 288 | mPopupMenu->insertSeparator(); |
289 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), | 289 | mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), |
290 | i18n("Beam selected via IR"),this, | 290 | i18n("Beam selected via IR"),this, |
291 | SLOT(beamSelected()),true); | 291 | SLOT(beamSelected()),true); |
292 | #endif | 292 | #endif |
293 | /* | 293 | /* |
294 | mPopupMenu = new QPopupMenu; | 294 | mPopupMenu = new QPopupMenu; |
295 | mPopupMenu->insertItem(i18n("Edit Event"), this, | 295 | mPopupMenu->insertItem(i18n("Edit Event"), this, |
296 | SLOT (editEvent())); | 296 | SLOT (editEvent())); |
297 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, | 297 | mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, |
298 | SLOT (deleteEvent())); | 298 | SLOT (deleteEvent())); |
299 | mPopupMenu->insertSeparator(); | 299 | mPopupMenu->insertSeparator(); |
300 | mPopupMenu->insertItem(i18n("Show Dates"), this, | 300 | mPopupMenu->insertItem(i18n("Show Dates"), this, |
301 | SLOT(showDates())); | 301 | SLOT(showDates())); |
302 | mPopupMenu->insertItem(i18n("Hide Dates"), this, | 302 | mPopupMenu->insertItem(i18n("Hide Dates"), this, |
303 | SLOT(hideDates())); | 303 | SLOT(hideDates())); |
304 | */ | 304 | */ |
305 | QObject::connect(mListView,SIGNAL( newEvent()), | 305 | QObject::connect(mListView,SIGNAL( newEvent()), |
306 | this,SIGNAL(signalNewEvent())); | 306 | this,SIGNAL(signalNewEvent())); |
307 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), | 307 | QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), |
308 | this,SLOT(defaultItemAction(QListViewItem *))); | 308 | this,SLOT(defaultItemAction(QListViewItem *))); |
309 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, | 309 | QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, |
310 | const QPoint &, int )), | 310 | const QPoint &, int )), |
311 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); | 311 | this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); |
312 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), | 312 | QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), |
313 | SLOT(processSelectionChange(QListViewItem *))); | 313 | SLOT(processSelectionChange(QListViewItem *))); |
314 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), | 314 | QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), |
315 | SIGNAL(showIncidenceSignal(Incidence *)) ); | 315 | SIGNAL(showIncidenceSignal(Incidence *)) ); |
316 | 316 | ||
317 | readSettings(KOGlobals::config(),"KOListView Layout"); | 317 | readSettings(KOGlobals::config(),"KOListView Layout"); |
318 | } | 318 | } |
319 | 319 | ||
320 | KOListView::~KOListView() | 320 | KOListView::~KOListView() |
321 | { | 321 | { |
322 | delete mPopupMenu; | 322 | delete mPopupMenu; |
323 | } | 323 | } |
324 | QString KOListView::getWhatsThisText(QPoint p) | 324 | QString KOListView::getWhatsThisText(QPoint p) |
325 | { | 325 | { |
326 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 326 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
327 | if ( item ) | 327 | if ( item ) |
328 | return KIncidenceFormatter::instance()->getFormattedText( item->data() ); | 328 | return KIncidenceFormatter::instance()->getFormattedText( item->data() ); |
329 | return i18n("That is the list view" ); | 329 | return i18n("That is the list view" ); |
330 | 330 | ||
331 | } | 331 | } |
332 | 332 | ||
333 | void KOListView::updateList() | 333 | void KOListView::updateList() |
334 | { | 334 | { |
335 | // qDebug(" KOListView::updateList() "); | 335 | // qDebug(" KOListView::updateList() "); |
336 | 336 | ||
337 | } | 337 | } |
338 | 338 | ||
339 | void KOListView::addCat( ) | 339 | void KOListView::addCat( ) |
340 | { | 340 | { |
341 | setCategories( false ); | 341 | setCategories( false ); |
342 | } | 342 | } |
343 | void KOListView::setCat() | 343 | void KOListView::setCat() |
344 | { | 344 | { |
345 | setCategories( true ); | 345 | setCategories( true ); |
346 | } | 346 | } |
347 | void KOListView::setAlarm() | 347 | void KOListView::setAlarm() |
348 | { | 348 | { |
349 | KOAlarmPrefs kap( this); | 349 | KOAlarmPrefs kap( this); |
350 | if ( !kap.exec() ) | 350 | if ( !kap.exec() ) |
351 | return; | 351 | return; |
352 | 352 | ||
353 | 353 | ||
354 | QStringList itemList; | 354 | QStringList itemList; |
355 | QPtrList<KOListViewItem> sel ; | 355 | QPtrList<KOListViewItem> sel ; |
356 | QListViewItem *qitem = mListView->firstChild (); | 356 | QListViewItem *qitem = mListView->firstChild (); |
357 | while ( qitem ) { | 357 | while ( qitem ) { |
358 | if ( qitem->isSelected() ) { | 358 | if ( qitem->isSelected() ) { |
359 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 359 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
360 | if ( inc->type() != "Journal" ) { | 360 | if ( inc->type() != "Journal" ) { |
361 | if ( inc->type() == "Todo" ) { | 361 | if ( inc->type() == "Todo" ) { |
362 | if ( ((Todo*)inc)->hasDueDate() ) | 362 | if ( ((Todo*)inc)->hasDueDate() ) |
363 | sel.append(((KOListViewItem *)qitem)); | 363 | sel.append(((KOListViewItem *)qitem)); |
364 | } else | 364 | } else |
365 | sel.append(((KOListViewItem *)qitem)); | 365 | sel.append(((KOListViewItem *)qitem)); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | qitem = qitem->nextSibling(); | 368 | qitem = qitem->nextSibling(); |
369 | } | 369 | } |
370 | int count = 0; | 370 | int count = 0; |
371 | KOListViewItem * item, *temp; | 371 | KOListViewItem * item, *temp; |
372 | item = sel.first(); | 372 | item = sel.first(); |
373 | Incidence* inc; | 373 | Incidence* inc; |
374 | while ( item ) { | 374 | while ( item ) { |
375 | inc = item->data(); | 375 | inc = item->data(); |
376 | ++count; | 376 | ++count; |
377 | if (kap.mAlarmButton->isChecked()) { | 377 | if (kap.mAlarmButton->isChecked()) { |
378 | if (inc->alarms().count() == 0) | 378 | if (inc->alarms().count() == 0) |
379 | inc->newAlarm(); | 379 | inc->newAlarm(); |
380 | QPtrList<Alarm> alarms = inc->alarms(); | 380 | QPtrList<Alarm> alarms = inc->alarms(); |
381 | Alarm *alarm; | 381 | Alarm *alarm; |
382 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 382 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
383 | alarm->setEnabled(true); | 383 | alarm->setEnabled(true); |
384 | int j = kap.mAlarmTimeEdit->value()* -60; | 384 | int j = kap.mAlarmTimeEdit->value()* -60; |
385 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 385 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
386 | j = j * 60; | 386 | j = j * 60; |
387 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 387 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
388 | j = j * (60 * 24); | 388 | j = j * (60 * 24); |
389 | alarm->setStartOffset( j ); | 389 | alarm->setStartOffset( j ); |
390 | 390 | ||
391 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 391 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
392 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 392 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
393 | } | 393 | } |
394 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 394 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
395 | alarm->setAudioAlarm(kap.mAlarmSound); | 395 | alarm->setAudioAlarm(kap.mAlarmSound); |
396 | else | 396 | else |
397 | alarm->setType(Alarm::Invalid); | 397 | alarm->setType(Alarm::Invalid); |
398 | //alarm->setAudioAlarm("default"); | 398 | //alarm->setAudioAlarm("default"); |
399 | // TODO: Deal with multiple alarms | 399 | // TODO: Deal with multiple alarms |
400 | break; // For now, stop after the first alarm | 400 | break; // For now, stop after the first alarm |
401 | } | 401 | } |
402 | } else { | 402 | } else { |
403 | Alarm* alarm = inc->alarms().first(); | 403 | Alarm* alarm = inc->alarms().first(); |
404 | if ( alarm ) { | 404 | if ( alarm ) { |
405 | alarm->setEnabled(false); | 405 | alarm->setEnabled(false); |
406 | alarm->setType(Alarm::Invalid); | 406 | alarm->setType(Alarm::Invalid); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | temp = item; | 409 | temp = item; |
410 | item = sel.next(); | 410 | item = sel.next(); |
411 | mUidDict.remove( inc->uid() ); | 411 | mUidDict.remove( inc->uid() ); |
412 | delete temp;; | 412 | delete temp;; |
413 | addIncidence( inc ); | 413 | addIncidence( inc ); |
414 | } | 414 | } |
415 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); | 415 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); |
416 | qDebug("KO: Set alarm for %d items", count); | 416 | qDebug("KO: Set alarm for %d items", count); |
417 | calendar()->reInitAlarmSettings(); | 417 | calendar()->reInitAlarmSettings(); |
418 | } | 418 | } |
419 | void KOListView::setCategories( bool removeOld ) | 419 | void KOListView::setCategories( bool removeOld ) |
420 | { | 420 | { |
421 | 421 | ||
422 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 422 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
423 | if (! csd->exec()) { | 423 | if (! csd->exec()) { |
424 | delete csd; | 424 | delete csd; |
425 | return; | 425 | return; |
426 | } | 426 | } |
427 | QStringList catList = csd->selectedCategories(); | 427 | QStringList catList = csd->selectedCategories(); |
428 | delete csd; | 428 | delete csd; |
429 | // if ( catList.count() == 0 ) | 429 | // if ( catList.count() == 0 ) |
430 | // return; | 430 | // return; |
431 | catList.sort(); | 431 | catList.sort(); |
432 | QString categoriesStr = catList.join(","); | 432 | QString categoriesStr = catList.join(","); |
433 | int i; | 433 | int i; |
434 | QStringList itemList; | 434 | QStringList itemList; |
435 | QPtrList<KOListViewItem> sel ; | 435 | QPtrList<KOListViewItem> sel ; |
436 | QListViewItem *qitem = mListView->firstChild (); | 436 | QListViewItem *qitem = mListView->firstChild (); |
437 | while ( qitem ) { | 437 | while ( qitem ) { |
438 | if ( qitem->isSelected() ) { | 438 | if ( qitem->isSelected() ) { |
439 | sel.append(((KOListViewItem *)qitem)); | 439 | sel.append(((KOListViewItem *)qitem)); |
440 | } | 440 | } |
441 | qitem = qitem->nextSibling(); | 441 | qitem = qitem->nextSibling(); |
442 | } | 442 | } |
443 | KOListViewItem * item, *temp; | 443 | KOListViewItem * item, *temp; |
444 | item = sel.first(); | 444 | item = sel.first(); |
445 | Incidence* inc; | 445 | Incidence* inc; |
446 | while ( item ) { | 446 | while ( item ) { |
447 | inc = item->data(); | 447 | inc = item->data(); |
448 | if ( removeOld ) { | 448 | if ( removeOld ) { |
449 | inc->setCategories( categoriesStr ); | 449 | inc->setCategories( categoriesStr ); |
450 | } else { | 450 | } else { |
451 | itemList = QStringList::split (",", inc->categoriesStr() ); | 451 | itemList = QStringList::split (",", inc->categoriesStr() ); |
452 | for( i = 0; i< catList.count(); ++i ) { | 452 | for( i = 0; i< catList.count(); ++i ) { |
453 | if ( !itemList.contains (catList[i])) | 453 | if ( !itemList.contains (catList[i])) |
454 | itemList.append( catList[i] ); | 454 | itemList.append( catList[i] ); |
455 | } | 455 | } |
456 | itemList.sort(); | 456 | itemList.sort(); |
457 | inc->setCategories( itemList.join(",") ); | 457 | inc->setCategories( itemList.join(",") ); |
458 | } | 458 | } |
459 | temp = item; | 459 | temp = item; |
460 | item = sel.next(); | 460 | item = sel.next(); |
461 | mUidDict.remove( inc->uid() ); | 461 | mUidDict.remove( inc->uid() ); |
462 | delete temp;; | 462 | delete temp;; |
463 | addIncidence( inc ); | 463 | addIncidence( inc ); |
464 | } | 464 | } |
465 | } | 465 | } |
466 | 466 | ||
467 | void KOListView::beamSelected() | 467 | void KOListView::beamSelected() |
468 | { | 468 | { |
469 | int icount = 0; | 469 | int icount = 0; |
470 | QPtrList<Incidence> delSel ; | 470 | QPtrList<Incidence> delSel ; |
471 | QListViewItem *item = mListView->firstChild (); | 471 | QListViewItem *item = mListView->firstChild (); |
472 | while ( item ) { | 472 | while ( item ) { |
473 | if ( item->isSelected() ) { | 473 | if ( item->isSelected() ) { |
474 | delSel.append(((KOListViewItem *)item)->data()); | 474 | delSel.append(((KOListViewItem *)item)->data()); |
475 | ++icount; | 475 | ++icount; |
476 | } | 476 | } |
477 | 477 | ||
478 | item = item->nextSibling(); | 478 | item = item->nextSibling(); |
479 | } | 479 | } |
480 | if ( icount ) { | 480 | if ( icount ) { |
481 | emit beamIncidenceList( delSel ); | 481 | emit beamIncidenceList( delSel ); |
482 | return; | 482 | return; |
483 | QString fn ; | 483 | QString fn ; |
484 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 484 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
485 | QString mes; | 485 | QString mes; |
486 | bool createbup = true; | 486 | bool createbup = true; |
487 | if ( createbup ) { | 487 | if ( createbup ) { |
488 | QString description = "\n"; | 488 | QString description = "\n"; |
489 | CalendarLocal* cal = new CalendarLocal(); | 489 | CalendarLocal* cal = new CalendarLocal(); |
490 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 490 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
491 | Incidence *incidence = delSel.first(); | 491 | Incidence *incidence = delSel.first(); |
492 | while ( incidence ) { | 492 | while ( incidence ) { |
493 | Incidence *in = incidence->clone(); | 493 | Incidence *in = incidence->clone(); |
494 | description += in->summary() + "\n"; | 494 | description += in->summary() + "\n"; |
495 | cal->addIncidence( in ); | 495 | cal->addIncidence( in ); |
496 | incidence = delSel.next(); | 496 | incidence = delSel.next(); |
497 | } | 497 | } |
498 | FileStorage storage( cal, fn, new VCalFormat ); | 498 | FileStorage storage( cal, fn, new VCalFormat ); |
499 | storage.save(); | 499 | storage.save(); |
500 | delete cal; | 500 | delete cal; |
501 | mes = i18n("KO/Pi: Ready for beaming"); | 501 | mes = i18n("KO/Pi: Ready for beaming"); |
502 | topLevelWidget()->setCaption(mes); | 502 | topLevelWidget()->setCaption(mes); |
503 | 503 | ||
504 | #ifndef DESKTOP_VERSION | 504 | #ifndef DESKTOP_VERSION |
505 | Ir *ir = new Ir( this ); | 505 | Ir *ir = new Ir( this ); |
506 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 506 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
507 | ir->send( fn, description, "text/x-vCalendar" ); | 507 | ir->send( fn, description, "text/x-vCalendar" ); |
508 | #endif | 508 | #endif |
509 | } | 509 | } |
510 | } | 510 | } |
511 | } | 511 | } |
512 | void KOListView::beamDone( Ir *ir ) | 512 | void KOListView::beamDone( Ir *ir ) |
513 | { | 513 | { |
514 | #ifndef DESKTOP_VERSION | 514 | #ifndef DESKTOP_VERSION |
515 | delete ir; | 515 | delete ir; |
516 | #endif | 516 | #endif |
517 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); | 517 | topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); |
518 | } | 518 | } |
519 | 519 | ||
520 | void KOListView::saveDescriptionToFile() | 520 | void KOListView::saveDescriptionToFile() |
521 | { | 521 | { |
522 | 522 | ||
523 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 523 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
524 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 524 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
525 | i18n("Continue"), i18n("Cancel"), 0, | 525 | i18n("Continue"), i18n("Cancel"), 0, |
526 | 0, 1 ); | 526 | 0, 1 ); |
527 | if ( result != 0 ) { | 527 | if ( result != 0 ) { |
528 | return; | 528 | return; |
529 | } | 529 | } |
530 | int icount = 0; | 530 | int icount = 0; |
531 | QPtrList<Incidence> delSel ; | 531 | QPtrList<Incidence> delSel ; |
532 | QListViewItem *item = mListView->firstChild (); | 532 | QListViewItem *item = mListView->firstChild (); |
533 | while ( item ) { | 533 | while ( item ) { |
534 | if ( item->isSelected() ) { | 534 | if ( item->isSelected() ) { |
535 | delSel.append(((KOListViewItem *)item)->data()); | 535 | delSel.append(((KOListViewItem *)item)->data()); |
536 | ++icount; | 536 | ++icount; |
537 | } | 537 | } |
538 | 538 | ||
539 | item = item->nextSibling(); | 539 | item = item->nextSibling(); |
540 | } | 540 | } |
541 | if ( icount ) { | 541 | if ( icount ) { |
542 | QString fn = KOPrefs::instance()->mLastSaveFile; | 542 | QString fn = KOPrefs::instance()->mLastSaveFile; |
543 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 543 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
544 | 544 | ||
545 | if ( fn == "" ) | 545 | if ( fn == "" ) |
546 | return; | 546 | return; |
547 | QFileInfo info; | 547 | QFileInfo info; |
548 | info.setFile( fn ); | 548 | info.setFile( fn ); |
549 | QString mes; | 549 | QString mes; |
550 | bool createbup = true; | 550 | bool createbup = true; |
551 | if ( info. exists() ) { | 551 | if ( info. exists() ) { |
552 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 552 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
553 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 553 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
554 | i18n("Overwrite!"), i18n("Cancel"), 0, | 554 | i18n("Overwrite!"), i18n("Cancel"), 0, |
555 | 0, 1 ); | 555 | 0, 1 ); |
556 | if ( result != 0 ) { | 556 | if ( result != 0 ) { |
557 | createbup = false; | 557 | createbup = false; |
558 | } | 558 | } |
559 | } | 559 | } |
560 | if ( createbup ) { | 560 | if ( createbup ) { |
561 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 561 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
562 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 562 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
563 | Incidence *incidence = delSel.first(); | 563 | Incidence *incidence = delSel.first(); |
564 | icount = 0; | 564 | icount = 0; |
565 | while ( incidence ) { | 565 | while ( incidence ) { |
566 | if ( incidence->type() == "Journal" ) { | 566 | if ( incidence->type() == "Journal" ) { |
567 | text += "\n************************************\n"; | 567 | text += "\n************************************\n"; |
568 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 568 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
569 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 569 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
570 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 570 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
571 | ++icount; | 571 | ++icount; |
572 | 572 | ||
573 | } else { | 573 | } else { |
574 | if ( !incidence->description().isEmpty() ) { | 574 | if ( !incidence->description().isEmpty() ) { |
575 | text += "\n************************************\n"; | 575 | text += "\n************************************\n"; |
576 | if ( incidence->type() == "Todo" ) | 576 | if ( incidence->type() == "Todo" ) |
577 | text += i18n("To-Do: "); | 577 | text += i18n("To-Do: "); |
578 | text += incidence->summary(); | 578 | text += incidence->summary(); |
579 | if ( incidence->hasStartDate() ) | 579 | if ( incidence->hasStartDate() ) |
580 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 580 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
581 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 581 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
582 | if ( !incidence->location().isEmpty() ) | 582 | if ( !incidence->location().isEmpty() ) |
583 | text += "\n" +i18n("Location: ") + incidence->location(); | 583 | text += "\n" +i18n("Location: ") + incidence->location(); |
584 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 584 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
585 | ++icount; | 585 | ++icount; |
586 | 586 | ||
587 | } | 587 | } |
588 | } | 588 | } |
589 | incidence = delSel.next(); | 589 | incidence = delSel.next(); |
590 | } | 590 | } |
591 | QFile file( fn ); | 591 | QFile file( fn ); |
592 | if (!file.open( IO_WriteOnly ) ) { | 592 | if (!file.open( IO_WriteOnly ) ) { |
593 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 593 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
594 | return; | 594 | return; |
595 | } | 595 | } |
596 | QTextStream ts( &file ); | 596 | QTextStream ts( &file ); |
597 | ts << text; | 597 | ts << text; |
598 | file.close(); | 598 | file.close(); |
599 | //qDebug("%s ", text.latin1()); | 599 | //qDebug("%s ", text.latin1()); |
600 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 600 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
601 | KOPrefs::instance()->mLastSaveFile = fn; | 601 | KOPrefs::instance()->mLastSaveFile = fn; |
602 | topLevelWidget()->setCaption(mes); | 602 | topLevelWidget()->setCaption(mes); |
603 | } | 603 | } |
604 | } | 604 | } |
605 | } | 605 | } |
606 | void KOListView::saveToFile() | 606 | void KOListView::saveToFile() |
607 | { | 607 | { |
608 | 608 | ||
609 | int icount = 0; | 609 | int icount = 0; |
610 | QPtrList<Incidence> delSel ; | 610 | QPtrList<Incidence> delSel ; |
611 | QListViewItem *item = mListView->firstChild (); | 611 | QListViewItem *item = mListView->firstChild (); |
612 | while ( item ) { | 612 | while ( item ) { |
613 | if ( item->isSelected() ) { | 613 | if ( item->isSelected() ) { |
614 | delSel.append(((KOListViewItem *)item)->data()); | 614 | delSel.append(((KOListViewItem *)item)->data()); |
615 | ++icount; | 615 | ++icount; |
616 | } | 616 | } |
617 | 617 | ||
618 | item = item->nextSibling(); | 618 | item = item->nextSibling(); |
619 | } | 619 | } |
620 | if ( icount ) { | 620 | if ( icount ) { |
621 | QString fn = KOPrefs::instance()->mLastSaveFile; | 621 | QString fn = KOPrefs::instance()->mLastSaveFile; |
622 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 622 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
623 | 623 | ||
624 | if ( fn == "" ) | 624 | if ( fn == "" ) |
625 | return; | 625 | return; |
626 | QFileInfo info; | 626 | QFileInfo info; |
627 | info.setFile( fn ); | 627 | info.setFile( fn ); |
628 | QString mes; | 628 | QString mes; |
629 | bool createbup = true; | 629 | bool createbup = true; |
630 | if ( info. exists() ) { | 630 | if ( info. exists() ) { |
631 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 631 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
632 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 632 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
633 | i18n("Overwrite!"), i18n("Cancel"), 0, | 633 | i18n("Overwrite!"), i18n("Cancel"), 0, |
634 | 0, 1 ); | 634 | 0, 1 ); |
635 | if ( result != 0 ) { | 635 | if ( result != 0 ) { |
636 | createbup = false; | 636 | createbup = false; |
637 | } | 637 | } |
638 | } | 638 | } |
639 | if ( createbup ) { | 639 | if ( createbup ) { |
640 | CalendarLocal cal; | 640 | CalendarLocal cal; |
641 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 641 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
642 | Incidence *incidence = delSel.first(); | 642 | Incidence *incidence = delSel.first(); |
643 | while ( incidence ) { | 643 | while ( incidence ) { |
644 | cal.addIncidence( incidence->clone() ); | 644 | cal.addIncidence( incidence->clone() ); |
645 | incidence = delSel.next(); | 645 | incidence = delSel.next(); |
646 | } | 646 | } |
647 | ICalFormat format; | 647 | ICalFormat format; |
648 | format.save( &cal, fn ); | 648 | format.save( &cal, fn ); |
649 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 649 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
650 | KOPrefs::instance()->mLastSaveFile = fn; | 650 | KOPrefs::instance()->mLastSaveFile = fn; |
651 | topLevelWidget()->setCaption(mes); | 651 | topLevelWidget()->setCaption(mes); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | } | 654 | } |
655 | void KOListView::deleteAll() | 655 | void KOListView::deleteAll() |
656 | { | 656 | { |
657 | int icount = 0; | 657 | int icount = 0; |
658 | QPtrList<Incidence> delSel ; | 658 | QPtrList<Incidence> delSel ; |
659 | QListViewItem *item = mListView->firstChild (); | 659 | QListViewItem *item = mListView->firstChild (); |
660 | while ( item ) { | 660 | while ( item ) { |
661 | if ( item->isSelected() ) { | 661 | if ( item->isSelected() ) { |
662 | delSel.append(((KOListViewItem *)item)->data()); | 662 | delSel.append(((KOListViewItem *)item)->data()); |
663 | ++icount; | 663 | ++icount; |
664 | } | 664 | } |
665 | 665 | ||
666 | item = item->nextSibling(); | 666 | item = item->nextSibling(); |
667 | } | 667 | } |
668 | if ( icount ) { | 668 | if ( icount ) { |
669 | Incidence *incidence = delSel.first(); | 669 | Incidence *incidence = delSel.first(); |
670 | Incidence *toDelete; | 670 | Incidence *toDelete; |
671 | KOPrefs *p = KOPrefs::instance(); | 671 | KOPrefs *p = KOPrefs::instance(); |
672 | bool confirm = p->mConfirm; | 672 | bool confirm = p->mConfirm; |
673 | QString mess; | 673 | QString mess; |
674 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); | 674 | mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); |
675 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { | 675 | if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { |
676 | p->mConfirm = false; | 676 | p->mConfirm = false; |
677 | int delCounter = 0; | 677 | int delCounter = 0; |
678 | QDialog dia ( this, "p-dialog", true ); | 678 | QDialog dia ( this, "p-dialog", true ); |
679 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); | 679 | QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); |
680 | QVBoxLayout lay( &dia ); | 680 | QVBoxLayout lay( &dia ); |
681 | lay.setMargin(7); | 681 | lay.setMargin(7); |
682 | lay.setSpacing(7); | 682 | lay.setSpacing(7); |
683 | lay.addWidget( &lab); | 683 | lay.addWidget( &lab); |
684 | QProgressBar bar( icount, &dia ); | 684 | QProgressBar bar( icount, &dia ); |
685 | lay.addWidget( &bar); | 685 | lay.addWidget( &bar); |
686 | int w = 220; | 686 | int w = 220; |
687 | int h = 50; | 687 | int h = 50; |
688 | int dw = QApplication::desktop()->width(); | 688 | int dw = QApplication::desktop()->width(); |
689 | int dh = QApplication::desktop()->height(); | 689 | int dh = QApplication::desktop()->height(); |
690 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 690 | dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
691 | //dia.resize( 240,50 ); | 691 | //dia.resize( 240,50 ); |
692 | dia.show(); | 692 | dia.show(); |
693 | 693 | ||
694 | while ( incidence ) { | 694 | while ( incidence ) { |
695 | bar.setProgress( delCounter ); | 695 | bar.setProgress( delCounter ); |
696 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); | 696 | mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); |
697 | dia.setCaption( mess ); | 697 | dia.setCaption( mess ); |
698 | qApp->processEvents(); | 698 | qApp->processEvents(); |
699 | toDelete = (incidence); | 699 | toDelete = (incidence); |
700 | incidence = delSel.next(); | 700 | incidence = delSel.next(); |
701 | emit deleteIncidenceSignal(toDelete ); | 701 | emit deleteIncidenceSignal(toDelete ); |
702 | if ( dia.result() != 0 ) | 702 | if ( dia.result() != 0 ) |
703 | break; | 703 | break; |
704 | 704 | ||
705 | } | 705 | } |
706 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); | 706 | mess = mess.sprintf( i18n("%d items remaining in list."), count() ); |
707 | topLevelWidget ()->setCaption( mess ); | 707 | topLevelWidget ()->setCaption( mess ); |
708 | p->mConfirm = confirm; | 708 | p->mConfirm = confirm; |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | } | 713 | } |
714 | int KOListView::maxDatesHint() | 714 | int KOListView::maxDatesHint() |
715 | { | 715 | { |
716 | return 0; | 716 | return 0; |
717 | } | 717 | } |
718 | 718 | ||
719 | int KOListView::currentDateCount() | 719 | int KOListView::currentDateCount() |
720 | { | 720 | { |
721 | return 0; | 721 | return 0; |
722 | } | 722 | } |
723 | 723 | ||
724 | QPtrList<Incidence> KOListView::selectedIncidences() | 724 | QPtrList<Incidence> KOListView::selectedIncidences() |
725 | { | 725 | { |
726 | QPtrList<Incidence> eventList; | 726 | QPtrList<Incidence> eventList; |
727 | QListViewItem *item = mListView->firstChild (); | 727 | QListViewItem *item = mListView->firstChild (); |
728 | while ( item ) { | 728 | while ( item ) { |
729 | if ( item->isSelected() ) { | 729 | if ( item->isSelected() ) { |
730 | eventList.append(((KOListViewItem *)item)->data()); | 730 | eventList.append(((KOListViewItem *)item)->data()); |
731 | } | 731 | } |
732 | 732 | ||
733 | item = item->nextSibling(); | 733 | item = item->nextSibling(); |
734 | } | 734 | } |
735 | 735 | ||
736 | // // QListViewItem *item = mListView->selectedItem(); | 736 | // // QListViewItem *item = mListView->selectedItem(); |
737 | //if (item) eventList.append(((KOListViewItem *)item)->data()); | 737 | //if (item) eventList.append(((KOListViewItem *)item)->data()); |
738 | 738 | ||
739 | return eventList; | 739 | return eventList; |
740 | } | 740 | } |
741 | 741 | ||
742 | DateList KOListView::selectedDates() | 742 | DateList KOListView::selectedDates() |
743 | { | 743 | { |
744 | DateList eventList; | 744 | DateList eventList; |
745 | return eventList; | 745 | return eventList; |
746 | } | 746 | } |
747 | 747 | ||
748 | void KOListView::showDates(bool show) | 748 | void KOListView::showDates(bool show) |
749 | { | 749 | { |
750 | // Shouldn't we set it to a value greater 0? When showDates is called with | 750 | // Shouldn't we set it to a value greater 0? When showDates is called with |
751 | // show == true at first, then the columnwidths are set to zero. | 751 | // show == true at first, then the columnwidths are set to zero. |
752 | static int oldColWidth1 = 0; | 752 | static int oldColWidth1 = 0; |
753 | static int oldColWidth3 = 0; | 753 | static int oldColWidth3 = 0; |
754 | 754 | ||
755 | if (!show) { | 755 | if (!show) { |
756 | oldColWidth1 = mListView->columnWidth(1); | 756 | oldColWidth1 = mListView->columnWidth(1); |
757 | oldColWidth3 = mListView->columnWidth(3); | 757 | oldColWidth3 = mListView->columnWidth(3); |
758 | mListView->setColumnWidth(1, 0); | 758 | mListView->setColumnWidth(1, 0); |
759 | mListView->setColumnWidth(3, 0); | 759 | mListView->setColumnWidth(3, 0); |
760 | } else { | 760 | } else { |
761 | mListView->setColumnWidth(1, oldColWidth1); | 761 | mListView->setColumnWidth(1, oldColWidth1); |
762 | mListView->setColumnWidth(3, oldColWidth3); | 762 | mListView->setColumnWidth(3, oldColWidth3); |
763 | } | 763 | } |
764 | mListView->repaint(); | 764 | mListView->repaint(); |
765 | } | 765 | } |
766 | 766 | ||
767 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 767 | void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
768 | const QDate &td) | 768 | const QDate &td) |
769 | { | 769 | { |
770 | #ifndef KORG_NOPRINTER | 770 | #ifndef KORG_NOPRINTER |
771 | calPrinter->preview(CalPrinter::Day, fd, td); | 771 | calPrinter->preview(CalPrinter::Day, fd, td); |
772 | #endif | 772 | #endif |
773 | } | 773 | } |
774 | 774 | ||
775 | void KOListView::showDates() | 775 | void KOListView::showDates() |
776 | { | 776 | { |
777 | showDates(true); | 777 | showDates(true); |
778 | } | 778 | } |
779 | 779 | ||
780 | void KOListView::hideDates() | 780 | void KOListView::hideDates() |
781 | { | 781 | { |
782 | showDates(false); | 782 | showDates(false); |
783 | } | 783 | } |
784 | 784 | ||
785 | void KOListView::updateView() | 785 | void KOListView::updateView() |
786 | { | 786 | { |
787 | mListView->setFocus(); | 787 | mListView->setFocus(); |
788 | if ( mListView->firstChild () ) | 788 | if ( mListView->firstChild () ) |
789 | mListView->setCurrentItem( mListView->firstChild () ); | 789 | mListView->setCurrentItem( mListView->firstChild () ); |
790 | } | 790 | } |
791 | void KOListView::updateConfig() | 791 | void KOListView::updateConfig() |
792 | { | 792 | { |
793 | 793 | ||
794 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 794 | mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
795 | updateView(); | 795 | updateView(); |
796 | 796 | ||
797 | } | 797 | } |
798 | void KOListView::setStartDate(const QDate &start) | 798 | void KOListView::setStartDate(const QDate &start) |
799 | { | 799 | { |
800 | mStartDate = start; | 800 | mStartDate = start; |
801 | } | 801 | } |
802 | 802 | ||
803 | void KOListView::showDates(const QDate &start, const QDate &end) | 803 | void KOListView::showDates(const QDate &start, const QDate &end) |
804 | { | 804 | { |
805 | clear(); | 805 | clear(); |
806 | mStartDate = start; | 806 | mStartDate = start; |
807 | QDate date = start; | 807 | QDate date = start; |
808 | QPtrList<Journal> j_list; | 808 | QPtrList<Journal> j_list; |
809 | while( date <= end ) { | 809 | while( date <= end ) { |
810 | addEvents(calendar()->events(date)); | 810 | addEvents(calendar()->events(date)); |
811 | addTodos(calendar()->todos(date)); | 811 | addTodos(calendar()->todos(date)); |
812 | Journal* jo = calendar()->journal(date); | 812 | Journal* jo = calendar()->journal(date); |
813 | if ( jo ) | 813 | if ( jo ) |
814 | j_list.append( jo ); | 814 | j_list.append( jo ); |
815 | date = date.addDays( 1 ); | 815 | date = date.addDays( 1 ); |
816 | } | 816 | } |
817 | addJournals(j_list); | 817 | addJournals(j_list); |
818 | emit incidenceSelected( 0 ); | 818 | emit incidenceSelected( 0 ); |
819 | updateView(); | 819 | updateView(); |
820 | 820 | ||
821 | } | 821 | } |
822 | 822 | ||
823 | void KOListView::addEvents(QPtrList<Event> eventList) | 823 | void KOListView::addEvents(QPtrList<Event> eventList) |
824 | { | 824 | { |
825 | Event *ev; | 825 | Event *ev; |
826 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 826 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
827 | addIncidence(ev); | 827 | addIncidence(ev); |
828 | } | 828 | } |
829 | if ( !mListView->currentItem() ){ | 829 | if ( !mListView->currentItem() ){ |
830 | updateView(); | 830 | updateView(); |
831 | } | 831 | } |
832 | } | 832 | } |
833 | 833 | ||
834 | void KOListView::addTodos(QPtrList<Todo> eventList) | 834 | void KOListView::addTodos(QPtrList<Todo> eventList) |
835 | { | 835 | { |
836 | Todo *ev; | 836 | Todo *ev; |
837 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 837 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
838 | addIncidence(ev); | 838 | addIncidence(ev); |
839 | } | 839 | } |
840 | if ( !mListView->currentItem() ){ | 840 | if ( !mListView->currentItem() ){ |
841 | updateView(); | 841 | updateView(); |
842 | } | 842 | } |
843 | } | 843 | } |
844 | void KOListView::addJournals(QPtrList<Journal> eventList) | 844 | void KOListView::addJournals(QPtrList<Journal> eventList) |
845 | { | 845 | { |
846 | Journal *ev; | 846 | Journal *ev; |
847 | for(ev = eventList.first(); ev; ev = eventList.next()) { | 847 | for(ev = eventList.first(); ev; ev = eventList.next()) { |
848 | addIncidence(ev); | 848 | addIncidence(ev); |
849 | } | 849 | } |
850 | if ( !mListView->currentItem() ){ | 850 | if ( !mListView->currentItem() ){ |
851 | updateView(); | 851 | updateView(); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | 854 | ||
855 | void KOListView::addIncidence(Incidence *incidence) | 855 | void KOListView::addIncidence(Incidence *incidence) |
856 | { | 856 | { |
857 | if ( mUidDict.find( incidence->uid() ) ) return; | 857 | if ( mUidDict.find( incidence->uid() ) ) return; |
858 | 858 | ||
859 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); | 859 | // mListView->setFont ( KOPrefs::instance()->mListViewFont ); |
860 | mUidDict.insert( incidence->uid(), incidence ); | 860 | mUidDict.insert( incidence->uid(), incidence ); |
861 | 861 | ||
862 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); | 862 | KOListViewItem *item = new KOListViewItem( incidence, mListView ); |
863 | ListItemVisitor v(item, mStartDate ); | 863 | ListItemVisitor v(item, mStartDate ); |
864 | if (incidence->accept(v)) return; | 864 | if (incidence->accept(v)) return; |
865 | else delete item; | 865 | else delete item; |
866 | //qDebug("delete item "); | 866 | //qDebug("delete item "); |
867 | } | 867 | } |
868 | 868 | ||
869 | void KOListView::showEvents(QPtrList<Event> eventList) | 869 | void KOListView::showEvents(QPtrList<Event> eventList) |
870 | { | 870 | { |
871 | clear(); | 871 | clear(); |
872 | 872 | ||
873 | addEvents(eventList); | 873 | addEvents(eventList); |
874 | 874 | ||
875 | // After new creation of list view no events are selected. | 875 | // After new creation of list view no events are selected. |
876 | emit incidenceSelected( 0 ); | 876 | emit incidenceSelected( 0 ); |
877 | } | 877 | } |
878 | int KOListView::count() | 878 | int KOListView::count() |
879 | { | 879 | { |
880 | return mListView->childCount(); | 880 | return mListView->childCount(); |
881 | } | 881 | } |
882 | 882 | ||
883 | void KOListView::changeEventDisplay(Event *event, int action) | 883 | void KOListView::changeEventDisplay(Event *event, int action) |
884 | { | 884 | { |
885 | KOListViewItem *item; | 885 | KOListViewItem *item; |
886 | 886 | ||
887 | switch(action) { | 887 | switch(action) { |
888 | case KOGlobals::EVENTADDED: | 888 | case KOGlobals::EVENTADDED: |
889 | addIncidence( event ); | 889 | addIncidence( event ); |
890 | break; | 890 | break; |
891 | case KOGlobals::EVENTEDITED: | 891 | case KOGlobals::EVENTEDITED: |
892 | item = getItemForEvent(event); | 892 | item = getItemForEvent(event); |
893 | if (item) { | 893 | if (item) { |
894 | mUidDict.remove( event->uid() ); | 894 | mUidDict.remove( event->uid() ); |
895 | delete item; | 895 | delete item; |
896 | addIncidence( event ); | 896 | addIncidence( event ); |
897 | } | 897 | } |
898 | break; | 898 | break; |
899 | case KOGlobals::EVENTDELETED: | 899 | case KOGlobals::EVENTDELETED: |
900 | item = getItemForEvent(event); | 900 | item = getItemForEvent(event); |
901 | if (item) { | 901 | if (item) { |
902 | mUidDict.remove( event->uid() ); | 902 | mUidDict.remove( event->uid() ); |
903 | delete item; | 903 | delete item; |
904 | } | 904 | } |
905 | break; | 905 | break; |
906 | default: | 906 | default: |
907 | ; | 907 | ; |
908 | } | 908 | } |
909 | } | 909 | } |
910 | 910 | ||
911 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 911 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
912 | { | 912 | { |
913 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 913 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
914 | while (item) { | 914 | while (item) { |
915 | if (item->data() == event) return item; | 915 | if (item->data() == event) return item; |
916 | item = (KOListViewItem *)item->nextSibling(); | 916 | item = (KOListViewItem *)item->nextSibling(); |
917 | } | 917 | } |
918 | return 0; | 918 | return 0; |
919 | } | 919 | } |
920 | 920 | ||
921 | void KOListView::defaultItemAction(QListViewItem *i) | 921 | void KOListView::defaultItemAction(QListViewItem *i) |
922 | { | 922 | { |
923 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 923 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
924 | if ( item ) defaultAction( item->data() ); | 924 | if ( item ) defaultAction( item->data() ); |
925 | 925 | ||
926 | } | 926 | } |
927 | 927 | ||
928 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 928 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
929 | { | 929 | { |
930 | mActiveItem = (KOListViewItem *)item; | 930 | mActiveItem = (KOListViewItem *)item; |
931 | if (mActiveItem) { | 931 | if (mActiveItem) { |
932 | Incidence *incidence = mActiveItem->data(); | 932 | Incidence *incidence = mActiveItem->data(); |
933 | mPopupMenu->showIncidencePopup(incidence); | 933 | mPopupMenu->showIncidencePopup(incidence); |
934 | 934 | ||
935 | /* | 935 | /* |
936 | if ( incidence && incidence->type() == "Event" ) { | 936 | if ( incidence && incidence->type() == "Event" ) { |
937 | Event *event = static_cast<Event *>( incidence ); | 937 | Event *event = static_cast<Event *>( incidence ); |
938 | mPopupMenu->showEventPopup(event); | 938 | mPopupMenu->showEventPopup(event); |
939 | } | 939 | } |
940 | */ | 940 | */ |
941 | } | 941 | } |
942 | } | 942 | } |
943 | 943 | ||
944 | void KOListView::readSettings(KConfig *config, QString setting) | 944 | void KOListView::readSettings(KConfig *config, QString setting) |
945 | { | 945 | { |
946 | // qDebug("KOListView::readSettings "); | 946 | // qDebug("KOListView::readSettings "); |
947 | mListView->restoreLayout(config,setting); | 947 | mListView->restoreLayout(config,setting); |
948 | } | 948 | } |
949 | 949 | ||
950 | void KOListView::writeSettings(KConfig *config, QString setting) | 950 | void KOListView::writeSettings(KConfig *config, QString setting) |
951 | { | 951 | { |
952 | // qDebug("KOListView::writeSettings "); | 952 | // qDebug("KOListView::writeSettings "); |
953 | mListView->saveLayout(config, setting); | 953 | mListView->saveLayout(config, setting); |
954 | } | 954 | } |
955 | 955 | ||
956 | void KOListView::processSelectionChange(QListViewItem *) | 956 | void KOListView::processSelectionChange(QListViewItem *) |
957 | { | 957 | { |
958 | 958 | ||
959 | KOListViewItem *item = | 959 | KOListViewItem *item = |
960 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 960 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
961 | 961 | ||
962 | if ( !item ) { | 962 | if ( !item ) { |
963 | emit incidenceSelected( 0 ); | 963 | emit incidenceSelected( 0 ); |
964 | } else { | 964 | } else { |
965 | emit incidenceSelected( item->data() ); | 965 | emit incidenceSelected( item->data() ); |
966 | } | 966 | } |
967 | } | 967 | } |
968 | 968 | ||
969 | void KOListView::clearSelection() | 969 | void KOListView::clearSelection() |
970 | { | 970 | { |
971 | mListView->selectAll( false ); | 971 | mListView->selectAll( false ); |
972 | } | 972 | } |
973 | void KOListView::allSelection() | 973 | void KOListView::allSelection() |
974 | { | 974 | { |
975 | mListView->selectAll( true ); | 975 | mListView->selectAll( true ); |
976 | } | 976 | } |
977 | 977 | ||
978 | void KOListView::clear() | 978 | void KOListView::clear() |
979 | { | 979 | { |
980 | mListView->clear(); | 980 | mListView->clear(); |
981 | mUidDict.clear(); | 981 | mUidDict.clear(); |
982 | } | 982 | } |
983 | 983 | ||
984 | Incidence* KOListView::currentItem() | 984 | Incidence* KOListView::currentItem() |
985 | { | 985 | { |
986 | if ( mListView->currentItem() ) | 986 | if ( mListView->currentItem() ) |
987 | return ((KOListViewItem*) mListView->currentItem())->data(); | 987 | return ((KOListViewItem*) mListView->currentItem())->data(); |
988 | return 0; | 988 | return 0; |
989 | } | 989 | } |
990 | void KOListView::keyPressEvent ( QKeyEvent *e) | 990 | void KOListView::keyPressEvent ( QKeyEvent *e) |
991 | { | 991 | { |
992 | 992 | ||
993 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { | 993 | if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { |
994 | deleteAll(); | 994 | deleteAll(); |
995 | return; | 995 | return; |
996 | } | 996 | } |
997 | 997 | ||
998 | e->ignore(); | 998 | e->ignore(); |
999 | } | 999 | } |
1000 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) | 1000 | void KOListViewListView::keyPressEvent ( QKeyEvent *e) |
1001 | { | 1001 | { |
1002 | 1002 | ||
1003 | switch ( e->key() ) { | 1003 | switch ( e->key() ) { |
1004 | case Qt::Key_Down: | 1004 | case Qt::Key_Down: |
1005 | if ( e->state() == ShiftButton ) { | 1005 | if ( e->state() == ShiftButton ) { |
1006 | QListViewItem* cn = currentItem(); | 1006 | QListViewItem* cn = currentItem(); |
1007 | if ( !cn ) | 1007 | if ( !cn ) |
1008 | cn = firstChild(); | 1008 | cn = firstChild(); |
1009 | if ( !cn ) | 1009 | if ( !cn ) |
1010 | return; | 1010 | return; |
1011 | while ( cn->nextSibling() ) | 1011 | while ( cn->nextSibling() ) |
1012 | cn = cn->nextSibling(); | 1012 | cn = cn->nextSibling(); |
1013 | setCurrentItem ( cn ); | 1013 | setCurrentItem ( cn ); |
1014 | ensureItemVisible ( cn ); | 1014 | ensureItemVisible ( cn ); |
1015 | 1015 | ||
1016 | e->accept(); | 1016 | e->accept(); |
1017 | return; | 1017 | return; |
1018 | } | 1018 | } |
1019 | if ( e->state() == ControlButton ) { | 1019 | if ( e->state() == ControlButton ) { |
1020 | int count = childCount (); | 1020 | int count = childCount (); |
1021 | int jump = count / 5; | 1021 | int jump = count / 5; |
1022 | QListViewItem* cn; | 1022 | QListViewItem* cn; |
1023 | cn = currentItem(); | 1023 | cn = currentItem(); |
1024 | if ( ! cn ) | 1024 | if ( ! cn ) |
1025 | return; | 1025 | return; |
1026 | if ( jump == 0 ) | 1026 | if ( jump == 0 ) |
1027 | jump = 1; | 1027 | jump = 1; |
1028 | while ( jump && cn->nextSibling() ) { | 1028 | while ( jump && cn->nextSibling() ) { |
1029 | cn = cn->nextSibling(); | 1029 | cn = cn->nextSibling(); |
1030 | --jump; | 1030 | --jump; |
1031 | } | 1031 | } |
1032 | setCurrentItem ( cn ); | 1032 | setCurrentItem ( cn ); |
1033 | ensureItemVisible ( cn ); | 1033 | ensureItemVisible ( cn ); |
1034 | 1034 | ||
1035 | } else | 1035 | } else |
1036 | QListView::keyPressEvent ( e ) ; | 1036 | QListView::keyPressEvent ( e ) ; |
1037 | e->accept(); | 1037 | e->accept(); |
1038 | break; | 1038 | break; |
1039 | 1039 | ||
1040 | case Qt::Key_Up: | 1040 | case Qt::Key_Up: |
1041 | if ( e->state() == ShiftButton ) { | 1041 | if ( e->state() == ShiftButton ) { |
1042 | QListViewItem* cn = firstChild(); | 1042 | QListViewItem* cn = firstChild(); |
1043 | if ( cn ) { | 1043 | if ( cn ) { |
1044 | setCurrentItem ( cn ); | 1044 | setCurrentItem ( cn ); |
1045 | ensureItemVisible ( cn ); | 1045 | ensureItemVisible ( cn ); |
1046 | } | 1046 | } |
1047 | e->accept(); | 1047 | e->accept(); |
1048 | return; | 1048 | return; |
1049 | } | 1049 | } |
1050 | if ( e->state() == ControlButton ) { | 1050 | if ( e->state() == ControlButton ) { |
1051 | int count = childCount (); | 1051 | int count = childCount (); |
1052 | int jump = count / 5; | 1052 | int jump = count / 5; |
1053 | QListViewItem* cn; | 1053 | QListViewItem* cn; |
1054 | cn = currentItem(); | 1054 | cn = currentItem(); |
1055 | if ( ! cn ) | 1055 | if ( ! cn ) |
1056 | return; | 1056 | return; |
1057 | if ( jump == 0 ) | 1057 | if ( jump == 0 ) |
1058 | jump = 1; | 1058 | jump = 1; |
1059 | while ( jump && cn->itemAbove ()) { | 1059 | while ( jump && cn->itemAbove ()) { |
1060 | cn = cn->itemAbove (); | 1060 | cn = cn->itemAbove (); |
1061 | --jump; | 1061 | --jump; |
1062 | } | 1062 | } |
1063 | setCurrentItem ( cn ); | 1063 | setCurrentItem ( cn ); |
1064 | ensureItemVisible ( cn ); | 1064 | ensureItemVisible ( cn ); |
1065 | } else | 1065 | } else |
1066 | QListView::keyPressEvent ( e ) ; | 1066 | QListView::keyPressEvent ( e ) ; |
1067 | e->accept(); | 1067 | e->accept(); |
1068 | break; | 1068 | break; |
1069 | case Qt::Key_I: { | 1069 | case Qt::Key_I: { |
1070 | QListViewItem* cn; | 1070 | QListViewItem* cn; |
1071 | cn = currentItem(); | 1071 | cn = currentItem(); |
1072 | if ( cn ) { | 1072 | if ( cn ) { |
1073 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1073 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1074 | if ( ci ){ | 1074 | if ( ci ){ |
1075 | emit showIncidence( ci->data()); | 1075 | emit showIncidence( ci->data()); |
1076 | cn = cn->nextSibling(); | 1076 | cn = cn->nextSibling(); |
1077 | if ( cn ) { | 1077 | if ( cn ) { |
1078 | setCurrentItem ( cn ); | 1078 | setCurrentItem ( cn ); |
1079 | ensureItemVisible ( cn ); | 1079 | ensureItemVisible ( cn ); |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
1082 | } | 1082 | } |
1083 | e->accept(); | 1083 | e->accept(); |
1084 | } | 1084 | } |
1085 | break; | 1085 | break; |
1086 | case Qt::Key_Return: | 1086 | case Qt::Key_Return: |
1087 | case Qt::Key_Enter: | 1087 | case Qt::Key_Enter: |
1088 | { | 1088 | { |
1089 | QListViewItem* cn; | 1089 | QListViewItem* cn; |
1090 | cn = currentItem(); | 1090 | cn = currentItem(); |
1091 | if ( cn ) { | 1091 | if ( cn ) { |
1092 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1092 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1093 | if ( ci ){ | 1093 | if ( ci ){ |
1094 | if ( e->state() == ShiftButton ) | 1094 | if ( e->state() == ShiftButton ) |
1095 | ci->setSelected( false ); | 1095 | ci->setSelected( false ); |
1096 | else | 1096 | else |
1097 | ci->setSelected( true ); | 1097 | ci->setSelected( true ); |
1098 | cn = cn->nextSibling(); | 1098 | cn = cn->nextSibling(); |
1099 | if ( cn ) { | 1099 | if ( cn ) { |
1100 | setCurrentItem ( cn ); | 1100 | setCurrentItem ( cn ); |
1101 | ensureItemVisible ( cn ); | 1101 | ensureItemVisible ( cn ); |
1102 | } | 1102 | } |
1103 | } | 1103 | } |
1104 | } | 1104 | } |
1105 | e->accept(); | 1105 | e->accept(); |
1106 | } | 1106 | } |
1107 | break; | 1107 | break; |
1108 | default: | 1108 | default: |
1109 | e->ignore(); | 1109 | e->ignore(); |
1110 | } | 1110 | } |
1111 | } | 1111 | } |
1112 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1112 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1113 | : KListView( lv ) | 1113 | : KListView( lv ) |
1114 | { | 1114 | { |
1115 | #ifndef DESKTOP_VERSION | 1115 | #ifndef DESKTOP_VERSION |
1116 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1116 | QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1117 | #endif | 1117 | #endif |
1118 | mYMousePos = -1000; | 1118 | mYMousePos = -1000; |
1119 | setSelectionMode( QListView::Multi ); | 1119 | setSelectionMode( QListView::Multi ); |
1120 | setMultiSelection( true); | 1120 | setMultiSelection( true); |
1121 | mAllowPopupMenu = true; | 1121 | mAllowPopupMenu = true; |
1122 | mMouseDown = false; | 1122 | mMouseDown = false; |
1123 | 1123 | ||
1124 | } | 1124 | } |
1125 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1125 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1126 | { | 1126 | { |
1127 | if (!e) return; | 1127 | if (!e) return; |
1128 | QPoint vp = contentsToViewport(e->pos()); | 1128 | QPoint vp = contentsToViewport(e->pos()); |
1129 | QListViewItem *item = itemAt(vp); | 1129 | QListViewItem *item = itemAt(vp); |
1130 | if (!item) { | 1130 | if (!item) { |
1131 | emit newEvent(); | 1131 | emit newEvent(); |
1132 | return; | 1132 | return; |
1133 | } | 1133 | } |
1134 | KListView::contentsMouseDoubleClickEvent(e); | 1134 | KListView::contentsMouseDoubleClickEvent(e); |
1135 | } | 1135 | } |
1136 | 1136 | ||
1137 | 1137 | ||
1138 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1138 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1139 | { | 1139 | { |
1140 | //qDebug("contentsMousePressEvent++++ "); | 1140 | //qDebug("contentsMousePressEvent++++ "); |
1141 | if (! mMouseDown ) { | 1141 | if (! mMouseDown ) { |
1142 | mAllowPopupMenu = true; | 1142 | mAllowPopupMenu = true; |
1143 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1143 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1144 | } | 1144 | } |
1145 | if ( e->button() == RightButton && mMouseDown ) | 1145 | if ( e->button() == RightButton && mMouseDown ) |
1146 | return; | 1146 | return; |
1147 | if ( e->button() == LeftButton ) | 1147 | if ( e->button() == LeftButton ) |
1148 | mMouseDown = true; | 1148 | mMouseDown = true; |
1149 | KListView::contentsMousePressEvent( e ); | 1149 | KListView::contentsMousePressEvent( e ); |
1150 | } | 1150 | } |
1151 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1151 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1152 | { | 1152 | { |
1153 | //qDebug("contentsMouseReleaseEv---- "); | 1153 | //qDebug("contentsMouseReleaseEv---- "); |
1154 | if ( ! mMouseDown ) { | 1154 | if ( ! mMouseDown ) { |
1155 | if ( e->button() == RightButton && ! mAllowPopupMenu ) | 1155 | if ( e->button() == RightButton && ! mAllowPopupMenu ) |
1156 | return; | 1156 | return; |
1157 | QListViewItem* ci = currentItem(); | 1157 | QListViewItem* ci = currentItem(); |
1158 | if ( ci ) | 1158 | if ( ci ) |
1159 | ci->setSelected( true ); | 1159 | ci->setSelected( true ); |
1160 | KListView::contentsMouseReleaseEvent(e); | 1160 | KListView::contentsMouseReleaseEvent(e); |
1161 | return; | 1161 | return; |
1162 | } | 1162 | } |
1163 | if ( e->button() == LeftButton ) | 1163 | if ( e->button() == LeftButton ) |
1164 | mMouseDown = false; | 1164 | mMouseDown = false; |
1165 | if ( e->button() == RightButton && ! mAllowPopupMenu ) | 1165 | if ( e->button() == RightButton && ! mAllowPopupMenu ) |
1166 | return; | 1166 | return; |
1167 | if ( e->button() == RightButton ) { | 1167 | if ( e->button() == RightButton ) { |
1168 | QListViewItem* ci = currentItem(); | 1168 | QListViewItem* ci = currentItem(); |
1169 | if ( ci ) | 1169 | if ( ci ) |
1170 | ci->setSelected( true ); | 1170 | ci->setSelected( true ); |
1171 | } | 1171 | } |
1172 | KListView::contentsMouseReleaseEvent(e); | 1172 | KListView::contentsMouseReleaseEvent(e); |
1173 | } | 1173 | } |
1174 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1174 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1175 | { | 1175 | { |
1176 | // qDebug("contentsMouseMoveEv....... "); | 1176 | // qDebug("contentsMouseMoveEv....... "); |
1177 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); | 1177 | // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); |
1178 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); | 1178 | int diff = mYMousePos - mapToGlobal( (e->pos())).y(); |
1179 | if ( diff < 0 ) diff = -diff; | 1179 | if ( diff < 0 ) diff = -diff; |
1180 | if ( diff > 20 ) | 1180 | if ( diff > 20 ) |
1181 | mAllowPopupMenu = false; | 1181 | mAllowPopupMenu = false; |
1182 | KListView::contentsMouseMoveEvent(e); | 1182 | KListView::contentsMouseMoveEvent(e); |
1183 | } | 1183 | } |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index f595d35..d0380e3 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1610 +1,1613 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qvbox.h> | 25 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #else | 34 | #else |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kglobal.h> | 40 | #include <kglobal.h> |
41 | #include <kconfig.h> | 41 | #include <kconfig.h> |
42 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
43 | 43 | ||
44 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
45 | 45 | ||
46 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
47 | #include "calprinter.h" | 47 | #include "calprinter.h" |
48 | #endif | 48 | #endif |
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
51 | #include "kocore.h" | 51 | #include "kocore.h" |
52 | #endif | 52 | #endif |
53 | #include "koglobals.h" | 53 | #include "koglobals.h" |
54 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
55 | 55 | ||
56 | #include "komonthview.h" | 56 | #include "komonthview.h" |
57 | 57 | ||
58 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
59 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
61 | #endif | 61 | #endif |
62 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
63 | { | 63 | { |
64 | public: | 64 | public: |
65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
70 | { | 70 | { |
71 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
72 | }; | 72 | }; |
73 | private: | 73 | private: |
74 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | 78 | ||
79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
80 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
81 | { | 81 | { |
82 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
84 | #endif | 84 | #endif |
85 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
86 | } | 86 | } |
87 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
88 | { | 88 | { |
89 | 89 | ||
90 | } | 90 | } |
91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
92 | { | 92 | { |
93 | QListBoxItem* item = itemAt ( p ); | 93 | QListBoxItem* item = itemAt ( p ); |
94 | if ( ! item ) { | 94 | if ( ! item ) { |
95 | return i18n("Click in the cell\nto add an event!"); | 95 | return i18n("Click in the cell\nto add an event!"); |
96 | } | 96 | } |
97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
98 | } | 98 | } |
99 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 99 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
100 | { | 100 | { |
101 | 101 | ||
102 | switch(e->key()) { | 102 | switch(e->key()) { |
103 | case Key_Right: | 103 | case Key_Right: |
104 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 104 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
105 | { | 105 | { |
106 | e->ignore(); | 106 | e->ignore(); |
107 | return; | 107 | return; |
108 | } | 108 | } |
109 | scrollBy(10,0); | 109 | scrollBy(10,0); |
110 | break; | 110 | break; |
111 | case Key_Left: | 111 | case Key_Left: |
112 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 112 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
113 | { | 113 | { |
114 | e->ignore(); | 114 | e->ignore(); |
115 | return; | 115 | return; |
116 | } | 116 | } |
117 | scrollBy(-10,0); | 117 | scrollBy(-10,0); |
118 | break; | 118 | break; |
119 | case Key_Up: | 119 | case Key_Up: |
120 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 120 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
121 | e->ignore(); | 121 | e->ignore(); |
122 | break; | 122 | break; |
123 | } | 123 | } |
124 | setCurrentItem((currentItem()+count()-1)%count()); | 124 | setCurrentItem((currentItem()+count()-1)%count()); |
125 | if(!itemVisible(currentItem())) { | 125 | if(!itemVisible(currentItem())) { |
126 | if((unsigned int) currentItem() == (count()-1)) { | 126 | if((unsigned int) currentItem() == (count()-1)) { |
127 | setTopItem(currentItem()-numItemsVisible()+1); | 127 | setTopItem(currentItem()-numItemsVisible()+1); |
128 | } else { | 128 | } else { |
129 | setTopItem(topItem()-1); | 129 | setTopItem(topItem()-1); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | break; | 132 | break; |
133 | case Key_Down: | 133 | case Key_Down: |
134 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 134 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
135 | e->ignore(); | 135 | e->ignore(); |
136 | break; | 136 | break; |
137 | } | 137 | } |
138 | setCurrentItem((currentItem()+1)%count()); | 138 | setCurrentItem((currentItem()+1)%count()); |
139 | if(!itemVisible(currentItem())) { | 139 | if(!itemVisible(currentItem())) { |
140 | if(currentItem() == 0) { | 140 | if(currentItem() == 0) { |
141 | setTopItem(0); | 141 | setTopItem(0); |
142 | } else { | 142 | } else { |
143 | setTopItem(topItem()+1); | 143 | setTopItem(topItem()+1); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | break; | 146 | break; |
147 | case Key_I: | 147 | case Key_I: |
148 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 148 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
149 | e->ignore(); | 149 | e->ignore(); |
150 | break; | 150 | break; |
151 | case Key_Shift: | 151 | case Key_Shift: |
152 | emit shiftDown(); | 152 | emit shiftDown(); |
153 | break; | 153 | break; |
154 | default: | 154 | default: |
155 | e->ignore(); | 155 | e->ignore(); |
156 | break; | 156 | break; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | void KNoScrollListBox::oneDown() | 160 | void KNoScrollListBox::oneDown() |
161 | { | 161 | { |
162 | setCurrentItem((currentItem()+1)%count()); | 162 | setCurrentItem((currentItem()+1)%count()); |
163 | if(!itemVisible(currentItem())) { | 163 | if(!itemVisible(currentItem())) { |
164 | if(currentItem() == 0) { | 164 | if(currentItem() == 0) { |
165 | setTopItem(0); | 165 | setTopItem(0); |
166 | } else { | 166 | } else { |
167 | setTopItem(topItem()+1); | 167 | setTopItem(topItem()+1); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | } | 170 | } |
171 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 171 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
172 | { | 172 | { |
173 | switch(e->key()) { | 173 | switch(e->key()) { |
174 | case Key_Shift: | 174 | case Key_Shift: |
175 | emit shiftUp(); | 175 | emit shiftUp(); |
176 | break; | 176 | break; |
177 | default: | 177 | default: |
178 | break; | 178 | break; |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 182 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
183 | { | 183 | { |
184 | QListBox::mousePressEvent(e); | 184 | QListBox::mousePressEvent(e); |
185 | 185 | ||
186 | if(e->button() == RightButton) { | 186 | if(e->button() == RightButton) { |
187 | emit rightClick(); | 187 | emit rightClick(); |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
191 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 191 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
192 | : QListBoxItem() | 192 | : QListBoxItem() |
193 | { | 193 | { |
194 | setText( s ); | 194 | setText( s ); |
195 | 195 | ||
196 | mIncidence = incidence; | 196 | mIncidence = incidence; |
197 | mDate = qd; | 197 | mDate = qd; |
198 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 198 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
199 | mRecur = false; | 199 | mRecur = false; |
200 | mAlarm = false; | 200 | mAlarm = false; |
201 | mReply = false; | 201 | mReply = false; |
202 | mInfo = false; | 202 | mInfo = false; |
203 | } | 203 | } |
204 | 204 | ||
205 | void MonthViewItem::paint(QPainter *p) | 205 | void MonthViewItem::paint(QPainter *p) |
206 | { | 206 | { |
207 | #if QT_VERSION >= 0x030000 | 207 | #if QT_VERSION >= 0x030000 |
208 | bool sel = isSelected(); | 208 | bool sel = isSelected(); |
209 | #else | 209 | #else |
210 | bool sel = selected(); | 210 | bool sel = selected(); |
211 | #endif | 211 | #endif |
212 | 212 | ||
213 | 213 | ||
214 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 214 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
215 | { | 215 | { |
216 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 216 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
217 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 217 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
218 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 218 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
219 | } | 219 | } |
220 | int x = 1; | 220 | int x = 1; |
221 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 221 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
222 | int size = PIXMAP_SIZE; | 222 | int size = PIXMAP_SIZE; |
223 | if ( QApplication::desktop()->width() < 300 ) | 223 | if ( QApplication::desktop()->width() < 300 ) |
224 | size = 3; | 224 | size = 3; |
225 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 225 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
226 | if ( mInfo ) { | 226 | if ( mInfo ) { |
227 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 227 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
228 | x += size + 1; | 228 | x += size + 1; |
229 | } | 229 | } |
230 | if ( mRecur ) { | 230 | if ( mRecur ) { |
231 | p->fillRect ( x, y,size,size, Qt::blue ); | 231 | p->fillRect ( x, y,size,size, Qt::blue ); |
232 | x += size + 1; | 232 | x += size + 1; |
233 | } | 233 | } |
234 | if ( mAlarm ) { | 234 | if ( mAlarm ) { |
235 | p->fillRect ( x, y,size,size, Qt::red ); | 235 | p->fillRect ( x, y,size,size, Qt::red ); |
236 | x += size + 1; | 236 | x += size + 1; |
237 | } | 237 | } |
238 | if ( mReply ) { | 238 | if ( mReply ) { |
239 | p->fillRect ( x, y,size,size, Qt::yellow ); | 239 | p->fillRect ( x, y,size,size, Qt::yellow ); |
240 | x += size + 1; | 240 | x += size + 1; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | QFontMetrics fm = p->fontMetrics(); | 243 | QFontMetrics fm = p->fontMetrics(); |
244 | int yPos; | 244 | int yPos; |
245 | int pmheight = size; | 245 | int pmheight = size; |
246 | if( pmheight < fm.height() ) | 246 | if( pmheight < fm.height() ) |
247 | yPos = fm.ascent() + fm.leading()/2; | 247 | yPos = fm.ascent() + fm.leading()/2; |
248 | else | 248 | else |
249 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 249 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
250 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 250 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
251 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 251 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
252 | p->drawText( x, yPos, text() ); | 252 | p->drawText( x, yPos, text() ); |
253 | if ( mIncidence->cancelled() ) { | 253 | if ( mIncidence->cancelled() ) { |
254 | int wid = fm.width( text() ); | 254 | int wid = fm.width( text() ); |
255 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); | 255 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); |
256 | } | 256 | } |
257 | 257 | ||
258 | } | 258 | } |
259 | 259 | ||
260 | int MonthViewItem::height(const QListBox *lb) const | 260 | int MonthViewItem::height(const QListBox *lb) const |
261 | { | 261 | { |
262 | return lb->fontMetrics().lineSpacing()+1; | 262 | return lb->fontMetrics().lineSpacing()+1; |
263 | } | 263 | } |
264 | 264 | ||
265 | int MonthViewItem::width(const QListBox *lb) const | 265 | int MonthViewItem::width(const QListBox *lb) const |
266 | { | 266 | { |
267 | int size = PIXMAP_SIZE; | 267 | int size = PIXMAP_SIZE; |
268 | if ( QApplication::desktop()->width() < 300 ) | 268 | if ( QApplication::desktop()->width() < 300 ) |
269 | size = 3; | 269 | size = 3; |
270 | int x = 1; | 270 | int x = 1; |
271 | if ( mInfo ) { | 271 | if ( mInfo ) { |
272 | x += size + 1; | 272 | x += size + 1; |
273 | } | 273 | } |
274 | if( mRecur ) { | 274 | if( mRecur ) { |
275 | x += size+1; | 275 | x += size+1; |
276 | } | 276 | } |
277 | if( mAlarm ) { | 277 | if( mAlarm ) { |
278 | x += size+1; | 278 | x += size+1; |
279 | } | 279 | } |
280 | if( mReply ) { | 280 | if( mReply ) { |
281 | x += size+1; | 281 | x += size+1; |
282 | } | 282 | } |
283 | 283 | ||
284 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 284 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
285 | } | 285 | } |
286 | 286 | ||
287 | 287 | ||
288 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 288 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
289 | : QWidget( par ), | 289 | : QWidget( par ), |
290 | mMonthView( parent ) | 290 | mMonthView( parent ) |
291 | { | 291 | { |
292 | 292 | ||
293 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 293 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
294 | 294 | ||
295 | // mLabel = new QLabel( this );QPushButton | 295 | // mLabel = new QLabel( this );QPushButton |
296 | mLabel = new QPushButton( this ); | 296 | mLabel = new QPushButton( this ); |
297 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 297 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
298 | //mLabel->setLineWidth( 1 ); | 298 | //mLabel->setLineWidth( 1 ); |
299 | //mLabel->setAlignment( AlignCenter ); | 299 | //mLabel->setAlignment( AlignCenter ); |
300 | mLabel->setFlat( true ); | 300 | mLabel->setFlat( true ); |
301 | mLabel->setFocusPolicy(NoFocus); | 301 | mLabel->setFocusPolicy(NoFocus); |
302 | mItemList = new KNoScrollListBox( this ); | 302 | mItemList = new KNoScrollListBox( this ); |
303 | mItemList->setMinimumSize( 10, 10 ); | 303 | mItemList->setMinimumSize( 10, 10 ); |
304 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 304 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
305 | mItemList->setLineWidth( 1 ); | 305 | mItemList->setLineWidth( 1 ); |
306 | topLayout->addWidget( mItemList ); | 306 | topLayout->addWidget( mItemList ); |
307 | mLabel->raise(); | 307 | mLabel->raise(); |
308 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 308 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
309 | mStandardPalette = palette(); | 309 | mStandardPalette = palette(); |
310 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 310 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
311 | 311 | ||
312 | enableScrollBars( false ); | 312 | enableScrollBars( false ); |
313 | updateConfig(); | 313 | updateConfig(); |
314 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 314 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
315 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 315 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
316 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 316 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
317 | SLOT( defaultAction( QListBoxItem * ) ) ); | 317 | SLOT( defaultAction( QListBoxItem * ) ) ); |
318 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 318 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
319 | const QPoint &) ), | 319 | const QPoint &) ), |
320 | SLOT( contextMenu( QListBoxItem * ) ) ); | 320 | SLOT( contextMenu( QListBoxItem * ) ) ); |
321 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 321 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
322 | SLOT( selection( QListBoxItem * ) ) ); | 322 | SLOT( selection( QListBoxItem * ) ) ); |
323 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 323 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
324 | SLOT( cellClicked( QListBoxItem * ) ) ); | 324 | SLOT( cellClicked( QListBoxItem * ) ) ); |
325 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 325 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
326 | SLOT( selection( QListBoxItem * ) ) ); | 326 | SLOT( selection( QListBoxItem * ) ) ); |
327 | } | 327 | } |
328 | #ifdef DESKTOP_VERSION | 328 | #ifdef DESKTOP_VERSION |
329 | QToolTipGroup *MonthViewCell::toolTipGroup() | 329 | QToolTipGroup *MonthViewCell::toolTipGroup() |
330 | { | 330 | { |
331 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 331 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
332 | return mToolTipGroup; | 332 | return mToolTipGroup; |
333 | } | 333 | } |
334 | #endif | 334 | #endif |
335 | 335 | ||
336 | void MonthViewCell::setDate( const QDate &date ) | 336 | void MonthViewCell::setDate( const QDate &date ) |
337 | { | 337 | { |
338 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 338 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
339 | mDate = date; | 339 | mDate = date; |
340 | 340 | ||
341 | 341 | ||
342 | 342 | ||
343 | //resizeEvent( 0 ); | 343 | //resizeEvent( 0 ); |
344 | } | 344 | } |
345 | 345 | ||
346 | QDate MonthViewCell::date() const | 346 | QDate MonthViewCell::date() const |
347 | { | 347 | { |
348 | return mDate; | 348 | return mDate; |
349 | } | 349 | } |
350 | 350 | ||
351 | void MonthViewCell::setPrimary( bool primary ) | 351 | void MonthViewCell::setPrimary( bool primary ) |
352 | { | 352 | { |
353 | mPrimary = primary; | 353 | mPrimary = primary; |
354 | //setMyPalette(); | 354 | //setMyPalette(); |
355 | } | 355 | } |
356 | void MonthViewCell::setMyPalette() | 356 | void MonthViewCell::setMyPalette() |
357 | { | 357 | { |
358 | 358 | ||
359 | if ( mHoliday) { | 359 | if ( mHoliday) { |
360 | setPalette( mHolidayPalette ); | 360 | setPalette( mHolidayPalette ); |
361 | } else { | 361 | } else { |
362 | if ( mPrimary ) { | 362 | if ( mPrimary ) { |
363 | setPalette( mPrimaryPalette ); | 363 | setPalette( mPrimaryPalette ); |
364 | } else { | 364 | } else { |
365 | setPalette( mNonPrimaryPalette ); | 365 | setPalette( mNonPrimaryPalette ); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | QPalette pal = palette(); | 368 | QPalette pal = palette(); |
369 | 369 | ||
370 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 370 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
371 | } | 371 | } |
372 | QPalette MonthViewCell::getPalette () | 372 | QPalette MonthViewCell::getPalette () |
373 | { | 373 | { |
374 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 374 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
375 | return mStandardPalette; | 375 | return mStandardPalette; |
376 | if ( mHoliday) { | 376 | if ( mHoliday) { |
377 | return mHolidayPalette ; | 377 | return mHolidayPalette ; |
378 | } else { | 378 | } else { |
379 | if ( mPrimary ) { | 379 | if ( mPrimary ) { |
380 | return mPrimaryPalette ; | 380 | return mPrimaryPalette ; |
381 | } | 381 | } |
382 | } | 382 | } |
383 | return mNonPrimaryPalette; | 383 | return mNonPrimaryPalette; |
384 | } | 384 | } |
385 | bool MonthViewCell::isPrimary() const | 385 | bool MonthViewCell::isPrimary() const |
386 | { | 386 | { |
387 | return mPrimary; | 387 | return mPrimary; |
388 | } | 388 | } |
389 | 389 | ||
390 | void MonthViewCell::setHoliday( bool holiday ) | 390 | void MonthViewCell::setHoliday( bool holiday ) |
391 | { | 391 | { |
392 | mHoliday = holiday; | 392 | mHoliday = holiday; |
393 | //setMyPalette(); | 393 | //setMyPalette(); |
394 | } | 394 | } |
395 | 395 | ||
396 | void MonthViewCell::setHoliday( const QString &holiday ) | 396 | void MonthViewCell::setHoliday( const QString &holiday ) |
397 | { | 397 | { |
398 | mHolidayString = holiday; | 398 | mHolidayString = holiday; |
399 | 399 | ||
400 | if ( !holiday.isEmpty() ) { | 400 | if ( !holiday.isEmpty() ) { |
401 | setHoliday( true ); | 401 | setHoliday( true ); |
402 | } | 402 | } |
403 | } | 403 | } |
404 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 404 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
405 | { | 405 | { |
406 | 406 | ||
407 | e->ignore(); | 407 | e->ignore(); |
408 | 408 | ||
409 | } | 409 | } |
410 | 410 | ||
411 | void MonthViewCell::startUpdateCell() | 411 | void MonthViewCell::startUpdateCell() |
412 | { | 412 | { |
413 | 413 | ||
414 | mItemList->setFocusPolicy(NoFocus); | 414 | mItemList->setFocusPolicy(NoFocus); |
415 | if ( !mMonthView->isUpdatePossible() ) | 415 | if ( !mMonthView->isUpdatePossible() ) |
416 | return; | 416 | return; |
417 | 417 | ||
418 | /* | 418 | /* |
419 | if ( !isVisible() ){ | 419 | if ( !isVisible() ){ |
420 | return; | 420 | return; |
421 | } | 421 | } |
422 | */ | 422 | */ |
423 | // qDebug("MonthViewCell::updateCell() "); | 423 | // qDebug("MonthViewCell::updateCell() "); |
424 | setPrimary( mDate.month()%2 ); | 424 | setPrimary( mDate.month()%2 ); |
425 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 425 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
426 | if ( mDate == QDate::currentDate() ) { | 426 | if ( mDate == QDate::currentDate() ) { |
427 | mItemList->setLineWidth( 3 ); | 427 | mItemList->setLineWidth( 3 ); |
428 | } else { | 428 | } else { |
429 | mItemList->setLineWidth( 1 ); | 429 | mItemList->setLineWidth( 1 ); |
430 | } | 430 | } |
431 | mItemList->clear(); | 431 | mItemList->clear(); |
432 | 432 | ||
433 | #ifdef DESKTOP_VERSION | 433 | #ifdef DESKTOP_VERSION |
434 | QToolTip::remove(this); | 434 | QToolTip::remove(this); |
435 | #endif | 435 | #endif |
436 | mToolTip = ""; | 436 | mToolTip = ""; |
437 | //qApp->processEvents(); | 437 | //qApp->processEvents(); |
438 | if ( !mHolidayString.isEmpty() ) { | 438 | if ( !mHolidayString.isEmpty() ) { |
439 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 439 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
440 | item->setPalette( mHolidayPalette ); | 440 | item->setPalette( mHolidayPalette ); |
441 | mItemList->insertItem( item ); | 441 | mItemList->insertItem( item ); |
442 | mToolTip += mHolidayString+"\n"; | 442 | mToolTip += mHolidayString+"\n"; |
443 | } | 443 | } |
444 | } | 444 | } |
445 | 445 | ||
446 | void MonthViewCell::insertEvent(Event *event) | 446 | void MonthViewCell::insertEvent(Event *event) |
447 | { | 447 | { |
448 | 448 | ||
449 | mItemList->setFocusPolicy(WheelFocus); | 449 | mItemList->setFocusPolicy(WheelFocus); |
450 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 450 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
451 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 451 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
452 | return; | 452 | return; |
453 | else | 453 | else |
454 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 454 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
455 | return; | 455 | return; |
456 | } | 456 | } |
457 | 457 | ||
458 | if ( event->categories().contains("Holiday") || | 458 | if ( event->categories().contains("Holiday") || |
459 | event->categories().contains(i18n("Holiday"))) { | 459 | event->categories().contains(i18n("Holiday"))) { |
460 | setHoliday( true ); | 460 | setHoliday( true ); |
461 | if ( mDate.dayOfWeek() == 7 ) | 461 | if ( mDate.dayOfWeek() == 7 ) |
462 | mItemList->setLineWidth( 3 ); | 462 | mItemList->setLineWidth( 3 ); |
463 | } | 463 | } |
464 | QString text; | 464 | QString text; |
465 | if (event->isMultiDay()) { | 465 | if (event->isMultiDay()) { |
466 | QString prefix = "<->"; | 466 | QString prefix = "<->"; |
467 | if ( event->doesRecur() ) { | 467 | if ( event->doesRecur() ) { |
468 | if ( event->recursOn( mDate) ) | 468 | if ( event->recursOn( mDate) ) |
469 | prefix ="->" ; | 469 | prefix ="->" ; |
470 | else { | 470 | else { |
471 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 471 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
472 | if ( event->recursOn( mDate.addDays( -days)) ) | 472 | if ( event->recursOn( mDate.addDays( -days)) ) |
473 | prefix ="<-" ; | 473 | prefix ="<-" ; |
474 | } | 474 | } |
475 | 475 | ||
476 | } else { | 476 | } else { |
477 | if (mDate == event->dtStart().date()) { | 477 | if (mDate == event->dtStart().date()) { |
478 | prefix ="->" ; | 478 | prefix ="->" ; |
479 | } else if (mDate == event->dtEnd().date()) { | 479 | } else if (mDate == event->dtEnd().date()) { |
480 | prefix ="<-" ; | 480 | prefix ="<-" ; |
481 | } | 481 | } |
482 | } | 482 | } |
483 | if ( !event->doesFloat() ) { | 483 | if ( !event->doesFloat() ) { |
484 | if ( mDate == event->dtStart().date () ) | 484 | if ( mDate == event->dtStart().date () ) |
485 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 485 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
486 | else if ( mDate == event->dtEnd().date () ) | 486 | else if ( mDate == event->dtEnd().date () ) |
487 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 487 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
488 | 488 | ||
489 | } | 489 | } |
490 | text = prefix + event->summary(); | 490 | text = prefix + event->summary(); |
491 | mToolTip += text; | 491 | mToolTip += text; |
492 | } else { | 492 | } else { |
493 | if (event->doesFloat()) { | 493 | if (event->doesFloat()) { |
494 | text = event->summary(); | 494 | text = event->summary(); |
495 | mToolTip += text; | 495 | mToolTip += text; |
496 | } | 496 | } |
497 | else { | 497 | else { |
498 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 498 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
499 | text += " " + event->summary(); | 499 | text += " " + event->summary(); |
500 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 500 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
501 | } | 501 | } |
502 | } | 502 | } |
503 | 503 | ||
504 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 504 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
505 | QPalette pal; | 505 | QPalette pal; |
506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 506 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
507 | QStringList categories = event->categories(); | 507 | QStringList categories = event->categories(); |
508 | QString cat = categories.first(); | 508 | QString cat = categories.first(); |
509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 509 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
510 | pal = getPalette(); | 510 | pal = getPalette(); |
511 | if (cat.isEmpty()) { | 511 | if (cat.isEmpty()) { |
512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 512 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
513 | } else { | 513 | } else { |
514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 514 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
515 | } | 515 | } |
516 | 516 | ||
517 | } else { | 517 | } else { |
518 | if (cat.isEmpty()) { | 518 | if (cat.isEmpty()) { |
519 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 519 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
520 | } else { | 520 | } else { |
521 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 521 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
522 | } | 522 | } |
523 | } | 523 | } |
524 | 524 | ||
525 | } else { | 525 | } else { |
526 | pal = mStandardPalette ; | 526 | pal = mStandardPalette ; |
527 | } | 527 | } |
528 | item->setPalette( pal ); | 528 | item->setPalette( pal ); |
529 | item->setRecur( event->recurrence()->doesRecur() ); | 529 | item->setRecur( event->recurrence()->doesRecur() ); |
530 | item->setAlarm( event->isAlarmEnabled() ); | 530 | item->setAlarm( event->isAlarmEnabled() ); |
531 | item->setMoreInfo( event->description().length() > 0 ); | 531 | item->setMoreInfo( event->description().length() > 0 ); |
532 | #ifdef DESKTOP_VERSION | 532 | #ifdef DESKTOP_VERSION |
533 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 533 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
534 | KOPrefs::instance()->email()); | 534 | KOPrefs::instance()->email()); |
535 | if ( me != 0 ) { | 535 | if ( me != 0 ) { |
536 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 536 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
537 | item->setReply(true); | 537 | item->setReply(true); |
538 | else | 538 | else |
539 | item->setReply(false); | 539 | item->setReply(false); |
540 | } else | 540 | } else |
541 | item->setReply(false); | 541 | item->setReply(false); |
542 | #endif | 542 | #endif |
543 | mItemList->insertItem( item ); | 543 | mItemList->insertItem( item ); |
544 | mToolTip += "\n"; | 544 | mToolTip += "\n"; |
545 | } | 545 | } |
546 | void MonthViewCell::insertTodo(Todo *todo) | 546 | void MonthViewCell::insertTodo(Todo *todo) |
547 | { | 547 | { |
548 | mItemList->setFocusPolicy(WheelFocus); | 548 | mItemList->setFocusPolicy(WheelFocus); |
549 | QString text; | 549 | QString text; |
550 | if (todo->hasDueDate()) { | 550 | if (todo->hasDueDate()) { |
551 | if (!todo->doesFloat()) { | 551 | if (!todo->doesFloat()) { |
552 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 552 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
553 | text += " "; | 553 | text += " "; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | text += i18n("T: %1").arg(todo->summary()); | 556 | text += i18n("T: %1").arg(todo->summary()); |
557 | 557 | ||
558 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 558 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
559 | //item->setPalette( mStandardPalette ); | 559 | //item->setPalette( mStandardPalette ); |
560 | QPalette pal; | 560 | QPalette pal; |
561 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 561 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
562 | QStringList categories = todo->categories(); | 562 | QStringList categories = todo->categories(); |
563 | QString cat = categories.first(); | 563 | QString cat = categories.first(); |
564 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 564 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
565 | pal = getPalette(); | 565 | pal = getPalette(); |
566 | if (cat.isEmpty()) { | 566 | if (cat.isEmpty()) { |
567 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 567 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
568 | } else { | 568 | } else { |
569 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 569 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
570 | } | 570 | } |
571 | 571 | ||
572 | } else { | 572 | } else { |
573 | if (cat.isEmpty()) { | 573 | if (cat.isEmpty()) { |
574 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 574 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
575 | } else { | 575 | } else { |
576 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 576 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | } else { | 580 | } else { |
581 | pal = mStandardPalette ; | 581 | pal = mStandardPalette ; |
582 | } | 582 | } |
583 | item->setPalette( pal ); | 583 | item->setPalette( pal ); |
584 | item->setRecur( todo->recurrence()->doesRecur() ); | ||
585 | item->setAlarm( todo->isAlarmEnabled() ); | ||
586 | item->setMoreInfo( todo->description().length() > 0 ); | ||
584 | mItemList->insertItem( item ); | 587 | mItemList->insertItem( item ); |
585 | mToolTip += text+"\n"; | 588 | mToolTip += text+"\n"; |
586 | } | 589 | } |
587 | void MonthViewCell::finishUpdateCell() | 590 | void MonthViewCell::finishUpdateCell() |
588 | { | 591 | { |
589 | #ifdef DESKTOP_VERSION | 592 | #ifdef DESKTOP_VERSION |
590 | if (mToolTip != "") | 593 | if (mToolTip != "") |
591 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 594 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
592 | #endif | 595 | #endif |
593 | mItemList->sort(); | 596 | mItemList->sort(); |
594 | //setMyPalette(); | 597 | //setMyPalette(); |
595 | setMyPalette(); | 598 | setMyPalette(); |
596 | QString text; | 599 | QString text; |
597 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 600 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
598 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 601 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
599 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 602 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
600 | mLabel->resize( mLabelBigSize ); | 603 | mLabel->resize( mLabelBigSize ); |
601 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 604 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
602 | } else { | 605 | } else { |
603 | mLabel->resize( mLabelSize ); | 606 | mLabel->resize( mLabelSize ); |
604 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 607 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
605 | } | 608 | } |
606 | 609 | ||
607 | mLabel->setText( text ); | 610 | mLabel->setText( text ); |
608 | resizeEvent( 0 ); | 611 | resizeEvent( 0 ); |
609 | } | 612 | } |
610 | void MonthViewCell::updateCell() | 613 | void MonthViewCell::updateCell() |
611 | { | 614 | { |
612 | qDebug("MonthViewCell::updateCell() "); | 615 | qDebug("MonthViewCell::updateCell() "); |
613 | if ( !mMonthView->isUpdatePossible() ) | 616 | if ( !mMonthView->isUpdatePossible() ) |
614 | return; | 617 | return; |
615 | startUpdateCell(); | 618 | startUpdateCell(); |
616 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 619 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
617 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 620 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
618 | Event *event; | 621 | Event *event; |
619 | for( event = events.first(); event; event = events.next() ) { // for event | 622 | for( event = events.first(); event; event = events.next() ) { // for event |
620 | insertEvent(event); | 623 | insertEvent(event); |
621 | } | 624 | } |
622 | // insert due todos | 625 | // insert due todos |
623 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 626 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
624 | Todo *todo; | 627 | Todo *todo; |
625 | for(todo = todos.first(); todo; todo = todos.next()) { | 628 | for(todo = todos.first(); todo; todo = todos.next()) { |
626 | insertTodo( todo ); | 629 | insertTodo( todo ); |
627 | } | 630 | } |
628 | finishUpdateCell(); | 631 | finishUpdateCell(); |
629 | // if ( isVisible()) | 632 | // if ( isVisible()) |
630 | //qApp->processEvents(); | 633 | //qApp->processEvents(); |
631 | } | 634 | } |
632 | 635 | ||
633 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 636 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
634 | { | 637 | { |
635 | 638 | ||
636 | if ( bigFont ) { | 639 | if ( bigFont ) { |
637 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 640 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
638 | int ps = fo.pointSize() + 2; | 641 | int ps = fo.pointSize() + 2; |
639 | if ( ps < 18 ) | 642 | if ( ps < 18 ) |
640 | ps += 2; | 643 | ps += 2; |
641 | fo.setPointSize( ps ); | 644 | fo.setPointSize( ps ); |
642 | setFont( fo ); | 645 | setFont( fo ); |
643 | } else | 646 | } else |
644 | setFont( KOPrefs::instance()->mMonthViewFont ); | 647 | setFont( KOPrefs::instance()->mMonthViewFont ); |
645 | 648 | ||
646 | QFontMetrics fm( font() ); | 649 | QFontMetrics fm( font() ); |
647 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 650 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
648 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 651 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
649 | mHolidayPalette = mStandardPalette; | 652 | mHolidayPalette = mStandardPalette; |
650 | mPrimaryPalette = mStandardPalette; | 653 | mPrimaryPalette = mStandardPalette; |
651 | mNonPrimaryPalette = mStandardPalette; | 654 | mNonPrimaryPalette = mStandardPalette; |
652 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 655 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
653 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 656 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
654 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 657 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
655 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 658 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
656 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 659 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
657 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 660 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
658 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 661 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
659 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 662 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
660 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 663 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
661 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 664 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
662 | } | 665 | } |
663 | //updateCell(); | 666 | //updateCell(); |
664 | } | 667 | } |
665 | 668 | ||
666 | void MonthViewCell::enableScrollBars( bool enabled ) | 669 | void MonthViewCell::enableScrollBars( bool enabled ) |
667 | { | 670 | { |
668 | if ( enabled ) { | 671 | if ( enabled ) { |
669 | mItemList->setVScrollBarMode(QScrollView::Auto); | 672 | mItemList->setVScrollBarMode(QScrollView::Auto); |
670 | mItemList->setHScrollBarMode(QScrollView::Auto); | 673 | mItemList->setHScrollBarMode(QScrollView::Auto); |
671 | } else { | 674 | } else { |
672 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 675 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
673 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 676 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
674 | } | 677 | } |
675 | } | 678 | } |
676 | 679 | ||
677 | Incidence *MonthViewCell::selectedIncidence() | 680 | Incidence *MonthViewCell::selectedIncidence() |
678 | { | 681 | { |
679 | int index = mItemList->currentItem(); | 682 | int index = mItemList->currentItem(); |
680 | if ( index < 0 ) return 0; | 683 | if ( index < 0 ) return 0; |
681 | 684 | ||
682 | MonthViewItem *item = | 685 | MonthViewItem *item = |
683 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 686 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
684 | 687 | ||
685 | if ( !item ) return 0; | 688 | if ( !item ) return 0; |
686 | 689 | ||
687 | return item->incidence(); | 690 | return item->incidence(); |
688 | } | 691 | } |
689 | 692 | ||
690 | QDate MonthViewCell::selectedIncidenceDate() | 693 | QDate MonthViewCell::selectedIncidenceDate() |
691 | { | 694 | { |
692 | QDate qd; | 695 | QDate qd; |
693 | int index = mItemList->currentItem(); | 696 | int index = mItemList->currentItem(); |
694 | if ( index < 0 ) return qd; | 697 | if ( index < 0 ) return qd; |
695 | 698 | ||
696 | MonthViewItem *item = | 699 | MonthViewItem *item = |
697 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 700 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
698 | 701 | ||
699 | if ( !item ) return qd; | 702 | if ( !item ) return qd; |
700 | 703 | ||
701 | return item->incidenceDate(); | 704 | return item->incidenceDate(); |
702 | } | 705 | } |
703 | 706 | ||
704 | void MonthViewCell::deselect() | 707 | void MonthViewCell::deselect() |
705 | { | 708 | { |
706 | mItemList->clearSelection(); | 709 | mItemList->clearSelection(); |
707 | enableScrollBars( false ); | 710 | enableScrollBars( false ); |
708 | // updateCell(); | 711 | // updateCell(); |
709 | } | 712 | } |
710 | void MonthViewCell::select() | 713 | void MonthViewCell::select() |
711 | { | 714 | { |
712 | ;// updateCell(); | 715 | ;// updateCell(); |
713 | } | 716 | } |
714 | 717 | ||
715 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 718 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
716 | { | 719 | { |
717 | if ( !mMonthView->isUpdatePossible() ) | 720 | if ( !mMonthView->isUpdatePossible() ) |
718 | return; | 721 | return; |
719 | 722 | ||
720 | int size = height() - mLabel->height() - 2; | 723 | int size = height() - mLabel->height() - 2; |
721 | if ( size > 0 ) | 724 | if ( size > 0 ) |
722 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 725 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
723 | size = width() - mLabel->width() -2; | 726 | size = width() - mLabel->width() -2; |
724 | if ( size > 0 ) | 727 | if ( size > 0 ) |
725 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 728 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
726 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 729 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
727 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 730 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
728 | } | 731 | } |
729 | 732 | ||
730 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 733 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
731 | { | 734 | { |
732 | if ( !item ) return; | 735 | if ( !item ) return; |
733 | 736 | ||
734 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 737 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
735 | Incidence *incidence = eventItem->incidence(); | 738 | Incidence *incidence = eventItem->incidence(); |
736 | if ( incidence ) mMonthView->defaultAction( incidence ); | 739 | if ( incidence ) mMonthView->defaultAction( incidence ); |
737 | } | 740 | } |
738 | void MonthViewCell::showDay() | 741 | void MonthViewCell::showDay() |
739 | { | 742 | { |
740 | emit showDaySignal( date() ); | 743 | emit showDaySignal( date() ); |
741 | } | 744 | } |
742 | void MonthViewCell::newEvent() | 745 | void MonthViewCell::newEvent() |
743 | { | 746 | { |
744 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 747 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
745 | emit newEventSignal( dt ); | 748 | emit newEventSignal( dt ); |
746 | } | 749 | } |
747 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 750 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
748 | { | 751 | { |
749 | static QListBoxItem * lastClicked = 0; | 752 | static QListBoxItem * lastClicked = 0; |
750 | if ( item == 0 ) { | 753 | if ( item == 0 ) { |
751 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 754 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
752 | emit newEventSignal( dt ); | 755 | emit newEventSignal( dt ); |
753 | return; | 756 | return; |
754 | } | 757 | } |
755 | /* | 758 | /* |
756 | if ( lastClicked ) | 759 | if ( lastClicked ) |
757 | if ( ! item ) { | 760 | if ( ! item ) { |
758 | if ( lastClicked->listBox() != item->listBox() ) | 761 | if ( lastClicked->listBox() != item->listBox() ) |
759 | lastClicked->listBox()->clearSelection(); | 762 | lastClicked->listBox()->clearSelection(); |
760 | } | 763 | } |
761 | */ | 764 | */ |
762 | 765 | ||
763 | mMonthView->setSelectedCell( this ); | 766 | mMonthView->setSelectedCell( this ); |
764 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 767 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
765 | select(); | 768 | select(); |
766 | } | 769 | } |
767 | 770 | ||
768 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 771 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
769 | { | 772 | { |
770 | if ( !item ) return; | 773 | if ( !item ) return; |
771 | 774 | ||
772 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 775 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
773 | Incidence *incidence = eventItem->incidence(); | 776 | Incidence *incidence = eventItem->incidence(); |
774 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 777 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
775 | } | 778 | } |
776 | 779 | ||
777 | void MonthViewCell::selection( QListBoxItem *item ) | 780 | void MonthViewCell::selection( QListBoxItem *item ) |
778 | { | 781 | { |
779 | if ( !item ) return; | 782 | if ( !item ) return; |
780 | 783 | ||
781 | mMonthView->setSelectedCell( this ); | 784 | mMonthView->setSelectedCell( this ); |
782 | } | 785 | } |
783 | 786 | ||
784 | 787 | ||
785 | // ******************************************************************************* | 788 | // ******************************************************************************* |
786 | // ******************************************************************************* | 789 | // ******************************************************************************* |
787 | // ******************************************************************************* | 790 | // ******************************************************************************* |
788 | 791 | ||
789 | 792 | ||
790 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 793 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
791 | : KOEventView( calendar, parent, name ), | 794 | : KOEventView( calendar, parent, name ), |
792 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 795 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
793 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 796 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
794 | { | 797 | { |
795 | mShortDayLabelsM = false; | 798 | mShortDayLabelsM = false; |
796 | mShortDayLabelsW = false; | 799 | mShortDayLabelsW = false; |
797 | skipResize = false; | 800 | skipResize = false; |
798 | clPending = true; | 801 | clPending = true; |
799 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 802 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
800 | mWidStack = new QWidgetStack( this ); | 803 | mWidStack = new QWidgetStack( this ); |
801 | QVBoxLayout* hb = new QVBoxLayout( this ); | 804 | QVBoxLayout* hb = new QVBoxLayout( this ); |
802 | mMonthView = new QWidget( mWidStack ); | 805 | mMonthView = new QWidget( mWidStack ); |
803 | mWeekView = new QWidget( mWidStack ); | 806 | mWeekView = new QWidget( mWidStack ); |
804 | #if QT_VERSION >= 0x030000 | 807 | #if QT_VERSION >= 0x030000 |
805 | mWidStack->addWidget(mMonthView ); | 808 | mWidStack->addWidget(mMonthView ); |
806 | mWidStack->addWidget(mWeekView ); | 809 | mWidStack->addWidget(mWeekView ); |
807 | #else | 810 | #else |
808 | mWidStack->addWidget( mMonthView, 1 ); | 811 | mWidStack->addWidget( mMonthView, 1 ); |
809 | mWidStack->addWidget( mWeekView , 1 ); | 812 | mWidStack->addWidget( mWeekView , 1 ); |
810 | #endif | 813 | #endif |
811 | hb->addWidget( mNavigatorBar ); | 814 | hb->addWidget( mNavigatorBar ); |
812 | hb->addWidget( mWidStack ); | 815 | hb->addWidget( mWidStack ); |
813 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 816 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
814 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 817 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
815 | if ( mShowWeekView ) | 818 | if ( mShowWeekView ) |
816 | mWeekStartsMonday = true; | 819 | mWeekStartsMonday = true; |
817 | updatePossible = false; | 820 | updatePossible = false; |
818 | //updatePossible = true; | 821 | //updatePossible = true; |
819 | mCells.setAutoDelete( true ); | 822 | mCells.setAutoDelete( true ); |
820 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 823 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
821 | mDayLabels.resize( mDaysPerWeek ); | 824 | mDayLabels.resize( mDaysPerWeek ); |
822 | mDayLabelsW.resize( mDaysPerWeek ); | 825 | mDayLabelsW.resize( mDaysPerWeek ); |
823 | QFont bfont = font(); | 826 | QFont bfont = font(); |
824 | if ( QApplication::desktop()->width() < 650 ) { | 827 | if ( QApplication::desktop()->width() < 650 ) { |
825 | bfont.setPointSize( bfont.pointSize() - 2 ); | 828 | bfont.setPointSize( bfont.pointSize() - 2 ); |
826 | } | 829 | } |
827 | bfont.setBold( true ); | 830 | bfont.setBold( true ); |
828 | int i; | 831 | int i; |
829 | 832 | ||
830 | for( i = 0; i < mDaysPerWeek; i++ ) { | 833 | for( i = 0; i < mDaysPerWeek; i++ ) { |
831 | QLabel *label = new QLabel( mMonthView ); | 834 | QLabel *label = new QLabel( mMonthView ); |
832 | label->setFont(bfont); | 835 | label->setFont(bfont); |
833 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 836 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
834 | label->setLineWidth(1); | 837 | label->setLineWidth(1); |
835 | label->setAlignment(AlignCenter); | 838 | label->setAlignment(AlignCenter); |
836 | mDayLabels.insert( i, label ); | 839 | mDayLabels.insert( i, label ); |
837 | label = new QLabel( mWeekView ); | 840 | label = new QLabel( mWeekView ); |
838 | label->setFont(bfont); | 841 | label->setFont(bfont); |
839 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 842 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
840 | label->setLineWidth(1); | 843 | label->setLineWidth(1); |
841 | label->setAlignment(AlignCenter); | 844 | label->setAlignment(AlignCenter); |
842 | mDayLabelsW.insert( i, label ); | 845 | mDayLabelsW.insert( i, label ); |
843 | } | 846 | } |
844 | 847 | ||
845 | bfont.setBold( false ); | 848 | bfont.setBold( false ); |
846 | mWeekLabels.resize( mNumWeeks+1 ); | 849 | mWeekLabels.resize( mNumWeeks+1 ); |
847 | mWeekLabelsW.resize( 2 ); | 850 | mWeekLabelsW.resize( 2 ); |
848 | for( i = 0; i < mNumWeeks+1; i++ ) { | 851 | for( i = 0; i < mNumWeeks+1; i++ ) { |
849 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 852 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
850 | label->setFocusPolicy(NoFocus); | 853 | label->setFocusPolicy(NoFocus); |
851 | label->setFont(bfont); | 854 | label->setFont(bfont); |
852 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 855 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
853 | label->setFlat(true); | 856 | label->setFlat(true); |
854 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 857 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
855 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 858 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
856 | //label->setLineWidth(1); | 859 | //label->setLineWidth(1); |
857 | //label->setAlignment(AlignCenter); | 860 | //label->setAlignment(AlignCenter); |
858 | mWeekLabels.insert( i, label ); | 861 | mWeekLabels.insert( i, label ); |
859 | } | 862 | } |
860 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 863 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
861 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 864 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
862 | 865 | ||
863 | for( i = 0; i < 1+1; i++ ) { | 866 | for( i = 0; i < 1+1; i++ ) { |
864 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 867 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
865 | label->setFocusPolicy(NoFocus); | 868 | label->setFocusPolicy(NoFocus); |
866 | label->setFont(bfont); | 869 | label->setFont(bfont); |
867 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 870 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
868 | label->setFlat(true); | 871 | label->setFlat(true); |
869 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 872 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
870 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 873 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
871 | //label->setLineWidth(1); | 874 | //label->setLineWidth(1); |
872 | //label->setAlignment(AlignCenter); | 875 | //label->setAlignment(AlignCenter); |
873 | mWeekLabelsW.insert( i, label ); | 876 | mWeekLabelsW.insert( i, label ); |
874 | } | 877 | } |
875 | mWeekLabelsW[1]->setText( i18n("W")); | 878 | mWeekLabelsW[1]->setText( i18n("W")); |
876 | 879 | ||
877 | 880 | ||
878 | int row, col; | 881 | int row, col; |
879 | mCells.resize( mNumCells ); | 882 | mCells.resize( mNumCells ); |
880 | for( row = 0; row < mNumWeeks; ++row ) { | 883 | for( row = 0; row < mNumWeeks; ++row ) { |
881 | for( col = 0; col < mDaysPerWeek; ++col ) { | 884 | for( col = 0; col < mDaysPerWeek; ++col ) { |
882 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 885 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
883 | mCells.insert( row * mDaysPerWeek + col, cell ); | 886 | mCells.insert( row * mDaysPerWeek + col, cell ); |
884 | 887 | ||
885 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 888 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
886 | SLOT( defaultAction( Incidence * ) ) ); | 889 | SLOT( defaultAction( Incidence * ) ) ); |
887 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 890 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
888 | SIGNAL( newEventSignal( QDateTime ) ) ); | 891 | SIGNAL( newEventSignal( QDateTime ) ) ); |
889 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 892 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
890 | SIGNAL( showDaySignal( QDate ) ) ); | 893 | SIGNAL( showDaySignal( QDate ) ) ); |
891 | } | 894 | } |
892 | } | 895 | } |
893 | mCellsW.resize( mDaysPerWeek ); | 896 | mCellsW.resize( mDaysPerWeek ); |
894 | for( col = 0; col < mDaysPerWeek; ++col ) { | 897 | for( col = 0; col < mDaysPerWeek; ++col ) { |
895 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 898 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
896 | mCellsW.insert( col, cell ); | 899 | mCellsW.insert( col, cell ); |
897 | 900 | ||
898 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 901 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
899 | SLOT( defaultAction( Incidence * ) ) ); | 902 | SLOT( defaultAction( Incidence * ) ) ); |
900 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 903 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
901 | SIGNAL( newEventSignal( QDateTime ) ) ); | 904 | SIGNAL( newEventSignal( QDateTime ) ) ); |
902 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 905 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
903 | SIGNAL( showDaySignal( QDate ) ) ); | 906 | SIGNAL( showDaySignal( QDate ) ) ); |
904 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 907 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
905 | } | 908 | } |
906 | 909 | ||
907 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 910 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
908 | mContextMenu = eventPopup(); | 911 | mContextMenu = eventPopup(); |
909 | // updateConfig(); //useless here... | 912 | // updateConfig(); //useless here... |
910 | // ... but we need mWidthLongDayLabel computed | 913 | // ... but we need mWidthLongDayLabel computed |
911 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 914 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
912 | mWidthLongDayLabel = 0; | 915 | mWidthLongDayLabel = 0; |
913 | for (int i = 0; i < 7; i++) { | 916 | for (int i = 0; i < 7; i++) { |
914 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 917 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
915 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 918 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
916 | } | 919 | } |
917 | 920 | ||
918 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 921 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
919 | 922 | ||
920 | #if 0 | 923 | #if 0 |
921 | if ( mShowWeekView ) | 924 | if ( mShowWeekView ) |
922 | mWidStack->raiseWidget( mWeekView ); | 925 | mWidStack->raiseWidget( mWeekView ); |
923 | else | 926 | else |
924 | mWidStack->raiseWidget( mMonthView ); | 927 | mWidStack->raiseWidget( mMonthView ); |
925 | #endif | 928 | #endif |
926 | 929 | ||
927 | emit incidenceSelected( 0 ); | 930 | emit incidenceSelected( 0 ); |
928 | #ifndef DESKTOP_VERSION | 931 | #ifndef DESKTOP_VERSION |
929 | resize( QApplication::desktop()->size() ); | 932 | resize( QApplication::desktop()->size() ); |
930 | #else | 933 | #else |
931 | resize(640, 480 ); | 934 | resize(640, 480 ); |
932 | updatePossible = true; | 935 | updatePossible = true; |
933 | #endif | 936 | #endif |
934 | computeLayout(); | 937 | computeLayout(); |
935 | 938 | ||
936 | if ( mShowWeekView ) | 939 | if ( mShowWeekView ) |
937 | mWidStack->raiseWidget( mWeekView ); | 940 | mWidStack->raiseWidget( mWeekView ); |
938 | else | 941 | else |
939 | mWidStack->raiseWidget( mMonthView ); | 942 | mWidStack->raiseWidget( mMonthView ); |
940 | } | 943 | } |
941 | 944 | ||
942 | KOMonthView::~KOMonthView() | 945 | KOMonthView::~KOMonthView() |
943 | { | 946 | { |
944 | delete mContextMenu; | 947 | delete mContextMenu; |
945 | } | 948 | } |
946 | 949 | ||
947 | void KOMonthView::selectInternalWeekNum ( int n ) | 950 | void KOMonthView::selectInternalWeekNum ( int n ) |
948 | { | 951 | { |
949 | switchView(); | 952 | switchView(); |
950 | emit selectWeekNum ( n ); | 953 | emit selectWeekNum ( n ); |
951 | } | 954 | } |
952 | 955 | ||
953 | int KOMonthView::currentWeek() | 956 | int KOMonthView::currentWeek() |
954 | { | 957 | { |
955 | if ( mShowWeekView ) | 958 | if ( mShowWeekView ) |
956 | return mWeekLabelsW[0]->getWeekNum(); | 959 | return mWeekLabelsW[0]->getWeekNum(); |
957 | return mWeekLabels[0]->getWeekNum(); | 960 | return mWeekLabels[0]->getWeekNum(); |
958 | } | 961 | } |
959 | void KOMonthView::switchView() | 962 | void KOMonthView::switchView() |
960 | { | 963 | { |
961 | 964 | ||
962 | if ( selectedCell( ) ) | 965 | if ( selectedCell( ) ) |
963 | selectedCell()->deselect(); | 966 | selectedCell()->deselect(); |
964 | mShowWeekView = !mShowWeekView; | 967 | mShowWeekView = !mShowWeekView; |
965 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 968 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
966 | if ( clPending ) { | 969 | if ( clPending ) { |
967 | computeLayout(); | 970 | computeLayout(); |
968 | updateConfig(); | 971 | updateConfig(); |
969 | } | 972 | } |
970 | if ( mShowWeekView ) | 973 | if ( mShowWeekView ) |
971 | mWidStack->raiseWidget( mWeekView ); | 974 | mWidStack->raiseWidget( mWeekView ); |
972 | else | 975 | else |
973 | mWidStack->raiseWidget( mMonthView ); | 976 | mWidStack->raiseWidget( mMonthView ); |
974 | clPending = false; | 977 | clPending = false; |
975 | } | 978 | } |
976 | 979 | ||
977 | int KOMonthView::maxDatesHint() | 980 | int KOMonthView::maxDatesHint() |
978 | { | 981 | { |
979 | return mNumCells; | 982 | return mNumCells; |
980 | } | 983 | } |
981 | 984 | ||
982 | int KOMonthView::currentDateCount() | 985 | int KOMonthView::currentDateCount() |
983 | { | 986 | { |
984 | return mNumCells; | 987 | return mNumCells; |
985 | } | 988 | } |
986 | 989 | ||
987 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 990 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
988 | { | 991 | { |
989 | QPtrList<Incidence> selected; | 992 | QPtrList<Incidence> selected; |
990 | 993 | ||
991 | if ( mSelectedCell ) { | 994 | if ( mSelectedCell ) { |
992 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 995 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
993 | if ( incidence ) selected.append( incidence ); | 996 | if ( incidence ) selected.append( incidence ); |
994 | } | 997 | } |
995 | 998 | ||
996 | return selected; | 999 | return selected; |
997 | } | 1000 | } |
998 | 1001 | ||
999 | DateList KOMonthView::selectedDates() | 1002 | DateList KOMonthView::selectedDates() |
1000 | { | 1003 | { |
1001 | DateList selected; | 1004 | DateList selected; |
1002 | 1005 | ||
1003 | if ( mSelectedCell ) { | 1006 | if ( mSelectedCell ) { |
1004 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1007 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1005 | if ( qd.isValid() ) selected.append( qd ); | 1008 | if ( qd.isValid() ) selected.append( qd ); |
1006 | } | 1009 | } |
1007 | 1010 | ||
1008 | return selected; | 1011 | return selected; |
1009 | } | 1012 | } |
1010 | 1013 | ||
1011 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1014 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1012 | const QDate &td) | 1015 | const QDate &td) |
1013 | { | 1016 | { |
1014 | #ifndef KORG_NOPRINTER | 1017 | #ifndef KORG_NOPRINTER |
1015 | calPrinter->preview(CalPrinter::Month, fd, td); | 1018 | calPrinter->preview(CalPrinter::Month, fd, td); |
1016 | #endif | 1019 | #endif |
1017 | } | 1020 | } |
1018 | 1021 | ||
1019 | void KOMonthView::updateConfig() | 1022 | void KOMonthView::updateConfig() |
1020 | { | 1023 | { |
1021 | 1024 | ||
1022 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1025 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1023 | 1026 | ||
1024 | if ( mShowWeekView ) { | 1027 | if ( mShowWeekView ) { |
1025 | mWeekStartsMonday = true; | 1028 | mWeekStartsMonday = true; |
1026 | } | 1029 | } |
1027 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1030 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1028 | mWidthLongDayLabel = 0; | 1031 | mWidthLongDayLabel = 0; |
1029 | 1032 | ||
1030 | for (int i = 0; i < 7; i++) { | 1033 | for (int i = 0; i < 7; i++) { |
1031 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1034 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1032 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1035 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1033 | } | 1036 | } |
1034 | bool temp = mShowSatSunComp ; | 1037 | bool temp = mShowSatSunComp ; |
1035 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1038 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1036 | if ( ! mShowWeekView ) { | 1039 | if ( ! mShowWeekView ) { |
1037 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1040 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1038 | computeLayout(); | 1041 | computeLayout(); |
1039 | } | 1042 | } |
1040 | updateDayLabels(); | 1043 | updateDayLabels(); |
1041 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1044 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1042 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1045 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1043 | //resizeEvent( 0 ); | 1046 | //resizeEvent( 0 ); |
1044 | for (uint i = 0; i < mCells.count(); ++i) { | 1047 | for (uint i = 0; i < mCells.count(); ++i) { |
1045 | mCells[i]->updateConfig(); | 1048 | mCells[i]->updateConfig(); |
1046 | } | 1049 | } |
1047 | 1050 | ||
1048 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1051 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1049 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1052 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1050 | } | 1053 | } |
1051 | #ifdef DESKTOP_VERSION | 1054 | #ifdef DESKTOP_VERSION |
1052 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1055 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1053 | #endif | 1056 | #endif |
1054 | updateView(); | 1057 | updateView(); |
1055 | } | 1058 | } |
1056 | 1059 | ||
1057 | void KOMonthView::updateDayLabels() | 1060 | void KOMonthView::updateDayLabels() |
1058 | { | 1061 | { |
1059 | 1062 | ||
1060 | QPtrVector<QLabel> *mDayLabelsT; | 1063 | QPtrVector<QLabel> *mDayLabelsT; |
1061 | 1064 | ||
1062 | mDayLabelsT = &mDayLabelsW; | 1065 | mDayLabelsT = &mDayLabelsW; |
1063 | for (int i = 0; i < 7; i++) { | 1066 | for (int i = 0; i < 7; i++) { |
1064 | if (mWeekStartsMonday) { | 1067 | if (mWeekStartsMonday) { |
1065 | bool show = mShortDayLabelsW; | 1068 | bool show = mShortDayLabelsW; |
1066 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1069 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1067 | show = true; | 1070 | show = true; |
1068 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1071 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1069 | } else { | 1072 | } else { |
1070 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | 1073 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1071 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | 1074 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1072 | 1075 | ||
1073 | } | 1076 | } |
1074 | } | 1077 | } |
1075 | mDayLabelsT = &mDayLabels; | 1078 | mDayLabelsT = &mDayLabels; |
1076 | for (int i = 0; i < 7; i++) { | 1079 | for (int i = 0; i < 7; i++) { |
1077 | if (mWeekStartsMonday) { | 1080 | if (mWeekStartsMonday) { |
1078 | bool show = mShortDayLabelsM; | 1081 | bool show = mShortDayLabelsM; |
1079 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1082 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1080 | show = true; | 1083 | show = true; |
1081 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1084 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1082 | } else { | 1085 | } else { |
1083 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1086 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1084 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1087 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1085 | 1088 | ||
1086 | } | 1089 | } |
1087 | } | 1090 | } |
1088 | 1091 | ||
1089 | } | 1092 | } |
1090 | 1093 | ||
1091 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1094 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1092 | { | 1095 | { |
1093 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1096 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1094 | 1097 | ||
1095 | QPtrVector<MonthViewCell> *cells; | 1098 | QPtrVector<MonthViewCell> *cells; |
1096 | QPtrVector<QLabel> *dayLabels; | 1099 | QPtrVector<QLabel> *dayLabels; |
1097 | QPtrVector<KOWeekButton> *weekLabels; | 1100 | QPtrVector<KOWeekButton> *weekLabels; |
1098 | int weekNum = 6; | 1101 | int weekNum = 6; |
1099 | if ( mShowWeekView ) { | 1102 | if ( mShowWeekView ) { |
1100 | weekNum = 1; | 1103 | weekNum = 1; |
1101 | cells = &mCellsW; | 1104 | cells = &mCellsW; |
1102 | dayLabels = &mDayLabelsW; | 1105 | dayLabels = &mDayLabelsW; |
1103 | weekLabels = &mWeekLabelsW; | 1106 | weekLabels = &mWeekLabelsW; |
1104 | } else { | 1107 | } else { |
1105 | cells = &mCells; | 1108 | cells = &mCells; |
1106 | dayLabels = &mDayLabels; | 1109 | dayLabels = &mDayLabels; |
1107 | weekLabels = &mWeekLabels; | 1110 | weekLabels = &mWeekLabels; |
1108 | } | 1111 | } |
1109 | 1112 | ||
1110 | mStartDate = start; | 1113 | mStartDate = start; |
1111 | 1114 | ||
1112 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1115 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1113 | 1116 | ||
1114 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1117 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1115 | mStartDate = mStartDate.addDays( -1 ); | 1118 | mStartDate = mStartDate.addDays( -1 ); |
1116 | } | 1119 | } |
1117 | 1120 | ||
1118 | bool primary = false; | 1121 | bool primary = false; |
1119 | uint i; | 1122 | uint i; |
1120 | for( i = 0; i < (*cells).size(); ++i ) { | 1123 | for( i = 0; i < (*cells).size(); ++i ) { |
1121 | QDate date = mStartDate.addDays( i ); | 1124 | QDate date = mStartDate.addDays( i ); |
1122 | (*cells)[i]->setDate( date ); | 1125 | (*cells)[i]->setDate( date ); |
1123 | 1126 | ||
1124 | #ifndef KORG_NOPLUGINS | 1127 | #ifndef KORG_NOPLUGINS |
1125 | // add holiday, if present | 1128 | // add holiday, if present |
1126 | QString hstring(KOCore::self()->holiday(date)); | 1129 | QString hstring(KOCore::self()->holiday(date)); |
1127 | (*cells)[i]->setHoliday( hstring ); | 1130 | (*cells)[i]->setHoliday( hstring ); |
1128 | #endif | 1131 | #endif |
1129 | 1132 | ||
1130 | } | 1133 | } |
1131 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1134 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1132 | for( i = 0; i < weekNum; ++i ) { | 1135 | for( i = 0; i < weekNum; ++i ) { |
1133 | int wno; | 1136 | int wno; |
1134 | // remember, according to ISO 8601, the first week of the year is the | 1137 | // remember, according to ISO 8601, the first week of the year is the |
1135 | // first week that contains a thursday. Thus we must subtract off 4, | 1138 | // first week that contains a thursday. Thus we must subtract off 4, |
1136 | // not just 1. | 1139 | // not just 1. |
1137 | int dayOfYear = date.dayOfYear(); | 1140 | int dayOfYear = date.dayOfYear(); |
1138 | if (dayOfYear % 7 != 0) | 1141 | if (dayOfYear % 7 != 0) |
1139 | wno = dayOfYear / 7 + 1; | 1142 | wno = dayOfYear / 7 + 1; |
1140 | else | 1143 | else |
1141 | wno =dayOfYear / 7; | 1144 | wno =dayOfYear / 7; |
1142 | (*weekLabels)[i]->setWeekNum( wno ); | 1145 | (*weekLabels)[i]->setWeekNum( wno ); |
1143 | date = date.addDays( 7 ); | 1146 | date = date.addDays( 7 ); |
1144 | } | 1147 | } |
1145 | updateView(); | 1148 | updateView(); |
1146 | } | 1149 | } |
1147 | 1150 | ||
1148 | void KOMonthView::showEvents(QPtrList<Event>) | 1151 | void KOMonthView::showEvents(QPtrList<Event>) |
1149 | { | 1152 | { |
1150 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1153 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1151 | } | 1154 | } |
1152 | 1155 | ||
1153 | void KOMonthView::changeEventDisplay(Event *, int) | 1156 | void KOMonthView::changeEventDisplay(Event *, int) |
1154 | { | 1157 | { |
1155 | // this should be re-written to be much more efficient, but this | 1158 | // this should be re-written to be much more efficient, but this |
1156 | // quick-and-dirty-hack gets the job done for right now. | 1159 | // quick-and-dirty-hack gets the job done for right now. |
1157 | updateView(); | 1160 | updateView(); |
1158 | } | 1161 | } |
1159 | 1162 | ||
1160 | void KOMonthView::updateView() | 1163 | void KOMonthView::updateView() |
1161 | { | 1164 | { |
1162 | 1165 | ||
1163 | if ( !updatePossible ) | 1166 | if ( !updatePossible ) |
1164 | return; | 1167 | return; |
1165 | //QTime ti; | 1168 | //QTime ti; |
1166 | //ti.start(); | 1169 | //ti.start(); |
1167 | QPtrVector<MonthViewCell> *cells; | 1170 | QPtrVector<MonthViewCell> *cells; |
1168 | if ( mShowWeekView ) { | 1171 | if ( mShowWeekView ) { |
1169 | cells = &mCellsW; | 1172 | cells = &mCellsW; |
1170 | } else { | 1173 | } else { |
1171 | cells = &mCells; | 1174 | cells = &mCells; |
1172 | } | 1175 | } |
1173 | #if 1 | 1176 | #if 1 |
1174 | int i; | 1177 | int i; |
1175 | int timeSpan = (*cells).size()-1; | 1178 | int timeSpan = (*cells).size()-1; |
1176 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1179 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1177 | timeSpan = 6; | 1180 | timeSpan = 6; |
1178 | for( i = 0; i < timeSpan + 1; ++i ) { | 1181 | for( i = 0; i < timeSpan + 1; ++i ) { |
1179 | (*cells)[i]->startUpdateCell(); | 1182 | (*cells)[i]->startUpdateCell(); |
1180 | } | 1183 | } |
1181 | 1184 | ||
1182 | QPtrList<Event> events = calendar()->events(); | 1185 | QPtrList<Event> events = calendar()->events(); |
1183 | Event *event; | 1186 | Event *event; |
1184 | QDateTime dt; | 1187 | QDateTime dt; |
1185 | bool ok; | 1188 | bool ok; |
1186 | QDate endDate = mStartDate.addDays( timeSpan ); | 1189 | QDate endDate = mStartDate.addDays( timeSpan ); |
1187 | for( event = events.first(); event; event = events.next() ) { // for event | 1190 | for( event = events.first(); event; event = events.next() ) { // for event |
1188 | if ( event->doesRecur() ) { | 1191 | if ( event->doesRecur() ) { |
1189 | bool last; | 1192 | bool last; |
1190 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1193 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1191 | QDateTime incidenceEnd; | 1194 | QDateTime incidenceEnd; |
1192 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1195 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1193 | bool invalid = false; | 1196 | bool invalid = false; |
1194 | while( true ) { | 1197 | while( true ) { |
1195 | if ( incidenceStart.isValid() ) { | 1198 | if ( incidenceStart.isValid() ) { |
1196 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1199 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1197 | int st = incidenceStart.date().daysTo( endDate ); | 1200 | int st = incidenceStart.date().daysTo( endDate ); |
1198 | if ( st >= 0 ) { // start before timeend | 1201 | if ( st >= 0 ) { // start before timeend |
1199 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1202 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1200 | if ( end >= 0 ) { // end after timestart --- got one! | 1203 | if ( end >= 0 ) { // end after timestart --- got one! |
1201 | //normalize | 1204 | //normalize |
1202 | st = timeSpan - st; | 1205 | st = timeSpan - st; |
1203 | if ( st < 0 ) st = 0; | 1206 | if ( st < 0 ) st = 0; |
1204 | if ( end > timeSpan ) end = timeSpan; | 1207 | if ( end > timeSpan ) end = timeSpan; |
1205 | int iii; | 1208 | int iii; |
1206 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1209 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1207 | for ( iii = st;iii<= end;++iii) | 1210 | for ( iii = st;iii<= end;++iii) |
1208 | (*cells)[iii]->insertEvent( event ); | 1211 | (*cells)[iii]->insertEvent( event ); |
1209 | } | 1212 | } |
1210 | } | 1213 | } |
1211 | } else { | 1214 | } else { |
1212 | if ( invalid ) | 1215 | if ( invalid ) |
1213 | break; | 1216 | break; |
1214 | invalid = true; | 1217 | invalid = true; |
1215 | //qDebug("invalid %s", event->summary().latin1()); | 1218 | //qDebug("invalid %s", event->summary().latin1()); |
1216 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1219 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1217 | } | 1220 | } |
1218 | if ( last ) | 1221 | if ( last ) |
1219 | break; | 1222 | break; |
1220 | bool ok; | 1223 | bool ok; |
1221 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1224 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1222 | if ( ! ok ) | 1225 | if ( ! ok ) |
1223 | break; | 1226 | break; |
1224 | if ( incidenceStart.date() > endDate ) | 1227 | if ( incidenceStart.date() > endDate ) |
1225 | break; | 1228 | break; |
1226 | } | 1229 | } |
1227 | } else { // no recur | 1230 | } else { // no recur |
1228 | int st = event->dtStart().date().daysTo( endDate ); | 1231 | int st = event->dtStart().date().daysTo( endDate ); |
1229 | if ( st >= 0 ) { // start before timeend | 1232 | if ( st >= 0 ) { // start before timeend |
1230 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1233 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1231 | if ( end >= 0 ) { // end after timestart --- got one! | 1234 | if ( end >= 0 ) { // end after timestart --- got one! |
1232 | //normalize | 1235 | //normalize |
1233 | st = timeSpan - st; | 1236 | st = timeSpan - st; |
1234 | if ( st < 0 ) st = 0; | 1237 | if ( st < 0 ) st = 0; |
1235 | if ( end > timeSpan ) end = timeSpan; | 1238 | if ( end > timeSpan ) end = timeSpan; |
1236 | int iii; | 1239 | int iii; |
1237 | for ( iii = st;iii<= end;++iii) | 1240 | for ( iii = st;iii<= end;++iii) |
1238 | (*cells)[iii]->insertEvent( event ); | 1241 | (*cells)[iii]->insertEvent( event ); |
1239 | } | 1242 | } |
1240 | } | 1243 | } |
1241 | } | 1244 | } |
1242 | } | 1245 | } |
1243 | // insert due todos | 1246 | // insert due todos |
1244 | QPtrList<Todo> todos = calendar()->todos( ); | 1247 | QPtrList<Todo> todos = calendar()->todos( ); |
1245 | Todo *todo; | 1248 | Todo *todo; |
1246 | for(todo = todos.first(); todo; todo = todos.next()) { | 1249 | for(todo = todos.first(); todo; todo = todos.next()) { |
1247 | //insertTodo( todo ); | 1250 | //insertTodo( todo ); |
1248 | if ( todo->hasDueDate() ) { | 1251 | if ( todo->hasDueDate() ) { |
1249 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1252 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1250 | if ( day >= 0 && day < timeSpan + 1) { | 1253 | if ( day >= 0 && day < timeSpan + 1) { |
1251 | (*cells)[day]->insertTodo( todo ); | 1254 | (*cells)[day]->insertTodo( todo ); |
1252 | } | 1255 | } |
1253 | } | 1256 | } |
1254 | } | 1257 | } |
1255 | 1258 | ||
1256 | for( i = 0; i < timeSpan+1; ++i ) { | 1259 | for( i = 0; i < timeSpan+1; ++i ) { |
1257 | (*cells)[i]->finishUpdateCell(); | 1260 | (*cells)[i]->finishUpdateCell(); |
1258 | } | 1261 | } |
1259 | processSelectionChange(); | 1262 | processSelectionChange(); |
1260 | (*cells)[0]->setFocus(); | 1263 | (*cells)[0]->setFocus(); |
1261 | 1264 | ||
1262 | 1265 | ||
1263 | #else | 1266 | #else |
1264 | // old code | 1267 | // old code |
1265 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1268 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1266 | int i; | 1269 | int i; |
1267 | for( i = 0; i < (*cells).count(); ++i ) { | 1270 | for( i = 0; i < (*cells).count(); ++i ) { |
1268 | (*cells)[i]->updateCell(); | 1271 | (*cells)[i]->updateCell(); |
1269 | } | 1272 | } |
1270 | 1273 | ||
1271 | //qDebug("KOMonthView::updateView() "); | 1274 | //qDebug("KOMonthView::updateView() "); |
1272 | processSelectionChange(); | 1275 | processSelectionChange(); |
1273 | // qDebug("---------------------------------------------------------------------+ "); | 1276 | // qDebug("---------------------------------------------------------------------+ "); |
1274 | (*cells)[0]->setFocus(); | 1277 | (*cells)[0]->setFocus(); |
1275 | #endif | 1278 | #endif |
1276 | 1279 | ||
1277 | //qDebug("update time %d ", ti.elapsed()); | 1280 | //qDebug("update time %d ", ti.elapsed()); |
1278 | } | 1281 | } |
1279 | 1282 | ||
1280 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1283 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1281 | { | 1284 | { |
1282 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1285 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1283 | computeLayout(); | 1286 | computeLayout(); |
1284 | clPending = true; | 1287 | clPending = true; |
1285 | if ( mShowWeekView ) | 1288 | if ( mShowWeekView ) |
1286 | mCellsW[0]->setFocus(); | 1289 | mCellsW[0]->setFocus(); |
1287 | else | 1290 | else |
1288 | mCells[0]->setFocus(); | 1291 | mCells[0]->setFocus(); |
1289 | } | 1292 | } |
1290 | void KOMonthView::computeLayoutWeek() | 1293 | void KOMonthView::computeLayoutWeek() |
1291 | { | 1294 | { |
1292 | static int lastWid = 0; | 1295 | static int lastWid = 0; |
1293 | static int lastHei = 0; | 1296 | static int lastHei = 0; |
1294 | int daysToShow; | 1297 | int daysToShow; |
1295 | bool combinedSatSun = false; | 1298 | bool combinedSatSun = false; |
1296 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1299 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1297 | daysToShow = 6; | 1300 | daysToShow = 6; |
1298 | combinedSatSun = true; | 1301 | combinedSatSun = true; |
1299 | } | 1302 | } |
1300 | int tWid = topLevelWidget()->size().width(); | 1303 | int tWid = topLevelWidget()->size().width(); |
1301 | int tHei = topLevelWidget()->size().height(); | 1304 | int tHei = topLevelWidget()->size().height(); |
1302 | 1305 | ||
1303 | int wid = width();//e | 1306 | int wid = width();//e |
1304 | int hei = height()-1-mNavigatorBar->height(); | 1307 | int hei = height()-1-mNavigatorBar->height(); |
1305 | 1308 | ||
1306 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1309 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1307 | return; | 1310 | return; |
1308 | 1311 | ||
1309 | if ( lastWid == width() && lastHei == height() ) | 1312 | if ( lastWid == width() && lastHei == height() ) |
1310 | return; | 1313 | return; |
1311 | lastWid = width(); | 1314 | lastWid = width(); |
1312 | lastHei = height(); | 1315 | lastHei = height(); |
1313 | 1316 | ||
1314 | 1317 | ||
1315 | if ( wid < hei ) | 1318 | if ( wid < hei ) |
1316 | daysToShow = 2; | 1319 | daysToShow = 2; |
1317 | else | 1320 | else |
1318 | daysToShow = 3; | 1321 | daysToShow = 3; |
1319 | mShowSatSunComp = true; | 1322 | mShowSatSunComp = true; |
1320 | combinedSatSun = true; | 1323 | combinedSatSun = true; |
1321 | 1324 | ||
1322 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1325 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1323 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1326 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1324 | int weeklabelwid = fm.width( "888" ); | 1327 | int weeklabelwid = fm.width( "888" ); |
1325 | wid -= weeklabelwid; | 1328 | wid -= weeklabelwid; |
1326 | 1329 | ||
1327 | int colWid = wid / daysToShow; | 1330 | int colWid = wid / daysToShow; |
1328 | int lastCol = wid - ( colWid*6 ); | 1331 | int lastCol = wid - ( colWid*6 ); |
1329 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1332 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1330 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1333 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1331 | int colModulo = wid % daysToShow; | 1334 | int colModulo = wid % daysToShow; |
1332 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1335 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1333 | //qDebug("rowmod %d ", rowModulo); | 1336 | //qDebug("rowmod %d ", rowModulo); |
1334 | int i; | 1337 | int i; |
1335 | int x,y,w,h; | 1338 | int x,y,w,h; |
1336 | x= 0; | 1339 | x= 0; |
1337 | y= 0; | 1340 | y= 0; |
1338 | w = colWid; | 1341 | w = colWid; |
1339 | h = dayLabelHei ; | 1342 | h = dayLabelHei ; |
1340 | for ( i = 0; i < 7; i++) { | 1343 | for ( i = 0; i < 7; i++) { |
1341 | if ( i && !( i % daysToShow) && i < 6) { | 1344 | if ( i && !( i % daysToShow) && i < 6) { |
1342 | y += hei/(5-daysToShow); | 1345 | y += hei/(5-daysToShow); |
1343 | x = 0; | 1346 | x = 0; |
1344 | w = colWid; | 1347 | w = colWid; |
1345 | } | 1348 | } |
1346 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1349 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1347 | ++w; | 1350 | ++w; |
1348 | } | 1351 | } |
1349 | if ( i >= 5 ) { | 1352 | if ( i >= 5 ) { |
1350 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1353 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1351 | x -= (w/2 ); | 1354 | x -= (w/2 ); |
1352 | } | 1355 | } |
1353 | else | 1356 | else |
1354 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1357 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1355 | x += w; | 1358 | x += w; |
1356 | } | 1359 | } |
1357 | x= 0; | 1360 | x= 0; |
1358 | y= dayLabelHei; | 1361 | y= dayLabelHei; |
1359 | w = colWid; | 1362 | w = colWid; |
1360 | h = cellHei; | 1363 | h = cellHei; |
1361 | for ( i = 0; i < mCellsW.count(); ++i) { | 1364 | for ( i = 0; i < mCellsW.count(); ++i) { |
1362 | if ( i > 6 ) { | 1365 | if ( i > 6 ) { |
1363 | mCellsW[i]->hide(); | 1366 | mCellsW[i]->hide(); |
1364 | continue; | 1367 | continue; |
1365 | } | 1368 | } |
1366 | 1369 | ||
1367 | w = colWid; | 1370 | w = colWid; |
1368 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1371 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1369 | ++w; | 1372 | ++w; |
1370 | } | 1373 | } |
1371 | if ( i == (daysToShow-1-rowModulo)*7) | 1374 | if ( i == (daysToShow-1-rowModulo)*7) |
1372 | ++h; | 1375 | ++h; |
1373 | 1376 | ||
1374 | if ( i >= 5 ) { | 1377 | if ( i >= 5 ) { |
1375 | if ( i ==5 ) { | 1378 | if ( i ==5 ) { |
1376 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1379 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1377 | x -= w ;y += h/2; | 1380 | x -= w ;y += h/2; |
1378 | } else { | 1381 | } else { |
1379 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1382 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1380 | ++w; | 1383 | ++w; |
1381 | } | 1384 | } |
1382 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1385 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1383 | y -= h/2; | 1386 | y -= h/2; |
1384 | } | 1387 | } |
1385 | } else | 1388 | } else |
1386 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1389 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1387 | 1390 | ||
1388 | 1391 | ||
1389 | x += w; | 1392 | x += w; |
1390 | if ( x + w/2 > wid ) { | 1393 | if ( x + w/2 > wid ) { |
1391 | x = 0; | 1394 | x = 0; |
1392 | y += h+dayLabelHei ; | 1395 | y += h+dayLabelHei ; |
1393 | } | 1396 | } |
1394 | } | 1397 | } |
1395 | y= dayLabelHei; | 1398 | y= dayLabelHei; |
1396 | h = cellHei ; | 1399 | h = cellHei ; |
1397 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1400 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1398 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1401 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1399 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1402 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1400 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1403 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1401 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1404 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1402 | updateDayLabels(); | 1405 | updateDayLabels(); |
1403 | //bool forceUpdate = !updatePossible; | 1406 | //bool forceUpdate = !updatePossible; |
1404 | updatePossible = true; | 1407 | updatePossible = true; |
1405 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1408 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1406 | //if ( forceUpdate ) | 1409 | //if ( forceUpdate ) |
1407 | // updateView(); | 1410 | // updateView(); |
1408 | } | 1411 | } |
1409 | void KOMonthView::computeLayout() | 1412 | void KOMonthView::computeLayout() |
1410 | { | 1413 | { |
1411 | 1414 | ||
1412 | 1415 | ||
1413 | static int lastWid = 0; | 1416 | static int lastWid = 0; |
1414 | static int lastHei = 0; | 1417 | static int lastHei = 0; |
1415 | 1418 | ||
1416 | if ( mShowWeekView ){ | 1419 | if ( mShowWeekView ){ |
1417 | computeLayoutWeek(); | 1420 | computeLayoutWeek(); |
1418 | return; | 1421 | return; |
1419 | } | 1422 | } |
1420 | int daysToShow = 7; | 1423 | int daysToShow = 7; |
1421 | bool combinedSatSun = false; | 1424 | bool combinedSatSun = false; |
1422 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1425 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1423 | daysToShow = 6; | 1426 | daysToShow = 6; |
1424 | combinedSatSun = true; | 1427 | combinedSatSun = true; |
1425 | } | 1428 | } |
1426 | int tWid = topLevelWidget()->size().width(); | 1429 | int tWid = topLevelWidget()->size().width(); |
1427 | int tHei = topLevelWidget()->size().height(); | 1430 | int tHei = topLevelWidget()->size().height(); |
1428 | 1431 | ||
1429 | int wid = width();//e | 1432 | int wid = width();//e |
1430 | int hei = height()-1-mNavigatorBar->height(); | 1433 | int hei = height()-1-mNavigatorBar->height(); |
1431 | 1434 | ||
1432 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1435 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1433 | return; | 1436 | return; |
1434 | } | 1437 | } |
1435 | if ( lastWid == width() && lastHei == height() ){ | 1438 | if ( lastWid == width() && lastHei == height() ){ |
1436 | return; | 1439 | return; |
1437 | } | 1440 | } |
1438 | 1441 | ||
1439 | lastWid = width(); | 1442 | lastWid = width(); |
1440 | lastHei = height(); | 1443 | lastHei = height(); |
1441 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); | 1444 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); |
1442 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1445 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1443 | int weeklabelwid = fm.width( "888" ); | 1446 | int weeklabelwid = fm.width( "888" ); |
1444 | wid -= weeklabelwid; | 1447 | wid -= weeklabelwid; |
1445 | 1448 | ||
1446 | int colWid = wid / daysToShow; | 1449 | int colWid = wid / daysToShow; |
1447 | int lastCol = wid - ( colWid*6 ); | 1450 | int lastCol = wid - ( colWid*6 ); |
1448 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1451 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1449 | int cellHei = (hei - dayLabelHei) /6; | 1452 | int cellHei = (hei - dayLabelHei) /6; |
1450 | int colModulo = wid % daysToShow; | 1453 | int colModulo = wid % daysToShow; |
1451 | int rowModulo = (hei- dayLabelHei) % 6; | 1454 | int rowModulo = (hei- dayLabelHei) % 6; |
1452 | //qDebug("rowmod %d ", rowModulo); | 1455 | //qDebug("rowmod %d ", rowModulo); |
1453 | int i; | 1456 | int i; |
1454 | int x,y,w,h; | 1457 | int x,y,w,h; |
1455 | x= 0; | 1458 | x= 0; |
1456 | y= 0; | 1459 | y= 0; |
1457 | w = colWid; | 1460 | w = colWid; |
1458 | h = dayLabelHei ; | 1461 | h = dayLabelHei ; |
1459 | for ( i = 0; i < 7; i++) { | 1462 | for ( i = 0; i < 7; i++) { |
1460 | if ( i == daysToShow-colModulo ) | 1463 | if ( i == daysToShow-colModulo ) |
1461 | ++w; | 1464 | ++w; |
1462 | if ( combinedSatSun ) { | 1465 | if ( combinedSatSun ) { |
1463 | if ( i >= daysToShow-1 ) { | 1466 | if ( i >= daysToShow-1 ) { |
1464 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1467 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1465 | x -= w/2 ; | 1468 | x -= w/2 ; |
1466 | } | 1469 | } |
1467 | else | 1470 | else |
1468 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1471 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1469 | } else | 1472 | } else |
1470 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1473 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1471 | x += w; | 1474 | x += w; |
1472 | } | 1475 | } |
1473 | x= 0; | 1476 | x= 0; |
1474 | y= dayLabelHei; | 1477 | y= dayLabelHei; |
1475 | w = colWid; | 1478 | w = colWid; |
1476 | h = cellHei ; | 1479 | h = cellHei ; |
1477 | for ( i = 0; i < mCells.count(); ++i) { | 1480 | for ( i = 0; i < mCells.count(); ++i) { |
1478 | //qDebug("iii %d ", i); | 1481 | //qDebug("iii %d ", i); |
1479 | w = colWid; | 1482 | w = colWid; |
1480 | if ( ((i) % 7) >= 7-colModulo ) { | 1483 | if ( ((i) % 7) >= 7-colModulo ) { |
1481 | ++w; | 1484 | ++w; |
1482 | } | 1485 | } |
1483 | if ( i == (6-rowModulo)*7) | 1486 | if ( i == (6-rowModulo)*7) |
1484 | ++h; | 1487 | ++h; |
1485 | if ( combinedSatSun ) { | 1488 | if ( combinedSatSun ) { |
1486 | if ( (i)%7 >= daysToShow-1 ) { | 1489 | if ( (i)%7 >= daysToShow-1 ) { |
1487 | if ( (i)%7 == daysToShow-1 ) { | 1490 | if ( (i)%7 == daysToShow-1 ) { |
1488 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1491 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1489 | x -= w ;y += h/2; | 1492 | x -= w ;y += h/2; |
1490 | } else { | 1493 | } else { |
1491 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1494 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1492 | y -= h/2; | 1495 | y -= h/2; |
1493 | } | 1496 | } |
1494 | } else | 1497 | } else |
1495 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1498 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1496 | 1499 | ||
1497 | } | 1500 | } |
1498 | else | 1501 | else |
1499 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1502 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1500 | x += w; | 1503 | x += w; |
1501 | if ( x + w/2 > wid ) { | 1504 | if ( x + w/2 > wid ) { |
1502 | x = 0; | 1505 | x = 0; |
1503 | y += h; | 1506 | y += h; |
1504 | } | 1507 | } |
1505 | } | 1508 | } |
1506 | y= dayLabelHei; | 1509 | y= dayLabelHei; |
1507 | h = cellHei ; | 1510 | h = cellHei ; |
1508 | for ( i = 0; i < 6; i++) { | 1511 | for ( i = 0; i < 6; i++) { |
1509 | if ( i == (6-rowModulo)) | 1512 | if ( i == (6-rowModulo)) |
1510 | ++h; | 1513 | ++h; |
1511 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1514 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1512 | y += h; | 1515 | y += h; |
1513 | } | 1516 | } |
1514 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1517 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1515 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1518 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1516 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1519 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1517 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1520 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1518 | updateDayLabels(); | 1521 | updateDayLabels(); |
1519 | //bool forceUpdate = !updatePossible; | 1522 | //bool forceUpdate = !updatePossible; |
1520 | updatePossible = true; | 1523 | updatePossible = true; |
1521 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1524 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1522 | } | 1525 | } |
1523 | 1526 | ||
1524 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1527 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1525 | { | 1528 | { |
1526 | mContextMenu->showIncidencePopup(incidence); | 1529 | mContextMenu->showIncidencePopup(incidence); |
1527 | /* | 1530 | /* |
1528 | if( incidence && incidence->type() == "Event" ) { | 1531 | if( incidence && incidence->type() == "Event" ) { |
1529 | Event *event = static_cast<Event *>(incidence); | 1532 | Event *event = static_cast<Event *>(incidence); |
1530 | mContextMenu->showEventPopup(event); | 1533 | mContextMenu->showEventPopup(event); |
1531 | } else { | 1534 | } else { |
1532 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1535 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1533 | } | 1536 | } |
1534 | */ | 1537 | */ |
1535 | } | 1538 | } |
1536 | MonthViewCell * KOMonthView::selectedCell( ) | 1539 | MonthViewCell * KOMonthView::selectedCell( ) |
1537 | { | 1540 | { |
1538 | return mSelectedCell; | 1541 | return mSelectedCell; |
1539 | } | 1542 | } |
1540 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1543 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1541 | { | 1544 | { |
1542 | // qDebug("KOMonthView::setSelectedCell "); | 1545 | // qDebug("KOMonthView::setSelectedCell "); |
1543 | if ( mSelectedCell && mSelectedCell != cell ) { | 1546 | if ( mSelectedCell && mSelectedCell != cell ) { |
1544 | MonthViewCell * mvc = mSelectedCell; | 1547 | MonthViewCell * mvc = mSelectedCell; |
1545 | mSelectedCell = cell; | 1548 | mSelectedCell = cell; |
1546 | mvc->deselect(); | 1549 | mvc->deselect(); |
1547 | } else | 1550 | } else |
1548 | mSelectedCell = cell; | 1551 | mSelectedCell = cell; |
1549 | // if ( mSelectedCell ) | 1552 | // if ( mSelectedCell ) |
1550 | // mSelectedCell->select(); | 1553 | // mSelectedCell->select(); |
1551 | if ( !mSelectedCell ) | 1554 | if ( !mSelectedCell ) |
1552 | emit incidenceSelected( 0 ); | 1555 | emit incidenceSelected( 0 ); |
1553 | else | 1556 | else |
1554 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1557 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1555 | } | 1558 | } |
1556 | 1559 | ||
1557 | void KOMonthView::processSelectionChange() | 1560 | void KOMonthView::processSelectionChange() |
1558 | { | 1561 | { |
1559 | QPtrList<Incidence> incidences = selectedIncidences(); | 1562 | QPtrList<Incidence> incidences = selectedIncidences(); |
1560 | if (incidences.count() > 0) { | 1563 | if (incidences.count() > 0) { |
1561 | emit incidenceSelected( incidences.first() ); | 1564 | emit incidenceSelected( incidences.first() ); |
1562 | } else { | 1565 | } else { |
1563 | emit incidenceSelected( 0 ); | 1566 | emit incidenceSelected( 0 ); |
1564 | } | 1567 | } |
1565 | } | 1568 | } |
1566 | 1569 | ||
1567 | void KOMonthView::clearSelection() | 1570 | void KOMonthView::clearSelection() |
1568 | { | 1571 | { |
1569 | if ( mSelectedCell ) { | 1572 | if ( mSelectedCell ) { |
1570 | mSelectedCell->deselect(); | 1573 | mSelectedCell->deselect(); |
1571 | mSelectedCell = 0; | 1574 | mSelectedCell = 0; |
1572 | } | 1575 | } |
1573 | } | 1576 | } |
1574 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1577 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1575 | { | 1578 | { |
1576 | //qDebug("KOMonthView::keyPressEvent "); | 1579 | //qDebug("KOMonthView::keyPressEvent "); |
1577 | switch(e->key()) { | 1580 | switch(e->key()) { |
1578 | case Key_Up: | 1581 | case Key_Up: |
1579 | { | 1582 | { |
1580 | emit prevMonth(); | 1583 | emit prevMonth(); |
1581 | if ( mShowWeekView ) | 1584 | if ( mShowWeekView ) |
1582 | mCellsW[0]->setFocus(); | 1585 | mCellsW[0]->setFocus(); |
1583 | else | 1586 | else |
1584 | mCells[0]->setFocus(); | 1587 | mCells[0]->setFocus(); |
1585 | } | 1588 | } |
1586 | e->accept(); | 1589 | e->accept(); |
1587 | break; | 1590 | break; |
1588 | case Key_Down: | 1591 | case Key_Down: |
1589 | { | 1592 | { |
1590 | emit nextMonth(); | 1593 | emit nextMonth(); |
1591 | if ( mShowWeekView ) | 1594 | if ( mShowWeekView ) |
1592 | mCellsW[0]->setFocus(); | 1595 | mCellsW[0]->setFocus(); |
1593 | else | 1596 | else |
1594 | mCells[0]->setFocus(); | 1597 | mCells[0]->setFocus(); |
1595 | 1598 | ||
1596 | } | 1599 | } |
1597 | e->accept(); | 1600 | e->accept(); |
1598 | break; | 1601 | break; |
1599 | case Key_Return: | 1602 | case Key_Return: |
1600 | case Key_Enter: | 1603 | case Key_Enter: |
1601 | { | 1604 | { |
1602 | selectInternalWeekNum ( currentWeek() ); | 1605 | selectInternalWeekNum ( currentWeek() ); |
1603 | } | 1606 | } |
1604 | e->accept(); | 1607 | e->accept(); |
1605 | break; | 1608 | break; |
1606 | default: | 1609 | default: |
1607 | e->ignore(); | 1610 | e->ignore(); |
1608 | break; | 1611 | break; |
1609 | } | 1612 | } |
1610 | } | 1613 | } |
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp index 391b3bb..18dc656 100644 --- a/korganizer/kowhatsnextview.cpp +++ b/korganizer/kowhatsnextview.cpp | |||
@@ -1,768 +1,774 @@ | |||
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 | 19 | ||
20 | #include <qlayout.h> | 20 | #include <qlayout.h> |
21 | #include <qtextbrowser.h> | 21 | #include <qtextbrowser.h> |
22 | #include <qtextcodec.h> | 22 | #include <qtextcodec.h> |
23 | #include <qfileinfo.h> | 23 | #include <qfileinfo.h> |
24 | #include <qlabel.h> | 24 | #include <qlabel.h> |
25 | 25 | ||
26 | #include <qapplication.h> | 26 | #include <qapplication.h> |
27 | #ifdef DESKTOP_VERSION | 27 | #ifdef DESKTOP_VERSION |
28 | #include <qpaintdevicemetrics.h> | 28 | #include <qpaintdevicemetrics.h> |
29 | #endif | 29 | #endif |
30 | #include <kglobal.h> | 30 | #include <kglobal.h> |
31 | #include <klocale.h> | 31 | #include <klocale.h> |
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <kiconloader.h> | 33 | #include <kiconloader.h> |
34 | #include <kmessagebox.h> | 34 | #include <kmessagebox.h> |
35 | 35 | ||
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOPRINTER | 38 | #ifndef KORG_NOPRINTER |
39 | #include "calprinter.h" | 39 | #include "calprinter.h" |
40 | #endif | 40 | #endif |
41 | #include "koglobals.h" | 41 | #include "koglobals.h" |
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "koeventviewerdialog.h" | 43 | #include "koeventviewerdialog.h" |
44 | #include <qstylesheet.h> | 44 | #include <qstylesheet.h> |
45 | #include "kowhatsnextview.h" | 45 | #include "kowhatsnextview.h" |
46 | using namespace KOrg; | 46 | using namespace KOrg; |
47 | 47 | ||
48 | void WhatsNextTextBrowser::setSource(const QString& n) | 48 | void WhatsNextTextBrowser::setSource(const QString& n) |
49 | { | 49 | { |
50 | 50 | ||
51 | if (n.startsWith("event:")) { | 51 | if (n.startsWith("event:")) { |
52 | emit showIncidence(n); | 52 | emit showIncidence(n); |
53 | return; | 53 | return; |
54 | } else if (n.startsWith("todo:")) { | 54 | } else if (n.startsWith("todo:")) { |
55 | emit showIncidence(n); | 55 | emit showIncidence(n); |
56 | return; | 56 | return; |
57 | } else { | 57 | } else { |
58 | QTextBrowser::setSource(n); | 58 | QTextBrowser::setSource(n); |
59 | } | 59 | } |
60 | } | 60 | } |
61 | void WhatsNextTextBrowser::printMe() | 61 | void WhatsNextTextBrowser::printMe() |
62 | { | 62 | { |
63 | #ifdef DESKTOP_VERSION | 63 | #ifdef DESKTOP_VERSION |
64 | QPrinter printer; | 64 | QPrinter printer; |
65 | if (!printer.setup() ) | 65 | if (!printer.setup() ) |
66 | return; | 66 | return; |
67 | QPainter p; | 67 | QPainter p; |
68 | p.begin ( &printer ); | 68 | p.begin ( &printer ); |
69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); | 69 | QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); |
70 | float dx, dy; | 70 | float dx, dy; |
71 | int wid = (m.width() * 9)/10; | 71 | int wid = (m.width() * 9)/10; |
72 | dx = (float) wid/(float)contentsWidth (); | 72 | dx = (float) wid/(float)contentsWidth (); |
73 | dy = (float)(m.height()) / (float)contentsHeight (); | 73 | dy = (float)(m.height()) / (float)contentsHeight (); |
74 | float scale; | 74 | float scale; |
75 | // scale to fit the width or height of the paper | 75 | // scale to fit the width or height of the paper |
76 | if ( dx < dy ) | 76 | if ( dx < dy ) |
77 | scale = dx; | 77 | scale = dx; |
78 | else | 78 | else |
79 | scale = dy; | 79 | scale = dy; |
80 | p.translate( m.width()/10,0 ); | 80 | p.translate( m.width()/10,0 ); |
81 | p.scale( scale, scale ); | 81 | p.scale( scale, scale ); |
82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); | 82 | drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); |
83 | p.end(); | 83 | p.end(); |
84 | #endif | 84 | #endif |
85 | } | 85 | } |
86 | 86 | ||
87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, | 87 | KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, |
88 | const char *name) | 88 | const char *name) |
89 | : KOrg::BaseView(calendar, parent, name) | 89 | : KOrg::BaseView(calendar, parent, name) |
90 | { | 90 | { |
91 | // mDateLabel = | 91 | // mDateLabel = |
92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); | 92 | // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); |
93 | // mDateLabel->setMargin(2); | 93 | // mDateLabel->setMargin(2); |
94 | // mDateLabel->setAlignment(AlignCenter); | 94 | // mDateLabel->setAlignment(AlignCenter); |
95 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 95 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
96 | mView = new WhatsNextTextBrowser(this); | 96 | mView = new WhatsNextTextBrowser(this); |
97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); | 97 | connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); |
98 | QStyleSheet* stsh = mView->styleSheet(); | 98 | QStyleSheet* stsh = mView->styleSheet(); |
99 | QStyleSheetItem * style ; | 99 | QStyleSheetItem * style ; |
100 | style = stsh->item ("h2" ); | 100 | style = stsh->item ("h2" ); |
101 | if ( style ) { | 101 | if ( style ) { |
102 | style->setMargin(QStyleSheetItem::MarginAll,0); | 102 | style->setMargin(QStyleSheetItem::MarginAll,0); |
103 | } | 103 | } |
104 | style = stsh->item ("h3" ); | 104 | style = stsh->item ("h3" ); |
105 | if ( style ) { | 105 | if ( style ) { |
106 | style->setMargin(QStyleSheetItem::MarginAll,0); | 106 | style->setMargin(QStyleSheetItem::MarginAll,0); |
107 | } | 107 | } |
108 | mEventViewer = 0; | 108 | mEventViewer = 0; |
109 | 109 | ||
110 | QBoxLayout *topLayout = new QVBoxLayout(this); | 110 | QBoxLayout *topLayout = new QVBoxLayout(this); |
111 | // topLayout->addWidget(mDateLabel); | 111 | // topLayout->addWidget(mDateLabel); |
112 | topLayout->addWidget(mView); | 112 | topLayout->addWidget(mView); |
113 | mTimer = new QTimer( this ); | 113 | mTimer = new QTimer( this ); |
114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); | 114 | connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); |
115 | 115 | ||
116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 116 | connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); | 117 | connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); |
118 | } | 118 | } |
119 | 119 | ||
120 | KOWhatsNextView::~KOWhatsNextView() | 120 | KOWhatsNextView::~KOWhatsNextView() |
121 | { | 121 | { |
122 | } | 122 | } |
123 | 123 | ||
124 | int KOWhatsNextView::maxDatesHint() | 124 | int KOWhatsNextView::maxDatesHint() |
125 | { | 125 | { |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
129 | int KOWhatsNextView::currentDateCount() | 129 | int KOWhatsNextView::currentDateCount() |
130 | { | 130 | { |
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | 133 | ||
134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() | 134 | QPtrList<Incidence> KOWhatsNextView::selectedIncidences() |
135 | { | 135 | { |
136 | QPtrList<Incidence> eventList; | 136 | QPtrList<Incidence> eventList; |
137 | 137 | ||
138 | return eventList; | 138 | return eventList; |
139 | } | 139 | } |
140 | 140 | ||
141 | void KOWhatsNextView::printMe() | 141 | void KOWhatsNextView::printMe() |
142 | { | 142 | { |
143 | #ifdef DESKTOP_VERSION | 143 | #ifdef DESKTOP_VERSION |
144 | mView->printMe(); | 144 | mView->printMe(); |
145 | #endif | 145 | #endif |
146 | } | 146 | } |
147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 147 | void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
148 | const QDate &td) | 148 | const QDate &td) |
149 | { | 149 | { |
150 | #ifndef KORG_NOPRINTER | 150 | #ifndef KORG_NOPRINTER |
151 | calPrinter->preview(CalPrinter::Day, fd, td); | 151 | calPrinter->preview(CalPrinter::Day, fd, td); |
152 | #endif | 152 | #endif |
153 | } | 153 | } |
154 | void KOWhatsNextView::updateConfig() | 154 | void KOWhatsNextView::updateConfig() |
155 | { | 155 | { |
156 | setFont( KOPrefs::instance()->mWhatsNextFont ); | 156 | setFont( KOPrefs::instance()->mWhatsNextFont ); |
157 | updateView(); | 157 | updateView(); |
158 | 158 | ||
159 | } | 159 | } |
160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) | 160 | void KOWhatsNextView::showEvent ( QShowEvent * e ) |
161 | { | 161 | { |
162 | //qDebug("KOWhatsNextView::showEvent "); | 162 | //qDebug("KOWhatsNextView::showEvent "); |
163 | restartTimer(); | 163 | restartTimer(); |
164 | QWidget::showEvent ( e ); | 164 | QWidget::showEvent ( e ); |
165 | } | 165 | } |
166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) | 166 | void KOWhatsNextView::hideEvent ( QHideEvent * e) |
167 | { | 167 | { |
168 | //qDebug(" KOWhatsNextView::hideEvent"); | 168 | //qDebug(" KOWhatsNextView::hideEvent"); |
169 | mTimer->stop(); | 169 | mTimer->stop(); |
170 | QWidget::hideEvent ( e ); | 170 | QWidget::hideEvent ( e ); |
171 | } | 171 | } |
172 | void KOWhatsNextView::restartTimer() | 172 | void KOWhatsNextView::restartTimer() |
173 | { | 173 | { |
174 | //qDebug("KOWhatsNextView::restartTimer() "); | 174 | //qDebug("KOWhatsNextView::restartTimer() "); |
175 | mTimer->start( 300000 ); | 175 | mTimer->start( 300000 ); |
176 | //mTimer->start( 5000 ); | 176 | //mTimer->start( 5000 ); |
177 | } | 177 | } |
178 | void KOWhatsNextView::updateView() | 178 | void KOWhatsNextView::updateView() |
179 | { | 179 | { |
180 | //qDebug("KOWhatsNextView::updateView() "); | 180 | //qDebug("KOWhatsNextView::updateView() "); |
181 | if ( mTimer->isActive() ) | 181 | if ( mTimer->isActive() ) |
182 | restartTimer(); | 182 | restartTimer(); |
183 | //qDebug("KOWhatsNextView::updateView() "); | 183 | //qDebug("KOWhatsNextView::updateView() "); |
184 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); | 184 | // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); |
185 | KIconLoader kil("korganizer"); | 185 | KIconLoader kil("korganizer"); |
186 | QString ipath;// = new QString(); | 186 | QString ipath;// = new QString(); |
187 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); | 187 | // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); |
188 | //<big><big><strong>" + date + "</strong></big></big>\n"; | 188 | //<big><big><strong>" + date + "</strong></big></big>\n"; |
189 | mText = "<table width=\"100%\">\n"; | 189 | mText = "<table width=\"100%\">\n"; |
190 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 190 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
191 | #ifdef DESKTOP_VERSION | 191 | #ifdef DESKTOP_VERSION |
192 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; | 192 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; |
193 | #else | 193 | #else |
194 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 194 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
195 | #endif | 195 | #endif |
196 | // mText += "<img src=\""; | 196 | // mText += "<img src=\""; |
197 | // mText += ipath; | 197 | // mText += ipath; |
198 | // mText += "\">"; | 198 | // mText += "\">"; |
199 | mEventDate = QDate::currentDate(); | 199 | mEventDate = QDate::currentDate(); |
200 | #ifdef DESKTOP_VERSION | 200 | #ifdef DESKTOP_VERSION |
201 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; | 201 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; |
202 | #else | 202 | #else |
203 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; | 203 | mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; |
204 | #endif | 204 | #endif |
205 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 205 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
206 | int iii; | 206 | int iii; |
207 | mTodos.clear(); | 207 | mTodos.clear(); |
208 | QPtrList<Event> events; | 208 | QPtrList<Event> events; |
209 | QPtrList<Todo> todos = calendar()->todos(); | 209 | QPtrList<Todo> todos = calendar()->todos(); |
210 | Todo * todo; | 210 | Todo * todo; |
211 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; | 211 | //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; |
212 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; | 212 | int daysToShow = KOPrefs::instance()->mWhatsNextDays ; |
213 | bool itemAdded = false; | 213 | bool itemAdded = false; |
214 | for ( iii = 0; iii < daysToShow; ++iii ) { | 214 | for ( iii = 0; iii < daysToShow; ++iii ) { |
215 | QString date; | 215 | QString date; |
216 | itemAdded = false; | 216 | itemAdded = false; |
217 | events = calendar()->events( mEventDate, true ); | 217 | events = calendar()->events( mEventDate, true ); |
218 | 218 | ||
219 | if ( iii == 0 ) { // today !!! | 219 | if ( iii == 0 ) { // today !!! |
220 | todo = todos.first(); | 220 | todo = todos.first(); |
221 | while(todo) { | 221 | while(todo) { |
222 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { | 222 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { |
223 | if ( ! itemAdded ) { | 223 | if ( ! itemAdded ) { |
224 | appendDay ( iii, mEventDate ); | 224 | appendDay ( iii, mEventDate ); |
225 | //itemAdded = true; | 225 | //itemAdded = true; |
226 | 226 | ||
227 | } //bool reply=false, bool notRed = true, bool appendTable = false); | 227 | } //bool reply=false, bool notRed = true, bool appendTable = false); |
228 | appendEvent(todo, false, false, !itemAdded ); | 228 | appendEvent(todo, false, false, !itemAdded ); |
229 | itemAdded = true; | 229 | itemAdded = true; |
230 | } | 230 | } |
231 | todo = todos.next(); | 231 | todo = todos.next(); |
232 | } | 232 | } |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | if (events.count() > 0) { | 236 | if (events.count() > 0) { |
237 | // mText += "<p></p>"; | 237 | // mText += "<p></p>"; |
238 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 238 | // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
239 | // mText += "<h2>"; | 239 | // mText += "<h2>"; |
240 | //mText += " <img src=\""; | 240 | //mText += " <img src=\""; |
241 | //mText += ipath; | 241 | //mText += ipath; |
242 | //mText += "\">"; | 242 | //mText += "\">"; |
243 | if ( ! itemAdded ) { | 243 | if ( ! itemAdded ) { |
244 | appendDay ( iii, mEventDate ); | 244 | appendDay ( iii, mEventDate ); |
245 | 245 | ||
246 | } | 246 | } |
247 | // for first day (iii == 0) | 247 | // for first day (iii == 0) |
248 | // we may have syncevents, or events in the past, which maybe should not be diaplayed | 248 | // we may have syncevents, or events in the past, which maybe should not be diaplayed |
249 | // for that reason we cannot append <table> in appendDay () for iii == 0 | 249 | // for that reason we cannot append <table> in appendDay () for iii == 0 |
250 | // we must append it in the first successful call of appendEvent() | 250 | // we must append it in the first successful call of appendEvent() |
251 | Event *ev = events.first(); | 251 | Event *ev = events.first(); |
252 | while(ev) { | 252 | while(ev) { |
253 | //qDebug("+++++event append %s", ev->summary().latin1()); | 253 | //qDebug("+++++event append %s", ev->summary().latin1()); |
254 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { | 254 | if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { |
255 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) | 255 | if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) |
256 | itemAdded = true; | 256 | itemAdded = true; |
257 | } | 257 | } |
258 | ev = events.next(); | 258 | ev = events.next(); |
259 | } | 259 | } |
260 | 260 | ||
261 | //mText += "</table>\n"; | 261 | //mText += "</table>\n"; |
262 | } | 262 | } |
263 | 263 | ||
264 | todo = todos.first(); | 264 | todo = todos.first(); |
265 | while(todo) { | 265 | while(todo) { |
266 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { | 266 | if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { |
267 | if ( ! itemAdded ) { | 267 | if ( ! itemAdded ) { |
268 | appendDay ( iii, mEventDate ); | 268 | appendDay ( iii, mEventDate ); |
269 | //itemAdded = true; | 269 | //itemAdded = true; |
270 | } | 270 | } |
271 | appendEvent(todo, false , iii!= 0,!itemAdded); | 271 | appendEvent(todo, false , iii!= 0,!itemAdded); |
272 | itemAdded = true; | 272 | itemAdded = true; |
273 | } | 273 | } |
274 | todo = todos.next(); | 274 | todo = todos.next(); |
275 | } | 275 | } |
276 | if ( !itemAdded && iii == 0 ) { | 276 | if ( !itemAdded && iii == 0 ) { |
277 | // appendDay ( iii, mEventDate ); | 277 | // appendDay ( iii, mEventDate ); |
278 | //mText += "<table>"; | 278 | //mText += "<table>"; |
279 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; | 279 | // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; |
280 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; | 280 | mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; |
281 | //mText +="</table>"; | 281 | //mText +="</table>"; |
282 | } | 282 | } |
283 | if ( itemAdded ) | 283 | if ( itemAdded ) |
284 | mText += "</table>\n"; | 284 | mText += "</table>\n"; |
285 | mEventDate = mEventDate.addDays( 1 ); | 285 | mEventDate = mEventDate.addDays( 1 ); |
286 | } | 286 | } |
287 | 287 | ||
288 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; | 288 | int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; |
289 | if (todos.count() > 0 && topmostPrios > 0 ) { | 289 | if (todos.count() > 0 && topmostPrios > 0 ) { |
290 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 290 | // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
291 | // mText += "<h2>"; | 291 | // mText += "<h2>"; |
292 | //<img src=\""; | 292 | //<img src=\""; |
293 | // mText += ipath; | 293 | // mText += ipath; |
294 | // mText += "\">"; | 294 | // mText += "\">"; |
295 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; | 295 | // mText += i18n("Overdue To-Do:") + "</h2>\n"; |
296 | 296 | ||
297 | //mText += "<ul>\n"; | 297 | //mText += "<ul>\n"; |
298 | bool gotone = false; | 298 | bool gotone = false; |
299 | int priority = 1; | 299 | int priority = 1; |
300 | int priosFound = 0; | 300 | int priosFound = 0; |
301 | #ifdef DESKTOP_VERSION | 301 | #ifdef DESKTOP_VERSION |
302 | mText +="<p></p>"; | 302 | mText +="<p></p>"; |
303 | #endif | 303 | #endif |
304 | 304 | ||
305 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; | 305 | mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; |
306 | mText += "<ul>\n"; | 306 | mText += "<ul>\n"; |
307 | while (!gotone && priority<6) { | 307 | while (!gotone && priority<6) { |
308 | todo = todos.first(); | 308 | todo = todos.first(); |
309 | while(todo) { | 309 | while(todo) { |
310 | if (!todo->isCompleted() && (todo->priority() == priority) ) { | 310 | if (!todo->isCompleted() && (todo->priority() == priority) ) { |
311 | if ( appendTodo(todo) ) | 311 | if ( appendTodo(todo) ) |
312 | gotone = true; | 312 | gotone = true; |
313 | } | 313 | } |
314 | todo = todos.next(); | 314 | todo = todos.next(); |
315 | } | 315 | } |
316 | if ( gotone ) { | 316 | if ( gotone ) { |
317 | gotone = false; | 317 | gotone = false; |
318 | ++priosFound; | 318 | ++priosFound; |
319 | if ( priosFound == topmostPrios ) | 319 | if ( priosFound == topmostPrios ) |
320 | break; | 320 | break; |
321 | } | 321 | } |
322 | priority++; | 322 | priority++; |
323 | // kdDebug() << "adding the todos..." << endl; | 323 | // kdDebug() << "adding the todos..." << endl; |
324 | } | 324 | } |
325 | mText += "</ul>\n"; | 325 | mText += "</ul>\n"; |
326 | } | 326 | } |
327 | 327 | ||
328 | int replys = 0; | 328 | int replys = 0; |
329 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); | 329 | events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); |
330 | if (events.count() > 0) { | 330 | if (events.count() > 0) { |
331 | Event *ev = events.first(); | 331 | Event *ev = events.first(); |
332 | while(ev) { | 332 | while(ev) { |
333 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 333 | Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
334 | if (me!=0) { | 334 | if (me!=0) { |
335 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 335 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
336 | if (replys == 0) { | 336 | if (replys == 0) { |
337 | mText += "<p></p>"; | 337 | mText += "<p></p>"; |
338 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); | 338 | // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); |
339 | //mText += "<h2>"; | 339 | //mText += "<h2>"; |
340 | //<img src=\""; | 340 | //<img src=\""; |
341 | // mText += ipath; | 341 | // mText += ipath; |
342 | // mText += "\">"; | 342 | // mText += "\">"; |
343 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; | 343 | //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; |
344 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 344 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
345 | mText += "<table>\n"; | 345 | mText += "<table>\n"; |
346 | } | 346 | } |
347 | replys++; | 347 | replys++; |
348 | appendEvent(ev,true); | 348 | appendEvent(ev,true); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | ev = events.next(); | 351 | ev = events.next(); |
352 | } | 352 | } |
353 | } | 353 | } |
354 | todos = calendar()->todos(); | 354 | todos = calendar()->todos(); |
355 | if (todos.count() > 0) { | 355 | if (todos.count() > 0) { |
356 | Todo *to = todos.first(); | 356 | Todo *to = todos.first(); |
357 | while(to) { | 357 | while(to) { |
358 | if ( !to->isCompleted() ){ | 358 | if ( !to->isCompleted() ){ |
359 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 359 | Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
360 | if (me!=0) { | 360 | if (me!=0) { |
361 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { | 361 | if (me->status()==Attendee::NeedsAction && me->RSVP()) { |
362 | if (replys == 0) { | 362 | if (replys == 0) { |
363 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; | 363 | mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; |
364 | mText += "<table>\n"; | 364 | mText += "<table>\n"; |
365 | } | 365 | } |
366 | replys++; | 366 | replys++; |
367 | appendEvent(to, true); | 367 | appendEvent(to, true); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | } | 370 | } |
371 | to = todos.next(); | 371 | to = todos.next(); |
372 | } | 372 | } |
373 | } | 373 | } |
374 | if (replys > 0 ) mText += "</table>\n"; | 374 | if (replys > 0 ) mText += "</table>\n"; |
375 | 375 | ||
376 | 376 | ||
377 | mText += "</td></tr>\n</table>\n"; | 377 | mText += "</td></tr>\n</table>\n"; |
378 | 378 | ||
379 | mView->setText(mText); | 379 | mView->setText(mText); |
380 | mView->setFocus(); | 380 | mView->setFocus(); |
381 | 381 | ||
382 | // QPixmap bPix = SmallIcon( "back" ); | 382 | // QPixmap bPix = SmallIcon( "back" ); |
383 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); | 383 | // qDebug("xxxxxxxxxxxxxxxxxxxxx "); |
384 | // QWidget* test = new QWidget(); | 384 | // QWidget* test = new QWidget(); |
385 | // test->setBackgroundMode(FixedPixmap ); | 385 | // test->setBackgroundMode(FixedPixmap ); |
386 | // test->setBackgroundPixmap ( bPix ); | 386 | // test->setBackgroundPixmap ( bPix ); |
387 | // test->resize( 300, 400 ); | 387 | // test->resize( 300, 400 ); |
388 | // test->show(); | 388 | // test->show(); |
389 | // mView->setBackgroundMode(FixedPixmap ); | 389 | // mView->setBackgroundMode(FixedPixmap ); |
390 | // mView->setBackgroundPixmap ( bPix ); | 390 | // mView->setBackgroundPixmap ( bPix ); |
391 | // qDebug("%s ",mText.latin1()); | 391 | // qDebug("%s ",mText.latin1()); |
392 | } | 392 | } |
393 | 393 | ||
394 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) | 394 | void KOWhatsNextView::appendDay( int i, QDate eventDate ) |
395 | { | 395 | { |
396 | QString date; | 396 | QString date; |
397 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); | 397 | QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); |
398 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { | 398 | if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { |
399 | if ( i == 0 ) { | 399 | if ( i == 0 ) { |
400 | //mText += "<table>\n"; | 400 | //mText += "<table>\n"; |
401 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; | 401 | return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; |
402 | } | 402 | } |
403 | else if ( i == 1 ) | 403 | else if ( i == 1 ) |
404 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; | 404 | date = "<em><font color=\"#000080\">" + day + "</font></em>" ; |
405 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; | 405 | else date = "<em><font color=\"#000080\">" + day + "</font></em>"; |
406 | mText += "<h2>" + date + "</h2>\n"; | 406 | mText += "<h2>" + date + "</h2>\n"; |
407 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 407 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
408 | mText += "<table>\n"; | 408 | mText += "<table>\n"; |
409 | 409 | ||
410 | 410 | ||
411 | 411 | ||
412 | } else { | 412 | } else { |
413 | if ( i == 0 ) { | 413 | if ( i == 0 ) { |
414 | //mText += "<table>\n"; | 414 | //mText += "<table>\n"; |
415 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; | 415 | return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; |
416 | } | 416 | } |
417 | 417 | ||
418 | #ifdef DESKTOP_VERSION | 418 | #ifdef DESKTOP_VERSION |
419 | else if ( i == 1 ) { | 419 | else if ( i == 1 ) { |
420 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; | 420 | date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; |
421 | } | 421 | } |
422 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; | 422 | else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; |
423 | #else | 423 | #else |
424 | else if ( i == 1 ) { | 424 | else if ( i == 1 ) { |
425 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; | 425 | date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; |
426 | } | 426 | } |
427 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; | 427 | else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; |
428 | 428 | ||
429 | #endif | 429 | #endif |
430 | mText += "<h2>" + date + "</h2>\n"; | 430 | mText += "<h2>" + date + "</h2>\n"; |
431 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; | 431 | //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; |
432 | mText += "<table>\n"; | 432 | mText += "<table>\n"; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
436 | 436 | ||
437 | void KOWhatsNextView::showDates(const QDate &, const QDate &) | 437 | void KOWhatsNextView::showDates(const QDate &, const QDate &) |
438 | { | 438 | { |
439 | updateView(); | 439 | updateView(); |
440 | } | 440 | } |
441 | 441 | ||
442 | void KOWhatsNextView::showEvents(QPtrList<Event>) | 442 | void KOWhatsNextView::showEvents(QPtrList<Event>) |
443 | { | 443 | { |
444 | } | 444 | } |
445 | 445 | ||
446 | void KOWhatsNextView::changeEventDisplay(Event *, int action) | 446 | void KOWhatsNextView::changeEventDisplay(Event *, int action) |
447 | { | 447 | { |
448 | switch(action) { | 448 | switch(action) { |
449 | case KOGlobals::EVENTADDED: | 449 | case KOGlobals::EVENTADDED: |
450 | updateView(); | 450 | updateView(); |
451 | break; | 451 | break; |
452 | case KOGlobals::EVENTEDITED: | 452 | case KOGlobals::EVENTEDITED: |
453 | updateView(); | 453 | updateView(); |
454 | break; | 454 | break; |
455 | case KOGlobals::EVENTDELETED: | 455 | case KOGlobals::EVENTDELETED: |
456 | updateView(); | 456 | updateView(); |
457 | break; | 457 | break; |
458 | default: | 458 | default: |
459 | updateView(); | 459 | updateView(); |
460 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; | 460 | kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
464 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) | 464 | bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) |
465 | { | 465 | { |
466 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) | 466 | if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) |
467 | return false; | 467 | return false; |
468 | QDateTime cdt = QDateTime::currentDateTime(); | 468 | QDateTime cdt = QDateTime::currentDateTime(); |
469 | QDateTime noc; | 469 | QDateTime noc; |
470 | QString tempText; | 470 | QString tempText; |
471 | if ( appendTable && !notRed ) { | 471 | if ( appendTable && !notRed ) { |
472 | tempText = "<table>"; | 472 | tempText = "<table>"; |
473 | } | 473 | } |
474 | bool ok = true; | 474 | bool ok = true; |
475 | if ( reply ) { | 475 | if ( reply ) { |
476 | noc = ev->getNextOccurence( cdt, &ok ); | 476 | noc = ev->getNextOccurence( cdt, &ok ); |
477 | if (! ok && ev->type() == "Event") | 477 | if (! ok && ev->type() == "Event") |
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | bool bDay = false; | 480 | bool bDay = false; |
481 | if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) | 481 | if ( ev->categories().contains( i18n("Birthday") ) || ev->categories().contains( i18n("Anniversary") ) ) |
482 | bDay = true; | 482 | bDay = true; |
483 | tempText += "<tr><td><b>"; | 483 | tempText += "<tr><td><b>"; |
484 | if (ev->type()=="Event") { | 484 | if (ev->type()=="Event") { |
485 | if (reply) { | 485 | if (reply) { |
486 | if (!ev->doesFloat()) | 486 | if (!ev->doesFloat()) |
487 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; | 487 | tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; |
488 | else | 488 | else |
489 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 489 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
490 | 490 | ||
491 | } else { | 491 | } else { |
492 | if (!ev->doesFloat()) { | 492 | if (!ev->doesFloat()) { |
493 | Event *event = static_cast<Event *>(ev); | 493 | Event *event = static_cast<Event *>(ev); |
494 | QDateTime st,end; | 494 | QDateTime st,end; |
495 | if ( event->recurrence()->doesRecur() ) { | 495 | if ( event->recurrence()->doesRecur() ) { |
496 | QDate recDate= mEventDate; | 496 | QDate recDate= mEventDate; |
497 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); | 497 | int days = event->dtStart().date().daysTo (event->dtEnd().date() ); |
498 | while ( ! event->recursOn( recDate ) ) { | 498 | while ( ! event->recursOn( recDate ) ) { |
499 | recDate = recDate.addDays( -1 ); | 499 | recDate = recDate.addDays( -1 ); |
500 | 500 | ||
501 | } | 501 | } |
502 | st = QDateTime ( recDate, event->dtStart().time() ); | 502 | st = QDateTime ( recDate, event->dtStart().time() ); |
503 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); | 503 | end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); |
504 | } | 504 | } |
505 | else { | 505 | else { |
506 | st = event->dtStart(); | 506 | st = event->dtStart(); |
507 | end = event->dtEnd(); | 507 | end = event->dtEnd(); |
508 | } | 508 | } |
509 | 509 | ||
510 | 510 | ||
511 | QString dateText; | 511 | QString dateText; |
512 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); | 512 | // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); |
513 | if ( st.date() < mEventDate ) | 513 | if ( st.date() < mEventDate ) |
514 | dateText = "++:++-"; | 514 | dateText = "++:++-"; |
515 | else | 515 | else |
516 | dateText = event->dtStartTimeStr() + "-"; | 516 | dateText = event->dtStartTimeStr() + "-"; |
517 | if ( end.date() > mEventDate ) | 517 | if ( end.date() > mEventDate ) |
518 | dateText += "++:++"; | 518 | dateText += "++:++"; |
519 | else | 519 | else |
520 | dateText += event->dtEndTimeStr(); | 520 | dateText += event->dtEndTimeStr(); |
521 | if ( notRed ) | 521 | if ( notRed ) |
522 | tempText += dateText; | 522 | tempText += dateText; |
523 | else { | 523 | else { |
524 | if ( end < cdt ) { | 524 | if ( end < cdt ) { |
525 | if ( !KOPrefs::instance()->mWNViewShowsPast ) | 525 | if ( !KOPrefs::instance()->mWNViewShowsPast ) |
526 | return false; | 526 | return false; |
527 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; | 527 | tempText += "<font color=\"#F00000\">" + dateText + "</font>"; |
528 | } | 528 | } |
529 | else if ( st < cdt ) | 529 | else if ( st < cdt ) |
530 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; | 530 | tempText += "<font color=\"#008000\">" + dateText + "</font>"; |
531 | else | 531 | else |
532 | tempText += dateText; | 532 | tempText += dateText; |
533 | 533 | ||
534 | } | 534 | } |
535 | 535 | ||
536 | } else { | 536 | } else { |
537 | if ( bDay ) { | 537 | if ( bDay ) { |
538 | 538 | ||
539 | if ( ev->categories().contains( i18n("Birthday") )) | 539 | if ( ev->categories().contains( i18n("Birthday") )) |
540 | tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; | 540 | tempText += "<font color=\"#F00000\">" + i18n("Birthday") +":</font>"; |
541 | else | 541 | else |
542 | tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; | 542 | tempText += "<font color=\"#F00000\">" + i18n("Anniversary")+":</font>"; |
543 | } else { | 543 | } else { |
544 | tempText += i18n("Allday:"); | 544 | tempText += i18n("Allday:"); |
545 | } | 545 | } |
546 | 546 | ||
547 | } | 547 | } |
548 | } | 548 | } |
549 | } else { | 549 | } else { |
550 | mTodos.append( ev ); | 550 | mTodos.append( ev ); |
551 | tempText += i18n("ToDo:"); | 551 | tempText += i18n("ToDo:"); |
552 | if (reply) { | 552 | if (reply) { |
553 | tempText += " "; | 553 | tempText += " "; |
554 | if ( noc != cdt ) { | 554 | if ( noc != cdt ) { |
555 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 555 | tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
556 | } | 556 | } |
557 | } else { | 557 | } else { |
558 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { | 558 | if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { |
559 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 559 | // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
560 | QString dfs = KGlobal::locale()->dateFormatShort(); | 560 | QString dfs = KGlobal::locale()->dateFormatShort(); |
561 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 561 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
562 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; | 562 | tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; |
563 | KGlobal::locale()->setDateFormatShort(dfs); | 563 | KGlobal::locale()->setDateFormatShort(dfs); |
564 | } else { | 564 | } else { |
565 | if (!ev->doesFloat() ) | 565 | if (!ev->doesFloat() ) |
566 | if( ( (Todo*)ev)->dtDue() < cdt ) { | 566 | if( ( (Todo*)ev)->dtDue() < cdt ) { |
567 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; | 567 | tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; |
568 | 568 | ||
569 | 569 | ||
570 | } else | 570 | } else |
571 | tempText +=((Todo*)ev)->dtDueTimeStr(); | 571 | tempText +=((Todo*)ev)->dtDueTimeStr(); |
572 | mTodos.append( ev ); | 572 | mTodos.append( ev ); |
573 | } | 573 | } |
574 | } | 574 | } |
575 | } | 575 | } |
576 | tempText += "</b></td><td>"; | 576 | tempText += "</b></td><td>"; |
577 | bool needClose = false; | 577 | bool needClose = false; |
578 | if ( ev->cancelled() ) { | 578 | if ( ev->cancelled() ) { |
579 | tempText += "<font color=\"#F00000\">[c"; | 579 | tempText += "<font color=\"#F00000\">[c"; |
580 | needClose =true; | 580 | needClose =true; |
581 | 581 | ||
582 | } | 582 | } |
583 | if ( ev->isAlarmEnabled() ) { | 583 | if ( ev->isAlarmEnabled() ) { |
584 | if ( !needClose) | 584 | if ( !needClose) |
585 | tempText +="["; | 585 | tempText +="["; |
586 | tempText += "a"; | 586 | tempText += "a"; |
587 | needClose =true; | 587 | needClose =true; |
588 | 588 | ||
589 | } | 589 | } |
590 | if ( ev->description().length() > 0 ) { | 590 | if ( ev->description().length() > 0 ) { |
591 | if ( !needClose) | 591 | if ( !needClose) |
592 | tempText +="["; | 592 | tempText +="["; |
593 | tempText += "i"; | 593 | tempText += "i"; |
594 | needClose =true; | 594 | needClose =true; |
595 | } | 595 | } |
596 | if ( ev->recurrence()->doesRecur() ) { | 596 | if ( ev->recurrence()->doesRecur() ) { |
597 | if ( !needClose) | 597 | if ( !needClose) |
598 | tempText +="["; | 598 | tempText +="["; |
599 | tempText += "r"; | 599 | tempText += "r"; |
600 | needClose =true; | 600 | needClose =true; |
601 | } | 601 | } |
602 | if ( needClose ) { | 602 | if ( needClose ) { |
603 | tempText += "] "; | 603 | tempText += "] "; |
604 | } | 604 | } |
605 | if ( ev->cancelled() ) | 605 | if ( ev->cancelled() ) |
606 | tempText += "</font>"; | 606 | tempText += "</font>"; |
607 | tempText += "<a "; | 607 | tempText += "<a "; |
608 | if (ev->type()=="Event") tempText += "href=\"event:"; | 608 | if (ev->type()=="Event") tempText += "href=\"event:"; |
609 | if (ev->type()=="Todo") tempText += "href=\"todo:"; | 609 | if (ev->type()=="Todo") tempText += "href=\"todo:"; |
610 | tempText += ev->uid() + "\">"; | 610 | tempText += ev->uid() + "\">"; |
611 | if ( ev->summary().length() > 0 ) | 611 | if ( ev->summary().length() > 0 ) |
612 | tempText += ev->summary(); | 612 | tempText += ev->summary(); |
613 | else | 613 | else |
614 | tempText += i18n("-no summary-"); | 614 | tempText += i18n("-no summary-"); |
615 | if ( bDay ) { | 615 | if ( bDay ) { |
616 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); | 616 | noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); |
617 | if ( ok ) { | 617 | if ( ok ) { |
618 | int years = 0; | 618 | int years = 0; |
619 | if ( ev->type() =="Todo" ) { | 619 | if ( ev->type() =="Todo" ) { |
620 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); | 620 | years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); |
621 | } else | 621 | } else |
622 | years = noc.date().year() - ev->dtStart().date().year(); | 622 | years = noc.date().year() - ev->dtStart().date().year(); |
623 | tempText += i18n(" (%1 y.)"). arg( years ); | 623 | tempText += i18n(" (%1 y.)"). arg( years ); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | 626 | ||
627 | tempText += "</a>"; | 627 | tempText += "</a>"; |
628 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 628 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
629 | if ( !ev->location().isEmpty() ) | 629 | if ( !ev->location().isEmpty() ) |
630 | tempText += " ("+ev->location() +")"; | 630 | tempText += " ("+ev->location() +")"; |
631 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) | 631 | if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) |
632 | tempText += " ["+ev->relatedTo()->summary() +"]"; | 632 | tempText += " ["+ev->relatedTo()->summary() +"]"; |
633 | tempText += "</td></tr>\n"; | 633 | tempText += "</td></tr>\n"; |
634 | mText += tempText; | 634 | mText += tempText; |
635 | return true; | 635 | return true; |
636 | } | 636 | } |
637 | 637 | ||
638 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) | 638 | bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) |
639 | { | 639 | { |
640 | if ( mTodos.find( ev ) != mTodos.end() ) return false; | 640 | if ( mTodos.find( ev ) != mTodos.end() ) return false; |
641 | 641 | ||
642 | mTodos.append( ev ); | 642 | mTodos.append( ev ); |
643 | if ( !isSub ) | 643 | if ( !isSub ) |
644 | mText += "<p>"; | 644 | mText += "<p>"; |
645 | else | 645 | else |
646 | mText += "<li>"; | 646 | mText += "<li>"; |
647 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; | 647 | mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; |
648 | 648 | ||
649 | 649 | ||
650 | mText += ind; | 650 | mText += ind; |
651 | bool needClose = false; | 651 | bool needClose = false; |
652 | if ( ev->cancelled() ) { | 652 | if ( ev->cancelled() ) { |
653 | mText += "<font color=\"#F00000\">[c"; | 653 | mText += "<font color=\"#F00000\">[c"; |
654 | needClose =true; | 654 | needClose =true; |
655 | 655 | ||
656 | } | 656 | } |
657 | if ( ev->isAlarmEnabled() ) { | 657 | if ( ev->isAlarmEnabled() ) { |
658 | if ( !needClose) | 658 | if ( !needClose) |
659 | mText +="["; | 659 | mText +="["; |
660 | mText += "a"; | 660 | mText += "a"; |
661 | needClose =true; | 661 | needClose =true; |
662 | 662 | ||
663 | } | 663 | } |
664 | 664 | ||
665 | if ( ev->description().length() > 0 ) { | 665 | if ( ev->description().length() > 0 ) { |
666 | if ( !needClose) | 666 | if ( !needClose) |
667 | mText +="["; | 667 | mText +="["; |
668 | mText += "i"; | 668 | mText += "i"; |
669 | needClose =true; | 669 | needClose =true; |
670 | } | ||
671 | if ( ev->doesRecur() ) { | ||
672 | if ( !needClose) | ||
673 | mText +="["; | ||
674 | mText += "r"; | ||
675 | needClose =true; | ||
670 | } | 676 | } |
671 | // if ( ev->recurrence()->doesRecur() ) { | 677 | // if ( ev->recurrence()->doesRecur() ) { |
672 | // if ( !needClose) | 678 | // if ( !needClose) |
673 | // mText +="("; | 679 | // mText +="("; |
674 | // mText += "r"; | 680 | // mText += "r"; |
675 | // needClose =true; | 681 | // needClose =true; |
676 | // } | 682 | // } |
677 | if ( needClose ) | 683 | if ( needClose ) |
678 | mText += "] "; | 684 | mText += "] "; |
679 | if ( ev->cancelled() ) | 685 | if ( ev->cancelled() ) |
680 | mText += "</font>"; | 686 | mText += "</font>"; |
681 | mText += "<a href=\"todo:" + ev->uid() + "\">"; | 687 | mText += "<a href=\"todo:" + ev->uid() + "\">"; |
682 | if ( ev->summary().length() > 0 ) | 688 | if ( ev->summary().length() > 0 ) |
683 | mText += ev->summary(); | 689 | mText += ev->summary(); |
684 | else | 690 | else |
685 | mText += i18n("-no summary-"); | 691 | mText += i18n("-no summary-"); |
686 | mText += "</a>"; | 692 | mText += "</a>"; |
687 | if ( ((Todo*)ev)->hasDueDate () ) { | 693 | if ( ((Todo*)ev)->hasDueDate () ) { |
688 | QString year = ""; | 694 | QString year = ""; |
689 | int ye = ((Todo*)ev)->dtDue().date().year(); | 695 | int ye = ((Todo*)ev)->dtDue().date().year(); |
690 | if ( QDateTime::currentDateTime().date().year() != ye ) | 696 | if ( QDateTime::currentDateTime().date().year() != ye ) |
691 | year = QString::number( ye ); | 697 | year = QString::number( ye ); |
692 | QString dfs = KGlobal::locale()->dateFormatShort(); | 698 | QString dfs = KGlobal::locale()->dateFormatShort(); |
693 | KGlobal::locale()->setDateFormatShort("%d.%b"); | 699 | KGlobal::locale()->setDateFormatShort("%d.%b"); |
694 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; | 700 | mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; |
695 | KGlobal::locale()->setDateFormatShort(dfs); | 701 | KGlobal::locale()->setDateFormatShort(dfs); |
696 | } | 702 | } |
697 | if ( KOPrefs::instance()->mWNViewShowLocation ) | 703 | if ( KOPrefs::instance()->mWNViewShowLocation ) |
698 | if ( !ev->location().isEmpty() ) | 704 | if ( !ev->location().isEmpty() ) |
699 | mText += " ("+ev->location() +")"; | 705 | mText += " ("+ev->location() +")"; |
700 | if ( !isSub ) { | 706 | if ( !isSub ) { |
701 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) | 707 | if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) |
702 | mText += " ["+ev->relatedTo()->summary() +"]"; | 708 | mText += " ["+ev->relatedTo()->summary() +"]"; |
703 | mText += "</p>\n"; | 709 | mText += "</p>\n"; |
704 | } | 710 | } |
705 | else { | 711 | else { |
706 | ind += "-"; | 712 | ind += "-"; |
707 | mText += "</li>\n"; | 713 | mText += "</li>\n"; |
708 | } | 714 | } |
709 | QPtrList<Incidence> Relations = ev->relations(); | 715 | QPtrList<Incidence> Relations = ev->relations(); |
710 | Incidence *to; | 716 | Incidence *to; |
711 | for (to=Relations.first();to;to=Relations.next()) { | 717 | for (to=Relations.first();to;to=Relations.next()) { |
712 | if (!((Todo*)to)->isCompleted()) | 718 | if (!((Todo*)to)->isCompleted()) |
713 | appendTodo( to, ind , true ); | 719 | appendTodo( to, ind , true ); |
714 | } | 720 | } |
715 | 721 | ||
716 | return true; | 722 | return true; |
717 | } | 723 | } |
718 | 724 | ||
719 | /* | 725 | /* |
720 | void KOWhatsNextView::createEventViewer() | 726 | void KOWhatsNextView::createEventViewer() |
721 | { | 727 | { |
722 | if (!mEventViewer) { | 728 | if (!mEventViewer) { |
723 | 729 | ||
724 | mEventViewer = new KOEventViewerDialog(this); | 730 | mEventViewer = new KOEventViewerDialog(this); |
725 | } | 731 | } |
726 | } | 732 | } |
727 | */ | 733 | */ |
728 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) | 734 | void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) |
729 | { | 735 | { |
730 | mEventViewer = v; | 736 | mEventViewer = v; |
731 | } | 737 | } |
732 | 738 | ||
733 | // TODO: Create this function in CalendarView and remove it from here | 739 | // TODO: Create this function in CalendarView and remove it from here |
734 | void KOWhatsNextView::showIncidence(const QString &uid) | 740 | void KOWhatsNextView::showIncidence(const QString &uid) |
735 | { | 741 | { |
736 | 742 | ||
737 | if ( !mEventViewer ) { | 743 | if ( !mEventViewer ) { |
738 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); | 744 | qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); |
739 | return; | 745 | return; |
740 | } | 746 | } |
741 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; | 747 | //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; |
742 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); | 748 | //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); |
743 | if (uid.startsWith("event:")) { | 749 | if (uid.startsWith("event:")) { |
744 | #ifdef DESKTOP_VERSION | 750 | #ifdef DESKTOP_VERSION |
745 | Event *event = calendar()->event(uid.mid(8)); | 751 | Event *event = calendar()->event(uid.mid(8)); |
746 | #else | 752 | #else |
747 | Event *event = calendar()->event(uid.mid(6)); | 753 | Event *event = calendar()->event(uid.mid(6)); |
748 | #endif | 754 | #endif |
749 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); | 755 | //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); |
750 | if (!event) return; | 756 | if (!event) return; |
751 | //createEventViewer(); | 757 | //createEventViewer(); |
752 | mEventViewer->setEvent(event); | 758 | mEventViewer->setEvent(event); |
753 | } else if (uid.startsWith("todo:")) { | 759 | } else if (uid.startsWith("todo:")) { |
754 | #ifdef DESKTOP_VERSION | 760 | #ifdef DESKTOP_VERSION |
755 | Todo *todo = calendar()->todo(uid.mid(7)); | 761 | Todo *todo = calendar()->todo(uid.mid(7)); |
756 | #else | 762 | #else |
757 | Todo *todo = calendar()->todo(uid.mid(5)); | 763 | Todo *todo = calendar()->todo(uid.mid(5)); |
758 | #endif | 764 | #endif |
759 | if (!todo) return; | 765 | if (!todo) return; |
760 | //createEventViewer(); | 766 | //createEventViewer(); |
761 | mEventViewer->setTodo(todo); | 767 | mEventViewer->setTodo(todo); |
762 | } else { | 768 | } else { |
763 | return; | 769 | return; |
764 | 770 | ||
765 | } | 771 | } |
766 | mEventViewer->showMe(); | 772 | mEventViewer->showMe(); |
767 | mEventViewer->raise(); | 773 | mEventViewer->raise(); |
768 | } | 774 | } |