author | zautrix <zautrix> | 2005-06-08 10:56:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-08 10:56:24 (UTC) |
commit | 2448916479b456ca7c880427a80e8e32e95b2fba (patch) (unidiff) | |
tree | 83be907f0eccb43ffc44a7f1bc07995c32760cb5 /korganizer | |
parent | 793d117812b4da36c9c11d90cccba347cbc6e208 (diff) | |
download | kdepimpi-2448916479b456ca7c880427a80e8e32e95b2fba.zip kdepimpi-2448916479b456ca7c880427a80e8e32e95b2fba.tar.gz kdepimpi-2448916479b456ca7c880427a80e8e32e95b2fba.tar.bz2 |
more type API changes
-rw-r--r-- | korganizer/incomingdialog.cpp | 14 | ||||
-rw-r--r-- | korganizer/koagendaview.cpp | 14 | ||||
-rw-r--r-- | korganizer/koeditorrecurrence.cpp | 2 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 12 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 4 | ||||
-rw-r--r-- | korganizer/outgoingdialog.cpp | 12 |
6 files changed, 29 insertions, 29 deletions
diff --git a/korganizer/incomingdialog.cpp b/korganizer/incomingdialog.cpp index 50e3077..fe78356 100644 --- a/korganizer/incomingdialog.cpp +++ b/korganizer/incomingdialog.cpp | |||
@@ -1,528 +1,528 @@ | |||
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 <qlistview.h> | 20 | #include <qlistview.h> |
21 | #include <qfile.h> | 21 | #include <qfile.h> |
22 | #include <qdir.h> | 22 | #include <qdir.h> |
23 | #include <qmap.h> | 23 | #include <qmap.h> |
24 | 24 | ||
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | #include <klocale.h> | 26 | #include <klocale.h> |
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kstandarddirs.h> | 28 | #include <kstandarddirs.h> |
29 | #include <kmessagebox.h> | 29 | #include <kmessagebox.h> |
30 | 30 | ||
31 | #include <libkcal/incidence.h> | 31 | #include <libkcal/incidence.h> |
32 | #include <libkcal/event.h> | 32 | #include <libkcal/event.h> |
33 | #include <libkcal/calendar.h> | 33 | #include <libkcal/calendar.h> |
34 | #include <libkcal/freebusy.h> | 34 | #include <libkcal/freebusy.h> |
35 | #include <libkcal/attendee.h> | 35 | #include <libkcal/attendee.h> |
36 | #include <libkcal/calendarresources.h> | 36 | #include <libkcal/calendarresources.h> |
37 | #include <libkcal/resourcecalendar.h> | 37 | #include <libkcal/resourcecalendar.h> |
38 | #include <kresources/resourceselectdialog.h> | 38 | #include <kresources/resourceselectdialog.h> |
39 | 39 | ||
40 | #ifndef KORG_NOMAIL | 40 | #ifndef KORG_NOMAIL |
41 | #include "mailscheduler.h" | 41 | #include "mailscheduler.h" |
42 | #else | 42 | #else |
43 | #include <libkcal/dummyscheduler.h> | 43 | #include <libkcal/dummyscheduler.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | 46 | ||
47 | #include "incomingdialog.h" | 47 | #include "incomingdialog.h" |
48 | #include "koeventviewerdialog.h" | 48 | #include "koeventviewerdialog.h" |
49 | #include "kocounterdialog.h" | 49 | #include "kocounterdialog.h" |
50 | #include "koprefs.h" | 50 | #include "koprefs.h" |
51 | 51 | ||
52 | #ifndef KORG_NOKABC | 52 | #ifndef KORG_NOKABC |
53 | #define KORG_NOKABC | 53 | #define KORG_NOKABC |
54 | //#include <kabc/stdaddressbook.h> | 54 | //#include <kabc/stdaddressbook.h> |
55 | #define size count | 55 | #define size count |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | 58 | ||
59 | ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev, | 59 | ScheduleItemIn::ScheduleItemIn(QListView *parent,IncidenceBase *ev, |
60 | Scheduler::Method method,ScheduleMessage::Status status) | 60 | Scheduler::Method method,ScheduleMessage::Status status) |
61 | : QListViewItem(parent) | 61 | : QListViewItem(parent) |
62 | { | 62 | { |
63 | mIncidence = ev; | 63 | mIncidence = ev; |
64 | mMethod = method; | 64 | mMethod = method; |
65 | mStatus = status; | 65 | mStatus = status; |
66 | setText(6,Scheduler::translatedMethodName(mMethod)+" "); | 66 | setText(6,Scheduler::translatedMethodName(mMethod)+" "); |
67 | setText(7,ScheduleMessage::statusName(status)); | 67 | setText(7,ScheduleMessage::statusName(status)); |
68 | } | 68 | } |
69 | 69 | ||
70 | 70 | ||
71 | /* Visitor */ | 71 | /* Visitor */ |
72 | ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) | 72 | ScheduleItemVisitor::ScheduleItemVisitor(ScheduleItemIn *item) |
73 | { | 73 | { |
74 | mItem = item; | 74 | mItem = item; |
75 | } | 75 | } |
76 | 76 | ||
77 | ScheduleItemVisitor::~ScheduleItemVisitor() | 77 | ScheduleItemVisitor::~ScheduleItemVisitor() |
78 | { | 78 | { |
79 | } | 79 | } |
80 | 80 | ||
81 | bool ScheduleItemVisitor::visit(Event *e) | 81 | bool ScheduleItemVisitor::visit(Event *e) |
82 | { | 82 | { |
83 | mItem->setText(0,e->summary()); | 83 | mItem->setText(0,e->summary()); |
84 | mItem->setText(1,e->dtStartDateStr()); | 84 | mItem->setText(1,e->dtStartDateStr()); |
85 | if (e->doesFloat()) { | 85 | if (e->doesFloat()) { |
86 | mItem->setText(2,i18n("no time ")); | 86 | mItem->setText(2,i18n("no time ")); |
87 | mItem->setText(4,i18n("no time ")); | 87 | mItem->setText(4,i18n("no time ")); |
88 | } | 88 | } |
89 | else { | 89 | else { |
90 | mItem->setText(2,e->dtStartTimeStr()); | 90 | mItem->setText(2,e->dtStartTimeStr()); |
91 | mItem->setText(4,e->dtEndTimeStr()); | 91 | mItem->setText(4,e->dtEndTimeStr()); |
92 | } | 92 | } |
93 | if (e->hasEndDate()) { | 93 | if (e->hasEndDate()) { |
94 | mItem->setText(3,e->dtEndDateStr()); | 94 | mItem->setText(3,e->dtEndDateStr()); |
95 | } | 95 | } |
96 | else { | 96 | else { |
97 | mItem->setText(3,""); | 97 | mItem->setText(3,""); |
98 | } | 98 | } |
99 | mItem->setText(5,e->organizer()+" "); | 99 | mItem->setText(5,e->organizer()+" "); |
100 | 100 | ||
101 | return true; | 101 | return true; |
102 | } | 102 | } |
103 | 103 | ||
104 | bool ScheduleItemVisitor::visit(Todo *e) | 104 | bool ScheduleItemVisitor::visit(Todo *e) |
105 | { | 105 | { |
106 | mItem->setText(0,e->summary()); | 106 | mItem->setText(0,e->summary()); |
107 | if (e->hasStartDate()) { | 107 | if (e->hasStartDate()) { |
108 | mItem->setText(1,e->dtStartDateStr()); | 108 | mItem->setText(1,e->dtStartDateStr()); |
109 | if (!e->doesFloat()) { | 109 | if (!e->doesFloat()) { |
110 | mItem->setText(2,e->dtStartTimeStr()); | 110 | mItem->setText(2,e->dtStartTimeStr()); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | if (e->hasDueDate()) { | 113 | if (e->hasDueDate()) { |
114 | mItem->setText(1,e->dtDueDateStr()); | 114 | mItem->setText(1,e->dtDueDateStr()); |
115 | if (!e->doesFloat()) { | 115 | if (!e->doesFloat()) { |
116 | mItem->setText(2,e->dtDueTimeStr()); | 116 | mItem->setText(2,e->dtDueTimeStr()); |
117 | } | 117 | } |
118 | } | 118 | } |
119 | mItem->setText(5,e->organizer()+" "); | 119 | mItem->setText(5,e->organizer()+" "); |
120 | 120 | ||
121 | return true; | 121 | return true; |
122 | } | 122 | } |
123 | 123 | ||
124 | bool ScheduleItemVisitor::visit(Journal *) | 124 | bool ScheduleItemVisitor::visit(Journal *) |
125 | { | 125 | { |
126 | return false; | 126 | return false; |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | /* | 130 | /* |
131 | * Constructs a IncomingDialog which is a child of 'parent', with the | 131 | * Constructs a IncomingDialog which is a child of 'parent', with the |
132 | * name 'name' and widget flags set to 'f' | 132 | * name 'name' and widget flags set to 'f' |
133 | * | 133 | * |
134 | * The dialog will by default be modeless, unless you set 'modal' to | 134 | * The dialog will by default be modeless, unless you set 'modal' to |
135 | * TRUE to construct a modal dialog. | 135 | * TRUE to construct a modal dialog. |
136 | */ | 136 | */ |
137 | IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, | 137 | IncomingDialog::IncomingDialog(Calendar *calendar,OutgoingDialog *outgoing, |
138 | QWidget* parent,const char* name,bool modal,WFlags fl) : | 138 | QWidget* parent,const char* name,bool modal,WFlags fl) : |
139 | IncomingDialog_base(parent,name,modal,fl) | 139 | IncomingDialog_base(parent,name,modal,fl) |
140 | { | 140 | { |
141 | mCalendar = calendar; | 141 | mCalendar = calendar; |
142 | mOutgoing = outgoing; | 142 | mOutgoing = outgoing; |
143 | #ifndef KORG_NOMAIL | 143 | #ifndef KORG_NOMAIL |
144 | mScheduler = new MailScheduler(mCalendar); | 144 | mScheduler = new MailScheduler(mCalendar); |
145 | #else | 145 | #else |
146 | mScheduler = new DummyScheduler(mCalendar); | 146 | mScheduler = new DummyScheduler(mCalendar); |
147 | #endif | 147 | #endif |
148 | mMessageListView->setColumnAlignment(1,AlignHCenter); | 148 | mMessageListView->setColumnAlignment(1,AlignHCenter); |
149 | mMessageListView->setColumnAlignment(2,AlignHCenter); | 149 | mMessageListView->setColumnAlignment(2,AlignHCenter); |
150 | mMessageListView->setColumnAlignment(3,AlignHCenter); | 150 | mMessageListView->setColumnAlignment(3,AlignHCenter); |
151 | mMessageListView->setColumnAlignment(4,AlignHCenter); | 151 | mMessageListView->setColumnAlignment(4,AlignHCenter); |
152 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), | 152 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), |
153 | this,SLOT(showEvent(QListViewItem *))); | 153 | this,SLOT(showEvent(QListViewItem *))); |
154 | retrieve(); | 154 | retrieve(); |
155 | } | 155 | } |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * Destroys the object and frees any allocated resources | 158 | * Destroys the object and frees any allocated resources |
159 | */ | 159 | */ |
160 | IncomingDialog::~IncomingDialog() | 160 | IncomingDialog::~IncomingDialog() |
161 | { | 161 | { |
162 | // no need to delete child widgets, Qt does it all for us | 162 | // no need to delete child widgets, Qt does it all for us |
163 | } | 163 | } |
164 | 164 | ||
165 | void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) | 165 | void IncomingDialog::setOutgoingDialog(OutgoingDialog *outgoing) |
166 | { | 166 | { |
167 | mOutgoing = outgoing; | 167 | mOutgoing = outgoing; |
168 | } | 168 | } |
169 | 169 | ||
170 | void IncomingDialog::retrieve() | 170 | void IncomingDialog::retrieve() |
171 | { | 171 | { |
172 | QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); | 172 | QPtrList <ScheduleMessage> messages = mScheduler->retrieveTransactions(); |
173 | 173 | ||
174 | ScheduleMessage *message; | 174 | ScheduleMessage *message; |
175 | for(message = messages.first();message;message = messages.next()) { | 175 | for(message = messages.first();message;message = messages.next()) { |
176 | IncidenceBase *inc = message->event(); | 176 | IncidenceBase *inc = message->event(); |
177 | Scheduler::Method method = (Scheduler::Method)message->method(); | 177 | Scheduler::Method method = (Scheduler::Method)message->method(); |
178 | ScheduleMessage::Status status = message->status(); | 178 | ScheduleMessage::Status status = message->status(); |
179 | 179 | ||
180 | ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); | 180 | ScheduleItemIn *item = new ScheduleItemIn(mMessageListView,inc,method,status); |
181 | if(inc->type()!="FreeBusy") { | 181 | if(inc->typeID() != freebusyID ) { |
182 | Incidence *incidence = static_cast<Incidence *>(inc); | 182 | Incidence *incidence = static_cast<Incidence *>(inc); |
183 | ScheduleItemVisitor v(item); | 183 | ScheduleItemVisitor v(item); |
184 | if (!incidence->accept(v)) delete item; | 184 | if (!incidence->accept(v)) delete item; |
185 | } else { | 185 | } else { |
186 | FreeBusy *fb = static_cast<FreeBusy *>(item->event()); | 186 | FreeBusy *fb = static_cast<FreeBusy *>(item->event()); |
187 | item->setText(0, "FreeBusy"); | 187 | item->setText(0, "FreeBusy"); |
188 | item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); | 188 | item->setText(1, KGlobal::locale()->formatDate( fb->dtStart().date() ) ); |
189 | item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); | 189 | item->setText(2, KGlobal::locale()->formatTime( fb->dtStart().time() ) ); |
190 | item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); | 190 | item->setText(3, KGlobal::locale()->formatDate( fb->dtEnd().date() ) ); |
191 | item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); | 191 | item->setText(4, KGlobal::locale()->formatTime( fb->dtEnd().time() ) ); |
192 | item->setText(5, fb->organizer()); | 192 | item->setText(5, fb->organizer()); |
193 | } | 193 | } |
194 | automaticAction(item); | 194 | automaticAction(item); |
195 | } | 195 | } |
196 | emit numMessagesChanged(mMessageListView->childCount()); | 196 | emit numMessagesChanged(mMessageListView->childCount()); |
197 | } | 197 | } |
198 | 198 | ||
199 | void IncomingDialog::acceptAllMessages() | 199 | void IncomingDialog::acceptAllMessages() |
200 | { | 200 | { |
201 | bool success = false; | 201 | bool success = false; |
202 | 202 | ||
203 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); | 203 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->firstChild(); |
204 | while(item) { | 204 | while(item) { |
205 | ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); | 205 | ScheduleItemIn *nextitem = (ScheduleItemIn *)(item->nextSibling()); |
206 | if (acceptMessage(item)) success = true; | 206 | if (acceptMessage(item)) success = true; |
207 | item = nextitem; | 207 | item = nextitem; |
208 | } | 208 | } |
209 | 209 | ||
210 | if (success) emit calendarUpdated(); | 210 | if (success) emit calendarUpdated(); |
211 | } | 211 | } |
212 | 212 | ||
213 | void IncomingDialog::acceptMessage() | 213 | void IncomingDialog::acceptMessage() |
214 | { | 214 | { |
215 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); | 215 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); |
216 | if (item) { | 216 | if (item) { |
217 | if (acceptMessage(item)) emit calendarUpdated(); | 217 | if (acceptMessage(item)) emit calendarUpdated(); |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | bool IncomingDialog::acceptMessage(ScheduleItemIn *item) | 221 | bool IncomingDialog::acceptMessage(ScheduleItemIn *item) |
222 | { | 222 | { |
223 | switch (item->method()) { | 223 | switch (item->method()) { |
224 | case Scheduler::Refresh: | 224 | case Scheduler::Refresh: |
225 | return incomeRefresh(item); | 225 | return incomeRefresh(item); |
226 | break; | 226 | break; |
227 | case Scheduler::Counter: | 227 | case Scheduler::Counter: |
228 | return incomeCounter(item); | 228 | return incomeCounter(item); |
229 | break; | 229 | break; |
230 | case Scheduler::Declinecounter: | 230 | case Scheduler::Declinecounter: |
231 | return incomeDeclineCounter(item); | 231 | return incomeDeclineCounter(item); |
232 | break; | 232 | break; |
233 | case Scheduler::Add: | 233 | case Scheduler::Add: |
234 | return incomeAdd(item); | 234 | return incomeAdd(item); |
235 | break; | 235 | break; |
236 | case Scheduler::Request: | 236 | case Scheduler::Request: |
237 | return incomeRequest(item); | 237 | return incomeRequest(item); |
238 | break; | 238 | break; |
239 | default: | 239 | default: |
240 | return incomeDefault(item); | 240 | return incomeDefault(item); |
241 | } | 241 | } |
242 | return false; | 242 | return false; |
243 | } | 243 | } |
244 | 244 | ||
245 | void IncomingDialog::rejectMessage() | 245 | void IncomingDialog::rejectMessage() |
246 | { | 246 | { |
247 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); | 247 | ScheduleItemIn *item = (ScheduleItemIn *)mMessageListView->selectedItem(); |
248 | if (item) { | 248 | if (item) { |
249 | mScheduler->deleteTransaction(item->event()); | 249 | mScheduler->deleteTransaction(item->event()); |
250 | delete item; | 250 | delete item; |
251 | emit numMessagesChanged(mMessageListView->childCount()); | 251 | emit numMessagesChanged(mMessageListView->childCount()); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | void IncomingDialog::showEvent(QListViewItem *item) | 255 | void IncomingDialog::showEvent(QListViewItem *item) |
256 | { | 256 | { |
257 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 257 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
258 | if( incidence && incidence->type() == "Event" ) { | 258 | if( incidence && incidence->typeID() == eventID ) { |
259 | Event *event = static_cast<Event *>(incidence); | 259 | Event *event = static_cast<Event *>(incidence); |
260 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); | 260 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); |
261 | eventViewer->setEvent(event); | 261 | eventViewer->setEvent(event); |
262 | eventViewer->show(); | 262 | eventViewer->show(); |
263 | } | 263 | } |
264 | } | 264 | } |
265 | 265 | ||
266 | bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) | 266 | bool IncomingDialog::incomeRefresh(ScheduleItemIn *item) |
267 | { | 267 | { |
268 | Event *ev = mCalendar->event(item->event()->uid()); | 268 | Event *ev = mCalendar->event(item->event()->uid()); |
269 | if (ev) { | 269 | if (ev) { |
270 | //user interaction before?? | 270 | //user interaction before?? |
271 | Attendee *att; | 271 | Attendee *att; |
272 | QPtrList<Attendee> attlist = ev->attendees(); | 272 | QPtrList<Attendee> attlist = ev->attendees(); |
273 | for (att=attlist.first(); att; att=attlist.next()) { | 273 | for (att=attlist.first(); att; att=attlist.next()) { |
274 | Event *event = new Event(*ev); | 274 | Event *event = new Event(*ev); |
275 | mOutgoing->addMessage(event,Scheduler::Request,att->email()); | 275 | mOutgoing->addMessage(event,Scheduler::Request,att->email()); |
276 | delete(event); | 276 | delete(event); |
277 | } | 277 | } |
278 | mScheduler->deleteTransaction(item->event()); | 278 | mScheduler->deleteTransaction(item->event()); |
279 | delete item; | 279 | delete item; |
280 | emit numMessagesChanged(mMessageListView->childCount()); | 280 | emit numMessagesChanged(mMessageListView->childCount()); |
281 | return true; | 281 | return true; |
282 | } | 282 | } |
283 | mScheduler->deleteTransaction(item->event()); | 283 | mScheduler->deleteTransaction(item->event()); |
284 | delete item; | 284 | delete item; |
285 | emit numMessagesChanged(mMessageListView->childCount()); | 285 | emit numMessagesChanged(mMessageListView->childCount()); |
286 | return false; | 286 | return false; |
287 | } | 287 | } |
288 | 288 | ||
289 | bool IncomingDialog::incomeCounter(ScheduleItemIn *item) | 289 | bool IncomingDialog::incomeCounter(ScheduleItemIn *item) |
290 | { | 290 | { |
291 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 291 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
292 | // currently only events supportet - attetion at insertion below! | 292 | // currently only events supportet - attetion at insertion below! |
293 | if ( incidence->type() != "Event" ) return false; | 293 | if ( incidence->typeID() != eventID ) return false; |
294 | 294 | ||
295 | Event *counterEvent = static_cast<Event *>( incidence ); | 295 | Event *counterEvent = static_cast<Event *>( incidence ); |
296 | 296 | ||
297 | Event *even = mCalendar->event(counterEvent->uid()); | 297 | Event *even = mCalendar->event(counterEvent->uid()); |
298 | 298 | ||
299 | KOCounterDialog *eventViewer = new KOCounterDialog(this); | 299 | KOCounterDialog *eventViewer = new KOCounterDialog(this); |
300 | eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); | 300 | eventViewer->addText(i18n("counter proposal event","<b>Counter-event:</b><p>")); |
301 | eventViewer->addEvent(counterEvent); | 301 | eventViewer->addEvent(counterEvent); |
302 | eventViewer->addText("<hr>"); | 302 | eventViewer->addText("<hr>"); |
303 | eventViewer->addText(i18n("<b>Original event:</b><p>")); | 303 | eventViewer->addText(i18n("<b>Original event:</b><p>")); |
304 | if (even) eventViewer->addEvent(even); | 304 | if (even) eventViewer->addEvent(even); |
305 | else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); | 305 | else eventViewer->addText(i18n("A corresponding event is missing in your calendar!")); |
306 | eventViewer->addText("<hr>"); | 306 | eventViewer->addText("<hr>"); |
307 | eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); | 307 | eventViewer->addText(i18n("If this counter-event is a good proposal for your event, press 'Accept'. All Attendees will then get the new version of this event")); |
308 | eventViewer->show(); | 308 | eventViewer->show(); |
309 | 309 | ||
310 | eventViewer->exec(); | 310 | eventViewer->exec(); |
311 | if (eventViewer->result()) { | 311 | if (eventViewer->result()) { |
312 | kdDebug() << "IncomingDialog::Counter:Accept" << endl; | 312 | kdDebug() << "IncomingDialog::Counter:Accept" << endl; |
313 | int revision = 0; | 313 | int revision = 0; |
314 | if (even) { | 314 | if (even) { |
315 | revision = even->revision(); | 315 | revision = even->revision(); |
316 | mCalendar->deleteEvent(even); | 316 | mCalendar->deleteEvent(even); |
317 | } | 317 | } |
318 | mCalendar->addIncidence(counterEvent); | 318 | mCalendar->addIncidence(counterEvent); |
319 | 319 | ||
320 | even = mCalendar->event(item->event()->uid()); | 320 | even = mCalendar->event(item->event()->uid()); |
321 | if (even) { | 321 | if (even) { |
322 | if (revision < even->revision()) | 322 | if (revision < even->revision()) |
323 | even->setRevision(even->revision()+1); | 323 | even->setRevision(even->revision()+1); |
324 | else | 324 | else |
325 | even->setRevision(revision+1); | 325 | even->setRevision(revision+1); |
326 | Event *ev = new Event(*even); | 326 | Event *ev = new Event(*even); |
327 | mOutgoing->addMessage(ev,Scheduler::Request); | 327 | mOutgoing->addMessage(ev,Scheduler::Request); |
328 | delete(ev); | 328 | delete(ev); |
329 | } | 329 | } |
330 | mScheduler->deleteTransaction(item->event()); | 330 | mScheduler->deleteTransaction(item->event()); |
331 | delete item; | 331 | delete item; |
332 | emit numMessagesChanged(mMessageListView->childCount()); | 332 | emit numMessagesChanged(mMessageListView->childCount()); |
333 | return true; | 333 | return true; |
334 | } else { | 334 | } else { |
335 | kdDebug() << "IncomingDialog::Counter:Decline" << endl; | 335 | kdDebug() << "IncomingDialog::Counter:Decline" << endl; |
336 | //the counter-sender's email is missing... | 336 | //the counter-sender's email is missing... |
337 | //now every attendee gets an declinecounter :-( | 337 | //now every attendee gets an declinecounter :-( |
338 | mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); | 338 | mOutgoing->addMessage(counterEvent,Scheduler::Declinecounter); |
339 | delete item; | 339 | delete item; |
340 | emit numMessagesChanged(mMessageListView->childCount()); | 340 | emit numMessagesChanged(mMessageListView->childCount()); |
341 | mScheduler->deleteTransaction(item->event()); | 341 | mScheduler->deleteTransaction(item->event()); |
342 | delete item; | 342 | delete item; |
343 | emit numMessagesChanged(mMessageListView->childCount()); | 343 | emit numMessagesChanged(mMessageListView->childCount()); |
344 | return true; | 344 | return true; |
345 | } | 345 | } |
346 | //mScheduler->deleteTransaction(item->event()); | 346 | //mScheduler->deleteTransaction(item->event()); |
347 | delete item; | 347 | delete item; |
348 | emit numMessagesChanged(mMessageListView->childCount()); | 348 | emit numMessagesChanged(mMessageListView->childCount()); |
349 | return false; | 349 | return false; |
350 | } | 350 | } |
351 | 351 | ||
352 | bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) | 352 | bool IncomingDialog::incomeDeclineCounter(ScheduleItemIn *item) |
353 | { | 353 | { |
354 | Event *even = mCalendar->event(item->event()->uid()); | 354 | Event *even = mCalendar->event(item->event()->uid()); |
355 | if (even) { | 355 | if (even) { |
356 | mOutgoing->addMessage(even,Scheduler::Refresh); | 356 | mOutgoing->addMessage(even,Scheduler::Refresh); |
357 | mScheduler->deleteTransaction(item->event()); | 357 | mScheduler->deleteTransaction(item->event()); |
358 | delete item; | 358 | delete item; |
359 | emit numMessagesChanged(mMessageListView->childCount()); | 359 | emit numMessagesChanged(mMessageListView->childCount()); |
360 | return true; | 360 | return true; |
361 | } | 361 | } |
362 | mScheduler->deleteTransaction(item->event()); | 362 | mScheduler->deleteTransaction(item->event()); |
363 | delete item; | 363 | delete item; |
364 | emit numMessagesChanged(mMessageListView->childCount()); | 364 | emit numMessagesChanged(mMessageListView->childCount()); |
365 | return false; | 365 | return false; |
366 | } | 366 | } |
367 | 367 | ||
368 | bool IncomingDialog::incomeAdd(ScheduleItemIn *item) | 368 | bool IncomingDialog::incomeAdd(ScheduleItemIn *item) |
369 | { | 369 | { |
370 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); | 370 | IncidenceBase *incidence = ((ScheduleItemIn *)item)->event(); |
371 | if (incidence->type() == "Event" ) { | 371 | if (incidence->typeID() == eventID ) { |
372 | Event *refr = static_cast<Event *>( incidence ); | 372 | Event *refr = static_cast<Event *>( incidence ); |
373 | mOutgoing->addMessage(refr,Scheduler::Refresh); | 373 | mOutgoing->addMessage(refr,Scheduler::Refresh); |
374 | mScheduler->deleteTransaction( incidence ); | 374 | mScheduler->deleteTransaction( incidence ); |
375 | delete item; | 375 | delete item; |
376 | emit numMessagesChanged(mMessageListView->childCount()); | 376 | emit numMessagesChanged(mMessageListView->childCount()); |
377 | return true; | 377 | return true; |
378 | } | 378 | } |
379 | else { | 379 | else { |
380 | kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl; | 380 | kdDebug() << "IncomingDialog::incomeAdd - only Events are supportet yet" << endl; |
381 | mScheduler->deleteTransaction( incidence ); | 381 | mScheduler->deleteTransaction( incidence ); |
382 | delete item; | 382 | delete item; |
383 | emit numMessagesChanged(mMessageListView->childCount()); | 383 | emit numMessagesChanged(mMessageListView->childCount()); |
384 | return false; | 384 | return false; |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | bool IncomingDialog::incomeDefault(ScheduleItemIn *item) | 388 | bool IncomingDialog::incomeDefault(ScheduleItemIn *item) |
389 | { | 389 | { |
390 | if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) { | 390 | if (mScheduler->acceptTransaction(item->event(),item->method(),item->status())) { |
391 | delete item; | 391 | delete item; |
392 | emit numMessagesChanged(mMessageListView->childCount()); | 392 | emit numMessagesChanged(mMessageListView->childCount()); |
393 | return true; | 393 | return true; |
394 | } | 394 | } |
395 | else { | 395 | else { |
396 | KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses.")); | 396 | KMessageBox::error(this,i18n("Unable to accept the IMIP-message. It may be a problem with the email addresses.")); |
397 | kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl; | 397 | kdDebug() << "IncomingDialog::acceptMessage(): Error!" << endl; |
398 | return false; | 398 | return false; |
399 | } | 399 | } |
400 | return false; | 400 | return false; |
401 | } | 401 | } |
402 | 402 | ||
403 | bool IncomingDialog::incomeRequest(ScheduleItemIn *item) | 403 | bool IncomingDialog::incomeRequest(ScheduleItemIn *item) |
404 | { | 404 | { |
405 | if (item->event()->type()=="FreeBusy") { | 405 | if (item->event()->typeID() == freebusyID ) { |
406 | //handel freebusy request | 406 | //handel freebusy request |
407 | IncidenceBase *inc = item->event(); | 407 | IncidenceBase *inc = item->event(); |
408 | QDateTime start = inc->dtStart(); | 408 | QDateTime start = inc->dtStart(); |
409 | QDateTime end = start.addDays(inc->duration()/86400); | 409 | QDateTime end = start.addDays(inc->duration()/86400); |
410 | 410 | ||
411 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 411 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
412 | freebusy->setOrganizer(inc->organizer()); | 412 | freebusy->setOrganizer(inc->organizer()); |
413 | Attendee *att = new Attendee(KOPrefs::instance()->fullName(), | 413 | Attendee *att = new Attendee(KOPrefs::instance()->fullName(), |
414 | KOPrefs::instance()->email()); | 414 | KOPrefs::instance()->email()); |
415 | freebusy->addAttendee(att); | 415 | freebusy->addAttendee(att); |
416 | 416 | ||
417 | kdDebug() << "calendarview: schedule_publish_freebusy: startDate: " | 417 | kdDebug() << "calendarview: schedule_publish_freebusy: startDate: " |
418 | << KGlobal::locale()->formatDateTime( start ) << " End Date: " | 418 | << KGlobal::locale()->formatDateTime( start ) << " End Date: " |
419 | << KGlobal::locale()->formatDateTime( end ) << endl; | 419 | << KGlobal::locale()->formatDateTime( end ) << endl; |
420 | 420 | ||
421 | if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { | 421 | if (mOutgoing->addMessage(freebusy,Scheduler::Reply)) { |
422 | delete item; | 422 | delete item; |
423 | emit numMessagesChanged(mMessageListView->childCount()); | 423 | emit numMessagesChanged(mMessageListView->childCount()); |
424 | delete(freebusy); | 424 | delete(freebusy); |
425 | return true; | 425 | return true; |
426 | } | 426 | } |
427 | return false; | 427 | return false; |
428 | } else { | 428 | } else { |
429 | return incomeDefault(item); | 429 | return incomeDefault(item); |
430 | } | 430 | } |
431 | return false; | 431 | return false; |
432 | } | 432 | } |
433 | 433 | ||
434 | bool IncomingDialog::automaticAction(ScheduleItemIn *item) | 434 | bool IncomingDialog::automaticAction(ScheduleItemIn *item) |
435 | { | 435 | { |
436 | bool autoAction = false; | 436 | bool autoAction = false; |
437 | IncidenceBase *inc = item->event(); | 437 | IncidenceBase *inc = item->event(); |
438 | Scheduler::Method method = item->method(); | 438 | Scheduler::Method method = item->method(); |
439 | 439 | ||
440 | if( inc->type()=="FreeBusy" ) { | 440 | if( inc->typeID() == freebusyID ) { |
441 | if ( method==Scheduler::Request ) { | 441 | if ( method==Scheduler::Request ) { |
442 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 442 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
443 | // reply freebusy information | 443 | // reply freebusy information |
444 | if ( checkOrganizerInAddressbook(inc->organizer()) ) { | 444 | if ( checkOrganizerInAddressbook(inc->organizer()) ) { |
445 | incomeRequest(item); | 445 | incomeRequest(item); |
446 | } | 446 | } |
447 | } else return false; | 447 | } else return false; |
448 | } else { | 448 | } else { |
449 | 449 | ||
450 | if ( method==Scheduler::Reply ) { | 450 | if ( method==Scheduler::Reply ) { |
451 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 451 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
452 | // insert freebusy information | 452 | // insert freebusy information |
453 | //if ( checkAttendeesInAddressbook(inc) ) | 453 | //if ( checkAttendeesInAddressbook(inc) ) |
454 | 454 | ||
455 | } else return false; | 455 | } else return false; |
456 | } else { | 456 | } else { |
457 | if ( method==Scheduler::Publish) { | 457 | if ( method==Scheduler::Publish) { |
458 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { | 458 | if ( KOPrefs::instance()->mIMIPAutoFreeBusy==KOPrefs::addressbookAuto ) { |
459 | // insert freebusy information | 459 | // insert freebusy information |
460 | //if ( checkOrganizerInAddressbook(inc->organizer()) ) | 460 | //if ( checkOrganizerInAddressbook(inc->organizer()) ) |
461 | 461 | ||
462 | } | 462 | } |
463 | } else return false; | 463 | } else return false; |
464 | } | 464 | } |
465 | } | 465 | } |
466 | } | 466 | } |
467 | 467 | ||
468 | if ( inc->type()=="Event" ) { | 468 | if ( inc->typeID() == eventID ) { |
469 | if ( method==Scheduler::Request || method==Scheduler::Publish ) { | 469 | if ( method==Scheduler::Request || method==Scheduler::Publish ) { |
470 | if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { | 470 | if ( KOPrefs::instance()->mIMIPAutoInsertRequest==KOPrefs::addressbookAuto ) { |
471 | // insert event | 471 | // insert event |
472 | if ( checkOrganizerInAddressbook(inc->organizer()) ) | 472 | if ( checkOrganizerInAddressbook(inc->organizer()) ) |
473 | autoAction = acceptMessage(item); | 473 | autoAction = acceptMessage(item); |
474 | } else return false; | 474 | } else return false; |
475 | } else { | 475 | } else { |
476 | 476 | ||
477 | if ( method==Scheduler::Reply ) { | 477 | if ( method==Scheduler::Reply ) { |
478 | if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { | 478 | if ( KOPrefs::instance()->mIMIPAutoInsertReply==KOPrefs::addressbookAuto ) { |
479 | // update event information | 479 | // update event information |
480 | if ( checkAttendeesInAddressbook(inc) ) | 480 | if ( checkAttendeesInAddressbook(inc) ) |
481 | autoAction = acceptMessage(item); | 481 | autoAction = acceptMessage(item); |
482 | } else return false; | 482 | } else return false; |
483 | } else { | 483 | } else { |
484 | 484 | ||
485 | if ( method==Scheduler::Refresh ) { | 485 | if ( method==Scheduler::Refresh ) { |
486 | if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { | 486 | if ( KOPrefs::instance()->mIMIPAutoRefresh==KOPrefs::addressbookAuto ) { |
487 | // send refresh-information | 487 | // send refresh-information |
488 | if ( checkAttendeesInAddressbook(inc) ) | 488 | if ( checkAttendeesInAddressbook(inc) ) |
489 | autoAction = acceptMessage(item); | 489 | autoAction = acceptMessage(item); |
490 | else return false; | 490 | else return false; |
491 | } else return false; | 491 | } else return false; |
492 | } else return false; | 492 | } else return false; |
493 | } | 493 | } |
494 | } | 494 | } |
495 | } | 495 | } |
496 | return autoAction; | 496 | return autoAction; |
497 | } | 497 | } |
498 | 498 | ||
499 | bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) | 499 | bool IncomingDialog::checkOrganizerInAddressbook(QString organizer) |
500 | { | 500 | { |
501 | bool inBook = false; | 501 | bool inBook = false; |
502 | #ifndef KORG_NOKABC | 502 | #ifndef KORG_NOKABC |
503 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 503 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
504 | KABC::Addressee::List addressList; | 504 | KABC::Addressee::List addressList; |
505 | addressList = add_book->findByEmail(organizer); | 505 | addressList = add_book->findByEmail(organizer); |
506 | if ( addressList.size()>0 ) inBook = true; | 506 | if ( addressList.size()>0 ) inBook = true; |
507 | #endif | 507 | #endif |
508 | return inBook; | 508 | return inBook; |
509 | } | 509 | } |
510 | 510 | ||
511 | bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) | 511 | bool IncomingDialog::checkAttendeesInAddressbook(IncidenceBase *inc) |
512 | { | 512 | { |
513 | bool inBook = false; | 513 | bool inBook = false; |
514 | #ifndef KORG_NOKABC | 514 | #ifndef KORG_NOKABC |
515 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 515 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
516 | KABC::Addressee::List addressList; | 516 | KABC::Addressee::List addressList; |
517 | QPtrList <Attendee> attendees; | 517 | QPtrList <Attendee> attendees; |
518 | Attendee *att; | 518 | Attendee *att; |
519 | attendees = inc->attendees(); | 519 | attendees = inc->attendees(); |
520 | for (att=attendees.first();att;att=attendees.next()) { | 520 | for (att=attendees.first();att;att=attendees.next()) { |
521 | addressList = add_book->findByEmail(att->email()); | 521 | addressList = add_book->findByEmail(att->email()); |
522 | if (addressList.size()>0 ) inBook = true; | 522 | if (addressList.size()>0 ) inBook = true; |
523 | } | 523 | } |
524 | #endif | 524 | #endif |
525 | return inBook; | 525 | return inBook; |
526 | } | 526 | } |
527 | 527 | ||
528 | //#include "incomingdialog.moc" | 528 | //#include "incomingdialog.moc" |
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 1320a2e..b2b136a 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -1,1654 +1,1654 @@ | |||
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 | myPix.resize( 1, 1 ); | 84 | myPix.resize( 1, 1 ); |
85 | mRows = rows; | 85 | mRows = rows; |
86 | 86 | ||
87 | mRedrawNeeded = true; | 87 | mRedrawNeeded = true; |
88 | setMinimumHeight( 20 ); | 88 | setMinimumHeight( 20 ); |
89 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 89 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
90 | 90 | ||
91 | enableClipper(true); | 91 | enableClipper(true); |
92 | 92 | ||
93 | setHScrollBarMode(AlwaysOff); | 93 | setHScrollBarMode(AlwaysOff); |
94 | setVScrollBarMode(AlwaysOff); | 94 | setVScrollBarMode(AlwaysOff); |
95 | 95 | ||
96 | resizeContents(50,mRows * mCellHeight); | 96 | resizeContents(50,mRows * mCellHeight); |
97 | 97 | ||
98 | viewport()->setBackgroundMode( PaletteBackground ); | 98 | viewport()->setBackgroundMode( PaletteBackground ); |
99 | } | 99 | } |
100 | 100 | ||
101 | void TimeLabels::setCellHeight(int height) | 101 | void TimeLabels::setCellHeight(int height) |
102 | { | 102 | { |
103 | mCellHeight = height; | 103 | mCellHeight = height; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | 106 | /* |
107 | Optimization so that only the "dirty" portion of the scroll view | 107 | Optimization so that only the "dirty" portion of the scroll view |
108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. | 108 | is redrawn. Unfortunately, this is not called by default paintEvent() method. |
109 | */ | 109 | */ |
110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) | 110 | void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) |
111 | { | 111 | { |
112 | 112 | ||
113 | cx = contentsX() + frameWidth()*2; | 113 | cx = contentsX() + frameWidth()*2; |
114 | cw = contentsWidth() ; | 114 | cw = contentsWidth() ; |
115 | // end of workaround | 115 | // end of workaround |
116 | 116 | ||
117 | int cell = ((int)(cy/mCellHeight)); | 117 | int cell = ((int)(cy/mCellHeight)); |
118 | int y = cell * mCellHeight; | 118 | int y = cell * mCellHeight; |
119 | QFontMetrics fm = fontMetrics(); | 119 | QFontMetrics fm = fontMetrics(); |
120 | QString hour; | 120 | QString hour; |
121 | QString suffix = "am"; | 121 | QString suffix = "am"; |
122 | int timeHeight = fm.ascent(); | 122 | int timeHeight = fm.ascent(); |
123 | QFont nFont = font(); | 123 | QFont nFont = font(); |
124 | p->setFont( font()); | 124 | p->setFont( font()); |
125 | 125 | ||
126 | if (!KGlobal::locale()->use12Clock()) { | 126 | if (!KGlobal::locale()->use12Clock()) { |
127 | suffix = "00"; | 127 | suffix = "00"; |
128 | } else | 128 | } else |
129 | if (cell > 11) suffix = "pm"; | 129 | if (cell > 11) suffix = "pm"; |
130 | 130 | ||
131 | if ( timeHeight > mCellHeight ) { | 131 | if ( timeHeight > mCellHeight ) { |
132 | timeHeight = mCellHeight-1; | 132 | timeHeight = mCellHeight-1; |
133 | int pointS = nFont.pointSize(); | 133 | int pointS = nFont.pointSize(); |
134 | while ( pointS > 4 ) { | 134 | while ( pointS > 4 ) { |
135 | nFont.setPointSize( pointS ); | 135 | nFont.setPointSize( pointS ); |
136 | fm = QFontMetrics( nFont ); | 136 | fm = QFontMetrics( nFont ); |
137 | if ( fm.ascent() < mCellHeight ) | 137 | if ( fm.ascent() < mCellHeight ) |
138 | break; | 138 | break; |
139 | -- pointS; | 139 | -- pointS; |
140 | } | 140 | } |
141 | fm = QFontMetrics( nFont ); | 141 | fm = QFontMetrics( nFont ); |
142 | timeHeight = fm.ascent(); | 142 | timeHeight = fm.ascent(); |
143 | } | 143 | } |
144 | //timeHeight -= (timeHeight/4-2); | 144 | //timeHeight -= (timeHeight/4-2); |
145 | QFont sFont = nFont; | 145 | QFont sFont = nFont; |
146 | sFont.setPointSize( sFont.pointSize()/2 ); | 146 | sFont.setPointSize( sFont.pointSize()/2 ); |
147 | QFontMetrics fmS( sFont ); | 147 | QFontMetrics fmS( sFont ); |
148 | int sHei = fmS.ascent() ; | 148 | int sHei = fmS.ascent() ; |
149 | //sHei -= (sHei/4-2); | 149 | //sHei -= (sHei/4-2); |
150 | int startW = mMiniWidth - frameWidth()-2 ; | 150 | int startW = mMiniWidth - frameWidth()-2 ; |
151 | int tw2 = fmS.width(suffix); | 151 | int tw2 = fmS.width(suffix); |
152 | timeHeight = (timeHeight-1) /2 -1; | 152 | timeHeight = (timeHeight-1) /2 -1; |
153 | //testline | 153 | //testline |
154 | //p->drawLine(0,0,0,contentsHeight()); | 154 | //p->drawLine(0,0,0,contentsHeight()); |
155 | while (y < cy + ch+mCellHeight) { | 155 | while (y < cy + ch+mCellHeight) { |
156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); | 156 | p->drawLine(startW-tw2+1 ,y,cw+2,y); |
157 | hour.setNum(cell); | 157 | hour.setNum(cell); |
158 | // handle 24h and am/pm time formats | 158 | // handle 24h and am/pm time formats |
159 | if (KGlobal::locale()->use12Clock()) { | 159 | if (KGlobal::locale()->use12Clock()) { |
160 | if (cell == 12) suffix = "pm"; | 160 | if (cell == 12) suffix = "pm"; |
161 | if (cell == 0) hour.setNum(12); | 161 | if (cell == 0) hour.setNum(12); |
162 | if (cell > 12) hour.setNum(cell - 12); | 162 | if (cell > 12) hour.setNum(cell - 12); |
163 | } | 163 | } |
164 | 164 | ||
165 | // center and draw the time label | 165 | // center and draw the time label |
166 | int timeWidth = fm.width(hour); | 166 | int timeWidth = fm.width(hour); |
167 | int offset = startW - timeWidth - tw2 -1 ; | 167 | int offset = startW - timeWidth - tw2 -1 ; |
168 | p->setFont( nFont ); | 168 | p->setFont( nFont ); |
169 | p->drawText( offset, y+ timeHeight, hour); | 169 | p->drawText( offset, y+ timeHeight, hour); |
170 | p->setFont( sFont ); | 170 | p->setFont( sFont ); |
171 | offset = startW - tw2; | 171 | offset = startW - tw2; |
172 | p->drawText( offset, y -1, suffix); | 172 | p->drawText( offset, y -1, suffix); |
173 | 173 | ||
174 | // increment indices | 174 | // increment indices |
175 | y += mCellHeight; | 175 | y += mCellHeight; |
176 | cell++; | 176 | cell++; |
177 | } | 177 | } |
178 | 178 | ||
179 | 179 | ||
180 | 180 | ||
181 | 181 | ||
182 | } | 182 | } |
183 | 183 | ||
184 | /** | 184 | /** |
185 | Calculates the minimum width. | 185 | Calculates the minimum width. |
186 | */ | 186 | */ |
187 | int TimeLabels::minimumWidth() const | 187 | int TimeLabels::minimumWidth() const |
188 | { | 188 | { |
189 | return mMiniWidth; | 189 | return mMiniWidth; |
190 | } | 190 | } |
191 | 191 | ||
192 | /** updates widget's internal state */ | 192 | /** updates widget's internal state */ |
193 | void TimeLabels::updateConfig() | 193 | void TimeLabels::updateConfig() |
194 | { | 194 | { |
195 | mRedrawNeeded = true; | 195 | mRedrawNeeded = true; |
196 | // set the font | 196 | // set the font |
197 | // config->setGroup("Fonts"); | 197 | // config->setGroup("Fonts"); |
198 | // QFont font = config->readFontEntry("TimeBar Font"); | 198 | // QFont font = config->readFontEntry("TimeBar Font"); |
199 | setFont(KOPrefs::instance()->mTimeBarFont); | 199 | setFont(KOPrefs::instance()->mTimeBarFont); |
200 | QString test = "20"; | 200 | QString test = "20"; |
201 | if (KGlobal::locale()->use12Clock()) | 201 | if (KGlobal::locale()->use12Clock()) |
202 | test = "12"; | 202 | test = "12"; |
203 | mMiniWidth = fontMetrics().width(test); | 203 | mMiniWidth = fontMetrics().width(test); |
204 | if (KGlobal::locale()->use12Clock()) | 204 | if (KGlobal::locale()->use12Clock()) |
205 | test = "pm"; | 205 | test = "pm"; |
206 | else { | 206 | else { |
207 | test = "00"; | 207 | test = "00"; |
208 | } | 208 | } |
209 | QFont sFont = font(); | 209 | QFont sFont = font(); |
210 | sFont.setPointSize( sFont.pointSize()/2 ); | 210 | sFont.setPointSize( sFont.pointSize()/2 ); |
211 | QFontMetrics fmS( sFont ); | 211 | QFontMetrics fmS( sFont ); |
212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; | 212 | mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; |
213 | // update geometry restrictions based on new settings | 213 | // update geometry restrictions based on new settings |
214 | setFixedWidth( mMiniWidth ); | 214 | setFixedWidth( mMiniWidth ); |
215 | 215 | ||
216 | // update HourSize | 216 | // update HourSize |
217 | mCellHeight = KOPrefs::instance()->mHourSize*4; | 217 | mCellHeight = KOPrefs::instance()->mHourSize*4; |
218 | resizeContents(mMiniWidth,mRows * mCellHeight+1); | 218 | resizeContents(mMiniWidth,mRows * mCellHeight+1); |
219 | } | 219 | } |
220 | 220 | ||
221 | /** update time label positions */ | 221 | /** update time label positions */ |
222 | void TimeLabels::positionChanged() | 222 | void TimeLabels::positionChanged() |
223 | { | 223 | { |
224 | int adjustment = mAgenda->contentsY(); | 224 | int adjustment = mAgenda->contentsY(); |
225 | setContentsPos(0, adjustment); | 225 | setContentsPos(0, adjustment); |
226 | } | 226 | } |
227 | 227 | ||
228 | /** */ | 228 | /** */ |
229 | void TimeLabels::setAgenda(KOAgenda* agenda) | 229 | void TimeLabels::setAgenda(KOAgenda* agenda) |
230 | { | 230 | { |
231 | mAgenda = agenda; | 231 | mAgenda = agenda; |
232 | } | 232 | } |
233 | 233 | ||
234 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | 234 | void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) |
235 | { | 235 | { |
236 | mMouseDownY = e->pos().y(); | 236 | mMouseDownY = e->pos().y(); |
237 | mOrgCap = topLevelWidget()->caption(); | 237 | mOrgCap = topLevelWidget()->caption(); |
238 | } | 238 | } |
239 | 239 | ||
240 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 240 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
241 | { | 241 | { |
242 | int diff = mMouseDownY - e->pos().y(); | 242 | int diff = mMouseDownY - e->pos().y(); |
243 | if ( diff < 10 && diff > -10 ) | 243 | if ( diff < 10 && diff > -10 ) |
244 | return; | 244 | return; |
245 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 245 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
246 | if ( tSize < 4 ) | 246 | if ( tSize < 4 ) |
247 | tSize = 4; | 247 | tSize = 4; |
248 | if ( tSize > 22 ) | 248 | if ( tSize > 22 ) |
249 | tSize = 22; | 249 | tSize = 22; |
250 | tSize = (tSize-2)/2; | 250 | tSize = (tSize-2)/2; |
251 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 251 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
252 | 252 | ||
253 | } | 253 | } |
254 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 254 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
255 | { | 255 | { |
256 | topLevelWidget()->setCaption( mOrgCap ); | 256 | topLevelWidget()->setCaption( mOrgCap ); |
257 | int diff = mMouseDownY - e->pos().y(); | 257 | int diff = mMouseDownY - e->pos().y(); |
258 | if ( diff < 10 && diff > -10 ) | 258 | if ( diff < 10 && diff > -10 ) |
259 | return; | 259 | return; |
260 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 260 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
261 | if ( tSize < 4 ) | 261 | if ( tSize < 4 ) |
262 | tSize = 4; | 262 | tSize = 4; |
263 | if ( tSize > 22 ) | 263 | if ( tSize > 22 ) |
264 | tSize = 22; | 264 | tSize = 22; |
265 | tSize = (tSize/2)*2; | 265 | tSize = (tSize/2)*2; |
266 | if ( tSize == KOPrefs::instance()->mHourSize ) | 266 | if ( tSize == KOPrefs::instance()->mHourSize ) |
267 | return; | 267 | return; |
268 | KOPrefs::instance()->mHourSize = tSize; | 268 | KOPrefs::instance()->mHourSize = tSize; |
269 | emit scaleChanged(); | 269 | emit scaleChanged(); |
270 | } | 270 | } |
271 | 271 | ||
272 | /** This is called in response to repaint() */ | 272 | /** This is called in response to repaint() */ |
273 | void TimeLabels::paintEvent(QPaintEvent*) | 273 | void TimeLabels::paintEvent(QPaintEvent*) |
274 | { | 274 | { |
275 | 275 | ||
276 | // kdDebug() << "paintevent..." << endl; | 276 | // kdDebug() << "paintevent..." << endl; |
277 | // this is another hack! | 277 | // this is another hack! |
278 | // QPainter painter(this); | 278 | // QPainter painter(this); |
279 | //QString c | 279 | //QString c |
280 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 280 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
281 | } | 281 | } |
282 | 282 | ||
283 | //////////////////////////////////////////////////////////////////////////// | 283 | //////////////////////////////////////////////////////////////////////////// |
284 | 284 | ||
285 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 285 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
286 | : QFrame(parent,name) | 286 | : QFrame(parent,name) |
287 | { | 287 | { |
288 | mColumns = 1; | 288 | mColumns = 1; |
289 | mTopBox = 0; | 289 | mTopBox = 0; |
290 | mLocation = loc; | 290 | mLocation = loc; |
291 | mTopLayout = 0; | 291 | mTopLayout = 0; |
292 | mPaintWidget = 0; | 292 | mPaintWidget = 0; |
293 | mXOffset = 0; | 293 | mXOffset = 0; |
294 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 294 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
295 | else mPixmap = SmallIcon("1downarrow"); | 295 | else mPixmap = SmallIcon("1downarrow"); |
296 | mEnabled.resize(mColumns); | 296 | mEnabled.resize(mColumns); |
297 | mEnabled.fill( false ); | 297 | mEnabled.fill( false ); |
298 | setMinimumHeight(mPixmap.height()); | 298 | setMinimumHeight(mPixmap.height()); |
299 | } | 299 | } |
300 | 300 | ||
301 | EventIndicator::~EventIndicator() | 301 | EventIndicator::~EventIndicator() |
302 | { | 302 | { |
303 | } | 303 | } |
304 | 304 | ||
305 | void EventIndicator::drawContents(QPainter *p) | 305 | void EventIndicator::drawContents(QPainter *p) |
306 | { | 306 | { |
307 | 307 | ||
308 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 308 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
309 | KDGanttSplitterHandle* han = 0; | 309 | KDGanttSplitterHandle* han = 0; |
310 | if ( mPaintWidget ) | 310 | if ( mPaintWidget ) |
311 | han = mPaintWidget->firstHandle(); | 311 | han = mPaintWidget->firstHandle(); |
312 | if ( ! han ) { | 312 | if ( ! han ) { |
313 | int i; | 313 | int i; |
314 | for(i=0;i<mColumns;++i) { | 314 | for(i=0;i<mColumns;++i) { |
315 | if (mEnabled[i]) { | 315 | if (mEnabled[i]) { |
316 | int cellWidth = contentsRect().right()/mColumns; | 316 | int cellWidth = contentsRect().right()/mColumns; |
317 | int xOffset = KOGlobals::self()->reverseLayout() ? | 317 | int xOffset = KOGlobals::self()->reverseLayout() ? |
318 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 318 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
319 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 319 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
320 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 320 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
321 | } | 321 | } |
322 | } | 322 | } |
323 | } else { | 323 | } else { |
324 | han->repaint(); | 324 | han->repaint(); |
325 | //mPaintWidget->setBackgroundColor( red ); | 325 | //mPaintWidget->setBackgroundColor( red ); |
326 | 326 | ||
327 | QPainter pa( han ); | 327 | QPainter pa( han ); |
328 | int i; | 328 | int i; |
329 | bool setColor = false; | 329 | bool setColor = false; |
330 | for(i=0;i<mColumns;++i) { | 330 | for(i=0;i<mColumns;++i) { |
331 | if (mEnabled[i]) { | 331 | if (mEnabled[i]) { |
332 | setColor = true; | 332 | setColor = true; |
333 | 333 | ||
334 | int cellWidth = contentsRect().right()/mColumns; | 334 | int cellWidth = contentsRect().right()/mColumns; |
335 | int xOffset = KOGlobals::self()->reverseLayout() ? | 335 | int xOffset = KOGlobals::self()->reverseLayout() ? |
336 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 336 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
337 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 337 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
338 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 338 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
339 | //qDebug("222draw pix %d ",xOffset ); | 339 | //qDebug("222draw pix %d ",xOffset ); |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | } | 343 | } |
344 | pa.end(); | 344 | pa.end(); |
345 | 345 | ||
346 | } | 346 | } |
347 | } | 347 | } |
348 | 348 | ||
349 | void EventIndicator::setXOffset( int x ) | 349 | void EventIndicator::setXOffset( int x ) |
350 | { | 350 | { |
351 | mXOffset = x; | 351 | mXOffset = x; |
352 | } | 352 | } |
353 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 353 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
354 | { | 354 | { |
355 | mPaintWidget = w; | 355 | mPaintWidget = w; |
356 | setMaximumHeight(0); | 356 | setMaximumHeight(0); |
357 | setMinimumHeight(0); | 357 | setMinimumHeight(0); |
358 | } | 358 | } |
359 | void EventIndicator::changeColumns(int columns) | 359 | void EventIndicator::changeColumns(int columns) |
360 | { | 360 | { |
361 | mColumns = columns; | 361 | mColumns = columns; |
362 | mEnabled.resize(mColumns); | 362 | mEnabled.resize(mColumns); |
363 | 363 | ||
364 | update(); | 364 | update(); |
365 | } | 365 | } |
366 | 366 | ||
367 | void EventIndicator::enableColumn(int column, bool enable) | 367 | void EventIndicator::enableColumn(int column, bool enable) |
368 | { | 368 | { |
369 | mEnabled[column] = enable; | 369 | mEnabled[column] = enable; |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | //////////////////////////////////////////////////////////////////////////// | 373 | //////////////////////////////////////////////////////////////////////////// |
374 | //////////////////////////////////////////////////////////////////////////// | 374 | //////////////////////////////////////////////////////////////////////////// |
375 | //////////////////////////////////////////////////////////////////////////// | 375 | //////////////////////////////////////////////////////////////////////////// |
376 | 376 | ||
377 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 377 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
378 | KOEventView (cal,parent,name) | 378 | KOEventView (cal,parent,name) |
379 | { | 379 | { |
380 | mBlockUpdating = true; | 380 | mBlockUpdating = true; |
381 | mStartHour = 8; | 381 | mStartHour = 8; |
382 | mSelectedDates.append(QDate::currentDate()); | 382 | mSelectedDates.append(QDate::currentDate()); |
383 | 383 | ||
384 | mLayoutDayLabels = 0; | 384 | mLayoutDayLabels = 0; |
385 | mDayLabelsFrame = 0; | 385 | mDayLabelsFrame = 0; |
386 | mDayLabels = 0; | 386 | mDayLabels = 0; |
387 | bool isRTL = KOGlobals::self()->reverseLayout(); | 387 | bool isRTL = KOGlobals::self()->reverseLayout(); |
388 | QPixmap expandPix; | 388 | QPixmap expandPix; |
389 | if ( KOPrefs::instance()->mVerticalScreen ) { | 389 | if ( KOPrefs::instance()->mVerticalScreen ) { |
390 | expandPix = SmallIcon( "1updownarrow" ); | 390 | expandPix = SmallIcon( "1updownarrow" ); |
391 | } else { | 391 | } else { |
392 | expandPix = SmallIcon("1leftrightarrow" ); | 392 | expandPix = SmallIcon("1leftrightarrow" ); |
393 | } | 393 | } |
394 | 394 | ||
395 | QBoxLayout *topLayout = new QVBoxLayout(this); | 395 | QBoxLayout *topLayout = new QVBoxLayout(this); |
396 | 396 | ||
397 | // Create day name labels for agenda columns | 397 | // Create day name labels for agenda columns |
398 | // Create agenda splitter | 398 | // Create agenda splitter |
399 | 399 | ||
400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 400 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 401 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
402 | topLayout->addWidget( mSplitterAgenda ); | 402 | topLayout->addWidget( mSplitterAgenda ); |
403 | mAllDayFrame = new QHBox(mSplitterAgenda); | 403 | mAllDayFrame = new QHBox(mSplitterAgenda); |
404 | mAllDayFrame->setFocusPolicy(NoFocus); | 404 | mAllDayFrame->setFocusPolicy(NoFocus); |
405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 405 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
406 | agendaFrame->setFocusPolicy(NoFocus); | 406 | agendaFrame->setFocusPolicy(NoFocus); |
407 | 407 | ||
408 | // Create all-day agenda widget | 408 | // Create all-day agenda widget |
409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 409 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
410 | 410 | ||
411 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 411 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
412 | mExpandButton->setPixmap( expandPix ); | 412 | mExpandButton->setPixmap( expandPix ); |
413 | int widebut = mExpandButton->sizeHint().width()+4; | 413 | int widebut = mExpandButton->sizeHint().width()+4; |
414 | int heibut = mExpandButton->sizeHint().height()+4; | 414 | int heibut = mExpandButton->sizeHint().height()+4; |
415 | if ( heibut > widebut ) | 415 | if ( heibut > widebut ) |
416 | widebut = heibut ; | 416 | widebut = heibut ; |
417 | 417 | ||
418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 418 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
419 | // QSizePolicy::Fixed ) ); | 419 | // QSizePolicy::Fixed ) ); |
420 | mExpandButton->setFixedSize( widebut, widebut); | 420 | mExpandButton->setFixedSize( widebut, widebut); |
421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 421 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
422 | mExpandButton->setFocusPolicy(NoFocus); | 422 | mExpandButton->setFocusPolicy(NoFocus); |
423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 423 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
424 | mAllDayAgenda->setFocusPolicy(NoFocus); | 424 | mAllDayAgenda->setFocusPolicy(NoFocus); |
425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 425 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
426 | 426 | ||
427 | // Create event context menu for all day agenda | 427 | // Create event context menu for all day agenda |
428 | //mAllDayAgendaPopup = eventPopup(); | 428 | //mAllDayAgendaPopup = eventPopup(); |
429 | 429 | ||
430 | // Create agenda frame | 430 | // Create agenda frame |
431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 431 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 432 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
433 | 433 | ||
434 | // create event indicator bars | 434 | // create event indicator bars |
435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 435 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
436 | #ifndef DESKTOP_VERSION | 436 | #ifndef DESKTOP_VERSION |
437 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 437 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
438 | #endif | 438 | #endif |
439 | mDayLabelsFrame = new QHBox(agendaFrame); | 439 | mDayLabelsFrame = new QHBox(agendaFrame); |
440 | //topLayout->addWidget(mDayLabelsFrame); | 440 | //topLayout->addWidget(mDayLabelsFrame); |
441 | mDayLabels = new QFrame (mDayLabelsFrame); | 441 | mDayLabels = new QFrame (mDayLabelsFrame); |
442 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 442 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
443 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 443 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
444 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 444 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
445 | 445 | ||
446 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 446 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
447 | agendaFrame); | 447 | agendaFrame); |
448 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 448 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
449 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 449 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
450 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 450 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
451 | 451 | ||
452 | // Create time labels | 452 | // Create time labels |
453 | mTimeLabels = new TimeLabels(24,agendaFrame); | 453 | mTimeLabels = new TimeLabels(24,agendaFrame); |
454 | agendaLayout->addWidget(mTimeLabels,2,0); | 454 | agendaLayout->addWidget(mTimeLabels,2,0); |
455 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 455 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
456 | this,SLOT(updateConfig())); | 456 | this,SLOT(updateConfig())); |
457 | 457 | ||
458 | // Create agenda | 458 | // Create agenda |
459 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 459 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
460 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 460 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
461 | agendaLayout->setColStretch(1,1); | 461 | agendaLayout->setColStretch(1,1); |
462 | mAgenda->setFocusPolicy(NoFocus); | 462 | mAgenda->setFocusPolicy(NoFocus); |
463 | // Create event context menu for agenda | 463 | // Create event context menu for agenda |
464 | mAllAgendaPopup = eventPopup(); | 464 | mAllAgendaPopup = eventPopup(); |
465 | 465 | ||
466 | #if 0 | 466 | #if 0 |
467 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 467 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
468 | i18n("Toggle Alarm"),mAgenda, | 468 | i18n("Toggle Alarm"),mAgenda, |
469 | SLOT(popupAlarm()),true); | 469 | SLOT(popupAlarm()),true); |
470 | 470 | ||
471 | #endif | 471 | #endif |
472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 472 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 473 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
474 | 474 | ||
475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 475 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 476 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
477 | mAgenda->setPopup( mAllAgendaPopup ); | 477 | mAgenda->setPopup( mAllAgendaPopup ); |
478 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | 478 | mAllDayAgenda->setPopup( mAllAgendaPopup ); |
479 | // make connections between dependent widgets | 479 | // make connections between dependent widgets |
480 | mTimeLabels->setAgenda(mAgenda); | 480 | mTimeLabels->setAgenda(mAgenda); |
481 | 481 | ||
482 | // Update widgets to reflect user preferences | 482 | // Update widgets to reflect user preferences |
483 | // updateConfig(); | 483 | // updateConfig(); |
484 | 484 | ||
485 | // createDayLabels(); | 485 | // createDayLabels(); |
486 | 486 | ||
487 | // these blank widgets make the All Day Event box line up with the agenda | 487 | // these blank widgets make the All Day Event box line up with the agenda |
488 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 488 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
489 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 489 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
490 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 490 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
491 | 491 | ||
492 | // Scrolling | 492 | // Scrolling |
493 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 493 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
494 | mTimeLabels, SLOT(positionChanged())); | 494 | mTimeLabels, SLOT(positionChanged())); |
495 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 495 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
496 | SLOT(setContentsPos(int))); | 496 | SLOT(setContentsPos(int))); |
497 | 497 | ||
498 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 498 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
499 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 499 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
500 | 500 | ||
501 | // Create/Show/Edit/Delete Event | 501 | // Create/Show/Edit/Delete Event |
502 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 502 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
503 | SLOT(newEvent(int,int))); | 503 | SLOT(newEvent(int,int))); |
504 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 504 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
505 | SLOT(newTodo(int,int))); | 505 | SLOT(newTodo(int,int))); |
506 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 506 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
507 | SLOT(newEvent(int,int,int,int))); | 507 | SLOT(newEvent(int,int,int,int))); |
508 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 508 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
509 | SLOT(newEventAllDay(int,int))); | 509 | SLOT(newEventAllDay(int,int))); |
510 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 510 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
511 | SLOT(newTodoAllDay(int,int))); | 511 | SLOT(newTodoAllDay(int,int))); |
512 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 512 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
513 | SLOT(newEventAllDay(int,int))); | 513 | SLOT(newEventAllDay(int,int))); |
514 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 514 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
515 | SLOT(newTimeSpanSelected(int,int,int,int))); | 515 | SLOT(newTimeSpanSelected(int,int,int,int))); |
516 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 516 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
517 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 517 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
518 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 518 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
519 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 519 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
520 | 520 | ||
521 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 521 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
522 | SIGNAL(editIncidenceSignal(Incidence *))); | 522 | SIGNAL(editIncidenceSignal(Incidence *))); |
523 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 523 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
524 | SIGNAL(editIncidenceSignal(Incidence *))); | 524 | SIGNAL(editIncidenceSignal(Incidence *))); |
525 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 525 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
526 | SIGNAL(showIncidenceSignal(Incidence *))); | 526 | SIGNAL(showIncidenceSignal(Incidence *))); |
527 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 527 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
528 | SIGNAL(showIncidenceSignal(Incidence *))); | 528 | SIGNAL(showIncidenceSignal(Incidence *))); |
529 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 529 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
530 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 530 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
531 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 531 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
532 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 532 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
533 | 533 | ||
534 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 534 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
535 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 535 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
536 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 536 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
537 | SLOT(updateEventDates(KOAgendaItem *, int))); | 537 | SLOT(updateEventDates(KOAgendaItem *, int))); |
538 | 538 | ||
539 | // event indicator update | 539 | // event indicator update |
540 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 540 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
541 | SLOT(updateEventIndicatorTop(int))); | 541 | SLOT(updateEventIndicatorTop(int))); |
542 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 542 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
543 | SLOT(updateEventIndicatorBottom(int))); | 543 | SLOT(updateEventIndicatorBottom(int))); |
544 | // drag signals | 544 | // drag signals |
545 | /* | 545 | /* |
546 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 546 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
547 | SLOT(startDrag(Event *))); | 547 | SLOT(startDrag(Event *))); |
548 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 548 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
549 | SLOT(startDrag(Event *))); | 549 | SLOT(startDrag(Event *))); |
550 | */ | 550 | */ |
551 | // synchronize selections | 551 | // synchronize selections |
552 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 552 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
553 | mAllDayAgenda, SLOT( deselectItem() ) ); | 553 | mAllDayAgenda, SLOT( deselectItem() ) ); |
554 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 554 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
555 | mAgenda, SLOT( deselectItem() ) ); | 555 | mAgenda, SLOT( deselectItem() ) ); |
556 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 556 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
557 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 557 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
558 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 558 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
559 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 559 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
560 | connect( mAgenda, SIGNAL( resizedSignal() ), | 560 | connect( mAgenda, SIGNAL( resizedSignal() ), |
561 | SLOT( updateConfig( ) ) ); | 561 | SLOT( updateConfig( ) ) ); |
562 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 562 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
563 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 563 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
564 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 564 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
565 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 565 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
566 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 566 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
567 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 567 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
568 | 568 | ||
569 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); | 569 | connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); |
570 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); | 570 | connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); |
571 | 571 | ||
572 | } | 572 | } |
573 | 573 | ||
574 | void KOAgendaView::toggleAllDay() | 574 | void KOAgendaView::toggleAllDay() |
575 | { | 575 | { |
576 | if ( mSplitterAgenda->firstHandle() ) | 576 | if ( mSplitterAgenda->firstHandle() ) |
577 | mSplitterAgenda->firstHandle()->toggle(); | 577 | mSplitterAgenda->firstHandle()->toggle(); |
578 | } | 578 | } |
579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 579 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
580 | { | 580 | { |
581 | calendar()->addIncidence( inc ); | 581 | calendar()->addIncidence( inc ); |
582 | 582 | ||
583 | if ( incOld ) { | 583 | if ( incOld ) { |
584 | if ( incOld->type() == "Todo" ) | 584 | if ( incOld->typeID() == todoID ) |
585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 585 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
586 | else | 586 | else |
587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 587 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
588 | } | 588 | } |
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | KOAgendaView::~KOAgendaView() | 592 | KOAgendaView::~KOAgendaView() |
593 | { | 593 | { |
594 | delete mAllAgendaPopup; | 594 | delete mAllAgendaPopup; |
595 | //delete mAllDayAgendaPopup; | 595 | //delete mAllDayAgendaPopup; |
596 | delete KOAgendaItem::paintPix(); | 596 | delete KOAgendaItem::paintPix(); |
597 | delete KOAgendaItem::paintPixSel(); | 597 | delete KOAgendaItem::paintPixSel(); |
598 | } | 598 | } |
599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 599 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
600 | { | 600 | { |
601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 601 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
602 | bool uc = false; | 602 | bool uc = false; |
603 | int ow = e->oldSize().width(); | 603 | int ow = e->oldSize().width(); |
604 | int oh = e->oldSize().height(); | 604 | int oh = e->oldSize().height(); |
605 | int w = e->size().width(); | 605 | int w = e->size().width(); |
606 | int h = e->size().height(); | 606 | int h = e->size().height(); |
607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 607 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 608 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
609 | uc = true; | 609 | uc = true; |
610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 610 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
611 | } | 611 | } |
612 | mUpcomingWidth = e->size().width() ; | 612 | mUpcomingWidth = e->size().width() ; |
613 | if ( mBlockUpdating || uc ) { | 613 | if ( mBlockUpdating || uc ) { |
614 | mBlockUpdating = false; | 614 | mBlockUpdating = false; |
615 | //mAgenda->setMinimumSize(800 , 600 ); | 615 | //mAgenda->setMinimumSize(800 , 600 ); |
616 | //qDebug("mAgenda->resize+++++++++++++++ "); | 616 | //qDebug("mAgenda->resize+++++++++++++++ "); |
617 | updateConfig(); | 617 | updateConfig(); |
618 | //qDebug("KOAgendaView::Updating now possible "); | 618 | //qDebug("KOAgendaView::Updating now possible "); |
619 | } else | 619 | } else |
620 | createDayLabels(); | 620 | createDayLabels(); |
621 | //qDebug("resizeEvent end "); | 621 | //qDebug("resizeEvent end "); |
622 | 622 | ||
623 | } | 623 | } |
624 | void KOAgendaView::slotDaylabelClicked( int num ) | 624 | void KOAgendaView::slotDaylabelClicked( int num ) |
625 | { | 625 | { |
626 | 626 | ||
627 | QDate firstDate = mSelectedDates.first(); | 627 | QDate firstDate = mSelectedDates.first(); |
628 | if ( num == -1 ) | 628 | if ( num == -1 ) |
629 | emit showDateView( 6, firstDate ); | 629 | emit showDateView( 6, firstDate ); |
630 | else if (num >= 0 ) { | 630 | else if (num >= 0 ) { |
631 | if ( mSelectedDates.count() == 1) | 631 | if ( mSelectedDates.count() == 1) |
632 | emit showDateView( 9, firstDate.addDays( num ) ); | 632 | emit showDateView( 9, firstDate.addDays( num ) ); |
633 | else | 633 | else |
634 | emit showDateView( 3, firstDate.addDays( num ) ); | 634 | emit showDateView( 3, firstDate.addDays( num ) ); |
635 | } | 635 | } |
636 | else | 636 | else |
637 | showDateView( 10, firstDate.addDays(1) ); | 637 | showDateView( 10, firstDate.addDays(1) ); |
638 | } | 638 | } |
639 | 639 | ||
640 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 640 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
641 | { | 641 | { |
642 | 642 | ||
643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 643 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 644 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
645 | mDayLabelsList.append( dayLabel ); | 645 | mDayLabelsList.append( dayLabel ); |
646 | mLayoutDayLabels->addWidget(dayLabel); | 646 | mLayoutDayLabels->addWidget(dayLabel); |
647 | return dayLabel ; | 647 | return dayLabel ; |
648 | } | 648 | } |
649 | 649 | ||
650 | void KOAgendaView::createDayLabels() | 650 | void KOAgendaView::createDayLabels() |
651 | { | 651 | { |
652 | 652 | ||
653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 653 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 654 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
655 | return; | 655 | return; |
656 | 656 | ||
657 | } | 657 | } |
658 | int newHight; | 658 | int newHight; |
659 | if ( !mSelectedDates.count()) | 659 | if ( !mSelectedDates.count()) |
660 | return; | 660 | return; |
661 | 661 | ||
662 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 662 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
663 | // It would remove some flickering and gain speed (since this is called by | 663 | // It would remove some flickering and gain speed (since this is called by |
664 | // each updateView() call) | 664 | // each updateView() call) |
665 | 665 | ||
666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 666 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 667 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
668 | if ( maxWid < 20 ) | 668 | if ( maxWid < 20 ) |
669 | maxWid = 20; | 669 | maxWid = 20; |
670 | 670 | ||
671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 671 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
672 | QFontMetrics fm ( dlf ); | 672 | QFontMetrics fm ( dlf ); |
673 | int selCount = mSelectedDates.count(); | 673 | int selCount = mSelectedDates.count(); |
674 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; | 674 | int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; |
675 | QString dayTest = "Mon 20"; | 675 | QString dayTest = "Mon 20"; |
676 | //QString dayTest = "Mon 20"; | 676 | //QString dayTest = "Mon 20"; |
677 | int wid = fm.width( dayTest ); | 677 | int wid = fm.width( dayTest ); |
678 | //maxWid -= ( selCount * 3 ); //working for QLabels | 678 | //maxWid -= ( selCount * 3 ); //working for QLabels |
679 | if ( QApplication::desktop()->width() <= 320 ) | 679 | if ( QApplication::desktop()->width() <= 320 ) |
680 | maxWid -= ( selCount * 3 ); //working for QPushButton | 680 | maxWid -= ( selCount * 3 ); //working for QPushButton |
681 | else | 681 | else |
682 | maxWid -= ( selCount * 3 ); //working for QPushButton | 682 | maxWid -= ( selCount * 3 ); //working for QPushButton |
683 | if ( maxWid < 0 ) | 683 | if ( maxWid < 0 ) |
684 | maxWid = 20; | 684 | maxWid = 20; |
685 | int needWid = wid * selCount; | 685 | int needWid = wid * selCount; |
686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 686 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
687 | //if ( needWid > maxWid ) | 687 | //if ( needWid > maxWid ) |
688 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 688 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
689 | while ( needWid > maxWid ) { | 689 | while ( needWid > maxWid ) { |
690 | dayTest = dayTest.left( dayTest.length() - 1 ); | 690 | dayTest = dayTest.left( dayTest.length() - 1 ); |
691 | wid = fm.width( dayTest ); | 691 | wid = fm.width( dayTest ); |
692 | needWid = wid * selCount; | 692 | needWid = wid * selCount; |
693 | } | 693 | } |
694 | int maxLen = dayTest.length(); | 694 | int maxLen = dayTest.length(); |
695 | int fontPoint = dlf.pointSize(); | 695 | int fontPoint = dlf.pointSize(); |
696 | if ( maxLen < 2 ) { | 696 | if ( maxLen < 2 ) { |
697 | int fontPoint = dlf.pointSize(); | 697 | int fontPoint = dlf.pointSize(); |
698 | while ( fontPoint > 4 ) { | 698 | while ( fontPoint > 4 ) { |
699 | --fontPoint; | 699 | --fontPoint; |
700 | dlf.setPointSize( fontPoint ); | 700 | dlf.setPointSize( fontPoint ); |
701 | QFontMetrics f( dlf ); | 701 | QFontMetrics f( dlf ); |
702 | wid = f.width( "30" ); | 702 | wid = f.width( "30" ); |
703 | needWid = wid * selCount; | 703 | needWid = wid * selCount; |
704 | if ( needWid < maxWid ) | 704 | if ( needWid < maxWid ) |
705 | break; | 705 | break; |
706 | } | 706 | } |
707 | maxLen = 2; | 707 | maxLen = 2; |
708 | } | 708 | } |
709 | //qDebug("Max len %d ", dayTest.length() ); | 709 | //qDebug("Max len %d ", dayTest.length() ); |
710 | 710 | ||
711 | QFontMetrics tempF( dlf ); | 711 | QFontMetrics tempF( dlf ); |
712 | newHight = tempF.height(); | 712 | newHight = tempF.height(); |
713 | mDayLabels->setFont( dlf ); | 713 | mDayLabels->setFont( dlf ); |
714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 714 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 715 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
716 | //mLayoutDayLabels->addSpacing( 2 ); | 716 | //mLayoutDayLabels->addSpacing( 2 ); |
717 | // QFont lFont = dlf; | 717 | // QFont lFont = dlf; |
718 | bool appendLabels = false; | 718 | bool appendLabels = false; |
719 | KOAgendaButton *dayLabel; | 719 | KOAgendaButton *dayLabel; |
720 | dayLabel = mDayLabelsList.first(); | 720 | dayLabel = mDayLabelsList.first(); |
721 | if ( !dayLabel ) { | 721 | if ( !dayLabel ) { |
722 | appendLabels = true; | 722 | appendLabels = true; |
723 | dayLabel = getNewDaylabel(); | 723 | dayLabel = getNewDaylabel(); |
724 | } | 724 | } |
725 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 725 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
726 | dayLabel->setFont( dlf ); | 726 | dayLabel->setFont( dlf ); |
727 | dayLabel->setNum( -1 ); | 727 | dayLabel->setNum( -1 ); |
728 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 728 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
729 | 729 | ||
730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 730 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
731 | dayLabel->show(); | 731 | dayLabel->show(); |
732 | DateList::ConstIterator dit; | 732 | DateList::ConstIterator dit; |
733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 733 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
734 | int counter = -1; | 734 | int counter = -1; |
735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 735 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
736 | ++counter; | 736 | ++counter; |
737 | QDate date = *dit; | 737 | QDate date = *dit; |
738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 738 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
739 | if ( ! appendLabels ) { | 739 | if ( ! appendLabels ) { |
740 | dayLabel = mDayLabelsList.next(); | 740 | dayLabel = mDayLabelsList.next(); |
741 | if ( !dayLabel ) | 741 | if ( !dayLabel ) |
742 | appendLabels = true; | 742 | appendLabels = true; |
743 | } | 743 | } |
744 | if ( appendLabels ) { | 744 | if ( appendLabels ) { |
745 | dayLabel = getNewDaylabel(); | 745 | dayLabel = getNewDaylabel(); |
746 | } | 746 | } |
747 | dayLabel->setMinimumWidth( 1 ); | 747 | dayLabel->setMinimumWidth( 1 ); |
748 | dayLabel->setMaximumWidth( 10240 ); | 748 | dayLabel->setMaximumWidth( 10240 ); |
749 | dayLabel->setFont( dlf ); | 749 | dayLabel->setFont( dlf ); |
750 | dayLabel->show(); | 750 | dayLabel->show(); |
751 | dayLabel->setAutoRepeat( false ); | 751 | dayLabel->setAutoRepeat( false ); |
752 | dayLabel->setNum( counter ); | 752 | dayLabel->setNum( counter ); |
753 | QString str; | 753 | QString str; |
754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 754 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 755 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
756 | switch ( maxLen ) { | 756 | switch ( maxLen ) { |
757 | case 2: | 757 | case 2: |
758 | str = QString::number( date.day() ); | 758 | str = QString::number( date.day() ); |
759 | break; | 759 | break; |
760 | 760 | ||
761 | case 3: | 761 | case 3: |
762 | str = dayName.left( 1 ) +QString::number( date.day()); | 762 | str = dayName.left( 1 ) +QString::number( date.day()); |
763 | 763 | ||
764 | break; | 764 | break; |
765 | case 4: | 765 | case 4: |
766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 766 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
767 | 767 | ||
768 | break; | 768 | break; |
769 | case 5: | 769 | case 5: |
770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 770 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
771 | 771 | ||
772 | break; | 772 | break; |
773 | case 6: | 773 | case 6: |
774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 774 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
775 | break; | 775 | break; |
776 | 776 | ||
777 | default: | 777 | default: |
778 | break; | 778 | break; |
779 | } | 779 | } |
780 | if ( oneday ) { | 780 | if ( oneday ) { |
781 | QString addString; | 781 | QString addString; |
782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 782 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
783 | addString = i18n("Today"); | 783 | addString = i18n("Today"); |
784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 784 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
785 | addString = i18n("Tomorrow"); | 785 | addString = i18n("Tomorrow"); |
786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 786 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
787 | addString = i18n("Yesterday"); | 787 | addString = i18n("Yesterday"); |
788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 788 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
789 | addString = i18n("Day before yesterday"); | 789 | addString = i18n("Day before yesterday"); |
790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 790 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
791 | addString = i18n("Day after tomorrow"); | 791 | addString = i18n("Day after tomorrow"); |
792 | if ( !addString.isEmpty() ) { | 792 | if ( !addString.isEmpty() ) { |
793 | str = addString+", " + str; | 793 | str = addString+", " + str; |
794 | } else { | 794 | } else { |
795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); | 795 | str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); |
796 | } | 796 | } |
797 | } | 797 | } |
798 | dayLabel->setText(str); | 798 | dayLabel->setText(str); |
799 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 799 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
800 | if (date == QDate::currentDate()) { | 800 | if (date == QDate::currentDate()) { |
801 | QFont bFont = dlf; | 801 | QFont bFont = dlf; |
802 | bFont.setBold( true ); | 802 | bFont.setBold( true ); |
803 | dayLabel->setFont(bFont); | 803 | dayLabel->setFont(bFont); |
804 | } | 804 | } |
805 | //dayLayout->addWidget(dayLabel); | 805 | //dayLayout->addWidget(dayLabel); |
806 | 806 | ||
807 | #ifndef KORG_NOPLUGINS | 807 | #ifndef KORG_NOPLUGINS |
808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); | 808 | CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); |
809 | CalendarDecoration *it; | 809 | CalendarDecoration *it; |
810 | for(it = cds.first(); it; it = cds.next()) { | 810 | for(it = cds.first(); it; it = cds.next()) { |
811 | QString text = it->shortText( date ); | 811 | QString text = it->shortText( date ); |
812 | if ( !text.isEmpty() ) { | 812 | if ( !text.isEmpty() ) { |
813 | QLabel *label = new QLabel(text,mDayLabels); | 813 | QLabel *label = new QLabel(text,mDayLabels); |
814 | label->setAlignment(AlignCenter); | 814 | label->setAlignment(AlignCenter); |
815 | dayLayout->addWidget(label); | 815 | dayLayout->addWidget(label); |
816 | } | 816 | } |
817 | } | 817 | } |
818 | 818 | ||
819 | for(it = cds.first(); it; it = cds.next()) { | 819 | for(it = cds.first(); it; it = cds.next()) { |
820 | QWidget *wid = it->smallWidget(mDayLabels,date); | 820 | QWidget *wid = it->smallWidget(mDayLabels,date); |
821 | if ( wid ) { | 821 | if ( wid ) { |
822 | // wid->setHeight(20); | 822 | // wid->setHeight(20); |
823 | dayLayout->addWidget(wid); | 823 | dayLayout->addWidget(wid); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | #endif | 826 | #endif |
827 | } | 827 | } |
828 | if ( ! appendLabels ) { | 828 | if ( ! appendLabels ) { |
829 | dayLabel = mDayLabelsList.next(); | 829 | dayLabel = mDayLabelsList.next(); |
830 | if ( !dayLabel ) | 830 | if ( !dayLabel ) |
831 | appendLabels = true; | 831 | appendLabels = true; |
832 | } | 832 | } |
833 | if ( appendLabels ) { | 833 | if ( appendLabels ) { |
834 | dayLabel = getNewDaylabel(); | 834 | dayLabel = getNewDaylabel(); |
835 | } | 835 | } |
836 | //dayLabel->hide();//test only | 836 | //dayLabel->hide();//test only |
837 | 837 | ||
838 | dayLabel->setText(">"); | 838 | dayLabel->setText(">"); |
839 | dayLabel->setFont( dlf ); | 839 | dayLabel->setFont( dlf ); |
840 | dayLabel->setAutoRepeat( true ); | 840 | dayLabel->setAutoRepeat( true ); |
841 | dayLabel->show(); | 841 | dayLabel->show(); |
842 | dayLabel->setNum( -2 ); | 842 | dayLabel->setNum( -2 ); |
843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); | 843 | dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); |
844 | 844 | ||
845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); | 845 | //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); |
846 | if ( !appendLabels ) { | 846 | if ( !appendLabels ) { |
847 | dayLabel = mDayLabelsList.next(); | 847 | dayLabel = mDayLabelsList.next(); |
848 | while ( dayLabel ) { | 848 | while ( dayLabel ) { |
849 | //qDebug("!dayLabel %d",dayLabel ); | 849 | //qDebug("!dayLabel %d",dayLabel ); |
850 | dayLabel->hide(); | 850 | dayLabel->hide(); |
851 | dayLabel = mDayLabelsList.next(); | 851 | dayLabel = mDayLabelsList.next(); |
852 | } | 852 | } |
853 | } | 853 | } |
854 | 854 | ||
855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); | 855 | mDayLabelsFrame->setFixedHeight( newHight + 4 ); |
856 | } | 856 | } |
857 | 857 | ||
858 | int KOAgendaView::maxDatesHint() | 858 | int KOAgendaView::maxDatesHint() |
859 | { | 859 | { |
860 | // Not sure about the max number of events, so return 0 for now. | 860 | // Not sure about the max number of events, so return 0 for now. |
861 | return 0; | 861 | return 0; |
862 | } | 862 | } |
863 | 863 | ||
864 | int KOAgendaView::currentDateCount() | 864 | int KOAgendaView::currentDateCount() |
865 | { | 865 | { |
866 | return mSelectedDates.count(); | 866 | return mSelectedDates.count(); |
867 | } | 867 | } |
868 | 868 | ||
869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() | 869 | QPtrList<Incidence> KOAgendaView::selectedIncidences() |
870 | { | 870 | { |
871 | QPtrList<Incidence> selected; | 871 | QPtrList<Incidence> selected; |
872 | Incidence *incidence; | 872 | Incidence *incidence; |
873 | 873 | ||
874 | incidence = mAgenda->selectedIncidence(); | 874 | incidence = mAgenda->selectedIncidence(); |
875 | if (incidence) selected.append(incidence); | 875 | if (incidence) selected.append(incidence); |
876 | 876 | ||
877 | incidence = mAllDayAgenda->selectedIncidence(); | 877 | incidence = mAllDayAgenda->selectedIncidence(); |
878 | if (incidence) selected.append(incidence); | 878 | if (incidence) selected.append(incidence); |
879 | 879 | ||
880 | return selected; | 880 | return selected; |
881 | } | 881 | } |
882 | 882 | ||
883 | DateList KOAgendaView::selectedDates() | 883 | DateList KOAgendaView::selectedDates() |
884 | { | 884 | { |
885 | DateList selected; | 885 | DateList selected; |
886 | QDate qd; | 886 | QDate qd; |
887 | 887 | ||
888 | qd = mAgenda->selectedIncidenceDate(); | 888 | qd = mAgenda->selectedIncidenceDate(); |
889 | if (qd.isValid()) selected.append(qd); | 889 | if (qd.isValid()) selected.append(qd); |
890 | 890 | ||
891 | qd = mAllDayAgenda->selectedIncidenceDate(); | 891 | qd = mAllDayAgenda->selectedIncidenceDate(); |
892 | if (qd.isValid()) selected.append(qd); | 892 | if (qd.isValid()) selected.append(qd); |
893 | 893 | ||
894 | return selected; | 894 | return selected; |
895 | } | 895 | } |
896 | 896 | ||
897 | 897 | ||
898 | void KOAgendaView::updateView() | 898 | void KOAgendaView::updateView() |
899 | { | 899 | { |
900 | if ( mBlockUpdating ) | 900 | if ( mBlockUpdating ) |
901 | return; | 901 | return; |
902 | // kdDebug() << "KOAgendaView::updateView()" << endl; | 902 | // kdDebug() << "KOAgendaView::updateView()" << endl; |
903 | fillAgenda(); | 903 | fillAgenda(); |
904 | 904 | ||
905 | } | 905 | } |
906 | 906 | ||
907 | 907 | ||
908 | /* | 908 | /* |
909 | Update configuration settings for the agenda view. This method is not | 909 | Update configuration settings for the agenda view. This method is not |
910 | complete. | 910 | complete. |
911 | */ | 911 | */ |
912 | void KOAgendaView::updateConfig() | 912 | void KOAgendaView::updateConfig() |
913 | { | 913 | { |
914 | if ( mBlockUpdating ) | 914 | if ( mBlockUpdating ) |
915 | return; | 915 | return; |
916 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { | 916 | if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { |
917 | int old = KOPrefs::instance()->mHourSize; | 917 | int old = KOPrefs::instance()->mHourSize; |
918 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; | 918 | KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; |
919 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); | 919 | //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); |
920 | } | 920 | } |
921 | 921 | ||
922 | 922 | ||
923 | // update config for children | 923 | // update config for children |
924 | mTimeLabels->updateConfig(); | 924 | mTimeLabels->updateConfig(); |
925 | mAgenda->storePosition(); | 925 | mAgenda->storePosition(); |
926 | mAgenda->updateConfig(); | 926 | mAgenda->updateConfig(); |
927 | mAllDayAgenda->updateConfig(); | 927 | mAllDayAgenda->updateConfig(); |
928 | // widget synchronization | 928 | // widget synchronization |
929 | //TODO: find a better way, maybe signal/slot | 929 | //TODO: find a better way, maybe signal/slot |
930 | mTimeLabels->positionChanged(); | 930 | mTimeLabels->positionChanged(); |
931 | 931 | ||
932 | // for some reason, this needs to be called explicitly | 932 | // for some reason, this needs to be called explicitly |
933 | mTimeLabels->repaint(); | 933 | mTimeLabels->repaint(); |
934 | 934 | ||
935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 935 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
936 | 936 | ||
937 | // ToolTips displaying summary of events | 937 | // ToolTips displaying summary of events |
938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() | 938 | KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() |
939 | ->mEnableToolTips); | 939 | ->mEnableToolTips); |
940 | 940 | ||
941 | //setHolidayMasks(); | 941 | //setHolidayMasks(); |
942 | 942 | ||
943 | //createDayLabels(); called by via updateView(); | 943 | //createDayLabels(); called by via updateView(); |
944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); | 944 | mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); |
945 | updateView(); | 945 | updateView(); |
946 | mAgenda->restorePosition(); | 946 | mAgenda->restorePosition(); |
947 | } | 947 | } |
948 | 948 | ||
949 | 949 | ||
950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) | 950 | void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) |
951 | { | 951 | { |
952 | 952 | ||
953 | 953 | ||
954 | int xxx = item->cellX(); | 954 | int xxx = item->cellX(); |
955 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); | 955 | //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); |
956 | if ( mMinY.at(xxx) > item->cellYTop() ) | 956 | if ( mMinY.at(xxx) > item->cellYTop() ) |
957 | mMinY.at(xxx) = item->cellYTop(); | 957 | mMinY.at(xxx) = item->cellYTop(); |
958 | if ( mMaxY.at(xxx) < item->cellYBottom() ) | 958 | if ( mMaxY.at(xxx) < item->cellYBottom() ) |
959 | mMaxY.at(xxx) = item->cellYBottom(); | 959 | mMaxY.at(xxx) = item->cellYBottom(); |
960 | 960 | ||
961 | QDateTime startDt,endDt; | 961 | QDateTime startDt,endDt; |
962 | QDate startDate; | 962 | QDate startDate; |
963 | int lenInSecs; | 963 | int lenInSecs; |
964 | // if ( type == KOAgenda::RESIZETOP ) | 964 | // if ( type == KOAgenda::RESIZETOP ) |
965 | // qDebug("RESIZETOP "); | 965 | // qDebug("RESIZETOP "); |
966 | // if ( type == KOAgenda::RESIZEBOTTOM ) | 966 | // if ( type == KOAgenda::RESIZEBOTTOM ) |
967 | // qDebug("RESIZEBOTTOM "); | 967 | // qDebug("RESIZEBOTTOM "); |
968 | // if ( type == KOAgenda::MOVE ) | 968 | // if ( type == KOAgenda::MOVE ) |
969 | // qDebug("MOVE "); | 969 | // qDebug("MOVE "); |
970 | if ( item->incidence()->type() == "Event" ) { | 970 | if ( item->incidence()->typeID() == eventID ) { |
971 | startDt =item->incidence()->dtStart(); | 971 | startDt =item->incidence()->dtStart(); |
972 | endDt = item->incidence()->dtEnd(); | 972 | endDt = item->incidence()->dtEnd(); |
973 | lenInSecs = startDt.secsTo( endDt ); | 973 | lenInSecs = startDt.secsTo( endDt ); |
974 | } | 974 | } |
975 | 975 | ||
976 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); | 976 | // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); |
977 | 977 | ||
978 | if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { | 978 | if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { |
979 | startDate = mSelectedDates[item->mLastMoveXPos]; | 979 | startDate = mSelectedDates[item->mLastMoveXPos]; |
980 | } else { | 980 | } else { |
981 | if (item->cellX() < 0) { | 981 | if (item->cellX() < 0) { |
982 | startDate = (mSelectedDates.first()).addDays(item->cellX()); | 982 | startDate = (mSelectedDates.first()).addDays(item->cellX()); |
983 | } else { | 983 | } else { |
984 | startDate = mSelectedDates[item->cellX()]; | 984 | startDate = mSelectedDates[item->cellX()]; |
985 | } | 985 | } |
986 | } | 986 | } |
987 | startDt.setDate(startDate); | 987 | startDt.setDate(startDate); |
988 | 988 | ||
989 | if (item->incidence()->doesFloat()) { | 989 | if (item->incidence()->doesFloat()) { |
990 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); | 990 | endDt.setDate(startDate.addDays(item->cellWidth() - 1)); |
991 | } else { | 991 | } else { |
992 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) | 992 | if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) |
993 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); | 993 | startDt.setTime(mAgenda->gyToTime(item->cellYTop())); |
994 | if ( item->incidence()->type() == "Event" ) { | 994 | if ( item->incidence()->typeID() == eventID ) { |
995 | if ( type == KOAgenda::MOVE ) { | 995 | if ( type == KOAgenda::MOVE ) { |
996 | endDt = startDt.addSecs(lenInSecs); | 996 | endDt = startDt.addSecs(lenInSecs); |
997 | 997 | ||
998 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { | 998 | } else if ( type == KOAgenda::RESIZEBOTTOM ) { |
999 | if (item->lastMultiItem()) { | 999 | if (item->lastMultiItem()) { |
1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1000 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1001 | endDt.setDate(startDate. | 1001 | endDt.setDate(startDate. |
1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1002 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1003 | } else { | 1003 | } else { |
1004 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1004 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1005 | endDt.setDate(startDate); | 1005 | endDt.setDate(startDate); |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | } else { | 1008 | } else { |
1009 | // todo | 1009 | // todo |
1010 | if (item->lastMultiItem()) { | 1010 | if (item->lastMultiItem()) { |
1011 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); | 1011 | endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); |
1012 | endDt.setDate(startDate. | 1012 | endDt.setDate(startDate. |
1013 | addDays(item->lastMultiItem()->cellX() - item->cellX())); | 1013 | addDays(item->lastMultiItem()->cellX() - item->cellX())); |
1014 | } else { | 1014 | } else { |
1015 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); | 1015 | //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); |
1016 | if ( item->cellYBottom() > 0 ) | 1016 | if ( item->cellYBottom() > 0 ) |
1017 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); | 1017 | endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); |
1018 | else | 1018 | else |
1019 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); | 1019 | endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); |
1020 | endDt.setDate(startDate); | 1020 | endDt.setDate(startDate); |
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | if ( item->incidence()->type() == "Event" ) { | 1024 | if ( item->incidence()->typeID() == eventID ) { |
1025 | item->incidence()->setDtStart(startDt); | 1025 | item->incidence()->setDtStart(startDt); |
1026 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); | 1026 | (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); |
1027 | } else if ( item->incidence()->type() == "Todo" ) { | 1027 | } else if ( item->incidence()->typeID() == todoID ) { |
1028 | Todo* to = static_cast<Todo*>(item->incidence()); | 1028 | Todo* to = static_cast<Todo*>(item->incidence()); |
1029 | 1029 | ||
1030 | to->setDtDue(endDt); | 1030 | to->setDtDue(endDt); |
1031 | if ( to->hasStartDate() ) { | 1031 | if ( to->hasStartDate() ) { |
1032 | if (to->dtStart() >= to->dtDue() ) | 1032 | if (to->dtStart() >= to->dtDue() ) |
1033 | to->setDtStart(to->dtDue().addDays( -2 )); | 1033 | to->setDtStart(to->dtDue().addDays( -2 )); |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | } | 1036 | } |
1037 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); | 1037 | //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); |
1038 | item->incidence()->setRevision(item->incidence()->revision()+1); | 1038 | item->incidence()->setRevision(item->incidence()->revision()+1); |
1039 | item->setItemDate(startDt.date()); | 1039 | item->setItemDate(startDt.date()); |
1040 | //item->updateItem(); | 1040 | //item->updateItem(); |
1041 | if ( item->incidence()->type() == "Todo" ) { | 1041 | if ( item->incidence()->typeID() == todoID ) { |
1042 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); | 1042 | emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); |
1043 | 1043 | ||
1044 | } | 1044 | } |
1045 | else | 1045 | else |
1046 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); | 1046 | emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); |
1047 | item->updateItem(); | 1047 | item->updateItem(); |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) | 1050 | void KOAgendaView::showDates( const QDate &start, const QDate &end ) |
1051 | { | 1051 | { |
1052 | // kdDebug() << "KOAgendaView::selectDates" << endl; | 1052 | // kdDebug() << "KOAgendaView::selectDates" << endl; |
1053 | 1053 | ||
1054 | mSelectedDates.clear(); | 1054 | mSelectedDates.clear(); |
1055 | // qDebug("KOAgendaView::showDates "); | 1055 | // qDebug("KOAgendaView::showDates "); |
1056 | QDate d = start; | 1056 | QDate d = start; |
1057 | while (d <= end) { | 1057 | while (d <= end) { |
1058 | mSelectedDates.append(d); | 1058 | mSelectedDates.append(d); |
1059 | d = d.addDays( 1 ); | 1059 | d = d.addDays( 1 ); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | // and update the view | 1062 | // and update the view |
1063 | fillAgenda(); | 1063 | fillAgenda(); |
1064 | } | 1064 | } |
1065 | 1065 | ||
1066 | 1066 | ||
1067 | void KOAgendaView::showEvents(QPtrList<Event>) | 1067 | void KOAgendaView::showEvents(QPtrList<Event>) |
1068 | { | 1068 | { |
1069 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; | 1069 | kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | void KOAgendaView::changeEventDisplay(Event *, int) | 1072 | void KOAgendaView::changeEventDisplay(Event *, int) |
1073 | { | 1073 | { |
1074 | // qDebug("KOAgendaView::changeEventDisplay "); | 1074 | // qDebug("KOAgendaView::changeEventDisplay "); |
1075 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; | 1075 | // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; |
1076 | // this should be re-written to be MUCH smarter. Right now we | 1076 | // this should be re-written to be MUCH smarter. Right now we |
1077 | // are just playing dumb. | 1077 | // are just playing dumb. |
1078 | fillAgenda(); | 1078 | fillAgenda(); |
1079 | } | 1079 | } |
1080 | 1080 | ||
1081 | void KOAgendaView::fillAgenda(const QDate &) | 1081 | void KOAgendaView::fillAgenda(const QDate &) |
1082 | { | 1082 | { |
1083 | // qDebug("KOAgendaView::fillAgenda "); | 1083 | // qDebug("KOAgendaView::fillAgenda "); |
1084 | fillAgenda(); | 1084 | fillAgenda(); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | void KOAgendaView::fillAgenda() | 1087 | void KOAgendaView::fillAgenda() |
1088 | { | 1088 | { |
1089 | if ( globalFlagBlockStartup ) | 1089 | if ( globalFlagBlockStartup ) |
1090 | return; | 1090 | return; |
1091 | if ( globalFlagBlockAgenda == 1 ) | 1091 | if ( globalFlagBlockAgenda == 1 ) |
1092 | return; | 1092 | return; |
1093 | static bool onlyOne = false; | 1093 | static bool onlyOne = false; |
1094 | if ( onlyOne ) | 1094 | if ( onlyOne ) |
1095 | return; | 1095 | return; |
1096 | onlyOne = true; | 1096 | onlyOne = true; |
1097 | //if ( globalFlagBlockAgenda == 2 ) | 1097 | //if ( globalFlagBlockAgenda == 2 ) |
1098 | //globalFlagBlockAgenda = 0; | 1098 | //globalFlagBlockAgenda = 0; |
1099 | // globalFlagBlockPainting = false; | 1099 | // globalFlagBlockPainting = false; |
1100 | if ( globalFlagBlockAgenda == 0 ) | 1100 | if ( globalFlagBlockAgenda == 0 ) |
1101 | globalFlagBlockAgenda = 1; | 1101 | globalFlagBlockAgenda = 1; |
1102 | // clearView(); | 1102 | // clearView(); |
1103 | //qDebug("fillAgenda()++++ "); | 1103 | //qDebug("fillAgenda()++++ "); |
1104 | globalFlagBlockAgendaItemPaint = 1; | 1104 | globalFlagBlockAgendaItemPaint = 1; |
1105 | 1105 | ||
1106 | mAllDayAgenda->changeColumns(mSelectedDates.count()); | 1106 | mAllDayAgenda->changeColumns(mSelectedDates.count()); |
1107 | mAgenda->changeColumns(mSelectedDates.count()); | 1107 | mAgenda->changeColumns(mSelectedDates.count()); |
1108 | qApp->processEvents(); | 1108 | qApp->processEvents(); |
1109 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); | 1109 | mEventIndicatorTop->changeColumns(mSelectedDates.count()); |
1110 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); | 1110 | mEventIndicatorBottom->changeColumns(mSelectedDates.count()); |
1111 | setHolidayMasks(); | 1111 | setHolidayMasks(); |
1112 | 1112 | ||
1113 | //mAgenda->hideUnused(); | 1113 | //mAgenda->hideUnused(); |
1114 | //mAllDayAgenda->hideUnused(); | 1114 | //mAllDayAgenda->hideUnused(); |
1115 | 1115 | ||
1116 | // mAgenda->blockNextRepaint( false ); | 1116 | // mAgenda->blockNextRepaint( false ); |
1117 | // mAgenda->viewport()->repaint(); | 1117 | // mAgenda->viewport()->repaint(); |
1118 | // mAgenda->blockNextRepaint( true ); | 1118 | // mAgenda->blockNextRepaint( true ); |
1119 | mMinY.resize(mSelectedDates.count()); | 1119 | mMinY.resize(mSelectedDates.count()); |
1120 | mMaxY.resize(mSelectedDates.count()); | 1120 | mMaxY.resize(mSelectedDates.count()); |
1121 | 1121 | ||
1122 | QPtrList<Event> dayEvents; | 1122 | QPtrList<Event> dayEvents; |
1123 | 1123 | ||
1124 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1124 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1125 | // Therefore, gtodoset all of them. | 1125 | // Therefore, gtodoset all of them. |
1126 | QPtrList<Todo> todos = calendar()->todos(); | 1126 | QPtrList<Todo> todos = calendar()->todos(); |
1127 | 1127 | ||
1128 | mAgenda->setDateList(mSelectedDates); | 1128 | mAgenda->setDateList(mSelectedDates); |
1129 | 1129 | ||
1130 | QDate today = QDate::currentDate(); | 1130 | QDate today = QDate::currentDate(); |
1131 | 1131 | ||
1132 | DateList::ConstIterator dit; | 1132 | DateList::ConstIterator dit; |
1133 | int curCol = 0; | 1133 | int curCol = 0; |
1134 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 1134 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
1135 | QDate currentDate = *dit; | 1135 | QDate currentDate = *dit; |
1136 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() | 1136 | // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() |
1137 | // << endl; | 1137 | // << endl; |
1138 | 1138 | ||
1139 | dayEvents = calendar()->events(currentDate,true); | 1139 | dayEvents = calendar()->events(currentDate,true); |
1140 | 1140 | ||
1141 | // Default values, which can never be reached | 1141 | // Default values, which can never be reached |
1142 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; | 1142 | mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; |
1143 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; | 1143 | mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; |
1144 | 1144 | ||
1145 | unsigned int numEvent; | 1145 | unsigned int numEvent; |
1146 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { | 1146 | for(numEvent=0;numEvent<dayEvents.count();++numEvent) { |
1147 | Event *event = dayEvents.at(numEvent); | 1147 | Event *event = dayEvents.at(numEvent); |
1148 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1148 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1149 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1149 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1150 | continue; | 1150 | continue; |
1151 | // kdDebug() << " Event: " << event->summary() << endl; | 1151 | // kdDebug() << " Event: " << event->summary() << endl; |
1152 | 1152 | ||
1153 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; | 1153 | int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; |
1154 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; | 1154 | int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; |
1155 | 1155 | ||
1156 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; | 1156 | // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; |
1157 | 1157 | ||
1158 | if (event->doesFloat()) { | 1158 | if (event->doesFloat()) { |
1159 | if (event->recurrence()->doesRecur()) { | 1159 | if (event->recurrence()->doesRecur()) { |
1160 | if (event->isMultiDay() ) { | 1160 | if (event->isMultiDay() ) { |
1161 | endX = endX - beginX;// endX is now number of days | 1161 | endX = endX - beginX;// endX is now number of days |
1162 | if ( event->recursOn( currentDate ) ) { | 1162 | if ( event->recursOn( currentDate ) ) { |
1163 | endX += curCol; | 1163 | endX += curCol; |
1164 | beginX = curCol; | 1164 | beginX = curCol; |
1165 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1165 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1166 | } else { | 1166 | } else { |
1167 | //qDebug("days %d %s",endX , currentDate.toString().latin1()); | 1167 | //qDebug("days %d %s",endX , currentDate.toString().latin1()); |
1168 | QDate dateit = currentDate.addDays( -endX ); | 1168 | QDate dateit = currentDate.addDays( -endX ); |
1169 | if ( event->recursOn( dateit ) ) { | 1169 | if ( event->recursOn( dateit ) ) { |
1170 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); | 1170 | //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); |
1171 | if ( curCol-endX < 0 ) { | 1171 | if ( curCol-endX < 0 ) { |
1172 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); | 1172 | mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); |
1173 | } | 1173 | } |
1174 | } | 1174 | } |
1175 | } | 1175 | } |
1176 | } else { | 1176 | } else { |
1177 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); | 1177 | mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); |
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | } else { | 1180 | } else { |
1181 | if (beginX <= 0 && curCol == 0) { | 1181 | if (beginX <= 0 && curCol == 0) { |
1182 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1182 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1183 | } else if (beginX == curCol) { | 1183 | } else if (beginX == curCol) { |
1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); | 1184 | mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); |
1185 | } | 1185 | } |
1186 | } | 1186 | } |
1187 | } else if (event->isMultiDay()) { | 1187 | } else if (event->isMultiDay()) { |
1188 | if ( event->doesRecur () ) { | 1188 | if ( event->doesRecur () ) { |
1189 | QDate dateit = currentDate; | 1189 | QDate dateit = currentDate; |
1190 | int count = 0; | 1190 | int count = 0; |
1191 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; | 1191 | int max = event->dtStart().daysTo( event->dtEnd() ) +2; |
1192 | while (! event->recursOn( dateit ) && count <= max ) { | 1192 | while (! event->recursOn( dateit ) && count <= max ) { |
1193 | ++count; | 1193 | ++count; |
1194 | dateit = dateit.addDays( -1 ); | 1194 | dateit = dateit.addDays( -1 ); |
1195 | } | 1195 | } |
1196 | bool ok; | 1196 | bool ok; |
1197 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); | 1197 | QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); |
1198 | if ( ok ) | 1198 | if ( ok ) |
1199 | { | 1199 | { |
1200 | int secs = event->dtStart().secsTo( event->dtEnd() ); | 1200 | int secs = event->dtStart().secsTo( event->dtEnd() ); |
1201 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; | 1201 | QDateTime nextOcend =nextOcstart.addSecs( secs ); ; |
1202 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; | 1202 | beginX = currentDate.daysTo(nextOcstart.date()) + curCol; |
1203 | endX = currentDate.daysTo(nextOcend.date()) + curCol; | 1203 | endX = currentDate.daysTo(nextOcend.date()) + curCol; |
1204 | 1204 | ||
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1207 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1208 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1208 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1209 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); | 1209 | //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); |
1210 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { | 1210 | if ((beginX <= 0 && curCol == 0) || beginX == curCol) { |
1211 | //qDebug("insert!!! "); | 1211 | //qDebug("insert!!! "); |
1212 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); | 1212 | mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); |
1213 | } | 1213 | } |
1214 | if (beginX == curCol) { | 1214 | if (beginX == curCol) { |
1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1215 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1216 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1216 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1217 | } else if (endX == curCol) { | 1217 | } else if (endX == curCol) { |
1218 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1218 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1219 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1219 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1220 | } else { | 1220 | } else { |
1221 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); | 1221 | mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); |
1222 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); | 1222 | mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); |
1223 | } | 1223 | } |
1224 | } else { | 1224 | } else { |
1225 | int startY = mAgenda->timeToY(event->dtStart().time()); | 1225 | int startY = mAgenda->timeToY(event->dtStart().time()); |
1226 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; | 1226 | int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; |
1227 | if (endY < startY) endY = startY; | 1227 | if (endY < startY) endY = startY; |
1228 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); | 1228 | mAgenda->insertItem(event,currentDate,curCol,startY,endY); |
1229 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1229 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1230 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1230 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1231 | } | 1231 | } |
1232 | } | 1232 | } |
1233 | // ---------- [display Todos -------------- | 1233 | // ---------- [display Todos -------------- |
1234 | unsigned int numTodo; | 1234 | unsigned int numTodo; |
1235 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { | 1235 | for (numTodo = 0; numTodo < todos.count(); ++numTodo) { |
1236 | Todo *todo = todos.at(numTodo); | 1236 | Todo *todo = todos.at(numTodo); |
1237 | 1237 | ||
1238 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date | 1238 | if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date |
1239 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; | 1239 | if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; |
1240 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. | 1240 | // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. |
1241 | // Already completed items can be displayed on their original due date | 1241 | // Already completed items can be displayed on their original due date |
1242 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda | 1242 | //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda |
1243 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; | 1243 | bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; |
1244 | bool fillIn = false; | 1244 | bool fillIn = false; |
1245 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) | 1245 | if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) |
1246 | fillIn = true; | 1246 | fillIn = true; |
1247 | if ( ! fillIn && !todo->hasCompletedDate() ) | 1247 | if ( ! fillIn && !todo->hasCompletedDate() ) |
1248 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); | 1248 | fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); |
1249 | if ( fillIn ) { | 1249 | if ( fillIn ) { |
1250 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue | 1250 | if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue |
1251 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1251 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1252 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); | 1252 | mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); |
1253 | } | 1253 | } |
1254 | else { | 1254 | else { |
1255 | QDateTime dt; | 1255 | QDateTime dt; |
1256 | if ( todo->hasCompletedDate() ) | 1256 | if ( todo->hasCompletedDate() ) |
1257 | dt = todo->completed(); | 1257 | dt = todo->completed(); |
1258 | else | 1258 | else |
1259 | dt = todo->dtDue();; | 1259 | dt = todo->dtDue();; |
1260 | 1260 | ||
1261 | 1261 | ||
1262 | int endY = mAgenda->timeToY(dt.time()) - 1; | 1262 | int endY = mAgenda->timeToY(dt.time()) - 1; |
1263 | int hi = (18/KOPrefs::instance()->mHourSize); | 1263 | int hi = (18/KOPrefs::instance()->mHourSize); |
1264 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); | 1264 | //qDebug("hei %d ",KOPrefs::instance()->mHourSize); |
1265 | int startY = endY -hi; | 1265 | int startY = endY -hi; |
1266 | 1266 | ||
1267 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); | 1267 | mAgenda->insertItem(todo,currentDate,curCol,startY,endY); |
1268 | 1268 | ||
1269 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; | 1269 | if (startY < mMinY[curCol]) mMinY[curCol] = startY; |
1270 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; | 1270 | if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; |
1271 | } | 1271 | } |
1272 | } | 1272 | } |
1273 | } | 1273 | } |
1274 | // ---------- display Todos] -------------- | 1274 | // ---------- display Todos] -------------- |
1275 | 1275 | ||
1276 | ++curCol; | 1276 | ++curCol; |
1277 | } | 1277 | } |
1278 | mAgenda->hideUnused(); | 1278 | mAgenda->hideUnused(); |
1279 | mAllDayAgenda->hideUnused(); | 1279 | mAllDayAgenda->hideUnused(); |
1280 | mAgenda->checkScrollBoundaries(); | 1280 | mAgenda->checkScrollBoundaries(); |
1281 | 1281 | ||
1282 | deleteSelectedDateTime(); | 1282 | deleteSelectedDateTime(); |
1283 | 1283 | ||
1284 | createDayLabels(); | 1284 | createDayLabels(); |
1285 | emit incidenceSelected( 0 ); | 1285 | emit incidenceSelected( 0 ); |
1286 | 1286 | ||
1287 | if ( globalFlagBlockAgenda == 2 ) { | 1287 | if ( globalFlagBlockAgenda == 2 ) { |
1288 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) | 1288 | if ( KOPrefs::instance()->mSetTimeToDayStartAt ) |
1289 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1289 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1290 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1290 | else if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1291 | setStartHour( QTime::currentTime ().hour() ); | 1291 | setStartHour( QTime::currentTime ().hour() ); |
1292 | // qApp->processEvents(); | 1292 | // qApp->processEvents(); |
1293 | } | 1293 | } |
1294 | qApp->processEvents(); | 1294 | qApp->processEvents(); |
1295 | //qDebug("qApp->processEvents(); END "); | 1295 | //qDebug("qApp->processEvents(); END "); |
1296 | globalFlagBlockAgenda = 0; | 1296 | globalFlagBlockAgenda = 0; |
1297 | 1297 | ||
1298 | // mAgenda->hideUnused(); | 1298 | // mAgenda->hideUnused(); |
1299 | //mAllDayAgenda->hideUnused(); | 1299 | //mAllDayAgenda->hideUnused(); |
1300 | mAllDayAgenda->drawContentsToPainter(); | 1300 | mAllDayAgenda->drawContentsToPainter(); |
1301 | mAgenda->drawContentsToPainter(); | 1301 | mAgenda->drawContentsToPainter(); |
1302 | repaintAgenda(); | 1302 | repaintAgenda(); |
1303 | onlyOne = false; | 1303 | onlyOne = false; |
1304 | // mAgenda->finishUpdate(); | 1304 | // mAgenda->finishUpdate(); |
1305 | //mAllDayAgenda->finishUpdate(); | 1305 | //mAllDayAgenda->finishUpdate(); |
1306 | 1306 | ||
1307 | // repaintAgenda(); | 1307 | // repaintAgenda(); |
1308 | //qApp->processEvents(); | 1308 | //qApp->processEvents(); |
1309 | // globalFlagBlockAgenda = 0; | 1309 | // globalFlagBlockAgenda = 0; |
1310 | } | 1310 | } |
1311 | void KOAgendaView::repaintAgenda() | 1311 | void KOAgendaView::repaintAgenda() |
1312 | { | 1312 | { |
1313 | // mAllDayAgenda->drawContentsToPainter(); | 1313 | // mAllDayAgenda->drawContentsToPainter(); |
1314 | // mAllDayAgenda->viewport()->repaint( false ); | 1314 | // mAllDayAgenda->viewport()->repaint( false ); |
1315 | // mAgenda->drawContentsToPainter(); | 1315 | // mAgenda->drawContentsToPainter(); |
1316 | // mAgenda->viewport()->repaint( false ); | 1316 | // mAgenda->viewport()->repaint( false ); |
1317 | // qApp->processEvents(); | 1317 | // qApp->processEvents(); |
1318 | 1318 | ||
1319 | //qDebug("KOAgendaView::repaintAgenda() "); | 1319 | //qDebug("KOAgendaView::repaintAgenda() "); |
1320 | //qApp->processEvents(); | 1320 | //qApp->processEvents(); |
1321 | mAgenda->viewport()->repaint( false ); | 1321 | mAgenda->viewport()->repaint( false ); |
1322 | mAllDayAgenda->viewport()->repaint( false ); | 1322 | mAllDayAgenda->viewport()->repaint( false ); |
1323 | mAgenda->finishUpdate(); | 1323 | mAgenda->finishUpdate(); |
1324 | mAllDayAgenda->finishUpdate(); | 1324 | mAllDayAgenda->finishUpdate(); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | 1327 | ||
1328 | void KOAgendaView::clearView() | 1328 | void KOAgendaView::clearView() |
1329 | { | 1329 | { |
1330 | // kdDebug() << "ClearView" << endl; | 1330 | // kdDebug() << "ClearView" << endl; |
1331 | mAllDayAgenda->clear(); | 1331 | mAllDayAgenda->clear(); |
1332 | mAgenda->clear(); | 1332 | mAgenda->clear(); |
1333 | } | 1333 | } |
1334 | void KOAgendaView::clearList() | 1334 | void KOAgendaView::clearList() |
1335 | { | 1335 | { |
1336 | // kdDebug() << "ClearView" << endl; | 1336 | // kdDebug() << "ClearView" << endl; |
1337 | clearView(); | 1337 | clearView(); |
1338 | mAllDayAgenda->hideUnused(); | 1338 | mAllDayAgenda->hideUnused(); |
1339 | mAgenda->hideUnused(); | 1339 | mAgenda->hideUnused(); |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1342 | void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1343 | const QDate &td) | 1343 | const QDate &td) |
1344 | { | 1344 | { |
1345 | #ifndef KORG_NOPRINTER | 1345 | #ifndef KORG_NOPRINTER |
1346 | if (fd == td) | 1346 | if (fd == td) |
1347 | calPrinter->preview(CalPrinter::Day, fd, td); | 1347 | calPrinter->preview(CalPrinter::Day, fd, td); |
1348 | else | 1348 | else |
1349 | calPrinter->preview(CalPrinter::Week, fd, td); | 1349 | calPrinter->preview(CalPrinter::Week, fd, td); |
1350 | #endif | 1350 | #endif |
1351 | } | 1351 | } |
1352 | 1352 | ||
1353 | // void KOAgendaView::updateMovedTodo() | 1353 | // void KOAgendaView::updateMovedTodo() |
1354 | // { | 1354 | // { |
1355 | // // updateConfig(); | 1355 | // // updateConfig(); |
1356 | // // emit updateTodoViews(); | 1356 | // // emit updateTodoViews(); |
1357 | // } | 1357 | // } |
1358 | 1358 | ||
1359 | void KOAgendaView::slotShowDateView( int mode , int d ) | 1359 | void KOAgendaView::slotShowDateView( int mode , int d ) |
1360 | { | 1360 | { |
1361 | if ( d >= mSelectedDates.count() ) { | 1361 | if ( d >= mSelectedDates.count() ) { |
1362 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); | 1362 | qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); |
1363 | 1363 | ||
1364 | } else { | 1364 | } else { |
1365 | QDate day = mSelectedDates[d]; | 1365 | QDate day = mSelectedDates[d]; |
1366 | emit showDateView(mode , day ); | 1366 | emit showDateView(mode , day ); |
1367 | } | 1367 | } |
1368 | 1368 | ||
1369 | } | 1369 | } |
1370 | void KOAgendaView::newEvent(int gx, int gy) | 1370 | void KOAgendaView::newEvent(int gx, int gy) |
1371 | { | 1371 | { |
1372 | if (!mSelectedDates.count()) return; | 1372 | if (!mSelectedDates.count()) return; |
1373 | 1373 | ||
1374 | QDate day = mSelectedDates[gx]; | 1374 | QDate day = mSelectedDates[gx]; |
1375 | 1375 | ||
1376 | QTime time = mAgenda->gyToTime(gy); | 1376 | QTime time = mAgenda->gyToTime(gy); |
1377 | QDateTime dt(day,time); | 1377 | QDateTime dt(day,time); |
1378 | // if ( dt < QDateTime::currentDateTime () ) | 1378 | // if ( dt < QDateTime::currentDateTime () ) |
1379 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); | 1379 | // dt = QDateTime::currentDateTime ().addSecs( 3600 ); |
1380 | emit newEventSignal(dt); | 1380 | emit newEventSignal(dt); |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) | 1383 | void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) |
1384 | { | 1384 | { |
1385 | if (!mSelectedDates.count()) return; | 1385 | if (!mSelectedDates.count()) return; |
1386 | 1386 | ||
1387 | QDate dayStart = mSelectedDates[gxStart]; | 1387 | QDate dayStart = mSelectedDates[gxStart]; |
1388 | QDate dayEnd = mSelectedDates[gxEnd]; | 1388 | QDate dayEnd = mSelectedDates[gxEnd]; |
1389 | 1389 | ||
1390 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1390 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1391 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1391 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1392 | 1392 | ||
1393 | QDateTime dtStart(dayStart,timeStart); | 1393 | QDateTime dtStart(dayStart,timeStart); |
1394 | QDateTime dtEnd(dayEnd,timeEnd); | 1394 | QDateTime dtEnd(dayEnd,timeEnd); |
1395 | 1395 | ||
1396 | emit newEventSignal(dtStart,dtEnd); | 1396 | emit newEventSignal(dtStart,dtEnd); |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | void KOAgendaView::newEventAllDay(int gx, int ) | 1399 | void KOAgendaView::newEventAllDay(int gx, int ) |
1400 | { | 1400 | { |
1401 | if (!mSelectedDates.count()) return; | 1401 | if (!mSelectedDates.count()) return; |
1402 | 1402 | ||
1403 | QDate day = mSelectedDates[gx]; | 1403 | QDate day = mSelectedDates[gx]; |
1404 | 1404 | ||
1405 | emit newEventSignal(day); | 1405 | emit newEventSignal(day); |
1406 | } | 1406 | } |
1407 | void KOAgendaView::newTodoAllDay(int gx, int ) | 1407 | void KOAgendaView::newTodoAllDay(int gx, int ) |
1408 | { | 1408 | { |
1409 | if (!mSelectedDates.count()) return; | 1409 | if (!mSelectedDates.count()) return; |
1410 | 1410 | ||
1411 | QDateTime day (mSelectedDates[gx] ); | 1411 | QDateTime day (mSelectedDates[gx] ); |
1412 | emit newTodoSignal(day, true); | 1412 | emit newTodoSignal(day, true); |
1413 | } | 1413 | } |
1414 | void KOAgendaView::newTodo(int gx, int gy ) | 1414 | void KOAgendaView::newTodo(int gx, int gy ) |
1415 | { | 1415 | { |
1416 | if (!mSelectedDates.count()) return; | 1416 | if (!mSelectedDates.count()) return; |
1417 | QDate dayStart = mSelectedDates[gx]; | 1417 | QDate dayStart = mSelectedDates[gx]; |
1418 | QTime timeStart = mAgenda->gyToTime(gy); | 1418 | QTime timeStart = mAgenda->gyToTime(gy); |
1419 | QDateTime dt (dayStart,timeStart); | 1419 | QDateTime dt (dayStart,timeStart); |
1420 | emit newTodoSignal( dt, false ); | 1420 | emit newTodoSignal( dt, false ); |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | void KOAgendaView::updateEventIndicatorTop(int newY) | 1423 | void KOAgendaView::updateEventIndicatorTop(int newY) |
1424 | { | 1424 | { |
1425 | uint i; | 1425 | uint i; |
1426 | for(i=0;i<mMinY.size();++i) { | 1426 | for(i=0;i<mMinY.size();++i) { |
1427 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); | 1427 | if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); |
1428 | else mEventIndicatorTop->enableColumn(i,false); | 1428 | else mEventIndicatorTop->enableColumn(i,false); |
1429 | } | 1429 | } |
1430 | 1430 | ||
1431 | mEventIndicatorTop->update(); | 1431 | mEventIndicatorTop->update(); |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | void KOAgendaView::updateEventIndicatorBottom(int newY) | 1434 | void KOAgendaView::updateEventIndicatorBottom(int newY) |
1435 | { | 1435 | { |
1436 | uint i; | 1436 | uint i; |
1437 | for(i=0;i<mMaxY.size();++i) { | 1437 | for(i=0;i<mMaxY.size();++i) { |
1438 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); | 1438 | if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); |
1439 | else mEventIndicatorBottom->enableColumn(i,false); | 1439 | else mEventIndicatorBottom->enableColumn(i,false); |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | mEventIndicatorBottom->update(); | 1442 | mEventIndicatorBottom->update(); |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | void KOAgendaView::startDrag(Event *event) | 1445 | void KOAgendaView::startDrag(Event *event) |
1446 | { | 1446 | { |
1447 | #ifndef KORG_NODND | 1447 | #ifndef KORG_NODND |
1448 | DndFactory factory( calendar() ); | 1448 | DndFactory factory( calendar() ); |
1449 | ICalDrag *vd = factory.createDrag(event,this); | 1449 | ICalDrag *vd = factory.createDrag(event,this); |
1450 | if (vd->drag()) { | 1450 | if (vd->drag()) { |
1451 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; | 1451 | kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; |
1452 | } | 1452 | } |
1453 | #endif | 1453 | #endif |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | void KOAgendaView::readSettings() | 1456 | void KOAgendaView::readSettings() |
1457 | { | 1457 | { |
1458 | readSettings(KOGlobals::config()); | 1458 | readSettings(KOGlobals::config()); |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | void KOAgendaView::readSettings(KConfig *config) | 1461 | void KOAgendaView::readSettings(KConfig *config) |
1462 | { | 1462 | { |
1463 | // kdDebug() << "KOAgendaView::readSettings()" << endl; | 1463 | // kdDebug() << "KOAgendaView::readSettings()" << endl; |
1464 | 1464 | ||
1465 | config->setGroup("Views"); | 1465 | config->setGroup("Views"); |
1466 | 1466 | ||
1467 | //#ifndef KORG_NOSPLITTER | 1467 | //#ifndef KORG_NOSPLITTER |
1468 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); | 1468 | QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); |
1469 | if (sizes.count() == 2) { | 1469 | if (sizes.count() == 2) { |
1470 | if ( sizes[0] < 20 ) { | 1470 | if ( sizes[0] < 20 ) { |
1471 | sizes[1] = sizes[1] +20 - sizes[0]; | 1471 | sizes[1] = sizes[1] +20 - sizes[0]; |
1472 | sizes[0] = 20; | 1472 | sizes[0] = 20; |
1473 | } | 1473 | } |
1474 | mSplitterAgenda->setSizes(sizes); | 1474 | mSplitterAgenda->setSizes(sizes); |
1475 | // qDebug("read %d %d ",sizes[0],sizes[1] ); | 1475 | // qDebug("read %d %d ",sizes[0],sizes[1] ); |
1476 | } | 1476 | } |
1477 | //#endif | 1477 | //#endif |
1478 | 1478 | ||
1479 | // updateConfig(); | 1479 | // updateConfig(); |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | void KOAgendaView::writeSettings(KConfig *config) | 1482 | void KOAgendaView::writeSettings(KConfig *config) |
1483 | { | 1483 | { |
1484 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; | 1484 | // kdDebug() << "KOAgendaView::writeSettings()" << endl; |
1485 | 1485 | ||
1486 | config->setGroup("Views"); | 1486 | config->setGroup("Views"); |
1487 | 1487 | ||
1488 | //#ifndef KORG_NOSPLITTER | 1488 | //#ifndef KORG_NOSPLITTER |
1489 | QValueList<int> list = mSplitterAgenda->sizes(); | 1489 | QValueList<int> list = mSplitterAgenda->sizes(); |
1490 | config->writeEntry("Separator AgendaView",list); | 1490 | config->writeEntry("Separator AgendaView",list); |
1491 | //qDebug("write %d %d ", list[0],list[1] ); | 1491 | //qDebug("write %d %d ", list[0],list[1] ); |
1492 | //#endif | 1492 | //#endif |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | void KOAgendaView::setHolidayMasks() | 1495 | void KOAgendaView::setHolidayMasks() |
1496 | { | 1496 | { |
1497 | mHolidayMask.resize(mSelectedDates.count()); | 1497 | mHolidayMask.resize(mSelectedDates.count()); |
1498 | 1498 | ||
1499 | uint i; | 1499 | uint i; |
1500 | for(i=0;i<mSelectedDates.count();++i) { | 1500 | for(i=0;i<mSelectedDates.count();++i) { |
1501 | QDate date = mSelectedDates[i]; | 1501 | QDate date = mSelectedDates[i]; |
1502 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); | 1502 | bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); |
1503 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); | 1503 | bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); |
1504 | bool showHoliday = false; | 1504 | bool showHoliday = false; |
1505 | if ( KOPrefs::instance()->mExcludeHolidays ) { | 1505 | if ( KOPrefs::instance()->mExcludeHolidays ) { |
1506 | QPtrList<Event> events = calendar()->events( date, true ); | 1506 | QPtrList<Event> events = calendar()->events( date, true ); |
1507 | Event *event; | 1507 | Event *event; |
1508 | for( event = events.first(); event; event = events.next() ) { | 1508 | for( event = events.first(); event; event = events.next() ) { |
1509 | if ( event->isHoliday()) { | 1509 | if ( event->isHoliday()) { |
1510 | showHoliday = true; | 1510 | showHoliday = true; |
1511 | break; | 1511 | break; |
1512 | } | 1512 | } |
1513 | } | 1513 | } |
1514 | 1514 | ||
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | #ifndef KORG_NOPLUGINS | 1517 | #ifndef KORG_NOPLUGINS |
1518 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && | 1518 | bool showHoliday = KOPrefs::instance()->mExcludeHolidays && |
1519 | !KOCore::self()->holiday(date).isEmpty(); | 1519 | !KOCore::self()->holiday(date).isEmpty(); |
1520 | #endif | 1520 | #endif |
1521 | bool showDay = showSaturday || showSunday || showHoliday; | 1521 | bool showDay = showSaturday || showSunday || showHoliday; |
1522 | 1522 | ||
1523 | if (showDay) { | 1523 | if (showDay) { |
1524 | mHolidayMask.at(i) = true; | 1524 | mHolidayMask.at(i) = true; |
1525 | } else { | 1525 | } else { |
1526 | mHolidayMask.at(i) = false; | 1526 | mHolidayMask.at(i) = false; |
1527 | } | 1527 | } |
1528 | } | 1528 | } |
1529 | 1529 | ||
1530 | mAgenda->setHolidayMask(&mHolidayMask); | 1530 | mAgenda->setHolidayMask(&mHolidayMask); |
1531 | mAllDayAgenda->setHolidayMask(&mHolidayMask); | 1531 | mAllDayAgenda->setHolidayMask(&mHolidayMask); |
1532 | } | 1532 | } |
1533 | 1533 | ||
1534 | void KOAgendaView::setContentsPos(int y) | 1534 | void KOAgendaView::setContentsPos(int y) |
1535 | { | 1535 | { |
1536 | mAgenda->setContentsPos(0,y); | 1536 | mAgenda->setContentsPos(0,y); |
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | void KOAgendaView::clearSelection() | 1539 | void KOAgendaView::clearSelection() |
1540 | { | 1540 | { |
1541 | mAgenda->deselectItem(); | 1541 | mAgenda->deselectItem(); |
1542 | mAllDayAgenda->deselectItem(); | 1542 | mAllDayAgenda->deselectItem(); |
1543 | } | 1543 | } |
1544 | 1544 | ||
1545 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, | 1545 | void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, |
1546 | int gxEnd, int gyEnd) | 1546 | int gxEnd, int gyEnd) |
1547 | { | 1547 | { |
1548 | mTimeSpanInAllDay = true; | 1548 | mTimeSpanInAllDay = true; |
1549 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); | 1549 | newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); |
1550 | } | 1550 | } |
1551 | 1551 | ||
1552 | 1552 | ||
1553 | 1553 | ||
1554 | 1554 | ||
1555 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, | 1555 | void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, |
1556 | int gxEnd, int gyEnd) | 1556 | int gxEnd, int gyEnd) |
1557 | { | 1557 | { |
1558 | if (!mSelectedDates.count()) return; | 1558 | if (!mSelectedDates.count()) return; |
1559 | 1559 | ||
1560 | QDate dayStart = mSelectedDates[gxStart]; | 1560 | QDate dayStart = mSelectedDates[gxStart]; |
1561 | QDate dayEnd = mSelectedDates[gxEnd]; | 1561 | QDate dayEnd = mSelectedDates[gxEnd]; |
1562 | 1562 | ||
1563 | QTime timeStart = mAgenda->gyToTime(gyStart); | 1563 | QTime timeStart = mAgenda->gyToTime(gyStart); |
1564 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); | 1564 | QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); |
1565 | 1565 | ||
1566 | QDateTime dtStart(dayStart,timeStart); | 1566 | QDateTime dtStart(dayStart,timeStart); |
1567 | QDateTime dtEnd(dayEnd,timeEnd); | 1567 | QDateTime dtEnd(dayEnd,timeEnd); |
1568 | 1568 | ||
1569 | mTimeSpanBegin = dtStart; | 1569 | mTimeSpanBegin = dtStart; |
1570 | mTimeSpanEnd = dtEnd; | 1570 | mTimeSpanEnd = dtEnd; |
1571 | 1571 | ||
1572 | } | 1572 | } |
1573 | 1573 | ||
1574 | void KOAgendaView::deleteSelectedDateTime() | 1574 | void KOAgendaView::deleteSelectedDateTime() |
1575 | { | 1575 | { |
1576 | mTimeSpanBegin.setDate(QDate()); | 1576 | mTimeSpanBegin.setDate(QDate()); |
1577 | mTimeSpanEnd.setDate(QDate()); | 1577 | mTimeSpanEnd.setDate(QDate()); |
1578 | mTimeSpanInAllDay = false; | 1578 | mTimeSpanInAllDay = false; |
1579 | } | 1579 | } |
1580 | 1580 | ||
1581 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) | 1581 | void KOAgendaView::keyPressEvent ( QKeyEvent * e ) |
1582 | { | 1582 | { |
1583 | e->ignore(); | 1583 | e->ignore(); |
1584 | } | 1584 | } |
1585 | 1585 | ||
1586 | void KOAgendaView::scrollOneHourUp() | 1586 | void KOAgendaView::scrollOneHourUp() |
1587 | { | 1587 | { |
1588 | 1588 | ||
1589 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); | 1589 | mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); |
1590 | } | 1590 | } |
1591 | void KOAgendaView::scrollOneHourDown() | 1591 | void KOAgendaView::scrollOneHourDown() |
1592 | { | 1592 | { |
1593 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); | 1593 | mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); |
1594 | } | 1594 | } |
1595 | 1595 | ||
1596 | void KOAgendaView::setStartHour( int h ) | 1596 | void KOAgendaView::setStartHour( int h ) |
1597 | { | 1597 | { |
1598 | mAgenda->setStartHour( h ); | 1598 | mAgenda->setStartHour( h ); |
1599 | 1599 | ||
1600 | } | 1600 | } |
1601 | void KOAgendaView::setInitStartHour() | 1601 | void KOAgendaView::setInitStartHour() |
1602 | { | 1602 | { |
1603 | 1603 | ||
1604 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) | 1604 | if ( KOPrefs::instance()->mCenterOnCurrentTime ) |
1605 | setStartHour( QTime::currentTime ().hour() ); | 1605 | setStartHour( QTime::currentTime ().hour() ); |
1606 | else | 1606 | else |
1607 | setStartHour( KOPrefs::instance()->mDayBegins ); | 1607 | setStartHour( KOPrefs::instance()->mDayBegins ); |
1608 | 1608 | ||
1609 | } | 1609 | } |
1610 | 1610 | ||
1611 | 1611 | ||
1612 | void KOAgendaView::updateTodo( Todo * t, int ) | 1612 | void KOAgendaView::updateTodo( Todo * t, int ) |
1613 | { | 1613 | { |
1614 | if ( !isVisible() ) | 1614 | if ( !isVisible() ) |
1615 | return; | 1615 | return; |
1616 | bool remove = false; | 1616 | bool remove = false; |
1617 | bool removeAD = false; | 1617 | bool removeAD = false; |
1618 | QDate da; | 1618 | QDate da; |
1619 | if ( t->hasCompletedDate() ) | 1619 | if ( t->hasCompletedDate() ) |
1620 | da = t->completed().date(); | 1620 | da = t->completed().date(); |
1621 | else | 1621 | else |
1622 | da = t->dtDue().date(); | 1622 | da = t->dtDue().date(); |
1623 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { | 1623 | if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { |
1624 | remove = true; | 1624 | remove = true; |
1625 | removeAD = true; | 1625 | removeAD = true; |
1626 | } | 1626 | } |
1627 | else { | 1627 | else { |
1628 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; | 1628 | bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; |
1629 | if ( overdue && | 1629 | if ( overdue && |
1630 | QDate::currentDate() >= mSelectedDates.first() && | 1630 | QDate::currentDate() >= mSelectedDates.first() && |
1631 | QDate::currentDate() <= mSelectedDates.last()) { | 1631 | QDate::currentDate() <= mSelectedDates.last()) { |
1632 | removeAD = false; | 1632 | removeAD = false; |
1633 | remove = true; | 1633 | remove = true; |
1634 | } | 1634 | } |
1635 | else { | 1635 | else { |
1636 | 1636 | ||
1637 | if ( da < mSelectedDates.first() || | 1637 | if ( da < mSelectedDates.first() || |
1638 | da > mSelectedDates.last() ) { | 1638 | da > mSelectedDates.last() ) { |
1639 | remove = true; | 1639 | remove = true; |
1640 | removeAD = true; | 1640 | removeAD = true; |
1641 | } else { | 1641 | } else { |
1642 | remove = t->doesFloat() && !t->hasCompletedDate(); | 1642 | remove = t->doesFloat() && !t->hasCompletedDate(); |
1643 | removeAD = !remove; | 1643 | removeAD = !remove; |
1644 | } | 1644 | } |
1645 | } | 1645 | } |
1646 | } | 1646 | } |
1647 | int days = mSelectedDates.first().daysTo( da ); | 1647 | int days = mSelectedDates.first().daysTo( da ); |
1648 | //qDebug("daysto %d %d %d", days, remove,removeAD ); | 1648 | //qDebug("daysto %d %d %d", days, remove,removeAD ); |
1649 | mAgenda->updateTodo( t , days, remove); | 1649 | mAgenda->updateTodo( t , days, remove); |
1650 | if ( KOPrefs::instance()->mShowTodoInAgenda ) | 1650 | if ( KOPrefs::instance()->mShowTodoInAgenda ) |
1651 | mAllDayAgenda->updateTodo( t , days, removeAD); | 1651 | mAllDayAgenda->updateTodo( t , days, removeAD); |
1652 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); | 1652 | //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); |
1653 | 1653 | ||
1654 | } | 1654 | } |
diff --git a/korganizer/koeditorrecurrence.cpp b/korganizer/koeditorrecurrence.cpp index e165017..dea8981 100644 --- a/korganizer/koeditorrecurrence.cpp +++ b/korganizer/koeditorrecurrence.cpp | |||
@@ -1,1108 +1,1108 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000-2003 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 <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qfiledialog.h> | 25 | #include <qfiledialog.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
33 | #include <qspinbox.h> | 33 | #include <qspinbox.h> |
34 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qapplication.h> | 35 | #include <qapplication.h> |
36 | 36 | ||
37 | #include <kdialog.h> | 37 | #include <kdialog.h> |
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <klocale.h> | 39 | #include <klocale.h> |
40 | #include <kiconloader.h> | 40 | #include <kiconloader.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <knumvalidator.h> | 42 | #include <knumvalidator.h> |
43 | 43 | ||
44 | #include <libkcal/event.h> | 44 | #include <libkcal/event.h> |
45 | #include <libkcal/todo.h> | 45 | #include <libkcal/todo.h> |
46 | 46 | ||
47 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
48 | 48 | ||
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | 50 | ||
51 | #include "koeditorrecurrence.h" | 51 | #include "koeditorrecurrence.h" |
52 | 52 | ||
53 | /////////////////////////// RecurBase /////////////////////////////// | 53 | /////////////////////////// RecurBase /////////////////////////////// |
54 | 54 | ||
55 | RecurBase::RecurBase( QWidget *parent, const char *name ) : | 55 | RecurBase::RecurBase( QWidget *parent, const char *name ) : |
56 | QWidget( parent, name ) | 56 | QWidget( parent, name ) |
57 | { | 57 | { |
58 | mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); | 58 | mFrequencyEdit = new QSpinBox( 1, 9999, 1, this ); |
59 | mFrequencyEdit->setValue( 1 ); | 59 | mFrequencyEdit->setValue( 1 ); |
60 | } | 60 | } |
61 | 61 | ||
62 | QWidget *RecurBase::frequencyEdit() | 62 | QWidget *RecurBase::frequencyEdit() |
63 | { | 63 | { |
64 | return mFrequencyEdit; | 64 | return mFrequencyEdit; |
65 | } | 65 | } |
66 | 66 | ||
67 | void RecurBase::setFrequency( int f ) | 67 | void RecurBase::setFrequency( int f ) |
68 | { | 68 | { |
69 | if ( f < 1 ) f = 1; | 69 | if ( f < 1 ) f = 1; |
70 | 70 | ||
71 | mFrequencyEdit->setValue( f ); | 71 | mFrequencyEdit->setValue( f ); |
72 | } | 72 | } |
73 | 73 | ||
74 | int RecurBase::frequency() | 74 | int RecurBase::frequency() |
75 | { | 75 | { |
76 | return mFrequencyEdit->value(); | 76 | return mFrequencyEdit->value(); |
77 | } | 77 | } |
78 | 78 | ||
79 | /////////////////////////// RecurDaily /////////////////////////////// | 79 | /////////////////////////// RecurDaily /////////////////////////////// |
80 | 80 | ||
81 | RecurDaily::RecurDaily( QWidget *parent, const char *name ) : | 81 | RecurDaily::RecurDaily( QWidget *parent, const char *name ) : |
82 | RecurBase( parent, name ) | 82 | RecurBase( parent, name ) |
83 | { | 83 | { |
84 | QBoxLayout *topLayout = new QHBoxLayout( this ); | 84 | QBoxLayout *topLayout = new QHBoxLayout( this ); |
85 | topLayout->setSpacing( KDialog::spacingHint() ); | 85 | topLayout->setSpacing( KDialog::spacingHint() ); |
86 | topLayout->setMargin( KDialog::marginHintSmall() ); | 86 | topLayout->setMargin( KDialog::marginHintSmall() ); |
87 | 87 | ||
88 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); | 88 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); |
89 | topLayout->addWidget( preLabel ); | 89 | topLayout->addWidget( preLabel ); |
90 | 90 | ||
91 | topLayout->addWidget( frequencyEdit() ); | 91 | topLayout->addWidget( frequencyEdit() ); |
92 | 92 | ||
93 | QLabel *postLabel = new QLabel( i18n("day(s)"), this ); | 93 | QLabel *postLabel = new QLabel( i18n("day(s)"), this ); |
94 | topLayout->addWidget( postLabel ); | 94 | topLayout->addWidget( postLabel ); |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | /////////////////////////// RecurWeekly /////////////////////////////// | 98 | /////////////////////////// RecurWeekly /////////////////////////////// |
99 | 99 | ||
100 | RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : | 100 | RecurWeekly::RecurWeekly( QWidget *parent, const char *name ) : |
101 | RecurBase( parent, name ) | 101 | RecurBase( parent, name ) |
102 | { | 102 | { |
103 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 103 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
104 | topLayout->setSpacing( KDialog::spacingHint() ); | 104 | topLayout->setSpacing( KDialog::spacingHint() ); |
105 | topLayout->setMargin( KDialog::marginHintSmall() ); | 105 | topLayout->setMargin( KDialog::marginHintSmall() ); |
106 | 106 | ||
107 | //topLayout->addStretch( 1 ); | 107 | //topLayout->addStretch( 1 ); |
108 | 108 | ||
109 | QBoxLayout *weeksLayout = new QHBoxLayout( topLayout ); | 109 | QBoxLayout *weeksLayout = new QHBoxLayout( topLayout ); |
110 | 110 | ||
111 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); | 111 | QLabel *preLabel = new QLabel( i18n("Recur every"), this ); |
112 | weeksLayout->addWidget( preLabel ); | 112 | weeksLayout->addWidget( preLabel ); |
113 | 113 | ||
114 | weeksLayout->addWidget( frequencyEdit() ); | 114 | weeksLayout->addWidget( frequencyEdit() ); |
115 | 115 | ||
116 | QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); | 116 | QLabel *postLabel = new QLabel( i18n("week(s) on:"), this ); |
117 | weeksLayout->addWidget( postLabel ); | 117 | weeksLayout->addWidget( postLabel ); |
118 | 118 | ||
119 | QHBox *dayBox = new QHBox( this ); | 119 | QHBox *dayBox = new QHBox( this ); |
120 | topLayout->addWidget( dayBox, 1, AlignVCenter ); | 120 | topLayout->addWidget( dayBox, 1, AlignVCenter ); |
121 | // TODO: Respect start of week setting | 121 | // TODO: Respect start of week setting |
122 | for ( int i = 0; i < 7; ++i ) { | 122 | for ( int i = 0; i < 7; ++i ) { |
123 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); | 123 | QString weekDayName = KGlobal::locale()->weekDayName( i + 1, true ); |
124 | int left = 1; | 124 | int left = 1; |
125 | if ( QApplication::desktop()->width() > 480 ) { | 125 | if ( QApplication::desktop()->width() > 480 ) { |
126 | ++left; | 126 | ++left; |
127 | if ( QApplication::desktop()->width() > 640 ) | 127 | if ( QApplication::desktop()->width() > 640 ) |
128 | ++left; | 128 | ++left; |
129 | } | 129 | } |
130 | mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox ); | 130 | mDayBoxes[ i ] = new QCheckBox( weekDayName.left( left ), dayBox ); |
131 | } | 131 | } |
132 | 132 | ||
133 | topLayout->addStretch( ); | 133 | topLayout->addStretch( ); |
134 | } | 134 | } |
135 | 135 | ||
136 | void RecurWeekly::setDays( const QBitArray &days ) | 136 | void RecurWeekly::setDays( const QBitArray &days ) |
137 | { | 137 | { |
138 | for ( int i = 0; i < 7; ++i ) { | 138 | for ( int i = 0; i < 7; ++i ) { |
139 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); | 139 | mDayBoxes[ i ]->setChecked( days.testBit( i ) ); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
143 | QBitArray RecurWeekly::days() | 143 | QBitArray RecurWeekly::days() |
144 | { | 144 | { |
145 | QBitArray days( 7 ); | 145 | QBitArray days( 7 ); |
146 | 146 | ||
147 | for ( int i = 0; i < 7; ++i ) { | 147 | for ( int i = 0; i < 7; ++i ) { |
148 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); | 148 | days.setBit( i, mDayBoxes[ i ]->isChecked() ); |
149 | } | 149 | } |
150 | 150 | ||
151 | return days; | 151 | return days; |
152 | } | 152 | } |
153 | 153 | ||
154 | /////////////////////////// RecurMonthly /////////////////////////////// | 154 | /////////////////////////// RecurMonthly /////////////////////////////// |
155 | 155 | ||
156 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : | 156 | RecurMonthly::RecurMonthly( QWidget *parent, const char *name ) : |
157 | RecurBase( parent, name ) | 157 | RecurBase( parent, name ) |
158 | { | 158 | { |
159 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 159 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
160 | topLayout->setSpacing( KDialog::spacingHint() ); | 160 | topLayout->setSpacing( KDialog::spacingHint() ); |
161 | topLayout->setMargin( KDialog::marginHintSmall() ); | 161 | topLayout->setMargin( KDialog::marginHintSmall() ); |
162 | 162 | ||
163 | 163 | ||
164 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 164 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); |
165 | 165 | ||
166 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 166 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
167 | freqLayout->addWidget( preLabel ); | 167 | freqLayout->addWidget( preLabel ); |
168 | 168 | ||
169 | freqLayout->addWidget( frequencyEdit() ); | 169 | freqLayout->addWidget( frequencyEdit() ); |
170 | 170 | ||
171 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); | 171 | QLabel *postLabel = new QLabel( i18n("month(s)"), this ); |
172 | freqLayout->addWidget( postLabel ); | 172 | freqLayout->addWidget( postLabel ); |
173 | 173 | ||
174 | 174 | ||
175 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 175 | QButtonGroup *buttonGroup = new QButtonGroup( this ); |
176 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 176 | buttonGroup->setFrameStyle( QFrame::NoFrame ); |
177 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 177 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); |
178 | 178 | ||
179 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); | 179 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 3, 2 ); |
180 | buttonLayout->setSpacing( KDialog::spacingHint() ); | 180 | buttonLayout->setSpacing( KDialog::spacingHint() ); |
181 | buttonLayout->setMargin( KDialog::marginHintSmall() ); | 181 | buttonLayout->setMargin( KDialog::marginHintSmall() ); |
182 | 182 | ||
183 | 183 | ||
184 | QString recurOnText; | 184 | QString recurOnText; |
185 | if ( QApplication::desktop()->width() > 320 ) { | 185 | if ( QApplication::desktop()->width() > 320 ) { |
186 | recurOnText = i18n("Recur on the"); | 186 | recurOnText = i18n("Recur on the"); |
187 | } | 187 | } |
188 | 188 | ||
189 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); | 189 | mByDayRadio = new QRadioButton( recurOnText, buttonGroup ); |
190 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); | 190 | buttonLayout->addWidget( mByDayRadio, 0, 0 ); |
191 | 191 | ||
192 | mByDayCombo = new QComboBox( buttonGroup ); | 192 | mByDayCombo = new QComboBox( buttonGroup ); |
193 | mByDayCombo->setSizeLimit( 7 ); | 193 | mByDayCombo->setSizeLimit( 7 ); |
194 | mByDayCombo->insertItem( i18n("1st") ); | 194 | mByDayCombo->insertItem( i18n("1st") ); |
195 | mByDayCombo->insertItem( i18n("2nd") ); | 195 | mByDayCombo->insertItem( i18n("2nd") ); |
196 | mByDayCombo->insertItem( i18n("3rd") ); | 196 | mByDayCombo->insertItem( i18n("3rd") ); |
197 | mByDayCombo->insertItem( i18n("4th") ); | 197 | mByDayCombo->insertItem( i18n("4th") ); |
198 | mByDayCombo->insertItem( i18n("5th") ); | 198 | mByDayCombo->insertItem( i18n("5th") ); |
199 | mByDayCombo->insertItem( i18n("6th") ); | 199 | mByDayCombo->insertItem( i18n("6th") ); |
200 | mByDayCombo->insertItem( i18n("7th") ); | 200 | mByDayCombo->insertItem( i18n("7th") ); |
201 | mByDayCombo->insertItem( i18n("8th") ); | 201 | mByDayCombo->insertItem( i18n("8th") ); |
202 | mByDayCombo->insertItem( i18n("9th") ); | 202 | mByDayCombo->insertItem( i18n("9th") ); |
203 | mByDayCombo->insertItem( i18n("10th") ); | 203 | mByDayCombo->insertItem( i18n("10th") ); |
204 | mByDayCombo->insertItem( i18n("11th") ); | 204 | mByDayCombo->insertItem( i18n("11th") ); |
205 | mByDayCombo->insertItem( i18n("12th") ); | 205 | mByDayCombo->insertItem( i18n("12th") ); |
206 | mByDayCombo->insertItem( i18n("13th") ); | 206 | mByDayCombo->insertItem( i18n("13th") ); |
207 | mByDayCombo->insertItem( i18n("14th") ); | 207 | mByDayCombo->insertItem( i18n("14th") ); |
208 | mByDayCombo->insertItem( i18n("15th") ); | 208 | mByDayCombo->insertItem( i18n("15th") ); |
209 | mByDayCombo->insertItem( i18n("16th") ); | 209 | mByDayCombo->insertItem( i18n("16th") ); |
210 | mByDayCombo->insertItem( i18n("17th") ); | 210 | mByDayCombo->insertItem( i18n("17th") ); |
211 | mByDayCombo->insertItem( i18n("18th") ); | 211 | mByDayCombo->insertItem( i18n("18th") ); |
212 | mByDayCombo->insertItem( i18n("19th") ); | 212 | mByDayCombo->insertItem( i18n("19th") ); |
213 | mByDayCombo->insertItem( i18n("20th") ); | 213 | mByDayCombo->insertItem( i18n("20th") ); |
214 | mByDayCombo->insertItem( i18n("21st") ); | 214 | mByDayCombo->insertItem( i18n("21st") ); |
215 | mByDayCombo->insertItem( i18n("22nd") ); | 215 | mByDayCombo->insertItem( i18n("22nd") ); |
216 | mByDayCombo->insertItem( i18n("23rd") ); | 216 | mByDayCombo->insertItem( i18n("23rd") ); |
217 | mByDayCombo->insertItem( i18n("24th") ); | 217 | mByDayCombo->insertItem( i18n("24th") ); |
218 | mByDayCombo->insertItem( i18n("25th") ); | 218 | mByDayCombo->insertItem( i18n("25th") ); |
219 | mByDayCombo->insertItem( i18n("26th") ); | 219 | mByDayCombo->insertItem( i18n("26th") ); |
220 | mByDayCombo->insertItem( i18n("27th") ); | 220 | mByDayCombo->insertItem( i18n("27th") ); |
221 | mByDayCombo->insertItem( i18n("28th") ); | 221 | mByDayCombo->insertItem( i18n("28th") ); |
222 | mByDayCombo->insertItem( i18n("29th") ); | 222 | mByDayCombo->insertItem( i18n("29th") ); |
223 | mByDayCombo->insertItem( i18n("30th") ); | 223 | mByDayCombo->insertItem( i18n("30th") ); |
224 | mByDayCombo->insertItem( i18n("31st") ); | 224 | mByDayCombo->insertItem( i18n("31st") ); |
225 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); | 225 | buttonLayout->addWidget( mByDayCombo, 0, 1 ); |
226 | 226 | ||
227 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); | 227 | QLabel *byDayLabel = new QLabel( i18n("day"), buttonGroup ); |
228 | buttonLayout->addWidget( byDayLabel, 0, 2 ); | 228 | buttonLayout->addWidget( byDayLabel, 0, 2 ); |
229 | 229 | ||
230 | 230 | ||
231 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); | 231 | mByPosRadio = new QRadioButton( recurOnText, buttonGroup); |
232 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); | 232 | buttonLayout->addWidget( mByPosRadio, 1, 0 ); |
233 | 233 | ||
234 | mByPosCountCombo = new QComboBox( buttonGroup ); | 234 | mByPosCountCombo = new QComboBox( buttonGroup ); |
235 | mByPosCountCombo->insertItem( i18n("1st") ); | 235 | mByPosCountCombo->insertItem( i18n("1st") ); |
236 | mByPosCountCombo->insertItem( i18n("2nd") ); | 236 | mByPosCountCombo->insertItem( i18n("2nd") ); |
237 | mByPosCountCombo->insertItem( i18n("3rd") ); | 237 | mByPosCountCombo->insertItem( i18n("3rd") ); |
238 | mByPosCountCombo->insertItem( i18n("4th") ); | 238 | mByPosCountCombo->insertItem( i18n("4th") ); |
239 | mByPosCountCombo->insertItem( i18n("5th") ); | 239 | mByPosCountCombo->insertItem( i18n("5th") ); |
240 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); | 240 | buttonLayout->addWidget( mByPosCountCombo, 1, 1 ); |
241 | 241 | ||
242 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); | 242 | mByPosWeekdayCombo = new QComboBox( buttonGroup ); |
243 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); | 243 | mByPosWeekdayCombo->insertItem( i18n("Monday") ); |
244 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); | 244 | mByPosWeekdayCombo->insertItem( i18n("Tuesday") ); |
245 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); | 245 | mByPosWeekdayCombo->insertItem( i18n("Wednesday") ); |
246 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); | 246 | mByPosWeekdayCombo->insertItem( i18n("Thursday") ); |
247 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); | 247 | mByPosWeekdayCombo->insertItem( i18n("Friday") ); |
248 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); | 248 | mByPosWeekdayCombo->insertItem( i18n("Saturday") ); |
249 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); | 249 | mByPosWeekdayCombo->insertItem( i18n("Sunday") ); |
250 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); | 250 | buttonLayout->addWidget( mByPosWeekdayCombo, 1, 2 ); |
251 | } | 251 | } |
252 | 252 | ||
253 | void RecurMonthly::setByDay( int day ) | 253 | void RecurMonthly::setByDay( int day ) |
254 | { | 254 | { |
255 | mByDayRadio->setChecked( true ); | 255 | mByDayRadio->setChecked( true ); |
256 | mByDayCombo->setCurrentItem( day ); | 256 | mByDayCombo->setCurrentItem( day ); |
257 | } | 257 | } |
258 | 258 | ||
259 | void RecurMonthly::setByPos( int count, int weekday ) | 259 | void RecurMonthly::setByPos( int count, int weekday ) |
260 | { | 260 | { |
261 | mByPosRadio->setChecked( true ); | 261 | mByPosRadio->setChecked( true ); |
262 | mByPosCountCombo->setCurrentItem( count ); | 262 | mByPosCountCombo->setCurrentItem( count ); |
263 | mByPosWeekdayCombo->setCurrentItem( weekday ); | 263 | mByPosWeekdayCombo->setCurrentItem( weekday ); |
264 | } | 264 | } |
265 | 265 | ||
266 | bool RecurMonthly::byDay() | 266 | bool RecurMonthly::byDay() |
267 | { | 267 | { |
268 | return mByDayRadio->isChecked(); | 268 | return mByDayRadio->isChecked(); |
269 | } | 269 | } |
270 | 270 | ||
271 | bool RecurMonthly::byPos() | 271 | bool RecurMonthly::byPos() |
272 | { | 272 | { |
273 | return mByPosRadio->isChecked(); | 273 | return mByPosRadio->isChecked(); |
274 | } | 274 | } |
275 | 275 | ||
276 | int RecurMonthly::day() | 276 | int RecurMonthly::day() |
277 | { | 277 | { |
278 | return mByDayCombo->currentItem() + 1; | 278 | return mByDayCombo->currentItem() + 1; |
279 | } | 279 | } |
280 | 280 | ||
281 | int RecurMonthly::count() | 281 | int RecurMonthly::count() |
282 | { | 282 | { |
283 | return mByPosCountCombo->currentItem() + 1; | 283 | return mByPosCountCombo->currentItem() + 1; |
284 | } | 284 | } |
285 | 285 | ||
286 | int RecurMonthly::weekday() | 286 | int RecurMonthly::weekday() |
287 | { | 287 | { |
288 | return mByPosWeekdayCombo->currentItem(); | 288 | return mByPosWeekdayCombo->currentItem(); |
289 | } | 289 | } |
290 | 290 | ||
291 | /////////////////////////// RecurYearly /////////////////////////////// | 291 | /////////////////////////// RecurYearly /////////////////////////////// |
292 | 292 | ||
293 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : | 293 | RecurYearly::RecurYearly( QWidget *parent, const char *name ) : |
294 | RecurBase( parent, name ) | 294 | RecurBase( parent, name ) |
295 | { | 295 | { |
296 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 296 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
297 | topLayout->setSpacing( KDialog::spacingHint() ); | 297 | topLayout->setSpacing( KDialog::spacingHint() ); |
298 | topLayout->setMargin( KDialog::marginHintSmall() ); | 298 | topLayout->setMargin( KDialog::marginHintSmall() ); |
299 | 299 | ||
300 | 300 | ||
301 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); | 301 | QBoxLayout *freqLayout = new QHBoxLayout( topLayout ); |
302 | 302 | ||
303 | QLabel *preLabel = new QLabel( i18n("every"), this ); | 303 | QLabel *preLabel = new QLabel( i18n("every"), this ); |
304 | freqLayout->addWidget( preLabel ); | 304 | freqLayout->addWidget( preLabel ); |
305 | 305 | ||
306 | freqLayout->addWidget( frequencyEdit() ); | 306 | freqLayout->addWidget( frequencyEdit() ); |
307 | 307 | ||
308 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); | 308 | QLabel *postLabel = new QLabel( i18n("year(s)"), this ); |
309 | freqLayout->addWidget( postLabel ); | 309 | freqLayout->addWidget( postLabel ); |
310 | 310 | ||
311 | 311 | ||
312 | QButtonGroup *buttonGroup = new QButtonGroup( this ); | 312 | QButtonGroup *buttonGroup = new QButtonGroup( this ); |
313 | buttonGroup->setFrameStyle( QFrame::NoFrame ); | 313 | buttonGroup->setFrameStyle( QFrame::NoFrame ); |
314 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); | 314 | topLayout->addWidget( buttonGroup, 1, AlignVCenter ); |
315 | 315 | ||
316 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); | 316 | QGridLayout *buttonLayout = new QGridLayout( buttonGroup, 2, 3 ); |
317 | 317 | ||
318 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); | 318 | mByMonthRadio = new QRadioButton( i18n("On day "), buttonGroup); |
319 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); | 319 | buttonLayout->addWidget( mByMonthRadio, 0, 0 , Qt::AlignRight); |
320 | mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup ); | 320 | mByDayLabel = new QLabel( i18n("%1 of ").arg(1), buttonGroup ); |
321 | 321 | ||
322 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); | 322 | buttonLayout->addWidget( mByDayLabel, 0, 1 ); |
323 | mByMonthCombo = new QComboBox( buttonGroup ); | 323 | mByMonthCombo = new QComboBox( buttonGroup ); |
324 | mByMonthCombo->insertItem( i18n("January") ); | 324 | mByMonthCombo->insertItem( i18n("January") ); |
325 | mByMonthCombo->insertItem( i18n("February") ); | 325 | mByMonthCombo->insertItem( i18n("February") ); |
326 | mByMonthCombo->insertItem( i18n("March") ); | 326 | mByMonthCombo->insertItem( i18n("March") ); |
327 | mByMonthCombo->insertItem( i18n("April") ); | 327 | mByMonthCombo->insertItem( i18n("April") ); |
328 | mByMonthCombo->insertItem( i18n("May") ); | 328 | mByMonthCombo->insertItem( i18n("May") ); |
329 | mByMonthCombo->insertItem( i18n("June") ); | 329 | mByMonthCombo->insertItem( i18n("June") ); |
330 | mByMonthCombo->insertItem( i18n("July") ); | 330 | mByMonthCombo->insertItem( i18n("July") ); |
331 | mByMonthCombo->insertItem( i18n("August") ); | 331 | mByMonthCombo->insertItem( i18n("August") ); |
332 | mByMonthCombo->insertItem( i18n("September") ); | 332 | mByMonthCombo->insertItem( i18n("September") ); |
333 | mByMonthCombo->insertItem( i18n("October") ); | 333 | mByMonthCombo->insertItem( i18n("October") ); |
334 | mByMonthCombo->insertItem( i18n("November") ); | 334 | mByMonthCombo->insertItem( i18n("November") ); |
335 | mByMonthCombo->insertItem( i18n("December") ); | 335 | mByMonthCombo->insertItem( i18n("December") ); |
336 | buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); | 336 | buttonLayout->addWidget( mByMonthCombo, 0, 2,Qt::AlignLeft ); |
337 | if ( QApplication::desktop()->width() <= 640 ) { | 337 | if ( QApplication::desktop()->width() <= 640 ) { |
338 | mByMonthCombo->setSizeLimit( 6 ); | 338 | mByMonthCombo->setSizeLimit( 6 ); |
339 | } | 339 | } |
340 | 340 | ||
341 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); | 341 | mByDayRadio = new QRadioButton( i18n("On day "), buttonGroup); |
342 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); | 342 | buttonLayout->addWidget( mByDayRadio, 1, 0 , Qt::AlignRight); |
343 | mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup ); | 343 | mDayOfLabel = new QLabel( i18n("%1 of the year").arg(1), buttonGroup ); |
344 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); | 344 | buttonLayout->addMultiCellWidget( mDayOfLabel, 1, 1, 1,3 ); |
345 | 345 | ||
346 | } | 346 | } |
347 | 347 | ||
348 | void RecurYearly::setByDay( int doy ) | 348 | void RecurYearly::setByDay( int doy ) |
349 | { | 349 | { |
350 | mByDayRadio->setChecked( true ); | 350 | mByDayRadio->setChecked( true ); |
351 | mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); | 351 | mDayOfLabel->setText(i18n("%1 of the year").arg( doy ) ); |
352 | } | 352 | } |
353 | 353 | ||
354 | void RecurYearly::setByMonth( int month, int day ) | 354 | void RecurYearly::setByMonth( int month, int day ) |
355 | { | 355 | { |
356 | mByMonthRadio->setChecked( true ); | 356 | mByMonthRadio->setChecked( true ); |
357 | mByMonthCombo->setCurrentItem( month - 1 ); | 357 | mByMonthCombo->setCurrentItem( month - 1 ); |
358 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); | 358 | mByDayLabel->setText(i18n("%1 of ").arg( day ) ); |
359 | mDay = day; | 359 | mDay = day; |
360 | } | 360 | } |
361 | 361 | ||
362 | bool RecurYearly::byMonth() | 362 | bool RecurYearly::byMonth() |
363 | { | 363 | { |
364 | return mByMonthRadio->isChecked(); | 364 | return mByMonthRadio->isChecked(); |
365 | } | 365 | } |
366 | 366 | ||
367 | bool RecurYearly::byDay() | 367 | bool RecurYearly::byDay() |
368 | { | 368 | { |
369 | return mByDayRadio->isChecked(); | 369 | return mByDayRadio->isChecked(); |
370 | } | 370 | } |
371 | 371 | ||
372 | int RecurYearly::month() | 372 | int RecurYearly::month() |
373 | { | 373 | { |
374 | return mByMonthCombo->currentItem() + 1; | 374 | return mByMonthCombo->currentItem() + 1; |
375 | } | 375 | } |
376 | int RecurYearly::day() | 376 | int RecurYearly::day() |
377 | { | 377 | { |
378 | return mDay;//mByDayCombo->currentItem() + 1; | 378 | return mDay;//mByDayCombo->currentItem() + 1; |
379 | } | 379 | } |
380 | 380 | ||
381 | //////////////////////////// ExceptionsWidget ////////////////////////// | 381 | //////////////////////////// ExceptionsWidget ////////////////////////// |
382 | 382 | ||
383 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : | 383 | ExceptionsWidget::ExceptionsWidget( QWidget *parent, const char *name ) : |
384 | QWidget( parent, name ) | 384 | QWidget( parent, name ) |
385 | { | 385 | { |
386 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 386 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
387 | 387 | ||
388 | QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), | 388 | QGroupBox *groupBox = new QGroupBox( 1, Horizontal, i18n("Exceptions"), |
389 | this ); | 389 | this ); |
390 | topLayout->addWidget( groupBox ); | 390 | topLayout->addWidget( groupBox ); |
391 | 391 | ||
392 | QWidget *box = new QWidget( groupBox ); | 392 | QWidget *box = new QWidget( groupBox ); |
393 | 393 | ||
394 | QGridLayout *boxLayout = new QGridLayout( box ); | 394 | QGridLayout *boxLayout = new QGridLayout( box ); |
395 | 395 | ||
396 | mExceptionDateEdit = new KDateEdit( box ); | 396 | mExceptionDateEdit = new KDateEdit( box ); |
397 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); | 397 | boxLayout->addWidget( mExceptionDateEdit, 0, 0 ); |
398 | 398 | ||
399 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); | 399 | QPushButton *addExceptionButton = new QPushButton( i18n("Add"), box ); |
400 | boxLayout->addWidget( addExceptionButton, 1, 0 ); | 400 | boxLayout->addWidget( addExceptionButton, 1, 0 ); |
401 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); | 401 | QPushButton *changeExceptionButton = new QPushButton( i18n("Change"), box ); |
402 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); | 402 | boxLayout->addWidget( changeExceptionButton, 2, 0 ); |
403 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); | 403 | QPushButton *deleteExceptionButton = new QPushButton( i18n("Delete"), box ); |
404 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); | 404 | boxLayout->addWidget( deleteExceptionButton, 3, 0 ); |
405 | 405 | ||
406 | mExceptionList = new QListBox( box ); | 406 | mExceptionList = new QListBox( box ); |
407 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); | 407 | boxLayout->addMultiCellWidget( mExceptionList, 0, 3, 1, 1 ); |
408 | 408 | ||
409 | boxLayout->setRowStretch( 4, 1 ); | 409 | boxLayout->setRowStretch( 4, 1 ); |
410 | boxLayout->setColStretch( 1, 3 ); | 410 | boxLayout->setColStretch( 1, 3 ); |
411 | 411 | ||
412 | connect( addExceptionButton, SIGNAL( clicked() ), | 412 | connect( addExceptionButton, SIGNAL( clicked() ), |
413 | SLOT( addException() ) ); | 413 | SLOT( addException() ) ); |
414 | connect( changeExceptionButton, SIGNAL( clicked() ), | 414 | connect( changeExceptionButton, SIGNAL( clicked() ), |
415 | SLOT( changeException() ) ); | 415 | SLOT( changeException() ) ); |
416 | connect( deleteExceptionButton, SIGNAL( clicked() ), | 416 | connect( deleteExceptionButton, SIGNAL( clicked() ), |
417 | SLOT( deleteException() ) ); | 417 | SLOT( deleteException() ) ); |
418 | if ( QApplication::desktop()->width() < 480 ) { | 418 | if ( QApplication::desktop()->width() < 480 ) { |
419 | setMinimumWidth( 220 ); | 419 | setMinimumWidth( 220 ); |
420 | } else { | 420 | } else { |
421 | setMinimumWidth( 440 ); | 421 | setMinimumWidth( 440 ); |
422 | mExceptionDateEdit->setMinimumWidth( 200 ); | 422 | mExceptionDateEdit->setMinimumWidth( 200 ); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | 425 | ||
426 | void ExceptionsWidget::setDefaults( const QDateTime &from ) | 426 | void ExceptionsWidget::setDefaults( const QDateTime &from ) |
427 | { | 427 | { |
428 | mExceptionDateEdit->setDate( from.date() ); | 428 | mExceptionDateEdit->setDate( from.date() ); |
429 | } | 429 | } |
430 | 430 | ||
431 | void ExceptionsWidget::addException() | 431 | void ExceptionsWidget::addException() |
432 | { | 432 | { |
433 | QDate date = mExceptionDateEdit->date(); | 433 | QDate date = mExceptionDateEdit->date(); |
434 | QString dateStr = KGlobal::locale()->formatDate( date ); | 434 | QString dateStr = KGlobal::locale()->formatDate( date ); |
435 | if( !mExceptionList->findItem( dateStr ) ) { | 435 | if( !mExceptionList->findItem( dateStr ) ) { |
436 | mExceptionDates.append( date ); | 436 | mExceptionDates.append( date ); |
437 | mExceptionList->insertItem( dateStr ); | 437 | mExceptionList->insertItem( dateStr ); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | void ExceptionsWidget::changeException() | 441 | void ExceptionsWidget::changeException() |
442 | { | 442 | { |
443 | int pos = mExceptionList->currentItem(); | 443 | int pos = mExceptionList->currentItem(); |
444 | if ( pos < 0 ) return; | 444 | if ( pos < 0 ) return; |
445 | 445 | ||
446 | QDate date = mExceptionDateEdit->date(); | 446 | QDate date = mExceptionDateEdit->date(); |
447 | mExceptionDates[ pos ] = date; | 447 | mExceptionDates[ pos ] = date; |
448 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); | 448 | mExceptionList->changeItem( KGlobal::locale()->formatDate( date ), pos ); |
449 | } | 449 | } |
450 | 450 | ||
451 | void ExceptionsWidget::deleteException() | 451 | void ExceptionsWidget::deleteException() |
452 | { | 452 | { |
453 | int pos = mExceptionList->currentItem(); | 453 | int pos = mExceptionList->currentItem(); |
454 | if ( pos < 0 ) return; | 454 | if ( pos < 0 ) return; |
455 | 455 | ||
456 | mExceptionDates.remove( mExceptionDates.at( pos ) ); | 456 | mExceptionDates.remove( mExceptionDates.at( pos ) ); |
457 | mExceptionList->removeItem( pos ); | 457 | mExceptionList->removeItem( pos ); |
458 | } | 458 | } |
459 | 459 | ||
460 | void ExceptionsWidget::setDates( const DateList &dates ) | 460 | void ExceptionsWidget::setDates( const DateList &dates ) |
461 | { | 461 | { |
462 | mExceptionList->clear(); | 462 | mExceptionList->clear(); |
463 | mExceptionDates.clear(); | 463 | mExceptionDates.clear(); |
464 | DateList::ConstIterator dit; | 464 | DateList::ConstIterator dit; |
465 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { | 465 | for ( dit = dates.begin(); dit != dates.end(); ++dit ) { |
466 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); | 466 | mExceptionList->insertItem( KGlobal::locale()->formatDate(* dit ) ); |
467 | mExceptionDates.append( *dit ); | 467 | mExceptionDates.append( *dit ); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | 470 | ||
471 | DateList ExceptionsWidget::dates() | 471 | DateList ExceptionsWidget::dates() |
472 | { | 472 | { |
473 | return mExceptionDates; | 473 | return mExceptionDates; |
474 | } | 474 | } |
475 | 475 | ||
476 | ///////////////////////// ExceptionsDialog /////////////////////////// | 476 | ///////////////////////// ExceptionsDialog /////////////////////////// |
477 | 477 | ||
478 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : | 478 | ExceptionsDialog::ExceptionsDialog( QWidget *parent, const char *name ) : |
479 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) | 479 | KDialogBase( parent, name, true, i18n("Edit exceptions"), Ok|Cancel ) |
480 | { | 480 | { |
481 | mExceptions = new ExceptionsWidget( this ); | 481 | mExceptions = new ExceptionsWidget( this ); |
482 | setMainWidget( mExceptions ); | 482 | setMainWidget( mExceptions ); |
483 | resize(220,10); | 483 | resize(220,10); |
484 | } | 484 | } |
485 | 485 | ||
486 | void ExceptionsDialog::setDefaults( const QDateTime &from ) | 486 | void ExceptionsDialog::setDefaults( const QDateTime &from ) |
487 | { | 487 | { |
488 | mExceptions->setDefaults( from ); | 488 | mExceptions->setDefaults( from ); |
489 | } | 489 | } |
490 | 490 | ||
491 | void ExceptionsDialog::setDates( const DateList &dates ) | 491 | void ExceptionsDialog::setDates( const DateList &dates ) |
492 | { | 492 | { |
493 | mExceptions->setDates( dates ); | 493 | mExceptions->setDates( dates ); |
494 | } | 494 | } |
495 | 495 | ||
496 | DateList ExceptionsDialog::dates() | 496 | DateList ExceptionsDialog::dates() |
497 | { | 497 | { |
498 | return mExceptions->dates(); | 498 | return mExceptions->dates(); |
499 | } | 499 | } |
500 | 500 | ||
501 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// | 501 | ///////////////////////// RecurrenceRangeWidget /////////////////////////// |
502 | 502 | ||
503 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, | 503 | RecurrenceRangeWidget::RecurrenceRangeWidget( QWidget *parent, |
504 | const char *name ) | 504 | const char *name ) |
505 | : QWidget( parent, name ) | 505 | : QWidget( parent, name ) |
506 | { | 506 | { |
507 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 507 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
508 | 508 | ||
509 | mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), | 509 | mRangeGroupBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Range"), |
510 | this ); | 510 | this ); |
511 | topLayout->addWidget( mRangeGroupBox ); | 511 | topLayout->addWidget( mRangeGroupBox ); |
512 | 512 | ||
513 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); | 513 | QWidget *rangeBox = new QWidget( mRangeGroupBox ); |
514 | QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); | 514 | QVBoxLayout *rangeLayout = new QVBoxLayout( rangeBox ); |
515 | rangeLayout->setSpacing( KDialog::spacingHint() ); | 515 | rangeLayout->setSpacing( KDialog::spacingHint() ); |
516 | rangeLayout->setMargin( KDialog::marginHintSmall() ); | 516 | rangeLayout->setMargin( KDialog::marginHintSmall() ); |
517 | 517 | ||
518 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); | 518 | mStartDateLabel = new QLabel( i18n("Begin on:"), rangeBox ); |
519 | rangeLayout->addWidget( mStartDateLabel ); | 519 | rangeLayout->addWidget( mStartDateLabel ); |
520 | 520 | ||
521 | QButtonGroup *rangeButtonGroup = new QButtonGroup; | 521 | QButtonGroup *rangeButtonGroup = new QButtonGroup; |
522 | 522 | ||
523 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); | 523 | mNoEndDateButton = new QRadioButton( i18n("No ending date"), rangeBox ); |
524 | rangeButtonGroup->insert( mNoEndDateButton ); | 524 | rangeButtonGroup->insert( mNoEndDateButton ); |
525 | rangeLayout->addWidget( mNoEndDateButton ); | 525 | rangeLayout->addWidget( mNoEndDateButton ); |
526 | 526 | ||
527 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); | 527 | QBoxLayout *durationLayout = new QHBoxLayout( rangeLayout ); |
528 | durationLayout->setSpacing( KDialog::spacingHint() ); | 528 | durationLayout->setSpacing( KDialog::spacingHint() ); |
529 | 529 | ||
530 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); | 530 | mEndDurationButton = new QRadioButton( i18n("End after"), rangeBox ); |
531 | rangeButtonGroup->insert( mEndDurationButton ); | 531 | rangeButtonGroup->insert( mEndDurationButton ); |
532 | durationLayout->addWidget( mEndDurationButton ); | 532 | durationLayout->addWidget( mEndDurationButton ); |
533 | 533 | ||
534 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); | 534 | mEndDurationEdit = new QSpinBox( 1, 9999, 1, rangeBox ); |
535 | durationLayout->addWidget( mEndDurationEdit ); | 535 | durationLayout->addWidget( mEndDurationEdit ); |
536 | 536 | ||
537 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); | 537 | QLabel *endDurationLabel = new QLabel( i18n("occurrence(s)"), rangeBox ); |
538 | durationLayout ->addWidget( endDurationLabel ); | 538 | durationLayout ->addWidget( endDurationLabel ); |
539 | 539 | ||
540 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); | 540 | QBoxLayout *endDateLayout = new QHBoxLayout( rangeLayout ); |
541 | endDateLayout->setSpacing( KDialog::spacingHint() ); | 541 | endDateLayout->setSpacing( KDialog::spacingHint() ); |
542 | 542 | ||
543 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); | 543 | mEndDateButton = new QRadioButton( i18n("End by:"), rangeBox ); |
544 | rangeButtonGroup->insert( mEndDateButton ); | 544 | rangeButtonGroup->insert( mEndDateButton ); |
545 | endDateLayout->addWidget( mEndDateButton ); | 545 | endDateLayout->addWidget( mEndDateButton ); |
546 | 546 | ||
547 | mEndDateEdit = new KDateEdit( rangeBox ); | 547 | mEndDateEdit = new KDateEdit( rangeBox ); |
548 | endDateLayout->addWidget( mEndDateEdit ); | 548 | endDateLayout->addWidget( mEndDateEdit ); |
549 | 549 | ||
550 | //endDateLayout->addStretch( 1 ); | 550 | //endDateLayout->addStretch( 1 ); |
551 | 551 | ||
552 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), | 552 | connect( mNoEndDateButton, SIGNAL( toggled( bool ) ), |
553 | SLOT( showCurrentRange() ) ); | 553 | SLOT( showCurrentRange() ) ); |
554 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), | 554 | connect( mEndDurationButton, SIGNAL( toggled( bool ) ), |
555 | SLOT( showCurrentRange() ) ); | 555 | SLOT( showCurrentRange() ) ); |
556 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), | 556 | connect( mEndDateButton, SIGNAL( toggled( bool ) ), |
557 | SLOT( showCurrentRange() ) ); | 557 | SLOT( showCurrentRange() ) ); |
558 | } | 558 | } |
559 | 559 | ||
560 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) | 560 | void RecurrenceRangeWidget::setDefaults( const QDateTime &from ) |
561 | { | 561 | { |
562 | mNoEndDateButton->setChecked( true ); | 562 | mNoEndDateButton->setChecked( true ); |
563 | 563 | ||
564 | setDateTimes( from ); | 564 | setDateTimes( from ); |
565 | mEndDateEdit->setDate( from.date() ); | 565 | mEndDateEdit->setDate( from.date() ); |
566 | } | 566 | } |
567 | 567 | ||
568 | void RecurrenceRangeWidget::setDuration( int duration ) | 568 | void RecurrenceRangeWidget::setDuration( int duration ) |
569 | { | 569 | { |
570 | if ( duration == -1 ) { | 570 | if ( duration == -1 ) { |
571 | mNoEndDateButton->setChecked( true ); | 571 | mNoEndDateButton->setChecked( true ); |
572 | } else if ( duration == 0 ) { | 572 | } else if ( duration == 0 ) { |
573 | mEndDateButton->setChecked( true ); | 573 | mEndDateButton->setChecked( true ); |
574 | } else { | 574 | } else { |
575 | mEndDurationButton->setChecked( true ); | 575 | mEndDurationButton->setChecked( true ); |
576 | mEndDurationEdit->setValue( duration ); | 576 | mEndDurationEdit->setValue( duration ); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | int RecurrenceRangeWidget::duration() | 580 | int RecurrenceRangeWidget::duration() |
581 | { | 581 | { |
582 | if ( mNoEndDateButton->isChecked() ) { | 582 | if ( mNoEndDateButton->isChecked() ) { |
583 | return -1; | 583 | return -1; |
584 | } else if ( mEndDurationButton->isChecked() ) { | 584 | } else if ( mEndDurationButton->isChecked() ) { |
585 | return mEndDurationEdit->value(); | 585 | return mEndDurationEdit->value(); |
586 | } else { | 586 | } else { |
587 | return 0; | 587 | return 0; |
588 | } | 588 | } |
589 | } | 589 | } |
590 | 590 | ||
591 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) | 591 | void RecurrenceRangeWidget::setEndDate( const QDate &date ) |
592 | { | 592 | { |
593 | mEndDateEdit->setDate( date ); | 593 | mEndDateEdit->setDate( date ); |
594 | } | 594 | } |
595 | 595 | ||
596 | QDate RecurrenceRangeWidget::endDate() | 596 | QDate RecurrenceRangeWidget::endDate() |
597 | { | 597 | { |
598 | return mEndDateEdit->date(); | 598 | return mEndDateEdit->date(); |
599 | } | 599 | } |
600 | 600 | ||
601 | void RecurrenceRangeWidget::showCurrentRange() | 601 | void RecurrenceRangeWidget::showCurrentRange() |
602 | { | 602 | { |
603 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); | 603 | mEndDurationEdit->setEnabled( mEndDurationButton->isChecked() ); |
604 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); | 604 | mEndDateEdit->setEnabled( mEndDateButton->isChecked() ); |
605 | } | 605 | } |
606 | 606 | ||
607 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, | 607 | void RecurrenceRangeWidget::setDateTimes( const QDateTime &start, |
608 | const QDateTime & ) | 608 | const QDateTime & ) |
609 | { | 609 | { |
610 | mStartDateLabel->setText( i18n("Start date: %1") | 610 | mStartDateLabel->setText( i18n("Start date: %1") |
611 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); | 611 | .arg( KGlobal::locale()->formatDate( start.date() ) ) ); |
612 | 612 | ||
613 | if(!mEndDateButton->isChecked()) | 613 | if(!mEndDateButton->isChecked()) |
614 | mEndDateEdit->setDate( start.date() ); | 614 | mEndDateEdit->setDate( start.date() ); |
615 | } | 615 | } |
616 | 616 | ||
617 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// | 617 | ///////////////////////// RecurrenceRangeDialog /////////////////////////// |
618 | 618 | ||
619 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, | 619 | RecurrenceRangeDialog::RecurrenceRangeDialog( QWidget *parent, |
620 | const char *name ) : | 620 | const char *name ) : |
621 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) | 621 | KDialogBase( parent, name, true, i18n("Edit Recurrence Range"), Ok|Cancel ) |
622 | { | 622 | { |
623 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); | 623 | mRecurrenceRangeWidget = new RecurrenceRangeWidget( this ); |
624 | setMainWidget( mRecurrenceRangeWidget ); | 624 | setMainWidget( mRecurrenceRangeWidget ); |
625 | } | 625 | } |
626 | 626 | ||
627 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) | 627 | void RecurrenceRangeDialog::setDefaults( const QDateTime &from ) |
628 | { | 628 | { |
629 | mRecurrenceRangeWidget->setDefaults( from ); | 629 | mRecurrenceRangeWidget->setDefaults( from ); |
630 | } | 630 | } |
631 | 631 | ||
632 | void RecurrenceRangeDialog::setDuration( int duration ) | 632 | void RecurrenceRangeDialog::setDuration( int duration ) |
633 | { | 633 | { |
634 | mRecurrenceRangeWidget->setDuration( duration ); | 634 | mRecurrenceRangeWidget->setDuration( duration ); |
635 | } | 635 | } |
636 | 636 | ||
637 | int RecurrenceRangeDialog::duration() | 637 | int RecurrenceRangeDialog::duration() |
638 | { | 638 | { |
639 | return mRecurrenceRangeWidget->duration(); | 639 | return mRecurrenceRangeWidget->duration(); |
640 | } | 640 | } |
641 | 641 | ||
642 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) | 642 | void RecurrenceRangeDialog::setEndDate( const QDate &date ) |
643 | { | 643 | { |
644 | mRecurrenceRangeWidget->setEndDate( date ); | 644 | mRecurrenceRangeWidget->setEndDate( date ); |
645 | } | 645 | } |
646 | 646 | ||
647 | QDate RecurrenceRangeDialog::endDate() | 647 | QDate RecurrenceRangeDialog::endDate() |
648 | { | 648 | { |
649 | return mRecurrenceRangeWidget->endDate(); | 649 | return mRecurrenceRangeWidget->endDate(); |
650 | } | 650 | } |
651 | 651 | ||
652 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, | 652 | void RecurrenceRangeDialog::setDateTimes( const QDateTime &start, |
653 | const QDateTime &end ) | 653 | const QDateTime &end ) |
654 | { | 654 | { |
655 | mRecurrenceRangeWidget->setDateTimes( start, end ); | 655 | mRecurrenceRangeWidget->setDateTimes( start, end ); |
656 | } | 656 | } |
657 | 657 | ||
658 | //////////////////////////// RecurrenceChooser //////////////////////// | 658 | //////////////////////////// RecurrenceChooser //////////////////////// |
659 | 659 | ||
660 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : | 660 | RecurrenceChooser::RecurrenceChooser( QWidget *parent, const char *name ) : |
661 | QWidget( parent, name ) | 661 | QWidget( parent, name ) |
662 | { | 662 | { |
663 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 663 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
664 | 664 | ||
665 | mTypeCombo = new QComboBox( this ); | 665 | mTypeCombo = new QComboBox( this ); |
666 | mTypeCombo->insertItem( i18n("Daily") ); | 666 | mTypeCombo->insertItem( i18n("Daily") ); |
667 | mTypeCombo->insertItem( i18n("Weekly") ); | 667 | mTypeCombo->insertItem( i18n("Weekly") ); |
668 | mTypeCombo->insertItem( i18n("Monthly") ); | 668 | mTypeCombo->insertItem( i18n("Monthly") ); |
669 | mTypeCombo->insertItem( i18n("Yearly") ); | 669 | mTypeCombo->insertItem( i18n("Yearly") ); |
670 | 670 | ||
671 | topLayout->addWidget( mTypeCombo ); | 671 | topLayout->addWidget( mTypeCombo ); |
672 | 672 | ||
673 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); | 673 | connect( mTypeCombo, SIGNAL( activated( int ) ), SLOT( emitChoice() ) ); |
674 | 674 | ||
675 | } | 675 | } |
676 | 676 | ||
677 | int RecurrenceChooser::type() | 677 | int RecurrenceChooser::type() |
678 | { | 678 | { |
679 | if ( mTypeCombo ) { | 679 | if ( mTypeCombo ) { |
680 | return mTypeCombo->currentItem(); | 680 | return mTypeCombo->currentItem(); |
681 | } else { | 681 | } else { |
682 | if ( mDailyButton->isChecked() ) return Daily; | 682 | if ( mDailyButton->isChecked() ) return Daily; |
683 | else if ( mWeeklyButton->isChecked() ) return Weekly; | 683 | else if ( mWeeklyButton->isChecked() ) return Weekly; |
684 | else if ( mMonthlyButton->isChecked() ) return Monthly; | 684 | else if ( mMonthlyButton->isChecked() ) return Monthly; |
685 | else return Yearly; | 685 | else return Yearly; |
686 | } | 686 | } |
687 | } | 687 | } |
688 | 688 | ||
689 | void RecurrenceChooser::setType( int type ) | 689 | void RecurrenceChooser::setType( int type ) |
690 | { | 690 | { |
691 | if ( mTypeCombo ) { | 691 | if ( mTypeCombo ) { |
692 | mTypeCombo->setCurrentItem( type ); | 692 | mTypeCombo->setCurrentItem( type ); |
693 | } else { | 693 | } else { |
694 | switch ( type ) { | 694 | switch ( type ) { |
695 | case Daily: | 695 | case Daily: |
696 | mDailyButton->setChecked( true ); | 696 | mDailyButton->setChecked( true ); |
697 | break; | 697 | break; |
698 | case Weekly: | 698 | case Weekly: |
699 | mWeeklyButton->setChecked( true ); | 699 | mWeeklyButton->setChecked( true ); |
700 | break; | 700 | break; |
701 | case Monthly: | 701 | case Monthly: |
702 | mMonthlyButton->setChecked( true ); | 702 | mMonthlyButton->setChecked( true ); |
703 | break; | 703 | break; |
704 | case Yearly: | 704 | case Yearly: |
705 | default: | 705 | default: |
706 | mYearlyButton->setChecked( true ); | 706 | mYearlyButton->setChecked( true ); |
707 | break; | 707 | break; |
708 | } | 708 | } |
709 | } | 709 | } |
710 | } | 710 | } |
711 | 711 | ||
712 | void RecurrenceChooser::emitChoice() | 712 | void RecurrenceChooser::emitChoice() |
713 | { | 713 | { |
714 | emit chosen ( type() ); | 714 | emit chosen ( type() ); |
715 | } | 715 | } |
716 | 716 | ||
717 | /////////////////////////////// Main Widget ///////////////////////////// | 717 | /////////////////////////////// Main Widget ///////////////////////////// |
718 | 718 | ||
719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : | 719 | KOEditorRecurrence::KOEditorRecurrence( QWidget* parent, const char *name ) : |
720 | QWidget( parent, name ) | 720 | QWidget( parent, name ) |
721 | { | 721 | { |
722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); | 722 | QGridLayout *topLayout = new QGridLayout( this, 2,2 ); |
723 | topLayout->setSpacing( KDialog::spacingHint() ); | 723 | topLayout->setSpacing( KDialog::spacingHint() ); |
724 | topLayout->setMargin( KDialog::marginHintSmall() ); | 724 | topLayout->setMargin( KDialog::marginHintSmall() ); |
725 | 725 | ||
726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); | 726 | mEnabledCheck = new QCheckBox( i18n("Enable Recurrence"), this ); |
727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), | 727 | connect( mEnabledCheck, SIGNAL( toggled( bool ) ), |
728 | SLOT( setEnabled( bool ) ) ); | 728 | SLOT( setEnabled( bool ) ) ); |
729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); | 729 | topLayout->addMultiCellWidget( mEnabledCheck, 0, 0, 0, 1 ); |
730 | 730 | ||
731 | 731 | ||
732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), | 732 | mTimeGroupBox = new QGroupBox( 1, Horizontal, i18n("Time"), |
733 | this ); | 733 | this ); |
734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); | 734 | topLayout->addMultiCellWidget( mTimeGroupBox, 1, 1 , 0 , 1 ); |
735 | 735 | ||
736 | if ( QApplication::desktop()->width() <= 640 ) { | 736 | if ( QApplication::desktop()->width() <= 640 ) { |
737 | mTimeGroupBox->hide(); | 737 | mTimeGroupBox->hide(); |
738 | } | 738 | } |
739 | 739 | ||
740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); | 740 | // QFrame *timeFrame = new QFrame( mTimeGroupBox ); |
741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); | 741 | // QBoxLayout *layoutTimeFrame = new QHBoxLayout( timeFrame ); |
742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); | 742 | // layoutTimeFrame->setSpacing( KDialog::spacingHint() ); |
743 | 743 | ||
744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); | 744 | mDateTimeLabel = new QLabel( mTimeGroupBox ); |
745 | // mDateTimeLabel = new QLabel( timeFrame ); | 745 | // mDateTimeLabel = new QLabel( timeFrame ); |
746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); | 746 | // layoutTimeFrame->addWidget( mDateTimeLabel ); |
747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); | 747 | //mTimeGroupBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ) ); |
748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); | 748 | //mDateTimeLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum) ); |
749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); | 749 | mRuleBox = new QGroupBox( 1, Horizontal, i18n("Recurrence Rule"), this ); |
750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); | 750 | topLayout->addMultiCellWidget( mRuleBox, 2, 2, 0, 1 ); |
751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); | 751 | mRecurrenceChooser = new RecurrenceChooser( mRuleBox ); |
752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), | 752 | connect( mRecurrenceChooser, SIGNAL( chosen( int ) ), |
753 | SLOT( showCurrentRule( int ) ) ); | 753 | SLOT( showCurrentRule( int ) ) ); |
754 | 754 | ||
755 | 755 | ||
756 | mRuleStack = new QWidgetStack( mRuleBox ); | 756 | mRuleStack = new QWidgetStack( mRuleBox ); |
757 | 757 | ||
758 | mDaily = new RecurDaily( mRuleStack ); | 758 | mDaily = new RecurDaily( mRuleStack ); |
759 | mRuleStack->addWidget( mDaily, 0 ); | 759 | mRuleStack->addWidget( mDaily, 0 ); |
760 | 760 | ||
761 | mWeekly = new RecurWeekly( mRuleStack ); | 761 | mWeekly = new RecurWeekly( mRuleStack ); |
762 | mRuleStack->addWidget( mWeekly, 0 ); | 762 | mRuleStack->addWidget( mWeekly, 0 ); |
763 | 763 | ||
764 | mMonthly = new RecurMonthly( mRuleStack ); | 764 | mMonthly = new RecurMonthly( mRuleStack ); |
765 | mRuleStack->addWidget( mMonthly, 0 ); | 765 | mRuleStack->addWidget( mMonthly, 0 ); |
766 | 766 | ||
767 | mYearly = new RecurYearly( mRuleStack ); | 767 | mYearly = new RecurYearly( mRuleStack ); |
768 | mRuleStack->addWidget( mYearly, 0 ); | 768 | mRuleStack->addWidget( mYearly, 0 ); |
769 | 769 | ||
770 | showCurrentRule( mRecurrenceChooser->type() ); | 770 | showCurrentRule( mRecurrenceChooser->type() ); |
771 | mRecurrenceRangeWidget = 0; | 771 | mRecurrenceRangeWidget = 0; |
772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); | 772 | mRecurrenceRangeDialog = new RecurrenceRangeDialog( this ); |
773 | mRecurrenceRange = mRecurrenceRangeDialog; | 773 | mRecurrenceRange = mRecurrenceRangeDialog; |
774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), | 774 | mRecurrenceRangeButton = new QPushButton( i18n("Recurrence Range..."), |
775 | this ); | 775 | this ); |
776 | 776 | ||
777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), | 777 | connect( mRecurrenceRangeButton, SIGNAL( clicked() ), |
778 | SLOT( showRecurrenceRangeDialog() ) ); | 778 | SLOT( showRecurrenceRangeDialog() ) ); |
779 | 779 | ||
780 | mExceptionsWidget = 0; | 780 | mExceptionsWidget = 0; |
781 | mExceptionsDialog = new ExceptionsDialog( this ); | 781 | mExceptionsDialog = new ExceptionsDialog( this ); |
782 | mExceptions = mExceptionsDialog; | 782 | mExceptions = mExceptionsDialog; |
783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); | 783 | mExceptionsButton = new QPushButton( i18n("Exceptions..."), this ); |
784 | if ( QApplication::desktop()->width() < 320 ) { | 784 | if ( QApplication::desktop()->width() < 320 ) { |
785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); | 785 | topLayout->addMultiCellWidget( mRecurrenceRangeButton, 3, 3, 0, 1 ); |
786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); | 786 | topLayout->addMultiCellWidget( mExceptionsButton, 4, 4, 0, 1 ); |
787 | } else { | 787 | } else { |
788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); | 788 | topLayout->addWidget( mRecurrenceRangeButton, 3, 0 ); |
789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); | 789 | topLayout->addWidget( mExceptionsButton, 3, 1 ); |
790 | } | 790 | } |
791 | connect( mExceptionsButton, SIGNAL( clicked() ), | 791 | connect( mExceptionsButton, SIGNAL( clicked() ), |
792 | SLOT( showExceptionsDialog() ) ); | 792 | SLOT( showExceptionsDialog() ) ); |
793 | } | 793 | } |
794 | 794 | ||
795 | KOEditorRecurrence::~KOEditorRecurrence() | 795 | KOEditorRecurrence::~KOEditorRecurrence() |
796 | { | 796 | { |
797 | } | 797 | } |
798 | 798 | ||
799 | void KOEditorRecurrence::setEnabled( bool enabled ) | 799 | void KOEditorRecurrence::setEnabled( bool enabled ) |
800 | { | 800 | { |
801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; | 801 | // kdDebug() << "KOEditorRecurrence::setEnabled(): " << (enabled ? "on" : "off") << endl; |
802 | 802 | ||
803 | mTimeGroupBox->setEnabled( enabled ); | 803 | mTimeGroupBox->setEnabled( enabled ); |
804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); | 804 | if ( mRecurrenceRangeWidget ) mRecurrenceRangeWidget->setEnabled( enabled ); |
805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); | 805 | if ( mRecurrenceRangeButton ) mRecurrenceRangeButton->setEnabled( enabled ); |
806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); | 806 | if ( mExceptionsWidget ) mExceptionsWidget->setEnabled( enabled ); |
807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); | 807 | if ( mExceptionsButton ) mExceptionsButton->setEnabled( enabled ); |
808 | mRuleBox->setEnabled( enabled ); | 808 | mRuleBox->setEnabled( enabled ); |
809 | } | 809 | } |
810 | 810 | ||
811 | void KOEditorRecurrence::showCurrentRule( int current ) | 811 | void KOEditorRecurrence::showCurrentRule( int current ) |
812 | { | 812 | { |
813 | switch ( current ) { | 813 | switch ( current ) { |
814 | case Daily: | 814 | case Daily: |
815 | mRuleStack->raiseWidget( mDaily ); | 815 | mRuleStack->raiseWidget( mDaily ); |
816 | break; | 816 | break; |
817 | case Weekly: | 817 | case Weekly: |
818 | mRuleStack->raiseWidget( mWeekly ); | 818 | mRuleStack->raiseWidget( mWeekly ); |
819 | break; | 819 | break; |
820 | case Monthly: | 820 | case Monthly: |
821 | mRuleStack->raiseWidget( mMonthly ); | 821 | mRuleStack->raiseWidget( mMonthly ); |
822 | break; | 822 | break; |
823 | default: | 823 | default: |
824 | case Yearly: | 824 | case Yearly: |
825 | mRuleStack->raiseWidget( mYearly ); | 825 | mRuleStack->raiseWidget( mYearly ); |
826 | break; | 826 | break; |
827 | } | 827 | } |
828 | } | 828 | } |
829 | 829 | ||
830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) | 830 | void KOEditorRecurrence::setDateTimes( QDateTime start, QDateTime end ) |
831 | { | 831 | { |
832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; | 832 | // kdDebug() << "KOEditorRecurrence::setDateTimes" << endl; |
833 | 833 | ||
834 | mRecurrenceRange->setDateTimes( start, end ); | 834 | mRecurrenceRange->setDateTimes( start, end ); |
835 | mExceptions->setDefaults( end ); | 835 | mExceptions->setDefaults( end ); |
836 | 836 | ||
837 | } | 837 | } |
838 | 838 | ||
839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) | 839 | void KOEditorRecurrence::setDefaults( QDateTime from, QDateTime to, bool ) |
840 | { | 840 | { |
841 | 841 | ||
842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); | 842 | // qDebug("KOEditorRecurrence::setDefaults %s %s ",from.toString().latin1(),to.toString().latin1() ); |
843 | setDateTimes( from, to ); | 843 | setDateTimes( from, to ); |
844 | 844 | ||
845 | bool enabled = false; | 845 | bool enabled = false; |
846 | mEnabledCheck->setChecked( enabled ); | 846 | mEnabledCheck->setChecked( enabled ); |
847 | setEnabled( enabled ); | 847 | setEnabled( enabled ); |
848 | 848 | ||
849 | mExceptions->setDefaults( to ); | 849 | mExceptions->setDefaults( to ); |
850 | mRecurrenceRange->setDefaults( to ); | 850 | mRecurrenceRange->setDefaults( to ); |
851 | 851 | ||
852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); | 852 | mRecurrenceChooser->setType( RecurrenceChooser::Weekly ); |
853 | showCurrentRule( mRecurrenceChooser->type() ); | 853 | showCurrentRule( mRecurrenceChooser->type() ); |
854 | 854 | ||
855 | mDaily->setFrequency( 1 ); | 855 | mDaily->setFrequency( 1 ); |
856 | 856 | ||
857 | mWeekly->setFrequency( 1 ); | 857 | mWeekly->setFrequency( 1 ); |
858 | QBitArray days( 7 ); | 858 | QBitArray days( 7 ); |
859 | days.fill( 0 ); | 859 | days.fill( 0 ); |
860 | days.setBit( from.date().dayOfWeek()- 1); | 860 | days.setBit( from.date().dayOfWeek()- 1); |
861 | mWeekly->setDays( days ); | 861 | mWeekly->setDays( days ); |
862 | mMonthly->setFrequency( 1 ); | 862 | mMonthly->setFrequency( 1 ); |
863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); | 863 | mMonthly->setByPos((from.date().day()/7), from.date().dayOfWeek()-1 ); |
864 | mMonthly->setByDay( from.date().day()-1 ); | 864 | mMonthly->setByDay( from.date().day()-1 ); |
865 | mYearly->setFrequency( 1 ); | 865 | mYearly->setFrequency( 1 ); |
866 | mYearly->setByDay( from.date().dayOfYear() ); | 866 | mYearly->setByDay( from.date().dayOfYear() ); |
867 | mYearly->setByMonth( from.date().month(), from.date().day() ); | 867 | mYearly->setByMonth( from.date().month(), from.date().day() ); |
868 | } | 868 | } |
869 | 869 | ||
870 | void KOEditorRecurrence::readEvent(Incidence *event) | 870 | void KOEditorRecurrence::readEvent(Incidence *event) |
871 | { | 871 | { |
872 | 872 | ||
873 | QDateTime dtEnd; | 873 | QDateTime dtEnd; |
874 | if ( event->type() == "Event" ) | 874 | if ( event->typeID() == eventID ) |
875 | dtEnd = ((Event*)event)->dtEnd(); | 875 | dtEnd = ((Event*)event)->dtEnd(); |
876 | else | 876 | else |
877 | dtEnd = ((Todo*)event)->dtDue(); | 877 | dtEnd = ((Todo*)event)->dtDue(); |
878 | 878 | ||
879 | setDefaults( event->dtStart(), dtEnd, true ); | 879 | setDefaults( event->dtStart(), dtEnd, true ); |
880 | QBitArray rDays( 7 ); | 880 | QBitArray rDays( 7 ); |
881 | QPtrList<Recurrence::rMonthPos> rmp; | 881 | QPtrList<Recurrence::rMonthPos> rmp; |
882 | QPtrList<int> rmd; | 882 | QPtrList<int> rmd; |
883 | int day = 0; | 883 | int day = 0; |
884 | int count = 0; | 884 | int count = 0; |
885 | int month = 0; | 885 | int month = 0; |
886 | setDateTimes( event->dtStart(), dtEnd ); | 886 | setDateTimes( event->dtStart(), dtEnd ); |
887 | 887 | ||
888 | Recurrence *r = event->recurrence(); | 888 | Recurrence *r = event->recurrence(); |
889 | int f = r->frequency(); | 889 | int f = r->frequency(); |
890 | 890 | ||
891 | int recurs = r->doesRecur(); | 891 | int recurs = r->doesRecur(); |
892 | 892 | ||
893 | mEnabledCheck->setChecked( recurs ); | 893 | mEnabledCheck->setChecked( recurs ); |
894 | setEnabled( recurs ); | 894 | setEnabled( recurs ); |
895 | 895 | ||
896 | int recurrenceType = RecurrenceChooser::Weekly; | 896 | int recurrenceType = RecurrenceChooser::Weekly; |
897 | 897 | ||
898 | switch ( recurs ) { | 898 | switch ( recurs ) { |
899 | case Recurrence::rNone: | 899 | case Recurrence::rNone: |
900 | setDefaults( event->dtStart(), dtEnd, true ); | 900 | setDefaults( event->dtStart(), dtEnd, true ); |
901 | break; | 901 | break; |
902 | case Recurrence::rDaily: | 902 | case Recurrence::rDaily: |
903 | recurrenceType = RecurrenceChooser::Daily; | 903 | recurrenceType = RecurrenceChooser::Daily; |
904 | mDaily->setFrequency( f ); | 904 | mDaily->setFrequency( f ); |
905 | break; | 905 | break; |
906 | case Recurrence::rWeekly: | 906 | case Recurrence::rWeekly: |
907 | recurrenceType = RecurrenceChooser::Weekly; | 907 | recurrenceType = RecurrenceChooser::Weekly; |
908 | mWeekly->setFrequency( f ); | 908 | mWeekly->setFrequency( f ); |
909 | mWeekly->setDays( r->days() ); | 909 | mWeekly->setDays( r->days() ); |
910 | break; | 910 | break; |
911 | case Recurrence::rMonthlyPos: | 911 | case Recurrence::rMonthlyPos: |
912 | // we only handle one possibility in the list right now, | 912 | // we only handle one possibility in the list right now, |
913 | // so I have hardcoded calls with first(). If we make the GUI | 913 | // so I have hardcoded calls with first(). If we make the GUI |
914 | // more extended, this can be changed. | 914 | // more extended, this can be changed. |
915 | recurrenceType = RecurrenceChooser::Monthly; | 915 | recurrenceType = RecurrenceChooser::Monthly; |
916 | 916 | ||
917 | rmp = r->monthPositions(); | 917 | rmp = r->monthPositions(); |
918 | if ( rmp.first()->negative ) | 918 | if ( rmp.first()->negative ) |
919 | count = 5 - rmp.first()->rPos - 1; | 919 | count = 5 - rmp.first()->rPos - 1; |
920 | else | 920 | else |
921 | count = rmp.first()->rPos - 1; | 921 | count = rmp.first()->rPos - 1; |
922 | day = 0; | 922 | day = 0; |
923 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; | 923 | while ( !rmp.first()->rDays.testBit( day ) ) ++day; |
924 | mMonthly->setByPos( count, day ); | 924 | mMonthly->setByPos( count, day ); |
925 | 925 | ||
926 | mMonthly->setFrequency( f ); | 926 | mMonthly->setFrequency( f ); |
927 | 927 | ||
928 | break; | 928 | break; |
929 | case Recurrence::rMonthlyDay: | 929 | case Recurrence::rMonthlyDay: |
930 | recurrenceType = RecurrenceChooser::Monthly; | 930 | recurrenceType = RecurrenceChooser::Monthly; |
931 | 931 | ||
932 | rmd = r->monthDays(); | 932 | rmd = r->monthDays(); |
933 | day = *rmd.first() - 1; | 933 | day = *rmd.first() - 1; |
934 | mMonthly->setByDay( day ); | 934 | mMonthly->setByDay( day ); |
935 | 935 | ||
936 | mMonthly->setFrequency( f ); | 936 | mMonthly->setFrequency( f ); |
937 | 937 | ||
938 | break; | 938 | break; |
939 | case Recurrence::rYearlyMonth: | 939 | case Recurrence::rYearlyMonth: |
940 | { | 940 | { |
941 | recurrenceType = RecurrenceChooser::Yearly; | 941 | recurrenceType = RecurrenceChooser::Yearly; |
942 | //qDebug("Recurrence::rYearlyMonth: "); | 942 | //qDebug("Recurrence::rYearlyMonth: "); |
943 | day = event->dtStart().date().day(); | 943 | day = event->dtStart().date().day(); |
944 | rmd = r->yearNums(); | 944 | rmd = r->yearNums(); |
945 | if ( rmd.count() > 0 ) | 945 | if ( rmd.count() > 0 ) |
946 | month = *rmd.first(); | 946 | month = *rmd.first(); |
947 | else | 947 | else |
948 | month = event->dtStart().date().month() ; | 948 | month = event->dtStart().date().month() ; |
949 | mYearly->setByMonth( month, day ); | 949 | mYearly->setByMonth( month, day ); |
950 | #if 0 | 950 | #if 0 |
951 | //qDebug("2day = %d ",day ); | 951 | //qDebug("2day = %d ",day ); |
952 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); | 952 | QPtrList<Recurrence::rMonthPos> monthlist = r->yearMonthPositions(); |
953 | int month; | 953 | int month; |
954 | if ( !monthlist.isEmpty() ) { | 954 | if ( !monthlist.isEmpty() ) { |
955 | month = monthlist.first()->rPos ; | 955 | month = monthlist.first()->rPos ; |
956 | } else { | 956 | } else { |
957 | month = event->dtStart().date().month() ; | 957 | month = event->dtStart().date().month() ; |
958 | } | 958 | } |
959 | mYearly->setByMonth( day, month ); | 959 | mYearly->setByMonth( day, month ); |
960 | #endif | 960 | #endif |
961 | mYearly->setFrequency( f ); | 961 | mYearly->setFrequency( f ); |
962 | } | 962 | } |
963 | 963 | ||
964 | break; | 964 | break; |
965 | case Recurrence::rYearlyDay: | 965 | case Recurrence::rYearlyDay: |
966 | //qDebug("Recurrence::rYearlyDay: "); | 966 | //qDebug("Recurrence::rYearlyDay: "); |
967 | recurrenceType = RecurrenceChooser::Yearly; | 967 | recurrenceType = RecurrenceChooser::Yearly; |
968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); | 968 | mYearly->setByDay( event->dtStart().date().dayOfYear() ); |
969 | mYearly->setFrequency( f ); | 969 | mYearly->setFrequency( f ); |
970 | break; | 970 | break; |
971 | default: | 971 | default: |
972 | setDefaults( event->dtStart(), dtEnd, true ); | 972 | setDefaults( event->dtStart(), dtEnd, true ); |
973 | break; | 973 | break; |
974 | } | 974 | } |
975 | 975 | ||
976 | mRecurrenceChooser->setType( recurrenceType ); | 976 | mRecurrenceChooser->setType( recurrenceType ); |
977 | showCurrentRule( recurrenceType ); | 977 | showCurrentRule( recurrenceType ); |
978 | 978 | ||
979 | mRecurrenceRange->setDateTimes( event->dtStart() ); | 979 | mRecurrenceRange->setDateTimes( event->dtStart() ); |
980 | 980 | ||
981 | if ( r->doesRecur() ) { | 981 | if ( r->doesRecur() ) { |
982 | mRecurrenceRange->setDuration( r->duration() ); | 982 | mRecurrenceRange->setDuration( r->duration() ); |
983 | if ( r->duration() == 0 ) | 983 | if ( r->duration() == 0 ) |
984 | { | 984 | { |
985 | if ( r->endDate() < event->dtStart().date() ) | 985 | if ( r->endDate() < event->dtStart().date() ) |
986 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 986 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
987 | else | 987 | else |
988 | mRecurrenceRange->setEndDate( r->endDate() ); | 988 | mRecurrenceRange->setEndDate( r->endDate() ); |
989 | } else | 989 | } else |
990 | mRecurrenceRange->setEndDate( event->dtStart().date() ); | 990 | mRecurrenceRange->setEndDate( event->dtStart().date() ); |
991 | } | 991 | } |
992 | 992 | ||
993 | mExceptions->setDates( event->exDates() ); | 993 | mExceptions->setDates( event->exDates() ); |
994 | } | 994 | } |
995 | 995 | ||
996 | void KOEditorRecurrence::writeEvent( Incidence *event ) | 996 | void KOEditorRecurrence::writeEvent( Incidence *event ) |
997 | { | 997 | { |
998 | Recurrence *r = event->recurrence(); | 998 | Recurrence *r = event->recurrence(); |
999 | 999 | ||
1000 | // clear out any old settings; | 1000 | // clear out any old settings; |
1001 | r->unsetRecurs(); | 1001 | r->unsetRecurs(); |
1002 | 1002 | ||
1003 | if ( mEnabledCheck->isChecked() ) { | 1003 | if ( mEnabledCheck->isChecked() ) { |
1004 | int duration = mRecurrenceRange->duration(); | 1004 | int duration = mRecurrenceRange->duration(); |
1005 | QDate endDate; | 1005 | QDate endDate; |
1006 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); | 1006 | if ( duration == 0 ) endDate = mRecurrenceRange->endDate(); |
1007 | 1007 | ||
1008 | int recurrenceType = mRecurrenceChooser->type(); | 1008 | int recurrenceType = mRecurrenceChooser->type(); |
1009 | 1009 | ||
1010 | if ( recurrenceType == RecurrenceChooser::Daily ) { | 1010 | if ( recurrenceType == RecurrenceChooser::Daily ) { |
1011 | int freq = mDaily->frequency(); | 1011 | int freq = mDaily->frequency(); |
1012 | if ( duration != 0 ) r->setDaily( freq, duration ); | 1012 | if ( duration != 0 ) r->setDaily( freq, duration ); |
1013 | else r->setDaily( freq, endDate ); | 1013 | else r->setDaily( freq, endDate ); |
1014 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { | 1014 | } else if ( recurrenceType == RecurrenceChooser::Weekly ) { |
1015 | int freq = mWeekly->frequency(); | 1015 | int freq = mWeekly->frequency(); |
1016 | QBitArray days = mWeekly->days(); | 1016 | QBitArray days = mWeekly->days(); |
1017 | int j; | 1017 | int j; |
1018 | bool found = false; | 1018 | bool found = false; |
1019 | for (j = 0; j < 7 ; ++j ) { | 1019 | for (j = 0; j < 7 ; ++j ) { |
1020 | found |=days.at(j); | 1020 | found |=days.at(j); |
1021 | } | 1021 | } |
1022 | if ( !found ) { | 1022 | if ( !found ) { |
1023 | days.setBit( event->dtStart().date().dayOfWeek()-1); | 1023 | days.setBit( event->dtStart().date().dayOfWeek()-1); |
1024 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); | 1024 | //qDebug("bit set %d ", event->dtStart().date().dayOfWeek()-1); |
1025 | } | 1025 | } |
1026 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); | 1026 | if ( duration != 0 ) r->setWeekly( freq, days, duration ); |
1027 | else r->setWeekly( freq, days, endDate ); | 1027 | else r->setWeekly( freq, days, endDate ); |
1028 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { | 1028 | } else if ( recurrenceType == RecurrenceChooser::Monthly ) { |
1029 | int freq = mMonthly->frequency(); | 1029 | int freq = mMonthly->frequency(); |
1030 | if ( mMonthly->byPos() ) { | 1030 | if ( mMonthly->byPos() ) { |
1031 | int pos = mMonthly->count(); | 1031 | int pos = mMonthly->count(); |
1032 | 1032 | ||
1033 | QBitArray days( 7 ); | 1033 | QBitArray days( 7 ); |
1034 | days.fill( false ); | 1034 | days.fill( false ); |
1035 | 1035 | ||
1036 | days.setBit( mMonthly->weekday() ); | 1036 | days.setBit( mMonthly->weekday() ); |
1037 | if ( duration != 0 ) | 1037 | if ( duration != 0 ) |
1038 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); | 1038 | r->setMonthly( Recurrence::rMonthlyPos, freq, duration ); |
1039 | else | 1039 | else |
1040 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 1040 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
1041 | r->addMonthlyPos( pos, days ); | 1041 | r->addMonthlyPos( pos, days ); |
1042 | } else { | 1042 | } else { |
1043 | // it's by day | 1043 | // it's by day |
1044 | int day = mMonthly->day(); | 1044 | int day = mMonthly->day(); |
1045 | 1045 | ||
1046 | if ( duration != 0 ) { | 1046 | if ( duration != 0 ) { |
1047 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); | 1047 | r->setMonthly( Recurrence::rMonthlyDay, freq, duration ); |
1048 | } else { | 1048 | } else { |
1049 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 1049 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
1050 | } | 1050 | } |
1051 | r->addMonthlyDay( day ); | 1051 | r->addMonthlyDay( day ); |
1052 | } | 1052 | } |
1053 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { | 1053 | } else if ( recurrenceType == RecurrenceChooser::Yearly ) { |
1054 | //qDebug("RecurrenceChooser::Yearly "); | 1054 | //qDebug("RecurrenceChooser::Yearly "); |
1055 | int freq = mYearly->frequency(); | 1055 | int freq = mYearly->frequency(); |
1056 | if ( mYearly->byDay() ) { | 1056 | if ( mYearly->byDay() ) { |
1057 | if ( duration != 0 ) { | 1057 | if ( duration != 0 ) { |
1058 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); | 1058 | r->setYearly( Recurrence::rYearlyDay, freq, duration ); |
1059 | } else { | 1059 | } else { |
1060 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); | 1060 | r->setYearly( Recurrence::rYearlyDay, freq, endDate ); |
1061 | } | 1061 | } |
1062 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); | 1062 | r->addYearlyNum( event->dtStart().date().dayOfYear() ); |
1063 | } else { | 1063 | } else { |
1064 | if ( duration != 0 ) { | 1064 | if ( duration != 0 ) { |
1065 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); | 1065 | r->setYearly( Recurrence::rYearlyMonth, freq, duration ); |
1066 | } else { | 1066 | } else { |
1067 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 1067 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
1068 | } | 1068 | } |
1069 | r->addYearlyNum( mYearly->month() ); | 1069 | r->addYearlyNum( mYearly->month() ); |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | } | 1072 | } |
1073 | 1073 | ||
1074 | event->setExDates( mExceptions->dates() ); | 1074 | event->setExDates( mExceptions->dates() ); |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) | 1078 | void KOEditorRecurrence::setDateTimeStr( const QString &str ) |
1079 | { | 1079 | { |
1080 | mDateTimeLabel->setText( str ); | 1080 | mDateTimeLabel->setText( str ); |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | bool KOEditorRecurrence::validateInput() | 1083 | bool KOEditorRecurrence::validateInput() |
1084 | { | 1084 | { |
1085 | // Check input here | 1085 | // Check input here |
1086 | 1086 | ||
1087 | return true; | 1087 | return true; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | void KOEditorRecurrence::showExceptionsDialog() | 1090 | void KOEditorRecurrence::showExceptionsDialog() |
1091 | { | 1091 | { |
1092 | DateList dates = mExceptions->dates(); | 1092 | DateList dates = mExceptions->dates(); |
1093 | int result = mExceptionsDialog->exec(); | 1093 | int result = mExceptionsDialog->exec(); |
1094 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); | 1094 | if ( result == QDialog::Rejected ) mExceptions->setDates( dates ); |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | void KOEditorRecurrence::showRecurrenceRangeDialog() | 1097 | void KOEditorRecurrence::showRecurrenceRangeDialog() |
1098 | { | 1098 | { |
1099 | int duration = mRecurrenceRange->duration(); | 1099 | int duration = mRecurrenceRange->duration(); |
1100 | QDate endDate = mRecurrenceRange->endDate(); | 1100 | QDate endDate = mRecurrenceRange->endDate(); |
1101 | 1101 | ||
1102 | int result = mRecurrenceRangeDialog->exec(); | 1102 | int result = mRecurrenceRangeDialog->exec(); |
1103 | if ( result == QDialog::Rejected ) { | 1103 | if ( result == QDialog::Rejected ) { |
1104 | mRecurrenceRange->setDuration( duration ); | 1104 | mRecurrenceRange->setDuration( duration ); |
1105 | mRecurrenceRange->setEndDate( endDate ); | 1105 | mRecurrenceRange->setEndDate( endDate ); |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | } | 1108 | } |
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index e5ff8af..02f13c7 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp | |||
@@ -1,307 +1,307 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | 21 | ||
22 | #include <libkcal/event.h> | 22 | #include <libkcal/event.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | 25 | ||
26 | #include "koeventviewer.h" | 26 | #include "koeventviewer.h" |
27 | #include <kmessagebox.h> | 27 | #include <kmessagebox.h> |
28 | #include "koprefs.h" | 28 | #include "koprefs.h" |
29 | #include <libkcal/todo.h> | 29 | #include <libkcal/todo.h> |
30 | #include "qapp.h" | 30 | #include "qapp.h" |
31 | 31 | ||
32 | #include "koeventviewerdialog.h" | 32 | #include "koeventviewerdialog.h" |
33 | extern int globalFlagBlockAgenda; | 33 | extern int globalFlagBlockAgenda; |
34 | 34 | ||
35 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) | 35 | KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) |
36 | : KDialogBase(parent,name, | 36 | : KDialogBase(parent,name, |
37 | #ifndef DESKTOP_VERSION | 37 | #ifndef DESKTOP_VERSION |
38 | true , | 38 | true , |
39 | #else | 39 | #else |
40 | false, | 40 | false, |
41 | #endif | 41 | #endif |
42 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) | 42 | i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) |
43 | { | 43 | { |
44 | sendSignalViewerClosed = true; | 44 | sendSignalViewerClosed = true; |
45 | mEventViewer = new KOEventViewer(this); | 45 | mEventViewer = new KOEventViewer(this); |
46 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 46 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
47 | setMainWidget(mEventViewer); | 47 | setMainWidget(mEventViewer); |
48 | setButtonText(Ok, i18n("Edit") ); | 48 | setButtonText(Ok, i18n("Edit") ); |
49 | 49 | ||
50 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 50 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), |
51 | SLOT(editIncidence())); | 51 | SLOT(editIncidence())); |
52 | QObject::connect(this,SIGNAL(user1Clicked()), | 52 | QObject::connect(this,SIGNAL(user1Clicked()), |
53 | SLOT(showIncidence())); | 53 | SLOT(showIncidence())); |
54 | mIncidence = 0; | 54 | mIncidence = 0; |
55 | // TODO: Set a sensible size (based on the content?). | 55 | // TODO: Set a sensible size (based on the content?). |
56 | //showMaximized(); | 56 | //showMaximized(); |
57 | //qDebug("++++++++++++KOEventViewerDialog() "); | 57 | //qDebug("++++++++++++KOEventViewerDialog() "); |
58 | // if ( KOPrefs::instance()->mCompactDialogs ) { | 58 | // if ( KOPrefs::instance()->mCompactDialogs ) { |
59 | // setFixedSize( 240,284 ); | 59 | // setFixedSize( 240,284 ); |
60 | // move( 0, 15 ); | 60 | // move( 0, 15 ); |
61 | // } else { | 61 | // } else { |
62 | // setMinimumSize(300,200); | 62 | // setMinimumSize(300,200); |
63 | // resize(320,300); | 63 | // resize(320,300); |
64 | // } | 64 | // } |
65 | mSyncMode = false; | 65 | mSyncMode = false; |
66 | mSyncResult = 0; | 66 | mSyncResult = 0; |
67 | 67 | ||
68 | } | 68 | } |
69 | 69 | ||
70 | KOEventViewerDialog::~KOEventViewerDialog() | 70 | KOEventViewerDialog::~KOEventViewerDialog() |
71 | { | 71 | { |
72 | //qDebug("-------~KOEventViewerDialog() "); | 72 | //qDebug("-------~KOEventViewerDialog() "); |
73 | } | 73 | } |
74 | void KOEventViewerDialog::showMe() | 74 | void KOEventViewerDialog::showMe() |
75 | { | 75 | { |
76 | 76 | ||
77 | #ifdef DESKTOP_VERSION | 77 | #ifdef DESKTOP_VERSION |
78 | int x,y,w,h; | 78 | int x,y,w,h; |
79 | x = geometry().x(); | 79 | x = geometry().x(); |
80 | y = geometry().y(); | 80 | y = geometry().y(); |
81 | w = width(); | 81 | w = width(); |
82 | h = height(); | 82 | h = height(); |
83 | show(); | 83 | show(); |
84 | setGeometry(x,y,w,h); | 84 | setGeometry(x,y,w,h); |
85 | raise(); | 85 | raise(); |
86 | #else | 86 | #else |
87 | showMaximized(); | 87 | showMaximized(); |
88 | #endif | 88 | #endif |
89 | QTimer::singleShot( 1, this, SLOT ( setMyFocus() ) ); | 89 | QTimer::singleShot( 1, this, SLOT ( setMyFocus() ) ); |
90 | 90 | ||
91 | } | 91 | } |
92 | void KOEventViewerDialog::setMyFocus() | 92 | void KOEventViewerDialog::setMyFocus() |
93 | { | 93 | { |
94 | 94 | ||
95 | setActiveWindow(); | 95 | setActiveWindow(); |
96 | mEventViewer->setFocus(); | 96 | mEventViewer->setFocus(); |
97 | 97 | ||
98 | } | 98 | } |
99 | void KOEventViewerDialog::print() | 99 | void KOEventViewerDialog::print() |
100 | { | 100 | { |
101 | mEventViewer->printMe(); | 101 | mEventViewer->printMe(); |
102 | 102 | ||
103 | } | 103 | } |
104 | void KOEventViewerDialog::setSyncMode( bool b ) | 104 | void KOEventViewerDialog::setSyncMode( bool b ) |
105 | { | 105 | { |
106 | mSyncMode = b; | 106 | mSyncMode = b; |
107 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); | 107 | //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); |
108 | if ( mSyncMode ) { | 108 | if ( mSyncMode ) { |
109 | findButton( Close )->setText( i18n("Cancel Sync")); | 109 | findButton( Close )->setText( i18n("Cancel Sync")); |
110 | findButton( Ok )->setText( i18n("Remote")); | 110 | findButton( Ok )->setText( i18n("Remote")); |
111 | findButton( User1 )->setText( i18n("Local")); | 111 | findButton( User1 )->setText( i18n("Local")); |
112 | } else { | 112 | } else { |
113 | findButton( Close )->setText( i18n("Close")); | 113 | findButton( Close )->setText( i18n("Close")); |
114 | findButton( Ok )->setText( i18n("Edit")); | 114 | findButton( Ok )->setText( i18n("Edit")); |
115 | findButton( User1 )->setText( i18n("Agenda")); | 115 | findButton( User1 )->setText( i18n("Agenda")); |
116 | } | 116 | } |
117 | mEventViewer->setSyncMode( b ); | 117 | mEventViewer->setSyncMode( b ); |
118 | } | 118 | } |
119 | void KOEventViewerDialog::setColorMode( int m ) | 119 | void KOEventViewerDialog::setColorMode( int m ) |
120 | { | 120 | { |
121 | mEventViewer->setColorMode( m ); | 121 | mEventViewer->setColorMode( m ); |
122 | } | 122 | } |
123 | int KOEventViewerDialog::executeS( bool local ) | 123 | int KOEventViewerDialog::executeS( bool local ) |
124 | { | 124 | { |
125 | mSyncResult = 3; | 125 | mSyncResult = 3; |
126 | if ( local ) | 126 | if ( local ) |
127 | findButton( User1 )->setFocus(); | 127 | findButton( User1 )->setFocus(); |
128 | else | 128 | else |
129 | findButton( Ok )->setFocus(); | 129 | findButton( Ok )->setFocus(); |
130 | exec(); | 130 | exec(); |
131 | return mSyncResult; | 131 | return mSyncResult; |
132 | } | 132 | } |
133 | 133 | ||
134 | void KOEventViewerDialog::updateConfig() | 134 | void KOEventViewerDialog::updateConfig() |
135 | { | 135 | { |
136 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); | 136 | mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); |
137 | 137 | ||
138 | } | 138 | } |
139 | void KOEventViewerDialog::setEvent(Event *event) | 139 | void KOEventViewerDialog::setEvent(Event *event) |
140 | { | 140 | { |
141 | mEventViewer->setEvent(event); | 141 | mEventViewer->setEvent(event); |
142 | mIncidence = event; | 142 | mIncidence = event; |
143 | mEventViewer->setFocus(); | 143 | mEventViewer->setFocus(); |
144 | //findButton( Close )->setFocus(); | 144 | //findButton( Close )->setFocus(); |
145 | if ( !mSyncMode ) { | 145 | if ( !mSyncMode ) { |
146 | findButton( User1 )->setText( i18n("Agenda")); | 146 | findButton( User1 )->setText( i18n("Agenda")); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | void KOEventViewerDialog::setIncidence(Incidence *in ) | 149 | void KOEventViewerDialog::setIncidence(Incidence *in ) |
150 | { | 150 | { |
151 | if ( in->type() == "Event" ) | 151 | if ( in->typeID() == eventID ) |
152 | setEvent( (Event*) in ); | 152 | setEvent( (Event*) in ); |
153 | else if ( in->type() =="Todo" ) | 153 | else if ( in->typeID() == todoID ) |
154 | setTodo( (Todo*) in ); | 154 | setTodo( (Todo*) in ); |
155 | else if ( in->type() =="Journal" ) | 155 | else if ( in->typeID() == journalID ) |
156 | setJournal( (Journal*) in ); | 156 | setJournal( (Journal*) in ); |
157 | } | 157 | } |
158 | void KOEventViewerDialog::addIncidence(Incidence *in) | 158 | void KOEventViewerDialog::addIncidence(Incidence *in) |
159 | { | 159 | { |
160 | if ( in->type() == "Event" ) | 160 | if ( in->typeID() == eventID ) |
161 | addEvent( (Event*) in ); | 161 | addEvent( (Event*) in ); |
162 | else if ( in->type() =="Todo" ) | 162 | else if ( in->typeID() == todoID ) |
163 | mEventViewer->setTodo( (Todo*) in, false ); | 163 | mEventViewer->setTodo( (Todo*) in, false ); |
164 | else if ( in->type() =="Journal" ) | 164 | else if ( in->typeID() == journalID ) |
165 | mEventViewer->setJournal( (Journal*) in, false ); | 165 | mEventViewer->setJournal( (Journal*) in, false ); |
166 | if ( mSyncMode ) { | 166 | if ( mSyncMode ) { |
167 | findButton( User1 )->setFocus(); | 167 | findButton( User1 )->setFocus(); |
168 | setCaption(i18n("Conflict! Please choose entry")); | 168 | setCaption(i18n("Conflict! Please choose entry")); |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | void KOEventViewerDialog::addEvent(Event *event) | 172 | void KOEventViewerDialog::addEvent(Event *event) |
173 | { | 173 | { |
174 | mEventViewer->addEvent(event); | 174 | mEventViewer->addEvent(event); |
175 | mIncidence = event; | 175 | mIncidence = event; |
176 | mEventViewer->setFocus(); | 176 | mEventViewer->setFocus(); |
177 | //findButton( Close )->setFocus(); | 177 | //findButton( Close )->setFocus(); |
178 | if ( !mSyncMode ) { | 178 | if ( !mSyncMode ) { |
179 | findButton( User1 )->setText( i18n("Agenda")); | 179 | findButton( User1 )->setText( i18n("Agenda")); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | void KOEventViewerDialog::setTodo(Todo *event) | 183 | void KOEventViewerDialog::setTodo(Todo *event) |
184 | { | 184 | { |
185 | mEventViewer->setTodo(event); | 185 | mEventViewer->setTodo(event); |
186 | mIncidence = (Incidence*)event; | 186 | mIncidence = (Incidence*)event; |
187 | mEventViewer->setFocus(); | 187 | mEventViewer->setFocus(); |
188 | //findButton( Close )->setFocus(); | 188 | //findButton( Close )->setFocus(); |
189 | if ( !mSyncMode ) { | 189 | if ( !mSyncMode ) { |
190 | findButton( User1 )->setText( i18n("Set complete")); | 190 | findButton( User1 )->setText( i18n("Set complete")); |
191 | } | 191 | } |
192 | } | 192 | } |
193 | void KOEventViewerDialog::setJournal(Journal *j) | 193 | void KOEventViewerDialog::setJournal(Journal *j) |
194 | { | 194 | { |
195 | mEventViewer->setJournal(j); | 195 | mEventViewer->setJournal(j); |
196 | mIncidence = (Incidence*)j; | 196 | mIncidence = (Incidence*)j; |
197 | mEventViewer->setFocus(); | 197 | mEventViewer->setFocus(); |
198 | //findButton( Close )->setFocus(); | 198 | //findButton( Close )->setFocus(); |
199 | if ( !mSyncMode ) { | 199 | if ( !mSyncMode ) { |
200 | findButton( User1 )->setText( i18n("Agenda")); | 200 | findButton( User1 )->setText( i18n("Agenda")); |
201 | } | 201 | } |
202 | } | 202 | } |
203 | 203 | ||
204 | void KOEventViewerDialog::addText(QString text) | 204 | void KOEventViewerDialog::addText(QString text) |
205 | { | 205 | { |
206 | mEventViewer->addText(text); | 206 | mEventViewer->addText(text); |
207 | mEventViewer->setFocus(); | 207 | mEventViewer->setFocus(); |
208 | //findButton( Close )->setFocus(); | 208 | //findButton( Close )->setFocus(); |
209 | } | 209 | } |
210 | void KOEventViewerDialog::editIncidence() | 210 | void KOEventViewerDialog::editIncidence() |
211 | { | 211 | { |
212 | sendSignalViewerClosed = false; | 212 | sendSignalViewerClosed = false; |
213 | if ( mSyncMode ) { | 213 | if ( mSyncMode ) { |
214 | mSyncResult = 2; | 214 | mSyncResult = 2; |
215 | accept(); | 215 | accept(); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | if ( mIncidence ){ | 218 | if ( mIncidence ){ |
219 | close(); | 219 | close(); |
220 | emit editIncidence( mIncidence ); | 220 | emit editIncidence( mIncidence ); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | void KOEventViewerDialog::showIncidence() | 223 | void KOEventViewerDialog::showIncidence() |
224 | { | 224 | { |
225 | sendSignalViewerClosed = false; | 225 | sendSignalViewerClosed = false; |
226 | if ( mSyncMode ) { | 226 | if ( mSyncMode ) { |
227 | mSyncResult = 1; | 227 | mSyncResult = 1; |
228 | accept(); | 228 | accept(); |
229 | return; | 229 | return; |
230 | } | 230 | } |
231 | 231 | ||
232 | if ( mIncidence ){ | 232 | if ( mIncidence ){ |
233 | QDate date; | 233 | QDate date; |
234 | if ( mIncidence->type() == "Todo" ) { | 234 | if ( mIncidence->type() == "Todo" ) { |
235 | /* | 235 | /* |
236 | if ( ((Todo*)mIncidence)->hasDueDate() ) | 236 | if ( ((Todo*)mIncidence)->hasDueDate() ) |
237 | date = ((Todo*)mIncidence)->dtDue().date(); | 237 | date = ((Todo*)mIncidence)->dtDue().date(); |
238 | else { | 238 | else { |
239 | globalFlagBlockAgenda = 2; | 239 | globalFlagBlockAgenda = 2; |
240 | emit showAgendaView( false ); | 240 | emit showAgendaView( false ); |
241 | return; | 241 | return; |
242 | } | 242 | } |
243 | */ | 243 | */ |
244 | ((Todo*)mIncidence)->setCompleted( true ); | 244 | ((Todo*)mIncidence)->setCompleted( true ); |
245 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); | 245 | ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); |
246 | emit todoCompleted(((Todo*)mIncidence)); | 246 | emit todoCompleted(((Todo*)mIncidence)); |
247 | } else { | 247 | } else { |
248 | date = mIncidence->dtStart().date(); | 248 | date = mIncidence->dtStart().date(); |
249 | globalFlagBlockAgenda = 1; | 249 | globalFlagBlockAgenda = 1; |
250 | emit showAgendaView( false ); | 250 | emit showAgendaView( false ); |
251 | globalFlagBlockAgenda = 2; | 251 | globalFlagBlockAgenda = 2; |
252 | emit jumpToTime( date ); | 252 | emit jumpToTime( date ); |
253 | } | 253 | } |
254 | close(); | 254 | close(); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) | 257 | void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) |
258 | { | 258 | { |
259 | switch ( e->key() ) { | 259 | switch ( e->key() ) { |
260 | 260 | ||
261 | case Qt::Key_A : | 261 | case Qt::Key_A : |
262 | case Qt::Key_L : | 262 | case Qt::Key_L : |
263 | showIncidence(); | 263 | showIncidence(); |
264 | break; | 264 | break; |
265 | case Qt::Key_E : | 265 | case Qt::Key_E : |
266 | case Qt::Key_R : | 266 | case Qt::Key_R : |
267 | editIncidence(); | 267 | editIncidence(); |
268 | break; | 268 | break; |
269 | case Qt::Key_C: | 269 | case Qt::Key_C: |
270 | case Qt::Key_Escape: | 270 | case Qt::Key_Escape: |
271 | sendSignalViewerClosed = true; | 271 | sendSignalViewerClosed = true; |
272 | close(); | 272 | close(); |
273 | break; | 273 | break; |
274 | case Qt::Key_I: | 274 | case Qt::Key_I: |
275 | #ifndef DESKTOP_VERSION | 275 | #ifndef DESKTOP_VERSION |
276 | sendSignalViewerClosed = true; | 276 | sendSignalViewerClosed = true; |
277 | close(); | 277 | close(); |
278 | #else | 278 | #else |
279 | sendSignalViewerClosed = true; | 279 | sendSignalViewerClosed = true; |
280 | slotViewerClosed(); | 280 | slotViewerClosed(); |
281 | //accept(); | 281 | //accept(); |
282 | #endif | 282 | #endif |
283 | break; | 283 | break; |
284 | default: | 284 | default: |
285 | KDialogBase::keyPressEvent ( e ); | 285 | KDialogBase::keyPressEvent ( e ); |
286 | break; | 286 | break; |
287 | } | 287 | } |
288 | 288 | ||
289 | } | 289 | } |
290 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) | 290 | void KOEventViewerDialog::hideEvent ( QHideEvent * e ) |
291 | { | 291 | { |
292 | KDialogBase::hideEvent ( e ); | 292 | KDialogBase::hideEvent ( e ); |
293 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); | 293 | QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); |
294 | } | 294 | } |
295 | 295 | ||
296 | void KOEventViewerDialog::slotViewerClosed() | 296 | void KOEventViewerDialog::slotViewerClosed() |
297 | { | 297 | { |
298 | if ( mSyncMode ) | 298 | if ( mSyncMode ) |
299 | return; | 299 | return; |
300 | 300 | ||
301 | if ( sendSignalViewerClosed ) { | 301 | if ( sendSignalViewerClosed ) { |
302 | //qDebug("KOEventViewerDialog::hideEvent "); | 302 | //qDebug("KOEventViewerDialog::hideEvent "); |
303 | emit signalViewerClosed(); | 303 | emit signalViewerClosed(); |
304 | } | 304 | } |
305 | sendSignalViewerClosed = true; | 305 | sendSignalViewerClosed = true; |
306 | } | 306 | } |
307 | 307 | ||
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 678cab6..c868270 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,2096 +1,2096 @@ | |||
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 | resetOnFocusIn = true; | 86 | resetOnFocusIn = true; |
87 | setVScrollBarMode(QScrollView::AlwaysOff); | 87 | setVScrollBarMode(QScrollView::AlwaysOff); |
88 | setHScrollBarMode(QScrollView::AlwaysOff); | 88 | setHScrollBarMode(QScrollView::AlwaysOff); |
89 | } | 89 | } |
90 | KNoScrollListBox::~KNoScrollListBox() | 90 | KNoScrollListBox::~KNoScrollListBox() |
91 | { | 91 | { |
92 | #if QT_VERSION >= 0x030000 | 92 | #if QT_VERSION >= 0x030000 |
93 | 93 | ||
94 | #else | 94 | #else |
95 | delete mWT; | 95 | delete mWT; |
96 | #endif | 96 | #endif |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) | 100 | void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) |
101 | { | 101 | { |
102 | QListBox::focusInEvent ( e ); | 102 | QListBox::focusInEvent ( e ); |
103 | if ( count() ){ | 103 | if ( count() ){ |
104 | int ci = currentItem(); | 104 | int ci = currentItem(); |
105 | if ( ci < 0 ) ci = 0; | 105 | if ( ci < 0 ) ci = 0; |
106 | 106 | ||
107 | setCurrentItem( ci ); | 107 | setCurrentItem( ci ); |
108 | setSelected ( ci, true ); | 108 | setSelected ( ci, true ); |
109 | emit highlighted( item ( ci ) ); | 109 | emit highlighted( item ( ci ) ); |
110 | 110 | ||
111 | resetOnFocusIn = true; | 111 | resetOnFocusIn = true; |
112 | 112 | ||
113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { | 113 | if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { |
114 | QListBoxItem *fi = firstItem (); | 114 | QListBoxItem *fi = firstItem (); |
115 | if (fi ) { | 115 | if (fi ) { |
116 | int ihei = fi->height( this ); | 116 | int ihei = fi->height( this ); |
117 | int hei = numRows () * ihei; | 117 | int hei = numRows () * ihei; |
118 | if ( hei < height() - horizontalScrollBar()->height () ) { | 118 | if ( hei < height() - horizontalScrollBar()->height () ) { |
119 | setVScrollBarMode(QScrollView::AlwaysOff); | 119 | setVScrollBarMode(QScrollView::AlwaysOff); |
120 | } | 120 | } |
121 | else | 121 | else |
122 | setVScrollBarMode(QScrollView::Auto); | 122 | setVScrollBarMode(QScrollView::Auto); |
123 | if ( ihei *3 > height() ) { | 123 | if ( ihei *3 > height() ) { |
124 | setHScrollBarMode(QScrollView::AlwaysOff); | 124 | setHScrollBarMode(QScrollView::AlwaysOff); |
125 | } | 125 | } |
126 | else { | 126 | else { |
127 | setHScrollBarMode(QScrollView::Auto); | 127 | setHScrollBarMode(QScrollView::Auto); |
128 | } | 128 | } |
129 | } else { | 129 | } else { |
130 | setVScrollBarMode(QScrollView::Auto); | 130 | setVScrollBarMode(QScrollView::Auto); |
131 | setHScrollBarMode(QScrollView::Auto); | 131 | setHScrollBarMode(QScrollView::Auto); |
132 | } | 132 | } |
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) | 136 | void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) |
137 | { | 137 | { |
138 | int i = currentItem (); | 138 | int i = currentItem (); |
139 | if ( i >= 0 ) { | 139 | if ( i >= 0 ) { |
140 | setSelected ( i, false ); | 140 | setSelected ( i, false ); |
141 | } | 141 | } |
142 | QListBox::focusOutEvent ( e ); | 142 | QListBox::focusOutEvent ( e ); |
143 | setVScrollBarMode(QScrollView::AlwaysOff); | 143 | setVScrollBarMode(QScrollView::AlwaysOff); |
144 | setHScrollBarMode(QScrollView::AlwaysOff); | 144 | setHScrollBarMode(QScrollView::AlwaysOff); |
145 | } | 145 | } |
146 | 146 | ||
147 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 147 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
148 | { | 148 | { |
149 | QListBoxItem* item = itemAt ( p ); | 149 | QListBoxItem* item = itemAt ( p ); |
150 | if ( ! item ) { | 150 | if ( ! item ) { |
151 | return i18n("Click in the cell\nto add an event!"); | 151 | return i18n("Click in the cell\nto add an event!"); |
152 | } | 152 | } |
153 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), | 153 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), |
154 | KOPrefs::instance()->mWTshowDetails, | 154 | KOPrefs::instance()->mWTshowDetails, |
155 | KOPrefs::instance()->mWTshowCreated, | 155 | KOPrefs::instance()->mWTshowCreated, |
156 | KOPrefs::instance()->mWTshowChanged); | 156 | KOPrefs::instance()->mWTshowChanged); |
157 | } | 157 | } |
158 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 158 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
159 | { | 159 | { |
160 | //qDebug("KNoScrollListBox::keyPressEvent "); | 160 | //qDebug("KNoScrollListBox::keyPressEvent "); |
161 | switch(e->key()) { | 161 | switch(e->key()) { |
162 | case Key_Right: | 162 | case Key_Right: |
163 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 163 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
164 | { | 164 | { |
165 | e->ignore(); | 165 | e->ignore(); |
166 | return; | 166 | return; |
167 | } | 167 | } |
168 | scrollBy(10,0); | 168 | scrollBy(10,0); |
169 | break; | 169 | break; |
170 | case Key_Left: | 170 | case Key_Left: |
171 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 171 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
172 | { | 172 | { |
173 | e->ignore(); | 173 | e->ignore(); |
174 | return; | 174 | return; |
175 | } | 175 | } |
176 | scrollBy(-10,0); | 176 | scrollBy(-10,0); |
177 | break; | 177 | break; |
178 | case Key_Up: | 178 | case Key_Up: |
179 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 179 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
180 | e->ignore(); | 180 | e->ignore(); |
181 | break; | 181 | break; |
182 | } | 182 | } |
183 | if ( count() ) { | 183 | if ( count() ) { |
184 | if ( currentItem() == 0 ) { | 184 | if ( currentItem() == 0 ) { |
185 | emit prevCell(); | 185 | emit prevCell(); |
186 | } else { | 186 | } else { |
187 | setCurrentItem((currentItem()+count()-1)%count()); | 187 | setCurrentItem((currentItem()+count()-1)%count()); |
188 | if(!itemVisible(currentItem())) { | 188 | if(!itemVisible(currentItem())) { |
189 | if((unsigned int) currentItem() == (count()-1)) { | 189 | if((unsigned int) currentItem() == (count()-1)) { |
190 | setTopItem(currentItem()-numItemsVisible()+1); | 190 | setTopItem(currentItem()-numItemsVisible()+1); |
191 | } else { | 191 | } else { |
192 | setTopItem(topItem()-1); | 192 | setTopItem(topItem()-1); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | } | 196 | } |
197 | break; | 197 | break; |
198 | case Key_Down: | 198 | case Key_Down: |
199 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 199 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
200 | e->ignore(); | 200 | e->ignore(); |
201 | break; | 201 | break; |
202 | } | 202 | } |
203 | if ( count () ) { | 203 | if ( count () ) { |
204 | if ( currentItem()+1 == count () ) { | 204 | if ( currentItem()+1 == count () ) { |
205 | emit nextCell(); | 205 | emit nextCell(); |
206 | } else { | 206 | } else { |
207 | setCurrentItem((currentItem()+1)%count()); | 207 | setCurrentItem((currentItem()+1)%count()); |
208 | if(!itemVisible(currentItem())) { | 208 | if(!itemVisible(currentItem())) { |
209 | if(currentItem() == 0) { | 209 | if(currentItem() == 0) { |
210 | setTopItem(0); | 210 | setTopItem(0); |
211 | } else { | 211 | } else { |
212 | setTopItem(topItem()+1); | 212 | setTopItem(topItem()+1); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | } | 216 | } |
217 | break; | 217 | break; |
218 | case Key_I: | 218 | case Key_I: |
219 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); | 219 | QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); |
220 | e->ignore(); | 220 | e->ignore(); |
221 | break; | 221 | break; |
222 | case Key_Return: | 222 | case Key_Return: |
223 | case Key_Enter: | 223 | case Key_Enter: |
224 | { | 224 | { |
225 | if ( currentItem() >= 0 ) { | 225 | if ( currentItem() >= 0 ) { |
226 | emit doubleClicked( item( currentItem() ) ); | 226 | emit doubleClicked( item( currentItem() ) ); |
227 | e->accept(); | 227 | e->accept(); |
228 | } else { | 228 | } else { |
229 | e->ignore(); | 229 | e->ignore(); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | break; | 232 | break; |
233 | case Key_Shift: | 233 | case Key_Shift: |
234 | emit shiftDown(); | 234 | emit shiftDown(); |
235 | break; | 235 | break; |
236 | default: | 236 | default: |
237 | e->ignore(); | 237 | e->ignore(); |
238 | break; | 238 | break; |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void KNoScrollListBox::oneDown() | 242 | void KNoScrollListBox::oneDown() |
243 | { | 243 | { |
244 | if ( count () ) { | 244 | if ( count () ) { |
245 | if ( currentItem()+1 == count () ) { | 245 | if ( currentItem()+1 == count () ) { |
246 | emit nextCell(); | 246 | emit nextCell(); |
247 | } else { | 247 | } else { |
248 | resetOnFocusIn = false; | 248 | resetOnFocusIn = false; |
249 | setCurrentItem((currentItem()+1)%count()); | 249 | setCurrentItem((currentItem()+1)%count()); |
250 | if(!itemVisible(currentItem())) { | 250 | if(!itemVisible(currentItem())) { |
251 | if(currentItem() == 0) { | 251 | if(currentItem() == 0) { |
252 | setTopItem(0); | 252 | setTopItem(0); |
253 | } else { | 253 | } else { |
254 | setTopItem(topItem()+1); | 254 | setTopItem(topItem()+1); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | } | 259 | } |
260 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 260 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
261 | { | 261 | { |
262 | switch(e->key()) { | 262 | switch(e->key()) { |
263 | case Key_Shift: | 263 | case Key_Shift: |
264 | emit shiftUp(); | 264 | emit shiftUp(); |
265 | break; | 265 | break; |
266 | default: | 266 | default: |
267 | break; | 267 | break; |
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 271 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
272 | { | 272 | { |
273 | QListBox::mousePressEvent(e); | 273 | QListBox::mousePressEvent(e); |
274 | 274 | ||
275 | if(e->button() == RightButton) { | 275 | if(e->button() == RightButton) { |
276 | emit rightClick(); | 276 | emit rightClick(); |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 280 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
281 | : QListBoxItem() | 281 | : QListBoxItem() |
282 | { | 282 | { |
283 | mblockRepaint = true; | 283 | mblockRepaint = true; |
284 | setText( s ); | 284 | setText( s ); |
285 | mMultiday = 0; | 285 | mMultiday = 0; |
286 | mIncidence = incidence; | 286 | mIncidence = incidence; |
287 | mDate = qd; | 287 | mDate = qd; |
288 | mRecur = false; | 288 | mRecur = false; |
289 | mAlarm = false; | 289 | mAlarm = false; |
290 | mReply = false; | 290 | mReply = false; |
291 | mInfo = false; | 291 | mInfo = false; |
292 | mdayPos = 0; | 292 | mdayPos = 0; |
293 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 293 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
294 | } | 294 | } |
295 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 295 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) |
296 | { | 296 | { |
297 | setText( s ); | 297 | setText( s ); |
298 | mMultiday = 0; | 298 | mMultiday = 0; |
299 | mIncidence = incidence; | 299 | mIncidence = incidence; |
300 | mDate = qd; | 300 | mDate = qd; |
301 | mRecur = false; | 301 | mRecur = false; |
302 | mAlarm = false; | 302 | mAlarm = false; |
303 | mReply = false; | 303 | mReply = false; |
304 | mInfo = false; | 304 | mInfo = false; |
305 | mdayPos = 0; | 305 | mdayPos = 0; |
306 | } | 306 | } |
307 | 307 | ||
308 | void MonthViewItem::paint(QPainter *p) | 308 | void MonthViewItem::paint(QPainter *p) |
309 | { | 309 | { |
310 | if ( mblockRepaint ) { | 310 | if ( mblockRepaint ) { |
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | #if QT_VERSION >= 0x030000 | 313 | #if QT_VERSION >= 0x030000 |
314 | bool sel = isSelected(); | 314 | bool sel = isSelected(); |
315 | #else | 315 | #else |
316 | bool sel = selected(); | 316 | bool sel = selected(); |
317 | #endif | 317 | #endif |
318 | 318 | ||
319 | 319 | ||
320 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 320 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
321 | { | 321 | { |
322 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 322 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
323 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 323 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
324 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 324 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
325 | } | 325 | } |
326 | int x = 1; | 326 | int x = 1; |
327 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 327 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
328 | int size = PIXMAP_SIZE; | 328 | int size = PIXMAP_SIZE; |
329 | if ( QApplication::desktop()->width() < 300 ) | 329 | if ( QApplication::desktop()->width() < 300 ) |
330 | size = 3; | 330 | size = 3; |
331 | int heihei = height( listBox () ); | 331 | int heihei = height( listBox () ); |
332 | int y = (heihei - size -1 ) /2; | 332 | int y = (heihei - size -1 ) /2; |
333 | 333 | ||
334 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 334 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
335 | if ( mInfo ) { | 335 | if ( mInfo ) { |
336 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 336 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
337 | x += size + 1; | 337 | x += size + 1; |
338 | } | 338 | } |
339 | if ( mRecur ) { | 339 | if ( mRecur ) { |
340 | p->fillRect ( x, y,size,size, Qt::blue ); | 340 | p->fillRect ( x, y,size,size, Qt::blue ); |
341 | x += size + 1; | 341 | x += size + 1; |
342 | } | 342 | } |
343 | if ( mAlarm ) { | 343 | if ( mAlarm ) { |
344 | p->fillRect ( x, y,size,size, Qt::red ); | 344 | p->fillRect ( x, y,size,size, Qt::red ); |
345 | x += size + 1; | 345 | x += size + 1; |
346 | } | 346 | } |
347 | if ( mReply ) { | 347 | if ( mReply ) { |
348 | p->fillRect ( x, y,size,size, Qt::yellow ); | 348 | p->fillRect ( x, y,size,size, Qt::yellow ); |
349 | x += size + 1; | 349 | x += size + 1; |
350 | } | 350 | } |
351 | } | 351 | } |
352 | if ( mMultiday ) { | 352 | if ( mMultiday ) { |
353 | int yyy = y+(size/2); | 353 | int yyy = y+(size/2); |
354 | int sizeM = size+2; | 354 | int sizeM = size+2; |
355 | p->setBrush( QBrush::SolidPattern ); | 355 | p->setBrush( QBrush::SolidPattern ); |
356 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 356 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
357 | if ( mMultiday == 2 || mMultiday == 3 ) { | 357 | if ( mMultiday == 2 || mMultiday == 3 ) { |
358 | QPointArray pa ( 3 ); | 358 | QPointArray pa ( 3 ); |
359 | pa.setPoint (0, x, yyy ); | 359 | pa.setPoint (0, x, yyy ); |
360 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 360 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
361 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 361 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
362 | p->drawPolygon( pa ); | 362 | p->drawPolygon( pa ); |
363 | } | 363 | } |
364 | if ( mMultiday == 2 || mMultiday == 1 ) { | 364 | if ( mMultiday == 2 || mMultiday == 1 ) { |
365 | QPointArray pa ( 3 ); | 365 | QPointArray pa ( 3 ); |
366 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 366 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
367 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 367 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
368 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 368 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
369 | p->drawPolygon( pa ); | 369 | p->drawPolygon( pa ); |
370 | } | 370 | } |
371 | if ( mMultiday == 1 ) { | 371 | if ( mMultiday == 1 ) { |
372 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 372 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
373 | 373 | ||
374 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 374 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
375 | } | 375 | } |
376 | if ( mMultiday == 3 ) { | 376 | if ( mMultiday == 3 ) { |
377 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 377 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
378 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 378 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
379 | 379 | ||
380 | } | 380 | } |
381 | x += sizeM/2 + 1; | 381 | x += sizeM/2 + 1; |
382 | x += sizeM + 1; | 382 | x += sizeM + 1; |
383 | } | 383 | } |
384 | 384 | ||
385 | if ( mIncidence->type() == "Todo" ){ | 385 | if ( mIncidence->typeID() == todoID ){ |
386 | Todo* td = ( Todo* ) mIncidence; | 386 | Todo* td = ( Todo* ) mIncidence; |
387 | if ( td->isCompleted() ) { | 387 | if ( td->isCompleted() ) { |
388 | int half = size/2; | 388 | int half = size/2; |
389 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 389 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
390 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 390 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
391 | x += half+half + 4; | 391 | x += half+half + 4; |
392 | 392 | ||
393 | } else { | 393 | } else { |
394 | int val = td->percentComplete()/20; | 394 | int val = td->percentComplete()/20; |
395 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); | 395 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); |
396 | p->drawRect ( x, y-2,7,size+4); | 396 | p->drawRect ( x, y-2,7,size+4); |
397 | x += size + 3; | 397 | x += size + 3; |
398 | } | 398 | } |
399 | } | 399 | } |
400 | QFontMetrics fm = p->fontMetrics(); | 400 | QFontMetrics fm = p->fontMetrics(); |
401 | int yPos; | 401 | int yPos; |
402 | int pmheight = size; | 402 | int pmheight = size; |
403 | if( pmheight < fm.height() ) | 403 | if( pmheight < fm.height() ) |
404 | yPos = fm.ascent() + fm.leading()/2; | 404 | yPos = fm.ascent() + fm.leading()/2; |
405 | else | 405 | else |
406 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 406 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
407 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 407 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
408 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 408 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
409 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 409 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
410 | p->drawText( x, yPos, text() ); | 410 | p->drawText( x, yPos, text() ); |
411 | if ( mIncidence->cancelled() ) { | 411 | if ( mIncidence->cancelled() ) { |
412 | int wid = fm.width( text() ); | 412 | int wid = fm.width( text() ); |
413 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 413 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
414 | } | 414 | } |
415 | } else { | 415 | } else { |
416 | QString pText = text(); | 416 | QString pText = text(); |
417 | if( pText.mid(2,1) == ":" ) | 417 | if( pText.mid(2,1) == ":" ) |
418 | pText = pText.mid( 6 ); | 418 | pText = pText.mid( 6 ); |
419 | p->drawText( x, yPos, pText ); | 419 | p->drawText( x, yPos, pText ); |
420 | if ( mIncidence->cancelled() ) { | 420 | if ( mIncidence->cancelled() ) { |
421 | int wid = fm.width( pText ); | 421 | int wid = fm.width( pText ); |
422 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 422 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
423 | } | 423 | } |
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | int MonthViewItem::height(const QListBox *lb) const | 427 | int MonthViewItem::height(const QListBox *lb) const |
428 | { | 428 | { |
429 | int ret = 10; | 429 | int ret = 10; |
430 | if ( lb ) | 430 | if ( lb ) |
431 | ret = lb->fontMetrics().lineSpacing()+1; | 431 | ret = lb->fontMetrics().lineSpacing()+1; |
432 | return ret; | 432 | return ret; |
433 | } | 433 | } |
434 | 434 | ||
435 | int MonthViewItem::width(const QListBox *lb) const | 435 | int MonthViewItem::width(const QListBox *lb) const |
436 | { | 436 | { |
437 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 437 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
438 | int size = PIXMAP_SIZE; | 438 | int size = PIXMAP_SIZE; |
439 | if ( QApplication::desktop()->width() < 300 ) | 439 | if ( QApplication::desktop()->width() < 300 ) |
440 | size = 3; | 440 | size = 3; |
441 | int x = 1; | 441 | int x = 1; |
442 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 442 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
443 | if ( mInfo ) { | 443 | if ( mInfo ) { |
444 | x += size + 1; | 444 | x += size + 1; |
445 | } | 445 | } |
446 | if( mRecur ) { | 446 | if( mRecur ) { |
447 | x += size+1; | 447 | x += size+1; |
448 | } | 448 | } |
449 | if( mAlarm ) { | 449 | if( mAlarm ) { |
450 | x += size+1; | 450 | x += size+1; |
451 | } | 451 | } |
452 | if( mReply ) { | 452 | if( mReply ) { |
453 | x += size+1; | 453 | x += size+1; |
454 | } | 454 | } |
455 | } | 455 | } |
456 | if( mMultiday ) { | 456 | if( mMultiday ) { |
457 | x += size+1+2+size/2; | 457 | x += size+1+2+size/2; |
458 | } | 458 | } |
459 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 459 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
460 | } | 460 | } |
461 | if ( ! lb ) | 461 | if ( ! lb ) |
462 | return 10; | 462 | return 10; |
463 | return lb->width(); | 463 | return lb->width(); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 467 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
468 | : KNoScrollListBox( par ), | 468 | : KNoScrollListBox( par ), |
469 | mMonthView( parent ) | 469 | mMonthView( parent ) |
470 | { | 470 | { |
471 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 471 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
472 | currentPalette = 0; | 472 | currentPalette = 0; |
473 | // mLabel = new QLabel( this );QPushButton | 473 | // mLabel = new QLabel( this );QPushButton |
474 | mLabel = new QPushButton( this ); | 474 | mLabel = new QPushButton( this ); |
475 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 475 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
476 | //mLabel->setLineWidth( 1 ); | 476 | //mLabel->setLineWidth( 1 ); |
477 | //mLabel->setAlignment( AlignCenter ); | 477 | //mLabel->setAlignment( AlignCenter ); |
478 | mLabel->setFlat( true ); | 478 | mLabel->setFlat( true ); |
479 | mLabel->setFocusPolicy(NoFocus); | 479 | mLabel->setFocusPolicy(NoFocus); |
480 | //mItemList = new KNoScrollListBox( this ); | 480 | //mItemList = new KNoScrollListBox( this ); |
481 | setMinimumSize( 10, 10 ); | 481 | setMinimumSize( 10, 10 ); |
482 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 482 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
483 | setLineWidth( 1 ); | 483 | setLineWidth( 1 ); |
484 | //topLayout->addWidget( mItemList ); | 484 | //topLayout->addWidget( mItemList ); |
485 | mLabel->raise(); | 485 | mLabel->raise(); |
486 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 486 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
487 | mStandardPalette = palette(); | 487 | mStandardPalette = palette(); |
488 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 488 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
489 | 489 | ||
490 | enableScrollBars( false ); | 490 | enableScrollBars( false ); |
491 | updateConfig(); | 491 | updateConfig(); |
492 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 492 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
493 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 493 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
494 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 494 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
495 | SLOT( defaultAction( QListBoxItem * ) ) ); | 495 | SLOT( defaultAction( QListBoxItem * ) ) ); |
496 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 496 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
497 | const QPoint &) ), | 497 | const QPoint &) ), |
498 | SLOT( contextMenu( QListBoxItem * ) ) ); | 498 | SLOT( contextMenu( QListBoxItem * ) ) ); |
499 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 499 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
500 | SLOT( selection( QListBoxItem * ) ) ); | 500 | SLOT( selection( QListBoxItem * ) ) ); |
501 | 501 | ||
502 | /* | 502 | /* |
503 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 503 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
504 | SLOT( selection( QListBoxItem * ) ) ); | 504 | SLOT( selection( QListBoxItem * ) ) ); |
505 | */ | 505 | */ |
506 | } | 506 | } |
507 | #ifdef DESKTOP_VERSION | 507 | #ifdef DESKTOP_VERSION |
508 | QToolTipGroup *MonthViewCell::toolTipGroup() | 508 | QToolTipGroup *MonthViewCell::toolTipGroup() |
509 | { | 509 | { |
510 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 510 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
511 | return mToolTipGroup; | 511 | return mToolTipGroup; |
512 | } | 512 | } |
513 | #endif | 513 | #endif |
514 | 514 | ||
515 | void MonthViewCell::setDate( const QDate &date ) | 515 | void MonthViewCell::setDate( const QDate &date ) |
516 | { | 516 | { |
517 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 517 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
518 | mDate = date; | 518 | mDate = date; |
519 | 519 | ||
520 | 520 | ||
521 | 521 | ||
522 | //resizeEvent( 0 ); | 522 | //resizeEvent( 0 ); |
523 | } | 523 | } |
524 | 524 | ||
525 | QDate MonthViewCell::date() const | 525 | QDate MonthViewCell::date() const |
526 | { | 526 | { |
527 | return mDate; | 527 | return mDate; |
528 | } | 528 | } |
529 | 529 | ||
530 | void MonthViewCell::setPrimary( bool primary ) | 530 | void MonthViewCell::setPrimary( bool primary ) |
531 | { | 531 | { |
532 | mPrimary = primary; | 532 | mPrimary = primary; |
533 | //setMyPalette(); | 533 | //setMyPalette(); |
534 | } | 534 | } |
535 | void MonthViewCell::setMyPalette() | 535 | void MonthViewCell::setMyPalette() |
536 | { | 536 | { |
537 | 537 | ||
538 | if ( mHoliday) { | 538 | if ( mHoliday) { |
539 | if ( currentPalette == 1 ) return; | 539 | if ( currentPalette == 1 ) return; |
540 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 540 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
541 | setPalette( mHolidayPalette ); | 541 | setPalette( mHolidayPalette ); |
542 | //mLabel->setPalette( mHolidayPalette ); | 542 | //mLabel->setPalette( mHolidayPalette ); |
543 | currentPalette = 1; | 543 | currentPalette = 1; |
544 | 544 | ||
545 | } else { | 545 | } else { |
546 | if ( mPrimary ) { | 546 | if ( mPrimary ) { |
547 | if ( currentPalette == 2 ) return; | 547 | if ( currentPalette == 2 ) return; |
548 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 548 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
549 | //mLabel->setPalette( mPrimaryPalette ); | 549 | //mLabel->setPalette( mPrimaryPalette ); |
550 | setPalette( mPrimaryPalette ); | 550 | setPalette( mPrimaryPalette ); |
551 | currentPalette = 2; | 551 | currentPalette = 2; |
552 | 552 | ||
553 | } else { | 553 | } else { |
554 | if ( currentPalette == 3 ) return; | 554 | if ( currentPalette == 3 ) return; |
555 | setPalette( mNonPrimaryPalette ); | 555 | setPalette( mNonPrimaryPalette ); |
556 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 556 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
557 | //mLabel->setPalette( mNonPrimaryPalette );; | 557 | //mLabel->setPalette( mNonPrimaryPalette );; |
558 | currentPalette = 3; | 558 | currentPalette = 3; |
559 | } | 559 | } |
560 | } | 560 | } |
561 | //QPalette pal = palette(); | 561 | //QPalette pal = palette(); |
562 | 562 | ||
563 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 563 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
564 | } | 564 | } |
565 | QPalette MonthViewCell::getPalette () | 565 | QPalette MonthViewCell::getPalette () |
566 | { | 566 | { |
567 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 567 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
568 | return mStandardPalette; | 568 | return mStandardPalette; |
569 | if ( mHoliday) { | 569 | if ( mHoliday) { |
570 | return mHolidayPalette ; | 570 | return mHolidayPalette ; |
571 | } else { | 571 | } else { |
572 | if ( mPrimary ) { | 572 | if ( mPrimary ) { |
573 | return mPrimaryPalette ; | 573 | return mPrimaryPalette ; |
574 | } | 574 | } |
575 | } | 575 | } |
576 | return mNonPrimaryPalette; | 576 | return mNonPrimaryPalette; |
577 | } | 577 | } |
578 | bool MonthViewCell::isPrimary() const | 578 | bool MonthViewCell::isPrimary() const |
579 | { | 579 | { |
580 | return mPrimary; | 580 | return mPrimary; |
581 | } | 581 | } |
582 | 582 | ||
583 | void MonthViewCell::setHoliday( bool holiday ) | 583 | void MonthViewCell::setHoliday( bool holiday ) |
584 | { | 584 | { |
585 | mHoliday = holiday; | 585 | mHoliday = holiday; |
586 | //setMyPalette(); | 586 | //setMyPalette(); |
587 | } | 587 | } |
588 | 588 | ||
589 | void MonthViewCell::setHoliday( const QString &holiday ) | 589 | void MonthViewCell::setHoliday( const QString &holiday ) |
590 | { | 590 | { |
591 | mHolidayString = holiday; | 591 | mHolidayString = holiday; |
592 | 592 | ||
593 | if ( !holiday.isEmpty() ) { | 593 | if ( !holiday.isEmpty() ) { |
594 | setHoliday( true ); | 594 | setHoliday( true ); |
595 | } | 595 | } |
596 | } | 596 | } |
597 | 597 | ||
598 | void MonthViewCell::startUpdateCell() | 598 | void MonthViewCell::startUpdateCell() |
599 | { | 599 | { |
600 | mdayCount = 0; | 600 | mdayCount = 0; |
601 | setFocusPolicy(NoFocus); | 601 | setFocusPolicy(NoFocus); |
602 | if ( !mMonthView->isUpdatePossible() ) | 602 | if ( !mMonthView->isUpdatePossible() ) |
603 | return; | 603 | return; |
604 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 604 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
605 | while ( mitem ) { | 605 | while ( mitem ) { |
606 | mitem->setBlockRepaint( true ); | 606 | mitem->setBlockRepaint( true ); |
607 | mitem = (MonthViewItem *)mitem->next(); | 607 | mitem = (MonthViewItem *)mitem->next(); |
608 | } | 608 | } |
609 | if ( mAvailItemList.count() > 20 ) { | 609 | if ( mAvailItemList.count() > 20 ) { |
610 | mAvailItemList.setAutoDelete( true ); | 610 | mAvailItemList.setAutoDelete( true ); |
611 | mAvailItemList.clear(); | 611 | mAvailItemList.clear(); |
612 | mAvailItemList.setAutoDelete( false ); | 612 | mAvailItemList.setAutoDelete( false ); |
613 | } | 613 | } |
614 | 614 | ||
615 | setPrimary( mDate.month()%2 ); | 615 | setPrimary( mDate.month()%2 ); |
616 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 616 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
617 | if ( mDate == QDate::currentDate() ) { | 617 | if ( mDate == QDate::currentDate() ) { |
618 | setLineWidth( 3 ); | 618 | setLineWidth( 3 ); |
619 | } else { | 619 | } else { |
620 | setLineWidth( 1 ); | 620 | setLineWidth( 1 ); |
621 | } | 621 | } |
622 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 622 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
623 | //clear(); | 623 | //clear(); |
624 | while ( CurrentAvailItem ) { | 624 | while ( CurrentAvailItem ) { |
625 | MonthViewItem *item = CurrentAvailItem; | 625 | MonthViewItem *item = CurrentAvailItem; |
626 | CurrentAvailItem = (MonthViewItem *)item->next(); | 626 | CurrentAvailItem = (MonthViewItem *)item->next(); |
627 | mAvailItemList.append( item ); | 627 | mAvailItemList.append( item ); |
628 | takeItem ( item ); | 628 | takeItem ( item ); |
629 | } | 629 | } |
630 | 630 | ||
631 | #ifdef DESKTOP_VERSION | 631 | #ifdef DESKTOP_VERSION |
632 | QToolTip::remove(this); | 632 | QToolTip::remove(this); |
633 | #endif | 633 | #endif |
634 | mToolTip.clear(); | 634 | mToolTip.clear(); |
635 | //qApp->processEvents(); | 635 | //qApp->processEvents(); |
636 | #if 0 | 636 | #if 0 |
637 | if ( !mHolidayString.isEmpty() ) { | 637 | if ( !mHolidayString.isEmpty() ) { |
638 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 638 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
639 | item->setPalette( mHolidayPalette ); | 639 | item->setPalette( mHolidayPalette ); |
640 | insertItem( item ); | 640 | insertItem( item ); |
641 | mToolTip.append ( mHolidayString ); | 641 | mToolTip.append ( mHolidayString ); |
642 | } | 642 | } |
643 | #endif | 643 | #endif |
644 | } | 644 | } |
645 | 645 | ||
646 | int MonthViewCell::insertEvent(Event *event) | 646 | int MonthViewCell::insertEvent(Event *event) |
647 | { | 647 | { |
648 | bool useToolTips = true; | 648 | bool useToolTips = true; |
649 | #ifndef DESKTOP_VERSION | 649 | #ifndef DESKTOP_VERSION |
650 | useToolTips = false; | 650 | useToolTips = false; |
651 | #endif | 651 | #endif |
652 | QString mToolTipText; | 652 | QString mToolTipText; |
653 | setFocusPolicy(WheelFocus); | 653 | setFocusPolicy(WheelFocus); |
654 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 654 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
655 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 655 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
656 | return mdayCount; | 656 | return mdayCount; |
657 | else | 657 | else |
658 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 658 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
659 | return mdayCount; | 659 | return mdayCount; |
660 | } | 660 | } |
661 | 661 | ||
662 | if ( event->isHoliday()) { | 662 | if ( event->isHoliday()) { |
663 | setHoliday( true ); | 663 | setHoliday( true ); |
664 | if ( mDate.dayOfWeek() == 7 ) | 664 | if ( mDate.dayOfWeek() == 7 ) |
665 | setLineWidth( 3 ); | 665 | setLineWidth( 3 ); |
666 | } | 666 | } |
667 | QString text; | 667 | QString text; |
668 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 668 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
669 | if (event->isMultiDay()) { | 669 | if (event->isMultiDay()) { |
670 | QString prefix = "<->";multiday = 2; | 670 | QString prefix = "<->";multiday = 2; |
671 | QString time; | 671 | QString time; |
672 | if ( event->doesRecur() ) { | 672 | if ( event->doesRecur() ) { |
673 | if ( event->recursOn( mDate) ) { | 673 | if ( event->recursOn( mDate) ) { |
674 | prefix ="->" ;multiday = 1; | 674 | prefix ="->" ;multiday = 1; |
675 | } | 675 | } |
676 | else { | 676 | else { |
677 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 677 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
678 | if ( event->recursOn( mDate.addDays( -days)) ) { | 678 | if ( event->recursOn( mDate.addDays( -days)) ) { |
679 | prefix ="<-" ;multiday = 3; | 679 | prefix ="<-" ;multiday = 3; |
680 | } | 680 | } |
681 | } | 681 | } |
682 | 682 | ||
683 | } else { | 683 | } else { |
684 | if (mDate == event->dtStart().date()) { | 684 | if (mDate == event->dtStart().date()) { |
685 | prefix ="->" ;multiday = 1; | 685 | prefix ="->" ;multiday = 1; |
686 | } else if (mDate == event->dtEnd().date()) { | 686 | } else if (mDate == event->dtEnd().date()) { |
687 | prefix ="<-" ;multiday = 3; | 687 | prefix ="<-" ;multiday = 3; |
688 | } | 688 | } |
689 | } | 689 | } |
690 | if ( !event->doesFloat() ) { | 690 | if ( !event->doesFloat() ) { |
691 | if ( mDate == event->dtStart().date () ) | 691 | if ( mDate == event->dtStart().date () ) |
692 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 692 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
693 | else if ( mDate == event->dtEnd().date () ) | 693 | else if ( mDate == event->dtEnd().date () ) |
694 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 694 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
695 | 695 | ||
696 | } | 696 | } |
697 | text = time + event->summary(); | 697 | text = time + event->summary(); |
698 | if ( useToolTips ) | 698 | if ( useToolTips ) |
699 | mToolTipText += prefix + text; | 699 | mToolTipText += prefix + text; |
700 | } else { | 700 | } else { |
701 | if (event->doesFloat()) { | 701 | if (event->doesFloat()) { |
702 | text = event->summary(); | 702 | text = event->summary(); |
703 | if ( useToolTips ) | 703 | if ( useToolTips ) |
704 | mToolTipText += text; | 704 | mToolTipText += text; |
705 | } | 705 | } |
706 | else { | 706 | else { |
707 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 707 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
708 | text += " " + event->summary(); | 708 | text += " " + event->summary(); |
709 | if ( useToolTips ) | 709 | if ( useToolTips ) |
710 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 710 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
711 | } | 711 | } |
712 | } | 712 | } |
713 | if ( useToolTips && ! event->location().isEmpty() ) { | 713 | if ( useToolTips && ! event->location().isEmpty() ) { |
714 | mToolTipText += " (" + event->location() +")"; | 714 | mToolTipText += " (" + event->location() +")"; |
715 | } | 715 | } |
716 | MonthViewItem *item ; | 716 | MonthViewItem *item ; |
717 | 717 | ||
718 | if ( mAvailItemList.count() ) { | 718 | if ( mAvailItemList.count() ) { |
719 | item = mAvailItemList.first(); | 719 | item = mAvailItemList.first(); |
720 | mAvailItemList.remove( item ); | 720 | mAvailItemList.remove( item ); |
721 | item->recycle( event, mDate, text ); | 721 | item->recycle( event, mDate, text ); |
722 | } else { | 722 | } else { |
723 | item = new MonthViewItem( event, mDate, text ); | 723 | item = new MonthViewItem( event, mDate, text ); |
724 | } | 724 | } |
725 | 725 | ||
726 | QPalette pal; | 726 | QPalette pal; |
727 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 727 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
728 | QStringList categories = event->categories(); | 728 | QStringList categories = event->categories(); |
729 | QString cat = categories.first(); | 729 | QString cat = categories.first(); |
730 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 730 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
731 | pal = getPalette(); | 731 | pal = getPalette(); |
732 | if (cat.isEmpty()) { | 732 | if (cat.isEmpty()) { |
733 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 733 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
734 | } else { | 734 | } else { |
735 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 735 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
736 | } | 736 | } |
737 | 737 | ||
738 | } else { | 738 | } else { |
739 | if (cat.isEmpty()) { | 739 | if (cat.isEmpty()) { |
740 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 740 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
741 | } else { | 741 | } else { |
742 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 742 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
743 | } | 743 | } |
744 | } | 744 | } |
745 | 745 | ||
746 | } else { | 746 | } else { |
747 | pal = mStandardPalette ; | 747 | pal = mStandardPalette ; |
748 | } | 748 | } |
749 | item->setPalette( pal ); | 749 | item->setPalette( pal ); |
750 | item->setRecur( event->recurrence()->doesRecur() ); | 750 | item->setRecur( event->recurrence()->doesRecur() ); |
751 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); | 751 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); |
752 | item->setMoreInfo( event->description().length() > 0 ); | 752 | item->setMoreInfo( event->description().length() > 0 ); |
753 | #ifdef DESKTOP_VERSION | 753 | #ifdef DESKTOP_VERSION |
754 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 754 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
755 | KOPrefs::instance()->email()); | 755 | KOPrefs::instance()->email()); |
756 | if ( me != 0 ) { | 756 | if ( me != 0 ) { |
757 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 757 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
758 | item->setReply(true && multiday < 2); | 758 | item->setReply(true && multiday < 2); |
759 | else | 759 | else |
760 | item->setReply(false); | 760 | item->setReply(false); |
761 | } else | 761 | } else |
762 | item->setReply(false); | 762 | item->setReply(false); |
763 | #endif | 763 | #endif |
764 | item->setMultiDay( multiday ); | 764 | item->setMultiDay( multiday ); |
765 | if ( multiday ) { | 765 | if ( multiday ) { |
766 | insertItem( item ,mdayCount); | 766 | insertItem( item ,mdayCount); |
767 | ++mdayCount; | 767 | ++mdayCount; |
768 | } else { | 768 | } else { |
769 | uint i; | 769 | uint i; |
770 | int pos = mdayCount; | 770 | int pos = mdayCount; |
771 | for ( i = mdayCount; i < count();++i ) { | 771 | for ( i = mdayCount; i < count();++i ) { |
772 | QListBoxItem* it = this->item ( i ); | 772 | QListBoxItem* it = this->item ( i ); |
773 | if ( it && text < it->text() ) { | 773 | if ( it && text < it->text() ) { |
774 | pos = i; | 774 | pos = i; |
775 | break; | 775 | break; |
776 | } | 776 | } |
777 | ++pos; | 777 | ++pos; |
778 | } | 778 | } |
779 | insertItem( item ,pos); | 779 | insertItem( item ,pos); |
780 | } | 780 | } |
781 | if ( useToolTips ) { | 781 | if ( useToolTips ) { |
782 | mToolTip.append( mToolTipText ); | 782 | mToolTip.append( mToolTipText ); |
783 | } | 783 | } |
784 | return mdayCount; | 784 | return mdayCount; |
785 | } | 785 | } |
786 | void MonthViewCell::insertTodo(Todo *todo) | 786 | void MonthViewCell::insertTodo(Todo *todo) |
787 | { | 787 | { |
788 | setFocusPolicy(WheelFocus); | 788 | setFocusPolicy(WheelFocus); |
789 | QString text; | 789 | QString text; |
790 | if (todo->hasDueDate()) { | 790 | if (todo->hasDueDate()) { |
791 | if (!todo->doesFloat()) { | 791 | if (!todo->doesFloat()) { |
792 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 792 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
793 | text += " "; | 793 | text += " "; |
794 | } | 794 | } |
795 | } | 795 | } |
796 | text += todo->summary(); | 796 | text += todo->summary(); |
797 | MonthViewItem *item ; | 797 | MonthViewItem *item ; |
798 | if ( mAvailItemList.count() ) { | 798 | if ( mAvailItemList.count() ) { |
799 | item = mAvailItemList.first(); | 799 | item = mAvailItemList.first(); |
800 | mAvailItemList.remove( item ); | 800 | mAvailItemList.remove( item ); |
801 | item->recycle( todo, mDate, text ); | 801 | item->recycle( todo, mDate, text ); |
802 | } else { | 802 | } else { |
803 | item = new MonthViewItem( todo, mDate, text ); | 803 | item = new MonthViewItem( todo, mDate, text ); |
804 | } | 804 | } |
805 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 805 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
806 | //item->setPalette( mStandardPalette ); | 806 | //item->setPalette( mStandardPalette ); |
807 | QPalette pal; | 807 | QPalette pal; |
808 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 808 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
809 | QStringList categories = todo->categories(); | 809 | QStringList categories = todo->categories(); |
810 | QString cat = categories.first(); | 810 | QString cat = categories.first(); |
811 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 811 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
812 | pal = getPalette(); | 812 | pal = getPalette(); |
813 | if (cat.isEmpty()) { | 813 | if (cat.isEmpty()) { |
814 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 814 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
815 | } else { | 815 | } else { |
816 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 816 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
817 | } | 817 | } |
818 | 818 | ||
819 | } else { | 819 | } else { |
820 | if (cat.isEmpty()) { | 820 | if (cat.isEmpty()) { |
821 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 821 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
822 | } else { | 822 | } else { |
823 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 823 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
824 | } | 824 | } |
825 | } | 825 | } |
826 | 826 | ||
827 | } else { | 827 | } else { |
828 | pal = mStandardPalette ; | 828 | pal = mStandardPalette ; |
829 | } | 829 | } |
830 | item->setPalette( pal ); | 830 | item->setPalette( pal ); |
831 | item->setRecur( todo->recurrence()->doesRecur() ); | 831 | item->setRecur( todo->recurrence()->doesRecur() ); |
832 | item->setAlarm( todo->isAlarmEnabled() ); | 832 | item->setAlarm( todo->isAlarmEnabled() ); |
833 | item->setMoreInfo( todo->description().length() > 0 ); | 833 | item->setMoreInfo( todo->description().length() > 0 ); |
834 | insertItem( item , count()); | 834 | insertItem( item , count()); |
835 | #ifdef DESKTOP_VERSION | 835 | #ifdef DESKTOP_VERSION |
836 | mToolTip.append( text ); | 836 | mToolTip.append( text ); |
837 | #endif | 837 | #endif |
838 | } | 838 | } |
839 | void MonthViewCell::repaintfinishUpdateCell() | 839 | void MonthViewCell::repaintfinishUpdateCell() |
840 | { | 840 | { |
841 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 841 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
842 | while ( mitem ) { | 842 | while ( mitem ) { |
843 | mitem->setBlockRepaint( false ); | 843 | mitem->setBlockRepaint( false ); |
844 | updateItem ( mitem ); | 844 | updateItem ( mitem ); |
845 | mitem = (MonthViewItem *)mitem->next(); | 845 | mitem = (MonthViewItem *)mitem->next(); |
846 | } | 846 | } |
847 | } | 847 | } |
848 | void MonthViewCell::finishUpdateCell() | 848 | void MonthViewCell::finishUpdateCell() |
849 | { | 849 | { |
850 | 850 | ||
851 | 851 | ||
852 | 852 | ||
853 | #ifdef DESKTOP_VERSION | 853 | #ifdef DESKTOP_VERSION |
854 | if (mToolTip.count() > 0 ) { | 854 | if (mToolTip.count() > 0 ) { |
855 | mToolTip.sort(); | 855 | mToolTip.sort(); |
856 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 856 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
857 | } | 857 | } |
858 | #endif | 858 | #endif |
859 | //sort(); | 859 | //sort(); |
860 | //setMyPalette(); | 860 | //setMyPalette(); |
861 | setMyPalette(); | 861 | setMyPalette(); |
862 | 862 | ||
863 | resizeEvent( 0 ); | 863 | resizeEvent( 0 ); |
864 | 864 | ||
865 | } | 865 | } |
866 | void MonthViewCell::updateCell() | 866 | void MonthViewCell::updateCell() |
867 | { | 867 | { |
868 | if ( !mMonthView->isUpdatePossible() ) | 868 | if ( !mMonthView->isUpdatePossible() ) |
869 | return; | 869 | return; |
870 | startUpdateCell(); | 870 | startUpdateCell(); |
871 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 871 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
872 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 872 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
873 | Event *event; | 873 | Event *event; |
874 | for( event = events.first(); event; event = events.next() ) { // for event | 874 | for( event = events.first(); event; event = events.next() ) { // for event |
875 | insertEvent(event); | 875 | insertEvent(event); |
876 | } | 876 | } |
877 | // insert due todos | 877 | // insert due todos |
878 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 878 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
879 | Todo *todo; | 879 | Todo *todo; |
880 | for(todo = todos.first(); todo; todo = todos.next()) { | 880 | for(todo = todos.first(); todo; todo = todos.next()) { |
881 | insertTodo( todo ); | 881 | insertTodo( todo ); |
882 | } | 882 | } |
883 | finishUpdateCell(); | 883 | finishUpdateCell(); |
884 | // if ( isVisible()) | 884 | // if ( isVisible()) |
885 | //qApp->processEvents(); | 885 | //qApp->processEvents(); |
886 | } | 886 | } |
887 | 887 | ||
888 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 888 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
889 | { | 889 | { |
890 | 890 | ||
891 | if ( bigFont ) { | 891 | if ( bigFont ) { |
892 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 892 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
893 | int ps = fo.pointSize() + 2; | 893 | int ps = fo.pointSize() + 2; |
894 | if ( ps < 18 ) | 894 | if ( ps < 18 ) |
895 | ps += 2; | 895 | ps += 2; |
896 | fo.setPointSize( ps ); | 896 | fo.setPointSize( ps ); |
897 | setFont( fo ); | 897 | setFont( fo ); |
898 | } else | 898 | } else |
899 | setFont( KOPrefs::instance()->mMonthViewFont ); | 899 | setFont( KOPrefs::instance()->mMonthViewFont ); |
900 | 900 | ||
901 | QFontMetrics fm( font() ); | 901 | QFontMetrics fm( font() ); |
902 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 902 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
903 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 903 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
904 | mHolidayPalette = mStandardPalette; | 904 | mHolidayPalette = mStandardPalette; |
905 | mPrimaryPalette = mStandardPalette; | 905 | mPrimaryPalette = mStandardPalette; |
906 | mNonPrimaryPalette = mStandardPalette; | 906 | mNonPrimaryPalette = mStandardPalette; |
907 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 907 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
908 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 908 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
909 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 909 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
910 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 910 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
911 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 911 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
912 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 912 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
913 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 913 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
914 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 914 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
915 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 915 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
916 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 916 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
917 | } | 917 | } |
918 | //updateCell(); | 918 | //updateCell(); |
919 | } | 919 | } |
920 | 920 | ||
921 | void MonthViewCell::enableScrollBars( bool enabled ) | 921 | void MonthViewCell::enableScrollBars( bool enabled ) |
922 | { | 922 | { |
923 | 923 | ||
924 | return; | 924 | return; |
925 | if ( enabled ) { | 925 | if ( enabled ) { |
926 | QListBoxItem *fi = firstItem (); | 926 | QListBoxItem *fi = firstItem (); |
927 | if (fi ) { | 927 | if (fi ) { |
928 | int ihei = fi->height( this ); | 928 | int ihei = fi->height( this ); |
929 | int hei = numRows () * ihei; | 929 | int hei = numRows () * ihei; |
930 | if ( hei < height() - horizontalScrollBar()->height () ) { | 930 | if ( hei < height() - horizontalScrollBar()->height () ) { |
931 | setVScrollBarMode(QScrollView::AlwaysOff); | 931 | setVScrollBarMode(QScrollView::AlwaysOff); |
932 | } | 932 | } |
933 | else | 933 | else |
934 | setVScrollBarMode(QScrollView::Auto); | 934 | setVScrollBarMode(QScrollView::Auto); |
935 | if ( ihei *3 > height() ) { | 935 | if ( ihei *3 > height() ) { |
936 | setHScrollBarMode(QScrollView::AlwaysOff); | 936 | setHScrollBarMode(QScrollView::AlwaysOff); |
937 | } | 937 | } |
938 | else { | 938 | else { |
939 | setHScrollBarMode(QScrollView::Auto); | 939 | setHScrollBarMode(QScrollView::Auto); |
940 | } | 940 | } |
941 | } else { | 941 | } else { |
942 | setVScrollBarMode(QScrollView::Auto); | 942 | setVScrollBarMode(QScrollView::Auto); |
943 | setHScrollBarMode(QScrollView::Auto); | 943 | setHScrollBarMode(QScrollView::Auto); |
944 | } | 944 | } |
945 | } else { | 945 | } else { |
946 | setVScrollBarMode(QScrollView::AlwaysOff); | 946 | setVScrollBarMode(QScrollView::AlwaysOff); |
947 | setHScrollBarMode(QScrollView::AlwaysOff); | 947 | setHScrollBarMode(QScrollView::AlwaysOff); |
948 | } | 948 | } |
949 | } | 949 | } |
950 | 950 | ||
951 | Incidence *MonthViewCell::selectedIncidence() | 951 | Incidence *MonthViewCell::selectedIncidence() |
952 | { | 952 | { |
953 | int index = currentItem(); | 953 | int index = currentItem(); |
954 | if ( index < 0 ) return 0; | 954 | if ( index < 0 ) return 0; |
955 | 955 | ||
956 | MonthViewItem *mitem = | 956 | MonthViewItem *mitem = |
957 | static_cast<MonthViewItem *>( item( index ) ); | 957 | static_cast<MonthViewItem *>( item( index ) ); |
958 | 958 | ||
959 | if ( !mitem ) return 0; | 959 | if ( !mitem ) return 0; |
960 | 960 | ||
961 | return mitem->incidence(); | 961 | return mitem->incidence(); |
962 | } | 962 | } |
963 | 963 | ||
964 | QDate MonthViewCell::selectedIncidenceDate() | 964 | QDate MonthViewCell::selectedIncidenceDate() |
965 | { | 965 | { |
966 | QDate qd; | 966 | QDate qd; |
967 | int index = currentItem(); | 967 | int index = currentItem(); |
968 | if ( index < 0 ) return qd; | 968 | if ( index < 0 ) return qd; |
969 | 969 | ||
970 | MonthViewItem *mitem = | 970 | MonthViewItem *mitem = |
971 | static_cast<MonthViewItem *>( item( index ) ); | 971 | static_cast<MonthViewItem *>( item( index ) ); |
972 | 972 | ||
973 | if ( !mitem ) return qd; | 973 | if ( !mitem ) return qd; |
974 | 974 | ||
975 | return mitem->incidenceDate(); | 975 | return mitem->incidenceDate(); |
976 | } | 976 | } |
977 | 977 | ||
978 | void MonthViewCell::deselect() | 978 | void MonthViewCell::deselect() |
979 | { | 979 | { |
980 | clearSelection(); | 980 | clearSelection(); |
981 | enableScrollBars( false ); | 981 | enableScrollBars( false ); |
982 | // updateCell(); | 982 | // updateCell(); |
983 | } | 983 | } |
984 | void MonthViewCell::select() | 984 | void MonthViewCell::select() |
985 | { | 985 | { |
986 | ;// updateCell(); | 986 | ;// updateCell(); |
987 | } | 987 | } |
988 | 988 | ||
989 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 989 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
990 | { | 990 | { |
991 | if ( !mMonthView->isUpdatePossible() ) | 991 | if ( !mMonthView->isUpdatePossible() ) |
992 | return; | 992 | return; |
993 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 993 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
994 | deselect(); | 994 | deselect(); |
995 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 995 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
996 | 996 | ||
997 | QString text; | 997 | QString text; |
998 | mLabel->setText( text ); | 998 | mLabel->setText( text ); |
999 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 999 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1000 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1000 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1001 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 1001 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
1002 | mLabel->resize( mLabelBigSize ); | 1002 | mLabel->resize( mLabelBigSize ); |
1003 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1003 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1004 | } else { | 1004 | } else { |
1005 | mLabel->resize( mLabelSize ); | 1005 | mLabel->resize( mLabelSize ); |
1006 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 1006 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
1007 | } | 1007 | } |
1008 | mLabel->setText( text ); | 1008 | mLabel->setText( text ); |
1009 | 1009 | ||
1010 | int size = height() - mLabel->height() - lineWidth()-1; | 1010 | int size = height() - mLabel->height() - lineWidth()-1; |
1011 | //qDebug("LW %d ", lineWidth()); | 1011 | //qDebug("LW %d ", lineWidth()); |
1012 | if ( size > 0 ) | 1012 | if ( size > 0 ) |
1013 | verticalScrollBar()->setMaximumHeight( size ); | 1013 | verticalScrollBar()->setMaximumHeight( size ); |
1014 | size = width() - mLabel->width() -lineWidth()-1; | 1014 | size = width() - mLabel->width() -lineWidth()-1; |
1015 | if ( size > 0 ) | 1015 | if ( size > 0 ) |
1016 | horizontalScrollBar()->setMaximumWidth( size ); | 1016 | horizontalScrollBar()->setMaximumWidth( size ); |
1017 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1017 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1018 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1018 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1019 | // mItemList->resize ( width(), height () ); | 1019 | // mItemList->resize ( width(), height () ); |
1020 | if ( e ) | 1020 | if ( e ) |
1021 | KNoScrollListBox::resizeEvent ( e ); | 1021 | KNoScrollListBox::resizeEvent ( e ); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1024 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1025 | { | 1025 | { |
1026 | 1026 | ||
1027 | if ( !item ) { | 1027 | if ( !item ) { |
1028 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1028 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1029 | emit newEventSignal( dt ); | 1029 | emit newEventSignal( dt ); |
1030 | return; | 1030 | return; |
1031 | } | 1031 | } |
1032 | 1032 | ||
1033 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1033 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1034 | Incidence *incidence = eventItem->incidence(); | 1034 | Incidence *incidence = eventItem->incidence(); |
1035 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1035 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1036 | } | 1036 | } |
1037 | void MonthViewCell::showDay() | 1037 | void MonthViewCell::showDay() |
1038 | { | 1038 | { |
1039 | emit showDaySignal( date() ); | 1039 | emit showDaySignal( date() ); |
1040 | } | 1040 | } |
1041 | void MonthViewCell::newEvent() | 1041 | void MonthViewCell::newEvent() |
1042 | { | 1042 | { |
1043 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1043 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1044 | emit newEventSignal( dt ); | 1044 | emit newEventSignal( dt ); |
1045 | } | 1045 | } |
1046 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1046 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1047 | { | 1047 | { |
1048 | mMonthView->setSelectedCell( this ); | 1048 | mMonthView->setSelectedCell( this ); |
1049 | if ( item == 0 ) { | 1049 | if ( item == 0 ) { |
1050 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1050 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1051 | emit newEventSignal( dt ); | 1051 | emit newEventSignal( dt ); |
1052 | return; | 1052 | return; |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1057 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1058 | { | 1058 | { |
1059 | mMonthView->setPopupCell( this ); | 1059 | mMonthView->setPopupCell( this ); |
1060 | if ( !item ) { | 1060 | if ( !item ) { |
1061 | mMonthView->showContextMenu( 0 ); | 1061 | mMonthView->showContextMenu( 0 ); |
1062 | return; | 1062 | return; |
1063 | } | 1063 | } |
1064 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1064 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1065 | Incidence *incidence = eventItem->incidence(); | 1065 | Incidence *incidence = eventItem->incidence(); |
1066 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1066 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | void MonthViewCell::selection( QListBoxItem *item ) | 1069 | void MonthViewCell::selection( QListBoxItem *item ) |
1070 | { | 1070 | { |
1071 | if ( !item ) return; | 1071 | if ( !item ) return; |
1072 | 1072 | ||
1073 | mMonthView->setSelectedCell( this ); | 1073 | mMonthView->setSelectedCell( this ); |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | 1076 | ||
1077 | // ******************************************************************************* | 1077 | // ******************************************************************************* |
1078 | // ******************************************************************************* | 1078 | // ******************************************************************************* |
1079 | // ******************************************************************************* | 1079 | // ******************************************************************************* |
1080 | 1080 | ||
1081 | 1081 | ||
1082 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1082 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1083 | : KOEventView( calendar, parent, name ), | 1083 | : KOEventView( calendar, parent, name ), |
1084 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1084 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1085 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1085 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1086 | { | 1086 | { |
1087 | mFlagKeyPressed = false; | 1087 | mFlagKeyPressed = false; |
1088 | mShortDayLabelsM = false; | 1088 | mShortDayLabelsM = false; |
1089 | mShortDayLabelsW = false; | 1089 | mShortDayLabelsW = false; |
1090 | skipResize = false; | 1090 | skipResize = false; |
1091 | clPending = true; | 1091 | clPending = true; |
1092 | mPopupCell = 0; | 1092 | mPopupCell = 0; |
1093 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1093 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1094 | mWidStack = new QWidgetStack( this ); | 1094 | mWidStack = new QWidgetStack( this ); |
1095 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1095 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1096 | mMonthView = new QWidget( mWidStack ); | 1096 | mMonthView = new QWidget( mWidStack ); |
1097 | mWeekView = new QWidget( mWidStack ); | 1097 | mWeekView = new QWidget( mWidStack ); |
1098 | #if QT_VERSION >= 0x030000 | 1098 | #if QT_VERSION >= 0x030000 |
1099 | mWidStack->addWidget(mMonthView ); | 1099 | mWidStack->addWidget(mMonthView ); |
1100 | mWidStack->addWidget(mWeekView ); | 1100 | mWidStack->addWidget(mWeekView ); |
1101 | #else | 1101 | #else |
1102 | mWidStack->addWidget( mMonthView, 1 ); | 1102 | mWidStack->addWidget( mMonthView, 1 ); |
1103 | mWidStack->addWidget( mWeekView , 1 ); | 1103 | mWidStack->addWidget( mWeekView , 1 ); |
1104 | #endif | 1104 | #endif |
1105 | hb->addWidget( mNavigatorBar ); | 1105 | hb->addWidget( mNavigatorBar ); |
1106 | hb->addWidget( mWidStack ); | 1106 | hb->addWidget( mWidStack ); |
1107 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1107 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1108 | updatePossible = false; | 1108 | updatePossible = false; |
1109 | //updatePossible = true; | 1109 | //updatePossible = true; |
1110 | mCells.setAutoDelete( true ); | 1110 | mCells.setAutoDelete( true ); |
1111 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1111 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1112 | mDayLabels.resize( mDaysPerWeek ); | 1112 | mDayLabels.resize( mDaysPerWeek ); |
1113 | mDayLabelsW.resize( mDaysPerWeek ); | 1113 | mDayLabelsW.resize( mDaysPerWeek ); |
1114 | QFont bfont = font(); | 1114 | QFont bfont = font(); |
1115 | if ( QApplication::desktop()->width() < 650 ) { | 1115 | if ( QApplication::desktop()->width() < 650 ) { |
1116 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1116 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1117 | } | 1117 | } |
1118 | bfont.setBold( true ); | 1118 | bfont.setBold( true ); |
1119 | int i; | 1119 | int i; |
1120 | 1120 | ||
1121 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1121 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1122 | QLabel *label = new QLabel( mMonthView ); | 1122 | QLabel *label = new QLabel( mMonthView ); |
1123 | label->setFont(bfont); | 1123 | label->setFont(bfont); |
1124 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1124 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1125 | label->setLineWidth(1); | 1125 | label->setLineWidth(1); |
1126 | label->setAlignment(AlignCenter); | 1126 | label->setAlignment(AlignCenter); |
1127 | mDayLabels.insert( i, label ); | 1127 | mDayLabels.insert( i, label ); |
1128 | label = new QLabel( mWeekView ); | 1128 | label = new QLabel( mWeekView ); |
1129 | label->setFont(bfont); | 1129 | label->setFont(bfont); |
1130 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1130 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1131 | label->setLineWidth(1); | 1131 | label->setLineWidth(1); |
1132 | label->setAlignment(AlignCenter); | 1132 | label->setAlignment(AlignCenter); |
1133 | mDayLabelsW.insert( i, label ); | 1133 | mDayLabelsW.insert( i, label ); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | bfont.setBold( false ); | 1136 | bfont.setBold( false ); |
1137 | mWeekLabels.resize( mNumWeeks+1 ); | 1137 | mWeekLabels.resize( mNumWeeks+1 ); |
1138 | mWeekLabelsW.resize( 2 ); | 1138 | mWeekLabelsW.resize( 2 ); |
1139 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1139 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1140 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1140 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1141 | label->setFocusPolicy(NoFocus); | 1141 | label->setFocusPolicy(NoFocus); |
1142 | label->setFont(bfont); | 1142 | label->setFont(bfont); |
1143 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1143 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1144 | label->setFlat(true); | 1144 | label->setFlat(true); |
1145 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1145 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1146 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1146 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1147 | //label->setLineWidth(1); | 1147 | //label->setLineWidth(1); |
1148 | //label->setAlignment(AlignCenter); | 1148 | //label->setAlignment(AlignCenter); |
1149 | mWeekLabels.insert( i, label ); | 1149 | mWeekLabels.insert( i, label ); |
1150 | } | 1150 | } |
1151 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1151 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1152 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1152 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1153 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1153 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1154 | 1154 | ||
1155 | for( i = 0; i < 1+1; i++ ) { | 1155 | for( i = 0; i < 1+1; i++ ) { |
1156 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1156 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1157 | label->setFocusPolicy(NoFocus); | 1157 | label->setFocusPolicy(NoFocus); |
1158 | label->setFont(bfont); | 1158 | label->setFont(bfont); |
1159 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1159 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1160 | label->setFlat(true); | 1160 | label->setFlat(true); |
1161 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1161 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1162 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1162 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1163 | //label->setLineWidth(1); | 1163 | //label->setLineWidth(1); |
1164 | //label->setAlignment(AlignCenter); | 1164 | //label->setAlignment(AlignCenter); |
1165 | mWeekLabelsW.insert( i, label ); | 1165 | mWeekLabelsW.insert( i, label ); |
1166 | } | 1166 | } |
1167 | mWeekLabelsW[1]->setText( i18n("W")); | 1167 | mWeekLabelsW[1]->setText( i18n("W")); |
1168 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1168 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1169 | 1169 | ||
1170 | 1170 | ||
1171 | int row, col; | 1171 | int row, col; |
1172 | mCells.resize( mNumCells ); | 1172 | mCells.resize( mNumCells ); |
1173 | for( row = 0; row < mNumWeeks; ++row ) { | 1173 | for( row = 0; row < mNumWeeks; ++row ) { |
1174 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1174 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1175 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1175 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1176 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1176 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1177 | 1177 | ||
1178 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1178 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1179 | SLOT( defaultAction( Incidence * ) ) ); | 1179 | SLOT( defaultAction( Incidence * ) ) ); |
1180 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1180 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1181 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1181 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1182 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1182 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1183 | SIGNAL( showDaySignal( QDate ) ) ); | 1183 | SIGNAL( showDaySignal( QDate ) ) ); |
1184 | connect( cell, SIGNAL( nextCell() ), | 1184 | connect( cell, SIGNAL( nextCell() ), |
1185 | SLOT( nextCell() ) ); | 1185 | SLOT( nextCell() ) ); |
1186 | connect( cell, SIGNAL( prevCell() ), | 1186 | connect( cell, SIGNAL( prevCell() ), |
1187 | SLOT( prevCell() ) ); | 1187 | SLOT( prevCell() ) ); |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | mCellsW.resize( mDaysPerWeek ); | 1190 | mCellsW.resize( mDaysPerWeek ); |
1191 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1191 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1192 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1192 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1193 | mCellsW.insert( col, cell ); | 1193 | mCellsW.insert( col, cell ); |
1194 | 1194 | ||
1195 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1195 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1196 | SLOT( defaultAction( Incidence * ) ) ); | 1196 | SLOT( defaultAction( Incidence * ) ) ); |
1197 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1197 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1198 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1198 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1199 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1199 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1200 | SIGNAL( showDaySignal( QDate ) ) ); | 1200 | SIGNAL( showDaySignal( QDate ) ) ); |
1201 | connect( cell, SIGNAL( nextCell() ), | 1201 | connect( cell, SIGNAL( nextCell() ), |
1202 | SLOT( nextCell() ) ); | 1202 | SLOT( nextCell() ) ); |
1203 | connect( cell, SIGNAL( prevCell() ), | 1203 | connect( cell, SIGNAL( prevCell() ), |
1204 | SLOT( prevCell() ) ); | 1204 | SLOT( prevCell() ) ); |
1205 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1205 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1208 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1209 | mContextMenu = eventPopup(); | 1209 | mContextMenu = eventPopup(); |
1210 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1210 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1211 | i18n("New Event..."),this, | 1211 | i18n("New Event..."),this, |
1212 | SLOT(slotNewEvent()),false); | 1212 | SLOT(slotNewEvent()),false); |
1213 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1213 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1214 | i18n("New Todo..."),this, | 1214 | i18n("New Todo..."),this, |
1215 | SLOT(slotNewTodo()),false); | 1215 | SLOT(slotNewTodo()),false); |
1216 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1216 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1217 | i18n("Journal"),this, | 1217 | i18n("Journal"),this, |
1218 | SLOT(slotEditJournal()),false); | 1218 | SLOT(slotEditJournal()),false); |
1219 | 1219 | ||
1220 | 1220 | ||
1221 | 1221 | ||
1222 | QString pathString = ""; | 1222 | QString pathString = ""; |
1223 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1223 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1224 | if ( QApplication::desktop()->width() < 480 ) | 1224 | if ( QApplication::desktop()->width() < 480 ) |
1225 | pathString += "icons16/"; | 1225 | pathString += "icons16/"; |
1226 | } else | 1226 | } else |
1227 | pathString += "iconsmini/"; | 1227 | pathString += "iconsmini/"; |
1228 | mNewItemMenu = new QPopupMenu( this ); | 1228 | mNewItemMenu = new QPopupMenu( this ); |
1229 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1229 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1230 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1230 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1231 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1231 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1232 | 1232 | ||
1233 | // updateConfig(); //useless here... | 1233 | // updateConfig(); //useless here... |
1234 | // ... but we need mWidthLongDayLabel computed | 1234 | // ... but we need mWidthLongDayLabel computed |
1235 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1235 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1236 | mWidthLongDayLabel = 0; | 1236 | mWidthLongDayLabel = 0; |
1237 | for (int i = 0; i < 7; i++) { | 1237 | for (int i = 0; i < 7; i++) { |
1238 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1238 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1239 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1239 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1240 | } | 1240 | } |
1241 | 1241 | ||
1242 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1242 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1243 | 1243 | ||
1244 | #if 0 | 1244 | #if 0 |
1245 | if ( mShowWeekView ) | 1245 | if ( mShowWeekView ) |
1246 | mWidStack->raiseWidget( mWeekView ); | 1246 | mWidStack->raiseWidget( mWeekView ); |
1247 | else | 1247 | else |
1248 | mWidStack->raiseWidget( mMonthView ); | 1248 | mWidStack->raiseWidget( mMonthView ); |
1249 | #endif | 1249 | #endif |
1250 | 1250 | ||
1251 | emit incidenceSelected( 0 ); | 1251 | emit incidenceSelected( 0 ); |
1252 | 1252 | ||
1253 | mComputeLayoutTimer = new QTimer( this ); | 1253 | mComputeLayoutTimer = new QTimer( this ); |
1254 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1254 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1255 | 1255 | ||
1256 | 1256 | ||
1257 | #ifndef DESKTOP_VERSION | 1257 | #ifndef DESKTOP_VERSION |
1258 | resize( QApplication::desktop()->size() ); | 1258 | resize( QApplication::desktop()->size() ); |
1259 | #else | 1259 | #else |
1260 | resize(640, 480 ); | 1260 | resize(640, 480 ); |
1261 | updatePossible = true; | 1261 | updatePossible = true; |
1262 | #endif | 1262 | #endif |
1263 | computeLayout(); | 1263 | computeLayout(); |
1264 | 1264 | ||
1265 | if ( mShowWeekView ) | 1265 | if ( mShowWeekView ) |
1266 | mWidStack->raiseWidget( mWeekView ); | 1266 | mWidStack->raiseWidget( mWeekView ); |
1267 | else | 1267 | else |
1268 | mWidStack->raiseWidget( mMonthView ); | 1268 | mWidStack->raiseWidget( mMonthView ); |
1269 | } | 1269 | } |
1270 | 1270 | ||
1271 | KOMonthView::~KOMonthView() | 1271 | KOMonthView::~KOMonthView() |
1272 | { | 1272 | { |
1273 | delete mContextMenu; | 1273 | delete mContextMenu; |
1274 | } | 1274 | } |
1275 | 1275 | ||
1276 | void KOMonthView::selectInternalWeekNum ( int n ) | 1276 | void KOMonthView::selectInternalWeekNum ( int n ) |
1277 | { | 1277 | { |
1278 | switchView(); | 1278 | switchView(); |
1279 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1279 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1280 | emit selectMonth (); | 1280 | emit selectMonth (); |
1281 | else | 1281 | else |
1282 | emit selectWeekNum ( n ); | 1282 | emit selectWeekNum ( n ); |
1283 | } | 1283 | } |
1284 | 1284 | ||
1285 | int KOMonthView::currentWeek() | 1285 | int KOMonthView::currentWeek() |
1286 | { | 1286 | { |
1287 | if ( mShowWeekView ) | 1287 | if ( mShowWeekView ) |
1288 | return mWeekLabelsW[0]->getWeekNum(); | 1288 | return mWeekLabelsW[0]->getWeekNum(); |
1289 | return mWeekLabels[0]->getWeekNum(); | 1289 | return mWeekLabels[0]->getWeekNum(); |
1290 | } | 1290 | } |
1291 | void KOMonthView::switchView() | 1291 | void KOMonthView::switchView() |
1292 | { | 1292 | { |
1293 | if ( selectedCell( ) ) | 1293 | if ( selectedCell( ) ) |
1294 | selectedCell()->deselect(); | 1294 | selectedCell()->deselect(); |
1295 | mShowWeekView = !mShowWeekView; | 1295 | mShowWeekView = !mShowWeekView; |
1296 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1296 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1297 | if ( clPending ) { | 1297 | if ( clPending ) { |
1298 | computeLayout(); | 1298 | computeLayout(); |
1299 | updateConfig(); | 1299 | updateConfig(); |
1300 | } | 1300 | } |
1301 | if ( mShowWeekView ) | 1301 | if ( mShowWeekView ) |
1302 | mWidStack->raiseWidget( mWeekView ); | 1302 | mWidStack->raiseWidget( mWeekView ); |
1303 | else | 1303 | else |
1304 | mWidStack->raiseWidget( mMonthView ); | 1304 | mWidStack->raiseWidget( mMonthView ); |
1305 | clPending = false; | 1305 | clPending = false; |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | int KOMonthView::maxDatesHint() | 1308 | int KOMonthView::maxDatesHint() |
1309 | { | 1309 | { |
1310 | return mNumCells; | 1310 | return mNumCells; |
1311 | } | 1311 | } |
1312 | 1312 | ||
1313 | int KOMonthView::currentDateCount() | 1313 | int KOMonthView::currentDateCount() |
1314 | { | 1314 | { |
1315 | return mNumCells; | 1315 | return mNumCells; |
1316 | } | 1316 | } |
1317 | 1317 | ||
1318 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1318 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1319 | { | 1319 | { |
1320 | QPtrList<Incidence> selected; | 1320 | QPtrList<Incidence> selected; |
1321 | 1321 | ||
1322 | if ( mSelectedCell ) { | 1322 | if ( mSelectedCell ) { |
1323 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1323 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1324 | if ( incidence ) selected.append( incidence ); | 1324 | if ( incidence ) selected.append( incidence ); |
1325 | } | 1325 | } |
1326 | 1326 | ||
1327 | return selected; | 1327 | return selected; |
1328 | } | 1328 | } |
1329 | 1329 | ||
1330 | DateList KOMonthView::selectedDates() | 1330 | DateList KOMonthView::selectedDates() |
1331 | { | 1331 | { |
1332 | DateList selected; | 1332 | DateList selected; |
1333 | 1333 | ||
1334 | if ( mSelectedCell ) { | 1334 | if ( mSelectedCell ) { |
1335 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1335 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1336 | if ( qd.isValid() ) selected.append( qd ); | 1336 | if ( qd.isValid() ) selected.append( qd ); |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | return selected; | 1339 | return selected; |
1340 | } | 1340 | } |
1341 | 1341 | ||
1342 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1342 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1343 | const QDate &td) | 1343 | const QDate &td) |
1344 | { | 1344 | { |
1345 | #ifndef KORG_NOPRINTER | 1345 | #ifndef KORG_NOPRINTER |
1346 | calPrinter->preview(CalPrinter::Month, fd, td); | 1346 | calPrinter->preview(CalPrinter::Month, fd, td); |
1347 | #endif | 1347 | #endif |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | void KOMonthView::updateConfig() | 1350 | void KOMonthView::updateConfig() |
1351 | { | 1351 | { |
1352 | 1352 | ||
1353 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1353 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1354 | 1354 | ||
1355 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1355 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1356 | mWeekStartsMonday = true; | 1356 | mWeekStartsMonday = true; |
1357 | } | 1357 | } |
1358 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1358 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1359 | mWidthLongDayLabel = 0; | 1359 | mWidthLongDayLabel = 0; |
1360 | 1360 | ||
1361 | for (int i = 0; i < 7; i++) { | 1361 | for (int i = 0; i < 7; i++) { |
1362 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1362 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1363 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1363 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1364 | } | 1364 | } |
1365 | bool temp = mShowSatSunComp ; | 1365 | bool temp = mShowSatSunComp ; |
1366 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1366 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1367 | if ( ! mShowWeekView ) { | 1367 | if ( ! mShowWeekView ) { |
1368 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1368 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1369 | computeLayout(); | 1369 | computeLayout(); |
1370 | } | 1370 | } |
1371 | updateDayLabels(); | 1371 | updateDayLabels(); |
1372 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1372 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1373 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1373 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1374 | //resizeEvent( 0 ); | 1374 | //resizeEvent( 0 ); |
1375 | for (uint i = 0; i < mCells.count(); ++i) { | 1375 | for (uint i = 0; i < mCells.count(); ++i) { |
1376 | mCells[i]->updateConfig(); | 1376 | mCells[i]->updateConfig(); |
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1379 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1380 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1380 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1381 | } | 1381 | } |
1382 | #ifdef DESKTOP_VERSION | 1382 | #ifdef DESKTOP_VERSION |
1383 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1383 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1384 | #endif | 1384 | #endif |
1385 | updateView(); | 1385 | updateView(); |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | void KOMonthView::updateDayLabels() | 1388 | void KOMonthView::updateDayLabels() |
1389 | { | 1389 | { |
1390 | 1390 | ||
1391 | QPtrVector<QLabel> *mDayLabelsT; | 1391 | QPtrVector<QLabel> *mDayLabelsT; |
1392 | 1392 | ||
1393 | mDayLabelsT = &mDayLabelsW; | 1393 | mDayLabelsT = &mDayLabelsW; |
1394 | for (int i = 0; i < 7; i++) { | 1394 | for (int i = 0; i < 7; i++) { |
1395 | { | 1395 | { |
1396 | bool show = mShortDayLabelsW; | 1396 | bool show = mShortDayLabelsW; |
1397 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1397 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1398 | show = true; | 1398 | show = true; |
1399 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1399 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1400 | } | 1400 | } |
1401 | } | 1401 | } |
1402 | mDayLabelsT = &mDayLabels; | 1402 | mDayLabelsT = &mDayLabels; |
1403 | for (int i = 0; i < 7; i++) { | 1403 | for (int i = 0; i < 7; i++) { |
1404 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1404 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1405 | bool show = mShortDayLabelsM; | 1405 | bool show = mShortDayLabelsM; |
1406 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1406 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1407 | show = true; | 1407 | show = true; |
1408 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1408 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1409 | } else { | 1409 | } else { |
1410 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1410 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1411 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1411 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1412 | 1412 | ||
1413 | } | 1413 | } |
1414 | } | 1414 | } |
1415 | 1415 | ||
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | void KOMonthView::clearList() | 1418 | void KOMonthView::clearList() |
1419 | { | 1419 | { |
1420 | unsigned int i; | 1420 | unsigned int i; |
1421 | for( i = 0; i < mCells.size(); ++i ) { | 1421 | for( i = 0; i < mCells.size(); ++i ) { |
1422 | mCells[i]->clear(); | 1422 | mCells[i]->clear(); |
1423 | } | 1423 | } |
1424 | for( i = 0; i < mCellsW.size(); ++i ) { | 1424 | for( i = 0; i < mCellsW.size(); ++i ) { |
1425 | mCellsW[i]->clear(); | 1425 | mCellsW[i]->clear(); |
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1428 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1429 | { | 1429 | { |
1430 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1430 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1431 | 1431 | ||
1432 | QPtrVector<MonthViewCell> *cells; | 1432 | QPtrVector<MonthViewCell> *cells; |
1433 | QPtrVector<QLabel> *dayLabels; | 1433 | QPtrVector<QLabel> *dayLabels; |
1434 | QPtrVector<KOWeekButton> *weekLabels; | 1434 | QPtrVector<KOWeekButton> *weekLabels; |
1435 | int weekNum = 6; | 1435 | int weekNum = 6; |
1436 | mStartDate = start; | 1436 | mStartDate = start; |
1437 | if ( mShowWeekView ) { | 1437 | if ( mShowWeekView ) { |
1438 | weekNum = 1; | 1438 | weekNum = 1; |
1439 | cells = &mCellsW; | 1439 | cells = &mCellsW; |
1440 | dayLabels = &mDayLabelsW; | 1440 | dayLabels = &mDayLabelsW; |
1441 | weekLabels = &mWeekLabelsW; | 1441 | weekLabels = &mWeekLabelsW; |
1442 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1442 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1443 | mStartDate = mStartDate.addDays( 1 ); | 1443 | mStartDate = mStartDate.addDays( 1 ); |
1444 | } | 1444 | } |
1445 | } else { | 1445 | } else { |
1446 | cells = &mCells; | 1446 | cells = &mCells; |
1447 | dayLabels = &mDayLabels; | 1447 | dayLabels = &mDayLabels; |
1448 | weekLabels = &mWeekLabels; | 1448 | weekLabels = &mWeekLabels; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1451 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1452 | 1452 | ||
1453 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1453 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1454 | mWeekStartsMonday = true; | 1454 | mWeekStartsMonday = true; |
1455 | } | 1455 | } |
1456 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1456 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1457 | 1457 | ||
1458 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1458 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1459 | mStartDate = mStartDate.addDays( -1 ); | 1459 | mStartDate = mStartDate.addDays( -1 ); |
1460 | } | 1460 | } |
1461 | bool primary = false; | 1461 | bool primary = false; |
1462 | uint i; | 1462 | uint i; |
1463 | for( i = 0; i < (*cells).size(); ++i ) { | 1463 | for( i = 0; i < (*cells).size(); ++i ) { |
1464 | QDate date = mStartDate.addDays( i ); | 1464 | QDate date = mStartDate.addDays( i ); |
1465 | (*cells)[i]->setDate( date ); | 1465 | (*cells)[i]->setDate( date ); |
1466 | 1466 | ||
1467 | #ifndef KORG_NOPLUGINS | 1467 | #ifndef KORG_NOPLUGINS |
1468 | // add holiday, if present | 1468 | // add holiday, if present |
1469 | QString hstring(KOCore::self()->holiday(date)); | 1469 | QString hstring(KOCore::self()->holiday(date)); |
1470 | (*cells)[i]->setHoliday( hstring ); | 1470 | (*cells)[i]->setHoliday( hstring ); |
1471 | #endif | 1471 | #endif |
1472 | 1472 | ||
1473 | } | 1473 | } |
1474 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1474 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1475 | for( i = 0; i < weekNum; ++i ) { | 1475 | for( i = 0; i < weekNum; ++i ) { |
1476 | int wno; | 1476 | int wno; |
1477 | // remember, according to ISO 8601, the first week of the year is the | 1477 | // remember, according to ISO 8601, the first week of the year is the |
1478 | // first week that contains a thursday. Thus we must subtract off 4, | 1478 | // first week that contains a thursday. Thus we must subtract off 4, |
1479 | // not just 1. | 1479 | // not just 1. |
1480 | int dayOfYear = date.dayOfYear(); | 1480 | int dayOfYear = date.dayOfYear(); |
1481 | if (dayOfYear % 7 != 0) | 1481 | if (dayOfYear % 7 != 0) |
1482 | wno = dayOfYear / 7 + 1; | 1482 | wno = dayOfYear / 7 + 1; |
1483 | else | 1483 | else |
1484 | wno =dayOfYear / 7; | 1484 | wno =dayOfYear / 7; |
1485 | (*weekLabels)[i]->setWeekNum( wno ); | 1485 | (*weekLabels)[i]->setWeekNum( wno ); |
1486 | date = date.addDays( 7 ); | 1486 | date = date.addDays( 7 ); |
1487 | } | 1487 | } |
1488 | updateView(); | 1488 | updateView(); |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | void KOMonthView::showEvents(QPtrList<Event>) | 1491 | void KOMonthView::showEvents(QPtrList<Event>) |
1492 | { | 1492 | { |
1493 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1493 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | void KOMonthView::changeEventDisplay(Event *, int) | 1496 | void KOMonthView::changeEventDisplay(Event *, int) |
1497 | { | 1497 | { |
1498 | // this should be re-written to be much more efficient, but this | 1498 | // this should be re-written to be much more efficient, but this |
1499 | // quick-and-dirty-hack gets the job done for right now. | 1499 | // quick-and-dirty-hack gets the job done for right now. |
1500 | //qDebug("KOMonthView::changeEventDisplay "); | 1500 | //qDebug("KOMonthView::changeEventDisplay "); |
1501 | updateView(); | 1501 | updateView(); |
1502 | } | 1502 | } |
1503 | 1503 | ||
1504 | void KOMonthView::updateView() | 1504 | void KOMonthView::updateView() |
1505 | { | 1505 | { |
1506 | 1506 | ||
1507 | if ( !updatePossible ) | 1507 | if ( !updatePossible ) |
1508 | return; | 1508 | return; |
1509 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1509 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1510 | //QTime ti; | 1510 | //QTime ti; |
1511 | //ti.start(); | 1511 | //ti.start(); |
1512 | clearSelection(); | 1512 | clearSelection(); |
1513 | QPtrVector<MonthViewCell> *cells; | 1513 | QPtrVector<MonthViewCell> *cells; |
1514 | if ( mShowWeekView ) { | 1514 | if ( mShowWeekView ) { |
1515 | cells = &mCellsW; | 1515 | cells = &mCellsW; |
1516 | } else { | 1516 | } else { |
1517 | cells = &mCells; | 1517 | cells = &mCells; |
1518 | } | 1518 | } |
1519 | #if 1 | 1519 | #if 1 |
1520 | int i; | 1520 | int i; |
1521 | int timeSpan = (*cells).size()-1; | 1521 | int timeSpan = (*cells).size()-1; |
1522 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1522 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1523 | timeSpan = 6; | 1523 | timeSpan = 6; |
1524 | for( i = 0; i < timeSpan + 1; ++i ) { | 1524 | for( i = 0; i < timeSpan + 1; ++i ) { |
1525 | (*cells)[i]->startUpdateCell(); | 1525 | (*cells)[i]->startUpdateCell(); |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | QPtrList<Event> events = calendar()->events(); | 1528 | QPtrList<Event> events = calendar()->events(); |
1529 | Event *event; | 1529 | Event *event; |
1530 | QDateTime dt; | 1530 | QDateTime dt; |
1531 | bool ok; | 1531 | bool ok; |
1532 | QDate endDate = mStartDate.addDays( timeSpan ); | 1532 | QDate endDate = mStartDate.addDays( timeSpan ); |
1533 | for( event = events.first(); event; event = events.next() ) { // for event | 1533 | for( event = events.first(); event; event = events.next() ) { // for event |
1534 | if ( event->doesRecur() ) { | 1534 | if ( event->doesRecur() ) { |
1535 | bool last; | 1535 | bool last; |
1536 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1536 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1537 | QDateTime incidenceEnd; | 1537 | QDateTime incidenceEnd; |
1538 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1538 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1539 | bool invalid = false; | 1539 | bool invalid = false; |
1540 | while( true ) { | 1540 | while( true ) { |
1541 | if ( incidenceStart.isValid() ) { | 1541 | if ( incidenceStart.isValid() ) { |
1542 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1542 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1543 | int st = incidenceStart.date().daysTo( endDate ); | 1543 | int st = incidenceStart.date().daysTo( endDate ); |
1544 | if ( st >= 0 ) { // start before timeend | 1544 | if ( st >= 0 ) { // start before timeend |
1545 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1545 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1546 | if ( end >= 0 ) { // end after timestart --- got one! | 1546 | if ( end >= 0 ) { // end after timestart --- got one! |
1547 | //normalize | 1547 | //normalize |
1548 | st = timeSpan - st; | 1548 | st = timeSpan - st; |
1549 | if ( st < 0 ) st = 0; | 1549 | if ( st < 0 ) st = 0; |
1550 | if ( end > timeSpan ) end = timeSpan; | 1550 | if ( end > timeSpan ) end = timeSpan; |
1551 | int iii; | 1551 | int iii; |
1552 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1552 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1553 | for ( iii = st;iii<= end;++iii) | 1553 | for ( iii = st;iii<= end;++iii) |
1554 | (*cells)[iii]->insertEvent( event ); | 1554 | (*cells)[iii]->insertEvent( event ); |
1555 | } | 1555 | } |
1556 | } | 1556 | } |
1557 | } else { | 1557 | } else { |
1558 | if ( invalid ) | 1558 | if ( invalid ) |
1559 | break; | 1559 | break; |
1560 | invalid = true; | 1560 | invalid = true; |
1561 | //qDebug("invalid %s", event->summary().latin1()); | 1561 | //qDebug("invalid %s", event->summary().latin1()); |
1562 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1562 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1563 | } | 1563 | } |
1564 | if ( last ) | 1564 | if ( last ) |
1565 | break; | 1565 | break; |
1566 | bool ok; | 1566 | bool ok; |
1567 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1567 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1568 | if ( ! ok ) | 1568 | if ( ! ok ) |
1569 | break; | 1569 | break; |
1570 | if ( incidenceStart.date() > endDate ) | 1570 | if ( incidenceStart.date() > endDate ) |
1571 | break; | 1571 | break; |
1572 | } | 1572 | } |
1573 | } else { // no recur | 1573 | } else { // no recur |
1574 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1574 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1575 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1575 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1576 | continue; | 1576 | continue; |
1577 | int st = event->dtStart().date().daysTo( endDate ); | 1577 | int st = event->dtStart().date().daysTo( endDate ); |
1578 | if ( st >= 0 ) { // start before timeend | 1578 | if ( st >= 0 ) { // start before timeend |
1579 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1579 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1580 | if ( end >= 0 ) { // end after timestart --- got one! | 1580 | if ( end >= 0 ) { // end after timestart --- got one! |
1581 | //normalize | 1581 | //normalize |
1582 | st = timeSpan - st; | 1582 | st = timeSpan - st; |
1583 | if ( st < 0 ) st = 0; | 1583 | if ( st < 0 ) st = 0; |
1584 | if ( end > timeSpan ) end = timeSpan; | 1584 | if ( end > timeSpan ) end = timeSpan; |
1585 | int iii; | 1585 | int iii; |
1586 | for ( iii = st;iii<= end;++iii) | 1586 | for ( iii = st;iii<= end;++iii) |
1587 | (*cells)[iii]->insertEvent( event ); | 1587 | (*cells)[iii]->insertEvent( event ); |
1588 | } | 1588 | } |
1589 | } | 1589 | } |
1590 | } | 1590 | } |
1591 | } | 1591 | } |
1592 | // insert due todos | 1592 | // insert due todos |
1593 | QPtrList<Todo> todos = calendar()->todos( ); | 1593 | QPtrList<Todo> todos = calendar()->todos( ); |
1594 | Todo *todo; | 1594 | Todo *todo; |
1595 | for(todo = todos.first(); todo; todo = todos.next()) { | 1595 | for(todo = todos.first(); todo; todo = todos.next()) { |
1596 | //insertTodo( todo ); | 1596 | //insertTodo( todo ); |
1597 | if ( todo->hasDueDate() ) { | 1597 | if ( todo->hasDueDate() ) { |
1598 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1598 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1599 | if ( day >= 0 && day < timeSpan + 1) { | 1599 | if ( day >= 0 && day < timeSpan + 1) { |
1600 | (*cells)[day]->insertTodo( todo ); | 1600 | (*cells)[day]->insertTodo( todo ); |
1601 | } | 1601 | } |
1602 | } | 1602 | } |
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | for( i = 0; i < timeSpan+1; ++i ) { | 1605 | for( i = 0; i < timeSpan+1; ++i ) { |
1606 | (*cells)[i]->finishUpdateCell(); | 1606 | (*cells)[i]->finishUpdateCell(); |
1607 | } | 1607 | } |
1608 | processSelectionChange(); | 1608 | processSelectionChange(); |
1609 | //qApp->processEvents(); | 1609 | //qApp->processEvents(); |
1610 | for( i = 0; i < timeSpan+1; ++i ) { | 1610 | for( i = 0; i < timeSpan+1; ++i ) { |
1611 | (*cells)[i]->repaintfinishUpdateCell(); | 1611 | (*cells)[i]->repaintfinishUpdateCell(); |
1612 | } | 1612 | } |
1613 | setKeyBFocus(); | 1613 | setKeyBFocus(); |
1614 | #else | 1614 | #else |
1615 | // old code | 1615 | // old code |
1616 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1616 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1617 | int i; | 1617 | int i; |
1618 | for( i = 0; i < (*cells).count(); ++i ) { | 1618 | for( i = 0; i < (*cells).count(); ++i ) { |
1619 | (*cells)[i]->updateCell(); | 1619 | (*cells)[i]->updateCell(); |
1620 | } | 1620 | } |
1621 | 1621 | ||
1622 | //qDebug("KOMonthView::updateView() "); | 1622 | //qDebug("KOMonthView::updateView() "); |
1623 | processSelectionChange(); | 1623 | processSelectionChange(); |
1624 | // qDebug("---------------------------------------------------------------------+ "); | 1624 | // qDebug("---------------------------------------------------------------------+ "); |
1625 | (*cells)[0]->setFocus(); | 1625 | (*cells)[0]->setFocus(); |
1626 | #endif | 1626 | #endif |
1627 | 1627 | ||
1628 | //qDebug("update time %d ", ti.elapsed()); | 1628 | //qDebug("update time %d ", ti.elapsed()); |
1629 | } | 1629 | } |
1630 | 1630 | ||
1631 | void KOMonthView::setKeyBoardFocus() | 1631 | void KOMonthView::setKeyBoardFocus() |
1632 | { | 1632 | { |
1633 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1633 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1634 | bool shootAgain = false; | 1634 | bool shootAgain = false; |
1635 | if ( mShowWeekView ) { | 1635 | if ( mShowWeekView ) { |
1636 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1636 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1637 | mWeekLabelsW[1]->setFocus(); | 1637 | mWeekLabelsW[1]->setFocus(); |
1638 | } | 1638 | } |
1639 | else { | 1639 | else { |
1640 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1640 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1641 | mWeekLabels[mNumWeeks]->setFocus(); | 1641 | mWeekLabels[mNumWeeks]->setFocus(); |
1642 | } | 1642 | } |
1643 | if ( shootAgain ) { | 1643 | if ( shootAgain ) { |
1644 | QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); | 1644 | QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); |
1645 | } | 1645 | } |
1646 | } | 1646 | } |
1647 | void KOMonthView::setKeyBFocus() | 1647 | void KOMonthView::setKeyBFocus() |
1648 | { | 1648 | { |
1649 | //qDebug("KOMonthView::setKeyBFocus() "); | 1649 | //qDebug("KOMonthView::setKeyBFocus() "); |
1650 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1650 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1651 | } | 1651 | } |
1652 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1652 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1653 | { | 1653 | { |
1654 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1654 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1655 | if ( isVisible() ) { | 1655 | if ( isVisible() ) { |
1656 | //qDebug("KOMonthView::isVisible "); | 1656 | //qDebug("KOMonthView::isVisible "); |
1657 | slotComputeLayout(); | 1657 | slotComputeLayout(); |
1658 | } else | 1658 | } else |
1659 | mComputeLayoutTimer->start( 100 ); | 1659 | mComputeLayoutTimer->start( 100 ); |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | void KOMonthView::slotComputeLayout() | 1662 | void KOMonthView::slotComputeLayout() |
1663 | { | 1663 | { |
1664 | mComputeLayoutTimer->stop(); | 1664 | mComputeLayoutTimer->stop(); |
1665 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1665 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1666 | computeLayout(); | 1666 | computeLayout(); |
1667 | clPending = true; | 1667 | clPending = true; |
1668 | setKeyBFocus(); | 1668 | setKeyBFocus(); |
1669 | } | 1669 | } |
1670 | void KOMonthView::computeLayoutWeek() | 1670 | void KOMonthView::computeLayoutWeek() |
1671 | { | 1671 | { |
1672 | static int lastWid = 0; | 1672 | static int lastWid = 0; |
1673 | static int lastHei = 0; | 1673 | static int lastHei = 0; |
1674 | int daysToShow; | 1674 | int daysToShow; |
1675 | bool combinedSatSun = false; | 1675 | bool combinedSatSun = false; |
1676 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1676 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1677 | daysToShow = 6; | 1677 | daysToShow = 6; |
1678 | combinedSatSun = true; | 1678 | combinedSatSun = true; |
1679 | } | 1679 | } |
1680 | int tWid = topLevelWidget()->size().width(); | 1680 | int tWid = topLevelWidget()->size().width(); |
1681 | int tHei = topLevelWidget()->size().height(); | 1681 | int tHei = topLevelWidget()->size().height(); |
1682 | 1682 | ||
1683 | int wid = width();//e | 1683 | int wid = width();//e |
1684 | int hei = height()-1-mNavigatorBar->height(); | 1684 | int hei = height()-1-mNavigatorBar->height(); |
1685 | 1685 | ||
1686 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1686 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1687 | return; | 1687 | return; |
1688 | 1688 | ||
1689 | if ( lastWid == width() && lastHei == height() ) { | 1689 | if ( lastWid == width() && lastHei == height() ) { |
1690 | //qDebug("KOListWeekView::No compute layout needed "); | 1690 | //qDebug("KOListWeekView::No compute layout needed "); |
1691 | return; | 1691 | return; |
1692 | } | 1692 | } |
1693 | lastWid = width(); | 1693 | lastWid = width(); |
1694 | lastHei = height(); | 1694 | lastHei = height(); |
1695 | 1695 | ||
1696 | 1696 | ||
1697 | if ( wid < hei ) | 1697 | if ( wid < hei ) |
1698 | daysToShow = 2; | 1698 | daysToShow = 2; |
1699 | else | 1699 | else |
1700 | daysToShow = 3; | 1700 | daysToShow = 3; |
1701 | mShowSatSunComp = true; | 1701 | mShowSatSunComp = true; |
1702 | combinedSatSun = true; | 1702 | combinedSatSun = true; |
1703 | 1703 | ||
1704 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1704 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1705 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1705 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1706 | int weeklabelwid = fm.width( "888" ); | 1706 | int weeklabelwid = fm.width( "888" ); |
1707 | wid -= weeklabelwid; | 1707 | wid -= weeklabelwid; |
1708 | 1708 | ||
1709 | int colWid = wid / daysToShow; | 1709 | int colWid = wid / daysToShow; |
1710 | int lastCol = wid - ( colWid*6 ); | 1710 | int lastCol = wid - ( colWid*6 ); |
1711 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1711 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1712 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1712 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1713 | int colModulo = wid % daysToShow; | 1713 | int colModulo = wid % daysToShow; |
1714 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1714 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1715 | //qDebug("rowmod %d ", rowModulo); | 1715 | //qDebug("rowmod %d ", rowModulo); |
1716 | int i; | 1716 | int i; |
1717 | int x,y,w,h; | 1717 | int x,y,w,h; |
1718 | x= 0; | 1718 | x= 0; |
1719 | y= 0; | 1719 | y= 0; |
1720 | w = colWid; | 1720 | w = colWid; |
1721 | h = dayLabelHei ; | 1721 | h = dayLabelHei ; |
1722 | for ( i = 0; i < 7; i++) { | 1722 | for ( i = 0; i < 7; i++) { |
1723 | if ( i && !( i % daysToShow) && i < 6) { | 1723 | if ( i && !( i % daysToShow) && i < 6) { |
1724 | y += hei/(5-daysToShow); | 1724 | y += hei/(5-daysToShow); |
1725 | x = 0; | 1725 | x = 0; |
1726 | w = colWid; | 1726 | w = colWid; |
1727 | } | 1727 | } |
1728 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1728 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1729 | ++w; | 1729 | ++w; |
1730 | } | 1730 | } |
1731 | if ( i >= 5 ) { | 1731 | if ( i >= 5 ) { |
1732 | int wi = width() - x - weeklabelwid; | 1732 | int wi = width() - x - weeklabelwid; |
1733 | if ( i == 5 ) { | 1733 | if ( i == 5 ) { |
1734 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); | 1734 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); |
1735 | } else { | 1735 | } else { |
1736 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | 1736 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); |
1737 | } | 1737 | } |
1738 | x = x - w + wi - (wi/2 ); | 1738 | x = x - w + wi - (wi/2 ); |
1739 | } | 1739 | } |
1740 | else { | 1740 | else { |
1741 | int wi = w; | 1741 | int wi = w; |
1742 | if ( !(( i+1) % daysToShow)) { | 1742 | if ( !(( i+1) % daysToShow)) { |
1743 | wi = width() - x - weeklabelwid; | 1743 | wi = width() - x - weeklabelwid; |
1744 | } | 1744 | } |
1745 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); | 1745 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); |
1746 | } | 1746 | } |
1747 | x += w; | 1747 | x += w; |
1748 | } | 1748 | } |
1749 | x= 0; | 1749 | x= 0; |
1750 | y= dayLabelHei; | 1750 | y= dayLabelHei; |
1751 | w = colWid; | 1751 | w = colWid; |
1752 | h = cellHei; | 1752 | h = cellHei; |
1753 | int max = 0; | 1753 | int max = 0; |
1754 | for ( i = 0; i < mCellsW.count(); ++i) { | 1754 | for ( i = 0; i < mCellsW.count(); ++i) { |
1755 | if ( i > 6 ) { | 1755 | if ( i > 6 ) { |
1756 | mCellsW[i]->hide(); | 1756 | mCellsW[i]->hide(); |
1757 | continue; | 1757 | continue; |
1758 | } | 1758 | } |
1759 | 1759 | ||
1760 | w = colWid; | 1760 | w = colWid; |
1761 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1761 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1762 | ++w; | 1762 | ++w; |
1763 | } | 1763 | } |
1764 | if ( i == (daysToShow-1-rowModulo)*7) | 1764 | if ( i == (daysToShow-1-rowModulo)*7) |
1765 | ++h; | 1765 | ++h; |
1766 | 1766 | ||
1767 | if ( i >= 5 ) { | 1767 | if ( i >= 5 ) { |
1768 | if ( i ==5 ) { | 1768 | if ( i ==5 ) { |
1769 | max = h/2; | 1769 | max = h/2; |
1770 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1770 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1771 | x -= w ;y += h/2; | 1771 | x -= w ;y += h/2; |
1772 | } else { | 1772 | } else { |
1773 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1773 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1774 | ++w; | 1774 | ++w; |
1775 | } | 1775 | } |
1776 | max = h-h/2; | 1776 | max = h-h/2; |
1777 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1777 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1778 | y -= h/2; | 1778 | y -= h/2; |
1779 | } | 1779 | } |
1780 | } else { | 1780 | } else { |
1781 | max = h; | 1781 | max = h; |
1782 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1782 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1783 | } | 1783 | } |
1784 | 1784 | ||
1785 | 1785 | ||
1786 | x += w; | 1786 | x += w; |
1787 | if ( x + w/2 > wid ) { | 1787 | if ( x + w/2 > wid ) { |
1788 | x = 0; | 1788 | x = 0; |
1789 | y += h+dayLabelHei ; | 1789 | y += h+dayLabelHei ; |
1790 | } | 1790 | } |
1791 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); | 1791 | //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); |
1792 | } | 1792 | } |
1793 | y= dayLabelHei; | 1793 | y= dayLabelHei; |
1794 | h = cellHei ; | 1794 | h = cellHei ; |
1795 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1795 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1796 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1796 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1797 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1797 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1798 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1798 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1799 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; | 1799 | mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; |
1800 | updateDayLabels(); | 1800 | updateDayLabels(); |
1801 | //bool forceUpdate = !updatePossible; | 1801 | //bool forceUpdate = !updatePossible; |
1802 | updatePossible = true; | 1802 | updatePossible = true; |
1803 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1803 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1804 | //if ( forceUpdate ) | 1804 | //if ( forceUpdate ) |
1805 | // updateView(); | 1805 | // updateView(); |
1806 | } | 1806 | } |
1807 | void KOMonthView::computeLayout() | 1807 | void KOMonthView::computeLayout() |
1808 | { | 1808 | { |
1809 | 1809 | ||
1810 | 1810 | ||
1811 | static int lastWid = 0; | 1811 | static int lastWid = 0; |
1812 | static int lastHei = 0; | 1812 | static int lastHei = 0; |
1813 | 1813 | ||
1814 | if ( mShowWeekView ){ | 1814 | if ( mShowWeekView ){ |
1815 | computeLayoutWeek(); | 1815 | computeLayoutWeek(); |
1816 | return; | 1816 | return; |
1817 | } | 1817 | } |
1818 | int daysToShow = 7; | 1818 | int daysToShow = 7; |
1819 | bool combinedSatSun = false; | 1819 | bool combinedSatSun = false; |
1820 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1820 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1821 | daysToShow = 6; | 1821 | daysToShow = 6; |
1822 | combinedSatSun = true; | 1822 | combinedSatSun = true; |
1823 | } | 1823 | } |
1824 | int tWid = topLevelWidget()->size().width(); | 1824 | int tWid = topLevelWidget()->size().width(); |
1825 | int tHei = topLevelWidget()->size().height(); | 1825 | int tHei = topLevelWidget()->size().height(); |
1826 | 1826 | ||
1827 | int wid = width();//e | 1827 | int wid = width();//e |
1828 | int hei = height()-1-mNavigatorBar->height(); | 1828 | int hei = height()-1-mNavigatorBar->height(); |
1829 | 1829 | ||
1830 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { | 1830 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1831 | return; | 1831 | return; |
1832 | } | 1832 | } |
1833 | if ( lastWid == width() && lastHei == height() ){ | 1833 | if ( lastWid == width() && lastHei == height() ){ |
1834 | //qDebug("KOMonthview::No compute layout needed "); | 1834 | //qDebug("KOMonthview::No compute layout needed "); |
1835 | return; | 1835 | return; |
1836 | } | 1836 | } |
1837 | 1837 | ||
1838 | lastWid = width(); | 1838 | lastWid = width(); |
1839 | lastHei = height(); | 1839 | lastHei = height(); |
1840 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); | 1840 | //qDebug("KOMonthView::computeLayout() MMM ------------------- "); |
1841 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1841 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1842 | int weeklabelwid = fm.width( "888" ); | 1842 | int weeklabelwid = fm.width( "888" ); |
1843 | wid -= weeklabelwid; | 1843 | wid -= weeklabelwid; |
1844 | 1844 | ||
1845 | int colWid = wid / daysToShow; | 1845 | int colWid = wid / daysToShow; |
1846 | int lastCol = wid - ( colWid*6 ); | 1846 | int lastCol = wid - ( colWid*6 ); |
1847 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1847 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1848 | int cellHei = (hei - dayLabelHei) /6; | 1848 | int cellHei = (hei - dayLabelHei) /6; |
1849 | int colModulo = wid % daysToShow; | 1849 | int colModulo = wid % daysToShow; |
1850 | int rowModulo = (hei- dayLabelHei) % 6; | 1850 | int rowModulo = (hei- dayLabelHei) % 6; |
1851 | //qDebug("rowmod %d ", rowModulo); | 1851 | //qDebug("rowmod %d ", rowModulo); |
1852 | int i; | 1852 | int i; |
1853 | int x,y,w,h; | 1853 | int x,y,w,h; |
1854 | x= 0; | 1854 | x= 0; |
1855 | y= 0; | 1855 | y= 0; |
1856 | w = colWid; | 1856 | w = colWid; |
1857 | h = dayLabelHei ; | 1857 | h = dayLabelHei ; |
1858 | for ( i = 0; i < 7; i++) { | 1858 | for ( i = 0; i < 7; i++) { |
1859 | if ( i == daysToShow-colModulo ) | 1859 | if ( i == daysToShow-colModulo ) |
1860 | ++w; | 1860 | ++w; |
1861 | if ( combinedSatSun ) { | 1861 | if ( combinedSatSun ) { |
1862 | if ( i >= daysToShow-1 ) { | 1862 | if ( i >= daysToShow-1 ) { |
1863 | 1863 | ||
1864 | if ( i == 6 ) | 1864 | if ( i == 6 ) |
1865 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); | 1865 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); |
1866 | else | 1866 | else |
1867 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1867 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1868 | x -= w/2 ; | 1868 | x -= w/2 ; |
1869 | } | 1869 | } |
1870 | else | 1870 | else |
1871 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1871 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1872 | } else | 1872 | } else |
1873 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1873 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1874 | x += w; | 1874 | x += w; |
1875 | } | 1875 | } |
1876 | x= 0; | 1876 | x= 0; |
1877 | y= dayLabelHei; | 1877 | y= dayLabelHei; |
1878 | w = colWid; | 1878 | w = colWid; |
1879 | h = cellHei ; | 1879 | h = cellHei ; |
1880 | int max = 0; | 1880 | int max = 0; |
1881 | for ( i = 0; i < mCells.count(); ++i) { | 1881 | for ( i = 0; i < mCells.count(); ++i) { |
1882 | //qDebug("iii %d ", i); | 1882 | //qDebug("iii %d ", i); |
1883 | w = colWid; | 1883 | w = colWid; |
1884 | if ( ((i) % 7) >= 7-colModulo ) { | 1884 | if ( ((i) % 7) >= 7-colModulo ) { |
1885 | ++w; | 1885 | ++w; |
1886 | } | 1886 | } |
1887 | if ( i == (6-rowModulo)*7) | 1887 | if ( i == (6-rowModulo)*7) |
1888 | ++h; | 1888 | ++h; |
1889 | if ( combinedSatSun ) { | 1889 | if ( combinedSatSun ) { |
1890 | if ( (i)%7 >= daysToShow-1 ) { | 1890 | if ( (i)%7 >= daysToShow-1 ) { |
1891 | if ( (i)%7 == daysToShow-1 ) { | 1891 | if ( (i)%7 == daysToShow-1 ) { |
1892 | w = width()-x-weeklabelwid; | 1892 | w = width()-x-weeklabelwid; |
1893 | max = h/2; | 1893 | max = h/2; |
1894 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1894 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1895 | x -= w ;y += h/2; | 1895 | x -= w ;y += h/2; |
1896 | } else { | 1896 | } else { |
1897 | w = width()-x-weeklabelwid; | 1897 | w = width()-x-weeklabelwid; |
1898 | max = h-h/2; | 1898 | max = h-h/2; |
1899 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); | 1899 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); |
1900 | y -= h/2; | 1900 | y -= h/2; |
1901 | } | 1901 | } |
1902 | } else { | 1902 | } else { |
1903 | max = h; | 1903 | max = h; |
1904 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1904 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | } | 1907 | } |
1908 | else { | 1908 | else { |
1909 | max = h; | 1909 | max = h; |
1910 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1910 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1911 | } | 1911 | } |
1912 | x += w; | 1912 | x += w; |
1913 | if ( x + w/2 > wid ) { | 1913 | if ( x + w/2 > wid ) { |
1914 | x = 0; | 1914 | x = 0; |
1915 | y += h; | 1915 | y += h; |
1916 | } | 1916 | } |
1917 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); | 1917 | //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); |
1918 | } | 1918 | } |
1919 | y= dayLabelHei; | 1919 | y= dayLabelHei; |
1920 | h = cellHei ; | 1920 | h = cellHei ; |
1921 | for ( i = 0; i < 6; i++) { | 1921 | for ( i = 0; i < 6; i++) { |
1922 | if ( i == (6-rowModulo)) | 1922 | if ( i == (6-rowModulo)) |
1923 | ++h; | 1923 | ++h; |
1924 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1924 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1925 | y += h; | 1925 | y += h; |
1926 | } | 1926 | } |
1927 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1927 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1928 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1928 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1929 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1929 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1930 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; | 1930 | mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; |
1931 | updateDayLabels(); | 1931 | updateDayLabels(); |
1932 | //bool forceUpdate = !updatePossible; | 1932 | //bool forceUpdate = !updatePossible; |
1933 | updatePossible = true; | 1933 | updatePossible = true; |
1934 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1934 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1935 | } | 1935 | } |
1936 | 1936 | ||
1937 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1937 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1938 | { | 1938 | { |
1939 | if( incidence ) | 1939 | if( incidence ) |
1940 | mContextMenu->showIncidencePopup(incidence); | 1940 | mContextMenu->showIncidencePopup(incidence); |
1941 | else { | 1941 | else { |
1942 | //qDebug("KOMonthView::showContextMenu "); | 1942 | //qDebug("KOMonthView::showContextMenu "); |
1943 | mNewItemMenu->popup(QCursor::pos()); | 1943 | mNewItemMenu->popup(QCursor::pos()); |
1944 | } | 1944 | } |
1945 | /* | 1945 | /* |
1946 | if( incidence && incidence->type() == "Event" ) { | 1946 | if( incidence && incidence->typeID() == eventID ) { |
1947 | Event *event = static_cast<Event *>(incidence); | 1947 | Event *event = static_cast<Event *>(incidence); |
1948 | mContextMenu->showEventPopup(event); | 1948 | mContextMenu->showEventPopup(event); |
1949 | } else { | 1949 | } else { |
1950 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1950 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1951 | } | 1951 | } |
1952 | */ | 1952 | */ |
1953 | } | 1953 | } |
1954 | MonthViewCell * KOMonthView::selectedCell( ) | 1954 | MonthViewCell * KOMonthView::selectedCell( ) |
1955 | { | 1955 | { |
1956 | return mSelectedCell; | 1956 | return mSelectedCell; |
1957 | } | 1957 | } |
1958 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1958 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1959 | { | 1959 | { |
1960 | //qDebug("KOMonthView::setSelectedCell %d", cell); | 1960 | //qDebug("KOMonthView::setSelectedCell %d", cell); |
1961 | if ( mSelectedCell && mSelectedCell != cell ) { | 1961 | if ( mSelectedCell && mSelectedCell != cell ) { |
1962 | MonthViewCell * mvc = mSelectedCell; | 1962 | MonthViewCell * mvc = mSelectedCell; |
1963 | mSelectedCell = cell; | 1963 | mSelectedCell = cell; |
1964 | mvc->deselect(); | 1964 | mvc->deselect(); |
1965 | } else | 1965 | } else |
1966 | mSelectedCell = cell; | 1966 | mSelectedCell = cell; |
1967 | // if ( mSelectedCell ) | 1967 | // if ( mSelectedCell ) |
1968 | // mSelectedCell->select(); | 1968 | // mSelectedCell->select(); |
1969 | if ( !mSelectedCell ) | 1969 | if ( !mSelectedCell ) |
1970 | emit incidenceSelected( 0 ); | 1970 | emit incidenceSelected( 0 ); |
1971 | else | 1971 | else |
1972 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1972 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1973 | } | 1973 | } |
1974 | 1974 | ||
1975 | void KOMonthView::processSelectionChange() | 1975 | void KOMonthView::processSelectionChange() |
1976 | { | 1976 | { |
1977 | QPtrList<Incidence> incidences = selectedIncidences(); | 1977 | QPtrList<Incidence> incidences = selectedIncidences(); |
1978 | if (incidences.count() > 0) { | 1978 | if (incidences.count() > 0) { |
1979 | emit incidenceSelected( incidences.first() ); | 1979 | emit incidenceSelected( incidences.first() ); |
1980 | } else { | 1980 | } else { |
1981 | emit incidenceSelected( 0 ); | 1981 | emit incidenceSelected( 0 ); |
1982 | clearSelection(); | 1982 | clearSelection(); |
1983 | } | 1983 | } |
1984 | } | 1984 | } |
1985 | 1985 | ||
1986 | void KOMonthView::clearSelection() | 1986 | void KOMonthView::clearSelection() |
1987 | { | 1987 | { |
1988 | if ( mSelectedCell ) { | 1988 | if ( mSelectedCell ) { |
1989 | mSelectedCell->deselect(); | 1989 | mSelectedCell->deselect(); |
1990 | mSelectedCell = 0; | 1990 | mSelectedCell = 0; |
1991 | } | 1991 | } |
1992 | } | 1992 | } |
1993 | 1993 | ||
1994 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) | 1994 | void KOMonthView::keyReleaseEvent ( QKeyEvent * e) |
1995 | { | 1995 | { |
1996 | if ( !e->isAutoRepeat() ) { | 1996 | if ( !e->isAutoRepeat() ) { |
1997 | mFlagKeyPressed = false; | 1997 | mFlagKeyPressed = false; |
1998 | } | 1998 | } |
1999 | } | 1999 | } |
2000 | 2000 | ||
2001 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 2001 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
2002 | { | 2002 | { |
2003 | 2003 | ||
2004 | qApp->processEvents(); | 2004 | qApp->processEvents(); |
2005 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { | 2005 | if ( e->isAutoRepeat() && !mFlagKeyPressed ) { |
2006 | //e->ignore(); | 2006 | //e->ignore(); |
2007 | e->accept(); | 2007 | e->accept(); |
2008 | return; | 2008 | return; |
2009 | } | 2009 | } |
2010 | if (! e->isAutoRepeat() ) | 2010 | if (! e->isAutoRepeat() ) |
2011 | mFlagKeyPressed = true; | 2011 | mFlagKeyPressed = true; |
2012 | switch(e->key()) { | 2012 | switch(e->key()) { |
2013 | case Key_Up: | 2013 | case Key_Up: |
2014 | { | 2014 | { |
2015 | if ( mShowWeekView ) { | 2015 | if ( mShowWeekView ) { |
2016 | emit selectWeekNum ( currentWeek() - 1 ); | 2016 | emit selectWeekNum ( currentWeek() - 1 ); |
2017 | } | 2017 | } |
2018 | else { | 2018 | else { |
2019 | emit prevMonth(); | 2019 | emit prevMonth(); |
2020 | } | 2020 | } |
2021 | } | 2021 | } |
2022 | e->accept(); | 2022 | e->accept(); |
2023 | break; | 2023 | break; |
2024 | case Key_Down: | 2024 | case Key_Down: |
2025 | { | 2025 | { |
2026 | if ( mShowWeekView ) { | 2026 | if ( mShowWeekView ) { |
2027 | emit selectWeekNum ( currentWeek() +1); | 2027 | emit selectWeekNum ( currentWeek() +1); |
2028 | } | 2028 | } |
2029 | else { | 2029 | else { |
2030 | emit nextMonth(); | 2030 | emit nextMonth(); |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | } | 2033 | } |
2034 | e->accept(); | 2034 | e->accept(); |
2035 | break; | 2035 | break; |
2036 | case Key_Return: | 2036 | case Key_Return: |
2037 | case Key_Enter: | 2037 | case Key_Enter: |
2038 | { | 2038 | { |
2039 | selectInternalWeekNum ( currentWeek() ); | 2039 | selectInternalWeekNum ( currentWeek() ); |
2040 | } | 2040 | } |
2041 | e->accept(); | 2041 | e->accept(); |
2042 | break; | 2042 | break; |
2043 | case Key_D: | 2043 | case Key_D: |
2044 | if ( mSelectedCell ) { | 2044 | if ( mSelectedCell ) { |
2045 | mSelectedCell->showDay(); | 2045 | mSelectedCell->showDay(); |
2046 | e->accept(); | 2046 | e->accept(); |
2047 | } else { | 2047 | } else { |
2048 | e->ignore(); | 2048 | e->ignore(); |
2049 | } | 2049 | } |
2050 | break; | 2050 | break; |
2051 | default: | 2051 | default: |
2052 | e->ignore(); | 2052 | e->ignore(); |
2053 | break; | 2053 | break; |
2054 | } | 2054 | } |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void KOMonthView::nextCell() | 2057 | void KOMonthView::nextCell() |
2058 | { | 2058 | { |
2059 | bool res = focusNextPrevChild ( true ); | 2059 | bool res = focusNextPrevChild ( true ); |
2060 | } | 2060 | } |
2061 | void KOMonthView::prevCell() | 2061 | void KOMonthView::prevCell() |
2062 | { | 2062 | { |
2063 | focusNextPrevChild ( false ); | 2063 | focusNextPrevChild ( false ); |
2064 | } | 2064 | } |
2065 | 2065 | ||
2066 | void KOMonthView::slotNewTodo() | 2066 | void KOMonthView::slotNewTodo() |
2067 | { | 2067 | { |
2068 | //qDebug("KOMonthView::slotNewTodo() "); | 2068 | //qDebug("KOMonthView::slotNewTodo() "); |
2069 | if ( mPopupCell ){ | 2069 | if ( mPopupCell ){ |
2070 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2070 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2071 | emit newTodoSignal(dt,true); | 2071 | emit newTodoSignal(dt,true); |
2072 | } | 2072 | } |
2073 | mPopupCell = 0; | 2073 | mPopupCell = 0; |
2074 | } | 2074 | } |
2075 | void KOMonthView::slotNewEvent() | 2075 | void KOMonthView::slotNewEvent() |
2076 | { | 2076 | { |
2077 | if ( mPopupCell ) { | 2077 | if ( mPopupCell ) { |
2078 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 2078 | QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
2079 | emit newEventSignal( dt ); | 2079 | emit newEventSignal( dt ); |
2080 | } | 2080 | } |
2081 | //qDebug("KOMonthView::slotNewEvent() "); | 2081 | //qDebug("KOMonthView::slotNewEvent() "); |
2082 | mPopupCell = 0; | 2082 | mPopupCell = 0; |
2083 | } | 2083 | } |
2084 | 2084 | ||
2085 | void KOMonthView::slotEditJournal() | 2085 | void KOMonthView::slotEditJournal() |
2086 | { | 2086 | { |
2087 | if ( mPopupCell ) | 2087 | if ( mPopupCell ) |
2088 | emit showJournalSignal( 7, mPopupCell->date() ); | 2088 | emit showJournalSignal( 7, mPopupCell->date() ); |
2089 | //qDebug("KOMonthView::slotEditJournal() "); | 2089 | //qDebug("KOMonthView::slotEditJournal() "); |
2090 | mPopupCell = 0; | 2090 | mPopupCell = 0; |
2091 | } | 2091 | } |
2092 | 2092 | ||
2093 | void KOMonthView::setPopupCell( MonthViewCell * c) | 2093 | void KOMonthView::setPopupCell( MonthViewCell * c) |
2094 | { | 2094 | { |
2095 | mPopupCell = c; | 2095 | mPopupCell = c; |
2096 | } | 2096 | } |
diff --git a/korganizer/outgoingdialog.cpp b/korganizer/outgoingdialog.cpp index 0fc90c4..7253c8e 100644 --- a/korganizer/outgoingdialog.cpp +++ b/korganizer/outgoingdialog.cpp | |||
@@ -1,393 +1,393 @@ | |||
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 <kdebug.h> | 20 | #include <kdebug.h> |
21 | 21 | ||
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qdir.h> | 23 | #include <qdir.h> |
24 | #include <qtextstream.h> | 24 | #include <qtextstream.h> |
25 | 25 | ||
26 | #include <kglobal.h> | 26 | #include <kglobal.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <ktempfile.h> | 28 | #include <ktempfile.h> |
29 | #include <kstandarddirs.h> | 29 | #include <kstandarddirs.h> |
30 | 30 | ||
31 | #include <libkcal/event.h> | 31 | #include <libkcal/event.h> |
32 | #include <libkcal/freebusy.h> | 32 | #include <libkcal/freebusy.h> |
33 | //#include <libkcal/imipscheduler.h> | 33 | //#include <libkcal/imipscheduler.h> |
34 | #include <libkcal/dummyscheduler.h> | 34 | #include <libkcal/dummyscheduler.h> |
35 | #include <libkcal/icalformat.h> | 35 | #include <libkcal/icalformat.h> |
36 | #include <libkcal/calendar.h> | 36 | #include <libkcal/calendar.h> |
37 | 37 | ||
38 | #ifndef KORG_NOMAIL | 38 | #ifndef KORG_NOMAIL |
39 | #include "mailscheduler.h" | 39 | #include "mailscheduler.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include "koprefs.h" | 42 | #include "koprefs.h" |
43 | #include "outgoingdialog.h" | 43 | #include "outgoingdialog.h" |
44 | #include "koeventviewerdialog.h" | 44 | #include "koeventviewerdialog.h" |
45 | #include "docprefs.h" | 45 | #include "docprefs.h" |
46 | 46 | ||
47 | ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev, | 47 | ScheduleItemOut::ScheduleItemOut(QListView *parent,IncidenceBase *ev, |
48 | Scheduler::Method method, | 48 | Scheduler::Method method, |
49 | const QString &recipients) | 49 | const QString &recipients) |
50 | : QListViewItem(parent) | 50 | : QListViewItem(parent) |
51 | { | 51 | { |
52 | mIncidence = ev; | 52 | mIncidence = ev; |
53 | mMethod = method; | 53 | mMethod = method; |
54 | mRecipients = recipients; | 54 | mRecipients = recipients; |
55 | 55 | ||
56 | // kdDebug() << "ScheduleItemOut: setting the summary" << endl; | 56 | // kdDebug() << "ScheduleItemOut: setting the summary" << endl; |
57 | //Set the summary | 57 | //Set the summary |
58 | if(ev->type() != "FreeBusy") { | 58 | if(ev->typeID() != freebusyID ) { |
59 | Incidence *incidence = static_cast<Incidence *>(ev); | 59 | Incidence *incidence = static_cast<Incidence *>(ev); |
60 | setText(0,incidence->summary()); | 60 | setText(0,incidence->summary()); |
61 | } else { | 61 | } else { |
62 | setText(0,i18n("Free Busy Object")); | 62 | setText(0,i18n("Free Busy Object")); |
63 | } | 63 | } |
64 | 64 | ||
65 | // kdDebug() << "ScheduleItemOut: checking if the object is an event" << endl; | 65 | // kdDebug() << "ScheduleItemOut: checking if the object is an event" << endl; |
66 | //If the object is an event | 66 | //If the object is an event |
67 | if(ev->type()=="Event") { | 67 | if(ev->typeID()== eventID ) { |
68 | Event *event = static_cast<Event *>(ev); | 68 | Event *event = static_cast<Event *>(ev); |
69 | 69 | ||
70 | setText(1,event->dtStartDateStr()); | 70 | setText(1,event->dtStartDateStr()); |
71 | if (event->doesFloat()) { //If the event floats set the start and end times to no time | 71 | if (event->doesFloat()) { //If the event floats set the start and end times to no time |
72 | setText(2,i18n("no time")); | 72 | setText(2,i18n("no time")); |
73 | setText(4,i18n("no time")); | 73 | setText(4,i18n("no time")); |
74 | } else { //If it does not float | 74 | } else { //If it does not float |
75 | setText(2,event->dtStartTimeStr()); | 75 | setText(2,event->dtStartTimeStr()); |
76 | if (event->hasDuration()) { | 76 | if (event->hasDuration()) { |
77 | setText(4,event->dtEndTimeStr()); | 77 | setText(4,event->dtEndTimeStr()); |
78 | } else { | 78 | } else { |
79 | setText(4,i18n("no time")); | 79 | setText(4,i18n("no time")); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | if (event->hasEndDate()) { | 82 | if (event->hasEndDate()) { |
83 | setText(3,event->dtEndDateStr()); | 83 | setText(3,event->dtEndDateStr()); |
84 | } | 84 | } |
85 | else { | 85 | else { |
86 | setText(3,i18n("no time")); | 86 | setText(3,i18n("no time")); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | //If the object is an Todo | 90 | //If the object is an Todo |
91 | if(ev->type()=="Todo") { | 91 | if(ev->typeID() == todoID ) { |
92 | Todo *event = static_cast<Todo *>(ev); | 92 | Todo *event = static_cast<Todo *>(ev); |
93 | if (event->hasStartDate()) { | 93 | if (event->hasStartDate()) { |
94 | setText(1,event->dtStartDateStr()); | 94 | setText(1,event->dtStartDateStr()); |
95 | if (!event->doesFloat()) { | 95 | if (!event->doesFloat()) { |
96 | setText(2,event->dtStartTimeStr()); | 96 | setText(2,event->dtStartTimeStr()); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | if (event->hasDueDate()) { | 99 | if (event->hasDueDate()) { |
100 | setText(3,event->dtDueDateStr()); | 100 | setText(3,event->dtDueDateStr()); |
101 | if (!event->doesFloat()) { | 101 | if (!event->doesFloat()) { |
102 | setText(4,event->dtDueTimeStr()); | 102 | setText(4,event->dtDueTimeStr()); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | // kdDebug() << "ScheduleItemOut: checking if the object is a FreeBusy object" << endl; | 107 | // kdDebug() << "ScheduleItemOut: checking if the object is a FreeBusy object" << endl; |
108 | //If the object is a freebusy object | 108 | //If the object is a freebusy object |
109 | if(ev->type() == "FreeBusy") { | 109 | if(ev->typeID() == freebusyID ) { |
110 | FreeBusy *freebusy = static_cast<FreeBusy *>(ev); | 110 | FreeBusy *freebusy = static_cast<FreeBusy *>(ev); |
111 | 111 | ||
112 | setText(1,freebusy->dtStartDateStr()); | 112 | setText(1,freebusy->dtStartDateStr()); |
113 | setText(2,freebusy->dtStartTimeStr()); | 113 | setText(2,freebusy->dtStartTimeStr()); |
114 | //Must try and get this to the users local settings | 114 | //Must try and get this to the users local settings |
115 | setText(3,KGlobal::locale()->formatDate( freebusy->dtEnd().date() ) ); | 115 | setText(3,KGlobal::locale()->formatDate( freebusy->dtEnd().date() ) ); |
116 | setText(4,KGlobal::locale()->formatTime( freebusy->dtEnd().time() ) ); | 116 | setText(4,KGlobal::locale()->formatTime( freebusy->dtEnd().time() ) ); |
117 | } | 117 | } |
118 | 118 | ||
119 | // kdDebug() << "ScheduleItemOut: Setting the method" << endl; | 119 | // kdDebug() << "ScheduleItemOut: Setting the method" << endl; |
120 | //Set the Method | 120 | //Set the Method |
121 | setText(5,Scheduler::translatedMethodName(mMethod)); | 121 | setText(5,Scheduler::translatedMethodName(mMethod)); |
122 | } | 122 | } |
123 | 123 | ||
124 | OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent, | 124 | OutgoingDialog::OutgoingDialog(Calendar *calendar,QWidget* parent, |
125 | const char* name,bool modal, | 125 | const char* name,bool modal, |
126 | WFlags fl) | 126 | WFlags fl) |
127 | : OutgoingDialog_base(parent,name,modal,fl) | 127 | : OutgoingDialog_base(parent,name,modal,fl) |
128 | { | 128 | { |
129 | mCalendar = calendar; | 129 | mCalendar = calendar; |
130 | 130 | ||
131 | mFormat = new ICalFormat; | 131 | mFormat = new ICalFormat; |
132 | 132 | ||
133 | if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) { | 133 | if (KOPrefs::instance()->mIMIPScheduler == KOPrefs::IMIPDummy ) { |
134 | mScheduler = new DummyScheduler(mCalendar); | 134 | mScheduler = new DummyScheduler(mCalendar); |
135 | } else { | 135 | } else { |
136 | #ifndef KORG_NOMAIL | 136 | #ifndef KORG_NOMAIL |
137 | mScheduler = new MailScheduler(mCalendar); | 137 | mScheduler = new MailScheduler(mCalendar); |
138 | #else | 138 | #else |
139 | mScheduler = new DummyScheduler(mCalendar); | 139 | mScheduler = new DummyScheduler(mCalendar); |
140 | #endif | 140 | #endif |
141 | } | 141 | } |
142 | mMessageListView->setColumnAlignment(1,AlignHCenter); | 142 | mMessageListView->setColumnAlignment(1,AlignHCenter); |
143 | mMessageListView->setColumnAlignment(2,AlignHCenter); | 143 | mMessageListView->setColumnAlignment(2,AlignHCenter); |
144 | mMessageListView->setColumnAlignment(3,AlignHCenter); | 144 | mMessageListView->setColumnAlignment(3,AlignHCenter); |
145 | mMessageListView->setColumnAlignment(4,AlignHCenter); | 145 | mMessageListView->setColumnAlignment(4,AlignHCenter); |
146 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), | 146 | QObject::connect(mMessageListView,SIGNAL(doubleClicked(QListViewItem *)), |
147 | this,SLOT(showEvent(QListViewItem *))); | 147 | this,SLOT(showEvent(QListViewItem *))); |
148 | mDocPrefs = new DocPrefs("groupschedule"); | 148 | mDocPrefs = new DocPrefs("groupschedule"); |
149 | loadMessages(); | 149 | loadMessages(); |
150 | } | 150 | } |
151 | 151 | ||
152 | OutgoingDialog::~OutgoingDialog() | 152 | OutgoingDialog::~OutgoingDialog() |
153 | { | 153 | { |
154 | delete mDocPrefs; | 154 | delete mDocPrefs; |
155 | delete mFormat; | 155 | delete mFormat; |
156 | } | 156 | } |
157 | 157 | ||
158 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method) | 158 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method) |
159 | { | 159 | { |
160 | kdDebug() << "Outgoing::addMessage" << "Method:" << method << endl; | 160 | kdDebug() << "Outgoing::addMessage" << "Method:" << method << endl; |
161 | if (method == Scheduler::Publish) return false; | 161 | if (method == Scheduler::Publish) return false; |
162 | if( mDocPrefs ) { | 162 | if( mDocPrefs ) { |
163 | if (method != Scheduler::Cancel) { | 163 | if (method != Scheduler::Cancel) { |
164 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); | 164 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); |
165 | } else { | 165 | } else { |
166 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) | 166 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) |
167 | return true; | 167 | return true; |
168 | } | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { | 171 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { |
172 | new ScheduleItemOut(mMessageListView,incidence,method); | 172 | new ScheduleItemOut(mMessageListView,incidence,method); |
173 | saveMessage(incidence,method); | 173 | saveMessage(incidence,method); |
174 | emit numMessagesChanged(mMessageListView->childCount()); | 174 | emit numMessagesChanged(mMessageListView->childCount()); |
175 | } | 175 | } |
176 | else { | 176 | else { |
177 | mScheduler->performTransaction(incidence,method); | 177 | mScheduler->performTransaction(incidence,method); |
178 | } | 178 | } |
179 | return true; | 179 | return true; |
180 | } | 180 | } |
181 | 181 | ||
182 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method, | 182 | bool OutgoingDialog::addMessage(IncidenceBase *incidence,Scheduler::Method method, |
183 | const QString &recipients) | 183 | const QString &recipients) |
184 | { | 184 | { |
185 | //if (method != Scheduler::Publish) return false; | 185 | //if (method != Scheduler::Publish) return false; |
186 | if( mDocPrefs ) { | 186 | if( mDocPrefs ) { |
187 | if (method != Scheduler::Cancel) { | 187 | if (method != Scheduler::Cancel) { |
188 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); | 188 | mDocPrefs->writeEntry( incidence->uid()+"-scheduled", true ); |
189 | } else { | 189 | } else { |
190 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) | 190 | if (!mDocPrefs->readBoolEntry(incidence->uid()+"-scheduled") ) |
191 | return true; | 191 | return true; |
192 | } | 192 | } |
193 | } | 193 | } |
194 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { | 194 | if (KOPrefs::instance()->mIMIPSend == KOPrefs::IMIPOutbox) { |
195 | new ScheduleItemOut(mMessageListView,incidence,method,recipients); | 195 | new ScheduleItemOut(mMessageListView,incidence,method,recipients); |
196 | saveMessage(incidence,method,recipients); | 196 | saveMessage(incidence,method,recipients); |
197 | emit numMessagesChanged(mMessageListView->childCount()); | 197 | emit numMessagesChanged(mMessageListView->childCount()); |
198 | } | 198 | } |
199 | else { | 199 | else { |
200 | mScheduler->performTransaction(incidence,method,recipients); | 200 | mScheduler->performTransaction(incidence,method,recipients); |
201 | } | 201 | } |
202 | return true; | 202 | return true; |
203 | } | 203 | } |
204 | 204 | ||
205 | void OutgoingDialog::send() | 205 | void OutgoingDialog::send() |
206 | { | 206 | { |
207 | kdDebug() << "OutgoingDialog::send" << endl; | 207 | kdDebug() << "OutgoingDialog::send" << endl; |
208 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild()); | 208 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->firstChild()); |
209 | while(item) { | 209 | while(item) { |
210 | bool success; | 210 | bool success; |
211 | if (item->method() == Scheduler::Publish) { | 211 | if (item->method() == Scheduler::Publish) { |
212 | success = mScheduler->publish(item->event(),item->recipients()); | 212 | success = mScheduler->publish(item->event(),item->recipients()); |
213 | } else { | 213 | } else { |
214 | success = mScheduler->performTransaction(item->event(),item->method()); | 214 | success = mScheduler->performTransaction(item->event(),item->method()); |
215 | } | 215 | } |
216 | ScheduleItemOut *oldItem = item; | 216 | ScheduleItemOut *oldItem = item; |
217 | item = (ScheduleItemOut *)(item->nextSibling()); | 217 | item = (ScheduleItemOut *)(item->nextSibling()); |
218 | if (success) { | 218 | if (success) { |
219 | deleteMessage(oldItem->event()); | 219 | deleteMessage(oldItem->event()); |
220 | delete (oldItem->event()); | 220 | delete (oldItem->event()); |
221 | delete oldItem; | 221 | delete oldItem; |
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | emit numMessagesChanged(mMessageListView->childCount()); | 225 | emit numMessagesChanged(mMessageListView->childCount()); |
226 | } | 226 | } |
227 | 227 | ||
228 | void OutgoingDialog::deleteItem() | 228 | void OutgoingDialog::deleteItem() |
229 | { | 229 | { |
230 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->selectedItem()); | 230 | ScheduleItemOut *item = (ScheduleItemOut *)(mMessageListView->selectedItem()); |
231 | if(!item) | 231 | if(!item) |
232 | return; | 232 | return; |
233 | deleteMessage(item->event()); | 233 | deleteMessage(item->event()); |
234 | delete(item->event()); | 234 | delete(item->event()); |
235 | mMessageListView->takeItem(item); | 235 | mMessageListView->takeItem(item); |
236 | emit numMessagesChanged(mMessageListView->childCount()); | 236 | emit numMessagesChanged(mMessageListView->childCount()); |
237 | } | 237 | } |
238 | 238 | ||
239 | void OutgoingDialog::showEvent(QListViewItem *qitem) | 239 | void OutgoingDialog::showEvent(QListViewItem *qitem) |
240 | { | 240 | { |
241 | ScheduleItemOut *item = (ScheduleItemOut *)qitem; | 241 | ScheduleItemOut *item = (ScheduleItemOut *)qitem; |
242 | Event *event = 0; | 242 | Event *event = 0; |
243 | Todo *todo = 0; | 243 | Todo *todo = 0; |
244 | if ( item->event()->type()=="Event" ) { | 244 | if ( item->event()->typeID() == eventID ) { |
245 | event = static_cast<Event *>(item->event()); | 245 | event = static_cast<Event *>(item->event()); |
246 | } | 246 | } |
247 | if ( item->event()->type()=="Todo" ) { | 247 | if ( item->event()->typeID() == todoID ) { |
248 | todo = static_cast<Todo *>(item->event()); | 248 | todo = static_cast<Todo *>(item->event()); |
249 | } | 249 | } |
250 | QString sendText; | 250 | QString sendText; |
251 | if (event || todo) { | 251 | if (event || todo) { |
252 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); | 252 | KOEventViewerDialog *eventViewer = new KOEventViewerDialog(this); |
253 | if (event) eventViewer->setEvent(event); | 253 | if (event) eventViewer->setEvent(event); |
254 | if (todo) eventViewer->setTodo(todo); | 254 | if (todo) eventViewer->setTodo(todo); |
255 | sendText = "<hr><h4>"+i18n("Event will be sent to:")+"</h4>"; | 255 | sendText = "<hr><h4>"+i18n("Event will be sent to:")+"</h4>"; |
256 | switch (item->method()) { | 256 | switch (item->method()) { |
257 | case Scheduler::Publish: { | 257 | case Scheduler::Publish: { |
258 | sendText += item->recipients(); | 258 | sendText += item->recipients(); |
259 | break; } | 259 | break; } |
260 | case Scheduler::Request: { | 260 | case Scheduler::Request: { |
261 | sendText += i18n("All attendees"); | 261 | sendText += i18n("All attendees"); |
262 | break; } | 262 | break; } |
263 | case Scheduler::Refresh: { | 263 | case Scheduler::Refresh: { |
264 | sendText += i18n("All attendees"); | 264 | sendText += i18n("All attendees"); |
265 | break; } | 265 | break; } |
266 | case Scheduler::Cancel: { | 266 | case Scheduler::Cancel: { |
267 | sendText += i18n("All attendees"); | 267 | sendText += i18n("All attendees"); |
268 | break; } | 268 | break; } |
269 | case Scheduler::Add: { | 269 | case Scheduler::Add: { |
270 | sendText += i18n("All attendees"); | 270 | sendText += i18n("All attendees"); |
271 | break; } | 271 | break; } |
272 | case Scheduler::Reply: { | 272 | case Scheduler::Reply: { |
273 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); | 273 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); |
274 | break; } | 274 | break; } |
275 | case Scheduler::Counter: { | 275 | case Scheduler::Counter: { |
276 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); | 276 | sendText += i18n("The organizer %1").arg(item->event()->organizer()); |
277 | break; } | 277 | break; } |
278 | case Scheduler::Declinecounter: { | 278 | case Scheduler::Declinecounter: { |
279 | sendText += i18n("All attendees"); | 279 | sendText += i18n("All attendees"); |
280 | break; } | 280 | break; } |
281 | case Scheduler::NoMethod: { | 281 | case Scheduler::NoMethod: { |
282 | sendText += ""; | 282 | sendText += ""; |
283 | break; } | 283 | break; } |
284 | default: | 284 | default: |
285 | sendText = ""; | 285 | sendText = ""; |
286 | } | 286 | } |
287 | eventViewer->addText(sendText); | 287 | eventViewer->addText(sendText); |
288 | eventViewer->show(); | 288 | eventViewer->show(); |
289 | } | 289 | } |
290 | } | 290 | } |
291 | 291 | ||
292 | bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method, | 292 | bool OutgoingDialog::saveMessage(IncidenceBase *incidence,Scheduler::Method method, |
293 | const QString &recipients) | 293 | const QString &recipients) |
294 | { | 294 | { |
295 | KTempFile ktfile(locateLocal("data","korganizer/outgoing/"),"ics"); | 295 | KTempFile ktfile(locateLocal("data","korganizer/outgoing/"),"ics"); |
296 | QString messageText = mFormat->createScheduleMessage(incidence,method); | 296 | QString messageText = mFormat->createScheduleMessage(incidence,method); |
297 | QTextStream *qts = ktfile.textStream(); | 297 | QTextStream *qts = ktfile.textStream(); |
298 | *qts << messageText; | 298 | *qts << messageText; |
299 | *qts << "METHOD-BEGIN:" << endl << method << endl << ":METHOD-END" << endl; | 299 | *qts << "METHOD-BEGIN:" << endl << method << endl << ":METHOD-END" << endl; |
300 | *qts << "RECIPIENTS-BEGIN:" << endl << recipients << endl << ":RECIPIENTS-END" << endl; | 300 | *qts << "RECIPIENTS-BEGIN:" << endl << recipients << endl << ":RECIPIENTS-END" << endl; |
301 | mMessageMap[incidence]=ktfile.name(); | 301 | mMessageMap[incidence]=ktfile.name(); |
302 | 302 | ||
303 | return true; | 303 | return true; |
304 | } | 304 | } |
305 | 305 | ||
306 | bool OutgoingDialog::deleteMessage(IncidenceBase *incidence) | 306 | bool OutgoingDialog::deleteMessage(IncidenceBase *incidence) |
307 | { | 307 | { |
308 | QFile f( mMessageMap[incidence] ); | 308 | QFile f( mMessageMap[incidence] ); |
309 | mMessageMap.remove(incidence); | 309 | mMessageMap.remove(incidence); |
310 | if ( !f.exists() ) return false; | 310 | if ( !f.exists() ) return false; |
311 | else | 311 | else |
312 | return f.remove(); | 312 | return f.remove(); |
313 | } | 313 | } |
314 | 314 | ||
315 | void OutgoingDialog::loadMessages() | 315 | void OutgoingDialog::loadMessages() |
316 | { | 316 | { |
317 | Scheduler::Method method; | 317 | Scheduler::Method method; |
318 | QString recipients; | 318 | QString recipients; |
319 | 319 | ||
320 | QString outgoingDirName = locateLocal("data","korganizer/outgoing"); | 320 | QString outgoingDirName = locateLocal("data","korganizer/outgoing"); |
321 | QDir outgoingDir(outgoingDirName); | 321 | QDir outgoingDir(outgoingDirName); |
322 | QStringList outgoing = outgoingDir.entryList(QDir::Files); | 322 | QStringList outgoing = outgoingDir.entryList(QDir::Files); |
323 | QStringList::ConstIterator it; | 323 | QStringList::ConstIterator it; |
324 | for(it = outgoing.begin(); it != outgoing.end(); ++it) { | 324 | for(it = outgoing.begin(); it != outgoing.end(); ++it) { |
325 | kdDebug() << "-- File: " << (*it) << endl; | 325 | kdDebug() << "-- File: " << (*it) << endl; |
326 | QFile f(outgoingDirName + "/" + (*it)); | 326 | QFile f(outgoingDirName + "/" + (*it)); |
327 | bool inserted = false; | 327 | bool inserted = false; |
328 | QMap<IncidenceBase*, QString>::Iterator iter; | 328 | QMap<IncidenceBase*, QString>::Iterator iter; |
329 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { | 329 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { |
330 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; | 330 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; |
331 | } | 331 | } |
332 | if (!inserted) { | 332 | if (!inserted) { |
333 | if (!f.open(IO_ReadOnly)) { | 333 | if (!f.open(IO_ReadOnly)) { |
334 | kdDebug() << "OutgoingDialog::loadMessage(): Can't open file'" | 334 | kdDebug() << "OutgoingDialog::loadMessage(): Can't open file'" |
335 | << (*it) << "'" << endl; | 335 | << (*it) << "'" << endl; |
336 | } else { | 336 | } else { |
337 | QTextStream t(&f); | 337 | QTextStream t(&f); |
338 | QString messageString = t.read(); | 338 | QString messageString = t.read(); |
339 | ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, | 339 | ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, |
340 | messageString); | 340 | messageString); |
341 | int begin_pos = messageString.find("METHOD-BEGIN:"); | 341 | int begin_pos = messageString.find("METHOD-BEGIN:"); |
342 | begin_pos = messageString.find('\n',begin_pos)+1; | 342 | begin_pos = messageString.find('\n',begin_pos)+1; |
343 | QString meth = messageString.mid(begin_pos,1); | 343 | QString meth = messageString.mid(begin_pos,1); |
344 | switch (meth.toInt()) { | 344 | switch (meth.toInt()) { |
345 | case 0:method=Scheduler::Publish; break; | 345 | case 0:method=Scheduler::Publish; break; |
346 | case 1:method=Scheduler::Request; break; | 346 | case 1:method=Scheduler::Request; break; |
347 | case 2:method=Scheduler::Refresh; break; | 347 | case 2:method=Scheduler::Refresh; break; |
348 | case 3:method=Scheduler::Cancel; break; | 348 | case 3:method=Scheduler::Cancel; break; |
349 | case 4:method=Scheduler::Add; break; | 349 | case 4:method=Scheduler::Add; break; |
350 | case 5:method=Scheduler::Reply; break; | 350 | case 5:method=Scheduler::Reply; break; |
351 | case 6:method=Scheduler::Counter; break; | 351 | case 6:method=Scheduler::Counter; break; |
352 | case 7:method=Scheduler::Declinecounter; break; | 352 | case 7:method=Scheduler::Declinecounter; break; |
353 | default :method=Scheduler::NoMethod; break; | 353 | default :method=Scheduler::NoMethod; break; |
354 | } | 354 | } |
355 | begin_pos = messageString.find("RECIPIENTS-BEGIN:"); | 355 | begin_pos = messageString.find("RECIPIENTS-BEGIN:"); |
356 | begin_pos = messageString.find('\n',begin_pos)+1; | 356 | begin_pos = messageString.find('\n',begin_pos)+1; |
357 | int end_pos = messageString.find(":RECIPIENTS-END",begin_pos)-1; | 357 | int end_pos = messageString.find(":RECIPIENTS-END",begin_pos)-1; |
358 | recipients = messageString.mid(begin_pos, end_pos-begin_pos); | 358 | recipients = messageString.mid(begin_pos, end_pos-begin_pos); |
359 | kdDebug() << "Outgoing::loadMessage(): Recipients: " << recipients << endl; | 359 | kdDebug() << "Outgoing::loadMessage(): Recipients: " << recipients << endl; |
360 | 360 | ||
361 | if (message) { | 361 | if (message) { |
362 | bool inserted = false; | 362 | bool inserted = false; |
363 | QMap<IncidenceBase*, QString>::Iterator iter; | 363 | QMap<IncidenceBase*, QString>::Iterator iter; |
364 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { | 364 | for ( iter = mMessageMap.begin(); iter != mMessageMap.end(); ++iter ) { |
365 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; | 365 | if (iter.data() == outgoingDirName + "/" + (*it)) inserted = true; |
366 | } | 366 | } |
367 | if (!inserted) { | 367 | if (!inserted) { |
368 | kdDebug() << "OutgoingDialog::loadMessage(): got message '" | 368 | kdDebug() << "OutgoingDialog::loadMessage(): got message '" |
369 | << (*it) << "'" << endl; | 369 | << (*it) << "'" << endl; |
370 | IncidenceBase *inc = message->event(); | 370 | IncidenceBase *inc = message->event(); |
371 | new ScheduleItemOut(mMessageListView,inc,method,recipients); | 371 | new ScheduleItemOut(mMessageListView,inc,method,recipients); |
372 | mMessageMap[message->event()]=outgoingDirName + "/" + (*it); | 372 | mMessageMap[message->event()]=outgoingDirName + "/" + (*it); |
373 | } | 373 | } |
374 | } else { | 374 | } else { |
375 | QString errorMessage; | 375 | QString errorMessage; |
376 | if (mFormat->exception()) { | 376 | if (mFormat->exception()) { |
377 | errorMessage = mFormat->exception()->message(); | 377 | errorMessage = mFormat->exception()->message(); |
378 | } | 378 | } |
379 | kdDebug() << "OutgoingDialog::loadMessage(): Error parsing " | 379 | kdDebug() << "OutgoingDialog::loadMessage(): Error parsing " |
380 | "message: " << errorMessage << endl; | 380 | "message: " << errorMessage << endl; |
381 | } | 381 | } |
382 | f.close(); | 382 | f.close(); |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | emit numMessagesChanged(mMessageListView->childCount()); | 386 | emit numMessagesChanged(mMessageListView->childCount()); |
387 | } | 387 | } |
388 | 388 | ||
389 | void OutgoingDialog::setDocumentId( const QString &id ) | 389 | void OutgoingDialog::setDocumentId( const QString &id ) |
390 | { | 390 | { |
391 | mDocPrefs->setDoc( id ); | 391 | mDocPrefs->setDoc( id ); |
392 | } | 392 | } |
393 | 393 | ||