author | zautrix <zautrix> | 2007-06-06 13:14:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2007-06-06 13:14:20 (UTC) |
commit | 623b4d4abe87789dacd4c14de88a63b44ca352b7 (patch) (unidiff) | |
tree | a6bcc1b9359bf904e08b508576c2d2e958cde55c | |
parent | d5c53970b9e12bfe774d1fecd603080aded24e09 (diff) | |
download | kdepimpi-623b4d4abe87789dacd4c14de88a63b44ca352b7.zip kdepimpi-623b4d4abe87789dacd4c14de88a63b44ca352b7.tar.gz kdepimpi-623b4d4abe87789dacd4c14de88a63b44ca352b7.tar.bz2 |
display of next alarm of recurring events in event viewer fixed
-rw-r--r-- | korganizer/koeventviewer.cpp | 20 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 16 |
2 files changed, 35 insertions, 1 deletions
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp index 607e549..92d2a80 100644 --- a/korganizer/koeventviewer.cpp +++ b/korganizer/koeventviewer.cpp | |||
@@ -1,849 +1,867 @@ | |||
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 <qtopia/qcopenvelope_qws.h> | 60 | #include <qtopia/qcopenvelope_qws.h> |
61 | #endif //DESKTOP_VERSION | 61 | #endif //DESKTOP_VERSION |
62 | #include <externalapphandler.h> | 62 | #include <externalapphandler.h> |
63 | 63 | ||
64 | KOEventViewer::KOEventViewer(QWidget *parent,const char *name) | 64 | KOEventViewer::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 | ||
71 | KOEventViewer::~KOEventViewer() | 71 | KOEventViewer::~KOEventViewer() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void KOEventViewer::printMe() | 75 | void 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 | } |
110 | void KOEventViewer::setSource(const QString& n) | 110 | void KOEventViewer::setSource(const QString& n) |
111 | { | 111 | { |
112 | 112 | ||
113 | if ( n.left(8) == "todo_uid" ) { | 113 | if ( n.left(8) == "todo_uid" ) { |
114 | int midstr = 9; | 114 | int midstr = 9; |
115 | #ifdef DESKTOP_VERSION | 115 | #ifdef DESKTOP_VERSION |
116 | midstr = 11; | 116 | midstr = 11; |
117 | #endif | 117 | #endif |
118 | //qDebug("-%s- ", n.mid(midstr).latin1()); | 118 | //qDebug("-%s- ", n.mid(midstr).latin1()); |
119 | emit showIncidence( n.mid(midstr) ); | 119 | emit showIncidence( n.mid(midstr) ); |
120 | return; | 120 | return; |
121 | } | 121 | } |
122 | 122 | ||
123 | if ( n.left(3) == "uid" ) | 123 | if ( n.left(3) == "uid" ) |
124 | #ifdef DESKTOP_VERSION | 124 | #ifdef DESKTOP_VERSION |
125 | { | 125 | { |
126 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 126 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
127 | KABC::AddressBook::Iterator it; | 127 | KABC::AddressBook::Iterator it; |
128 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 128 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
129 | // LR I do not understand, why the uid string is different on zaurus and desktop | 129 | // LR I do not understand, why the uid string is different on zaurus and desktop |
130 | QString uid = "uid://"+(*it).uid(); | 130 | QString uid = "uid://"+(*it).uid(); |
131 | 131 | ||
132 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); | 132 | //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); |
133 | if (n == uid ) { | 133 | if (n == uid ) { |
134 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); | 134 | //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); |
135 | QDialog dia( this,"dia123", true ); | 135 | QDialog dia( this,"dia123", true ); |
136 | dia.setCaption( i18n("Details of attendee") ); | 136 | dia.setCaption( i18n("Details of attendee") ); |
137 | QVBoxLayout lay ( &dia ); | 137 | QVBoxLayout lay ( &dia ); |
138 | KABC::AddresseeView av ( &dia ); | 138 | KABC::AddresseeView av ( &dia ); |
139 | av.setAddressee( (*it) ); | 139 | av.setAddressee( (*it) ); |
140 | lay.addWidget( &av ); | 140 | lay.addWidget( &av ); |
141 | if ( QApplication::desktop()->width() < 480 ) | 141 | if ( QApplication::desktop()->width() < 480 ) |
142 | dia.resize( 220, 240); | 142 | dia.resize( 220, 240); |
143 | else { | 143 | else { |
144 | dia.resize( 400,400); | 144 | dia.resize( 400,400); |
145 | } | 145 | } |
146 | dia.exec(); | 146 | dia.exec(); |
147 | break; | 147 | break; |
148 | } | 148 | } |
149 | } | 149 | } |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | #else | 152 | #else |
153 | { | 153 | { |
154 | if ( "uid:organizer" == n ) { | 154 | if ( "uid:organizer" == n ) { |
155 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); | 155 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); |
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 158 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
159 | if (attendees.count()) { | 159 | if (attendees.count()) { |
160 | Attendee *a; | 160 | Attendee *a; |
161 | for(a=attendees.first();a;a=attendees.next()) { | 161 | for(a=attendees.first();a;a=attendees.next()) { |
162 | if ( "uid:"+a->uid() == n ) { | 162 | if ( "uid:"+a->uid() == n ) { |
163 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); | 163 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); |
164 | return; | 164 | return; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | } | 167 | } |
168 | return; | 168 | return; |
169 | } | 169 | } |
170 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 170 | //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
171 | // the result should now arrive through method insertAttendees | 171 | // the result should now arrive through method insertAttendees |
172 | //QString uid = "uid:"+(*it).uid(); | 172 | //QString uid = "uid:"+(*it).uid(); |
173 | #endif | 173 | #endif |
174 | if ( n.left(6) == "mailto" ) { | 174 | if ( n.left(6) == "mailto" ) { |
175 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); | 175 | // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); |
176 | //#ifndef DESKTOP_VERSION | 176 | //#ifndef DESKTOP_VERSION |
177 | if ( n.mid(7,3) == "ALL" ) { | 177 | if ( n.mid(7,3) == "ALL" ) { |
178 | mailToAttendees( true ); | 178 | mailToAttendees( true ); |
179 | } else if ( n.mid(7,4) == "RSVP" ) { | 179 | } else if ( n.mid(7,4) == "RSVP" ) { |
180 | mailToAttendees( false ); | 180 | mailToAttendees( false ); |
181 | } else { | 181 | } else { |
182 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); | 182 | ExternalAppHandler::instance()->mailToOneContact( n.mid(7) ); |
183 | //QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); | 183 | //QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); |
184 | //e << n.mid(7); | 184 | //e << n.mid(7); |
185 | } | 185 | } |
186 | //#endif | 186 | //#endif |
187 | 187 | ||
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | #ifndef KORG_NODCOP | 191 | #ifndef KORG_NODCOP |
192 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; | 192 | kdDebug() << "KOEventViewer::setSource(): " << n << endl; |
193 | QString tmpStr; | 193 | QString tmpStr; |
194 | if (n.startsWith("mailto:")) { | 194 | if (n.startsWith("mailto:")) { |
195 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); | 195 | KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); |
196 | //emit showIncidence(n); | 196 | //emit showIncidence(n); |
197 | return; | 197 | return; |
198 | } else if (n.startsWith("uid:")) { | 198 | } else if (n.startsWith("uid:")) { |
199 | DCOPClient *client = KApplication::kApplication()->dcopClient(); | 199 | DCOPClient *client = KApplication::kApplication()->dcopClient(); |
200 | const QByteArray noParamData; | 200 | const QByteArray noParamData; |
201 | const QByteArray paramData; | 201 | const QByteArray paramData; |
202 | QByteArray replyData; | 202 | QByteArray replyData; |
203 | QCString replyTypeStr; | 203 | QCString replyTypeStr; |
204 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) | 204 | #define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) |
205 | bool foundAbbrowser = PING_ABBROWSER; | 205 | bool foundAbbrowser = PING_ABBROWSER; |
206 | 206 | ||
207 | if (foundAbbrowser) { | 207 | if (foundAbbrowser) { |
208 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor | 208 | //KAddressbook is already running, so just DCOP to it to bring up the contact editor |
209 | //client->send("kaddressbook","KAddressBookIface", | 209 | //client->send("kaddressbook","KAddressBookIface", |
210 | QDataStream arg(paramData, IO_WriteOnly); | 210 | QDataStream arg(paramData, IO_WriteOnly); |
211 | arg << n.mid(6); | 211 | arg << n.mid(6); |
212 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); | 212 | client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); |
213 | return; | 213 | return; |
214 | } else { | 214 | } else { |
215 | /* | 215 | /* |
216 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. | 216 | KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. |
217 | We start it without its main interface | 217 | We start it without its main interface |
218 | */ | 218 | */ |
219 | KIconLoader* iconLoader = new KIconLoader(); | 219 | KIconLoader* iconLoader = new KIconLoader(); |
220 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); | 220 | QString iconPath = iconLoader->iconPath("go",KIcon::Small); |
221 | ActionManager::setStartedKAddressBook(true); | 221 | ActionManager::setStartedKAddressBook(true); |
222 | tmpStr = "kaddressbook --editor-only --uid "; | 222 | tmpStr = "kaddressbook --editor-only --uid "; |
223 | tmpStr += KProcess::quote(n.mid(6)); | 223 | tmpStr += KProcess::quote(n.mid(6)); |
224 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); | 224 | KRun::runCommand(tmpStr,"KAddressBook",iconPath); |
225 | return; | 225 | return; |
226 | } | 226 | } |
227 | } else { | 227 | } else { |
228 | //QTextBrowser::setSource(n); | 228 | //QTextBrowser::setSource(n); |
229 | } | 229 | } |
230 | #endif | 230 | #endif |
231 | } | 231 | } |
232 | void KOEventViewer::mailToAttendees( bool all ) | 232 | void KOEventViewer::mailToAttendees( bool all ) |
233 | { | 233 | { |
234 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); | 234 | QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); |
235 | if (attendees.count() == 0) return; | 235 | if (attendees.count() == 0) return; |
236 | QStringList nameList; | 236 | QStringList nameList; |
237 | QStringList emailList; | 237 | QStringList emailList; |
238 | QStringList uidList; | 238 | QStringList uidList; |
239 | Attendee* a; | 239 | Attendee* a; |
240 | for(a=attendees.first();a;a=attendees.next()) { | 240 | for(a=attendees.first();a;a=attendees.next()) { |
241 | if ( !all && !a->RSVP() ) continue; | 241 | if ( !all && !a->RSVP() ) continue; |
242 | if (!a->email().isEmpty()) { | 242 | if (!a->email().isEmpty()) { |
243 | #ifndef DESKTOP_VERSION | 243 | #ifndef DESKTOP_VERSION |
244 | nameList.append (a->realName() ); | 244 | nameList.append (a->realName() ); |
245 | emailList.append (a->email() ); | 245 | emailList.append (a->email() ); |
246 | uidList.append (a->uid() ); | 246 | uidList.append (a->uid() ); |
247 | #else | 247 | #else |
248 | emailList.append(a->realName() +" <" + a->email() +">"); | 248 | emailList.append(a->realName() +" <" + a->email() +">"); |
249 | #endif | 249 | #endif |
250 | } | 250 | } |
251 | } | 251 | } |
252 | #ifndef DESKTOP_VERSION | 252 | #ifndef DESKTOP_VERSION |
253 | QString uid = "ComposeMailUIpick2"+mMailSubject; | 253 | QString uid = "ComposeMailUIpick2"+mMailSubject; |
254 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); | 254 | bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); |
255 | 255 | ||
256 | #else | 256 | #else |
257 | ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject ); | 257 | ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject ); |
258 | #endif | 258 | #endif |
259 | 259 | ||
260 | } | 260 | } |
261 | void KOEventViewer::addTag(const QString & tag,const QString & text) | 261 | void KOEventViewer::addTag(const QString & tag,const QString & text) |
262 | { | 262 | { |
263 | int number=text.contains("\n"); | 263 | int number=text.contains("\n"); |
264 | QString str = "<" + tag + ">"; | 264 | QString str = "<" + tag + ">"; |
265 | QString tmpText=text; | 265 | QString tmpText=text; |
266 | QString tmpStr=str; | 266 | QString tmpStr=str; |
267 | if(number !=-1) | 267 | if(number !=-1) |
268 | { | 268 | { |
269 | if (number > 0) { | 269 | if (number > 0) { |
270 | int pos=0; | 270 | int pos=0; |
271 | QString tmp; | 271 | QString tmp; |
272 | for(int i=0;i<=number;i++) { | 272 | for(int i=0;i<=number;i++) { |
273 | pos=tmpText.find("\n"); | 273 | pos=tmpText.find("\n"); |
274 | tmp=tmpText.left(pos); | 274 | tmp=tmpText.left(pos); |
275 | tmpText=tmpText.right(tmpText.length()-pos-1); | 275 | tmpText=tmpText.right(tmpText.length()-pos-1); |
276 | tmpStr+=tmp+"<br>"; | 276 | tmpStr+=tmp+"<br>"; |
277 | } | 277 | } |
278 | } | 278 | } |
279 | else tmpStr += tmpText; | 279 | else tmpStr += tmpText; |
280 | tmpStr+="</" + tag + ">"; | 280 | tmpStr+="</" + tag + ">"; |
281 | mText.append(tmpStr); | 281 | mText.append(tmpStr); |
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | str += text + "</" + tag + ">"; | 285 | str += text + "</" + tag + ">"; |
286 | mText.append(str); | 286 | mText.append(str); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | 289 | ||
290 | void KOEventViewer::setColorMode( int m ) | 290 | void KOEventViewer::setColorMode( int m ) |
291 | { | 291 | { |
292 | mColorMode = m; | 292 | mColorMode = m; |
293 | } | 293 | } |
294 | void KOEventViewer::appendEvent(Event *event, int mode ) | 294 | void KOEventViewer::appendEvent(Event *event, int mode ) |
295 | { | 295 | { |
296 | mMailSubject = ""; | 296 | mMailSubject = ""; |
297 | mCurrentIncidence = event; | 297 | mCurrentIncidence = event; |
298 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 298 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
299 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); | 299 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); |
300 | topLevelWidget()->setCaption(i18n("Event Viewer")); | 300 | topLevelWidget()->setCaption(i18n("Event Viewer")); |
301 | if ( mode == 0 ) { | 301 | if ( mode == 0 ) { |
302 | addTag("h2",deTag(event->summary())); | 302 | addTag("h2",deTag(event->summary())); |
303 | formatReadOnly(event); | 303 | formatReadOnly(event); |
304 | } | 304 | } |
305 | else { | 305 | else { |
306 | if ( mColorMode == 1 ) { | 306 | if ( mColorMode == 1 ) { |
307 | mText +="<font color=\"#00A000\">"; | 307 | mText +="<font color=\"#00A000\">"; |
308 | } | 308 | } |
309 | if ( mColorMode == 2 ) { | 309 | if ( mColorMode == 2 ) { |
310 | mText +="<font color=\"#C00000\">"; | 310 | mText +="<font color=\"#C00000\">"; |
311 | } | 311 | } |
312 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 312 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
313 | if ( mode == 1 ) { | 313 | if ( mode == 1 ) { |
314 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 314 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
315 | } else { | 315 | } else { |
316 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 316 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
317 | } | 317 | } |
318 | formatReadOnly(event); | 318 | formatReadOnly(event); |
319 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 319 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
320 | if ( mColorMode ) | 320 | if ( mColorMode ) |
321 | mText += "</font>"; | 321 | mText += "</font>"; |
322 | } | 322 | } |
323 | mMailSubject += i18n( "Meeting " )+ event->summary(); | 323 | mMailSubject += i18n( "Meeting " )+ event->summary(); |
324 | if (event->cancelled ()) { | 324 | if (event->cancelled ()) { |
325 | mText +="<font color=\"#B00000\">"; | 325 | mText +="<font color=\"#B00000\">"; |
326 | addTag("i",i18n("This event has been cancelled!")); | 326 | addTag("i",i18n("This event has been cancelled!")); |
327 | mText.append("<br>"); | 327 | mText.append("<br>"); |
328 | mText += "</font>"; | 328 | mText += "</font>"; |
329 | mMailSubject += i18n("(cancelled)"); | 329 | mMailSubject += i18n("(cancelled)"); |
330 | } | 330 | } |
331 | 331 | ||
332 | if (event->doesFloat()) { | 332 | if (event->doesFloat()) { |
333 | if (event->isMultiDay()) { | 333 | if (event->isMultiDay()) { |
334 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 334 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
335 | .arg(event->dtStartDateStr(shortDate)) | 335 | .arg(event->dtStartDateStr(shortDate)) |
336 | .arg(event->dtEndDateStr(shortDate))); | 336 | .arg(event->dtEndDateStr(shortDate))); |
337 | mText.append(i18n("<p><b>Duration:</b> %1 days</p>") | 337 | mText.append(i18n("<p><b>Duration:</b> %1 days</p>") |
338 | .arg(event->dtStart().daysTo(event->dtEnd())+1)); | 338 | .arg(event->dtStart().daysTo(event->dtEnd())+1)); |
339 | } else { | 339 | } else { |
340 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 340 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
341 | } | 341 | } |
342 | } else { | 342 | } else { |
343 | if (event->isMultiDay()) { | 343 | if (event->isMultiDay()) { |
344 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 344 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
345 | .arg(event->dtStartStr( shortDate))); | 345 | .arg(event->dtStartStr( shortDate))); |
346 | mText.append(i18n("<p><b>To:</b> %1</p>") | 346 | mText.append(i18n("<p><b>To:</b> %1</p>") |
347 | .arg(event->dtEndStr(shortDate))); | 347 | .arg(event->dtEndStr(shortDate))); |
348 | } else { | 348 | } else { |
349 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 349 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
350 | .arg(event->dtStartTimeStr()) | 350 | .arg(event->dtStartTimeStr()) |
351 | .arg(event->dtEndTimeStr())); | 351 | .arg(event->dtEndTimeStr())); |
352 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 352 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
353 | .arg(event->dtStartDateStr( shortDate ))); | 353 | .arg(event->dtStartDateStr( shortDate ))); |
354 | } | 354 | } |
355 | } | 355 | } |
356 | if (!event->location().isEmpty()) { | 356 | if (!event->location().isEmpty()) { |
357 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); | 357 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); |
358 | mMailSubject += i18n(" at ") + event->location(); | 358 | mMailSubject += i18n(" at ") + event->location(); |
359 | } | 359 | } |
360 | if (event->doesRecur()) { | 360 | if (event->doesRecur()) { |
361 | 361 | ||
362 | QString recurText = event->recurrenceText(); | 362 | QString recurText = event->recurrenceText(); |
363 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 363 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
364 | bool ok; | 364 | bool ok; |
365 | QDate start = QDate::currentDate(); | 365 | QDate start = QDate::currentDate(); |
366 | QDateTime next; | 366 | QDateTime next; |
367 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 367 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
368 | if ( ok ) { | 368 | if ( ok ) { |
369 | if ( wideScreen ){ | 369 | if ( wideScreen ){ |
370 | addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) ); | 370 | addTag("p",i18n("<b>Next recurrence is on:</b>") +" " + KGlobal::locale()->formatDate( next.date(), shortDate ) ); |
371 | } else { | 371 | } else { |
372 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 372 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
373 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 373 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
374 | } | 374 | } |
375 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); | 375 | mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( next, true ); |
376 | 376 | ||
377 | } else { | 377 | } else { |
378 | bool last; | 378 | bool last; |
379 | QDate nextd; | 379 | QDate nextd; |
380 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 380 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
381 | if ( last ) { | 381 | if ( last ) { |
382 | if ( wideScreen ){ | 382 | if ( wideScreen ){ |
383 | addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate )); | 383 | addTag("p",i18n("<b>Last recurrence was on:</b>") +" " + KGlobal::locale()->formatDate( nextd, shortDate )); |
384 | } else{ | 384 | } else{ |
385 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 385 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
386 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 386 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | } | 389 | } |
390 | } else { | 390 | } else { |
391 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); | 391 | mMailSubject += i18n(" - " )+event->dtStartStr( true ); |
392 | 392 | ||
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | if (event->isAlarmEnabled()) { | 396 | if (event->isAlarmEnabled()) { |
397 | Alarm *alarm =event->alarms().first() ; | 397 | Alarm *alarm =event->alarms().first() ; |
398 | QDateTime t = alarm->time(); | 398 | QDateTime t = alarm->time(); |
399 | |||
400 | if (event->doesRecur()) { | ||
401 | bool ok = false; | ||
402 | int offset = 0; | ||
403 | QDateTime next = event->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | ||
404 | if ( ok ) { | ||
405 | t = next; | ||
406 | } | ||
407 | } | ||
408 | |||
399 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 409 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
400 | if(wideScreen ){ | 410 | if(wideScreen ){ |
401 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); | 411 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); |
402 | }else{ | 412 | }else{ |
403 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 413 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
404 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 414 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
405 | } | 415 | } |
406 | //addTag("p",s); | 416 | //addTag("p",s); |
407 | if ( !(event->alarmEnabled() ) ) { | 417 | if ( !(event->alarmEnabled() ) ) { |
408 | addTag("p", "<em>("+i18n("Enable alarm in resource settings") + ")</em>"); | 418 | addTag("p", "<em>("+i18n("Enable alarm in resource settings") + ")</em>"); |
409 | 419 | ||
410 | } | 420 | } |
411 | } | 421 | } |
412 | 422 | ||
413 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); | 423 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); |
414 | 424 | ||
415 | formatCategories(event); | 425 | formatCategories(event); |
416 | 426 | ||
417 | formatAttendees(event); | 427 | formatAttendees(event); |
418 | 428 | ||
419 | if ( KOPrefs::instance()->mEVshowCreated ) { | 429 | if ( KOPrefs::instance()->mEVshowCreated ) { |
420 | if(wideScreen ){ | 430 | if(wideScreen ){ |
421 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 431 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
422 | }else{ | 432 | }else{ |
423 | addTag("p",i18n("<b>Created: ") +" </b>"); | 433 | addTag("p",i18n("<b>Created: ") +" </b>"); |
424 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 434 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
425 | } | 435 | } |
426 | 436 | ||
427 | 437 | ||
428 | } | 438 | } |
429 | if ( KOPrefs::instance()->mEVshowChanged ) { | 439 | if ( KOPrefs::instance()->mEVshowChanged ) { |
430 | if(wideScreen ){ | 440 | if(wideScreen ){ |
431 | addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); | 441 | addTag("p",i18n("<b>Last modified: ") +" </b>" + KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); |
432 | }else{ | 442 | }else{ |
433 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 443 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
434 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 444 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
435 | } | 445 | } |
436 | 446 | ||
437 | } | 447 | } |
438 | if ( KOPrefs::instance()->mEVshowDetails ) { | 448 | if ( KOPrefs::instance()->mEVshowDetails ) { |
439 | if (!event->description().isEmpty()) { | 449 | if (!event->description().isEmpty()) { |
440 | addTag("p",i18n("<b>Details: </b>")); | 450 | addTag("p",i18n("<b>Details: </b>")); |
441 | addTag("p",deTag(event->description())); | 451 | addTag("p",deTag(event->description())); |
442 | } | 452 | } |
443 | } | 453 | } |
444 | setText(mText); | 454 | setText(mText); |
445 | //QWhatsThis::add(this,mText); | 455 | //QWhatsThis::add(this,mText); |
446 | 456 | ||
447 | } | 457 | } |
448 | 458 | ||
449 | void KOEventViewer::appendTodo(Todo *event, int mode ) | 459 | void KOEventViewer::appendTodo(Todo *event, int mode ) |
450 | { | 460 | { |
451 | mMailSubject = ""; | 461 | mMailSubject = ""; |
452 | mCurrentIncidence = event; | 462 | mCurrentIncidence = event; |
453 | topLevelWidget()->setCaption(i18n("Todo Viewer")); | 463 | topLevelWidget()->setCaption(i18n("Todo Viewer")); |
454 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 464 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
455 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); | 465 | bool wideScreen = ( QApplication::desktop()->width() >= 640 ); |
456 | if (mode == 0 ) { | 466 | if (mode == 0 ) { |
457 | addTag("h2",deTag(event->summary())); | 467 | addTag("h2",deTag(event->summary())); |
458 | formatReadOnly(event); | 468 | formatReadOnly(event); |
459 | } | 469 | } |
460 | else { | 470 | else { |
461 | if ( mColorMode == 1 ) { | 471 | if ( mColorMode == 1 ) { |
462 | mText +="<font color=\"#00A000\">"; | 472 | mText +="<font color=\"#00A000\">"; |
463 | } | 473 | } |
464 | if ( mColorMode == 2 ) { | 474 | if ( mColorMode == 2 ) { |
465 | mText +="<font color=\"#B00000\">"; | 475 | mText +="<font color=\"#B00000\">"; |
466 | } | 476 | } |
467 | if ( mode == 1 ) { | 477 | if ( mode == 1 ) { |
468 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 478 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
469 | } else { | 479 | } else { |
470 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 480 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
471 | } | 481 | } |
472 | formatReadOnly(event); | 482 | formatReadOnly(event); |
473 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 483 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
474 | if ( mColorMode ) | 484 | if ( mColorMode ) |
475 | mText += "</font>"; | 485 | mText += "</font>"; |
476 | } | 486 | } |
477 | mMailSubject += i18n( "Todo " )+ event->summary(); | 487 | mMailSubject += i18n( "Todo " )+ event->summary(); |
478 | 488 | ||
479 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 489 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
480 | mText +="<font color=\"#B00000\">"; | 490 | mText +="<font color=\"#B00000\">"; |
481 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); | 491 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(KOPrefs::instance()->mShortDateInViewer) ) ); |
482 | mText += "</font>"; | 492 | mText += "</font>"; |
483 | } else { | 493 | } else { |
484 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 494 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
485 | .arg(event->percentComplete())); | 495 | .arg(event->percentComplete())); |
486 | } | 496 | } |
487 | 497 | ||
488 | if (event->cancelled ()) { | 498 | if (event->cancelled ()) { |
489 | mText +="<font color=\"#B00000\">"; | 499 | mText +="<font color=\"#B00000\">"; |
490 | addTag("i",i18n("This todo has been cancelled!")); | 500 | addTag("i",i18n("This todo has been cancelled!")); |
491 | mText.append("<br>"); | 501 | mText.append("<br>"); |
492 | mText += "</font>"; | 502 | mText += "</font>"; |
493 | mMailSubject += i18n("(cancelled)"); | 503 | mMailSubject += i18n("(cancelled)"); |
494 | } | 504 | } |
495 | 505 | ||
496 | 506 | ||
497 | 507 | ||
498 | if (event->doesRecur()) { | 508 | if (event->doesRecur()) { |
499 | 509 | ||
500 | QString recurText = event->recurrence()->recurrenceText(); | 510 | QString recurText = event->recurrence()->recurrenceText(); |
501 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 511 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
502 | 512 | ||
503 | } | 513 | } |
504 | if (event->hasStartDate()) { | 514 | if (event->hasStartDate()) { |
505 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); | 515 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(KOPrefs::instance()->mShortDateInViewer))); |
506 | } | 516 | } |
507 | if (event->hasDueDate()) { | 517 | if (event->hasDueDate()) { |
508 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); | 518 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); |
509 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); | 519 | mMailSubject += i18n(" - " )+event->dtDueStr( true ); |
510 | } | 520 | } |
511 | if (!event->location().isEmpty()) { | 521 | if (!event->location().isEmpty()) { |
512 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); | 522 | addTag("p","<b>"+i18n("Location: ")+"</b>"+ deTag(event->location() ) ); |
513 | mMailSubject += i18n(" at ") + event->location(); | 523 | mMailSubject += i18n(" at ") + event->location(); |
514 | } | 524 | } |
515 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 525 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
516 | .arg(QString::number(event->priority()))); | 526 | .arg(QString::number(event->priority()))); |
517 | 527 | ||
518 | if (event->isAlarmEnabled()) { | 528 | if (event->isAlarmEnabled()) { |
519 | Alarm *alarm =event->alarms().first() ; | 529 | Alarm *alarm =event->alarms().first() ; |
520 | QDateTime t = alarm->time(); | 530 | QDateTime t = alarm->time(); |
521 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 531 | if (event->doesRecur()) { |
532 | bool ok = false; | ||
533 | int offset = 0; | ||
534 | QDateTime next = event->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | ||
535 | if ( ok ) { | ||
536 | t = next; | ||
537 | } | ||
538 | } | ||
539 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | ||
522 | if ( wideScreen ) { | 540 | if ( wideScreen ) { |
523 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); | 541 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"+ KGlobal::locale()->formatDateTime( t, shortDate )); |
524 | } else { | 542 | } else { |
525 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 543 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
526 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 544 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
527 | } | 545 | } |
528 | if ( !(event->alarmEnabled() ) ) { | 546 | if ( !(event->alarmEnabled() ) ) { |
529 | addTag("p", "<em>("+i18n("Enable alarm in resource settings") + ")</em>"); | 547 | addTag("p", "<em>("+i18n("Enable alarm in resource settings") + ")</em>"); |
530 | 548 | ||
531 | } | 549 | } |
532 | } | 550 | } |
533 | 551 | ||
534 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); | 552 | addTag("p","<b>"+i18n("Access: ") + "</b>" + event->secrecyStr()); |
535 | 553 | ||
536 | formatCategories(event); | 554 | formatCategories(event); |
537 | 555 | ||
538 | formatAttendees(event); | 556 | formatAttendees(event); |
539 | 557 | ||
540 | if ( KOPrefs::instance()->mEVshowCreated ) { | 558 | if ( KOPrefs::instance()->mEVshowCreated ) { |
541 | if(wideScreen ){ | 559 | if(wideScreen ){ |
542 | 560 | ||
543 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 561 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
544 | 562 | ||
545 | } else { | 563 | } else { |
546 | addTag("p",i18n("<b>Created: ") +" </b>"); | 564 | addTag("p",i18n("<b>Created: ") +" </b>"); |
547 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 565 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
548 | } | 566 | } |
549 | } | 567 | } |
550 | if ( KOPrefs::instance()->mEVshowChanged ) { | 568 | if ( KOPrefs::instance()->mEVshowChanged ) { |
551 | if(wideScreen ){ | 569 | if(wideScreen ){ |
552 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); | 570 | addTag("p",i18n("<b>Last modified: ") +" </b>" +KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ) ); |
553 | 571 | ||
554 | } else { | 572 | } else { |
555 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 573 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
556 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 574 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
557 | } | 575 | } |
558 | } | 576 | } |
559 | if ( event->relatedTo() ) { | 577 | if ( event->relatedTo() ) { |
560 | addTag("b",i18n("Parent todo:<br>")); | 578 | addTag("b",i18n("Parent todo:<br>")); |
561 | 579 | ||
562 | QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); | 580 | QString t_name = "[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] ";// +event->relatedTo()->summary()); |
563 | 581 | ||
564 | mText += t_name; | 582 | mText += t_name; |
565 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; | 583 | mText += "<a href=\"todo_uid:" + event->relatedTo()->uid() + "\">"; |
566 | mText += deTag(event->relatedTo()->summary()); | 584 | mText += deTag(event->relatedTo()->summary()); |
567 | mText += "</a><br>"; | 585 | mText += "</a><br>"; |
568 | 586 | ||
569 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); | 587 | // mText.append(deTag("[" +QString::number(event->relatedTo()->priority()) + "/" + QString::number(((Todo*)event->relatedTo())->percentComplete())+"%] " +event->relatedTo()->summary()) +"<br>"); |
570 | } | 588 | } |
571 | QPtrList<Incidence> Relations = event->relations(); | 589 | QPtrList<Incidence> Relations = event->relations(); |
572 | Incidence *to; | 590 | Incidence *to; |
573 | if ( Relations.first() ) | 591 | if ( Relations.first() ) |
574 | addTag("b",i18n("Sub todos:<br>")); | 592 | addTag("b",i18n("Sub todos:<br>")); |
575 | for (to=Relations.first();to;to=Relations.next()) { | 593 | for (to=Relations.first();to;to=Relations.next()) { |
576 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); | 594 | QString t_name = "[" +QString::number(((Todo*)to)->priority()) + "/" + QString::number(((Todo*)to)->percentComplete())+"%] ";// +to->relatedTo()->summary()); |
577 | mText += t_name; | 595 | mText += t_name; |
578 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; | 596 | mText += "<a href=\"todo_uid:" + to->uid() + "\">"; |
579 | mText += deTag(to->summary()); | 597 | mText += deTag(to->summary()); |
580 | mText += "</a><br>"; | 598 | mText += "</a><br>"; |
581 | 599 | ||
582 | } | 600 | } |
583 | 601 | ||
584 | if ( KOPrefs::instance()->mEVshowDetails ) { | 602 | if ( KOPrefs::instance()->mEVshowDetails ) { |
585 | if (!event->description().isEmpty()) { | 603 | if (!event->description().isEmpty()) { |
586 | addTag("p",i18n("<b>Details: </b>")); | 604 | addTag("p",i18n("<b>Details: </b>")); |
587 | addTag("p",deTag(event->description())); | 605 | addTag("p",deTag(event->description())); |
588 | } | 606 | } |
589 | } | 607 | } |
590 | setText(mText); | 608 | setText(mText); |
591 | } | 609 | } |
592 | 610 | ||
593 | void KOEventViewer::formatCategories(Incidence *event) | 611 | void KOEventViewer::formatCategories(Incidence *event) |
594 | { | 612 | { |
595 | if (!event->categoriesStr().isEmpty()) { | 613 | if (!event->categoriesStr().isEmpty()) { |
596 | if (event->categories().count() == 1) { | 614 | if (event->categories().count() == 1) { |
597 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); | 615 | addTag("p","<b>"+i18n("Category") + ":</b> " + event->categoriesStrWithSpace()); |
598 | } else { | 616 | } else { |
599 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; | 617 | addTag("p","<b>"+i18n("Categories")+":</b> " + event->categoriesStrWithSpace() ) ; |
600 | } | 618 | } |
601 | } | 619 | } |
602 | } | 620 | } |
603 | void KOEventViewer::formatAttendees(Incidence *event) | 621 | void KOEventViewer::formatAttendees(Incidence *event) |
604 | { | 622 | { |
605 | QPtrList<Attendee> attendees = event->attendees(); | 623 | QPtrList<Attendee> attendees = event->attendees(); |
606 | if (attendees.count()) { | 624 | if (attendees.count()) { |
607 | 625 | ||
608 | 626 | ||
609 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 627 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
610 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 628 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
611 | addTag("h3",i18n("Organizer")); | 629 | addTag("h3",i18n("Organizer")); |
612 | mText.append("<ul><li>"); | 630 | mText.append("<ul><li>"); |
613 | #ifndef KORG_NOKABC | 631 | #ifndef KORG_NOKABC |
614 | 632 | ||
615 | #ifdef DESKTOP_VERSION | 633 | #ifdef DESKTOP_VERSION |
616 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 634 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
617 | KABC::Addressee::List addressList; | 635 | KABC::Addressee::List addressList; |
618 | addressList = add_book->findByEmail(event->organizer()); | 636 | addressList = add_book->findByEmail(event->organizer()); |
619 | KABC::Addressee o = addressList.first(); | 637 | KABC::Addressee o = addressList.first(); |
620 | if (!o.isEmpty() && addressList.size()<2) { | 638 | if (!o.isEmpty() && addressList.size()<2) { |
621 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 639 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
622 | mText += o.formattedName(); | 640 | mText += o.formattedName(); |
623 | mText += "</a>\n"; | 641 | mText += "</a>\n"; |
624 | } else { | 642 | } else { |
625 | mText.append(event->organizer()); | 643 | mText.append(event->organizer()); |
626 | } | 644 | } |
627 | #else //DESKTOP_VERSION | 645 | #else //DESKTOP_VERSION |
628 | mText += "<a href=\"uid:organizer\">"; | 646 | mText += "<a href=\"uid:organizer\">"; |
629 | mText += event->organizer(); | 647 | mText += event->organizer(); |
630 | mText += "</a>\n"; | 648 | mText += "</a>\n"; |
631 | #endif //DESKTOP_VERSION | 649 | #endif //DESKTOP_VERSION |
632 | 650 | ||
633 | 651 | ||
634 | #else | 652 | #else |
635 | mText.append(event->organizer()); | 653 | mText.append(event->organizer()); |
636 | #endif | 654 | #endif |
637 | 655 | ||
638 | if (iconPath) { | 656 | if (iconPath) { |
639 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 657 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
640 | mText += "<IMG src=\"" + iconPath + "\">"; | 658 | mText += "<IMG src=\"" + iconPath + "\">"; |
641 | mText += "</a>\n"; | 659 | mText += "</a>\n"; |
642 | } | 660 | } |
643 | mText.append("</li></ul>"); | 661 | mText.append("</li></ul>"); |
644 | 662 | ||
645 | addTag("h3",i18n("Attendees")); | 663 | addTag("h3",i18n("Attendees")); |
646 | Attendee *a; | 664 | Attendee *a; |
647 | mText.append("<ul>"); | 665 | mText.append("<ul>"); |
648 | int a_count = 0; | 666 | int a_count = 0; |
649 | int a_count_nr = 0; | 667 | int a_count_nr = 0; |
650 | 668 | ||
651 | for(a=attendees.first();a;a=attendees.next()) { | 669 | for(a=attendees.first();a;a=attendees.next()) { |
652 | #ifndef KORG_NOKABC | 670 | #ifndef KORG_NOKABC |
653 | #ifdef DESKTOP_VERSION | 671 | #ifdef DESKTOP_VERSION |
654 | if (a->name().isEmpty()) { | 672 | if (a->name().isEmpty()) { |
655 | addressList = add_book->findByEmail(a->email()); | 673 | addressList = add_book->findByEmail(a->email()); |
656 | KABC::Addressee o = addressList.first(); | 674 | KABC::Addressee o = addressList.first(); |
657 | if (!o.isEmpty() && addressList.size()<2) { | 675 | if (!o.isEmpty() && addressList.size()<2) { |
658 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 676 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
659 | mText += o.formattedName(); | 677 | mText += o.formattedName(); |
660 | mText += "</a>\n"; | 678 | mText += "</a>\n"; |
661 | } else { | 679 | } else { |
662 | mText += "<li>"; | 680 | mText += "<li>"; |
663 | mText.append(a->email()); | 681 | mText.append(a->email()); |
664 | mText += "\n"; | 682 | mText += "\n"; |
665 | } | 683 | } |
666 | } else { | 684 | } else { |
667 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 685 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
668 | if (!a->name().isEmpty()) mText += a->name(); | 686 | if (!a->name().isEmpty()) mText += a->name(); |
669 | else mText += a->email(); | 687 | else mText += a->email(); |
670 | mText += "</a>\n"; | 688 | mText += "</a>\n"; |
671 | } | 689 | } |
672 | #else //DESKTOP_VERSION | 690 | #else //DESKTOP_VERSION |
673 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 691 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
674 | if (!a->name().isEmpty()) mText += a->name(); | 692 | if (!a->name().isEmpty()) mText += a->name(); |
675 | else mText += a->email(); | 693 | else mText += a->email(); |
676 | mText += "</a>\n"; | 694 | mText += "</a>\n"; |
677 | #endif //DESKTOP_VERSION | 695 | #endif //DESKTOP_VERSION |
678 | #else | 696 | #else |
679 | //qDebug("nokabc "); | 697 | //qDebug("nokabc "); |
680 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 698 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
681 | if (!a->name().isEmpty()) mText += a->name(); | 699 | if (!a->name().isEmpty()) mText += a->name(); |
682 | else mText += a->email(); | 700 | else mText += a->email(); |
683 | mText += "</a>\n"; | 701 | mText += "</a>\n"; |
684 | #endif | 702 | #endif |
685 | 703 | ||
686 | 704 | ||
687 | if (!a->email().isEmpty()) { | 705 | if (!a->email().isEmpty()) { |
688 | if (iconPath) { | 706 | if (iconPath) { |
689 | mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">"; | 707 | mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">"; |
690 | if ( a->RSVP() ) { | 708 | if ( a->RSVP() ) { |
691 | ++a_count_nr; | 709 | ++a_count_nr; |
692 | mText += "<IMG src=\"" + iconPath + "\">"; | 710 | mText += "<IMG src=\"" + iconPath + "\">"; |
693 | } | 711 | } |
694 | else { | 712 | else { |
695 | ++a_count; | 713 | ++a_count; |
696 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 714 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
697 | } | 715 | } |
698 | mText += "</a>\n"; | 716 | mText += "</a>\n"; |
699 | } | 717 | } |
700 | } | 718 | } |
701 | if (a->status() != Attendee::NeedsAction ) | 719 | if (a->status() != Attendee::NeedsAction ) |
702 | mText +="[" + a->statusStr() + "] "; | 720 | mText +="[" + a->statusStr() + "] "; |
703 | if (a->role() == Attendee::Chair ) | 721 | if (a->role() == Attendee::Chair ) |
704 | mText +="(" + a->roleStr().left(1) + ".)"; | 722 | mText +="(" + a->roleStr().left(1) + ".)"; |
705 | } | 723 | } |
706 | mText.append("</li></ul>"); | 724 | mText.append("</li></ul>"); |
707 | if ( (a_count+a_count_nr) > 1 ) { | 725 | if ( (a_count+a_count_nr) > 1 ) { |
708 | mText += "<a href=\"mailto:ALL\">"; | 726 | mText += "<a href=\"mailto:ALL\">"; |
709 | mText += i18n( "Mail to all" ); | 727 | mText += i18n( "Mail to all" ); |
710 | mText += "</a> ( "; | 728 | mText += "</a> ( "; |
711 | mText += "<IMG src=\"" + iconPath + "\">"; | 729 | mText += "<IMG src=\"" + iconPath + "\">"; |
712 | mText += i18n( " and " ); | 730 | mText += i18n( " and " ); |
713 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; | 731 | mText += "<IMG src=\"" + NOiconPath + "\"> )"; |
714 | mText += "<br>\n"; | 732 | mText += "<br>\n"; |
715 | 733 | ||
716 | 734 | ||
717 | } | 735 | } |
718 | if ( a_count_nr > 1 ) { | 736 | if ( a_count_nr > 1 ) { |
719 | mText += "<a href=\"mailto:RSVP\">"; | 737 | mText += "<a href=\"mailto:RSVP\">"; |
720 | mText += i18n( "Mail to selected" ); | 738 | mText += i18n( "Mail to selected" ); |
721 | mText += "</a> ( "; | 739 | mText += "</a> ( "; |
722 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); | 740 | mText += i18n( "<IMG src=\"%1\"> only )").arg ( iconPath ); |
723 | mText += "<br>\n"; | 741 | mText += "<br>\n"; |
724 | } | 742 | } |
725 | } | 743 | } |
726 | 744 | ||
727 | } | 745 | } |
728 | void KOEventViewer::appendJournal(Journal *jour, int mode ) | 746 | void KOEventViewer::appendJournal(Journal *jour, int mode ) |
729 | { | 747 | { |
730 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; | 748 | bool shortDate = KOPrefs::instance()->mShortDateInViewer; |
731 | QString text_d = i18n("Journal from: "); | 749 | QString text_d = i18n("Journal from: "); |
732 | if ( !jour->summary().isEmpty() ) | 750 | if ( !jour->summary().isEmpty() ) |
733 | text_d = jour->summary(); | 751 | text_d = jour->summary(); |
734 | if (mode == 0 ) { | 752 | if (mode == 0 ) { |
735 | addTag("h2", text_d ); | 753 | addTag("h2", text_d ); |
736 | } | 754 | } |
737 | else { | 755 | else { |
738 | if ( mode == 1 ) { | 756 | if ( mode == 1 ) { |
739 | addTag("h3",i18n( "Local: " ) + text_d ); | 757 | addTag("h3",i18n( "Local: " ) + text_d ); |
740 | } else { | 758 | } else { |
741 | addTag("h3",i18n( "Remote: " ) + text_d ); | 759 | addTag("h3",i18n( "Remote: " ) + text_d ); |
742 | } | 760 | } |
743 | } | 761 | } |
744 | topLevelWidget()->setCaption(i18n("Journal viewer")); | 762 | topLevelWidget()->setCaption(i18n("Journal viewer")); |
745 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); | 763 | mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); |
746 | formatReadOnly(jour); | 764 | formatReadOnly(jour); |
747 | addTag("p","<b>"+i18n( "Last modified: " ) + "</b>"+KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); | 765 | addTag("p","<b>"+i18n( "Last modified: " ) + "</b>"+KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); |
748 | 766 | ||
749 | if (!jour->description().isEmpty()) { | 767 | if (!jour->description().isEmpty()) { |
750 | addTag("p",deTag(jour->description())); | 768 | addTag("p",deTag(jour->description())); |
751 | } | 769 | } |
752 | setText(mText); | 770 | setText(mText); |
753 | } | 771 | } |
754 | 772 | ||
755 | void KOEventViewer::formatReadOnly(Incidence *event) | 773 | void KOEventViewer::formatReadOnly(Incidence *event) |
756 | { | 774 | { |
757 | int id = event->calID(); | 775 | int id = event->calID(); |
758 | if ( id > 1 ) { | 776 | if ( id > 1 ) { |
759 | addTag("p", "<em>("+i18n("Calendar:")+" " + KOPrefs::instance()->getCalendar( id )->mName + ")</em>"); | 777 | addTag("p", "<em>("+i18n("Calendar:")+" " + KOPrefs::instance()->getCalendar( id )->mName + ")</em>"); |
760 | } | 778 | } |
761 | if (event->isReadOnly()) { | 779 | if (event->isReadOnly()) { |
762 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 780 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
763 | } | 781 | } |
764 | } | 782 | } |
765 | void KOEventViewer::setSyncMode( bool b ) | 783 | void KOEventViewer::setSyncMode( bool b ) |
766 | { | 784 | { |
767 | mSyncMode = b; | 785 | mSyncMode = b; |
768 | } | 786 | } |
769 | 787 | ||
770 | void KOEventViewer::setTodo(Todo *event, bool clearV ) | 788 | void KOEventViewer::setTodo(Todo *event, bool clearV ) |
771 | { | 789 | { |
772 | if ( clearV ) | 790 | if ( clearV ) |
773 | clearEvents(); | 791 | clearEvents(); |
774 | if ( mSyncMode ) { | 792 | if ( mSyncMode ) { |
775 | if ( clearV ) | 793 | if ( clearV ) |
776 | appendTodo(event,1 ); | 794 | appendTodo(event,1 ); |
777 | else | 795 | else |
778 | appendTodo(event,2); | 796 | appendTodo(event,2); |
779 | } else | 797 | } else |
780 | appendTodo(event); | 798 | appendTodo(event); |
781 | } | 799 | } |
782 | void KOEventViewer::setJournal(Journal *event, bool clearV ) | 800 | void KOEventViewer::setJournal(Journal *event, bool clearV ) |
783 | { | 801 | { |
784 | if ( clearV ) | 802 | if ( clearV ) |
785 | clearEvents(); | 803 | clearEvents(); |
786 | if ( mSyncMode ) { | 804 | if ( mSyncMode ) { |
787 | if ( clearV ) | 805 | if ( clearV ) |
788 | appendJournal(event, 1); | 806 | appendJournal(event, 1); |
789 | else | 807 | else |
790 | appendJournal(event, 2); | 808 | appendJournal(event, 2); |
791 | } else | 809 | } else |
792 | appendJournal(event); | 810 | appendJournal(event); |
793 | } | 811 | } |
794 | 812 | ||
795 | void KOEventViewer::setEvent(Event *event) | 813 | void KOEventViewer::setEvent(Event *event) |
796 | { | 814 | { |
797 | clearEvents(); | 815 | clearEvents(); |
798 | if ( mSyncMode ) | 816 | if ( mSyncMode ) |
799 | appendEvent(event, 1); | 817 | appendEvent(event, 1); |
800 | else | 818 | else |
801 | appendEvent(event); | 819 | appendEvent(event); |
802 | } | 820 | } |
803 | 821 | ||
804 | void KOEventViewer::addEvent(Event *event) | 822 | void KOEventViewer::addEvent(Event *event) |
805 | { | 823 | { |
806 | if ( mSyncMode ) | 824 | if ( mSyncMode ) |
807 | appendEvent(event, 2); | 825 | appendEvent(event, 2); |
808 | else | 826 | else |
809 | appendEvent(event); | 827 | appendEvent(event); |
810 | } | 828 | } |
811 | 829 | ||
812 | void KOEventViewer::clearEvents(bool now) | 830 | void KOEventViewer::clearEvents(bool now) |
813 | { | 831 | { |
814 | mText = ""; | 832 | mText = ""; |
815 | if (now) setText(mText); | 833 | if (now) setText(mText); |
816 | } | 834 | } |
817 | 835 | ||
818 | void KOEventViewer::addText(QString text) | 836 | void KOEventViewer::addText(QString text) |
819 | { | 837 | { |
820 | mText.append(text); | 838 | mText.append(text); |
821 | setText(mText); | 839 | setText(mText); |
822 | } | 840 | } |
823 | QString KOEventViewer::deTag(QString text) | 841 | QString KOEventViewer::deTag(QString text) |
824 | { | 842 | { |
825 | #if QT_VERSION >= 0x030000 | 843 | #if QT_VERSION >= 0x030000 |
826 | text.replace( '<' , "<" ); | 844 | text.replace( '<' , "<" ); |
827 | text.replace( '>' , ">" ); | 845 | text.replace( '>' , ">" ); |
828 | #else | 846 | #else |
829 | if ( text.find ('<') >= 0 ) { | 847 | if ( text.find ('<') >= 0 ) { |
830 | text.replace( QRegExp("<") , "<" ); | 848 | text.replace( QRegExp("<") , "<" ); |
831 | } | 849 | } |
832 | if ( text.find ('>') >= 0 ) { | 850 | if ( text.find ('>') >= 0 ) { |
833 | text.replace( QRegExp(">") , ">" ); | 851 | text.replace( QRegExp(">") , ">" ); |
834 | } | 852 | } |
835 | #endif | 853 | #endif |
836 | return text; | 854 | return text; |
837 | } | 855 | } |
838 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) | 856 | void KOEventViewer::keyPressEvent ( QKeyEvent * e ) |
839 | { | 857 | { |
840 | switch ( e->key() ) { | 858 | switch ( e->key() ) { |
841 | case Qt::Key_Return: | 859 | case Qt::Key_Return: |
842 | case Qt::Key_Enter : | 860 | case Qt::Key_Enter : |
843 | e->ignore(); | 861 | e->ignore(); |
844 | break; | 862 | break; |
845 | default: | 863 | default: |
846 | QTextBrowser::keyPressEvent ( e ); | 864 | QTextBrowser::keyPressEvent ( e ); |
847 | break; | 865 | break; |
848 | } | 866 | } |
849 | } | 867 | } |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 4dfe16a..733b897 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,427 +1,443 @@ | |||
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 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 11 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 12 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) | 13 | QString 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 | ||
31 | KIncidenceFormatter* KIncidenceFormatter::instance() | 31 | KIncidenceFormatter* 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 | } |
38 | KIncidenceFormatter::~KIncidenceFormatter() | 38 | KIncidenceFormatter::~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 | } |
44 | KIncidenceFormatter::KIncidenceFormatter() | 44 | KIncidenceFormatter::KIncidenceFormatter() |
45 | { | 45 | { |
46 | mColorMode = 0; | 46 | mColorMode = 0; |
47 | } | 47 | } |
48 | void KIncidenceFormatter::setEvent(Event *event) | 48 | void 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 | formatReadOnly(event); |
56 | } | 56 | } |
57 | else { | 57 | else { |
58 | if ( mColorMode == 1 ) { | 58 | if ( mColorMode == 1 ) { |
59 | mText +="<font color=\"#00A000\">"; | 59 | mText +="<font color=\"#00A000\">"; |
60 | } | 60 | } |
61 | if ( mColorMode == 2 ) { | 61 | if ( mColorMode == 2 ) { |
62 | mText +="<font color=\"#C00000\">"; | 62 | mText +="<font color=\"#C00000\">"; |
63 | } | 63 | } |
64 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 64 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
65 | if ( mode == 1 ) { | 65 | if ( mode == 1 ) { |
66 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 66 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
67 | } else { | 67 | } else { |
68 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 68 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
69 | } | 69 | } |
70 | formatReadOnly(event); | 70 | formatReadOnly(event); |
71 | 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 ) ); |
72 | if ( mColorMode ) | 72 | if ( mColorMode ) |
73 | mText += "</font>"; | 73 | mText += "</font>"; |
74 | } | 74 | } |
75 | if (event->cancelled ()) { | 75 | if (event->cancelled ()) { |
76 | mText +="<font color=\"#B00000\">"; | 76 | mText +="<font color=\"#B00000\">"; |
77 | addTag("i",i18n("This event has been cancelled!")); | 77 | addTag("i",i18n("This event has been cancelled!")); |
78 | mText.append("<br>"); | 78 | mText.append("<br>"); |
79 | mText += "</font>"; | 79 | mText += "</font>"; |
80 | } | 80 | } |
81 | if (event->doesFloat()) { | 81 | if (event->doesFloat()) { |
82 | if (event->isMultiDay()) { | 82 | if (event->isMultiDay()) { |
83 | 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>") |
84 | .arg(event->dtStartDateStr(shortDate)) | 84 | .arg(event->dtStartDateStr(shortDate)) |
85 | .arg(event->dtEndDateStr(shortDate))); | 85 | .arg(event->dtEndDateStr(shortDate))); |
86 | mText.append(i18n("<p><b>Duration:</b> %1 days</p>") | 86 | mText.append(i18n("<p><b>Duration:</b> %1 days</p>") |
87 | .arg(event->dtStart().daysTo(event->dtEnd())+1)); | 87 | .arg(event->dtStart().daysTo(event->dtEnd())+1)); |
88 | } else { | 88 | } else { |
89 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 89 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
90 | } | 90 | } |
91 | } else { | 91 | } else { |
92 | if (event->isMultiDay()) { | 92 | if (event->isMultiDay()) { |
93 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 93 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
94 | .arg(event->dtStartStr( shortDate))); | 94 | .arg(event->dtStartStr( shortDate))); |
95 | mText.append(i18n("<p><b>To:</b> %1</p>") | 95 | mText.append(i18n("<p><b>To:</b> %1</p>") |
96 | .arg(event->dtEndStr(shortDate))); | 96 | .arg(event->dtEndStr(shortDate))); |
97 | } else { | 97 | } else { |
98 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 98 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
99 | .arg(event->dtStartTimeStr()) | 99 | .arg(event->dtStartTimeStr()) |
100 | .arg(event->dtEndTimeStr())); | 100 | .arg(event->dtEndTimeStr())); |
101 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 101 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
102 | .arg(event->dtStartDateStr( shortDate ))); | 102 | .arg(event->dtStartDateStr( shortDate ))); |
103 | } | 103 | } |
104 | } | 104 | } |
105 | if (!event->location().isEmpty()) { | 105 | if (!event->location().isEmpty()) { |
106 | addTag("b",i18n("Location: ")); | 106 | addTag("b",i18n("Location: ")); |
107 | mText.append(deTag(event->location())+"<br>"); | 107 | mText.append(deTag(event->location())+"<br>"); |
108 | } | 108 | } |
109 | 109 | ||
110 | if (event->doesRecur()) { | 110 | if (event->doesRecur()) { |
111 | 111 | ||
112 | QString recurText = event->recurrence()->recurrenceText(); | 112 | QString recurText = event->recurrence()->recurrenceText(); |
113 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 113 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
114 | 114 | ||
115 | bool ok; | 115 | bool ok; |
116 | QDate start = QDate::currentDate(); | 116 | QDate start = QDate::currentDate(); |
117 | QDateTime next; | 117 | QDateTime next; |
118 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 118 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
119 | if ( ok ) { | 119 | if ( ok ) { |
120 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 120 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
121 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 121 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
122 | 122 | ||
123 | } else { | 123 | } else { |
124 | bool last; | 124 | bool last; |
125 | QDate nextd; | 125 | QDate nextd; |
126 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 126 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
127 | if ( last ) { | 127 | if ( last ) { |
128 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 128 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
129 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 129 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | if (event->isAlarmEnabled()) { | 135 | if (event->isAlarmEnabled()) { |
136 | Alarm *alarm =event->alarms().first() ; | 136 | Alarm *alarm =event->alarms().first() ; |
137 | QDateTime t = alarm->time(); | 137 | QDateTime t = alarm->time(); |
138 | if (event->doesRecur()) { | ||
139 | bool ok = false; | ||
140 | int offset = 0; | ||
141 | QDateTime next = event->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | ||
142 | if ( ok ) { | ||
143 | t = next; | ||
144 | } | ||
145 | } | ||
138 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 146 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
139 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 147 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
140 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 148 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
141 | //addTag("p",s); | 149 | //addTag("p",s); |
142 | } | 150 | } |
143 | 151 | ||
144 | 152 | ||
145 | 153 | ||
146 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 154 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
147 | // mText.append(event->secrecyStr()+"<br>"); | 155 | // mText.append(event->secrecyStr()+"<br>"); |
148 | formatCategories(event); | 156 | formatCategories(event); |
149 | 157 | ||
150 | formatAttendees(event); | 158 | formatAttendees(event); |
151 | 159 | ||
152 | if ( mCreated ) { | 160 | if ( mCreated ) { |
153 | #ifdef DESKTOP_VERSION | 161 | #ifdef DESKTOP_VERSION |
154 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 162 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
155 | #else | 163 | #else |
156 | addTag("p",i18n("<b>Created: ") +" </b>"); | 164 | addTag("p",i18n("<b>Created: ") +" </b>"); |
157 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 165 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
158 | #endif | 166 | #endif |
159 | 167 | ||
160 | } | 168 | } |
161 | if ( mModified ) { | 169 | if ( mModified ) { |
162 | #ifdef DESKTOP_VERSION | 170 | #ifdef DESKTOP_VERSION |
163 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 171 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
164 | #else | 172 | #else |
165 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 173 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
166 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 174 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
167 | #endif | 175 | #endif |
168 | 176 | ||
169 | } | 177 | } |
170 | if ( mDetails ) { | 178 | if ( mDetails ) { |
171 | if (!event->description().isEmpty()) { | 179 | if (!event->description().isEmpty()) { |
172 | addTag("p",i18n("<b>Details: </b>")); | 180 | addTag("p",i18n("<b>Details: </b>")); |
173 | addTag("p",deTag(event->description())); | 181 | addTag("p",deTag(event->description())); |
174 | } | 182 | } |
175 | } | 183 | } |
176 | 184 | ||
177 | } | 185 | } |
178 | 186 | ||
179 | void KIncidenceFormatter::setTodo(Todo *event ) | 187 | void KIncidenceFormatter::setTodo(Todo *event ) |
180 | { | 188 | { |
181 | int mode = 0; | 189 | int mode = 0; |
182 | mCurrentIncidence = event; | 190 | mCurrentIncidence = event; |
183 | bool shortDate = true; | 191 | bool shortDate = true; |
184 | if (mode == 0 ) { | 192 | if (mode == 0 ) { |
185 | addTag("h3",deTag(event->summary())); | 193 | addTag("h3",deTag(event->summary())); |
186 | formatReadOnly(event); | 194 | formatReadOnly(event); |
187 | } | 195 | } |
188 | else { | 196 | else { |
189 | if ( mColorMode == 1 ) { | 197 | if ( mColorMode == 1 ) { |
190 | mText +="<font color=\"#00A000\">"; | 198 | mText +="<font color=\"#00A000\">"; |
191 | } | 199 | } |
192 | if ( mColorMode == 2 ) { | 200 | if ( mColorMode == 2 ) { |
193 | mText +="<font color=\"#B00000\">"; | 201 | mText +="<font color=\"#B00000\">"; |
194 | } | 202 | } |
195 | if ( mode == 1 ) { | 203 | if ( mode == 1 ) { |
196 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 204 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
197 | } else { | 205 | } else { |
198 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 206 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
199 | } | 207 | } |
200 | formatReadOnly(event); | 208 | formatReadOnly(event); |
201 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 209 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
202 | if ( mColorMode ) | 210 | if ( mColorMode ) |
203 | mText += "</font>"; | 211 | mText += "</font>"; |
204 | } | 212 | } |
205 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 213 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
206 | mText +="<font color=\"#B00000\">"; | 214 | mText +="<font color=\"#B00000\">"; |
207 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | 215 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); |
208 | mText += "</font>"; | 216 | mText += "</font>"; |
209 | } else { | 217 | } else { |
210 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 218 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
211 | .arg(event->percentComplete())); | 219 | .arg(event->percentComplete())); |
212 | } | 220 | } |
213 | if (event->cancelled ()) { | 221 | if (event->cancelled ()) { |
214 | mText +="<font color=\"#B00000\">"; | 222 | mText +="<font color=\"#B00000\">"; |
215 | addTag("i",i18n("This todo has been cancelled!")); | 223 | addTag("i",i18n("This todo has been cancelled!")); |
216 | mText.append("<br>"); | 224 | mText.append("<br>"); |
217 | mText += "</font>"; | 225 | mText += "</font>"; |
218 | } | 226 | } |
219 | 227 | ||
220 | 228 | ||
221 | if (event->doesRecur()) { | 229 | if (event->doesRecur()) { |
222 | 230 | ||
223 | QString recurText = event->recurrence()->recurrenceText(); | 231 | QString recurText = event->recurrence()->recurrenceText(); |
224 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 232 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
225 | } | 233 | } |
226 | 234 | ||
227 | if (event->hasStartDate()) { | 235 | if (event->hasStartDate()) { |
228 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); | 236 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); |
229 | } | 237 | } |
230 | 238 | ||
231 | 239 | ||
232 | if (event->hasDueDate()) { | 240 | if (event->hasDueDate()) { |
233 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 241 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
234 | } | 242 | } |
235 | 243 | ||
236 | if (!event->location().isEmpty()) { | 244 | if (!event->location().isEmpty()) { |
237 | addTag("b",i18n("Location: ")); | 245 | addTag("b",i18n("Location: ")); |
238 | mText.append(deTag(event->location())+"<br>"); | 246 | mText.append(deTag(event->location())+"<br>"); |
239 | } | 247 | } |
240 | 248 | ||
241 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 249 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
242 | .arg(QString::number(event->priority()))); | 250 | .arg(QString::number(event->priority()))); |
243 | 251 | ||
244 | if (event->isAlarmEnabled()) { | 252 | if (event->isAlarmEnabled()) { |
245 | Alarm *alarm =event->alarms().first() ; | 253 | Alarm *alarm =event->alarms().first() ; |
246 | QDateTime t = alarm->time(); | 254 | QDateTime t = alarm->time(); |
255 | if (event->doesRecur()) { | ||
256 | bool ok = false; | ||
257 | int offset = 0; | ||
258 | QDateTime next = event->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; | ||
259 | if ( ok ) { | ||
260 | t = next; | ||
261 | } | ||
262 | } | ||
247 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 263 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
248 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 264 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
249 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 265 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
250 | //addTag("p",s); | 266 | //addTag("p",s); |
251 | } | 267 | } |
252 | 268 | ||
253 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 269 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
254 | formatCategories(event); | 270 | formatCategories(event); |
255 | 271 | ||
256 | formatAttendees(event); | 272 | formatAttendees(event); |
257 | if ( mCreated ) { | 273 | if ( mCreated ) { |
258 | #ifdef DESKTOP_VERSION | 274 | #ifdef DESKTOP_VERSION |
259 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 275 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
260 | #else | 276 | #else |
261 | addTag("p",i18n("<b>Created: ") +" </b>"); | 277 | addTag("p",i18n("<b>Created: ") +" </b>"); |
262 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 278 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
263 | #endif | 279 | #endif |
264 | 280 | ||
265 | } | 281 | } |
266 | if ( mModified ) { | 282 | if ( mModified ) { |
267 | #ifdef DESKTOP_VERSION | 283 | #ifdef DESKTOP_VERSION |
268 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 284 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
269 | #else | 285 | #else |
270 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 286 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
271 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 287 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
272 | #endif | 288 | #endif |
273 | 289 | ||
274 | } | 290 | } |
275 | if ( mDetails ) { | 291 | if ( mDetails ) { |
276 | if (!event->description().isEmpty()) { | 292 | if (!event->description().isEmpty()) { |
277 | addTag("p",i18n("<b>Details: </b>")); | 293 | addTag("p",i18n("<b>Details: </b>")); |
278 | addTag("p",deTag(event->description())); | 294 | addTag("p",deTag(event->description())); |
279 | } | 295 | } |
280 | } | 296 | } |
281 | } | 297 | } |
282 | 298 | ||
283 | void KIncidenceFormatter::setJournal(Journal* ) | 299 | void KIncidenceFormatter::setJournal(Journal* ) |
284 | { | 300 | { |
285 | 301 | ||
286 | } | 302 | } |
287 | 303 | ||
288 | void KIncidenceFormatter::formatCategories(Incidence *event) | 304 | void KIncidenceFormatter::formatCategories(Incidence *event) |
289 | { | 305 | { |
290 | if (!event->categoriesStr().isEmpty()) { | 306 | if (!event->categoriesStr().isEmpty()) { |
291 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); | 307 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); |
292 | //mText.append(event->categoriesStr()); | 308 | //mText.append(event->categoriesStr()); |
293 | } | 309 | } |
294 | } | 310 | } |
295 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 311 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
296 | { | 312 | { |
297 | int number=text.contains("\n"); | 313 | int number=text.contains("\n"); |
298 | QString str = "<" + tag + ">"; | 314 | QString str = "<" + tag + ">"; |
299 | QString tmpText=text; | 315 | QString tmpText=text; |
300 | QString tmpStr=str; | 316 | QString tmpStr=str; |
301 | if(number !=-1) | 317 | if(number !=-1) |
302 | { | 318 | { |
303 | if (number > 0) { | 319 | if (number > 0) { |
304 | int pos=0; | 320 | int pos=0; |
305 | QString tmp; | 321 | QString tmp; |
306 | for(int i=0;i<=number;i++) { | 322 | for(int i=0;i<=number;i++) { |
307 | pos=tmpText.find("\n"); | 323 | pos=tmpText.find("\n"); |
308 | tmp=tmpText.left(pos); | 324 | tmp=tmpText.left(pos); |
309 | tmpText=tmpText.right(tmpText.length()-pos-1); | 325 | tmpText=tmpText.right(tmpText.length()-pos-1); |
310 | tmpStr+=tmp+"<br>"; | 326 | tmpStr+=tmp+"<br>"; |
311 | } | 327 | } |
312 | } | 328 | } |
313 | else tmpStr += tmpText; | 329 | else tmpStr += tmpText; |
314 | tmpStr+="</" + tag + ">"; | 330 | tmpStr+="</" + tag + ">"; |
315 | mText.append(tmpStr); | 331 | mText.append(tmpStr); |
316 | } | 332 | } |
317 | else | 333 | else |
318 | { | 334 | { |
319 | str += text + "</" + tag + ">"; | 335 | str += text + "</" + tag + ">"; |
320 | mText.append(str); | 336 | mText.append(str); |
321 | } | 337 | } |
322 | } | 338 | } |
323 | 339 | ||
324 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 340 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
325 | { | 341 | { |
326 | QPtrList<Attendee> attendees = event->attendees(); | 342 | QPtrList<Attendee> attendees = event->attendees(); |
327 | if (attendees.count()) { | 343 | if (attendees.count()) { |
328 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 344 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
329 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 345 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
330 | addTag("h3",i18n("Organizer")); | 346 | addTag("h3",i18n("Organizer")); |
331 | mText.append("<ul><li>"); | 347 | mText.append("<ul><li>"); |
332 | #if 0 | 348 | #if 0 |
333 | //ndef KORG_NOKABC | 349 | //ndef KORG_NOKABC |
334 | 350 | ||
335 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 351 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
336 | KABC::Addressee::List addressList; | 352 | KABC::Addressee::List addressList; |
337 | addressList = add_book->findByEmail(event->organizer()); | 353 | addressList = add_book->findByEmail(event->organizer()); |
338 | KABC::Addressee o = addressList.first(); | 354 | KABC::Addressee o = addressList.first(); |
339 | if (!o.isEmpty() && addressList.size()<2) { | 355 | if (!o.isEmpty() && addressList.size()<2) { |
340 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 356 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
341 | mText += o.formattedName(); | 357 | mText += o.formattedName(); |
342 | mText += "</a>\n"; | 358 | mText += "</a>\n"; |
343 | } else { | 359 | } else { |
344 | mText.append(event->organizer()); | 360 | mText.append(event->organizer()); |
345 | } | 361 | } |
346 | #else | 362 | #else |
347 | mText.append(event->organizer()); | 363 | mText.append(event->organizer()); |
348 | #endif | 364 | #endif |
349 | if (iconPath) { | 365 | if (iconPath) { |
350 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 366 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
351 | mText += "<IMG src=\"" + iconPath + "\">"; | 367 | mText += "<IMG src=\"" + iconPath + "\">"; |
352 | mText += "</a>\n"; | 368 | mText += "</a>\n"; |
353 | } | 369 | } |
354 | mText.append("</li></ul>"); | 370 | mText.append("</li></ul>"); |
355 | 371 | ||
356 | addTag("h3",i18n("Attendees")); | 372 | addTag("h3",i18n("Attendees")); |
357 | Attendee *a; | 373 | Attendee *a; |
358 | mText.append("<ul>"); | 374 | mText.append("<ul>"); |
359 | for(a=attendees.first();a;a=attendees.next()) { | 375 | for(a=attendees.first();a;a=attendees.next()) { |
360 | #if 0 | 376 | #if 0 |
361 | //ndef KORG_NOKABC | 377 | //ndef KORG_NOKABC |
362 | if (a->name().isEmpty()) { | 378 | if (a->name().isEmpty()) { |
363 | addressList = add_book->findByEmail(a->email()); | 379 | addressList = add_book->findByEmail(a->email()); |
364 | KABC::Addressee o = addressList.first(); | 380 | KABC::Addressee o = addressList.first(); |
365 | if (!o.isEmpty() && addressList.size()<2) { | 381 | if (!o.isEmpty() && addressList.size()<2) { |
366 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 382 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
367 | mText += o.formattedName(); | 383 | mText += o.formattedName(); |
368 | mText += "</a>\n"; | 384 | mText += "</a>\n"; |
369 | } else { | 385 | } else { |
370 | mText += "<li>"; | 386 | mText += "<li>"; |
371 | mText.append(a->email()); | 387 | mText.append(a->email()); |
372 | mText += "\n"; | 388 | mText += "\n"; |
373 | } | 389 | } |
374 | } else { | 390 | } else { |
375 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 391 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
376 | if (!a->name().isEmpty()) mText += a->name(); | 392 | if (!a->name().isEmpty()) mText += a->name(); |
377 | else mText += a->email(); | 393 | else mText += a->email(); |
378 | mText += "</a>\n"; | 394 | mText += "</a>\n"; |
379 | } | 395 | } |
380 | #else | 396 | #else |
381 | //qDebug("nokabc "); | 397 | //qDebug("nokabc "); |
382 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 398 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
383 | if (!a->name().isEmpty()) mText += a->name(); | 399 | if (!a->name().isEmpty()) mText += a->name(); |
384 | else mText += a->email(); | 400 | else mText += a->email(); |
385 | mText += "</a>\n"; | 401 | mText += "</a>\n"; |
386 | #endif | 402 | #endif |
387 | 403 | ||
388 | if (!a->email().isEmpty()) { | 404 | if (!a->email().isEmpty()) { |
389 | if (iconPath) { | 405 | if (iconPath) { |
390 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 406 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
391 | if ( a->RSVP() ) | 407 | if ( a->RSVP() ) |
392 | mText += "<IMG src=\"" + iconPath + "\">"; | 408 | mText += "<IMG src=\"" + iconPath + "\">"; |
393 | else | 409 | else |
394 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 410 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
395 | mText += "</a>\n"; | 411 | mText += "</a>\n"; |
396 | } | 412 | } |
397 | } | 413 | } |
398 | if (a->status() != Attendee::NeedsAction ) | 414 | if (a->status() != Attendee::NeedsAction ) |
399 | mText +="[" + a->statusStr() + "] "; | 415 | mText +="[" + a->statusStr() + "] "; |
400 | if (a->role() == Attendee::Chair ) | 416 | if (a->role() == Attendee::Chair ) |
401 | mText +="(" + a->roleStr().left(1) + ".)"; | 417 | mText +="(" + a->roleStr().left(1) + ".)"; |
402 | } | 418 | } |
403 | mText.append("</li></ul>"); | 419 | mText.append("</li></ul>"); |
404 | } | 420 | } |
405 | } | 421 | } |
406 | 422 | ||
407 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 423 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
408 | { | 424 | { |
409 | if (event->isReadOnly()) { | 425 | if (event->isReadOnly()) { |
410 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 426 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
411 | } | 427 | } |
412 | } | 428 | } |
413 | QString KIncidenceFormatter::deTag(QString text) | 429 | QString KIncidenceFormatter::deTag(QString text) |
414 | { | 430 | { |
415 | #if QT_VERSION >= 0x030000 | 431 | #if QT_VERSION >= 0x030000 |
416 | text.replace( '<' , "<" ); | 432 | text.replace( '<' , "<" ); |
417 | text.replace( '>' , ">" ); | 433 | text.replace( '>' , ">" ); |
418 | #else | 434 | #else |
419 | if ( text.find ('<') >= 0 ) { | 435 | if ( text.find ('<') >= 0 ) { |
420 | text.replace( QRegExp("<") , "<" ); | 436 | text.replace( QRegExp("<") , "<" ); |
421 | } | 437 | } |
422 | if ( text.find ('>') >= 0 ) { | 438 | if ( text.find ('>') >= 0 ) { |
423 | text.replace( QRegExp(">") , ">" ); | 439 | text.replace( QRegExp(">") , ">" ); |
424 | } | 440 | } |
425 | #endif | 441 | #endif |
426 | return text; | 442 | return text; |
427 | } | 443 | } |