summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeventviewer.cpp9
-rw-r--r--korganizer/komonthview.cpp4
-rw-r--r--libkcal/kincidenceformatter.cpp9
3 files changed, 12 insertions, 10 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index c8c2f28..6315827 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,797 +1,800 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#include <qprinter.h> 56#include <qprinter.h>
57#include <qpainter.h> 57#include <qpainter.h>
58#include <qpaintdevicemetrics.h> 58#include <qpaintdevicemetrics.h>
59#else //DESKTOP_VERSION 59#else //DESKTOP_VERSION
60#include <externalapphandler.h> 60#include <externalapphandler.h>
61#include <qtopia/qcopenvelope_qws.h> 61#include <qtopia/qcopenvelope_qws.h>
62#endif //DESKTOP_VERSION 62#endif //DESKTOP_VERSION
63 63
64KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 64KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
65 : QTextBrowser(parent,name) 65 : QTextBrowser(parent,name)
66{ 66{
67 mSyncMode = false; 67 mSyncMode = false;
68 mColorMode = 0; 68 mColorMode = 0;
69} 69}
70 70
71KOEventViewer::~KOEventViewer() 71KOEventViewer::~KOEventViewer()
72{ 72{
73} 73}
74 74
75void KOEventViewer::printMe() 75void KOEventViewer::printMe()
76{ 76{
77#ifdef DESKTOP_VERSION 77#ifdef DESKTOP_VERSION
78 78
79 KOPrintPrefs pp ( this ); 79 KOPrintPrefs pp ( this );
80 if (!pp.exec() ) 80 if (!pp.exec() )
81 return; 81 return;
82 int scaleval = pp.printMode() ; 82 int scaleval = pp.printMode() ;
83 83
84 QPrinter printer; 84 QPrinter printer;
85 if (!printer.setup() ) 85 if (!printer.setup() )
86 return; 86 return;
87 QPainter p; 87 QPainter p;
88 p.begin ( &printer ); 88 p.begin ( &printer );
89 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 89 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
90 float dx, dy; 90 float dx, dy;
91 int wid = (m.width() * 9)/10; 91 int wid = (m.width() * 9)/10;
92 dx = (float) wid/(float)contentsWidth (); 92 dx = (float) wid/(float)contentsWidth ();
93 dy = (float)(m.height()) / (float)contentsHeight (); 93 dy = (float)(m.height()) / (float)contentsHeight ();
94 float scale; 94 float scale;
95 // scale to fit the width or height of the paper 95 // scale to fit the width or height of the paper
96 if ( dx < dy ) 96 if ( dx < dy )
97 scale = dx; 97 scale = dx;
98 else 98 else
99 scale = dy; 99 scale = dy;
100 100
101 p.translate( m.width()/10,0 ); 101 p.translate( m.width()/10,0 );
102 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 102 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
103 p.scale( scale, scale ); 103 p.scale( scale, scale );
104 } 104 }
105 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 105 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
106 p.end(); 106 p.end();
107#endif 107#endif
108 108
109} 109}
110void KOEventViewer::setSource(const QString& n) 110void KOEventViewer::setSource(const QString& n)
111{ 111{
112 112
113 if ( n.left(3) == "uid" ) 113 if ( n.left(3) == "uid" )
114#ifdef DESKTOP_VERSION 114#ifdef DESKTOP_VERSION
115 { 115 {
116 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 116 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
117 KABC::AddressBook::Iterator it; 117 KABC::AddressBook::Iterator it;
118 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 118 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
119 // LR I do not understand, why the uid string is different on zaurus and desktop 119 // LR I do not understand, why the uid string is different on zaurus and desktop
120 QString uid = "uid://"+(*it).uid(); 120 QString uid = "uid://"+(*it).uid();
121 121
122 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 122 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
123 if (n == uid ) { 123 if (n == uid ) {
124 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 124 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
125 QDialog dia( this,"dia123", true ); 125 QDialog dia( this,"dia123", true );
126 dia.setCaption( i18n("Details of attendee") ); 126 dia.setCaption( i18n("Details of attendee") );
127 QVBoxLayout lay ( &dia ); 127 QVBoxLayout lay ( &dia );
128 KABC::AddresseeView av ( &dia ); 128 KABC::AddresseeView av ( &dia );
129 av.setAddressee( (*it) ); 129 av.setAddressee( (*it) );
130 lay.addWidget( &av ); 130 lay.addWidget( &av );
131 if ( QApplication::desktop()->width() < 480 ) 131 if ( QApplication::desktop()->width() < 480 )
132 dia.resize( 220, 240); 132 dia.resize( 220, 240);
133 else { 133 else {
134 dia.resize( 400,400); 134 dia.resize( 400,400);
135 } 135 }
136 dia.exec(); 136 dia.exec();
137 break; 137 break;
138 } 138 }
139 } 139 }
140 return; 140 return;
141 } 141 }
142#else 142#else
143 { 143 {
144 if ( "uid:organizer" == n ) { 144 if ( "uid:organizer" == n ) {
145 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 145 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
146 return; 146 return;
147 } 147 }
148 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 148 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
149 if (attendees.count()) { 149 if (attendees.count()) {
150 Attendee *a; 150 Attendee *a;
151 for(a=attendees.first();a;a=attendees.next()) { 151 for(a=attendees.first();a;a=attendees.next()) {
152 if ( "uid:"+a->uid() == n ) { 152 if ( "uid:"+a->uid() == n ) {
153 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 153 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
154 return; 154 return;
155 } 155 }
156 } 156 }
157 } 157 }
158 return; 158 return;
159 } 159 }
160 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 160 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
161 // the result should now arrive through method insertAttendees 161 // the result should now arrive through method insertAttendees
162 //QString uid = "uid:"+(*it).uid(); 162 //QString uid = "uid:"+(*it).uid();
163#endif 163#endif
164 if ( n.left(6) == "mailto" ) { 164 if ( n.left(6) == "mailto" ) {
165 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 165 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
166#ifndef DESKTOP_VERSION 166#ifndef DESKTOP_VERSION
167 if ( n.mid(7,3) == "ALL" ) { 167 if ( n.mid(7,3) == "ALL" ) {
168 mailToAttendees( true ); 168 mailToAttendees( true );
169 } else if ( n.mid(7,4) == "RSVP" ) { 169 } else if ( n.mid(7,4) == "RSVP" ) {
170 mailToAttendees( false ); 170 mailToAttendees( false );
171 } else { 171 } else {
172 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 172 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
173 e << n.mid(7); 173 e << n.mid(7);
174 } 174 }
175#endif 175#endif
176 176
177 } 177 }
178 178
179 179
180#ifndef KORG_NODCOP 180#ifndef KORG_NODCOP
181 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 181 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
182 QString tmpStr; 182 QString tmpStr;
183 if (n.startsWith("mailto:")) { 183 if (n.startsWith("mailto:")) {
184 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 184 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
185 //emit showIncidence(n); 185 //emit showIncidence(n);
186 return; 186 return;
187 } else if (n.startsWith("uid:")) { 187 } else if (n.startsWith("uid:")) {
188 DCOPClient *client = KApplication::kApplication()->dcopClient(); 188 DCOPClient *client = KApplication::kApplication()->dcopClient();
189 const QByteArray noParamData; 189 const QByteArray noParamData;
190 const QByteArray paramData; 190 const QByteArray paramData;
191 QByteArray replyData; 191 QByteArray replyData;
192 QCString replyTypeStr; 192 QCString replyTypeStr;
193#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 193#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
194 bool foundAbbrowser = PING_ABBROWSER; 194 bool foundAbbrowser = PING_ABBROWSER;
195 195
196 if (foundAbbrowser) { 196 if (foundAbbrowser) {
197 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 197 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
198 //client->send("kaddressbook","KAddressBookIface", 198 //client->send("kaddressbook","KAddressBookIface",
199 QDataStream arg(paramData, IO_WriteOnly); 199 QDataStream arg(paramData, IO_WriteOnly);
200 arg << n.mid(6); 200 arg << n.mid(6);
201 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 201 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
202 return; 202 return;
203 } else { 203 } else {
204 /* 204 /*
205 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 205 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
206 We start it without its main interface 206 We start it without its main interface
207 */ 207 */
208 KIconLoader* iconLoader = new KIconLoader(); 208 KIconLoader* iconLoader = new KIconLoader();
209 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 209 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
210 ActionManager::setStartedKAddressBook(true); 210 ActionManager::setStartedKAddressBook(true);
211 tmpStr = "kaddressbook --editor-only --uid "; 211 tmpStr = "kaddressbook --editor-only --uid ";
212 tmpStr += KProcess::quote(n.mid(6)); 212 tmpStr += KProcess::quote(n.mid(6));
213 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 213 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
214 return; 214 return;
215 } 215 }
216 } else { 216 } else {
217 //QTextBrowser::setSource(n); 217 //QTextBrowser::setSource(n);
218 } 218 }
219#endif 219#endif
220} 220}
221void KOEventViewer::mailToAttendees( bool all ) 221void KOEventViewer::mailToAttendees( bool all )
222{ 222{
223 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 223 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
224 if (attendees.count() == 0) return; 224 if (attendees.count() == 0) return;
225 QStringList nameList; 225 QStringList nameList;
226 QStringList emailList; 226 QStringList emailList;
227 QStringList uidList; 227 QStringList uidList;
228 Attendee* a; 228 Attendee* a;
229 for(a=attendees.first();a;a=attendees.next()) { 229 for(a=attendees.first();a;a=attendees.next()) {
230 if ( !all && !a->RSVP() ) continue; 230 if ( !all && !a->RSVP() ) continue;
231 if (!a->email().isEmpty()) { 231 if (!a->email().isEmpty()) {
232 nameList.append (a->name() ); 232 nameList.append (a->name() );
233 emailList.append (a->email() ); 233 emailList.append (a->email() );
234 uidList.append (a->uid() ); 234 uidList.append (a->uid() );
235 } 235 }
236 } 236 }
237 QString uid = "ComposeMailUIpick2"+mMailSubject; 237 QString uid = "ComposeMailUIpick2"+mMailSubject;
238#ifndef DESKTOP_VERSION 238#ifndef DESKTOP_VERSION
239 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 239 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
240#endif 240#endif
241 241
242} 242}
243void KOEventViewer::addTag(const QString & tag,const QString & text) 243void KOEventViewer::addTag(const QString & tag,const QString & text)
244{ 244{
245 int number=text.contains("\n"); 245 int number=text.contains("\n");
246 QString str = "<" + tag + ">"; 246 QString str = "<" + tag + ">";
247 QString tmpText=text; 247 QString tmpText=text;
248 QString tmpStr=str; 248 QString tmpStr=str;
249 if(number !=-1) 249 if(number !=-1)
250 { 250 {
251 if (number > 0) { 251 if (number > 0) {
252 int pos=0; 252 int pos=0;
253 QString tmp; 253 QString tmp;
254 for(int i=0;i<=number;i++) { 254 for(int i=0;i<=number;i++) {
255 pos=tmpText.find("\n"); 255 pos=tmpText.find("\n");
256 tmp=tmpText.left(pos); 256 tmp=tmpText.left(pos);
257 tmpText=tmpText.right(tmpText.length()-pos-1); 257 tmpText=tmpText.right(tmpText.length()-pos-1);
258 tmpStr+=tmp+"<br>"; 258 tmpStr+=tmp+"<br>";
259 } 259 }
260 } 260 }
261 else tmpStr += tmpText; 261 else tmpStr += tmpText;
262 tmpStr+="</" + tag + ">"; 262 tmpStr+="</" + tag + ">";
263 mText.append(tmpStr); 263 mText.append(tmpStr);
264 } 264 }
265 else 265 else
266 { 266 {
267 str += text + "</" + tag + ">"; 267 str += text + "</" + tag + ">";
268 mText.append(str); 268 mText.append(str);
269 } 269 }
270} 270}
271 271
272void KOEventViewer::setColorMode( int m ) 272void KOEventViewer::setColorMode( int m )
273{ 273{
274 mColorMode = m; 274 mColorMode = m;
275} 275}
276void KOEventViewer::appendEvent(Event *event, int mode ) 276void KOEventViewer::appendEvent(Event *event, int mode )
277{ 277{
278 mMailSubject = ""; 278 mMailSubject = "";
279 mCurrentIncidence = event; 279 mCurrentIncidence = event;
280 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 280 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
281 bool wideScreen = ( QApplication::desktop()->width() >= 640 ); 281 bool wideScreen = ( QApplication::desktop()->width() >= 640 );
282 topLevelWidget()->setCaption(i18n("Event Viewer")); 282 topLevelWidget()->setCaption(i18n("Event Viewer"));
283 if ( mode == 0 ) { 283 if ( mode == 0 ) {
284 addTag("h2",deTag(event->summary())); 284 addTag("h2",deTag(event->summary()));
285 formatReadOnly(event);
285 } 286 }
286 else { 287 else {
287 if ( mColorMode == 1 ) { 288 if ( mColorMode == 1 ) {
288 mText +="<font color=\"#00A000\">"; 289 mText +="<font color=\"#00A000\">";
289 } 290 }
290 if ( mColorMode == 2 ) { 291 if ( mColorMode == 2 ) {
291 mText +="<font color=\"#C00000\">"; 292 mText +="<font color=\"#C00000\">";
292 } 293 }
293 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 294 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
294 if ( mode == 1 ) { 295 if ( mode == 1 ) {
295 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 296 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
296 } else { 297 } else {
297 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 298 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
298 } 299 }
300 formatReadOnly(event);
299 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 301 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
300 if ( mColorMode ) 302 if ( mColorMode )
301 mText += "</font>"; 303 mText += "</font>";
302 } 304 }
303 mMailSubject += i18n( "Meeting " )+ event->summary(); 305 mMailSubject += i18n( "Meeting " )+ event->summary();
304 if (event->cancelled ()) { 306 if (event->cancelled ()) {
305 mText +="<font color=\"#B00000\">"; 307 mText +="<font color=\"#B00000\">";
306 addTag("i",i18n("This event has been cancelled!")); 308 addTag("i",i18n("This event has been cancelled!"));
307 mText.append("<br>"); 309 mText.append("<br>");
308 mText += "</font>"; 310 mText += "</font>";
309 mMailSubject += i18n("(cancelled)"); 311 mMailSubject += i18n("(cancelled)");
310 } 312 }
311 313
312 if (event->doesFloat()) { 314 if (event->doesFloat()) {
313 if (event->isMultiDay()) { 315 if (event->isMultiDay()) {
314 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 316 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
315 .arg(event->dtStartDateStr(shortDate)) 317 .arg(event->dtStartDateStr(shortDate))
316 .arg(event->dtEndDateStr(shortDate))); 318 .arg(event->dtEndDateStr(shortDate)));
317 } else { 319 } else {
318 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 320 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
319 } 321 }
320 } else { 322 } else {
321 if (event->isMultiDay()) { 323 if (event->isMultiDay()) {
322 mText.append(i18n("<p><b>From:</b> %1</p> ") 324 mText.append(i18n("<p><b>From:</b> %1</p> ")
323 .arg(event->dtStartStr( shortDate))); 325 .arg(event->dtStartStr( shortDate)));
324 mText.append(i18n("<p><b>To:</b> %1</p>") 326 mText.append(i18n("<p><b>To:</b> %1</p>")
325 .arg(event->dtEndStr(shortDate))); 327 .arg(event->dtEndStr(shortDate)));
326 } else { 328 } else {
327 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 329 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
328 .arg(event->dtStartTimeStr()) 330 .arg(event->dtStartTimeStr())
329 .arg(event->dtEndTimeStr())); 331 .arg(event->dtEndTimeStr()));
330 mText.append(i18n("<p><b>On:</b> %1</p> ") 332 mText.append(i18n("<p><b>On:</b> %1</p> ")
331 .arg(event->dtStartDateStr( shortDate ))); 333 .arg(event->dtStartDateStr( shortDate )));
332 } 334 }
333 } 335 }
334 if (!event->location().isEmpty()) { 336 if (!event->location().isEmpty()) {
335 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); 337 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) );
336 mMailSubject += i18n(" at ") + event->location(); 338 mMailSubject += i18n(" at ") + event->location();
337 } 339 }
338 if (event->recurrence()->doesRecur()) { 340 if (event->recurrence()->doesRecur()) {
339 341
340 QString recurText = event->recurrence()->recurrenceText(); 342 QString recurText = event->recurrence()->recurrenceText();
341 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 343 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
342 bool ok; 344 bool ok;
343 QDate start = QDate::currentDate(); 345 QDate start = QDate::currentDate();
344 QDateTime next; 346 QDateTime next;
345 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 347 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
346 if ( ok ) { 348 if ( ok ) {
347 if ( wideScreen ){ 349 if ( wideScreen ){
348 addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) ); 350 addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) );
349 } else { 351 } else {
350 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 352 addTag("p",i18n("<b>Next recurrence is on:</b>") );
351 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 353 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
352 } 354 }
353 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); 355 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true );
354 356
355 } else { 357 } else {
356 bool last; 358 bool last;
357 QDate nextd; 359 QDate nextd;
358 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 360 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
359 if ( last ) { 361 if ( last ) {
360 if ( wideScreen ){ 362 if ( wideScreen ){
361 addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate )); 363 addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate ));
362 } else{ 364 } else{
363 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 365 addTag("p",i18n("<b>Last recurrence was on:</b>") );
364 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 366 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
365 } 367 }
366 } 368 }
367 } 369 }
368 } else { 370 } else {
369 mMailSubject += i18n(" - " )+event->dtStartStr( true ); 371 mMailSubject += i18n(" - " )+event->dtStartStr( true );
370 372
371 } 373 }
372 374
373 375
374 if (event->isAlarmEnabled()) { 376 if (event->isAlarmEnabled()) {
375 Alarm *alarm =event->alarms().first() ; 377 Alarm *alarm =event->alarms().first() ;
376 QDateTime t = alarm->time(); 378 QDateTime t = alarm->time();
377 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 379 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
378 if(wideScreen ){ 380 if(wideScreen ){
379 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); 381 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate ));
380 }else{ 382 }else{
381 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 383 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
382 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 384 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
383 } 385 }
384 //addTag("p",s); 386 //addTag("p",s);
385 } 387 }
386 388
387 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); 389 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr());
388 390
389 formatCategories(event); 391 formatCategories(event);
390 392
391 formatReadOnly(event);
392 formatAttendees(event); 393 formatAttendees(event);
393 394
394 if ( KOPrefs::instance()->mEVshowCreated ) { 395 if ( KOPrefs::instance()->mEVshowCreated ) {
395 if(wideScreen ){ 396 if(wideScreen ){
396 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 397 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
397 }else{ 398 }else{
398 addTag("p",i18n("<b>Created: ") +" </b>"); 399 addTag("p",i18n("<b>Created: ") +" </b>");
399 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 400 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
400 } 401 }
401 402
402 403
403 } 404 }
404 if ( KOPrefs::instance()->mEVshowChanged ) { 405 if ( KOPrefs::instance()->mEVshowChanged ) {
405 if(wideScreen ){ 406 if(wideScreen ){
406 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 407 addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
407 }else{ 408 }else{
408 addTag("p",i18n("<b>Last modified: ") +" </b>"); 409 addTag("p",i18n("<b>Last modified: ") +" </b>");
409 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 410 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
410 } 411 }
411 412
412 } 413 }
413 if ( KOPrefs::instance()->mEVshowDetails ) { 414 if ( KOPrefs::instance()->mEVshowDetails ) {
414 if (!event->description().isEmpty()) { 415 if (!event->description().isEmpty()) {
415 addTag("p",i18n("<b>Details: </b>")); 416 addTag("p",i18n("<b>Details: </b>"));
416 addTag("p",deTag(event->description())); 417 addTag("p",deTag(event->description()));
417 } 418 }
418 } 419 }
419 setText(mText); 420 setText(mText);
420 //QWhatsThis::add(this,mText); 421 //QWhatsThis::add(this,mText);
421 422
422} 423}
423 424
424void KOEventViewer::appendTodo(Todo *event, int mode ) 425void KOEventViewer::appendTodo(Todo *event, int mode )
425{ 426{
426 mMailSubject = ""; 427 mMailSubject = "";
427 mCurrentIncidence = event; 428 mCurrentIncidence = event;
428 topLevelWidget()->setCaption(i18n("Todo Viewer")); 429 topLevelWidget()->setCaption(i18n("Todo Viewer"));
429 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 430 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
430 bool wideScreen = ( QApplication::desktop()->width() >= 640 ); 431 bool wideScreen = ( QApplication::desktop()->width() >= 640 );
431 if (mode == 0 ) 432 if (mode == 0 ) {
432 addTag("h2",deTag(event->summary())); 433 addTag("h2",deTag(event->summary()));
434 formatReadOnly(event);
435 }
433 else { 436 else {
434 if ( mColorMode == 1 ) { 437 if ( mColorMode == 1 ) {
435 mText +="<font color=\"#00A000\">"; 438 mText +="<font color=\"#00A000\">";
436 } 439 }
437 if ( mColorMode == 2 ) { 440 if ( mColorMode == 2 ) {
438 mText +="<font color=\"#B00000\">"; 441 mText +="<font color=\"#B00000\">";
439 } 442 }
440 if ( mode == 1 ) { 443 if ( mode == 1 ) {
441 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 444 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
442 } else { 445 } else {
443 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 446 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
444 } 447 }
448 formatReadOnly(event);
445 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 449 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
446 if ( mColorMode ) 450 if ( mColorMode )
447 mText += "</font>"; 451 mText += "</font>";
448 } 452 }
449 mMailSubject += i18n( "Todo " )+ event->summary(); 453 mMailSubject += i18n( "Todo " )+ event->summary();
450 454
451 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 455 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
452 mText +="<font color=\"#B00000\">"; 456 mText +="<font color=\"#B00000\">";
453 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); 457 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) );
454 mText += "</font>"; 458 mText += "</font>";
455 } else { 459 } else {
456 mText.append(i18n("<p><i>%1 % completed</i></p>") 460 mText.append(i18n("<p><i>%1 % completed</i></p>")
457 .arg(event->percentComplete())); 461 .arg(event->percentComplete()));
458 } 462 }
459 463
460 if (event->cancelled ()) { 464 if (event->cancelled ()) {
461 mText +="<font color=\"#B00000\">"; 465 mText +="<font color=\"#B00000\">";
462 addTag("i",i18n("This todo has been cancelled!")); 466 addTag("i",i18n("This todo has been cancelled!"));
463 mText.append("<br>"); 467 mText.append("<br>");
464 mText += "</font>"; 468 mText += "</font>";
465 mMailSubject += i18n("(cancelled)"); 469 mMailSubject += i18n("(cancelled)");
466 } 470 }
467 471
468 472
469 473
470 if (event->recurrence()->doesRecur()) { 474 if (event->recurrence()->doesRecur()) {
471 475
472 QString recurText = event->recurrence()->recurrenceText(); 476 QString recurText = event->recurrence()->recurrenceText();
473 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 477 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
474 478
475 } 479 }
476 if (event->hasStartDate()) { 480 if (event->hasStartDate()) {
477 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); 481 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer)));
478 } 482 }
479 if (event->hasDueDate()) { 483 if (event->hasDueDate()) {
480 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 484 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
481 mMailSubject += i18n(" - " )+event->dtDueStr( true ); 485 mMailSubject += i18n(" - " )+event->dtDueStr( true );
482 } 486 }
483 if (!event->location().isEmpty()) { 487 if (!event->location().isEmpty()) {
484 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); 488 addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) );
485 mMailSubject += i18n(" at ") + event->location(); 489 mMailSubject += i18n(" at ") + event->location();
486 } 490 }
487 mText.append(i18n("<p><b>Priority:</b> %2</p>") 491 mText.append(i18n("<p><b>Priority:</b> %2</p>")
488 .arg(QString::number(event->priority()))); 492 .arg(QString::number(event->priority())));
489 493
490 if (event->isAlarmEnabled()) { 494 if (event->isAlarmEnabled()) {
491 Alarm *alarm =event->alarms().first() ; 495 Alarm *alarm =event->alarms().first() ;
492 QDateTime t = alarm->time(); 496 QDateTime t = alarm->time();
493 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 497 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
494 if ( wideScreen ) { 498 if ( wideScreen ) {
495 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); 499 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate ));
496 } else { 500 } else {
497 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 501 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
498 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 502 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
499 } 503 }
500 } 504 }
501 505
502 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); 506 addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr());
503 507
504 formatCategories(event); 508 formatCategories(event);
505 509
506 formatReadOnly(event);
507 formatAttendees(event); 510 formatAttendees(event);
508 511
509 if ( KOPrefs::instance()->mEVshowCreated ) { 512 if ( KOPrefs::instance()->mEVshowCreated ) {
510 if(wideScreen ){ 513 if(wideScreen ){
511 514
512 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 515 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
513 516
514 } else { 517 } else {
515 addTag("p",i18n("<b>Created: ") +" </b>"); 518 addTag("p",i18n("<b>Created: ") +" </b>");
516 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 519 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
517 } 520 }
518 } 521 }
519 if ( KOPrefs::instance()->mEVshowChanged ) { 522 if ( KOPrefs::instance()->mEVshowChanged ) {
520 if(wideScreen ){ 523 if(wideScreen ){
521 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); 524 addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) );
522 525
523 } else { 526 } else {
524 addTag("p",i18n("<b>Last modified: ") +" </b>"); 527 addTag("p",i18n("<b>Last modified: ") +" </b>");
525 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 528 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
526 } 529 }
527 } 530 }
528 if ( event->relatedTo() ) { 531 if ( event->relatedTo() ) {
529 addTag("b",i18n("Parent todo:<br>")); 532 addTag("b",i18n("Parent todo:<br>"));
530 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>"); 533 mText.append(deTag(event->relatedTo()->summary())+" [" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] <br>");
531 } 534 }
532 QPtrList<Incidence> Relations = event->relations(); 535 QPtrList<Incidence> Relations = event->relations();
533 Incidence *to; 536 Incidence *to;
534 if ( Relations.first() ) 537 if ( Relations.first() )
535 addTag("b",i18n("Sub todos:<br>")); 538 addTag("b",i18n("Sub todos:<br>"));
536 for (to=Relations.first();to;to=Relations.next()) { 539 for (to=Relations.first();to;to=Relations.next()) {
537 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>"); 540 mText.append( deTag(to->summary())+" [" +QString::number(to->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%]<br>");
538 541
539 } 542 }
540 543
541 if ( KOPrefs::instance()->mEVshowDetails ) { 544 if ( KOPrefs::instance()->mEVshowDetails ) {
542 if (!event->description().isEmpty()) { 545 if (!event->description().isEmpty()) {
543 addTag("p",i18n("<b>Details: </b>")); 546 addTag("p",i18n("<b>Details: </b>"));
544 addTag("p",deTag(event->description())); 547 addTag("p",deTag(event->description()));
545 } 548 }
546 } 549 }
547 setText(mText); 550 setText(mText);
548} 551}
549 552
550void KOEventViewer::formatCategories(Incidence *event) 553void KOEventViewer::formatCategories(Incidence *event)
551{ 554{
552 if (!event->categoriesStr().isEmpty()) { 555 if (!event->categoriesStr().isEmpty()) {
553 if (event->categories().count() == 1) { 556 if (event->categories().count() == 1) {
554 addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); 557 addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace());
555 } else { 558 } else {
556 addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; 559 addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ;
557 } 560 }
558 } 561 }
559} 562}
560void KOEventViewer::formatAttendees(Incidence *event) 563void KOEventViewer::formatAttendees(Incidence *event)
561{ 564{
562 QPtrList<Attendee> attendees = event->attendees(); 565 QPtrList<Attendee> attendees = event->attendees();
563 if (attendees.count()) { 566 if (attendees.count()) {
564 567
565 568
566 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 569 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
567 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 570 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
568 addTag("h3",i18n("Organizer")); 571 addTag("h3",i18n("Organizer"));
569 mText.append("<ul><li>"); 572 mText.append("<ul><li>");
570#ifndef KORG_NOKABC 573#ifndef KORG_NOKABC
571 574
572#ifdef DESKTOP_VERSION 575#ifdef DESKTOP_VERSION
573 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 576 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
574 KABC::Addressee::List addressList; 577 KABC::Addressee::List addressList;
575 addressList = add_book->findByEmail(event->organizer()); 578 addressList = add_book->findByEmail(event->organizer());
576 KABC::Addressee o = addressList.first(); 579 KABC::Addressee o = addressList.first();
577 if (!o.isEmpty() && addressList.size()<2) { 580 if (!o.isEmpty() && addressList.size()<2) {
578 mText += "<a href=\"uid:" + o.uid() + "\">"; 581 mText += "<a href=\"uid:" + o.uid() + "\">";
579 mText += o.formattedName(); 582 mText += o.formattedName();
580 mText += "</a>\n"; 583 mText += "</a>\n";
581 } else { 584 } else {
582 mText.append(event->organizer()); 585 mText.append(event->organizer());
583 } 586 }
584#else //DESKTOP_VERSION 587#else //DESKTOP_VERSION
585 mText += "<a href=\"uid:organizer\">"; 588 mText += "<a href=\"uid:organizer\">";
586 mText += event->organizer(); 589 mText += event->organizer();
587 mText += "</a>\n"; 590 mText += "</a>\n";
588#endif //DESKTOP_VERSION 591#endif //DESKTOP_VERSION
589 592
590 593
591#else 594#else
592 mText.append(event->organizer()); 595 mText.append(event->organizer());
593#endif 596#endif
594 597
595 if (iconPath) { 598 if (iconPath) {
596 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 599 mText += " <a href=\"mailto:" + event->organizer() + "\">";
597 mText += "<IMG src=\"" + iconPath + "\">"; 600 mText += "<IMG src=\"" + iconPath + "\">";
598 mText += "</a>\n"; 601 mText += "</a>\n";
599 } 602 }
600 mText.append("</li></ul>"); 603 mText.append("</li></ul>");
601 604
602 addTag("h3",i18n("Attendees")); 605 addTag("h3",i18n("Attendees"));
603 Attendee *a; 606 Attendee *a;
604 mText.append("<ul>"); 607 mText.append("<ul>");
605 int a_count = 0; 608 int a_count = 0;
606 int a_count_nr = 0; 609 int a_count_nr = 0;
607 610
608 for(a=attendees.first();a;a=attendees.next()) { 611 for(a=attendees.first();a;a=attendees.next()) {
609#ifndef KORG_NOKABC 612#ifndef KORG_NOKABC
610#ifdef DESKTOP_VERSION 613#ifdef DESKTOP_VERSION
611 if (a->name().isEmpty()) { 614 if (a->name().isEmpty()) {
612 addressList = add_book->findByEmail(a->email()); 615 addressList = add_book->findByEmail(a->email());
613 KABC::Addressee o = addressList.first(); 616 KABC::Addressee o = addressList.first();
614 if (!o.isEmpty() && addressList.size()<2) { 617 if (!o.isEmpty() && addressList.size()<2) {
615 mText += "<a href=\"uid:" + o.uid() + "\">"; 618 mText += "<a href=\"uid:" + o.uid() + "\">";
616 mText += o.formattedName(); 619 mText += o.formattedName();
617 mText += "</a>\n"; 620 mText += "</a>\n";
618 } else { 621 } else {
619 mText += "<li>"; 622 mText += "<li>";
620 mText.append(a->email()); 623 mText.append(a->email());
621 mText += "\n"; 624 mText += "\n";
622 } 625 }
623 } else { 626 } else {
624 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 627 mText += "<li><a href=\"uid:" + a->uid() + "\">";
625 if (!a->name().isEmpty()) mText += a->name(); 628 if (!a->name().isEmpty()) mText += a->name();
626 else mText += a->email(); 629 else mText += a->email();
627 mText += "</a>\n"; 630 mText += "</a>\n";
628 } 631 }
629#else //DESKTOP_VERSION 632#else //DESKTOP_VERSION
630 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 633 mText += "<li><a href=\"uid:" + a->uid() + "\">";
631 if (!a->name().isEmpty()) mText += a->name(); 634 if (!a->name().isEmpty()) mText += a->name();
632 else mText += a->email(); 635 else mText += a->email();
633 mText += "</a>\n"; 636 mText += "</a>\n";
634#endif //DESKTOP_VERSION 637#endif //DESKTOP_VERSION
635#else 638#else
636 //qDebug("nokabc "); 639 //qDebug("nokabc ");
637 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 640 mText += "<li><a href=\"uid:" + a->uid() + "\">";
638 if (!a->name().isEmpty()) mText += a->name(); 641 if (!a->name().isEmpty()) mText += a->name();
639 else mText += a->email(); 642 else mText += a->email();
640 mText += "</a>\n"; 643 mText += "</a>\n";
641#endif 644#endif
642 645
643 646
644 if (!a->email().isEmpty()) { 647 if (!a->email().isEmpty()) {
645 if (iconPath) { 648 if (iconPath) {
646 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 649 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
647 if ( a->RSVP() ) { 650 if ( a->RSVP() ) {
648 ++a_count_nr; 651 ++a_count_nr;
649 mText += "<IMG src=\"" + iconPath + "\">"; 652 mText += "<IMG src=\"" + iconPath + "\">";
650 } 653 }
651 else { 654 else {
652 ++a_count; 655 ++a_count;
653 mText += "<IMG src=\"" + NOiconPath + "\">"; 656 mText += "<IMG src=\"" + NOiconPath + "\">";
654 } 657 }
655 mText += "</a>\n"; 658 mText += "</a>\n";
656 } 659 }
657 } 660 }
658 if (a->status() != Attendee::NeedsAction ) 661 if (a->status() != Attendee::NeedsAction )
659 mText +="[" + a->statusStr() + "] "; 662 mText +="[" + a->statusStr() + "] ";
660 if (a->role() == Attendee::Chair ) 663 if (a->role() == Attendee::Chair )
661 mText +="(" + a->roleStr().left(1) + ".)"; 664 mText +="(" + a->roleStr().left(1) + ".)";
662 } 665 }
663 mText.append("</li></ul>"); 666 mText.append("</li></ul>");
664 if ( (a_count+a_count_nr) > 1 ) { 667 if ( (a_count+a_count_nr) > 1 ) {
665 mText += "<a href=\"mailto:ALL\">"; 668 mText += "<a href=\"mailto:ALL\">";
666 mText += i18n( "Mail to all" ); 669 mText += i18n( "Mail to all" );
667 mText += "</a> ( "; 670 mText += "</a> ( ";
668 mText += "<IMG src=\"" + iconPath + "\">"; 671 mText += "<IMG src=\"" + iconPath + "\">";
669 mText += i18n( " and " ); 672 mText += i18n( " and " );
670 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 673 mText += "<IMG src=\"" + NOiconPath + "\"> )";
671 mText += "<br>\n"; 674 mText += "<br>\n";
672 675
673 676
674 } 677 }
675 if ( a_count_nr > 1 ) { 678 if ( a_count_nr > 1 ) {
676 mText += "<a href=\"mailto:RSVP\">"; 679 mText += "<a href=\"mailto:RSVP\">";
677 mText += i18n( "Mail to selected" ); 680 mText += i18n( "Mail to selected" );
678 mText += "</a> ( "; 681 mText += "</a> ( ";
679 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); 682 mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath );
680 mText += "<br>\n"; 683 mText += "<br>\n";
681 } 684 }
682 } 685 }
683 686
684} 687}
685void KOEventViewer::appendJournal(Journal *jour, int mode ) 688void KOEventViewer::appendJournal(Journal *jour, int mode )
686{ 689{
687 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 690 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
688 if (mode == 0 ) { 691 if (mode == 0 ) {
689 addTag("h2",i18n("Journal from: ")); 692 addTag("h2",i18n("Journal from: "));
690 } 693 }
691 else { 694 else {
692 if ( mode == 1 ) { 695 if ( mode == 1 ) {
693 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 696 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
694 } else { 697 } else {
695 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 698 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
696 } 699 }
697 } 700 }
698 topLevelWidget()->setCaption("Journal Viewer"); 701 topLevelWidget()->setCaption("Journal Viewer");
699 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 702 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
700 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 703 addTag("b",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
701 if (!jour->description().isEmpty()) { 704 if (!jour->description().isEmpty()) {
702 addTag("p",deTag(jour->description())); 705 addTag("p",deTag(jour->description()));
703 } 706 }
704 setText(mText); 707 setText(mText);
705} 708}
706 709
707void KOEventViewer::formatReadOnly(Incidence *event) 710void KOEventViewer::formatReadOnly(Incidence *event)
708{ 711{
709 if (event->isReadOnly()) { 712 if (event->isReadOnly()) {
710 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 713 addTag("p","<em>(" + i18n("read-only") + ")</em>");
711 } 714 }
712} 715}
713void KOEventViewer::setSyncMode( bool b ) 716void KOEventViewer::setSyncMode( bool b )
714{ 717{
715 mSyncMode = b; 718 mSyncMode = b;
716} 719}
717 720
718void KOEventViewer::setTodo(Todo *event, bool clearV ) 721void KOEventViewer::setTodo(Todo *event, bool clearV )
719{ 722{
720 if ( clearV ) 723 if ( clearV )
721 clearEvents(); 724 clearEvents();
722 if ( mSyncMode ) { 725 if ( mSyncMode ) {
723 if ( clearV ) 726 if ( clearV )
724 appendTodo(event,1 ); 727 appendTodo(event,1 );
725 else 728 else
726 appendTodo(event,2); 729 appendTodo(event,2);
727 } else 730 } else
728 appendTodo(event); 731 appendTodo(event);
729} 732}
730void KOEventViewer::setJournal(Journal *event, bool clearV ) 733void KOEventViewer::setJournal(Journal *event, bool clearV )
731{ 734{
732 if ( clearV ) 735 if ( clearV )
733 clearEvents(); 736 clearEvents();
734 if ( mSyncMode ) { 737 if ( mSyncMode ) {
735 if ( clearV ) 738 if ( clearV )
736 appendJournal(event, 1); 739 appendJournal(event, 1);
737 else 740 else
738 appendJournal(event, 2); 741 appendJournal(event, 2);
739 } else 742 } else
740 appendJournal(event); 743 appendJournal(event);
741} 744}
742 745
743void KOEventViewer::setEvent(Event *event) 746void KOEventViewer::setEvent(Event *event)
744{ 747{
745 clearEvents(); 748 clearEvents();
746 if ( mSyncMode ) 749 if ( mSyncMode )
747 appendEvent(event, 1); 750 appendEvent(event, 1);
748 else 751 else
749 appendEvent(event); 752 appendEvent(event);
750} 753}
751 754
752void KOEventViewer::addEvent(Event *event) 755void KOEventViewer::addEvent(Event *event)
753{ 756{
754 if ( mSyncMode ) 757 if ( mSyncMode )
755 appendEvent(event, 2); 758 appendEvent(event, 2);
756 else 759 else
757 appendEvent(event); 760 appendEvent(event);
758} 761}
759 762
760void KOEventViewer::clearEvents(bool now) 763void KOEventViewer::clearEvents(bool now)
761{ 764{
762 mText = ""; 765 mText = "";
763 if (now) setText(mText); 766 if (now) setText(mText);
764} 767}
765 768
766void KOEventViewer::addText(QString text) 769void KOEventViewer::addText(QString text)
767{ 770{
768 mText.append(text); 771 mText.append(text);
769 setText(mText); 772 setText(mText);
770} 773}
771QString KOEventViewer::deTag(QString text) 774QString KOEventViewer::deTag(QString text)
772{ 775{
773#if QT_VERSION >= 0x030000 776#if QT_VERSION >= 0x030000
774 text.replace( '<' , "&lt;" ); 777 text.replace( '<' , "&lt;" );
775 text.replace( '>' , "&gt;" ); 778 text.replace( '>' , "&gt;" );
776#else 779#else
777 if ( text.find ('<') >= 0 ) { 780 if ( text.find ('<') >= 0 ) {
778 text.replace( QRegExp("<") , "&lt;" ); 781 text.replace( QRegExp("<") , "&lt;" );
779 } 782 }
780 if ( text.find ('>') >= 0 ) { 783 if ( text.find ('>') >= 0 ) {
781 text.replace( QRegExp(">") , "&gt;" ); 784 text.replace( QRegExp(">") , "&gt;" );
782 } 785 }
783#endif 786#endif
784 return text; 787 return text;
785} 788}
786void KOEventViewer::keyPressEvent ( QKeyEvent * e ) 789void KOEventViewer::keyPressEvent ( QKeyEvent * e )
787{ 790{
788 switch ( e->key() ) { 791 switch ( e->key() ) {
789 case Qt::Key_Return: 792 case Qt::Key_Return:
790 case Qt::Key_Enter : 793 case Qt::Key_Enter :
791 e->ignore(); 794 e->ignore();
792 break; 795 break;
793 default: 796 default:
794 QTextBrowser::keyPressEvent ( e ); 797 QTextBrowser::keyPressEvent ( e );
795 break; 798 break;
796 } 799 }
797} 800}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 475bb4a..cba85fa 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,2115 +1,2111 @@
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
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
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
68protected: 68protected:
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 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::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}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~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
100void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 100void 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}
136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 136void 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
147QString KNoScrollListBox::getWhatsThisText(QPoint p) 147QString 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}
158void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 158void 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
242void KNoScrollListBox::oneDown() 242void 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}
260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 260void 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
271void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 271void 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
280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 280MonthViewItem::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}
295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 295void 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
308void MonthViewItem::paint(QPainter *p) 308void 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
319
320 int heihei = height( listBox () ); 318 int heihei = height( listBox () );
321 int x = 1; 319 int x = 1;
322 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
323 { 321 {
324 p->setBackgroundColor( palette().color( QPalette::Normal, \ 322 p->setBackgroundColor( palette().color( QPalette::Normal, \
325 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 323 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
326 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); 324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
327 } 325 }
328 326
329 //int y = 3;//(height() - mRecurPixmap.height()) /2; 327 //int y = 3;//(height() - mRecurPixmap.height()) /2;
330 int size = PIXMAP_SIZE; 328 int size = PIXMAP_SIZE;
331 if ( QApplication::desktop()->width() < 300 ) 329 if ( QApplication::desktop()->width() < 300 )
332 size = 3; 330 size = 3;
333 int y = (heihei - size -1 ) /2; 331 int y = (heihei - size -1 ) /2;
334 332
335 if ( mIncidence->calID() > 1 ) { 333 if ( mIncidence->calID() > 1 ) {
336 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 334 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
337 p->drawRect ( x, y-2,size,size+4); 335 p->drawRect ( x, y-2,size,size+4);
338 x += size + 1; 336 x += size + 1;
339 } 337 }
340
341 if ( KOPrefs::instance()->mMonthShowIcons ) { 338 if ( KOPrefs::instance()->mMonthShowIcons ) {
342 if ( mInfo ) { 339 if ( mInfo ) {
343 p->fillRect ( x, y,size,size, Qt::darkGreen ); 340 p->fillRect ( x, y,size,size, Qt::darkGreen );
344 x += size + 1; 341 x += size + 1;
345 } 342 }
346 if ( mRecur ) { 343 if ( mRecur ) {
347 p->fillRect ( x, y,size,size, Qt::blue ); 344 p->fillRect ( x, y,size,size, Qt::blue );
348 x += size + 1; 345 x += size + 1;
349 } 346 }
350 if ( mAlarm ) { 347 if ( mAlarm ) {
351 p->fillRect ( x, y,size,size, Qt::red ); 348 p->fillRect ( x, y,size,size, Qt::red );
352 x += size + 1; 349 x += size + 1;
353 } 350 }
354 if ( mReply ) { 351 if ( mReply ) {
355 p->fillRect ( x, y,size,size, Qt::yellow ); 352 p->fillRect ( x, y,size,size, Qt::yellow );
356 x += size + 1; 353 x += size + 1;
357 } 354 }
358 } 355 }
359 if ( mMultiday ) { 356 if ( mMultiday ) {
360 int yyy = y+(size/2); 357 int yyy = y+(size/2);
361 int sizeM = size+2; 358 int sizeM = size+2;
362 p->setBrush( QBrush::SolidPattern ); 359 p->setBrush( QBrush::SolidPattern );
363 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 360 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
364 if ( mMultiday == 2 || mMultiday == 3 ) { 361 if ( mMultiday == 2 || mMultiday == 3 ) {
365 QPointArray pa ( 3 ); 362 QPointArray pa ( 3 );
366 pa.setPoint (0, x, yyy ); 363 pa.setPoint (0, x, yyy );
367 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 364 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
368 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 365 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
369 p->drawPolygon( pa ); 366 p->drawPolygon( pa );
370 } 367 }
371 if ( mMultiday == 2 || mMultiday == 1 ) { 368 if ( mMultiday == 2 || mMultiday == 1 ) {
372 QPointArray pa ( 3 ); 369 QPointArray pa ( 3 );
373 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 370 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
374 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 371 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
375 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 372 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
376 p->drawPolygon( pa ); 373 p->drawPolygon( pa );
377 } 374 }
378 if ( mMultiday == 1 ) { 375 if ( mMultiday == 1 ) {
379 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 376 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
380
381 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 377 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
382 } 378 }
383 if ( mMultiday == 3 ) { 379 if ( mMultiday == 3 ) {
384 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 380 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
385 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 381 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
386 382
387 } 383 }
388 x += sizeM/2 + 1; 384 x += sizeM/2 + 1;
389 x += sizeM + 1; 385 x += sizeM + 1;
390 } 386 }
391 387
392 if ( mIncidence->typeID() == todoID ){ 388 if ( mIncidence->typeID() == todoID ){
393 Todo* td = ( Todo* ) mIncidence; 389 Todo* td = ( Todo* ) mIncidence;
394 if ( td->isCompleted() ) { 390 if ( td->isCompleted() ) {
395 int half = size/2; 391 int half = size/2;
396 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 392 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
397 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 393 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
398 x += half+half + 4; 394 x += half+half + 4;
399 395
400 } else { 396 } else {
401 int val = td->percentComplete()/20; 397 int val = td->percentComplete()/20;
402 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 398 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
403 p->drawRect ( x, y-2,7,size+4); 399 p->drawRect ( x, y-2,7,size+4);
404 x += size + 3; 400 x += size + 3;
405 } 401 }
406 } 402 }
407 QFontMetrics fm = p->fontMetrics(); 403 QFontMetrics fm = p->fontMetrics();
408 int yPos; 404 int yPos;
409 int pmheight = size; 405 int pmheight = size;
410 if( pmheight < fm.height() ) 406 if( pmheight < fm.height() )
411 yPos = fm.ascent() + fm.leading()/2; 407 yPos = fm.ascent() + fm.leading()/2;
412 else 408 else
413 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 409 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
414 p->setPen( palette().color( QPalette::Normal, sel ? \ 410 p->setPen( palette().color( QPalette::Normal, sel ? \
415 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 411 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
416 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 412 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
417 p->drawText( x, yPos, text() ); 413 p->drawText( x, yPos, text() );
418 if ( mIncidence->cancelled() ) { 414 if ( mIncidence->cancelled() ) {
419 int wid = fm.width( text() ); 415 int wid = fm.width( text() );
420 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 416 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
421 } 417 }
422 } else { 418 } else {
423 QString pText = text(); 419 QString pText = text();
424 if( pText.mid(2,1) == ":" ) 420 if( pText.mid(2,1) == ":" )
425 pText = pText.mid( 6 ); 421 pText = pText.mid( 6 );
426 p->drawText( x, yPos, pText ); 422 p->drawText( x, yPos, pText );
427 if ( mIncidence->cancelled() ) { 423 if ( mIncidence->cancelled() ) {
428 int wid = fm.width( pText ); 424 int wid = fm.width( pText );
429 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 425 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
430 } 426 }
431 } 427 }
432} 428}
433 429
434int MonthViewItem::height(const QListBox *lb) const 430int MonthViewItem::height(const QListBox *lb) const
435{ 431{
436 int ret = 10; 432 int ret = 10;
437 if ( lb ) 433 if ( lb )
438 ret = lb->fontMetrics().lineSpacing()+1; 434 ret = lb->fontMetrics().lineSpacing()+1;
439 return ret; 435 return ret;
440} 436}
441 437
442int MonthViewItem::width(const QListBox *lb) const 438int MonthViewItem::width(const QListBox *lb) const
443{ 439{
444 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 440 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
445 int size = PIXMAP_SIZE; 441 int size = PIXMAP_SIZE;
446 if ( QApplication::desktop()->width() < 300 ) 442 if ( QApplication::desktop()->width() < 300 )
447 size = 3; 443 size = 3;
448 int x = 1; 444 int x = 1;
449 if ( KOPrefs::instance()->mMonthShowIcons ) { 445 if ( KOPrefs::instance()->mMonthShowIcons ) {
450 if ( mInfo ) { 446 if ( mInfo ) {
451 x += size + 1; 447 x += size + 1;
452 } 448 }
453 if( mRecur ) { 449 if( mRecur ) {
454 x += size+1; 450 x += size+1;
455 } 451 }
456 if( mAlarm ) { 452 if( mAlarm ) {
457 x += size+1; 453 x += size+1;
458 } 454 }
459 if( mReply ) { 455 if( mReply ) {
460 x += size+1; 456 x += size+1;
461 } 457 }
462 } 458 }
463 if( mMultiday ) { 459 if( mMultiday ) {
464 x += size+1+2+size/2; 460 x += size+1+2+size/2;
465 } 461 }
466 return( x + lb->fontMetrics().width( text() ) + 1 ); 462 return( x + lb->fontMetrics().width( text() ) + 1 );
467 } 463 }
468 if ( ! lb ) 464 if ( ! lb )
469 return 10; 465 return 10;
470 return lb->width(); 466 return lb->width();
471} 467}
472 468
473 469
474MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 470MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
475 : KNoScrollListBox( par ), 471 : KNoScrollListBox( par ),
476 mMonthView( parent ) 472 mMonthView( parent )
477{ 473{
478 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 474 //QVBoxLayout *topLayout = new QVBoxLayout( this );
479 currentPalette = 0; 475 currentPalette = 0;
480 // mLabel = new QLabel( this );QPushButton 476 // mLabel = new QLabel( this );QPushButton
481 mLabel = new QPushButton( this ); 477 mLabel = new QPushButton( this );
482 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 478 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
483 //mLabel->setLineWidth( 1 ); 479 //mLabel->setLineWidth( 1 );
484 //mLabel->setAlignment( AlignCenter ); 480 //mLabel->setAlignment( AlignCenter );
485 mLabel->setFlat( true ); 481 mLabel->setFlat( true );
486 mLabel->setFocusPolicy(NoFocus); 482 mLabel->setFocusPolicy(NoFocus);
487 //mItemList = new KNoScrollListBox( this ); 483 //mItemList = new KNoScrollListBox( this );
488 setMinimumSize( 10, 10 ); 484 setMinimumSize( 10, 10 );
489 setFrameStyle( QFrame::Panel | QFrame::Plain ); 485 setFrameStyle( QFrame::Panel | QFrame::Plain );
490 setLineWidth( 1 ); 486 setLineWidth( 1 );
491 //topLayout->addWidget( mItemList ); 487 //topLayout->addWidget( mItemList );
492 mLabel->raise(); 488 mLabel->raise();
493 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 489 // QColor( 0,0,255 ) QColor( 160,1600,255 )
494 mStandardPalette = palette(); 490 mStandardPalette = palette();
495 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 491 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
496 492
497 enableScrollBars( false ); 493 enableScrollBars( false );
498 updateConfig(); 494 updateConfig();
499 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 495 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
500 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 496 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
501 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 497 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
502 SLOT( defaultAction( QListBoxItem * ) ) ); 498 SLOT( defaultAction( QListBoxItem * ) ) );
503 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 499 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
504 const QPoint &) ), 500 const QPoint &) ),
505 SLOT( contextMenu( QListBoxItem * ) ) ); 501 SLOT( contextMenu( QListBoxItem * ) ) );
506 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 502 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
507 SLOT( selection( QListBoxItem * ) ) ); 503 SLOT( selection( QListBoxItem * ) ) );
508 504
509 /* 505 /*
510 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 506 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
511 SLOT( selection( QListBoxItem * ) ) ); 507 SLOT( selection( QListBoxItem * ) ) );
512 */ 508 */
513} 509}
514#ifdef DESKTOP_VERSION 510#ifdef DESKTOP_VERSION
515QToolTipGroup *MonthViewCell::toolTipGroup() 511QToolTipGroup *MonthViewCell::toolTipGroup()
516{ 512{
517 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 513 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
518 return mToolTipGroup; 514 return mToolTipGroup;
519} 515}
520#endif 516#endif
521 517
522void MonthViewCell::setDate( const QDate &date ) 518void MonthViewCell::setDate( const QDate &date )
523{ 519{
524 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 520 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
525 mDate = date; 521 mDate = date;
526 522
527 523
528 524
529 //resizeEvent( 0 ); 525 //resizeEvent( 0 );
530} 526}
531 527
532QDate MonthViewCell::date() const 528QDate MonthViewCell::date() const
533{ 529{
534 return mDate; 530 return mDate;
535} 531}
536 532
537void MonthViewCell::setPrimary( bool primary ) 533void MonthViewCell::setPrimary( bool primary )
538{ 534{
539 mPrimary = primary; 535 mPrimary = primary;
540 //setMyPalette(); 536 //setMyPalette();
541} 537}
542void MonthViewCell::setMyPalette() 538void MonthViewCell::setMyPalette()
543{ 539{
544 540
545 if ( mHoliday) { 541 if ( mHoliday) {
546 if ( currentPalette == 1 ) return; 542 if ( currentPalette == 1 ) return;
547 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 543 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
548 setPalette( mHolidayPalette ); 544 setPalette( mHolidayPalette );
549 //mLabel->setPalette( mHolidayPalette ); 545 //mLabel->setPalette( mHolidayPalette );
550 currentPalette = 1; 546 currentPalette = 1;
551 547
552 } else { 548 } else {
553 if ( mPrimary ) { 549 if ( mPrimary ) {
554 if ( currentPalette == 2 ) return; 550 if ( currentPalette == 2 ) return;
555 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 551 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
556 //mLabel->setPalette( mPrimaryPalette ); 552 //mLabel->setPalette( mPrimaryPalette );
557 setPalette( mPrimaryPalette ); 553 setPalette( mPrimaryPalette );
558 currentPalette = 2; 554 currentPalette = 2;
559 555
560 } else { 556 } else {
561 if ( currentPalette == 3 ) return; 557 if ( currentPalette == 3 ) return;
562 setPalette( mNonPrimaryPalette ); 558 setPalette( mNonPrimaryPalette );
563 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 559 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
564 //mLabel->setPalette( mNonPrimaryPalette );; 560 //mLabel->setPalette( mNonPrimaryPalette );;
565 currentPalette = 3; 561 currentPalette = 3;
566 } 562 }
567 } 563 }
568 //QPalette pal = palette(); 564 //QPalette pal = palette();
569 565
570 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 566 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
571} 567}
572QPalette MonthViewCell::getPalette () 568QPalette MonthViewCell::getPalette ()
573{ 569{
574 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 570 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
575 return mStandardPalette; 571 return mStandardPalette;
576 if ( mHoliday) { 572 if ( mHoliday) {
577 return mHolidayPalette ; 573 return mHolidayPalette ;
578 } else { 574 } else {
579 if ( mPrimary ) { 575 if ( mPrimary ) {
580 return mPrimaryPalette ; 576 return mPrimaryPalette ;
581 } 577 }
582 } 578 }
583 return mNonPrimaryPalette; 579 return mNonPrimaryPalette;
584} 580}
585bool MonthViewCell::isPrimary() const 581bool MonthViewCell::isPrimary() const
586{ 582{
587 return mPrimary; 583 return mPrimary;
588} 584}
589 585
590void MonthViewCell::setHoliday( bool holiday ) 586void MonthViewCell::setHoliday( bool holiday )
591{ 587{
592 mHoliday = holiday; 588 mHoliday = holiday;
593 //setMyPalette(); 589 //setMyPalette();
594} 590}
595 591
596void MonthViewCell::setHoliday( const QString &holiday ) 592void MonthViewCell::setHoliday( const QString &holiday )
597{ 593{
598 mHolidayString = holiday; 594 mHolidayString = holiday;
599 595
600 if ( !holiday.isEmpty() ) { 596 if ( !holiday.isEmpty() ) {
601 setHoliday( true ); 597 setHoliday( true );
602 } 598 }
603} 599}
604 600
605void MonthViewCell::startUpdateCell() 601void MonthViewCell::startUpdateCell()
606{ 602{
607 mdayCount = 0; 603 mdayCount = 0;
608 setFocusPolicy(NoFocus); 604 setFocusPolicy(NoFocus);
609 if ( !mMonthView->isUpdatePossible() ) 605 if ( !mMonthView->isUpdatePossible() )
610 return; 606 return;
611 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 607 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
612 while ( mitem ) { 608 while ( mitem ) {
613 mitem->setBlockRepaint( true ); 609 mitem->setBlockRepaint( true );
614 mitem = (MonthViewItem *)mitem->next(); 610 mitem = (MonthViewItem *)mitem->next();
615 } 611 }
616 if ( mAvailItemList.count() > 20 ) { 612 if ( mAvailItemList.count() > 20 ) {
617 mAvailItemList.setAutoDelete( true ); 613 mAvailItemList.setAutoDelete( true );
618 mAvailItemList.clear(); 614 mAvailItemList.clear();
619 mAvailItemList.setAutoDelete( false ); 615 mAvailItemList.setAutoDelete( false );
620 clear(); 616 clear();
621 } 617 }
622 618
623 setPrimary( mDate.month()%2 ); 619 setPrimary( mDate.month()%2 );
624 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 620 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
625 if ( mDate == QDate::currentDate() ) { 621 if ( mDate == QDate::currentDate() ) {
626 setLineWidth( 3 ); 622 setLineWidth( 3 );
627 } else { 623 } else {
628 setLineWidth( 1 ); 624 setLineWidth( 1 );
629 } 625 }
630 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 626 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
631 //clear(); 627 //clear();
632 while ( CurrentAvailItem ) { 628 while ( CurrentAvailItem ) {
633 MonthViewItem *item = CurrentAvailItem; 629 MonthViewItem *item = CurrentAvailItem;
634 CurrentAvailItem = (MonthViewItem *)item->next(); 630 CurrentAvailItem = (MonthViewItem *)item->next();
635 mAvailItemList.append( item ); 631 mAvailItemList.append( item );
636 takeItem ( item ); 632 takeItem ( item );
637 } 633 }
638 634
639#ifdef DESKTOP_VERSION 635#ifdef DESKTOP_VERSION
640 QToolTip::remove(this); 636 QToolTip::remove(this);
641#endif 637#endif
642 mToolTip.clear(); 638 mToolTip.clear();
643 //qApp->processEvents(); 639 //qApp->processEvents();
644#if 0 640#if 0
645 if ( !mHolidayString.isEmpty() ) { 641 if ( !mHolidayString.isEmpty() ) {
646 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 642 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
647 item->setPalette( mHolidayPalette ); 643 item->setPalette( mHolidayPalette );
648 insertItem( item ); 644 insertItem( item );
649 mToolTip.append ( mHolidayString ); 645 mToolTip.append ( mHolidayString );
650 } 646 }
651#endif 647#endif
652} 648}
653 649
654int MonthViewCell::insertEvent(Event *event) 650int MonthViewCell::insertEvent(Event *event)
655{ 651{
656 bool useToolTips = true; 652 bool useToolTips = true;
657#ifndef DESKTOP_VERSION 653#ifndef DESKTOP_VERSION
658 useToolTips = false; 654 useToolTips = false;
659#endif 655#endif
660 QString mToolTipText; 656 QString mToolTipText;
661 setFocusPolicy(WheelFocus); 657 setFocusPolicy(WheelFocus);
662 if ( !(event->doesRecur() == Recurrence::rNone) ) { 658 if ( !(event->doesRecur() == Recurrence::rNone) ) {
663 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 659 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
664 return mdayCount; 660 return mdayCount;
665 else 661 else
666 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 662 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
667 return mdayCount; 663 return mdayCount;
668 } 664 }
669 665
670 if ( event->isHoliday()) { 666 if ( event->isHoliday()) {
671 setHoliday( true ); 667 setHoliday( true );
672 if ( mDate.dayOfWeek() == 7 ) 668 if ( mDate.dayOfWeek() == 7 )
673 setLineWidth( 3 ); 669 setLineWidth( 3 );
674 } 670 }
675 QString text; 671 QString text;
676 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 672 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
677 if (event->isMultiDay()) { 673 if (event->isMultiDay()) {
678 QString prefix = "<->";multiday = 2; 674 QString prefix = "<->";multiday = 2;
679 QString time; 675 QString time;
680 if ( event->doesRecur() ) { 676 if ( event->doesRecur() ) {
681 if ( event->recursOn( mDate) ) { 677 if ( event->recursOn( mDate) ) {
682 prefix ="->" ;multiday = 1; 678 prefix ="->" ;multiday = 1;
683 } 679 }
684 else { 680 else {
685 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 681 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
686 if ( event->recursOn( mDate.addDays( -days)) ) { 682 if ( event->recursOn( mDate.addDays( -days)) ) {
687 prefix ="<-" ;multiday = 3; 683 prefix ="<-" ;multiday = 3;
688 } 684 }
689 } 685 }
690 686
691 } else { 687 } else {
692 if (mDate == event->dtStart().date()) { 688 if (mDate == event->dtStart().date()) {
693 prefix ="->" ;multiday = 1; 689 prefix ="->" ;multiday = 1;
694 } else if (mDate == event->dtEnd().date()) { 690 } else if (mDate == event->dtEnd().date()) {
695 prefix ="<-" ;multiday = 3; 691 prefix ="<-" ;multiday = 3;
696 } 692 }
697 } 693 }
698 if ( !event->doesFloat() ) { 694 if ( !event->doesFloat() ) {
699 if ( mDate == event->dtStart().date () ) 695 if ( mDate == event->dtStart().date () )
700 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 696 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
701 else if ( mDate == event->dtEnd().date () ) 697 else if ( mDate == event->dtEnd().date () )
702 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 698 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
703 699
704 } 700 }
705 text = time + event->summary(); 701 text = time + event->summary();
706 if ( useToolTips ) 702 if ( useToolTips )
707 mToolTipText += prefix + text; 703 mToolTipText += prefix + text;
708 } else { 704 } else {
709 if (event->doesFloat()) { 705 if (event->doesFloat()) {
710 text = event->summary(); 706 text = event->summary();
711 if ( useToolTips ) 707 if ( useToolTips )
712 mToolTipText += text; 708 mToolTipText += text;
713 } 709 }
714 else { 710 else {
715 text = KGlobal::locale()->formatTime(event->dtStart().time()); 711 text = KGlobal::locale()->formatTime(event->dtStart().time());
716 text += " " + event->summary(); 712 text += " " + event->summary();
717 if ( useToolTips ) 713 if ( useToolTips )
718 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 714 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
719 } 715 }
720 } 716 }
721 if ( useToolTips && ! event->location().isEmpty() ) { 717 if ( useToolTips && ! event->location().isEmpty() ) {
722 mToolTipText += " (" + event->location() +")"; 718 mToolTipText += " (" + event->location() +")";
723 } 719 }
724 MonthViewItem *item ; 720 MonthViewItem *item ;
725 721
726 if ( mAvailItemList.count() ) { 722 if ( mAvailItemList.count() ) {
727 item = mAvailItemList.first(); 723 item = mAvailItemList.first();
728 mAvailItemList.remove( item ); 724 mAvailItemList.remove( item );
729 item->recycle( event, mDate, text ); 725 item->recycle( event, mDate, text );
730 } else { 726 } else {
731 item = new MonthViewItem( event, mDate, text ); 727 item = new MonthViewItem( event, mDate, text );
732 } 728 }
733 729
734 QPalette pal; 730 QPalette pal;
735 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 731 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
736 QStringList categories = event->categories(); 732 QStringList categories = event->categories();
737 QString cat = categories.first(); 733 QString cat = categories.first();
738 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 734 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
739 pal = getPalette(); 735 pal = getPalette();
740 if (cat.isEmpty()) { 736 if (cat.isEmpty()) {
741 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 737 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
742 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); 738 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
743 } else { 739 } else {
744 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 740 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
745 } 741 }
746 742
747 } else { 743 } else {
748 if (cat.isEmpty()) { 744 if (cat.isEmpty()) {
749 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 745 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
750 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); 746 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
751 } else { 747 } else {
752 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 748 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
753 } 749 }
754 } 750 }
755 751
756 } else { 752 } else {
757 pal = mStandardPalette ; 753 pal = mStandardPalette ;
758 } 754 }
759 item->setPalette( pal ); 755 item->setPalette( pal );
760 item->setRecur( event->recurrence()->doesRecur() ); 756 item->setRecur( event->recurrence()->doesRecur() );
761 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); 757 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
762 item->setMoreInfo( event->description().length() > 0 ); 758 item->setMoreInfo( event->description().length() > 0 );
763#ifdef DESKTOP_VERSION 759#ifdef DESKTOP_VERSION
764 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 760 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
765 KOPrefs::instance()->email()); 761 KOPrefs::instance()->email());
766 if ( me != 0 ) { 762 if ( me != 0 ) {
767 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 763 if ( me->status() == Attendee::NeedsAction && me->RSVP())
768 item->setReply(true && multiday < 2); 764 item->setReply(true && multiday < 2);
769 else 765 else
770 item->setReply(false); 766 item->setReply(false);
771 } else 767 } else
772 item->setReply(false); 768 item->setReply(false);
773#endif 769#endif
774 770
775 item->setMultiDay( multiday ); 771 item->setMultiDay( multiday );
776 if ( multiday ) { 772 if ( multiday ) {
777 insertItem( item ,mdayCount); 773 insertItem( item ,mdayCount);
778 ++mdayCount; 774 ++mdayCount;
779 } else { 775 } else {
780 uint i = mdayCount; 776 uint i = mdayCount;
781 uint pos = mdayCount; 777 uint pos = mdayCount;
782 uint itcount = count(); 778 uint itcount = count();
783 if ( itcount > 1000 ) { 779 if ( itcount > 1000 ) {
784 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); 780 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount);
785 itcount = 0; 781 itcount = 0;
786 } 782 }
787 for ( i = pos; i < itcount;++i ) { 783 for ( i = pos; i < itcount;++i ) {
788 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); 784 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount );
789 QListBoxItem* it = this->item ( i ); 785 QListBoxItem* it = this->item ( i );
790 if ( it && text < it->text() ) { 786 if ( it && text < it->text() ) {
791 pos = i; 787 pos = i;
792 break; 788 break;
793 } 789 }
794 ++pos; 790 ++pos;
795 } 791 }
796 insertItem( item ,pos); 792 insertItem( item ,pos);
797 } 793 }
798 if ( useToolTips ) { 794 if ( useToolTips ) {
799 mToolTip.append( mToolTipText ); 795 mToolTip.append( mToolTipText );
800 } 796 }
801 return mdayCount; 797 return mdayCount;
802} 798}
803void MonthViewCell::insertTodo(Todo *todo) 799void MonthViewCell::insertTodo(Todo *todo)
804{ 800{
805 setFocusPolicy(WheelFocus); 801 setFocusPolicy(WheelFocus);
806 QString text; 802 QString text;
807 if (todo->hasDueDate()) { 803 if (todo->hasDueDate()) {
808 if (!todo->doesFloat()) { 804 if (!todo->doesFloat()) {
809 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 805 text += KGlobal::locale()->formatTime(todo->dtDue().time());
810 text += " "; 806 text += " ";
811 } 807 }
812 } 808 }
813 text += todo->summary(); 809 text += todo->summary();
814 MonthViewItem *item ; 810 MonthViewItem *item ;
815 if ( mAvailItemList.count() ) { 811 if ( mAvailItemList.count() ) {
816 item = mAvailItemList.first(); 812 item = mAvailItemList.first();
817 mAvailItemList.remove( item ); 813 mAvailItemList.remove( item );
818 item->recycle( todo, mDate, text ); 814 item->recycle( todo, mDate, text );
819 } else { 815 } else {
820 item = new MonthViewItem( todo, mDate, text ); 816 item = new MonthViewItem( todo, mDate, text );
821 } 817 }
822 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 818 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
823 //item->setPalette( mStandardPalette ); 819 //item->setPalette( mStandardPalette );
824 QPalette pal; 820 QPalette pal;
825 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 821 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
826 QStringList categories = todo->categories(); 822 QStringList categories = todo->categories();
827 QString cat = categories.first(); 823 QString cat = categories.first();
828 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 824 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
829 pal = getPalette(); 825 pal = getPalette();
830 if (cat.isEmpty()) { 826 if (cat.isEmpty()) {
831 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 827 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
832 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); 828 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
833 } else { 829 } else {
834 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 830 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
835 } 831 }
836 832
837 } else { 833 } else {
838 if (cat.isEmpty()) { 834 if (cat.isEmpty()) {
839 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 835 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
840 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); 836 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
841 } else { 837 } else {
842 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 838 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
843 } 839 }
844 } 840 }
845 841
846 } else { 842 } else {
847 pal = mStandardPalette ; 843 pal = mStandardPalette ;
848 } 844 }
849 item->setPalette( pal ); 845 item->setPalette( pal );
850 item->setRecur( todo->recurrence()->doesRecur() ); 846 item->setRecur( todo->recurrence()->doesRecur() );
851 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 847 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
852 item->setMoreInfo( todo->description().length() > 0 ); 848 item->setMoreInfo( todo->description().length() > 0 );
853 insertItem( item , count()); 849 insertItem( item , count());
854#ifdef DESKTOP_VERSION 850#ifdef DESKTOP_VERSION
855 mToolTip.append( text ); 851 mToolTip.append( text );
856#endif 852#endif
857} 853}
858void MonthViewCell::repaintfinishUpdateCell() 854void MonthViewCell::repaintfinishUpdateCell()
859{ 855{
860 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 856 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
861 while ( mitem ) { 857 while ( mitem ) {
862 mitem->setBlockRepaint( false ); 858 mitem->setBlockRepaint( false );
863 updateItem ( mitem ); 859 updateItem ( mitem );
864 mitem = (MonthViewItem *)mitem->next(); 860 mitem = (MonthViewItem *)mitem->next();
865 } 861 }
866} 862}
867void MonthViewCell::finishUpdateCell() 863void MonthViewCell::finishUpdateCell()
868{ 864{
869 865
870 866
871 867
872#ifdef DESKTOP_VERSION 868#ifdef DESKTOP_VERSION
873 if (mToolTip.count() > 0 ) { 869 if (mToolTip.count() > 0 ) {
874 mToolTip.sort(); 870 mToolTip.sort();
875 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 871 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
876 } 872 }
877#endif 873#endif
878 //sort(); 874 //sort();
879 //setMyPalette(); 875 //setMyPalette();
880 setMyPalette(); 876 setMyPalette();
881 877
882 resizeEvent( 0 ); 878 resizeEvent( 0 );
883 879
884} 880}
885void MonthViewCell::updateCell() 881void MonthViewCell::updateCell()
886{ 882{
887 if ( !mMonthView->isUpdatePossible() ) 883 if ( !mMonthView->isUpdatePossible() )
888 return; 884 return;
889 startUpdateCell(); 885 startUpdateCell();
890 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 886 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
891 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 887 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
892 Event *event; 888 Event *event;
893 for( event = events.first(); event; event = events.next() ) { // for event 889 for( event = events.first(); event; event = events.next() ) { // for event
894 insertEvent(event); 890 insertEvent(event);
895 } 891 }
896 // insert due todos 892 // insert due todos
897 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 893 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
898 Todo *todo; 894 Todo *todo;
899 for(todo = todos.first(); todo; todo = todos.next()) { 895 for(todo = todos.first(); todo; todo = todos.next()) {
900 insertTodo( todo ); 896 insertTodo( todo );
901 } 897 }
902 finishUpdateCell(); 898 finishUpdateCell();
903 // if ( isVisible()) 899 // if ( isVisible())
904 //qApp->processEvents(); 900 //qApp->processEvents();
905} 901}
906 902
907void MonthViewCell::updateConfig( bool bigFont ) // = false 903void MonthViewCell::updateConfig( bool bigFont ) // = false
908{ 904{
909 905
910 if ( bigFont ) { 906 if ( bigFont ) {
911 QFont fo = KOPrefs::instance()->mMonthViewFont; 907 QFont fo = KOPrefs::instance()->mMonthViewFont;
912 int ps = fo.pointSize() + 2; 908 int ps = fo.pointSize() + 2;
913 if ( ps < 18 ) 909 if ( ps < 18 )
914 ps += 2; 910 ps += 2;
915 fo.setPointSize( ps ); 911 fo.setPointSize( ps );
916 setFont( fo ); 912 setFont( fo );
917 } else 913 } else
918 setFont( KOPrefs::instance()->mMonthViewFont ); 914 setFont( KOPrefs::instance()->mMonthViewFont );
919 915
920 QFontMetrics fm( font() ); 916 QFontMetrics fm( font() );
921 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 917 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
922 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 918 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
923 mHolidayPalette = mStandardPalette; 919 mHolidayPalette = mStandardPalette;
924 mPrimaryPalette = mStandardPalette; 920 mPrimaryPalette = mStandardPalette;
925 mNonPrimaryPalette = mStandardPalette; 921 mNonPrimaryPalette = mStandardPalette;
926 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 922 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
927 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 923 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
928 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 924 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
929 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 925 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
930 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 926 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
931 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 927 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
932 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 928 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
933 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 929 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
934 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 930 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
935 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 931 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
936 } 932 }
937 //updateCell(); 933 //updateCell();
938} 934}
939 935
940void MonthViewCell::enableScrollBars( bool enabled ) 936void MonthViewCell::enableScrollBars( bool enabled )
941{ 937{
942 938
943 return; 939 return;
944 if ( enabled ) { 940 if ( enabled ) {
945 QListBoxItem *fi = firstItem (); 941 QListBoxItem *fi = firstItem ();
946 if (fi ) { 942 if (fi ) {
947 int ihei = fi->height( this ); 943 int ihei = fi->height( this );
948 int hei = numRows () * ihei; 944 int hei = numRows () * ihei;
949 if ( hei < height() - horizontalScrollBar()->height () ) { 945 if ( hei < height() - horizontalScrollBar()->height () ) {
950 setVScrollBarMode(QScrollView::AlwaysOff); 946 setVScrollBarMode(QScrollView::AlwaysOff);
951 } 947 }
952 else 948 else
953 setVScrollBarMode(QScrollView::Auto); 949 setVScrollBarMode(QScrollView::Auto);
954 if ( ihei *3 > height() ) { 950 if ( ihei *3 > height() ) {
955 setHScrollBarMode(QScrollView::AlwaysOff); 951 setHScrollBarMode(QScrollView::AlwaysOff);
956 } 952 }
957 else { 953 else {
958 setHScrollBarMode(QScrollView::Auto); 954 setHScrollBarMode(QScrollView::Auto);
959 } 955 }
960 } else { 956 } else {
961 setVScrollBarMode(QScrollView::Auto); 957 setVScrollBarMode(QScrollView::Auto);
962 setHScrollBarMode(QScrollView::Auto); 958 setHScrollBarMode(QScrollView::Auto);
963 } 959 }
964 } else { 960 } else {
965 setVScrollBarMode(QScrollView::AlwaysOff); 961 setVScrollBarMode(QScrollView::AlwaysOff);
966 setHScrollBarMode(QScrollView::AlwaysOff); 962 setHScrollBarMode(QScrollView::AlwaysOff);
967 } 963 }
968} 964}
969 965
970Incidence *MonthViewCell::selectedIncidence() 966Incidence *MonthViewCell::selectedIncidence()
971{ 967{
972 int index = currentItem(); 968 int index = currentItem();
973 if ( index < 0 ) return 0; 969 if ( index < 0 ) return 0;
974 970
975 MonthViewItem *mitem = 971 MonthViewItem *mitem =
976 static_cast<MonthViewItem *>( item( index ) ); 972 static_cast<MonthViewItem *>( item( index ) );
977 973
978 if ( !mitem ) return 0; 974 if ( !mitem ) return 0;
979 975
980 return mitem->incidence(); 976 return mitem->incidence();
981} 977}
982 978
983QDate MonthViewCell::selectedIncidenceDate() 979QDate MonthViewCell::selectedIncidenceDate()
984{ 980{
985 QDate qd; 981 QDate qd;
986 int index = currentItem(); 982 int index = currentItem();
987 if ( index < 0 ) return qd; 983 if ( index < 0 ) return qd;
988 984
989 MonthViewItem *mitem = 985 MonthViewItem *mitem =
990 static_cast<MonthViewItem *>( item( index ) ); 986 static_cast<MonthViewItem *>( item( index ) );
991 987
992 if ( !mitem ) return qd; 988 if ( !mitem ) return qd;
993 989
994 return mitem->incidenceDate(); 990 return mitem->incidenceDate();
995} 991}
996 992
997void MonthViewCell::deselect() 993void MonthViewCell::deselect()
998{ 994{
999 clearSelection(); 995 clearSelection();
1000 enableScrollBars( false ); 996 enableScrollBars( false );
1001 // updateCell(); 997 // updateCell();
1002} 998}
1003void MonthViewCell::select() 999void MonthViewCell::select()
1004{ 1000{
1005 ;// updateCell(); 1001 ;// updateCell();
1006} 1002}
1007 1003
1008void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1004void MonthViewCell::resizeEvent ( QResizeEvent * e )
1009{ 1005{
1010 if ( !mMonthView->isUpdatePossible() ) 1006 if ( !mMonthView->isUpdatePossible() )
1011 return; 1007 return;
1012 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1008 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1013 deselect(); 1009 deselect();
1014 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1010 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1015 1011
1016 QString text; 1012 QString text;
1017 mLabel->setText( text ); 1013 mLabel->setText( text );
1018 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1014 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1019 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1015 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1020 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1016 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1021 mLabel->resize( mLabelBigSize ); 1017 mLabel->resize( mLabelBigSize );
1022 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1018 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1023 } else { 1019 } else {
1024 mLabel->resize( mLabelSize ); 1020 mLabel->resize( mLabelSize );
1025 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1021 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1026 } 1022 }
1027 mLabel->setText( text ); 1023 mLabel->setText( text );
1028 1024
1029 int size = height() - mLabel->height() - lineWidth()-1; 1025 int size = height() - mLabel->height() - lineWidth()-1;
1030 //qDebug("LW %d ", lineWidth()); 1026 //qDebug("LW %d ", lineWidth());
1031 if ( size > 0 ) 1027 if ( size > 0 )
1032 verticalScrollBar()->setMaximumHeight( size ); 1028 verticalScrollBar()->setMaximumHeight( size );
1033 size = width() - mLabel->width() -lineWidth()-1; 1029 size = width() - mLabel->width() -lineWidth()-1;
1034 if ( size > 0 ) 1030 if ( size > 0 )
1035 horizontalScrollBar()->setMaximumWidth( size ); 1031 horizontalScrollBar()->setMaximumWidth( size );
1036 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1032 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1037 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1033 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1038 // mItemList->resize ( width(), height () ); 1034 // mItemList->resize ( width(), height () );
1039 if ( e ) 1035 if ( e )
1040 KNoScrollListBox::resizeEvent ( e ); 1036 KNoScrollListBox::resizeEvent ( e );
1041} 1037}
1042 1038
1043void MonthViewCell::defaultAction( QListBoxItem *item ) 1039void MonthViewCell::defaultAction( QListBoxItem *item )
1044{ 1040{
1045 1041
1046 if ( !item ) { 1042 if ( !item ) {
1047 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1043 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1048 emit newEventSignal( dt ); 1044 emit newEventSignal( dt );
1049 return; 1045 return;
1050 } 1046 }
1051 1047
1052 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1048 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1053 Incidence *incidence = eventItem->incidence(); 1049 Incidence *incidence = eventItem->incidence();
1054 if ( incidence ) mMonthView->defaultAction( incidence ); 1050 if ( incidence ) mMonthView->defaultAction( incidence );
1055} 1051}
1056void MonthViewCell::showDay() 1052void MonthViewCell::showDay()
1057{ 1053{
1058 emit showDaySignal( date() ); 1054 emit showDaySignal( date() );
1059} 1055}
1060void MonthViewCell::newEvent() 1056void MonthViewCell::newEvent()
1061{ 1057{
1062 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1058 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1063 emit newEventSignal( dt ); 1059 emit newEventSignal( dt );
1064} 1060}
1065void MonthViewCell::cellClicked( QListBoxItem *item ) 1061void MonthViewCell::cellClicked( QListBoxItem *item )
1066{ 1062{
1067 mMonthView->setSelectedCell( this ); 1063 mMonthView->setSelectedCell( this );
1068 if ( item == 0 ) { 1064 if ( item == 0 ) {
1069 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1065 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1070 emit newEventSignal( dt ); 1066 emit newEventSignal( dt );
1071 return; 1067 return;
1072 } 1068 }
1073 1069
1074} 1070}
1075 1071
1076void MonthViewCell::contextMenu( QListBoxItem *item ) 1072void MonthViewCell::contextMenu( QListBoxItem *item )
1077{ 1073{
1078 mMonthView->setPopupCell( this ); 1074 mMonthView->setPopupCell( this );
1079 if ( !item ) { 1075 if ( !item ) {
1080 mMonthView->showContextMenu( 0 ); 1076 mMonthView->showContextMenu( 0 );
1081 return; 1077 return;
1082 } 1078 }
1083 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1079 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1084 Incidence *incidence = eventItem->incidence(); 1080 Incidence *incidence = eventItem->incidence();
1085 if ( incidence ) mMonthView->showContextMenu( incidence ); 1081 if ( incidence ) mMonthView->showContextMenu( incidence );
1086} 1082}
1087 1083
1088void MonthViewCell::selection( QListBoxItem *item ) 1084void MonthViewCell::selection( QListBoxItem *item )
1089{ 1085{
1090 if ( !item ) return; 1086 if ( !item ) return;
1091 1087
1092 mMonthView->setSelectedCell( this ); 1088 mMonthView->setSelectedCell( this );
1093} 1089}
1094 1090
1095 1091
1096// ******************************************************************************* 1092// *******************************************************************************
1097// ******************************************************************************* 1093// *******************************************************************************
1098// ******************************************************************************* 1094// *******************************************************************************
1099 1095
1100 1096
1101KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1097KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1102 : KOEventView( calendar, parent, name ), 1098 : KOEventView( calendar, parent, name ),
1103 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1099 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1104 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1100 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1105{ 1101{
1106 mFlagKeyPressed = false; 1102 mFlagKeyPressed = false;
1107 mShortDayLabelsM = false; 1103 mShortDayLabelsM = false;
1108 mShortDayLabelsW = false; 1104 mShortDayLabelsW = false;
1109 skipResize = false; 1105 skipResize = false;
1110 clPending = true; 1106 clPending = true;
1111 mPopupCell = 0; 1107 mPopupCell = 0;
1112 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1108 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1113 mWidStack = new QWidgetStack( this ); 1109 mWidStack = new QWidgetStack( this );
1114 QVBoxLayout* hb = new QVBoxLayout( this ); 1110 QVBoxLayout* hb = new QVBoxLayout( this );
1115 mMonthView = new QWidget( mWidStack ); 1111 mMonthView = new QWidget( mWidStack );
1116 mWeekView = new QWidget( mWidStack ); 1112 mWeekView = new QWidget( mWidStack );
1117#if QT_VERSION >= 0x030000 1113#if QT_VERSION >= 0x030000
1118 mWidStack->addWidget(mMonthView ); 1114 mWidStack->addWidget(mMonthView );
1119 mWidStack->addWidget(mWeekView ); 1115 mWidStack->addWidget(mWeekView );
1120#else 1116#else
1121 mWidStack->addWidget( mMonthView, 1 ); 1117 mWidStack->addWidget( mMonthView, 1 );
1122 mWidStack->addWidget( mWeekView , 1 ); 1118 mWidStack->addWidget( mWeekView , 1 );
1123#endif 1119#endif
1124 hb->addWidget( mNavigatorBar ); 1120 hb->addWidget( mNavigatorBar );
1125 hb->addWidget( mWidStack ); 1121 hb->addWidget( mWidStack );
1126 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1122 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1127 updatePossible = false; 1123 updatePossible = false;
1128 //updatePossible = true; 1124 //updatePossible = true;
1129 mCells.setAutoDelete( true ); 1125 mCells.setAutoDelete( true );
1130 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1126 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1131 mDayLabels.resize( mDaysPerWeek ); 1127 mDayLabels.resize( mDaysPerWeek );
1132 mDayLabelsW.resize( mDaysPerWeek ); 1128 mDayLabelsW.resize( mDaysPerWeek );
1133 QFont bfont = font(); 1129 QFont bfont = font();
1134 if ( QApplication::desktop()->width() < 650 ) { 1130 if ( QApplication::desktop()->width() < 650 ) {
1135 bfont.setPointSize( bfont.pointSize() - 2 ); 1131 bfont.setPointSize( bfont.pointSize() - 2 );
1136 } 1132 }
1137 bfont.setBold( true ); 1133 bfont.setBold( true );
1138 int i; 1134 int i;
1139 1135
1140 for( i = 0; i < mDaysPerWeek; i++ ) { 1136 for( i = 0; i < mDaysPerWeek; i++ ) {
1141 QLabel *label = new QLabel( mMonthView ); 1137 QLabel *label = new QLabel( mMonthView );
1142 label->setFont(bfont); 1138 label->setFont(bfont);
1143 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1139 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1144 label->setLineWidth(1); 1140 label->setLineWidth(1);
1145 label->setAlignment(AlignCenter); 1141 label->setAlignment(AlignCenter);
1146 mDayLabels.insert( i, label ); 1142 mDayLabels.insert( i, label );
1147 label = new QLabel( mWeekView ); 1143 label = new QLabel( mWeekView );
1148 label->setFont(bfont); 1144 label->setFont(bfont);
1149 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1145 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1150 label->setLineWidth(1); 1146 label->setLineWidth(1);
1151 label->setAlignment(AlignCenter); 1147 label->setAlignment(AlignCenter);
1152 mDayLabelsW.insert( i, label ); 1148 mDayLabelsW.insert( i, label );
1153 } 1149 }
1154 1150
1155 bfont.setBold( false ); 1151 bfont.setBold( false );
1156 mWeekLabels.resize( mNumWeeks+1 ); 1152 mWeekLabels.resize( mNumWeeks+1 );
1157 mWeekLabelsW.resize( 2 ); 1153 mWeekLabelsW.resize( 2 );
1158 for( i = 0; i < mNumWeeks+1; i++ ) { 1154 for( i = 0; i < mNumWeeks+1; i++ ) {
1159 KOWeekButton *label = new KOWeekButton( mMonthView ); 1155 KOWeekButton *label = new KOWeekButton( mMonthView );
1160 label->setFocusPolicy(NoFocus); 1156 label->setFocusPolicy(NoFocus);
1161 label->setFont(bfont); 1157 label->setFont(bfont);
1162 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1158 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1163 label->setFlat(true); 1159 label->setFlat(true);
1164 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1160 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1165 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1161 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1166 //label->setLineWidth(1); 1162 //label->setLineWidth(1);
1167 //label->setAlignment(AlignCenter); 1163 //label->setAlignment(AlignCenter);
1168 mWeekLabels.insert( i, label ); 1164 mWeekLabels.insert( i, label );
1169 } 1165 }
1170 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1166 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1171 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1167 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1172 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1168 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1173 1169
1174 for( i = 0; i < 1+1; i++ ) { 1170 for( i = 0; i < 1+1; i++ ) {
1175 KOWeekButton *label = new KOWeekButton( mWeekView ); 1171 KOWeekButton *label = new KOWeekButton( mWeekView );
1176 label->setFocusPolicy(NoFocus); 1172 label->setFocusPolicy(NoFocus);
1177 label->setFont(bfont); 1173 label->setFont(bfont);
1178 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1174 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1179 label->setFlat(true); 1175 label->setFlat(true);
1180 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1176 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1181 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1177 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1182 //label->setLineWidth(1); 1178 //label->setLineWidth(1);
1183 //label->setAlignment(AlignCenter); 1179 //label->setAlignment(AlignCenter);
1184 mWeekLabelsW.insert( i, label ); 1180 mWeekLabelsW.insert( i, label );
1185 } 1181 }
1186 mWeekLabelsW[1]->setText( i18n("W")); 1182 mWeekLabelsW[1]->setText( i18n("W"));
1187 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1183 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1188 1184
1189 1185
1190 int row, col; 1186 int row, col;
1191 mCells.resize( mNumCells ); 1187 mCells.resize( mNumCells );
1192 for( row = 0; row < mNumWeeks; ++row ) { 1188 for( row = 0; row < mNumWeeks; ++row ) {
1193 for( col = 0; col < mDaysPerWeek; ++col ) { 1189 for( col = 0; col < mDaysPerWeek; ++col ) {
1194 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1190 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1195 mCells.insert( row * mDaysPerWeek + col, cell ); 1191 mCells.insert( row * mDaysPerWeek + col, cell );
1196 1192
1197 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1193 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1198 SLOT( defaultAction( Incidence * ) ) ); 1194 SLOT( defaultAction( Incidence * ) ) );
1199 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1195 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1200 SIGNAL( newEventSignal( QDateTime ) ) ); 1196 SIGNAL( newEventSignal( QDateTime ) ) );
1201 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1197 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1202 SIGNAL( showDaySignal( QDate ) ) ); 1198 SIGNAL( showDaySignal( QDate ) ) );
1203 connect( cell, SIGNAL( nextCell() ), 1199 connect( cell, SIGNAL( nextCell() ),
1204 SLOT( nextCell() ) ); 1200 SLOT( nextCell() ) );
1205 connect( cell, SIGNAL( prevCell() ), 1201 connect( cell, SIGNAL( prevCell() ),
1206 SLOT( prevCell() ) ); 1202 SLOT( prevCell() ) );
1207 } 1203 }
1208 } 1204 }
1209 mCellsW.resize( mDaysPerWeek ); 1205 mCellsW.resize( mDaysPerWeek );
1210 for( col = 0; col < mDaysPerWeek; ++col ) { 1206 for( col = 0; col < mDaysPerWeek; ++col ) {
1211 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1207 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1212 mCellsW.insert( col, cell ); 1208 mCellsW.insert( col, cell );
1213 1209
1214 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1210 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1215 SLOT( defaultAction( Incidence * ) ) ); 1211 SLOT( defaultAction( Incidence * ) ) );
1216 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1212 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1217 SIGNAL( newEventSignal( QDateTime ) ) ); 1213 SIGNAL( newEventSignal( QDateTime ) ) );
1218 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1214 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1219 SIGNAL( showDaySignal( QDate ) ) ); 1215 SIGNAL( showDaySignal( QDate ) ) );
1220 connect( cell, SIGNAL( nextCell() ), 1216 connect( cell, SIGNAL( nextCell() ),
1221 SLOT( nextCell() ) ); 1217 SLOT( nextCell() ) );
1222 connect( cell, SIGNAL( prevCell() ), 1218 connect( cell, SIGNAL( prevCell() ),
1223 SLOT( prevCell() ) ); 1219 SLOT( prevCell() ) );
1224 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1220 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1225 } 1221 }
1226 1222
1227 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1223 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1228 mContextMenu = eventPopup(); 1224 mContextMenu = eventPopup();
1229 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1225 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1230 i18n("New Event..."),this, 1226 i18n("New Event..."),this,
1231 SLOT(slotNewEvent()),false); 1227 SLOT(slotNewEvent()),false);
1232 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1228 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1233 i18n("New Todo..."),this, 1229 i18n("New Todo..."),this,
1234 SLOT(slotNewTodo()),false); 1230 SLOT(slotNewTodo()),false);
1235 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1231 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1236 i18n("Journal"),this, 1232 i18n("Journal"),this,
1237 SLOT(slotEditJournal()),false); 1233 SLOT(slotEditJournal()),false);
1238 1234
1239 1235
1240 1236
1241 QString pathString = ""; 1237 QString pathString = "";
1242 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1238 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1243 if ( QApplication::desktop()->width() < 480 ) 1239 if ( QApplication::desktop()->width() < 480 )
1244 pathString += "icons16/"; 1240 pathString += "icons16/";
1245 } else 1241 } else
1246 pathString += "iconsmini/"; 1242 pathString += "iconsmini/";
1247 mNewItemMenu = new QPopupMenu( this ); 1243 mNewItemMenu = new QPopupMenu( this );
1248 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1244 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1249 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1245 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1250 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1246 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1251 1247
1252 // updateConfig(); //useless here... 1248 // updateConfig(); //useless here...
1253 // ... but we need mWidthLongDayLabel computed 1249 // ... but we need mWidthLongDayLabel computed
1254 QFontMetrics fontmetric(mDayLabels[0]->font()); 1250 QFontMetrics fontmetric(mDayLabels[0]->font());
1255 mWidthLongDayLabel = 0; 1251 mWidthLongDayLabel = 0;
1256 for (int i = 0; i < 7; i++) { 1252 for (int i = 0; i < 7; i++) {
1257 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1253 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1258 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1254 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1259 } 1255 }
1260 1256
1261 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1257 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1262 1258
1263#if 0 1259#if 0
1264 if ( mShowWeekView ) 1260 if ( mShowWeekView )
1265 mWidStack->raiseWidget( mWeekView ); 1261 mWidStack->raiseWidget( mWeekView );
1266 else 1262 else
1267 mWidStack->raiseWidget( mMonthView ); 1263 mWidStack->raiseWidget( mMonthView );
1268#endif 1264#endif
1269 1265
1270 emit incidenceSelected( 0 ); 1266 emit incidenceSelected( 0 );
1271 1267
1272 mComputeLayoutTimer = new QTimer( this ); 1268 mComputeLayoutTimer = new QTimer( this );
1273 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1269 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1274 1270
1275 1271
1276#ifndef DESKTOP_VERSION 1272#ifndef DESKTOP_VERSION
1277 resize( QApplication::desktop()->size() ); 1273 resize( QApplication::desktop()->size() );
1278#else 1274#else
1279 resize(640, 480 ); 1275 resize(640, 480 );
1280 updatePossible = true; 1276 updatePossible = true;
1281#endif 1277#endif
1282 computeLayout(); 1278 computeLayout();
1283 1279
1284 if ( mShowWeekView ) 1280 if ( mShowWeekView )
1285 mWidStack->raiseWidget( mWeekView ); 1281 mWidStack->raiseWidget( mWeekView );
1286 else 1282 else
1287 mWidStack->raiseWidget( mMonthView ); 1283 mWidStack->raiseWidget( mMonthView );
1288} 1284}
1289 1285
1290KOMonthView::~KOMonthView() 1286KOMonthView::~KOMonthView()
1291{ 1287{
1292 delete mContextMenu; 1288 delete mContextMenu;
1293} 1289}
1294 1290
1295void KOMonthView::selectInternalWeekNum ( int n ) 1291void KOMonthView::selectInternalWeekNum ( int n )
1296{ 1292{
1297 switchView(); 1293 switchView();
1298 if ( !KOPrefs::instance()->mMonthViewWeek ) 1294 if ( !KOPrefs::instance()->mMonthViewWeek )
1299 emit selectMonth (); 1295 emit selectMonth ();
1300 else 1296 else
1301 emit selectWeekNum ( n ); 1297 emit selectWeekNum ( n );
1302} 1298}
1303 1299
1304int KOMonthView::currentWeek() 1300int KOMonthView::currentWeek()
1305{ 1301{
1306 if ( mShowWeekView ) 1302 if ( mShowWeekView )
1307 return mWeekLabelsW[0]->getWeekNum(); 1303 return mWeekLabelsW[0]->getWeekNum();
1308 return mWeekLabels[0]->getWeekNum(); 1304 return mWeekLabels[0]->getWeekNum();
1309} 1305}
1310void KOMonthView::switchView() 1306void KOMonthView::switchView()
1311{ 1307{
1312 if ( selectedCell( ) ) 1308 if ( selectedCell( ) )
1313 selectedCell()->deselect(); 1309 selectedCell()->deselect();
1314 mShowWeekView = !mShowWeekView; 1310 mShowWeekView = !mShowWeekView;
1315 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1311 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1316 if ( clPending ) { 1312 if ( clPending ) {
1317 computeLayout(); 1313 computeLayout();
1318 updateConfig(); 1314 updateConfig();
1319 } 1315 }
1320 if ( mShowWeekView ) 1316 if ( mShowWeekView )
1321 mWidStack->raiseWidget( mWeekView ); 1317 mWidStack->raiseWidget( mWeekView );
1322 else 1318 else
1323 mWidStack->raiseWidget( mMonthView ); 1319 mWidStack->raiseWidget( mMonthView );
1324 clPending = false; 1320 clPending = false;
1325} 1321}
1326 1322
1327int KOMonthView::maxDatesHint() 1323int KOMonthView::maxDatesHint()
1328{ 1324{
1329 return mNumCells; 1325 return mNumCells;
1330} 1326}
1331 1327
1332int KOMonthView::currentDateCount() 1328int KOMonthView::currentDateCount()
1333{ 1329{
1334 return mNumCells; 1330 return mNumCells;
1335} 1331}
1336 1332
1337QPtrList<Incidence> KOMonthView::selectedIncidences() 1333QPtrList<Incidence> KOMonthView::selectedIncidences()
1338{ 1334{
1339 QPtrList<Incidence> selected; 1335 QPtrList<Incidence> selected;
1340 1336
1341 if ( mSelectedCell ) { 1337 if ( mSelectedCell ) {
1342 Incidence *incidence = mSelectedCell->selectedIncidence(); 1338 Incidence *incidence = mSelectedCell->selectedIncidence();
1343 if ( incidence ) selected.append( incidence ); 1339 if ( incidence ) selected.append( incidence );
1344 } 1340 }
1345 1341
1346 return selected; 1342 return selected;
1347} 1343}
1348 1344
1349DateList KOMonthView::selectedDates() 1345DateList KOMonthView::selectedDates()
1350{ 1346{
1351 DateList selected; 1347 DateList selected;
1352 1348
1353 if ( mSelectedCell ) { 1349 if ( mSelectedCell ) {
1354 QDate qd = mSelectedCell->selectedIncidenceDate(); 1350 QDate qd = mSelectedCell->selectedIncidenceDate();
1355 if ( qd.isValid() ) selected.append( qd ); 1351 if ( qd.isValid() ) selected.append( qd );
1356 } 1352 }
1357 1353
1358 return selected; 1354 return selected;
1359} 1355}
1360 1356
1361void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1357void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1362 const QDate &td) 1358 const QDate &td)
1363{ 1359{
1364#ifndef KORG_NOPRINTER 1360#ifndef KORG_NOPRINTER
1365 calPrinter->preview(CalPrinter::Month, fd, td); 1361 calPrinter->preview(CalPrinter::Month, fd, td);
1366#endif 1362#endif
1367} 1363}
1368 1364
1369void KOMonthView::updateConfig() 1365void KOMonthView::updateConfig()
1370{ 1366{
1371 1367
1372 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1368 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1373 1369
1374 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1370 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1375 mWeekStartsMonday = true; 1371 mWeekStartsMonday = true;
1376 } 1372 }
1377 QFontMetrics fontmetric(mDayLabels[0]->font()); 1373 QFontMetrics fontmetric(mDayLabels[0]->font());
1378 mWidthLongDayLabel = 0; 1374 mWidthLongDayLabel = 0;
1379 1375
1380 for (int i = 0; i < 7; i++) { 1376 for (int i = 0; i < 7; i++) {
1381 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1377 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1382 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1378 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1383 } 1379 }
1384 bool temp = mShowSatSunComp ; 1380 bool temp = mShowSatSunComp ;
1385 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1381 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1386 if ( ! mShowWeekView ) { 1382 if ( ! mShowWeekView ) {
1387 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1383 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1388 computeLayout(); 1384 computeLayout();
1389 } 1385 }
1390 updateDayLabels(); 1386 updateDayLabels();
1391 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1387 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1392 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1388 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1393 //resizeEvent( 0 ); 1389 //resizeEvent( 0 );
1394 for (uint i = 0; i < mCells.count(); ++i) { 1390 for (uint i = 0; i < mCells.count(); ++i) {
1395 mCells[i]->updateConfig(); 1391 mCells[i]->updateConfig();
1396 } 1392 }
1397 1393
1398 for (uint i = 0; i < mCellsW.count(); ++i) { 1394 for (uint i = 0; i < mCellsW.count(); ++i) {
1399 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1395 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1400 } 1396 }
1401#ifdef DESKTOP_VERSION 1397#ifdef DESKTOP_VERSION
1402 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1398 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1403#endif 1399#endif
1404 updateView(); 1400 updateView();
1405} 1401}
1406 1402
1407void KOMonthView::updateDayLabels() 1403void KOMonthView::updateDayLabels()
1408{ 1404{
1409 1405
1410 QPtrVector<QLabel> *mDayLabelsT; 1406 QPtrVector<QLabel> *mDayLabelsT;
1411 1407
1412 mDayLabelsT = &mDayLabelsW; 1408 mDayLabelsT = &mDayLabelsW;
1413 for (int i = 0; i < 7; i++) { 1409 for (int i = 0; i < 7; i++) {
1414 { 1410 {
1415 bool show = mShortDayLabelsW; 1411 bool show = mShortDayLabelsW;
1416 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1412 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1417 show = true; 1413 show = true;
1418 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1414 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1419 } 1415 }
1420 } 1416 }
1421 mDayLabelsT = &mDayLabels; 1417 mDayLabelsT = &mDayLabels;
1422 for (int i = 0; i < 7; i++) { 1418 for (int i = 0; i < 7; i++) {
1423 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1419 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1424 bool show = mShortDayLabelsM; 1420 bool show = mShortDayLabelsM;
1425 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1421 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1426 show = true; 1422 show = true;
1427 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1423 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1428 } else { 1424 } else {
1429 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1425 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1430 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1426 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1431 1427
1432 } 1428 }
1433 } 1429 }
1434 1430
1435} 1431}
1436 1432
1437void KOMonthView::clearList() 1433void KOMonthView::clearList()
1438{ 1434{
1439 unsigned int i; 1435 unsigned int i;
1440 for( i = 0; i < mCells.size(); ++i ) { 1436 for( i = 0; i < mCells.size(); ++i ) {
1441 mCells[i]->clear(); 1437 mCells[i]->clear();
1442 } 1438 }
1443 for( i = 0; i < mCellsW.size(); ++i ) { 1439 for( i = 0; i < mCellsW.size(); ++i ) {
1444 mCellsW[i]->clear(); 1440 mCellsW[i]->clear();
1445 } 1441 }
1446} 1442}
1447void KOMonthView::showDates(const QDate &start, const QDate &) 1443void KOMonthView::showDates(const QDate &start, const QDate &)
1448{ 1444{
1449 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1445 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1450 1446
1451 QPtrVector<MonthViewCell> *cells; 1447 QPtrVector<MonthViewCell> *cells;
1452 QPtrVector<QLabel> *dayLabels; 1448 QPtrVector<QLabel> *dayLabels;
1453 QPtrVector<KOWeekButton> *weekLabels; 1449 QPtrVector<KOWeekButton> *weekLabels;
1454 int weekNum = 6; 1450 int weekNum = 6;
1455 mStartDate = start; 1451 mStartDate = start;
1456 if ( mShowWeekView ) { 1452 if ( mShowWeekView ) {
1457 weekNum = 1; 1453 weekNum = 1;
1458 cells = &mCellsW; 1454 cells = &mCellsW;
1459 dayLabels = &mDayLabelsW; 1455 dayLabels = &mDayLabelsW;
1460 weekLabels = &mWeekLabelsW; 1456 weekLabels = &mWeekLabelsW;
1461 if ( !KGlobal::locale()->weekStartsMonday() ) { 1457 if ( !KGlobal::locale()->weekStartsMonday() ) {
1462 mStartDate = mStartDate.addDays( 1 ); 1458 mStartDate = mStartDate.addDays( 1 );
1463 } 1459 }
1464 } else { 1460 } else {
1465 cells = &mCells; 1461 cells = &mCells;
1466 dayLabels = &mDayLabels; 1462 dayLabels = &mDayLabels;
1467 weekLabels = &mWeekLabels; 1463 weekLabels = &mWeekLabels;
1468 } 1464 }
1469 1465
1470 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1466 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1471 1467
1472 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1468 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1473 mWeekStartsMonday = true; 1469 mWeekStartsMonday = true;
1474 } 1470 }
1475 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1471 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1476 1472
1477 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1473 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1478 mStartDate = mStartDate.addDays( -1 ); 1474 mStartDate = mStartDate.addDays( -1 );
1479 } 1475 }
1480 bool primary = false; 1476 bool primary = false;
1481 uint i; 1477 uint i;
1482 for( i = 0; i < (*cells).size(); ++i ) { 1478 for( i = 0; i < (*cells).size(); ++i ) {
1483 QDate date = mStartDate.addDays( i ); 1479 QDate date = mStartDate.addDays( i );
1484 (*cells)[i]->setDate( date ); 1480 (*cells)[i]->setDate( date );
1485 1481
1486#ifndef KORG_NOPLUGINS 1482#ifndef KORG_NOPLUGINS
1487 // add holiday, if present 1483 // add holiday, if present
1488 QString hstring(KOCore::self()->holiday(date)); 1484 QString hstring(KOCore::self()->holiday(date));
1489 (*cells)[i]->setHoliday( hstring ); 1485 (*cells)[i]->setHoliday( hstring );
1490#endif 1486#endif
1491 1487
1492 } 1488 }
1493 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1489 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1494 for( i = 0; i < weekNum; ++i ) { 1490 for( i = 0; i < weekNum; ++i ) {
1495 int wno; 1491 int wno;
1496 // remember, according to ISO 8601, the first week of the year is the 1492 // remember, according to ISO 8601, the first week of the year is the
1497 // first week that contains a thursday. Thus we must subtract off 4, 1493 // first week that contains a thursday. Thus we must subtract off 4,
1498 // not just 1. 1494 // not just 1.
1499 int dayOfYear = date.dayOfYear(); 1495 int dayOfYear = date.dayOfYear();
1500 if (dayOfYear % 7 != 0) 1496 if (dayOfYear % 7 != 0)
1501 wno = dayOfYear / 7 + 1; 1497 wno = dayOfYear / 7 + 1;
1502 else 1498 else
1503 wno =dayOfYear / 7; 1499 wno =dayOfYear / 7;
1504 (*weekLabels)[i]->setWeekNum( wno ); 1500 (*weekLabels)[i]->setWeekNum( wno );
1505 date = date.addDays( 7 ); 1501 date = date.addDays( 7 );
1506 } 1502 }
1507 updateView(); 1503 updateView();
1508} 1504}
1509 1505
1510void KOMonthView::showEvents(QPtrList<Event>) 1506void KOMonthView::showEvents(QPtrList<Event>)
1511{ 1507{
1512 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1508 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1513} 1509}
1514 1510
1515void KOMonthView::changeEventDisplay(Event *, int) 1511void KOMonthView::changeEventDisplay(Event *, int)
1516{ 1512{
1517 // this should be re-written to be much more efficient, but this 1513 // this should be re-written to be much more efficient, but this
1518 // quick-and-dirty-hack gets the job done for right now. 1514 // quick-and-dirty-hack gets the job done for right now.
1519 //qDebug("KOMonthView::changeEventDisplay "); 1515 //qDebug("KOMonthView::changeEventDisplay ");
1520 updateView(); 1516 updateView();
1521} 1517}
1522 1518
1523void KOMonthView::updateView() 1519void KOMonthView::updateView()
1524{ 1520{
1525 1521
1526 if ( !updatePossible ) 1522 if ( !updatePossible )
1527 return; 1523 return;
1528 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1524 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1529 //QTime ti; 1525 //QTime ti;
1530 //ti.start(); 1526 //ti.start();
1531 clearSelection(); 1527 clearSelection();
1532 QPtrVector<MonthViewCell> *cells; 1528 QPtrVector<MonthViewCell> *cells;
1533 if ( mShowWeekView ) { 1529 if ( mShowWeekView ) {
1534 cells = &mCellsW; 1530 cells = &mCellsW;
1535 } else { 1531 } else {
1536 cells = &mCells; 1532 cells = &mCells;
1537 } 1533 }
1538#if 1 1534#if 1
1539 int i; 1535 int i;
1540 int timeSpan = (*cells).size()-1; 1536 int timeSpan = (*cells).size()-1;
1541 if ( KOPrefs::instance()->mMonthViewWeek ) 1537 if ( KOPrefs::instance()->mMonthViewWeek )
1542 timeSpan = 6; 1538 timeSpan = 6;
1543 for( i = 0; i < timeSpan + 1; ++i ) { 1539 for( i = 0; i < timeSpan + 1; ++i ) {
1544 (*cells)[i]->startUpdateCell(); 1540 (*cells)[i]->startUpdateCell();
1545 } 1541 }
1546 1542
1547 QPtrList<Event> events = calendar()->events(); 1543 QPtrList<Event> events = calendar()->events();
1548 Event *event; 1544 Event *event;
1549 QDateTime dt; 1545 QDateTime dt;
1550 bool ok; 1546 bool ok;
1551 QDate endDate = mStartDate.addDays( timeSpan ); 1547 QDate endDate = mStartDate.addDays( timeSpan );
1552 for( event = events.first(); event; event = events.next() ) { // for event 1548 for( event = events.first(); event; event = events.next() ) { // for event
1553 if ( event->doesRecur() ) { 1549 if ( event->doesRecur() ) {
1554 bool last; 1550 bool last;
1555 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1551 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1556 QDateTime incidenceEnd; 1552 QDateTime incidenceEnd;
1557 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1553 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1558 bool invalid = false; 1554 bool invalid = false;
1559 while( true ) { 1555 while( true ) {
1560 if ( incidenceStart.isValid() ) { 1556 if ( incidenceStart.isValid() ) {
1561 incidenceEnd = incidenceStart.addDays( eventlen ); 1557 incidenceEnd = incidenceStart.addDays( eventlen );
1562 int st = incidenceStart.date().daysTo( endDate ); 1558 int st = incidenceStart.date().daysTo( endDate );
1563 if ( st >= 0 ) { // start before timeend 1559 if ( st >= 0 ) { // start before timeend
1564 int end = mStartDate.daysTo( incidenceEnd.date() ); 1560 int end = mStartDate.daysTo( incidenceEnd.date() );
1565 if ( end >= 0 ) { // end after timestart --- got one! 1561 if ( end >= 0 ) { // end after timestart --- got one!
1566 //normalize 1562 //normalize
1567 st = timeSpan - st; 1563 st = timeSpan - st;
1568 if ( st < 0 ) st = 0; 1564 if ( st < 0 ) st = 0;
1569 if ( end > timeSpan ) end = timeSpan; 1565 if ( end > timeSpan ) end = timeSpan;
1570 int iii; 1566 int iii;
1571 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1567 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1572 for ( iii = st;iii<= end;++iii) 1568 for ( iii = st;iii<= end;++iii)
1573 (*cells)[iii]->insertEvent( event ); 1569 (*cells)[iii]->insertEvent( event );
1574 } 1570 }
1575 } 1571 }
1576 } else { 1572 } else {
1577 if ( invalid ) 1573 if ( invalid )
1578 break; 1574 break;
1579 invalid = true; 1575 invalid = true;
1580 //qDebug("invalid %s", event->summary().latin1()); 1576 //qDebug("invalid %s", event->summary().latin1());
1581 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1577 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1582 } 1578 }
1583 if ( last ) 1579 if ( last )
1584 break; 1580 break;
1585 bool ok; 1581 bool ok;
1586 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1582 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1587 if ( ! ok ) 1583 if ( ! ok )
1588 break; 1584 break;
1589 if ( incidenceStart.date() > endDate ) 1585 if ( incidenceStart.date() > endDate )
1590 break; 1586 break;
1591 } 1587 }
1592 } else { // no recur 1588 } else { // no recur
1593 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1589 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1594 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1590 if ( event->uid().left(15) == QString("last-syncEvent-") )
1595 continue; 1591 continue;
1596 int st = event->dtStart().date().daysTo( endDate ); 1592 int st = event->dtStart().date().daysTo( endDate );
1597 if ( st >= 0 ) { // start before timeend 1593 if ( st >= 0 ) { // start before timeend
1598 int end = mStartDate.daysTo( event->dtEnd().date() ); 1594 int end = mStartDate.daysTo( event->dtEnd().date() );
1599 if ( end >= 0 ) { // end after timestart --- got one! 1595 if ( end >= 0 ) { // end after timestart --- got one!
1600 //normalize 1596 //normalize
1601 st = timeSpan - st; 1597 st = timeSpan - st;
1602 if ( st < 0 ) st = 0; 1598 if ( st < 0 ) st = 0;
1603 if ( end > timeSpan ) end = timeSpan; 1599 if ( end > timeSpan ) end = timeSpan;
1604 int iii; 1600 int iii;
1605 for ( iii = st;iii<= end;++iii) 1601 for ( iii = st;iii<= end;++iii)
1606 (*cells)[iii]->insertEvent( event ); 1602 (*cells)[iii]->insertEvent( event );
1607 } 1603 }
1608 } 1604 }
1609 } 1605 }
1610 } 1606 }
1611 // insert due todos 1607 // insert due todos
1612 QPtrList<Todo> todos = calendar()->todos( ); 1608 QPtrList<Todo> todos = calendar()->todos( );
1613 Todo *todo; 1609 Todo *todo;
1614 for(todo = todos.first(); todo; todo = todos.next()) { 1610 for(todo = todos.first(); todo; todo = todos.next()) {
1615 //insertTodo( todo ); 1611 //insertTodo( todo );
1616 if ( todo->hasDueDate() ) { 1612 if ( todo->hasDueDate() ) {
1617 int day = mStartDate.daysTo( todo->dtDue().date() ); 1613 int day = mStartDate.daysTo( todo->dtDue().date() );
1618 if ( day >= 0 && day < timeSpan + 1) { 1614 if ( day >= 0 && day < timeSpan + 1) {
1619 (*cells)[day]->insertTodo( todo ); 1615 (*cells)[day]->insertTodo( todo );
1620 } 1616 }
1621 } 1617 }
1622 } 1618 }
1623 1619
1624 for( i = 0; i < timeSpan+1; ++i ) { 1620 for( i = 0; i < timeSpan+1; ++i ) {
1625 (*cells)[i]->finishUpdateCell(); 1621 (*cells)[i]->finishUpdateCell();
1626 } 1622 }
1627 processSelectionChange(); 1623 processSelectionChange();
1628 //qApp->processEvents(); 1624 //qApp->processEvents();
1629 for( i = 0; i < timeSpan+1; ++i ) { 1625 for( i = 0; i < timeSpan+1; ++i ) {
1630 (*cells)[i]->repaintfinishUpdateCell(); 1626 (*cells)[i]->repaintfinishUpdateCell();
1631 } 1627 }
1632 setKeyBFocus(); 1628 setKeyBFocus();
1633#else 1629#else
1634 // old code 1630 // old code
1635 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1631 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1636 int i; 1632 int i;
1637 for( i = 0; i < (*cells).count(); ++i ) { 1633 for( i = 0; i < (*cells).count(); ++i ) {
1638 (*cells)[i]->updateCell(); 1634 (*cells)[i]->updateCell();
1639 } 1635 }
1640 1636
1641 //qDebug("KOMonthView::updateView() "); 1637 //qDebug("KOMonthView::updateView() ");
1642 processSelectionChange(); 1638 processSelectionChange();
1643 // qDebug("---------------------------------------------------------------------+ "); 1639 // qDebug("---------------------------------------------------------------------+ ");
1644 (*cells)[0]->setFocus(); 1640 (*cells)[0]->setFocus();
1645#endif 1641#endif
1646 1642
1647 //qDebug("update time %d ", ti.elapsed()); 1643 //qDebug("update time %d ", ti.elapsed());
1648} 1644}
1649 1645
1650void KOMonthView::setKeyBoardFocus() 1646void KOMonthView::setKeyBoardFocus()
1651{ 1647{
1652 //qDebug("KOMonthView::setKeyBoardFocus() "); 1648 //qDebug("KOMonthView::setKeyBoardFocus() ");
1653 bool shootAgain = false; 1649 bool shootAgain = false;
1654 if ( mShowWeekView ) { 1650 if ( mShowWeekView ) {
1655 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1651 shootAgain = !mWeekLabelsW[1]->hasFocus();
1656 mWeekLabelsW[1]->setFocus(); 1652 mWeekLabelsW[1]->setFocus();
1657 } 1653 }
1658 else { 1654 else {
1659 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1655 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1660 mWeekLabels[mNumWeeks]->setFocus(); 1656 mWeekLabels[mNumWeeks]->setFocus();
1661 } 1657 }
1662 if ( shootAgain ) { 1658 if ( shootAgain ) {
1663 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1659 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1664 } 1660 }
1665} 1661}
1666void KOMonthView::setKeyBFocus() 1662void KOMonthView::setKeyBFocus()
1667{ 1663{
1668 //qDebug("KOMonthView::setKeyBFocus() "); 1664 //qDebug("KOMonthView::setKeyBFocus() ");
1669 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1665 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1670} 1666}
1671void KOMonthView::resizeEvent(QResizeEvent * e) 1667void KOMonthView::resizeEvent(QResizeEvent * e)
1672{ 1668{
1673 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1669 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1674 if ( isVisible() ) { 1670 if ( isVisible() ) {
1675 //qDebug("KOMonthView::isVisible "); 1671 //qDebug("KOMonthView::isVisible ");
1676 slotComputeLayout(); 1672 slotComputeLayout();
1677 } else 1673 } else
1678 mComputeLayoutTimer->start( 100 ); 1674 mComputeLayoutTimer->start( 100 );
1679} 1675}
1680 1676
1681void KOMonthView::slotComputeLayout() 1677void KOMonthView::slotComputeLayout()
1682{ 1678{
1683 mComputeLayoutTimer->stop(); 1679 mComputeLayoutTimer->stop();
1684 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1680 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1685 computeLayout(); 1681 computeLayout();
1686 clPending = true; 1682 clPending = true;
1687 setKeyBFocus(); 1683 setKeyBFocus();
1688} 1684}
1689void KOMonthView::computeLayoutWeek() 1685void KOMonthView::computeLayoutWeek()
1690{ 1686{
1691 static int lastWid = 0; 1687 static int lastWid = 0;
1692 static int lastHei = 0; 1688 static int lastHei = 0;
1693 int daysToShow; 1689 int daysToShow;
1694 bool combinedSatSun = false; 1690 bool combinedSatSun = false;
1695 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1691 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1696 daysToShow = 6; 1692 daysToShow = 6;
1697 combinedSatSun = true; 1693 combinedSatSun = true;
1698 } 1694 }
1699 int tWid = topLevelWidget()->size().width(); 1695 int tWid = topLevelWidget()->size().width();
1700 int tHei = topLevelWidget()->size().height(); 1696 int tHei = topLevelWidget()->size().height();
1701 1697
1702 int wid = width();//e 1698 int wid = width();//e
1703 int hei = height()-1-mNavigatorBar->height(); 1699 int hei = height()-1-mNavigatorBar->height();
1704 1700
1705 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1701 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1706 return; 1702 return;
1707 1703
1708 if ( lastWid == width() && lastHei == height() ) { 1704 if ( lastWid == width() && lastHei == height() ) {
1709 //qDebug("KOListWeekView::No compute layout needed "); 1705 //qDebug("KOListWeekView::No compute layout needed ");
1710 return; 1706 return;
1711 } 1707 }
1712 lastWid = width(); 1708 lastWid = width();
1713 lastHei = height(); 1709 lastHei = height();
1714 1710
1715 1711
1716 if ( wid < hei ) 1712 if ( wid < hei )
1717 daysToShow = 2; 1713 daysToShow = 2;
1718 else 1714 else
1719 daysToShow = 3; 1715 daysToShow = 3;
1720 mShowSatSunComp = true; 1716 mShowSatSunComp = true;
1721 combinedSatSun = true; 1717 combinedSatSun = true;
1722 1718
1723 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1719 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1724 QFontMetrics fm ( mWeekLabels[0]->font() ); 1720 QFontMetrics fm ( mWeekLabels[0]->font() );
1725 int weeklabelwid = fm.width( "888" ); 1721 int weeklabelwid = fm.width( "888" );
1726 wid -= weeklabelwid; 1722 wid -= weeklabelwid;
1727 1723
1728 int colWid = wid / daysToShow; 1724 int colWid = wid / daysToShow;
1729 int lastCol = wid - ( colWid*6 ); 1725 int lastCol = wid - ( colWid*6 );
1730 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1726 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1731 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1727 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1732 int colModulo = wid % daysToShow; 1728 int colModulo = wid % daysToShow;
1733 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1729 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1734 //qDebug("rowmod %d ", rowModulo); 1730 //qDebug("rowmod %d ", rowModulo);
1735 int i; 1731 int i;
1736 int x,y,w,h; 1732 int x,y,w,h;
1737 x= 0; 1733 x= 0;
1738 y= 0; 1734 y= 0;
1739 w = colWid; 1735 w = colWid;
1740 h = dayLabelHei ; 1736 h = dayLabelHei ;
1741 for ( i = 0; i < 7; i++) { 1737 for ( i = 0; i < 7; i++) {
1742 if ( i && !( i % daysToShow) && i < 6) { 1738 if ( i && !( i % daysToShow) && i < 6) {
1743 y += hei/(5-daysToShow); 1739 y += hei/(5-daysToShow);
1744 x = 0; 1740 x = 0;
1745 w = colWid; 1741 w = colWid;
1746 } 1742 }
1747 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1743 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1748 ++w; 1744 ++w;
1749 } 1745 }
1750 if ( i >= 5 ) { 1746 if ( i >= 5 ) {
1751 int wi = width() - x - weeklabelwid; 1747 int wi = width() - x - weeklabelwid;
1752 if ( i == 5 ) { 1748 if ( i == 5 ) {
1753 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1749 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1754 } else { 1750 } else {
1755 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1751 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1756 } 1752 }
1757 x = x - w + wi - (wi/2 ); 1753 x = x - w + wi - (wi/2 );
1758 } 1754 }
1759 else { 1755 else {
1760 int wi = w; 1756 int wi = w;
1761 if ( !(( i+1) % daysToShow)) { 1757 if ( !(( i+1) % daysToShow)) {
1762 wi = width() - x - weeklabelwid; 1758 wi = width() - x - weeklabelwid;
1763 } 1759 }
1764 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1760 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1765 } 1761 }
1766 x += w; 1762 x += w;
1767 } 1763 }
1768 x= 0; 1764 x= 0;
1769 y= dayLabelHei; 1765 y= dayLabelHei;
1770 w = colWid; 1766 w = colWid;
1771 h = cellHei; 1767 h = cellHei;
1772 int max = 0; 1768 int max = 0;
1773 for ( i = 0; i < mCellsW.count(); ++i) { 1769 for ( i = 0; i < mCellsW.count(); ++i) {
1774 if ( i > 6 ) { 1770 if ( i > 6 ) {
1775 mCellsW[i]->hide(); 1771 mCellsW[i]->hide();
1776 continue; 1772 continue;
1777 } 1773 }
1778 1774
1779 w = colWid; 1775 w = colWid;
1780 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1776 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1781 ++w; 1777 ++w;
1782 } 1778 }
1783 if ( i == (daysToShow-1-rowModulo)*7) 1779 if ( i == (daysToShow-1-rowModulo)*7)
1784 ++h; 1780 ++h;
1785 1781
1786 if ( i >= 5 ) { 1782 if ( i >= 5 ) {
1787 if ( i ==5 ) { 1783 if ( i ==5 ) {
1788 max = h/2; 1784 max = h/2;
1789 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1785 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1790 x -= w ;y += h/2; 1786 x -= w ;y += h/2;
1791 } else { 1787 } else {
1792 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1788 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1793 ++w; 1789 ++w;
1794 } 1790 }
1795 max = h-h/2; 1791 max = h-h/2;
1796 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1792 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1797 y -= h/2; 1793 y -= h/2;
1798 } 1794 }
1799 } else { 1795 } else {
1800 max = h; 1796 max = h;
1801 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1797 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1802 } 1798 }
1803 1799
1804 1800
1805 x += w; 1801 x += w;
1806 if ( x + w/2 > wid ) { 1802 if ( x + w/2 > wid ) {
1807 x = 0; 1803 x = 0;
1808 y += h+dayLabelHei ; 1804 y += h+dayLabelHei ;
1809 } 1805 }
1810 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1806 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1811 } 1807 }
1812 y= dayLabelHei; 1808 y= dayLabelHei;
1813 h = cellHei ; 1809 h = cellHei ;
1814 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1810 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1815 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1811 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1816 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1812 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1817 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1813 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1818 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1814 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1819 updateDayLabels(); 1815 updateDayLabels();
1820 //bool forceUpdate = !updatePossible; 1816 //bool forceUpdate = !updatePossible;
1821 updatePossible = true; 1817 updatePossible = true;
1822 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1818 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1823 //if ( forceUpdate ) 1819 //if ( forceUpdate )
1824 // updateView(); 1820 // updateView();
1825} 1821}
1826void KOMonthView::computeLayout() 1822void KOMonthView::computeLayout()
1827{ 1823{
1828 1824
1829 1825
1830 static int lastWid = 0; 1826 static int lastWid = 0;
1831 static int lastHei = 0; 1827 static int lastHei = 0;
1832 1828
1833 if ( mShowWeekView ){ 1829 if ( mShowWeekView ){
1834 computeLayoutWeek(); 1830 computeLayoutWeek();
1835 return; 1831 return;
1836 } 1832 }
1837 int daysToShow = 7; 1833 int daysToShow = 7;
1838 bool combinedSatSun = false; 1834 bool combinedSatSun = false;
1839 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1835 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1840 daysToShow = 6; 1836 daysToShow = 6;
1841 combinedSatSun = true; 1837 combinedSatSun = true;
1842 } 1838 }
1843 int tWid = topLevelWidget()->size().width(); 1839 int tWid = topLevelWidget()->size().width();
1844 int tHei = topLevelWidget()->size().height(); 1840 int tHei = topLevelWidget()->size().height();
1845 1841
1846 int wid = width();//e 1842 int wid = width();//e
1847 int hei = height()-1-mNavigatorBar->height(); 1843 int hei = height()-1-mNavigatorBar->height();
1848 1844
1849 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1845 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1850 return; 1846 return;
1851 } 1847 }
1852 if ( lastWid == width() && lastHei == height() ){ 1848 if ( lastWid == width() && lastHei == height() ){
1853 //qDebug("KOMonthview::No compute layout needed "); 1849 //qDebug("KOMonthview::No compute layout needed ");
1854 return; 1850 return;
1855 } 1851 }
1856 1852
1857 lastWid = width(); 1853 lastWid = width();
1858 lastHei = height(); 1854 lastHei = height();
1859 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1855 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1860 QFontMetrics fm ( mWeekLabels[0]->font() ); 1856 QFontMetrics fm ( mWeekLabels[0]->font() );
1861 int weeklabelwid = fm.width( "888" ); 1857 int weeklabelwid = fm.width( "888" );
1862 wid -= weeklabelwid; 1858 wid -= weeklabelwid;
1863 1859
1864 int colWid = wid / daysToShow; 1860 int colWid = wid / daysToShow;
1865 int lastCol = wid - ( colWid*6 ); 1861 int lastCol = wid - ( colWid*6 );
1866 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1862 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1867 int cellHei = (hei - dayLabelHei) /6; 1863 int cellHei = (hei - dayLabelHei) /6;
1868 int colModulo = wid % daysToShow; 1864 int colModulo = wid % daysToShow;
1869 int rowModulo = (hei- dayLabelHei) % 6; 1865 int rowModulo = (hei- dayLabelHei) % 6;
1870 //qDebug("rowmod %d ", rowModulo); 1866 //qDebug("rowmod %d ", rowModulo);
1871 int i; 1867 int i;
1872 int x,y,w,h; 1868 int x,y,w,h;
1873 x= 0; 1869 x= 0;
1874 y= 0; 1870 y= 0;
1875 w = colWid; 1871 w = colWid;
1876 h = dayLabelHei ; 1872 h = dayLabelHei ;
1877 for ( i = 0; i < 7; i++) { 1873 for ( i = 0; i < 7; i++) {
1878 if ( i == daysToShow-colModulo ) 1874 if ( i == daysToShow-colModulo )
1879 ++w; 1875 ++w;
1880 if ( combinedSatSun ) { 1876 if ( combinedSatSun ) {
1881 if ( i >= daysToShow-1 ) { 1877 if ( i >= daysToShow-1 ) {
1882 1878
1883 if ( i == 6 ) 1879 if ( i == 6 )
1884 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 1880 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
1885 else 1881 else
1886 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1882 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1887 x -= w/2 ; 1883 x -= w/2 ;
1888 } 1884 }
1889 else 1885 else
1890 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1886 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1891 } else 1887 } else
1892 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1888 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1893 x += w; 1889 x += w;
1894 } 1890 }
1895 x= 0; 1891 x= 0;
1896 y= dayLabelHei; 1892 y= dayLabelHei;
1897 w = colWid; 1893 w = colWid;
1898 h = cellHei ; 1894 h = cellHei ;
1899 int max = 0; 1895 int max = 0;
1900 for ( i = 0; i < mCells.count(); ++i) { 1896 for ( i = 0; i < mCells.count(); ++i) {
1901 //qDebug("iii %d ", i); 1897 //qDebug("iii %d ", i);
1902 w = colWid; 1898 w = colWid;
1903 if ( ((i) % 7) >= 7-colModulo ) { 1899 if ( ((i) % 7) >= 7-colModulo ) {
1904 ++w; 1900 ++w;
1905 } 1901 }
1906 if ( i == (6-rowModulo)*7) 1902 if ( i == (6-rowModulo)*7)
1907 ++h; 1903 ++h;
1908 if ( combinedSatSun ) { 1904 if ( combinedSatSun ) {
1909 if ( (i)%7 >= daysToShow-1 ) { 1905 if ( (i)%7 >= daysToShow-1 ) {
1910 if ( (i)%7 == daysToShow-1 ) { 1906 if ( (i)%7 == daysToShow-1 ) {
1911 w = width()-x-weeklabelwid; 1907 w = width()-x-weeklabelwid;
1912 max = h/2; 1908 max = h/2;
1913 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1909 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1914 x -= w ;y += h/2; 1910 x -= w ;y += h/2;
1915 } else { 1911 } else {
1916 w = width()-x-weeklabelwid; 1912 w = width()-x-weeklabelwid;
1917 max = h-h/2; 1913 max = h-h/2;
1918 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1914 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1919 y -= h/2; 1915 y -= h/2;
1920 } 1916 }
1921 } else { 1917 } else {
1922 max = h; 1918 max = h;
1923 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1919 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1924 } 1920 }
1925 1921
1926 } 1922 }
1927 else { 1923 else {
1928 max = h; 1924 max = h;
1929 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1925 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1930 } 1926 }
1931 x += w; 1927 x += w;
1932 if ( x + w/2 > wid ) { 1928 if ( x + w/2 > wid ) {
1933 x = 0; 1929 x = 0;
1934 y += h; 1930 y += h;
1935 } 1931 }
1936 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1932 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1937 } 1933 }
1938 y= dayLabelHei; 1934 y= dayLabelHei;
1939 h = cellHei ; 1935 h = cellHei ;
1940 for ( i = 0; i < 6; i++) { 1936 for ( i = 0; i < 6; i++) {
1941 if ( i == (6-rowModulo)) 1937 if ( i == (6-rowModulo))
1942 ++h; 1938 ++h;
1943 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1939 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1944 y += h; 1940 y += h;
1945 } 1941 }
1946 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1942 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1947 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1943 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1948 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1944 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1949 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1945 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1950 updateDayLabels(); 1946 updateDayLabels();
1951 //bool forceUpdate = !updatePossible; 1947 //bool forceUpdate = !updatePossible;
1952 updatePossible = true; 1948 updatePossible = true;
1953 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1949 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1954} 1950}
1955 1951
1956void KOMonthView::showContextMenu( Incidence *incidence ) 1952void KOMonthView::showContextMenu( Incidence *incidence )
1957{ 1953{
1958 if( incidence ) 1954 if( incidence )
1959 mContextMenu->showIncidencePopup(incidence); 1955 mContextMenu->showIncidencePopup(incidence);
1960 else { 1956 else {
1961 //qDebug("KOMonthView::showContextMenu "); 1957 //qDebug("KOMonthView::showContextMenu ");
1962 mNewItemMenu->popup(QCursor::pos()); 1958 mNewItemMenu->popup(QCursor::pos());
1963 } 1959 }
1964 /* 1960 /*
1965 if( incidence && incidence->typeID() == eventID ) { 1961 if( incidence && incidence->typeID() == eventID ) {
1966 Event *event = static_cast<Event *>(incidence); 1962 Event *event = static_cast<Event *>(incidence);
1967 mContextMenu->showEventPopup(event); 1963 mContextMenu->showEventPopup(event);
1968 } else { 1964 } else {
1969 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1965 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1970 } 1966 }
1971 */ 1967 */
1972} 1968}
1973MonthViewCell * KOMonthView::selectedCell( ) 1969MonthViewCell * KOMonthView::selectedCell( )
1974{ 1970{
1975 return mSelectedCell; 1971 return mSelectedCell;
1976} 1972}
1977void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1973void KOMonthView::setSelectedCell( MonthViewCell *cell )
1978{ 1974{
1979 //qDebug("KOMonthView::setSelectedCell %d", cell); 1975 //qDebug("KOMonthView::setSelectedCell %d", cell);
1980 if ( mSelectedCell && mSelectedCell != cell ) { 1976 if ( mSelectedCell && mSelectedCell != cell ) {
1981 MonthViewCell * mvc = mSelectedCell; 1977 MonthViewCell * mvc = mSelectedCell;
1982 mSelectedCell = cell; 1978 mSelectedCell = cell;
1983 mvc->deselect(); 1979 mvc->deselect();
1984 } else 1980 } else
1985 mSelectedCell = cell; 1981 mSelectedCell = cell;
1986 // if ( mSelectedCell ) 1982 // if ( mSelectedCell )
1987 // mSelectedCell->select(); 1983 // mSelectedCell->select();
1988 if ( !mSelectedCell ) 1984 if ( !mSelectedCell )
1989 emit incidenceSelected( 0 ); 1985 emit incidenceSelected( 0 );
1990 else 1986 else
1991 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1987 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1992} 1988}
1993 1989
1994void KOMonthView::processSelectionChange() 1990void KOMonthView::processSelectionChange()
1995{ 1991{
1996 QPtrList<Incidence> incidences = selectedIncidences(); 1992 QPtrList<Incidence> incidences = selectedIncidences();
1997 if (incidences.count() > 0) { 1993 if (incidences.count() > 0) {
1998 emit incidenceSelected( incidences.first() ); 1994 emit incidenceSelected( incidences.first() );
1999 } else { 1995 } else {
2000 emit incidenceSelected( 0 ); 1996 emit incidenceSelected( 0 );
2001 clearSelection(); 1997 clearSelection();
2002 } 1998 }
2003} 1999}
2004 2000
2005void KOMonthView::clearSelection() 2001void KOMonthView::clearSelection()
2006{ 2002{
2007 if ( mSelectedCell ) { 2003 if ( mSelectedCell ) {
2008 mSelectedCell->deselect(); 2004 mSelectedCell->deselect();
2009 mSelectedCell = 0; 2005 mSelectedCell = 0;
2010 } 2006 }
2011} 2007}
2012 2008
2013void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 2009void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
2014{ 2010{
2015 if ( !e->isAutoRepeat() ) { 2011 if ( !e->isAutoRepeat() ) {
2016 mFlagKeyPressed = false; 2012 mFlagKeyPressed = false;
2017 } 2013 }
2018} 2014}
2019 2015
2020void KOMonthView::keyPressEvent ( QKeyEvent * e ) 2016void KOMonthView::keyPressEvent ( QKeyEvent * e )
2021{ 2017{
2022 2018
2023 qApp->processEvents(); 2019 qApp->processEvents();
2024 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2020 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2025 //e->ignore(); 2021 //e->ignore();
2026 e->accept(); 2022 e->accept();
2027 return; 2023 return;
2028 } 2024 }
2029 if (! e->isAutoRepeat() ) 2025 if (! e->isAutoRepeat() )
2030 mFlagKeyPressed = true; 2026 mFlagKeyPressed = true;
2031 switch(e->key()) { 2027 switch(e->key()) {
2032 case Key_Up: 2028 case Key_Up:
2033 { 2029 {
2034 if ( mShowWeekView ) { 2030 if ( mShowWeekView ) {
2035 emit selectWeekNum ( currentWeek() - 1 ); 2031 emit selectWeekNum ( currentWeek() - 1 );
2036 } 2032 }
2037 else { 2033 else {
2038 emit prevMonth(); 2034 emit prevMonth();
2039 } 2035 }
2040 } 2036 }
2041 e->accept(); 2037 e->accept();
2042 break; 2038 break;
2043 case Key_Down: 2039 case Key_Down:
2044 { 2040 {
2045 if ( mShowWeekView ) { 2041 if ( mShowWeekView ) {
2046 emit selectWeekNum ( currentWeek() +1); 2042 emit selectWeekNum ( currentWeek() +1);
2047 } 2043 }
2048 else { 2044 else {
2049 emit nextMonth(); 2045 emit nextMonth();
2050 } 2046 }
2051 2047
2052 } 2048 }
2053 e->accept(); 2049 e->accept();
2054 break; 2050 break;
2055 case Key_Return: 2051 case Key_Return:
2056 case Key_Enter: 2052 case Key_Enter:
2057 { 2053 {
2058 selectInternalWeekNum ( currentWeek() ); 2054 selectInternalWeekNum ( currentWeek() );
2059 } 2055 }
2060 e->accept(); 2056 e->accept();
2061 break; 2057 break;
2062 case Key_D: 2058 case Key_D:
2063 if ( mSelectedCell ) { 2059 if ( mSelectedCell ) {
2064 mSelectedCell->showDay(); 2060 mSelectedCell->showDay();
2065 e->accept(); 2061 e->accept();
2066 } else { 2062 } else {
2067 e->ignore(); 2063 e->ignore();
2068 } 2064 }
2069 break; 2065 break;
2070 default: 2066 default:
2071 e->ignore(); 2067 e->ignore();
2072 break; 2068 break;
2073 } 2069 }
2074} 2070}
2075 2071
2076void KOMonthView::nextCell() 2072void KOMonthView::nextCell()
2077{ 2073{
2078 bool res = focusNextPrevChild ( true ); 2074 bool res = focusNextPrevChild ( true );
2079} 2075}
2080void KOMonthView::prevCell() 2076void KOMonthView::prevCell()
2081{ 2077{
2082 focusNextPrevChild ( false ); 2078 focusNextPrevChild ( false );
2083} 2079}
2084 2080
2085void KOMonthView::slotNewTodo() 2081void KOMonthView::slotNewTodo()
2086{ 2082{
2087 //qDebug("KOMonthView::slotNewTodo() "); 2083 //qDebug("KOMonthView::slotNewTodo() ");
2088 if ( mPopupCell ){ 2084 if ( mPopupCell ){
2089 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2085 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2090 emit newTodoSignal(dt,true); 2086 emit newTodoSignal(dt,true);
2091 } 2087 }
2092 mPopupCell = 0; 2088 mPopupCell = 0;
2093} 2089}
2094void KOMonthView::slotNewEvent() 2090void KOMonthView::slotNewEvent()
2095{ 2091{
2096 if ( mPopupCell ) { 2092 if ( mPopupCell ) {
2097 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2093 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2098 emit newEventSignal( dt ); 2094 emit newEventSignal( dt );
2099 } 2095 }
2100 //qDebug("KOMonthView::slotNewEvent() "); 2096 //qDebug("KOMonthView::slotNewEvent() ");
2101 mPopupCell = 0; 2097 mPopupCell = 0;
2102} 2098}
2103 2099
2104void KOMonthView::slotEditJournal() 2100void KOMonthView::slotEditJournal()
2105{ 2101{
2106 if ( mPopupCell ) 2102 if ( mPopupCell )
2107 emit showJournalSignal( 7, mPopupCell->date() ); 2103 emit showJournalSignal( 7, mPopupCell->date() );
2108 //qDebug("KOMonthView::slotEditJournal() "); 2104 //qDebug("KOMonthView::slotEditJournal() ");
2109 mPopupCell = 0; 2105 mPopupCell = 0;
2110} 2106}
2111 2107
2112void KOMonthView::setPopupCell( MonthViewCell * c) 2108void KOMonthView::setPopupCell( MonthViewCell * c)
2113{ 2109{
2114 mPopupCell = c; 2110 mPopupCell = c;
2115} 2111}
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index d1ace4f..9359fad 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,422 +1,425 @@
1#include "kincidenceformatter.h" 1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h> 2#include <kstaticdeleter.h>
3#include <kglobal.h> 3#include <kglobal.h>
4#include <klocale.h> 4#include <klocale.h>
5#ifdef DEKTOP_VERSION 5#ifdef DEKTOP_VERSION
6#include <kabc/stdaddressbook.h> 6#include <kabc/stdaddressbook.h>
7#define size count 7#define size count
8#endif 8#endif
9 9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) 13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
14{ 14{
15// #ifndef QT_NO_INPUTDIALOG 15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 17// #else
18// return QString::null; 18// return QString::null;
19// #endif 19// #endif
20 mDetails = details; 20 mDetails = details;
21 mCreated = created ; 21 mCreated = created ;
22 mModified = modified; 22 mModified = modified;
23 mText = ""; 23 mText = "";
24 if ( inc->typeID() == eventID ) 24 if ( inc->typeID() == eventID )
25 setEvent((Event *) inc ); 25 setEvent((Event *) inc );
26 else if ( inc->typeID() == todoID ) 26 else if ( inc->typeID() == todoID )
27 setTodo((Todo *) inc ); 27 setTodo((Todo *) inc );
28 return mText; 28 return mText;
29} 29}
30 30
31KIncidenceFormatter* KIncidenceFormatter::instance() 31KIncidenceFormatter* KIncidenceFormatter::instance()
32{ 32{
33 if (!mInstance) { 33 if (!mInstance) {
34 mInstance = insd.setObject(new KIncidenceFormatter()); 34 mInstance = insd.setObject(new KIncidenceFormatter());
35 } 35 }
36 return mInstance; 36 return mInstance;
37} 37}
38KIncidenceFormatter::~KIncidenceFormatter() 38KIncidenceFormatter::~KIncidenceFormatter()
39{ 39{
40 if (mInstance == this) 40 if (mInstance == this)
41 mInstance = insd.setObject(0); 41 mInstance = insd.setObject(0);
42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); 42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
43} 43}
44KIncidenceFormatter::KIncidenceFormatter() 44KIncidenceFormatter::KIncidenceFormatter()
45{ 45{
46 mColorMode = 0; 46 mColorMode = 0;
47} 47}
48void KIncidenceFormatter::setEvent(Event *event) 48void KIncidenceFormatter::setEvent(Event *event)
49{ 49{
50 int mode = 0; 50 int mode = 0;
51 mCurrentIncidence = event; 51 mCurrentIncidence = event;
52 bool shortDate = true; 52 bool shortDate = true;
53 if ( mode == 0 ) { 53 if ( mode == 0 ) {
54 addTag("h3",deTag(event->summary())); 54 addTag("h3",deTag(event->summary()));
55 formatReadOnly(event);
55 } 56 }
56 else { 57 else {
57 if ( mColorMode == 1 ) { 58 if ( mColorMode == 1 ) {
58 mText +="<font color=\"#00A000\">"; 59 mText +="<font color=\"#00A000\">";
59 } 60 }
60 if ( mColorMode == 2 ) { 61 if ( mColorMode == 2 ) {
61 mText +="<font color=\"#C00000\">"; 62 mText +="<font color=\"#C00000\">";
62 } 63 }
63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 64 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
64 if ( mode == 1 ) { 65 if ( mode == 1 ) {
65 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 66 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
66 } else { 67 } else {
67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 68 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
68 } 69 }
70 formatReadOnly(event);
69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 71 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
70 if ( mColorMode ) 72 if ( mColorMode )
71 mText += "</font>"; 73 mText += "</font>";
72 } 74 }
73 if (event->cancelled ()) { 75 if (event->cancelled ()) {
74 mText +="<font color=\"#B00000\">"; 76 mText +="<font color=\"#B00000\">";
75 addTag("i",i18n("This event has been cancelled!")); 77 addTag("i",i18n("This event has been cancelled!"));
76 mText.append("<br>"); 78 mText.append("<br>");
77 mText += "</font>"; 79 mText += "</font>";
78 } 80 }
79 if (event->doesFloat()) { 81 if (event->doesFloat()) {
80 if (event->isMultiDay()) { 82 if (event->isMultiDay()) {
81 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 83 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
82 .arg(event->dtStartDateStr(shortDate)) 84 .arg(event->dtStartDateStr(shortDate))
83 .arg(event->dtEndDateStr(shortDate))); 85 .arg(event->dtEndDateStr(shortDate)));
84 } else { 86 } else {
85 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 87 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
86 } 88 }
87 } else { 89 } else {
88 if (event->isMultiDay()) { 90 if (event->isMultiDay()) {
89 mText.append(i18n("<p><b>From:</b> %1</p> ") 91 mText.append(i18n("<p><b>From:</b> %1</p> ")
90 .arg(event->dtStartStr( shortDate))); 92 .arg(event->dtStartStr( shortDate)));
91 mText.append(i18n("<p><b>To:</b> %1</p>") 93 mText.append(i18n("<p><b>To:</b> %1</p>")
92 .arg(event->dtEndStr(shortDate))); 94 .arg(event->dtEndStr(shortDate)));
93 } else { 95 } else {
94 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 96 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
95 .arg(event->dtStartTimeStr()) 97 .arg(event->dtStartTimeStr())
96 .arg(event->dtEndTimeStr())); 98 .arg(event->dtEndTimeStr()));
97 mText.append(i18n("<p><b>On:</b> %1</p> ") 99 mText.append(i18n("<p><b>On:</b> %1</p> ")
98 .arg(event->dtStartDateStr( shortDate ))); 100 .arg(event->dtStartDateStr( shortDate )));
99 } 101 }
100 } 102 }
101 if (!event->location().isEmpty()) { 103 if (!event->location().isEmpty()) {
102 addTag("b",i18n("Location: ")); 104 addTag("b",i18n("Location: "));
103 mText.append(deTag(event->location())+"<br>"); 105 mText.append(deTag(event->location())+"<br>");
104 } 106 }
105 107
106 if (event->recurrence()->doesRecur()) { 108 if (event->recurrence()->doesRecur()) {
107 109
108 QString recurText = event->recurrence()->recurrenceText(); 110 QString recurText = event->recurrence()->recurrenceText();
109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 111 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
110 112
111 bool ok; 113 bool ok;
112 QDate start = QDate::currentDate(); 114 QDate start = QDate::currentDate();
113 QDateTime next; 115 QDateTime next;
114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 116 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
115 if ( ok ) { 117 if ( ok ) {
116 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 118 addTag("p",i18n("<b>Next recurrence is on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 119 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
118 120
119 } else { 121 } else {
120 bool last; 122 bool last;
121 QDate nextd; 123 QDate nextd;
122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 124 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
123 if ( last ) { 125 if ( last ) {
124 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 126 addTag("p",i18n("<b>Last recurrence was on:</b>") );
125 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 127 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
126 } 128 }
127 } 129 }
128 } 130 }
129 131
130 132
131 if (event->isAlarmEnabled()) { 133 if (event->isAlarmEnabled()) {
132 Alarm *alarm =event->alarms().first() ; 134 Alarm *alarm =event->alarms().first() ;
133 QDateTime t = alarm->time(); 135 QDateTime t = alarm->time();
134 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 136 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
135 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 137 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
136 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 138 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
137 //addTag("p",s); 139 //addTag("p",s);
138 } 140 }
139 141
140 142
141 143
142 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 144 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
143 // mText.append(event->secrecyStr()+"<br>"); 145 // mText.append(event->secrecyStr()+"<br>");
144 formatCategories(event); 146 formatCategories(event);
145 147
146 formatReadOnly(event);
147 formatAttendees(event); 148 formatAttendees(event);
148 149
149 if ( mCreated ) { 150 if ( mCreated ) {
150#ifdef DESKTOP_VERSION 151#ifdef DESKTOP_VERSION
151 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 152 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
152#else 153#else
153 addTag("p",i18n("<b>Created: ") +" </b>"); 154 addTag("p",i18n("<b>Created: ") +" </b>");
154 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 155 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
155#endif 156#endif
156 157
157 } 158 }
158 if ( mModified ) { 159 if ( mModified ) {
159#ifdef DESKTOP_VERSION 160#ifdef DESKTOP_VERSION
160 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 161 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
161#else 162#else
162 addTag("p",i18n("<b>Last modified: ") +" </b>"); 163 addTag("p",i18n("<b>Last modified: ") +" </b>");
163 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 164 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
164#endif 165#endif
165 166
166 } 167 }
167 if ( mDetails ) { 168 if ( mDetails ) {
168 if (!event->description().isEmpty()) { 169 if (!event->description().isEmpty()) {
169 addTag("p",i18n("<b>Details: </b>")); 170 addTag("p",i18n("<b>Details: </b>"));
170 addTag("p",deTag(event->description())); 171 addTag("p",deTag(event->description()));
171 } 172 }
172 } 173 }
173 174
174} 175}
175 176
176void KIncidenceFormatter::setTodo(Todo *event ) 177void KIncidenceFormatter::setTodo(Todo *event )
177{ 178{
178 int mode = 0; 179 int mode = 0;
179 mCurrentIncidence = event; 180 mCurrentIncidence = event;
180 bool shortDate = true; 181 bool shortDate = true;
181 if (mode == 0 ) 182 if (mode == 0 ) {
182 addTag("h3",deTag(event->summary())); 183 addTag("h3",deTag(event->summary()));
184 formatReadOnly(event);
185 }
183 else { 186 else {
184 if ( mColorMode == 1 ) { 187 if ( mColorMode == 1 ) {
185 mText +="<font color=\"#00A000\">"; 188 mText +="<font color=\"#00A000\">";
186 } 189 }
187 if ( mColorMode == 2 ) { 190 if ( mColorMode == 2 ) {
188 mText +="<font color=\"#B00000\">"; 191 mText +="<font color=\"#B00000\">";
189 } 192 }
190 if ( mode == 1 ) { 193 if ( mode == 1 ) {
191 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 194 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
192 } else { 195 } else {
193 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 196 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
194 } 197 }
198 formatReadOnly(event);
195 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 199 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
196 if ( mColorMode ) 200 if ( mColorMode )
197 mText += "</font>"; 201 mText += "</font>";
198 } 202 }
199 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 203 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
200 mText +="<font color=\"#B00000\">"; 204 mText +="<font color=\"#B00000\">";
201 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); 205 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) );
202 mText += "</font>"; 206 mText += "</font>";
203 } else { 207 } else {
204 mText.append(i18n("<p><i>%1 % completed</i></p>") 208 mText.append(i18n("<p><i>%1 % completed</i></p>")
205 .arg(event->percentComplete())); 209 .arg(event->percentComplete()));
206 } 210 }
207 if (event->cancelled ()) { 211 if (event->cancelled ()) {
208 mText +="<font color=\"#B00000\">"; 212 mText +="<font color=\"#B00000\">";
209 addTag("i",i18n("This todo has been cancelled!")); 213 addTag("i",i18n("This todo has been cancelled!"));
210 mText.append("<br>"); 214 mText.append("<br>");
211 mText += "</font>"; 215 mText += "</font>";
212 } 216 }
213 217
214 218
215 if (event->recurrence()->doesRecur()) { 219 if (event->recurrence()->doesRecur()) {
216 220
217 QString recurText = event->recurrence()->recurrenceText(); 221 QString recurText = event->recurrence()->recurrenceText();
218 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 222 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
219 } 223 }
220 224
221 if (event->hasStartDate()) { 225 if (event->hasStartDate()) {
222 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); 226 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate)));
223 } 227 }
224 228
225 229
226 if (event->hasDueDate()) { 230 if (event->hasDueDate()) {
227 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 231 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
228 } 232 }
229 233
230 if (!event->location().isEmpty()) { 234 if (!event->location().isEmpty()) {
231 addTag("b",i18n("Location: ")); 235 addTag("b",i18n("Location: "));
232 mText.append(deTag(event->location())+"<br>"); 236 mText.append(deTag(event->location())+"<br>");
233 } 237 }
234 238
235 mText.append(i18n("<p><b>Priority:</b> %2</p>") 239 mText.append(i18n("<p><b>Priority:</b> %2</p>")
236 .arg(QString::number(event->priority()))); 240 .arg(QString::number(event->priority())));
237 241
238 if (event->isAlarmEnabled()) { 242 if (event->isAlarmEnabled()) {
239 Alarm *alarm =event->alarms().first() ; 243 Alarm *alarm =event->alarms().first() ;
240 QDateTime t = alarm->time(); 244 QDateTime t = alarm->time();
241 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 245 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
242 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 246 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
243 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 247 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
244 //addTag("p",s); 248 //addTag("p",s);
245 } 249 }
246 250
247 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 251 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
248 formatCategories(event); 252 formatCategories(event);
249 253
250 formatReadOnly(event);
251 formatAttendees(event); 254 formatAttendees(event);
252 if ( mCreated ) { 255 if ( mCreated ) {
253#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
254 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 257 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
255#else 258#else
256 addTag("p",i18n("<b>Created: ") +" </b>"); 259 addTag("p",i18n("<b>Created: ") +" </b>");
257 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 260 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
258#endif 261#endif
259 262
260 } 263 }
261 if ( mModified ) { 264 if ( mModified ) {
262#ifdef DESKTOP_VERSION 265#ifdef DESKTOP_VERSION
263 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 266 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
264#else 267#else
265 addTag("p",i18n("<b>Last modified: ") +" </b>"); 268 addTag("p",i18n("<b>Last modified: ") +" </b>");
266 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 269 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
267#endif 270#endif
268 271
269 } 272 }
270 if ( mDetails ) { 273 if ( mDetails ) {
271 if (!event->description().isEmpty()) { 274 if (!event->description().isEmpty()) {
272 addTag("p",i18n("<b>Details: </b>")); 275 addTag("p",i18n("<b>Details: </b>"));
273 addTag("p",deTag(event->description())); 276 addTag("p",deTag(event->description()));
274 } 277 }
275 } 278 }
276} 279}
277 280
278void KIncidenceFormatter::setJournal(Journal* ) 281void KIncidenceFormatter::setJournal(Journal* )
279{ 282{
280 283
281} 284}
282 285
283void KIncidenceFormatter::formatCategories(Incidence *event) 286void KIncidenceFormatter::formatCategories(Incidence *event)
284{ 287{
285 if (!event->categoriesStr().isEmpty()) { 288 if (!event->categoriesStr().isEmpty()) {
286 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); 289 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() );
287 //mText.append(event->categoriesStr()); 290 //mText.append(event->categoriesStr());
288 } 291 }
289} 292}
290void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 293void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
291{ 294{
292 int number=text.contains("\n"); 295 int number=text.contains("\n");
293 QString str = "<" + tag + ">"; 296 QString str = "<" + tag + ">";
294 QString tmpText=text; 297 QString tmpText=text;
295 QString tmpStr=str; 298 QString tmpStr=str;
296 if(number !=-1) 299 if(number !=-1)
297 { 300 {
298 if (number > 0) { 301 if (number > 0) {
299 int pos=0; 302 int pos=0;
300 QString tmp; 303 QString tmp;
301 for(int i=0;i<=number;i++) { 304 for(int i=0;i<=number;i++) {
302 pos=tmpText.find("\n"); 305 pos=tmpText.find("\n");
303 tmp=tmpText.left(pos); 306 tmp=tmpText.left(pos);
304 tmpText=tmpText.right(tmpText.length()-pos-1); 307 tmpText=tmpText.right(tmpText.length()-pos-1);
305 tmpStr+=tmp+"<br>"; 308 tmpStr+=tmp+"<br>";
306 } 309 }
307 } 310 }
308 else tmpStr += tmpText; 311 else tmpStr += tmpText;
309 tmpStr+="</" + tag + ">"; 312 tmpStr+="</" + tag + ">";
310 mText.append(tmpStr); 313 mText.append(tmpStr);
311 } 314 }
312 else 315 else
313 { 316 {
314 str += text + "</" + tag + ">"; 317 str += text + "</" + tag + ">";
315 mText.append(str); 318 mText.append(str);
316 } 319 }
317} 320}
318 321
319void KIncidenceFormatter::formatAttendees(Incidence *event) 322void KIncidenceFormatter::formatAttendees(Incidence *event)
320{ 323{
321 QPtrList<Attendee> attendees = event->attendees(); 324 QPtrList<Attendee> attendees = event->attendees();
322 if (attendees.count()) { 325 if (attendees.count()) {
323 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 326 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
324 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 327 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
325 addTag("h3",i18n("Organizer")); 328 addTag("h3",i18n("Organizer"));
326 mText.append("<ul><li>"); 329 mText.append("<ul><li>");
327#if 0 330#if 0
328 //ndef KORG_NOKABC 331 //ndef KORG_NOKABC
329 332
330 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 333 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
331 KABC::Addressee::List addressList; 334 KABC::Addressee::List addressList;
332 addressList = add_book->findByEmail(event->organizer()); 335 addressList = add_book->findByEmail(event->organizer());
333 KABC::Addressee o = addressList.first(); 336 KABC::Addressee o = addressList.first();
334 if (!o.isEmpty() && addressList.size()<2) { 337 if (!o.isEmpty() && addressList.size()<2) {
335 mText += "<a href=\"uid:" + o.uid() + "\">"; 338 mText += "<a href=\"uid:" + o.uid() + "\">";
336 mText += o.formattedName(); 339 mText += o.formattedName();
337 mText += "</a>\n"; 340 mText += "</a>\n";
338 } else { 341 } else {
339 mText.append(event->organizer()); 342 mText.append(event->organizer());
340 } 343 }
341#else 344#else
342 mText.append(event->organizer()); 345 mText.append(event->organizer());
343#endif 346#endif
344 if (iconPath) { 347 if (iconPath) {
345 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 348 mText += " <a href=\"mailto:" + event->organizer() + "\">";
346 mText += "<IMG src=\"" + iconPath + "\">"; 349 mText += "<IMG src=\"" + iconPath + "\">";
347 mText += "</a>\n"; 350 mText += "</a>\n";
348 } 351 }
349 mText.append("</li></ul>"); 352 mText.append("</li></ul>");
350 353
351 addTag("h3",i18n("Attendees")); 354 addTag("h3",i18n("Attendees"));
352 Attendee *a; 355 Attendee *a;
353 mText.append("<ul>"); 356 mText.append("<ul>");
354 for(a=attendees.first();a;a=attendees.next()) { 357 for(a=attendees.first();a;a=attendees.next()) {
355#if 0 358#if 0
356//ndef KORG_NOKABC 359//ndef KORG_NOKABC
357 if (a->name().isEmpty()) { 360 if (a->name().isEmpty()) {
358 addressList = add_book->findByEmail(a->email()); 361 addressList = add_book->findByEmail(a->email());
359 KABC::Addressee o = addressList.first(); 362 KABC::Addressee o = addressList.first();
360 if (!o.isEmpty() && addressList.size()<2) { 363 if (!o.isEmpty() && addressList.size()<2) {
361 mText += "<a href=\"uid:" + o.uid() + "\">"; 364 mText += "<a href=\"uid:" + o.uid() + "\">";
362 mText += o.formattedName(); 365 mText += o.formattedName();
363 mText += "</a>\n"; 366 mText += "</a>\n";
364 } else { 367 } else {
365 mText += "<li>"; 368 mText += "<li>";
366 mText.append(a->email()); 369 mText.append(a->email());
367 mText += "\n"; 370 mText += "\n";
368 } 371 }
369 } else { 372 } else {
370 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 373 mText += "<li><a href=\"uid:" + a->uid() + "\">";
371 if (!a->name().isEmpty()) mText += a->name(); 374 if (!a->name().isEmpty()) mText += a->name();
372 else mText += a->email(); 375 else mText += a->email();
373 mText += "</a>\n"; 376 mText += "</a>\n";
374 } 377 }
375#else 378#else
376 //qDebug("nokabc "); 379 //qDebug("nokabc ");
377 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 380 mText += "<li><a href=\"uid:" + a->uid() + "\">";
378 if (!a->name().isEmpty()) mText += a->name(); 381 if (!a->name().isEmpty()) mText += a->name();
379 else mText += a->email(); 382 else mText += a->email();
380 mText += "</a>\n"; 383 mText += "</a>\n";
381#endif 384#endif
382 385
383 if (!a->email().isEmpty()) { 386 if (!a->email().isEmpty()) {
384 if (iconPath) { 387 if (iconPath) {
385 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 388 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
386 if ( a->RSVP() ) 389 if ( a->RSVP() )
387 mText += "<IMG src=\"" + iconPath + "\">"; 390 mText += "<IMG src=\"" + iconPath + "\">";
388 else 391 else
389 mText += "<IMG src=\"" + NOiconPath + "\">"; 392 mText += "<IMG src=\"" + NOiconPath + "\">";
390 mText += "</a>\n"; 393 mText += "</a>\n";
391 } 394 }
392 } 395 }
393 if (a->status() != Attendee::NeedsAction ) 396 if (a->status() != Attendee::NeedsAction )
394 mText +="[" + a->statusStr() + "] "; 397 mText +="[" + a->statusStr() + "] ";
395 if (a->role() == Attendee::Chair ) 398 if (a->role() == Attendee::Chair )
396 mText +="(" + a->roleStr().left(1) + ".)"; 399 mText +="(" + a->roleStr().left(1) + ".)";
397 } 400 }
398 mText.append("</li></ul>"); 401 mText.append("</li></ul>");
399 } 402 }
400} 403}
401 404
402void KIncidenceFormatter::formatReadOnly(Incidence *event) 405void KIncidenceFormatter::formatReadOnly(Incidence *event)
403{ 406{
404 if (event->isReadOnly()) { 407 if (event->isReadOnly()) {
405 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 408 addTag("p","<em>(" + i18n("read-only") + ")</em>");
406 } 409 }
407} 410}
408QString KIncidenceFormatter::deTag(QString text) 411QString KIncidenceFormatter::deTag(QString text)
409{ 412{
410#if QT_VERSION >= 0x030000 413#if QT_VERSION >= 0x030000
411 text.replace( '<' , "&lt;" ); 414 text.replace( '<' , "&lt;" );
412 text.replace( '>' , "&gt;" ); 415 text.replace( '>' , "&gt;" );
413#else 416#else
414 if ( text.find ('<') >= 0 ) { 417 if ( text.find ('<') >= 0 ) {
415 text.replace( QRegExp("<") , "&lt;" ); 418 text.replace( QRegExp("<") , "&lt;" );
416 } 419 }
417 if ( text.find ('>') >= 0 ) { 420 if ( text.find ('>') >= 0 ) {
418 text.replace( QRegExp(">") , "&gt;" ); 421 text.replace( QRegExp(">") , "&gt;" );
419 } 422 }
420#endif 423#endif
421 return text; 424 return text;
422} 425}